feat(m7.5c): TypeScript OpenAI-compatible model adapter - #33
Merged
Conversation
The TS package had only FakeModel; this is its first real LLM adapter — and since
the global fetch is built in, it lives in the core package with ZERO new deps.
- openai.ts: OpenAICompatModel over the global fetch, speaking the Chat Completions
dialect — one adapter for OpenAI, Groq, Gemini (compat), Z.ai/GLM, Ollama, and
vLLM. Sends the model only each capability's intent surface (ToolSpec) — never
policy metadata (§2.5); maps text + tool_calls responses (tool calls win over a
'stop' finish); malformed tool JSON and 4xx are hinted control-plane errors;
max_completion_tokens for api.openai.com vs max_tokens for compat servers (by
host); an injectable FetchLike for deterministic, network-free tests.
- provider registry + resolveModel('provider:model' / bare provider / bare model
name by prefix) + defaultModel() env auto-detect (OPENAI→GEMINI→GROQ→ZAI→
OLLAMA_BASE_URL→VLLM_BASE_URL); a missing key yields our hinted error, not a raw
401; Anthropic's native dialect returns a clear 'not yet ported' error.
- tests (injected fetch, no network): text + tool-call mapping, tool-calls-win,
malformed-args error, only-the-intent-surface on the wire, 4xx hinted, token-field
by host, and resolution (provider:model, bare-name sniff, ollama needs a model,
missing key, anthropic not-yet, unknown provider, env auto-detect).
Verified: make js-check green — format, typecheck, 139 tests (138 pass, 1 skip).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The TS package had only FakeModel; this is its first real LLM adapter — and since the global fetch is built in, it lives in the core package with ZERO new deps.
Verified: make js-check green — format, typecheck, 139 tests (138 pass, 1 skip).