@smooai/smooth-operator-core 1.8.6 → 1.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -24,6 +24,8 @@ export { approve, approveAlways, deny, HumanDecision, isApproved } from './human
24
24
  export type { HumanApprovalRequest, HumanApprovalResponse, HumanGate } from './humanGate.js';
25
25
  export { AutoMode, autoModeFromEnv, autoModeFromValue, decide, domainMatchesSuffixList, extractHosts, hostFromToken, PermissionHook, splitCompound, stripWrappersAndSudo, toolCategory, } from './permission.js';
26
26
  export type { Category, Verdict } from './permission.js';
27
+ export { ALL_PRESETS, Activity, ApiFormat, anthropicProvider, buildModelInfoUrl, defaultModelRouting, fetchModelInfo, googleProvider, kimiCodeProvider, kimiProvider, llmGatewayProvider, modelSlot, ollamaProvider, openAiProvider, openRouterProvider, parseModelInfo, Preset, presetFromName, presetProviderId, ProviderRegistry, quirkKeys, quirksDebugSnapshot, quirksForModel, slotFor, smooaiGatewayProvider, withFallback, } from './providers.js';
28
+ export type { LlmConfig, ModelQuirks, ModelRouting, ModelSlot, PresetInfo, ProviderConfig, ResolvedModel } from './providers.js';
27
29
  export { hostMatchesGlob, PermissionGrants } from './permissionGrants.js';
28
30
  export type { GrantQuery } from './permissionGrants.js';
29
31
  export { DenyPolicy, DenyRules, globMatch } from './denyPolicy.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3E,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC9K,OAAO,EAAE,IAAI,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AAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACvE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9E,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ export { driveTurn, InProcessActivities, InProcessExecutor } from './executor.js
15
15
  export { createGatewayClient, gatewayClientFrom } from './gatewayClient.js';
16
16
  export { approve, approveAlways, deny, HumanDecision, isApproved } from './humanGate.js';
17
17
  export { AutoMode, autoModeFromEnv, autoModeFromValue, decide, domainMatchesSuffixList, extractHosts, hostFromToken, PermissionHook, splitCompound, stripWrappersAndSudo, toolCategory, } from './permission.js';
18
+ export { ALL_PRESETS, Activity, ApiFormat, anthropicProvider, buildModelInfoUrl, defaultModelRouting, fetchModelInfo, googleProvider, kimiCodeProvider, kimiProvider, llmGatewayProvider, modelSlot, ollamaProvider, openAiProvider, openRouterProvider, parseModelInfo, Preset, presetFromName, presetProviderId, ProviderRegistry, quirkKeys, quirksDebugSnapshot, quirksForModel, slotFor, smooaiGatewayProvider, withFallback, } from './providers.js';
18
19
  export { hostMatchesGlob, PermissionGrants } from './permissionGrants.js';
19
20
  export { DenyPolicy, DenyRules, globMatch } from './denyPolicy.js';
20
21
  export { InMemoryKnowledge } from './knowledge.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OA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AAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAEjI,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAExF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,291 @@
