Skip to content

[AgentProfile][ts-client] AgentProfile types + client + resolve/materialize types + deriveSwitchPlan #3722

Closed

Description

@simonrosenberg

✅ As merged on main — DONE (PR #213 · released in ts-client v1.26.0, npm latest)

  • src/models/agent-profile.ts — AgentProfile union (OpenHandsAgentProfile w/ llm_profile_ref; ACPAgentProfile w/ acp_* and no llm_profile_ref/credential), both carrying mcp_server_refs: string[] | null; AgentProfileSummary; AgentProfileDiagnostics (mirrors the Python resolver.AgentProfileDiagnostics field-for-field).
  • src/client/agent-profiles-client.ts — AgentProfilesClient (list/get/save/delete/rename/activate by id/materialize by name), surfacing 409/422 via HttpError.
  • src/profiles/derive-switch-plan.ts — pure deriveSwitchPlan (unit-tested across providers).
  • ACP credential descriptor (api_key_env_var / base_url_env_var / file_secrets) on ACPProviderInfo for all three providers (claude-code / codex / gemini-cli).
  • agent_profile_id on the create-conversation path + launched_profile on ConversationInfo are typed and present on main.

⚠️ Corrections to the original Scope below: the ACP descriptor lives in src/models/acp.ts (not src/utils/acp.ts — the file was relocated utils/→models/ in earlier work #210). The provenance type shipped as LaunchedAgentProfile { agent_profile_id, revision } (named launched_profile on ConversationInfo) — the { id, revision, snapshot } shape below was superseded (no snapshot member). Publishing is tag-driven, so the committed package.json version is set at publish time. All acceptance criteria met.

Original spec (delivered as above; acp.ts path + LaunchedProfile/snapshot superseded by the corrections)

Phase 3 — typescript-client · typescript-client · size M · Parent epic #3713

Depends on: [agent-server] /api/agent-profiles router + provenance (#3719, #3720)

ts-client is a small, hand-written repo (no codegen). Work is purely additive. Split into 2 PRs only if the diff gets unwieldy.

Context

The client is a thin, hand-written wrapper (no codegen). Hard ordering: author only after the SDK schema + routers are frozen. No MCPProfilesClient is needed — mcp_server_refs is a plain string[] | null field. The ACP provider credential metadata (api_key_env_var, base_url_env_var, file_secrets) is static and goes directly into src/utils/acp.ts (actual: src/models/acp.ts) — no API call needed.

Scope

1. AgentProfile union + client

  • AgentProfile discriminated union (on agent_kind) in src/models/agent-profile.ts:
    • OpenHands variant: { id, name, revision, llm_profile_ref: string, mcp_server_refs: string[] | null, agent, skills, system_message_suffix, condenser, verification, enable_sub_agents, tool_concurrency_limit }
    • ACP variant: { id, name, revision, acp_server, acp_model, acp_session_mode, acp_prompt_timeout, acp_command, acp_args, mcp_server_refs: string[] | null } — no llm_profile_ref, no credential field
    • AgentProfileSummary for lists.
  • src/client/agent-profiles-client.ts over /api/agent-profiles (list/get/save/delete/rename/activate/materialize), surfacing 409-on-referenced + 422-dangling-mcp-server-ref errors via HttpError status.
  • Typed agent_profile_id on the conversation-create path (CreateConversationPayload is Record<string, unknown> today — additive, no break).

2. ACP provider descriptor extension

3. Resolve/materialize types + deriveSwitchPlan

  • Type the materialize response (resolved AgentSettingsConfig union + ref resolved/dangling status + valid verdict) and the LaunchedProfile { id, revision, snapshot } provenance (actual: LaunchedAgentProfile { agent_profile_id, revision }).
  • Pure deriveSwitchPlan(snapshot, targetProfile, providerInfo) → current | switch-live(mutableFields) | start-new(reason) | disabled(reason), consuming ACPProviderInfo.supports_runtime_model_switch + the existing switchProfile/switchLLM/switchAcpModel methods (conversation-client.ts:262–283). OpenHands→OpenHands live only if just the LLM differs; ACP→ACP live only if same provider + identity and only acp_model differs and the provider supports it; kind change never live.

Wiring/publish: dedicated clients only. Wire into ConversationManager, export from src/clients.ts + src/index.ts, add api-clients.test.ts coverage. Publishing is tag-driven; canvas re-pins via the usual temp-SHA dance.

Acceptance criteria

  • Exported types match the SDK schemas field-for-field; union narrows on agent_kind (both variants have mcp_server_refs: string[] | null).
  • ACPProviderInfo has credential metadata fields for all three providers; no hardcoded provider lists in canvas.
  • FK error statuses surfaced; deriveSwitchPlan is pure + unit-tested across all ACP providers + OpenHands.
  • tsc clean; new clients tested.

Activity

  1. added
    enhancement
    on Jun 15, 2026
  2. changed the title [-][AgentProfile][ts-client] MCPConfig + MCPProfile types + MCPProfilesClient[/-] [+][AgentProfile][ts-client] Profile types + clients (MCPProfile, AgentProfile, resolve/materialize) + deriveSwitchPlan[/+] on Jun 15, 2026
  3. changed the title [-][AgentProfile][ts-client] Profile types + clients (MCPProfile, AgentProfile, resolve/materialize) + deriveSwitchPlan[/-] [+][AgentProfile][ts-client] AgentProfile types + client + resolve/materialize types + deriveSwitchPlan[/+] on Jun 15, 2026
  4. simonrosenberg commented on Jun 17, 2026

    @simonrosenberg
    MemberAuthor

    Status — part 2 of 3 done (issue stays open)

    Part 2 · ACP provider descriptor extension — done via OpenHands/typescript-client#210 (merged).

    Note on scope: the credential descriptor fields this part asked to add (api_key_env_var, base_url_env_var, file_secrets) were already present on ACPProviderInfo — they landed earlier with the registry-mirror PRs typescript-client#173 / #187 / #205, which post-date this issue's text (and the registry moved from src/utils/acp.ts → src/models/acp.ts). So #210's actual contribution was:

    Acceptance criterion "ACPProviderInfo has credential metadata fields for all three providers" is therefore satisfied on main.

    Still outstanding:

    • Part 1 · AgentProfile union + client — AgentProfile discriminated union (src/models/agent-profile.ts) + AgentProfilesClient over /api/agent-profiles + typed agent_profile_id on conversation-create. (Prior attempt typescript-client#195 was closed unmerged.)
    • Part 3 · resolve/materialize types + deriveSwitchPlan — typed materialize response (resolved AgentSettingsConfig union + LaunchedProfile provenance) and the pure deriveSwitchPlan(snapshot, targetProfile, providerInfo).

    Leaving this open to track parts 1 & 3.

  5. simonrosenberg commented on Jun 18, 2026

    @simonrosenberg
    MemberAuthor

    Resolved by typescript-client PR #213 (merged 2026-06-18) — AgentProfile model + client (CRUD/activate/materialize), AgentProfileDiagnostics types, agent_profile_id + LaunchedProfile on conversation, and pure deriveSwitchPlan. Phase 3 complete. Note: #213 is on ts-client main but not yet in a release (latest v1.25.0) — a ts-client release must be cut before canvas (#3726) can consume it.

  6. simonrosenberg commented on Jun 21, 2026

    @simonrosenberg
    MemberAuthor

    Audit note (2026-06-21) — closed + correct, released in ts-client v1.26.0 (npm latest). PR #213 fully implements this: AgentProfile types (src/models/agent-profile.ts), AgentProfilesClient (src/client/agent-profiles-client.ts), and a pure deriveSwitchPlan (src/profiles/derive-switch-plan.ts). Containment re-verified: git show v1.26.0:… confirms all three present.

    Two doc-only clarifications (no code change): the ACP credential descriptor lives in src/models/acp.ts, not src/utils/acp.ts as the body says (the file was relocated utils/→models/ in earlier work #210); and the agent_profile_id / launched_profile ConversationInfo types are already present on main — only their server-side runtime activation was gated on SDK #3784.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementsdk

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions