@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,181 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { open, readdir, rename, rm } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { AgentError } from '../../../error.js';
|
|
5
|
+
import { parseInlineMediaState } from '../../inline-media.js';
|
|
6
|
+
import { MAX_SEGMENT_BYTES } from './records.js';
|
|
7
|
+
export async function renameIfExists(from, to) {
|
|
8
|
+
try {
|
|
9
|
+
await rename(from, to);
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
if (error.code === 'ENOENT')
|
|
14
|
+
return false;
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function stageSessionSegments(sessionDirectory, records, operation = 'rollback') {
|
|
19
|
+
let group;
|
|
20
|
+
if (records.length === 0)
|
|
21
|
+
throw new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Session history is corrupt.');
|
|
22
|
+
const transactionId = randomUUID();
|
|
23
|
+
const files = [];
|
|
24
|
+
const segments = [];
|
|
25
|
+
const flush = async () => {
|
|
26
|
+
if (group === undefined)
|
|
27
|
+
return;
|
|
28
|
+
const number = segments.length + 1;
|
|
29
|
+
const path = join(sessionDirectory, `events-${String(number).padStart(6, '0')}.jsonl`);
|
|
30
|
+
const temporaryPath = `${path}.${transactionId}.${operation}-tmp`;
|
|
31
|
+
const handle = await open(temporaryPath, 'wx', 0o600);
|
|
32
|
+
files.push({ path, temporaryPath });
|
|
33
|
+
try {
|
|
34
|
+
await handle.writeFile(group.lines.join(''));
|
|
35
|
+
await handle.sync();
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
await handle.close();
|
|
39
|
+
}
|
|
40
|
+
segments.push({
|
|
41
|
+
number,
|
|
42
|
+
firstSequence: group.firstSequence,
|
|
43
|
+
lastSequence: group.lastSequence,
|
|
44
|
+
bytes: group.bytes
|
|
45
|
+
});
|
|
46
|
+
group = undefined;
|
|
47
|
+
};
|
|
48
|
+
try {
|
|
49
|
+
for (const record of records) {
|
|
50
|
+
const line = `${JSON.stringify(record)}\n`;
|
|
51
|
+
const bytes = Buffer.byteLength(line);
|
|
52
|
+
if (group !== undefined && group.bytes > 0 && group.bytes + bytes > MAX_SEGMENT_BYTES)
|
|
53
|
+
await flush();
|
|
54
|
+
if (group === undefined) {
|
|
55
|
+
group = {
|
|
56
|
+
lines: [],
|
|
57
|
+
bytes: 0,
|
|
58
|
+
firstSequence: record.sequence,
|
|
59
|
+
lastSequence: record.sequence
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
group.lines.push(line);
|
|
63
|
+
group.bytes += bytes;
|
|
64
|
+
group.lastSequence = record.sequence;
|
|
65
|
+
}
|
|
66
|
+
await flush();
|
|
67
|
+
return { files, segments };
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
await Promise.all(files.map((item) => rm(item.temporaryPath, { force: true }))).catch(() => undefined);
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export async function stageUnreferencedImages(sessionDirectory, directoryName, retained, transactionId) {
|
|
75
|
+
const directory = join(sessionDirectory, directoryName);
|
|
76
|
+
let names;
|
|
77
|
+
try {
|
|
78
|
+
names = await readdir(directory);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (error.code === 'ENOENT')
|
|
82
|
+
return [];
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
const moved = [];
|
|
86
|
+
try {
|
|
87
|
+
for (const name of names) {
|
|
88
|
+
if (retained.has(name))
|
|
89
|
+
continue;
|
|
90
|
+
const from = join(directory, name);
|
|
91
|
+
const trash = join(directory, `.${name}.${transactionId}.rollback-trash`);
|
|
92
|
+
await rename(from, trash);
|
|
93
|
+
moved.push({ from: trash, to: from, trash });
|
|
94
|
+
}
|
|
95
|
+
return moved;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
await restoreRenamedFiles(moved);
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export async function restoreRenamedFiles(files) {
|
|
103
|
+
for (const file of files.toReversed())
|
|
104
|
+
await rename(file.from, file.to).catch(() => undefined);
|
|
105
|
+
}
|
|
106
|
+
export function retainedSessionTitle(records, fallback) {
|
|
107
|
+
let title = fallback;
|
|
108
|
+
for (const record of records) {
|
|
109
|
+
if ((record.type === 'session.created' || record.type === 'session.title.updated') &&
|
|
110
|
+
isObject(record.payload) &&
|
|
111
|
+
typeof record.payload.title === 'string' &&
|
|
112
|
+
record.payload.title.trim().length > 0)
|
|
113
|
+
title = record.payload.title;
|
|
114
|
+
}
|
|
115
|
+
return title;
|
|
116
|
+
}
|
|
117
|
+
export function forkedPayload(type, value, sourceSessionId, targetSessionId, title, identities) {
|
|
118
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
119
|
+
return value;
|
|
120
|
+
const payload = { ...value };
|
|
121
|
+
const remapWindow = (value) => {
|
|
122
|
+
const state = parseInlineMediaState(value);
|
|
123
|
+
if (!state)
|
|
124
|
+
return value;
|
|
125
|
+
for (const cursor of [state.consideredThrough, state.evictedThrough]) {
|
|
126
|
+
if (!cursor?.sourceId.startsWith('input:'))
|
|
127
|
+
continue;
|
|
128
|
+
const target = identities.get(cursor.sourceId.slice(6));
|
|
129
|
+
if (!target)
|
|
130
|
+
throw new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Fork media reference is missing.');
|
|
131
|
+
cursor.sourceId = `input:${target.recordId}`;
|
|
132
|
+
}
|
|
133
|
+
return state;
|
|
134
|
+
};
|
|
135
|
+
if (type === 'resource.window')
|
|
136
|
+
return remapWindow(payload);
|
|
137
|
+
if (payload.sessionId === sourceSessionId)
|
|
138
|
+
payload.sessionId = targetSessionId;
|
|
139
|
+
const application = (input) => {
|
|
140
|
+
if (typeof input.inputRef !== 'string') {
|
|
141
|
+
const recordId = isObject(input.metadata) ? input.metadata.recordId : undefined;
|
|
142
|
+
const identity = typeof recordId === 'string' ? identities.get(recordId) : undefined;
|
|
143
|
+
return identity && isObject(input.metadata)
|
|
144
|
+
? { ...input, metadata: { ...input.metadata, recordId: identity.recordId } }
|
|
145
|
+
: input;
|
|
146
|
+
}
|
|
147
|
+
const identity = identities.get(input.inputRef);
|
|
148
|
+
if (!identity)
|
|
149
|
+
throw new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Fork input reference is missing.');
|
|
150
|
+
return {
|
|
151
|
+
...input,
|
|
152
|
+
inputRef: identity.recordId,
|
|
153
|
+
...(isObject(input.metadata)
|
|
154
|
+
? { metadata: { ...input.metadata, recordId: identity.recordId } }
|
|
155
|
+
: {})
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
if (type === 'model.context')
|
|
159
|
+
return application(payload);
|
|
160
|
+
if (type === 'compact.completed') {
|
|
161
|
+
if (payload.inlineMediaState)
|
|
162
|
+
payload.inlineMediaState = remapWindow(payload.inlineMediaState);
|
|
163
|
+
if (Array.isArray(payload.retainedModelContext))
|
|
164
|
+
payload.retainedModelContext = payload.retainedModelContext.map((item) => isObject(item) ? application(item) : item);
|
|
165
|
+
if (Array.isArray(payload.pendingInputs))
|
|
166
|
+
payload.pendingInputs = payload.pendingInputs.map((record) => {
|
|
167
|
+
const identity = identities.get(record.recordId);
|
|
168
|
+
if (!identity)
|
|
169
|
+
throw new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Fork pending input reference is missing.');
|
|
170
|
+
return { ...record, ...identity, sessionId: targetSessionId };
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
if (type === 'session.title.updated') {
|
|
174
|
+
payload.title = title;
|
|
175
|
+
payload.automatic = false;
|
|
176
|
+
}
|
|
177
|
+
return payload;
|
|
178
|
+
}
|
|
179
|
+
function isObject(value) {
|
|
180
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
181
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SessionRecord } from '../types.js';
|
|
2
|
+
export declare const MAX_INPUT_IMAGES = 5;
|
|
3
|
+
export declare function generatedImageFileNames(records: readonly SessionRecord[]): readonly string[];
|
|
4
|
+
export declare function copyGeneratedImages(sourceSessionDirectory: string, targetSessionDirectory: string, fileNames: readonly string[]): Promise<void>;
|
|
5
|
+
interface InputImageReference {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly fileName: string;
|
|
8
|
+
readonly mimeType: string;
|
|
9
|
+
readonly byteSize: number;
|
|
10
|
+
readonly sha256: string;
|
|
11
|
+
readonly resourceId?: string;
|
|
12
|
+
readonly url?: string;
|
|
13
|
+
readonly urlExpiresAt?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function inputImageReferences(value: unknown): InputImageReference[];
|
|
16
|
+
export declare function inputImageReference(value: unknown): InputImageReference | undefined;
|
|
17
|
+
export declare function validInputImageFileName(fileName: string): boolean;
|
|
18
|
+
export declare function readInputImageBytes(directory: string, reference: InputImageReference): Promise<Buffer>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { copyFile, mkdir, open, readFile } from 'node:fs/promises';
|
|
2
|
+
import { basename, join } from 'node:path';
|
|
3
|
+
import { AgentError } from '../../../error.js';
|
|
4
|
+
import { isModelImageUrl } from '../../../model/image.js';
|
|
5
|
+
export const MAX_INPUT_IMAGES = 5;
|
|
6
|
+
const MAX_INPUT_IMAGE_BYTES = 5 * 1024 * 1024;
|
|
7
|
+
const MAX_INPUT_IMAGES_BYTES = 10 * 1024 * 1024;
|
|
8
|
+
const INPUT_IMAGE_MIME_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp']);
|
|
9
|
+
export function generatedImageFileNames(records) {
|
|
10
|
+
const names = new Set();
|
|
11
|
+
for (const record of records) {
|
|
12
|
+
if (record.type !== 'tool.completed' || !isObject(record.payload))
|
|
13
|
+
continue;
|
|
14
|
+
const artifacts = record.payload.artifacts;
|
|
15
|
+
if (!Array.isArray(artifacts))
|
|
16
|
+
continue;
|
|
17
|
+
for (const artifact of artifacts) {
|
|
18
|
+
if (!isObject(artifact) ||
|
|
19
|
+
artifact.kind !== 'image' ||
|
|
20
|
+
typeof artifact.fileName !== 'string' ||
|
|
21
|
+
basename(artifact.fileName) !== artifact.fileName ||
|
|
22
|
+
!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}\.png$/u.test(artifact.fileName))
|
|
23
|
+
continue;
|
|
24
|
+
names.add(artifact.fileName);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return [...names];
|
|
28
|
+
}
|
|
29
|
+
export async function copyGeneratedImages(sourceSessionDirectory, targetSessionDirectory, fileNames) {
|
|
30
|
+
if (fileNames.length === 0)
|
|
31
|
+
return;
|
|
32
|
+
const source = join(sourceSessionDirectory, 'generated_images');
|
|
33
|
+
const target = join(targetSessionDirectory, 'generated_images');
|
|
34
|
+
await mkdir(target, { recursive: true });
|
|
35
|
+
for (const fileName of fileNames) {
|
|
36
|
+
const path = join(target, fileName);
|
|
37
|
+
await copyFile(join(source, fileName), path);
|
|
38
|
+
const handle = await open(path, 'r');
|
|
39
|
+
try {
|
|
40
|
+
await handle.sync();
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
await handle.close();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function inputImageReferences(value) {
|
|
48
|
+
if (!Array.isArray(value))
|
|
49
|
+
return [];
|
|
50
|
+
const references = [];
|
|
51
|
+
let totalBytes = 0;
|
|
52
|
+
for (const image of value) {
|
|
53
|
+
const reference = inputImageReference(image);
|
|
54
|
+
if (reference === undefined)
|
|
55
|
+
continue;
|
|
56
|
+
totalBytes += reference.byteSize;
|
|
57
|
+
if (references.length >= MAX_INPUT_IMAGES || totalBytes > MAX_INPUT_IMAGES_BYTES)
|
|
58
|
+
throw corruptInputImageReference();
|
|
59
|
+
references.push(reference);
|
|
60
|
+
}
|
|
61
|
+
return references;
|
|
62
|
+
}
|
|
63
|
+
export function inputImageReference(value) {
|
|
64
|
+
if (!isObject(value) ||
|
|
65
|
+
(!Object.hasOwn(value, 'fileName') && !Object.hasOwn(value, 'resourceId')))
|
|
66
|
+
return undefined;
|
|
67
|
+
const fileName = value.fileName ??
|
|
68
|
+
(typeof value.resourceId === 'string' ? `${value.resourceId}.bin` : undefined);
|
|
69
|
+
if (typeof value.name !== 'string' ||
|
|
70
|
+
typeof value.mimeType !== 'string' ||
|
|
71
|
+
!INPUT_IMAGE_MIME_TYPES.has(value.mimeType) ||
|
|
72
|
+
typeof value.byteSize !== 'number' ||
|
|
73
|
+
!Number.isSafeInteger(value.byteSize) ||
|
|
74
|
+
value.byteSize <= 0 ||
|
|
75
|
+
value.byteSize > MAX_INPUT_IMAGE_BYTES ||
|
|
76
|
+
typeof fileName !== 'string' ||
|
|
77
|
+
!validInputImageFileName(fileName) ||
|
|
78
|
+
typeof value.sha256 !== 'string' ||
|
|
79
|
+
!/^[a-f0-9]{64}$/u.test(value.sha256) ||
|
|
80
|
+
(value.resourceId !== undefined &&
|
|
81
|
+
(typeof value.resourceId !== 'string' ||
|
|
82
|
+
!/^[a-f0-9]{64}$/u.test(value.resourceId) ||
|
|
83
|
+
fileName !== `${value.resourceId}.bin`)) ||
|
|
84
|
+
(value.url !== undefined && !isModelImageUrl(value.url)) ||
|
|
85
|
+
(value.urlExpiresAt !== undefined &&
|
|
86
|
+
(typeof value.urlExpiresAt !== 'number' ||
|
|
87
|
+
!Number.isSafeInteger(value.urlExpiresAt) ||
|
|
88
|
+
value.urlExpiresAt <= 0)) ||
|
|
89
|
+
(value.urlExpiresAt !== undefined && value.url === undefined))
|
|
90
|
+
throw corruptInputImageReference();
|
|
91
|
+
return {
|
|
92
|
+
name: value.name,
|
|
93
|
+
fileName,
|
|
94
|
+
mimeType: value.mimeType,
|
|
95
|
+
byteSize: value.byteSize,
|
|
96
|
+
sha256: value.sha256,
|
|
97
|
+
...(typeof value.resourceId === 'string' ? { resourceId: value.resourceId } : {}),
|
|
98
|
+
...(value.url === undefined ? {} : { url: value.url }),
|
|
99
|
+
...(typeof value.urlExpiresAt === 'number' ? { urlExpiresAt: value.urlExpiresAt } : {})
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export function validInputImageFileName(fileName) {
|
|
103
|
+
return (basename(fileName) === fileName && /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}\.bin$/u.test(fileName));
|
|
104
|
+
}
|
|
105
|
+
export async function readInputImageBytes(directory, reference) {
|
|
106
|
+
try {
|
|
107
|
+
return await readFile(join(directory, reference.fileName));
|
|
108
|
+
}
|
|
109
|
+
catch (cause) {
|
|
110
|
+
throw new AgentError('MAR_AGENT_IMAGE_UNAVAILABLE', 'Session input image is unavailable.', {
|
|
111
|
+
cause
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function corruptInputImageReference(cause) {
|
|
116
|
+
return new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Session input image is corrupt.', {
|
|
117
|
+
...(cause === undefined ? {} : { cause })
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function isObject(value) {
|
|
121
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
122
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AgentError } from '../../../error.js';
|
|
2
|
+
import type { SessionIndex, SessionMeta } from '../types.js';
|
|
3
|
+
export declare class ParentPublicationRejected extends AgentError {
|
|
4
|
+
}
|
|
5
|
+
/** Runs the short disk index transaction; the caller owns its cache. */
|
|
6
|
+
export declare function commitSessionIndex(root: string, snapshot: () => {
|
|
7
|
+
index: SessionIndex;
|
|
8
|
+
dirty: ReadonlyMap<string, number>;
|
|
9
|
+
derivedOnly: ReadonlySet<string>;
|
|
10
|
+
}, committed: (index: SessionIndex, dirty: ReadonlyMap<string, number>, created: ReadonlySet<string>) => void, deletedIds?: string | readonly string[], createdIds?: readonly string[], onPersisted?: () => void, storageSelection?: {
|
|
11
|
+
readonly before: SessionMeta;
|
|
12
|
+
readonly generation: string;
|
|
13
|
+
}, deleteExpected?: readonly SessionMeta[]): Promise<void>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { lstat } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
4
|
+
import { AgentError } from '../../../error.js';
|
|
5
|
+
import { acquireFileLock } from '../../../storage/file-lock.js';
|
|
6
|
+
import { normalizeSessionSource, persistFormatSelection, prepareSessionIndexCommit, readSessionIndex } from './directory-index.js';
|
|
7
|
+
import { treeDeleteMarker } from './transaction-recovery.js';
|
|
8
|
+
export class ParentPublicationRejected extends AgentError {
|
|
9
|
+
}
|
|
10
|
+
/** Runs the short disk index transaction; the caller owns its cache. */
|
|
11
|
+
export async function commitSessionIndex(root, snapshot, committed, deletedIds, createdIds = [], onPersisted, storageSelection, deleteExpected) {
|
|
12
|
+
const release = await acquireFileLock(join(root, 'sessions', 'index.lock'));
|
|
13
|
+
const path = join(root, 'sessions', 'index.json');
|
|
14
|
+
let failure;
|
|
15
|
+
try {
|
|
16
|
+
const disk = await readSessionIndex(path);
|
|
17
|
+
if (!disk)
|
|
18
|
+
throw new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Session index is missing.');
|
|
19
|
+
for (const id of createdIds) {
|
|
20
|
+
const created = snapshot().index.sessions.find((entry) => entry.id === id);
|
|
21
|
+
if (!created)
|
|
22
|
+
throw new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Session publication is missing.');
|
|
23
|
+
const source = normalizeSessionSource(created.source);
|
|
24
|
+
if (source.type !== 'subagent')
|
|
25
|
+
continue;
|
|
26
|
+
if (!disk.sessions.some((entry) => entry.id === source.parentSessionId))
|
|
27
|
+
throw new ParentPublicationRejected('MAR_AGENT_SESSION_NOT_FOUND', 'Parent Session was not found.');
|
|
28
|
+
try {
|
|
29
|
+
await lstat(treeDeleteMarker(join(root, 'sessions'), source.parentSessionId));
|
|
30
|
+
throw new ParentPublicationRejected('MAR_AGENT_SESSION_LOCKED', 'Parent Session is under maintenance.');
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (error.code !== 'ENOENT')
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (deleteExpected) {
|
|
38
|
+
const ids = new Set(deleteExpected.map((entry) => entry.id));
|
|
39
|
+
for (const expected of deleteExpected) {
|
|
40
|
+
const current = disk.sessions.find((entry) => entry.id === expected.id);
|
|
41
|
+
if (!current ||
|
|
42
|
+
current.createdAt !== expected.createdAt ||
|
|
43
|
+
current.workspace !== expected.workspace ||
|
|
44
|
+
!isDeepStrictEqual(current.source, expected.source) ||
|
|
45
|
+
!isDeepStrictEqual(current.storage, expected.storage) ||
|
|
46
|
+
current.storageTransactionId !== expected.storageTransactionId ||
|
|
47
|
+
current.nextSequence !== expected.nextSequence)
|
|
48
|
+
throw new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Session tree changed during deletion.');
|
|
49
|
+
}
|
|
50
|
+
for (const entry of disk.sessions) {
|
|
51
|
+
const source = normalizeSessionSource(entry.source);
|
|
52
|
+
if (source.type === 'subagent' && ids.has(source.parentSessionId) && !ids.has(entry.id))
|
|
53
|
+
throw new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Session tree changed during deletion.');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const local = snapshot();
|
|
57
|
+
const dirty = local.dirty;
|
|
58
|
+
const derivedOnly = local.derivedOnly;
|
|
59
|
+
const created = new Set(createdIds);
|
|
60
|
+
const updated = prepareSessionIndexCommit(disk, local.index, dirty, derivedOnly, deletedIds, createdIds);
|
|
61
|
+
if (storageSelection) {
|
|
62
|
+
const before = storageSelection.before;
|
|
63
|
+
const selected = disk.sessions.find((item) => item.id === before.id);
|
|
64
|
+
const replacement = updated.sessions.find((item) => item.id === before.id);
|
|
65
|
+
if (!selected ||
|
|
66
|
+
!replacement ||
|
|
67
|
+
!isDeepStrictEqual(selected.storage, before.storage) ||
|
|
68
|
+
selected.nextSequence !== before.nextSequence ||
|
|
69
|
+
selected.storageTransactionId !== before.storageTransactionId)
|
|
70
|
+
throw new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Session history changed during replacement.');
|
|
71
|
+
replacement.storage = { encoding: 2, generation: storageSelection.generation };
|
|
72
|
+
}
|
|
73
|
+
await persistFormatSelection(path, updated);
|
|
74
|
+
onPersisted?.();
|
|
75
|
+
committed(updated, dirty, created);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
failure = error;
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
if (failure !== undefined)
|
|
83
|
+
await release().catch(() => undefined);
|
|
84
|
+
else
|
|
85
|
+
await release();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Read-only version admission before any v1 recovery can modify its evidence. */
|
|
2
|
+
export declare function preflightV1Session(directory: string): Promise<void>;
|
|
3
|
+
/** Inspect history only when an existing v2 recovery may replace or remove it. */
|
|
4
|
+
export declare function preflightV2Recovery(directory: string): Promise<void>;
|
|
5
|
+
/** Retired paths may be restored or deleted by the same journal, including other generations. */
|
|
6
|
+
export declare function preflightRetiredRecovery(root: string, journalDirectory: string): Promise<void>;
|
|
7
|
+
/** Check known versioned fields without treating ordinary corruption as a future format. */
|
|
8
|
+
export declare function admitV1RecordVersion(line: string): void;
|
|
9
|
+
export declare function admitWorldStateVersion(value: unknown): void;
|
|
10
|
+
export declare function admitResourceMetadataVersion(value: unknown): void;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { readFile, readdir } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { AgentError } from '../../../error.js';
|
|
4
|
+
import { retiredSessionTrashPath } from './transaction-recovery.js';
|
|
5
|
+
import { decodeJsonlValue } from './jsonl-codec.js';
|
|
6
|
+
const SEGMENT_OR_STAGE = /^events-\d{6}\.jsonl(?:\.[0-9a-f-]{36}\.(?:rollback-tmp|rollback-backup|clear-backup))?$/iu;
|
|
7
|
+
const WORLD_STATE = /^context-world-state\.json(?:\.\d+\.[0-9a-f-]+\.(?:rollback|clear)-backup)?$/iu;
|
|
8
|
+
const JOURNAL_TEMP = /^storage-transaction\.json\.[0-9a-f-]{36}\.tmp$/iu;
|
|
9
|
+
/** Read-only version admission before any v1 recovery can modify its evidence. */
|
|
10
|
+
export async function preflightV1Session(directory) {
|
|
11
|
+
await preflightSession(directory, 1, false);
|
|
12
|
+
}
|
|
13
|
+
/** Inspect history only when an existing v2 recovery may replace or remove it. */
|
|
14
|
+
export async function preflightV2Recovery(directory) {
|
|
15
|
+
await preflightSession(directory, 2, true);
|
|
16
|
+
}
|
|
17
|
+
/** Retired paths may be restored or deleted by the same journal, including other generations. */
|
|
18
|
+
export async function preflightRetiredRecovery(root, journalDirectory) {
|
|
19
|
+
let journal;
|
|
20
|
+
try {
|
|
21
|
+
journal = await readJsonIfComplete(join(journalDirectory, 'storage-transaction.json'));
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (error.code === 'ENOENT')
|
|
25
|
+
return;
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
if (!isObject(journal) || typeof journal.id !== 'string' || !/^[0-9a-f-]{36}$/iu.test(journal.id))
|
|
29
|
+
return;
|
|
30
|
+
if (typeof journal.targetGeneration === 'string' &&
|
|
31
|
+
/^[0-9a-f-]{36}$/iu.test(journal.targetGeneration))
|
|
32
|
+
await preflightSession(join(root, 'v2', journal.targetGeneration), 2, false);
|
|
33
|
+
if (!Array.isArray(journal.retiredPaths))
|
|
34
|
+
return;
|
|
35
|
+
for (const path of journal.retiredPaths) {
|
|
36
|
+
if (typeof path !== 'string' ||
|
|
37
|
+
!/^(?:events-\d{6}\.jsonl|resources|tool_results|context-world-state\.json|v2\/[0-9a-f-]{36})$/u.test(path))
|
|
38
|
+
continue;
|
|
39
|
+
for (const candidate of [join(root, path), retiredSessionTrashPath(root, path, journal.id)]) {
|
|
40
|
+
if (path.startsWith('v2/'))
|
|
41
|
+
await preflightSession(candidate, 2, false);
|
|
42
|
+
else if (path === 'resources')
|
|
43
|
+
await admitResourceDirectory(candidate);
|
|
44
|
+
else if (path === 'context-world-state.json') {
|
|
45
|
+
try {
|
|
46
|
+
admitWorldStateVersion(await readJsonIfComplete(candidate));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (error.code !== 'ENOENT')
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else if (path.startsWith('events-'))
|
|
54
|
+
await admitSegment(candidate, 1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function admitSegment(path, encoding) {
|
|
59
|
+
let content;
|
|
60
|
+
try {
|
|
61
|
+
content = await readFile(path, 'utf8');
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (error.code === 'ENOENT')
|
|
65
|
+
return;
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
for (const line of content.split('\n')) {
|
|
69
|
+
if (!line)
|
|
70
|
+
continue;
|
|
71
|
+
let value;
|
|
72
|
+
try {
|
|
73
|
+
value = JSON.parse(line);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
admitRecordVersion(value, encoding);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function preflightSession(directory, encoding, recoveryOnly) {
|
|
82
|
+
let names;
|
|
83
|
+
try {
|
|
84
|
+
names = await readdir(directory);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
if (error.code === 'ENOENT')
|
|
88
|
+
return;
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
const journalPresent = names.includes('storage-transaction.json');
|
|
92
|
+
for (const name of names) {
|
|
93
|
+
const path = join(directory, name);
|
|
94
|
+
if (SEGMENT_OR_STAGE.test(name)) {
|
|
95
|
+
if (recoveryOnly && !journalPresent && /^events-\d{6}\.jsonl$/iu.test(name))
|
|
96
|
+
continue;
|
|
97
|
+
await admitSegment(path, encoding);
|
|
98
|
+
}
|
|
99
|
+
else if (name === 'storage-transaction.json' ||
|
|
100
|
+
JOURNAL_TEMP.test(name) ||
|
|
101
|
+
WORLD_STATE.test(name)) {
|
|
102
|
+
if (recoveryOnly && !journalPresent && name === 'context-world-state.json')
|
|
103
|
+
continue;
|
|
104
|
+
const value = await readJsonIfComplete(path);
|
|
105
|
+
if (isObject(value)) {
|
|
106
|
+
if (name === 'storage-transaction.json' || JOURNAL_TEMP.test(name))
|
|
107
|
+
rejectFuture(value.version, 1);
|
|
108
|
+
else
|
|
109
|
+
admitWorldStateVersion(value);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (recoveryOnly && !journalPresent) {
|
|
114
|
+
await admitPendingResources(join(directory, 'resources'));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
await admitResourceDirectory(join(directory, 'resources'));
|
|
118
|
+
await admitPendingResources(join(directory, 'resources'));
|
|
119
|
+
}
|
|
120
|
+
async function admitPendingResources(directory) {
|
|
121
|
+
let names;
|
|
122
|
+
try {
|
|
123
|
+
names = await readdir(directory);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (error.code === 'ENOENT')
|
|
127
|
+
return;
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
const metadata = new Set();
|
|
131
|
+
for (const name of names) {
|
|
132
|
+
const pending = /^\.([a-f0-9]{64})\.pending$/u.exec(name);
|
|
133
|
+
if (pending)
|
|
134
|
+
metadata.add(`${pending[1]}.json`);
|
|
135
|
+
if (/^\.[a-f0-9]{64}\.json\.[a-f0-9-]{36}\.tmp$/u.test(name))
|
|
136
|
+
metadata.add(name);
|
|
137
|
+
}
|
|
138
|
+
for (const name of metadata) {
|
|
139
|
+
try {
|
|
140
|
+
admitResourceMetadataVersion(await readJsonIfComplete(join(directory, name)));
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
if (error.code !== 'ENOENT')
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async function admitResourceDirectory(resources) {
|
|
149
|
+
let resourceNames;
|
|
150
|
+
try {
|
|
151
|
+
resourceNames = await readdir(resources);
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
if (error.code === 'ENOENT')
|
|
155
|
+
return;
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
for (const name of resourceNames) {
|
|
159
|
+
if (!/^(?:[a-f0-9]{64}\.json|\.[a-f0-9]{64}\.json\.[0-9a-f-]{36}\.rollback-trash)$/iu.test(name))
|
|
160
|
+
continue;
|
|
161
|
+
const value = await readJsonIfComplete(join(resources, name));
|
|
162
|
+
admitResourceMetadataVersion(value);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/** Check known versioned fields without treating ordinary corruption as a future format. */
|
|
166
|
+
export function admitV1RecordVersion(line) {
|
|
167
|
+
const value = JSON.parse(line);
|
|
168
|
+
admitRecordVersion(value, 1);
|
|
169
|
+
}
|
|
170
|
+
function admitRecordVersion(value, encoding) {
|
|
171
|
+
try {
|
|
172
|
+
decodeJsonlValue(value, encoding);
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
if (error instanceof AgentError && error.code === 'MAR_AGENT_SESSION_VERSION_UNSUPPORTED')
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async function readJsonIfComplete(path) {
|
|
180
|
+
const content = await readFile(path, 'utf8');
|
|
181
|
+
try {
|
|
182
|
+
return JSON.parse(content);
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function rejectFuture(version, supported) {
|
|
189
|
+
if (typeof version === 'number' && Number.isSafeInteger(version) && version > supported)
|
|
190
|
+
throw new AgentError('MAR_AGENT_SESSION_VERSION_UNSUPPORTED', 'Session encoding is unsupported.');
|
|
191
|
+
}
|
|
192
|
+
export function admitWorldStateVersion(value) {
|
|
193
|
+
if (!isObject(value))
|
|
194
|
+
return;
|
|
195
|
+
rejectFuture(value.version, 1);
|
|
196
|
+
if (isObject(value.state))
|
|
197
|
+
rejectFuture(value.state.version, 2);
|
|
198
|
+
}
|
|
199
|
+
export function admitResourceMetadataVersion(value) {
|
|
200
|
+
if (isObject(value))
|
|
201
|
+
rejectFuture(value.resourceInputVersion, 1);
|
|
202
|
+
}
|
|
203
|
+
function isObject(value) {
|
|
204
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
205
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SessionRecord } from '../types.js';
|
|
2
|
+
type LogicalSessionRecord = SessionRecord;
|
|
3
|
+
/** Decode one complete JSONL record using the encoding selected by the Session index. */
|
|
4
|
+
export declare function decodeJsonlRecord(line: string, encoding: number): LogicalSessionRecord;
|
|
5
|
+
/** Decode an already-parsed line without repeating JSON parsing. */
|
|
6
|
+
export declare function decodeJsonlValue(value: unknown, encoding: number): LogicalSessionRecord;
|
|
7
|
+
/** Encode one v2 record without a line delimiter; the segment writer owns framing. */
|
|
8
|
+
export declare function encodeJsonlRecord(record: LogicalSessionRecord, encoding: number): string;
|
|
9
|
+
/** Normalize known physical image references without examining unrelated payload fields. */
|
|
10
|
+
export declare function normalizeJsonlRecord(record: LogicalSessionRecord): LogicalSessionRecord;
|
|
11
|
+
export {};
|