1
+ /**
2
+ * Provider routing — the TypeScript port of the Rust reference engine's
3
+ * `providers.rs`, `quirks.rs` and `resolution.rs`.
4
+ *
5
+ * Three concerns, one module because they are one story: **which** model a given
6
+ * activity should use, **what** wire quirks that concrete model has, and — when
7
+ * the route points at a LiteLLM-style gateway — **which** upstream model a
8
+ * semantic alias actually resolves to.
9
+ *
10
+ * - {@link ProviderRegistry} holds provider credentials/URLs and a
11
+ * {@link ModelRouting} table mapping each {@link Activity} to a
12
+ * {@link ModelSlot}. {@link ProviderRegistry.llmConfigFor} walks the slot's
13
+ * fallback chain until it finds a registered provider.
14
+ * - {@link quirksForModel} looks up per-model wire quirks by substring on the
15
+ * concrete upstream name.
16
+ * - {@link buildModelInfoUrl} / {@link parseModelInfo} / {@link fetchModelInfo}
17
+ * recover the gateway's alias → upstream map from `GET /model/info`.
18
+ *
19
+ * The on-disk JSON shape is shared with the Rust CLI (`~/.smooth/providers.json`),
20
+ * so the serialized keys are snake_case and must stay byte-compatible: the same
21
+ * file is written by one engine and read by another. Legacy `thinking` /
22
+ * `planning` field names still deserialize onto the merged `reasoning` slot.
23
+ *
24
+ * Routing values are pinned across all five engines by the shared corpus at
25
+ * `spec/providers/routing.json` — a slot that resolves to the wrong model or
26
+ * base URL sends real traffic and real money somewhere nobody intended, and it
27
+ * looks like it is working.
28
+ */
29
+ import type { ChatClientLike } from './agent.js';
30
+ /**
31
+ * The wire dialect a provider speaks. The string values match the Rust
32
+ * reference's serde output so `providers.json` round-trips between engines.
33
+ */
34
+ export declare enum ApiFormat {
35
+ /** The OpenAI `/chat/completions` dialect. */
36
+ OpenAiCompat = "OpenAiCompat",
37
+ /** Anthropic's native `/messages` dialect. */
38
+ Anthropic = "Anthropic"
39
+ }
40
+ /** Connection detail for a single LLM provider. */
41
+ export interface ProviderConfig {
42
+ id: string;
43
+ apiUrl: string;
44
+ apiKey: string;
45
+ apiFormat: ApiFormat;
46
+ defaultModel: string;
47
+ }
48
+ /** OpenRouter — an OpenAI-compatible proxy for many models. */
49
+ export declare function openRouterProvider(apiKey: string): ProviderConfig;
50
+ /** The OpenAI direct API. */
51
+ export declare function openAiProvider(apiKey: string): ProviderConfig;
52
+ /** The Anthropic native API. */
53
+ export declare function anthropicProvider(apiKey: string): ProviderConfig;
54
+ /** A local Ollama instance — no API key needed. */
55
+ export declare function ollamaProvider(): ProviderConfig;
56
+ /** The Google Gemini API (OpenAI-compatible surface). */
57
+ export declare function googleProvider(apiKey: string): ProviderConfig;
58
+ /** Moonshot AI's general-purpose API (OpenAI-compatible). */
59
+ export declare function kimiProvider(apiKey: string): ProviderConfig;
60
+ /** Moonshot's coding-optimized API (Anthropic-compatible). */
61
+ export declare function kimiCodeProvider(apiKey: string): ProviderConfig;
62
+ /** LLM Gateway — a unified API for 210+ models. */
63
+ export declare function llmGatewayProvider(apiKey: string): ProviderConfig;
64
+ /**
65
+ * The hosted LiteLLM-backed gateway run by Smoo AI.
66
+ *
67
+ * One API key, one URL, OpenAI-compatible. The gateway handles provider
68
+ * selection, billing, moderation and cost tracking server-side, so consumers
69
+ * reference models by semantic aliases (`smooth-coding`, `smooth-judge`, …) that
70
+ * the gateway maps to whichever underlying model is currently best — upgrades
71
+ * ship server-side with no client release.
72
+ *
73
+ * `SMOOAI_GATEWAY_URL` overrides the base URL. Only an ABSENT variable takes the
74
+ * default: a set-but-empty override yields an empty base URL, matching Rust.
75
+ */
76
+ export declare function smooaiGatewayProvider(apiKey: string): ProviderConfig;
77
+ /** A ready-made provider + routing configuration. */
78
+ export declare enum Preset {
79
+ /** The hosted Smoo AI gateway — the recommended default. */
80
+ SmoaiGateway = "SmoaiGateway",
81
+ /** Chinese frontier models via OpenRouter — the cheapest option. */
82
+ OpenRouterLowCost = "OpenRouterLowCost",
83
+ /** Chinese frontier models via LLM Gateway. */
84
+ LlmGatewayLowCost = "LlmGatewayLowCost",
85
+ /** OpenAI models. */
86
+ OpenAI = "OpenAI",
87
+ /** Anthropic Claude models. */
88
+ Anthropic = "Anthropic"
89
+ }
90
+ /** One row of {@link ALL_PRESETS}: CLI name, display label, description. */
91
+ export interface PresetInfo {
92
+ name: string;
93
+ label: string;
94
+ description: string;
95
+ }
96
+ /**
97
+ * Every preset. The first entry is the recommended default — `th auth login`
98
+ * shows them in this order.
99
+ */
100
+ export declare const ALL_PRESETS: readonly PresetInfo[];
101
+ /** Parse a preset name or alias. Returns `undefined` for unknown names. */
102
+ export declare function presetFromName(name: string): Preset | undefined;
103
+ /** The provider id a preset requires. */
104
+ export declare function presetProviderId(preset: Preset): string;
105
+ /**
106
+ * Selects which model slot a call routes through. Six semantic slots: the legacy
107
+ * `Thinking` + `Planning` split collapsed into {@link Activity.Reasoning}, and the
108
+ * legacy "default" alias is served by {@link Activity.Coding}.
109
+ */
110
+ export declare enum Activity {
111
+ /** The outer coding loop — the workhorse slot, which also serves the legacy "default" call path. */
112
+ Coding = "Coding",
113
+ /** Deep reasoning / planning / chain-of-thought. */
114
+ Reasoning = "Reasoning",
115
+ /** Code review, critique, adversarial checks. */
116
+ Reviewing = "Reviewing",
117
+ /** LLM-as-a-judge: yes/no verdicts, low latency, used by Narc guardrails and bench scoring. */
118
+ Judge = "Judge",
119
+ /** Context compression during long agent runs. */
120
+ Summarize = "Summarize",
121
+ /**
122
+ * Small, latency-sensitive utility calls: session auto-naming, short titles,
123
+ * one-liner summaries, autocomplete. Sub-second first token, short output, no
124
+ * tool use — don't pay Sonnet-plus prices to name a session.
125
+ */
126
+ Fast = "Fast"
127
+ }
128
+ /** A provider id + model name, with an optional fallback used when the provider is not registered. */
129
+ export interface ModelSlot {
130
+ provider: string;
131
+ model: string;
132
+ fallback?: ModelSlot;
133
+ }
134
+ /** Build a slot with no fallback. */
135
+ export declare function modelSlot(provider: string, model: string): ModelSlot;
136
+ /** Return a copy of `slot` with `fallback` attached. */
137
+ export declare function withFallback(slot: ModelSlot, fallback: ModelSlot): ModelSlot;
138
+ /**
139
+ * The per-activity routing table.
140
+ *
141
+ * Six semantic slots plus a `default` slot kept for wire compatibility: no
142
+ * {@link Activity} routes through `default` directly ({@link Activity.Coding}
143
+ * serves the default path), but the field stays so pre-collapse configs load.
144
+ */
145
+ export interface ModelRouting {
146
+ coding: ModelSlot;
147
+ /** Merged deep-reasoning slot. Absent in older files (which carry `thinking`); falls back to `default`. */
148
+ reasoning?: ModelSlot;
149
+ reviewing: ModelSlot;
150
+ judge: ModelSlot;
151
+ summarize: ModelSlot;
152
+ default: ModelSlot;
153
+ /** Optional on disk: pre-`fast` files fall back to `default` at lookup time. */
154
+ fast?: ModelSlot;
155
+ /** Legacy field, deserialized but ignored at lookup time — `reasoning` absorbed it. */
156
+ planning?: ModelSlot;
157
+ }
158
+ /**
159
+ * The neutral, provider-agnostic routing every slot starts on: the well-known
160
+ * `openrouter` provider id with a placeholder `auto` model, so the library ships
161
+ * no opinion about a specific hosted gateway. Consumers opt into the Smoo AI
162
+ * gateway via {@link Preset.SmoaiGateway} explicitly.
163
+ */
164
+ export declare function defaultModelRouting(): ModelRouting;
165
+ /** The slot for an activity. `Reasoning` and `Fast` fall back to `default` when absent. */
166
+ export declare function slotFor(routing: ModelRouting, activity: Activity): ModelSlot;
167
+ /**
168
+ * A fully resolved route: the provider connection plus the model the activity
169
+ * picked. Feed `apiUrl`/`apiKey` to {@link createGatewayClient}.
170
+ */
171
+ export interface LlmConfig {
172
+ apiUrl: string;
173
+ apiKey: string;
174
+ model: string;
175
+ maxTokens: number;
176
+ temperature: number;
177
+ apiFormat: ApiFormat;
178
+ }
179
+ /** Registered providers plus the per-activity routing table. */
180
+ export declare class ProviderRegistry {
181
+ private readonly providers;
182
+ /** The per-activity table. Reassign a slot to re-point a route. */
183
+ routing: ModelRouting;
184
+ /**
185
+ * A registry pre-configured with a preset: registers the preset's provider
186
+ * and installs routing tuned for the preset's goals (cost, quality, latency).
187
+ */
188
+ static fromPreset(preset: Preset, apiKey: string): ProviderRegistry;
189
+ /**
190
+ * A minimal registry from `SMOOTH_API_KEY` (required), `SMOOTH_PROVIDER`
191
+ * (defaults to `openrouter`) and `SMOOTH_MODEL` (optional). Returns
192
+ * `undefined` when `SMOOTH_API_KEY` is unset — never a keyless client.
193
+ */
194
+ static fromEnv(): ProviderRegistry | undefined;
195
+ /** Read a registry from a JSON file (e.g. `~/.smooth/providers.json`). */
196
+ static loadFromFile(path: string): ProviderRegistry;
197
+ /** Deserialize a registry from the JSON shape {@link ProviderRegistry.toJson} writes. */
198
+ static fromJson(json: string): ProviderRegistry;
199
+ /** Add (or replace) a provider configuration. */
200
+ registerProvider(config: ProviderConfig): void;
201
+ /** Drop a provider by id. */
202
+ removeProvider(id: string): void;
203
+ /** Look up a provider by id. */
204
+ getProvider(id: string): ProviderConfig | undefined;
205
+ /** Every registered provider id, sorted. */
206
+ listProviders(): string[];
207
+ /** Point every routing slot at `providerId` using its default model. */
208
+ setDefaultProvider(providerId: string): void;
209
+ /** Install a custom routing table. */
210
+ withRouting(routing: ModelRouting): this;
211
+ private resolveSlot;
212
+ /**
213
+ * Resolve the route for an activity. Throws when the slot's provider — and
214
+ * every fallback — is unregistered, rather than silently substituting some
215
+ * other provider.
216
+ */
217
+ llmConfigFor(activity: Activity): LlmConfig;
218
+ /** Resolve the wire-compat `default` slot. */
219
+ defaultLlmConfig(): LlmConfig;
220
+ /**
221
+ * Build a gateway client for an activity's resolved route — the one line
222
+ * between "which model should this call use" and a client that speaks to it.
223
+ *
224
+ * The client is OpenAI-compatible; an {@link ApiFormat.Anthropic} provider is
225
+ * rejected rather than silently spoken to in the wrong dialect.
226
+ */
227
+ clientFor(activity: Activity): {
228
+ client: ChatClientLike;
229
+ config: LlmConfig;
230
+ };
231
+ /** Serialize to the on-disk JSON shape, snake_case keys and all. */
232
+ toJson(pretty?: boolean): string;
233
+ /** Write the registry as pretty-printed JSON, creating parent directories. */
234
+ saveToFile(path: string): void;
235
+ }
236
+ /**
237
+ * Per-model wire-format flags. Populate a field only when the quirk is worth the
238
+ * branch — every conditional is a place for drift.
239
+ *
240
+ * When routing through a LiteLLM-style gateway the concrete upstream model only
241
+ * reveals itself in response headers (`x-litellm-model-name`), by which point the
242
+ * request is already sent. So prefer always-safe request shapes over per-model
243
+ * conditionals, and keep this table for the cases where the strict form does not
244
+ * work everywhere.
245
+ */
246
+ export interface ModelQuirks {
247
+ /** When `false`, force `parallel_tool_calls` off even if the agent config requests it. */
248
+ allowParallelTools?: boolean;
249
+ /** Ask the client to be extra careful about tool_call echo shape. Nothing reads this yet. */
250
+ strictToolCallJson: boolean;
251
+ }
252
+ /**
253
+ * Look up quirks by concrete upstream name. Matching is case-insensitive and
254
+ * substring-based, so minor version drift (`qwen3-coder-plus-2025-04`) still hits
255
+ * the `qwen3-coder` entry. Returns safe defaults when nothing matches.
256
+ */
257
+ export declare function quirksForModel(upstream: string): ModelQuirks;
258
+ /** The quirk table's canonical keys, for diagnostics. */
259
+ export declare function quirkKeys(): string[];
260
+ /** Every quirk entry matching an upstream name. Usually one wins; the full set is kept for tests. */
261
+ export declare function quirksDebugSnapshot(upstream: string): Record<string, ModelQuirks>;
262
+ /** One routing entry returned by a gateway's `/model/info`. */
263
+ export interface ResolvedModel {
264
+ /** The name callers use (e.g. `smooth-coding`). */
265
+ alias: string;
266
+ /** The concrete model (e.g. `moonshot/kimi-k2-thinking`), when the gateway surfaces it. */
267
+ upstream?: string;
268
+ /** Stable id from `model_info.id`, useful for tracing a rename. */
269
+ id?: string;
270
+ }
271
+ /**
272
+ * Derive the `/model/info` URL from a provider's OpenAI-compat `apiUrl`
273
+ * (e.g. `https://llm.smoo.ai/v1`). Stripping `/v1` is safe: `/model/info` lives
274
+ * at the gateway root in every LiteLLM deployment seen.
275
+ */
276
+ export declare function buildModelInfoUrl(apiUrl: string): string;
277
+ /**
278
+ * Parse a `/model/info` response body into an alias → entry map, sorted by alias
279
+ * so diagnostics print the same order every run (Rust returns a `BTreeMap`).
280
+ *
281
+ * Throws when the body is not valid JSON or is missing the `data` array.
282
+ */
283
+ export declare function parseModelInfo(body: string): Map<string, ResolvedModel>;
284
+ /**
285
+ * Ask a LiteLLM gateway for its alias → upstream map.
286
+ *
287
+ * A 401 means the provider's API key is missing or rejected; either way the
288
+ * caller cannot see the mapping.
289
+ */
290
+ export declare function fetchModelInfo(apiUrl: string, apiKey: string, timeoutMs?: number): Promise<Map<string, ResolvedModel>>;
291
+ //# sourceMappingURL=providers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAOjD;;;GAGG;AACH,oBAAY,SAAS;IACjB,8CAA8C;IAC9C,YAAY,iBAAiB;IAC7B,8CAA8C;IAC9C,SAAS,cAAc;CAC1B;AAED,mDAAmD;AACnD,MAAM,WAAW,cAAc;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,+DAA+D;AAC/D,wBAAgB,kBAAkB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AAC,MAAM,UAAQ,GAAG,MAAM;IAoB9B,8EAA8E;IAC9E,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAIjC;AAMD;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IACxB,0FAA0F;IAC1F,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,6FAA6F;IAC7F,kBAAkB,EAAE,OAAO,CAAC;CAC/B;AAOD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAM5D;AAED,yDAAyD;AACzD,wBAAgB,SAAS,IAAI,MAAM,EAAE,CAEpC;AAED,qGAAqG;AACrG,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAOjF;AAMD,+DAA+D;AAC/D,MAAM,WAAW,aAAa;IAC1B,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,EAAE,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIxD;AAMD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAoBvE;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAc5H"}
@@ -0,0 +1,591 @@
1
+ /**
2
+ * Provider routing — the TypeScript port of the Rust reference engine's
3
+ * `providers.rs`, `quirks.rs` and `resolution.rs`.
4
+ *
5
+ * Three concerns, one module because they are one story: **which** model a given
6
+ * activity should use, **what** wire quirks that concrete model has, and — when
7
+ * the route points at a LiteLLM-style gateway — **which** upstream model a
8
+ * semantic alias actually resolves to.
9
+ *
10
+ * - {@link ProviderRegistry} holds provider credentials/URLs and a
11
+ * {@link ModelRouting} table mapping each {@link Activity} to a
12
+ * {@link ModelSlot}. {@link ProviderRegistry.llmConfigFor} walks the slot's
13
+ * fallback chain until it finds a registered provider.
14
+ * - {@link quirksForModel} looks up per-model wire quirks by substring on the
15
+ * concrete upstream name.
16
+ * - {@link buildModelInfoUrl} / {@link parseModelInfo} / {@link fetchModelInfo}
17
+ * recover the gateway's alias → upstream map from `GET /model/info`.
18
+ *
19
+ * The on-disk JSON shape is shared with the Rust CLI (`~/.smooth/providers.json`),
20
+ * so the serialized keys are snake_case and must stay byte-compatible: the same
21
+ * file is written by one engine and read by another. Legacy `thinking` /
22
+ * `planning` field names still deserialize onto the merged `reasoning` slot.
23
+ *
24
+ * Routing values are pinned across all five engines by the shared corpus at
25
+ * `spec/providers/routing.json` — a slot that resolves to the wrong model or
26
+ * base URL sends real traffic and real money somewhere nobody intended, and it
27
+ * looks like it is working.
28
+ */
29
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
30
+ import { dirname } from 'node:path';
31
+ import { createGatewayClient } from './gatewayClient.js';
32
+ // ---------------------------------------------------------------------------
33
+ // Providers
34
+ // ---------------------------------------------------------------------------
35
+ /**
36
+ * The wire dialect a provider speaks. The string values match the Rust
37
+ * reference's serde output so `providers.json` round-trips between engines.
38
+ */
39
+ export var ApiFormat;
40
+ (function (ApiFormat) {
41
+ /** The OpenAI `/chat/completions` dialect. */
42
+ ApiFormat["OpenAiCompat"] = "OpenAiCompat";
43
+ /** Anthropic's native `/messages` dialect. */
44
+ ApiFormat["Anthropic"] = "Anthropic";
45
+ })(ApiFormat || (ApiFormat = {}));
46
+ /** OpenRouter — an OpenAI-compatible proxy for many models. */
47
+ export function openRouterProvider(apiKey) {
48
+ return { id: 'openrouter', apiUrl: 'https://openrouter.ai/api/v1', apiKey, apiFormat: ApiFormat.OpenAiCompat, defaultModel: 'openai/gpt-4o' };
49
+ }
50
+ /** The OpenAI direct API. */
51
+ export function openAiProvider(apiKey) {
52
+ return { id: 'openai', apiUrl: 'https://api.openai.com/v1', apiKey, apiFormat: ApiFormat.OpenAiCompat, defaultModel: 'gpt-4o' };
53
+ }
54
+ /** The Anthropic native API. */
55
+ export function anthropicProvider(apiKey) {
56
+ return { id: 'anthropic', apiUrl: 'https://api.anthropic.com/v1', apiKey, apiFormat: ApiFormat.Anthropic, defaultModel: 'claude-sonnet-4-20250514' };
57
+ }
58
+ /** A local Ollama instance — no API key needed. */
59
+ export function ollamaProvider() {
60
+ return { id: 'ollama', apiUrl: 'http://localhost:11434/v1', apiKey: '', apiFormat: ApiFormat.OpenAiCompat, defaultModel: 'llama3' };
61
+ }
62
+ /** The Google Gemini API (OpenAI-compatible surface). */
63
+ export function googleProvider(apiKey) {
64
+ return {
65
+ id: 'google',
66
+ apiUrl: 'https://generativelanguage.googleapis.com/v1beta/openai',
67
+ apiKey,
68
+ apiFormat: ApiFormat.OpenAiCompat,
69
+ defaultModel: 'gemini-2.0-flash',
70
+ };
71
+ }
72
+ /** Moonshot AI's general-purpose API (OpenAI-compatible). */
73
+ export function kimiProvider(apiKey) {
74
+ return { id: 'kimi', apiUrl: 'https://api.moonshot.ai/v1', apiKey, apiFormat: ApiFormat.OpenAiCompat, defaultModel: 'kimi-k2.5' };
75
+ }
76
+ /** Moonshot's coding-optimized API (Anthropic-compatible). */
77
+ export function kimiCodeProvider(apiKey) {
78
+ return { id: 'kimi-code', apiUrl: 'https://api.kimi.com/coding/v1', apiKey, apiFormat: ApiFormat.Anthropic, defaultModel: 'kimi-for-coding' };
79
+ }
80
+ /** LLM Gateway — a unified API for 210+ models. */
81
+ export function llmGatewayProvider(apiKey) {
82
+ return { id: 'llmgateway', apiUrl: 'https://api.llmgateway.io/v1', apiKey, apiFormat: ApiFormat.OpenAiCompat, defaultModel: 'openai/gpt-4o' };
83
+ }
84
+ /**
85
+ * The hosted LiteLLM-backed gateway run by Smoo AI.
86
+ *
87
+ * One API key, one URL, OpenAI-compatible. The gateway handles provider
88
+ * selection, billing, moderation and cost tracking server-side, so consumers
89
+ * reference models by semantic aliases (`smooth-coding`, `smooth-judge`, …) that
90
+ * the gateway maps to whichever underlying model is currently best — upgrades
91
+ * ship server-side with no client release.
92
+ *
93
+ * `SMOOAI_GATEWAY_URL` overrides the base URL. Only an ABSENT variable takes the
94
+ * default: a set-but-empty override yields an empty base URL, matching Rust.
95
+ */
96
+ export function smooaiGatewayProvider(apiKey) {
97
+ const override = process.env.SMOOAI_GATEWAY_URL;
98
+ return {
99
+ id: 'smooai-gateway',
100
+ apiUrl: override === undefined ? 'https://llm.smoo.ai/v1' : override,
101
+ apiKey,
102
+ apiFormat: ApiFormat.OpenAiCompat,
103
+ defaultModel: 'smooth-default',
104
+ };
105
+ }
106
+ // ---------------------------------------------------------------------------
107
+ // Presets
108
+ // ---------------------------------------------------------------------------
109
+ /** A ready-made provider + routing configuration. */
110
+ export var Preset;
111
+ (function (Preset) {
112
+ /** The hosted Smoo AI gateway — the recommended default. */
113
+ Preset["SmoaiGateway"] = "SmoaiGateway";
114
+ /** Chinese frontier models via OpenRouter — the cheapest option. */
115
+ Preset["OpenRouterLowCost"] = "OpenRouterLowCost";
116
+ /** Chinese frontier models via LLM Gateway. */
117
+ Preset["LlmGatewayLowCost"] = "LlmGatewayLowCost";
118
+ /** OpenAI models. */
119
+ Preset["OpenAI"] = "OpenAI";
120
+ /** Anthropic Claude models. */
121
+ Preset["Anthropic"] = "Anthropic";
122
+ })(Preset || (Preset = {}));
123
+ /**
124
+ * Every preset. The first entry is the recommended default — `th auth login`
125
+ * shows them in this order.
126
+ */
127
+ export const ALL_PRESETS = [
128
+ {
129
+ name: 'smooai-gateway',
130
+ label: 'Smoo AI Gateway (recommended)',
131
+ description: 'Hosted LiteLLM gateway run by Smoo AI — billing, moderation, governance, 100+ models. One key, one URL, no config.',
132
+ },
133
+ {
134
+ name: 'openrouter-low-cost',
135
+ label: 'OpenRouter Low Cost',
136
+ description: 'GLM-5.1 thinking (#1 SWE-Bench Pro), MiniMax-M2.7 coding (56% SWE-Pro, 10B params), DeepSeek-V3.2 default',
137
+ },
138
+ {
139
+ name: 'llmgateway-low-cost',
140
+ label: 'LLM Gateway Low Cost',
141
+ description: 'GLM-5 thinking, MiniMax-M2.7 coding, DeepSeek-V3.2 default — unified billing, 224 models',
142
+ },
143
+ { name: 'openai', label: 'OpenAI', description: 'o3-mini thinking, GPT-4o coding — OpenAI ecosystem' },
144
+ { name: 'anthropic', label: 'Anthropic', description: 'Claude Opus thinking, Sonnet coding — highest quality' },
145
+ ];
146
+ /** Parse a preset name or alias. Returns `undefined` for unknown names. */
147
+ export function presetFromName(name) {
148
+ switch (name) {
149
+ case 'smooai-gateway':
150
+ case 'smooai':
151
+ case 'gateway':
152
+ return Preset.SmoaiGateway;
153
+ case 'openrouter-low-cost':
154
+ case 'low-cost':
155
+ return Preset.OpenRouterLowCost;
156
+ case 'llmgateway-low-cost':
157
+ case 'gateway-low-cost':
158
+ return Preset.LlmGatewayLowCost;
159
+ case 'openai':
160
+ case 'codex':
161
+ return Preset.OpenAI;
162
+ case 'anthropic':
163
+ return Preset.Anthropic;
164
+ default:
165
+ return undefined;
166
+ }
167
+ }
168
+ /** The provider id a preset requires. */
169
+ export function presetProviderId(preset) {
170
+ switch (preset) {
171
+ case Preset.SmoaiGateway:
172
+ return 'smooai-gateway';
173
+ case Preset.OpenRouterLowCost:
174
+ return 'openrouter';
175
+ case Preset.LlmGatewayLowCost:
176
+ return 'llmgateway';
177
+ case Preset.OpenAI:
178
+ return 'openai';
179
+ case Preset.Anthropic:
180
+ return 'anthropic';
181
+ }
182
+ }
183
+ // ---------------------------------------------------------------------------
184
+ // Routing
185
+ // ---------------------------------------------------------------------------
186
+ /**
187
+ * Selects which model slot a call routes through. Six semantic slots: the legacy
188
+ * `Thinking` + `Planning` split collapsed into {@link Activity.Reasoning}, and the
189
+ * legacy "default" alias is served by {@link Activity.Coding}.
190
+ */
191
+ export var Activity;
192
+ (function (Activity) {
193
+ /** The outer coding loop — the workhorse slot, which also serves the legacy "default" call path. */
194
+ Activity["Coding"] = "Coding";
195
+ /** Deep reasoning / planning / chain-of-thought. */
196
+ Activity["Reasoning"] = "Reasoning";
197
+ /** Code review, critique, adversarial checks. */
198
+ Activity["Reviewing"] = "Reviewing";
199
+ /** LLM-as-a-judge: yes/no verdicts, low latency, used by Narc guardrails and bench scoring. */
200
+ Activity["Judge"] = "Judge";
201
+ /** Context compression during long agent runs. */
202
+ Activity["Summarize"] = "Summarize";
203
+ /**
204
+ * Small, latency-sensitive utility calls: session auto-naming, short titles,
205
+ * one-liner summaries, autocomplete. Sub-second first token, short output, no
206
+ * tool use — don't pay Sonnet-plus prices to name a session.
207
+ */
208
+ Activity["Fast"] = "Fast";
209
+ })(Activity || (Activity = {}));
210
+ /** Build a slot with no fallback. */
211
+ export function modelSlot(provider, model) {
212
+ return { provider, model };
213
+ }
214
+ /** Return a copy of `slot` with `fallback` attached. */
215
+ export function withFallback(slot, fallback) {
216
+ return { ...slot, fallback };
217
+ }
218
+ /**
219
+ * The neutral, provider-agnostic routing every slot starts on: the well-known
220
+ * `openrouter` provider id with a placeholder `auto` model, so the library ships
221
+ * no opinion about a specific hosted gateway. Consumers opt into the Smoo AI
222
+ * gateway via {@link Preset.SmoaiGateway} explicitly.
223
+ */
224
+ export function defaultModelRouting() {
225
+ const slot = () => modelSlot('openrouter', 'openrouter/auto');
226
+ return { coding: slot(), reasoning: slot(), reviewing: slot(), judge: slot(), summarize: slot(), default: slot(), fast: slot() };
227
+ }
228
+ /** The slot for an activity. `Reasoning` and `Fast` fall back to `default` when absent. */
229
+ export function slotFor(routing, activity) {
230
+ switch (activity) {
231
+ case Activity.Coding:
232
+ return routing.coding;
233
+ case Activity.Reasoning:
234
+ return routing.reasoning ?? routing.default;
235
+ case Activity.Reviewing:
236
+ return routing.reviewing;
237
+ case Activity.Judge:
238
+ return routing.judge;
239
+ case Activity.Summarize:
240
+ return routing.summarize;
241
+ case Activity.Fast:
242
+ return routing.fast ?? routing.default;
243
+ }
244
+ }
245
+ function uniformRouting(slot) {
246
+ return { coding: slot, reasoning: slot, reviewing: slot, judge: slot, summarize: slot, default: slot, fast: slot };
247
+ }
248
+ const slotFromWire = (w) => ({
249
+ provider: w.provider,
250
+ model: w.model,
251
+ ...(w.fallback ? { fallback: slotFromWire(w.fallback) } : {}),
252
+ });
253
+ const slotToWire = (s) => ({
254
+ provider: s.provider,
255
+ model: s.model,
256
+ ...(s.fallback ? { fallback: slotToWire(s.fallback) } : {}),
257
+ });
258
+ // ---------------------------------------------------------------------------
259
+ // Registry
260
+ // ---------------------------------------------------------------------------
261
+ /** Registered providers plus the per-activity routing table. */
262
+ export class ProviderRegistry {
263
+ providers = new Map();
264
+ /** The per-activity table. Reassign a slot to re-point a route. */
265
+ routing = defaultModelRouting();
266
+ /**
267
+ * A registry pre-configured with a preset: registers the preset's provider
268
+ * and installs routing tuned for the preset's goals (cost, quality, latency).
269
+ */
270
+ static fromPreset(preset, apiKey) {
271
+ const registry = new ProviderRegistry();
272
+ switch (preset) {
273
+ case Preset.SmoaiGateway:
274
+ // Semantic aliases the gateway's LiteLLM config maps to whichever
275
+ // underlying model is currently best. Changing the underlying model
276
+ // is a server-side deploy — no client release needed.
277
+ registry.registerProvider(smooaiGatewayProvider(apiKey));
278
+ registry.routing = {
279
+ coding: modelSlot('smooai-gateway', 'smooth-coding'),
280
+ reasoning: modelSlot('smooai-gateway', 'smooth-reasoning'),
281
+ reviewing: modelSlot('smooai-gateway', 'smooth-reviewing'),
282
+ judge: modelSlot('smooai-gateway', 'smooth-judge'),
283
+ summarize: modelSlot('smooai-gateway', 'smooth-summarize'),
284
+ default: modelSlot('smooai-gateway', 'smooth-default'),
285
+ fast: modelSlot('smooai-gateway', 'smooth-fast'),
286
+ };
287
+ break;
288
+ case Preset.OpenRouterLowCost:
289
+ // OpenRouter uses provider-prefixed model IDs.
290
+ registry.registerProvider(openRouterProvider(apiKey));
291
+ registry.routing = {
292
+ coding: withFallback(modelSlot('openrouter', 'minimax/minimax-m2.7'), modelSlot('openrouter', 'minimax/minimax-m2.5')),
293
+ reasoning: modelSlot('openrouter', 'z-ai/glm-5.1'),
294
+ reviewing: modelSlot('openrouter', 'deepseek/deepseek-v3.2'),
295
+ judge: modelSlot('openrouter', 'google/gemini-2.5-flash'),
296
+ summarize: modelSlot('openrouter', 'deepseek/deepseek-v3.2'),
297
+ default: modelSlot('openrouter', 'deepseek/deepseek-v3.2'),
298
+ fast: modelSlot('openrouter', 'google/gemini-2.5-flash-lite'),
299
+ };
300
+ break;
301
+ case Preset.LlmGatewayLowCost:
302
+ // LLM Gateway uses bare model names.
303
+ registry.registerProvider(llmGatewayProvider(apiKey));
304
+ registry.routing = {
305
+ coding: withFallback(modelSlot('llmgateway', 'minimax-m2.7'), modelSlot('llmgateway', 'minimax-m2.5')),
306
+ reasoning: modelSlot('llmgateway', 'glm-5'),
307
+ reviewing: modelSlot('llmgateway', 'deepseek-v3.2'),
308
+ judge: modelSlot('llmgateway', 'gemini-2.5-flash'),
309
+ summarize: modelSlot('llmgateway', 'deepseek-v3.2'),
310
+ default: modelSlot('llmgateway', 'deepseek-v3.2'),
311
+ fast: modelSlot('llmgateway', 'gemini-2.5-flash-lite'),
312
+ };
313
+ break;
314
+ case Preset.OpenAI:
315
+ registry.registerProvider(openAiProvider(apiKey));
316
+ registry.routing = {
317
+ coding: modelSlot('openai', 'gpt-4o'),
318
+ reasoning: modelSlot('openai', 'o3-mini'),
319
+ reviewing: modelSlot('openai', 'gpt-4o'),
320
+ judge: modelSlot('openai', 'gpt-4o-mini'),
321
+ summarize: modelSlot('openai', 'gpt-4o-mini'),
322
+ default: modelSlot('openai', 'gpt-4o'),
323
+ fast: modelSlot('openai', 'gpt-4o-mini'),
324
+ };
325
+ break;
326
+ case Preset.Anthropic:
327
+ registry.registerProvider(anthropicProvider(apiKey));
328
+ registry.routing = {
329
+ coding: modelSlot('anthropic', 'claude-sonnet-4-20250514'),
330
+ reasoning: modelSlot('anthropic', 'claude-opus-4-20250514'),
331
+ reviewing: modelSlot('anthropic', 'claude-sonnet-4-20250514'),
332
+ judge: modelSlot('anthropic', 'claude-haiku-4-5-20251001'),
333
+ summarize: modelSlot('anthropic', 'claude-haiku-4-5-20251001'),
334
+ default: modelSlot('anthropic', 'claude-sonnet-4-20250514'),
335
+ fast: modelSlot('anthropic', 'claude-haiku-4-5-20251001'),
336
+ };
337
+ break;
338
+ }
339
+ return registry;
340
+ }
341
+ /**
342
+ * A minimal registry from `SMOOTH_API_KEY` (required), `SMOOTH_PROVIDER`
343
+ * (defaults to `openrouter`) and `SMOOTH_MODEL` (optional). Returns
344
+ * `undefined` when `SMOOTH_API_KEY` is unset — never a keyless client.
345
+ */
346
+ static fromEnv() {
347
+ const apiKey = process.env.SMOOTH_API_KEY;
348
+ if (apiKey === undefined)
349
+ return undefined;
350
+ const providerId = process.env.SMOOTH_PROVIDER || 'openrouter';
351
+ let config;
352
+ switch (providerId) {
353
+ case 'openai':
354
+ config = openAiProvider(apiKey);
355
+ break;
356
+ case 'anthropic':
357
+ config = anthropicProvider(apiKey);
358
+ break;
359
+ case 'ollama':
360
+ config = { ...ollamaProvider(), apiKey };
361
+ break;
362
+ case 'google':
363
+ config = googleProvider(apiKey);
364
+ break;
365
+ case 'kimi':
366
+ config = kimiProvider(apiKey);
367
+ break;
368
+ case 'kimi-code':
369
+ config = kimiCodeProvider(apiKey);
370
+ break;
371
+ case 'llmgateway':
372
+ config = llmGatewayProvider(apiKey);
373
+ break;
374
+ default:
375
+ config = openRouterProvider(apiKey);
376
+ }
377
+ const registry = new ProviderRegistry();
378
+ registry.registerProvider(config);
379
+ registry.routing = uniformRouting(modelSlot(providerId, process.env.SMOOTH_MODEL || config.defaultModel));
380
+ return registry;
381
+ }
382
+ /** Read a registry from a JSON file (e.g. `~/.smooth/providers.json`). */
383
+ static loadFromFile(path) {
384
+ return ProviderRegistry.fromJson(readFileSync(path, 'utf8'));
385
+ }
386
+ /** Deserialize a registry from the JSON shape {@link ProviderRegistry.toJson} writes. */
387
+ static fromJson(json) {
388
+ const file = JSON.parse(json);
389
+ const registry = new ProviderRegistry();
390
+ const w = file.routing;
391
+ registry.routing = {
392
+ coding: slotFromWire(w.coding),
393
+ // An explicit `reasoning` always wins over the legacy `thinking`.
394
+ ...(w.reasoning ?? w.thinking ? { reasoning: slotFromWire((w.reasoning ?? w.thinking)) } : {}),
395
+ reviewing: slotFromWire(w.reviewing),
396
+ judge: slotFromWire(w.judge),
397
+ summarize: slotFromWire(w.summarize),
398
+ default: slotFromWire(w.default),
399
+ ...(w.fast ? { fast: slotFromWire(w.fast) } : {}),
400
+ ...(w.planning ? { planning: slotFromWire(w.planning) } : {}),
401
+ };
402
+ for (const p of file.providers ?? []) {
403
+ registry.registerProvider({ id: p.id, apiUrl: p.api_url, apiKey: p.api_key, apiFormat: p.api_format, defaultModel: p.default_model });
404
+ }
405
+ return registry;
406
+ }
407
+ /** Add (or replace) a provider configuration. */
408
+ registerProvider(config) {
409
+ this.providers.set(config.id, config);
410
+ }
411
+ /** Drop a provider by id. */
412
+ removeProvider(id) {
413
+ this.providers.delete(id);
414
+ }
415
+ /** Look up a provider by id. */
416
+ getProvider(id) {
417
+ return this.providers.get(id);
418
+ }
419
+ /** Every registered provider id, sorted. */
420
+ listProviders() {
421
+ return [...this.providers.keys()].sort();
422
+ }
423
+ /** Point every routing slot at `providerId` using its default model. */
424
+ setDefaultProvider(providerId) {
425
+ this.routing = uniformRouting(modelSlot(providerId, this.providers.get(providerId)?.defaultModel ?? ''));
426
+ }
427
+ /** Install a custom routing table. */
428
+ withRouting(routing) {
429
+ this.routing = routing;
430
+ return this;
431
+ }
432
+ resolveSlot(slot) {
433
+ const provider = this.providers.get(slot.provider);
434
+ if (provider) {
435
+ return {
436
+ apiUrl: provider.apiUrl,
437
+ apiKey: provider.apiKey,
438
+ model: slot.model,
439
+ maxTokens: 32768,
440
+ temperature: 0.0,
441
+ apiFormat: provider.apiFormat,
442
+ };
443
+ }
444
+ if (slot.fallback)
445
+ return this.resolveSlot(slot.fallback);
446
+ throw new Error(`provider '${slot.provider}' not registered and no fallback available`);
447
+ }
448
+ /**
449
+ * Resolve the route for an activity. Throws when the slot's provider — and
450
+ * every fallback — is unregistered, rather than silently substituting some
451
+ * other provider.
452
+ */
453
+ llmConfigFor(activity) {
454
+ return this.resolveSlot(slotFor(this.routing, activity));
455
+ }
456
+ /** Resolve the wire-compat `default` slot. */
457
+ defaultLlmConfig() {
458
+ return this.resolveSlot(this.routing.default);
459
+ }
460
+ /**
461
+ * Build a gateway client for an activity's resolved route — the one line
462
+ * between "which model should this call use" and a client that speaks to it.
463
+ *
464
+ * The client is OpenAI-compatible; an {@link ApiFormat.Anthropic} provider is
465
+ * rejected rather than silently spoken to in the wrong dialect.
466
+ */
467
+ clientFor(activity) {
468
+ const config = this.llmConfigFor(activity);
469
+ if (config.apiFormat !== ApiFormat.OpenAiCompat) {
470
+ throw new Error(`activity ${activity} routes to a ${config.apiFormat} provider, which the OpenAI-compatible gateway client cannot speak`);
471
+ }
472
+ return { client: createGatewayClient({ baseURL: config.apiUrl, apiKey: config.apiKey }), config };
473
+ }
474
+ /** Serialize to the on-disk JSON shape, snake_case keys and all. */
475
+ toJson(pretty = false) {
476
+ const providers = this.listProviders().map((id) => {
477
+ const p = this.providers.get(id);
478
+ return { id: p.id, api_url: p.apiUrl, api_key: p.apiKey, api_format: p.apiFormat, default_model: p.defaultModel };
479
+ });
480
+ const r = this.routing;
481
+ const routing = {
482
+ coding: slotToWire(r.coding),
483
+ ...(r.reasoning ? { reasoning: slotToWire(r.reasoning) } : {}),
484
+ reviewing: slotToWire(r.reviewing),
485
+ judge: slotToWire(r.judge),
486
+ summarize: slotToWire(r.summarize),
487
+ default: slotToWire(r.default),
488
+ ...(r.fast ? { fast: slotToWire(r.fast) } : {}),
489
+ ...(r.planning ? { planning: slotToWire(r.planning) } : {}),
490
+ };
491
+ const file = { providers, routing };
492
+ return pretty ? JSON.stringify(file, null, 2) : JSON.stringify(file);
493
+ }
494
+ /** Write the registry as pretty-printed JSON, creating parent directories. */
495
+ saveToFile(path) {
496
+ mkdirSync(dirname(path), { recursive: true });
497
+ writeFileSync(path, this.toJson(true));
498
+ }
499
+ }
500
+ const QUIRKS_TABLE = [
501
+ ['qwen3-coder', { strictToolCallJson: true }],
502
+ ['qwen-coder', { strictToolCallJson: true }],
503
+ ];
504
+ /**
505
+ * Look up quirks by concrete upstream name. Matching is case-insensitive and
506
+ * substring-based, so minor version drift (`qwen3-coder-plus-2025-04`) still hits
507
+ * the `qwen3-coder` entry. Returns safe defaults when nothing matches.
508
+ */
509
+ export function quirksForModel(upstream) {
510
+ const lc = upstream.toLowerCase();
511
+ for (const [needle, quirks] of QUIRKS_TABLE) {
512
+ if (lc.includes(needle))
513
+ return { ...quirks };
514
+ }
515
+ return { strictToolCallJson: false };
516
+ }
517
+ /** The quirk table's canonical keys, for diagnostics. */
518
+ export function quirkKeys() {
519
+ return QUIRKS_TABLE.map(([needle]) => needle);
520
+ }
521
+ /** Every quirk entry matching an upstream name. Usually one wins; the full set is kept for tests. */
522
+ export function quirksDebugSnapshot(upstream) {
523
+ const lc = upstream.toLowerCase();
524
+ const out = {};
525
+ for (const [needle, quirks] of QUIRKS_TABLE) {
526
+ if (lc.includes(needle))
527
+ out[needle] = { ...quirks };
528
+ }
529
+ return out;
530
+ }
531
+ /**
532
+ * Derive the `/model/info` URL from a provider's OpenAI-compat `apiUrl`
533
+ * (e.g. `https://llm.smoo.ai/v1`). Stripping `/v1` is safe: `/model/info` lives
534
+ * at the gateway root in every LiteLLM deployment seen.
535
+ */
536
+ export function buildModelInfoUrl(apiUrl) {
537
+ const trimmed = apiUrl.replace(/\/+$/, '');
538
+ const base = trimmed.endsWith('/v1') ? trimmed.slice(0, -'/v1'.length) : trimmed;
539
+ return `${base}/model/info`;
540
+ }
541
+ /**
542
+ * Parse a `/model/info` response body into an alias → entry map, sorted by alias
543
+ * so diagnostics print the same order every run (Rust returns a `BTreeMap`).
544
+ *
545
+ * Throws when the body is not valid JSON or is missing the `data` array.
546
+ */
547
+ export function parseModelInfo(body) {
548
+ let doc;
549
+ try {
550
+ doc = JSON.parse(body);
551
+ }
552
+ catch (error) {
553
+ throw new Error(`parsing /model/info response: ${error instanceof Error ? error.message : String(error)}`);
554
+ }
555
+ if (!Array.isArray(doc?.data)) {
556
+ throw new Error('parsing /model/info response: missing `data` array');
557
+ }
558
+ const entries = doc.data.map((entry) => [
559
+ entry.model_name,
560
+ {
561
+ alias: entry.model_name,
562
+ ...(entry.litellm_params?.model !== undefined ? { upstream: entry.litellm_params.model } : {}),
563
+ ...(entry.model_info?.id !== undefined ? { id: entry.model_info.id } : {}),
564
+ },
565
+ ]);
566
+ entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
567
+ return new Map(entries);
568
+ }
569
+ /**
570
+ * Ask a LiteLLM gateway for its alias → upstream map.
571
+ *
572
+ * A 401 means the provider's API key is missing or rejected; either way the
573
+ * caller cannot see the mapping.
574
+ */
575
+ export async function fetchModelInfo(apiUrl, apiKey, timeoutMs = 10_000) {
576
+ const url = buildModelInfoUrl(apiUrl);
577
+ const controller = new AbortController();
578
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
579
+ try {
580
+ const response = await fetch(url, { headers: { Authorization: `Bearer ${apiKey}` }, signal: controller.signal });
581
+ const body = await response.text();
582
+ if (!response.ok) {
583
+ throw new Error(`GET ${url} returned ${response.status}: ${body}`);
584
+ }
585
+ return parseModelInfo(body);
586
+ }
587
+ finally {
588
+ clearTimeout(timer);
589
+ }
590
+ }
591
+ //# sourceMappingURL=providers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,SAAS,EAAE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UAAU,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QACjH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,OAAO,GAAG,aAAa,QAAQ,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;YAAS,CAAC;QACP,YAAY,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smooai/smooth-operator-core",
3
- "version": "1.8.6",
3
+ "version": "1.8.7",
4
4
  "description": "Native TypeScript implementation of the smooth-operator agent engine — an in-process, OpenAI-compatible agentic tool-calling loop with knowledge grounding. The TypeScript sibling of the Rust reference engine, the C# core, and the Python core.",
5
5
  "type": "module",
6
6
  "license": "MIT",