@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,313 @@
|
|
|
1
|
+
import { open, readFile } from 'node:fs/promises';
|
|
2
|
+
import { AgentError } from '../../../error.js';
|
|
3
|
+
import { admitV1RecordVersion } from './jsonl-admission.js';
|
|
4
|
+
import { decodeJsonlRecord, decodeJsonlValue } from './jsonl-codec.js';
|
|
5
|
+
export const MAX_SEGMENT_BYTES = 16 * 1024 * 1024;
|
|
6
|
+
const REVERSE_READ_CHUNK_BYTES = 64 * 1024;
|
|
7
|
+
const MAX_HISTORY_PAGE_FILES = 32;
|
|
8
|
+
const MAX_HISTORY_PAGE_OFFSETS = 128;
|
|
9
|
+
/** Read only the prefix needed by discovery; never load the entire transcript. */
|
|
10
|
+
export async function* readRecordsFromHead(path, encoding = 1) {
|
|
11
|
+
const handle = await open(path, 'r');
|
|
12
|
+
try {
|
|
13
|
+
const { size } = await handle.stat();
|
|
14
|
+
let position = 0;
|
|
15
|
+
let pending = [];
|
|
16
|
+
while (position < size) {
|
|
17
|
+
const chunk = Buffer.allocUnsafe(Math.min(REVERSE_READ_CHUNK_BYTES, size - position));
|
|
18
|
+
const { bytesRead } = await handle.read(chunk, 0, Math.min(chunk.length, size - position), position);
|
|
19
|
+
if (bytesRead === 0)
|
|
20
|
+
break;
|
|
21
|
+
position += bytesRead;
|
|
22
|
+
const data = chunk.subarray(0, bytesRead);
|
|
23
|
+
let start = 0;
|
|
24
|
+
for (;;) {
|
|
25
|
+
const end = data.indexOf(0x0a, start);
|
|
26
|
+
if (end < 0)
|
|
27
|
+
break;
|
|
28
|
+
const part = data.subarray(start, end);
|
|
29
|
+
const line = (pending.length === 0 ? part : Buffer.concat([...pending, part])).toString('utf8');
|
|
30
|
+
pending = [];
|
|
31
|
+
start = end + 1;
|
|
32
|
+
if (!line)
|
|
33
|
+
continue;
|
|
34
|
+
let record;
|
|
35
|
+
try {
|
|
36
|
+
record = decodeJsonlRecord(line, encoding);
|
|
37
|
+
}
|
|
38
|
+
catch (cause) {
|
|
39
|
+
if (cause instanceof AgentError)
|
|
40
|
+
throw cause;
|
|
41
|
+
throw new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Session history is corrupt.', {
|
|
42
|
+
cause
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
yield record;
|
|
46
|
+
}
|
|
47
|
+
if (start < data.length)
|
|
48
|
+
pending.push(data.subarray(start));
|
|
49
|
+
}
|
|
50
|
+
if (pending.length > 0) {
|
|
51
|
+
let record;
|
|
52
|
+
const tail = Buffer.concat(pending).toString('utf8');
|
|
53
|
+
let value;
|
|
54
|
+
try {
|
|
55
|
+
value = JSON.parse(tail);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return; // Readers ignore only an interrupted final line.
|
|
59
|
+
}
|
|
60
|
+
record = decodeJsonlValue(value, encoding);
|
|
61
|
+
yield record;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
await handle.close();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export async function readRecords(path, encoding = 1) {
|
|
69
|
+
const value = await readFile(path, 'utf8');
|
|
70
|
+
const lines = value.split('\n');
|
|
71
|
+
if (lines.at(-1) === '')
|
|
72
|
+
lines.pop();
|
|
73
|
+
const records = [];
|
|
74
|
+
for (const [index, line] of lines.entries()) {
|
|
75
|
+
if (!line)
|
|
76
|
+
continue;
|
|
77
|
+
let parsed;
|
|
78
|
+
try {
|
|
79
|
+
parsed = JSON.parse(line);
|
|
80
|
+
}
|
|
81
|
+
catch (cause) {
|
|
82
|
+
if (index === lines.length - 1 && !value.endsWith('\n'))
|
|
83
|
+
break;
|
|
84
|
+
throw new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Session history is corrupt.', {
|
|
85
|
+
cause
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
records.push(decodeJsonlValue(parsed, encoding));
|
|
89
|
+
}
|
|
90
|
+
return records;
|
|
91
|
+
}
|
|
92
|
+
/** Repair only the final record under the Session writer lock; never skip middle damage. */
|
|
93
|
+
export async function repairSegmentTail(path, encoding = 1) {
|
|
94
|
+
const data = await readFile(path);
|
|
95
|
+
if (data.length === 0 || data.at(-1) === 10)
|
|
96
|
+
return;
|
|
97
|
+
const boundary = data.lastIndexOf(10);
|
|
98
|
+
let complete = false;
|
|
99
|
+
try {
|
|
100
|
+
const tail = data.subarray(boundary + 1).toString('utf8');
|
|
101
|
+
const record = JSON.parse(tail);
|
|
102
|
+
// A complete future-version record must not be mistaken for an interrupted v1 tail.
|
|
103
|
+
if (encoding === 1) {
|
|
104
|
+
admitV1RecordVersion(tail);
|
|
105
|
+
complete =
|
|
106
|
+
record?.schemaVersion === 1 &&
|
|
107
|
+
Number.isSafeInteger(record.sequence) &&
|
|
108
|
+
typeof record.sessionId === 'string' &&
|
|
109
|
+
typeof record.type === 'string';
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
decodeJsonlRecord(tail, encoding);
|
|
113
|
+
complete = true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
if (error instanceof AgentError && error.code === 'MAR_AGENT_SESSION_VERSION_UNSUPPORTED')
|
|
118
|
+
throw error;
|
|
119
|
+
// An interrupted final line is discarded before another record can be appended.
|
|
120
|
+
}
|
|
121
|
+
const handle = await open(path, 'r+');
|
|
122
|
+
try {
|
|
123
|
+
if (complete) {
|
|
124
|
+
const { bytesWritten } = await handle.write(Buffer.from('\n'), 0, 1, data.length);
|
|
125
|
+
if (bytesWritten !== 1)
|
|
126
|
+
throw new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Session tail repair is incomplete.');
|
|
127
|
+
}
|
|
128
|
+
else
|
|
129
|
+
await handle.truncate(boundary + 1);
|
|
130
|
+
await handle.sync();
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
await handle.close();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function readRecordPageFromTail(path, beforeSequence, limit, positions, encoding) {
|
|
137
|
+
const newestFirst = [];
|
|
138
|
+
for await (const record of readRecordsFromTail(path, { beforeSequence, limit, positions }, encoding)) {
|
|
139
|
+
if (!(record.sequence < beforeSequence))
|
|
140
|
+
continue;
|
|
141
|
+
newestFirst.push(record);
|
|
142
|
+
if (newestFirst.length > limit)
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
records: newestFirst.slice(0, limit).reverse(),
|
|
147
|
+
hasEarlier: newestFirst.length > limit
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Decode complete records newest-first, releasing the file as soon as a reader stops. */
|
|
151
|
+
export async function* readRecordsFromTail(path, page, encoding = 1) {
|
|
152
|
+
const handle = await open(path, 'r');
|
|
153
|
+
try {
|
|
154
|
+
const metadata = await handle.stat({ bigint: true });
|
|
155
|
+
const size = Number(metadata.size);
|
|
156
|
+
let position = size;
|
|
157
|
+
let cached;
|
|
158
|
+
if (page !== undefined) {
|
|
159
|
+
const signature = `${metadata.dev}:${metadata.ino}:${metadata.size}:${metadata.mtimeNs}:${metadata.ctimeNs}`;
|
|
160
|
+
const previous = page.positions.get(path);
|
|
161
|
+
cached = previous?.signature === signature ? previous : { signature, offsets: new Map() };
|
|
162
|
+
page.positions.delete(path);
|
|
163
|
+
page.positions.set(path, cached);
|
|
164
|
+
if (page.positions.size > MAX_HISTORY_PAGE_FILES)
|
|
165
|
+
page.positions.delete(page.positions.keys().next().value);
|
|
166
|
+
let nearestSequence = Number.POSITIVE_INFINITY;
|
|
167
|
+
for (const [sequence, offset] of cached.offsets) {
|
|
168
|
+
if (sequence >= page.beforeSequence && sequence < nearestSequence) {
|
|
169
|
+
nearestSequence = sequence;
|
|
170
|
+
position = offset;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
let accepted = 0;
|
|
175
|
+
const remember = (record, offset) => {
|
|
176
|
+
if (page === undefined || cached === undefined || record.sequence >= page.beforeSequence)
|
|
177
|
+
return;
|
|
178
|
+
if (++accepted !== page.limit)
|
|
179
|
+
return;
|
|
180
|
+
cached.offsets.set(record.sequence, offset);
|
|
181
|
+
if (cached.offsets.size > MAX_HISTORY_PAGE_OFFSETS)
|
|
182
|
+
cached.offsets.delete(cached.offsets.keys().next().value);
|
|
183
|
+
};
|
|
184
|
+
let pendingLineParts = [];
|
|
185
|
+
let invalidFinalLineMayBeIgnored = false;
|
|
186
|
+
let inspectedFileEnd = position !== size;
|
|
187
|
+
const decode = (line, allowInvalidFinalLine) => {
|
|
188
|
+
if (line.length === 0)
|
|
189
|
+
return undefined;
|
|
190
|
+
const text = line.toString('utf8');
|
|
191
|
+
let parsed;
|
|
192
|
+
try {
|
|
193
|
+
parsed = JSON.parse(text);
|
|
194
|
+
}
|
|
195
|
+
catch (cause) {
|
|
196
|
+
if (allowInvalidFinalLine)
|
|
197
|
+
return undefined;
|
|
198
|
+
throw new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Session history is corrupt.', {
|
|
199
|
+
cause
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return decodeJsonlValue(parsed, encoding);
|
|
203
|
+
};
|
|
204
|
+
while (position > 0) {
|
|
205
|
+
const start = Math.max(0, position - REVERSE_READ_CHUNK_BYTES);
|
|
206
|
+
const chunk = Buffer.allocUnsafe(position - start);
|
|
207
|
+
let bytesRead = 0;
|
|
208
|
+
while (bytesRead < chunk.length) {
|
|
209
|
+
const result = await handle.read(chunk, bytesRead, chunk.length - bytesRead, start + bytesRead);
|
|
210
|
+
if (result.bytesRead === 0)
|
|
211
|
+
break;
|
|
212
|
+
bytesRead += result.bytesRead;
|
|
213
|
+
}
|
|
214
|
+
const value = chunk.subarray(0, bytesRead);
|
|
215
|
+
if (!inspectedFileEnd) {
|
|
216
|
+
inspectedFileEnd = true;
|
|
217
|
+
invalidFinalLineMayBeIgnored = value.at(-1) !== 0x0a;
|
|
218
|
+
}
|
|
219
|
+
let lineEnd = value.length;
|
|
220
|
+
for (let index = value.length - 1; index >= 0; index--) {
|
|
221
|
+
if (value[index] !== 0x0a)
|
|
222
|
+
continue;
|
|
223
|
+
const currentPart = value.subarray(index + 1, lineEnd);
|
|
224
|
+
const line = pendingLineParts.length === 0
|
|
225
|
+
? currentPart
|
|
226
|
+
: Buffer.concat([currentPart, ...pendingLineParts.reverse()]);
|
|
227
|
+
const record = decode(line, invalidFinalLineMayBeIgnored);
|
|
228
|
+
invalidFinalLineMayBeIgnored = false;
|
|
229
|
+
pendingLineParts = [];
|
|
230
|
+
lineEnd = index;
|
|
231
|
+
if (record !== undefined) {
|
|
232
|
+
remember(record, start + index + 1);
|
|
233
|
+
yield record;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (lineEnd > 0)
|
|
237
|
+
pendingLineParts.push(value.subarray(0, lineEnd));
|
|
238
|
+
position = start;
|
|
239
|
+
}
|
|
240
|
+
if (pendingLineParts.length > 0) {
|
|
241
|
+
const record = decode(Buffer.concat(pendingLineParts.reverse()), invalidFinalLineMayBeIgnored);
|
|
242
|
+
if (record !== undefined) {
|
|
243
|
+
remember(record, 0);
|
|
244
|
+
yield record;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
finally {
|
|
249
|
+
await handle.close();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function segmentNumberFromPath(path) {
|
|
253
|
+
const match = /events-(\d{6})\.jsonl$/.exec(path);
|
|
254
|
+
return match === null ? undefined : Number(match[1]);
|
|
255
|
+
}
|
|
256
|
+
/** Owns bounded reverse-read positions for the shared Store domain. */
|
|
257
|
+
export class SessionHistoryPageReader {
|
|
258
|
+
#positions = new Map();
|
|
259
|
+
async read(meta, input, segmentPaths) {
|
|
260
|
+
const before = input.beforeSequence ?? Number.POSITIVE_INFINITY;
|
|
261
|
+
const limit = Math.min(1000, Math.max(1, input.limit ?? 100));
|
|
262
|
+
const page = [];
|
|
263
|
+
let hasEarlier = false;
|
|
264
|
+
const paths = (await segmentPaths()).reverse();
|
|
265
|
+
for (const [pathIndex, path] of paths.entries()) {
|
|
266
|
+
const segmentNumber = segmentNumberFromPath(path);
|
|
267
|
+
const segment = meta.segments?.find((item) => item.number === segmentNumber);
|
|
268
|
+
if (segment !== undefined && segment.firstSequence >= before)
|
|
269
|
+
continue;
|
|
270
|
+
const window = await readRecordPageFromTail(path, before, limit - page.length, this.#positions, meta.storage?.encoding ?? 1);
|
|
271
|
+
page.unshift(...window.records);
|
|
272
|
+
if (window.hasEarlier) {
|
|
273
|
+
hasEarlier = true;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
if (page.length >= limit) {
|
|
277
|
+
hasEarlier = pathIndex < paths.length - 1;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
const previousBeforeSequence = hasEarlier ? page[0]?.sequence : undefined;
|
|
282
|
+
return { records: page, ...(previousBeforeSequence ? { previousBeforeSequence } : {}) };
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
export async function appendRecordBytes(path, serialized, onWriteFailure) {
|
|
286
|
+
const bytes = Buffer.from(serialized);
|
|
287
|
+
const handle = await open(path, 'a', 0o600);
|
|
288
|
+
let failure;
|
|
289
|
+
try {
|
|
290
|
+
let offset = 0;
|
|
291
|
+
while (offset < bytes.length) {
|
|
292
|
+
const { bytesWritten } = await handle.write(bytes, offset, bytes.length - offset);
|
|
293
|
+
if (bytesWritten === 0)
|
|
294
|
+
throw new AgentError('MAR_AGENT_SESSION_CORRUPT', 'Session append is incomplete.');
|
|
295
|
+
offset += bytesWritten;
|
|
296
|
+
}
|
|
297
|
+
await handle.sync();
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
failure = { error };
|
|
301
|
+
}
|
|
302
|
+
try {
|
|
303
|
+
await handle.close();
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
failure ??= { error };
|
|
307
|
+
}
|
|
308
|
+
if (failure) {
|
|
309
|
+
// Opening/encoding failures cannot have appended bytes; write/sync/close failures can.
|
|
310
|
+
onWriteFailure(failure.error);
|
|
311
|
+
throw failure.error;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ModelImage } from '../../../model/image.js';
|
|
2
|
+
import type { SessionRecord } from '../types.js';
|
|
3
|
+
import type { SessionResource } from '../../resource-contract.js';
|
|
4
|
+
export type { SessionResource } from '../../resource-contract.js';
|
|
5
|
+
export declare function resourceMetadata(directory: string, resourceId: string): Promise<SessionResource | undefined>;
|
|
6
|
+
export declare function persistResource(directory: string, image: ModelImage): Promise<SessionResource>;
|
|
7
|
+
export declare function setResourceUrl(directory: string, resourceId: string, published: {
|
|
8
|
+
url: string;
|
|
9
|
+
urlExpiresAt: number;
|
|
10
|
+
}): Promise<SessionResource>;
|
|
11
|
+
export declare function readResource(directory: string, resourceId: string): Promise<{
|
|
12
|
+
mimeType: string;
|
|
13
|
+
dataBase64: string;
|
|
14
|
+
} | undefined>;
|
|
15
|
+
/** Resource identities are SDK-owned metadata, never interpreted as file paths. */
|
|
16
|
+
export declare function resourceFiles(records: readonly SessionRecord[]): Set<string>;
|
|
17
|
+
export declare function copyResources(source: string, target: string, records: readonly SessionRecord[]): Promise<void>;
|
|
18
|
+
export declare function completeResources(directory: string, record: SessionRecord): Promise<void>;
|
|
19
|
+
export declare function recoverResources(directory: string, readHistory: () => Promise<SessionRecord[]>): Promise<void>;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { mkdir, readFile, readdir, rename, rm, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { basename, dirname, join } from 'node:path';
|
|
4
|
+
import { AgentError } from '../../../error.js';
|
|
5
|
+
import { isModelImageUrl } from '../../../model/image.js';
|
|
6
|
+
import { readInputImageBytes } from './images.js';
|
|
7
|
+
import { admitResourceMetadataVersion } from './jsonl-admission.js';
|
|
8
|
+
const idPattern = /^[a-f0-9]{64}$/u;
|
|
9
|
+
const mimeTypes = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp']);
|
|
10
|
+
function resourceIdentity(mimeType, sha256) {
|
|
11
|
+
return createHash('sha256').update(mimeType).update('\0').update(sha256).digest('hex');
|
|
12
|
+
}
|
|
13
|
+
export async function resourceMetadata(directory, resourceId) {
|
|
14
|
+
if (!idPattern.test(resourceId))
|
|
15
|
+
return undefined;
|
|
16
|
+
try {
|
|
17
|
+
const value = JSON.parse(await readFile(join(directory, `${resourceId}.json`), 'utf8'));
|
|
18
|
+
const resource = value;
|
|
19
|
+
admitResourceMetadataVersion(value);
|
|
20
|
+
if (!value ||
|
|
21
|
+
typeof value !== 'object' ||
|
|
22
|
+
Array.isArray(value) ||
|
|
23
|
+
typeof resource.resourceId !== 'string' ||
|
|
24
|
+
typeof resource.mimeType !== 'string' ||
|
|
25
|
+
typeof resource.byteSize !== 'number' ||
|
|
26
|
+
typeof resource.sha256 !== 'string' ||
|
|
27
|
+
(resource.url !== undefined &&
|
|
28
|
+
(typeof resource.url !== 'string' ||
|
|
29
|
+
!isModelImageUrl(resource.url) ||
|
|
30
|
+
!Number.isSafeInteger(resource.urlExpiresAt) ||
|
|
31
|
+
resource.urlExpiresAt <= 0)) ||
|
|
32
|
+
(resource.url === undefined && resource.urlExpiresAt !== undefined))
|
|
33
|
+
throw new Error('Invalid Session image resource metadata.');
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
catch (cause) {
|
|
37
|
+
if (cause instanceof AgentError && cause.code === 'MAR_AGENT_SESSION_VERSION_UNSUPPORTED')
|
|
38
|
+
throw cause;
|
|
39
|
+
if (cause.code === 'ENOENT')
|
|
40
|
+
return undefined;
|
|
41
|
+
throw new AgentError('MAR_AGENT_IMAGE_UNAVAILABLE', 'Session image resource is unavailable.', {
|
|
42
|
+
cause
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export async function persistResource(directory, image) {
|
|
47
|
+
if (image.resourceId !== undefined && image.dataBase64 === undefined) {
|
|
48
|
+
const existing = await resourceMetadata(directory, image.resourceId);
|
|
49
|
+
if (existing !== undefined && existing.mimeType === image.mimeType)
|
|
50
|
+
return existing;
|
|
51
|
+
throw new AgentError('MAR_AGENT_IMAGE_UNAVAILABLE', 'Session image resource is missing.');
|
|
52
|
+
}
|
|
53
|
+
const data = Buffer.from(image.dataBase64 ?? '', 'base64');
|
|
54
|
+
if (data.toString('base64') !== image.dataBase64)
|
|
55
|
+
throw new AgentError('MAR_AGENT_SESSION_INPUT_INVALID', 'Image resource data is not canonical base64.');
|
|
56
|
+
if (!mimeTypes.has(image.mimeType) || data.length === 0 || data.length > 20 * 1024 * 1024)
|
|
57
|
+
throw new AgentError('MAR_AGENT_HOST_LIMIT_EXCEEDED', 'Image resource exceeds supported limits.');
|
|
58
|
+
const sha256 = createHash('sha256').update(data).digest('hex');
|
|
59
|
+
const resourceId = resourceIdentity(image.mimeType, sha256);
|
|
60
|
+
if (image.resourceId !== undefined && image.resourceId !== resourceId)
|
|
61
|
+
throw new AgentError('MAR_AGENT_SESSION_INPUT_INVALID', 'Image resource identity does not match its bytes.');
|
|
62
|
+
let existing;
|
|
63
|
+
try {
|
|
64
|
+
existing = await resourceMetadata(directory, resourceId);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (!(error instanceof AgentError) || error.code !== 'MAR_AGENT_IMAGE_UNAVAILABLE')
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
const resource = {
|
|
71
|
+
...existing,
|
|
72
|
+
resourceInputVersion: 1,
|
|
73
|
+
resourceId,
|
|
74
|
+
mimeType: image.mimeType,
|
|
75
|
+
byteSize: data.length,
|
|
76
|
+
sha256
|
|
77
|
+
};
|
|
78
|
+
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
79
|
+
await writeFile(join(directory, `.${resourceId}.pending`), '', { mode: 0o600, flush: true });
|
|
80
|
+
await atomicWrite(join(directory, `${resourceId}.bin`), data);
|
|
81
|
+
await atomicWrite(join(directory, `${resourceId}.json`), JSON.stringify(resource));
|
|
82
|
+
return resource;
|
|
83
|
+
}
|
|
84
|
+
export async function setResourceUrl(directory, resourceId, published) {
|
|
85
|
+
const resource = await resourceMetadata(directory, resourceId);
|
|
86
|
+
if (!resource)
|
|
87
|
+
throw new AgentError('MAR_AGENT_IMAGE_UNAVAILABLE', 'Session image resource is missing.');
|
|
88
|
+
if (resource.url !== undefined)
|
|
89
|
+
return resource;
|
|
90
|
+
if (!isModelImageUrl(published.url) ||
|
|
91
|
+
!Number.isSafeInteger(published.urlExpiresAt) ||
|
|
92
|
+
published.urlExpiresAt <= 0)
|
|
93
|
+
throw new AgentError('MAR_AGENT_IMAGE_PUBLICATION_FAILED', 'Image URL publication failed.');
|
|
94
|
+
const result = { ...resource, url: published.url, urlExpiresAt: published.urlExpiresAt };
|
|
95
|
+
await atomicWrite(join(directory, `${resourceId}.json`), JSON.stringify(result));
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
export async function readResource(directory, resourceId) {
|
|
99
|
+
const resource = await resourceMetadata(directory, resourceId);
|
|
100
|
+
if (!resource)
|
|
101
|
+
return undefined;
|
|
102
|
+
const bytes = await readInputImageBytes(directory, {
|
|
103
|
+
...resource,
|
|
104
|
+
name: 'image',
|
|
105
|
+
fileName: `${resourceId}.bin`
|
|
106
|
+
});
|
|
107
|
+
return { mimeType: resource.mimeType, dataBase64: bytes.toString('base64') };
|
|
108
|
+
}
|
|
109
|
+
/** Resource identities are SDK-owned metadata, never interpreted as file paths. */
|
|
110
|
+
export function resourceFiles(records) {
|
|
111
|
+
const ids = new Set();
|
|
112
|
+
const visit = (value) => {
|
|
113
|
+
if (Array.isArray(value)) {
|
|
114
|
+
for (const item of value)
|
|
115
|
+
visit(item);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (!value || typeof value !== 'object')
|
|
119
|
+
return;
|
|
120
|
+
const item = value;
|
|
121
|
+
if (item.resourceInputVersion === 1 &&
|
|
122
|
+
typeof item.resourceId === 'string' &&
|
|
123
|
+
idPattern.test(item.resourceId))
|
|
124
|
+
ids.add(item.resourceId);
|
|
125
|
+
for (const key of ['images', 'input', 'pendingInputs', 'payload', 'retainedModelContext'])
|
|
126
|
+
if (item[key] !== undefined)
|
|
127
|
+
visit(item[key]);
|
|
128
|
+
};
|
|
129
|
+
for (const record of records)
|
|
130
|
+
visit(record.payload);
|
|
131
|
+
return new Set([...ids].flatMap((id) => [`${id}.bin`, `${id}.json`]));
|
|
132
|
+
}
|
|
133
|
+
export async function copyResources(source, target, records) {
|
|
134
|
+
const files = resourceFiles(records);
|
|
135
|
+
if (!files.size)
|
|
136
|
+
return;
|
|
137
|
+
await mkdir(join(target, 'resources'), { recursive: true, mode: 0o700 });
|
|
138
|
+
for (const file of files) {
|
|
139
|
+
if (!file.endsWith('.bin'))
|
|
140
|
+
continue;
|
|
141
|
+
const resourceId = file.slice(0, -4);
|
|
142
|
+
const resource = await resourceMetadata(join(source, 'resources'), resourceId);
|
|
143
|
+
if (resource === undefined)
|
|
144
|
+
continue;
|
|
145
|
+
let bytes;
|
|
146
|
+
try {
|
|
147
|
+
bytes = await readInputImageBytes(join(source, 'resources'), {
|
|
148
|
+
...resource,
|
|
149
|
+
name: 'image',
|
|
150
|
+
fileName: file
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
if (error instanceof AgentError && error.code === 'MAR_AGENT_IMAGE_UNAVAILABLE')
|
|
155
|
+
continue;
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
await writeFile(join(target, 'resources', file), bytes, {
|
|
159
|
+
mode: 0o600,
|
|
160
|
+
flag: 'wx',
|
|
161
|
+
flush: true
|
|
162
|
+
});
|
|
163
|
+
await writeFile(join(target, 'resources', `${resourceId}.json`), JSON.stringify(resource), {
|
|
164
|
+
mode: 0o600,
|
|
165
|
+
flag: 'wx',
|
|
166
|
+
flush: true
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
export async function completeResources(directory, record) {
|
|
171
|
+
for (const file of resourceFiles([record]))
|
|
172
|
+
if (file.endsWith('.bin'))
|
|
173
|
+
await rm(join(directory, `.${file.slice(0, -4)}.pending`), { force: true });
|
|
174
|
+
}
|
|
175
|
+
export async function recoverResources(directory, readHistory) {
|
|
176
|
+
let names;
|
|
177
|
+
try {
|
|
178
|
+
names = await readdir(directory);
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
if (error.code === 'ENOENT')
|
|
182
|
+
return;
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
const pending = names.filter((name) => /^\.[a-f0-9]{64}\.pending$/u.test(name));
|
|
186
|
+
if (pending.length) {
|
|
187
|
+
const retained = resourceFiles(await readHistory());
|
|
188
|
+
for (const name of pending) {
|
|
189
|
+
const id = name.slice(1, -8);
|
|
190
|
+
if (!retained.has(`${id}.bin`))
|
|
191
|
+
for (const suffix of ['bin', 'json'])
|
|
192
|
+
await rm(join(directory, `${id}.${suffix}`), { force: true });
|
|
193
|
+
await rm(join(directory, name), { force: true });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
for (const name of names)
|
|
197
|
+
if (/^\.[a-f0-9]{64}\.(?:bin|json)\.[a-f0-9-]{36}\.tmp$/u.test(name))
|
|
198
|
+
await rm(join(directory, name), { force: true });
|
|
199
|
+
}
|
|
200
|
+
async function atomicWrite(path, data) {
|
|
201
|
+
const temporary = join(dirname(path), `.${basename(path)}.${randomUUID()}.tmp`);
|
|
202
|
+
try {
|
|
203
|
+
await writeFile(temporary, data, { mode: 0o600, flag: 'wx', flush: true });
|
|
204
|
+
await rename(temporary, path);
|
|
205
|
+
}
|
|
206
|
+
finally {
|
|
207
|
+
await rm(temporary, { force: true });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface PooledStore {
|
|
2
|
+
readonly root: string;
|
|
3
|
+
references: number;
|
|
4
|
+
closed: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** Shares a storage domain across handles while keeping their close responsibilities separate. */
|
|
7
|
+
export declare class JsonlStorePool<T extends PooledStore> {
|
|
8
|
+
#private;
|
|
9
|
+
acquire(root: string, open: () => Promise<T>): Promise<T>;
|
|
10
|
+
release(shared: T, beforeLastClose: () => Promise<void> | undefined): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Shares a storage domain across handles while keeping their close responsibilities separate. */
|
|
2
|
+
export class JsonlStorePool {
|
|
3
|
+
#instances = new Map();
|
|
4
|
+
#opening = new Map();
|
|
5
|
+
#closing = new Map();
|
|
6
|
+
async acquire(root, open) {
|
|
7
|
+
const closing = this.#closing.get(root);
|
|
8
|
+
if (closing) {
|
|
9
|
+
await closing;
|
|
10
|
+
return this.acquire(root, open);
|
|
11
|
+
}
|
|
12
|
+
const existing = this.#instances.get(root);
|
|
13
|
+
if (existing) {
|
|
14
|
+
existing.references++;
|
|
15
|
+
return existing;
|
|
16
|
+
}
|
|
17
|
+
const pending = this.#opening.get(root);
|
|
18
|
+
if (pending) {
|
|
19
|
+
const shared = await pending;
|
|
20
|
+
shared.references++;
|
|
21
|
+
return shared;
|
|
22
|
+
}
|
|
23
|
+
const opening = open();
|
|
24
|
+
this.#opening.set(root, opening);
|
|
25
|
+
try {
|
|
26
|
+
const shared = await opening;
|
|
27
|
+
this.#instances.set(root, shared);
|
|
28
|
+
return shared;
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
this.#opening.delete(root);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async release(shared, beforeLastClose) {
|
|
35
|
+
shared.references--;
|
|
36
|
+
if (shared.references > 0)
|
|
37
|
+
return;
|
|
38
|
+
const flush = beforeLastClose();
|
|
39
|
+
if (flush) {
|
|
40
|
+
const closing = flush.then(() => {
|
|
41
|
+
shared.closed = true;
|
|
42
|
+
this.#instances.delete(shared.root);
|
|
43
|
+
this.#closing.delete(shared.root);
|
|
44
|
+
}, (error) => {
|
|
45
|
+
this.#closing.delete(shared.root);
|
|
46
|
+
throw error;
|
|
47
|
+
});
|
|
48
|
+
this.#closing.set(shared.root, closing);
|
|
49
|
+
await closing;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
shared.closed = true;
|
|
53
|
+
this.#instances.delete(shared.root);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** One authoritative journal for an entire Session tree; markers only locate it. */
|
|
2
|
+
export interface SessionTreeDeleteTransaction {
|
|
3
|
+
readonly version: 1;
|
|
4
|
+
readonly kind: 'delete';
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly phase?: 'preparing' | 'ready' | 'restored';
|
|
7
|
+
readonly members: readonly {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly existed: boolean;
|
|
10
|
+
readonly identity: {
|
|
11
|
+
readonly createdAt: string;
|
|
12
|
+
readonly workspace: string;
|
|
13
|
+
readonly source?: unknown;
|
|
14
|
+
readonly storage?: unknown;
|
|
15
|
+
readonly storageTransactionId?: string;
|
|
16
|
+
readonly nextSequence: number;
|
|
17
|
+
};
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
20
|
+
export declare function treeDeleteMarker(root: string, sessionId: string): string;
|
|
21
|
+
export declare function readTreeDeleteTransaction(root: string, sessionId: string): Promise<SessionTreeDeleteTransaction | undefined>;
|
|
22
|
+
export declare function beginTreeDeleteTransaction(root: string, transaction: SessionTreeDeleteTransaction, sync: (path: string) => Promise<void>): Promise<void>;
|
|
23
|
+
/** Called only with all tree writers and read gates held. */
|
|
24
|
+
export declare function stageTreeDelete(root: string, transaction: SessionTreeDeleteTransaction, sync: (path: string) => Promise<void>): Promise<void>;
|
|
25
|
+
/** Index membership selects restore versus retirement; never infer commit from file presence. */
|
|
26
|
+
export declare function finishTreeDelete(root: string, transaction: SessionTreeDeleteTransaction, committed: boolean, sync: (path: string) => Promise<void>): Promise<void>;
|
|
27
|
+
/** Remove only markers owned by the preparing or fully restored transaction. */
|
|
28
|
+
export declare function finishTreeDeletePreparation(root: string, transaction: SessionTreeDeleteTransaction, sync: (path: string) => Promise<void>): Promise<void>;
|
|
29
|
+
export declare function isUnjournaledTransactionFile(name: string): boolean;
|
|
30
|
+
export interface SessionStorageTransaction {
|
|
31
|
+
readonly version: 1;
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly kind: 'rollback' | 'clear';
|
|
34
|
+
readonly originalSegments: readonly string[];
|
|
35
|
+
readonly stagedSegments: readonly {
|
|
36
|
+
readonly path: string;
|
|
37
|
+
readonly temporary: string;
|
|
38
|
+
}[];
|
|
39
|
+
readonly sidecarBackup: string;
|
|
40
|
+
readonly retiredPaths?: readonly string[];
|
|
41
|
+
readonly targetGeneration?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Deterministic names make a partially staged retirement recoverable from the same journal. */
|
|
44
|
+
export declare function retiredSessionTrashPath(root: string, path: string, transactionId: string): string;
|
|
45
|
+
/** The index's transaction ID, not the journal's existence, decides the commit side. */
|
|
46
|
+
export declare function beginSessionStorageTransaction(directory: string, transaction: SessionStorageTransaction): Promise<void>;
|
|
47
|
+
/** Must run under the corresponding Session writer lock. Safe to repeat after interruption. */
|
|
48
|
+
export declare function recoverSessionStorageTransaction(directory: string, committedTransactionId?: string, sessionDirectory?: string): Promise<void>;
|