@namzu/sdk 0.1.8 → 0.3.0
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 +69 -2
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +5 -2
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/RouterAgent.d.ts.map +1 -1
- package/dist/agents/RouterAgent.js +3 -0
- package/dist/agents/RouterAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +21 -5
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/bridge/a2a/index.d.ts +1 -1
- package/dist/bridge/a2a/index.d.ts.map +1 -1
- package/dist/bridge/a2a/index.js +1 -1
- package/dist/bridge/a2a/index.js.map +1 -1
- package/dist/bridge/a2a/mapper.d.ts.map +1 -1
- package/dist/bridge/a2a/mapper.js +6 -0
- package/dist/bridge/a2a/mapper.js.map +1 -1
- package/dist/bridge/a2a/message.d.ts +0 -2
- package/dist/bridge/a2a/message.d.ts.map +1 -1
- package/dist/bridge/a2a/message.js +0 -26
- package/dist/bridge/a2a/message.js.map +1 -1
- package/dist/bridge/a2a/task.d.ts +5 -4
- package/dist/bridge/a2a/task.d.ts.map +1 -1
- package/dist/bridge/a2a/task.js +4 -4
- package/dist/bridge/a2a/task.js.map +1 -1
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +6 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/constants/a2a/index.d.ts +2 -2
- package/dist/constants/a2a/index.d.ts.map +1 -1
- package/dist/constants/a2a/index.js.map +1 -1
- package/dist/contracts/api.d.ts +14 -27
- package/dist/contracts/api.d.ts.map +1 -1
- package/dist/contracts/ids.d.ts +1 -1
- package/dist/contracts/ids.d.ts.map +1 -1
- package/dist/contracts/index.d.ts +3 -3
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +1 -1
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/schemas.d.ts +1 -31
- package/dist/contracts/schemas.d.ts.map +1 -1
- package/dist/contracts/schemas.js +1 -7
- package/dist/contracts/schemas.js.map +1 -1
- package/dist/gateway/local.d.ts.map +1 -1
- package/dist/gateway/local.js +6 -0
- package/dist/gateway/local.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/manager/agent/__tests__/lifecycle.test.d.ts +2 -0
- package/dist/manager/agent/__tests__/lifecycle.test.d.ts.map +1 -0
- package/dist/manager/agent/__tests__/lifecycle.test.js +316 -0
- package/dist/manager/agent/__tests__/lifecycle.test.js.map +1 -0
- package/dist/manager/agent/lifecycle.d.ts +67 -3
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +375 -14
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/index.d.ts +2 -0
- package/dist/manager/index.d.ts.map +1 -1
- package/dist/manager/index.js +1 -0
- package/dist/manager/index.js.map +1 -1
- package/dist/manager/run/persistence.d.ts +10 -1
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +20 -0
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/manager/thread/__tests__/lifecycle.test.d.ts +2 -0
- package/dist/manager/thread/__tests__/lifecycle.test.d.ts.map +1 -0
- package/dist/manager/thread/__tests__/lifecycle.test.js +216 -0
- package/dist/manager/thread/__tests__/lifecycle.test.js.map +1 -0
- package/dist/manager/thread/lifecycle.d.ts +105 -0
- package/dist/manager/thread/lifecycle.d.ts.map +1 -0
- package/dist/manager/thread/lifecycle.js +186 -0
- package/dist/manager/thread/lifecycle.js.map +1 -0
- package/dist/rag/retriever.js +2 -2
- package/dist/run/reporter.d.ts.map +1 -1
- package/dist/run/reporter.js +25 -0
- package/dist/run/reporter.js.map +1 -1
- package/dist/runtime/query/__tests__/context.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/context.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/context.test.js +85 -0
- package/dist/runtime/query/__tests__/context.test.js.map +1 -0
- package/dist/runtime/query/context-cache.d.ts +3 -3
- package/dist/runtime/query/context-cache.d.ts.map +1 -1
- package/dist/runtime/query/context-cache.js +2 -2
- package/dist/runtime/query/context-cache.js.map +1 -1
- package/dist/runtime/query/context.d.ts +45 -1
- package/dist/runtime/query/context.d.ts.map +1 -1
- package/dist/runtime/query/context.js +50 -8
- package/dist/runtime/query/context.js.map +1 -1
- package/dist/runtime/query/events.d.ts.map +1 -1
- package/dist/runtime/query/events.js +8 -0
- package/dist/runtime/query/events.js.map +1 -1
- package/dist/runtime/query/index.d.ts +22 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +11 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/session/__tests__/integration/_fixtures.d.ts +122 -0
- package/dist/session/__tests__/integration/_fixtures.d.ts.map +1 -0
- package/dist/session/__tests__/integration/_fixtures.js +215 -0
- package/dist/session/__tests__/integration/_fixtures.js.map +1 -0
- package/dist/session/__tests__/integration/archive-gate.test.d.ts +15 -0
- package/dist/session/__tests__/integration/archive-gate.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/archive-gate.test.js +214 -0
- package/dist/session/__tests__/integration/archive-gate.test.js.map +1 -0
- package/dist/session/__tests__/integration/capacity-caps.test.d.ts +13 -0
- package/dist/session/__tests__/integration/capacity-caps.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/capacity-caps.test.js +123 -0
- package/dist/session/__tests__/integration/capacity-caps.test.js.map +1 -0
- package/dist/session/__tests__/integration/e2e-spawn.test.d.ts +18 -0
- package/dist/session/__tests__/integration/e2e-spawn.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/e2e-spawn.test.js +238 -0
- package/dist/session/__tests__/integration/e2e-spawn.test.js.map +1 -0
- package/dist/session/__tests__/integration/event-stream-ordering.test.d.ts +15 -0
- package/dist/session/__tests__/integration/event-stream-ordering.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/event-stream-ordering.test.js +330 -0
- package/dist/session/__tests__/integration/event-stream-ordering.test.js.map +1 -0
- package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.d.ts +12 -0
- package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.js +182 -0
- package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.js.map +1 -0
- package/dist/session/__tests__/integration/handoff-illegal-transition.test.d.ts +18 -0
- package/dist/session/__tests__/integration/handoff-illegal-transition.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/handoff-illegal-transition.test.js +156 -0
- package/dist/session/__tests__/integration/handoff-illegal-transition.test.js.map +1 -0
- package/dist/session/__tests__/integration/handoff-single-e2e.test.d.ts +15 -0
- package/dist/session/__tests__/integration/handoff-single-e2e.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/handoff-single-e2e.test.js +179 -0
- package/dist/session/__tests__/integration/handoff-single-e2e.test.js.map +1 -0
- package/dist/session/__tests__/integration/hierarchy-lifecycle.test.d.ts +12 -0
- package/dist/session/__tests__/integration/hierarchy-lifecycle.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/hierarchy-lifecycle.test.js +158 -0
- package/dist/session/__tests__/integration/hierarchy-lifecycle.test.js.map +1 -0
- package/dist/session/__tests__/integration/migration-filesystem.test.d.ts +11 -0
- package/dist/session/__tests__/integration/migration-filesystem.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/migration-filesystem.test.js +140 -0
- package/dist/session/__tests__/integration/migration-filesystem.test.js.map +1 -0
- package/dist/session/__tests__/integration/migration-id-prefix.test.d.ts +13 -0
- package/dist/session/__tests__/integration/migration-id-prefix.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/migration-id-prefix.test.js +84 -0
- package/dist/session/__tests__/integration/migration-id-prefix.test.js.map +1 -0
- package/dist/session/__tests__/integration/prev-artifact-dag.test.d.ts +14 -0
- package/dist/session/__tests__/integration/prev-artifact-dag.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/prev-artifact-dag.test.js +242 -0
- package/dist/session/__tests__/integration/prev-artifact-dag.test.js.map +1 -0
- package/dist/session/__tests__/integration/retention-archive.test.d.ts +12 -0
- package/dist/session/__tests__/integration/retention-archive.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/retention-archive.test.js +187 -0
- package/dist/session/__tests__/integration/retention-archive.test.js.map +1 -0
- package/dist/session/__tests__/integration/spawn-rollback.test.d.ts +26 -0
- package/dist/session/__tests__/integration/spawn-rollback.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/spawn-rollback.test.js +236 -0
- package/dist/session/__tests__/integration/spawn-rollback.test.js.map +1 -0
- package/dist/session/__tests__/integration/summary-materialization-e2e.test.d.ts +18 -0
- package/dist/session/__tests__/integration/summary-materialization-e2e.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/summary-materialization-e2e.test.js +201 -0
- package/dist/session/__tests__/integration/summary-materialization-e2e.test.js.map +1 -0
- package/dist/session/__tests__/integration/tenant-isolation.test.d.ts +14 -0
- package/dist/session/__tests__/integration/tenant-isolation.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/tenant-isolation.test.js +189 -0
- package/dist/session/__tests__/integration/tenant-isolation.test.js.map +1 -0
- package/dist/session/errors.d.ts +139 -0
- package/dist/session/errors.d.ts.map +1 -0
- package/dist/session/errors.js +107 -0
- package/dist/session/errors.js.map +1 -0
- package/dist/session/events/index.d.ts +4 -0
- package/dist/session/events/index.d.ts.map +1 -0
- package/dist/session/events/index.js +8 -0
- package/dist/session/events/index.js.map +1 -0
- package/dist/session/events/schema-version.d.ts +13 -0
- package/dist/session/events/schema-version.d.ts.map +1 -0
- package/dist/session/events/schema-version.js +12 -0
- package/dist/session/events/schema-version.js.map +1 -0
- package/dist/session/events/types.d.ts +64 -0
- package/dist/session/events/types.d.ts.map +1 -0
- package/dist/session/events/types.js +2 -0
- package/dist/session/events/types.js.map +1 -0
- package/dist/session/handoff/__tests__/broadcast.test.d.ts +2 -0
- package/dist/session/handoff/__tests__/broadcast.test.d.ts.map +1 -0
- package/dist/session/handoff/__tests__/broadcast.test.js +261 -0
- package/dist/session/handoff/__tests__/broadcast.test.js.map +1 -0
- package/dist/session/handoff/__tests__/capacity.test.d.ts +2 -0
- package/dist/session/handoff/__tests__/capacity.test.d.ts.map +1 -0
- package/dist/session/handoff/__tests__/capacity.test.js +103 -0
- package/dist/session/handoff/__tests__/capacity.test.js.map +1 -0
- package/dist/session/handoff/__tests__/single.test.d.ts +2 -0
- package/dist/session/handoff/__tests__/single.test.d.ts.map +1 -0
- package/dist/session/handoff/__tests__/single.test.js +239 -0
- package/dist/session/handoff/__tests__/single.test.js.map +1 -0
- package/dist/session/handoff/assignment.d.ts +71 -0
- package/dist/session/handoff/assignment.d.ts.map +1 -0
- package/dist/session/handoff/assignment.js +11 -0
- package/dist/session/handoff/assignment.js.map +1 -0
- package/dist/session/handoff/broadcast.d.ts +54 -0
- package/dist/session/handoff/broadcast.d.ts.map +1 -0
- package/dist/session/handoff/broadcast.js +311 -0
- package/dist/session/handoff/broadcast.js.map +1 -0
- package/dist/session/handoff/capacity.d.ts +66 -0
- package/dist/session/handoff/capacity.d.ts.map +1 -0
- package/dist/session/handoff/capacity.js +60 -0
- package/dist/session/handoff/capacity.js.map +1 -0
- package/dist/session/handoff/events.d.ts +66 -0
- package/dist/session/handoff/events.d.ts.map +1 -0
- package/dist/session/handoff/events.js +13 -0
- package/dist/session/handoff/events.js.map +1 -0
- package/dist/session/handoff/index.d.ts +12 -0
- package/dist/session/handoff/index.d.ts.map +1 -0
- package/dist/session/handoff/index.js +9 -0
- package/dist/session/handoff/index.js.map +1 -0
- package/dist/session/handoff/single.d.ts +69 -0
- package/dist/session/handoff/single.d.ts.map +1 -0
- package/dist/session/handoff/single.js +229 -0
- package/dist/session/handoff/single.js.map +1 -0
- package/dist/session/handoff/version.d.ts +52 -0
- package/dist/session/handoff/version.d.ts.map +1 -0
- package/dist/session/handoff/version.js +36 -0
- package/dist/session/handoff/version.js.map +1 -0
- package/dist/session/hierarchy/__tests__/session.test.d.ts +2 -0
- package/dist/session/hierarchy/__tests__/session.test.d.ts.map +1 -0
- package/dist/session/hierarchy/__tests__/session.test.js +69 -0
- package/dist/session/hierarchy/__tests__/session.test.js.map +1 -0
- package/dist/session/hierarchy/actor.d.ts +26 -0
- package/dist/session/hierarchy/actor.d.ts.map +1 -0
- package/dist/session/hierarchy/actor.js +2 -0
- package/dist/session/hierarchy/actor.js.map +1 -0
- package/dist/session/hierarchy/index.d.ts +9 -0
- package/dist/session/hierarchy/index.d.ts.map +1 -0
- package/dist/session/hierarchy/index.js +4 -0
- package/dist/session/hierarchy/index.js.map +1 -0
- package/dist/session/hierarchy/lineage.d.ts +15 -0
- package/dist/session/hierarchy/lineage.d.ts.map +1 -0
- package/dist/session/hierarchy/lineage.js +2 -0
- package/dist/session/hierarchy/lineage.js.map +1 -0
- package/dist/session/hierarchy/project.d.ts +40 -0
- package/dist/session/hierarchy/project.d.ts.map +1 -0
- package/dist/session/hierarchy/project.js +2 -0
- package/dist/session/hierarchy/project.js.map +1 -0
- package/dist/session/hierarchy/session.d.ts +71 -0
- package/dist/session/hierarchy/session.d.ts.map +1 -0
- package/dist/session/hierarchy/session.js +51 -0
- package/dist/session/hierarchy/session.js.map +1 -0
- package/dist/session/hierarchy/sub-session.d.ts +76 -0
- package/dist/session/hierarchy/sub-session.d.ts.map +1 -0
- package/dist/session/hierarchy/sub-session.js +2 -0
- package/dist/session/hierarchy/sub-session.js.map +1 -0
- package/dist/session/hierarchy/tenant.d.ts +13 -0
- package/dist/session/hierarchy/tenant.d.ts.map +1 -0
- package/dist/session/hierarchy/tenant.js +2 -0
- package/dist/session/hierarchy/tenant.js.map +1 -0
- package/dist/session/hierarchy/thread.d.ts +54 -0
- package/dist/session/hierarchy/thread.d.ts.map +1 -0
- package/dist/session/hierarchy/thread.js +2 -0
- package/dist/session/hierarchy/thread.js.map +1 -0
- package/dist/session/index.d.ts +10 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +15 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/intervention/__tests__/prev-artifact.test.d.ts +2 -0
- package/dist/session/intervention/__tests__/prev-artifact.test.d.ts.map +1 -0
- package/dist/session/intervention/__tests__/prev-artifact.test.js +179 -0
- package/dist/session/intervention/__tests__/prev-artifact.test.js.map +1 -0
- package/dist/session/intervention/index.d.ts +3 -0
- package/dist/session/intervention/index.d.ts.map +1 -0
- package/dist/session/intervention/index.js +8 -0
- package/dist/session/intervention/index.js.map +1 -0
- package/dist/session/intervention/prev-artifact.d.ts +103 -0
- package/dist/session/intervention/prev-artifact.d.ts.map +1 -0
- package/dist/session/intervention/prev-artifact.js +112 -0
- package/dist/session/intervention/prev-artifact.js.map +1 -0
- package/dist/session/migration/__tests__/filesystem.test.d.ts +2 -0
- package/dist/session/migration/__tests__/filesystem.test.d.ts.map +1 -0
- package/dist/session/migration/__tests__/filesystem.test.js +188 -0
- package/dist/session/migration/__tests__/filesystem.test.js.map +1 -0
- package/dist/session/migration/__tests__/id-prefix.test.d.ts +2 -0
- package/dist/session/migration/__tests__/id-prefix.test.d.ts.map +1 -0
- package/dist/session/migration/__tests__/id-prefix.test.js +83 -0
- package/dist/session/migration/__tests__/id-prefix.test.js.map +1 -0
- package/dist/session/migration/__tests__/marker.test.d.ts +2 -0
- package/dist/session/migration/__tests__/marker.test.d.ts.map +1 -0
- package/dist/session/migration/__tests__/marker.test.js +75 -0
- package/dist/session/migration/__tests__/marker.test.js.map +1 -0
- package/dist/session/migration/errors.d.ts +26 -0
- package/dist/session/migration/errors.d.ts.map +1 -0
- package/dist/session/migration/errors.js +22 -0
- package/dist/session/migration/errors.js.map +1 -0
- package/dist/session/migration/filesystem.d.ts +94 -0
- package/dist/session/migration/filesystem.d.ts.map +1 -0
- package/dist/session/migration/filesystem.js +319 -0
- package/dist/session/migration/filesystem.js.map +1 -0
- package/dist/session/migration/id-prefix.d.ts +93 -0
- package/dist/session/migration/id-prefix.d.ts.map +1 -0
- package/dist/session/migration/id-prefix.js +111 -0
- package/dist/session/migration/id-prefix.js.map +1 -0
- package/dist/session/migration/index.d.ts +8 -0
- package/dist/session/migration/index.d.ts.map +1 -0
- package/dist/session/migration/index.js +8 -0
- package/dist/session/migration/index.js.map +1 -0
- package/dist/session/migration/marker.d.ts +57 -0
- package/dist/session/migration/marker.d.ts.map +1 -0
- package/dist/session/migration/marker.js +111 -0
- package/dist/session/migration/marker.js.map +1 -0
- package/dist/session/retention/__tests__/archive.test.d.ts +2 -0
- package/dist/session/retention/__tests__/archive.test.d.ts.map +1 -0
- package/dist/session/retention/__tests__/archive.test.js +253 -0
- package/dist/session/retention/__tests__/archive.test.js.map +1 -0
- package/dist/session/retention/__tests__/disk-backend.test.d.ts +2 -0
- package/dist/session/retention/__tests__/disk-backend.test.d.ts.map +1 -0
- package/dist/session/retention/__tests__/disk-backend.test.js +154 -0
- package/dist/session/retention/__tests__/disk-backend.test.js.map +1 -0
- package/dist/session/retention/archive-backend-ref.d.ts +18 -0
- package/dist/session/retention/archive-backend-ref.d.ts.map +1 -0
- package/dist/session/retention/archive-backend-ref.js +2 -0
- package/dist/session/retention/archive-backend-ref.js.map +1 -0
- package/dist/session/retention/archive.d.ts +130 -0
- package/dist/session/retention/archive.d.ts.map +1 -0
- package/dist/session/retention/archive.js +203 -0
- package/dist/session/retention/archive.js.map +1 -0
- package/dist/session/retention/backend.d.ts +101 -0
- package/dist/session/retention/backend.d.ts.map +1 -0
- package/dist/session/retention/backend.js +15 -0
- package/dist/session/retention/backend.js.map +1 -0
- package/dist/session/retention/disk-backend.d.ts +59 -0
- package/dist/session/retention/disk-backend.d.ts.map +1 -0
- package/dist/session/retention/disk-backend.js +236 -0
- package/dist/session/retention/disk-backend.js.map +1 -0
- package/dist/session/retention/index.d.ts +9 -0
- package/dist/session/retention/index.d.ts.map +1 -0
- package/dist/session/retention/index.js +6 -0
- package/dist/session/retention/index.js.map +1 -0
- package/dist/session/retention/policy.d.ts +49 -0
- package/dist/session/retention/policy.d.ts.map +1 -0
- package/dist/session/retention/policy.js +21 -0
- package/dist/session/retention/policy.js.map +1 -0
- package/dist/session/summary/__tests__/materialize.test.d.ts +2 -0
- package/dist/session/summary/__tests__/materialize.test.d.ts.map +1 -0
- package/dist/session/summary/__tests__/materialize.test.js +270 -0
- package/dist/session/summary/__tests__/materialize.test.js.map +1 -0
- package/dist/session/summary/deliverable.d.ts +74 -0
- package/dist/session/summary/deliverable.d.ts.map +1 -0
- package/dist/session/summary/deliverable.js +20 -0
- package/dist/session/summary/deliverable.js.map +1 -0
- package/dist/session/summary/index.d.ts +6 -0
- package/dist/session/summary/index.d.ts.map +1 -0
- package/dist/session/summary/index.js +9 -0
- package/dist/session/summary/index.js.map +1 -0
- package/dist/session/summary/materialize.d.ts +82 -0
- package/dist/session/summary/materialize.d.ts.map +1 -0
- package/dist/session/summary/materialize.js +117 -0
- package/dist/session/summary/materialize.js.map +1 -0
- package/dist/session/summary/ref.d.ts +91 -0
- package/dist/session/summary/ref.d.ts.map +1 -0
- package/dist/session/summary/ref.js +51 -0
- package/dist/session/summary/ref.js.map +1 -0
- package/dist/session/workspace/__tests__/git-worktree.test.d.ts +2 -0
- package/dist/session/workspace/__tests__/git-worktree.test.d.ts.map +1 -0
- package/dist/session/workspace/__tests__/git-worktree.test.js +244 -0
- package/dist/session/workspace/__tests__/git-worktree.test.js.map +1 -0
- package/dist/session/workspace/__tests__/path-builder.test.d.ts +2 -0
- package/dist/session/workspace/__tests__/path-builder.test.d.ts.map +1 -0
- package/dist/session/workspace/__tests__/path-builder.test.js +37 -0
- package/dist/session/workspace/__tests__/path-builder.test.js.map +1 -0
- package/dist/session/workspace/driver.d.ts +55 -0
- package/dist/session/workspace/driver.d.ts.map +1 -0
- package/dist/session/workspace/driver.js +12 -0
- package/dist/session/workspace/driver.js.map +1 -0
- package/dist/session/workspace/git-worktree.d.ts +65 -0
- package/dist/session/workspace/git-worktree.d.ts.map +1 -0
- package/dist/session/workspace/git-worktree.js +156 -0
- package/dist/session/workspace/git-worktree.js.map +1 -0
- package/dist/session/workspace/index.d.ts +8 -0
- package/dist/session/workspace/index.d.ts.map +1 -0
- package/dist/session/workspace/index.js +7 -0
- package/dist/session/workspace/index.js.map +1 -0
- package/dist/session/workspace/path-builder.d.ts +50 -0
- package/dist/session/workspace/path-builder.d.ts.map +1 -0
- package/dist/session/workspace/path-builder.js +50 -0
- package/dist/session/workspace/path-builder.js.map +1 -0
- package/dist/session/workspace/ref.d.ts +46 -0
- package/dist/session/workspace/ref.d.ts.map +1 -0
- package/dist/session/workspace/ref.js +11 -0
- package/dist/session/workspace/ref.js.map +1 -0
- package/dist/session/workspace/registry.d.ts +26 -0
- package/dist/session/workspace/registry.d.ts.map +1 -0
- package/dist/session/workspace/registry.js +35 -0
- package/dist/session/workspace/registry.js.map +1 -0
- package/dist/store/index.d.ts +0 -2
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +0 -1
- package/dist/store/index.js.map +1 -1
- package/dist/store/session/__tests__/disk.test.d.ts +2 -0
- package/dist/store/session/__tests__/disk.test.d.ts.map +1 -0
- package/dist/store/session/__tests__/disk.test.js +267 -0
- package/dist/store/session/__tests__/disk.test.js.map +1 -0
- package/dist/store/session/__tests__/memory.test.d.ts +2 -0
- package/dist/store/session/__tests__/memory.test.d.ts.map +1 -0
- package/dist/store/session/__tests__/memory.test.js +258 -0
- package/dist/store/session/__tests__/memory.test.js.map +1 -0
- package/dist/store/session/disk.d.ts +86 -0
- package/dist/store/session/disk.d.ts.map +1 -0
- package/dist/store/session/disk.js +818 -0
- package/dist/store/session/disk.js.map +1 -0
- package/dist/store/session/index.d.ts +7 -0
- package/dist/store/session/index.d.ts.map +1 -0
- package/dist/store/session/index.js +10 -0
- package/dist/store/session/index.js.map +1 -0
- package/dist/store/session/linkage.d.ts +38 -0
- package/dist/store/session/linkage.d.ts.map +1 -0
- package/dist/store/session/linkage.js +64 -0
- package/dist/store/session/linkage.js.map +1 -0
- package/dist/store/session/memory.d.ts +49 -0
- package/dist/store/session/memory.d.ts.map +1 -0
- package/dist/store/session/memory.js +335 -0
- package/dist/store/session/memory.js.map +1 -0
- package/dist/store/session/messages.d.ts +20 -0
- package/dist/store/session/messages.d.ts.map +1 -0
- package/dist/store/session/messages.js +12 -0
- package/dist/store/session/messages.js.map +1 -0
- package/dist/store/thread/disk.d.ts +41 -0
- package/dist/store/thread/disk.d.ts.map +1 -0
- package/dist/store/thread/disk.js +229 -0
- package/dist/store/thread/disk.js.map +1 -0
- package/dist/store/thread/index.d.ts +4 -0
- package/dist/store/thread/index.d.ts.map +1 -0
- package/dist/store/thread/index.js +6 -0
- package/dist/store/thread/index.js.map +1 -0
- package/dist/store/thread/memory.d.ts +23 -0
- package/dist/store/thread/memory.d.ts.map +1 -0
- package/dist/store/thread/memory.js +90 -0
- package/dist/store/thread/memory.js.map +1 -0
- package/dist/tools/builtins/__tests__/structuredOutput.example.d.ts +1 -1
- package/dist/types/agent/base.d.ts +24 -1
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/factory.d.ts +8 -2
- package/dist/types/agent/factory.d.ts.map +1 -1
- package/dist/types/agent/task.d.ts +57 -2
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/agent/task.js.map +1 -1
- package/dist/types/ids/index.d.ts +22 -3
- package/dist/types/ids/index.d.ts.map +1 -1
- package/dist/types/ids/index.js +8 -1
- package/dist/types/ids/index.js.map +1 -1
- package/dist/types/invocation/__tests__/state.test.js +36 -29
- package/dist/types/invocation/__tests__/state.test.js.map +1 -1
- package/dist/types/invocation/index.d.ts +20 -4
- package/dist/types/invocation/index.d.ts.map +1 -1
- package/dist/types/invocation/index.js +10 -7
- package/dist/types/invocation/index.js.map +1 -1
- package/dist/types/rag/retrieval.d.ts +4 -3
- package/dist/types/rag/retrieval.d.ts.map +1 -1
- package/dist/types/run/config.d.ts +12 -1
- package/dist/types/run/config.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +26 -1
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/index.d.ts.map +1 -1
- package/dist/types/run/index.js +8 -0
- package/dist/types/run/index.js.map +1 -1
- package/dist/types/run/metadata.d.ts +12 -2
- package/dist/types/run/metadata.d.ts.map +1 -1
- package/dist/types/run/status.d.ts +26 -0
- package/dist/types/run/status.d.ts.map +1 -0
- package/dist/types/run/status.js +2 -0
- package/dist/types/run/status.js.map +1 -0
- package/dist/types/session/ids.d.ts +9 -0
- package/dist/types/session/ids.d.ts.map +1 -0
- package/dist/types/session/ids.js +9 -0
- package/dist/types/session/ids.js.map +1 -0
- package/dist/types/session/index.d.ts +3 -0
- package/dist/types/session/index.d.ts.map +1 -0
- package/dist/types/session/index.js +5 -0
- package/dist/types/session/index.js.map +1 -0
- package/dist/types/session/store.d.ts +210 -0
- package/dist/types/session/store.d.ts.map +1 -0
- package/dist/types/session/store.js +9 -0
- package/dist/types/session/store.js.map +1 -0
- package/dist/types/thread/index.d.ts +2 -0
- package/dist/types/thread/index.d.ts.map +1 -0
- package/dist/types/thread/index.js +5 -0
- package/dist/types/thread/index.js.map +1 -0
- package/dist/types/thread/store.d.ts +86 -0
- package/dist/types/thread/store.d.ts.map +1 -0
- package/dist/types/thread/store.js +22 -0
- package/dist/types/thread/store.js.map +1 -0
- package/dist/utils/id.d.ts +8 -2
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/id.js +22 -4
- package/dist/utils/id.js.map +1 -1
- package/package.json +6 -11
- package/src/agents/ReactiveAgent.ts +7 -2
- package/src/agents/RouterAgent.ts +5 -0
- package/src/agents/SupervisorAgent.ts +29 -6
- package/src/bridge/a2a/index.ts +0 -1
- package/src/bridge/a2a/mapper.ts +7 -0
- package/src/bridge/a2a/message.ts +0 -32
- package/src/bridge/a2a/task.ts +9 -8
- package/src/bridge/sse/mapper.ts +8 -1
- package/src/constants/a2a/index.ts +2 -2
- package/src/contracts/api.ts +14 -30
- package/src/contracts/ids.ts +1 -1
- package/src/contracts/index.ts +3 -7
- package/src/contracts/schemas.ts +1 -8
- package/src/gateway/local.ts +6 -0
- package/src/index.ts +14 -4
- package/src/manager/agent/__tests__/lifecycle.test.ts +473 -0
- package/src/manager/agent/lifecycle.ts +515 -21
- package/src/manager/index.ts +3 -0
- package/src/manager/run/persistence.ts +26 -1
- package/src/manager/thread/__tests__/lifecycle.test.ts +286 -0
- package/src/manager/thread/lifecycle.ts +217 -0
- package/src/rag/retriever.ts +2 -2
- package/src/run/reporter.ts +28 -0
- package/src/runtime/query/__tests__/context.test.ts +102 -0
- package/src/runtime/query/context-cache.ts +4 -4
- package/src/runtime/query/context.ts +98 -9
- package/src/runtime/query/events.ts +8 -0
- package/src/runtime/query/index.ts +38 -1
- package/src/session/__tests__/integration/_fixtures.ts +310 -0
- package/src/session/__tests__/integration/archive-gate.test.ts +288 -0
- package/src/session/__tests__/integration/capacity-caps.test.ts +171 -0
- package/src/session/__tests__/integration/e2e-spawn.test.ts +296 -0
- package/src/session/__tests__/integration/event-stream-ordering.test.ts +410 -0
- package/src/session/__tests__/integration/handoff-broadcast-e2e.test.ts +271 -0
- package/src/session/__tests__/integration/handoff-illegal-transition.test.ts +214 -0
- package/src/session/__tests__/integration/handoff-single-e2e.test.ts +251 -0
- package/src/session/__tests__/integration/hierarchy-lifecycle.test.ts +240 -0
- package/src/session/__tests__/integration/migration-filesystem.test.ts +209 -0
- package/src/session/__tests__/integration/migration-id-prefix.test.ts +101 -0
- package/src/session/__tests__/integration/prev-artifact-dag.test.ts +325 -0
- package/src/session/__tests__/integration/retention-archive.test.ts +233 -0
- package/src/session/__tests__/integration/spawn-rollback.test.ts +313 -0
- package/src/session/__tests__/integration/summary-materialization-e2e.test.ts +239 -0
- package/src/session/__tests__/integration/tenant-isolation.test.ts +292 -0
- package/src/session/errors.ts +159 -0
- package/src/session/events/index.ts +16 -0
- package/src/session/events/schema-version.ts +13 -0
- package/src/session/events/types.ts +71 -0
- package/src/session/handoff/__tests__/broadcast.test.ts +378 -0
- package/src/session/handoff/__tests__/capacity.test.ts +129 -0
- package/src/session/handoff/__tests__/single.test.ts +333 -0
- package/src/session/handoff/assignment.ts +74 -0
- package/src/session/handoff/broadcast.ts +406 -0
- package/src/session/handoff/capacity.ts +121 -0
- package/src/session/handoff/events.ts +72 -0
- package/src/session/handoff/index.ts +29 -0
- package/src/session/handoff/single.ts +310 -0
- package/src/session/handoff/version.ts +59 -0
- package/src/session/hierarchy/__tests__/session.test.ts +100 -0
- package/src/session/hierarchy/actor.ts +17 -0
- package/src/session/hierarchy/index.ts +18 -0
- package/src/session/hierarchy/lineage.ts +15 -0
- package/src/session/hierarchy/project.ts +41 -0
- package/src/session/hierarchy/session.ts +109 -0
- package/src/session/hierarchy/sub-session.ts +92 -0
- package/src/session/hierarchy/tenant.ts +13 -0
- package/src/session/hierarchy/thread.ts +55 -0
- package/src/session/index.ts +15 -0
- package/src/session/intervention/__tests__/prev-artifact.test.ts +234 -0
- package/src/session/intervention/index.ts +16 -0
- package/src/session/intervention/prev-artifact.ts +180 -0
- package/src/session/migration/__tests__/filesystem.test.ts +263 -0
- package/src/session/migration/__tests__/id-prefix.test.ts +101 -0
- package/src/session/migration/__tests__/marker.test.ts +84 -0
- package/src/session/migration/errors.ts +23 -0
- package/src/session/migration/filesystem.ts +401 -0
- package/src/session/migration/id-prefix.ts +141 -0
- package/src/session/migration/index.ts +38 -0
- package/src/session/migration/marker.ts +131 -0
- package/src/session/retention/__tests__/archive.test.ts +318 -0
- package/src/session/retention/__tests__/disk-backend.test.ts +180 -0
- package/src/session/retention/archive-backend-ref.ts +17 -0
- package/src/session/retention/archive.ts +281 -0
- package/src/session/retention/backend.ts +107 -0
- package/src/session/retention/disk-backend.ts +304 -0
- package/src/session/retention/index.ts +16 -0
- package/src/session/retention/policy.ts +53 -0
- package/src/session/summary/__tests__/materialize.test.ts +343 -0
- package/src/session/summary/deliverable.ts +84 -0
- package/src/session/summary/index.ts +31 -0
- package/src/session/summary/materialize.ts +169 -0
- package/src/session/summary/ref.ts +104 -0
- package/src/session/workspace/__tests__/git-worktree.test.ts +258 -0
- package/src/session/workspace/__tests__/path-builder.test.ts +51 -0
- package/src/session/workspace/driver.ts +60 -0
- package/src/session/workspace/git-worktree.ts +209 -0
- package/src/session/workspace/index.ts +25 -0
- package/src/session/workspace/path-builder.ts +71 -0
- package/src/session/workspace/ref.ts +50 -0
- package/src/session/workspace/registry.ts +42 -0
- package/src/store/index.ts +0 -3
- package/src/store/session/__tests__/disk.test.ts +397 -0
- package/src/store/session/__tests__/memory.test.ts +402 -0
- package/src/store/session/disk.ts +976 -0
- package/src/store/session/index.ts +13 -0
- package/src/store/session/linkage.ts +80 -0
- package/src/store/session/memory.ts +412 -0
- package/src/store/session/messages.ts +21 -0
- package/src/store/thread/disk.ts +261 -0
- package/src/store/thread/index.ts +7 -0
- package/src/store/thread/memory.ts +104 -0
- package/src/types/agent/base.ts +27 -1
- package/src/types/agent/factory.ts +8 -3
- package/src/types/agent/task.ts +66 -2
- package/src/types/ids/index.ts +34 -3
- package/src/types/invocation/__tests__/state.test.ts +37 -29
- package/src/types/invocation/index.ts +26 -10
- package/src/types/rag/retrieval.ts +4 -3
- package/src/types/run/config.ts +13 -1
- package/src/types/run/events.ts +36 -1
- package/src/types/run/index.ts +8 -0
- package/src/types/run/metadata.ts +12 -2
- package/src/types/run/status.ts +33 -0
- package/src/types/session/ids.ts +23 -0
- package/src/types/session/index.ts +27 -0
- package/src/types/session/store.ts +252 -0
- package/src/types/thread/index.ts +5 -0
- package/src/types/thread/store.ts +92 -0
- package/src/utils/id.ts +34 -4
- package/dist/store/conversation/memory.d.ts +0 -21
- package/dist/store/conversation/memory.d.ts.map +0 -1
- package/dist/store/conversation/memory.js +0 -86
- package/dist/store/conversation/memory.js.map +0 -1
- package/dist/types/conversation/index.d.ts +0 -7
- package/dist/types/conversation/index.d.ts.map +0 -1
- package/dist/types/conversation/index.js +0 -2
- package/dist/types/conversation/index.js.map +0 -1
- package/src/store/conversation/memory.ts +0 -121
- package/src/types/conversation/index.ts +0 -8
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { DefaultPathBuilder, type PathBuilder } from '../../../session/workspace/path-builder.js'
|
|
3
|
+
import type { RunId, SessionId, TenantId } from '../../../types/ids/index.js'
|
|
4
|
+
import type { LLMProvider } from '../../../types/provider/index.js'
|
|
5
|
+
import type { AgentRunConfig } from '../../../types/run/index.js'
|
|
6
|
+
import type { ProjectId, ThreadId } from '../../../types/session/ids.js'
|
|
7
|
+
import { RunContextFactory } from '../context.js'
|
|
8
|
+
|
|
9
|
+
function mockProvider(): LLMProvider {
|
|
10
|
+
return {
|
|
11
|
+
id: 'mock',
|
|
12
|
+
supports: () => true,
|
|
13
|
+
chat: async () => ({ message: { role: 'assistant', content: '' } }),
|
|
14
|
+
} as unknown as LLMProvider
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function buildConfig(overrides: Partial<Parameters<typeof RunContextFactory.build>[0]> = {}) {
|
|
18
|
+
const sessionId = 'ses_test' as SessionId
|
|
19
|
+
const threadId = 'thd_test' as ThreadId
|
|
20
|
+
const projectId = 'prj_test' as ProjectId
|
|
21
|
+
const tenantId = 'tnt_test' as TenantId
|
|
22
|
+
const runConfig: AgentRunConfig = {
|
|
23
|
+
model: 'test',
|
|
24
|
+
tokenBudget: 1_000,
|
|
25
|
+
timeoutMs: 5_000,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
agentId: 'agent-1',
|
|
30
|
+
agentName: 'agent-1',
|
|
31
|
+
runConfig,
|
|
32
|
+
provider: mockProvider(),
|
|
33
|
+
messages: [],
|
|
34
|
+
sessionId,
|
|
35
|
+
threadId,
|
|
36
|
+
projectId,
|
|
37
|
+
tenantId,
|
|
38
|
+
workingDirectory: '/tmp/run-context-test',
|
|
39
|
+
...overrides,
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe('RunContextFactory.build', () => {
|
|
44
|
+
it('requires sessionId, threadId, projectId, tenantId and returns them on the context', () => {
|
|
45
|
+
const cfg = buildConfig()
|
|
46
|
+
const ctx = RunContextFactory.build(cfg)
|
|
47
|
+
|
|
48
|
+
expect(ctx.sessionId).toBe(cfg.sessionId)
|
|
49
|
+
expect(ctx.threadId).toBe(cfg.threadId)
|
|
50
|
+
expect(ctx.projectId).toBe(cfg.projectId)
|
|
51
|
+
expect(ctx.tenantId).toBe(cfg.tenantId)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('uses the injected PathBuilder to resolve the output dir (no hardcoded .namzu/threads)', () => {
|
|
55
|
+
const pathBuilderMock: PathBuilder = {
|
|
56
|
+
rootDir: vi.fn(() => '/mock/root'),
|
|
57
|
+
projectDir: vi.fn((pid) => `/mock/root/projects/${pid}`),
|
|
58
|
+
sessionDir: vi.fn((pid, sid) => `/mock/root/projects/${pid}/sessions/${sid}`),
|
|
59
|
+
subSessionDir: vi.fn(),
|
|
60
|
+
runDir: vi.fn(),
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const cfg = buildConfig({ pathBuilder: pathBuilderMock })
|
|
64
|
+
const ctx = RunContextFactory.build(cfg)
|
|
65
|
+
|
|
66
|
+
expect(pathBuilderMock.sessionDir).toHaveBeenCalledWith(cfg.projectId, cfg.sessionId)
|
|
67
|
+
expect(ctx.outputDir).toBe(`/mock/root/projects/${cfg.projectId}/sessions/${cfg.sessionId}`)
|
|
68
|
+
// Legacy hardcoded path must not leak.
|
|
69
|
+
expect(ctx.outputDir).not.toContain('.namzu/threads')
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('falls back to DefaultPathBuilder rooted at {cwd}/.namzu when no pathBuilder is provided', () => {
|
|
73
|
+
const cfg = buildConfig()
|
|
74
|
+
const ctx = RunContextFactory.build(cfg)
|
|
75
|
+
|
|
76
|
+
// Layout lives under projects/{pid}/sessions/{sid} — no `.namzu/threads/`.
|
|
77
|
+
expect(ctx.outputDir).toContain('/.namzu/projects/prj_test/sessions/ses_test')
|
|
78
|
+
expect(ctx.outputDir).not.toContain('threads')
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('seeds RunPersistence with propagated sessionId/threadId/tenantId/projectId', () => {
|
|
82
|
+
const cfg = buildConfig()
|
|
83
|
+
const ctx = RunContextFactory.build(cfg)
|
|
84
|
+
|
|
85
|
+
expect(ctx.runMgr.sessionId).toBe(cfg.sessionId)
|
|
86
|
+
expect(ctx.runMgr.threadId).toBe(cfg.threadId)
|
|
87
|
+
expect(ctx.runMgr.tenantId).toBe(cfg.tenantId)
|
|
88
|
+
expect(ctx.runMgr.projectId).toBe(cfg.projectId)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('reuses the runId supplied by the caller', () => {
|
|
92
|
+
const runId = 'run_fixed' as RunId
|
|
93
|
+
const ctx = RunContextFactory.build(buildConfig({ runId }))
|
|
94
|
+
expect(ctx.runId).toBe(runId)
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
it('DefaultPathBuilder lays out runs under sessions/{sessionId}/runs', () => {
|
|
98
|
+
const builder = new DefaultPathBuilder('/base/.namzu')
|
|
99
|
+
const runDir = builder.runDir('prj_x' as ProjectId, 'ses_y' as SessionId, 'run_z' as RunId)
|
|
100
|
+
expect(runDir).toBe('/base/.namzu/projects/prj_x/sessions/ses_y/runs/run_z')
|
|
101
|
+
})
|
|
102
|
+
})
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto'
|
|
2
2
|
import type { AgentContextLevel } from '../../types/agent/factory.js'
|
|
3
|
-
import type { ThreadId } from '../../types/ids/index.js'
|
|
4
3
|
import type { AgentPersona } from '../../types/persona/index.js'
|
|
4
|
+
import type { ProjectId } from '../../types/session/ids.js'
|
|
5
5
|
import type { Skill } from '../../types/skills/index.js'
|
|
6
6
|
import type { ToolRegistryContract } from '../../types/tool/index.js'
|
|
7
7
|
import { PromptBuilder, type PromptSegments } from './prompt.js'
|
|
8
8
|
|
|
9
9
|
export interface ContextCacheConfig {
|
|
10
10
|
agentId: string
|
|
11
|
-
|
|
11
|
+
projectId: ProjectId
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export interface PromptCacheInput {
|
|
@@ -21,7 +21,7 @@ export interface PromptCacheInput {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export class ContextCache {
|
|
24
|
-
readonly
|
|
24
|
+
readonly projectId: ProjectId
|
|
25
25
|
readonly agentId: string
|
|
26
26
|
|
|
27
27
|
private cachedPrompt: string | undefined
|
|
@@ -30,7 +30,7 @@ export class ContextCache {
|
|
|
30
30
|
private cachedStaticHash: string | undefined
|
|
31
31
|
|
|
32
32
|
constructor(config: ContextCacheConfig) {
|
|
33
|
-
this.
|
|
33
|
+
this.projectId = config.projectId
|
|
34
34
|
this.agentId = config.agentId
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -1,17 +1,42 @@
|
|
|
1
1
|
import { join } from 'node:path'
|
|
2
2
|
import { PlanManager } from '../../manager/plan/lifecycle.js'
|
|
3
3
|
import { RunPersistence } from '../../manager/run/persistence.js'
|
|
4
|
+
import {
|
|
5
|
+
DefaultFilesystemMigrator,
|
|
6
|
+
type FilesystemMigrationResult,
|
|
7
|
+
type FilesystemMigrationSink,
|
|
8
|
+
type FilesystemMigrator,
|
|
9
|
+
NOOP_FILESYSTEM_MIGRATION_SINK,
|
|
10
|
+
} from '../../session/migration/index.js'
|
|
11
|
+
import { DefaultPathBuilder, type PathBuilder } from '../../session/workspace/path-builder.js'
|
|
4
12
|
import { ActivityStore } from '../../store/activity/memory.js'
|
|
5
13
|
import { type ActivityTrackingConfig, resolveActivityTracking } from '../../types/activity/index.js'
|
|
6
|
-
import type { RunId,
|
|
14
|
+
import type { RunId, SessionId, TenantId } from '../../types/ids/index.js'
|
|
7
15
|
import type { Message } from '../../types/message/index.js'
|
|
8
16
|
import type { PermissionMode } from '../../types/permission/index.js'
|
|
9
17
|
import type { LLMProvider } from '../../types/provider/index.js'
|
|
10
18
|
import type { AgentRunConfig } from '../../types/run/index.js'
|
|
19
|
+
import type { ProjectId, ThreadId } from '../../types/session/ids.js'
|
|
11
20
|
import type { ModelPricing } from '../../utils/cost.js'
|
|
12
21
|
import { generateRunId } from '../../utils/id.js'
|
|
13
22
|
import { type Logger, getRootLogger } from '../../utils/logger.js'
|
|
14
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Config accepted by {@link RunContextFactory.build}. `sessionId`,
|
|
26
|
+
* `threadId`, `projectId`, and `tenantId` are required — runs carry the full
|
|
27
|
+
* five-layer scope (Tenant → Project → Thread → Session → Run) per
|
|
28
|
+
* Convention #17.
|
|
29
|
+
*
|
|
30
|
+
* `pathBuilder` is optional; when absent a {@link DefaultPathBuilder} is
|
|
31
|
+
* constructed against `{workingDirectory}/.namzu`.
|
|
32
|
+
*
|
|
33
|
+
* `filesystemMigrator` + `migrationSink` are optional; when absent a
|
|
34
|
+
* {@link DefaultFilesystemMigrator} wired to the
|
|
35
|
+
* {@link NOOP_FILESYSTEM_MIGRATION_SINK} is used. Migration runs once per
|
|
36
|
+
* process via {@link RunContextFactory.ensureMigrated}; the static `build`
|
|
37
|
+
* method stays synchronous so existing call sites are not broken — async
|
|
38
|
+
* callers (e.g. `query()`) invoke `ensureMigrated` themselves before build.
|
|
39
|
+
*/
|
|
15
40
|
export interface RunContextConfig {
|
|
16
41
|
agentId: string
|
|
17
42
|
agentName: string
|
|
@@ -23,7 +48,22 @@ export interface RunContextConfig {
|
|
|
23
48
|
messages: Message[]
|
|
24
49
|
signal?: AbortSignal
|
|
25
50
|
|
|
51
|
+
sessionId: SessionId
|
|
26
52
|
threadId: ThreadId
|
|
53
|
+
projectId: ProjectId
|
|
54
|
+
tenantId: TenantId
|
|
55
|
+
|
|
56
|
+
pathBuilder?: PathBuilder
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Optional injected migrator — tests pass a stub; production code relies
|
|
60
|
+
* on the {@link DefaultFilesystemMigrator}. See session-hierarchy.md
|
|
61
|
+
* §13.4.1.
|
|
62
|
+
*/
|
|
63
|
+
filesystemMigrator?: FilesystemMigrator
|
|
64
|
+
|
|
65
|
+
/** Optional sink for `filesystem.migrated` events. Defaults to no-op. */
|
|
66
|
+
migrationSink?: FilesystemMigrationSink
|
|
27
67
|
|
|
28
68
|
runId?: RunId
|
|
29
69
|
|
|
@@ -32,9 +72,13 @@ export interface RunContextConfig {
|
|
|
32
72
|
depth?: number
|
|
33
73
|
}
|
|
34
74
|
|
|
75
|
+
/** Result of {@link RunContextFactory.build}. */
|
|
35
76
|
export interface RunContext {
|
|
36
77
|
runId: RunId
|
|
78
|
+
sessionId: SessionId
|
|
37
79
|
threadId: ThreadId
|
|
80
|
+
projectId: ProjectId
|
|
81
|
+
tenantId: TenantId
|
|
38
82
|
runMgr: RunPersistence
|
|
39
83
|
activityStore: ActivityStore
|
|
40
84
|
planManager: PlanManager
|
|
@@ -46,7 +90,44 @@ export interface RunContext {
|
|
|
46
90
|
trackingConfig: ActivityTrackingConfig
|
|
47
91
|
}
|
|
48
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Module-level first-call guard for the boot-time filesystem migration
|
|
95
|
+
* (session-hierarchy.md §13.4.1). Keyed on the root directory so a single
|
|
96
|
+
* process that spans multiple `.namzu` roots (unusual but legal) migrates
|
|
97
|
+
* each one once. Subsequent calls short-circuit via the cached promise —
|
|
98
|
+
* never re-reading the on-disk marker per call.
|
|
99
|
+
*/
|
|
100
|
+
const migrationPromises = new Map<string, Promise<FilesystemMigrationResult>>()
|
|
101
|
+
|
|
102
|
+
/** Testing hook — clears the first-call guard cache. */
|
|
103
|
+
export function __resetMigrationGuardForTests(): void {
|
|
104
|
+
migrationPromises.clear()
|
|
105
|
+
}
|
|
106
|
+
|
|
49
107
|
export class RunContextFactory {
|
|
108
|
+
/**
|
|
109
|
+
* Run the boot-time filesystem migration for `rootDir` at most once per
|
|
110
|
+
* process. Safe to `await` from any async entry point; concurrent callers
|
|
111
|
+
* for the same root share a single migration promise (no duplicate work,
|
|
112
|
+
* no race with the on-disk `.tmp` lock).
|
|
113
|
+
*/
|
|
114
|
+
static ensureMigrated(
|
|
115
|
+
rootDir: string,
|
|
116
|
+
migrator: FilesystemMigrator = new DefaultFilesystemMigrator(NOOP_FILESYSTEM_MIGRATION_SINK),
|
|
117
|
+
): Promise<FilesystemMigrationResult> {
|
|
118
|
+
const cached = migrationPromises.get(rootDir)
|
|
119
|
+
if (cached) return cached
|
|
120
|
+
const promise = migrator.migrate(rootDir)
|
|
121
|
+
migrationPromises.set(rootDir, promise)
|
|
122
|
+
// Crash-safety: if the migration rejects, drop the cached promise so
|
|
123
|
+
// the next caller gets a fresh attempt. Successful results stay cached
|
|
124
|
+
// (idempotency — further calls short-circuit without re-running).
|
|
125
|
+
promise.catch(() => {
|
|
126
|
+
migrationPromises.delete(rootDir)
|
|
127
|
+
})
|
|
128
|
+
return promise
|
|
129
|
+
}
|
|
130
|
+
|
|
50
131
|
static build(config: RunContextConfig): RunContext {
|
|
51
132
|
const abortController = new AbortController()
|
|
52
133
|
if (config.signal) {
|
|
@@ -57,17 +138,18 @@ export class RunContextFactory {
|
|
|
57
138
|
const permissionMode = config.runConfig.permissionMode ?? 'auto'
|
|
58
139
|
const runId = config.runId ?? generateRunId()
|
|
59
140
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const threadId: ThreadId = config.threadId
|
|
64
|
-
const outputDir = join(cwd, '.namzu', 'threads', threadId, 'runs')
|
|
141
|
+
const pathBuilder = config.pathBuilder ?? new DefaultPathBuilder(join(cwd, '.namzu'))
|
|
142
|
+
const outputDir = pathBuilder.sessionDir(config.projectId, config.sessionId)
|
|
143
|
+
const runsDir = join(outputDir, 'runs')
|
|
65
144
|
|
|
66
145
|
const log = getRootLogger().child({
|
|
67
146
|
component: 'query',
|
|
68
147
|
agent: config.agentName,
|
|
69
148
|
runId,
|
|
70
|
-
|
|
149
|
+
sessionId: config.sessionId,
|
|
150
|
+
threadId: config.threadId,
|
|
151
|
+
projectId: config.projectId,
|
|
152
|
+
tenantId: config.tenantId,
|
|
71
153
|
})
|
|
72
154
|
|
|
73
155
|
const runMgr = new RunPersistence({
|
|
@@ -76,9 +158,13 @@ export class RunContextFactory {
|
|
|
76
158
|
agentName: config.agentName,
|
|
77
159
|
runConfig: config.runConfig,
|
|
78
160
|
providerId: config.provider.id,
|
|
79
|
-
outputDir,
|
|
161
|
+
outputDir: runsDir,
|
|
80
162
|
pricing: config.pricing,
|
|
81
163
|
log,
|
|
164
|
+
sessionId: config.sessionId,
|
|
165
|
+
threadId: config.threadId,
|
|
166
|
+
tenantId: config.tenantId,
|
|
167
|
+
projectId: config.projectId,
|
|
82
168
|
parentRunId: config.parentRunId,
|
|
83
169
|
depth: config.depth,
|
|
84
170
|
})
|
|
@@ -89,7 +175,10 @@ export class RunContextFactory {
|
|
|
89
175
|
|
|
90
176
|
return {
|
|
91
177
|
runId,
|
|
92
|
-
|
|
178
|
+
sessionId: config.sessionId,
|
|
179
|
+
threadId: config.threadId,
|
|
180
|
+
projectId: config.projectId,
|
|
181
|
+
tenantId: config.tenantId,
|
|
93
182
|
runMgr,
|
|
94
183
|
activityStore,
|
|
95
184
|
planManager,
|
|
@@ -80,6 +80,10 @@ export class EventTranslator {
|
|
|
80
80
|
})
|
|
81
81
|
break
|
|
82
82
|
default: {
|
|
83
|
+
// `TaskEvent.type` is scoped to task-store events; sub-session
|
|
84
|
+
// lifecycle events (subsession_spawned / _messaged / _idled) and
|
|
85
|
+
// run-scoped `RunEvent` variants never reach this wrapper. The
|
|
86
|
+
// exhaustiveness guard below enforces that at compile time.
|
|
83
87
|
const _exhaustive: never = event.type
|
|
84
88
|
throw new Error(`Unhandled task event type: ${_exhaustive}`)
|
|
85
89
|
}
|
|
@@ -134,6 +138,10 @@ export class EventTranslator {
|
|
|
134
138
|
case 'plan.failed':
|
|
135
139
|
break
|
|
136
140
|
default: {
|
|
141
|
+
// `PlanEvent.type` is scoped to plan-manager events; sub-session
|
|
142
|
+
// lifecycle events and other `RunEvent` variants never reach this
|
|
143
|
+
// wrapper. The exhaustiveness guard below enforces that at compile
|
|
144
|
+
// time.
|
|
137
145
|
const _exhaustive: never = event.type
|
|
138
146
|
throw new Error(`Unhandled plan event type: ${_exhaustive}`)
|
|
139
147
|
}
|
|
@@ -8,6 +8,7 @@ import { extractFromUserMessage } from '../../compaction/extractor.js'
|
|
|
8
8
|
import { WorkingStateManager } from '../../compaction/manager.js'
|
|
9
9
|
import type { CompactionConfig } from '../../config/runtime.js'
|
|
10
10
|
import { getTracer } from '../../provider/telemetry/setup.js'
|
|
11
|
+
import type { PathBuilder } from '../../session/workspace/path-builder.js'
|
|
11
12
|
import { GENAI, NAMZU, agentRunSpanName } from '../../telemetry/attributes.js'
|
|
12
13
|
import { buildAdvisoryTools } from '../../tools/advisory/index.js'
|
|
13
14
|
import { SearchToolsTool } from '../../tools/builtins/search-tools.js'
|
|
@@ -20,7 +21,7 @@ import {
|
|
|
20
21
|
type ResumeHandler,
|
|
21
22
|
autoApproveHandler,
|
|
22
23
|
} from '../../types/hitl/index.js'
|
|
23
|
-
import type { RunId,
|
|
24
|
+
import type { RunId, SessionId, TenantId } from '../../types/ids/index.js'
|
|
24
25
|
import type { InvocationState } from '../../types/invocation/index.js'
|
|
25
26
|
import { type Message, createSystemMessage } from '../../types/message/index.js'
|
|
26
27
|
import type { AgentPersona } from '../../types/persona/index.js'
|
|
@@ -28,6 +29,7 @@ import type { LLMProvider } from '../../types/provider/index.js'
|
|
|
28
29
|
import type { TaskRouterConfig } from '../../types/router/index.js'
|
|
29
30
|
import type { AgentRun, AgentRunConfig, RunEvent, RunEventListener } from '../../types/run/index.js'
|
|
30
31
|
import type { Sandbox, SandboxProvider } from '../../types/sandbox/index.js'
|
|
32
|
+
import type { ProjectId, ThreadId } from '../../types/session/ids.js'
|
|
31
33
|
import type { Skill } from '../../types/skills/index.js'
|
|
32
34
|
import type { TaskStore } from '../../types/task/index.js'
|
|
33
35
|
import type { ToolRegistryContract } from '../../types/tool/index.js'
|
|
@@ -65,8 +67,31 @@ export interface QueryParams {
|
|
|
65
67
|
resumeHandler: ResumeHandler
|
|
66
68
|
resumeFromCheckpoint?: CheckpointId
|
|
67
69
|
|
|
70
|
+
/** Session scope for the run. Required — every run is attributed to a Session. */
|
|
71
|
+
sessionId: SessionId
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Topic the Session lives under. Required in 0.3.0 — every run carries
|
|
75
|
+
* the full five-layer scope (Tenant → Project → Thread → Session →
|
|
76
|
+
* Run). Denormalized from `session.threadId`; callers build this
|
|
77
|
+
* alongside `sessionId` so the query pipeline never needs a second
|
|
78
|
+
* SessionStore round-trip to recover it.
|
|
79
|
+
*/
|
|
68
80
|
threadId: ThreadId
|
|
69
81
|
|
|
82
|
+
/** Long-lived goal scope for the run. Required. */
|
|
83
|
+
projectId: ProjectId
|
|
84
|
+
|
|
85
|
+
/** Isolation boundary (Convention #17). Required. */
|
|
86
|
+
tenantId: TenantId
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Optional path layout override. Defaults to a {@link DefaultPathBuilder}
|
|
90
|
+
* rooted at `{workingDirectory}/.namzu`. First-call filesystem migration
|
|
91
|
+
* runs on this same entry point.
|
|
92
|
+
*/
|
|
93
|
+
pathBuilder?: PathBuilder
|
|
94
|
+
|
|
70
95
|
runId?: RunId
|
|
71
96
|
|
|
72
97
|
parentRunId?: RunId
|
|
@@ -112,6 +137,14 @@ export interface QueryParams {
|
|
|
112
137
|
}
|
|
113
138
|
|
|
114
139
|
export async function* query(params: QueryParams): AsyncGenerator<RunEvent, AgentRun> {
|
|
140
|
+
// Boot-time filesystem migration (session-hierarchy.md §13.4.1). First
|
|
141
|
+
// call per process per root actually runs; subsequent calls short-circuit
|
|
142
|
+
// via the in-memory guard in `context.ts`. Kept here rather than inside
|
|
143
|
+
// the synchronous `RunContextFactory.build` so the factory signature stays
|
|
144
|
+
// sync for tests / non-async call sites.
|
|
145
|
+
const cwdForMigration = params.workingDirectory ?? process.cwd()
|
|
146
|
+
await RunContextFactory.ensureMigrated(`${cwdForMigration}/.namzu`)
|
|
147
|
+
|
|
115
148
|
const ctx = RunContextFactory.build({
|
|
116
149
|
agentId: params.agentId,
|
|
117
150
|
agentName: params.agentName,
|
|
@@ -122,7 +155,11 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Agen
|
|
|
122
155
|
enableActivityTracking: params.enableActivityTracking,
|
|
123
156
|
messages: params.messages,
|
|
124
157
|
signal: params.signal,
|
|
158
|
+
sessionId: params.sessionId,
|
|
125
159
|
threadId: params.threadId,
|
|
160
|
+
projectId: params.projectId,
|
|
161
|
+
tenantId: params.tenantId,
|
|
162
|
+
pathBuilder: params.pathBuilder,
|
|
126
163
|
runId: params.runId,
|
|
127
164
|
parentRunId: params.parentRunId,
|
|
128
165
|
depth: params.depth,
|