Skip to content

feat(agentstudio): PR-01 β€” HTTP client foundation + Factory wiring#219

Draft
cmarguta-alg wants to merge 1 commit into
algolia:mainfrom
cmarguta-alg:feat/agentstudio/pr-01-client-foundation
Draft

feat(agentstudio): PR-01 β€” HTTP client foundation + Factory wiring#219
cmarguta-alg wants to merge 1 commit into
algolia:mainfrom
cmarguta-alg:feat/agentstudio/pr-01-client-foundation

Conversation

@cmarguta-alg
Copy link
Copy Markdown

Summary

  • Introduces package api/agentstudio: NewClient, ResolveHost, structured error mapping (checkResponse / extractDetail / sentinels), and typed client methods for the Agents REST tag (same surface as rag-openapi.json β†’ GET/POST/PATCH/DELETE /1/agents/...).
  • Wires AgentStudioClient func() (*agentstudio.Client, error) on cmdutil.Factory (pkg/cmd/factory), with resolveAgentStudioBaseURL unit tests mirroring runtime precedence: profile/env override β†’ ldflag agentstudio.DefaultBaseURL β†’ cluster-proxy fallback.
  • Profile: `agent_studio_url` + `GetAgentStudioURL()` (env `ALGOLIA_AGENT_STUDIO_URL` wins).
  • Build: `task build` passes `-X github.com/algolia/cli/api/agentstudio.DefaultBaseURL=$ALGOLIA_AGENT_STUDIO_URL`; .env.example documents the var.

Out of scope (follow-up PRs)

  • No `algolia agents` Cobra commands or user docs yet β€” PR-02 per split plan (file may live on contributor fork; link if missing).

Base branch

  • Opened against `main` (algolia/cli has no `development` branch β€” align with team if a different long-lived branch is preferred).

QA / Anya β€” Phase 1 vetting

Automated (required): `go test ./api/agentstudio/... ./pkg/cmd/factory/... -count=1`, `go test ./... -count=1`, `task lint`, `task build`.

Manual / exploratory

  1. M01 β€” Confirm `ResolveHost` / URL precedence behaviour matches unit tests for your staging profile (no new CLI surface; optional HTTP probe with env-based credentials only β€” no keys on argv).
  2. M02 β€” Optional: single `curl` to staging `GET …/1/agents` with Search API key to confirm 401/200 class matches expectations.
  3. M03 β€” Review `client_test.go` error-mapping table for parity with FastAPI envelopes you have seen in `conversational-ai`.

Sign-off: Reply in-thread when automated + chosen manual rows are done.

Test plan

  • `go test ./api/agentstudio/...`
  • `go test ./pkg/cmd/factory/...`
  • `go test ./...`
  • `task lint` (CI)

Made with Cursor

Add api/agentstudio transport (ResolveHost, NewClient, error mapping) and
client methods for the Agents API tag. Wire AgentStudioClient on cmdutil.Factory
with profile/agent_studio_url and ALGOLIA_AGENT_STUDIO_URL precedence; inject
build-time DefaultBaseURL via task build.

User-facing algolia agents commands land in follow-up PRs β€” this slice is
library + factory only.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codacy-production
Copy link
Copy Markdown

Up to standards βœ…

🟒 Issues 0 issues

Results:
0 new issues

View in Codacy

🟒 Metrics 133 complexity · 8 duplication

Metric Results
Complexity 133
Duplication 8

View in Codacy

TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant