@pellux/goodvibes-sdk 0.34.0 → 0.34.2
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/contracts/artifacts/operator-contract.json +1 -1
- package/dist/events/workflows.d.ts +4 -0
- package/dist/events/workflows.d.ts.map +1 -1
- package/dist/platform/agents/message-bus-core.d.ts +11 -0
- package/dist/platform/agents/message-bus-core.d.ts.map +1 -1
- package/dist/platform/agents/message-bus-core.js +28 -21
- package/dist/platform/agents/orchestrator-runner.d.ts.map +1 -1
- package/dist/platform/agents/orchestrator-runner.js +6 -4
- package/dist/platform/agents/wrfc-config.d.ts.map +1 -1
- package/dist/platform/agents/wrfc-config.js +16 -10
- package/dist/platform/agents/wrfc-controller.d.ts +26 -0
- package/dist/platform/agents/wrfc-controller.d.ts.map +1 -1
- package/dist/platform/agents/wrfc-controller.js +134 -138
- package/dist/platform/agents/wrfc-runtime-events.d.ts +1 -0
- package/dist/platform/agents/wrfc-runtime-events.d.ts.map +1 -1
- package/dist/platform/agents/wrfc-runtime-events.js +4 -1
- package/dist/platform/automation/delivery-manager.d.ts.map +1 -1
- package/dist/platform/automation/delivery-manager.js +1 -6
- package/dist/platform/batch/manager.d.ts.map +1 -1
- package/dist/platform/batch/manager.js +1 -3
- package/dist/platform/channels/policy-manager.d.ts.map +1 -1
- package/dist/platform/channels/policy-manager.js +1 -3
- package/dist/platform/channels/reply-pipeline.d.ts.map +1 -1
- package/dist/platform/channels/reply-pipeline.js +4 -0
- package/dist/platform/config/schema-domain-core.d.ts +1 -1
- package/dist/platform/config/schema-domain-core.d.ts.map +1 -1
- package/dist/platform/config/schema-domain-core.js +12 -12
- package/dist/platform/config/schema-domain-runtime.d.ts +1 -1
- package/dist/platform/config/schema-domain-runtime.d.ts.map +1 -1
- package/dist/platform/config/schema-domain-runtime.js +19 -18
- package/dist/platform/config/schema-domain-surfaces.d.ts +1 -1
- package/dist/platform/config/schema-domain-surfaces.d.ts.map +1 -1
- package/dist/platform/config/schema-domain-surfaces.js +4 -3
- package/dist/platform/config/schema-shared.d.ts +6 -0
- package/dist/platform/config/schema-shared.d.ts.map +1 -1
- package/dist/platform/config/schema-shared.js +21 -1
- package/dist/platform/control-plane/approval-broker.d.ts.map +1 -1
- package/dist/platform/control-plane/approval-broker.js +1 -3
- package/dist/platform/control-plane/session-broker-state.d.ts.map +1 -1
- package/dist/platform/control-plane/session-broker-state.js +1 -3
- package/dist/platform/core/compaction-sections.d.ts +3 -1
- package/dist/platform/core/compaction-sections.d.ts.map +1 -1
- package/dist/platform/core/compaction-sections.js +70 -66
- package/dist/platform/core/context-compaction.d.ts.map +1 -1
- package/dist/platform/core/context-compaction.js +10 -16
- package/dist/platform/core/orchestrator-context-runtime.d.ts +2 -2
- package/dist/platform/core/orchestrator-context-runtime.d.ts.map +1 -1
- package/dist/platform/core/orchestrator-context-runtime.js +24 -21
- package/dist/platform/core/orchestrator-tool-runtime.d.ts.map +1 -1
- package/dist/platform/core/orchestrator-tool-runtime.js +2 -1
- package/dist/platform/core/session-lineage.d.ts +2 -5
- package/dist/platform/core/session-lineage.d.ts.map +1 -1
- package/dist/platform/core/session-lineage.js +4 -16
- package/dist/platform/core/wrfc-routing.d.ts.map +1 -1
- package/dist/platform/core/wrfc-routing.js +1 -3
- package/dist/platform/daemon/http/mcp-routes.d.ts.map +1 -1
- package/dist/platform/daemon/http/mcp-routes.js +1 -3
- package/dist/platform/daemon/http/openai-compatible-routes.d.ts.map +1 -1
- package/dist/platform/daemon/http/openai-compatible-routes.js +1 -3
- package/dist/platform/daemon/http/runtime-routes.d.ts.map +1 -1
- package/dist/platform/daemon/http/runtime-routes.js +1 -3
- package/dist/platform/hooks/runners/http.d.ts.map +1 -1
- package/dist/platform/hooks/runners/http.js +9 -19
- package/dist/platform/integrations/webhooks.js +2 -11
- package/dist/platform/knowledge/semantic/self-improvement.d.ts.map +1 -1
- package/dist/platform/knowledge/semantic/self-improvement.js +2 -21
- package/dist/platform/mcp/client.d.ts.map +1 -1
- package/dist/platform/mcp/client.js +1 -3
- package/dist/platform/mcp/config.d.ts.map +1 -1
- package/dist/platform/mcp/config.js +1 -3
- package/dist/platform/media/builtin-generation-providers.d.ts.map +1 -1
- package/dist/platform/media/builtin-generation-providers.js +1 -6
- package/dist/platform/providers/anthropic-compat.d.ts.map +1 -1
- package/dist/platform/providers/anthropic-compat.js +11 -131
- package/dist/platform/providers/anthropic-sdk-provider.d.ts.map +1 -1
- package/dist/platform/providers/anthropic-sdk-provider.js +8 -42
- package/dist/platform/providers/anthropic-sse-assembler.d.ts +80 -0
- package/dist/platform/providers/anthropic-sse-assembler.d.ts.map +1 -0
- package/dist/platform/providers/anthropic-sse-assembler.js +146 -0
- package/dist/platform/providers/anthropic-stream.d.ts +30 -0
- package/dist/platform/providers/anthropic-stream.d.ts.map +1 -0
- package/dist/platform/providers/anthropic-stream.js +44 -0
- package/dist/platform/providers/anthropic-vertex.d.ts.map +1 -1
- package/dist/platform/providers/anthropic-vertex.js +1 -3
- package/dist/platform/providers/anthropic.d.ts.map +1 -1
- package/dist/platform/providers/anthropic.js +15 -151
- package/dist/platform/providers/capabilities.d.ts.map +1 -1
- package/dist/platform/providers/capabilities.js +11 -7
- package/dist/platform/providers/context-discovery.d.ts.map +1 -1
- package/dist/platform/providers/context-discovery.js +9 -16
- package/dist/platform/providers/context-window-fallback.d.ts +24 -0
- package/dist/platform/providers/context-window-fallback.d.ts.map +1 -0
- package/dist/platform/providers/context-window-fallback.js +48 -0
- package/dist/platform/providers/gemini.d.ts.map +1 -1
- package/dist/platform/providers/gemini.js +3 -6
- package/dist/platform/providers/json-ttl-cache.d.ts +35 -0
- package/dist/platform/providers/json-ttl-cache.d.ts.map +1 -0
- package/dist/platform/providers/json-ttl-cache.js +52 -0
- package/dist/platform/providers/llama-cpp.d.ts.map +1 -1
- package/dist/platform/providers/llama-cpp.js +2 -23
- package/dist/platform/providers/lm-studio-helpers.d.ts +1 -1
- package/dist/platform/providers/lm-studio-helpers.d.ts.map +1 -1
- package/dist/platform/providers/lm-studio-helpers.js +5 -25
- package/dist/platform/providers/model-benchmarks.d.ts.map +1 -1
- package/dist/platform/providers/model-benchmarks.js +11 -34
- package/dist/platform/providers/model-catalog-cache.d.ts.map +1 -1
- package/dist/platform/providers/model-catalog-cache.js +15 -38
- package/dist/platform/providers/model-catalog-synthetic.d.ts.map +1 -1
- package/dist/platform/providers/model-catalog-synthetic.js +3 -2
- package/dist/platform/providers/model-catalog.d.ts.map +1 -1
- package/dist/platform/providers/model-catalog.js +3 -2
- package/dist/platform/providers/model-limits.d.ts.map +1 -1
- package/dist/platform/providers/model-limits.js +18 -42
- package/dist/platform/providers/ollama.d.ts.map +1 -1
- package/dist/platform/providers/ollama.js +3 -24
- package/dist/platform/providers/openai-codex.d.ts.map +1 -1
- package/dist/platform/providers/openai-codex.js +8 -9
- package/dist/platform/providers/openai-compat.d.ts.map +1 -1
- package/dist/platform/providers/openai-compat.js +13 -40
- package/dist/platform/providers/openai-stream-helpers.d.ts +62 -0
- package/dist/platform/providers/openai-stream-helpers.d.ts.map +1 -0
- package/dist/platform/providers/openai-stream-helpers.js +73 -0
- package/dist/platform/providers/openai.d.ts.map +1 -1
- package/dist/platform/providers/openai.js +13 -41
- package/dist/platform/providers/provider-error.d.ts +17 -0
- package/dist/platform/providers/provider-error.d.ts.map +1 -0
- package/dist/platform/providers/provider-error.js +33 -0
- package/dist/platform/providers/provider-stop-reason.d.ts +15 -0
- package/dist/platform/providers/provider-stop-reason.d.ts.map +1 -0
- package/dist/platform/providers/provider-stop-reason.js +15 -0
- package/dist/platform/providers/sse-line-buffer.d.ts +13 -0
- package/dist/platform/providers/sse-line-buffer.d.ts.map +1 -0
- package/dist/platform/providers/sse-line-buffer.js +23 -0
- package/dist/platform/providers/tool-formats.d.ts +5 -0
- package/dist/platform/providers/tool-formats.d.ts.map +1 -1
- package/dist/platform/providers/tool-formats.js +14 -0
- package/dist/platform/runtime/bootstrap-runtime-events.d.ts.map +1 -1
- package/dist/platform/runtime/bootstrap-runtime-events.js +6 -0
- package/dist/platform/runtime/bootstrap-services.d.ts.map +1 -1
- package/dist/platform/runtime/bootstrap-services.js +4 -5
- package/dist/platform/runtime/emitters/workflows.d.ts +4 -0
- package/dist/platform/runtime/emitters/workflows.d.ts.map +1 -1
- package/dist/platform/runtime/emitters/workflows.js +3 -0
- package/dist/platform/runtime/remote/distributed-runtime-store.d.ts.map +1 -1
- package/dist/platform/runtime/remote/distributed-runtime-store.js +1 -3
- package/dist/platform/runtime/retention/pruner.js +2 -5
- package/dist/platform/runtime/store/helpers/reducers/lifecycle.d.ts.map +1 -1
- package/dist/platform/runtime/store/helpers/reducers/lifecycle.js +15 -14
- package/dist/platform/runtime/store/helpers/reducers/shared.d.ts +6 -0
- package/dist/platform/runtime/store/helpers/reducers/shared.d.ts.map +1 -1
- package/dist/platform/runtime/store/helpers/reducers/shared.js +8 -1
- package/dist/platform/runtime/telemetry/exporters/queue.d.ts.map +1 -1
- package/dist/platform/runtime/telemetry/exporters/queue.js +1 -7
- package/dist/platform/runtime/transports/http-helpers.d.ts +0 -1
- package/dist/platform/runtime/transports/http-helpers.d.ts.map +1 -1
- package/dist/platform/runtime/transports/http-helpers.js +1 -3
- package/dist/platform/runtime/ui-read-model-helpers.d.ts +2 -0
- package/dist/platform/runtime/ui-read-model-helpers.d.ts.map +1 -1
- package/dist/platform/runtime/ui-read-model-helpers.js +8 -0
- package/dist/platform/runtime/ui-read-models-core.d.ts.map +1 -1
- package/dist/platform/runtime/ui-read-models-core.js +3 -5
- package/dist/platform/runtime/ui-read-models-observability-remote.d.ts.map +1 -1
- package/dist/platform/runtime/ui-read-models-observability-remote.js +2 -4
- package/dist/platform/runtime/ui-read-models-operations.d.ts.map +1 -1
- package/dist/platform/runtime/ui-read-models-operations.js +8 -26
- package/dist/platform/scheduler/scheduler.d.ts.map +1 -1
- package/dist/platform/scheduler/scheduler.js +1 -3
- package/dist/platform/tools/agent/index.d.ts +1 -0
- package/dist/platform/tools/agent/index.d.ts.map +1 -1
- package/dist/platform/tools/agent/index.js +1 -0
- package/dist/platform/tools/agent/predicates.d.ts +15 -0
- package/dist/platform/tools/agent/predicates.d.ts.map +1 -0
- package/dist/platform/tools/agent/predicates.js +15 -0
- package/dist/platform/tools/exec/runtime.d.ts.map +1 -1
- package/dist/platform/tools/exec/runtime.js +1 -7
- package/dist/platform/tools/fetch/runtime.d.ts.map +1 -1
- package/dist/platform/tools/fetch/runtime.js +9 -20
- package/dist/platform/tools/shared/process-manager.d.ts.map +1 -1
- package/dist/platform/tools/shared/process-manager.js +1 -6
- package/dist/platform/utils/concurrency.d.ts +1 -0
- package/dist/platform/utils/concurrency.d.ts.map +1 -1
- package/dist/platform/utils/concurrency.js +1 -0
- package/dist/platform/utils/error-display.d.ts +9 -0
- package/dist/platform/utils/error-display.d.ts.map +1 -1
- package/dist/platform/utils/error-display.js +11 -0
- package/dist/platform/utils/fetch-with-timeout.d.ts +22 -2
- package/dist/platform/utils/fetch-with-timeout.d.ts.map +1 -1
- package/dist/platform/utils/fetch-with-timeout.js +33 -15
- package/dist/platform/utils/record-coerce.d.ts +5 -0
- package/dist/platform/utils/record-coerce.d.ts.map +1 -1
- package/dist/platform/utils/record-coerce.js +7 -0
- package/dist/platform/utils/retry.d.ts.map +1 -1
- package/dist/platform/utils/retry.js +2 -4
- package/dist/platform/version.js +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider/model-family-aware context-window fallback.
|
|
3
|
+
*
|
|
4
|
+
* Used only when neither the live catalog (models.dev) nor the provider API
|
|
5
|
+
* reports a context window for a model — e.g. a model newer than the models.dev
|
|
6
|
+
* snapshot (the "brand-new gpt-5.5" case). A single flat default badly mis-sizes
|
|
7
|
+
* the window and drives auto-compaction to fire far too early (small default) or
|
|
8
|
+
* too late (large default, risking a provider "context length exceeded" error).
|
|
9
|
+
* Infer a sane family default from the provider and model id instead.
|
|
10
|
+
*
|
|
11
|
+
* The real window always wins whenever the catalog / OpenRouter / provider_api
|
|
12
|
+
* supplies one; this is the last line of defense, not a primary source.
|
|
13
|
+
*/
|
|
14
|
+
/** Last-resort default when neither provider nor model id is recognised. */
|
|
15
|
+
export const FALLBACK_CONTEXT_WINDOW = 128_000;
|
|
16
|
+
/**
|
|
17
|
+
* Best-effort context window (in tokens) inferred from provider + model id.
|
|
18
|
+
*
|
|
19
|
+
* Over-estimating is the dangerous direction (it risks context-overflow errors),
|
|
20
|
+
* so only known-large families get a large window; older/unknown families stay at
|
|
21
|
+
* the conservative {@link FALLBACK_CONTEXT_WINDOW}.
|
|
22
|
+
*/
|
|
23
|
+
export function inferFallbackContextWindow(provider, modelId) {
|
|
24
|
+
const p = provider.toLowerCase();
|
|
25
|
+
const id = (modelId ?? '').toLowerCase();
|
|
26
|
+
if (p.includes('google') || p.includes('gemini') || id.startsWith('gemini'))
|
|
27
|
+
return 1_000_000;
|
|
28
|
+
if (p.includes('anthropic') || id.startsWith('claude'))
|
|
29
|
+
return 200_000;
|
|
30
|
+
if (p.includes('xai') || p.includes('grok') || id.startsWith('grok'))
|
|
31
|
+
return 256_000;
|
|
32
|
+
const looksOpenAI = p.includes('openai') ||
|
|
33
|
+
id.startsWith('gpt') ||
|
|
34
|
+
id.startsWith('chatgpt') ||
|
|
35
|
+
id.startsWith('o1') ||
|
|
36
|
+
id.startsWith('o3') ||
|
|
37
|
+
id.startsWith('o4');
|
|
38
|
+
if (looksOpenAI) {
|
|
39
|
+
// gpt-5 / gpt-4.1 families are 400k; the o-series reasoning models are 200k;
|
|
40
|
+
// gpt-4o / gpt-4-turbo / gpt-4o-mini and anything unrecognised stay at 128k.
|
|
41
|
+
if (id.startsWith('gpt-5') || id.startsWith('gpt-4.1') || id.startsWith('gpt-4-1'))
|
|
42
|
+
return 400_000;
|
|
43
|
+
if (id.startsWith('o1') || id.startsWith('o3') || id.startsWith('o4'))
|
|
44
|
+
return 200_000;
|
|
45
|
+
return 128_000;
|
|
46
|
+
}
|
|
47
|
+
return FALLBACK_CONTEXT_WINDOW;
|
|
48
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/gemini.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,YAAY,EAEZ,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,gBAAgB,CAAC;AAexB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/gemini.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,YAAY,EAEZ,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,gBAAgB,CAAC;AAexB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAwB3D;;;;;GAKG;AACH,qBAAa,cAAe,YAAW,WAAW;IAChD,QAAQ,CAAC,IAAI,YAAY;IACzB,uEAAuE;IACvE,OAAO,CAAC,iBAAiB,CAA6B;IACtD,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAM;IAE/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA0B;IACzD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAsC;IAEtE,0EAA0E;IAC1E,OAAO,CAAC,iBAAiB,CAAuB;IAChD,yEAAyE;IACzE,OAAO,CAAC,iBAAiB,CAAuB;IAChD,wCAAwC;IACxC,OAAO,CAAC,mBAAmB,CAAa;IACxC,qEAAqE;IACrE,OAAO,CAAC,iBAAiB,CAAqB;gBAElC,MAAM,EAAE,MAAM,EAAE,eAAe,GAAE,IAAI,CAAC,eAAe,EAAE,YAAY,CAA0B;IAKzG,OAAO,CAAC,gBAAgB;YAWV,mBAAmB;IA2F3B,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAwMhD,KAAK,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAmD1E,eAAe,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAmC3F"}
|
|
@@ -7,6 +7,7 @@ import { fetchWithTimeout, instrumentedFetch } from '../utils/fetch-with-timeout
|
|
|
7
7
|
import { instrumentedLlmCall } from '../runtime/llm-observability.js';
|
|
8
8
|
import { toGeminiFunctionDeclarations, toGeminiContents, fromGeminiParts, } from './tool-formats.js';
|
|
9
9
|
import { summarizeError, toProviderError } from '../utils/error-display.js';
|
|
10
|
+
import { SseLineBuffer } from './sse-line-buffer.js';
|
|
10
11
|
const GEMINI_API_BASE = 'https://generativelanguage.googleapis.com/v1beta';
|
|
11
12
|
const GEMINI_CACHE_TTL_SECONDS = 3600;
|
|
12
13
|
const NOOP_CACHE_HIT_TRACKER = {
|
|
@@ -219,17 +220,13 @@ export class GeminiProvider {
|
|
|
219
220
|
phase: 'response',
|
|
220
221
|
});
|
|
221
222
|
}
|
|
222
|
-
const
|
|
223
|
-
let buffer = '';
|
|
223
|
+
const sseBuffer = new SseLineBuffer();
|
|
224
224
|
try {
|
|
225
225
|
while (true) {
|
|
226
226
|
const { done, value } = await reader.read();
|
|
227
227
|
if (done)
|
|
228
228
|
break;
|
|
229
|
-
|
|
230
|
-
const lines = buffer.split('\n');
|
|
231
|
-
buffer = lines.pop() ?? '';
|
|
232
|
-
for (const line of lines) {
|
|
229
|
+
for (const line of sseBuffer.feed(value)) {
|
|
233
230
|
if (!line.startsWith('data: '))
|
|
234
231
|
continue;
|
|
235
232
|
const data = line.slice(6).trim();
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic on-disk TTL cache helpers shared by model-limits, model-catalog-cache,
|
|
3
|
+
* and model-benchmarks.
|
|
4
|
+
*
|
|
5
|
+
* Each cache file has the same envelope shape:
|
|
6
|
+
* { version: 1, fetchedAt: number, ttlMs: number, <payload> }
|
|
7
|
+
*
|
|
8
|
+
* Only the envelope fields and the single payload key/kind differ between caches;
|
|
9
|
+
* those differences are captured by the arguments to validateTtlCacheEnvelope.
|
|
10
|
+
*/
|
|
11
|
+
/** 24-hour TTL in milliseconds. */
|
|
12
|
+
export declare const TTL_24H_MS = 86400000;
|
|
13
|
+
/** Base envelope fields shared by all on-disk TTL caches. */
|
|
14
|
+
export interface TtlCacheEnvelope {
|
|
15
|
+
version: 1;
|
|
16
|
+
fetchedAt: number;
|
|
17
|
+
ttlMs: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns true when the cache has exceeded its declared TTL.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isTtlCacheStale(cache: Pick<TtlCacheEnvelope, 'fetchedAt' | 'ttlMs'>): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Validate the shared TTL cache envelope and one payload field.
|
|
25
|
+
*
|
|
26
|
+
* @param value Raw parsed JSON value.
|
|
27
|
+
* @param payloadKey Name of the payload field (e.g. `'models'`, `'entries'`).
|
|
28
|
+
* @param payloadKind Whether the payload should be an `'object'` or `'array'`.
|
|
29
|
+
* @returns `{ cache: T }` on success, or `{ cache: null, reason }` on failure.
|
|
30
|
+
*/
|
|
31
|
+
export declare function validateTtlCacheEnvelope<T>(value: unknown, payloadKey: string, payloadKind: 'object' | 'array'): {
|
|
32
|
+
cache: T | null;
|
|
33
|
+
reason?: string;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=json-ttl-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-ttl-cache.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/json-ttl-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,mCAAmC;AACnC,eAAO,MAAM,UAAU,WAAa,CAAC;AAErC,6DAA6D;AAC7D,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,CAAC,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,gBAAgB,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,OAAO,CAE7F;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,QAAQ,GAAG,OAAO,GAC9B;IAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAuBtC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic on-disk TTL cache helpers shared by model-limits, model-catalog-cache,
|
|
3
|
+
* and model-benchmarks.
|
|
4
|
+
*
|
|
5
|
+
* Each cache file has the same envelope shape:
|
|
6
|
+
* { version: 1, fetchedAt: number, ttlMs: number, <payload> }
|
|
7
|
+
*
|
|
8
|
+
* Only the envelope fields and the single payload key/kind differ between caches;
|
|
9
|
+
* those differences are captured by the arguments to validateTtlCacheEnvelope.
|
|
10
|
+
*/
|
|
11
|
+
/** 24-hour TTL in milliseconds. */
|
|
12
|
+
export const TTL_24H_MS = 86_400_000;
|
|
13
|
+
/**
|
|
14
|
+
* Returns true when the cache has exceeded its declared TTL.
|
|
15
|
+
*/
|
|
16
|
+
export function isTtlCacheStale(cache) {
|
|
17
|
+
return Date.now() - cache.fetchedAt > cache.ttlMs;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validate the shared TTL cache envelope and one payload field.
|
|
21
|
+
*
|
|
22
|
+
* @param value Raw parsed JSON value.
|
|
23
|
+
* @param payloadKey Name of the payload field (e.g. `'models'`, `'entries'`).
|
|
24
|
+
* @param payloadKind Whether the payload should be an `'object'` or `'array'`.
|
|
25
|
+
* @returns `{ cache: T }` on success, or `{ cache: null, reason }` on failure.
|
|
26
|
+
*/
|
|
27
|
+
export function validateTtlCacheEnvelope(value, payloadKey, payloadKind) {
|
|
28
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
29
|
+
return { cache: null, reason: 'root value is not an object' };
|
|
30
|
+
}
|
|
31
|
+
const parsed = value;
|
|
32
|
+
if (parsed['version'] !== 1)
|
|
33
|
+
return { cache: null, reason: 'unsupported cache version' };
|
|
34
|
+
if (typeof parsed['fetchedAt'] !== 'number' || !Number.isFinite(parsed['fetchedAt'])) {
|
|
35
|
+
return { cache: null, reason: 'fetchedAt must be a finite number' };
|
|
36
|
+
}
|
|
37
|
+
if (typeof parsed['ttlMs'] !== 'number' || !Number.isFinite(parsed['ttlMs'])) {
|
|
38
|
+
return { cache: null, reason: 'ttlMs must be a finite number' };
|
|
39
|
+
}
|
|
40
|
+
const payload = parsed[payloadKey];
|
|
41
|
+
if (payloadKind === 'object') {
|
|
42
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
|
|
43
|
+
return { cache: null, reason: `${payloadKey} must be an object` };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
if (!Array.isArray(payload)) {
|
|
48
|
+
return { cache: null, reason: `${payloadKey} must be an array` };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return { cache: parsed };
|
|
52
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llama-cpp.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/llama-cpp.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,WAAW,EAEX,wBAAwB,EACxB,uBAAuB,EAEvB,uBAAuB,EACvB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Ac,CAAC,CAAqC;gBAEzD,IAAI,EAAE,uBAAuB;IAazC,YAAY,IAAI,OAAO;IAIjB,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAUhD,KAAK,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAY1E,eAAe,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,uBAAuB,CAAC;YAsC5E,yBAAyB;CAoGxC"}
|
|
@@ -3,7 +3,8 @@ import { instrumentedLlmCall } from '../runtime/llm-observability.js';
|
|
|
3
3
|
import { ProviderError } from '../types/errors.js';
|
|
4
4
|
import { OpenAICompatProvider } from './openai-compat.js';
|
|
5
5
|
import { mapLlamaCppStopReason } from './stop-reason-maps.js';
|
|
6
|
-
import { summarizeError
|
|
6
|
+
import { summarizeError } from '../utils/error-display.js';
|
|
7
|
+
import { getErrorStatus, normalizeProviderError } from './provider-error.js';
|
|
7
8
|
import { instrumentedFetch } from '../utils/fetch-with-timeout.js';
|
|
8
9
|
import { extractTextToolCalls, fromOpenAIToolCalls, toOpenAIMessages, toOpenAITools, } from './tool-formats.js';
|
|
9
10
|
export class LlamaCppProvider {
|
|
@@ -294,28 +295,6 @@ async function buildHttpError(prefix, response, provider, operation, phase) {
|
|
|
294
295
|
phase,
|
|
295
296
|
});
|
|
296
297
|
}
|
|
297
|
-
function normalizeProviderError(err, provider, operation, phase = 'request') {
|
|
298
|
-
const status = getErrorStatus(err);
|
|
299
|
-
return toProviderError(err, {
|
|
300
|
-
...(status !== undefined ? { statusCode: status } : {}),
|
|
301
|
-
provider,
|
|
302
|
-
operation,
|
|
303
|
-
phase,
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
function getErrorStatus(err) {
|
|
307
|
-
if (err && typeof err === 'object') {
|
|
308
|
-
const record = err;
|
|
309
|
-
if (typeof record.status === 'number')
|
|
310
|
-
return record.status;
|
|
311
|
-
if (typeof record.statusCode === 'number')
|
|
312
|
-
return record.statusCode;
|
|
313
|
-
}
|
|
314
|
-
return undefined;
|
|
315
|
-
}
|
|
316
|
-
function getErrorMessage(err) {
|
|
317
|
-
return summarizeError(err);
|
|
318
|
-
}
|
|
319
298
|
function toRecord(value) {
|
|
320
299
|
return value && typeof value === 'object' ? value : {};
|
|
321
300
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ProviderError } from '../types/errors.js';
|
|
2
2
|
import type { ToolDefinition } from '../types/tools.js';
|
|
3
|
+
export { normalizeProviderError } from './provider-error.js';
|
|
3
4
|
import type { ChatRequest, ContentPart, ProviderMessage } from './interface.js';
|
|
4
5
|
export type ResponsesInputItem = {
|
|
5
6
|
role: 'user';
|
|
@@ -82,5 +83,4 @@ export declare function makeTranscriptKey(model: string, systemPrompt: string |
|
|
|
82
83
|
export declare function toRecord(value: unknown): Record<string, unknown>;
|
|
83
84
|
export declare function shouldFallbackFromNative(err: unknown): boolean;
|
|
84
85
|
export declare function shouldFallbackFromResponses(err: unknown): boolean;
|
|
85
|
-
export declare function normalizeProviderError(err: unknown, provider: string, operation: string, phase?: string): ProviderError;
|
|
86
86
|
//# sourceMappingURL=lm-studio-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lm-studio-helpers.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/lm-studio-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAY,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"lm-studio-helpers.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/lm-studio-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAY,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGlE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAq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,CAAC,CAwBxB;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,QAAQ,EAAE,eAAe,EAAE,GAC1B,MAAM,CAMR;AAUD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEhE;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAM9D;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKjE"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
2
|
import { ProviderError } from '../types/errors.js';
|
|
3
|
-
import { summarizeError
|
|
3
|
+
import { summarizeError } from '../utils/error-display.js';
|
|
4
|
+
import { getErrorStatus } from './provider-error.js';
|
|
5
|
+
export { normalizeProviderError } from './provider-error.js';
|
|
4
6
|
export function createResponsesClient(baseURL, apiKey, defaultHeaders) {
|
|
5
7
|
const client = new OpenAI({
|
|
6
8
|
apiKey,
|
|
@@ -222,7 +224,7 @@ export function toRecord(value) {
|
|
|
222
224
|
}
|
|
223
225
|
export function shouldFallbackFromNative(err) {
|
|
224
226
|
const status = getErrorStatus(err);
|
|
225
|
-
const message =
|
|
227
|
+
const message = summarizeError(err);
|
|
226
228
|
if (status === 404 || status === 405 || status === 501)
|
|
227
229
|
return true;
|
|
228
230
|
if (status === 400 && /previous_response_id|response_id/i.test(message))
|
|
@@ -231,30 +233,8 @@ export function shouldFallbackFromNative(err) {
|
|
|
231
233
|
}
|
|
232
234
|
export function shouldFallbackFromResponses(err) {
|
|
233
235
|
const status = getErrorStatus(err);
|
|
234
|
-
const message =
|
|
236
|
+
const message = summarizeError(err);
|
|
235
237
|
if (status === 404 || status === 405 || status === 501)
|
|
236
238
|
return true;
|
|
237
239
|
return /not implemented|unsupported|unknown endpoint/i.test(message);
|
|
238
240
|
}
|
|
239
|
-
function getErrorStatus(err) {
|
|
240
|
-
if (err && typeof err === 'object') {
|
|
241
|
-
const record = err;
|
|
242
|
-
if (typeof record.status === 'number')
|
|
243
|
-
return record.status;
|
|
244
|
-
if (typeof record.statusCode === 'number')
|
|
245
|
-
return record.statusCode;
|
|
246
|
-
}
|
|
247
|
-
return undefined;
|
|
248
|
-
}
|
|
249
|
-
function getErrorMessage(err) {
|
|
250
|
-
return summarizeError(err);
|
|
251
|
-
}
|
|
252
|
-
export function normalizeProviderError(err, provider, operation, phase = 'request') {
|
|
253
|
-
const status = getErrorStatus(err);
|
|
254
|
-
return toProviderError(err, {
|
|
255
|
-
...(status !== undefined ? { statusCode: status } : {}),
|
|
256
|
-
provider,
|
|
257
|
-
operation,
|
|
258
|
-
phase,
|
|
259
|
-
});
|
|
260
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-benchmarks.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/model-benchmarks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model-benchmarks.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/model-benchmarks.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,eAAe,CAAC;CAC7B;AAED,MAAM,MAAM,WAAW,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AA8ChD,eAAO,MAAM,gBAAgB,MAAO,CAAC;AACrC,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,eAAO,MAAM,gBAAgB,MAAO,CAAC;AAoErC,wBAAgB,cAAc,CAAC,UAAU,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAOzE;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,eAAe,GAAG,WAAW,CAIvE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAKlE;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,SAAS,CAA4C;IAC7D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAyB;gBAE9C,OAAO,EAAE,qBAAqB;IAI1C,YAAY,IAAI,MAAM;IAItB,OAAO,CAAC,UAAU;IAIlB,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAO7C,cAAc,IAAI,IAAI;IAUhB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAmBxC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAgE5D,uBAAuB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;YAW9B,eAAe;IAU7B,OAAO,CAAC,SAAS;IAuBjB,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -2,10 +2,10 @@ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { logger } from '../utils/logger.js';
|
|
4
4
|
import { summarizeError } from '../utils/error-display.js';
|
|
5
|
-
import {
|
|
5
|
+
import { TTL_24H_MS, isTtlCacheStale, validateTtlCacheEnvelope } from './json-ttl-cache.js';
|
|
6
|
+
import { instrumentedFetch, fetchWithTimeout } from '../utils/fetch-with-timeout.js';
|
|
6
7
|
const ZEROEVAL_URL = 'https://api.zeroeval.com/leaderboard/models/full?justCanonicals=true';
|
|
7
8
|
const FETCH_TIMEOUT_MS = 20_000;
|
|
8
|
-
const CACHE_TTL_MS = 86_400_000;
|
|
9
9
|
export const S_TIER_THRESHOLD = 0.80;
|
|
10
10
|
export const A_TIER_THRESHOLD = 0.65;
|
|
11
11
|
export const B_TIER_THRESHOLD = 0.50;
|
|
@@ -72,21 +72,7 @@ function buildNameIndex(entries) {
|
|
|
72
72
|
return index;
|
|
73
73
|
}
|
|
74
74
|
function validateBenchmarksCache(value) {
|
|
75
|
-
|
|
76
|
-
return { cache: null, reason: 'root value is not an object' };
|
|
77
|
-
}
|
|
78
|
-
const parsed = value;
|
|
79
|
-
if (parsed.version !== 1)
|
|
80
|
-
return { cache: null, reason: 'unsupported cache version' };
|
|
81
|
-
if (typeof parsed.fetchedAt !== 'number' || !Number.isFinite(parsed.fetchedAt)) {
|
|
82
|
-
return { cache: null, reason: 'fetchedAt must be a finite number' };
|
|
83
|
-
}
|
|
84
|
-
if (typeof parsed.ttlMs !== 'number' || !Number.isFinite(parsed.ttlMs)) {
|
|
85
|
-
return { cache: null, reason: 'ttlMs must be a finite number' };
|
|
86
|
-
}
|
|
87
|
-
if (!Array.isArray(parsed.entries))
|
|
88
|
-
return { cache: null, reason: 'entries must be an array' };
|
|
89
|
-
return { cache: parsed };
|
|
75
|
+
return validateTtlCacheEnvelope(value, 'entries', 'array');
|
|
90
76
|
}
|
|
91
77
|
export function compositeScore(benchmarks) {
|
|
92
78
|
let total = 0;
|
|
@@ -158,7 +144,7 @@ export class BenchmarkStore {
|
|
|
158
144
|
const next = {
|
|
159
145
|
version: 1,
|
|
160
146
|
fetchedAt: Date.now(),
|
|
161
|
-
ttlMs:
|
|
147
|
+
ttlMs: TTL_24H_MS,
|
|
162
148
|
entries,
|
|
163
149
|
};
|
|
164
150
|
this.saveCache(next);
|
|
@@ -236,22 +222,13 @@ export class BenchmarkStore {
|
|
|
236
222
|
.map((entry) => entry.id);
|
|
237
223
|
}
|
|
238
224
|
async fetchBenchmarks() {
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
signal: controller.signal,
|
|
245
|
-
headers: { Accept: 'application/json' },
|
|
246
|
-
});
|
|
247
|
-
if (!response.ok) {
|
|
248
|
-
throw new Error(`ZeroEval API returned ${response.status} ${response.statusText}`);
|
|
249
|
-
}
|
|
250
|
-
return parseEntries(await response.json());
|
|
251
|
-
}
|
|
252
|
-
finally {
|
|
253
|
-
clearTimeout(timer);
|
|
225
|
+
const response = await fetchWithTimeout(ZEROEVAL_URL, {
|
|
226
|
+
headers: { Accept: 'application/json' },
|
|
227
|
+
}, FETCH_TIMEOUT_MS, instrumentedFetch);
|
|
228
|
+
if (!response.ok) {
|
|
229
|
+
throw new Error(`ZeroEval API returned ${response.status} ${response.statusText}`);
|
|
254
230
|
}
|
|
231
|
+
return parseEntries(await response.json());
|
|
255
232
|
}
|
|
256
233
|
loadCache() {
|
|
257
234
|
try {
|
|
@@ -288,6 +265,6 @@ export class BenchmarkStore {
|
|
|
288
265
|
}
|
|
289
266
|
}
|
|
290
267
|
isCacheStale(cache) {
|
|
291
|
-
return
|
|
268
|
+
return isTtlCacheStale(cache);
|
|
292
269
|
}
|
|
293
270
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-catalog-cache.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/model-catalog-cache.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"model-catalog-cache.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/model-catalog-cache.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAkBvD,UAAU,gBAAgB;IACxB,OAAO,EAAE,CAAC,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB;AA6BD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE1D;AAsHD,iBAAS,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAmBpE;AAED,iBAAS,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAc1F;AAED,iBAAS,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAE7D;AAED;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAa5D;AAED,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,GACpB,CAAC"}
|
|
@@ -2,10 +2,10 @@ import fs from 'node:fs';
|
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { logger } from '../utils/logger.js';
|
|
4
4
|
import { summarizeError } from '../utils/error-display.js';
|
|
5
|
-
import {
|
|
5
|
+
import { TTL_24H_MS, isTtlCacheStale, validateTtlCacheEnvelope } from './json-ttl-cache.js';
|
|
6
|
+
import { instrumentedFetch, fetchWithTimeout } from '../utils/fetch-with-timeout.js';
|
|
6
7
|
const MODELS_DEV_URL = 'https://models.dev/api.json';
|
|
7
8
|
const CATALOG_FETCH_TIMEOUT_MS = 30_000;
|
|
8
|
-
const CATALOG_TTL_MS = 86_400_000; // 24 hours
|
|
9
9
|
export function getCatalogCachePath(cacheDir) {
|
|
10
10
|
return join(cacheDir, 'model-catalog.json');
|
|
11
11
|
}
|
|
@@ -78,7 +78,7 @@ function transformModelsDevResponse(json) {
|
|
|
78
78
|
const supportsReasoning = modelData.reasoning === true;
|
|
79
79
|
const inputCost = typeof cost?.input === 'number' ? cost.input : 0;
|
|
80
80
|
const outputCost = typeof cost?.output === 'number' ? cost.output : 0;
|
|
81
|
-
const contextWindow = typeof limit?.context === 'number' ? limit.context : undefined;
|
|
81
|
+
const contextWindow = typeof limit?.context === 'number' && limit.context > 0 ? limit.context : undefined;
|
|
82
82
|
let tier;
|
|
83
83
|
if (providerCategory === 'subscription') {
|
|
84
84
|
tier = 'subscription';
|
|
@@ -115,21 +115,7 @@ function transformModelsDevResponse(json) {
|
|
|
115
115
|
return models;
|
|
116
116
|
}
|
|
117
117
|
function validateCatalogCache(value) {
|
|
118
|
-
|
|
119
|
-
return { cache: null, reason: 'root value is not an object' };
|
|
120
|
-
}
|
|
121
|
-
const parsed = value;
|
|
122
|
-
if (parsed.version !== 1)
|
|
123
|
-
return { cache: null, reason: 'unsupported cache version' };
|
|
124
|
-
if (typeof parsed.fetchedAt !== 'number' || !Number.isFinite(parsed.fetchedAt)) {
|
|
125
|
-
return { cache: null, reason: 'fetchedAt must be a finite number' };
|
|
126
|
-
}
|
|
127
|
-
if (typeof parsed.ttlMs !== 'number' || !Number.isFinite(parsed.ttlMs)) {
|
|
128
|
-
return { cache: null, reason: 'ttlMs must be a finite number' };
|
|
129
|
-
}
|
|
130
|
-
if (!Array.isArray(parsed.models))
|
|
131
|
-
return { cache: null, reason: 'models must be an array' };
|
|
132
|
-
return { cache: parsed };
|
|
118
|
+
return validateTtlCacheEnvelope(value, 'models', 'array');
|
|
133
119
|
}
|
|
134
120
|
function loadCatalogCache(cachePath) {
|
|
135
121
|
try {
|
|
@@ -159,7 +145,7 @@ function saveCatalogCache(models, cachePath, tmpPath) {
|
|
|
159
145
|
const payload = {
|
|
160
146
|
version: 1,
|
|
161
147
|
fetchedAt: Date.now(),
|
|
162
|
-
ttlMs:
|
|
148
|
+
ttlMs: TTL_24H_MS,
|
|
163
149
|
models,
|
|
164
150
|
};
|
|
165
151
|
fs.writeFileSync(tmpPath, JSON.stringify(payload, null, 2), 'utf-8');
|
|
@@ -170,31 +156,22 @@ function saveCatalogCache(models, cachePath, tmpPath) {
|
|
|
170
156
|
}
|
|
171
157
|
}
|
|
172
158
|
function isCatalogCacheStale(cache) {
|
|
173
|
-
return
|
|
159
|
+
return isTtlCacheStale(cache);
|
|
174
160
|
}
|
|
175
161
|
/**
|
|
176
162
|
* Fetch models.dev/api.json and parse into CatalogModel[].
|
|
177
163
|
* Uses a 30-second timeout.
|
|
178
164
|
*/
|
|
179
165
|
export async function fetchCatalog() {
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
signal: controller.signal,
|
|
186
|
-
headers: { Accept: 'application/json' },
|
|
187
|
-
});
|
|
188
|
-
if (!response.ok) {
|
|
189
|
-
throw new Error(`models.dev API returned ${response.status} ${response.statusText}`);
|
|
190
|
-
}
|
|
191
|
-
const json = await response.json();
|
|
192
|
-
const models = transformModelsDevResponse(json);
|
|
193
|
-
logger.debug('[model-catalog] Fetched models from models.dev', { count: models.length });
|
|
194
|
-
return models;
|
|
195
|
-
}
|
|
196
|
-
finally {
|
|
197
|
-
clearTimeout(timer);
|
|
166
|
+
const response = await fetchWithTimeout(MODELS_DEV_URL, {
|
|
167
|
+
headers: { Accept: 'application/json' },
|
|
168
|
+
}, CATALOG_FETCH_TIMEOUT_MS, instrumentedFetch);
|
|
169
|
+
if (!response.ok) {
|
|
170
|
+
throw new Error(`models.dev API returned ${response.status} ${response.statusText}`);
|
|
198
171
|
}
|
|
172
|
+
const json = await response.json();
|
|
173
|
+
const models = transformModelsDevResponse(json);
|
|
174
|
+
logger.debug('[model-catalog] Fetched models from models.dev', { count: models.length });
|
|
175
|
+
return models;
|
|
199
176
|
}
|
|
200
177
|
export { loadCatalogCache, saveCatalogCache, isCatalogCacheStale, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-catalog-synthetic.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/model-catalog-synthetic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model-catalog-synthetic.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/model-catalog-synthetic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAoB,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEtF,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE;QACZ,WAAW,EAAE,OAAO,CAAC;QACrB,WAAW,EAAE,OAAO,CAAC;QACrB,SAAS,EAAE,OAAO,CAAC;QACnB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IACF,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,uBAAuB,GAAG,SAAS,CAAC;IAC9D,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,cAAc,CAAC;IACvD,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACxC;AAED,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,aAAa,CAAC;IACpB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAID,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AASD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMvD;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,cAAc,EAAE,CAgF/F;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,SAAS,cAAc,EAAE,EAC1C,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,cAAc,GAAG,SAAS,GAC/D,kBAAkB,GAAG,IAAI,CAoB3B;AAED,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,SAAS,cAAc,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAEnG;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,SAAS,YAAY,EAAE,EAC/B,eAAe,EAAE,SAAS,cAAc,EAAE,GACzC,sBAAsB,EAAE,CAoC1B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { logger } from '../utils/logger.js';
|
|
2
|
+
import { inferFallbackContextWindow } from './context-window-fallback.js';
|
|
2
3
|
import { compositeScore } from './model-benchmarks.js';
|
|
3
4
|
const MAX_FAMILY_UNIQUE_NAMES = 20;
|
|
4
5
|
export function nameToSlug(name) {
|
|
@@ -127,7 +128,7 @@ export function getSyntheticModelDefinitions(models, canonicalModels) {
|
|
|
127
128
|
const catalogMatch = models.find((model) => canonical.backends.some((backend) => backend.modelId === model.id));
|
|
128
129
|
const displayName = catalogMatch?.name ?? canonical.id;
|
|
129
130
|
const hasReasoning = catalogMatch?.reasoning === true;
|
|
130
|
-
const hasCatalogContextWindow = bestBackend?.contextWindow != null;
|
|
131
|
+
const hasCatalogContextWindow = bestBackend?.contextWindow != null && bestBackend.contextWindow > 0;
|
|
131
132
|
return {
|
|
132
133
|
id: canonical.id,
|
|
133
134
|
provider: 'synthetic',
|
|
@@ -140,7 +141,7 @@ export function getSyntheticModelDefinitions(models, canonicalModels) {
|
|
|
140
141
|
reasoning: hasReasoning,
|
|
141
142
|
multimodal: false,
|
|
142
143
|
},
|
|
143
|
-
contextWindow: hasCatalogContextWindow ? bestBackend.contextWindow :
|
|
144
|
+
contextWindow: hasCatalogContextWindow ? bestBackend.contextWindow : inferFallbackContextWindow('synthetic', canonical.id),
|
|
144
145
|
...(!hasCatalogContextWindow ? { contextWindowProvenance: 'fallback' } : {}),
|
|
145
146
|
selectable: true,
|
|
146
147
|
tier: canonical.tier === 'free' ? 'free' : canonical.tier === 'subscription' ? 'subscription' : 'standard',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-catalog.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/model-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAsB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"model-catalog.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/model-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAsB,MAAM,8BAA8B,CAAC;AAI/F,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,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0BAA0B,CAAC;AAClC,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,qBAAqB,EACrB,UAAU,EACV,kBAAkB,GACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,kCAAkC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { logger } from '../utils/logger.js';
|
|
2
|
+
import { inferFallbackContextWindow } from './context-window-fallback.js';
|
|
2
3
|
export function getCostFromPricingCatalog(modelId, catalog, modelLimitsService, opts = {}) {
|
|
3
4
|
if (modelId.endsWith(':free')) {
|
|
4
5
|
return { input: 0, output: 0 };
|
|
@@ -93,7 +94,7 @@ export function getCatalogModelDefinitionsFrom(models) {
|
|
|
93
94
|
const isAnthropic = providerLower.includes('anthropic');
|
|
94
95
|
const isOpenAI = providerLower.includes('openai');
|
|
95
96
|
const hasReasoning = model.reasoning === true || isAnthropic || isOpenAI || isGoogle;
|
|
96
|
-
const hasCatalogContextWindow = model.contextWindow != null;
|
|
97
|
+
const hasCatalogContextWindow = model.contextWindow != null && model.contextWindow > 0;
|
|
97
98
|
return {
|
|
98
99
|
id: model.id,
|
|
99
100
|
provider: model.providerId,
|
|
@@ -108,7 +109,7 @@ export function getCatalogModelDefinitionsFrom(models) {
|
|
|
108
109
|
},
|
|
109
110
|
contextWindow: hasCatalogContextWindow
|
|
110
111
|
? model.contextWindow
|
|
111
|
-
: (
|
|
112
|
+
: inferFallbackContextWindow(model.provider, model.id),
|
|
112
113
|
...(!hasCatalogContextWindow ? { contextWindowProvenance: 'fallback' } : {}),
|
|
113
114
|
selectable: true,
|
|
114
115
|
tier: model.tier === 'subscription' ? 'subscription' : isFree ? 'free' : model.pricing.input >= 3 ? 'premium' : 'standard',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-limits.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/model-limits.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AA6ClE,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEhE;
|
|
1
|
+
{"version":3,"file":"model-limits.d.ts","sourceRoot":"","sources":["../../../src/platform/providers/model-limits.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AA6ClE,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEhE;AA6GD,qBAAa,kBAAkB;IAIjB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,WAAW,CAAiD;gBAEvC,OAAO,EAAE,yBAAyB;IAE/D,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,kBAAkB;IA4B1B,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAWpG,sBAAsB,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ,CAAC,WAAW,CAAC;IAIxE,wBAAwB,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM;IAc3D,6BAA6B,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM;IAK1E,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAiChC,IAAI,IAAI,IAAI;CASb"}
|