@myagentroam/agent 0.11.32 → 0.11.34
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/cli/catalog-file.d.ts +78 -0
- package/dist/cli/catalog-file.js +102 -0
- package/dist/cli/codex-auth-file.d.ts +1 -1
- package/dist/cli/codex-auth-file.js +9 -10
- package/dist/cli/main.js +44 -54
- package/dist/error.d.ts +15 -0
- package/dist/error.js +74 -0
- package/dist/extensions/agents.d.ts +100 -0
- package/dist/extensions/agents.js +121 -0
- package/dist/extensions/capabilities.d.ts +4 -0
- package/dist/extensions/commands.d.ts +23 -0
- package/dist/extensions/commands.js +45 -0
- package/dist/extensions/compaction.d.ts +36 -0
- package/dist/extensions/contracts.d.ts +147 -0
- package/dist/extensions/data.d.ts +81 -0
- package/dist/extensions/data.js +78 -0
- package/dist/extensions/environment.d.ts +39 -0
- package/dist/extensions/environment.js +52 -0
- package/dist/extensions/files.d.ts +68 -0
- package/dist/extensions/files.js +26 -0
- package/dist/extensions/hooks.d.ts +32 -0
- package/dist/extensions/host-ports.d.ts +24 -0
- package/dist/extensions/manager.d.ts +42 -0
- package/dist/extensions/manager.js +457 -0
- package/dist/extensions/mcp.d.ts +116 -0
- package/dist/extensions/mcp.js +434 -0
- package/dist/extensions/model-request.d.ts +65 -0
- package/dist/extensions/model-request.js +197 -0
- package/dist/extensions/model-stream.d.ts +18 -0
- package/dist/extensions/model-stream.js +108 -0
- package/dist/extensions/models.d.ts +46 -0
- package/dist/extensions/models.js +7 -0
- package/dist/extensions/network.d.ts +40 -0
- package/dist/extensions/network.js +97 -0
- package/dist/extensions/operation.d.ts +32 -0
- package/dist/extensions/processes.d.ts +64 -0
- package/dist/extensions/processes.js +284 -0
- package/dist/extensions/prompt-composition.d.ts +38 -0
- package/dist/extensions/prompt-composition.js +100 -0
- package/dist/extensions/prompt-input.d.ts +30 -0
- package/dist/extensions/prompt-input.js +48 -0
- package/dist/extensions/prompts.d.ts +31 -0
- package/dist/extensions/prompts.js +88 -0
- package/dist/extensions/resources.d.ts +26 -0
- package/dist/extensions/resources.js +221 -0
- package/dist/extensions/services.d.ts +31 -0
- package/dist/extensions/services.js +61 -0
- package/dist/extensions/session-api.d.ts +6 -0
- package/dist/extensions/session-api.js +52 -0
- package/dist/extensions/session-input.d.ts +184 -0
- package/dist/extensions/session-input.js +422 -0
- package/dist/extensions/session-messages.d.ts +41 -0
- package/dist/extensions/session-messages.js +76 -0
- package/dist/extensions/session-tools.d.ts +32 -0
- package/dist/extensions/session-tools.js +208 -0
- package/dist/extensions/session.d.ts +60 -0
- package/dist/extensions/session.js +265 -0
- package/dist/extensions/settings.d.ts +76 -0
- package/dist/extensions/settings.js +115 -0
- package/dist/extensions/store.d.ts +10 -0
- package/dist/extensions/store.js +131 -0
- package/dist/extensions/tool-runtime.d.ts +16 -0
- package/dist/extensions/tools.d.ts +80 -0
- package/dist/extensions/tools.js +270 -0
- package/dist/extensions.d.ts +22 -0
- package/dist/host/contracts.d.ts +58 -0
- package/dist/host/contracts.js +18 -0
- package/dist/host/description.d.ts +19 -0
- package/dist/host/local-agent-host.d.ts +96 -0
- package/dist/host/local-agent-host.js +429 -0
- package/dist/host/local-exec-tool.d.ts +26 -0
- package/dist/host/local-exec-tool.js +686 -0
- package/dist/host/local-file-access.d.ts +30 -0
- package/dist/host/local-file-access.js +107 -0
- package/dist/host/local-network-access.d.ts +6 -0
- package/dist/host/local-network-access.js +101 -0
- package/dist/host/local-process-executor.d.ts +5 -0
- package/dist/host/local-process-executor.js +17 -0
- package/dist/host/local-session-environment.d.ts +18 -0
- package/dist/host/local-shell.d.ts +3 -0
- package/dist/host/local-tool-registry.d.ts +34 -0
- package/dist/host/local-tool-registry.js +134 -0
- package/dist/host/network.d.ts +5 -0
- package/dist/host/network.js +42 -0
- package/dist/host/process-control.d.ts +2 -0
- package/dist/host/process-control.js +26 -0
- package/dist/host/skill-contract.d.ts +6 -0
- package/dist/host.d.ts +17 -0
- package/dist/host.js +3 -0
- package/dist/index.d.ts +26 -51
- package/dist/index.js +9 -12
- package/dist/model/anthropic-messages.d.ts +10 -0
- package/dist/model/anthropic-messages.js +692 -0
- package/dist/model/anthropic-thinking.js +33 -0
- package/dist/model/configuration.d.ts +111 -0
- package/dist/model/configuration.js +201 -0
- package/dist/model/contracts.d.ts +229 -0
- package/dist/model/http.d.ts +13 -0
- package/dist/model/http.js +119 -0
- package/dist/model/image-contract.d.ts +10 -0
- package/dist/model/image.d.ts +9 -0
- package/dist/model/inline-media-budget.d.ts +7 -0
- package/dist/model/inline-media-budget.js +36 -0
- package/dist/model/input-images.d.ts +3 -0
- package/dist/model/input-images.js +16 -0
- package/dist/model/openai-responses.d.ts +59 -0
- package/dist/model/openai-responses.js +1586 -0
- package/dist/model/recovery.js +80 -0
- package/dist/model/request-configuration.d.ts +17 -0
- package/dist/model/request-configuration.js +47 -0
- package/dist/model/responses-event-projection.d.ts +24 -0
- package/dist/model/responses-event-projection.js +194 -0
- package/dist/model/responses-request.d.ts +5 -0
- package/dist/model/responses-request.js +363 -0
- package/dist/model/responses-session-cache.d.ts +33 -0
- package/dist/model/responses-session-cache.js +64 -0
- package/dist/model/runtime-credential.d.ts +1 -0
- package/dist/model/runtime-credential.js +1 -0
- package/dist/model/sse.js +281 -0
- package/dist/model/text-blocks.js +40 -0
- package/dist/model/tool-declarations.d.ts +4 -0
- package/dist/model/tool-definition-projection.d.ts +6 -0
- package/dist/model/tool-definition-projection.js +11 -0
- package/dist/model/tool-schema.d.ts +2 -0
- package/dist/model/tool-schema.js +17 -0
- package/dist/model/transport-test.d.ts +10 -0
- package/dist/model/transport-test.js +27 -0
- package/dist/model/usage-observer.d.ts +5 -0
- package/dist/model/usage.d.ts +40 -0
- package/dist/network/credential-runtime.d.ts +8 -0
- package/dist/network/credential-runtime.js +72 -0
- package/dist/network/credentials.d.ts +20 -0
- package/dist/network/credentials.js +18 -0
- package/dist/network/http.d.ts +20 -0
- package/dist/network/http.js +421 -0
- package/dist/network/product-user-agent.d.ts +5 -0
- package/dist/network/product-user-agent.js +22 -0
- package/dist/network/transport-error.d.ts +5 -0
- package/dist/network/transport-error.js +31 -0
- package/dist/process/contracts.d.ts +26 -0
- package/dist/prompts/index.d.ts +20 -0
- package/dist/prompts/index.js +49 -0
- package/dist/prompts/prompt-sections.d.ts +6 -0
- package/dist/prompts/prompt-sections.js +6 -0
- package/dist/prompts/read-context.js +152 -0
- package/dist/runtime/compaction/contracts.d.ts +23 -0
- package/dist/runtime/compaction/coordinator.js +88 -0
- package/dist/runtime/compaction/generate.d.ts +31 -0
- package/dist/runtime/compaction/generate.js +84 -0
- package/dist/runtime/compaction/history.d.ts +16 -0
- package/dist/runtime/compaction/operation.d.ts +30 -0
- package/dist/runtime/compaction/operation.js +131 -0
- package/dist/runtime/compaction/requests.d.ts +16 -0
- package/dist/runtime/compaction/requests.js +114 -0
- package/dist/runtime/compaction/retained-context.d.ts +6 -0
- package/dist/runtime/compaction/retained-context.js +48 -0
- package/dist/runtime/compaction/smart.d.ts +14 -0
- package/dist/runtime/compaction/smart.js +59 -0
- package/dist/runtime/context/contextual-blocks.d.ts +31 -0
- package/dist/runtime/context/contextual-blocks.js +158 -0
- package/dist/runtime/context/environment.d.ts +5 -0
- package/dist/runtime/context/gc-candidates-code.d.ts +6 -0
- package/dist/runtime/context/gc-candidates-code.js +102 -0
- package/dist/runtime/context/gc-candidates-exec.d.ts +6 -0
- package/dist/runtime/context/gc-candidates-exec.js +131 -0
- package/dist/runtime/context/gc-candidates-read-patch.d.ts +7 -0
- package/dist/runtime/context/gc-candidates-read-patch.js +118 -0
- package/dist/runtime/context/gc-candidates-subagent.d.ts +6 -0
- package/dist/runtime/context/gc-candidates-subagent.js +100 -0
- package/dist/runtime/context/gc-candidates-web.d.ts +6 -0
- package/dist/runtime/context/gc-candidates-web.js +58 -0
- package/dist/runtime/context/gc-candidates.d.ts +12 -0
- package/dist/runtime/context/gc-candidates.js +192 -0
- package/dist/runtime/context/gc-contracts.d.ts +57 -0
- package/dist/runtime/context/gc-economics.d.ts +48 -0
- package/dist/runtime/context/gc-economics.js +161 -0
- package/dist/runtime/context/gc-runtime.d.ts +43 -0
- package/dist/runtime/context/gc-tokens.d.ts +26 -0
- package/dist/runtime/context/gc-tokens.js +106 -0
- package/dist/runtime/context/gc.d.ts +7 -0
- package/dist/runtime/context/gc.js +552 -0
- package/dist/runtime/context/instructions.d.ts +37 -0
- package/dist/runtime/context/instructions.js +297 -0
- package/dist/runtime/context/normalize.d.ts +5 -0
- package/dist/runtime/context/projection.d.ts +23 -0
- package/dist/runtime/context/projection.js +284 -0
- package/dist/runtime/context/request-budget.d.ts +5 -0
- package/dist/runtime/context/request-budget.js +25 -0
- package/dist/runtime/context/restore.d.ts +27 -0
- package/dist/runtime/context/restore.js +186 -0
- package/dist/runtime/context/usage.d.ts +17 -0
- package/dist/runtime/context/usage.js +124 -0
- package/dist/runtime/context/world-state.d.ts +34 -0
- package/dist/runtime/context/world-state.js +232 -0
- package/dist/runtime/contracts.d.ts +29 -0
- package/dist/runtime/event-projection.d.ts +14 -0
- package/dist/runtime/event-projection.js +87 -0
- package/dist/runtime/events.d.ts +195 -0
- package/dist/runtime/execution-handle.d.ts +12 -0
- package/dist/runtime/execution-handle.js +1 -0
- package/dist/runtime/execution.d.ts +55 -0
- package/dist/runtime/execution.js +444 -0
- package/dist/runtime/model-progress.js +85 -0
- package/dist/runtime/resource-publication.d.ts +27 -0
- package/dist/runtime/resource-publication.js +60 -0
- package/dist/runtime/tool-round-contract.d.ts +19 -0
- package/dist/runtime/tool-round-contract.js +1 -0
- package/dist/runtime/wait.js +82 -0
- package/dist/sandbox/linux/bubblewrap-sandbox-executor.d.ts +1 -1
- package/dist/sandbox/linux/bubblewrap-sandbox-executor.js +8 -8
- package/dist/sdk/agent.d.ts +7 -0
- package/dist/sdk/agent.js +321 -0
- package/dist/sdk/execution-code-mode.d.ts +18 -0
- package/dist/sdk/execution-code-mode.js +51 -0
- package/dist/sdk/execution-compact-commit.d.ts +23 -0
- package/dist/sdk/execution-compact-commit.js +41 -0
- package/dist/sdk/execution-compact-extension.d.ts +12 -0
- package/dist/sdk/execution-compact-extension.js +46 -0
- package/dist/sdk/execution-compact-generation.d.ts +17 -0
- package/dist/sdk/execution-compact-generation.js +30 -0
- package/dist/sdk/execution-compaction-flight.d.ts +31 -0
- package/dist/sdk/execution-compaction-flight.js +50 -0
- package/dist/sdk/execution-compaction.d.ts +47 -0
- package/dist/sdk/execution-compaction.js +121 -0
- package/dist/sdk/execution-context-coordinator.d.ts +56 -0
- package/dist/sdk/execution-context-coordinator.js +102 -0
- package/dist/sdk/execution-input.d.ts +58 -0
- package/dist/sdk/execution-input.js +266 -0
- package/dist/sdk/execution-model-context.d.ts +52 -0
- package/dist/sdk/execution-model-context.js +156 -0
- package/dist/sdk/execution-model-lifecycle.d.ts +39 -0
- package/dist/sdk/execution-model-lifecycle.js +73 -0
- package/dist/sdk/execution-model-request.d.ts +40 -0
- package/dist/sdk/execution-model-request.js +45 -0
- package/dist/sdk/execution-round-preparation.d.ts +11 -0
- package/dist/sdk/execution-round-preparation.js +18 -0
- package/dist/sdk/execution-round-request.d.ts +30 -0
- package/dist/sdk/execution-round-request.js +31 -0
- package/dist/sdk/execution-tool-catalog.d.ts +46 -0
- package/dist/sdk/execution-tool-catalog.js +103 -0
- package/dist/sdk/execution-tool-scope.d.ts +67 -0
- package/dist/sdk/execution-tool-scope.js +147 -0
- package/dist/sdk/extension-agent-controller.d.ts +3 -0
- package/dist/sdk/extension-agent-controller.js +69 -0
- package/dist/sdk/extension-agents.d.ts +9 -0
- package/dist/sdk/extension-agents.js +58 -0
- package/dist/sdk/extension-models.d.ts +17 -0
- package/dist/sdk/extension-models.js +142 -0
- package/dist/sdk/extension-session-launch.d.ts +18 -0
- package/dist/sdk/extension-session-launch.js +73 -0
- package/dist/sdk/extension-session.d.ts +30 -0
- package/dist/sdk/extension-session.js +107 -0
- package/dist/sdk/extension-tool-runtime.d.ts +2 -0
- package/dist/sdk/extension-tool-runtime.js +14 -0
- package/dist/sdk/extension-tools.d.ts +16 -0
- package/dist/sdk/extension-tools.js +126 -0
- package/dist/sdk/model-input-projection.d.ts +4 -0
- package/dist/sdk/model-input-projection.js +27 -0
- package/dist/sdk/model-runtime.d.ts +21 -0
- package/dist/sdk/model-runtime.js +91 -0
- package/dist/sdk/native-steer.d.ts +20 -0
- package/dist/sdk/native-steer.js +84 -0
- package/dist/sdk/request-preparation.d.ts +9 -0
- package/dist/sdk/resource-input.d.ts +33 -0
- package/dist/sdk/resource-input.js +402 -0
- package/dist/sdk/session-catalog.d.ts +2 -0
- package/dist/sdk/session-catalog.js +12 -0
- package/dist/sdk/session-composition.d.ts +54 -0
- package/dist/sdk/session-composition.js +1 -0
- package/dist/sdk/session-execution-factory.d.ts +43 -0
- package/dist/sdk/session-execution-factory.js +937 -0
- package/dist/sdk/session-execution.d.ts +163 -0
- package/dist/sdk/session-execution.js +388 -0
- package/dist/sdk/session-extension-messages.d.ts +16 -0
- package/dist/sdk/session-extension-messages.js +64 -0
- package/dist/sdk/session-extension-prompt.d.ts +35 -0
- package/dist/sdk/session-extension-prompt.js +62 -0
- package/dist/sdk/session-maintenance.d.ts +25 -0
- package/dist/sdk/session-maintenance.js +205 -0
- package/dist/sdk/session-model-adapters.d.ts +28 -0
- package/dist/sdk/session-model-adapters.js +96 -0
- package/dist/sdk/session-open.d.ts +22 -0
- package/dist/sdk/session-open.js +44 -0
- package/dist/sdk/session-registry.d.ts +17 -0
- package/dist/sdk/session-registry.js +83 -0
- package/dist/sdk/session-runtime.d.ts +72 -0
- package/dist/sdk/session-runtime.js +205 -0
- package/dist/sdk/session.d.ts +3 -0
- package/dist/sdk/session.js +313 -0
- package/dist/sdk/subagent-backend.d.ts +3 -0
- package/dist/sdk/subagent-backend.js +49 -0
- package/dist/sdk/types.d.ts +80 -0
- package/dist/sdk/types.js +1 -0
- package/dist/session/catalog.d.ts +70 -0
- package/dist/session/catalog.js +194 -0
- package/dist/session/code-observation-contract.d.ts +40 -0
- package/dist/session/code-observation-contract.js +1 -0
- package/dist/session/code-observation-projection.d.ts +54 -0
- package/dist/session/code-observation-projection.js +165 -0
- package/dist/session/code-state.d.ts +27 -0
- package/dist/session/code-state.js +89 -0
- package/dist/session/context-gc-checkpoint.d.ts +26 -0
- package/dist/session/context-gc-checkpoint.js +935 -0
- package/dist/session/context-gc-contract.d.ts +141 -0
- package/dist/session/context-gc-contract.js +1 -0
- package/dist/session/context-gc-observations.d.ts +58 -0
- package/dist/session/context-gc-observations.js +187 -0
- package/dist/session/context-gc-replacements.d.ts +63 -0
- package/dist/session/context-gc-subagent.d.ts +54 -0
- package/dist/session/deferred-input.d.ts +5 -0
- package/dist/session/deferred-input.js +74 -0
- package/dist/session/extension-checkpoint.d.ts +8 -0
- package/dist/session/extension-checkpoint.js +30 -0
- package/dist/session/history-input-limits.d.ts +4 -0
- package/dist/session/history-input-limits.js +4 -0
- package/dist/session/inline-media-contract.d.ts +16 -0
- package/dist/session/inline-media-contract.js +1 -0
- package/dist/session/inline-media.d.ts +26 -0
- package/dist/session/inline-media.js +138 -0
- package/dist/session/model-request.d.ts +14 -0
- package/dist/session/model-request.js +1 -0
- package/dist/session/record-contract.d.ts +19 -0
- package/dist/session/record-contract.js +1 -0
- package/dist/session/record-projection.d.ts +6 -0
- package/dist/session/record-projection.js +80 -0
- package/dist/session/resource-contract.d.ts +9 -0
- package/dist/session/resource-contract.js +1 -0
- package/dist/session/rollback.d.ts +13 -0
- package/dist/session/rollback.js +46 -0
- package/dist/session/store/contracts.d.ts +160 -0
- package/dist/session/store/contracts.js +1 -0
- package/dist/session/store/current-state.d.ts +17 -0
- package/dist/session/store/current-state.js +53 -0
- package/dist/session/store/execution-state.d.ts +13 -0
- package/dist/session/store/execution-state.js +103 -0
- package/dist/session/store/index.d.ts +4 -0
- package/dist/session/store/index.js +2 -0
- package/dist/session/store/jsonl/directory-index.d.ts +26 -0
- package/dist/session/store/jsonl/directory-index.js +283 -0
- package/dist/session/store/jsonl/fs-durability.d.ts +3 -0
- package/dist/session/store/jsonl/fs-durability.js +17 -0
- package/dist/session/store/jsonl/history-replacement.d.ts +48 -0
- package/dist/session/store/jsonl/history-replacement.js +147 -0
- package/dist/session/store/jsonl/history.d.ts +25 -0
- package/dist/session/store/jsonl/history.js +181 -0
- package/dist/session/store/jsonl/images.d.ts +19 -0
- package/dist/session/store/jsonl/images.js +122 -0
- package/dist/session/store/jsonl/index-transaction.d.ts +13 -0
- package/dist/session/store/jsonl/index-transaction.js +87 -0
- package/dist/session/store/jsonl/jsonl-admission.d.ts +10 -0
- package/dist/session/store/jsonl/jsonl-admission.js +205 -0
- package/dist/session/store/jsonl/jsonl-codec.d.ts +11 -0
- package/dist/session/store/jsonl/jsonl-codec.js +138 -0
- package/dist/session/store/jsonl/jsonl-migration.d.ts +12 -0
- package/dist/session/store/jsonl/jsonl-migration.js +105 -0
- package/dist/session/store/jsonl/jsonl-store.d.ts +171 -0
- package/dist/session/store/jsonl/jsonl-store.js +2482 -0
- package/dist/session/store/jsonl/open-recovery.d.ts +13 -0
- package/dist/session/store/jsonl/open-recovery.js +131 -0
- package/dist/session/store/jsonl/read-pins.d.ts +4 -0
- package/dist/session/store/jsonl/read-pins.js +131 -0
- package/dist/session/store/jsonl/record-append.d.ts +16 -0
- package/dist/session/store/jsonl/record-append.js +49 -0
- package/dist/session/store/jsonl/records.d.ts +30 -0
- package/dist/session/store/jsonl/records.js +313 -0
- package/dist/session/store/jsonl/resources.d.ts +19 -0
- package/dist/session/store/jsonl/resources.js +209 -0
- package/dist/session/store/jsonl/store-pool.d.ts +12 -0
- package/dist/session/store/jsonl/store-pool.js +55 -0
- package/dist/session/store/jsonl/transaction-recovery.d.ts +48 -0
- package/dist/session/store/jsonl/transaction-recovery.js +374 -0
- package/dist/session/store/jsonl/tree-maintenance.d.ts +12 -0
- package/dist/session/store/jsonl/tree-maintenance.js +59 -0
- package/dist/session/store/types.d.ts +69 -0
- package/dist/session/store/types.js +1 -0
- package/dist/session/summary.d.ts +18 -0
- package/dist/session/summary.js +1 -0
- package/dist/session/todo.d.ts +11 -0
- package/dist/session/todo.js +30 -0
- package/dist/session/tool-result-resources.d.ts +27 -0
- package/dist/session/tool-result-resources.js +255 -0
- package/dist/session/types.js +1 -0
- package/dist/session/user-history.d.ts +17 -0
- package/dist/session/user-history.js +1 -0
- package/dist/session-store.d.ts +2 -0
- package/dist/session-store.js +1 -0
- package/dist/shared/auto-title.d.ts +3 -3
- package/dist/shared/auto-title.js +6 -6
- package/dist/shared/model-text.d.ts +8 -8
- package/dist/shared/model-text.js +8 -7
- package/dist/storage/file-lock.js +83 -0
- package/dist/subagent/contracts.d.ts +107 -0
- package/dist/subagent/contracts.js +1 -0
- package/dist/subagent/limits.d.ts +17 -0
- package/dist/subagent/limits.js +17 -0
- package/dist/subagent/model-update.js +81 -0
- package/dist/subagent/session-controller.d.ts +148 -0
- package/dist/subagent/session-controller.js +1761 -0
- package/dist/subagent/wait-targets.d.ts +10 -0
- package/dist/subagent/wait-targets.js +26 -0
- package/dist/subagent/wait.d.ts +26 -0
- package/dist/subagent/wait.js +73 -0
- package/dist/tools/agent/agent-cancel.d.ts +7 -0
- package/dist/tools/agent/agent-cancel.js +29 -0
- package/dist/tools/agent/agent-message.d.ts +7 -0
- package/dist/tools/agent/agent-message.js +57 -0
- package/dist/tools/agent/agent-start.d.ts +12 -0
- package/dist/tools/agent/agent-start.js +106 -0
- package/dist/tools/agent/agent-wait.d.ts +7 -0
- package/dist/tools/agent/agent-wait.js +91 -0
- package/dist/tools/agent/question.d.ts +7 -0
- package/dist/tools/agent/question.js +125 -0
- package/dist/tools/agent/skill.d.ts +11 -0
- package/dist/tools/agent/skill.js +38 -0
- package/dist/tools/agent/sleep.d.ts +9 -0
- package/dist/tools/agent/sleep.js +54 -0
- package/dist/tools/agent/smart-compact.d.ts +9 -0
- package/dist/tools/agent/smart-compact.js +23 -0
- package/dist/tools/agent/todo-read.d.ts +14 -0
- package/dist/tools/agent/todo-write.d.ts +14 -0
- package/dist/tools/agent/todo-write.js +66 -0
- package/dist/tools/agent/todo.d.ts +25 -0
- package/dist/tools/agent/todo.js +32 -0
- package/dist/tools/callers.d.ts +7 -0
- package/dist/tools/callers.js +39 -0
- package/dist/tools/code-mode/cells.d.ts +29 -0
- package/dist/tools/code-mode/cells.js +338 -0
- package/dist/tools/code-mode/dispatch.d.ts +20 -0
- package/dist/tools/code-mode/dispatch.js +80 -0
- package/dist/tools/code-mode/engine.d.ts +60 -0
- package/dist/tools/code-mode/engine.js +1 -0
- package/dist/tools/code-mode/index.d.ts +31 -0
- package/dist/tools/code-mode/index.js +751 -0
- package/dist/tools/code-mode/observations.d.ts +8 -0
- package/dist/tools/code-mode/observations.js +64 -0
- package/dist/tools/code-mode/worker.d.ts +1 -0
- package/dist/tools/contracts.d.ts +193 -0
- package/dist/tools/contracts.js +1 -0
- package/dist/tools/definition-projection.d.ts +1 -0
- package/dist/tools/definition-projection.js +1 -0
- package/dist/tools/execution-limits.d.ts +69 -0
- package/dist/tools/execution-limits.js +58 -0
- package/dist/tools/execution.d.ts +30 -0
- package/dist/tools/execution.js +191 -0
- package/dist/tools/local/apply-patch-parser.js +177 -0
- package/dist/tools/local/apply-patch.d.ts +19 -0
- package/dist/tools/local/apply-patch.js +489 -0
- package/dist/tools/local/exec.d.ts +28 -0
- package/dist/tools/local/exec.js +194 -0
- package/dist/tools/local/image-processing.js +146 -0
- package/dist/tools/local/read.d.ts +43 -0
- package/dist/tools/local/read.js +470 -0
- package/dist/tools/local/view-image.d.ts +15 -0
- package/dist/tools/local/view-image.js +317 -0
- package/dist/tools/mcp/catalog.js +220 -0
- package/dist/tools/mcp/history.d.ts +4 -0
- package/dist/tools/mcp/tool-search.d.ts +45 -0
- package/dist/tools/mcp/tool-search.js +294 -0
- package/dist/tools/output-projection.d.ts +18 -0
- package/dist/tools/output-projection.js +341 -0
- package/dist/tools/permission-contract.d.ts +25 -0
- package/dist/tools/permission-contract.js +1 -0
- package/dist/tools/permissions.d.ts +61 -0
- package/dist/tools/permissions.js +237 -0
- package/dist/tools/registry.d.ts +7 -0
- package/dist/tools/result-extension-contract.d.ts +37 -0
- package/dist/tools/result-extension-contract.js +32 -0
- package/dist/tools/result-extensions.d.ts +12 -0
- package/dist/tools/result-extensions.js +104 -0
- package/dist/tools/runtime-context.d.ts +89 -0
- package/dist/tools/runtime-context.js +1 -0
- package/dist/tools/runtime-resource-handles.js +28 -0
- package/dist/tools/runtime.js +77 -0
- package/dist/tools/scheduler.d.ts +12 -0
- package/dist/tools/shared/path-resolver.js +133 -0
- package/dist/tools/wait.d.ts +1 -0
- package/dist/tools/wait.js +1 -0
- package/package.json +15 -3
- package/dist/agent-core/error.d.ts +0 -15
- package/dist/agent-core/error.js +0 -74
- package/dist/agent-core/extensions/agents.d.ts +0 -79
- package/dist/agent-core/extensions/agents.js +0 -186
- package/dist/agent-core/extensions/compaction.d.ts +0 -48
- package/dist/agent-core/extensions/contracts.d.ts +0 -265
- package/dist/agent-core/extensions/data.d.ts +0 -84
- package/dist/agent-core/extensions/data.js +0 -83
- package/dist/agent-core/extensions/environment.d.ts +0 -27
- package/dist/agent-core/extensions/environment.js +0 -52
- package/dist/agent-core/extensions/files.d.ts +0 -64
- package/dist/agent-core/extensions/files.js +0 -26
- package/dist/agent-core/extensions/hooks.d.ts +0 -32
- package/dist/agent-core/extensions/manager.d.ts +0 -39
- package/dist/agent-core/extensions/manager.js +0 -458
- package/dist/agent-core/extensions/mcp.d.ts +0 -99
- package/dist/agent-core/extensions/mcp.js +0 -433
- package/dist/agent-core/extensions/model-request.d.ts +0 -56
- package/dist/agent-core/extensions/model-request.js +0 -197
- package/dist/agent-core/extensions/model-stream.d.ts +0 -9
- package/dist/agent-core/extensions/model-stream.js +0 -108
- package/dist/agent-core/extensions/models.d.ts +0 -43
- package/dist/agent-core/extensions/network.d.ts +0 -32
- package/dist/agent-core/extensions/network.js +0 -97
- package/dist/agent-core/extensions/operation.d.ts +0 -30
- package/dist/agent-core/extensions/processes.d.ts +0 -52
- package/dist/agent-core/extensions/processes.js +0 -284
- package/dist/agent-core/extensions/prompt-composition.d.ts +0 -24
- package/dist/agent-core/extensions/prompt-composition.js +0 -106
- package/dist/agent-core/extensions/prompt-input.d.ts +0 -23
- package/dist/agent-core/extensions/prompt-input.js +0 -48
- package/dist/agent-core/extensions/resources.d.ts +0 -27
- package/dist/agent-core/extensions/resources.js +0 -221
- package/dist/agent-core/extensions/services.d.ts +0 -31
- package/dist/agent-core/extensions/services.js +0 -61
- package/dist/agent-core/extensions/session-input.d.ts +0 -163
- package/dist/agent-core/extensions/session-input.js +0 -411
- package/dist/agent-core/extensions/session-messages.d.ts +0 -41
- package/dist/agent-core/extensions/session-messages.js +0 -76
- package/dist/agent-core/extensions/session.d.ts +0 -69
- package/dist/agent-core/extensions/session.js +0 -607
- package/dist/agent-core/extensions/settings.d.ts +0 -59
- package/dist/agent-core/extensions/settings.js +0 -115
- package/dist/agent-core/extensions/store.d.ts +0 -10
- package/dist/agent-core/extensions/store.js +0 -131
- package/dist/agent-core/extensions/tools.d.ts +0 -61
- package/dist/agent-core/extensions/tools.js +0 -269
- package/dist/agent-core/host/contracts.d.ts +0 -100
- package/dist/agent-core/host/contracts.js +0 -18
- package/dist/agent-core/host/local-agent-host.d.ts +0 -96
- package/dist/agent-core/host/local-agent-host.js +0 -425
- package/dist/agent-core/host/local-file-access.d.ts +0 -30
- package/dist/agent-core/host/local-file-access.js +0 -107
- package/dist/agent-core/host/local-network-access.d.ts +0 -6
- package/dist/agent-core/host/local-network-access.js +0 -101
- package/dist/agent-core/host/local-process-executor.d.ts +0 -29
- package/dist/agent-core/host/local-process-executor.js +0 -41
- package/dist/agent-core/host/local-session-environment.d.ts +0 -18
- package/dist/agent-core/host/local-shell.d.ts +0 -3
- package/dist/agent-core/host/network.d.ts +0 -4
- package/dist/agent-core/host/network.js +0 -6
- package/dist/agent-core/model/anthropic-messages.d.ts +0 -10
- package/dist/agent-core/model/anthropic-messages.js +0 -707
- package/dist/agent-core/model/anthropic-thinking.js +0 -33
- package/dist/agent-core/model/catalog-file.d.ts +0 -80
- package/dist/agent-core/model/catalog-file.js +0 -103
- package/dist/agent-core/model/configuration.d.ts +0 -127
- package/dist/agent-core/model/configuration.js +0 -168
- package/dist/agent-core/model/contracts.d.ts +0 -229
- package/dist/agent-core/model/http.d.ts +0 -27
- package/dist/agent-core/model/http.js +0 -534
- package/dist/agent-core/model/image.d.ts +0 -17
- package/dist/agent-core/model/openai-responses.d.ts +0 -77
- package/dist/agent-core/model/openai-responses.js +0 -2123
- package/dist/agent-core/model/product-user-agent.d.ts +0 -5
- package/dist/agent-core/model/product-user-agent.js +0 -22
- package/dist/agent-core/model/recovery.js +0 -80
- package/dist/agent-core/model/request-configuration.d.ts +0 -17
- package/dist/agent-core/model/request-configuration.js +0 -47
- package/dist/agent-core/model/runtime-credential.d.ts +0 -8
- package/dist/agent-core/model/runtime-credential.js +0 -72
- package/dist/agent-core/model/sse.js +0 -281
- package/dist/agent-core/model/text-blocks.js +0 -40
- package/dist/agent-core/model/tool-declarations.d.ts +0 -4
- package/dist/agent-core/model/transport-test.d.ts +0 -3
- package/dist/agent-core/model/transport-test.js +0 -23
- package/dist/agent-core/model/usage-observer.d.ts +0 -31
- package/dist/agent-core/prompts/index.d.ts +0 -20
- package/dist/agent-core/prompts/index.js +0 -49
- package/dist/agent-core/runtime/compaction/coordinator.js +0 -88
- package/dist/agent-core/runtime/compaction/generate.d.ts +0 -28
- package/dist/agent-core/runtime/compaction/generate.js +0 -84
- package/dist/agent-core/runtime/compaction/history.d.ts +0 -16
- package/dist/agent-core/runtime/compaction/operation.d.ts +0 -29
- package/dist/agent-core/runtime/compaction/operation.js +0 -131
- package/dist/agent-core/runtime/compaction/requests.d.ts +0 -16
- package/dist/agent-core/runtime/compaction/requests.js +0 -114
- package/dist/agent-core/runtime/compaction/retained-context.d.ts +0 -6
- package/dist/agent-core/runtime/compaction/retained-context.js +0 -47
- package/dist/agent-core/runtime/compaction/smart.d.ts +0 -14
- package/dist/agent-core/runtime/compaction/smart.js +0 -59
- package/dist/agent-core/runtime/context/contextual-blocks.d.ts +0 -30
- package/dist/agent-core/runtime/context/contextual-blocks.js +0 -146
- package/dist/agent-core/runtime/context/environment.d.ts +0 -5
- package/dist/agent-core/runtime/context/gc-runtime.d.ts +0 -38
- package/dist/agent-core/runtime/context/gc-tokens.d.ts +0 -25
- package/dist/agent-core/runtime/context/gc-tokens.js +0 -103
- package/dist/agent-core/runtime/context/gc.d.ts +0 -75
- package/dist/agent-core/runtime/context/gc.js +0 -1386
- package/dist/agent-core/runtime/context/instructions.d.ts +0 -37
- package/dist/agent-core/runtime/context/instructions.js +0 -297
- package/dist/agent-core/runtime/context/normalize.d.ts +0 -5
- package/dist/agent-core/runtime/context/projection.d.ts +0 -23
- package/dist/agent-core/runtime/context/projection.js +0 -284
- package/dist/agent-core/runtime/context/request-budget.d.ts +0 -4
- package/dist/agent-core/runtime/context/request-budget.js +0 -25
- package/dist/agent-core/runtime/context/restore.d.ts +0 -25
- package/dist/agent-core/runtime/context/restore.js +0 -186
- package/dist/agent-core/runtime/context/usage.d.ts +0 -17
- package/dist/agent-core/runtime/context/usage.js +0 -124
- package/dist/agent-core/runtime/context/world-state.d.ts +0 -33
- package/dist/agent-core/runtime/context/world-state.js +0 -232
- package/dist/agent-core/runtime/contracts.d.ts +0 -41
- package/dist/agent-core/runtime/event-projection.d.ts +0 -14
- package/dist/agent-core/runtime/event-projection.js +0 -87
- package/dist/agent-core/runtime/events.d.ts +0 -197
- package/dist/agent-core/runtime/execution-handle.d.ts +0 -12
- package/dist/agent-core/runtime/execution.d.ts +0 -50
- package/dist/agent-core/runtime/execution.js +0 -445
- package/dist/agent-core/runtime/model-progress.js +0 -85
- package/dist/agent-core/runtime/resource-publication.d.ts +0 -8
- package/dist/agent-core/runtime/resource-publication.js +0 -60
- package/dist/agent-core/sdk/agent.d.ts +0 -11
- package/dist/agent-core/sdk/agent.js +0 -474
- package/dist/agent-core/sdk/extension-agents.d.ts +0 -9
- package/dist/agent-core/sdk/extension-agents.js +0 -58
- package/dist/agent-core/sdk/extension-models.d.ts +0 -13
- package/dist/agent-core/sdk/extension-models.js +0 -137
- package/dist/agent-core/sdk/extension-session.d.ts +0 -30
- package/dist/agent-core/sdk/extension-session.js +0 -105
- package/dist/agent-core/sdk/extension-tools.d.ts +0 -16
- package/dist/agent-core/sdk/extension-tools.js +0 -126
- package/dist/agent-core/sdk/model-runtime.d.ts +0 -18
- package/dist/agent-core/sdk/model-runtime.js +0 -93
- package/dist/agent-core/sdk/native-steer.d.ts +0 -20
- package/dist/agent-core/sdk/native-steer.js +0 -84
- package/dist/agent-core/sdk/request-preparation.d.ts +0 -7
- package/dist/agent-core/sdk/resource-input.d.ts +0 -32
- package/dist/agent-core/sdk/resource-input.js +0 -403
- package/dist/agent-core/sdk/session.d.ts +0 -94
- package/dist/agent-core/sdk/session.js +0 -2377
- package/dist/agent-core/sdk/subagent-backend.d.ts +0 -3
- package/dist/agent-core/sdk/subagent-backend.js +0 -49
- package/dist/agent-core/sdk/types.d.ts +0 -81
- package/dist/agent-core/session/catalog.d.ts +0 -99
- package/dist/agent-core/session/catalog.js +0 -200
- package/dist/agent-core/session/context-gc-checkpoint.d.ts +0 -165
- package/dist/agent-core/session/context-gc-checkpoint.js +0 -935
- package/dist/agent-core/session/context-gc-observations.d.ts +0 -60
- package/dist/agent-core/session/context-gc-observations.js +0 -187
- package/dist/agent-core/session/context-gc-replacements.d.ts +0 -62
- package/dist/agent-core/session/context-gc-subagent.d.ts +0 -53
- package/dist/agent-core/session/deferred-input.d.ts +0 -5
- package/dist/agent-core/session/deferred-input.js +0 -74
- package/dist/agent-core/session/inline-media.d.ts +0 -45
- package/dist/agent-core/session/inline-media.js +0 -163
- package/dist/agent-core/session/rollback.d.ts +0 -13
- package/dist/agent-core/session/rollback.js +0 -46
- package/dist/agent-core/session/store/contracts.d.ts +0 -158
- package/dist/agent-core/session/store/current-state.d.ts +0 -17
- package/dist/agent-core/session/store/current-state.js +0 -53
- package/dist/agent-core/session/store/directory-index.d.ts +0 -18
- package/dist/agent-core/session/store/directory-index.js +0 -169
- package/dist/agent-core/session/store/execution-state.d.ts +0 -18
- package/dist/agent-core/session/store/execution-state.js +0 -175
- package/dist/agent-core/session/store/history.d.ts +0 -25
- package/dist/agent-core/session/store/history.js +0 -181
- package/dist/agent-core/session/store/images.d.ts +0 -19
- package/dist/agent-core/session/store/images.js +0 -110
- package/dist/agent-core/session/store/index.d.ts +0 -4
- package/dist/agent-core/session/store/index.js +0 -2
- package/dist/agent-core/session/store/jsonl-store.d.ts +0 -171
- package/dist/agent-core/session/store/jsonl-store.js +0 -2078
- package/dist/agent-core/session/store/records.d.ts +0 -23
- package/dist/agent-core/session/store/records.js +0 -261
- package/dist/agent-core/session/store/resources.d.ts +0 -26
- package/dist/agent-core/session/store/resources.js +0 -197
- package/dist/agent-core/session/store/types.d.ts +0 -82
- package/dist/agent-core/session/tool-result-resources.d.ts +0 -26
- package/dist/agent-core/session/tool-result-resources.js +0 -256
- package/dist/agent-core/session/transaction-recovery.d.ts +0 -16
- package/dist/agent-core/session/transaction-recovery.js +0 -135
- package/dist/agent-core/storage/file-lock.js +0 -83
- package/dist/agent-core/subagent/contracts.d.ts +0 -117
- package/dist/agent-core/subagent/model-update.js +0 -81
- package/dist/agent-core/subagent/scheduler.d.ts +0 -135
- package/dist/agent-core/subagent/scheduler.js +0 -369
- package/dist/agent-core/subagent/session-controller.d.ts +0 -138
- package/dist/agent-core/subagent/session-controller.js +0 -1594
- package/dist/agent-core/subagent/wait.d.ts +0 -14
- package/dist/agent-core/subagent/wait.js +0 -32
- package/dist/agent-core/tools/agent/agent-cancel.d.ts +0 -7
- package/dist/agent-core/tools/agent/agent-cancel.js +0 -29
- package/dist/agent-core/tools/agent/agent-message.d.ts +0 -7
- package/dist/agent-core/tools/agent/agent-message.js +0 -57
- package/dist/agent-core/tools/agent/agent-start.d.ts +0 -12
- package/dist/agent-core/tools/agent/agent-start.js +0 -106
- package/dist/agent-core/tools/agent/agent-wait.d.ts +0 -7
- package/dist/agent-core/tools/agent/agent-wait.js +0 -91
- package/dist/agent-core/tools/agent/question.d.ts +0 -7
- package/dist/agent-core/tools/agent/question.js +0 -125
- package/dist/agent-core/tools/agent/skill.d.ts +0 -11
- package/dist/agent-core/tools/agent/skill.js +0 -38
- package/dist/agent-core/tools/agent/sleep.d.ts +0 -12
- package/dist/agent-core/tools/agent/sleep.js +0 -54
- package/dist/agent-core/tools/agent/smart-compact.d.ts +0 -9
- package/dist/agent-core/tools/agent/smart-compact.js +0 -23
- package/dist/agent-core/tools/agent/todo-read.d.ts +0 -14
- package/dist/agent-core/tools/agent/todo-write.d.ts +0 -14
- package/dist/agent-core/tools/agent/todo-write.js +0 -66
- package/dist/agent-core/tools/agent/todo.d.ts +0 -26
- package/dist/agent-core/tools/agent/todo.js +0 -60
- package/dist/agent-core/tools/callers.d.ts +0 -6
- package/dist/agent-core/tools/callers.js +0 -39
- package/dist/agent-core/tools/code-mode/cells.d.ts +0 -29
- package/dist/agent-core/tools/code-mode/cells.js +0 -337
- package/dist/agent-core/tools/code-mode/dispatch.d.ts +0 -20
- package/dist/agent-core/tools/code-mode/dispatch.js +0 -80
- package/dist/agent-core/tools/code-mode/engine.d.ts +0 -60
- package/dist/agent-core/tools/code-mode/index.d.ts +0 -29
- package/dist/agent-core/tools/code-mode/index.js +0 -749
- package/dist/agent-core/tools/code-mode/observations.d.ts +0 -98
- package/dist/agent-core/tools/code-mode/observations.js +0 -228
- package/dist/agent-core/tools/code-mode/state.d.ts +0 -9
- package/dist/agent-core/tools/code-mode/state.js +0 -82
- package/dist/agent-core/tools/contracts.d.ts +0 -211
- package/dist/agent-core/tools/definition-projection.d.ts +0 -7
- package/dist/agent-core/tools/definition-projection.js +0 -26
- package/dist/agent-core/tools/execution-limits.d.ts +0 -69
- package/dist/agent-core/tools/execution-limits.js +0 -69
- package/dist/agent-core/tools/execution.d.ts +0 -46
- package/dist/agent-core/tools/execution.js +0 -191
- package/dist/agent-core/tools/local/apply-patch-parser.js +0 -177
- package/dist/agent-core/tools/local/apply-patch.d.ts +0 -19
- package/dist/agent-core/tools/local/apply-patch.js +0 -489
- package/dist/agent-core/tools/local/exec.d.ts +0 -53
- package/dist/agent-core/tools/local/exec.js +0 -877
- package/dist/agent-core/tools/local/image-processing.js +0 -146
- package/dist/agent-core/tools/local/read-context.js +0 -152
- package/dist/agent-core/tools/local/read.d.ts +0 -43
- package/dist/agent-core/tools/local/read.js +0 -470
- package/dist/agent-core/tools/local/registry.d.ts +0 -34
- package/dist/agent-core/tools/local/registry.js +0 -132
- package/dist/agent-core/tools/local/view-image.d.ts +0 -15
- package/dist/agent-core/tools/local/view-image.js +0 -317
- package/dist/agent-core/tools/local/workspace-tools.d.ts +0 -12
- package/dist/agent-core/tools/local/workspace-tools.js +0 -28
- package/dist/agent-core/tools/mcp/catalog.js +0 -220
- package/dist/agent-core/tools/mcp/history.d.ts +0 -4
- package/dist/agent-core/tools/mcp/tool-search.d.ts +0 -45
- package/dist/agent-core/tools/mcp/tool-search.js +0 -294
- package/dist/agent-core/tools/output-projection.d.ts +0 -18
- package/dist/agent-core/tools/output-projection.js +0 -341
- package/dist/agent-core/tools/permissions.d.ts +0 -85
- package/dist/agent-core/tools/permissions.js +0 -237
- package/dist/agent-core/tools/registry.d.ts +0 -7
- package/dist/agent-core/tools/result-extensions.d.ts +0 -46
- package/dist/agent-core/tools/result-extensions.js +0 -134
- package/dist/agent-core/tools/runtime-context.d.ts +0 -74
- package/dist/agent-core/tools/runtime-resource-handles.js +0 -28
- package/dist/agent-core/tools/runtime.js +0 -77
- package/dist/agent-core/tools/scheduler.d.ts +0 -12
- package/dist/agent-core/tools/shared/path-resolver.js +0 -133
- package/dist/agent-core/tools/wait.js +0 -82
- /package/dist/{agent-core/extensions/models.js → extensions/capabilities.js} +0 -0
- /package/dist/{agent-core/extensions → extensions}/compaction.js +0 -0
- /package/dist/{agent-core/model → extensions}/contracts.js +0 -0
- /package/dist/{agent-core/extensions → extensions}/hooks.js +0 -0
- /package/dist/{agent-core/runtime/context/contracts.js → extensions/host-ports.js} +0 -0
- /package/dist/{agent-core/extensions → extensions}/operation.js +0 -0
- /package/dist/{agent-core/runtime/contracts.js → extensions/tool-runtime.js} +0 -0
- /package/dist/{agent-core/extensions/contracts.js → extensions.js} +0 -0
- /package/dist/{agent-core/runtime/events.js → host/description.js} +0 -0
- /package/dist/{agent-core/host → host}/local-session-environment.js +0 -0
- /package/dist/{agent-core/host → host}/local-shell.js +0 -0
- /package/dist/{agent-core/runtime/execution-handle.js → host/skill-contract.js} +0 -0
- /package/dist/{agent-core/model → model}/anthropic-thinking.d.ts +0 -0
- /package/dist/{agent-core/model → model}/attempt-diagnostics.d.ts +0 -0
- /package/dist/{agent-core/model → model}/attempt-diagnostics.js +0 -0
- /package/dist/{agent-core/session/store → model}/contracts.js +0 -0
- /package/dist/{agent-core/sdk/types.js → model/image-contract.js} +0 -0
- /package/dist/{agent-core/model → model}/image.js +0 -0
- /package/dist/{agent-core/model → model}/native-context.d.ts +0 -0
- /package/dist/{agent-core/model → model}/native-context.js +0 -0
- /package/dist/{agent-core/model → model}/recovery.d.ts +0 -0
- /package/dist/{agent-core/model → model}/sse.d.ts +0 -0
- /package/dist/{agent-core/model → model}/text-blocks.d.ts +0 -0
- /package/dist/{agent-core/model → model}/tool-declarations.js +0 -0
- /package/dist/{agent-core/model → model}/tool-input.d.ts +0 -0
- /package/dist/{agent-core/model → model}/tool-input.js +0 -0
- /package/dist/{agent-core/model → model}/usage-observer.js +0 -0
- /package/dist/{agent-core/session/store/types.js → model/usage.js} +0 -0
- /package/dist/{agent-core/subagent → process}/contracts.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/compact.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/compact.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/core.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/core.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/markup.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/markup.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/modes.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/modes.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/output.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/output.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/permissions.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/permissions.js +0 -0
- /package/dist/{agent-core/tools/local → prompts}/read-context.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/resources.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/resources.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/subagent.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/subagent.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/workflow.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/workflow.js +0 -0
- /package/dist/{agent-core/runtime → runtime}/async-queue.d.ts +0 -0
- /package/dist/{agent-core/runtime → runtime}/async-queue.js +0 -0
- /package/dist/{agent-core/tools → runtime/compaction}/contracts.js +0 -0
- /package/dist/{agent-core/runtime → runtime}/compaction/coordinator.d.ts +0 -0
- /package/dist/{agent-core/runtime → runtime}/compaction/history.js +0 -0
- /package/dist/{agent-core/runtime → runtime}/context/contracts.d.ts +0 -0
- /package/dist/{agent-core/session/types.js → runtime/context/contracts.js} +0 -0
- /package/dist/{agent-core/runtime → runtime}/context/environment.js +0 -0
- /package/dist/{agent-core/tools/code-mode/engine.js → runtime/context/gc-contracts.js} +0 -0
- /package/dist/{agent-core/runtime → runtime}/context/gc-runtime.js +0 -0
- /package/dist/{agent-core/runtime → runtime}/context/normalize.js +0 -0
- /package/dist/{agent-core/tools/code-mode/worker.d.ts → runtime/contracts.js} +0 -0
- /package/dist/{agent-core/tools/runtime-context.js → runtime/events.js} +0 -0
- /package/dist/{agent-core/runtime → runtime}/execution-policy.d.ts +0 -0
- /package/dist/{agent-core/runtime → runtime}/execution-policy.js +0 -0
- /package/dist/{agent-core/runtime → runtime}/model-generation-timing.d.ts +0 -0
- /package/dist/{agent-core/runtime → runtime}/model-generation-timing.js +0 -0
- /package/dist/{agent-core/runtime → runtime}/model-progress.d.ts +0 -0
- /package/dist/{agent-core/runtime → runtime}/plan-output.d.ts +0 -0
- /package/dist/{agent-core/runtime → runtime}/plan-output.js +0 -0
- /package/dist/{agent-core/tools/public-metadata.d.ts → runtime/public-tool-metadata.d.ts} +0 -0
- /package/dist/{agent-core/tools/public-metadata.js → runtime/public-tool-metadata.js} +0 -0
- /package/dist/{agent-core/runtime → runtime}/token-budget.d.ts +0 -0
- /package/dist/{agent-core/runtime → runtime}/token-budget.js +0 -0
- /package/dist/{agent-core/tools → runtime}/wait.d.ts +0 -0
- /package/dist/{agent-core/sdk → sdk}/request-preparation.js +0 -0
- /package/dist/{agent-core/session → session}/context-gc-markup.d.ts +0 -0
- /package/dist/{agent-core/session → session}/context-gc-markup.js +0 -0
- /package/dist/{agent-core/session → session}/context-gc-replacements.js +0 -0
- /package/dist/{agent-core/session → session}/context-gc-subagent.js +0 -0
- /package/dist/{agent-core/session → session}/types.d.ts +0 -0
- /package/dist/{agent-core/storage → storage}/file-lock.d.ts +0 -0
- /package/dist/{agent-core/subagent → subagent}/model-update.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/agent/todo-read.js +0 -0
- /package/dist/{agent-core/tools → tools}/code-mode/quickjs-engine.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/code-mode/quickjs-engine.js +0 -0
- /package/dist/{agent-core/tools → tools}/code-mode/text-output.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/code-mode/text-output.js +0 -0
- /package/dist/{agent-core/tools → tools}/code-mode/worker.js +0 -0
- /package/dist/{agent-core/tools → tools}/file-change-diff.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/file-change-diff.js +0 -0
- /package/dist/{agent-core/tools → tools}/input-diagnostics/source-preview.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/input-diagnostics/source-preview.js +0 -0
- /package/dist/{agent-core/tools → tools}/input.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/input.js +0 -0
- /package/dist/{agent-core/tools → tools}/local/apply-patch-parser.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/local/image-processing.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/mcp/catalog.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/mcp/history.js +0 -0
- /package/dist/{agent-core/tools → tools}/registry.js +0 -0
- /package/dist/{agent-core/tools → tools}/runtime-resource-handles.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/runtime.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/scheduler.js +0 -0
- /package/dist/{agent-core/tools → tools}/shared/patch-result.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/shared/patch-result.js +0 -0
- /package/dist/{agent-core/tools → tools}/shared/path-resolver.d.ts +0 -0
|
@@ -1,707 +0,0 @@
|
|
|
1
|
-
import { observeModelRequestUsage } from './usage-observer.js';
|
|
2
|
-
import { jsonToolInput } from './tool-input.js';
|
|
3
|
-
import { observationModelParts } from '../tools/code-mode/observations.js';
|
|
4
|
-
import { modelImageKey, modelImageUrl } from './image.js';
|
|
5
|
-
import { stableToolSchema } from '../tools/definition-projection.js';
|
|
6
|
-
import { randomUUID } from 'node:crypto';
|
|
7
|
-
import { MarAgentError } from '../error.js';
|
|
8
|
-
import { assertInlineMediaBudget } from '../session/inline-media.js';
|
|
9
|
-
import { resolveModelDefaultReasoningEffort } from './configuration.js';
|
|
10
|
-
import { isRetryableUpstreamOverloadCode, number, parseSse, record, text, observeModelStreamEvent, modelStreamEventObservedAt } from './sse.js';
|
|
11
|
-
import { fetchModelResponse, modelRetryMaxAttempts, isRetryableModelRequestError, isRetryableModelTransportError, modelRetryDelay, waitForModelRetry } from './http.js';
|
|
12
|
-
import { anthropicThinkingBlock, assertAnthropicThinkingBudget } from './anthropic-thinking.js';
|
|
13
|
-
import { resolveModelTextBlocks } from './text-blocks.js';
|
|
14
|
-
import { reportModelAttempt } from './attempt-diagnostics.js';
|
|
15
|
-
import { productUserAgent } from './product-user-agent.js';
|
|
16
|
-
export class AnthropicMessagesAdapter {
|
|
17
|
-
configuration;
|
|
18
|
-
constructor(configuration) {
|
|
19
|
-
this.configuration = configuration;
|
|
20
|
-
}
|
|
21
|
-
async *start(request, signal) {
|
|
22
|
-
const retryState = request.retryState ?? { attempts: 0 };
|
|
23
|
-
const maxAttempts = modelRetryMaxAttempts(retryState);
|
|
24
|
-
let resetOutputTiming = false;
|
|
25
|
-
while (retryState.attempts < maxAttempts) {
|
|
26
|
-
signal.throwIfAborted();
|
|
27
|
-
if (resetOutputTiming)
|
|
28
|
-
yield { type: 'output.reset' };
|
|
29
|
-
resetOutputTiming = false;
|
|
30
|
-
const attempt = retryState.attempts++;
|
|
31
|
-
const startedAt = Date.now();
|
|
32
|
-
const attemptDiagnostic = {
|
|
33
|
-
protocol: 'ANTHROPIC_MESSAGES',
|
|
34
|
-
transport: 'HTTP',
|
|
35
|
-
attempt: attempt + 1,
|
|
36
|
-
maxAttempts,
|
|
37
|
-
continuation: false,
|
|
38
|
-
credentialReason: 'REQUEST'
|
|
39
|
-
};
|
|
40
|
-
// Buffer non-semantic events until a semantic event makes this attempt non-retryable.
|
|
41
|
-
const prelude = [];
|
|
42
|
-
let sawSemanticEvent = false;
|
|
43
|
-
let firstSemanticEventType;
|
|
44
|
-
await reportModelAttempt(request, { ...attemptDiagnostic, state: 'STARTED' });
|
|
45
|
-
try {
|
|
46
|
-
for await (const event of observeModelRequestUsage(() => this.startAttempt(request, signal), request, this.configuration, signal)) {
|
|
47
|
-
if (event.type.startsWith('output.')) {
|
|
48
|
-
resetOutputTiming = true;
|
|
49
|
-
yield event;
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (!sawSemanticEvent && !isSemanticEvent(event)) {
|
|
53
|
-
prelude.push(event);
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
if (!sawSemanticEvent) {
|
|
57
|
-
sawSemanticEvent = true;
|
|
58
|
-
firstSemanticEventType = event.type;
|
|
59
|
-
for (const pending of prelude)
|
|
60
|
-
yield pending;
|
|
61
|
-
prelude.length = 0;
|
|
62
|
-
}
|
|
63
|
-
yield event;
|
|
64
|
-
}
|
|
65
|
-
await reportModelAttempt(request, {
|
|
66
|
-
...attemptDiagnostic,
|
|
67
|
-
state: 'SUCCEEDED',
|
|
68
|
-
semanticEventObserved: sawSemanticEvent,
|
|
69
|
-
...(firstSemanticEventType === undefined ? {} : { firstSemanticEventType }),
|
|
70
|
-
durationMs: Math.max(0, Date.now() - startedAt)
|
|
71
|
-
});
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
const retryable = isRetryableModelRequestError(error) || isAnthropicRecoverableStreamError(error);
|
|
76
|
-
const willRetry = !signal.aborted && !sawSemanticEvent && retryable && attempt + 1 < maxAttempts;
|
|
77
|
-
const delayMs = willRetry ? modelRetryDelay(retryAfter(error), attempt) : undefined;
|
|
78
|
-
await reportModelAttempt(request, {
|
|
79
|
-
...attemptDiagnostic,
|
|
80
|
-
state: 'FAILED',
|
|
81
|
-
semanticEventObserved: sawSemanticEvent,
|
|
82
|
-
...(firstSemanticEventType === undefined ? {} : { firstSemanticEventType }),
|
|
83
|
-
durationMs: Math.max(0, Date.now() - startedAt),
|
|
84
|
-
errorCode: error instanceof MarAgentError ? error.code : 'MAR_AGENT_MODEL_ATTEMPT_FAILED',
|
|
85
|
-
retryable,
|
|
86
|
-
willRetry,
|
|
87
|
-
...(delayMs === undefined
|
|
88
|
-
? {}
|
|
89
|
-
: { retryDelayMs: delayMs, retryReason: 'STREAM' })
|
|
90
|
-
});
|
|
91
|
-
if (!willRetry)
|
|
92
|
-
throw error;
|
|
93
|
-
await waitForModelRetry(retryAfter(error), attempt, signal, delayMs);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
async *startAttempt(request, signal) {
|
|
98
|
-
assertInlineMediaBudget(request);
|
|
99
|
-
const apiKey = this.configuration.apiKey;
|
|
100
|
-
if (apiKey === undefined)
|
|
101
|
-
throw new MarAgentError('MAR_AGENT_MODEL_CONFIG_INVALID', 'Anthropic Messages requires a static API key.');
|
|
102
|
-
const tools = request.allowTools === false
|
|
103
|
-
? []
|
|
104
|
-
: request.tools.map((tool) => ({
|
|
105
|
-
name: tool.name,
|
|
106
|
-
description: tool.description,
|
|
107
|
-
input_schema: stableToolSchema(tool.inputSchema)
|
|
108
|
-
}));
|
|
109
|
-
const response = await fetchModelResponse(`${this.configuration.baseUrl.replace(/\/$/, '')}/v1/messages`, {
|
|
110
|
-
method: 'POST',
|
|
111
|
-
headers: {
|
|
112
|
-
'x-api-key': apiKey.reveal(),
|
|
113
|
-
'anthropic-version': '2023-06-01',
|
|
114
|
-
'content-type': 'application/json',
|
|
115
|
-
'user-agent': productUserAgent(),
|
|
116
|
-
accept: 'text/event-stream'
|
|
117
|
-
},
|
|
118
|
-
body: JSON.stringify({
|
|
119
|
-
model: this.configuration.modelId,
|
|
120
|
-
system: request.systemBlocks !== undefined
|
|
121
|
-
? anthropicTextBlocks(request.system, request.systemBlocks)
|
|
122
|
-
: request.system
|
|
123
|
-
? [
|
|
124
|
-
{
|
|
125
|
-
type: 'text',
|
|
126
|
-
text: request.system,
|
|
127
|
-
cache_control: { type: 'ephemeral' }
|
|
128
|
-
}
|
|
129
|
-
]
|
|
130
|
-
: [],
|
|
131
|
-
messages: anthropicMessages(request.messages, request.images, request.tools, this.configuration.id, request.systemBlocks === undefined &&
|
|
132
|
-
request.messages.every((message) => message.textBlocks === undefined), request.cachePrefixMessages),
|
|
133
|
-
tools,
|
|
134
|
-
...(request.toolChoice === undefined
|
|
135
|
-
? {}
|
|
136
|
-
: { tool_choice: { type: request.toolChoice } }),
|
|
137
|
-
stream: true,
|
|
138
|
-
max_tokens: Math.min(request.outputLimit ?? this.configuration.maxOutputTokens, this.configuration.maxOutputTokens),
|
|
139
|
-
output_config: {
|
|
140
|
-
effort: request.reasoningEffort?.trim() ||
|
|
141
|
-
resolveModelDefaultReasoningEffort(this.configuration)
|
|
142
|
-
}
|
|
143
|
-
})
|
|
144
|
-
}, signal, 1);
|
|
145
|
-
const blocks = new Map();
|
|
146
|
-
const hostedTools = new Map();
|
|
147
|
-
// Block completion precedes the stop reason, which determines commentary vs final answer.
|
|
148
|
-
const pendingTextBlocks = new Set();
|
|
149
|
-
let responseId = `anthropic-${randomUUID()}`;
|
|
150
|
-
const completedThinking = new Set();
|
|
151
|
-
let terminal;
|
|
152
|
-
let latestInputUsage;
|
|
153
|
-
let thinkingBytes = 0;
|
|
154
|
-
for await (const raw of parseAnthropicSse(response, signal, apiKey.reveal())) {
|
|
155
|
-
const event = record(raw);
|
|
156
|
-
const type = text(event.type) ?? 'unknown';
|
|
157
|
-
const index = number(event.index) ?? -1;
|
|
158
|
-
if (type === 'message_start') {
|
|
159
|
-
const message = record(event.message);
|
|
160
|
-
responseId = text(message.id) ?? responseId;
|
|
161
|
-
yield observeModelStreamEvent({
|
|
162
|
-
type: 'response.started',
|
|
163
|
-
responseId,
|
|
164
|
-
...(text(message.model) ? { modelId: text(message.model) } : {})
|
|
165
|
-
}, modelStreamEventObservedAt(raw));
|
|
166
|
-
const usage = record(message.usage);
|
|
167
|
-
const inputTokens = inputTokenCount(usage.input_tokens);
|
|
168
|
-
const cacheReadTokens = inputTokenCount(usage.cache_read_input_tokens);
|
|
169
|
-
const cacheWriteTokens = inputTokenCount(usage.cache_creation_input_tokens);
|
|
170
|
-
latestInputUsage = inputUsage(inputTokens, cacheReadTokens, cacheWriteTokens);
|
|
171
|
-
yield observeModelStreamEvent({
|
|
172
|
-
type: 'usage',
|
|
173
|
-
final: false,
|
|
174
|
-
usage: {
|
|
175
|
-
...latestInputUsage
|
|
176
|
-
}
|
|
177
|
-
}, modelStreamEventObservedAt(raw));
|
|
178
|
-
}
|
|
179
|
-
else if (type === 'content_block_start') {
|
|
180
|
-
const block = record(event.content_block);
|
|
181
|
-
const blockType = text(block.type) ?? 'unknown';
|
|
182
|
-
if (blockType === 'thinking' &&
|
|
183
|
-
((block.thinking !== undefined && typeof block.thinking !== 'string') ||
|
|
184
|
-
(block.signature !== undefined && typeof block.signature !== 'string')))
|
|
185
|
-
throw new MarAgentError('MAR_AGENT_MODEL_PROTOCOL_ERROR', 'Anthropic returned an invalid native thinking block.');
|
|
186
|
-
if (['tool_use', 'server_tool_use', 'thinking', 'redacted_thinking'].includes(blockType)) {
|
|
187
|
-
for (const blockIndex of pendingTextBlocks) {
|
|
188
|
-
const pending = blocks.get(blockIndex);
|
|
189
|
-
if (pending?.type === 'text')
|
|
190
|
-
yield observeModelStreamEvent({
|
|
191
|
-
type: 'text.completed',
|
|
192
|
-
itemId: pending.id,
|
|
193
|
-
phase: 'commentary',
|
|
194
|
-
text: pending.text
|
|
195
|
-
}, modelStreamEventObservedAt(raw));
|
|
196
|
-
}
|
|
197
|
-
pendingTextBlocks.clear();
|
|
198
|
-
}
|
|
199
|
-
const id = text(block.id) ?? `${responseId}:content-${index}`;
|
|
200
|
-
if (['text', 'thinking', 'redacted_thinking', 'tool_use', 'server_tool_use'].includes(blockType))
|
|
201
|
-
yield observeModelStreamEvent({ type: 'output.started' }, modelStreamEventObservedAt(raw));
|
|
202
|
-
blocks.set(index, {
|
|
203
|
-
type: blockType,
|
|
204
|
-
id,
|
|
205
|
-
name: text(block.name),
|
|
206
|
-
json: Object.keys(record(block.input)).length ? JSON.stringify(block.input) : '',
|
|
207
|
-
text: text(block.text) ?? text(block.thinking) ?? '',
|
|
208
|
-
signature: text(block.signature) ?? '',
|
|
209
|
-
...(blockType === 'redacted_thinking' ? { data: block.data } : {})
|
|
210
|
-
});
|
|
211
|
-
if (blockType === 'text' && text(block.text))
|
|
212
|
-
yield observeModelStreamEvent({
|
|
213
|
-
type: 'text.delta',
|
|
214
|
-
itemId: id,
|
|
215
|
-
phase: 'commentary',
|
|
216
|
-
delta: text(block.text) ?? ''
|
|
217
|
-
}, modelStreamEventObservedAt(raw));
|
|
218
|
-
else if (blockType === 'server_tool_use') {
|
|
219
|
-
const toolName = text(block.name) ?? 'unknown';
|
|
220
|
-
const kind = toolName === 'web_fetch' ? 'WEB_FETCH' : 'WEB_SEARCH';
|
|
221
|
-
const summary = anthropicHostedInputSummary(record(block.input));
|
|
222
|
-
hostedTools.set(id, { kind, toolName, summary });
|
|
223
|
-
yield observeModelStreamEvent({
|
|
224
|
-
type: 'hosted_tool',
|
|
225
|
-
itemId: id,
|
|
226
|
-
kind,
|
|
227
|
-
toolName,
|
|
228
|
-
...(Object.keys(summary).length ? { input: summary } : {}),
|
|
229
|
-
status: 'RUNNING',
|
|
230
|
-
summary
|
|
231
|
-
}, modelStreamEventObservedAt(raw));
|
|
232
|
-
}
|
|
233
|
-
else if (blockType === 'web_search_tool_result' ||
|
|
234
|
-
blockType === 'web_fetch_tool_result') {
|
|
235
|
-
const toolId = text(block.tool_use_id);
|
|
236
|
-
const hosted = toolId === undefined ? undefined : hostedTools.get(toolId);
|
|
237
|
-
if (toolId !== undefined && hosted !== undefined) {
|
|
238
|
-
const result = block.content;
|
|
239
|
-
const sources = anthropicHostedSources(result);
|
|
240
|
-
const summary = {
|
|
241
|
-
...hosted.summary,
|
|
242
|
-
...(Array.isArray(result) ? { sources } : {}),
|
|
243
|
-
...(Array.isArray(result) && result.length > 20 ? { sourcesTruncated: true } : {})
|
|
244
|
-
};
|
|
245
|
-
hostedTools.set(toolId, { ...hosted, summary });
|
|
246
|
-
yield observeModelStreamEvent({
|
|
247
|
-
type: 'hosted_tool',
|
|
248
|
-
itemId: toolId,
|
|
249
|
-
kind: hosted.kind,
|
|
250
|
-
toolName: hosted.toolName,
|
|
251
|
-
...(Object.keys(anthropicHostedInputSummary(hosted.summary)).length
|
|
252
|
-
? { input: anthropicHostedInputSummary(hosted.summary) }
|
|
253
|
-
: {}),
|
|
254
|
-
...(sources.length
|
|
255
|
-
? {
|
|
256
|
-
output: {
|
|
257
|
-
sources,
|
|
258
|
-
...(summary.sourcesTruncated ? { sourcesTruncated: true } : {})
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
: {}),
|
|
262
|
-
...(summary.sourcesTruncated ? { truncated: true } : {}),
|
|
263
|
-
status: anthropicHostedResultFailed(result) ? 'FAILED' : 'COMPLETED',
|
|
264
|
-
summary
|
|
265
|
-
}, modelStreamEventObservedAt(raw));
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
else if (type === 'content_block_delta') {
|
|
270
|
-
const delta = record(event.delta);
|
|
271
|
-
const block = blocks.get(index);
|
|
272
|
-
if (block === undefined)
|
|
273
|
-
continue;
|
|
274
|
-
const deltaType = text(delta.type);
|
|
275
|
-
if (deltaType === 'text_delta') {
|
|
276
|
-
const value = text(delta.text) ?? '';
|
|
277
|
-
block.text += value;
|
|
278
|
-
yield observeModelStreamEvent({ type: 'text.delta', itemId: block.id, phase: 'commentary', delta: value }, modelStreamEventObservedAt(raw));
|
|
279
|
-
}
|
|
280
|
-
else if (deltaType === 'thinking_delta') {
|
|
281
|
-
const value = text(delta.thinking) ?? '';
|
|
282
|
-
block.text += value;
|
|
283
|
-
if (value.length > 0)
|
|
284
|
-
yield observeModelStreamEvent({ type: 'output.delta' }, modelStreamEventObservedAt(raw));
|
|
285
|
-
}
|
|
286
|
-
else if (deltaType === 'signature_delta') {
|
|
287
|
-
if (block.type !== 'thinking' || typeof delta.signature !== 'string')
|
|
288
|
-
throw new MarAgentError('MAR_AGENT_MODEL_PROTOCOL_ERROR', 'Anthropic returned an invalid thinking signature delta.');
|
|
289
|
-
block.signature += delta.signature;
|
|
290
|
-
}
|
|
291
|
-
else if (deltaType === 'input_json_delta') {
|
|
292
|
-
const value = text(delta.partial_json) ?? '';
|
|
293
|
-
block.json += value;
|
|
294
|
-
if (value.length > 0)
|
|
295
|
-
yield observeModelStreamEvent({ type: 'output.delta' }, modelStreamEventObservedAt(raw));
|
|
296
|
-
}
|
|
297
|
-
else if (deltaType === 'citations_delta') {
|
|
298
|
-
const citation = record(delta.citation);
|
|
299
|
-
const url = text(citation.url);
|
|
300
|
-
if (url)
|
|
301
|
-
yield observeModelStreamEvent({
|
|
302
|
-
type: 'citation',
|
|
303
|
-
citation: { id: `${block.id}-citation`, url, title: text(citation.title) }
|
|
304
|
-
}, modelStreamEventObservedAt(raw));
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
else if (type === 'content_block_stop') {
|
|
308
|
-
const block = blocks.get(index);
|
|
309
|
-
if (block?.type === 'text')
|
|
310
|
-
pendingTextBlocks.add(index);
|
|
311
|
-
else if (block?.type === 'thinking' || block?.type === 'redacted_thinking') {
|
|
312
|
-
if (completedThinking.has(index))
|
|
313
|
-
continue;
|
|
314
|
-
completedThinking.add(index);
|
|
315
|
-
if (block.type === 'redacted_thinking' || block.signature) {
|
|
316
|
-
const item = anthropicThinkingBlock(block.type === 'thinking'
|
|
317
|
-
? { type: 'thinking', thinking: block.text, signature: block.signature }
|
|
318
|
-
: { type: 'redacted_thinking', data: block.data });
|
|
319
|
-
if (!item)
|
|
320
|
-
throw new MarAgentError('MAR_AGENT_MODEL_PROTOCOL_ERROR', 'Anthropic returned an invalid or oversized native thinking block.');
|
|
321
|
-
thinkingBytes += Buffer.byteLength(JSON.stringify(item));
|
|
322
|
-
assertAnthropicThinkingBudget(thinkingBytes);
|
|
323
|
-
yield observeModelStreamEvent({
|
|
324
|
-
type: 'response.item',
|
|
325
|
-
provider: 'ANTHROPIC_MESSAGES',
|
|
326
|
-
contextKind: 'private',
|
|
327
|
-
item
|
|
328
|
-
}, modelStreamEventObservedAt(raw));
|
|
329
|
-
}
|
|
330
|
-
if (block.type === 'thinking' && block.text.trim())
|
|
331
|
-
yield observeModelStreamEvent({
|
|
332
|
-
type: 'reasoning.completed',
|
|
333
|
-
itemId: block.id,
|
|
334
|
-
representation: 'visible_thinking',
|
|
335
|
-
text: block.text
|
|
336
|
-
}, modelStreamEventObservedAt(raw));
|
|
337
|
-
}
|
|
338
|
-
else if (block?.type === 'server_tool_use') {
|
|
339
|
-
yield observeModelStreamEvent({ type: 'output.paused' }, modelStreamEventObservedAt(raw));
|
|
340
|
-
const hosted = hostedTools.get(block.id);
|
|
341
|
-
if (hosted !== undefined) {
|
|
342
|
-
let input;
|
|
343
|
-
try {
|
|
344
|
-
input = JSON.parse(block.json || '{}');
|
|
345
|
-
}
|
|
346
|
-
catch {
|
|
347
|
-
input = undefined;
|
|
348
|
-
}
|
|
349
|
-
const summary = { ...hosted.summary, ...anthropicHostedInputSummary(record(input)) };
|
|
350
|
-
if (summary.query !== hosted.summary.query || summary.url !== hosted.summary.url) {
|
|
351
|
-
hostedTools.set(block.id, { ...hosted, summary });
|
|
352
|
-
yield observeModelStreamEvent({
|
|
353
|
-
type: 'hosted_tool',
|
|
354
|
-
itemId: block.id,
|
|
355
|
-
kind: hosted.kind,
|
|
356
|
-
toolName: hosted.toolName,
|
|
357
|
-
input: anthropicHostedInputSummary(record(input)),
|
|
358
|
-
status: 'RUNNING',
|
|
359
|
-
summary
|
|
360
|
-
}, modelStreamEventObservedAt(raw));
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
else if (block?.type === 'tool_use') {
|
|
365
|
-
let args = {};
|
|
366
|
-
let argumentError;
|
|
367
|
-
try {
|
|
368
|
-
args = JSON.parse(block.json || '{}');
|
|
369
|
-
}
|
|
370
|
-
catch {
|
|
371
|
-
argumentError = 'Tool arguments are invalid JSON.';
|
|
372
|
-
}
|
|
373
|
-
yield observeModelStreamEvent({
|
|
374
|
-
type: 'client_tool.call',
|
|
375
|
-
callId: block.id,
|
|
376
|
-
name: block.name ?? 'unknown',
|
|
377
|
-
arguments: args,
|
|
378
|
-
...(argumentError ? { argumentError } : {})
|
|
379
|
-
}, modelStreamEventObservedAt(raw));
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
else if (type === 'message_delta') {
|
|
383
|
-
const delta = record(event.delta);
|
|
384
|
-
const reason = text(delta.stop_reason);
|
|
385
|
-
if (reason !== undefined)
|
|
386
|
-
yield observeModelStreamEvent({ type: 'output.completed' }, modelStreamEventObservedAt(raw));
|
|
387
|
-
terminal =
|
|
388
|
-
reason === 'tool_use'
|
|
389
|
-
? 'tool_use'
|
|
390
|
-
: reason === 'pause_turn'
|
|
391
|
-
? 'pause'
|
|
392
|
-
: reason === 'max_tokens'
|
|
393
|
-
? 'max_output'
|
|
394
|
-
: 'completed';
|
|
395
|
-
const phase = terminal === 'completed' ? 'final_answer' : 'commentary';
|
|
396
|
-
for (const blockIndex of pendingTextBlocks) {
|
|
397
|
-
const block = blocks.get(blockIndex);
|
|
398
|
-
if (block?.type === 'text')
|
|
399
|
-
yield observeModelStreamEvent({ type: 'text.completed', itemId: block.id, phase, text: block.text }, modelStreamEventObservedAt(raw));
|
|
400
|
-
}
|
|
401
|
-
pendingTextBlocks.clear();
|
|
402
|
-
const usage = record(event.usage);
|
|
403
|
-
const inputTokens = inputTokenCount(usage.input_tokens);
|
|
404
|
-
const cacheReadTokens = inputTokenCount(usage.cache_read_input_tokens);
|
|
405
|
-
const cacheWriteTokens = inputTokenCount(usage.cache_creation_input_tokens);
|
|
406
|
-
// Some compatible gateways emit a complete all-zero input placeholder at the end.
|
|
407
|
-
const zeroPlaceholder = inputTokens === 0 && cacheReadTokens === 0 && cacheWriteTokens === 0;
|
|
408
|
-
if (!zeroPlaceholder)
|
|
409
|
-
latestInputUsage = inputUsage(inputTokens ?? latestInputUsage?.inputTokens, cacheReadTokens ?? latestInputUsage?.cacheReadTokens, cacheWriteTokens ?? latestInputUsage?.cacheWriteTokens);
|
|
410
|
-
yield observeModelStreamEvent({
|
|
411
|
-
type: 'usage',
|
|
412
|
-
final: reason !== undefined,
|
|
413
|
-
usage: {
|
|
414
|
-
...latestInputUsage,
|
|
415
|
-
outputTokens: number(usage.output_tokens)
|
|
416
|
-
}
|
|
417
|
-
}, modelStreamEventObservedAt(raw));
|
|
418
|
-
}
|
|
419
|
-
else if (type === 'message_stop') {
|
|
420
|
-
yield observeModelStreamEvent({ type: 'completed', reason: terminal ?? 'completed' }, modelStreamEventObservedAt(raw));
|
|
421
|
-
}
|
|
422
|
-
else if (type === 'error') {
|
|
423
|
-
const upstream = record(event.error);
|
|
424
|
-
const code = boundedError(text(upstream.code) ?? text(upstream.type), 80);
|
|
425
|
-
const message = boundedError(text(upstream.message), 1_000);
|
|
426
|
-
const retryable = isRetryableUpstreamOverloadCode(code);
|
|
427
|
-
throw new MarAgentError(code ?? 'MAR_AGENT_MODEL_PROTOCOL_ERROR', message ?? 'Anthropic Messages request failed.', retryable
|
|
428
|
-
? {
|
|
429
|
-
details: { retryAfter: response.headers.get('retry-after') },
|
|
430
|
-
retryable: true
|
|
431
|
-
}
|
|
432
|
-
: {});
|
|
433
|
-
}
|
|
434
|
-
else
|
|
435
|
-
yield observeModelStreamEvent({ type: 'unknown', nativeType: type }, modelStreamEventObservedAt(raw));
|
|
436
|
-
}
|
|
437
|
-
if (terminal === undefined)
|
|
438
|
-
throw new MarAgentError('MAR_AGENT_MODEL_PROTOCOL_ERROR', 'Anthropic Messages stream ended without a terminal event.', {
|
|
439
|
-
retryable: true,
|
|
440
|
-
details: {
|
|
441
|
-
reason: 'ANTHROPIC_MESSAGES_EARLY_EOF',
|
|
442
|
-
retryAfter: response.headers.get('retry-after')
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
async function* parseAnthropicSse(response, signal, apiKey) {
|
|
448
|
-
try {
|
|
449
|
-
yield* parseSse(response, signal, undefined, undefined, [apiKey]);
|
|
450
|
-
}
|
|
451
|
-
catch (cause) {
|
|
452
|
-
if (response.ok &&
|
|
453
|
-
!signal.aborted &&
|
|
454
|
-
(isRetryableModelTransportError(cause) ||
|
|
455
|
-
(cause instanceof MarAgentError && cause.details?.reason === 'MODEL_STREAM_IDLE_TIMEOUT')))
|
|
456
|
-
throw new MarAgentError('MAR_AGENT_MODEL_PROTOCOL_ERROR', 'Anthropic Messages stream was interrupted.', {
|
|
457
|
-
retryable: true,
|
|
458
|
-
details: {
|
|
459
|
-
reason: 'ANTHROPIC_MESSAGES_EARLY_EOF',
|
|
460
|
-
retryAfter: response.headers.get('retry-after')
|
|
461
|
-
},
|
|
462
|
-
cause
|
|
463
|
-
});
|
|
464
|
-
throw cause;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
function anthropicHostedInputSummary(input) {
|
|
468
|
-
const query = text(input.query);
|
|
469
|
-
const url = text(input.url);
|
|
470
|
-
return {
|
|
471
|
-
...(query ? { query: query.slice(0, 10_000) } : {}),
|
|
472
|
-
...(url ? { url: url.slice(0, 2_048) } : {})
|
|
473
|
-
};
|
|
474
|
-
}
|
|
475
|
-
function anthropicHostedSources(result) {
|
|
476
|
-
if (!Array.isArray(result))
|
|
477
|
-
return [];
|
|
478
|
-
return result
|
|
479
|
-
.slice(0, 20)
|
|
480
|
-
.map((entry) => {
|
|
481
|
-
const source = record(entry);
|
|
482
|
-
const url = text(source.url);
|
|
483
|
-
if (!url)
|
|
484
|
-
return undefined;
|
|
485
|
-
const title = text(source.title);
|
|
486
|
-
const snippet = text(source.snippet);
|
|
487
|
-
return {
|
|
488
|
-
url: url.slice(0, 2_048),
|
|
489
|
-
...(title ? { title: title.slice(0, 256) } : {}),
|
|
490
|
-
...(snippet ? { snippet: snippet.slice(0, 2000) } : {})
|
|
491
|
-
};
|
|
492
|
-
})
|
|
493
|
-
.filter((source) => source !== undefined);
|
|
494
|
-
}
|
|
495
|
-
function anthropicHostedResultFailed(result) {
|
|
496
|
-
const entries = Array.isArray(result) ? result : [result];
|
|
497
|
-
return entries.some((entry) => text(record(entry).type)?.endsWith('_tool_result_error'));
|
|
498
|
-
}
|
|
499
|
-
function isSemanticEvent(event) {
|
|
500
|
-
if (event.type.startsWith('output.'))
|
|
501
|
-
return false;
|
|
502
|
-
return event.type !== 'response.started' && event.type !== 'usage';
|
|
503
|
-
}
|
|
504
|
-
export function isAnthropicRecoverableStreamError(error) {
|
|
505
|
-
return (error instanceof MarAgentError &&
|
|
506
|
-
error.retryable &&
|
|
507
|
-
(isRetryableUpstreamOverloadCode(error.code) ||
|
|
508
|
-
error.details?.reason === 'ANTHROPIC_MESSAGES_EARLY_EOF'));
|
|
509
|
-
}
|
|
510
|
-
function retryAfter(error) {
|
|
511
|
-
const value = error.details?.retryAfter;
|
|
512
|
-
return typeof value === 'string' ? value : null;
|
|
513
|
-
}
|
|
514
|
-
function inputTokenCount(value) {
|
|
515
|
-
return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : undefined;
|
|
516
|
-
}
|
|
517
|
-
function inputUsage(inputTokens, cacheReadTokens, cacheWriteTokens) {
|
|
518
|
-
return {
|
|
519
|
-
inputTokens,
|
|
520
|
-
contextInputTokens: tokenSum(inputTokens, cacheReadTokens, cacheWriteTokens),
|
|
521
|
-
...(inputTokens === undefined
|
|
522
|
-
? {}
|
|
523
|
-
: { totalInputTokens: tokenSum(inputTokens, cacheReadTokens, cacheWriteTokens) }),
|
|
524
|
-
cacheReadTokens,
|
|
525
|
-
cacheWriteTokens
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
function tokenSum(...values) {
|
|
529
|
-
return values.some((value) => value !== undefined)
|
|
530
|
-
? values.reduce((sum, value) => sum + (value ?? 0), 0)
|
|
531
|
-
: undefined;
|
|
532
|
-
}
|
|
533
|
-
function boundedError(value, maximum) {
|
|
534
|
-
const normalized = value?.trim();
|
|
535
|
-
if (!normalized)
|
|
536
|
-
return undefined;
|
|
537
|
-
return [...normalized].slice(0, maximum).join('');
|
|
538
|
-
}
|
|
539
|
-
function anthropicMessages(messages, images, tools = [], modelId, automaticCache = true, cachePrefixMessages) {
|
|
540
|
-
if (cachePrefixMessages !== undefined &&
|
|
541
|
-
(!Number.isSafeInteger(cachePrefixMessages) ||
|
|
542
|
-
cachePrefixMessages < 0 ||
|
|
543
|
-
cachePrefixMessages > messages.length))
|
|
544
|
-
throw new MarAgentError('MAR_AGENT_MODEL_REQUEST_INVALID', 'The captured cache prefix is invalid.');
|
|
545
|
-
const imageMessage = messages.findLastIndex(isRealUserMessage);
|
|
546
|
-
const toolDefinitions = new Map(tools.map((tool) => [tool.name, tool]));
|
|
547
|
-
const result = [];
|
|
548
|
-
let thinkingBytes = 0;
|
|
549
|
-
for (const [index, message] of messages.entries()) {
|
|
550
|
-
if (index === cachePrefixMessages)
|
|
551
|
-
for (const prior of result.slice(-2))
|
|
552
|
-
prior.content = withCacheBreakpoint(prior.content);
|
|
553
|
-
const userImages = message.role === 'user'
|
|
554
|
-
? uniqueModelImages(message.images, index === imageMessage ? images : undefined)
|
|
555
|
-
: [];
|
|
556
|
-
if (message.role === 'provider') {
|
|
557
|
-
if (message.provider !== 'ANTHROPIC_MESSAGES' || message.providerModelId !== modelId)
|
|
558
|
-
continue;
|
|
559
|
-
const block = anthropicThinkingBlock(message.item);
|
|
560
|
-
if (!block)
|
|
561
|
-
continue;
|
|
562
|
-
thinkingBytes += Buffer.byteLength(JSON.stringify(block));
|
|
563
|
-
assertAnthropicThinkingBudget(thinkingBytes);
|
|
564
|
-
const previous = result.at(-1);
|
|
565
|
-
if (previous?.role === 'assistant' && Array.isArray(previous.content))
|
|
566
|
-
previous.content.push(block);
|
|
567
|
-
else
|
|
568
|
-
result.push({ role: 'assistant', content: [block] });
|
|
569
|
-
continue;
|
|
570
|
-
}
|
|
571
|
-
if (message.role === 'tool_call') {
|
|
572
|
-
const block = {
|
|
573
|
-
type: 'tool_use',
|
|
574
|
-
id: message.callId,
|
|
575
|
-
name: message.name,
|
|
576
|
-
input: jsonToolInput(message, toolDefinitions.get(message.name ?? ''))
|
|
577
|
-
};
|
|
578
|
-
const previous = result.at(-1);
|
|
579
|
-
if (previous?.role === 'assistant' && Array.isArray(previous.content))
|
|
580
|
-
previous.content.push(block);
|
|
581
|
-
else
|
|
582
|
-
result.push({ role: 'assistant', content: [block] });
|
|
583
|
-
continue;
|
|
584
|
-
}
|
|
585
|
-
if (message.role === 'tool') {
|
|
586
|
-
const block = {
|
|
587
|
-
type: 'tool_result',
|
|
588
|
-
tool_use_id: message.callId,
|
|
589
|
-
...(message.isError === undefined ? {} : { is_error: message.isError }),
|
|
590
|
-
content: observationModelParts(message)?.map((part) => part.type === 'text'
|
|
591
|
-
? { type: 'text', text: part.text }
|
|
592
|
-
: {
|
|
593
|
-
type: 'image',
|
|
594
|
-
source: anthropicImageSource(part.image)
|
|
595
|
-
}) ??
|
|
596
|
-
(message.textBlocks !== undefined
|
|
597
|
-
? [
|
|
598
|
-
...anthropicTextBlocks(message.content, message.textBlocks),
|
|
599
|
-
...(message.images ?? []).map((image) => ({
|
|
600
|
-
type: 'image',
|
|
601
|
-
source: anthropicImageSource(image)
|
|
602
|
-
}))
|
|
603
|
-
]
|
|
604
|
-
: message.images?.length
|
|
605
|
-
? [
|
|
606
|
-
{ type: 'text', text: message.content },
|
|
607
|
-
...message.images.map((image) => ({
|
|
608
|
-
type: 'image',
|
|
609
|
-
source: anthropicImageSource(image)
|
|
610
|
-
}))
|
|
611
|
-
]
|
|
612
|
-
: message.content)
|
|
613
|
-
};
|
|
614
|
-
const previous = result.at(-1);
|
|
615
|
-
if (previous?.role === 'user' && Array.isArray(previous.content))
|
|
616
|
-
previous.content.push(block);
|
|
617
|
-
else
|
|
618
|
-
result.push({ role: 'user', content: [block] });
|
|
619
|
-
continue;
|
|
620
|
-
}
|
|
621
|
-
if (message.role === 'assistant') {
|
|
622
|
-
if (!message.content && message.textBlocks === undefined)
|
|
623
|
-
continue;
|
|
624
|
-
const blocks = message.textBlocks !== undefined
|
|
625
|
-
? anthropicTextBlocks(message.content, message.textBlocks)
|
|
626
|
-
: [{ type: 'text', text: message.content }];
|
|
627
|
-
const previous = result.at(-1);
|
|
628
|
-
if (previous?.role === 'assistant' && Array.isArray(previous.content))
|
|
629
|
-
previous.content.push(...blocks);
|
|
630
|
-
else
|
|
631
|
-
result.push({ role: 'assistant', content: blocks });
|
|
632
|
-
continue;
|
|
633
|
-
}
|
|
634
|
-
result.push({
|
|
635
|
-
role: message.role,
|
|
636
|
-
content: message.textBlocks !== undefined
|
|
637
|
-
? [
|
|
638
|
-
...userImages.map((image) => ({
|
|
639
|
-
type: 'image',
|
|
640
|
-
source: anthropicImageSource(image)
|
|
641
|
-
})),
|
|
642
|
-
...anthropicTextBlocks(message.content, message.textBlocks)
|
|
643
|
-
]
|
|
644
|
-
: userImages.length > 0
|
|
645
|
-
? [
|
|
646
|
-
...userImages.map((image) => ({
|
|
647
|
-
type: 'image',
|
|
648
|
-
source: anthropicImageSource(image)
|
|
649
|
-
})),
|
|
650
|
-
{ type: 'text', text: message.content }
|
|
651
|
-
]
|
|
652
|
-
: message.content
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
if (cachePrefixMessages === messages.length ||
|
|
656
|
-
(cachePrefixMessages === undefined && automaticCache))
|
|
657
|
-
for (const message of result.slice(-2))
|
|
658
|
-
message.content = withCacheBreakpoint(message.content);
|
|
659
|
-
return result;
|
|
660
|
-
}
|
|
661
|
-
function anthropicTextBlocks(text, blocks) {
|
|
662
|
-
return resolveModelTextBlocks(text, blocks).map((block) => ({
|
|
663
|
-
type: 'text',
|
|
664
|
-
text: block.text,
|
|
665
|
-
...(block.cache ? { cache_control: { type: 'ephemeral' } } : {})
|
|
666
|
-
}));
|
|
667
|
-
}
|
|
668
|
-
function isRealUserMessage(message) {
|
|
669
|
-
return (message.role === 'user' &&
|
|
670
|
-
message.contextKind === undefined &&
|
|
671
|
-
message.contextualBlock === undefined);
|
|
672
|
-
}
|
|
673
|
-
function uniqueModelImages(...groups) {
|
|
674
|
-
const seen = new Set();
|
|
675
|
-
return groups.flatMap((group) => (group ?? []).flatMap((image) => {
|
|
676
|
-
const key = modelImageKey(image);
|
|
677
|
-
if (seen.has(key))
|
|
678
|
-
return [];
|
|
679
|
-
seen.add(key);
|
|
680
|
-
return [image];
|
|
681
|
-
}));
|
|
682
|
-
}
|
|
683
|
-
function anthropicImageSource(image) {
|
|
684
|
-
const url = modelImageUrl(image);
|
|
685
|
-
return url === image.url
|
|
686
|
-
? { type: 'url', url }
|
|
687
|
-
: { type: 'base64', media_type: image.mimeType, data: image.dataBase64 };
|
|
688
|
-
}
|
|
689
|
-
function isObject(value) {
|
|
690
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
691
|
-
}
|
|
692
|
-
function withCacheBreakpoint(content) {
|
|
693
|
-
if (typeof content === 'string')
|
|
694
|
-
return [{ type: 'text', text: content, cache_control: { type: 'ephemeral' } }];
|
|
695
|
-
if (!Array.isArray(content) || content.length === 0)
|
|
696
|
-
return content;
|
|
697
|
-
const blocks = [...content];
|
|
698
|
-
const index = blocks.findLastIndex((block) => isObject(block) && block.type !== 'thinking' && block.type !== 'redacted_thinking');
|
|
699
|
-
const last = blocks[index];
|
|
700
|
-
if (!last || typeof last !== 'object')
|
|
701
|
-
return content;
|
|
702
|
-
blocks[index] = {
|
|
703
|
-
...last,
|
|
704
|
-
cache_control: { type: 'ephemeral' }
|
|
705
|
-
};
|
|
706
|
-
return blocks;
|
|
707
|
-
}
|