@myagentroam/agent 0.11.33 → 0.11.35
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/fork-session.d.ts +19 -0
- package/dist/session/store/jsonl/fork-session.js +142 -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 +2395 -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 +87 -0
- package/dist/subagent/session-controller.js +1343 -0
- package/dist/subagent/task.d.ts +134 -0
- package/dist/subagent/task.js +436 -0
- package/dist/subagent/turn-contracts.d.ts +64 -0
- package/dist/subagent/turn-contracts.js +1 -0
- package/dist/subagent/wait-targets.d.ts +10 -0
- package/dist/subagent/wait-targets.js +26 -0
- package/dist/subagent/wait.d.ts +26 -0
- package/dist/subagent/wait.js +73 -0
- package/dist/tools/agent/agent-cancel.d.ts +7 -0
- package/dist/tools/agent/agent-cancel.js +29 -0
- package/dist/tools/agent/agent-message.d.ts +7 -0
- package/dist/tools/agent/agent-message.js +57 -0
- package/dist/tools/agent/agent-start.d.ts +12 -0
- package/dist/tools/agent/agent-start.js +106 -0
- package/dist/tools/agent/agent-wait.d.ts +7 -0
- package/dist/tools/agent/agent-wait.js +91 -0
- package/dist/tools/agent/question.d.ts +7 -0
- package/dist/tools/agent/question.js +125 -0
- package/dist/tools/agent/skill.d.ts +11 -0
- package/dist/tools/agent/skill.js +38 -0
- package/dist/tools/agent/sleep.d.ts +9 -0
- package/dist/tools/agent/sleep.js +54 -0
- package/dist/tools/agent/smart-compact.d.ts +9 -0
- package/dist/tools/agent/smart-compact.js +23 -0
- package/dist/tools/agent/todo-read.d.ts +14 -0
- package/dist/tools/agent/todo-write.d.ts +14 -0
- package/dist/tools/agent/todo-write.js +66 -0
- package/dist/tools/agent/todo.d.ts +25 -0
- package/dist/tools/agent/todo.js +32 -0
- package/dist/tools/callers.d.ts +7 -0
- package/dist/tools/callers.js +39 -0
- package/dist/tools/code-mode/cells.d.ts +29 -0
- package/dist/tools/code-mode/cells.js +338 -0
- package/dist/tools/code-mode/dispatch.d.ts +20 -0
- package/dist/tools/code-mode/dispatch.js +80 -0
- package/dist/tools/code-mode/engine.d.ts +60 -0
- package/dist/tools/code-mode/engine.js +1 -0
- package/dist/tools/code-mode/index.d.ts +31 -0
- package/dist/tools/code-mode/index.js +751 -0
- package/dist/tools/code-mode/observations.d.ts +8 -0
- package/dist/tools/code-mode/observations.js +64 -0
- package/dist/tools/code-mode/worker.d.ts +1 -0
- package/dist/tools/contracts.d.ts +193 -0
- package/dist/tools/contracts.js +1 -0
- package/dist/tools/definition-projection.d.ts +1 -0
- package/dist/tools/definition-projection.js +1 -0
- package/dist/tools/execution-limits.d.ts +69 -0
- package/dist/tools/execution-limits.js +58 -0
- package/dist/tools/execution.d.ts +30 -0
- package/dist/tools/execution.js +191 -0
- package/dist/tools/local/apply-patch-parser.js +177 -0
- package/dist/tools/local/apply-patch.d.ts +19 -0
- package/dist/tools/local/apply-patch.js +489 -0
- package/dist/tools/local/exec.d.ts +28 -0
- package/dist/tools/local/exec.js +194 -0
- package/dist/tools/local/image-processing.js +146 -0
- package/dist/tools/local/read.d.ts +43 -0
- package/dist/tools/local/read.js +470 -0
- package/dist/tools/local/view-image.d.ts +15 -0
- package/dist/tools/local/view-image.js +317 -0
- package/dist/tools/mcp/catalog.js +220 -0
- package/dist/tools/mcp/history.d.ts +4 -0
- package/dist/tools/mcp/tool-search.d.ts +45 -0
- package/dist/tools/mcp/tool-search.js +294 -0
- package/dist/tools/output-projection.d.ts +18 -0
- package/dist/tools/output-projection.js +341 -0
- package/dist/tools/permission-contract.d.ts +25 -0
- package/dist/tools/permission-contract.js +1 -0
- package/dist/tools/permissions.d.ts +61 -0
- package/dist/tools/permissions.js +237 -0
- package/dist/tools/registry.d.ts +7 -0
- package/dist/tools/result-extension-contract.d.ts +37 -0
- package/dist/tools/result-extension-contract.js +32 -0
- package/dist/tools/result-extensions.d.ts +12 -0
- package/dist/tools/result-extensions.js +104 -0
- package/dist/tools/runtime-context.d.ts +89 -0
- package/dist/tools/runtime-context.js +1 -0
- package/dist/tools/runtime-resource-handles.js +28 -0
- package/dist/tools/runtime.js +77 -0
- package/dist/tools/scheduler.d.ts +12 -0
- package/dist/tools/shared/path-resolver.js +133 -0
- package/dist/tools/wait.d.ts +1 -0
- package/dist/tools/wait.js +1 -0
- package/package.json +15 -3
- package/dist/agent-core/error.d.ts +0 -15
- package/dist/agent-core/error.js +0 -74
- package/dist/agent-core/extensions/agents.d.ts +0 -79
- package/dist/agent-core/extensions/agents.js +0 -186
- package/dist/agent-core/extensions/compaction.d.ts +0 -48
- package/dist/agent-core/extensions/contracts.d.ts +0 -265
- package/dist/agent-core/extensions/data.d.ts +0 -84
- package/dist/agent-core/extensions/data.js +0 -83
- package/dist/agent-core/extensions/environment.d.ts +0 -27
- package/dist/agent-core/extensions/environment.js +0 -52
- package/dist/agent-core/extensions/files.d.ts +0 -64
- package/dist/agent-core/extensions/files.js +0 -26
- package/dist/agent-core/extensions/hooks.d.ts +0 -32
- package/dist/agent-core/extensions/manager.d.ts +0 -39
- package/dist/agent-core/extensions/manager.js +0 -458
- package/dist/agent-core/extensions/mcp.d.ts +0 -99
- package/dist/agent-core/extensions/mcp.js +0 -433
- package/dist/agent-core/extensions/model-request.d.ts +0 -56
- package/dist/agent-core/extensions/model-request.js +0 -197
- package/dist/agent-core/extensions/model-stream.d.ts +0 -9
- package/dist/agent-core/extensions/model-stream.js +0 -108
- package/dist/agent-core/extensions/models.d.ts +0 -43
- package/dist/agent-core/extensions/network.d.ts +0 -32
- package/dist/agent-core/extensions/network.js +0 -97
- package/dist/agent-core/extensions/operation.d.ts +0 -30
- package/dist/agent-core/extensions/processes.d.ts +0 -52
- package/dist/agent-core/extensions/processes.js +0 -284
- package/dist/agent-core/extensions/prompt-composition.d.ts +0 -24
- package/dist/agent-core/extensions/prompt-composition.js +0 -106
- package/dist/agent-core/extensions/prompt-input.d.ts +0 -23
- package/dist/agent-core/extensions/prompt-input.js +0 -48
- package/dist/agent-core/extensions/resources.d.ts +0 -27
- package/dist/agent-core/extensions/resources.js +0 -221
- package/dist/agent-core/extensions/services.d.ts +0 -31
- package/dist/agent-core/extensions/services.js +0 -61
- package/dist/agent-core/extensions/session-input.d.ts +0 -163
- package/dist/agent-core/extensions/session-input.js +0 -411
- package/dist/agent-core/extensions/session-messages.d.ts +0 -41
- package/dist/agent-core/extensions/session-messages.js +0 -76
- package/dist/agent-core/extensions/session.d.ts +0 -69
- package/dist/agent-core/extensions/session.js +0 -607
- package/dist/agent-core/extensions/settings.d.ts +0 -59
- package/dist/agent-core/extensions/settings.js +0 -115
- package/dist/agent-core/extensions/store.d.ts +0 -10
- package/dist/agent-core/extensions/store.js +0 -131
- package/dist/agent-core/extensions/tools.d.ts +0 -61
- package/dist/agent-core/extensions/tools.js +0 -269
- package/dist/agent-core/host/contracts.d.ts +0 -100
- package/dist/agent-core/host/contracts.js +0 -18
- package/dist/agent-core/host/local-agent-host.d.ts +0 -96
- package/dist/agent-core/host/local-agent-host.js +0 -425
- package/dist/agent-core/host/local-file-access.d.ts +0 -30
- package/dist/agent-core/host/local-file-access.js +0 -107
- package/dist/agent-core/host/local-network-access.d.ts +0 -6
- package/dist/agent-core/host/local-network-access.js +0 -101
- package/dist/agent-core/host/local-process-executor.d.ts +0 -29
- package/dist/agent-core/host/local-process-executor.js +0 -41
- package/dist/agent-core/host/local-session-environment.d.ts +0 -18
- package/dist/agent-core/host/local-shell.d.ts +0 -3
- package/dist/agent-core/host/network.d.ts +0 -4
- package/dist/agent-core/host/network.js +0 -6
- package/dist/agent-core/model/anthropic-messages.d.ts +0 -10
- package/dist/agent-core/model/anthropic-messages.js +0 -707
- package/dist/agent-core/model/anthropic-thinking.js +0 -33
- package/dist/agent-core/model/catalog-file.d.ts +0 -80
- package/dist/agent-core/model/catalog-file.js +0 -103
- package/dist/agent-core/model/configuration.d.ts +0 -127
- package/dist/agent-core/model/configuration.js +0 -168
- package/dist/agent-core/model/contracts.d.ts +0 -229
- package/dist/agent-core/model/http.d.ts +0 -27
- package/dist/agent-core/model/http.js +0 -534
- package/dist/agent-core/model/image.d.ts +0 -17
- package/dist/agent-core/model/openai-responses.d.ts +0 -77
- package/dist/agent-core/model/openai-responses.js +0 -2123
- package/dist/agent-core/model/product-user-agent.d.ts +0 -5
- package/dist/agent-core/model/product-user-agent.js +0 -22
- package/dist/agent-core/model/recovery.js +0 -80
- package/dist/agent-core/model/request-configuration.d.ts +0 -17
- package/dist/agent-core/model/request-configuration.js +0 -47
- package/dist/agent-core/model/runtime-credential.d.ts +0 -8
- package/dist/agent-core/model/runtime-credential.js +0 -72
- package/dist/agent-core/model/sse.js +0 -281
- package/dist/agent-core/model/text-blocks.js +0 -40
- package/dist/agent-core/model/tool-declarations.d.ts +0 -4
- package/dist/agent-core/model/transport-test.d.ts +0 -3
- package/dist/agent-core/model/transport-test.js +0 -23
- package/dist/agent-core/model/usage-observer.d.ts +0 -31
- package/dist/agent-core/prompts/index.d.ts +0 -20
- package/dist/agent-core/prompts/index.js +0 -49
- package/dist/agent-core/runtime/compaction/coordinator.js +0 -88
- package/dist/agent-core/runtime/compaction/generate.d.ts +0 -28
- package/dist/agent-core/runtime/compaction/generate.js +0 -84
- package/dist/agent-core/runtime/compaction/history.d.ts +0 -16
- package/dist/agent-core/runtime/compaction/operation.d.ts +0 -29
- package/dist/agent-core/runtime/compaction/operation.js +0 -131
- package/dist/agent-core/runtime/compaction/requests.d.ts +0 -16
- package/dist/agent-core/runtime/compaction/requests.js +0 -114
- package/dist/agent-core/runtime/compaction/retained-context.d.ts +0 -6
- package/dist/agent-core/runtime/compaction/retained-context.js +0 -47
- package/dist/agent-core/runtime/compaction/smart.d.ts +0 -14
- package/dist/agent-core/runtime/compaction/smart.js +0 -59
- package/dist/agent-core/runtime/context/contextual-blocks.d.ts +0 -30
- package/dist/agent-core/runtime/context/contextual-blocks.js +0 -146
- package/dist/agent-core/runtime/context/environment.d.ts +0 -5
- package/dist/agent-core/runtime/context/gc-runtime.d.ts +0 -38
- package/dist/agent-core/runtime/context/gc-tokens.d.ts +0 -25
- package/dist/agent-core/runtime/context/gc-tokens.js +0 -103
- package/dist/agent-core/runtime/context/gc.d.ts +0 -75
- package/dist/agent-core/runtime/context/gc.js +0 -1386
- package/dist/agent-core/runtime/context/instructions.d.ts +0 -37
- package/dist/agent-core/runtime/context/instructions.js +0 -297
- package/dist/agent-core/runtime/context/normalize.d.ts +0 -5
- package/dist/agent-core/runtime/context/projection.d.ts +0 -23
- package/dist/agent-core/runtime/context/projection.js +0 -284
- package/dist/agent-core/runtime/context/request-budget.d.ts +0 -4
- package/dist/agent-core/runtime/context/request-budget.js +0 -25
- package/dist/agent-core/runtime/context/restore.d.ts +0 -25
- package/dist/agent-core/runtime/context/restore.js +0 -186
- package/dist/agent-core/runtime/context/usage.d.ts +0 -17
- package/dist/agent-core/runtime/context/usage.js +0 -124
- package/dist/agent-core/runtime/context/world-state.d.ts +0 -33
- package/dist/agent-core/runtime/context/world-state.js +0 -232
- package/dist/agent-core/runtime/contracts.d.ts +0 -41
- package/dist/agent-core/runtime/event-projection.d.ts +0 -14
- package/dist/agent-core/runtime/event-projection.js +0 -87
- package/dist/agent-core/runtime/events.d.ts +0 -197
- package/dist/agent-core/runtime/execution-handle.d.ts +0 -12
- package/dist/agent-core/runtime/execution.d.ts +0 -50
- package/dist/agent-core/runtime/execution.js +0 -445
- package/dist/agent-core/runtime/model-progress.js +0 -85
- package/dist/agent-core/runtime/resource-publication.d.ts +0 -8
- package/dist/agent-core/runtime/resource-publication.js +0 -60
- package/dist/agent-core/sdk/agent.d.ts +0 -11
- package/dist/agent-core/sdk/agent.js +0 -474
- package/dist/agent-core/sdk/extension-agents.d.ts +0 -9
- package/dist/agent-core/sdk/extension-agents.js +0 -58
- package/dist/agent-core/sdk/extension-models.d.ts +0 -13
- package/dist/agent-core/sdk/extension-models.js +0 -137
- package/dist/agent-core/sdk/extension-session.d.ts +0 -30
- package/dist/agent-core/sdk/extension-session.js +0 -105
- package/dist/agent-core/sdk/extension-tools.d.ts +0 -16
- package/dist/agent-core/sdk/extension-tools.js +0 -126
- package/dist/agent-core/sdk/model-runtime.d.ts +0 -18
- package/dist/agent-core/sdk/model-runtime.js +0 -93
- package/dist/agent-core/sdk/native-steer.d.ts +0 -20
- package/dist/agent-core/sdk/native-steer.js +0 -84
- package/dist/agent-core/sdk/request-preparation.d.ts +0 -7
- package/dist/agent-core/sdk/resource-input.d.ts +0 -32
- package/dist/agent-core/sdk/resource-input.js +0 -403
- package/dist/agent-core/sdk/session.d.ts +0 -94
- package/dist/agent-core/sdk/session.js +0 -2377
- package/dist/agent-core/sdk/subagent-backend.d.ts +0 -3
- package/dist/agent-core/sdk/subagent-backend.js +0 -49
- package/dist/agent-core/sdk/types.d.ts +0 -81
- package/dist/agent-core/session/catalog.d.ts +0 -99
- package/dist/agent-core/session/catalog.js +0 -200
- package/dist/agent-core/session/context-gc-checkpoint.d.ts +0 -165
- package/dist/agent-core/session/context-gc-checkpoint.js +0 -935
- package/dist/agent-core/session/context-gc-observations.d.ts +0 -60
- package/dist/agent-core/session/context-gc-observations.js +0 -187
- package/dist/agent-core/session/context-gc-replacements.d.ts +0 -62
- package/dist/agent-core/session/context-gc-subagent.d.ts +0 -53
- package/dist/agent-core/session/deferred-input.d.ts +0 -5
- package/dist/agent-core/session/deferred-input.js +0 -74
- package/dist/agent-core/session/inline-media.d.ts +0 -45
- package/dist/agent-core/session/inline-media.js +0 -163
- package/dist/agent-core/session/rollback.d.ts +0 -13
- package/dist/agent-core/session/rollback.js +0 -46
- package/dist/agent-core/session/store/contracts.d.ts +0 -158
- package/dist/agent-core/session/store/current-state.d.ts +0 -17
- package/dist/agent-core/session/store/current-state.js +0 -53
- package/dist/agent-core/session/store/directory-index.d.ts +0 -18
- package/dist/agent-core/session/store/directory-index.js +0 -169
- package/dist/agent-core/session/store/execution-state.d.ts +0 -18
- package/dist/agent-core/session/store/execution-state.js +0 -175
- package/dist/agent-core/session/store/history.d.ts +0 -25
- package/dist/agent-core/session/store/history.js +0 -181
- package/dist/agent-core/session/store/images.d.ts +0 -19
- package/dist/agent-core/session/store/images.js +0 -110
- package/dist/agent-core/session/store/index.d.ts +0 -4
- package/dist/agent-core/session/store/index.js +0 -2
- package/dist/agent-core/session/store/jsonl-store.d.ts +0 -171
- package/dist/agent-core/session/store/jsonl-store.js +0 -2078
- package/dist/agent-core/session/store/records.d.ts +0 -23
- package/dist/agent-core/session/store/records.js +0 -261
- package/dist/agent-core/session/store/resources.d.ts +0 -26
- package/dist/agent-core/session/store/resources.js +0 -197
- package/dist/agent-core/session/store/types.d.ts +0 -82
- package/dist/agent-core/session/tool-result-resources.d.ts +0 -26
- package/dist/agent-core/session/tool-result-resources.js +0 -256
- package/dist/agent-core/session/transaction-recovery.d.ts +0 -16
- package/dist/agent-core/session/transaction-recovery.js +0 -135
- package/dist/agent-core/storage/file-lock.js +0 -83
- package/dist/agent-core/subagent/contracts.d.ts +0 -117
- package/dist/agent-core/subagent/model-update.js +0 -81
- package/dist/agent-core/subagent/scheduler.d.ts +0 -135
- package/dist/agent-core/subagent/scheduler.js +0 -369
- package/dist/agent-core/subagent/session-controller.d.ts +0 -138
- package/dist/agent-core/subagent/session-controller.js +0 -1594
- package/dist/agent-core/subagent/wait.d.ts +0 -14
- package/dist/agent-core/subagent/wait.js +0 -32
- package/dist/agent-core/tools/agent/agent-cancel.d.ts +0 -7
- package/dist/agent-core/tools/agent/agent-cancel.js +0 -29
- package/dist/agent-core/tools/agent/agent-message.d.ts +0 -7
- package/dist/agent-core/tools/agent/agent-message.js +0 -57
- package/dist/agent-core/tools/agent/agent-start.d.ts +0 -12
- package/dist/agent-core/tools/agent/agent-start.js +0 -106
- package/dist/agent-core/tools/agent/agent-wait.d.ts +0 -7
- package/dist/agent-core/tools/agent/agent-wait.js +0 -91
- package/dist/agent-core/tools/agent/question.d.ts +0 -7
- package/dist/agent-core/tools/agent/question.js +0 -125
- package/dist/agent-core/tools/agent/skill.d.ts +0 -11
- package/dist/agent-core/tools/agent/skill.js +0 -38
- package/dist/agent-core/tools/agent/sleep.d.ts +0 -12
- package/dist/agent-core/tools/agent/sleep.js +0 -54
- package/dist/agent-core/tools/agent/smart-compact.d.ts +0 -9
- package/dist/agent-core/tools/agent/smart-compact.js +0 -23
- package/dist/agent-core/tools/agent/todo-read.d.ts +0 -14
- package/dist/agent-core/tools/agent/todo-write.d.ts +0 -14
- package/dist/agent-core/tools/agent/todo-write.js +0 -66
- package/dist/agent-core/tools/agent/todo.d.ts +0 -26
- package/dist/agent-core/tools/agent/todo.js +0 -60
- package/dist/agent-core/tools/callers.d.ts +0 -6
- package/dist/agent-core/tools/callers.js +0 -39
- package/dist/agent-core/tools/code-mode/cells.d.ts +0 -29
- package/dist/agent-core/tools/code-mode/cells.js +0 -337
- package/dist/agent-core/tools/code-mode/dispatch.d.ts +0 -20
- package/dist/agent-core/tools/code-mode/dispatch.js +0 -80
- package/dist/agent-core/tools/code-mode/engine.d.ts +0 -60
- package/dist/agent-core/tools/code-mode/index.d.ts +0 -29
- package/dist/agent-core/tools/code-mode/index.js +0 -749
- package/dist/agent-core/tools/code-mode/observations.d.ts +0 -98
- package/dist/agent-core/tools/code-mode/observations.js +0 -228
- package/dist/agent-core/tools/code-mode/state.d.ts +0 -9
- package/dist/agent-core/tools/code-mode/state.js +0 -82
- package/dist/agent-core/tools/contracts.d.ts +0 -211
- package/dist/agent-core/tools/definition-projection.d.ts +0 -7
- package/dist/agent-core/tools/definition-projection.js +0 -26
- package/dist/agent-core/tools/execution-limits.d.ts +0 -69
- package/dist/agent-core/tools/execution-limits.js +0 -69
- package/dist/agent-core/tools/execution.d.ts +0 -46
- package/dist/agent-core/tools/execution.js +0 -191
- package/dist/agent-core/tools/local/apply-patch-parser.js +0 -177
- package/dist/agent-core/tools/local/apply-patch.d.ts +0 -19
- package/dist/agent-core/tools/local/apply-patch.js +0 -489
- package/dist/agent-core/tools/local/exec.d.ts +0 -53
- package/dist/agent-core/tools/local/exec.js +0 -877
- package/dist/agent-core/tools/local/image-processing.js +0 -146
- package/dist/agent-core/tools/local/read-context.js +0 -152
- package/dist/agent-core/tools/local/read.d.ts +0 -43
- package/dist/agent-core/tools/local/read.js +0 -470
- package/dist/agent-core/tools/local/registry.d.ts +0 -34
- package/dist/agent-core/tools/local/registry.js +0 -132
- package/dist/agent-core/tools/local/view-image.d.ts +0 -15
- package/dist/agent-core/tools/local/view-image.js +0 -317
- package/dist/agent-core/tools/local/workspace-tools.d.ts +0 -12
- package/dist/agent-core/tools/local/workspace-tools.js +0 -28
- package/dist/agent-core/tools/mcp/catalog.js +0 -220
- package/dist/agent-core/tools/mcp/history.d.ts +0 -4
- package/dist/agent-core/tools/mcp/tool-search.d.ts +0 -45
- package/dist/agent-core/tools/mcp/tool-search.js +0 -294
- package/dist/agent-core/tools/output-projection.d.ts +0 -18
- package/dist/agent-core/tools/output-projection.js +0 -341
- package/dist/agent-core/tools/permissions.d.ts +0 -85
- package/dist/agent-core/tools/permissions.js +0 -237
- package/dist/agent-core/tools/registry.d.ts +0 -7
- package/dist/agent-core/tools/result-extensions.d.ts +0 -46
- package/dist/agent-core/tools/result-extensions.js +0 -134
- package/dist/agent-core/tools/runtime-context.d.ts +0 -74
- package/dist/agent-core/tools/runtime-resource-handles.js +0 -28
- package/dist/agent-core/tools/runtime.js +0 -77
- package/dist/agent-core/tools/scheduler.d.ts +0 -12
- package/dist/agent-core/tools/shared/path-resolver.js +0 -133
- package/dist/agent-core/tools/wait.js +0 -82
- /package/dist/{agent-core/extensions/models.js → extensions/capabilities.js} +0 -0
- /package/dist/{agent-core/extensions → extensions}/compaction.js +0 -0
- /package/dist/{agent-core/model → extensions}/contracts.js +0 -0
- /package/dist/{agent-core/extensions → extensions}/hooks.js +0 -0
- /package/dist/{agent-core/runtime/context/contracts.js → extensions/host-ports.js} +0 -0
- /package/dist/{agent-core/extensions → extensions}/operation.js +0 -0
- /package/dist/{agent-core/runtime/contracts.js → extensions/tool-runtime.js} +0 -0
- /package/dist/{agent-core/extensions/contracts.js → extensions.js} +0 -0
- /package/dist/{agent-core/runtime/events.js → host/description.js} +0 -0
- /package/dist/{agent-core/host → host}/local-session-environment.js +0 -0
- /package/dist/{agent-core/host → host}/local-shell.js +0 -0
- /package/dist/{agent-core/runtime/execution-handle.js → host/skill-contract.js} +0 -0
- /package/dist/{agent-core/model → model}/anthropic-thinking.d.ts +0 -0
- /package/dist/{agent-core/model → model}/attempt-diagnostics.d.ts +0 -0
- /package/dist/{agent-core/model → model}/attempt-diagnostics.js +0 -0
- /package/dist/{agent-core/session/store → model}/contracts.js +0 -0
- /package/dist/{agent-core/sdk/types.js → model/image-contract.js} +0 -0
- /package/dist/{agent-core/model → model}/image.js +0 -0
- /package/dist/{agent-core/model → model}/native-context.d.ts +0 -0
- /package/dist/{agent-core/model → model}/native-context.js +0 -0
- /package/dist/{agent-core/model → model}/recovery.d.ts +0 -0
- /package/dist/{agent-core/model → model}/sse.d.ts +0 -0
- /package/dist/{agent-core/model → model}/text-blocks.d.ts +0 -0
- /package/dist/{agent-core/model → model}/tool-declarations.js +0 -0
- /package/dist/{agent-core/model → model}/tool-input.d.ts +0 -0
- /package/dist/{agent-core/model → model}/tool-input.js +0 -0
- /package/dist/{agent-core/model → model}/usage-observer.js +0 -0
- /package/dist/{agent-core/session/store/types.js → model/usage.js} +0 -0
- /package/dist/{agent-core/subagent → process}/contracts.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/compact.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/compact.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/core.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/core.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/markup.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/markup.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/modes.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/modes.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/output.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/output.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/permissions.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/permissions.js +0 -0
- /package/dist/{agent-core/tools/local → prompts}/read-context.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/resources.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/resources.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/subagent.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/subagent.js +0 -0
- /package/dist/{agent-core/prompts → prompts}/workflow.d.ts +0 -0
- /package/dist/{agent-core/prompts → prompts}/workflow.js +0 -0
- /package/dist/{agent-core/runtime → runtime}/async-queue.d.ts +0 -0
- /package/dist/{agent-core/runtime → runtime}/async-queue.js +0 -0
- /package/dist/{agent-core/tools → runtime/compaction}/contracts.js +0 -0
- /package/dist/{agent-core/runtime → runtime}/compaction/coordinator.d.ts +0 -0
- /package/dist/{agent-core/runtime → runtime}/compaction/history.js +0 -0
- /package/dist/{agent-core/runtime → runtime}/context/contracts.d.ts +0 -0
- /package/dist/{agent-core/session/types.js → runtime/context/contracts.js} +0 -0
- /package/dist/{agent-core/runtime → runtime}/context/environment.js +0 -0
- /package/dist/{agent-core/tools/code-mode/engine.js → runtime/context/gc-contracts.js} +0 -0
- /package/dist/{agent-core/runtime → runtime}/context/gc-runtime.js +0 -0
- /package/dist/{agent-core/runtime → runtime}/context/normalize.js +0 -0
- /package/dist/{agent-core/tools/code-mode/worker.d.ts → runtime/contracts.js} +0 -0
- /package/dist/{agent-core/tools/runtime-context.js → runtime/events.js} +0 -0
- /package/dist/{agent-core/runtime → runtime}/execution-policy.d.ts +0 -0
- /package/dist/{agent-core/runtime → runtime}/execution-policy.js +0 -0
- /package/dist/{agent-core/runtime → runtime}/model-generation-timing.d.ts +0 -0
- /package/dist/{agent-core/runtime → runtime}/model-generation-timing.js +0 -0
- /package/dist/{agent-core/runtime → runtime}/model-progress.d.ts +0 -0
- /package/dist/{agent-core/runtime → runtime}/plan-output.d.ts +0 -0
- /package/dist/{agent-core/runtime → runtime}/plan-output.js +0 -0
- /package/dist/{agent-core/tools/public-metadata.d.ts → runtime/public-tool-metadata.d.ts} +0 -0
- /package/dist/{agent-core/tools/public-metadata.js → runtime/public-tool-metadata.js} +0 -0
- /package/dist/{agent-core/runtime → runtime}/token-budget.d.ts +0 -0
- /package/dist/{agent-core/runtime → runtime}/token-budget.js +0 -0
- /package/dist/{agent-core/tools → runtime}/wait.d.ts +0 -0
- /package/dist/{agent-core/sdk → sdk}/request-preparation.js +0 -0
- /package/dist/{agent-core/session → session}/context-gc-markup.d.ts +0 -0
- /package/dist/{agent-core/session → session}/context-gc-markup.js +0 -0
- /package/dist/{agent-core/session → session}/context-gc-replacements.js +0 -0
- /package/dist/{agent-core/session → session}/context-gc-subagent.js +0 -0
- /package/dist/{agent-core/session → session}/types.d.ts +0 -0
- /package/dist/{agent-core/storage → storage}/file-lock.d.ts +0 -0
- /package/dist/{agent-core/subagent → subagent}/model-update.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/agent/todo-read.js +0 -0
- /package/dist/{agent-core/tools → tools}/code-mode/quickjs-engine.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/code-mode/quickjs-engine.js +0 -0
- /package/dist/{agent-core/tools → tools}/code-mode/text-output.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/code-mode/text-output.js +0 -0
- /package/dist/{agent-core/tools → tools}/code-mode/worker.js +0 -0
- /package/dist/{agent-core/tools → tools}/file-change-diff.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/file-change-diff.js +0 -0
- /package/dist/{agent-core/tools → tools}/input-diagnostics/source-preview.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/input-diagnostics/source-preview.js +0 -0
- /package/dist/{agent-core/tools → tools}/input.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/input.js +0 -0
- /package/dist/{agent-core/tools → tools}/local/apply-patch-parser.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/local/image-processing.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/mcp/catalog.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/mcp/history.js +0 -0
- /package/dist/{agent-core/tools → tools}/registry.js +0 -0
- /package/dist/{agent-core/tools → tools}/runtime-resource-handles.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/runtime.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/scheduler.js +0 -0
- /package/dist/{agent-core/tools → tools}/shared/patch-result.d.ts +0 -0
- /package/dist/{agent-core/tools → tools}/shared/patch-result.js +0 -0
- /package/dist/{agent-core/tools → tools}/shared/path-resolver.d.ts +0 -0
|
@@ -1,935 +0,0 @@
|
|
|
1
|
-
import { posix, win32 } from 'node:path';
|
|
2
|
-
import { isDeepStrictEqual } from 'node:util';
|
|
3
|
-
import { inlineMediaGcAnchored, parseInlineMediaGc } from './inline-media.js';
|
|
4
|
-
import { codeCallEvidence, codePartialPatchCallEvidence, callsFromRecord, codeObservationEvidence, observationsFromRecord, retainedCodeInputs } from './context-gc-observations.js';
|
|
5
|
-
import { parseReadContextOutput } from '../tools/local/read-context.js';
|
|
6
|
-
import { codeCellCompletionSequence, contextGcApplyPatchInputReplacement, contextGcCodeModeInputReplacement, contextGcCodeModeOutputReplacement, contextGcExecInputReplacement, contextGcExecOutputReplacement, contextGcPatchResultFromCompletedPayload, contextGcPatchResultFromFailedPayload, contextGcStaleReadReplacement, contextGcWebOutputReplacement, normalizeContextGcCodeModeInput, normalizeContextGcExecResult } from './context-gc-replacements.js';
|
|
7
|
-
import { contextGcSubagentNeedsRetainedPriorFinal, contextGcSubagentOutputReplacement, contextGcSubagentSnapshotIsPreciselyCovered, contextGcSubagentSnapshotIsSuperseded, normalizeContextGcSubagentSnapshot } from './context-gc-subagent.js';
|
|
8
|
-
export const CONTEXT_GC_CHECKPOINT_VERSION = 1;
|
|
9
|
-
export const CONTEXT_GC_MAX_TARGETS = 4_096;
|
|
10
|
-
/** Disposable memoization for one evaluation's immutable record snapshot. */
|
|
11
|
-
export class ContextGcCheckpointCache {
|
|
12
|
-
#snapshot;
|
|
13
|
-
read(records, boundarySequence = records.at(-1)?.sequence ?? 0) {
|
|
14
|
-
const cached = this.#snapshot;
|
|
15
|
-
if (cached?.records === records && cached.boundarySequence === boundarySequence)
|
|
16
|
-
return cached.value;
|
|
17
|
-
const value = latestValidContextGcCheckpoint(records, boundarySequence);
|
|
18
|
-
this.#snapshot = { records, boundarySequence, value };
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export function contextGcMinimumUsageGrowth(contextWindowTokens) {
|
|
23
|
-
return Math.max(2_000, Math.floor(contextWindowTokens * 0.05));
|
|
24
|
-
}
|
|
25
|
-
/** Compare adjacent checkpoint triggers only within the same model/window scope. */
|
|
26
|
-
export function contextGcCheckpointIntervalEligible(trigger, previous) {
|
|
27
|
-
if (!previous ||
|
|
28
|
-
trigger.modelId !== previous.modelId ||
|
|
29
|
-
trigger.contextWindowTokens !== previous.contextWindowTokens)
|
|
30
|
-
return true;
|
|
31
|
-
return (trigger.normalRolloutOrdinal - previous.normalRolloutOrdinal >= 2 &&
|
|
32
|
-
trigger.contextInputTokens - previous.contextInputTokens >=
|
|
33
|
-
contextGcMinimumUsageGrowth(trigger.contextWindowTokens));
|
|
34
|
-
}
|
|
35
|
-
export function contextGcLogicalPathKey(path, workspace, platform) {
|
|
36
|
-
if (!path || !workspace || path.includes('\0') || workspace.includes('\0'))
|
|
37
|
-
return undefined;
|
|
38
|
-
const windows = platform === 'win32' ||
|
|
39
|
-
(platform === undefined &&
|
|
40
|
-
(/^[a-zA-Z]:[\\/]/u.test(workspace) || /^[\\/]{2}/u.test(workspace)));
|
|
41
|
-
if (windows) {
|
|
42
|
-
const root = win32.resolve(workspace.replaceAll('/', '\\'));
|
|
43
|
-
const resolved = win32.resolve(root, path.replaceAll('/', '\\'));
|
|
44
|
-
const relative = win32.relative(root, resolved);
|
|
45
|
-
if (relative === '..' || relative.startsWith(`..${win32.sep}`) || win32.isAbsolute(relative))
|
|
46
|
-
return undefined;
|
|
47
|
-
return resolved.replaceAll('\\', '/').toLowerCase();
|
|
48
|
-
}
|
|
49
|
-
const root = posix.resolve(workspace);
|
|
50
|
-
const resolved = posix.resolve(root, path);
|
|
51
|
-
const relative = posix.relative(root, resolved);
|
|
52
|
-
if (relative === '..' || relative.startsWith('../') || posix.isAbsolute(relative))
|
|
53
|
-
return undefined;
|
|
54
|
-
return resolved;
|
|
55
|
-
}
|
|
56
|
-
export function contextGcTargetKey(target) {
|
|
57
|
-
// Tool outputs are identified by their record/call and observation, not optional tool-name metadata.
|
|
58
|
-
return `${target.sequence}:${target.recordId}:${target.role}:${target.callId ?? ''}:${target.role === 'tool' ? '' : (target.toolName ?? '')}${target.observationId ? `:${target.observationId}` : ''}`;
|
|
59
|
-
}
|
|
60
|
-
export function contextGcReplacementKey(replacement) {
|
|
61
|
-
return contextGcTargetKey(replacement.target);
|
|
62
|
-
}
|
|
63
|
-
export function contextGcBaseFromRecords(records, boundarySequence = records.at(-1)?.sequence ?? 0) {
|
|
64
|
-
const compact = records.findLast((record) => record.sequence <= boundarySequence &&
|
|
65
|
-
record.type === 'compact.completed' &&
|
|
66
|
-
isNonemptyString(record.payload?.summary));
|
|
67
|
-
if (compact)
|
|
68
|
-
return { type: 'COMPACT', sequence: compact.sequence, recordId: compact.recordId };
|
|
69
|
-
const first = records.find((record) => record.sequence <= boundarySequence && record.type === 'session.created');
|
|
70
|
-
return first ? { type: 'SESSION_START', firstSequence: first.sequence } : undefined;
|
|
71
|
-
}
|
|
72
|
-
export function contextGcBaseSequence(base) {
|
|
73
|
-
return base.type === 'COMPACT' ? base.sequence : base.firstSequence;
|
|
74
|
-
}
|
|
75
|
-
export function normalizeContextGcReplacements(replacements) {
|
|
76
|
-
const normalized = new Map();
|
|
77
|
-
const readItems = new Map();
|
|
78
|
-
for (const replacement of replacements) {
|
|
79
|
-
if (!isContextGcReplacement(replacement))
|
|
80
|
-
return undefined;
|
|
81
|
-
const value = structuredClone(replacement);
|
|
82
|
-
const key = contextGcReplacementKey(value);
|
|
83
|
-
if (value.kind === 'READ_OUTPUT_ITEMS') {
|
|
84
|
-
const items = normalized.get(key)?.kind === 'READ_OUTPUT_ITEMS'
|
|
85
|
-
? readItems.get(key)
|
|
86
|
-
: new Map();
|
|
87
|
-
for (const item of value.items)
|
|
88
|
-
items.set(item.index, item);
|
|
89
|
-
readItems.set(key, items);
|
|
90
|
-
}
|
|
91
|
-
normalized.set(key, value);
|
|
92
|
-
}
|
|
93
|
-
const values = [...normalized].map(([key, value]) => {
|
|
94
|
-
if (value.kind !== 'READ_OUTPUT_ITEMS')
|
|
95
|
-
return value;
|
|
96
|
-
const items = [...readItems.get(key).values()];
|
|
97
|
-
return {
|
|
98
|
-
...value,
|
|
99
|
-
items,
|
|
100
|
-
evidenceSequences: [...new Set(items.map((item) => item.evidenceSequence))]
|
|
101
|
-
};
|
|
102
|
-
});
|
|
103
|
-
const targets = new Set(values.flatMap((replacement) => [
|
|
104
|
-
contextGcTargetKey(replacement.target),
|
|
105
|
-
...(replacement.kind === 'TOOL_CALL_INPUT'
|
|
106
|
-
? replacement.providerAliasTargets.map(contextGcTargetKey)
|
|
107
|
-
: [])
|
|
108
|
-
]));
|
|
109
|
-
if (targets.size > CONTEXT_GC_MAX_TARGETS)
|
|
110
|
-
return undefined;
|
|
111
|
-
return values.sort((left, right) => left.target.sequence - right.target.sequence ||
|
|
112
|
-
contextGcReplacementKey(left).localeCompare(contextGcReplacementKey(right)));
|
|
113
|
-
}
|
|
114
|
-
export function parseContextGcCheckpoint(record) {
|
|
115
|
-
if (record?.type !== 'context.gc.completed' || !isRecord(record.payload))
|
|
116
|
-
return undefined;
|
|
117
|
-
const payload = record.payload;
|
|
118
|
-
if (payload.version !== CONTEXT_GC_CHECKPOINT_VERSION ||
|
|
119
|
-
!isNonemptyString(payload.checkpointId) ||
|
|
120
|
-
!isPositiveInteger(payload.generation) ||
|
|
121
|
-
!isContextGcBase(payload.base) ||
|
|
122
|
-
!isPositiveInteger(payload.boundarySequence) ||
|
|
123
|
-
!Array.isArray(payload.replacements) ||
|
|
124
|
-
(payload.replacements.length === 0 && payload.inlineMedia === undefined) ||
|
|
125
|
-
!isContextGcTrigger(payload.trigger) ||
|
|
126
|
-
!isContextGcEconomicsPolicy(payload.economics) ||
|
|
127
|
-
!isContextGcMetrics(payload.metrics) ||
|
|
128
|
-
(payload.inlineMedia !== undefined && !parseInlineMediaGc(payload.inlineMedia)))
|
|
129
|
-
return undefined;
|
|
130
|
-
const replacements = normalizeContextGcReplacements(payload.replacements);
|
|
131
|
-
if (!replacements || replacements.length !== payload.replacements.length)
|
|
132
|
-
return undefined;
|
|
133
|
-
return {
|
|
134
|
-
version: 1,
|
|
135
|
-
checkpointId: payload.checkpointId,
|
|
136
|
-
generation: payload.generation,
|
|
137
|
-
base: structuredClone(payload.base),
|
|
138
|
-
boundarySequence: payload.boundarySequence,
|
|
139
|
-
replacements,
|
|
140
|
-
trigger: structuredClone(payload.trigger),
|
|
141
|
-
economics: structuredClone(payload.economics),
|
|
142
|
-
metrics: structuredClone(payload.metrics),
|
|
143
|
-
...(payload.inlineMedia === undefined
|
|
144
|
-
? {}
|
|
145
|
-
: { inlineMedia: parseInlineMediaGc(payload.inlineMedia) })
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
export function validateContextGcCheckpoint(records, record, workspace = sessionWorkspace(records), committedReplacements = []) {
|
|
149
|
-
const payload = parseContextGcCheckpoint(record);
|
|
150
|
-
if (!payload || payload.boundarySequence >= record.sequence)
|
|
151
|
-
return undefined;
|
|
152
|
-
const base = contextGcBaseFromRecords(records, payload.boundarySequence);
|
|
153
|
-
if (!sameContextGcBase(payload.base, base))
|
|
154
|
-
return undefined;
|
|
155
|
-
const baseSequence = contextGcBaseSequence(payload.base);
|
|
156
|
-
// Later cell completion cannot retroactively authorize an earlier checkpoint.
|
|
157
|
-
records = records.filter((item) => item.sequence <= payload.boundarySequence);
|
|
158
|
-
if (payload.inlineMedia && !inlineMediaGcAnchored(records, payload.inlineMedia))
|
|
159
|
-
return undefined;
|
|
160
|
-
const recordsBySequence = new Map(records.map((item) => [item.sequence, item]));
|
|
161
|
-
if (!triggerMatchesRecords(records, recordsBySequence, payload))
|
|
162
|
-
return undefined;
|
|
163
|
-
if (payload.trigger.usageSequence === null &&
|
|
164
|
-
!isDeepStrictEqual(payload.replacements, committedReplacements))
|
|
165
|
-
return undefined;
|
|
166
|
-
const committed = new Map(committedReplacements.map((replacement) => [contextGcReplacementKey(replacement), replacement]));
|
|
167
|
-
const changed = payload.replacements.flatMap((replacement) => {
|
|
168
|
-
const previous = committed.get(contextGcReplacementKey(replacement));
|
|
169
|
-
if (isDeepStrictEqual(previous, replacement))
|
|
170
|
-
return [];
|
|
171
|
-
if (previous?.kind === 'READ_OUTPUT_ITEMS' && replacement.kind === 'READ_OUTPUT_ITEMS') {
|
|
172
|
-
const retained = new Map(previous.items.map((item) => [item.index, item]));
|
|
173
|
-
const items = replacement.items.filter((item) => !isDeepStrictEqual(retained.get(item.index), item));
|
|
174
|
-
if (items.length > 0)
|
|
175
|
-
return [
|
|
176
|
-
{
|
|
177
|
-
...replacement,
|
|
178
|
-
items,
|
|
179
|
-
evidenceSequences: [...new Set(items.map((item) => item.evidenceSequence))]
|
|
180
|
-
}
|
|
181
|
-
];
|
|
182
|
-
}
|
|
183
|
-
return [replacement];
|
|
184
|
-
});
|
|
185
|
-
const targets = payload.replacements.flatMap((replacement) => [
|
|
186
|
-
replacement.target,
|
|
187
|
-
...(replacement.kind === 'TOOL_CALL_INPUT' ? replacement.providerAliasTargets : [])
|
|
188
|
-
]);
|
|
189
|
-
if (new Set(targets.map(contextGcTargetKey)).size !== targets.length)
|
|
190
|
-
return undefined;
|
|
191
|
-
for (const replacement of changed) {
|
|
192
|
-
for (const target of [
|
|
193
|
-
replacement.target,
|
|
194
|
-
...(replacement.kind === 'TOOL_CALL_INPUT' ? replacement.providerAliasTargets : [])
|
|
195
|
-
]) {
|
|
196
|
-
const source = recordsBySequence.get(target.sequence);
|
|
197
|
-
if (!source || !targetMatchesRecord(target, source))
|
|
198
|
-
return undefined;
|
|
199
|
-
}
|
|
200
|
-
const evidence = replacement.kind === 'READ_OUTPUT_ITEMS'
|
|
201
|
-
? replacement.evidenceSequences
|
|
202
|
-
: [
|
|
203
|
-
replacement.evidenceSequence,
|
|
204
|
-
...(replacement.kind === 'SUBAGENT_OUTPUT' &&
|
|
205
|
-
replacement.retainedPriorFinal !== undefined
|
|
206
|
-
? [replacement.retainedPriorFinal.evidenceSequence]
|
|
207
|
-
: [])
|
|
208
|
-
];
|
|
209
|
-
if (evidence.some((sequence) => !isPositiveInteger(sequence) ||
|
|
210
|
-
sequence < baseSequence ||
|
|
211
|
-
sequence > payload.boundarySequence ||
|
|
212
|
-
!recordsBySequence.has(sequence)))
|
|
213
|
-
return undefined;
|
|
214
|
-
if (!replacementMatchesRecords(replacement, records, recordsBySequence, workspace, payload.trigger.platform))
|
|
215
|
-
return undefined;
|
|
216
|
-
}
|
|
217
|
-
return payload;
|
|
218
|
-
}
|
|
219
|
-
export function latestValidContextGcCheckpoint(records, boundarySequence = records.at(-1)?.sequence ?? 0) {
|
|
220
|
-
const base = contextGcBaseFromRecords(records, boundarySequence);
|
|
221
|
-
if (!base)
|
|
222
|
-
return undefined;
|
|
223
|
-
const baseSequence = contextGcBaseSequence(base);
|
|
224
|
-
// Committed local checkpoints are trusted; historical evidence is checked at commit only.
|
|
225
|
-
for (let index = records.length - 1; index >= 0; index--) {
|
|
226
|
-
const record = records[index];
|
|
227
|
-
if (record.sequence < baseSequence)
|
|
228
|
-
break;
|
|
229
|
-
if (record.sequence > boundarySequence || record.type !== 'context.gc.completed')
|
|
230
|
-
continue;
|
|
231
|
-
const payload = parseContextGcCheckpoint(record);
|
|
232
|
-
if (payload &&
|
|
233
|
-
payload.boundarySequence >= baseSequence &&
|
|
234
|
-
payload.boundarySequence < record.sequence &&
|
|
235
|
-
sameContextGcBase(payload.base, base))
|
|
236
|
-
return { record, payload };
|
|
237
|
-
}
|
|
238
|
-
return undefined;
|
|
239
|
-
}
|
|
240
|
-
export function sameContextGcBase(left, right) {
|
|
241
|
-
if (!left || !right || left.type !== right.type)
|
|
242
|
-
return false;
|
|
243
|
-
return left.type === 'SESSION_START'
|
|
244
|
-
? left.firstSequence ===
|
|
245
|
-
right.firstSequence
|
|
246
|
-
: left.sequence === right.sequence &&
|
|
247
|
-
left.recordId === right.recordId;
|
|
248
|
-
}
|
|
249
|
-
function targetMatchesRecord(target, record) {
|
|
250
|
-
if (record.type !== 'model.context' ||
|
|
251
|
-
record.recordId !== target.recordId ||
|
|
252
|
-
!isRecord(record.payload) ||
|
|
253
|
-
record.payload.role !== target.role)
|
|
254
|
-
return false;
|
|
255
|
-
const messageCallId = modelContextCallId(record.payload);
|
|
256
|
-
const messageToolName = modelContextToolName(record.payload);
|
|
257
|
-
return ((target.callId === undefined || target.callId === messageCallId) &&
|
|
258
|
-
(target.observationId === undefined ||
|
|
259
|
-
observationsFromRecord(record)?.some((value) => value.id === target.observationId) ===
|
|
260
|
-
true) &&
|
|
261
|
-
(target.toolName === undefined || target.toolName === messageToolName));
|
|
262
|
-
}
|
|
263
|
-
/** A checkpoint draft is valid only when its replacements match the source records and evidence. */
|
|
264
|
-
function replacementMatchesRecords(replacement, records, recordsBySequence, workspace, platform) {
|
|
265
|
-
let source = recordsBySequence.get(replacement.target.sequence);
|
|
266
|
-
if (!source || !isRecord(source.payload))
|
|
267
|
-
return false;
|
|
268
|
-
let sourceToolSequence = source.sequence;
|
|
269
|
-
if (replacement.target.observationId) {
|
|
270
|
-
const selected = observationsFromRecord(source)?.find((value) => value.id === replacement.target.observationId);
|
|
271
|
-
if (!selected)
|
|
272
|
-
return false;
|
|
273
|
-
if (selected.type === 'tool_result') {
|
|
274
|
-
const evidence = codeObservationEvidence(records, source, selected);
|
|
275
|
-
if (!evidence)
|
|
276
|
-
return false;
|
|
277
|
-
sourceToolSequence = evidence.completed.sequence;
|
|
278
|
-
source = {
|
|
279
|
-
...source,
|
|
280
|
-
payload: {
|
|
281
|
-
...source.payload,
|
|
282
|
-
callId: selected.source.callId,
|
|
283
|
-
content: selected.result.content
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
else
|
|
288
|
-
source = { ...source, payload: { ...source.payload, content: selected.value } };
|
|
289
|
-
recordsBySequence = new Map(recordsBySequence).set(source.sequence, source);
|
|
290
|
-
}
|
|
291
|
-
if (!isRecord(source.payload))
|
|
292
|
-
return false;
|
|
293
|
-
if (replacement.kind === 'READ_OUTPUT_ITEMS') {
|
|
294
|
-
if (!workspace || toolNameForCallId(records, replacement.callId, source.sequence) !== 'read')
|
|
295
|
-
return false;
|
|
296
|
-
const parsed = typeof source.payload.content === 'string'
|
|
297
|
-
? parseReadContextOutput(source.payload.content)
|
|
298
|
-
: undefined;
|
|
299
|
-
if (!parsed)
|
|
300
|
-
return false;
|
|
301
|
-
const originalItems = new Map(parsed.items.map((item) => [item.index, item]));
|
|
302
|
-
return replacement.items.every((item) => {
|
|
303
|
-
const original = originalItems.get(item.index);
|
|
304
|
-
const evidence = appliedPatchEvidenceForPath(records, recordsBySequence, item.evidenceSequence, item.path, workspace, platform, sourceToolSequence, item.supersededByCallId);
|
|
305
|
-
return (original?.pathTruncated === false &&
|
|
306
|
-
original?.path === item.path &&
|
|
307
|
-
evidence !== undefined &&
|
|
308
|
-
item.replacement ===
|
|
309
|
-
contextGcStaleReadReplacement({
|
|
310
|
-
path: item.path,
|
|
311
|
-
content: original.content,
|
|
312
|
-
operation: evidence.file.operation
|
|
313
|
-
}));
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
if (replacement.kind === 'TOOL_CALL_INPUT' && replacement.toolName === 'apply_patch') {
|
|
317
|
-
const evidence = successfulToolEvidence(records, recordsBySequence, replacement.evidenceSequence, 'apply_patch');
|
|
318
|
-
const result = contextGcPatchResultFromCompletedPayload(evidence?.completed.payload);
|
|
319
|
-
return (evidence?.callId === replacement.callId &&
|
|
320
|
-
evidence.call.sequence === replacement.target.sequence &&
|
|
321
|
-
result !== undefined &&
|
|
322
|
-
isDeepStrictEqual(replacement.replacementArguments, contextGcApplyPatchInputReplacement(source.payload.arguments, result)));
|
|
323
|
-
}
|
|
324
|
-
if (replacement.kind === 'TOOL_CALL_INPUT' && replacement.toolName === 'code_exec') {
|
|
325
|
-
const evidence = successfulToolEvidence(records, recordsBySequence, replacement.evidenceSequence, replacement.toolName);
|
|
326
|
-
const input = normalizeContextGcCodeModeInput(source.payload.arguments);
|
|
327
|
-
return (evidence?.callId === replacement.callId &&
|
|
328
|
-
codeCellCompletionSequence(records, evidence.completed) !== undefined &&
|
|
329
|
-
evidence.call.sequence === replacement.target.sequence &&
|
|
330
|
-
input !== undefined &&
|
|
331
|
-
isDeepStrictEqual(replacement.replacementArguments, contextGcCodeModeInputReplacement(input, observationsFromRecord(evidence.result)
|
|
332
|
-
? retainedCodeInputs(records, replacement.callId)
|
|
333
|
-
: [])));
|
|
334
|
-
}
|
|
335
|
-
if (replacement.kind === 'CODE_MODE_OUTPUT') {
|
|
336
|
-
const evidence = ['code_exec', 'code_exec_wait']
|
|
337
|
-
.map((name) => successfulToolEvidence(records, recordsBySequence, replacement.evidenceSequence, name))
|
|
338
|
-
.find((item) => item !== undefined);
|
|
339
|
-
return (evidence?.callId === replacement.callId &&
|
|
340
|
-
codeCellCompletionSequence(records, evidence.completed) !== undefined &&
|
|
341
|
-
evidence.result.sequence === replacement.target.sequence &&
|
|
342
|
-
isRecord(evidence.result.payload) &&
|
|
343
|
-
typeof evidence.result.payload.content === 'string' &&
|
|
344
|
-
isRecord(evidence.completed.payload) &&
|
|
345
|
-
typeof evidence.completed.payload.truncated === 'boolean' &&
|
|
346
|
-
replacement.replacementContent ===
|
|
347
|
-
contextGcCodeModeOutputReplacement(source.payload.content, replacement.target.observationId
|
|
348
|
-
? observationsFromRecord(source)?.some((value) => value.id === replacement.target.observationId &&
|
|
349
|
-
value.type === 'value' &&
|
|
350
|
-
value.truncated === true) === true
|
|
351
|
-
: evidence.completed.payload.truncated));
|
|
352
|
-
}
|
|
353
|
-
if (replacement.kind === 'SUBAGENT_OUTPUT') {
|
|
354
|
-
const retainedPriorFinal = replacement.retainedPriorFinal;
|
|
355
|
-
const sourceEvidence = successfulToolEvidence(records, recordsBySequence, source.sequence, replacement.toolName);
|
|
356
|
-
const terminalEvidence = successfulToolEvidence(records, recordsBySequence, replacement.evidenceSequence, replacement.terminalToolName, replacement.terminalCallId);
|
|
357
|
-
if (!sourceEvidence ||
|
|
358
|
-
sourceEvidence.callId !== replacement.callId ||
|
|
359
|
-
!terminalEvidence ||
|
|
360
|
-
terminalEvidence.callId !== replacement.terminalCallId ||
|
|
361
|
-
!isRecord(terminalEvidence.result.payload) ||
|
|
362
|
-
!isRecord(sourceEvidence.result.payload))
|
|
363
|
-
return false;
|
|
364
|
-
let retainedPriorFinalEvidence;
|
|
365
|
-
let retainedPriorFinalSnapshot;
|
|
366
|
-
if (retainedPriorFinal !== undefined) {
|
|
367
|
-
retainedPriorFinalEvidence = successfulToolEvidence(records, recordsBySequence, retainedPriorFinal.evidenceSequence, retainedPriorFinal.toolName, retainedPriorFinal.callId);
|
|
368
|
-
if (!retainedPriorFinalEvidence ||
|
|
369
|
-
retainedPriorFinalEvidence.callId !== retainedPriorFinal.callId ||
|
|
370
|
-
!isRecord(retainedPriorFinalEvidence.result.payload))
|
|
371
|
-
return false;
|
|
372
|
-
retainedPriorFinalSnapshot = normalizeContextGcSubagentSnapshot(retainedPriorFinalEvidence.result.payload.content, retainedPriorFinalEvidence.completed.payload, retainedPriorFinal.toolName);
|
|
373
|
-
}
|
|
374
|
-
const sourceSnapshot = normalizeContextGcSubagentSnapshot(sourceEvidence.result.payload.content, sourceEvidence.completed.payload, replacement.toolName);
|
|
375
|
-
const terminalSnapshot = normalizeContextGcSubagentSnapshot(terminalEvidence.result.payload.content, terminalEvidence.completed.payload, replacement.terminalToolName);
|
|
376
|
-
return (sourceSnapshot !== undefined &&
|
|
377
|
-
terminalSnapshot !== undefined &&
|
|
378
|
-
contextGcSubagentNeedsRetainedPriorFinal(sourceSnapshot) ===
|
|
379
|
-
(retainedPriorFinal !== undefined) &&
|
|
380
|
-
(retainedPriorFinalEvidence === undefined ||
|
|
381
|
-
retainedPriorFinalEvidence.result.sequence < sourceEvidence.result.sequence) &&
|
|
382
|
-
sourceEvidence.completed.sequence < terminalEvidence.completed.sequence &&
|
|
383
|
-
(contextGcSubagentSnapshotIsSuperseded(sourceSnapshot, terminalSnapshot, retainedPriorFinalSnapshot) ||
|
|
384
|
-
contextGcSubagentSnapshotIsPreciselyCovered(sourceSnapshot, terminalSnapshot)) &&
|
|
385
|
-
replacement.replacementContent ===
|
|
386
|
-
contextGcSubagentOutputReplacement({
|
|
387
|
-
sourceContent: sourceEvidence.result.payload.content,
|
|
388
|
-
source: sourceSnapshot,
|
|
389
|
-
terminal: terminalSnapshot
|
|
390
|
-
}));
|
|
391
|
-
}
|
|
392
|
-
if (replacement.kind === 'WEB_OUTPUT') {
|
|
393
|
-
const sourceEvidence = successfulToolEvidence(records, recordsBySequence, source.sequence, replacement.toolName);
|
|
394
|
-
if (!sourceEvidence ||
|
|
395
|
-
sourceEvidence.callId !== replacement.callId ||
|
|
396
|
-
hasFailedToolEvidence(records, sourceEvidence.call, sourceEvidence.result, replacement.toolName) ||
|
|
397
|
-
!completeWebToolEvidence(sourceEvidence.completed, sourceEvidence.result) ||
|
|
398
|
-
!isRecord(sourceEvidence.result.payload) ||
|
|
399
|
-
typeof sourceEvidence.result.payload.content !== 'string' ||
|
|
400
|
-
sourceEvidence.result.sequence !== replacement.evidenceSequence ||
|
|
401
|
-
!isRecord(sourceEvidence.completed.payload) ||
|
|
402
|
-
typeof sourceEvidence.completed.payload.truncated !== 'boolean')
|
|
403
|
-
return false;
|
|
404
|
-
return (replacement.replacementContent ===
|
|
405
|
-
contextGcWebOutputReplacement(replacement.toolName, sourceEvidence.result.payload.content, sourceEvidence.completed.payload.truncated));
|
|
406
|
-
}
|
|
407
|
-
if (!isSuccessfulExecLifecycleEvidence(replacement, source, records, recordsBySequence))
|
|
408
|
-
return false;
|
|
409
|
-
if (replacement.kind === 'TOOL_CALL_INPUT')
|
|
410
|
-
return isDeepStrictEqual(replacement.replacementArguments, contextGcExecInputReplacement(source.payload.arguments, replacement.toolName));
|
|
411
|
-
const targetEvidence = successfulToolEvidence(records, recordsBySequence, source.sequence, 'exec', replacement.callId) ??
|
|
412
|
-
successfulToolEvidence(records, recordsBySequence, source.sequence, 'exec_wait', replacement.callId);
|
|
413
|
-
const result = normalizeContextGcExecResult(source.payload.content, targetEvidence?.completed.payload);
|
|
414
|
-
return (result !== undefined &&
|
|
415
|
-
replacement.replacementContent === contextGcExecOutputReplacement(result));
|
|
416
|
-
}
|
|
417
|
-
function toolNameForCallId(records, callId, beforeSequence) {
|
|
418
|
-
const call = modelToolCallForCallId(records, callId, beforeSequence);
|
|
419
|
-
return call && isRecord(call.payload) && typeof call.payload.name === 'string'
|
|
420
|
-
? call.payload.name
|
|
421
|
-
: undefined;
|
|
422
|
-
}
|
|
423
|
-
function successfulToolEvidence(records, recordsBySequence, evidenceSequence, toolName, expectedCallId) {
|
|
424
|
-
const result = recordsBySequence.get(evidenceSequence);
|
|
425
|
-
if (result?.type !== 'model.context' ||
|
|
426
|
-
!isRecord(result.payload) ||
|
|
427
|
-
result.payload.role !== 'tool' ||
|
|
428
|
-
typeof result.payload.callId !== 'string')
|
|
429
|
-
return undefined;
|
|
430
|
-
const callId = result.payload.callId;
|
|
431
|
-
const call = modelToolCallForCallId(records, callId, result.sequence);
|
|
432
|
-
if (!call ||
|
|
433
|
-
!isRecord(call.payload) ||
|
|
434
|
-
call.payload.name !== toolName ||
|
|
435
|
-
(expectedCallId && expectedCallId !== callId)) {
|
|
436
|
-
for (const observation of observationsFromRecord(result) ?? []) {
|
|
437
|
-
if (observation.type !== 'tool_result' ||
|
|
438
|
-
observation.source.toolName !== toolName ||
|
|
439
|
-
(expectedCallId && observation.source.callId !== expectedCallId))
|
|
440
|
-
continue;
|
|
441
|
-
const evidence = codeObservationEvidence(records, result, observation);
|
|
442
|
-
if (evidence)
|
|
443
|
-
return evidence;
|
|
444
|
-
}
|
|
445
|
-
for (const entry of callsFromRecord(result) ?? []) {
|
|
446
|
-
if (entry.toolName !== toolName || (expectedCallId && entry.callId !== expectedCallId))
|
|
447
|
-
continue;
|
|
448
|
-
const evidence = codeCallEvidence(records, result, entry);
|
|
449
|
-
if (evidence)
|
|
450
|
-
return evidence;
|
|
451
|
-
}
|
|
452
|
-
return undefined;
|
|
453
|
-
}
|
|
454
|
-
const completed = records.findLast((record) => record.sequence > call.sequence &&
|
|
455
|
-
record.sequence < result.sequence &&
|
|
456
|
-
record.type === 'tool.completed' &&
|
|
457
|
-
isRecord(record.payload) &&
|
|
458
|
-
record.payload.type === 'tool.completed' &&
|
|
459
|
-
record.payload.callId === callId &&
|
|
460
|
-
record.payload.toolName === toolName);
|
|
461
|
-
return completed ? { callId, call, completed, result } : undefined;
|
|
462
|
-
}
|
|
463
|
-
function completeWebToolEvidence(completed, result) {
|
|
464
|
-
return (isRecord(completed.payload) &&
|
|
465
|
-
completed.payload.type === 'tool.completed' &&
|
|
466
|
-
typeof completed.payload.truncated === 'boolean' &&
|
|
467
|
-
isRecord(result.payload) &&
|
|
468
|
-
typeof result.payload.content === 'string');
|
|
469
|
-
}
|
|
470
|
-
function hasFailedToolEvidence(records, call, result, toolName) {
|
|
471
|
-
if (!isRecord(result.payload) || typeof result.payload.callId !== 'string')
|
|
472
|
-
return true;
|
|
473
|
-
const callId = result.payload.callId;
|
|
474
|
-
return records.some((record) => record.sequence > call.sequence &&
|
|
475
|
-
record.sequence < result.sequence &&
|
|
476
|
-
record.type === 'tool.failed' &&
|
|
477
|
-
isRecord(record.payload) &&
|
|
478
|
-
record.payload.type === 'tool.failed' &&
|
|
479
|
-
record.payload.callId === callId &&
|
|
480
|
-
record.payload.toolName === toolName);
|
|
481
|
-
}
|
|
482
|
-
function modelToolCallForCallId(records, callId, beforeSequence) {
|
|
483
|
-
const direct = records.findLast((record) => record.sequence < beforeSequence &&
|
|
484
|
-
record.type === 'model.context' &&
|
|
485
|
-
isRecord(record.payload) &&
|
|
486
|
-
record.payload.role === 'tool_call' &&
|
|
487
|
-
record.payload.callId === callId);
|
|
488
|
-
if (direct)
|
|
489
|
-
return direct;
|
|
490
|
-
const started = records.findLast((record) => record.sequence < beforeSequence &&
|
|
491
|
-
record.type === 'tool.started' &&
|
|
492
|
-
isRecord(record.payload) &&
|
|
493
|
-
record.payload.callId === callId &&
|
|
494
|
-
typeof record.payload.parentCallId === 'string');
|
|
495
|
-
return started && isRecord(started.payload)
|
|
496
|
-
? {
|
|
497
|
-
...started,
|
|
498
|
-
payload: {
|
|
499
|
-
role: 'tool_call',
|
|
500
|
-
name: started.payload.toolName,
|
|
501
|
-
callId,
|
|
502
|
-
arguments: started.payload.input
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
: undefined;
|
|
506
|
-
}
|
|
507
|
-
function modelToolResultForCall(records, call, beforeSequence) {
|
|
508
|
-
if (!isRecord(call.payload) || typeof call.payload.callId !== 'string')
|
|
509
|
-
return undefined;
|
|
510
|
-
const callId = call.payload.callId;
|
|
511
|
-
return records.find((record) => record.sequence > call.sequence &&
|
|
512
|
-
record.sequence <= beforeSequence &&
|
|
513
|
-
record.type === 'model.context' &&
|
|
514
|
-
isRecord(record.payload) &&
|
|
515
|
-
record.payload.role === 'tool' &&
|
|
516
|
-
record.payload.callId === callId);
|
|
517
|
-
}
|
|
518
|
-
function partialPatchEvidence(records, recordsBySequence, evidenceSequence, expectedCallId) {
|
|
519
|
-
const result = recordsBySequence.get(evidenceSequence);
|
|
520
|
-
if (result?.type !== 'model.context' ||
|
|
521
|
-
!isRecord(result.payload) ||
|
|
522
|
-
result.payload.role !== 'tool' ||
|
|
523
|
-
typeof result.payload.callId !== 'string')
|
|
524
|
-
return undefined;
|
|
525
|
-
const callId = result.payload.callId;
|
|
526
|
-
const call = modelToolCallForCallId(records, callId, result.sequence);
|
|
527
|
-
if (!call ||
|
|
528
|
-
!isRecord(call.payload) ||
|
|
529
|
-
call.payload.name !== 'apply_patch' ||
|
|
530
|
-
(expectedCallId && callId !== expectedCallId)) {
|
|
531
|
-
for (const entry of callsFromRecord(result) ?? []) {
|
|
532
|
-
if (expectedCallId && entry.callId !== expectedCallId)
|
|
533
|
-
continue;
|
|
534
|
-
const evidence = codePartialPatchCallEvidence(records, result, entry);
|
|
535
|
-
if (evidence)
|
|
536
|
-
return evidence;
|
|
537
|
-
}
|
|
538
|
-
return undefined;
|
|
539
|
-
}
|
|
540
|
-
const failed = records.findLast((record) => record.sequence > call.sequence &&
|
|
541
|
-
record.sequence < result.sequence &&
|
|
542
|
-
record.type === 'tool.failed' &&
|
|
543
|
-
isRecord(record.payload) &&
|
|
544
|
-
record.payload.callId === callId &&
|
|
545
|
-
contextGcPatchResultFromFailedPayload(record.payload) !== undefined);
|
|
546
|
-
return failed ? { callId, call, failed, result } : undefined;
|
|
547
|
-
}
|
|
548
|
-
function appliedPatchEvidenceForPath(records, recordsBySequence, evidenceSequence, path, workspace, platform, readSequence, expectedCallId) {
|
|
549
|
-
const evidence = successfulToolEvidence(records, recordsBySequence, evidenceSequence, 'apply_patch', expectedCallId);
|
|
550
|
-
const partial = evidence
|
|
551
|
-
? undefined
|
|
552
|
-
: partialPatchEvidence(records, recordsBySequence, evidenceSequence, expectedCallId);
|
|
553
|
-
const callId = evidence?.callId ?? partial?.callId;
|
|
554
|
-
const terminalSequence = evidence?.completed.sequence ?? partial?.failed.sequence;
|
|
555
|
-
const result = evidence
|
|
556
|
-
? contextGcPatchResultFromCompletedPayload(evidence.completed.payload)
|
|
557
|
-
: contextGcPatchResultFromFailedPayload(partial?.failed.payload);
|
|
558
|
-
if (!result || !callId || terminalSequence === undefined || readSequence >= terminalSequence)
|
|
559
|
-
return undefined;
|
|
560
|
-
const expected = contextGcLogicalPathKey(path, workspace, platform);
|
|
561
|
-
if (!expected)
|
|
562
|
-
return undefined;
|
|
563
|
-
const file = result.files.find((file) => file.operation !== 'added' &&
|
|
564
|
-
contextGcLogicalPathKey(file.path, workspace, platform) === expected);
|
|
565
|
-
return file && file.operation !== 'added'
|
|
566
|
-
? { callId, file: { operation: file.operation } }
|
|
567
|
-
: undefined;
|
|
568
|
-
}
|
|
569
|
-
function isSuccessfulExecLifecycleEvidence(replacement, source, records, recordsBySequence) {
|
|
570
|
-
const expectedTerminal = replacement.kind === 'EXEC_OUTPUT' ? replacement.terminalCallId : undefined;
|
|
571
|
-
const evidence = successfulToolEvidence(records, recordsBySequence, replacement.evidenceSequence, 'exec', expectedTerminal) ??
|
|
572
|
-
successfulToolEvidence(records, recordsBySequence, replacement.evidenceSequence, 'exec_wait', expectedTerminal);
|
|
573
|
-
if (!evidence || !isRecord(evidence.call.payload) || !isRecord(evidence.result.payload))
|
|
574
|
-
return false;
|
|
575
|
-
const finalResult = normalizeContextGcExecResult(evidence.result.payload.content, evidence.completed.payload);
|
|
576
|
-
if (!finalResult || finalResult.status === 'running')
|
|
577
|
-
return false;
|
|
578
|
-
const targetCall = replacement.kind === 'TOOL_CALL_INPUT'
|
|
579
|
-
? source
|
|
580
|
-
: modelToolCallForCallId(records, replacement.callId, source.sequence);
|
|
581
|
-
if (!targetCall ||
|
|
582
|
-
targetCall.sequence > evidence.call.sequence ||
|
|
583
|
-
!isRecord(targetCall.payload) ||
|
|
584
|
-
targetCall.payload.role !== 'tool_call' ||
|
|
585
|
-
(targetCall.payload.name !== 'exec' && targetCall.payload.name !== 'exec_wait') ||
|
|
586
|
-
targetCall.payload.callId !== replacement.callId)
|
|
587
|
-
return false;
|
|
588
|
-
const targetResult = replacement.kind === 'EXEC_OUTPUT'
|
|
589
|
-
? source
|
|
590
|
-
: modelToolResultForCall(records, targetCall, evidence.result.sequence);
|
|
591
|
-
if (!targetResult)
|
|
592
|
-
return false;
|
|
593
|
-
const targetEvidence = successfulToolEvidence(records, recordsBySequence, targetResult.sequence, targetCall.payload.name, replacement.callId);
|
|
594
|
-
if (!targetEvidence || targetEvidence.call.sequence !== targetCall.sequence)
|
|
595
|
-
return false;
|
|
596
|
-
if (targetEvidence.callId === evidence.callId)
|
|
597
|
-
return targetEvidence.call.sequence === evidence.call.sequence;
|
|
598
|
-
const evidenceInput = evidence.call.payload.arguments;
|
|
599
|
-
const targetInput = targetCall.payload.arguments;
|
|
600
|
-
if (!isRecord(evidenceInput) || !isRecord(targetInput))
|
|
601
|
-
return false;
|
|
602
|
-
const evidenceProcessId = evidenceInput.processId;
|
|
603
|
-
const targetOutput = isRecord(targetResult.payload) && targetEvidence
|
|
604
|
-
? normalizeContextGcExecResult(targetResult.payload.content, targetEvidence.completed.payload)
|
|
605
|
-
: undefined;
|
|
606
|
-
const targetProcessId = typeof targetInput.processId === 'string'
|
|
607
|
-
? targetInput.processId
|
|
608
|
-
: typeof targetOutput?.processId === 'string'
|
|
609
|
-
? targetOutput.processId
|
|
610
|
-
: undefined;
|
|
611
|
-
return (typeof evidenceProcessId === 'string' &&
|
|
612
|
-
targetProcessId === evidenceProcessId &&
|
|
613
|
-
targetResult.sequence <= evidence.result.sequence);
|
|
614
|
-
}
|
|
615
|
-
function triggerMatchesRecords(records, recordsBySequence, payload) {
|
|
616
|
-
if (payload.trigger.usageSequence !== null &&
|
|
617
|
-
(payload.trigger.usageSequence < contextGcBaseSequence(payload.base) ||
|
|
618
|
-
payload.trigger.usageSequence > payload.boundarySequence))
|
|
619
|
-
return false;
|
|
620
|
-
const withoutUsage = payload.trigger.usageSequence === null;
|
|
621
|
-
if (withoutUsage &&
|
|
622
|
-
(!payload.inlineMedia ||
|
|
623
|
-
payload.inlineMedia.reason === 'TEXT_GC' ||
|
|
624
|
-
payload.metrics.stage !== 'INLINE_MEDIA' ||
|
|
625
|
-
payload.trigger.contextInputTokens !== 0))
|
|
626
|
-
return false;
|
|
627
|
-
const usageRecord = withoutUsage
|
|
628
|
-
? undefined
|
|
629
|
-
: recordsBySequence.get(payload.trigger.usageSequence);
|
|
630
|
-
if (!withoutUsage &&
|
|
631
|
-
(!usageRecord ||
|
|
632
|
-
!isRecord(usageRecord.payload) ||
|
|
633
|
-
usageRecord.payload.type !== 'usage.updated' ||
|
|
634
|
-
modelContextUsage(usageRecord.payload) !== payload.trigger.contextInputTokens))
|
|
635
|
-
return false;
|
|
636
|
-
const baseSequence = contextGcBaseSequence(payload.base);
|
|
637
|
-
let modelId;
|
|
638
|
-
let contextWindowTokens;
|
|
639
|
-
let triggerConfigurationMatches = false;
|
|
640
|
-
let latestMatchingUsageSequence;
|
|
641
|
-
let normalRolloutOrdinal = 0;
|
|
642
|
-
for (const record of records) {
|
|
643
|
-
if (record.sequence < baseSequence)
|
|
644
|
-
continue;
|
|
645
|
-
if (record.sequence > payload.boundarySequence)
|
|
646
|
-
break;
|
|
647
|
-
if ((record.type === 'execution.header' || record.type === 'compact.completed') &&
|
|
648
|
-
isRecord(record.payload)) {
|
|
649
|
-
if (typeof record.payload.modelId === 'string')
|
|
650
|
-
modelId = record.payload.modelId;
|
|
651
|
-
if (isPositiveInteger(record.payload.contextWindowTokens))
|
|
652
|
-
contextWindowTokens = record.payload.contextWindowTokens;
|
|
653
|
-
if (withoutUsage)
|
|
654
|
-
latestMatchingUsageSequence = undefined;
|
|
655
|
-
}
|
|
656
|
-
const matchingConfiguration = modelId === payload.trigger.modelId &&
|
|
657
|
-
contextWindowTokens === payload.trigger.contextWindowTokens;
|
|
658
|
-
if (record.sequence === usageRecord?.sequence || withoutUsage)
|
|
659
|
-
triggerConfigurationMatches = matchingConfiguration;
|
|
660
|
-
if (matchingConfiguration &&
|
|
661
|
-
isRecord(record.payload) &&
|
|
662
|
-
record.payload.type === 'usage.updated' &&
|
|
663
|
-
modelContextUsage(record.payload) !== undefined)
|
|
664
|
-
latestMatchingUsageSequence = record.sequence;
|
|
665
|
-
if (matchingConfiguration &&
|
|
666
|
-
record.type === 'model.attempt' &&
|
|
667
|
-
isRecord(record.payload) &&
|
|
668
|
-
record.payload.purpose === 'EXECUTION' &&
|
|
669
|
-
record.payload.state === 'SUCCEEDED')
|
|
670
|
-
normalRolloutOrdinal++;
|
|
671
|
-
}
|
|
672
|
-
return (triggerConfigurationMatches &&
|
|
673
|
-
(withoutUsage
|
|
674
|
-
? latestMatchingUsageSequence === undefined
|
|
675
|
-
: latestMatchingUsageSequence === payload.trigger.usageSequence) &&
|
|
676
|
-
normalRolloutOrdinal === payload.trigger.normalRolloutOrdinal);
|
|
677
|
-
}
|
|
678
|
-
function modelContextUsage(value) {
|
|
679
|
-
const context = value.contextInputTokens ?? value.inputTokens;
|
|
680
|
-
return isNonnegativeInteger(context) ? context : undefined;
|
|
681
|
-
}
|
|
682
|
-
function sessionWorkspace(records) {
|
|
683
|
-
const created = records.find((record) => record.type === 'session.created' && isRecord(record.payload));
|
|
684
|
-
return created && isRecord(created.payload) && isNonemptyString(created.payload.workspace)
|
|
685
|
-
? created.payload.workspace
|
|
686
|
-
: undefined;
|
|
687
|
-
}
|
|
688
|
-
function modelContextCallId(payload) {
|
|
689
|
-
if (typeof payload.callId === 'string')
|
|
690
|
-
return payload.callId;
|
|
691
|
-
if (payload.role !== 'provider' || !isRecord(payload.item))
|
|
692
|
-
return undefined;
|
|
693
|
-
const value = payload.item.call_id;
|
|
694
|
-
return typeof value === 'string' ? value : undefined;
|
|
695
|
-
}
|
|
696
|
-
function modelContextToolName(payload) {
|
|
697
|
-
if ((payload.role === 'tool_call' || payload.role === 'tool') && typeof payload.name === 'string')
|
|
698
|
-
return payload.name;
|
|
699
|
-
if (payload.role !== 'provider' || !isRecord(payload.item))
|
|
700
|
-
return undefined;
|
|
701
|
-
const value = payload.item.name;
|
|
702
|
-
return typeof value === 'string' ? value : undefined;
|
|
703
|
-
}
|
|
704
|
-
function isContextGcReplacement(value) {
|
|
705
|
-
if (!isRecord(value) ||
|
|
706
|
-
!isContextGcTarget(value.target) ||
|
|
707
|
-
!isNonemptyString(value.callId) ||
|
|
708
|
-
(value.target.callId !== value.callId && value.target.observationId === undefined))
|
|
709
|
-
return false;
|
|
710
|
-
if (value.kind === 'READ_OUTPUT_ITEMS') {
|
|
711
|
-
const items = value.items;
|
|
712
|
-
const evidenceSequences = value.evidenceSequences;
|
|
713
|
-
if (!(hasOnlyKeys(value, ['kind', 'callId', 'target', 'items', 'evidenceSequences']) &&
|
|
714
|
-
value.target.role === 'tool' &&
|
|
715
|
-
Array.isArray(items) &&
|
|
716
|
-
items.length > 0 &&
|
|
717
|
-
items.every((item) => isRecord(item) &&
|
|
718
|
-
hasOnlyKeys(item, [
|
|
719
|
-
'index',
|
|
720
|
-
'path',
|
|
721
|
-
'replacement',
|
|
722
|
-
'evidenceSequence',
|
|
723
|
-
'supersededByCallId'
|
|
724
|
-
]) &&
|
|
725
|
-
(item.supersededByCallId === undefined || isNonemptyString(item.supersededByCallId)) &&
|
|
726
|
-
isNonnegativeInteger(item.index) &&
|
|
727
|
-
isNonemptyString(item.path) &&
|
|
728
|
-
isNonemptyString(item.replacement) &&
|
|
729
|
-
isPositiveInteger(item.evidenceSequence)) &&
|
|
730
|
-
Array.isArray(evidenceSequences) &&
|
|
731
|
-
evidenceSequences.length > 0 &&
|
|
732
|
-
evidenceSequences.every(isPositiveInteger)))
|
|
733
|
-
return false;
|
|
734
|
-
const evidence = new Set(evidenceSequences);
|
|
735
|
-
const usedEvidence = new Set(items.map((item) => item.evidenceSequence));
|
|
736
|
-
return (new Set(items.map((item) => item.index)).size === items.length &&
|
|
737
|
-
evidence.size === evidenceSequences.length &&
|
|
738
|
-
usedEvidence.size === evidence.size &&
|
|
739
|
-
evidenceSequences.every((sequence) => usedEvidence.has(sequence)));
|
|
740
|
-
}
|
|
741
|
-
if (value.kind === 'TOOL_CALL_INPUT')
|
|
742
|
-
return (hasOnlyKeys(value, [
|
|
743
|
-
'kind',
|
|
744
|
-
'toolName',
|
|
745
|
-
'callId',
|
|
746
|
-
'target',
|
|
747
|
-
'replacementArguments',
|
|
748
|
-
'providerAliasTargets',
|
|
749
|
-
'evidenceSequence'
|
|
750
|
-
]) &&
|
|
751
|
-
value.target.role === 'tool_call' &&
|
|
752
|
-
(value.toolName === 'apply_patch' ||
|
|
753
|
-
value.toolName === 'exec' ||
|
|
754
|
-
value.toolName === 'exec_wait' ||
|
|
755
|
-
value.toolName === 'code_exec') &&
|
|
756
|
-
value.target.toolName === value.toolName &&
|
|
757
|
-
Array.isArray(value.providerAliasTargets) &&
|
|
758
|
-
value.providerAliasTargets.every((target) => isContextGcTarget(target) &&
|
|
759
|
-
target.role === 'provider' &&
|
|
760
|
-
target.callId === value.callId &&
|
|
761
|
-
target.toolName === value.toolName) &&
|
|
762
|
-
isPositiveInteger(value.evidenceSequence) &&
|
|
763
|
-
value.replacementArguments !== undefined);
|
|
764
|
-
if (value.kind === 'SUBAGENT_OUTPUT')
|
|
765
|
-
return (hasOnlyKeys(value, [
|
|
766
|
-
'kind',
|
|
767
|
-
'toolName',
|
|
768
|
-
'callId',
|
|
769
|
-
'target',
|
|
770
|
-
'replacementContent',
|
|
771
|
-
'terminalToolName',
|
|
772
|
-
'terminalCallId',
|
|
773
|
-
'evidenceSequence',
|
|
774
|
-
'retainedPriorFinal'
|
|
775
|
-
]) &&
|
|
776
|
-
value.target.role === 'tool' &&
|
|
777
|
-
(value.toolName === 'agent_wait' ||
|
|
778
|
-
value.toolName === 'agent_message' ||
|
|
779
|
-
value.toolName === 'agent_cancel') &&
|
|
780
|
-
(value.target.toolName === undefined || value.target.toolName === value.toolName) &&
|
|
781
|
-
isNonemptyString(value.replacementContent) &&
|
|
782
|
-
(value.terminalToolName === 'agent_start' ||
|
|
783
|
-
value.terminalToolName === 'agent_wait' ||
|
|
784
|
-
value.terminalToolName === 'agent_message' ||
|
|
785
|
-
value.terminalToolName === 'agent_cancel') &&
|
|
786
|
-
isNonemptyString(value.terminalCallId) &&
|
|
787
|
-
isPositiveInteger(value.evidenceSequence) &&
|
|
788
|
-
(value.retainedPriorFinal === undefined ||
|
|
789
|
-
(isRecord(value.retainedPriorFinal) &&
|
|
790
|
-
Object.keys(value.retainedPriorFinal).every((key) => ['toolName', 'callId', 'evidenceSequence'].includes(key)) &&
|
|
791
|
-
(value.retainedPriorFinal.toolName === 'agent_start' ||
|
|
792
|
-
value.retainedPriorFinal.toolName === 'agent_wait' ||
|
|
793
|
-
value.retainedPriorFinal.toolName === 'agent_message' ||
|
|
794
|
-
value.retainedPriorFinal.toolName === 'agent_cancel') &&
|
|
795
|
-
isNonemptyString(value.retainedPriorFinal.callId) &&
|
|
796
|
-
isPositiveInteger(value.retainedPriorFinal.evidenceSequence))));
|
|
797
|
-
if (value.kind === 'WEB_OUTPUT')
|
|
798
|
-
return (hasOnlyKeys(value, [
|
|
799
|
-
'kind',
|
|
800
|
-
'toolName',
|
|
801
|
-
'callId',
|
|
802
|
-
'target',
|
|
803
|
-
'replacementContent',
|
|
804
|
-
'evidenceSequence'
|
|
805
|
-
]) &&
|
|
806
|
-
value.target.role === 'tool' &&
|
|
807
|
-
(value.toolName === 'web_search' || value.toolName === 'web_fetch') &&
|
|
808
|
-
(value.target.toolName === undefined || value.target.toolName === value.toolName) &&
|
|
809
|
-
isNonemptyString(value.replacementContent) &&
|
|
810
|
-
isPositiveInteger(value.evidenceSequence));
|
|
811
|
-
if (value.kind === 'CODE_MODE_OUTPUT')
|
|
812
|
-
return (hasOnlyKeys(value, ['kind', 'callId', 'target', 'replacementContent', 'evidenceSequence']) &&
|
|
813
|
-
value.target.role === 'tool' &&
|
|
814
|
-
isNonemptyString(value.replacementContent) &&
|
|
815
|
-
isPositiveInteger(value.evidenceSequence));
|
|
816
|
-
return (value.kind === 'EXEC_OUTPUT' &&
|
|
817
|
-
hasOnlyKeys(value, [
|
|
818
|
-
'kind',
|
|
819
|
-
'callId',
|
|
820
|
-
'target',
|
|
821
|
-
'replacementContent',
|
|
822
|
-
'evidenceSequence',
|
|
823
|
-
'terminalCallId'
|
|
824
|
-
]) &&
|
|
825
|
-
(value.terminalCallId === undefined || isNonemptyString(value.terminalCallId)) &&
|
|
826
|
-
value.target.role === 'tool' &&
|
|
827
|
-
isNonemptyString(value.replacementContent) &&
|
|
828
|
-
isPositiveInteger(value.evidenceSequence));
|
|
829
|
-
}
|
|
830
|
-
function isContextGcTarget(value) {
|
|
831
|
-
return (isRecord(value) &&
|
|
832
|
-
hasOnlyKeys(value, ['sequence', 'recordId', 'role', 'callId', 'toolName', 'observationId']) &&
|
|
833
|
-
(value.observationId === undefined ||
|
|
834
|
-
(value.role === 'tool' && isNonemptyString(value.observationId))) &&
|
|
835
|
-
isPositiveInteger(value.sequence) &&
|
|
836
|
-
isNonemptyString(value.recordId) &&
|
|
837
|
-
(value.role === 'tool_call' || value.role === 'tool' || value.role === 'provider') &&
|
|
838
|
-
(value.callId === undefined || isNonemptyString(value.callId)) &&
|
|
839
|
-
(value.toolName === undefined || isNonemptyString(value.toolName)));
|
|
840
|
-
}
|
|
841
|
-
function isContextGcBase(value) {
|
|
842
|
-
return (isRecord(value) &&
|
|
843
|
-
((value.type === 'SESSION_START' && isPositiveInteger(value.firstSequence)) ||
|
|
844
|
-
(value.type === 'COMPACT' &&
|
|
845
|
-
isPositiveInteger(value.sequence) &&
|
|
846
|
-
isNonemptyString(value.recordId))));
|
|
847
|
-
}
|
|
848
|
-
function isContextGcTrigger(value) {
|
|
849
|
-
return (isRecord(value) &&
|
|
850
|
-
(value.usageSequence === null || isPositiveInteger(value.usageSequence)) &&
|
|
851
|
-
isNonnegativeInteger(value.contextInputTokens) &&
|
|
852
|
-
isPositiveInteger(value.contextWindowTokens) &&
|
|
853
|
-
isNonnegativeInteger(value.normalRolloutOrdinal) &&
|
|
854
|
-
isNonemptyString(value.modelId) &&
|
|
855
|
-
(value.platform === 'linux' || value.platform === 'darwin' || value.platform === 'win32'));
|
|
856
|
-
}
|
|
857
|
-
function isContextGcEconomicsPolicy(value) {
|
|
858
|
-
return (isRecord(value) &&
|
|
859
|
-
value.version === 1 &&
|
|
860
|
-
[
|
|
861
|
-
'immediatePaybackRollouts',
|
|
862
|
-
'maximumPaybackRollouts',
|
|
863
|
-
'contextGrowthSampleWindow',
|
|
864
|
-
'minimumContextGrowthSamples',
|
|
865
|
-
'minimumObservationRollouts',
|
|
866
|
-
'stageAProtectionRollouts',
|
|
867
|
-
'largeExecProtectionRollouts'
|
|
868
|
-
].every((key) => isNonnegativeInteger(value[key])) &&
|
|
869
|
-
[
|
|
870
|
-
'normalInputCostRate',
|
|
871
|
-
'cacheReadCostRate',
|
|
872
|
-
'cacheWriteCostRate',
|
|
873
|
-
'outputCostRate',
|
|
874
|
-
'minimumGrossReductionRate',
|
|
875
|
-
'minimumCacheInvestmentRoi'
|
|
876
|
-
].every((key) => isNonnegativeFinite(value[key])));
|
|
877
|
-
}
|
|
878
|
-
function isContextGcMetrics(value) {
|
|
879
|
-
if (!isRecord(value) ||
|
|
880
|
-
(value.stage !== 'STAGE_A' &&
|
|
881
|
-
value.stage !== 'STAGE_A_AND_EXEC' &&
|
|
882
|
-
value.stage !== 'INLINE_MEDIA'))
|
|
883
|
-
return false;
|
|
884
|
-
const nonnegative = [
|
|
885
|
-
'beforeTokens',
|
|
886
|
-
'afterTokens',
|
|
887
|
-
'reclaimedTokens',
|
|
888
|
-
'grossReductionRate',
|
|
889
|
-
'cacheRebuildPenaltyCostUnits',
|
|
890
|
-
'compactDeferralCreditCostUnits',
|
|
891
|
-
'projectedRolloutsUntilCompactAfterGc',
|
|
892
|
-
'contextGrowthSampleCount',
|
|
893
|
-
'contextGrowthP75Tokens',
|
|
894
|
-
'minimumObservedRollouts',
|
|
895
|
-
'protectedCandidateTokens',
|
|
896
|
-
'eligibleCandidateCount',
|
|
897
|
-
'eligibleTargetCount'
|
|
898
|
-
];
|
|
899
|
-
const optionalNonnegative = [
|
|
900
|
-
'effectiveMinimumGrossReductionRate',
|
|
901
|
-
'minimumRequiredReclaimedTokens',
|
|
902
|
-
'imminentCompactAvoidanceCreditCostUnits',
|
|
903
|
-
'appliedCompactCreditCostUnits',
|
|
904
|
-
'projectedTokensBeforeGc',
|
|
905
|
-
'projectedTokensAfterGc'
|
|
906
|
-
];
|
|
907
|
-
return (nonnegative.every((key) => isNonnegativeFinite(value[key])) &&
|
|
908
|
-
['requiredPositiveNetRollouts', 'requiredTargetRoiRollouts'].every((key) => isNonnegativeFinite(value[key]) || (value.stage === 'INLINE_MEDIA' && value[key] === null)) &&
|
|
909
|
-
optionalNonnegative.every((key) => value[key] === undefined || isNonnegativeFinite(value[key])) &&
|
|
910
|
-
Number.isFinite(value.expectedNetSavedCostUnits) &&
|
|
911
|
-
Number.isFinite(value.cacheInvestmentRoi) &&
|
|
912
|
-
(value.tokenEstimator === undefined || value.tokenEstimator === 'UTF8_BYTES_V1') &&
|
|
913
|
-
(value.cachePenaltyKnown === undefined || typeof value.cachePenaltyKnown === 'boolean'));
|
|
914
|
-
}
|
|
915
|
-
function isRecord(value) {
|
|
916
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
917
|
-
}
|
|
918
|
-
function hasOnlyKeys(value, keys) {
|
|
919
|
-
return Object.keys(value).every((key) => keys.includes(key));
|
|
920
|
-
}
|
|
921
|
-
function isNonemptyString(value) {
|
|
922
|
-
return typeof value === 'string' && value.length > 0;
|
|
923
|
-
}
|
|
924
|
-
function isPositiveInteger(value) {
|
|
925
|
-
return Number.isSafeInteger(value) && Number(value) > 0;
|
|
926
|
-
}
|
|
927
|
-
function isNonnegativeInteger(value) {
|
|
928
|
-
return Number.isSafeInteger(value) && Number(value) >= 0;
|
|
929
|
-
}
|
|
930
|
-
function isNonnegativeFinite(value) {
|
|
931
|
-
return typeof value === 'number' && Number.isFinite(value) && value >= 0;
|
|
932
|
-
}
|
|
933
|
-
function isValidBoundary(value) {
|
|
934
|
-
return Number.isSafeInteger(value) && value > 0;
|
|
935
|
-
}
|