@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,534 +0,0 @@
|
|
|
1
|
-
import { setTimeout as delay } from 'node:timers/promises';
|
|
2
|
-
import { connect as connectTcp } from 'node:net';
|
|
3
|
-
import { connect as connectTls } from 'node:tls';
|
|
4
|
-
import { Client, Socks5ProxyAgent, buildConnector, fetch as undiciFetch } from 'undici';
|
|
5
|
-
import { MarAgentError } from '../error.js';
|
|
6
|
-
export const MAX_MODEL_ATTEMPTS = 8;
|
|
7
|
-
export function modelRetryMaxAttempts(state) {
|
|
8
|
-
const maximum = state.maxAttempts ?? MAX_MODEL_ATTEMPTS;
|
|
9
|
-
if (!Number.isInteger(maximum) || maximum < 1 || maximum > MAX_MODEL_ATTEMPTS)
|
|
10
|
-
throw new MarAgentError('MAR_AGENT_MODEL_CONFIG_INVALID', `Model attempts must be between 1 and ${MAX_MODEL_ATTEMPTS}.`);
|
|
11
|
-
return maximum;
|
|
12
|
-
}
|
|
13
|
-
const RETRYABLE_STATUS = new Set([408, 409, 429, 500, 502, 503, 504]);
|
|
14
|
-
const DEFAULT_MODEL_CONNECTION_TIMEOUT_MS = 30_000;
|
|
15
|
-
const SOCKS5_HANDSHAKE_TIMEOUT_MS = 10_000;
|
|
16
|
-
const RETRYABLE_TRANSPORT_CODES = new Set([
|
|
17
|
-
'EAI_AGAIN',
|
|
18
|
-
'ENOTFOUND',
|
|
19
|
-
'ECONNREFUSED',
|
|
20
|
-
'ECONNRESET',
|
|
21
|
-
'EHOSTUNREACH',
|
|
22
|
-
'ENETDOWN',
|
|
23
|
-
'ENETUNREACH',
|
|
24
|
-
'EPIPE',
|
|
25
|
-
'ETIMEDOUT',
|
|
26
|
-
'UND_ERR_CONNECT_TIMEOUT',
|
|
27
|
-
'UND_ERR_HEADERS_TIMEOUT',
|
|
28
|
-
'UND_ERR_SOCKET'
|
|
29
|
-
]);
|
|
30
|
-
export async function fetchModelResponse(url, init, signal, attempts = MAX_MODEL_ATTEMPTS, connectionTimeoutMs = DEFAULT_MODEL_CONNECTION_TIMEOUT_MS) {
|
|
31
|
-
let response;
|
|
32
|
-
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
33
|
-
try {
|
|
34
|
-
const resolved = typeof init === 'function' ? await init() : init;
|
|
35
|
-
const attempt = isModelHttpAttempt(resolved)
|
|
36
|
-
? resolved
|
|
37
|
-
: { request: resolved, httpVersion: '1.1' };
|
|
38
|
-
response = await fetchWithConnectionTimeout(url, attempt, signal, connectionTimeoutMs);
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
if (signal.aborted)
|
|
42
|
-
throw signal.reason ?? error;
|
|
43
|
-
if (isModelConnectionTimeout(error)) {
|
|
44
|
-
if (attempt + 1 >= attempts)
|
|
45
|
-
throw error;
|
|
46
|
-
await waitForModelRetry(null, attempt, signal);
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (!isRetryableModelTransportError(error))
|
|
50
|
-
throw error;
|
|
51
|
-
if (attempt + 1 >= attempts)
|
|
52
|
-
throw new MarAgentError(hasErrorCode(error, 'ETIMEDOUT') ||
|
|
53
|
-
hasErrorCode(error, 'UND_ERR_CONNECT_TIMEOUT') ||
|
|
54
|
-
hasErrorCode(error, 'UND_ERR_HEADERS_TIMEOUT')
|
|
55
|
-
? 'MAR_AGENT_MODEL_TIMEOUT'
|
|
56
|
-
: 'MAR_AGENT_MODEL_CONNECTION_FAILED', attempts === 1
|
|
57
|
-
? 'Model transport request failed.'
|
|
58
|
-
: 'Model transport request failed after retries.', { retryable: true, details: { reason: 'MODEL_TRANSPORT_FAILURE' }, cause: error });
|
|
59
|
-
await waitForModelRetry(null, attempt, signal);
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (!RETRYABLE_STATUS.has(response.status) || attempt + 1 >= attempts)
|
|
63
|
-
return response;
|
|
64
|
-
const retryAfter = response.headers.get('retry-after');
|
|
65
|
-
await response.body?.cancel().catch(() => undefined);
|
|
66
|
-
await waitForModelRetry(retryAfter, attempt, signal);
|
|
67
|
-
}
|
|
68
|
-
return response;
|
|
69
|
-
}
|
|
70
|
-
async function fetchWithConnectionTimeout(url, attempt, signal, connectionTimeoutMs) {
|
|
71
|
-
if (signal.aborted)
|
|
72
|
-
throw signal.reason;
|
|
73
|
-
const controller = new AbortController();
|
|
74
|
-
const timeoutError = new MarAgentError('MAR_AGENT_MODEL_TIMEOUT', 'Model connection timed out.', {
|
|
75
|
-
details: { reason: 'MODEL_CONNECTION_TIMEOUT' },
|
|
76
|
-
retryable: true
|
|
77
|
-
});
|
|
78
|
-
let rejectInterruption = () => undefined;
|
|
79
|
-
const interruption = new Promise((_resolve, reject) => {
|
|
80
|
-
rejectInterruption = reject;
|
|
81
|
-
});
|
|
82
|
-
const abortFromCaller = () => {
|
|
83
|
-
const reason = signal.reason;
|
|
84
|
-
controller.abort(reason);
|
|
85
|
-
rejectInterruption(reason);
|
|
86
|
-
};
|
|
87
|
-
signal.addEventListener('abort', abortFromCaller, { once: true });
|
|
88
|
-
const timeout = setTimeout(() => {
|
|
89
|
-
controller.abort(timeoutError);
|
|
90
|
-
rejectInterruption(timeoutError);
|
|
91
|
-
}, Math.max(1, connectionTimeoutMs));
|
|
92
|
-
try {
|
|
93
|
-
return await Promise.race([fetchHttpAttempt(url, attempt, controller.signal), interruption]);
|
|
94
|
-
}
|
|
95
|
-
finally {
|
|
96
|
-
clearTimeout(timeout);
|
|
97
|
-
signal.removeEventListener('abort', abortFromCaller);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
async function fetchHttpAttempt(url, attempt, signal) {
|
|
101
|
-
if (attempt.httpVersion === '1.1' && attempt.socks5Url === undefined)
|
|
102
|
-
return await fetch(url, { ...attempt.request, signal });
|
|
103
|
-
const dispatcher = attempt.socks5Url === undefined
|
|
104
|
-
? http2Client(url)
|
|
105
|
-
: attempt.httpVersion === '2'
|
|
106
|
-
? http2SocksClient(url, attempt.socks5Url)
|
|
107
|
-
: new Socks5ProxyAgent(attempt.socks5Url);
|
|
108
|
-
try {
|
|
109
|
-
const response = await undiciFetch(url, {
|
|
110
|
-
...attempt.request,
|
|
111
|
-
signal,
|
|
112
|
-
dispatcher
|
|
113
|
-
});
|
|
114
|
-
return responseWithDispatcherLifecycle(response, dispatcher);
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
await dispatcher.destroy(error instanceof Error ? error : null).catch(() => undefined);
|
|
118
|
-
if (hasErrorCode(error, 'MAR_AGENT_HTTP2_NEGOTIATION_FAILED'))
|
|
119
|
-
throw new MarAgentError('MAR_AGENT_MODEL_CONNECTION_FAILED', 'Model endpoint did not negotiate HTTP/2.', { cause: error });
|
|
120
|
-
throw error;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function http2Client(url) {
|
|
124
|
-
return new Client(new URL(url).origin, {
|
|
125
|
-
allowH2: true,
|
|
126
|
-
connect: strictHttp2Connector()
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
function http2SocksClient(url, socks5Url) {
|
|
130
|
-
return new Client(new URL(url).origin, {
|
|
131
|
-
allowH2: true,
|
|
132
|
-
connect: async (options, callback) => {
|
|
133
|
-
try {
|
|
134
|
-
const tlsSocket = await connectSocks5Target({
|
|
135
|
-
socks5Url,
|
|
136
|
-
targetHost: options.hostname,
|
|
137
|
-
targetPort: Number(options.port || 443),
|
|
138
|
-
tls: true,
|
|
139
|
-
servername: options.servername || options.hostname,
|
|
140
|
-
alpnProtocols: ['h2'],
|
|
141
|
-
requiredAlpnProtocol: 'h2'
|
|
142
|
-
});
|
|
143
|
-
callback(null, tlsSocket);
|
|
144
|
-
}
|
|
145
|
-
catch (error) {
|
|
146
|
-
callback(asError(error), null);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
export async function connectSocks5Target(input) {
|
|
152
|
-
if (input.signal?.aborted)
|
|
153
|
-
throw input.signal.reason;
|
|
154
|
-
const proxy = parseSocks5Proxy(input.socks5Url);
|
|
155
|
-
const targetHost = Buffer.from(input.targetHost, 'utf8');
|
|
156
|
-
if (targetHost.length === 0 ||
|
|
157
|
-
targetHost.length > 255 ||
|
|
158
|
-
!Number.isSafeInteger(input.targetPort) ||
|
|
159
|
-
input.targetPort < 1 ||
|
|
160
|
-
input.targetPort > 65_535)
|
|
161
|
-
throw invalidSocks5Proxy();
|
|
162
|
-
const socket = connectTcp({ host: proxy.hostname, port: proxy.port });
|
|
163
|
-
const timeoutError = Object.assign(new Error('SOCKS5 connection timed out.'), {
|
|
164
|
-
code: 'ETIMEDOUT'
|
|
165
|
-
});
|
|
166
|
-
const abort = () => socket.destroy(asError(input.signal?.reason));
|
|
167
|
-
const timeout = () => socket.destroy(timeoutError);
|
|
168
|
-
input.signal?.addEventListener('abort', abort, { once: true });
|
|
169
|
-
socket.setTimeout(SOCKS5_HANDSHAKE_TIMEOUT_MS);
|
|
170
|
-
socket.once('timeout', timeout);
|
|
171
|
-
try {
|
|
172
|
-
await waitForSocketConnect(socket);
|
|
173
|
-
const methods = proxy.username === undefined ? [0x00] : [0x00, 0x02];
|
|
174
|
-
await writeSocket(socket, Buffer.from([0x05, methods.length, ...methods]));
|
|
175
|
-
const greeting = await readSocketExactly(socket, 2);
|
|
176
|
-
if (greeting[0] !== 0x05 || greeting[1] === 0xff)
|
|
177
|
-
throw socks5ProtocolError('EACCES', 'SOCKS5 proxy rejected authentication methods.');
|
|
178
|
-
if (greeting[1] === 0x02) {
|
|
179
|
-
if (proxy.username === undefined || proxy.password === undefined)
|
|
180
|
-
throw socks5ProtocolError('EACCES', 'SOCKS5 proxy requires authentication.');
|
|
181
|
-
const username = Buffer.from(proxy.username, 'utf8');
|
|
182
|
-
const password = Buffer.from(proxy.password, 'utf8');
|
|
183
|
-
await writeSocket(socket, Buffer.concat([
|
|
184
|
-
Buffer.from([0x01, username.length]),
|
|
185
|
-
username,
|
|
186
|
-
Buffer.from([password.length]),
|
|
187
|
-
password
|
|
188
|
-
]));
|
|
189
|
-
const authentication = await readSocketExactly(socket, 2);
|
|
190
|
-
if (authentication[0] !== 0x01 || authentication[1] !== 0x00)
|
|
191
|
-
throw socks5ProtocolError('EACCES', 'SOCKS5 proxy authentication failed.');
|
|
192
|
-
}
|
|
193
|
-
else if (greeting[1] !== 0x00)
|
|
194
|
-
throw socks5ProtocolError('EACCES', 'SOCKS5 proxy selected an unsupported method.');
|
|
195
|
-
const port = Buffer.allocUnsafe(2);
|
|
196
|
-
port.writeUInt16BE(input.targetPort);
|
|
197
|
-
await writeSocket(socket, Buffer.concat([Buffer.from([0x05, 0x01, 0x00, 0x03, targetHost.length]), targetHost, port]));
|
|
198
|
-
const reply = await readSocketExactly(socket, 4);
|
|
199
|
-
if (reply[0] !== 0x05 || reply[2] !== 0x00)
|
|
200
|
-
throw socks5ProtocolError('EPROTO', 'SOCKS5 proxy returned an invalid response.');
|
|
201
|
-
if (reply[1] !== 0x00)
|
|
202
|
-
throw socks5ReplyError(reply[1]);
|
|
203
|
-
await consumeSocks5BoundAddress(socket, reply[3]);
|
|
204
|
-
socket.setTimeout(0);
|
|
205
|
-
socket.off('timeout', timeout);
|
|
206
|
-
input.signal?.removeEventListener('abort', abort);
|
|
207
|
-
if (!input.tls)
|
|
208
|
-
return socket;
|
|
209
|
-
return await upgradeSocks5Tls(socket, input);
|
|
210
|
-
}
|
|
211
|
-
catch (error) {
|
|
212
|
-
socket.destroy();
|
|
213
|
-
throw error;
|
|
214
|
-
}
|
|
215
|
-
finally {
|
|
216
|
-
socket.off('timeout', timeout);
|
|
217
|
-
input.signal?.removeEventListener('abort', abort);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
function parseSocks5Proxy(value) {
|
|
221
|
-
try {
|
|
222
|
-
const url = new URL(value);
|
|
223
|
-
const port = url.port === '' ? 1080 : Number(url.port);
|
|
224
|
-
if (url.protocol !== 'socks5:' ||
|
|
225
|
-
url.hostname.length === 0 ||
|
|
226
|
-
!Number.isSafeInteger(port) ||
|
|
227
|
-
port < 1 ||
|
|
228
|
-
port > 65_535 ||
|
|
229
|
-
(url.pathname !== '' && url.pathname !== '/') ||
|
|
230
|
-
url.search !== '' ||
|
|
231
|
-
url.hash !== '')
|
|
232
|
-
throw invalidSocks5Proxy();
|
|
233
|
-
const hasAuthentication = url.username !== '' || url.password !== '';
|
|
234
|
-
const username = hasAuthentication ? decodeURIComponent(url.username) : undefined;
|
|
235
|
-
const password = hasAuthentication ? decodeURIComponent(url.password) : undefined;
|
|
236
|
-
if ((hasAuthentication && username?.length === 0) ||
|
|
237
|
-
(username !== undefined && Buffer.byteLength(username) > 255) ||
|
|
238
|
-
(password !== undefined && Buffer.byteLength(password) > 255))
|
|
239
|
-
throw invalidSocks5Proxy();
|
|
240
|
-
return {
|
|
241
|
-
hostname: url.hostname,
|
|
242
|
-
port,
|
|
243
|
-
...(username === undefined ? {} : { username, password: password ?? '' })
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
catch (cause) {
|
|
247
|
-
if (cause instanceof MarAgentError)
|
|
248
|
-
throw cause;
|
|
249
|
-
throw invalidSocks5Proxy(cause);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
async function waitForSocketConnect(socket) {
|
|
253
|
-
if (socket.readyState === 'open')
|
|
254
|
-
return;
|
|
255
|
-
await new Promise((resolve, reject) => {
|
|
256
|
-
const cleanup = () => {
|
|
257
|
-
socket.off('connect', connected);
|
|
258
|
-
socket.off('error', failed);
|
|
259
|
-
socket.off('close', closed);
|
|
260
|
-
};
|
|
261
|
-
const connected = () => {
|
|
262
|
-
cleanup();
|
|
263
|
-
resolve();
|
|
264
|
-
};
|
|
265
|
-
const failed = (error) => {
|
|
266
|
-
cleanup();
|
|
267
|
-
reject(error);
|
|
268
|
-
};
|
|
269
|
-
const closed = () => {
|
|
270
|
-
cleanup();
|
|
271
|
-
reject(Object.assign(new Error('SOCKS5 proxy connection closed.'), { code: 'ECONNRESET' }));
|
|
272
|
-
};
|
|
273
|
-
socket.once('connect', connected);
|
|
274
|
-
socket.once('error', failed);
|
|
275
|
-
socket.once('close', closed);
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
async function writeSocket(socket, value) {
|
|
279
|
-
await new Promise((resolve, reject) => {
|
|
280
|
-
socket.write(value, (error) => (error ? reject(error) : resolve()));
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
async function readSocketExactly(socket, length) {
|
|
284
|
-
while (socket.readableLength < length) {
|
|
285
|
-
if (socket.readableEnded || socket.destroyed)
|
|
286
|
-
throw Object.assign(new Error('SOCKS5 proxy connection ended early.'), {
|
|
287
|
-
code: 'ECONNRESET'
|
|
288
|
-
});
|
|
289
|
-
await new Promise((resolve, reject) => {
|
|
290
|
-
const cleanup = () => {
|
|
291
|
-
socket.off('readable', readable);
|
|
292
|
-
socket.off('error', failed);
|
|
293
|
-
socket.off('end', ended);
|
|
294
|
-
socket.off('close', ended);
|
|
295
|
-
};
|
|
296
|
-
const readable = () => {
|
|
297
|
-
cleanup();
|
|
298
|
-
resolve();
|
|
299
|
-
};
|
|
300
|
-
const failed = (error) => {
|
|
301
|
-
cleanup();
|
|
302
|
-
reject(error);
|
|
303
|
-
};
|
|
304
|
-
const ended = () => {
|
|
305
|
-
cleanup();
|
|
306
|
-
reject(Object.assign(new Error('SOCKS5 proxy connection ended early.'), {
|
|
307
|
-
code: 'ECONNRESET'
|
|
308
|
-
}));
|
|
309
|
-
};
|
|
310
|
-
socket.once('readable', readable);
|
|
311
|
-
socket.once('error', failed);
|
|
312
|
-
socket.once('end', ended);
|
|
313
|
-
socket.once('close', ended);
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
const value = socket.read(length);
|
|
317
|
-
if (!Buffer.isBuffer(value) || value.length !== length)
|
|
318
|
-
throw socks5ProtocolError('EPROTO', 'SOCKS5 proxy returned an invalid response.');
|
|
319
|
-
return value;
|
|
320
|
-
}
|
|
321
|
-
async function consumeSocks5BoundAddress(socket, addressType) {
|
|
322
|
-
if (addressType === 0x01) {
|
|
323
|
-
await readSocketExactly(socket, 6);
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
if (addressType === 0x04) {
|
|
327
|
-
await readSocketExactly(socket, 18);
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
if (addressType === 0x03) {
|
|
331
|
-
const length = (await readSocketExactly(socket, 1))[0];
|
|
332
|
-
await readSocketExactly(socket, length + 2);
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
throw socks5ProtocolError('EPROTO', 'SOCKS5 proxy returned an invalid address.');
|
|
336
|
-
}
|
|
337
|
-
async function upgradeSocks5Tls(socket, input) {
|
|
338
|
-
const tlsSocket = connectTls({
|
|
339
|
-
socket,
|
|
340
|
-
servername: input.servername ?? input.targetHost,
|
|
341
|
-
...(input.alpnProtocols === undefined ? {} : { ALPNProtocols: [...input.alpnProtocols] })
|
|
342
|
-
});
|
|
343
|
-
const abort = () => tlsSocket.destroy(asError(input.signal?.reason));
|
|
344
|
-
const timeoutError = Object.assign(new Error('TLS connection timed out.'), {
|
|
345
|
-
code: 'ETIMEDOUT'
|
|
346
|
-
});
|
|
347
|
-
const timeout = () => tlsSocket.destroy(timeoutError);
|
|
348
|
-
input.signal?.addEventListener('abort', abort, { once: true });
|
|
349
|
-
tlsSocket.setTimeout(SOCKS5_HANDSHAKE_TIMEOUT_MS);
|
|
350
|
-
tlsSocket.once('timeout', timeout);
|
|
351
|
-
try {
|
|
352
|
-
await new Promise((resolve, reject) => {
|
|
353
|
-
const cleanup = () => {
|
|
354
|
-
tlsSocket.off('secureConnect', connected);
|
|
355
|
-
tlsSocket.off('error', failed);
|
|
356
|
-
tlsSocket.off('close', closed);
|
|
357
|
-
};
|
|
358
|
-
const connected = () => {
|
|
359
|
-
cleanup();
|
|
360
|
-
resolve();
|
|
361
|
-
};
|
|
362
|
-
const failed = (error) => {
|
|
363
|
-
cleanup();
|
|
364
|
-
reject(error);
|
|
365
|
-
};
|
|
366
|
-
const closed = () => {
|
|
367
|
-
cleanup();
|
|
368
|
-
reject(Object.assign(new Error('TLS connection closed early.'), { code: 'ECONNRESET' }));
|
|
369
|
-
};
|
|
370
|
-
tlsSocket.once('secureConnect', connected);
|
|
371
|
-
tlsSocket.once('error', failed);
|
|
372
|
-
tlsSocket.once('close', closed);
|
|
373
|
-
});
|
|
374
|
-
tlsSocket.setTimeout(0);
|
|
375
|
-
tlsSocket.off('timeout', timeout);
|
|
376
|
-
if (input.requiredAlpnProtocol !== undefined &&
|
|
377
|
-
tlsSocket.alpnProtocol !== input.requiredAlpnProtocol)
|
|
378
|
-
throw http2NegotiationError();
|
|
379
|
-
return tlsSocket;
|
|
380
|
-
}
|
|
381
|
-
catch (error) {
|
|
382
|
-
tlsSocket.destroy();
|
|
383
|
-
throw error;
|
|
384
|
-
}
|
|
385
|
-
finally {
|
|
386
|
-
tlsSocket.off('timeout', timeout);
|
|
387
|
-
input.signal?.removeEventListener('abort', abort);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
function socks5ReplyError(reply) {
|
|
391
|
-
const code = reply === 0x03
|
|
392
|
-
? 'ENETUNREACH'
|
|
393
|
-
: reply === 0x04
|
|
394
|
-
? 'EHOSTUNREACH'
|
|
395
|
-
: reply === 0x05
|
|
396
|
-
? 'ECONNREFUSED'
|
|
397
|
-
: reply === 0x06
|
|
398
|
-
? 'ETIMEDOUT'
|
|
399
|
-
: reply === 0x07
|
|
400
|
-
? 'EPROTONOSUPPORT'
|
|
401
|
-
: reply === 0x08
|
|
402
|
-
? 'EAFNOSUPPORT'
|
|
403
|
-
: 'EIO';
|
|
404
|
-
return socks5ProtocolError(code, 'SOCKS5 proxy could not connect to the model endpoint.');
|
|
405
|
-
}
|
|
406
|
-
function socks5ProtocolError(code, message) {
|
|
407
|
-
return Object.assign(new Error(message), { code });
|
|
408
|
-
}
|
|
409
|
-
function invalidSocks5Proxy(cause) {
|
|
410
|
-
return new MarAgentError('MAR_AGENT_MODEL_CONFIG_INVALID', 'SOCKS5 proxy URL is invalid.', {
|
|
411
|
-
...(cause === undefined ? {} : { cause })
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
function asError(error) {
|
|
415
|
-
return error instanceof Error ? error : new Error('Model transport failed.', { cause: error });
|
|
416
|
-
}
|
|
417
|
-
function strictHttp2Connector() {
|
|
418
|
-
const connector = buildConnector({ allowH2: true });
|
|
419
|
-
return (options, callback) => connector(options, (error, socket) => {
|
|
420
|
-
if (error || socket === null) {
|
|
421
|
-
callback(error, socket);
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
if (!('alpnProtocol' in socket) || socket.alpnProtocol !== 'h2') {
|
|
425
|
-
const negotiationError = http2NegotiationError();
|
|
426
|
-
socket.destroy(negotiationError);
|
|
427
|
-
callback(negotiationError, null);
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
callback(null, socket);
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
function http2NegotiationError() {
|
|
434
|
-
return Object.assign(new Error('HTTP/2 ALPN negotiation failed.'), {
|
|
435
|
-
code: 'MAR_AGENT_HTTP2_NEGOTIATION_FAILED'
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
function responseWithDispatcherLifecycle(response, dispatcher) {
|
|
439
|
-
if (response.body === null) {
|
|
440
|
-
void dispatcher.close();
|
|
441
|
-
return response;
|
|
442
|
-
}
|
|
443
|
-
const reader = response.body.getReader();
|
|
444
|
-
let closed = false;
|
|
445
|
-
const close = async () => {
|
|
446
|
-
if (closed)
|
|
447
|
-
return;
|
|
448
|
-
closed = true;
|
|
449
|
-
await dispatcher.close().catch(() => undefined);
|
|
450
|
-
};
|
|
451
|
-
const body = new ReadableStream({
|
|
452
|
-
async pull(controller) {
|
|
453
|
-
try {
|
|
454
|
-
const result = await reader.read();
|
|
455
|
-
if (result.done) {
|
|
456
|
-
controller.close();
|
|
457
|
-
await close();
|
|
458
|
-
}
|
|
459
|
-
else
|
|
460
|
-
controller.enqueue(result.value);
|
|
461
|
-
}
|
|
462
|
-
catch (error) {
|
|
463
|
-
controller.error(error);
|
|
464
|
-
await close();
|
|
465
|
-
}
|
|
466
|
-
},
|
|
467
|
-
async cancel(reason) {
|
|
468
|
-
await reader.cancel(reason).catch(() => undefined);
|
|
469
|
-
await close();
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
return new Response(body, {
|
|
473
|
-
status: response.status,
|
|
474
|
-
statusText: response.statusText,
|
|
475
|
-
headers: response.headers
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
function isModelHttpAttempt(value) {
|
|
479
|
-
return 'request' in value && (value.httpVersion === '1.1' || value.httpVersion === '2');
|
|
480
|
-
}
|
|
481
|
-
function hasErrorCode(error, code) {
|
|
482
|
-
let current = error;
|
|
483
|
-
for (let depth = 0; depth < 6 && current !== null && typeof current === 'object'; depth++) {
|
|
484
|
-
const value = current;
|
|
485
|
-
if (value.code === code)
|
|
486
|
-
return true;
|
|
487
|
-
current = value.cause;
|
|
488
|
-
}
|
|
489
|
-
return false;
|
|
490
|
-
}
|
|
491
|
-
export function modelRetryDelay(retryAfter, attempt) {
|
|
492
|
-
return retryAfterDelay(retryAfter) ?? (attempt + 1) * 5_000 + Math.floor(Math.random() * 3_001);
|
|
493
|
-
}
|
|
494
|
-
export async function waitForModelRetry(retryAfter, attempt, signal, delayMs = modelRetryDelay(retryAfter, attempt)) {
|
|
495
|
-
await delay(delayMs, undefined, { signal });
|
|
496
|
-
}
|
|
497
|
-
export function isRetryableModelHttpStatus(status) {
|
|
498
|
-
return RETRYABLE_STATUS.has(status);
|
|
499
|
-
}
|
|
500
|
-
export function isRetryableModelRequestError(error) {
|
|
501
|
-
return (error instanceof MarAgentError &&
|
|
502
|
-
error.retryable &&
|
|
503
|
-
(error.details?.reason === 'MODEL_PROGRESS_TIMEOUT' ||
|
|
504
|
-
error.details?.reason === 'MODEL_CONNECTION_TIMEOUT' ||
|
|
505
|
-
error.details?.reason === 'MODEL_TRANSPORT_FAILURE' ||
|
|
506
|
-
(typeof error.details?.status === 'number' &&
|
|
507
|
-
isRetryableModelHttpStatus(error.details.status))));
|
|
508
|
-
}
|
|
509
|
-
function retryAfterDelay(value) {
|
|
510
|
-
if (value !== null) {
|
|
511
|
-
const seconds = Number(value);
|
|
512
|
-
if (Number.isFinite(seconds))
|
|
513
|
-
return Math.min(30_000, Math.max(0, seconds * 1000));
|
|
514
|
-
const date = Date.parse(value);
|
|
515
|
-
if (Number.isFinite(date))
|
|
516
|
-
return Math.min(30_000, Math.max(0, date - Date.now()));
|
|
517
|
-
}
|
|
518
|
-
return undefined;
|
|
519
|
-
}
|
|
520
|
-
function isModelConnectionTimeout(error) {
|
|
521
|
-
return (error instanceof MarAgentError &&
|
|
522
|
-
error.code === 'MAR_AGENT_MODEL_TIMEOUT' &&
|
|
523
|
-
error.details?.reason === 'MODEL_CONNECTION_TIMEOUT');
|
|
524
|
-
}
|
|
525
|
-
export function isRetryableModelTransportError(error) {
|
|
526
|
-
let current = error;
|
|
527
|
-
for (let depth = 0; depth < 4 && current !== null && typeof current === 'object'; depth++) {
|
|
528
|
-
const record = current;
|
|
529
|
-
if (typeof record.code === 'string' && RETRYABLE_TRANSPORT_CODES.has(record.code))
|
|
530
|
-
return true;
|
|
531
|
-
current = record.cause;
|
|
532
|
-
}
|
|
533
|
-
return false;
|
|
534
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export interface ModelImage {
|
|
2
|
-
readonly resourceInputVersion?: 1;
|
|
3
|
-
readonly mimeType: string;
|
|
4
|
-
readonly dataBase64?: string;
|
|
5
|
-
readonly resourceId?: string;
|
|
6
|
-
readonly byteSize?: number;
|
|
7
|
-
/** Fixed published resource; image bytes are persisted separately. */
|
|
8
|
-
readonly url?: string;
|
|
9
|
-
readonly urlExpiresAt?: number;
|
|
10
|
-
}
|
|
11
|
-
export declare function modelImageUrl(image: ModelImage): string;
|
|
12
|
-
export declare function modelImageKey(image: ModelImage): string;
|
|
13
|
-
/** Only immutable URL references may enter durable model history. */
|
|
14
|
-
export declare function persistedModelImages(images: readonly ModelImage[] | undefined): ModelImage[];
|
|
15
|
-
/** Durable images contain a URL or resource reference, never inline image bytes. */
|
|
16
|
-
export declare function parseModelImages(value: unknown): ModelImage[] | undefined;
|
|
17
|
-
export declare function isModelImageUrl(value: unknown): value is string;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { MarAgentError } from '../error.js';
|
|
2
|
-
import { type MarAgentModelConfiguration, type ModelCredentialAcquireReason } from './configuration.js';
|
|
3
|
-
import WebSocket from 'ws';
|
|
4
|
-
import type { ModelAdapter, ModelAttemptDiagnostic, ModelEvent, ModelRequest, ModelTurnSession } from './contracts.js';
|
|
5
|
-
export declare const OPENAI_RESPONSES_EARLY_EOF_REASON = "OPENAI_RESPONSES_EARLY_EOF";
|
|
6
|
-
export declare const OPENAI_RESPONSES_WEBSOCKET_CONNECTION_LIMIT_REASON = "OPENAI_RESPONSES_WEBSOCKET_CONNECTION_LIMIT";
|
|
7
|
-
type ResponsesRequestBody = Readonly<Record<string, unknown>> & {
|
|
8
|
-
readonly input: readonly unknown[];
|
|
9
|
-
};
|
|
10
|
-
interface ResponsesSessionState {
|
|
11
|
-
socket?: WebSocket;
|
|
12
|
-
endpoint?: string;
|
|
13
|
-
credentialRevision?: number;
|
|
14
|
-
credentialFingerprint?: string;
|
|
15
|
-
connectionId?: string;
|
|
16
|
-
proxyType?: 'DIRECT' | 'SOCKS5';
|
|
17
|
-
lastRequest?: ResponsesRequestBody;
|
|
18
|
-
lastMessageCount?: number;
|
|
19
|
-
lastInputItemCount?: number;
|
|
20
|
-
lastSystem?: string;
|
|
21
|
-
lastResponse?: {
|
|
22
|
-
readonly responseId: string;
|
|
23
|
-
readonly outputItems: readonly Record<string, unknown>[];
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
interface PreparedResponsesRequest {
|
|
27
|
-
readonly inputItemCount: number;
|
|
28
|
-
readonly fullBody: ResponsesRequestBody;
|
|
29
|
-
readonly body: ResponsesRequestBody;
|
|
30
|
-
readonly continuation: boolean;
|
|
31
|
-
}
|
|
32
|
-
type ResponsesWebSocketDiagnostic = Pick<ModelAttemptDiagnostic, 'requestBytes' | 'imageCount' | 'imageBytes' | 'requestFrameCount' | 'sentFrameCount' | 'webSocketPhase' | 'webSocketCloseCode'>;
|
|
33
|
-
export declare class OpenAiResponsesAdapter implements ModelAdapter {
|
|
34
|
-
#private;
|
|
35
|
-
constructor(configuration: MarAgentModelConfiguration);
|
|
36
|
-
get configuration(): MarAgentModelConfiguration;
|
|
37
|
-
prepareReconfigure(configuration: MarAgentModelConfiguration): (() => void) | undefined;
|
|
38
|
-
start(request: ModelRequest, signal: AbortSignal): AsyncIterable<ModelEvent>;
|
|
39
|
-
createTurnSession(): ModelTurnSession;
|
|
40
|
-
close(): Promise<void>;
|
|
41
|
-
releaseTurnSession(state: ResponsesSessionState, cacheLease: boolean): void;
|
|
42
|
-
startTurn(request: ModelRequest, signal: AbortSignal, turn: OpenAiResponsesTurnSession, prepared: PreparedResponsesRequest): AsyncIterable<ModelEvent>;
|
|
43
|
-
private startAttempt;
|
|
44
|
-
}
|
|
45
|
-
declare class OpenAiResponsesTurnSession implements ModelTurnSession {
|
|
46
|
-
#private;
|
|
47
|
-
private readonly adapter;
|
|
48
|
-
private readonly state;
|
|
49
|
-
private readonly cacheLease;
|
|
50
|
-
constructor(adapter: OpenAiResponsesAdapter, state: ResponsesSessionState, cacheLease: boolean);
|
|
51
|
-
start(request: ModelRequest, signal: AbortSignal): AsyncIterable<ModelEvent>;
|
|
52
|
-
close(): Promise<void>;
|
|
53
|
-
resetContinuation(): void;
|
|
54
|
-
continuationInputCount(): number;
|
|
55
|
-
commitContinuationInput(messageCount: number): void;
|
|
56
|
-
captureCompletedResponseId(responseId: string | undefined): void;
|
|
57
|
-
prepareRequest(request: ModelRequest): PreparedResponsesRequest;
|
|
58
|
-
currentTurnState(): string | undefined;
|
|
59
|
-
beginAttempt(): void;
|
|
60
|
-
captureWebSocketDiagnostic(diagnostic: ResponsesWebSocketDiagnostic): void;
|
|
61
|
-
connectionDiagnostic(): Pick<ModelAttemptDiagnostic, 'connectionId' | 'connectionReused' | 'proxyType'> & ResponsesWebSocketDiagnostic;
|
|
62
|
-
captureTurnState(value: unknown): void;
|
|
63
|
-
withTurnStateMetadata(body: ResponsesRequestBody): ResponsesRequestBody;
|
|
64
|
-
invalidateWebSocket(): void;
|
|
65
|
-
webSocketForRequest(input: {
|
|
66
|
-
readonly configuration: MarAgentModelConfiguration;
|
|
67
|
-
readonly promptCacheKey: string | undefined;
|
|
68
|
-
readonly reason: ModelCredentialAcquireReason;
|
|
69
|
-
readonly signal: AbortSignal;
|
|
70
|
-
readonly continuation: boolean;
|
|
71
|
-
readonly credentialAcquired: (revision: number) => void;
|
|
72
|
-
}): Promise<WebSocket>;
|
|
73
|
-
private connectWebSocket;
|
|
74
|
-
}
|
|
75
|
-
export declare function isOpenAiResponsesRecoverableStreamError(error: unknown): error is MarAgentError;
|
|
76
|
-
export declare function openAiInput(messages: ModelRequest['messages'], images: ModelRequest['images'] | undefined, modelId: string, requireEncryptedReasoning: boolean, configurationUpdates?: boolean, nativeTools?: boolean, tools?: ModelRequest['tools'], previousOutputItems?: readonly Record<string, unknown>[]): Record<string, unknown>[];
|
|
77
|
-
export {};
|