Skip to content

feat(m7.5c): TypeScript OpenAI-compatible model adapter - #33

Merged
shamspias merged 1 commit into
mainfrom
build/m7.5c-ts-model
Jul 5, 2026
Merged

feat(m7.5c): TypeScript OpenAI-compatible model adapter#33
shamspias merged 1 commit into
mainfrom
build/m7.5c-ts-model

Conversation

@shamspias

Copy link
Copy Markdown
Owner

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).

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).
@shamspias
shamspias merged commit 78e5386 into main Jul 5, 2026
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