@namzu/sdk 0.4.1 → 0.4.3
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/CHANGELOG.md +83 -0
- package/dist/__tests__/replay-public-surface.test.d.ts +2 -0
- package/dist/__tests__/replay-public-surface.test.d.ts.map +1 -0
- package/dist/__tests__/replay-public-surface.test.js +45 -0
- package/dist/__tests__/replay-public-surface.test.js.map +1 -0
- package/dist/advisory/context.test.d.ts +16 -0
- package/dist/advisory/context.test.d.ts.map +1 -0
- package/dist/advisory/context.test.js +92 -0
- package/dist/advisory/context.test.js.map +1 -0
- package/dist/advisory/evaluator.test.d.ts +34 -0
- package/dist/advisory/evaluator.test.d.ts.map +1 -0
- package/dist/advisory/evaluator.test.js +172 -0
- package/dist/advisory/evaluator.test.js.map +1 -0
- package/dist/advisory/executor.test.d.ts +35 -0
- package/dist/advisory/executor.test.d.ts.map +1 -0
- package/dist/advisory/executor.test.js +233 -0
- package/dist/advisory/executor.test.js.map +1 -0
- package/dist/advisory/registry.test.d.ts +16 -0
- package/dist/advisory/registry.test.d.ts.map +1 -0
- package/dist/advisory/registry.test.js +62 -0
- package/dist/advisory/registry.test.js.map +1 -0
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/bridge/a2a/agent-card.test.d.ts +24 -0
- package/dist/bridge/a2a/agent-card.test.d.ts.map +1 -0
- package/dist/bridge/a2a/agent-card.test.js +118 -0
- package/dist/bridge/a2a/agent-card.test.js.map +1 -0
- package/dist/bridge/a2a/mapper.test.d.ts +29 -0
- package/dist/bridge/a2a/mapper.test.d.ts.map +1 -0
- package/dist/bridge/a2a/mapper.test.js +265 -0
- package/dist/bridge/a2a/mapper.test.js.map +1 -0
- package/dist/bridge/a2a/message.test.d.ts +20 -0
- package/dist/bridge/a2a/message.test.d.ts.map +1 -0
- package/dist/bridge/a2a/message.test.js +116 -0
- package/dist/bridge/a2a/message.test.js.map +1 -0
- package/dist/bridge/a2a/task.d.ts +2 -2
- package/dist/bridge/a2a/task.d.ts.map +1 -1
- package/dist/bridge/a2a/task.js.map +1 -1
- package/dist/bridge/a2a/task.test.d.ts +29 -0
- package/dist/bridge/a2a/task.test.d.ts.map +1 -0
- package/dist/bridge/a2a/task.test.js +198 -0
- package/dist/bridge/a2a/task.test.js.map +1 -0
- package/dist/bridge/mcp/connector/adapter.test.d.ts +27 -0
- package/dist/bridge/mcp/connector/adapter.test.d.ts.map +1 -0
- package/dist/bridge/mcp/connector/adapter.test.js +203 -0
- package/dist/bridge/mcp/connector/adapter.test.js.map +1 -0
- package/dist/bridge/sse/mapper.test.d.ts +27 -0
- package/dist/bridge/sse/mapper.test.d.ts.map +1 -0
- package/dist/bridge/sse/mapper.test.js +271 -0
- package/dist/bridge/sse/mapper.test.js.map +1 -0
- package/dist/bridge/tools/connector/adapter.test.d.ts +28 -0
- package/dist/bridge/tools/connector/adapter.test.d.ts.map +1 -0
- package/dist/bridge/tools/connector/adapter.test.js +182 -0
- package/dist/bridge/tools/connector/adapter.test.js.map +1 -0
- package/dist/bridge/tools/connector/definitions.test.d.ts +23 -0
- package/dist/bridge/tools/connector/definitions.test.d.ts.map +1 -0
- package/dist/bridge/tools/connector/definitions.test.js +158 -0
- package/dist/bridge/tools/connector/definitions.test.js.map +1 -0
- package/dist/bridge/tools/connector/router.test.d.ts +21 -0
- package/dist/bridge/tools/connector/router.test.d.ts.map +1 -0
- package/dist/bridge/tools/connector/router.test.js +139 -0
- package/dist/bridge/tools/connector/router.test.js.map +1 -0
- package/dist/bus/breaker.test.d.ts +41 -0
- package/dist/bus/breaker.test.d.ts.map +1 -0
- package/dist/bus/breaker.test.js +242 -0
- package/dist/bus/breaker.test.js.map +1 -0
- package/dist/bus/index.test.d.ts +25 -0
- package/dist/bus/index.test.d.ts.map +1 -0
- package/dist/bus/index.test.js +151 -0
- package/dist/bus/index.test.js.map +1 -0
- package/dist/bus/lock.test.d.ts +44 -0
- package/dist/bus/lock.test.d.ts.map +1 -0
- package/dist/bus/lock.test.js +226 -0
- package/dist/bus/lock.test.js.map +1 -0
- package/dist/bus/ownership.test.d.ts +26 -0
- package/dist/bus/ownership.test.d.ts.map +1 -0
- package/dist/bus/ownership.test.js +205 -0
- package/dist/bus/ownership.test.js.map +1 -0
- package/dist/config/runtime.d.ts +24 -25
- package/dist/config/runtime.d.ts.map +1 -1
- package/dist/config/runtime.js.map +1 -1
- package/dist/connector/BaseConnector.test.d.ts +21 -0
- package/dist/connector/BaseConnector.test.d.ts.map +1 -0
- package/dist/connector/BaseConnector.test.js +108 -0
- package/dist/connector/BaseConnector.test.js.map +1 -0
- package/dist/connector/builtins/http.test.d.ts +30 -0
- package/dist/connector/builtins/http.test.d.ts.map +1 -0
- package/dist/connector/builtins/http.test.js +232 -0
- package/dist/connector/builtins/http.test.js.map +1 -0
- package/dist/connector/builtins/webhook.test.d.ts +20 -0
- package/dist/connector/builtins/webhook.test.d.ts.map +1 -0
- package/dist/connector/builtins/webhook.test.js +113 -0
- package/dist/connector/builtins/webhook.test.js.map +1 -0
- package/dist/connector/execution/factory.test.d.ts +16 -0
- package/dist/connector/execution/factory.test.d.ts.map +1 -0
- package/dist/connector/execution/factory.test.js +64 -0
- package/dist/connector/execution/factory.test.js.map +1 -0
- package/dist/connector/execution/remote.test.d.ts +16 -0
- package/dist/connector/execution/remote.test.d.ts.map +1 -0
- package/dist/connector/execution/remote.test.js +53 -0
- package/dist/connector/execution/remote.test.js.map +1 -0
- package/dist/connector/mcp/adapter.test.d.ts +34 -0
- package/dist/connector/mcp/adapter.test.d.ts.map +1 -0
- package/dist/connector/mcp/adapter.test.js +199 -0
- package/dist/connector/mcp/adapter.test.js.map +1 -0
- package/dist/contracts/api.d.ts +2 -2
- package/dist/contracts/api.d.ts.map +1 -1
- package/dist/contracts/index.d.ts +1 -2
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/schemas.d.ts +10 -10
- package/dist/index.d.ts +3 -103
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -89
- package/dist/index.js.map +1 -1
- package/dist/manager/agent/__tests__/lifecycle.test.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts +1 -1
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +1 -1
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/run/persistence.d.ts +3 -3
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/manager/thread/__tests__/lifecycle.test.js.map +1 -1
- package/dist/manager/thread/lifecycle.d.ts +1 -1
- package/dist/manager/thread/lifecycle.d.ts.map +1 -1
- package/dist/plugin/loader.d.ts +0 -5
- package/dist/plugin/loader.d.ts.map +1 -1
- package/dist/plugin/loader.js +1 -13
- package/dist/plugin/loader.js.map +1 -1
- package/dist/public-runtime.d.ts +70 -0
- package/dist/public-runtime.d.ts.map +1 -0
- package/dist/public-runtime.js +108 -0
- package/dist/public-runtime.js.map +1 -0
- package/dist/public-tools.d.ts +19 -0
- package/dist/public-tools.d.ts.map +1 -0
- package/dist/public-tools.js +34 -0
- package/dist/public-tools.js.map +1 -0
- package/dist/public-types.d.ts +55 -0
- package/dist/public-types.d.ts.map +1 -0
- package/dist/public-types.js +14 -0
- package/dist/public-types.js.map +1 -0
- package/dist/rag/chunking.test.d.ts +20 -0
- package/dist/rag/chunking.test.d.ts.map +1 -0
- package/dist/rag/chunking.test.js +92 -0
- package/dist/rag/chunking.test.js.map +1 -0
- package/dist/rag/context-assembler.test.d.ts +19 -0
- package/dist/rag/context-assembler.test.d.ts.map +1 -0
- package/dist/rag/context-assembler.test.js +98 -0
- package/dist/rag/context-assembler.test.js.map +1 -0
- package/dist/rag/embedding.test.d.ts +19 -0
- package/dist/rag/embedding.test.d.ts.map +1 -0
- package/dist/rag/embedding.test.js +115 -0
- package/dist/rag/embedding.test.js.map +1 -0
- package/dist/rag/ingestion.test.d.ts +22 -0
- package/dist/rag/ingestion.test.d.ts.map +1 -0
- package/dist/rag/ingestion.test.js +99 -0
- package/dist/rag/ingestion.test.js.map +1 -0
- package/dist/rag/knowledge-base.test.d.ts +17 -0
- package/dist/rag/knowledge-base.test.d.ts.map +1 -0
- package/dist/rag/knowledge-base.test.js +77 -0
- package/dist/rag/knowledge-base.test.js.map +1 -0
- package/dist/rag/rag-tool.d.ts +1 -1
- package/dist/rag/rag-tool.test.d.ts +21 -0
- package/dist/rag/rag-tool.test.d.ts.map +1 -0
- package/dist/rag/rag-tool.test.js +149 -0
- package/dist/rag/rag-tool.test.js.map +1 -0
- package/dist/rag/retriever.test.d.ts +26 -0
- package/dist/rag/retriever.test.d.ts.map +1 -0
- package/dist/rag/retriever.test.js +180 -0
- package/dist/rag/retriever.test.js.map +1 -0
- package/dist/rag/vector-store.test.d.ts +38 -0
- package/dist/rag/vector-store.test.d.ts.map +1 -0
- package/dist/rag/vector-store.test.js +175 -0
- package/dist/rag/vector-store.test.js.map +1 -0
- package/dist/registry/ManagedRegistry.test.d.ts +21 -0
- package/dist/registry/ManagedRegistry.test.d.ts.map +1 -0
- package/dist/registry/ManagedRegistry.test.js +98 -0
- package/dist/registry/ManagedRegistry.test.js.map +1 -0
- package/dist/registry/Registry.test.d.ts +18 -0
- package/dist/registry/Registry.test.d.ts.map +1 -0
- package/dist/registry/Registry.test.js +79 -0
- package/dist/registry/Registry.test.js.map +1 -0
- package/dist/registry/agent/definitions.test.d.ts +15 -0
- package/dist/registry/agent/definitions.test.d.ts.map +1 -0
- package/dist/registry/agent/definitions.test.js +84 -0
- package/dist/registry/agent/definitions.test.js.map +1 -0
- package/dist/registry/connector/definitions.test.d.ts +13 -0
- package/dist/registry/connector/definitions.test.d.ts.map +1 -0
- package/dist/registry/connector/definitions.test.js +41 -0
- package/dist/registry/connector/definitions.test.js.map +1 -0
- package/dist/registry/connector/scoped.test.d.ts +21 -0
- package/dist/registry/connector/scoped.test.d.ts.map +1 -0
- package/dist/registry/connector/scoped.test.js +115 -0
- package/dist/registry/connector/scoped.test.js.map +1 -0
- package/dist/registry/plugin/index.test.d.ts +12 -0
- package/dist/registry/plugin/index.test.d.ts.map +1 -0
- package/dist/registry/plugin/index.test.js +69 -0
- package/dist/registry/plugin/index.test.js.map +1 -0
- package/dist/registry/tool/execute.test.d.ts +42 -0
- package/dist/registry/tool/execute.test.d.ts.map +1 -0
- package/dist/registry/tool/execute.test.js +281 -0
- package/dist/registry/tool/execute.test.js.map +1 -0
- package/dist/run/LimitChecker.d.ts +0 -1
- package/dist/run/LimitChecker.d.ts.map +1 -1
- package/dist/run/LimitChecker.js +0 -6
- package/dist/run/LimitChecker.js.map +1 -1
- package/dist/run/reporter.d.ts +2 -2
- package/dist/run/reporter.d.ts.map +1 -1
- package/dist/run/reporter.js.map +1 -1
- package/dist/runtime/query/__tests__/checkpoint.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/checkpoint.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/checkpoint.test.js +150 -0
- package/dist/runtime/query/__tests__/checkpoint.test.js.map +1 -0
- package/dist/runtime/query/checkpoint.d.ts +23 -0
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +49 -0
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/context.d.ts +0 -2
- package/dist/runtime/query/context.d.ts.map +1 -1
- package/dist/runtime/query/context.js +0 -4
- package/dist/runtime/query/context.js.map +1 -1
- package/dist/runtime/query/index.d.ts +3 -3
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.test.d.ts +42 -0
- package/dist/runtime/query/iteration/phases/advisory.test.d.ts.map +1 -0
- package/dist/runtime/query/iteration/phases/advisory.test.js +334 -0
- package/dist/runtime/query/iteration/phases/advisory.test.js.map +1 -0
- package/dist/runtime/query/replay/__tests__/mutate.test.d.ts +2 -0
- package/dist/runtime/query/replay/__tests__/mutate.test.d.ts.map +1 -0
- package/dist/runtime/query/replay/__tests__/mutate.test.js +123 -0
- package/dist/runtime/query/replay/__tests__/mutate.test.js.map +1 -0
- package/dist/runtime/query/replay/__tests__/prepare.test.d.ts +2 -0
- package/dist/runtime/query/replay/__tests__/prepare.test.d.ts.map +1 -0
- package/dist/runtime/query/replay/__tests__/prepare.test.js +171 -0
- package/dist/runtime/query/replay/__tests__/prepare.test.js.map +1 -0
- package/dist/runtime/query/replay/list.d.ts +24 -0
- package/dist/runtime/query/replay/list.d.ts.map +1 -0
- package/dist/runtime/query/replay/list.js +21 -0
- package/dist/runtime/query/replay/list.js.map +1 -0
- package/dist/runtime/query/replay/mutate.d.ts +17 -0
- package/dist/runtime/query/replay/mutate.d.ts.map +1 -0
- package/dist/runtime/query/replay/mutate.js +62 -0
- package/dist/runtime/query/replay/mutate.js.map +1 -0
- package/dist/runtime/query/replay/prepare.d.ts +56 -0
- package/dist/runtime/query/replay/prepare.d.ts.map +1 -0
- package/dist/runtime/query/replay/prepare.js +65 -0
- package/dist/runtime/query/replay/prepare.js.map +1 -0
- package/dist/runtime/query/result.d.ts +2 -2
- package/dist/runtime/query/result.d.ts.map +1 -1
- package/dist/session/__tests__/integration/_fixtures.d.ts +4 -4
- package/dist/session/__tests__/integration/_fixtures.d.ts.map +1 -1
- package/dist/session/__tests__/integration/_fixtures.js.map +1 -1
- package/dist/session/__tests__/integration/archive-gate.test.js.map +1 -1
- package/dist/session/__tests__/integration/capacity-caps.test.js.map +1 -1
- package/dist/session/__tests__/integration/e2e-spawn.test.js.map +1 -1
- package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.js.map +1 -1
- package/dist/session/__tests__/integration/handoff-single-e2e.test.js.map +1 -1
- package/dist/session/__tests__/integration/prev-artifact-dag.test.js.map +1 -1
- package/dist/session/__tests__/integration/retention-archive.test.js.map +1 -1
- package/dist/session/__tests__/integration/spawn-rollback.test.js.map +1 -1
- package/dist/session/__tests__/integration/summary-materialization-e2e.test.js +1 -1
- package/dist/session/__tests__/integration/summary-materialization-e2e.test.js.map +1 -1
- package/dist/session/errors.d.ts +1 -1
- package/dist/session/errors.d.ts.map +1 -1
- package/dist/session/events/index.d.ts +3 -3
- package/dist/session/events/index.d.ts.map +1 -1
- package/dist/session/events/index.js +3 -2
- package/dist/session/events/index.js.map +1 -1
- package/dist/session/handoff/__tests__/broadcast.test.js.map +1 -1
- package/dist/session/handoff/__tests__/capacity.test.js.map +1 -1
- package/dist/session/handoff/__tests__/single.test.js.map +1 -1
- package/dist/session/handoff/assignment.d.ts +1 -1
- package/dist/session/handoff/assignment.d.ts.map +1 -1
- package/dist/session/handoff/broadcast.d.ts.map +1 -1
- package/dist/session/handoff/broadcast.js.map +1 -1
- package/dist/session/handoff/single.d.ts.map +1 -1
- package/dist/session/handoff/single.js.map +1 -1
- package/dist/session/index.d.ts +0 -1
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +7 -6
- package/dist/session/index.js.map +1 -1
- package/dist/session/intervention/__tests__/prev-artifact.test.js.map +1 -1
- package/dist/session/intervention/prev-artifact.d.ts +1 -1
- package/dist/session/intervention/prev-artifact.d.ts.map +1 -1
- package/dist/session/retention/__tests__/archive.test.js.map +1 -1
- package/dist/session/retention/__tests__/disk-backend.test.js.map +1 -1
- package/dist/session/retention/archive.d.ts +1 -1
- package/dist/session/retention/archive.d.ts.map +1 -1
- package/dist/session/retention/backend.d.ts +4 -4
- package/dist/session/retention/backend.d.ts.map +1 -1
- package/dist/session/retention/disk-backend.d.ts +1 -1
- package/dist/session/retention/disk-backend.d.ts.map +1 -1
- package/dist/session/retention/index.d.ts +3 -3
- package/dist/session/retention/index.d.ts.map +1 -1
- package/dist/session/retention/index.js +4 -2
- package/dist/session/retention/index.js.map +1 -1
- package/dist/session/status/__tests__/derive.test.d.ts +2 -0
- package/dist/session/status/__tests__/derive.test.d.ts.map +1 -0
- package/dist/session/{hierarchy/__tests__/session.test.js → status/__tests__/derive.test.js} +2 -2
- package/dist/session/status/__tests__/derive.test.js.map +1 -0
- package/dist/session/status/derive.d.ts +33 -0
- package/dist/session/status/derive.d.ts.map +1 -0
- package/dist/session/{hierarchy/session.js → status/derive.js} +6 -1
- package/dist/session/status/derive.js.map +1 -0
- package/dist/session/summary/__tests__/materialize.test.js +2 -1
- package/dist/session/summary/__tests__/materialize.test.js.map +1 -1
- package/dist/session/summary/errors.d.ts +43 -0
- package/dist/session/summary/errors.d.ts.map +1 -0
- package/dist/session/summary/errors.js +37 -0
- package/dist/session/summary/errors.js.map +1 -0
- package/dist/session/summary/index.d.ts +4 -3
- package/dist/session/summary/index.d.ts.map +1 -1
- package/dist/session/summary/index.js +5 -4
- package/dist/session/summary/index.js.map +1 -1
- package/dist/session/summary/materialize.d.ts +2 -2
- package/dist/session/summary/materialize.d.ts.map +1 -1
- package/dist/session/summary/materialize.js +2 -1
- package/dist/session/summary/materialize.js.map +1 -1
- package/dist/session/workspace/__tests__/git-worktree.test.js.map +1 -1
- package/dist/session/workspace/driver.d.ts +2 -2
- package/dist/session/workspace/driver.d.ts.map +1 -1
- package/dist/session/workspace/git-worktree.d.ts +1 -1
- package/dist/session/workspace/git-worktree.d.ts.map +1 -1
- package/dist/session/workspace/git-worktree.js.map +1 -1
- package/dist/session/workspace/index.d.ts +1 -1
- package/dist/session/workspace/index.d.ts.map +1 -1
- package/dist/session/workspace/index.js +3 -2
- package/dist/session/workspace/index.js.map +1 -1
- package/dist/store/run/disk.d.ts +4 -4
- package/dist/store/run/disk.d.ts.map +1 -1
- package/dist/store/run/disk.js.map +1 -1
- package/dist/store/session/__tests__/disk.test.js.map +1 -1
- package/dist/store/session/__tests__/memory.test.js.map +1 -1
- package/dist/store/session/disk.d.ts +6 -6
- package/dist/store/session/disk.d.ts.map +1 -1
- package/dist/store/session/disk.js +1 -1
- package/dist/store/session/disk.js.map +1 -1
- package/dist/store/session/index.d.ts +1 -1
- package/dist/store/session/index.d.ts.map +1 -1
- package/dist/store/session/index.js +2 -1
- package/dist/store/session/index.js.map +1 -1
- package/dist/store/session/linkage.d.ts +1 -1
- package/dist/store/session/linkage.d.ts.map +1 -1
- package/dist/store/session/memory.d.ts +5 -5
- package/dist/store/session/memory.d.ts.map +1 -1
- package/dist/store/session/memory.js +1 -1
- package/dist/store/session/memory.js.map +1 -1
- package/dist/store/thread/disk.d.ts +1 -1
- package/dist/store/thread/disk.d.ts.map +1 -1
- package/dist/store/thread/memory.d.ts +1 -1
- package/dist/store/thread/memory.d.ts.map +1 -1
- package/dist/telemetry/attributes.d.ts +0 -1
- package/dist/telemetry/attributes.d.ts.map +1 -1
- package/dist/telemetry/attributes.js +0 -3
- package/dist/telemetry/attributes.js.map +1 -1
- package/dist/telemetry/runtime-accessors.d.ts +1 -2
- package/dist/telemetry/runtime-accessors.d.ts.map +1 -1
- package/dist/telemetry/runtime-accessors.js +1 -4
- package/dist/telemetry/runtime-accessors.js.map +1 -1
- package/dist/test-setup.d.ts +22 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/test-setup.js +23 -0
- package/dist/test-setup.js.map +1 -0
- package/dist/tools/builtins/bash.d.ts +1 -1
- package/dist/tools/builtins/computer-use.d.ts +4 -4
- package/dist/tools/builtins/edit.d.ts +1 -1
- package/dist/tools/builtins/glob.d.ts +1 -1
- package/dist/tools/builtins/grep.d.ts +1 -1
- package/dist/tools/builtins/ls.d.ts +1 -1
- package/dist/tools/builtins/read-file.d.ts +1 -1
- package/dist/tools/builtins/search-tools.d.ts +1 -1
- package/dist/tools/builtins/write-file.d.ts +1 -1
- package/dist/types/agent/task.d.ts +2 -2
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/{session/hierarchy/project.d.ts → types/project/entity.d.ts} +4 -4
- package/dist/types/project/entity.d.ts.map +1 -0
- package/dist/types/project/entity.js +2 -0
- package/dist/types/project/entity.js.map +1 -0
- package/dist/types/project/index.d.ts +2 -0
- package/dist/types/project/index.d.ts.map +1 -0
- package/dist/types/project/index.js +4 -0
- package/dist/types/project/index.js.map +1 -0
- package/dist/types/retention/archive-backend-ref.d.ts.map +1 -0
- package/dist/types/retention/archive-backend-ref.js.map +1 -0
- package/dist/types/retention/index.d.ts +4 -0
- package/dist/types/retention/index.d.ts.map +1 -0
- package/dist/types/retention/index.js +4 -0
- package/dist/types/retention/index.js.map +1 -0
- package/dist/types/retention/policy.d.ts.map +1 -0
- package/dist/types/retention/policy.js.map +1 -0
- package/dist/types/run/entity.d.ts +56 -0
- package/dist/types/run/entity.d.ts.map +1 -0
- package/dist/types/run/entity.js +2 -0
- package/dist/types/run/entity.js.map +1 -0
- package/dist/types/run/events.d.ts +2 -2
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/index.d.ts +7 -1
- package/dist/types/run/index.d.ts.map +1 -1
- package/dist/types/run/index.js +8 -9
- package/dist/types/run/index.js.map +1 -1
- package/dist/{session/hierarchy → types/run}/lineage.d.ts +1 -1
- package/dist/types/run/lineage.d.ts.map +1 -0
- package/dist/types/run/lineage.js.map +1 -0
- package/dist/types/run/replay.d.ts +53 -0
- package/dist/types/run/replay.d.ts.map +1 -0
- package/dist/types/run/replay.js +15 -0
- package/dist/types/run/replay.js.map +1 -0
- package/dist/types/run/schema-version.d.ts.map +1 -0
- package/dist/types/run/schema-version.js.map +1 -0
- package/dist/{session/events/types.d.ts → types/run/subsession-events.d.ts} +5 -5
- package/dist/types/run/subsession-events.d.ts.map +1 -0
- package/dist/types/run/subsession-events.js +2 -0
- package/dist/types/run/subsession-events.js.map +1 -0
- package/dist/{session/hierarchy → types/session}/actor.d.ts +1 -1
- package/dist/types/session/actor.d.ts.map +1 -0
- package/dist/{session/hierarchy → types/session}/actor.js.map +1 -1
- package/dist/types/session/entity.d.ts +51 -0
- package/dist/types/session/entity.d.ts.map +1 -0
- package/dist/types/session/entity.js +2 -0
- package/dist/types/session/entity.js.map +1 -0
- package/dist/types/session/index.d.ts +4 -0
- package/dist/types/session/index.d.ts.map +1 -1
- package/dist/{store → types}/session/messages.d.ts +2 -2
- package/dist/{store → types}/session/messages.d.ts.map +1 -1
- package/dist/types/session/messages.js.map +1 -0
- package/dist/types/session/store.d.ts +6 -6
- package/dist/types/session/store.d.ts.map +1 -1
- package/dist/{session/hierarchy → types/session}/sub-session.d.ts +9 -9
- package/dist/types/session/sub-session.d.ts.map +1 -0
- package/dist/types/session/sub-session.js.map +1 -0
- package/dist/{session → types}/summary/deliverable.d.ts +2 -2
- package/dist/types/summary/deliverable.d.ts.map +1 -0
- package/dist/types/summary/deliverable.js.map +1 -0
- package/dist/types/summary/index.d.ts +4 -0
- package/dist/types/summary/index.d.ts.map +1 -0
- package/dist/types/summary/index.js +4 -0
- package/dist/types/summary/index.js.map +1 -0
- package/dist/{session → types}/summary/ref.d.ts +9 -36
- package/dist/types/summary/ref.d.ts.map +1 -0
- package/dist/types/summary/ref.js +28 -0
- package/dist/types/summary/ref.js.map +1 -0
- package/dist/{session/hierarchy/tenant.d.ts → types/tenant/entity.d.ts} +2 -2
- package/dist/types/tenant/entity.d.ts.map +1 -0
- package/dist/types/tenant/entity.js +2 -0
- package/dist/types/tenant/entity.js.map +1 -0
- package/dist/types/tenant/index.d.ts +2 -0
- package/dist/types/tenant/index.d.ts.map +1 -0
- package/dist/types/tenant/index.js +4 -0
- package/dist/types/tenant/index.js.map +1 -0
- package/dist/{session/hierarchy/thread.d.ts → types/thread/entity.d.ts} +31 -7
- package/dist/types/thread/entity.d.ts.map +1 -0
- package/dist/types/thread/entity.js +2 -0
- package/dist/types/thread/entity.js.map +1 -0
- package/dist/types/thread/index.d.ts +1 -0
- package/dist/types/thread/index.d.ts.map +1 -1
- package/dist/types/thread/store.d.ts +1 -1
- package/dist/types/thread/store.d.ts.map +1 -1
- package/dist/types/workspace/index.d.ts +2 -0
- package/dist/types/workspace/index.d.ts.map +1 -0
- package/dist/types/workspace/index.js +7 -0
- package/dist/types/workspace/index.js.map +1 -0
- package/dist/{session → types}/workspace/ref.d.ts +1 -1
- package/dist/types/workspace/ref.d.ts.map +1 -0
- package/dist/types/workspace/ref.js.map +1 -0
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +5 -0
- package/dist/utils/logger.js.map +1 -1
- package/package.json +4 -1
- package/src/__tests__/replay-public-surface.test.ts +54 -0
- package/src/advisory/context.test.ts +109 -0
- package/src/advisory/evaluator.test.ts +192 -0
- package/src/advisory/executor.test.ts +272 -0
- package/src/advisory/registry.test.ts +75 -0
- package/src/agents/SupervisorAgent.ts +1 -1
- package/src/bridge/a2a/agent-card.test.ts +140 -0
- package/src/bridge/a2a/mapper.test.ts +293 -0
- package/src/bridge/a2a/message.test.ts +138 -0
- package/src/bridge/a2a/task.test.ts +235 -0
- package/src/bridge/a2a/task.ts +4 -4
- package/src/bridge/mcp/connector/adapter.test.ts +230 -0
- package/src/bridge/sse/mapper.test.ts +422 -0
- package/src/bridge/tools/connector/adapter.test.ts +224 -0
- package/src/bridge/tools/connector/definitions.test.ts +183 -0
- package/src/bridge/tools/connector/router.test.ts +159 -0
- package/src/bus/breaker.test.ts +274 -0
- package/src/bus/index.test.ts +183 -0
- package/src/bus/lock.test.ts +265 -0
- package/src/bus/ownership.test.ts +243 -0
- package/src/config/runtime.ts +0 -2
- package/src/connector/BaseConnector.test.ts +130 -0
- package/src/connector/builtins/http.test.ts +290 -0
- package/src/connector/builtins/webhook.test.ts +138 -0
- package/src/connector/execution/factory.test.ts +75 -0
- package/src/connector/execution/remote.test.ts +63 -0
- package/src/connector/mcp/adapter.test.ts +249 -0
- package/src/contracts/api.ts +2 -2
- package/src/contracts/index.ts +1 -3
- package/src/index.ts +11 -362
- package/src/manager/agent/__tests__/lifecycle.test.ts +2 -2
- package/src/manager/agent/lifecycle.ts +5 -5
- package/src/manager/run/persistence.ts +4 -4
- package/src/manager/thread/__tests__/lifecycle.test.ts +1 -1
- package/src/manager/thread/lifecycle.ts +2 -2
- package/src/plugin/loader.ts +0 -16
- package/src/public-runtime.ts +373 -0
- package/src/public-tools.ts +63 -0
- package/src/public-types.ts +156 -0
- package/src/rag/chunking.test.ts +107 -0
- package/src/rag/context-assembler.test.ts +114 -0
- package/src/rag/embedding.test.ts +130 -0
- package/src/rag/ingestion.test.ts +114 -0
- package/src/rag/knowledge-base.test.ts +106 -0
- package/src/rag/rag-tool.test.ts +167 -0
- package/src/rag/retriever.test.ts +210 -0
- package/src/rag/vector-store.test.ts +196 -0
- package/src/registry/ManagedRegistry.test.ts +118 -0
- package/src/registry/Registry.test.ts +91 -0
- package/src/registry/agent/definitions.test.ts +100 -0
- package/src/registry/connector/definitions.test.ts +51 -0
- package/src/registry/connector/scoped.test.ts +129 -0
- package/src/registry/plugin/index.test.ts +85 -0
- package/src/registry/tool/execute.test.ts +330 -0
- package/src/run/LimitChecker.ts +0 -9
- package/src/run/reporter.ts +3 -3
- package/src/runtime/query/__tests__/checkpoint.test.ts +169 -0
- package/src/runtime/query/checkpoint.ts +54 -0
- package/src/runtime/query/context.ts +0 -5
- package/src/runtime/query/index.ts +4 -4
- package/src/runtime/query/iteration/phases/advisory.test.ts +412 -0
- package/src/runtime/query/replay/__tests__/mutate.test.ts +134 -0
- package/src/runtime/query/replay/__tests__/prepare.test.ts +207 -0
- package/src/runtime/query/replay/list.ts +32 -0
- package/src/runtime/query/replay/mutate.ts +76 -0
- package/src/runtime/query/replay/prepare.ts +114 -0
- package/src/runtime/query/result.ts +2 -2
- package/src/session/__tests__/integration/_fixtures.ts +2 -2
- package/src/session/__tests__/integration/archive-gate.test.ts +1 -1
- package/src/session/__tests__/integration/capacity-caps.test.ts +1 -1
- package/src/session/__tests__/integration/e2e-spawn.test.ts +1 -1
- package/src/session/__tests__/integration/handoff-broadcast-e2e.test.ts +1 -1
- package/src/session/__tests__/integration/handoff-single-e2e.test.ts +1 -1
- package/src/session/__tests__/integration/prev-artifact-dag.test.ts +4 -1
- package/src/session/__tests__/integration/retention-archive.test.ts +1 -1
- package/src/session/__tests__/integration/spawn-rollback.test.ts +2 -2
- package/src/session/__tests__/integration/summary-materialization-e2e.test.ts +1 -1
- package/src/session/errors.ts +1 -1
- package/src/session/events/index.ts +5 -4
- package/src/session/handoff/__tests__/broadcast.test.ts +1 -1
- package/src/session/handoff/__tests__/capacity.test.ts +1 -1
- package/src/session/handoff/__tests__/single.test.ts +1 -1
- package/src/session/handoff/assignment.ts +1 -1
- package/src/session/handoff/broadcast.ts +2 -2
- package/src/session/handoff/single.ts +2 -2
- package/src/session/index.ts +7 -6
- package/src/session/intervention/__tests__/prev-artifact.test.ts +4 -1
- package/src/session/intervention/prev-artifact.ts +1 -1
- package/src/session/retention/__tests__/archive.test.ts +3 -3
- package/src/session/retention/__tests__/disk-backend.test.ts +4 -4
- package/src/session/retention/archive.ts +2 -2
- package/src/session/retention/backend.ts +4 -4
- package/src/session/retention/disk-backend.ts +4 -4
- package/src/session/retention/index.ts +6 -4
- package/src/session/{hierarchy/__tests__/session.test.ts → status/__tests__/derive.test.ts} +3 -2
- package/src/session/{hierarchy/session.ts → status/derive.ts} +9 -55
- package/src/session/summary/__tests__/materialize.test.ts +4 -7
- package/src/session/summary/errors.ts +51 -0
- package/src/session/summary/index.ts +7 -10
- package/src/session/summary/materialize.ts +4 -5
- package/src/session/workspace/__tests__/git-worktree.test.ts +1 -1
- package/src/session/workspace/driver.ts +2 -2
- package/src/session/workspace/git-worktree.ts +1 -1
- package/src/session/workspace/index.ts +7 -6
- package/src/store/run/disk.ts +4 -4
- package/src/store/session/__tests__/disk.test.ts +2 -2
- package/src/store/session/__tests__/memory.test.ts +2 -2
- package/src/store/session/disk.ts +12 -12
- package/src/store/session/index.ts +3 -2
- package/src/store/session/linkage.ts +1 -1
- package/src/store/session/memory.ts +6 -6
- package/src/store/thread/disk.ts +1 -1
- package/src/store/thread/memory.ts +1 -1
- package/src/telemetry/attributes.ts +0 -4
- package/src/telemetry/runtime-accessors.ts +1 -5
- package/src/test-setup.ts +24 -0
- package/src/types/agent/task.ts +2 -2
- package/src/{session/hierarchy/project.ts → types/project/entity.ts} +3 -3
- package/src/types/project/index.ts +4 -0
- package/src/types/retention/index.ts +6 -0
- package/src/types/run/entity.ts +63 -0
- package/src/types/run/events.ts +6 -6
- package/src/types/run/index.ts +16 -9
- package/src/{session/hierarchy → types/run}/lineage.ts +1 -1
- package/src/types/run/replay.ts +61 -0
- package/src/{session/events/types.ts → types/run/subsession-events.ts} +4 -4
- package/src/{session/hierarchy → types/session}/actor.ts +1 -1
- package/src/types/session/entity.ts +59 -0
- package/src/types/session/index.ts +15 -0
- package/src/{store → types}/session/messages.ts +2 -2
- package/src/types/session/store.ts +6 -6
- package/src/{session/hierarchy → types/session}/sub-session.ts +9 -9
- package/src/{session → types}/summary/deliverable.ts +2 -2
- package/src/types/summary/index.ts +18 -0
- package/src/{session → types}/summary/ref.ts +9 -44
- package/src/{session/hierarchy/tenant.ts → types/tenant/entity.ts} +1 -1
- package/src/types/tenant/index.ts +4 -0
- package/src/{session/hierarchy/thread.ts → types/thread/entity.ts} +30 -6
- package/src/types/thread/index.ts +1 -0
- package/src/types/thread/store.ts +1 -1
- package/src/types/workspace/index.ts +12 -0
- package/src/{session → types}/workspace/ref.ts +1 -1
- package/src/utils/logger.ts +6 -1
- package/dist/contracts/ids.d.ts +0 -2
- package/dist/contracts/ids.d.ts.map +0 -1
- package/dist/contracts/ids.js +0 -2
- package/dist/contracts/ids.js.map +0 -1
- package/dist/session/events/schema-version.d.ts.map +0 -1
- package/dist/session/events/schema-version.js.map +0 -1
- package/dist/session/events/types.d.ts.map +0 -1
- package/dist/session/events/types.js +0 -2
- package/dist/session/events/types.js.map +0 -1
- package/dist/session/hierarchy/__tests__/session.test.d.ts +0 -2
- package/dist/session/hierarchy/__tests__/session.test.d.ts.map +0 -1
- package/dist/session/hierarchy/__tests__/session.test.js.map +0 -1
- package/dist/session/hierarchy/actor.d.ts.map +0 -1
- package/dist/session/hierarchy/index.d.ts +0 -9
- package/dist/session/hierarchy/index.d.ts.map +0 -1
- package/dist/session/hierarchy/index.js +0 -4
- package/dist/session/hierarchy/index.js.map +0 -1
- package/dist/session/hierarchy/lineage.d.ts.map +0 -1
- package/dist/session/hierarchy/lineage.js.map +0 -1
- package/dist/session/hierarchy/project.d.ts.map +0 -1
- package/dist/session/hierarchy/project.js +0 -2
- package/dist/session/hierarchy/project.js.map +0 -1
- package/dist/session/hierarchy/session.d.ts +0 -71
- package/dist/session/hierarchy/session.d.ts.map +0 -1
- package/dist/session/hierarchy/session.js.map +0 -1
- package/dist/session/hierarchy/sub-session.d.ts.map +0 -1
- package/dist/session/hierarchy/sub-session.js.map +0 -1
- package/dist/session/hierarchy/tenant.d.ts.map +0 -1
- package/dist/session/hierarchy/tenant.js +0 -2
- package/dist/session/hierarchy/tenant.js.map +0 -1
- package/dist/session/hierarchy/thread.d.ts.map +0 -1
- package/dist/session/hierarchy/thread.js +0 -2
- package/dist/session/hierarchy/thread.js.map +0 -1
- package/dist/session/retention/archive-backend-ref.d.ts.map +0 -1
- package/dist/session/retention/archive-backend-ref.js.map +0 -1
- package/dist/session/retention/policy.d.ts.map +0 -1
- package/dist/session/retention/policy.js.map +0 -1
- package/dist/session/summary/deliverable.d.ts.map +0 -1
- package/dist/session/summary/deliverable.js.map +0 -1
- package/dist/session/summary/ref.d.ts.map +0 -1
- package/dist/session/summary/ref.js +0 -51
- package/dist/session/summary/ref.js.map +0 -1
- package/dist/session/workspace/ref.d.ts.map +0 -1
- package/dist/session/workspace/ref.js.map +0 -1
- package/dist/store/session/messages.js.map +0 -1
- package/dist/tools/builtins/__tests__/structuredOutput.example.d.ts +0 -140
- package/dist/tools/builtins/__tests__/structuredOutput.example.d.ts.map +0 -1
- package/dist/tools/builtins/__tests__/structuredOutput.example.js +0 -183
- package/dist/tools/builtins/__tests__/structuredOutput.example.js.map +0 -1
- package/dist/types/run/state.d.ts +0 -30
- package/dist/types/run/state.d.ts.map +0 -1
- package/dist/types/run/state.js +0 -2
- package/dist/types/run/state.js.map +0 -1
- package/src/contracts/ids.ts +0 -1
- package/src/session/hierarchy/index.ts +0 -18
- package/src/tools/builtins/__tests__/structuredOutput.example.ts +0 -221
- package/src/types/run/state.ts +0 -35
- /package/dist/{session → types}/retention/archive-backend-ref.d.ts +0 -0
- /package/dist/{session → types}/retention/archive-backend-ref.js +0 -0
- /package/dist/{session → types}/retention/policy.d.ts +0 -0
- /package/dist/{session → types}/retention/policy.js +0 -0
- /package/dist/{session/hierarchy → types/run}/lineage.js +0 -0
- /package/dist/{session/events → types/run}/schema-version.d.ts +0 -0
- /package/dist/{session/events → types/run}/schema-version.js +0 -0
- /package/dist/{session/hierarchy → types/session}/actor.js +0 -0
- /package/dist/{store → types}/session/messages.js +0 -0
- /package/dist/{session/hierarchy → types/session}/sub-session.js +0 -0
- /package/dist/{session → types}/summary/deliverable.js +0 -0
- /package/dist/{session → types}/workspace/ref.js +0 -0
- /package/src/{session → types}/retention/archive-backend-ref.ts +0 -0
- /package/src/{session → types}/retention/policy.ts +0 -0
- /package/src/{session/events → types/run}/schema-version.ts +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { MutationNotApplicableError } from '../../../../types/run/replay.js';
|
|
3
|
+
import { applyMutations } from '../mutate.js';
|
|
4
|
+
function assistantWithCalls(toolCallIds) {
|
|
5
|
+
return {
|
|
6
|
+
role: 'assistant',
|
|
7
|
+
content: null,
|
|
8
|
+
toolCalls: toolCallIds.map((id) => ({
|
|
9
|
+
id,
|
|
10
|
+
type: 'function',
|
|
11
|
+
function: { name: 'noop', arguments: '{}' },
|
|
12
|
+
})),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
describe('applyMutations / injectToolResponse', () => {
|
|
16
|
+
it('appends a ToolMessage when the toolCallId is pending', () => {
|
|
17
|
+
const messages = [
|
|
18
|
+
{ role: 'user', content: 'do stuff' },
|
|
19
|
+
assistantWithCalls(['call_a', 'call_b']),
|
|
20
|
+
{ role: 'tool', content: 'a done', toolCallId: 'call_a' },
|
|
21
|
+
];
|
|
22
|
+
const mutations = [
|
|
23
|
+
{
|
|
24
|
+
type: 'injectToolResponse',
|
|
25
|
+
toolCallId: 'call_b',
|
|
26
|
+
response: { success: true, output: 'mocked-b', data: { x: 1 } },
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
const result = applyMutations(messages, mutations);
|
|
30
|
+
expect(result).toHaveLength(4);
|
|
31
|
+
const last = result[3];
|
|
32
|
+
expect(last.role).toBe('tool');
|
|
33
|
+
expect(last.toolCallId).toBe('call_b');
|
|
34
|
+
expect(last.content).toBe('mocked-b');
|
|
35
|
+
});
|
|
36
|
+
it('throws MutationNotApplicableError when no pending tool calls exist', () => {
|
|
37
|
+
const messages = [
|
|
38
|
+
{ role: 'user', content: 'hi' },
|
|
39
|
+
{ role: 'assistant', content: 'hello' },
|
|
40
|
+
];
|
|
41
|
+
expect(() => applyMutations(messages, [
|
|
42
|
+
{
|
|
43
|
+
type: 'injectToolResponse',
|
|
44
|
+
toolCallId: 'call_missing',
|
|
45
|
+
response: { success: true, output: 'x' },
|
|
46
|
+
},
|
|
47
|
+
])).toThrow(MutationNotApplicableError);
|
|
48
|
+
});
|
|
49
|
+
it('throws with availableToolCallIds populated when toolCallId is not pending', () => {
|
|
50
|
+
const messages = [
|
|
51
|
+
{ role: 'user', content: 'do stuff' },
|
|
52
|
+
assistantWithCalls(['call_a', 'call_b']),
|
|
53
|
+
];
|
|
54
|
+
try {
|
|
55
|
+
applyMutations(messages, [
|
|
56
|
+
{
|
|
57
|
+
type: 'injectToolResponse',
|
|
58
|
+
toolCallId: 'call_z',
|
|
59
|
+
response: { success: true, output: 'x' },
|
|
60
|
+
},
|
|
61
|
+
]);
|
|
62
|
+
expect.fail('expected MutationNotApplicableError');
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
expect(err).toBeInstanceOf(MutationNotApplicableError);
|
|
66
|
+
const e = err;
|
|
67
|
+
expect(e.availableToolCallIds).toEqual(['call_a', 'call_b']);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
it('considers a tool call satisfied only when a subsequent ToolMessage responds to it', () => {
|
|
71
|
+
const messages = [
|
|
72
|
+
{ role: 'user', content: 'do stuff' },
|
|
73
|
+
assistantWithCalls(['call_a', 'call_b', 'call_c']),
|
|
74
|
+
{ role: 'tool', content: 'a done', toolCallId: 'call_a' },
|
|
75
|
+
{ role: 'tool', content: 'c done', toolCallId: 'call_c' },
|
|
76
|
+
];
|
|
77
|
+
try {
|
|
78
|
+
applyMutations(messages, [
|
|
79
|
+
{
|
|
80
|
+
type: 'injectToolResponse',
|
|
81
|
+
toolCallId: 'call_a',
|
|
82
|
+
response: { success: true, output: 're-answered' },
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
expect.fail('expected MutationNotApplicableError — call_a already satisfied');
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
const e = err;
|
|
89
|
+
expect(e.availableToolCallIds).toEqual(['call_b']);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
it('applies mutations in order so a later mutation sees earlier ones', () => {
|
|
93
|
+
const messages = [
|
|
94
|
+
{ role: 'user', content: 'two calls pending' },
|
|
95
|
+
assistantWithCalls(['call_x', 'call_y']),
|
|
96
|
+
];
|
|
97
|
+
const result = applyMutations(messages, [
|
|
98
|
+
{
|
|
99
|
+
type: 'injectToolResponse',
|
|
100
|
+
toolCallId: 'call_x',
|
|
101
|
+
response: { success: true, output: 'x-result' },
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
type: 'injectToolResponse',
|
|
105
|
+
toolCallId: 'call_y',
|
|
106
|
+
response: { success: true, output: 'y-result' },
|
|
107
|
+
},
|
|
108
|
+
]);
|
|
109
|
+
expect(result).toHaveLength(4);
|
|
110
|
+
expect(result[2].toolCallId).toBe('call_x');
|
|
111
|
+
expect(result[3].toolCallId).toBe('call_y');
|
|
112
|
+
});
|
|
113
|
+
it('returns the original messages unchanged when the mutation list is empty', () => {
|
|
114
|
+
const messages = [
|
|
115
|
+
{ role: 'user', content: 'no-op' },
|
|
116
|
+
{ role: 'assistant', content: 'ok' },
|
|
117
|
+
];
|
|
118
|
+
const result = applyMutations(messages, []);
|
|
119
|
+
expect(result).toEqual(messages);
|
|
120
|
+
expect(result).not.toBe(messages);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
//# sourceMappingURL=mutate.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutate.test.js","sourceRoot":"","sources":["../../../../../src/runtime/query/replay/__tests__/mutate.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAG7C,OAAO,EAAiB,0BAA0B,EAAE,MAAM,iCAAiC,CAAA;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,SAAS,kBAAkB,CAAC,WAAqB;IAChD,OAAO;QACN,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACnC,EAAE;YACF,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE;SAC3C,CAAC,CAAC;KACH,CAAA;AACF,CAAC;AAED,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACpD,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC/D,MAAM,QAAQ,GAAc;YAC3B,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE;YACrC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACxC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE;SACzD,CAAA;QACD,MAAM,SAAS,GAAe;YAC7B;gBACC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OAAO,EAAE;YAClC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE;SACpC,CAAA;QACD,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;QAC3C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QAChC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.test.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/query/replay/__tests__/prepare.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { mkdir, mkdtemp, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import { prepareReplayState } from '../prepare.js';
|
|
6
|
+
const RUN_ID = 'run_source';
|
|
7
|
+
function makeCheckpoint(overrides) {
|
|
8
|
+
return {
|
|
9
|
+
id: 'cp_default',
|
|
10
|
+
runId: RUN_ID,
|
|
11
|
+
iteration: 1,
|
|
12
|
+
messages: [{ role: 'user', content: 'hi' }],
|
|
13
|
+
tokenUsage: {
|
|
14
|
+
promptTokens: 0,
|
|
15
|
+
completionTokens: 0,
|
|
16
|
+
totalTokens: 0,
|
|
17
|
+
cachedTokens: 0,
|
|
18
|
+
cacheWriteTokens: 0,
|
|
19
|
+
},
|
|
20
|
+
costInfo: { inputCostPer1M: 0, outputCostPer1M: 0, totalCost: 0, cacheDiscount: 0 },
|
|
21
|
+
guardState: { iterationCount: 1, elapsedMs: 0 },
|
|
22
|
+
createdAt: Date.now(),
|
|
23
|
+
...overrides,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async function seedCheckpoint(baseDir, cp) {
|
|
27
|
+
const cpDir = join(baseDir, cp.runId, 'checkpoints');
|
|
28
|
+
await mkdir(cpDir, { recursive: true });
|
|
29
|
+
await writeFile(join(cpDir, `${cp.id}.json`), JSON.stringify(cp), 'utf-8');
|
|
30
|
+
}
|
|
31
|
+
async function seedEmergency(emergencyDir, dump) {
|
|
32
|
+
await mkdir(emergencyDir, { recursive: true });
|
|
33
|
+
await writeFile(join(emergencyDir, `${dump.runId}.json`), JSON.stringify(dump), 'utf-8');
|
|
34
|
+
}
|
|
35
|
+
describe('prepareReplayState', () => {
|
|
36
|
+
let baseDir;
|
|
37
|
+
let emergencyDir;
|
|
38
|
+
beforeEach(async () => {
|
|
39
|
+
const wrapper = await mkdtemp(join(tmpdir(), 'namzu-prepare-replay-'));
|
|
40
|
+
baseDir = join(wrapper, 'runs');
|
|
41
|
+
emergencyDir = join(wrapper, 'emergency');
|
|
42
|
+
await mkdir(baseDir, { recursive: true });
|
|
43
|
+
});
|
|
44
|
+
afterEach(async () => {
|
|
45
|
+
// Per-test tmpdir isolation; vitest cleans tmpdir between runs.
|
|
46
|
+
});
|
|
47
|
+
it('resolves a specific CheckpointId and returns the checkpoint messages', async () => {
|
|
48
|
+
const cp = makeCheckpoint({
|
|
49
|
+
id: 'cp_one',
|
|
50
|
+
iteration: 3,
|
|
51
|
+
messages: [
|
|
52
|
+
{ role: 'user', content: 'start' },
|
|
53
|
+
{ role: 'assistant', content: 'ok' },
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
await seedCheckpoint(baseDir, cp);
|
|
57
|
+
const prepared = await prepareReplayState({
|
|
58
|
+
baseDir,
|
|
59
|
+
runId: RUN_ID,
|
|
60
|
+
fromCheckpoint: 'cp_one',
|
|
61
|
+
});
|
|
62
|
+
expect(prepared.sourceCheckpoint.id).toBe('cp_one');
|
|
63
|
+
expect(prepared.messages).toEqual(cp.messages);
|
|
64
|
+
expect(prepared.attribution.sourceRunId).toBe(RUN_ID);
|
|
65
|
+
expect(prepared.attribution.fromCheckpointId).toBe('cp_one');
|
|
66
|
+
expect(prepared.attribution.mutations).toEqual([]);
|
|
67
|
+
expect(prepared.attribution.replayedAt).toBeGreaterThan(0);
|
|
68
|
+
});
|
|
69
|
+
it("resolves 'latest' to the checkpoint with the highest iteration", async () => {
|
|
70
|
+
await seedCheckpoint(baseDir, makeCheckpoint({ id: 'cp_a', iteration: 1 }));
|
|
71
|
+
await seedCheckpoint(baseDir, makeCheckpoint({ id: 'cp_b', iteration: 5 }));
|
|
72
|
+
await seedCheckpoint(baseDir, makeCheckpoint({ id: 'cp_c', iteration: 3 }));
|
|
73
|
+
const prepared = await prepareReplayState({
|
|
74
|
+
baseDir,
|
|
75
|
+
runId: RUN_ID,
|
|
76
|
+
fromCheckpoint: 'latest',
|
|
77
|
+
});
|
|
78
|
+
expect(prepared.sourceCheckpoint.id).toBe('cp_b');
|
|
79
|
+
expect(prepared.sourceCheckpoint.iteration).toBe(5);
|
|
80
|
+
});
|
|
81
|
+
it("throws when 'latest' is requested but no checkpoints exist", async () => {
|
|
82
|
+
await expect(prepareReplayState({
|
|
83
|
+
baseDir,
|
|
84
|
+
runId: RUN_ID,
|
|
85
|
+
fromCheckpoint: 'latest',
|
|
86
|
+
})).rejects.toThrow(/No checkpoints found/);
|
|
87
|
+
});
|
|
88
|
+
it('throws when a specific CheckpointId does not resolve', async () => {
|
|
89
|
+
await expect(prepareReplayState({
|
|
90
|
+
baseDir,
|
|
91
|
+
runId: RUN_ID,
|
|
92
|
+
fromCheckpoint: 'cp_missing',
|
|
93
|
+
})).rejects.toThrow(/not found/);
|
|
94
|
+
});
|
|
95
|
+
it('applies injectToolResponse mutations at the fork point', async () => {
|
|
96
|
+
const assistantMsg = {
|
|
97
|
+
role: 'assistant',
|
|
98
|
+
content: null,
|
|
99
|
+
toolCalls: [{ id: 'call_a', type: 'function', function: { name: 'noop', arguments: '{}' } }],
|
|
100
|
+
};
|
|
101
|
+
const cp = makeCheckpoint({
|
|
102
|
+
id: 'cp_with_tool',
|
|
103
|
+
messages: [{ role: 'user', content: 'run tool' }, assistantMsg],
|
|
104
|
+
});
|
|
105
|
+
await seedCheckpoint(baseDir, cp);
|
|
106
|
+
const mutations = [
|
|
107
|
+
{
|
|
108
|
+
type: 'injectToolResponse',
|
|
109
|
+
toolCallId: 'call_a',
|
|
110
|
+
response: { success: true, output: 'mocked-a' },
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
const prepared = await prepareReplayState({
|
|
114
|
+
baseDir,
|
|
115
|
+
runId: RUN_ID,
|
|
116
|
+
fromCheckpoint: 'cp_with_tool',
|
|
117
|
+
mutate: mutations,
|
|
118
|
+
});
|
|
119
|
+
expect(prepared.messages).toHaveLength(3);
|
|
120
|
+
const appended = prepared.messages[2];
|
|
121
|
+
expect(appended.role).toBe('tool');
|
|
122
|
+
expect(appended.toolCallId).toBe('call_a');
|
|
123
|
+
expect(appended.content).toBe('mocked-a');
|
|
124
|
+
expect(prepared.attribution.mutations).toEqual(mutations);
|
|
125
|
+
});
|
|
126
|
+
it("resolves 'emergency' via the emergency dump and projects it to a checkpoint", async () => {
|
|
127
|
+
const dump = {
|
|
128
|
+
id: 'esave_xyz',
|
|
129
|
+
runId: RUN_ID,
|
|
130
|
+
messages: [{ role: 'user', content: 'before crash' }],
|
|
131
|
+
tokenUsage: {
|
|
132
|
+
promptTokens: 4,
|
|
133
|
+
completionTokens: 2,
|
|
134
|
+
totalTokens: 6,
|
|
135
|
+
cachedTokens: 0,
|
|
136
|
+
cacheWriteTokens: 0,
|
|
137
|
+
},
|
|
138
|
+
currentIteration: 9,
|
|
139
|
+
startedAt: 1_000,
|
|
140
|
+
savedAt: 2_000,
|
|
141
|
+
processSignal: 'SIGTERM',
|
|
142
|
+
};
|
|
143
|
+
await seedEmergency(emergencyDir, dump);
|
|
144
|
+
const prepared = await prepareReplayState({
|
|
145
|
+
baseDir,
|
|
146
|
+
runId: RUN_ID,
|
|
147
|
+
fromCheckpoint: 'emergency',
|
|
148
|
+
emergencyDir,
|
|
149
|
+
});
|
|
150
|
+
expect(prepared.sourceCheckpoint.id).toBe('cp_emergency_xyz');
|
|
151
|
+
expect(prepared.sourceCheckpoint.iteration).toBe(9);
|
|
152
|
+
expect(prepared.messages).toEqual(dump.messages);
|
|
153
|
+
expect(prepared.attribution.fromCheckpointId).toBe('cp_emergency_xyz');
|
|
154
|
+
});
|
|
155
|
+
it("throws when 'emergency' is requested without emergencyDir", async () => {
|
|
156
|
+
await expect(prepareReplayState({
|
|
157
|
+
baseDir,
|
|
158
|
+
runId: RUN_ID,
|
|
159
|
+
fromCheckpoint: 'emergency',
|
|
160
|
+
})).rejects.toThrow(/emergencyDir/);
|
|
161
|
+
});
|
|
162
|
+
it("throws when 'emergency' dump file is missing", async () => {
|
|
163
|
+
await expect(prepareReplayState({
|
|
164
|
+
baseDir,
|
|
165
|
+
runId: RUN_ID,
|
|
166
|
+
fromCheckpoint: 'emergency',
|
|
167
|
+
emergencyDir,
|
|
168
|
+
})).rejects.toThrow(/No emergency dump/);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
//# sourceMappingURL=prepare.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.test.js","sourceRoot":"","sources":["../../../../../src/runtime/query/replay/__tests__/prepare.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAMpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAElD,MAAM,MAAM,GAAG,YAAqB,CAAA;AAEpC,SAAS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BAAgB,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;QAC7D,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnD,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAChD,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IACvE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;QAC1E,MAAM,MAAM,CACX,kBAAkB,CAAC;YAClB,OAAO;YACP,KAAK,EAAE,MAAM;YACb,cAAc,EAAE,WAAW;SAC3B,CAAC,CACF,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;QAC7D,MAAM,MAAM,CACX,kBAAkB,CAAC;YAClB,OAAO;YACP,KAAK,EAAE,MAAM;YACb,cAAc,EAAE,WAAW;YAC3B,YAAY;SACZ,CAAC,CACF,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RunId } from '../../../types/ids/index.js';
|
|
2
|
+
import type { CheckpointListEntry } from '../../../types/run/replay.js';
|
|
3
|
+
import type { Logger } from '../../../utils/logger.js';
|
|
4
|
+
export interface ListCheckpointsInput {
|
|
5
|
+
/** Directory that contains `<runId>/` for the target run. */
|
|
6
|
+
baseDir: string;
|
|
7
|
+
/** Run whose checkpoints should be listed. */
|
|
8
|
+
runId: RunId;
|
|
9
|
+
logger?: Logger;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Read-only listing of a run's checkpoints for use with {@link
|
|
13
|
+
* import('./prepare.js').prepareReplayState}. Returns the public
|
|
14
|
+
* {@link CheckpointListEntry} projection — just enough for a caller to
|
|
15
|
+
* pick a fork point — not the full `IterationCheckpoint` payload.
|
|
16
|
+
*
|
|
17
|
+
* Entries are returned in the order the underlying store returns them
|
|
18
|
+
* (disk store sorts by `createdAt` ascending). Callers that want a
|
|
19
|
+
* specific order should sort client-side.
|
|
20
|
+
*
|
|
21
|
+
* See ses_005-deterministic-replay/design.md §3.1.
|
|
22
|
+
*/
|
|
23
|
+
export declare function listCheckpoints(input: ListCheckpointsInput): Promise<CheckpointListEntry[]>;
|
|
24
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/runtime/query/replay/list.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAGtD,MAAM,WAAW,oBAAoB;IACpC,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAA;IACf,8CAA8C;IAC9C,KAAK,EAAE,KAAK,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAKjG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RunDiskStore } from '../../../store/run/disk.js';
|
|
2
|
+
import { CheckpointManager } from '../checkpoint.js';
|
|
3
|
+
/**
|
|
4
|
+
* Read-only listing of a run's checkpoints for use with {@link
|
|
5
|
+
* import('./prepare.js').prepareReplayState}. Returns the public
|
|
6
|
+
* {@link CheckpointListEntry} projection — just enough for a caller to
|
|
7
|
+
* pick a fork point — not the full `IterationCheckpoint` payload.
|
|
8
|
+
*
|
|
9
|
+
* Entries are returned in the order the underlying store returns them
|
|
10
|
+
* (disk store sorts by `createdAt` ascending). Callers that want a
|
|
11
|
+
* specific order should sort client-side.
|
|
12
|
+
*
|
|
13
|
+
* See ses_005-deterministic-replay/design.md §3.1.
|
|
14
|
+
*/
|
|
15
|
+
export async function listCheckpoints(input) {
|
|
16
|
+
const store = new RunDiskStore({ baseDir: input.baseDir, logger: input.logger });
|
|
17
|
+
await store.initRun(input.runId);
|
|
18
|
+
const mgr = new CheckpointManager(store);
|
|
19
|
+
return mgr.listEntries();
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/runtime/query/replay/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAIzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAUpD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,KAA2B;IAChE,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;IAChF,MAAM,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAChC,MAAM,GAAG,GAAG,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAA;IACxC,OAAO,GAAG,CAAC,WAAW,EAAE,CAAA;AACzB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Message } from '../../../types/message/index.js';
|
|
2
|
+
import { type Mutation } from '../../../types/run/replay.js';
|
|
3
|
+
/**
|
|
4
|
+
* Apply an ordered list of {@link Mutation} to a checkpoint's message
|
|
5
|
+
* history at the fork point, producing a new message array that the
|
|
6
|
+
* resumed iteration loop consumes. Pure function; does not touch the run
|
|
7
|
+
* store, does not emit events.
|
|
8
|
+
*
|
|
9
|
+
* Throws {@link MutationNotApplicableError} when an `injectToolResponse`
|
|
10
|
+
* mutation targets a tool call id that is not pending at the fork point —
|
|
11
|
+
* the error payload carries the list of ids that *are* pending so the
|
|
12
|
+
* caller can recover without guessing.
|
|
13
|
+
*
|
|
14
|
+
* See ses_005-deterministic-replay design §3.3.
|
|
15
|
+
*/
|
|
16
|
+
export declare function applyMutations(messages: readonly Message[], mutations: readonly Mutation[]): Message[];
|
|
17
|
+
//# sourceMappingURL=mutate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutate.d.ts","sourceRoot":"","sources":["../../../../src/runtime/query/replay/mutate.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,OAAO,EAGZ,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,KAAK,QAAQ,EAA8B,MAAM,8BAA8B,CAAA;AA8BxF;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC7B,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,SAAS,EAAE,SAAS,QAAQ,EAAE,GAC5B,OAAO,EAAE,CAMX"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createToolMessage, } from '../../../types/message/index.js';
|
|
2
|
+
import { MutationNotApplicableError } from '../../../types/run/replay.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the tool calls on the most recent assistant message that do not
|
|
5
|
+
* yet have a matching {@link import('../../../types/message/index.js').ToolMessage}
|
|
6
|
+
* response further down the message list. These are the fork-point "pending"
|
|
7
|
+
* tool calls that mutations may target.
|
|
8
|
+
*/
|
|
9
|
+
function findPendingToolCalls(messages) {
|
|
10
|
+
let lastAssistantIdx = -1;
|
|
11
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
12
|
+
const msg = messages[i];
|
|
13
|
+
if (msg && msg.role === 'assistant' && (msg.toolCalls?.length ?? 0) > 0) {
|
|
14
|
+
lastAssistantIdx = i;
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (lastAssistantIdx === -1)
|
|
19
|
+
return [];
|
|
20
|
+
const assistant = messages[lastAssistantIdx];
|
|
21
|
+
const satisfied = new Set();
|
|
22
|
+
for (let i = lastAssistantIdx + 1; i < messages.length; i++) {
|
|
23
|
+
const msg = messages[i];
|
|
24
|
+
if (msg && msg.role === 'tool') {
|
|
25
|
+
satisfied.add(msg.toolCallId);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return (assistant.toolCalls ?? []).filter((tc) => !satisfied.has(tc.id));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Apply an ordered list of {@link Mutation} to a checkpoint's message
|
|
32
|
+
* history at the fork point, producing a new message array that the
|
|
33
|
+
* resumed iteration loop consumes. Pure function; does not touch the run
|
|
34
|
+
* store, does not emit events.
|
|
35
|
+
*
|
|
36
|
+
* Throws {@link MutationNotApplicableError} when an `injectToolResponse`
|
|
37
|
+
* mutation targets a tool call id that is not pending at the fork point —
|
|
38
|
+
* the error payload carries the list of ids that *are* pending so the
|
|
39
|
+
* caller can recover without guessing.
|
|
40
|
+
*
|
|
41
|
+
* See ses_005-deterministic-replay design §3.3.
|
|
42
|
+
*/
|
|
43
|
+
export function applyMutations(messages, mutations) {
|
|
44
|
+
let current = [...messages];
|
|
45
|
+
for (const m of mutations) {
|
|
46
|
+
current = applyOne(current, m);
|
|
47
|
+
}
|
|
48
|
+
return current;
|
|
49
|
+
}
|
|
50
|
+
function applyOne(messages, mutation) {
|
|
51
|
+
switch (mutation.type) {
|
|
52
|
+
case 'injectToolResponse': {
|
|
53
|
+
const pending = findPendingToolCalls(messages);
|
|
54
|
+
const match = pending.find((tc) => tc.id === mutation.toolCallId);
|
|
55
|
+
if (!match) {
|
|
56
|
+
throw new MutationNotApplicableError(`No pending tool call ${mutation.toolCallId} at fork point`, pending.map((tc) => tc.id));
|
|
57
|
+
}
|
|
58
|
+
return [...messages, createToolMessage(mutation.response.output, mutation.toolCallId)];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=mutate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutate.js","sourceRoot":"","sources":["../../../../src/runtime/query/replay/mutate.ts"],"names":[],"mappings":"AACA,OAAO,EAIN,iBAAiB,GACjB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAiB,0BAA0B,EAAE,MAAM,8BAA8B,CAAA;AAExF;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,QAA4B;IACzD,IAAI,gBAAgB,GAAG,CAAC,CAAC,CAAA;IACzB,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/C,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;QACvB,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;YACzE,gBAAgB,GAAG,CAAC,CAAA;YACpB,MAAK;QACN,CAAC;IACF,CAAC;IACD,IAAI,gBAAgB,KAAK,CAAC,CAAC;QAAE,OAAO,EAAE,CAAA;IAEtC,MAAM,SAAS,GAAG,QAAQ,CAAC,gBAAgB,CAAqB,CAAA;IAChE,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAA;IACnC,KAAK,IAAI,CAAC,GAAG,gBAAgB,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7D,MAAM,GAAG,GAAG,QAAQ,CAAC,CA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AC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAA;QACvF,CAAC;IACF,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { CheckpointId, IterationCheckpoint } from '../../../types/hitl/index.js';
|
|
2
|
+
import type { RunId } from '../../../types/ids/index.js';
|
|
3
|
+
import type { Message } from '../../../types/message/index.js';
|
|
4
|
+
import type { Mutation, ReplayAttribution } from '../../../types/run/replay.js';
|
|
5
|
+
import type { Logger } from '../../../utils/logger.js';
|
|
6
|
+
export type CheckpointSelector = CheckpointId | 'latest' | 'emergency';
|
|
7
|
+
export interface PrepareReplayInput {
|
|
8
|
+
/** Directory that contains `<runId>/` for the source run. */
|
|
9
|
+
baseDir: string;
|
|
10
|
+
/** Source run to fork from. */
|
|
11
|
+
runId: RunId;
|
|
12
|
+
/** Which checkpoint to fork at. */
|
|
13
|
+
fromCheckpoint: CheckpointSelector;
|
|
14
|
+
/** Optional mutations applied at the fork point before the caller hands state to `query()`. */
|
|
15
|
+
mutate?: Mutation[];
|
|
16
|
+
/**
|
|
17
|
+
* Directory that holds emergency dumps. Required only when `fromCheckpoint`
|
|
18
|
+
* is `'emergency'`; conventionally sibling of `baseDir` (the `.namzu/emergency`
|
|
19
|
+
* folder), but left explicit so callers with non-default layouts can redirect.
|
|
20
|
+
*/
|
|
21
|
+
emergencyDir?: string;
|
|
22
|
+
logger?: Logger;
|
|
23
|
+
}
|
|
24
|
+
export interface PreparedReplayState {
|
|
25
|
+
/**
|
|
26
|
+
* Message history at the fork point, with mutations applied. Seed this
|
|
27
|
+
* as the new run's initial messages and pass `sourceCheckpoint.id` as
|
|
28
|
+
* `resumeFromCheckpoint` when you call `query()`.
|
|
29
|
+
*/
|
|
30
|
+
messages: Message[];
|
|
31
|
+
/** The checkpoint the replay forks from (already projected if emergency). */
|
|
32
|
+
sourceCheckpoint: IterationCheckpoint;
|
|
33
|
+
/**
|
|
34
|
+
* Attribution to stamp on the replay run once it is created. The caller
|
|
35
|
+
* sets `Run.replayOf = buildAttribution(prepared, replayedAt)` on the
|
|
36
|
+
* new `RunPersistence` before persisting the first time.
|
|
37
|
+
*/
|
|
38
|
+
attribution: ReplayAttribution;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Produce the state materials needed to execute a replay run — the mutated
|
|
42
|
+
* message history, the resolved source checkpoint, and the replay
|
|
43
|
+
* attribution record. Pure read; does not touch the run store beyond
|
|
44
|
+
* reading the source run's checkpoint files.
|
|
45
|
+
*
|
|
46
|
+
* This is the state-preparation half of the replay primitive. The
|
|
47
|
+
* caller is expected to thread the returned `messages` +
|
|
48
|
+
* `sourceCheckpoint.id` into `query({ resumeFromCheckpoint, messages,
|
|
49
|
+
* ... })` and stamp `Run.replayOf = prepared.attribution` on the resulting
|
|
50
|
+
* run. The end-to-end `replay()` entry that does all of this in one call
|
|
51
|
+
* is a follow-up session (`ReplayEnvironment` shape).
|
|
52
|
+
*
|
|
53
|
+
* See `ses_005-deterministic-replay/design.md` §3.1.
|
|
54
|
+
*/
|
|
55
|
+
export declare function prepareReplayState(input: PrepareReplayInput): Promise<PreparedReplayState>;
|
|
56
|
+
//# sourceMappingURL=prepare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../../../src/runtime/query/replay/prepare.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAItD,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,QAAQ,GAAG,WAAW,CAAA;AAEtE,MAAM,WAAW,kBAAkB;IAClC,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAA;IACf,+BAA+B;IAC/B,KAAK,EAAE,KAAK,CAAA;IACZ,mCAAmC;IACnC,cAAc,EAAE,kBAAkB,CAAA;IAClC,+FAA+F;IAC/F,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAA;IACnB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,6EAA6E;IAC7E,gBAAgB,EAAE,mBAAmB,CAAA;IACrC;;;;OAIG;IACH,WAAW,EAAE,iBAAiB,CAAA;CAC9B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAahG"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { EmergencySaveManager } from '../../../manager/run/emergency.js';
|
|
3
|
+
import { RunDiskStore } from '../../../store/run/disk.js';
|
|
4
|
+
import { projectEmergencyToCheckpoint } from '../checkpoint.js';
|
|
5
|
+
import { applyMutations } from './mutate.js';
|
|
6
|
+
/**
|
|
7
|
+
* Produce the state materials needed to execute a replay run — the mutated
|
|
8
|
+
* message history, the resolved source checkpoint, and the replay
|
|
9
|
+
* attribution record. Pure read; does not touch the run store beyond
|
|
10
|
+
* reading the source run's checkpoint files.
|
|
11
|
+
*
|
|
12
|
+
* This is the state-preparation half of the replay primitive. The
|
|
13
|
+
* caller is expected to thread the returned `messages` +
|
|
14
|
+
* `sourceCheckpoint.id` into `query({ resumeFromCheckpoint, messages,
|
|
15
|
+
* ... })` and stamp `Run.replayOf = prepared.attribution` on the resulting
|
|
16
|
+
* run. The end-to-end `replay()` entry that does all of this in one call
|
|
17
|
+
* is a follow-up session (`ReplayEnvironment` shape).
|
|
18
|
+
*
|
|
19
|
+
* See `ses_005-deterministic-replay/design.md` §3.1.
|
|
20
|
+
*/
|
|
21
|
+
export async function prepareReplayState(input) {
|
|
22
|
+
const sourceCheckpoint = await resolveCheckpoint(input);
|
|
23
|
+
const mutations = input.mutate ?? [];
|
|
24
|
+
const messages = applyMutations(sourceCheckpoint.messages, mutations);
|
|
25
|
+
const attribution = {
|
|
26
|
+
sourceRunId: input.runId,
|
|
27
|
+
fromCheckpointId: sourceCheckpoint.id,
|
|
28
|
+
mutations,
|
|
29
|
+
replayedAt: Date.now(),
|
|
30
|
+
};
|
|
31
|
+
return { messages, sourceCheckpoint, attribution };
|
|
32
|
+
}
|
|
33
|
+
async function resolveCheckpoint(input) {
|
|
34
|
+
if (input.fromCheckpoint === 'emergency') {
|
|
35
|
+
return resolveEmergency(input);
|
|
36
|
+
}
|
|
37
|
+
const store = new RunDiskStore({ baseDir: input.baseDir, logger: input.logger });
|
|
38
|
+
await store.initRun(input.runId);
|
|
39
|
+
if (input.fromCheckpoint === 'latest') {
|
|
40
|
+
const all = await store.listCheckpoints();
|
|
41
|
+
if (all.length === 0) {
|
|
42
|
+
throw new Error(`No checkpoints found for run ${input.runId} in ${input.baseDir}`);
|
|
43
|
+
}
|
|
44
|
+
return [...all].sort((a, b) => b.iteration - a.iteration)[0];
|
|
45
|
+
}
|
|
46
|
+
const checkpoint = await store.readCheckpoint(input.fromCheckpoint);
|
|
47
|
+
if (!checkpoint) {
|
|
48
|
+
throw new Error(`Checkpoint ${input.fromCheckpoint} not found for run ${input.runId}`);
|
|
49
|
+
}
|
|
50
|
+
return checkpoint;
|
|
51
|
+
}
|
|
52
|
+
async function resolveEmergency(input) {
|
|
53
|
+
if (!input.emergencyDir) {
|
|
54
|
+
throw new Error("fromCheckpoint: 'emergency' requires an `emergencyDir` — conventionally sibling of baseDir");
|
|
55
|
+
}
|
|
56
|
+
const path = join(input.emergencyDir, `${input.runId}.json`);
|
|
57
|
+
try {
|
|
58
|
+
const dump = EmergencySaveManager.loadSave(path);
|
|
59
|
+
return projectEmergencyToCheckpoint(dump);
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
throw new Error(`No emergency dump found for run ${input.runId} at ${path}`, { cause: err });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=prepare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../../../src/runtime/query/replay/prepare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAMzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAuC5C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAAyB;IACjE,MAAM,gBAAgB,GAAG,MAAM,iBAAiB,CAAC,KAAK,CAAC,CAAA;IACvD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,IAAI,EAAE,CAAA;IACpC,MAAM,QAAQ,GAAG,cAAc,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;IAErE,MAAM,WAAW,GAAsB;QACtC,WAAW,EAAE,KAAK,CAAC,KAAK;QACxB,gBAAgB,EAAE,gBAAgB,CAAC,EAAE;QACrC,SAAS;QACT,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;KACtB,CAAA;IAED,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAA;AACnD,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,KAAyB;IACzD,IAAI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,GAAG,KAAK,CAAC,KAAK,OAAO,CAAC,CAAA;IAC5D,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAChD,OAAO,4BAA4B,CAAC,IAAI,CAAC,CAAA;IAC1C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,CAAC,KAAK,OAAO,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IAC7F,CAAC;AACF,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { type Span } from '@opentelemetry/api';
|
|
|
2
2
|
import type { PlanManager } from '../../manager/plan/lifecycle.js';
|
|
3
3
|
import type { RunPersistence } from '../../manager/run/persistence.js';
|
|
4
4
|
import type { ActivityStore } from '../../store/activity/memory.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { Run, RunEvent } from '../../types/run/index.js';
|
|
6
6
|
import type { Logger } from '../../utils/logger.js';
|
|
7
7
|
import type { EmitEvent } from './events.js';
|
|
8
8
|
export interface ResultAssemblerConfig {
|
|
@@ -19,6 +19,6 @@ export declare class ResultAssembler {
|
|
|
19
19
|
completeRun(rootSpan: Span): AsyncGenerator<RunEvent>;
|
|
20
20
|
completeSession(rootSpan: Span): AsyncGenerator<RunEvent>;
|
|
21
21
|
handleError(err: unknown, rootSpan: Span): AsyncGenerator<RunEvent>;
|
|
22
|
-
finalize(): Promise<
|
|
22
|
+
finalize(): Promise<Run>;
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=result.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../../src/runtime/query/result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAkB,MAAM,oBAAoB,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAClE,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