@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
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
2
|
+
import { AgentError } from '../../error.js';
|
|
3
|
+
import { TOOL_EXECUTION_LIMITS } from '../execution-limits.js';
|
|
4
|
+
import { sourcePreview } from '../input-diagnostics/source-preview.js';
|
|
5
|
+
const beginMarker = '*** Begin Patch';
|
|
6
|
+
const endMarker = '*** End Patch';
|
|
7
|
+
const addHeader = '*** Add File: ';
|
|
8
|
+
const updateHeader = '*** Update File: ';
|
|
9
|
+
const deleteHeader = '*** Delete File: ';
|
|
10
|
+
const moveHeader = '*** Move to: ';
|
|
11
|
+
export function parsePatch(patch) {
|
|
12
|
+
if (typeof patch !== 'string')
|
|
13
|
+
throw new AgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Patch must be a string.');
|
|
14
|
+
if (Buffer.byteLength(patch) > TOOL_EXECUTION_LIMITS.patchMaxBytes)
|
|
15
|
+
throw new AgentError('MAR_AGENT_TOOL_OUTPUT_LIMIT', 'Patch exceeds the input byte limit.');
|
|
16
|
+
return new FreeformPatchParser(patch).parse();
|
|
17
|
+
}
|
|
18
|
+
class FreeformPatchParser {
|
|
19
|
+
#lines;
|
|
20
|
+
#lineOffsets = [];
|
|
21
|
+
#claimed = new Set();
|
|
22
|
+
#index = 1;
|
|
23
|
+
constructor(patch) {
|
|
24
|
+
const sourceLines = patch.split('\n');
|
|
25
|
+
let offset = 0;
|
|
26
|
+
this.#lines = sourceLines.map((line, index) => {
|
|
27
|
+
this.#lineOffsets.push(offset);
|
|
28
|
+
offset += line.length + 1;
|
|
29
|
+
return index < sourceLines.length - 1 && line.endsWith('\r') ? line.slice(0, -1) : line;
|
|
30
|
+
});
|
|
31
|
+
if (patch.endsWith('\n'))
|
|
32
|
+
this.#lines.pop();
|
|
33
|
+
}
|
|
34
|
+
parse() {
|
|
35
|
+
for (const [index, line] of this.#lines.entries()) {
|
|
36
|
+
const column = line.indexOf('\r');
|
|
37
|
+
if (column !== -1)
|
|
38
|
+
this.#fail('Patch contains unsupported bare carriage returns.', index, column);
|
|
39
|
+
}
|
|
40
|
+
this.#marker(0, beginMarker, 'first');
|
|
41
|
+
this.#marker(this.#lines.length - 1, endMarker, 'last');
|
|
42
|
+
if (this.#lines.length < 3)
|
|
43
|
+
this.#fail('Patch must contain at least one operation.', 1);
|
|
44
|
+
const changes = [];
|
|
45
|
+
while (this.#index < this.#lines.length - 1) {
|
|
46
|
+
const headerIndex = this.#index++;
|
|
47
|
+
const header = this.#lines[headerIndex];
|
|
48
|
+
if (header.startsWith(addHeader)) {
|
|
49
|
+
const path = this.#path(headerIndex, addHeader);
|
|
50
|
+
const lines = [];
|
|
51
|
+
while (this.#hasBodyLine()) {
|
|
52
|
+
const index = this.#index++;
|
|
53
|
+
const line = this.#lines[index];
|
|
54
|
+
if (!line.startsWith('+'))
|
|
55
|
+
this.#fail('Added file lines must start with +.', index);
|
|
56
|
+
lines.push(line.slice(1));
|
|
57
|
+
}
|
|
58
|
+
changes.push({ kind: 'add', path, lines });
|
|
59
|
+
}
|
|
60
|
+
else if (header.startsWith(deleteHeader)) {
|
|
61
|
+
changes.push({ kind: 'delete', path: this.#path(headerIndex, deleteHeader) });
|
|
62
|
+
}
|
|
63
|
+
else if (header.startsWith(updateHeader)) {
|
|
64
|
+
const path = this.#path(headerIndex, updateHeader);
|
|
65
|
+
let targetPath;
|
|
66
|
+
if (this.#lines[this.#index]?.startsWith(moveHeader)) {
|
|
67
|
+
targetPath = this.#path(this.#index++, moveHeader);
|
|
68
|
+
}
|
|
69
|
+
const hunks = [];
|
|
70
|
+
while (this.#index < this.#lines.length - 1 && this.#lines[this.#index].startsWith('@@'))
|
|
71
|
+
hunks.push(this.#hunk());
|
|
72
|
+
if (!hunks.length && !targetPath)
|
|
73
|
+
this.#fail('Update operations must contain hunks or move a file.', headerIndex);
|
|
74
|
+
changes.push({ kind: 'update', path, ...(targetPath ? { targetPath } : {}), hunks });
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.#fail("Expected an operation header: '*** Add File: <path>', '*** Update File: <path>', or '*** Delete File: <path>'.", headerIndex, Math.max(...[addHeader, updateHeader, deleteHeader].map((prefix) => commonPrefixLength(header, prefix))));
|
|
78
|
+
}
|
|
79
|
+
if (changes.length > TOOL_EXECUTION_LIMITS.patchMaxFiles)
|
|
80
|
+
throw new AgentError('MAR_AGENT_TOOL_OUTPUT_LIMIT', 'Patch exceeds the file limit.');
|
|
81
|
+
}
|
|
82
|
+
if (!changes.some((change) => change.kind !== 'update' || change.targetPath || change.hunks.some((hunk) => !hunk.anchor)))
|
|
83
|
+
this.#fail('Patch must change or move at least one file. No additions, deletions, or moves were supplied; context-only hunks only validate existing lines. Use read to inspect a file, or supply -old/+new lines to edit it.', 1);
|
|
84
|
+
return changes;
|
|
85
|
+
}
|
|
86
|
+
#marker(index, marker, position) {
|
|
87
|
+
const line = this.#lines[index];
|
|
88
|
+
const trimmed = line.trim();
|
|
89
|
+
if (trimmed === marker || trimmed === `${marker} ***`)
|
|
90
|
+
return;
|
|
91
|
+
const leading = line.length - line.trimStart().length;
|
|
92
|
+
const expected = trimmed.startsWith(`${marker} ***`) ? `${marker} ***` : marker;
|
|
93
|
+
this.#fail(`Expected ${position} line to be '${marker}' (optional trailing ' ***').`, index, leading + commonPrefixLength(trimmed, expected));
|
|
94
|
+
}
|
|
95
|
+
#path(index, prefix) {
|
|
96
|
+
const path = this.#lines[index].slice(prefix.length);
|
|
97
|
+
if (!path || path.trim() !== path) {
|
|
98
|
+
const column = path.trimStart() !== path ? prefix.length : prefix.length + path.trimEnd().length;
|
|
99
|
+
this.#fail('Patch paths must be non-empty and unpadded.', index, column);
|
|
100
|
+
}
|
|
101
|
+
const key = isAbsolute(path) ? resolve(path) : resolve('/', path);
|
|
102
|
+
if (this.#claimed.has(key))
|
|
103
|
+
this.#fail('Patch contains duplicate or overlapping paths.', index, prefix.length);
|
|
104
|
+
this.#claimed.add(key);
|
|
105
|
+
return path;
|
|
106
|
+
}
|
|
107
|
+
#hasBodyLine() {
|
|
108
|
+
return this.#index < this.#lines.length - 1 && !this.#lines[this.#index].startsWith('*** ');
|
|
109
|
+
}
|
|
110
|
+
#hunk() {
|
|
111
|
+
const index = this.#index++;
|
|
112
|
+
const header = this.#lines[index];
|
|
113
|
+
let changeContext;
|
|
114
|
+
if (header !== '@@') {
|
|
115
|
+
if (!header.startsWith('@@ '))
|
|
116
|
+
this.#fail('Patch change context headers must use @@ or @@ <context>.', index, 2);
|
|
117
|
+
changeContext = header.slice(3);
|
|
118
|
+
if (!changeContext.trim())
|
|
119
|
+
this.#fail('Patch change context must be non-empty.', index, 3);
|
|
120
|
+
}
|
|
121
|
+
const oldLines = [];
|
|
122
|
+
const patchLines = [];
|
|
123
|
+
let addedLines = 0;
|
|
124
|
+
let deletedLines = 0;
|
|
125
|
+
while (this.#hasBodyLine() && !this.#lines[this.#index].startsWith('@@')) {
|
|
126
|
+
const lineIndex = this.#index++;
|
|
127
|
+
const line = this.#lines[lineIndex];
|
|
128
|
+
const value = line.slice(1);
|
|
129
|
+
if (line.startsWith(' ')) {
|
|
130
|
+
oldLines.push(value);
|
|
131
|
+
patchLines.push({ kind: 'context', value });
|
|
132
|
+
}
|
|
133
|
+
else if (line.startsWith('+')) {
|
|
134
|
+
patchLines.push({ kind: 'addition', value });
|
|
135
|
+
addedLines++;
|
|
136
|
+
}
|
|
137
|
+
else if (line.startsWith('-')) {
|
|
138
|
+
oldLines.push(value);
|
|
139
|
+
patchLines.push({ kind: 'deletion', value });
|
|
140
|
+
deletedLines++;
|
|
141
|
+
}
|
|
142
|
+
else
|
|
143
|
+
this.#fail('Patch hunk lines must start with space, +, or -.', lineIndex);
|
|
144
|
+
}
|
|
145
|
+
if (!oldLines.length)
|
|
146
|
+
this.#fail('Insertion hunks require context.', index);
|
|
147
|
+
return {
|
|
148
|
+
...(changeContext === undefined ? {} : { changeContext }),
|
|
149
|
+
oldLines,
|
|
150
|
+
patchLines,
|
|
151
|
+
addedLines,
|
|
152
|
+
deletedLines,
|
|
153
|
+
anchor: !addedLines && !deletedLines
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
#fail(message, index, characterOffset = 0) {
|
|
157
|
+
const source = this.#lines[index];
|
|
158
|
+
const line = index + 1;
|
|
159
|
+
const column = characterCount(source.slice(0, characterOffset)) + 1;
|
|
160
|
+
const offset = this.#lineOffsets[index] + characterOffset;
|
|
161
|
+
const preview = sourcePreview(source, column);
|
|
162
|
+
const gutter = String(line);
|
|
163
|
+
throw new AgentError('MAR_AGENT_TOOL_INPUT_INVALID', `Patch syntax error at line ${line}, column ${column}: ${message}\n${gutter} | ${preview.text}\n${' '.repeat(gutter.length)} | ${' '.repeat(preview.caret)}^`, { details: { line, column, offset } });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function commonPrefixLength(actual, expected) {
|
|
167
|
+
let index = 0;
|
|
168
|
+
while (index < actual.length && index < expected.length && actual[index] === expected[index])
|
|
169
|
+
index++;
|
|
170
|
+
return index;
|
|
171
|
+
}
|
|
172
|
+
function characterCount(value) {
|
|
173
|
+
let count = 0;
|
|
174
|
+
for (const _character of value)
|
|
175
|
+
count++;
|
|
176
|
+
return count;
|
|
177
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ClientToolDefinition } from '../contracts.js';
|
|
2
|
+
import type { ApplyPatchResult } from '../contracts.js';
|
|
3
|
+
import { WorkspacePathResolver } from '../shared/path-resolver.js';
|
|
4
|
+
export type { ApplyPatchFileResult, ApplyPatchResult } from '../contracts.js';
|
|
5
|
+
export declare const applyPatchToolDefinition: ClientToolDefinition;
|
|
6
|
+
export declare function applyPatchToolInput(input: unknown): string;
|
|
7
|
+
interface PatchFileOperations {
|
|
8
|
+
rename(source: string, target: string): Promise<void>;
|
|
9
|
+
rm(path: string, options?: {
|
|
10
|
+
force?: boolean;
|
|
11
|
+
recursive?: boolean;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare class ApplyPatchTool {
|
|
15
|
+
#private;
|
|
16
|
+
private readonly paths;
|
|
17
|
+
constructor(paths: WorkspacePathResolver, operations?: Partial<PatchFileOperations>);
|
|
18
|
+
execute(patch: string): Promise<ApplyPatchResult>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { chmod, lstat, mkdir, readFile, rename, rm, rmdir, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { dirname, parse, resolve } from 'node:path';
|
|
4
|
+
import { TextDecoder } from 'node:util';
|
|
5
|
+
import { AgentError } from '../../error.js';
|
|
6
|
+
import { TOOL_EXECUTION_LIMITS } from '../execution-limits.js';
|
|
7
|
+
import { captureFileChange, reserveFileChangePaths } from '../result-extensions.js';
|
|
8
|
+
import { parsePatch } from './apply-patch-parser.js';
|
|
9
|
+
export const applyPatchToolDefinition = {
|
|
10
|
+
name: 'apply_patch',
|
|
11
|
+
allowedCallers: ['direct', 'programmatic'],
|
|
12
|
+
codeModeExposure: 'both',
|
|
13
|
+
parallelSafety: 'serial',
|
|
14
|
+
description: `Preferred for precise, reviewable local edits. Do not batch all task files merely to reduce tool calls. Group only a few tightly coupled edits whose combined patch is quick to generate and review; split broad or independent work into successive bounded patches before composing them. Submit a raw *** Begin Patch / *** End Patch patch, each marker on its own line. Surrounding marker whitespace and an optional trailing *** are accepted; incomplete markers or extra text are rejected. Add File content lines, including blank lines, must start with +. Syntax errors include line/column and a bounded excerpt of the submitted patch with a caret at the error. Supports Add File, Update File, Delete File, and Move to. Add File may replace an existing regular file, and Move to may replace an existing regular destination; duplicate operations on the same resolved path remain invalid. Update hunks accept @@ or @@ <change context>. Context-only hunks, including trailing hunks, and unchanged file sections are validated in order but are not written or reported as edits. The patch must include a change or move. Context is searched forward with Codex-style exact, whitespace-tolerant, then common Unicode punctuation-tolerant matching. Syntax and resolved paths are validated before writing, then file units are committed in order. Each file unit is atomic, and a Move keeps its source and destination atomic. On MAR_AGENT_PATCH_PARTIAL, earlier files remain applied; the error lists applied, failed, and pending paths, so retry only failed and pending paths. Existing file permissions, line endings, and final-newline state are preserved. Returns changed file paths and operations with per-file and total line counts when all units succeed. In Code Mode, the Promise resolves on success and rejects with code/message on failure; the returned envelope has data.files and data.totals, not an ok or success flag. Oversized patches are rejected without advertising defensive limits as recommended patch sizes. A first-unit MAR_AGENT_PATCH_CONFLICT applies nothing; hunk match conflicts identify the affected path and hunk so you can reread only that file before retrying.`,
|
|
15
|
+
inputMode: 'freeform',
|
|
16
|
+
outputSchema: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
required: ['content', 'data'],
|
|
19
|
+
properties: {
|
|
20
|
+
content: { type: 'string' },
|
|
21
|
+
data: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
required: ['files', 'totals'],
|
|
24
|
+
properties: {
|
|
25
|
+
files: {
|
|
26
|
+
type: 'array',
|
|
27
|
+
items: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
required: ['path', 'operation', 'addedLines', 'deletedLines'],
|
|
30
|
+
properties: {
|
|
31
|
+
path: { type: 'string' },
|
|
32
|
+
targetPath: { type: 'string' },
|
|
33
|
+
operation: { enum: ['added', 'modified', 'deleted', 'moved'] },
|
|
34
|
+
addedLines: { type: 'number' },
|
|
35
|
+
deletedLines: { type: 'number' }
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
totals: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
required: ['files', 'addedLines', 'deletedLines'],
|
|
42
|
+
properties: {
|
|
43
|
+
files: { type: 'number' },
|
|
44
|
+
addedLines: { type: 'number' },
|
|
45
|
+
deletedLines: { type: 'number' }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
inputSchema: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: { patch: { type: 'string' } },
|
|
55
|
+
required: ['patch'],
|
|
56
|
+
additionalProperties: false
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
export function applyPatchToolInput(input) {
|
|
60
|
+
const patch = typeof input === 'string' ? input : input?.patch;
|
|
61
|
+
if (typeof patch !== 'string')
|
|
62
|
+
throw new AgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Patch is required.');
|
|
63
|
+
return patch;
|
|
64
|
+
}
|
|
65
|
+
const defaultFileOperations = { rename, rm };
|
|
66
|
+
const utf8Decoder = new TextDecoder('utf-8', { fatal: true });
|
|
67
|
+
export class ApplyPatchTool {
|
|
68
|
+
paths;
|
|
69
|
+
#fileOperations;
|
|
70
|
+
constructor(paths, operations = {}) {
|
|
71
|
+
this.paths = paths;
|
|
72
|
+
this.#fileOperations = { ...defaultFileOperations, ...operations };
|
|
73
|
+
}
|
|
74
|
+
async execute(patch) {
|
|
75
|
+
const changes = parsePatch(patch);
|
|
76
|
+
reserveFileChangePaths(changes.flatMap((change) => change.kind === 'update' && change.targetPath
|
|
77
|
+
? [change.path, change.targetPath]
|
|
78
|
+
: [change.path]));
|
|
79
|
+
const resolvedChanges = await this.#resolveChanges(changes);
|
|
80
|
+
const results = [];
|
|
81
|
+
let totalBytes = 0;
|
|
82
|
+
const pendingChanges = [];
|
|
83
|
+
for (const resolvedChange of resolvedChanges) {
|
|
84
|
+
if (resolvedChange.kind === 'update' &&
|
|
85
|
+
resolvedChange.change.hunks.every((hunk) => hunk.anchor))
|
|
86
|
+
totalBytes = (await this.#preflight(resolvedChange, totalBytes)).totalBytes;
|
|
87
|
+
else
|
|
88
|
+
pendingChanges.push(resolvedChange);
|
|
89
|
+
}
|
|
90
|
+
for (const [index, resolvedChange] of pendingChanges.entries()) {
|
|
91
|
+
try {
|
|
92
|
+
const preflight = await this.#preflight(resolvedChange, totalBytes);
|
|
93
|
+
if (preflight.mutations.length)
|
|
94
|
+
await this.#commit(preflight.mutations);
|
|
95
|
+
if (preflight.result)
|
|
96
|
+
results.push(preflight.result);
|
|
97
|
+
totalBytes = preflight.totalBytes;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
if (!results.length ||
|
|
101
|
+
(error instanceof AgentError && error.code === 'MAR_AGENT_PATCH_ROLLBACK_FAILED'))
|
|
102
|
+
throw error;
|
|
103
|
+
throw partialPatchError(error, results, pendingChanges.slice(index));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
files: results,
|
|
108
|
+
totals: {
|
|
109
|
+
files: results.length,
|
|
110
|
+
addedLines: results.reduce((total, file) => total + file.addedLines, 0),
|
|
111
|
+
deletedLines: results.reduce((total, file) => total + file.deletedLines, 0)
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
async #resolveChanges(changes) {
|
|
116
|
+
const resolvedChanges = [];
|
|
117
|
+
const claimedTargets = new Set();
|
|
118
|
+
const claimTarget = (target) => {
|
|
119
|
+
const key = resolve(target);
|
|
120
|
+
if (claimedTargets.has(key))
|
|
121
|
+
invalid('Patch contains duplicate or overlapping paths.');
|
|
122
|
+
claimedTargets.add(key);
|
|
123
|
+
};
|
|
124
|
+
for (const change of changes) {
|
|
125
|
+
if (change.kind === 'add') {
|
|
126
|
+
const target = await this.paths.resolve(change.path, true, 'write');
|
|
127
|
+
claimTarget(target);
|
|
128
|
+
resolvedChanges.push({ kind: 'add', change, target });
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const source = await this.paths.resolve(change.path, true, 'write');
|
|
132
|
+
claimTarget(source);
|
|
133
|
+
if (change.kind === 'delete') {
|
|
134
|
+
resolvedChanges.push({ kind: 'delete', change, source });
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (change.targetPath) {
|
|
138
|
+
const target = await this.paths.resolve(change.targetPath, true, 'write');
|
|
139
|
+
claimTarget(target);
|
|
140
|
+
resolvedChanges.push({
|
|
141
|
+
kind: 'move',
|
|
142
|
+
change: { ...change, targetPath: change.targetPath },
|
|
143
|
+
source,
|
|
144
|
+
target
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
else
|
|
148
|
+
resolvedChanges.push({ kind: 'update', change, source });
|
|
149
|
+
}
|
|
150
|
+
return resolvedChanges;
|
|
151
|
+
}
|
|
152
|
+
async #preflight(resolvedChange, currentTotalBytes) {
|
|
153
|
+
if (resolvedChange.kind === 'add') {
|
|
154
|
+
const { change } = resolvedChange;
|
|
155
|
+
const targetStat = await optionalLstat(resolvedChange.target);
|
|
156
|
+
if (targetStat && !targetStat.isFile())
|
|
157
|
+
invalid('Patch targets must be regular files.');
|
|
158
|
+
const content = Buffer.from(change.lines.length ? `${change.lines.join('\n')}\n` : '');
|
|
159
|
+
const totalBytes = enforceContentLimits(content, currentTotalBytes);
|
|
160
|
+
return {
|
|
161
|
+
mutations: [
|
|
162
|
+
{
|
|
163
|
+
path: change.path,
|
|
164
|
+
target: resolvedChange.target,
|
|
165
|
+
content,
|
|
166
|
+
...(targetStat ? { mode: targetStat.mode & 0o7777 } : {}),
|
|
167
|
+
expectedExisting: targetStat !== undefined,
|
|
168
|
+
...(targetStat ? { original: await readBoundedFile(resolvedChange.target) } : {})
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
result: {
|
|
172
|
+
path: change.path,
|
|
173
|
+
operation: 'added',
|
|
174
|
+
addedLines: change.lines.length,
|
|
175
|
+
deletedLines: 0
|
|
176
|
+
},
|
|
177
|
+
totalBytes
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const sourceStat = await lstat(resolvedChange.source);
|
|
181
|
+
if (!sourceStat.isFile())
|
|
182
|
+
invalid('Patch sources must be regular files.');
|
|
183
|
+
const original = await readBoundedFile(resolvedChange.source);
|
|
184
|
+
let totalBytes = enforceContentLimits(original, currentTotalBytes);
|
|
185
|
+
if (resolvedChange.kind === 'delete') {
|
|
186
|
+
const { change } = resolvedChange;
|
|
187
|
+
return {
|
|
188
|
+
mutations: [
|
|
189
|
+
{ path: change.path, target: resolvedChange.source, expectedExisting: true, original }
|
|
190
|
+
],
|
|
191
|
+
result: {
|
|
192
|
+
path: change.path,
|
|
193
|
+
operation: 'deleted',
|
|
194
|
+
addedLines: 0,
|
|
195
|
+
deletedLines: logicalLineCount(original)
|
|
196
|
+
},
|
|
197
|
+
totalBytes
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
const { change } = resolvedChange;
|
|
201
|
+
const content = change.hunks.length
|
|
202
|
+
? applyHunks(original, change.hunks, change.path)
|
|
203
|
+
: original;
|
|
204
|
+
totalBytes = enforceContentLimits(content, totalBytes);
|
|
205
|
+
const addedLines = change.hunks.reduce((sum, hunk) => sum + hunk.addedLines, 0);
|
|
206
|
+
const deletedLines = change.hunks.reduce((sum, hunk) => sum + hunk.deletedLines, 0);
|
|
207
|
+
if (resolvedChange.kind === 'update' && !addedLines && !deletedLines)
|
|
208
|
+
return { mutations: [], totalBytes };
|
|
209
|
+
if (resolvedChange.kind === 'move') {
|
|
210
|
+
const moveChange = resolvedChange.change;
|
|
211
|
+
const targetStat = await optionalLstat(resolvedChange.target);
|
|
212
|
+
if (targetStat && !targetStat.isFile())
|
|
213
|
+
invalid('Patch targets must be regular files.');
|
|
214
|
+
return {
|
|
215
|
+
mutations: [
|
|
216
|
+
{ path: change.path, target: resolvedChange.source, expectedExisting: true, original },
|
|
217
|
+
{
|
|
218
|
+
path: moveChange.targetPath,
|
|
219
|
+
target: resolvedChange.target,
|
|
220
|
+
content,
|
|
221
|
+
mode: (targetStat ?? sourceStat).mode & 0o7777,
|
|
222
|
+
expectedExisting: targetStat !== undefined,
|
|
223
|
+
...(targetStat ? { original: await readBoundedFile(resolvedChange.target) } : {})
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
result: {
|
|
227
|
+
path: change.path,
|
|
228
|
+
targetPath: moveChange.targetPath,
|
|
229
|
+
operation: 'moved',
|
|
230
|
+
addedLines,
|
|
231
|
+
deletedLines
|
|
232
|
+
},
|
|
233
|
+
totalBytes
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
mutations: [
|
|
238
|
+
{
|
|
239
|
+
path: change.path,
|
|
240
|
+
target: resolvedChange.source,
|
|
241
|
+
content,
|
|
242
|
+
mode: sourceStat.mode & 0o7777,
|
|
243
|
+
expectedExisting: true,
|
|
244
|
+
original
|
|
245
|
+
}
|
|
246
|
+
],
|
|
247
|
+
result: {
|
|
248
|
+
path: change.path,
|
|
249
|
+
operation: 'modified',
|
|
250
|
+
addedLines,
|
|
251
|
+
deletedLines
|
|
252
|
+
},
|
|
253
|
+
totalBytes
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
async #commit(mutations) {
|
|
257
|
+
const staged = [];
|
|
258
|
+
const backups = [];
|
|
259
|
+
const installed = [];
|
|
260
|
+
const createdDirectories = [];
|
|
261
|
+
try {
|
|
262
|
+
for (const mutation of mutations) {
|
|
263
|
+
if (!mutation.content)
|
|
264
|
+
continue;
|
|
265
|
+
await ensureDirectory(dirname(mutation.target), createdDirectories);
|
|
266
|
+
const temporary = `${mutation.target}.mar-patch-${randomUUID()}.tmp`;
|
|
267
|
+
await writeFile(temporary, mutation.content, { flag: 'wx' });
|
|
268
|
+
if (mutation.mode !== undefined)
|
|
269
|
+
await chmod(temporary, mutation.mode);
|
|
270
|
+
staged.push({ ...mutation, temporary });
|
|
271
|
+
}
|
|
272
|
+
for (const mutation of mutations)
|
|
273
|
+
if ((await exists(mutation.target)) !== mutation.expectedExisting)
|
|
274
|
+
throw new AgentError('MAR_AGENT_PATCH_CONFLICT', 'A patch target changed after preflight.');
|
|
275
|
+
for (const mutation of mutations) {
|
|
276
|
+
if (!(await exists(mutation.target)))
|
|
277
|
+
continue;
|
|
278
|
+
const backup = `${mutation.target}.mar-patch-${randomUUID()}.bak`;
|
|
279
|
+
await this.#fileOperations.rename(mutation.target, backup);
|
|
280
|
+
backups.push({ target: mutation.target, backup });
|
|
281
|
+
if (mutation.original && !(await readBoundedFile(backup)).equals(mutation.original))
|
|
282
|
+
throw new AgentError('MAR_AGENT_PATCH_CONFLICT', 'A patch target changed after preflight.');
|
|
283
|
+
}
|
|
284
|
+
for (const item of staged) {
|
|
285
|
+
await this.#fileOperations.rename(item.temporary, item.target);
|
|
286
|
+
installed.push(item.target);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
let rollbackError;
|
|
291
|
+
for (const target of installed.reverse())
|
|
292
|
+
await this.#fileOperations
|
|
293
|
+
.rm(target, { force: true })
|
|
294
|
+
.catch((cause) => (rollbackError ??= cause));
|
|
295
|
+
for (const item of backups.reverse())
|
|
296
|
+
await this.#fileOperations
|
|
297
|
+
.rename(item.backup, item.target)
|
|
298
|
+
.catch((cause) => (rollbackError ??= cause));
|
|
299
|
+
await Promise.allSettled(staged.map((item) => this.#fileOperations.rm(item.temporary, { force: true })));
|
|
300
|
+
for (const directory of createdDirectories.reverse())
|
|
301
|
+
await rmdir(directory).catch(() => undefined);
|
|
302
|
+
if (rollbackError)
|
|
303
|
+
throw new AgentError('MAR_AGENT_PATCH_ROLLBACK_FAILED', 'Patch commit failed and rollback could not restore every file.', { cause: rollbackError });
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
306
|
+
await Promise.all(backups.map((item) => this.#fileOperations.rm(item.backup, { force: true })));
|
|
307
|
+
for (const mutation of mutations)
|
|
308
|
+
await captureFileChange(mutation.path, mutation.original, mutation.content);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
function applyHunks(original, hunks, path) {
|
|
312
|
+
let text;
|
|
313
|
+
try {
|
|
314
|
+
text = utf8Decoder.decode(original);
|
|
315
|
+
}
|
|
316
|
+
catch (cause) {
|
|
317
|
+
throw new AgentError('MAR_AGENT_PATCH_CONFLICT', 'Patched files must be valid UTF-8.', {
|
|
318
|
+
cause
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
const newline = text.includes('\r\n') ? '\r\n' : '\n';
|
|
322
|
+
if (text.replaceAll('\r\n', '').includes('\r'))
|
|
323
|
+
invalid('Patched files contain mixed carriage returns.');
|
|
324
|
+
const normalized = text.replaceAll('\r\n', '\n');
|
|
325
|
+
const finalNewline = normalized.endsWith('\n');
|
|
326
|
+
let lines = (finalNewline ? normalized.slice(0, -1) : normalized).split('\n');
|
|
327
|
+
if (lines.length === 1 && lines[0] === '')
|
|
328
|
+
lines = [];
|
|
329
|
+
let searchStart = 0;
|
|
330
|
+
for (const [hunkIndex, hunk] of hunks.entries()) {
|
|
331
|
+
if (hunk.changeContext !== undefined) {
|
|
332
|
+
const contextPosition = seekSequence(lines, [hunk.changeContext], searchStart);
|
|
333
|
+
if (contextPosition === undefined)
|
|
334
|
+
throw new AgentError('MAR_AGENT_PATCH_CONFLICT', `Patch hunk ${hunkIndex + 1} could not find change context in ${path}:\n${summarizePatchLines([hunk.changeContext])}`);
|
|
335
|
+
searchStart = contextPosition + 1;
|
|
336
|
+
}
|
|
337
|
+
const position = seekSequence(lines, hunk.oldLines, searchStart);
|
|
338
|
+
if (position === undefined)
|
|
339
|
+
throw new AgentError('MAR_AGENT_PATCH_CONFLICT', `Patch hunk ${hunkIndex + 1} could not find expected lines in ${path}:\n${summarizePatchLines(hunk.oldLines)}`);
|
|
340
|
+
if (hunk.anchor) {
|
|
341
|
+
searchStart = position + hunk.oldLines.length;
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
const replacement = materializeHunk(lines, position, hunk.patchLines);
|
|
345
|
+
lines.splice(position, hunk.oldLines.length, ...replacement);
|
|
346
|
+
searchStart = position + replacement.length;
|
|
347
|
+
}
|
|
348
|
+
return Buffer.from(`${lines.join(newline)}${finalNewline ? newline : ''}`);
|
|
349
|
+
}
|
|
350
|
+
function materializeHunk(source, position, patchLines) {
|
|
351
|
+
const replacement = [];
|
|
352
|
+
let sourceOffset = 0;
|
|
353
|
+
for (const line of patchLines) {
|
|
354
|
+
if (line.kind === 'addition') {
|
|
355
|
+
replacement.push(line.value);
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
if (line.kind === 'context')
|
|
359
|
+
replacement.push(source[position + sourceOffset]);
|
|
360
|
+
sourceOffset++;
|
|
361
|
+
}
|
|
362
|
+
return replacement;
|
|
363
|
+
}
|
|
364
|
+
function seekSequence(lines, pattern, start) {
|
|
365
|
+
if (!pattern.length)
|
|
366
|
+
return start;
|
|
367
|
+
if (pattern.length > lines.length)
|
|
368
|
+
return undefined;
|
|
369
|
+
const comparators = [
|
|
370
|
+
(actual, expected) => actual === expected,
|
|
371
|
+
(actual, expected) => actual.trimEnd() === expected.trimEnd(),
|
|
372
|
+
(actual, expected) => actual.trim() === expected.trim(),
|
|
373
|
+
(actual, expected) => normalizePatchContext(actual) === normalizePatchContext(expected)
|
|
374
|
+
];
|
|
375
|
+
for (const matches of comparators)
|
|
376
|
+
for (let position = start; position <= lines.length - pattern.length; position++)
|
|
377
|
+
if (pattern.every((line, offset) => matches(lines[position + offset], line)))
|
|
378
|
+
return position;
|
|
379
|
+
return undefined;
|
|
380
|
+
}
|
|
381
|
+
function normalizePatchContext(value) {
|
|
382
|
+
return [...value.trim()]
|
|
383
|
+
.map((character) => {
|
|
384
|
+
if ('‐‑‒–—―−'.includes(character))
|
|
385
|
+
return '-';
|
|
386
|
+
if ('‘’‚‛'.includes(character))
|
|
387
|
+
return "'";
|
|
388
|
+
if ('“”„‟'.includes(character))
|
|
389
|
+
return '"';
|
|
390
|
+
if (' '.includes(character))
|
|
391
|
+
return ' ';
|
|
392
|
+
return character;
|
|
393
|
+
})
|
|
394
|
+
.join('');
|
|
395
|
+
}
|
|
396
|
+
function summarizePatchLines(lines) {
|
|
397
|
+
const value = lines.join('\n');
|
|
398
|
+
return value.length <= 1_000 ? value : `${[...value].slice(0, 1_000).join('')}…`;
|
|
399
|
+
}
|
|
400
|
+
function logicalLineCount(content) {
|
|
401
|
+
if (!content.length)
|
|
402
|
+
return 0;
|
|
403
|
+
const text = content.toString('utf8').replaceAll('\r\n', '\n');
|
|
404
|
+
return text.endsWith('\n') ? text.slice(0, -1).split('\n').length : text.split('\n').length;
|
|
405
|
+
}
|
|
406
|
+
async function readBoundedFile(path) {
|
|
407
|
+
const info = await lstat(path);
|
|
408
|
+
if (info.size > TOOL_EXECUTION_LIMITS.patchMaxFileBytes)
|
|
409
|
+
throw new AgentError('MAR_AGENT_TOOL_OUTPUT_LIMIT', 'Patched file exceeds the byte limit.');
|
|
410
|
+
return readFile(path);
|
|
411
|
+
}
|
|
412
|
+
function enforceContentLimits(content, current) {
|
|
413
|
+
if (content.byteLength > TOOL_EXECUTION_LIMITS.patchMaxFileBytes)
|
|
414
|
+
throw new AgentError('MAR_AGENT_TOOL_OUTPUT_LIMIT', 'Patched file exceeds the byte limit.');
|
|
415
|
+
const total = current + content.byteLength;
|
|
416
|
+
if (total > TOOL_EXECUTION_LIMITS.patchMaxTotalBytes)
|
|
417
|
+
throw new AgentError('MAR_AGENT_TOOL_OUTPUT_LIMIT', 'Patch working set exceeds the byte limit.');
|
|
418
|
+
return total;
|
|
419
|
+
}
|
|
420
|
+
function partialPatchError(cause, appliedResults, pendingChanges) {
|
|
421
|
+
const appliedFiles = appliedResults.map(resultPath);
|
|
422
|
+
const failedFile = changePath(pendingChanges[0].change);
|
|
423
|
+
const pendingFiles = pendingChanges.slice(1).map(({ change }) => changePath(change));
|
|
424
|
+
return new AgentError('MAR_AGENT_PATCH_PARTIAL', `Patch partially applied. Applied: ${summarizePaths(appliedFiles)}. Failed: ${failedFile}. Pending: ${summarizePaths(pendingFiles)}. Retry only failed and pending paths.`, {
|
|
425
|
+
cause,
|
|
426
|
+
retryable: true,
|
|
427
|
+
details: {
|
|
428
|
+
appliedFiles,
|
|
429
|
+
failedFile,
|
|
430
|
+
pendingFiles,
|
|
431
|
+
files: appliedResults,
|
|
432
|
+
totals: {
|
|
433
|
+
files: appliedResults.length,
|
|
434
|
+
addedLines: appliedResults.reduce((total, file) => total + file.addedLines, 0),
|
|
435
|
+
deletedLines: appliedResults.reduce((total, file) => total + file.deletedLines, 0)
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
function resultPath(result) {
|
|
441
|
+
return result.targetPath === undefined ? result.path : `${result.path} -> ${result.targetPath}`;
|
|
442
|
+
}
|
|
443
|
+
function changePath(change) {
|
|
444
|
+
return change.kind === 'update' && change.targetPath !== undefined
|
|
445
|
+
? `${change.path} -> ${change.targetPath}`
|
|
446
|
+
: change.path;
|
|
447
|
+
}
|
|
448
|
+
function summarizePaths(paths) {
|
|
449
|
+
if (!paths.length)
|
|
450
|
+
return '(none)';
|
|
451
|
+
const visible = paths.slice(0, 12);
|
|
452
|
+
const suffix = paths.length > visible.length ? `, … (${paths.length} total)` : '';
|
|
453
|
+
return `${visible.join(', ')}${suffix}`;
|
|
454
|
+
}
|
|
455
|
+
async function optionalLstat(path) {
|
|
456
|
+
try {
|
|
457
|
+
return await lstat(path);
|
|
458
|
+
}
|
|
459
|
+
catch (error) {
|
|
460
|
+
if (error.code === 'ENOENT')
|
|
461
|
+
return undefined;
|
|
462
|
+
throw error;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
async function ensureDirectory(path, created) {
|
|
466
|
+
const missing = [];
|
|
467
|
+
let current = path;
|
|
468
|
+
const root = parse(path).root;
|
|
469
|
+
while (current !== root && !(await exists(current))) {
|
|
470
|
+
missing.push(current);
|
|
471
|
+
current = dirname(current);
|
|
472
|
+
}
|
|
473
|
+
await mkdir(path, { recursive: true });
|
|
474
|
+
created.push(...missing.reverse());
|
|
475
|
+
}
|
|
476
|
+
async function exists(path) {
|
|
477
|
+
try {
|
|
478
|
+
await lstat(path);
|
|
479
|
+
return true;
|
|
480
|
+
}
|
|
481
|
+
catch (error) {
|
|
482
|
+
if (error.code === 'ENOENT')
|
|
483
|
+
return false;
|
|
484
|
+
throw error;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
function invalid(message) {
|
|
488
|
+
throw new AgentError('MAR_AGENT_TOOL_INPUT_INVALID', message);
|
|
489
|
+
}
|