Skip to content

feat(provider): add getModels() helper#19

Draft
DaniAkash wants to merge 1 commit into
mainfrom
feat/get-available-models
Draft

feat(provider): add getModels() helper#19
DaniAkash wants to merge 1 commit into
mainfrom
feat/get-available-models

Conversation

@DaniAkash
Copy link
Copy Markdown
Owner

⚠️ Draft — waiting on upstream

This PR is pre-implementation against the documented upstream shape. It will not pass typecheck until openclaw/acpx#300 merges and a corresponding acpx release ships (expected as 0.8.0 based on the documented type signatures).

Do not mark ready / merge until:

  1. feat(runtime): expose session models on getStatus openclaw/acpx#300 is merged.
  2. acpx@0.8.0 (or whatever version lands the models field) is published to npm.
  3. Locally: bun install resolves the new acpx, then bun run typecheck passes — confirming upstream's published types match the documented shape.
  4. Verified the published runtime.d.ts exposes models?: AcpRuntimeSessionModels on AcpRuntimeStatus plus the AcpRuntimeSessionModels export. If upstream renamed during review, update src/types.ts, src/provider.ts, and src/index.ts to match.

Summary

Hosts can now read the models advertised by the underlying ACP agent (Claude Code, Codex) with one typed call instead of reaching into the untyped runtime.getStatus().details.acpx.available_models bag.

const provider = createAcpxProvider({ agent: 'claude-code', cwd })
const models = await provider.getModels()
// → { currentModelId: 'claude-opus-4-7',
//     availableModelIds: ['claude-haiku-4-5', 'claude-sonnet-4-6', 'claude-opus-4-7'] }
//   or `undefined` if the agent didn't advertise any (Gemini, custom adapters)

This unblocks the Gap 1 follow-up identified in the model-selection research — host UIs that want to render a model picker before the first prompt no longer need to type-cast their way through details. Returning undefined when no models were advertised lets callers branch cleanly on agents like Gemini CLI.

Files changed

File Change
src/types.ts Re-export AcpRuntimeSessionModels + AcpRuntimeStatus from acpx/runtime
src/provider.ts Add getModels(opts?) method on AcpxProvider — resolves a handle, calls runtime.getStatus, returns the typed models field
src/index.ts Re-export the two new types
README.md New ## Listing models section after "Tools — via MCP servers"
test/unit/provider.test.ts NEW — three tests: models advertised → returned, models omitted → undefined, runtime without getStatus → undefined
package.json Version 0.0.10.1.0; acpx peer-dep + dev-dep >=0.6.1>=0.8.0

Test plan

Check Status Why
bun run typecheck 4 errors All from missing upstream types — expected, will go green when acpx@0.8.0 publishes
bun run lint ✅ clean
bun run fallow ✅ exit 0
bun test ✅ 183 pass / 15 skip / 0 fail / 280 expect() TS types are erased at runtime; the 3 new tests are part of the 183
bun run build ✅ ESM + .d.ts (~32 KB) bunup's esbuild path strips types without re-checking

Coordination with #17

#17 (the onPermissionRequest callback follow-up) and this PR both target the same upstream acpx release. Whichever lands second needs to bump its version one step further (e.g. 0.1.00.2.0) and resolve any package.json conflict — both PRs touch version and the acpx dep range to identical values today.

Known issue: dev-dep won't resolve from a clean install

The dev-dep range acpx >=0.8.0 doesn't have a matching version published yet. bun install from a fresh checkout of this branch will fail. This is expected for the draft phase. Branch exists for review, not for fresh installs.

When upstream lands, the resolver will pick up acpx@0.8.0 automatically and everything goes green.

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