package app import ( "context" "strings" ) // Old single-page names use the current contents pipeline and response contract. func (s *Service) pageAlias(ctx context.Context, name string, body []byte) (ResultsResponse, error) { var q struct { URL string `json:"url"` Query string `json:"query"` Instructions string `json:"instructions"` IncludeMarkdown bool `json:"include_markdown"` MaxChars int `json:"max_chars"` } if err := decodeRequest(body, &q); err != nil { return ResultsResponse{}, err } q.Query = strings.TrimSpace(q.Query) if name == "preview" && q.Query == "" { return ResultsResponse{}, failure(400, "INVALID_REQUEST", "preview requires query") } if len(q.Query) > 4000 || len(q.Instructions) > 4000 || q.MaxChars < 0 || q.MaxChars > 10000 { return ResultsResponse{}, failure(400, "INVALID_REQUEST", "query/instructions must be at most 4000 bytes; max_chars must be 0–10000") } if q.Query == "" { q.Query = strings.TrimSpace(q.Instructions) } return s.contents(ctx, ContentsRequest{ URLs: []string{q.URL}, ContentsOptions: ContentsOptions{ Text: Feature{Set: true, Enabled: name == "extract" || q.IncludeMarkdown, MaxCharacters: q.MaxChars}, Summary: Feature{Set: true, Enabled: name != "extract", Query: q.Query}, }, }) }