maka-agent 0.2.0-dev.22.20260905 → 0.2.0-dev.24.20260907
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/acp/maka-acp-agent.js +2 -1
- package/dist/acp/session-configuration.js +143 -0
- package/dist/acp/session-registry.js +90 -4
- package/dist/cli-core.js +2 -0
- package/dist/pi-transcript.js +5 -12
- package/dist/pi-tui-runner.js +74 -4
- package/dist/runtime-host-cli-context.js +167 -78
- package/dist/runtime-host-cli-installation.js +8 -2
- package/dist/runtime-host-cli.js +31 -1
- package/dist/runtime-host-handoff-surface.js +81 -0
- package/dist/runtime-host-installed-update-bootstrap.js +13 -0
- package/dist/runtime-host-installed-update-coordinator.js +33 -0
- package/dist/runtime-host-lifecycle-transaction.js +9 -1
- package/dist/runtime-host-local-handoff.js +37 -4
- package/dist/runtime-host-local-managed-activation.js +84 -0
- package/dist/runtime-host-local-source-retirement.js +18 -2
- package/dist/runtime-host-managed-lifecycle-manager.js +1 -0
- package/dist/runtime-host-operator-retirement.js +50 -0
- package/dist/runtime-host-service-manager.js +3 -0
- package/dist/runtime-host-session-driver.js +4 -25
- package/dist/runtime-host-session-update.js +62 -0
- package/dist/runtime-host-tui-command.js +38 -73
- package/dist/runtime-host-tui-context.js +1 -0
- package/dist/runtime-host-tui-owner.js +226 -0
- package/dist/tui-copy-catalog.js +140 -3
- package/dist/tui-host-owner-copy.js +24 -0
- package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/bot-events.js +18 -63
- package/node_modules/@maka/core/dist/canonical-runtime-event.js +3 -1
- package/node_modules/@maka/core/dist/model-call-attempt.js +0 -82
- package/node_modules/@maka/core/dist/model-call-usage-projection.js +0 -186
- package/node_modules/@maka/core/dist/model-failure.js +40 -0
- package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -4
- package/node_modules/@maka/core/dist/model-metadata.js +3 -3
- package/node_modules/@maka/core/dist/model-web-search.js +5 -4
- package/node_modules/@maka/core/dist/provider-registry.js +45 -4
- package/node_modules/@maka/core/dist/record-schema.js +22 -2
- package/node_modules/@maka/core/dist/redaction.js +41 -58
- package/node_modules/@maka/core/dist/runtime-boundary.js +31 -11
- package/node_modules/@maka/core/dist/runtime-event.js +37 -6
- package/node_modules/@maka/core/dist/runtime-handoff.js +98 -0
- package/node_modules/@maka/core/dist/runtime-invocation.js +1 -1
- package/node_modules/@maka/core/dist/runtime-logical-execution.js +112 -0
- package/node_modules/@maka/core/dist/session-trace.js +5 -1
- package/node_modules/@maka/core/dist/session.js +54 -52
- package/node_modules/@maka/core/dist/slash-command-catalog.js +2 -0
- package/node_modules/@maka/core/dist/tool-result-archive-evidence.js +20 -0
- package/node_modules/@maka/core/dist/usage-ledger-merge.js +7 -9
- package/node_modules/@maka/core/dist/usage-record-schema.js +26 -35
- package/node_modules/@maka/core/dist/workhub-creation-intent.js +34 -20
- package/node_modules/@maka/core/package.json +4 -0
- package/node_modules/@maka/eval/harbor/egress-proxy/entrypoint.sh +2 -1
- package/node_modules/@maka/mcp/dist/index.js +131 -1
- package/node_modules/@maka/runtime/dist/agent-run.js +272 -105
- package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +13 -5
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +109 -34
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +155 -134
- package/node_modules/@maka/runtime/dist/bots/base-adapter.js +17 -0
- package/node_modules/@maka/runtime/dist/bots/bot-test.js +38 -22
- package/node_modules/@maka/runtime/dist/bots/dingtalk-bridge.js +7 -5
- package/node_modules/@maka/runtime/dist/bots/discord-bridge.js +4 -4
- package/node_modules/@maka/runtime/dist/bots/feishu-bridge.js +4 -5
- package/node_modules/@maka/runtime/dist/bots/qq-bridge.js +6 -4
- package/node_modules/@maka/runtime/dist/bots/slack-bridge.js +3 -4
- package/node_modules/@maka/runtime/dist/bots/telegram-bridge.js +4 -5
- package/node_modules/@maka/runtime/dist/bots/wechat-bridge.js +17 -19
- package/node_modules/@maka/runtime/dist/bots/wecom-bridge.js +5 -6
- package/node_modules/@maka/runtime/dist/bots/ws-bridge-base.js +2 -3
- package/node_modules/@maka/runtime/dist/context-budget.js +14 -9
- package/node_modules/@maka/runtime/dist/conversation-copy.js +5 -4
- package/node_modules/@maka/runtime/dist/goal-continuation.js +36 -4
- package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +18 -9
- package/node_modules/@maka/runtime/dist/history-compact-summarizer.js +30 -22
- package/node_modules/@maka/runtime/dist/history-compaction.js +29 -4
- package/node_modules/@maka/runtime/dist/ledger-tool-result-archive-reader.js +106 -0
- package/node_modules/@maka/runtime/dist/message-authority.js +9 -0
- package/node_modules/@maka/runtime/dist/model-adapter.js +19 -98
- package/node_modules/@maka/runtime/dist/model-factory.js +19 -81
- package/node_modules/@maka/runtime/dist/model-fetcher.js +7 -0
- package/node_modules/@maka/runtime/dist/model-runtime.js +85 -111
- package/node_modules/@maka/runtime/dist/native-web-search-tool.js +2 -1
- package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +2 -2
- package/node_modules/@maka/runtime/dist/opencode-session-header.js +4 -2
- package/node_modules/@maka/runtime/dist/provider-error-classification.js +84 -123
- package/node_modules/@maka/runtime/dist/provider-request-telemetry.js +68 -108
- package/node_modules/@maka/runtime/dist/run-handoff-gate.js +97 -0
- package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +82 -54
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +117 -159
- package/node_modules/@maka/runtime/dist/runtime-kernel.js +150 -112
- package/node_modules/@maka/runtime/dist/runtime-ledger-repair.js +160 -79
- package/node_modules/@maka/runtime/dist/runtime-read-model.js +30 -89
- package/node_modules/@maka/runtime/dist/runtime-resume.js +80 -4
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +5 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +171 -288
- package/node_modules/@maka/runtime/dist/session-projection-helpers.js +0 -27
- package/node_modules/@maka/runtime/dist/session-trace-projection.js +3 -30
- package/node_modules/@maka/runtime/dist/subscription-model-fetch.js +3 -4
- package/node_modules/@maka/runtime/dist/test-connection.js +16 -16
- package/node_modules/@maka/runtime/dist/tool-result-archive-encoding.js +38 -0
- package/node_modules/@maka/runtime/dist/tool-runtime.js +3 -61
- package/node_modules/@maka/runtime/package.json +1 -0
- package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +35 -0
- package/node_modules/@maka/runtime-host/dist/candidate-entry.js +4 -1
- package/node_modules/@maka/runtime-host/dist/client/connect-or-spawn.js +9 -1
- package/node_modules/@maka/runtime-host/dist/client/connection.js +3 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +156 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +273 -0
- package/node_modules/@maka/runtime-host/dist/client/host-retirement.js +26 -5
- package/node_modules/@maka/runtime-host/dist/client/index.js +3 -1
- package/node_modules/@maka/runtime-host/dist/client/launcher.js +3 -0
- package/node_modules/@maka/runtime-host/dist/client/peer-client.js +13 -0
- package/node_modules/@maka/runtime-host/dist/client/registered-host-termination.js +0 -59
- package/node_modules/@maka/runtime-host/dist/client/remote-compatibility-error.js +2 -0
- package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +27 -5
- package/node_modules/@maka/runtime-host/dist/operator/index.js +2 -1
- package/node_modules/@maka/runtime-host/dist/operator/retirement-cancellation.js +20 -0
- package/node_modules/@maka/runtime-host/dist/peer-mesh/node.js +28 -16
- package/node_modules/@maka/runtime-host/dist/protocol/external-session.js +4 -0
- package/node_modules/@maka/runtime-host/dist/protocol/host-status.js +29 -12
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +37 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +2 -0
- package/node_modules/@maka/runtime-host/dist/protocol/session-collaboration.js +28 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +40 -20
- package/node_modules/@maka/runtime-host/dist/protocol/session-transcript.js +0 -5
- package/node_modules/@maka/runtime-host/dist/protocol/session-turns.js +29 -58
- package/node_modules/@maka/runtime-host/dist/protocol/turn.js +11 -1
- package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +33 -0
- package/node_modules/@maka/runtime-host/dist/server/access-authority.js +26 -1
- package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +6 -1
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +19 -4
- package/node_modules/@maka/runtime-host/dist/server/canonical-usage-reader.js +24 -11
- package/node_modules/@maka/runtime-host/dist/server/connection-session.js +7 -6
- package/node_modules/@maka/runtime-host/dist/server/daily-review-coordinator.js +7 -4
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +168 -28
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +5 -5
- package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +3 -2
- package/node_modules/@maka/runtime-host/dist/server/external-session-coordinator.js +6 -3
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +40 -1
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +108 -23
- package/node_modules/@maka/runtime-host/dist/server/host-residency-registry.js +13 -7
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-admission-registry.js +3 -1
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +124 -62
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +85 -8
- package/node_modules/@maka/runtime-host/dist/server/root-admission-owner.js +7 -0
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +344 -71
- package/node_modules/@maka/runtime-host/dist/server/scheduled-task-coordinator.js +37 -2
- package/node_modules/@maka/runtime-host/dist/server/serial-outbound-writer.js +45 -3
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +201 -12
- package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +87 -25
- package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +8 -55
- package/node_modules/@maka/runtime-host/dist/server/session-sidecar-purge.js +1 -16
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-pager.js +0 -1
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +460 -70
- package/node_modules/@maka/runtime-host/dist/server/shared-session-transcript.js +1 -1
- package/node_modules/@maka/runtime-host/dist/server/storage-maintenance.js +109 -0
- package/node_modules/@maka/runtime-host/dist/server/usage-pricing-coordinator.js +4 -11
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +44 -15
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +6 -2
- package/node_modules/@maka/storage/dist/agent-run-store.js +44 -0
- package/node_modules/@maka/storage/dist/artifact-store.js +21 -10
- package/node_modules/@maka/storage/dist/artifact-stores.js +1 -1
- package/node_modules/@maka/storage/dist/claude-code-session-adapter.js +0 -4
- package/node_modules/@maka/storage/dist/codex-session-adapter.js +0 -2
- package/node_modules/@maka/storage/dist/context-offload-snapshot.js +325 -0
- package/node_modules/@maka/storage/dist/conversation-operational-state.js +4 -0
- package/node_modules/@maka/storage/dist/execution-stores.js +11 -7
- package/node_modules/@maka/storage/dist/file-session-repository.js +1012 -0
- package/node_modules/@maka/storage/dist/model-call-ledger.js +199 -32
- package/node_modules/@maka/storage/dist/model-call-usage-sql.js +136 -0
- package/node_modules/@maka/storage/dist/opencode-session-adapter.js +0 -4
- package/node_modules/@maka/storage/dist/operational-state-backup.js +9 -5
- package/node_modules/@maka/storage/dist/operational-state-store-public.js +1 -1
- package/node_modules/@maka/storage/dist/operational-state-store.js +5 -3
- package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
- package/node_modules/@maka/storage/dist/runtime-transcript-query.js +308 -0
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +24 -4
- package/node_modules/@maka/storage/dist/session-message-projection.js +15 -0
- package/node_modules/@maka/storage/dist/session-repository.js +767 -0
- package/node_modules/@maka/storage/dist/session-store.js +25 -99
- package/node_modules/@maka/storage/dist/sqlite-artifact-metadata.js +10 -3
- package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +24 -8
- package/node_modules/@maka/storage/dist/sqlite-core-execution-schema.js +17 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +44 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +129 -25
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +109 -892
- package/node_modules/@maka/storage/dist/sqlite-usage-schema.js +200 -20
- package/node_modules/@maka/storage/dist/tool-result-archive-evidence.js +111 -0
- package/node_modules/@maka/storage/dist/usage-stores.js +6 -2
- package/node_modules/@maka/storage/package.json +2 -0
- package/package.json +1 -1
|
@@ -16,8 +16,6 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
import { dedupeModelCallAttempts, summarizeModelCallCoverage, } from './model-call-attempt.js';
|
|
20
|
-
import { usageBucketKey } from './usage-stats/bucket-key.js';
|
|
21
19
|
const DAY_MS = 86_400_000;
|
|
22
20
|
export function resolveUsageRange(range, now) {
|
|
23
21
|
if (typeof range === 'object')
|
|
@@ -44,190 +42,6 @@ export function usageStatusForAttempt(status) {
|
|
|
44
42
|
return 'error';
|
|
45
43
|
return 'aborted';
|
|
46
44
|
}
|
|
47
|
-
function matchesQuery(attempt, query, range) {
|
|
48
|
-
if (attempt.completedAt < range.from || attempt.completedAt > range.to)
|
|
49
|
-
return false;
|
|
50
|
-
if (query.sessionId !== undefined && attempt.sessionId !== query.sessionId)
|
|
51
|
-
return false;
|
|
52
|
-
if (query.providerId !== undefined && attempt.providerId !== query.providerId)
|
|
53
|
-
return false;
|
|
54
|
-
if (query.modelId !== undefined && attempt.modelId !== query.modelId)
|
|
55
|
-
return false;
|
|
56
|
-
if (query.connectionSlug !== undefined && attempt.connectionSlug !== query.connectionSlug) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
if (query.status !== undefined && query.status !== 'all') {
|
|
60
|
-
if (usageStatusForAttempt(attempt.status) !== query.status)
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Selects the attempts a query addresses, in append order, deduped by
|
|
67
|
-
* `attemptId` so a re-appended settlement counts once.
|
|
68
|
-
*/
|
|
69
|
-
export function selectModelCallAttempts(attempts, query, now) {
|
|
70
|
-
const range = resolveUsageRange(query.range, now);
|
|
71
|
-
const rows = dedupeModelCallAttempts(attempts).filter((a) => matchesQuery(a, query, range));
|
|
72
|
-
return { rows, range };
|
|
73
|
-
}
|
|
74
|
-
function tokens(attempt) {
|
|
75
|
-
const reportedCacheRead = attempt.cacheReadInputTokens ?? 0;
|
|
76
|
-
const input = attempt.inputTokens ?? 0;
|
|
77
|
-
const output = attempt.outputTokens ?? 0;
|
|
78
|
-
const cacheMiss = attempt.cacheMissInputTokens ?? 0;
|
|
79
|
-
// With no reported prompt total there is no denominator to validate against,
|
|
80
|
-
// but the provider's cache evidence remains authoritative. Presentation code
|
|
81
|
-
// must leave ratios unavailable while Usage coverage is partial.
|
|
82
|
-
const cacheRead = attempt.inputTokens === undefined
|
|
83
|
-
? reportedCacheRead
|
|
84
|
-
: clampCacheReadTokens(input, reportedCacheRead);
|
|
85
|
-
const cacheWrite = attempt.cacheWriteInputTokens ?? 0;
|
|
86
|
-
const reasoning = attempt.reasoningTokens ?? 0;
|
|
87
|
-
return { input, output, cacheMiss, cacheRead, cacheWrite, reasoning, total: input + output };
|
|
88
|
-
}
|
|
89
45
|
export function clampCacheReadTokens(inputTokens, cacheReadTokens) {
|
|
90
46
|
return Math.min(cacheReadTokens, inputTokens);
|
|
91
47
|
}
|
|
92
|
-
/** Cost contributed by an attempt. Unpriced records contribute nothing to the
|
|
93
|
-
* sum and are surfaced through coverage instead of being counted as zero. */
|
|
94
|
-
function pricedCost(attempt) {
|
|
95
|
-
return attempt.costBasis === 'priced' ? (attempt.costUsd ?? 0) : 0;
|
|
96
|
-
}
|
|
97
|
-
export function projectModelCallUsageSummary(attempts, query, now) {
|
|
98
|
-
const { rows, range } = selectModelCallAttempts(attempts, query, now);
|
|
99
|
-
const totals = {
|
|
100
|
-
input: 0,
|
|
101
|
-
output: 0,
|
|
102
|
-
cacheMiss: 0,
|
|
103
|
-
cacheRead: 0,
|
|
104
|
-
cacheWrite: 0,
|
|
105
|
-
reasoning: 0,
|
|
106
|
-
total: 0,
|
|
107
|
-
};
|
|
108
|
-
let totalCostUsd = 0;
|
|
109
|
-
let totalDurationMs = 0;
|
|
110
|
-
let cacheHitRequests = 0;
|
|
111
|
-
let cacheCreateRequests = 0;
|
|
112
|
-
let errorRequests = 0;
|
|
113
|
-
for (const attempt of rows) {
|
|
114
|
-
const t = tokens(attempt);
|
|
115
|
-
totals.input += t.input;
|
|
116
|
-
totals.output += t.output;
|
|
117
|
-
totals.cacheMiss += t.cacheMiss;
|
|
118
|
-
totals.cacheRead += t.cacheRead;
|
|
119
|
-
totals.cacheWrite += t.cacheWrite;
|
|
120
|
-
totals.reasoning += t.reasoning;
|
|
121
|
-
totals.total += t.total;
|
|
122
|
-
totalCostUsd += pricedCost(attempt);
|
|
123
|
-
totalDurationMs += attempt.latencyMs;
|
|
124
|
-
if (t.cacheRead > 0)
|
|
125
|
-
cacheHitRequests += 1;
|
|
126
|
-
if (t.cacheWrite > 0)
|
|
127
|
-
cacheCreateRequests += 1;
|
|
128
|
-
if (usageStatusForAttempt(attempt.status) === 'error')
|
|
129
|
-
errorRequests += 1;
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
range,
|
|
133
|
-
totalRequests: rows.length,
|
|
134
|
-
totalCostUsd,
|
|
135
|
-
totalDurationMs,
|
|
136
|
-
totalTokens: totals,
|
|
137
|
-
cacheHitRequests,
|
|
138
|
-
cacheCreateRequests,
|
|
139
|
-
errorRequests,
|
|
140
|
-
coverage: summarizeModelCallCoverage(rows),
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
export function projectModelCallUsageBuckets(attempts, query, groupBy, now) {
|
|
144
|
-
const { rows } = selectModelCallAttempts(attempts, query, now);
|
|
145
|
-
const groups = new Map();
|
|
146
|
-
for (const attempt of rows) {
|
|
147
|
-
const key = usageBucketKey({ providerId: attempt.providerId, modelId: attempt.modelId, ts: attempt.completedAt }, groupBy);
|
|
148
|
-
const group = groups.get(key);
|
|
149
|
-
if (group)
|
|
150
|
-
group.push(attempt);
|
|
151
|
-
else
|
|
152
|
-
groups.set(key, [attempt]);
|
|
153
|
-
}
|
|
154
|
-
return [...groups.entries()]
|
|
155
|
-
.map(([key, group]) => {
|
|
156
|
-
const agg = {
|
|
157
|
-
input: 0,
|
|
158
|
-
output: 0,
|
|
159
|
-
cacheMiss: 0,
|
|
160
|
-
cacheRead: 0,
|
|
161
|
-
cacheWrite: 0,
|
|
162
|
-
reasoning: 0,
|
|
163
|
-
total: 0,
|
|
164
|
-
};
|
|
165
|
-
let costUsd = 0;
|
|
166
|
-
let latency = 0;
|
|
167
|
-
let errors = 0;
|
|
168
|
-
for (const attempt of group) {
|
|
169
|
-
const t = tokens(attempt);
|
|
170
|
-
agg.input += t.input;
|
|
171
|
-
agg.output += t.output;
|
|
172
|
-
agg.cacheMiss += t.cacheMiss;
|
|
173
|
-
agg.cacheRead += t.cacheRead;
|
|
174
|
-
agg.cacheWrite += t.cacheWrite;
|
|
175
|
-
agg.reasoning += t.reasoning;
|
|
176
|
-
agg.total += t.total;
|
|
177
|
-
costUsd += pricedCost(attempt);
|
|
178
|
-
latency += attempt.latencyMs;
|
|
179
|
-
if (usageStatusForAttempt(attempt.status) === 'error')
|
|
180
|
-
errors += 1;
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
key,
|
|
184
|
-
label: key,
|
|
185
|
-
requests: group.length,
|
|
186
|
-
inputTokens: agg.input,
|
|
187
|
-
outputTokens: agg.output,
|
|
188
|
-
cacheMissTokens: agg.cacheMiss,
|
|
189
|
-
cacheReadTokens: agg.cacheRead,
|
|
190
|
-
cacheWriteTokens: agg.cacheWrite,
|
|
191
|
-
reasoningTokens: agg.reasoning,
|
|
192
|
-
totalTokens: agg.total,
|
|
193
|
-
costUsd,
|
|
194
|
-
avgLatencyMs: group.length === 0 ? 0 : latency / group.length,
|
|
195
|
-
errorRate: group.length === 0 ? 0 : errors / group.length,
|
|
196
|
-
};
|
|
197
|
-
})
|
|
198
|
-
.sort((left, right) => right.requests - left.requests);
|
|
199
|
-
}
|
|
200
|
-
export function projectModelCallUsageLogs(attempts, query, now, offset = 0, limit = 100) {
|
|
201
|
-
const { rows } = selectModelCallAttempts(attempts, query, now);
|
|
202
|
-
const ordered = [...rows].sort((left, right) => right.completedAt - left.completedAt);
|
|
203
|
-
const page = ordered.slice(offset, offset + limit).map((attempt) => {
|
|
204
|
-
const t = tokens(attempt);
|
|
205
|
-
return {
|
|
206
|
-
id: attempt.attemptId,
|
|
207
|
-
ts: attempt.completedAt,
|
|
208
|
-
callKind: attempt.callKind,
|
|
209
|
-
callId: attempt.logicalCallId,
|
|
210
|
-
...(attempt.connectionSlug !== undefined ? { connectionSlug: attempt.connectionSlug } : {}),
|
|
211
|
-
providerId: attempt.providerId,
|
|
212
|
-
modelId: attempt.modelId,
|
|
213
|
-
inputTokens: t.input,
|
|
214
|
-
outputTokens: t.output,
|
|
215
|
-
cacheMissTokens: t.cacheMiss,
|
|
216
|
-
cacheReadTokens: t.cacheRead,
|
|
217
|
-
cacheWriteTokens: t.cacheWrite,
|
|
218
|
-
reasoningTokens: t.reasoning,
|
|
219
|
-
totalTokens: t.total,
|
|
220
|
-
// A row keeps its basis, not just its number. Collapsing an unpriced call
|
|
221
|
-
// to 0 here would reproduce, per row, exactly the ambiguity the coverage
|
|
222
|
-
// breakdown removes from the totals.
|
|
223
|
-
...(attempt.costBasis === 'priced' ? { costUsd: attempt.costUsd ?? 0 } : {}),
|
|
224
|
-
costBasis: attempt.costBasis,
|
|
225
|
-
latencyMs: attempt.latencyMs,
|
|
226
|
-
status: usageStatusForAttempt(attempt.status),
|
|
227
|
-
...(attempt.errorClass !== undefined ? { errorClass: attempt.errorClass } : {}),
|
|
228
|
-
sessionId: attempt.sessionId,
|
|
229
|
-
turnId: attempt.turnId,
|
|
230
|
-
};
|
|
231
|
-
});
|
|
232
|
-
return { rows: page, total: ordered.length, coverage: summarizeModelCallCoverage(rows) };
|
|
233
|
-
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { defineObjectShape, hasExactShape, isRecord } from './record-schema.js';
|
|
20
|
+
export const MODEL_FAILURE_MESSAGE_MAX_BYTES = 2 * 1024;
|
|
21
|
+
const EXHAUSTED_SHAPE = defineObjectShape()(['decision', 'attempts'], []);
|
|
22
|
+
const DECLINED_SHAPE = defineObjectShape()(['decision', 'because'], []);
|
|
23
|
+
export function isModelRetryDecision(value) {
|
|
24
|
+
if (!isRecord(value))
|
|
25
|
+
return false;
|
|
26
|
+
switch (value.decision) {
|
|
27
|
+
case 'exhausted':
|
|
28
|
+
return (hasExactShape(value, EXHAUSTED_SHAPE) &&
|
|
29
|
+
Number.isSafeInteger(value.attempts) &&
|
|
30
|
+
Number(value.attempts) > 0);
|
|
31
|
+
case 'declined':
|
|
32
|
+
return (hasExactShape(value, DECLINED_SHAPE) &&
|
|
33
|
+
(value.because === 'side_effects' ||
|
|
34
|
+
value.because === 'observable_output' ||
|
|
35
|
+
value.because === 'policy' ||
|
|
36
|
+
value.because === 'budget'));
|
|
37
|
+
default:
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -2009,7 +2009,7 @@ export const GENERATED_MODELS_DEV_MODEL_PROVIDER_OVERRIDES = {
|
|
|
2009
2009
|
"alibaba-token-plan-cn": {},
|
|
2010
2010
|
"alibaba-token-plan": {},
|
|
2011
2011
|
"cerebras": {},
|
|
2012
|
-
"cohere": { "north-mini-code-1-0": { "
|
|
2012
|
+
"cohere": { "north-mini-code-1-0": { "adapter": { "kind": "openai-compatible", "name": "provider" }, "baseUrl": "https://api.cohere.ai/compatibility/v1" } },
|
|
2013
2013
|
"cloudflare-workers-ai": {},
|
|
2014
2014
|
"deepinfra": {},
|
|
2015
2015
|
"deepseek": {},
|
|
@@ -2027,8 +2027,8 @@ export const GENERATED_MODELS_DEV_MODEL_PROVIDER_OVERRIDES = {
|
|
|
2027
2027
|
"nvidia": {},
|
|
2028
2028
|
"ollama-cloud": {},
|
|
2029
2029
|
"openai": {},
|
|
2030
|
-
"opencode": { "claude-3-5-haiku": { "
|
|
2031
|
-
"opencode-go": { "gpt-5.6-luna": { "
|
|
2030
|
+
"opencode": { "claude-3-5-haiku": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "claude-fable-5": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "claude-haiku-4-5": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "claude-opus-4-1": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "claude-opus-4-5": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "claude-opus-4-6": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "claude-opus-4-7": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "claude-opus-4-8": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "claude-opus-5": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "claude-sonnet-4": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "claude-sonnet-4-5": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "claude-sonnet-4-6": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "claude-sonnet-5": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "gemini-3-flash": { "adapter": { "kind": "google", "normalizeBaseUrl": false } }, "gemini-3-pro": { "adapter": { "kind": "google", "normalizeBaseUrl": false } }, "gemini-3.1-pro": { "adapter": { "kind": "google", "normalizeBaseUrl": false } }, "gemini-3.5-flash": { "adapter": { "kind": "google", "normalizeBaseUrl": false } }, "gemini-3.5-flash-lite": { "adapter": { "kind": "google", "normalizeBaseUrl": false } }, "gemini-3.6-flash": { "adapter": { "kind": "google", "normalizeBaseUrl": false } }, "gemini-3.7-flash": { "adapter": { "kind": "google", "normalizeBaseUrl": false } }, "gpt-5": { "adapter": { "kind": "openai" } }, "gpt-5-codex": { "adapter": { "kind": "openai" } }, "gpt-5-nano": { "adapter": { "kind": "openai" } }, "gpt-5.1": { "adapter": { "kind": "openai" } }, "gpt-5.1-codex": { "adapter": { "kind": "openai" } }, "gpt-5.1-codex-max": { "adapter": { "kind": "openai" } }, "gpt-5.1-codex-mini": { "adapter": { "kind": "openai" } }, "gpt-5.2": { "adapter": { "kind": "openai" } }, "gpt-5.2-codex": { "adapter": { "kind": "openai" } }, "gpt-5.3-codex": { "adapter": { "kind": "openai" } }, "gpt-5.3-codex-spark": { "adapter": { "kind": "openai" } }, "gpt-5.4": { "adapter": { "kind": "openai" } }, "gpt-5.4-mini": { "adapter": { "kind": "openai" } }, "gpt-5.4-nano": { "adapter": { "kind": "openai" } }, "gpt-5.4-pro": { "adapter": { "kind": "openai" } }, "gpt-5.5": { "adapter": { "kind": "openai" } }, "gpt-5.5-pro": { "adapter": { "kind": "openai" } }, "gpt-5.6-luna": { "adapter": { "kind": "openai" } }, "gpt-5.6-sol": { "adapter": { "kind": "openai" } }, "gpt-5.6-terra": { "adapter": { "kind": "openai" } }, "grok-4.5": { "adapter": { "kind": "openai" } }, "grok-4.6": { "adapter": { "kind": "openai" } }, "grok-build-0.1": { "adapter": { "kind": "openai" } }, "minimax-m2.1-free": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "minimax-m2.5-free": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "minimax-m3-free": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "muse-spark-1.2": { "adapter": { "kind": "openai" } }, "muse-spark-1.2-contributor-free": { "adapter": { "kind": "openai" } }, "qwen3.5-plus": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "qwen3.6-plus": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "qwen3.6-plus-free": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } } },
|
|
2031
|
+
"opencode-go": { "gpt-5.6-luna": { "adapter": { "kind": "openai" } }, "grok-4.5": { "adapter": { "kind": "openai" } }, "grok-4.6": { "adapter": { "kind": "openai" } }, "minimax-m2.5": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "minimax-m2.7": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "minimax-m3": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } }, "muse-spark-1.2-contributor": { "adapter": { "kind": "openai" } }, "qwen3.8-flash": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true } } },
|
|
2032
2032
|
"openrouter": {},
|
|
2033
2033
|
"siliconflow": {},
|
|
2034
2034
|
"stepfun": {},
|
|
@@ -2047,7 +2047,7 @@ export const GENERATED_MODELS_DEV_MODEL_PROVIDER_OVERRIDES = {
|
|
|
2047
2047
|
"xiaomi-token-plan-ams": {},
|
|
2048
2048
|
"zai": {},
|
|
2049
2049
|
"zai-coding-plan": {},
|
|
2050
|
-
"zenmux": { "anthropic/claude-3.5-haiku": { "
|
|
2050
|
+
"zenmux": { "anthropic/claude-3.5-haiku": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "anthropic/claude-3.7-sonnet": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "anthropic/claude-fable-5": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "anthropic/claude-haiku-4.5": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "anthropic/claude-opus-4": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "anthropic/claude-opus-4.1": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "anthropic/claude-opus-4.5": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "anthropic/claude-opus-4.6": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "anthropic/claude-opus-4.7": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "anthropic/claude-opus-4.8": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "anthropic/claude-sonnet-4": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "anthropic/claude-sonnet-4.5": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "anthropic/claude-sonnet-4.6": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "anthropic/claude-sonnet-5": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "anthropic/claude-sonnet-5-free": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "minimax/minimax-m2": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "minimax/minimax-m2.1": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "minimax/minimax-m2.5": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "minimax/minimax-m2.5-lightning": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "minimax/minimax-m2.7": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "minimax/minimax-m2.7-highspeed": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "minimax/minimax-m3": { "adapter": { "kind": "anthropic", "auth": "api-key", "normalizeBaseUrl": true }, "baseUrl": "https://zenmux.ai/api/anthropic/v1" }, "openai/gpt-5": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" }, "openai/gpt-5-codex": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" }, "openai/gpt-5.1": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" }, "openai/gpt-5.1-chat": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" }, "openai/gpt-5.1-codex": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" }, "openai/gpt-5.1-codex-mini": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" }, "openai/gpt-5.2": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" }, "openai/gpt-5.2-codex": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" }, "openai/gpt-5.2-pro": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" }, "openai/gpt-5.3-chat": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" }, "openai/gpt-5.3-codex": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" }, "openai/gpt-5.4": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" }, "openai/gpt-5.4-mini": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" }, "openai/gpt-5.4-nano": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" }, "openai/gpt-5.4-pro": { "adapter": { "kind": "openai" }, "baseUrl": "https://zenmux.ai/api/v1" } },
|
|
2051
2051
|
};
|
|
2052
2052
|
export const GENERATED_MODELS_DEV_PROVIDER_FACTS = {
|
|
2053
2053
|
"anthropic": { "id": "anthropic", "name": "Anthropic", "doc": "https://docs.anthropic.com/en/docs/about-claude/models" },
|
|
@@ -39,7 +39,6 @@ export function installRefreshedModelMetadata(metadata) {
|
|
|
39
39
|
function activeMetadata() {
|
|
40
40
|
return refreshedMetadata ?? bundledModelMetadata;
|
|
41
41
|
}
|
|
42
|
-
const generatedModelProviderOverrides = GENERATED_MODELS_DEV_MODEL_PROVIDER_OVERRIDES;
|
|
43
42
|
/** Access paths that serve a canonical provider's model catalog. */
|
|
44
43
|
const GENERATED_METADATA_PROVIDER_ALIASES = {
|
|
45
44
|
'xai-oauth': 'xai',
|
|
@@ -95,8 +94,9 @@ export function modelMetadataIdsForProvider(providerType) {
|
|
|
95
94
|
: []),
|
|
96
95
|
]));
|
|
97
96
|
}
|
|
98
|
-
export function
|
|
99
|
-
|
|
97
|
+
export function lookupModelRuntimeOverride(providerType, modelId) {
|
|
98
|
+
const overrides = GENERATED_MODELS_DEV_MODEL_PROVIDER_OVERRIDES;
|
|
99
|
+
return overrides[providerType]?.[modelId.trim()];
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* The request wire a model served over the OpenAI adapter must use.
|
|
@@ -29,7 +29,7 @@ import { deepSeekModelSupportsResponses } from './model-metadata.js';
|
|
|
29
29
|
* Responses and Anthropic Messages. Search never switches wire independently
|
|
30
30
|
* from the primary model request.
|
|
31
31
|
*/
|
|
32
|
-
export function resolveHostedWebSearchCapability(providerType, models, modelId) {
|
|
32
|
+
export function resolveHostedWebSearchCapability(providerType, models, modelId, effectiveWire) {
|
|
33
33
|
const id = modelId.trim();
|
|
34
34
|
if (!id)
|
|
35
35
|
return null;
|
|
@@ -39,9 +39,10 @@ export function resolveHostedWebSearchCapability(providerType, models, modelId)
|
|
|
39
39
|
const adapter = providerHostedWebSearchAdapter(providerType);
|
|
40
40
|
if (!adapter)
|
|
41
41
|
return null;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
const wire = effectiveWire ?? stored?.apiProtocol;
|
|
43
|
+
if (wire !== undefined &&
|
|
44
|
+
((adapter.adapter === 'openai-responses' && wire !== 'openai-responses') ||
|
|
45
|
+
(adapter.adapter === 'anthropic-messages' && wire !== 'anthropic-messages'))) {
|
|
45
46
|
return null;
|
|
46
47
|
}
|
|
47
48
|
if (stored?.capabilities?.webSearch === true) {
|
|
@@ -116,12 +116,12 @@ if (zenmux.api !== 'https://zenmux.ai/api/v1') {
|
|
|
116
116
|
throw new Error('models.dev ZenMux provider facts are missing the official OpenAI-compatible API');
|
|
117
117
|
}
|
|
118
118
|
const zenmuxModelProviderOverrides = GENERATED_MODELS_DEV_MODEL_PROVIDER_OVERRIDES.zenmux;
|
|
119
|
-
if (zenmuxModelProviderOverrides['anthropic/claude-sonnet-4.6']?.
|
|
120
|
-
zenmuxModelProviderOverrides['anthropic/claude-sonnet-4.6']?.
|
|
119
|
+
if (zenmuxModelProviderOverrides['anthropic/claude-sonnet-4.6']?.adapter.kind !== 'anthropic' ||
|
|
120
|
+
zenmuxModelProviderOverrides['anthropic/claude-sonnet-4.6']?.baseUrl !==
|
|
121
121
|
'https://zenmux.ai/api/anthropic/v1') {
|
|
122
122
|
throw new Error('models.dev ZenMux snapshot is missing its Anthropic model-level protocol override');
|
|
123
123
|
}
|
|
124
|
-
if (zenmuxModelProviderOverrides['openai/gpt-5.4']?.
|
|
124
|
+
if (zenmuxModelProviderOverrides['openai/gpt-5.4']?.adapter.kind !== 'openai') {
|
|
125
125
|
throw new Error('models.dev ZenMux snapshot is missing its native OpenAI model-level protocol override');
|
|
126
126
|
}
|
|
127
127
|
const zenmuxOpenAICompatibleMetadata = Object.fromEntries(Object.entries(GENERATED_MODELS_DEV_METADATA.zenmux).filter(([id]) => zenmuxModelProviderOverrides[id] === undefined));
|
|
@@ -505,6 +505,14 @@ const providerRegistry = {
|
|
|
505
505
|
fallbackModels: [...kimiCodingPlanModelIds],
|
|
506
506
|
status: 'ready',
|
|
507
507
|
runtimeAdapter: { kind: 'anthropic', auth: 'api-key', normalizeBaseUrl: true },
|
|
508
|
+
protocolAdapters: {
|
|
509
|
+
'openai-chat': {
|
|
510
|
+
kind: 'openai-compatible',
|
|
511
|
+
name: 'provider',
|
|
512
|
+
normalizeUsage: true,
|
|
513
|
+
normalizeBaseUrl: true,
|
|
514
|
+
},
|
|
515
|
+
},
|
|
508
516
|
modelDiscovery: { kind: 'protocol' },
|
|
509
517
|
category: 'domestic',
|
|
510
518
|
catalogGroup: 'plans',
|
|
@@ -891,6 +899,10 @@ const providerRegistry = {
|
|
|
891
899
|
fallbackModels: opencodeModelIds,
|
|
892
900
|
status: 'ready',
|
|
893
901
|
runtimeAdapter: { kind: 'openai-compatible', name: 'provider' },
|
|
902
|
+
protocolAdapters: {
|
|
903
|
+
'anthropic-messages': { kind: 'anthropic', auth: 'api-key', normalizeBaseUrl: true },
|
|
904
|
+
'openai-responses': { kind: 'openai', apiProtocol: 'openai-responses' },
|
|
905
|
+
},
|
|
894
906
|
modelDiscovery: { kind: 'protocol' },
|
|
895
907
|
category: 'overseas',
|
|
896
908
|
catalogGroup: 'plans',
|
|
@@ -904,6 +916,10 @@ const providerRegistry = {
|
|
|
904
916
|
fallbackModels: opencodeGoModelIds,
|
|
905
917
|
status: 'ready',
|
|
906
918
|
runtimeAdapter: { kind: 'openai-compatible', name: 'provider' },
|
|
919
|
+
protocolAdapters: {
|
|
920
|
+
'anthropic-messages': { kind: 'anthropic', auth: 'api-key', normalizeBaseUrl: true },
|
|
921
|
+
'openai-responses': { kind: 'openai', apiProtocol: 'openai-responses' },
|
|
922
|
+
},
|
|
907
923
|
modelDiscovery: { kind: 'protocol' },
|
|
908
924
|
category: 'overseas',
|
|
909
925
|
catalogGroup: 'plans',
|
|
@@ -1182,6 +1198,22 @@ const providerRegistry = {
|
|
|
1182
1198
|
signupUrl: 'https://modelstudio.console.alibabacloud.com/',
|
|
1183
1199
|
catalogOrder: 41.4,
|
|
1184
1200
|
},
|
|
1201
|
+
commandcode: {
|
|
1202
|
+
label: 'Command Code',
|
|
1203
|
+
baseUrl: 'https://api.commandcode.ai/provider/v1',
|
|
1204
|
+
authKind: 'api_key',
|
|
1205
|
+
fallbackModels: [],
|
|
1206
|
+
status: 'ready',
|
|
1207
|
+
runtimeAdapter: { kind: 'openai-compatible', name: 'provider' },
|
|
1208
|
+
protocolAdapters: {
|
|
1209
|
+
'anthropic-messages': { kind: 'anthropic', auth: 'bearer', normalizeBaseUrl: true },
|
|
1210
|
+
},
|
|
1211
|
+
modelDiscovery: { kind: 'protocol', modelProtocols: 'commandcode' },
|
|
1212
|
+
category: 'overseas',
|
|
1213
|
+
catalogGroup: 'plans',
|
|
1214
|
+
signupUrl: 'https://commandcode.ai/docs/plans/goat',
|
|
1215
|
+
catalogOrder: 41.5,
|
|
1216
|
+
},
|
|
1185
1217
|
'cloudflare-workers-ai': {
|
|
1186
1218
|
label: cloudflareWorkersAi.name,
|
|
1187
1219
|
baseUrl: '',
|
|
@@ -1299,7 +1331,16 @@ const providerRegistry = {
|
|
|
1299
1331
|
authKind: 'oauth_token',
|
|
1300
1332
|
fallbackModels: githubCopilotModelIds,
|
|
1301
1333
|
status: 'ready',
|
|
1302
|
-
runtimeAdapter: { kind: '
|
|
1334
|
+
runtimeAdapter: { kind: 'openai-compatible', name: 'provider', includeUsage: false },
|
|
1335
|
+
protocolAdapters: {
|
|
1336
|
+
'anthropic-messages': {
|
|
1337
|
+
kind: 'anthropic',
|
|
1338
|
+
auth: 'bearer',
|
|
1339
|
+
normalizeBaseUrl: true,
|
|
1340
|
+
includeBetaHeaders: false,
|
|
1341
|
+
},
|
|
1342
|
+
'openai-responses': { kind: 'openai', apiProtocol: 'openai-responses' },
|
|
1343
|
+
},
|
|
1303
1344
|
modelDiscovery: { kind: 'protocol', auth: 'github-copilot' },
|
|
1304
1345
|
category: 'oauth',
|
|
1305
1346
|
signupUrl: 'https://github.com/features/copilot/plans',
|
|
@@ -19,11 +19,18 @@
|
|
|
19
19
|
/**
|
|
20
20
|
* Defines a JSON object shape while making schema additions a type error until
|
|
21
21
|
* both the required and optional key lists are updated.
|
|
22
|
+
*
|
|
23
|
+
* `retired` names keys older writers persisted that this type no longer has.
|
|
24
|
+
* They are accepted on read and dropped by {@link pickShape}, so what the shape
|
|
25
|
+
* emits may shrink freely while what it accepts only grows. Removing a key from
|
|
26
|
+
* `optional` without listing it here makes every stored record carrying it fail
|
|
27
|
+
* validation outright.
|
|
22
28
|
*/
|
|
23
29
|
export function defineObjectShape() {
|
|
24
|
-
return (required, optional) => ({
|
|
30
|
+
return (required, optional, retired = []) => ({
|
|
25
31
|
required,
|
|
26
32
|
allowed: new Set([...required, ...optional]),
|
|
33
|
+
retired: new Set(retired),
|
|
27
34
|
});
|
|
28
35
|
}
|
|
29
36
|
export function isRecord(value) {
|
|
@@ -31,7 +38,20 @@ export function isRecord(value) {
|
|
|
31
38
|
}
|
|
32
39
|
export function hasExactShape(value, shape) {
|
|
33
40
|
return (shape.required.every((key) => Object.hasOwn(value, key)) &&
|
|
34
|
-
Object.keys(value).every((key) => shape.allowed.has(key)));
|
|
41
|
+
Object.keys(value).every((key) => shape.allowed.has(key) || shape.retired?.has(key) === true));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Narrows a record to the keys a shape allows. `undefined` entries are dropped
|
|
45
|
+
* so the result serializes the way {@link hasExactShape} reads it back.
|
|
46
|
+
*/
|
|
47
|
+
export function pickShape(value, shape) {
|
|
48
|
+
const picked = {};
|
|
49
|
+
for (const key of shape.allowed) {
|
|
50
|
+
const entry = value[key];
|
|
51
|
+
if (entry !== undefined)
|
|
52
|
+
picked[key] = entry;
|
|
53
|
+
}
|
|
54
|
+
return picked;
|
|
35
55
|
}
|
|
36
56
|
export function isFiniteNumber(value) {
|
|
37
57
|
return typeof value === 'number' && Number.isFinite(value);
|
|
@@ -174,76 +174,59 @@ function isAssignmentSensitiveKey(key) {
|
|
|
174
174
|
const suffix = sensitiveKeySegments(key).at(-1);
|
|
175
175
|
return suffix !== 'auth' && suffix !== 'authorization';
|
|
176
176
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
provider: '模型服务返回错误',
|
|
183
|
-
network: '网络错误',
|
|
184
|
-
},
|
|
185
|
-
'zh-TW': {
|
|
186
|
-
timeout: '請求逾時',
|
|
187
|
-
rateLimit: '已達模型速率限制',
|
|
188
|
-
authentication: '驗證失敗',
|
|
189
|
-
provider: '模型服務傳回錯誤',
|
|
190
|
-
network: '網路錯誤',
|
|
191
|
-
},
|
|
192
|
-
en: {
|
|
193
|
-
timeout: 'Request timed out',
|
|
194
|
-
rateLimit: 'Rate limit exceeded',
|
|
195
|
-
authentication: 'Authentication failed',
|
|
196
|
-
provider: 'Provider returned an error',
|
|
197
|
-
network: 'Network error',
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
function classifyGeneralizedError(error) {
|
|
177
|
+
/**
|
|
178
|
+
* Keyword classification shared by the localized message helpers and by
|
|
179
|
+
* producers that emit a stable machine code instead of prose.
|
|
180
|
+
*/
|
|
181
|
+
export function classifyGeneralizedError(error) {
|
|
201
182
|
const message = error instanceof Error ? error.message : String(error);
|
|
202
|
-
const
|
|
203
|
-
const lower = redacted.toLowerCase();
|
|
183
|
+
const lower = redactSecrets(message).toLowerCase();
|
|
204
184
|
if (lower.includes('timeout'))
|
|
205
185
|
return 'timeout';
|
|
206
186
|
if (lower.includes('429') || lower.includes('rate'))
|
|
207
|
-
return '
|
|
187
|
+
return 'rate_limited';
|
|
208
188
|
if (lower.includes('401') || lower.includes('403') || isAuthenticationErrorText(lower))
|
|
209
|
-
return '
|
|
210
|
-
if (
|
|
211
|
-
return '
|
|
189
|
+
return 'auth_failed';
|
|
190
|
+
if (/\b5\d\d\b/.test(lower))
|
|
191
|
+
return 'provider_error';
|
|
212
192
|
if (lower.includes('network') ||
|
|
213
193
|
lower.includes('fetch') ||
|
|
214
194
|
lower.includes('econn') ||
|
|
215
195
|
lower.includes('enotfound'))
|
|
216
|
-
return '
|
|
217
|
-
return
|
|
196
|
+
return 'network_error';
|
|
197
|
+
return undefined;
|
|
218
198
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
199
|
+
/** Locale copy for each {@link GeneralizedErrorClass}; catalog authors spread
|
|
200
|
+
* this per-locale block instead of restating the sentences. */
|
|
201
|
+
export const GENERALIZED_ERROR_COPY = {
|
|
202
|
+
'zh-CN': {
|
|
203
|
+
timeout: '请求超时',
|
|
204
|
+
rate_limited: '触发模型速率限制',
|
|
205
|
+
auth_failed: '鉴权失败',
|
|
206
|
+
provider_error: '模型服务返回错误',
|
|
207
|
+
network_error: '网络错误',
|
|
208
|
+
},
|
|
209
|
+
'zh-TW': {
|
|
210
|
+
timeout: '請求逾時',
|
|
211
|
+
rate_limited: '已達模型速率限制',
|
|
212
|
+
auth_failed: '驗證失敗',
|
|
213
|
+
provider_error: '模型服務傳回錯誤',
|
|
214
|
+
network_error: '網路錯誤',
|
|
215
|
+
},
|
|
216
|
+
en: {
|
|
217
|
+
timeout: 'Request timed out',
|
|
218
|
+
rate_limited: 'Rate limit exceeded',
|
|
219
|
+
auth_failed: 'Authentication failed',
|
|
220
|
+
provider_error: 'Provider returned an error',
|
|
221
|
+
network_error: 'Network error',
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
export function generalizedErrorMessageForLocale(error, fallback, locale) {
|
|
225
|
+
const classified = classifyGeneralizedError(error);
|
|
226
|
+
return classified ? GENERALIZED_ERROR_COPY[locale][classified] : fallback;
|
|
222
227
|
}
|
|
223
228
|
export function generalizedErrorMessage(error, fallback = 'Operation failed') {
|
|
224
|
-
return
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Chinese-locale companion to `generalizedErrorMessage()` (PR110b
|
|
228
|
-
* follow-up). Same classification rules; returns Chinese phrasing
|
|
229
|
-
* instead of English. Used by surfaces that must enforce a
|
|
230
|
-
* Chinese-only error copy contract (session start, onboarding setup
|
|
231
|
-
* banners, etc.) — the English version would have leaked through any
|
|
232
|
-
* matched category, breaking the gate.
|
|
233
|
-
*
|
|
234
|
-
* The fallback default is also Chinese so callers that don't supply
|
|
235
|
-
* one still produce a Chinese-only result. Pass a more specific
|
|
236
|
-
* Chinese fallback (e.g. "会话已创建但发送失败,请重试。") for better
|
|
237
|
-
* UX when the classifier can't categorize.
|
|
238
|
-
*/
|
|
239
|
-
export function generalizedErrorMessageChinese(error, fallback = '操作失败') {
|
|
240
|
-
return localizedGeneralizedErrorMessage(error, fallback, 'zh-CN');
|
|
241
|
-
}
|
|
242
|
-
export function generalizedErrorMessageTraditionalChinese(error, fallback = '操作失敗') {
|
|
243
|
-
return localizedGeneralizedErrorMessage(error, fallback, 'zh-TW');
|
|
244
|
-
}
|
|
245
|
-
export function generalizedErrorMessageForLocale(error, fallback, locale) {
|
|
246
|
-
return localizedGeneralizedErrorMessage(error, fallback, locale);
|
|
229
|
+
return generalizedErrorMessageForLocale(error, fallback, 'en');
|
|
247
230
|
}
|
|
248
231
|
export function isAuthenticationErrorText(message) {
|
|
249
232
|
return message.replace(/\bauthorit\w*/g, '').includes('auth');
|