@namzu/sdk 0.4.0 → 0.4.2
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 +86 -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/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js.map +1 -1
- 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/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/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/rag-tool.d.ts +1 -1
- 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/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/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/package.json +1 -1
- package/src/__tests__/replay-public-surface.test.ts +54 -0
- package/src/agents/SupervisorAgent.ts +1 -1
- package/src/bridge/a2a/task.ts +4 -4
- package/src/config/runtime.ts +0 -2
- 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/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/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/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/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,76 @@
|
|
|
1
|
+
import type { ToolCallId } from '../../../types/ids/index.js'
|
|
2
|
+
import {
|
|
3
|
+
type AssistantMessage,
|
|
4
|
+
type Message,
|
|
5
|
+
type ToolCall,
|
|
6
|
+
createToolMessage,
|
|
7
|
+
} from '../../../types/message/index.js'
|
|
8
|
+
import { type Mutation, MutationNotApplicableError } from '../../../types/run/replay.js'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Returns the tool calls on the most recent assistant message that do not
|
|
12
|
+
* yet have a matching {@link import('../../../types/message/index.js').ToolMessage}
|
|
13
|
+
* response further down the message list. These are the fork-point "pending"
|
|
14
|
+
* tool calls that mutations may target.
|
|
15
|
+
*/
|
|
16
|
+
function findPendingToolCalls(messages: readonly Message[]): ToolCall[] {
|
|
17
|
+
let lastAssistantIdx = -1
|
|
18
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
19
|
+
const msg = messages[i]
|
|
20
|
+
if (msg && msg.role === 'assistant' && (msg.toolCalls?.length ?? 0) > 0) {
|
|
21
|
+
lastAssistantIdx = i
|
|
22
|
+
break
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (lastAssistantIdx === -1) return []
|
|
26
|
+
|
|
27
|
+
const assistant = messages[lastAssistantIdx] as AssistantMessage
|
|
28
|
+
const satisfied = new Set<string>()
|
|
29
|
+
for (let i = lastAssistantIdx + 1; i < messages.length; i++) {
|
|
30
|
+
const msg = messages[i]
|
|
31
|
+
if (msg && msg.role === 'tool') {
|
|
32
|
+
satisfied.add(msg.toolCallId)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return (assistant.toolCalls ?? []).filter((tc) => !satisfied.has(tc.id))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Apply an ordered list of {@link Mutation} to a checkpoint's message
|
|
40
|
+
* history at the fork point, producing a new message array that the
|
|
41
|
+
* resumed iteration loop consumes. Pure function; does not touch the run
|
|
42
|
+
* store, does not emit events.
|
|
43
|
+
*
|
|
44
|
+
* Throws {@link MutationNotApplicableError} when an `injectToolResponse`
|
|
45
|
+
* mutation targets a tool call id that is not pending at the fork point —
|
|
46
|
+
* the error payload carries the list of ids that *are* pending so the
|
|
47
|
+
* caller can recover without guessing.
|
|
48
|
+
*
|
|
49
|
+
* See ses_005-deterministic-replay design §3.3.
|
|
50
|
+
*/
|
|
51
|
+
export function applyMutations(
|
|
52
|
+
messages: readonly Message[],
|
|
53
|
+
mutations: readonly Mutation[],
|
|
54
|
+
): Message[] {
|
|
55
|
+
let current: Message[] = [...messages]
|
|
56
|
+
for (const m of mutations) {
|
|
57
|
+
current = applyOne(current, m)
|
|
58
|
+
}
|
|
59
|
+
return current
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function applyOne(messages: Message[], mutation: Mutation): Message[] {
|
|
63
|
+
switch (mutation.type) {
|
|
64
|
+
case 'injectToolResponse': {
|
|
65
|
+
const pending = findPendingToolCalls(messages)
|
|
66
|
+
const match = pending.find((tc) => tc.id === mutation.toolCallId)
|
|
67
|
+
if (!match) {
|
|
68
|
+
throw new MutationNotApplicableError(
|
|
69
|
+
`No pending tool call ${mutation.toolCallId} at fork point`,
|
|
70
|
+
pending.map((tc) => tc.id as ToolCallId),
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
return [...messages, createToolMessage(mutation.response.output, mutation.toolCallId)]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { join } from 'node:path'
|
|
2
|
+
import { EmergencySaveManager } from '../../../manager/run/emergency.js'
|
|
3
|
+
import { RunDiskStore } from '../../../store/run/disk.js'
|
|
4
|
+
import type { CheckpointId, IterationCheckpoint } from '../../../types/hitl/index.js'
|
|
5
|
+
import type { RunId } from '../../../types/ids/index.js'
|
|
6
|
+
import type { Message } from '../../../types/message/index.js'
|
|
7
|
+
import type { Mutation, ReplayAttribution } from '../../../types/run/replay.js'
|
|
8
|
+
import type { Logger } from '../../../utils/logger.js'
|
|
9
|
+
import { projectEmergencyToCheckpoint } from '../checkpoint.js'
|
|
10
|
+
import { applyMutations } from './mutate.js'
|
|
11
|
+
|
|
12
|
+
export type CheckpointSelector = CheckpointId | 'latest' | 'emergency'
|
|
13
|
+
|
|
14
|
+
export interface PrepareReplayInput {
|
|
15
|
+
/** Directory that contains `<runId>/` for the source run. */
|
|
16
|
+
baseDir: string
|
|
17
|
+
/** Source run to fork from. */
|
|
18
|
+
runId: RunId
|
|
19
|
+
/** Which checkpoint to fork at. */
|
|
20
|
+
fromCheckpoint: CheckpointSelector
|
|
21
|
+
/** Optional mutations applied at the fork point before the caller hands state to `query()`. */
|
|
22
|
+
mutate?: Mutation[]
|
|
23
|
+
/**
|
|
24
|
+
* Directory that holds emergency dumps. Required only when `fromCheckpoint`
|
|
25
|
+
* is `'emergency'`; conventionally sibling of `baseDir` (the `.namzu/emergency`
|
|
26
|
+
* folder), but left explicit so callers with non-default layouts can redirect.
|
|
27
|
+
*/
|
|
28
|
+
emergencyDir?: string
|
|
29
|
+
logger?: Logger
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface PreparedReplayState {
|
|
33
|
+
/**
|
|
34
|
+
* Message history at the fork point, with mutations applied. Seed this
|
|
35
|
+
* as the new run's initial messages and pass `sourceCheckpoint.id` as
|
|
36
|
+
* `resumeFromCheckpoint` when you call `query()`.
|
|
37
|
+
*/
|
|
38
|
+
messages: Message[]
|
|
39
|
+
/** The checkpoint the replay forks from (already projected if emergency). */
|
|
40
|
+
sourceCheckpoint: IterationCheckpoint
|
|
41
|
+
/**
|
|
42
|
+
* Attribution to stamp on the replay run once it is created. The caller
|
|
43
|
+
* sets `Run.replayOf = buildAttribution(prepared, replayedAt)` on the
|
|
44
|
+
* new `RunPersistence` before persisting the first time.
|
|
45
|
+
*/
|
|
46
|
+
attribution: ReplayAttribution
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Produce the state materials needed to execute a replay run — the mutated
|
|
51
|
+
* message history, the resolved source checkpoint, and the replay
|
|
52
|
+
* attribution record. Pure read; does not touch the run store beyond
|
|
53
|
+
* reading the source run's checkpoint files.
|
|
54
|
+
*
|
|
55
|
+
* This is the state-preparation half of the replay primitive. The
|
|
56
|
+
* caller is expected to thread the returned `messages` +
|
|
57
|
+
* `sourceCheckpoint.id` into `query({ resumeFromCheckpoint, messages,
|
|
58
|
+
* ... })` and stamp `Run.replayOf = prepared.attribution` on the resulting
|
|
59
|
+
* run. The end-to-end `replay()` entry that does all of this in one call
|
|
60
|
+
* is a follow-up session (`ReplayEnvironment` shape).
|
|
61
|
+
*
|
|
62
|
+
* See `ses_005-deterministic-replay/design.md` §3.1.
|
|
63
|
+
*/
|
|
64
|
+
export async function prepareReplayState(input: PrepareReplayInput): Promise<PreparedReplayState> {
|
|
65
|
+
const sourceCheckpoint = await resolveCheckpoint(input)
|
|
66
|
+
const mutations = input.mutate ?? []
|
|
67
|
+
const messages = applyMutations(sourceCheckpoint.messages, mutations)
|
|
68
|
+
|
|
69
|
+
const attribution: ReplayAttribution = {
|
|
70
|
+
sourceRunId: input.runId,
|
|
71
|
+
fromCheckpointId: sourceCheckpoint.id,
|
|
72
|
+
mutations,
|
|
73
|
+
replayedAt: Date.now(),
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return { messages, sourceCheckpoint, attribution }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function resolveCheckpoint(input: PrepareReplayInput): Promise<IterationCheckpoint> {
|
|
80
|
+
if (input.fromCheckpoint === 'emergency') {
|
|
81
|
+
return resolveEmergency(input)
|
|
82
|
+
}
|
|
83
|
+
const store = new RunDiskStore({ baseDir: input.baseDir, logger: input.logger })
|
|
84
|
+
await store.initRun(input.runId)
|
|
85
|
+
|
|
86
|
+
if (input.fromCheckpoint === 'latest') {
|
|
87
|
+
const all = await store.listCheckpoints()
|
|
88
|
+
if (all.length === 0) {
|
|
89
|
+
throw new Error(`No checkpoints found for run ${input.runId} in ${input.baseDir}`)
|
|
90
|
+
}
|
|
91
|
+
return [...all].sort((a, b) => b.iteration - a.iteration)[0] as IterationCheckpoint
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const checkpoint = await store.readCheckpoint(input.fromCheckpoint)
|
|
95
|
+
if (!checkpoint) {
|
|
96
|
+
throw new Error(`Checkpoint ${input.fromCheckpoint} not found for run ${input.runId}`)
|
|
97
|
+
}
|
|
98
|
+
return checkpoint
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function resolveEmergency(input: PrepareReplayInput): Promise<IterationCheckpoint> {
|
|
102
|
+
if (!input.emergencyDir) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
"fromCheckpoint: 'emergency' requires an `emergencyDir` — conventionally sibling of baseDir",
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
const path = join(input.emergencyDir, `${input.runId}.json`)
|
|
108
|
+
try {
|
|
109
|
+
const dump = EmergencySaveManager.loadSave(path)
|
|
110
|
+
return projectEmergencyToCheckpoint(dump)
|
|
111
|
+
} catch (err) {
|
|
112
|
+
throw new Error(`No emergency dump found for run ${input.runId} at ${path}`, { cause: err })
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -3,7 +3,7 @@ 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
5
|
import { GENAI, NAMZU } from '../../telemetry/attributes.js'
|
|
6
|
-
import type {
|
|
6
|
+
import type { Run, RunEvent } from '../../types/run/index.js'
|
|
7
7
|
import { toErrorMessage } from '../../utils/error.js'
|
|
8
8
|
import type { Logger } from '../../utils/logger.js'
|
|
9
9
|
import type { EmitEvent } from './events.js'
|
|
@@ -87,7 +87,7 @@ export class ResultAssembler {
|
|
|
87
87
|
})
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
async finalize(): Promise<
|
|
90
|
+
async finalize(): Promise<Run> {
|
|
91
91
|
await this.config.runMgr.persist()
|
|
92
92
|
return this.config.runMgr.getRun()
|
|
93
93
|
}
|
|
@@ -30,11 +30,11 @@ import type { AgentDefinition } from '../../../types/agent/factory.js'
|
|
|
30
30
|
import type { AgentTaskContext, SendMessageOptions } from '../../../types/agent/task.js'
|
|
31
31
|
import type { AgentId, RunId, SessionId, TenantId, UserId } from '../../../types/ids/index.js'
|
|
32
32
|
import { createAssistantMessage } from '../../../types/message/index.js'
|
|
33
|
+
import type { ActorRef } from '../../../types/session/actor.js'
|
|
34
|
+
import type { Session } from '../../../types/session/entity.js'
|
|
33
35
|
import type { ProjectId, SummaryId, ThreadId } from '../../../types/session/ids.js'
|
|
34
36
|
import { ZERO_COST } from '../../../utils/cost.js'
|
|
35
37
|
import { DefaultCapacityValidator } from '../../handoff/capacity.js'
|
|
36
|
-
import type { ActorRef } from '../../hierarchy/actor.js'
|
|
37
|
-
import type { Session } from '../../hierarchy/session.js'
|
|
38
38
|
import { SessionSummaryMaterializer } from '../../summary/materialize.js'
|
|
39
39
|
import type { ExecFile, ExecFileResult } from '../../workspace/git-worktree.js'
|
|
40
40
|
import { GitWorktreeDriver } from '../../workspace/git-worktree.js'
|
|
@@ -17,6 +17,7 @@ import { ThreadManager } from '../../../manager/thread/lifecycle.js'
|
|
|
17
17
|
import { InMemorySessionStore } from '../../../store/session/memory.js'
|
|
18
18
|
import { InMemoryThreadStore } from '../../../store/thread/memory.js'
|
|
19
19
|
import type { AgentId, RunId, UserId } from '../../../types/ids/index.js'
|
|
20
|
+
import type { ActorRef } from '../../../types/session/actor.js'
|
|
20
21
|
import { generateHandoffId } from '../../../utils/id.js'
|
|
21
22
|
import { ThreadClosedError } from '../../errors.js'
|
|
22
23
|
import type { HandoffAssignment } from '../../handoff/assignment.js'
|
|
@@ -24,7 +25,6 @@ import { type BroadcastHandoffDeps, executeBroadcastHandoff } from '../../handof
|
|
|
24
25
|
import { DefaultCapacityValidator } from '../../handoff/capacity.js'
|
|
25
26
|
import type { HandoffEventSink } from '../../handoff/events.js'
|
|
26
27
|
import { type SingleHandoffDeps, executeSingleHandoff } from '../../handoff/single.js'
|
|
27
|
-
import type { ActorRef } from '../../hierarchy/actor.js'
|
|
28
28
|
import { GitWorktreeDriver } from '../../workspace/git-worktree.js'
|
|
29
29
|
import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
|
|
30
30
|
import {
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { describe, expect, it } from 'vitest'
|
|
14
|
+
import type { ActorRef } from '../../../types/session/actor.js'
|
|
14
15
|
import { DelegationCapacityExceeded } from '../../handoff/capacity.js'
|
|
15
|
-
import type { ActorRef } from '../../hierarchy/actor.js'
|
|
16
16
|
import {
|
|
17
17
|
DEFAULT_TENANT,
|
|
18
18
|
agentActor,
|
|
@@ -34,10 +34,10 @@ import type { AgentTaskContext, SendMessageOptions } from '../../../types/agent/
|
|
|
34
34
|
import type { RunId, TenantId, UserId } from '../../../types/ids/index.js'
|
|
35
35
|
import { createAssistantMessage } from '../../../types/message/index.js'
|
|
36
36
|
import type { RunEvent } from '../../../types/run/events.js'
|
|
37
|
+
import type { ActorRef } from '../../../types/session/actor.js'
|
|
37
38
|
import type { SummaryId } from '../../../types/session/ids.js'
|
|
38
39
|
import { ZERO_COST } from '../../../utils/cost.js'
|
|
39
40
|
import { DefaultCapacityValidator } from '../../handoff/capacity.js'
|
|
40
|
-
import type { ActorRef } from '../../hierarchy/actor.js'
|
|
41
41
|
import { SessionSummaryMaterializer } from '../../summary/materialize.js'
|
|
42
42
|
import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
|
|
43
43
|
|
|
@@ -14,13 +14,13 @@ import { ThreadManager } from '../../../manager/thread/lifecycle.js'
|
|
|
14
14
|
import { InMemorySessionStore } from '../../../store/session/memory.js'
|
|
15
15
|
import { InMemoryThreadStore } from '../../../store/thread/memory.js'
|
|
16
16
|
import type { SessionId } from '../../../types/ids/index.js'
|
|
17
|
+
import type { ActorRef } from '../../../types/session/actor.js'
|
|
17
18
|
import type { ProjectId, ThreadId } from '../../../types/session/ids.js'
|
|
18
19
|
import { generateHandoffId } from '../../../utils/id.js'
|
|
19
20
|
import type { HandoffAssignment } from '../../handoff/assignment.js'
|
|
20
21
|
import { type BroadcastHandoffDeps, executeBroadcastHandoff } from '../../handoff/broadcast.js'
|
|
21
22
|
import { DefaultCapacityValidator } from '../../handoff/capacity.js'
|
|
22
23
|
import type { HandoffEventSink } from '../../handoff/events.js'
|
|
23
|
-
import type { ActorRef } from '../../hierarchy/actor.js'
|
|
24
24
|
import type { ExecFile } from '../../workspace/git-worktree.js'
|
|
25
25
|
import { GitWorktreeDriver } from '../../workspace/git-worktree.js'
|
|
26
26
|
import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
|
|
@@ -17,13 +17,13 @@ import { ThreadManager } from '../../../manager/thread/lifecycle.js'
|
|
|
17
17
|
import { InMemorySessionStore } from '../../../store/session/memory.js'
|
|
18
18
|
import { InMemoryThreadStore } from '../../../store/thread/memory.js'
|
|
19
19
|
import type { TenantId } from '../../../types/ids/index.js'
|
|
20
|
+
import type { Session } from '../../../types/session/entity.js'
|
|
20
21
|
import { generateHandoffId } from '../../../utils/id.js'
|
|
21
22
|
import { TenantIsolationError } from '../../errors.js'
|
|
22
23
|
import type { HandoffAssignment } from '../../handoff/assignment.js'
|
|
23
24
|
import { DefaultCapacityValidator } from '../../handoff/capacity.js'
|
|
24
25
|
import type { HandoffEventSink } from '../../handoff/events.js'
|
|
25
26
|
import { type SingleHandoffDeps, executeSingleHandoff } from '../../handoff/single.js'
|
|
26
|
-
import type { Session } from '../../hierarchy/session.js'
|
|
27
27
|
import { GitWorktreeDriver } from '../../workspace/git-worktree.js'
|
|
28
28
|
import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
|
|
29
29
|
import { DEFAULT_TENANT, OTHER_TENANT, okExec, stubLogger, userActor } from './_fixtures.js'
|
|
@@ -20,13 +20,16 @@ import type {
|
|
|
20
20
|
SummaryId,
|
|
21
21
|
ThreadId,
|
|
22
22
|
} from '../../../types/session/ids.js'
|
|
23
|
+
import type {
|
|
24
|
+
DeliverableRef,
|
|
25
|
+
SessionSummaryDeliverable,
|
|
26
|
+
} from '../../../types/summary/deliverable.js'
|
|
23
27
|
import {
|
|
24
28
|
ArtifactRefCycleError,
|
|
25
29
|
type InterventionChainLoader,
|
|
26
30
|
InterventionDepthExceeded,
|
|
27
31
|
validatePrevArtifactChain,
|
|
28
32
|
} from '../../intervention/prev-artifact.js'
|
|
29
|
-
import type { DeliverableRef, SessionSummaryDeliverable } from '../../summary/deliverable.js'
|
|
30
33
|
import { DEFAULT_TENANT, agentActor, userActor } from './_fixtures.js'
|
|
31
34
|
|
|
32
35
|
const TEST_THREAD_ID = 'thd_test' as ThreadId
|
|
@@ -16,9 +16,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
16
16
|
import { InMemorySessionStore } from '../../../store/session/memory.js'
|
|
17
17
|
import { createUserMessage } from '../../../types/message/index.js'
|
|
18
18
|
import type { ThreadId, WorkspaceId } from '../../../types/session/ids.js'
|
|
19
|
+
import type { WorkspaceRef } from '../../../types/workspace/ref.js'
|
|
19
20
|
import { ArchivalManager, ArchiveNotConfiguredError } from '../../retention/archive.js'
|
|
20
21
|
import { DiskArchiveBackend } from '../../retention/disk-backend.js'
|
|
21
|
-
import type { WorkspaceRef } from '../../workspace/ref.js'
|
|
22
22
|
import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
|
|
23
23
|
import { DEFAULT_TENANT, agentActor, userActor } from './_fixtures.js'
|
|
24
24
|
|
|
@@ -41,10 +41,11 @@ import type { AgentDefinition } from '../../../types/agent/factory.js'
|
|
|
41
41
|
import type { AgentTaskContext, SendMessageOptions } from '../../../types/agent/task.js'
|
|
42
42
|
import type { RunId, TenantId, UserId } from '../../../types/ids/index.js'
|
|
43
43
|
import { createAssistantMessage } from '../../../types/message/index.js'
|
|
44
|
+
import type { ActorRef } from '../../../types/session/actor.js'
|
|
44
45
|
import type { SummaryId } from '../../../types/session/ids.js'
|
|
46
|
+
import type { WorkspaceRef } from '../../../types/workspace/ref.js'
|
|
45
47
|
import { ZERO_COST } from '../../../utils/cost.js'
|
|
46
48
|
import { DefaultCapacityValidator } from '../../handoff/capacity.js'
|
|
47
|
-
import type { ActorRef } from '../../hierarchy/actor.js'
|
|
48
49
|
import { SessionSummaryMaterializer } from '../../summary/materialize.js'
|
|
49
50
|
import type {
|
|
50
51
|
BranchWorkspaceParams,
|
|
@@ -52,7 +53,6 @@ import type {
|
|
|
52
53
|
WorkspaceBackendDriver,
|
|
53
54
|
WorkspaceInspection,
|
|
54
55
|
} from '../../workspace/driver.js'
|
|
55
|
-
import type { WorkspaceRef } from '../../workspace/ref.js'
|
|
56
56
|
import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
|
|
57
57
|
|
|
58
58
|
const tenant = 'tnt_alpha' as TenantId
|
|
@@ -19,8 +19,8 @@ import { describe, expect, it } from 'vitest'
|
|
|
19
19
|
import { InMemorySessionStore } from '../../../store/session/memory.js'
|
|
20
20
|
import type { SessionId } from '../../../types/ids/index.js'
|
|
21
21
|
import type { SummaryId, ThreadId } from '../../../types/session/ids.js'
|
|
22
|
+
import { SessionAlreadySummarizedError } from '../../summary/errors.js'
|
|
22
23
|
import { SessionSummaryMaterializer } from '../../summary/materialize.js'
|
|
23
|
-
import { SessionAlreadySummarizedError } from '../../summary/ref.js'
|
|
24
24
|
import { DEFAULT_TENANT, agentActor } from './_fixtures.js'
|
|
25
25
|
|
|
26
26
|
const TEST_THREAD_ID = 'thd_test' as ThreadId
|
package/src/session/errors.ts
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { SessionId, TenantId } from '../types/ids/index.js'
|
|
11
|
+
import type { SessionStatus } from '../types/session/entity.js'
|
|
11
12
|
import type { ThreadId } from '../types/session/ids.js'
|
|
12
|
-
import type { SessionStatus } from './hierarchy/session.js'
|
|
13
13
|
import type { WorkspaceBackendKind } from './workspace/driver.js'
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
// Sub-barrel for session-hierarchy run-event surface.
|
|
2
|
-
//
|
|
2
|
+
// Shape types live under `types/run/` (subsession-events.ts + schema-version.ts);
|
|
3
|
+
// this barrel only re-exports them. No runtime emitter lives here today.
|
|
3
4
|
//
|
|
4
5
|
// Phase 2 scope is limited to the sub-session lifecycle variants that are
|
|
5
6
|
// spliced into `RunEvent`. A dedicated `SessionHierarchyEvent` top-level
|
|
6
7
|
// union lands in a later phase (see session-hierarchy.md §10.2).
|
|
7
8
|
|
|
8
|
-
export { RUN_EVENT_SCHEMA_VERSION } from '
|
|
9
|
-
export type { RunEventSchemaVersion } from '
|
|
9
|
+
export { RUN_EVENT_SCHEMA_VERSION } from '../../types/run/schema-version.js'
|
|
10
|
+
export type { RunEventSchemaVersion } from '../../types/run/schema-version.js'
|
|
10
11
|
|
|
11
12
|
export type {
|
|
12
13
|
SubsessionSpawnedEvent,
|
|
13
14
|
SubsessionMessagedEvent,
|
|
14
15
|
SubsessionIdledEvent,
|
|
15
16
|
SubsessionLifecycleEvent,
|
|
16
|
-
} from '
|
|
17
|
+
} from '../../types/run/subsession-events.js'
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
2
|
import { ThreadManager } from '../../../manager/thread/lifecycle.js'
|
|
3
|
-
import type { ActorRef } from '../../../session/hierarchy/actor.js'
|
|
4
3
|
import {
|
|
5
4
|
type ExecFile,
|
|
6
5
|
type ExecFileResult,
|
|
@@ -10,6 +9,7 @@ import { WorkspaceBackendRegistry } from '../../../session/workspace/registry.js
|
|
|
10
9
|
import { InMemorySessionStore } from '../../../store/session/memory.js'
|
|
11
10
|
import { InMemoryThreadStore } from '../../../store/thread/memory.js'
|
|
12
11
|
import type { SessionId, TenantId, UserId } from '../../../types/ids/index.js'
|
|
12
|
+
import type { ActorRef } from '../../../types/session/actor.js'
|
|
13
13
|
import type { ProjectId } from '../../../types/session/ids.js'
|
|
14
14
|
import { generateHandoffId } from '../../../utils/id.js'
|
|
15
15
|
import type { HandoffAssignment } from '../assignment.js'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import type { ActorRef } from '../../../session/hierarchy/actor.js'
|
|
3
2
|
import { InMemorySessionStore } from '../../../store/session/memory.js'
|
|
4
3
|
import { InMemoryThreadStore } from '../../../store/thread/memory.js'
|
|
5
4
|
import type { AgentId, SessionId, TenantId, UserId } from '../../../types/ids/index.js'
|
|
5
|
+
import type { ActorRef } from '../../../types/session/actor.js'
|
|
6
6
|
import type { ProjectId, ThreadId } from '../../../types/session/ids.js'
|
|
7
7
|
import { DefaultCapacityValidator, DelegationCapacityExceeded } from '../capacity.js'
|
|
8
8
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
2
|
import { ThreadManager } from '../../../manager/thread/lifecycle.js'
|
|
3
3
|
import { TenantIsolationError } from '../../../session/errors.js'
|
|
4
|
-
import type { ActorRef } from '../../../session/hierarchy/actor.js'
|
|
5
4
|
import {
|
|
6
5
|
type ExecFile,
|
|
7
6
|
type ExecFileResult,
|
|
@@ -11,6 +10,7 @@ import { WorkspaceBackendRegistry } from '../../../session/workspace/registry.js
|
|
|
11
10
|
import { InMemorySessionStore } from '../../../store/session/memory.js'
|
|
12
11
|
import { InMemoryThreadStore } from '../../../store/thread/memory.js'
|
|
13
12
|
import type { AgentId, SessionId, TenantId, UserId } from '../../../types/ids/index.js'
|
|
13
|
+
import type { ActorRef } from '../../../types/session/actor.js'
|
|
14
14
|
import { generateHandoffId } from '../../../utils/id.js'
|
|
15
15
|
import type { HandoffAssignment } from '../assignment.js'
|
|
16
16
|
import { DefaultCapacityValidator } from '../capacity.js'
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type { SessionId, TenantId } from '../../types/ids/index.js'
|
|
12
|
+
import type { ActorRef } from '../../types/session/actor.js'
|
|
12
13
|
import type { HandoffId, ProjectId, ThreadId, WorkspaceId } from '../../types/session/ids.js'
|
|
13
|
-
import type { ActorRef } from '../hierarchy/actor.js'
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Handoff mode discriminator. `single` transfers ownership of the source
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
|
|
24
24
|
import type { ThreadManager } from '../../manager/thread/lifecycle.js'
|
|
25
25
|
import type { SessionId, TenantId } from '../../types/ids/index.js'
|
|
26
|
+
import type { Session } from '../../types/session/entity.js'
|
|
26
27
|
import type { SubSessionId } from '../../types/session/ids.js'
|
|
27
28
|
import type { SessionStore } from '../../types/session/store.js'
|
|
29
|
+
import type { WorkspaceRef } from '../../types/workspace/ref.js'
|
|
28
30
|
import { TenantIsolationError } from '../errors.js'
|
|
29
|
-
import type { Session } from '../hierarchy/session.js'
|
|
30
31
|
import type { WorkspaceBackendDriver } from '../workspace/driver.js'
|
|
31
|
-
import type { WorkspaceRef } from '../workspace/ref.js'
|
|
32
32
|
import type { WorkspaceBackendRegistry } from '../workspace/registry.js'
|
|
33
33
|
import type { HandoffAssignment, HandoffOutcome } from './assignment.js'
|
|
34
34
|
import type { CapacityValidator } from './capacity.js'
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
|
|
23
23
|
import type { ThreadManager } from '../../manager/thread/lifecycle.js'
|
|
24
24
|
import type { SessionId, TenantId } from '../../types/ids/index.js'
|
|
25
|
+
import type { Session } from '../../types/session/entity.js'
|
|
25
26
|
import type { SessionStore } from '../../types/session/store.js'
|
|
27
|
+
import type { WorkspaceRef } from '../../types/workspace/ref.js'
|
|
26
28
|
import { TenantIsolationError } from '../errors.js'
|
|
27
|
-
import type { Session } from '../hierarchy/session.js'
|
|
28
29
|
import type { WorkspaceBackendDriver } from '../workspace/driver.js'
|
|
29
|
-
import type { WorkspaceRef } from '../workspace/ref.js'
|
|
30
30
|
import type { WorkspaceBackendRegistry } from '../workspace/registry.js'
|
|
31
31
|
import type { HandoffAssignment, HandoffOutcome } from './assignment.js'
|
|
32
32
|
import type { CapacityValidator } from './capacity.js'
|
package/src/session/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// Top-level barrel for the session
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
1
|
+
// Top-level barrel for the session module.
|
|
2
|
+
// Shape types (Project / Thread / Session / SubSession / Actor / Lineage /
|
|
3
|
+
// Tenant) live under `types/` as of ses_010 (2026-04-21); this barrel
|
|
4
|
+
// re-exports only the runtime machinery that lives under `session/*/`
|
|
5
|
+
// (events, workspace, handoff, summary, intervention, migration, retention,
|
|
6
|
+
// status). Consumers of `@namzu/sdk` reach entity shapes through the root
|
|
7
|
+
// barrel directly.
|
|
6
8
|
|
|
7
|
-
export * from './hierarchy/index.js'
|
|
8
9
|
export * from './events/index.js'
|
|
9
10
|
export * from './workspace/index.js'
|
|
10
11
|
export * from './handoff/index.js'
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
2
|
import type { SessionId } from '../../../types/ids/index.js'
|
|
3
3
|
import type { DeliverableId, SubSessionId, SummaryId } from '../../../types/session/ids.js'
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
DeliverableRef,
|
|
6
|
+
SessionSummaryDeliverable,
|
|
7
|
+
} from '../../../types/summary/deliverable.js'
|
|
5
8
|
import {
|
|
6
9
|
ArtifactRefCycleError,
|
|
7
10
|
type InterventionChainLoader,
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import type { SessionId } from '../../types/ids/index.js'
|
|
19
19
|
import type { SubSessionId } from '../../types/session/ids.js'
|
|
20
|
-
import type { DeliverableRef } from '
|
|
20
|
+
import type { DeliverableRef } from '../../types/summary/deliverable.js'
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Minimal record the validator needs to step ancestrally from one
|
|
@@ -2,15 +2,15 @@ import { mkdtempSync, rmSync } from 'node:fs'
|
|
|
2
2
|
import { tmpdir } from 'node:os'
|
|
3
3
|
import { join } from 'node:path'
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
-
import type { ActorRef } from '../../../session/hierarchy/actor.js'
|
|
6
|
-
import type { SubSession } from '../../../session/hierarchy/sub-session.js'
|
|
7
5
|
import { type ExecFile, GitWorktreeDriver } from '../../../session/workspace/git-worktree.js'
|
|
8
|
-
import type { WorkspaceRef } from '../../../session/workspace/ref.js'
|
|
9
6
|
import { WorkspaceBackendRegistry } from '../../../session/workspace/registry.js'
|
|
10
7
|
import { InMemorySessionStore } from '../../../store/session/memory.js'
|
|
11
8
|
import type { AgentId, TenantId, UserId } from '../../../types/ids/index.js'
|
|
12
9
|
import { createUserMessage } from '../../../types/message/index.js'
|
|
10
|
+
import type { ActorRef } from '../../../types/session/actor.js'
|
|
13
11
|
import type { ThreadId, WorkspaceId } from '../../../types/session/ids.js'
|
|
12
|
+
import type { SubSession } from '../../../types/session/sub-session.js'
|
|
13
|
+
import type { WorkspaceRef } from '../../../types/workspace/ref.js'
|
|
14
14
|
import {
|
|
15
15
|
ArchivalManager,
|
|
16
16
|
ArchiveNotConfiguredError,
|
|
@@ -3,13 +3,13 @@ import { readFile, readdir } from 'node:fs/promises'
|
|
|
3
3
|
import { tmpdir } from 'node:os'
|
|
4
4
|
import { join } from 'node:path'
|
|
5
5
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
6
|
-
import type { SessionMessage } from '../../../store/session/messages.js'
|
|
7
6
|
import type { MessageId, SessionId, TenantId } from '../../../types/ids/index.js'
|
|
8
7
|
import { createUserMessage } from '../../../types/message/index.js'
|
|
8
|
+
import type { ArchiveBackendRef } from '../../../types/retention/archive-backend-ref.js'
|
|
9
9
|
import type { SubSessionId, SummaryId, WorkspaceId } from '../../../types/session/ids.js'
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
10
|
+
import type { SessionMessage } from '../../../types/session/messages.js'
|
|
11
|
+
import type { SessionSummaryRef } from '../../../types/summary/ref.js'
|
|
12
|
+
import type { WorkspaceRef } from '../../../types/workspace/ref.js'
|
|
13
13
|
import { DiskArchiveBackend } from '../disk-backend.js'
|
|
14
14
|
|
|
15
15
|
const tenantA = 'tnt_alpha' as TenantId
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
import type { SessionId, SubSessionId, TenantId } from '../../types/ids/index.js'
|
|
29
29
|
import type { WorkspaceId } from '../../types/session/ids.js'
|
|
30
30
|
import type { SessionStore } from '../../types/session/store.js'
|
|
31
|
-
import type { SubSession, SubSessionStatus } from '
|
|
32
|
-
import type { WorkspaceRef } from '
|
|
31
|
+
import type { SubSession, SubSessionStatus } from '../../types/session/sub-session.js'
|
|
32
|
+
import type { WorkspaceRef } from '../../types/workspace/ref.js'
|
|
33
33
|
import type { WorkspaceBackendRegistry } from '../workspace/registry.js'
|
|
34
34
|
import type { ArchiveBackend, SubSessionTombstone } from './backend.js'
|
|
35
35
|
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
* `SessionStore` is the Store it mutates.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import type { SessionMessage } from '../../store/session/messages.js'
|
|
16
15
|
import type { SessionId, SubSessionId, TenantId } from '../../types/ids/index.js'
|
|
16
|
+
import type { ArchiveBackendRef } from '../../types/retention/archive-backend-ref.js'
|
|
17
17
|
import type { SummaryId } from '../../types/session/ids.js'
|
|
18
|
-
import type {
|
|
19
|
-
import type {
|
|
20
|
-
import type {
|
|
18
|
+
import type { SessionMessage } from '../../types/session/messages.js'
|
|
19
|
+
import type { SessionSummaryRef } from '../../types/summary/ref.js'
|
|
20
|
+
import type { WorkspaceRef } from '../../types/workspace/ref.js'
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Output of a successful {@link ArchiveBackend.store} call. `archiveRef` is
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
import { randomBytes } from 'node:crypto'
|
|
30
30
|
import { mkdir, readFile, readdir, rename, unlink, writeFile } from 'node:fs/promises'
|
|
31
31
|
import { join } from 'node:path'
|
|
32
|
-
import type { SessionMessage } from '../../store/session/messages.js'
|
|
33
32
|
import type { SessionId, SubSessionId, TenantId } from '../../types/ids/index.js'
|
|
34
|
-
import type {
|
|
35
|
-
import type {
|
|
36
|
-
import type {
|
|
33
|
+
import type { ArchiveBackendRef } from '../../types/retention/archive-backend-ref.js'
|
|
34
|
+
import type { SessionMessage } from '../../types/session/messages.js'
|
|
35
|
+
import type { SessionSummaryRef } from '../../types/summary/ref.js'
|
|
36
|
+
import type { WorkspaceRef } from '../../types/workspace/ref.js'
|
|
37
37
|
import type { ArchiveBackend, ArchiveInput, ArchiveOutput } from './backend.js'
|
|
38
38
|
|
|
39
39
|
/**
|