maka-agent 0.2.0-dev.23.20260906 → 0.2.0-dev.25.20260908
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/README.md +38 -19
- package/README.zh-CN.md +34 -19
- 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-tools.js +6 -0
- package/dist/pi-transcript.js +5 -12
- package/dist/pi-tui-layout.js +56 -10
- package/dist/pi-tui-pickers.js +102 -1
- package/dist/pi-tui-runner.js +230 -46
- package/dist/pi-tui-todo.js +221 -0
- package/dist/pi-tui-transcript-viewer.js +134 -7
- package/dist/runtime-host-cli-context.js +224 -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 +106 -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 +48 -5
- 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 -3
- package/dist/runtime-host-session-channel.js +13 -0
- package/dist/runtime-host-session-driver.js +46 -26
- 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 +219 -6
- 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/agent-run.js +1 -0
- package/node_modules/@maka/core/dist/attachments.js +3 -0
- package/node_modules/@maka/core/dist/canonical-json.js +27 -0
- package/node_modules/@maka/core/dist/canonical-runtime-event.js +3 -1
- package/node_modules/@maka/core/dist/capabilities.js +35 -0
- package/node_modules/@maka/core/dist/computer-use.js +0 -1
- package/node_modules/@maka/core/dist/display-redaction.js +18 -0
- package/node_modules/@maka/core/dist/llm-connections.js +13 -0
- package/node_modules/@maka/core/dist/model-call-attempt.js +2 -0
- 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 +7 -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/redaction.js +35 -0
- package/node_modules/@maka/core/dist/run-composition.js +77 -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 +84 -56
- package/node_modules/@maka/core/dist/slash-command-catalog.js +3 -0
- package/node_modules/@maka/core/dist/tool-result-archive-evidence.js +20 -0
- package/node_modules/@maka/core/dist/tool-result-record-schema.js +2 -1
- package/node_modules/@maka/core/dist/usage-record-schema.js +26 -35
- package/node_modules/@maka/core/package.json +5 -0
- package/node_modules/@maka/eval/dist/experiment-directory.js +4 -13
- package/node_modules/@maka/mcp/dist/index.js +131 -1
- package/node_modules/@maka/runtime/dist/agent-run-inspect.js +0 -13
- package/node_modules/@maka/runtime/dist/agent-run.js +351 -105
- package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +29 -13
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +109 -34
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +184 -183
- package/node_modules/@maka/runtime/dist/archive-read-tool.js +2 -2
- package/node_modules/@maka/runtime/dist/context-budget-helpers.js +0 -16
- package/node_modules/@maka/runtime/dist/context-budget.js +14 -9
- package/node_modules/@maka/runtime/dist/conversation-copy.js +158 -15
- package/node_modules/@maka/runtime/dist/github-copilot-oauth-enrollment.js +3 -3
- 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 +174 -0
- package/node_modules/@maka/runtime/dist/mcp-tools.js +7 -2
- 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 +49 -2
- package/node_modules/@maka/runtime/dist/model-history.js +0 -112
- 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/plugin-runtime.js +20 -10
- package/node_modules/@maka/runtime/dist/plugin-tool-service.js +205 -0
- package/node_modules/@maka/runtime/dist/provider-error-classification.js +84 -123
- package/node_modules/@maka/runtime/dist/provider-request-telemetry.js +76 -109
- package/node_modules/@maka/runtime/dist/request-shape.js +23 -0
- package/node_modules/@maka/runtime/dist/run-handoff-gate.js +97 -0
- package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +83 -55
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +121 -159
- package/node_modules/@maka/runtime/dist/runtime-kernel.js +157 -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/stream-graph-coordinator.js +21 -0
- package/node_modules/@maka/runtime/dist/stream-graph-supervisor-tools.js +0 -5
- package/node_modules/@maka/runtime/dist/subscription-model-fetch.js +3 -4
- package/node_modules/@maka/runtime/dist/test-connection.js +16 -17
- package/node_modules/@maka/runtime/dist/tool-activation-identity.js +41 -0
- package/node_modules/@maka/runtime/dist/tool-availability.js +11 -1
- package/node_modules/@maka/runtime/dist/tool-result-archive-encoding.js +38 -0
- package/node_modules/@maka/runtime/dist/tool-result-archive-resource.js +63 -1
- package/node_modules/@maka/runtime/dist/tool-result-archive-transition.js +42 -12
- package/node_modules/@maka/runtime/dist/tool-result-archive.js +27 -4
- package/node_modules/@maka/runtime/dist/tool-runtime.js +3 -61
- package/node_modules/@maka/runtime/package.json +2 -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 +179 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +275 -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 +46 -5
- package/node_modules/@maka/runtime-host/dist/control/endpoint.js +1 -3
- package/node_modules/@maka/runtime-host/dist/node-error.js +22 -0
- package/node_modules/@maka/runtime-host/dist/operator/index.js +2 -1
- package/node_modules/@maka/runtime-host/dist/operator/managed-deployment.js +1 -3
- package/node_modules/@maka/runtime-host/dist/operator/retirement-cancellation.js +20 -0
- package/node_modules/@maka/runtime-host/dist/peer-mesh/limits.js +0 -1
- package/node_modules/@maka/runtime-host/dist/peer-mesh/model.js +1 -1
- package/node_modules/@maka/runtime-host/dist/peer-reachability/publisher.js +1 -3
- package/node_modules/@maka/runtime-host/dist/protocol/host-status.js +21 -12
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +29 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +1 -0
- package/node_modules/@maka/runtime-host/dist/protocol/plan.js +1 -0
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +27 -5
- package/node_modules/@maka/runtime-host/dist/protocol/project-catalog.js +2 -2
- 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 +31 -2
- package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +1 -0
- package/node_modules/@maka/runtime-host/dist/server/agent-graph-coordinator.js +0 -3
- 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-artifacts.js +32 -32
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +144 -33
- 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 +45 -16
- 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/interactive-run-composer.js +47 -22
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +76 -6
- package/node_modules/@maka/runtime-host/dist/server/plugin-platform-coordinator.js +6 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-platform.js +6 -0
- 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-retirement-coordinator.js +5 -2
- package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +12 -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-action-gate.js +20 -2
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +13 -4
- package/node_modules/@maka/runtime-host/dist/server/workhub-message-attachments.js +46 -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 -5
- package/node_modules/@maka/storage/dist/codex-session-adapter.js +284 -198
- 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/git-exec.js +61 -0
- package/node_modules/@maka/storage/dist/git-worktree-child-executor.js +8 -35
- package/node_modules/@maka/storage/dist/goal-authority.js +2 -2
- package/node_modules/@maka/storage/dist/interaction-store.js +2 -2
- 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/project-catalog.js +2 -23
- package/node_modules/@maka/storage/dist/runtime-event-invariants.js +2 -2
- package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
- package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +8 -3
- package/node_modules/@maka/storage/dist/runtime-transcript-query.js +308 -0
- package/node_modules/@maka/storage/dist/scheduled-task-store.js +249 -283
- package/node_modules/@maka/storage/dist/session-bundle-manifest.js +5 -17
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +26 -5
- package/node_modules/@maka/storage/dist/session-copy-cleanup.js +2 -1
- 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 +130 -27
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +109 -892
- package/node_modules/@maka/storage/dist/storage-id.js +28 -0
- package/node_modules/@maka/storage/dist/tool-result-archive-evidence.js +138 -0
- package/node_modules/@maka/storage/dist/workspace-identity.js +2 -15
- package/node_modules/@maka/storage/dist/workspace-version-authority-internal.js +1 -8
- package/node_modules/@maka/storage/package.json +2 -0
- package/package.json +1 -1
|
@@ -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',
|
|
@@ -49,6 +48,10 @@ const GENERATED_METADATA_PROVIDER_ALIASES = {
|
|
|
49
48
|
function generatedMetadataProviderType(providerType) {
|
|
50
49
|
return GENERATED_METADATA_PROVIDER_ALIASES[providerType] ?? providerType;
|
|
51
50
|
}
|
|
51
|
+
/** Whether discovery is the complete usable model catalog for this account. */
|
|
52
|
+
export function providerReportsCompleteModelCatalog(providerType) {
|
|
53
|
+
return providerType === 'github-copilot';
|
|
54
|
+
}
|
|
52
55
|
/**
|
|
53
56
|
* Whether the active metadata describes this model at all. `lookupModelMetadata`
|
|
54
57
|
* answers "no" with an empty object, and callers were reading that sentinel by
|
|
@@ -95,8 +98,9 @@ export function modelMetadataIdsForProvider(providerType) {
|
|
|
95
98
|
: []),
|
|
96
99
|
]));
|
|
97
100
|
}
|
|
98
|
-
export function
|
|
99
|
-
|
|
101
|
+
export function lookupModelRuntimeOverride(providerType, modelId) {
|
|
102
|
+
const overrides = GENERATED_MODELS_DEV_MODEL_PROVIDER_OVERRIDES;
|
|
103
|
+
return overrides[providerType]?.[modelId.trim()];
|
|
100
104
|
}
|
|
101
105
|
/**
|
|
102
106
|
* 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,7 @@ 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));
|
|
35
42
|
}
|
|
36
43
|
/**
|
|
37
44
|
* Narrows a record to the keys a shape allows. `undefined` entries are dropped
|
|
@@ -53,6 +53,7 @@ export function redactSecrets(value) {
|
|
|
53
53
|
}
|
|
54
54
|
function redactTextSecrets(value) {
|
|
55
55
|
let next = value;
|
|
56
|
+
next = redactUrlUserinfoSecrets(next);
|
|
56
57
|
next = redactUrlQuerySecrets(next);
|
|
57
58
|
next = next.replace(QUOTED_SECRET_KEY_VALUE_PATTERN, (match, prefix, key) => isSensitiveKey(key) ? `${prefix}[redacted]` : match);
|
|
58
59
|
next = next.replace(AUTHORIZATION_HEADER_PATTERN, (_match, boundary, prefix) => `${boundary}${prefix}[redacted]`);
|
|
@@ -134,6 +135,17 @@ function redactJsonValue(value) {
|
|
|
134
135
|
}
|
|
135
136
|
return { value: next, changed };
|
|
136
137
|
}
|
|
138
|
+
function redactUrlUserinfoSecrets(value) {
|
|
139
|
+
// Authority runs through the first `/`, `?`, `#`, whitespace, quote, or
|
|
140
|
+
// angle bracket. If it contains `@`, everything from the host-start through
|
|
141
|
+
// the last `@` is userinfo. The class matches display-redaction's
|
|
142
|
+
// streamingTerminator so a bare `https://host` followed later by an
|
|
143
|
+
// email/`@package` (including across JSON quotes) cannot swallow the gap.
|
|
144
|
+
// Known boundary: punctuation like commas can still join a bare URL to a
|
|
145
|
+
// later `@` into one fake credentialed match; a proper fix would restrict
|
|
146
|
+
// userinfo to the RFC 3986 set instead of exclusion. http(s) only for now.
|
|
147
|
+
return value.replace(/(https?:\/\/)[^\s"'<>/?#]*@/gi, '$1[redacted]@');
|
|
148
|
+
}
|
|
137
149
|
function redactUrlQuerySecrets(value) {
|
|
138
150
|
return value.replace(/([?&])([^=\s&?#]+)=([^&\s#]*)/g, (match, sep, key) => {
|
|
139
151
|
if (!isSensitiveKey(key))
|
|
@@ -191,6 +203,10 @@ export function classifyGeneralizedError(error) {
|
|
|
191
203
|
return 'provider_error';
|
|
192
204
|
if (lower.includes('network') ||
|
|
193
205
|
lower.includes('fetch') ||
|
|
206
|
+
// Chromium network stack error codes (`net::ERR_CONNECTION_RESET`,
|
|
207
|
+
// `net::ERR_NAME_NOT_RESOLVED`, ...) never match the Node errno
|
|
208
|
+
// spellings below.
|
|
209
|
+
lower.includes('net::err') ||
|
|
194
210
|
lower.includes('econn') ||
|
|
195
211
|
lower.includes('enotfound'))
|
|
196
212
|
return 'network_error';
|
|
@@ -231,3 +247,22 @@ export function generalizedErrorMessage(error, fallback = 'Operation failed') {
|
|
|
231
247
|
export function isAuthenticationErrorText(message) {
|
|
232
248
|
return message.replace(/\bauthorit\w*/g, '').includes('auth');
|
|
233
249
|
}
|
|
250
|
+
const reportedFailures = new WeakSet();
|
|
251
|
+
/** Redacted diagnostics channel for unexpected operation failures. Copy
|
|
252
|
+
* catalogs live here (bare-importable) because a depended-on copy catalog may
|
|
253
|
+
* only hold bare package runtime imports. */
|
|
254
|
+
export function reportUnexpectedOperation(scope, error) {
|
|
255
|
+
// One failure, one diagnostic: a rejection formatted again by an outer layer
|
|
256
|
+
// is the same defect, not a second one.
|
|
257
|
+
if (typeof error === 'object' && error !== null) {
|
|
258
|
+
if (reportedFailures.has(error))
|
|
259
|
+
return;
|
|
260
|
+
reportedFailures.add(error);
|
|
261
|
+
}
|
|
262
|
+
const detail = error instanceof Error ? (error.stack ?? `${error.name}: ${error.message}`) : String(error);
|
|
263
|
+
console.error(`[${scope}] operation failed:`, redactSecrets(detail));
|
|
264
|
+
}
|
|
265
|
+
export function unexpectedOperationFallback(error, fallback, scope) {
|
|
266
|
+
reportUnexpectedOperation(scope, error);
|
|
267
|
+
return fallback;
|
|
268
|
+
}
|
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { defineObjectShape, hasExactShape, isRecord } from './record-schema.js';
|
|
20
20
|
export const RUN_COMPOSITION_SCHEMA_VERSION = 1;
|
|
21
|
+
export const REQUEST_COMPOSITION_SCHEMA_VERSION = 1;
|
|
22
|
+
// Composition evidence is exact: reject an over-bound provider surface rather
|
|
23
|
+
// than silently truncating the resolved snapshot.
|
|
24
|
+
export const COMPOSITION_MAX_TOOLS = 256;
|
|
25
|
+
export const COMPOSITION_MAX_TOOL_NAME_LENGTH = 128;
|
|
26
|
+
export const REQUEST_COMPOSITION_MAX_TOOL_DESCRIPTION_LENGTH = 16_384;
|
|
21
27
|
const RUN_COMPOSITION_SHAPE = defineObjectShape()([
|
|
22
28
|
'schemaVersion',
|
|
23
29
|
'composerId',
|
|
@@ -30,6 +36,20 @@ const RUN_COMPOSITION_SHAPE = defineObjectShape()([
|
|
|
30
36
|
'toolNames',
|
|
31
37
|
'contextWindow',
|
|
32
38
|
], []);
|
|
39
|
+
const REQUEST_COMPOSITION_SHAPE = defineObjectShape()([
|
|
40
|
+
'schemaVersion',
|
|
41
|
+
'compositionId',
|
|
42
|
+
'step',
|
|
43
|
+
'reason',
|
|
44
|
+
'sourceRevisions',
|
|
45
|
+
'systemPromptHash',
|
|
46
|
+
'toolCatalogHash',
|
|
47
|
+
'toolAvailabilityHash',
|
|
48
|
+
'providerOptionsHash',
|
|
49
|
+
'toolNames',
|
|
50
|
+
'toolSchemas',
|
|
51
|
+
], []);
|
|
52
|
+
const REQUEST_COMPOSITION_TOOL_SCHEMA_SHAPE = defineObjectShape()(['name', 'description', 'inputSchema'], ['providerTool']);
|
|
33
53
|
const ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;
|
|
34
54
|
const HASH_PATTERN = /^sha256:[a-f0-9]{64}$/;
|
|
35
55
|
const SOURCE_REVISION_SHAPE = defineObjectShape()(['id', 'revision'], []);
|
|
@@ -64,6 +84,41 @@ export function createRunCompositionSnapshot(input) {
|
|
|
64
84
|
toolNames: [...input.toolNames].sort(compareExactString),
|
|
65
85
|
});
|
|
66
86
|
}
|
|
87
|
+
export function createRequestCompositionSnapshot(input, reason) {
|
|
88
|
+
return decodeRequestCompositionSnapshot({
|
|
89
|
+
schemaVersion: REQUEST_COMPOSITION_SCHEMA_VERSION,
|
|
90
|
+
...input,
|
|
91
|
+
reason,
|
|
92
|
+
sourceRevisions: [...input.sourceRevisions].sort((left, right) => compareExactString(left.id, right.id)),
|
|
93
|
+
toolNames: [...input.toolNames].sort(compareExactString),
|
|
94
|
+
toolSchemas: [...input.toolSchemas].sort((left, right) => compareExactString(left.name, right.name)),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
export function decodeRequestCompositionSnapshot(value) {
|
|
98
|
+
if (!isRecord(value) || !hasExactShape(value, REQUEST_COMPOSITION_SHAPE)) {
|
|
99
|
+
throw new Error('Invalid Request Composition snapshot schema');
|
|
100
|
+
}
|
|
101
|
+
const valid = value.schemaVersion === REQUEST_COMPOSITION_SCHEMA_VERSION &&
|
|
102
|
+
boundedString(value.compositionId, 128) &&
|
|
103
|
+
Number.isSafeInteger(value.step) &&
|
|
104
|
+
value.step >= 0 &&
|
|
105
|
+
(value.reason === 'initial' || value.reason === 'change') &&
|
|
106
|
+
canonicalSourceRevisions(value.sourceRevisions) &&
|
|
107
|
+
hash(value.systemPromptHash) &&
|
|
108
|
+
hash(value.toolCatalogHash) &&
|
|
109
|
+
hash(value.toolAvailabilityHash) &&
|
|
110
|
+
hash(value.providerOptionsHash) &&
|
|
111
|
+
canonicalToolNames(value.toolNames) &&
|
|
112
|
+
canonicalToolSchemas(value.toolSchemas);
|
|
113
|
+
if (!valid)
|
|
114
|
+
throw new Error('Invalid Request Composition snapshot schema');
|
|
115
|
+
return Object.freeze({
|
|
116
|
+
...value,
|
|
117
|
+
sourceRevisions: Object.freeze(value.sourceRevisions.map((source) => Object.freeze({ ...source }))),
|
|
118
|
+
toolNames: Object.freeze([...value.toolNames]),
|
|
119
|
+
toolSchemas: Object.freeze(value.toolSchemas.map((schema) => Object.freeze(structuredClone(schema)))),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
67
122
|
function compareExactString(left, right) {
|
|
68
123
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
69
124
|
}
|
|
@@ -84,16 +139,36 @@ function canonicalSourceRevisions(value) {
|
|
|
84
139
|
return true;
|
|
85
140
|
}
|
|
86
141
|
function canonicalToolNames(value) {
|
|
87
|
-
if (!Array.isArray(value) || value.length >
|
|
142
|
+
if (!Array.isArray(value) || value.length > COMPOSITION_MAX_TOOLS)
|
|
88
143
|
return false;
|
|
89
144
|
let previous;
|
|
90
145
|
for (const name of value) {
|
|
91
|
-
if (!boundedString(name,
|
|
146
|
+
if (!boundedString(name, COMPOSITION_MAX_TOOL_NAME_LENGTH) ||
|
|
147
|
+
(previous !== undefined && previous >= name)) {
|
|
92
148
|
return false;
|
|
149
|
+
}
|
|
93
150
|
previous = name;
|
|
94
151
|
}
|
|
95
152
|
return true;
|
|
96
153
|
}
|
|
154
|
+
function canonicalToolSchemas(value) {
|
|
155
|
+
if (!Array.isArray(value) || value.length > COMPOSITION_MAX_TOOLS)
|
|
156
|
+
return false;
|
|
157
|
+
let previous;
|
|
158
|
+
for (const schema of value) {
|
|
159
|
+
if (!isRecord(schema) ||
|
|
160
|
+
!hasExactShape(schema, REQUEST_COMPOSITION_TOOL_SCHEMA_SHAPE) ||
|
|
161
|
+
!boundedString(schema.name, COMPOSITION_MAX_TOOL_NAME_LENGTH) ||
|
|
162
|
+
!boundedString(schema.description, REQUEST_COMPOSITION_MAX_TOOL_DESCRIPTION_LENGTH) ||
|
|
163
|
+
!isRecord(schema.inputSchema) ||
|
|
164
|
+
(schema.providerTool !== undefined && !isRecord(schema.providerTool)) ||
|
|
165
|
+
(previous !== undefined && previous >= schema.name)) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
previous = schema.name;
|
|
169
|
+
}
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
97
172
|
function hash(value) {
|
|
98
173
|
return typeof value === 'string' && HASH_PATTERN.test(value);
|
|
99
174
|
}
|
|
@@ -65,6 +65,8 @@ export function createRuntimeBoundaryCursor(segments) {
|
|
|
65
65
|
const invocationIds = new Set();
|
|
66
66
|
const runIds = new Set();
|
|
67
67
|
const turnIds = new Set();
|
|
68
|
+
let previousTurnId;
|
|
69
|
+
let protocol = 'runtime_boundary_cursor_v1';
|
|
68
70
|
for (const segment of canonicalSegments) {
|
|
69
71
|
if (segment.identity.sessionId !== sessionId) {
|
|
70
72
|
throw new Error('Runtime boundary segments must belong to the same session');
|
|
@@ -78,24 +80,30 @@ export function createRuntimeBoundaryCursor(segments) {
|
|
|
78
80
|
}
|
|
79
81
|
invocationIds.add(segment.identity.invocationId);
|
|
80
82
|
if (turnIds.has(segment.identity.turnId)) {
|
|
81
|
-
|
|
83
|
+
if (previousTurnId !== segment.identity.turnId) {
|
|
84
|
+
throw new Error('Runtime boundary lineage returns to a previous turnId');
|
|
85
|
+
}
|
|
86
|
+
protocol = 'runtime_boundary_cursor_v2';
|
|
82
87
|
}
|
|
83
88
|
turnIds.add(segment.identity.turnId);
|
|
89
|
+
previousTurnId = segment.identity.turnId;
|
|
84
90
|
}
|
|
85
91
|
return {
|
|
86
|
-
protocol
|
|
92
|
+
protocol,
|
|
87
93
|
segments: canonicalSegments,
|
|
88
|
-
manifestDigest: digestRuntimeBoundaryManifest(canonicalSegments),
|
|
94
|
+
manifestDigest: digestRuntimeBoundaryManifest(canonicalSegments, protocol),
|
|
89
95
|
};
|
|
90
96
|
}
|
|
91
|
-
export function digestRuntimeBoundaryManifest(segments) {
|
|
97
|
+
export function digestRuntimeBoundaryManifest(segments, protocol = 'runtime_boundary_cursor_v1') {
|
|
92
98
|
const canonicalSegments = segments.map(decodeRuntimePrefixSegment);
|
|
93
99
|
const json = stableJsonStringify({
|
|
94
|
-
protocol
|
|
100
|
+
protocol,
|
|
95
101
|
segments: canonicalSegments,
|
|
96
102
|
});
|
|
97
103
|
const hash = nodeCrypto.createHash('sha256');
|
|
98
|
-
updateLengthPrefixed(hash, Buffer.from(
|
|
104
|
+
updateLengthPrefixed(hash, Buffer.from(protocol === 'runtime_boundary_cursor_v1'
|
|
105
|
+
? 'maka.runtime-boundary-manifest.v1'
|
|
106
|
+
: 'maka.runtime-boundary-manifest.v2', 'utf8'));
|
|
99
107
|
updateLengthPrefixed(hash, Buffer.from(json, 'utf8'));
|
|
100
108
|
return `sha256:${hash.digest('hex')}`;
|
|
101
109
|
}
|
|
@@ -115,13 +123,16 @@ export function decodeRuntimePrefixSegment(value) {
|
|
|
115
123
|
export function decodeRuntimeBoundaryCursor(value) {
|
|
116
124
|
if (!isRecord(value) ||
|
|
117
125
|
!hasExactKeys(value, ['protocol', 'segments', 'manifestDigest']) ||
|
|
118
|
-
value.protocol !== 'runtime_boundary_cursor_v1'
|
|
126
|
+
(value.protocol !== 'runtime_boundary_cursor_v1' &&
|
|
127
|
+
value.protocol !== 'runtime_boundary_cursor_v2') ||
|
|
119
128
|
!Array.isArray(value.segments) ||
|
|
120
129
|
value.segments.length === 0) {
|
|
121
130
|
throw new Error('Invalid RuntimeEvent boundary cursor');
|
|
122
131
|
}
|
|
123
132
|
const segments = value.segments.map(decodeRuntimePrefixSegment);
|
|
124
133
|
const cursor = createRuntimeBoundaryCursor(segments);
|
|
134
|
+
if (cursor.protocol !== value.protocol)
|
|
135
|
+
throw new Error('RuntimeEvent boundary cursor version mismatch');
|
|
125
136
|
const manifestDigest = decodeBoundaryDigest(value.manifestDigest);
|
|
126
137
|
if (cursor.manifestDigest !== manifestDigest) {
|
|
127
138
|
throw new Error('RuntimeEvent boundary manifest digest mismatch');
|
|
@@ -173,12 +184,21 @@ export function decodeContinuationClaim(value) {
|
|
|
173
184
|
throw new Error('Continuation claim target invocationId reuses source identity');
|
|
174
185
|
}
|
|
175
186
|
const targetTurnId = value.target.turnId;
|
|
176
|
-
if (boundary.segments.some((segment) => segment.identity.turnId === targetTurnId)) {
|
|
177
|
-
throw new Error('Continuation claim target turnId reuses source identity');
|
|
178
|
-
}
|
|
179
187
|
const targetOpening = decodeRuntimeInvocationOpened(value.targetOpening);
|
|
180
188
|
const openSource = targetOpening.source;
|
|
181
|
-
if (openSource.kind
|
|
189
|
+
if (openSource.kind === 'handoff') {
|
|
190
|
+
if (targetTurnId !== source.identity.turnId) {
|
|
191
|
+
throw new Error('Handoff claim must preserve the logical turnId');
|
|
192
|
+
}
|
|
193
|
+
const root = boundary.segments.find((segment) => segment.identity.turnId === targetTurnId);
|
|
194
|
+
if (root?.identity.runId !== openSource.rootRunId) {
|
|
195
|
+
throw new Error('Handoff claim logical root mismatch');
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else if (boundary.segments.some((segment) => segment.identity.turnId === targetTurnId)) {
|
|
199
|
+
throw new Error('Continuation claim target turnId reuses source identity');
|
|
200
|
+
}
|
|
201
|
+
if ((openSource.kind !== 'continuation' && openSource.kind !== 'handoff') ||
|
|
182
202
|
openSource.claimId !== value.claimId ||
|
|
183
203
|
openSource.boundaryDigest !== boundaryDigest ||
|
|
184
204
|
openSource.sourceInvocationId !== source.identity.invocationId ||
|