maka-agent 0.2.0-dev.23.20260906 → 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-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/canonical-runtime-event.js +3 -1
- 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 +9 -2
- 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.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-record-schema.js +26 -35
- package/node_modules/@maka/core/package.json +4 -0
- 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 +127 -133
- 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/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/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 +2 -0
- package/node_modules/@maka/runtime-host/dist/client/launcher.js +3 -0
- 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/protocol/host-status.js +21 -12
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +25 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +1 -0
- 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/server/access-credential-store.js +1 -0
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +19 -4
- package/node_modules/@maka/runtime-host/dist/server/connection-session.js +7 -6
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +100 -24
- 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/goal-coordinator.js +40 -1
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +96 -17
- 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 +76 -6
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +325 -73
- 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 +50 -7
- 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/workhub-coordination-coordinator.js +0 -1
- 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/execution-stores.js +9 -7
- package/node_modules/@maka/storage/dist/file-session-repository.js +1012 -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/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 +7 -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/tool-result-archive-evidence.js +111 -0
- package/node_modules/@maka/storage/package.json +2 -0
- package/package.json +1 -1
|
@@ -29,7 +29,7 @@ import { isJSONArray, } from '@ai-sdk/provider';
|
|
|
29
29
|
import { lookupModelMetadata } from '@maka/core/model-metadata';
|
|
30
30
|
import { resolveThinkingLevel, supportsRelayFastServiceTier, thinkingOptionsForModel, thinkingVariantsForConnection, } from '@maka/core/model-thinking';
|
|
31
31
|
import { createOpenAiChatReasoningTransport, createOpenAiChatReasoningTransportState, } from './openai-chat-reasoning-transport.js';
|
|
32
|
-
import {
|
|
32
|
+
import { openResponsesUrl } from './provider-urls.js';
|
|
33
33
|
import { createOpenResponsesCompatibilityFinalizer } from './open-responses-compatibility.js';
|
|
34
34
|
import { resolveModelRuntime } from './model-runtime.js';
|
|
35
35
|
import { runtimeProviderName } from './provider-runtime-policy.js';
|
|
@@ -51,22 +51,14 @@ export function getAIModel(input) {
|
|
|
51
51
|
bodyOverlay: connection.requestBodyOverlay,
|
|
52
52
|
};
|
|
53
53
|
const requestFetch = createRequestCustomizationFetch(baseFetch, requestCustomization);
|
|
54
|
-
if (adapter.kind === 'google' && adapter.normalizeBaseUrl === false) {
|
|
55
|
-
return createGoogle({ apiKey, baseURL, fetch: requestFetch }).chat(modelId);
|
|
56
|
-
}
|
|
57
54
|
switch (adapter.kind) {
|
|
58
55
|
case 'anthropic':
|
|
59
56
|
return createAnthropic({
|
|
60
57
|
...(adapter.auth === 'bearer' ? { authToken: apiKey } : { apiKey }),
|
|
61
|
-
baseURL
|
|
58
|
+
baseURL,
|
|
62
59
|
fetch: requestFetch,
|
|
63
|
-
headers: { 'anthropic-beta': ANTHROPIC_BETA },
|
|
60
|
+
headers: adapter.includeBetaHeaders === false ? undefined : { 'anthropic-beta': ANTHROPIC_BETA },
|
|
64
61
|
}).chat(modelId);
|
|
65
|
-
case 'unavailable':
|
|
66
|
-
// A retired provider must never reach model construction. The pickers
|
|
67
|
-
// filter it out and `resolveModelRuntime` refuses earlier; this is the
|
|
68
|
-
// backstop that keeps a stored connection from silently sending.
|
|
69
|
-
throw new Error('This provider is retired and can no longer be used to send.');
|
|
70
62
|
case 'openai-codex':
|
|
71
63
|
return createOpenAI({
|
|
72
64
|
apiKey,
|
|
@@ -76,36 +68,10 @@ export function getAIModel(input) {
|
|
|
76
68
|
: requestFetch,
|
|
77
69
|
headers: openAiCodexHeaders(apiKey),
|
|
78
70
|
}).responses(modelId);
|
|
79
|
-
case 'github-copilot': {
|
|
80
|
-
if (wire === 'openai-responses') {
|
|
81
|
-
return createOpenAI({ apiKey, baseURL, fetch: requestFetch }).responses(modelId);
|
|
82
|
-
}
|
|
83
|
-
if (wire === 'anthropic-messages') {
|
|
84
|
-
return createAnthropic({
|
|
85
|
-
authToken: apiKey,
|
|
86
|
-
baseURL: anthropicV1BaseUrl(baseURL),
|
|
87
|
-
fetch: requestFetch,
|
|
88
|
-
}).chat(modelId);
|
|
89
|
-
}
|
|
90
|
-
if (reasoningReplay.kind !== 'openai-chat-plaintext') {
|
|
91
|
-
throw new Error('Copilot OpenAI Chat wire requires plaintext reasoning replay');
|
|
92
|
-
}
|
|
93
|
-
const reasoningTransport = createOpenAiChatReasoningTransport(requestFetch, openAiChatReasoningTransportState ??
|
|
94
|
-
createOpenAiChatReasoningTransportState(reasoningReplay.requestField));
|
|
95
|
-
return createOpenAICompatible({
|
|
96
|
-
name: 'github-copilot',
|
|
97
|
-
apiKey,
|
|
98
|
-
baseURL,
|
|
99
|
-
fetch: reasoningTransport.fetch,
|
|
100
|
-
transformRequestBody: reasoningTransport.transformRequestBody,
|
|
101
|
-
}).chatModel(modelId);
|
|
102
|
-
}
|
|
103
71
|
case 'openai': {
|
|
104
72
|
const openai = createOpenAI({
|
|
105
73
|
apiKey,
|
|
106
|
-
|
|
107
|
-
// overrides back to their base so probe-approved relay URLs work.
|
|
108
|
-
baseURL: wire === 'openai-responses' && baseURL ? openAiResponsesBaseUrl(baseURL) : baseURL,
|
|
74
|
+
baseURL,
|
|
109
75
|
fetch: !hasRequestCustomization && openAiResponsesTransportState
|
|
110
76
|
? openAiResponsesTransportState.wrapFetch(requestFetch)
|
|
111
77
|
: requestFetch,
|
|
@@ -115,7 +81,7 @@ export function getAIModel(input) {
|
|
|
115
81
|
case 'google':
|
|
116
82
|
return createGoogle({
|
|
117
83
|
apiKey,
|
|
118
|
-
baseURL
|
|
84
|
+
baseURL,
|
|
119
85
|
fetch: requestFetch,
|
|
120
86
|
}).chat(modelId);
|
|
121
87
|
case 'cohere':
|
|
@@ -125,9 +91,6 @@ export function getAIModel(input) {
|
|
|
125
91
|
throw new Error(`${connection.providerType} connection ${connection.slug} requires a base URL`);
|
|
126
92
|
}
|
|
127
93
|
if (wire === 'openai-responses') {
|
|
128
|
-
if (reasoningReplay.kind !== 'responses') {
|
|
129
|
-
throw new Error('Responses wire requires a Responses continuation contract');
|
|
130
|
-
}
|
|
131
94
|
if (reasoningReplay.contract.adapter === 'open-responses') {
|
|
132
95
|
const finalizeBody = createOpenResponsesCompatibilityFinalizer(reasoningReplay.contract.compatibility);
|
|
133
96
|
// Request customization is applied first; provider compatibility is
|
|
@@ -148,9 +111,7 @@ export function getAIModel(input) {
|
|
|
148
111
|
}
|
|
149
112
|
return createOpenAI({
|
|
150
113
|
apiKey,
|
|
151
|
-
|
|
152
|
-
// native adapter appends `/responses` itself, so pass the base.
|
|
153
|
-
baseURL: baseURL ? openAiResponsesBaseUrl(baseURL) : baseURL,
|
|
114
|
+
baseURL,
|
|
154
115
|
fetch: requestFetch,
|
|
155
116
|
}).responses(modelId);
|
|
156
117
|
}
|
|
@@ -158,7 +119,7 @@ export function getAIModel(input) {
|
|
|
158
119
|
throw new Error('OpenAI-compatible Chat wire requires plaintext reasoning replay');
|
|
159
120
|
}
|
|
160
121
|
const reasoningTransport = createOpenAiChatReasoningTransport(requestFetch, openAiChatReasoningTransportState ??
|
|
161
|
-
createOpenAiChatReasoningTransportState(reasoningReplay.requestField),
|
|
122
|
+
createOpenAiChatReasoningTransportState(reasoningReplay.requestField), adapter.normalizeUsage);
|
|
162
123
|
const transformRequestBody = adapter.replayAssistantReasoningDetails
|
|
163
124
|
? composeRequestTransforms(reasoningTransport.transformRequestBody, replayAssistantReasoning('reasoning', true))
|
|
164
125
|
: reasoningTransport.transformRequestBody;
|
|
@@ -378,10 +339,10 @@ function claudeThinkingMode(providerType, modelId, thinkingOptions) {
|
|
|
378
339
|
? 'adaptive'
|
|
379
340
|
: 'legacy';
|
|
380
341
|
}
|
|
381
|
-
export function buildProviderOptions(connection, modelId, thinkingLevel) {
|
|
382
|
-
return withParallelToolCallOptions(connection, modelId, buildThinkingProviderOptions(connection, modelId, thinkingLevel));
|
|
342
|
+
export function buildProviderOptions(connection, modelId, thinkingLevel, runtime = resolveModelRuntime(connection, modelId)) {
|
|
343
|
+
return withParallelToolCallOptions(connection, modelId, buildThinkingProviderOptions(connection, modelId, thinkingLevel, runtime), runtime);
|
|
383
344
|
}
|
|
384
|
-
function buildThinkingProviderOptions(connection, modelId, thinkingLevel) {
|
|
345
|
+
function buildThinkingProviderOptions(connection, modelId, thinkingLevel, runtime = resolveModelRuntime(connection, modelId)) {
|
|
385
346
|
const thinkingOptions = thinkingOptionsForModel(connection.providerType, modelId);
|
|
386
347
|
const level = resolveThinkingLevel(connection, modelId, thinkingLevel);
|
|
387
348
|
switch (connection.providerType) {
|
|
@@ -396,7 +357,7 @@ function buildThinkingProviderOptions(connection, modelId, thinkingLevel) {
|
|
|
396
357
|
if (thinkingLevel === 'off')
|
|
397
358
|
return {};
|
|
398
359
|
const effort = level ?? 'max';
|
|
399
|
-
if (
|
|
360
|
+
if (runtime.wire === 'openai-chat') {
|
|
400
361
|
// The kimiCodingPlan provider-options namespace is the
|
|
401
362
|
// openai-compatible adapter name; ai-sdk resolves its camelCase
|
|
402
363
|
// alias to the kimi-coding-plan schema key (reasoning_effort).
|
|
@@ -471,7 +432,7 @@ function buildThinkingProviderOptions(connection, modelId, thinkingLevel) {
|
|
|
471
432
|
};
|
|
472
433
|
}
|
|
473
434
|
case 'openai': {
|
|
474
|
-
const usesResponses =
|
|
435
|
+
const usesResponses = runtime.wire === 'openai-responses';
|
|
475
436
|
const reasoningEffort = level === 'off'
|
|
476
437
|
? 'none'
|
|
477
438
|
: (level ??
|
|
@@ -493,9 +454,7 @@ function buildThinkingProviderOptions(connection, modelId, thinkingLevel) {
|
|
|
493
454
|
};
|
|
494
455
|
case 'xai':
|
|
495
456
|
case 'xai-oauth':
|
|
496
|
-
|
|
497
|
-
// model serves the plain OpenAI-compatible chat wire handled below.
|
|
498
|
-
if (modelId === 'grok-4.5') {
|
|
457
|
+
if (runtime.wire === 'openai-responses') {
|
|
499
458
|
return {
|
|
500
459
|
openai: {
|
|
501
460
|
store: false,
|
|
@@ -506,7 +465,7 @@ function buildThinkingProviderOptions(connection, modelId, thinkingLevel) {
|
|
|
506
465
|
},
|
|
507
466
|
};
|
|
508
467
|
}
|
|
509
|
-
return buildFamilyWire(connection, modelId, level, thinkingOptions, thinkingLevel);
|
|
468
|
+
return buildFamilyWire(connection, modelId, level, thinkingOptions, thinkingLevel, runtime);
|
|
510
469
|
case 'volcengine-ark':
|
|
511
470
|
return {
|
|
512
471
|
[toCamelCase(connection.providerType)]: {
|
|
@@ -550,11 +509,10 @@ function buildThinkingProviderOptions(connection, modelId, thinkingLevel) {
|
|
|
550
509
|
// above (level is defined only when metadata declares it) is what makes
|
|
551
510
|
// this safe to generalize: undeclared models never reach the wire.
|
|
552
511
|
default:
|
|
553
|
-
return buildFamilyWire(connection, modelId, level, thinkingOptions, thinkingLevel);
|
|
512
|
+
return buildFamilyWire(connection, modelId, level, thinkingOptions, thinkingLevel, runtime);
|
|
554
513
|
}
|
|
555
514
|
}
|
|
556
|
-
function withParallelToolCallOptions(connection, modelId, options) {
|
|
557
|
-
const runtime = resolveModelRuntime(connection, modelId);
|
|
515
|
+
function withParallelToolCallOptions(connection, modelId, options, runtime) {
|
|
558
516
|
if (runtime.parallelToolCalls === undefined)
|
|
559
517
|
return options;
|
|
560
518
|
let providerKey;
|
|
@@ -563,16 +521,9 @@ function withParallelToolCallOptions(connection, modelId, options) {
|
|
|
563
521
|
providerKey = 'openai';
|
|
564
522
|
optionKey = 'parallelToolCalls';
|
|
565
523
|
}
|
|
566
|
-
else if (runtime.adapter.kind === 'github-copilot') {
|
|
567
|
-
if (runtime.wire === 'anthropic-messages')
|
|
568
|
-
return options;
|
|
569
|
-
providerKey = runtime.wire === 'openai-responses' ? 'openai' : 'githubCopilot';
|
|
570
|
-
optionKey = runtime.wire === 'openai-responses' ? 'parallelToolCalls' : 'parallel_tool_calls';
|
|
571
|
-
}
|
|
572
524
|
else if (runtime.adapter.kind === 'openai-compatible') {
|
|
573
525
|
if (runtime.wire === 'openai-responses') {
|
|
574
|
-
if (runtime.reasoningReplay.
|
|
575
|
-
runtime.reasoningReplay.contract.adapter !== 'openai') {
|
|
526
|
+
if (runtime.reasoningReplay.contract.adapter !== 'openai') {
|
|
576
527
|
return options;
|
|
577
528
|
}
|
|
578
529
|
providerKey = 'openai';
|
|
@@ -595,8 +546,8 @@ function withParallelToolCallOptions(connection, modelId, options) {
|
|
|
595
546
|
},
|
|
596
547
|
};
|
|
597
548
|
}
|
|
598
|
-
function buildFamilyWire(connection, modelId, level, thinkingOptions, requestedLevel) {
|
|
599
|
-
const { adapter, wire, reasoningReplay } =
|
|
549
|
+
function buildFamilyWire(connection, modelId, level, thinkingOptions, requestedLevel, runtime) {
|
|
550
|
+
const { adapter, wire, reasoningReplay } = runtime;
|
|
600
551
|
const explicitReasoningEffort = level ? (level === 'off' ? 'none' : level) : undefined;
|
|
601
552
|
const serviceTier = wire === 'openai-responses' &&
|
|
602
553
|
reasoningReplay.kind === 'responses' &&
|
|
@@ -609,9 +560,6 @@ function buildFamilyWire(connection, modelId, level, thinkingOptions, requestedL
|
|
|
609
560
|
// consumes a provider-native reasoningEffort through the same namespace,
|
|
610
561
|
// keyed by the provider name getAIModel passes to createOpenResponses.
|
|
611
562
|
if (wire === 'openai-responses') {
|
|
612
|
-
if (reasoningReplay.kind !== 'responses') {
|
|
613
|
-
throw new Error('Responses wire requires a Responses continuation contract');
|
|
614
|
-
}
|
|
615
563
|
// Connection-aware: a relay model's declared variants count too.
|
|
616
564
|
const reasons = thinkingVariantsForConnection(connection, modelId).length > 0;
|
|
617
565
|
if (reasoningReplay.contract.adapter === 'open-responses') {
|
|
@@ -687,16 +635,6 @@ function buildFamilyWire(connection, modelId, level, thinkingOptions, requestedL
|
|
|
687
635
|
? { thinking: { type: 'disabled' } }
|
|
688
636
|
: {},
|
|
689
637
|
};
|
|
690
|
-
case 'github-copilot': {
|
|
691
|
-
// Copilot routes per account-declared model protocol (mirrors the
|
|
692
|
-
// getAIModel case), defaulting to its OpenAI-compatible chat wire. Its
|
|
693
|
-
// Responses protocol is answered by the wire branch above.
|
|
694
|
-
const copilotProtocol = connection.models?.find((model) => model.id === modelId)?.apiProtocol;
|
|
695
|
-
if (copilotProtocol === 'anthropic-messages') {
|
|
696
|
-
return level !== 'off' ? { anthropic: { effort: level } } : {};
|
|
697
|
-
}
|
|
698
|
-
return { githubCopilot: { reasoningEffort: explicitReasoningEffort } };
|
|
699
|
-
}
|
|
700
638
|
default:
|
|
701
639
|
return {};
|
|
702
640
|
}
|
|
@@ -149,6 +149,13 @@ async function fetchProviderModelsStrict(connection, apiKey, fetchFn) {
|
|
|
149
149
|
.filter((model) => discovery.filter !== 'language-models' || model.type === 'language')
|
|
150
150
|
.map(toModelInfo)
|
|
151
151
|
.filter((model) => model !== null);
|
|
152
|
+
if (discovery.modelProtocols === 'commandcode') {
|
|
153
|
+
for (const model of models) {
|
|
154
|
+
if (/^(?:anthropic\/)?claude-/i.test(model.id)) {
|
|
155
|
+
model.apiProtocol = 'anthropic-messages';
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
152
159
|
return filterDiscoveredModels(models, discovery.filter);
|
|
153
160
|
}
|
|
154
161
|
case 'google': {
|
|
@@ -17,59 +17,54 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { PROVIDER_REGISTRY, effectiveBaseUrl, } from '@maka/core/llm-connections';
|
|
20
|
-
import { lookupModelMetadata,
|
|
20
|
+
import { lookupModelMetadata, lookupModelRuntimeOverride, openAiAdapterApiProtocol, } from '@maka/core/model-metadata';
|
|
21
21
|
import { isRetiredProvider } from '@maka/core/provider-registry';
|
|
22
|
+
import { anthropicV1BaseUrl, googleV1BetaBaseUrl, openAiResponsesBaseUrl, } from './provider-urls.js';
|
|
22
23
|
import { resolveApplyPatchProfile } from './apply-patch-profile.js';
|
|
23
24
|
import { resolveRuntimeProviderAdapter, runtimeProviderName, } from './provider-runtime-policy.js';
|
|
24
25
|
export function resolveModelRuntime(connection, modelId) {
|
|
25
|
-
//
|
|
26
|
-
// so consulting it first would let a per-model entry hand a retired provider
|
|
27
|
-
// a working adapter and skip the `unavailable` refusal below entirely. No
|
|
28
|
-
// such entry exists today, but that table is generated from an external
|
|
29
|
-
// source — one row should not be able to undo a retirement.
|
|
26
|
+
// Model metadata cannot reactivate a retired provider.
|
|
30
27
|
if (isRetiredProvider(connection.providerType)) {
|
|
31
28
|
throw new Error(`"${connection.providerType}" is retired and can no longer resolve a model runtime.`);
|
|
32
29
|
}
|
|
33
|
-
const override =
|
|
30
|
+
const override = lookupModelRuntimeOverride(connection.providerType, modelId);
|
|
34
31
|
const defaults = PROVIDER_REGISTRY[connection.providerType];
|
|
35
|
-
// Unknown providerType with no per-model override → can't resolve an adapter.
|
|
36
|
-
// Throw a clear error rather than crashing on `.runtimeAdapter`. Mirrors
|
|
37
|
-
// `isRealConnection` in @maka/core/connection-readiness.ts.
|
|
38
32
|
if (!override && !defaults) {
|
|
39
33
|
throw new Error(`Unknown provider type "${connection.providerType}"; cannot resolve model runtime.`);
|
|
40
34
|
}
|
|
41
35
|
const apiProtocol = connection.models?.find((model) => model.id === modelId)?.apiProtocol;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const adapter = resolveRuntimeProviderAdapter(baseAdapter);
|
|
36
|
+
const baseAdapter = resolveRuntimeProviderAdapter(override?.adapter ?? defaults.runtimeAdapter);
|
|
37
|
+
const calls = adapterCalls(baseAdapter);
|
|
38
|
+
const preferred = openAiAdapterApiProtocol(modelId, connection.providerType);
|
|
39
|
+
const defaultCall = calls.find((call) => call.wire === preferred) ?? calls[0];
|
|
40
|
+
const declared = apiProtocol ? defaults.protocolAdapters?.[apiProtocol] : undefined;
|
|
41
|
+
const call = apiProtocol === undefined
|
|
42
|
+
? defaultCall
|
|
43
|
+
: (calls.find((candidate) => candidate.wire === apiProtocol) ??
|
|
44
|
+
(declared
|
|
45
|
+
? adapterCalls(resolveRuntimeProviderAdapter(declared)).find((candidate) => candidate.wire === apiProtocol)
|
|
46
|
+
: undefined) ??
|
|
47
|
+
adapterCalls(resolveRuntimeProviderAdapter(defaults.runtimeAdapter)).find((candidate) => candidate.wire === apiProtocol));
|
|
48
|
+
if (!call)
|
|
49
|
+
throw new Error(`${defaults.label} does not support ${apiProtocol} for model ${modelId}`);
|
|
50
|
+
const { adapter, wire, reasoningReplay: replay } = call;
|
|
58
51
|
const configuredBaseUrl = connection.baseUrl?.trim();
|
|
59
52
|
const resolvedBaseUrl = configuredBaseUrl
|
|
60
53
|
? effectiveBaseUrl(connection)
|
|
61
|
-
: (override?.
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
: ((calls.includes(call) ? override?.baseUrl : undefined) ?? effectiveBaseUrl(connection));
|
|
55
|
+
const baseUrl = adapter.kind === 'anthropic' && adapter.normalizeBaseUrl
|
|
56
|
+
? anthropicV1BaseUrl(resolvedBaseUrl)
|
|
57
|
+
: adapter.kind === 'google' && adapter.normalizeBaseUrl !== false
|
|
58
|
+
? googleV1BetaBaseUrl(resolvedBaseUrl)
|
|
59
|
+
: adapter.kind === 'openai-compatible' && adapter.normalizeBaseUrl
|
|
60
|
+
? anthropicV1BaseUrl(resolvedBaseUrl)
|
|
61
|
+
: wire === 'openai-responses' && resolvedBaseUrl
|
|
62
|
+
? openAiResponsesBaseUrl(resolvedBaseUrl)
|
|
63
|
+
: resolvedBaseUrl;
|
|
64
|
+
const parallelToolCalls = resolveParallelToolCalls(connection, modelId, baseAdapter);
|
|
65
65
|
return {
|
|
66
|
-
|
|
67
|
-
baseUrl
|
|
68
|
-
? kimiOpenAiBaseUrl(resolvedBaseUrl)
|
|
69
|
-
: resolvedBaseUrl,
|
|
70
|
-
...(apiProtocol ? { apiProtocol } : {}),
|
|
71
|
-
wire,
|
|
72
|
-
reasoningReplay: replay,
|
|
66
|
+
...call,
|
|
67
|
+
baseUrl,
|
|
73
68
|
...(parallelToolCalls === undefined ? {} : { parallelToolCalls }),
|
|
74
69
|
...(replay.kind === 'responses' &&
|
|
75
70
|
replay.contract.adapter === 'open-responses' &&
|
|
@@ -99,88 +94,67 @@ function resolveParallelToolCalls(connection, modelId, adapter) {
|
|
|
99
94
|
// they require an explicit model declaration instead of inheriting this.
|
|
100
95
|
return adapter.kind === 'openai' || adapter.kind === 'openai-codex' ? true : undefined;
|
|
101
96
|
}
|
|
102
|
-
export function modelUsesAnthropicMessages(connection, modelId) {
|
|
103
|
-
return resolveModelRuntime(connection, modelId).wire === 'anthropic-messages';
|
|
104
|
-
}
|
|
105
97
|
/** Native OpenAI lanes keep mutable continuation state inside ModelAdapter. */
|
|
106
98
|
export function modelUsesNativeOpenAiResponses(connection, modelId) {
|
|
107
99
|
return (connection.providerType === 'openai' &&
|
|
108
100
|
resolveModelRuntime(connection, modelId).wire === 'openai-responses');
|
|
109
101
|
}
|
|
110
|
-
function
|
|
102
|
+
function adapterCalls(adapter) {
|
|
111
103
|
switch (adapter.kind) {
|
|
112
104
|
case 'anthropic':
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
// pickers filtering it out; failing here beats sending on a wire we
|
|
117
|
-
// cannot name.
|
|
118
|
-
throw new Error('This provider has no Runtime adapter and cannot resolve a wire.');
|
|
119
|
-
case 'openai-codex':
|
|
120
|
-
return 'openai-responses';
|
|
121
|
-
case 'github-copilot':
|
|
122
|
-
return apiProtocol === 'anthropic-messages'
|
|
123
|
-
? 'anthropic-messages'
|
|
124
|
-
: apiProtocol === 'openai-responses'
|
|
125
|
-
? 'openai-responses'
|
|
126
|
-
: 'openai-chat';
|
|
127
|
-
case 'openai':
|
|
128
|
-
return (adapter.apiProtocol ??
|
|
129
|
-
apiProtocol ??
|
|
130
|
-
openAiAdapterApiProtocol(modelId, providerType)) === 'openai-responses'
|
|
131
|
-
? 'openai-responses'
|
|
132
|
-
: 'openai-chat';
|
|
133
|
-
case 'openai-compatible':
|
|
134
|
-
return adapter.responses !== undefined &&
|
|
135
|
-
(apiProtocol ?? openAiAdapterApiProtocol(modelId, providerType)) === 'openai-responses'
|
|
136
|
-
? 'openai-responses'
|
|
137
|
-
: 'openai-chat';
|
|
105
|
+
return [
|
|
106
|
+
{ adapter, wire: 'anthropic-messages', reasoningReplay: { kind: 'anthropic-signed' } },
|
|
107
|
+
];
|
|
138
108
|
case 'google':
|
|
139
|
-
return 'google-generate';
|
|
109
|
+
return [{ adapter, wire: 'google-generate', reasoningReplay: { kind: 'none' } }];
|
|
140
110
|
case 'cohere':
|
|
141
|
-
return 'cohere-v2';
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
111
|
+
return [{ adapter, wire: 'cohere-v2', reasoningReplay: { kind: 'none' } }];
|
|
112
|
+
case 'openai-codex':
|
|
113
|
+
return [
|
|
114
|
+
{
|
|
115
|
+
adapter,
|
|
116
|
+
wire: 'openai-responses',
|
|
117
|
+
reasoningReplay: {
|
|
118
|
+
kind: 'responses',
|
|
119
|
+
contract: { adapter: 'openai', reasoningReplay: 'encrypted-content' },
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
];
|
|
123
|
+
case 'openai': {
|
|
124
|
+
const calls = [];
|
|
125
|
+
if (adapter.apiProtocol !== 'openai-responses')
|
|
126
|
+
calls.push({ adapter, wire: 'openai-chat', reasoningReplay: { kind: 'none' } });
|
|
127
|
+
if (adapter.apiProtocol !== 'openai-chat')
|
|
128
|
+
calls.push({
|
|
129
|
+
adapter,
|
|
130
|
+
wire: 'openai-responses',
|
|
131
|
+
reasoningReplay: {
|
|
132
|
+
kind: 'responses',
|
|
133
|
+
contract: { adapter: 'openai', reasoningReplay: 'encrypted-content' },
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
return calls;
|
|
137
|
+
}
|
|
138
|
+
case 'openai-compatible': {
|
|
139
|
+
const calls = [
|
|
140
|
+
{
|
|
141
|
+
adapter,
|
|
142
|
+
wire: 'openai-chat',
|
|
143
|
+
reasoningReplay: {
|
|
144
|
+
kind: 'openai-chat-plaintext',
|
|
145
|
+
requestField: adapter.replayAssistantReasoningAs ?? 'observed',
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
];
|
|
149
|
+
if (adapter.responses)
|
|
150
|
+
calls.push({
|
|
151
|
+
adapter,
|
|
152
|
+
wire: 'openai-responses',
|
|
153
|
+
reasoningReplay: { kind: 'responses', contract: adapter.responses },
|
|
154
|
+
});
|
|
155
|
+
return calls;
|
|
156
|
+
}
|
|
157
|
+
case 'unavailable':
|
|
158
|
+
throw new Error('This provider has no Runtime adapter and cannot resolve a wire.');
|
|
185
159
|
}
|
|
186
160
|
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { z } from 'zod';
|
|
20
20
|
import { resolveHostedWebSearchCapability } from '@maka/core/model-web-search';
|
|
21
|
+
import { resolveModelRuntime } from './model-runtime.js';
|
|
21
22
|
export const NATIVE_WEB_SEARCH_TOOL_NAME = 'WebSearch';
|
|
22
23
|
/**
|
|
23
24
|
* Provider-executed search descriptor. AI SDK compiles this into the selected
|
|
@@ -61,7 +62,7 @@ export function routeWebSearchTools(input) {
|
|
|
61
62
|
: undefined;
|
|
62
63
|
}
|
|
63
64
|
else {
|
|
64
|
-
const capability = resolveHostedWebSearchCapability(input.connection.providerType, input.connection.models, input.model);
|
|
65
|
+
const capability = resolveHostedWebSearchCapability(input.connection.providerType, input.connection.models, input.model, resolveModelRuntime(input.connection, input.model).wire);
|
|
65
66
|
if ((firstSearchIndex >= 0 || input.allowAddNative === true) &&
|
|
66
67
|
capability?.implemented === true &&
|
|
67
68
|
capability.adapter === 'openai-responses') {
|
|
@@ -91,7 +91,7 @@ export function buildOpenAiCodexHistoryCompactor(options) {
|
|
|
91
91
|
catch (error) {
|
|
92
92
|
if (error instanceof HistoryCompactSummarizerError)
|
|
93
93
|
throw error;
|
|
94
|
-
if (classifyError(error) === '
|
|
94
|
+
if (classifyError(error) === 'context_overflow') {
|
|
95
95
|
throw new HistoryCompactSummarizerError('input_too_large', { cause: error });
|
|
96
96
|
}
|
|
97
97
|
throw new HistoryCompactSummarizerError('provider_error', { cause: error });
|
|
@@ -126,7 +126,7 @@ export function shouldFallbackFromOpenAiCodexHistoryCompaction(error, abortSigna
|
|
|
126
126
|
if (error.reason !== 'provider_error')
|
|
127
127
|
return false;
|
|
128
128
|
const diagnostic = providerFailureDiagnostic(error);
|
|
129
|
-
return diagnostic.errorClass === '
|
|
129
|
+
return diagnostic.errorClass === 'request_rejected' && !diagnostic.retryable;
|
|
130
130
|
}
|
|
131
131
|
function hasAbortCause(error) {
|
|
132
132
|
const seen = new Set();
|
|
@@ -17,11 +17,13 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
export const OPENCODE_SESSION_HEADER = 'x-opencode-session';
|
|
20
|
-
/** Adds OpenCode Go
|
|
20
|
+
/** Adds OpenCode Go/Free session identity without overriding an explicit header. */
|
|
21
21
|
export function withOpenCodeSessionHeader(providerType, sessionId, headers) {
|
|
22
22
|
const normalizedSessionId = sessionId?.trim();
|
|
23
|
-
if (providerType !== 'opencode-go'
|
|
23
|
+
if ((providerType !== 'opencode-go' && providerType !== 'opencode-free') ||
|
|
24
|
+
!normalizedSessionId) {
|
|
24
25
|
return headers;
|
|
26
|
+
}
|
|
25
27
|
if (Object.keys(headers ?? {}).some((name) => name.toLowerCase() === OPENCODE_SESSION_HEADER)) {
|
|
26
28
|
return headers;
|
|
27
29
|
}
|