Skip to content

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

Merged
DaniAkash merged 4 commits into
mainfrom
feat/get-available-models
May 19, 2026
Merged

feat(provider): add getModels() helper#19
DaniAkash merged 4 commits into
mainfrom
feat/get-available-models

Conversation

@DaniAkash
Copy link
Copy Markdown
Owner

@DaniAkash DaniAkash commented May 7, 2026

Summary

Upstream: openclaw/acpx#300 — the runtime PR this provider change consumes.

Adds AcpxProvider.getModels() — a typed helper that returns the agent's advertised model list (current + available IDs) with one call instead of reaching into the untyped runtime.getStatus().details 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 (e.g. Gemini, custom adapters)

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

What changed

File Change
package.json Version 0.0.40.0.5. acpx peer-dep + dev-dep raised to >=0.8.0 (the upstream version that ships AcpRuntimeStatus.models + AcpRuntimeSessionModels via openclaw/acpx#300).
src/types.ts Re-export AcpRuntimeSessionModels + AcpRuntimeStatus from acpx/runtime.
src/provider.ts Add getModels(opts?) on AcpxProvider — resolves a handle, calls runtime.getStatus, returns the typed models field (or undefined when omitted / when the runtime has no getStatus method).
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 using MockAcpRuntime: (1) returns the models field verbatim when present, (2) returns undefined when status omits models, (3) returns undefined when the runtime implementation has no getStatus method at all.

Test plan

  • bun run lint clean.
  • bun run typecheck clean (passes against the now-published acpx@0.8.0).
  • bun run fallow clean.
  • bun test — 266 pass / 24 skip / 0 fail across the monorepo (290 tests, 30 files; the three new tests are part of the 266).
  • bun run build clean (ESM + .d.ts).

Coordination

Ships alongside two sibling provider features that all target 0.0.5:

  • #17onPermissionRequest callback
  • #23sessionOptions forwarding

Whichever lands first wins 0.0.5; the other two will need a follow-up bump (0.0.50.0.60.0.7) and a one-line package.json rebase to resolve the version conflict. All three are independent on the code side.

Resolves package.json version conflict: keep this branch's 0.1.0
bump (main is at 0.0.4; this PR ships new public API). README and
provider.ts auto-merged cleanly.

Resyncs bun.lock against acpx@0.8.0 — now published with the
AcpRuntimeStatus.models surface this PR consumes.
@DaniAkash DaniAkash marked this pull request as ready for review May 17, 2026 07:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a typed AcpxProvider.getModels() convenience API so callers can retrieve the runtime-advertised session model list (currentModelId + availableModelIds) without digging into runtime.getStatus().details, alongside docs/tests and the dependency bump needed to consume the upstream status shape.

Changes:

  • Add AcpxProvider.getModels(opts?) that calls runtime.getStatus({ handle }) and returns status.models (or undefined when unsupported/unadvertised).
  • Re-export AcpRuntimeSessionModels and AcpRuntimeStatus types, and document the new helper in the provider README.
  • Bump acpx peer/dev dependency to >=0.8.0 and add unit tests covering the new behavior.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/acpx-ai-provider/src/provider.ts Adds the getModels() helper that reads status.models via runtime.getStatus.
packages/acpx-ai-provider/src/types.ts Re-exports new runtime status/model types for downstream consumers.
packages/acpx-ai-provider/src/index.ts Exposes the new re-exported types at the package surface.
packages/acpx-ai-provider/README.md Documents “Listing models” usage and expected undefined cases.
packages/acpx-ai-provider/test/unit/provider.test.ts Adds unit tests validating getModels() behavior across supported/unsupported runtimes.
packages/acpx-ai-provider/package.json Bumps version and raises acpx peer/dev dependency to >=0.8.0.
bun.lock Updates lockfile for new dependency range, but currently contains a workspace version mismatch for acpx-ai-provider.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…dels

# Conflicts:
#	bun.lock
#	packages/acpx-ai-provider/README.md
#	packages/acpx-ai-provider/package.json
#	packages/acpx-ai-provider/test/unit/provider.test.ts
@DaniAkash DaniAkash merged commit e80b07d into main May 19, 2026
2 checks passed
@DaniAkash DaniAkash deleted the feat/get-available-models branch May 19, 2026 09:37
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.

2 participants