Skip to content

feat(wrapper-ts): add listAllModels() for aggregate provider discovery#54

Merged
manojp99 merged 1 commit into
mainfrom
feat/wrapper-ts-list-all-models
Jun 12, 2026
Merged

feat(wrapper-ts): add listAllModels() for aggregate provider discovery#54
manojp99 merged 1 commit into
mainfrom
feat/wrapper-ts-list-all-models

Conversation

@manojp99

Copy link
Copy Markdown
Collaborator

Summary

Add a new listAllModels() function to the TypeScript wrapper, exposing the engine's aggregate provider discovery mode introduced in #49.

  • Queries all configured providers in parallel (anthropic, openai, ollama, azure-openai)
  • Returns per-provider results with auth status for each
  • Eliminates the need for hosts to make 4 sequential or parallel single-provider calls

Motivation

The paperclip adapter currently uses a static list of models when selecting which provider/model to use. The ideal flow is:

  1. Call listAllModels() once to get all available models across all configured providers
  2. Check auth status per-provider (ok vs credentials_missing vs module_not_installed)
  3. Use a single dynamic dropdown instead of hardcoded options

With the engine's existing aggregate mode (amplifier-agent models list with no --provider flag), this is now efficient and straightforward.

Design

Separate function, not overload:

  • New listAllModels() is a distinct exported function returning a different envelope type
  • Existing listModels(provider) behavior is unchanged and fully backward compatible
  • Union return types would complicate call-site type narrowing; distinct functions are clearer

Status is a free-form string:

  • Engine emits ok | credentials_missing | module_not_installed | error today
  • Wrapper accepts any string to permit future engine additions without wrapper version bumps
  • Hosts should compare against literal "ok" rather than exhaustive enums

Refactored helpers for code reuse:

  • Extracted runModelsListSubprocess(args, options) and interpretOutcome(outcome, validate)
  • Both listModels and listAllModels share the same subprocess driver + exit-code interpretation
  • No behavioral changes to existing listModels() callers

Testing

  • 11 new test cases (A1-A11) mirror the existing 9 for single-provider mode
  • Additional tests for the aggregate-specific scenarios (mixed provider statuses, missing results[] field)
  • All 124 tests pass (pnpm test)
  • Asserts correct argv construction (omits --provider in aggregate mode, includes it in single-provider)

Engine compatibility

Requires engine ≥ #49 (merged into main at commit e48a644). The aggregate CLI endpoint is already live — no engine changes in this PR.

Backward compatibility

Zero breaking changes. Existing listModels(provider) callers see no change in signature, behavior, or error types.

Add a new listAllModels() function to expose the engine's aggregate provider
discovery mode, which queries all configured providers in parallel and returns
per-provider results with auth status.

Design choices:
- Separate function (not overload) due to structurally different envelope type
- Extracted runModelsListSubprocess() and interpretOutcome() helpers for code reuse
- Status field intentionally free-form string to permit future engine additions
- Existing listModels() behavior unchanged; backward compatible

Testing:
- 11 new test cases (A1-A11) mirror existing 9 for listModels
- All 124 tests pass
- Asserts correct argv construction (omits --provider in aggregate mode)

Motivates paperclip's amplifier-local adapter to use dynamic model discovery
instead of static list or 4 parallel single-provider calls.

Requires: engine PR #49+ for amplifier-agent models list aggregate mode support

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
@manojp99 manojp99 merged commit 47189f5 into main Jun 12, 2026
2 of 3 checks passed
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