@namzu/sdk 0.1.8 → 0.2.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 +16 -0
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +5 -3
- 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 +18 -5
- package/dist/agents/SupervisorAgent.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/task.d.ts +2 -2
- package/dist/bridge/a2a/task.d.ts.map +1 -1
- package/dist/bridge/a2a/task.js.map +1 -1
- package/dist/bridge/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 +22 -3
- package/dist/contracts/api.d.ts.map +1 -1
- package/dist/contracts/index.d.ts +3 -1
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.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 +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- 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 +302 -0
- package/dist/manager/agent/__tests__/lifecycle.test.js.map +1 -0
- package/dist/manager/agent/lifecycle.d.ts +58 -3
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +311 -12
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/run/persistence.d.ts +8 -1
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +15 -0
- package/dist/manager/run/persistence.js.map +1 -1
- 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 +84 -0
- package/dist/runtime/query/__tests__/context.test.js.map +1 -0
- package/dist/runtime/query/context.d.ts +55 -2
- package/dist/runtime/query/context.d.ts.map +1 -1
- package/dist/runtime/query/context.js +48 -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 +25 -2
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +11 -1
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/session/__tests__/integration/_fixtures.d.ts +115 -0
- package/dist/session/__tests__/integration/_fixtures.d.ts.map +1 -0
- package/dist/session/__tests__/integration/_fixtures.js +198 -0
- package/dist/session/__tests__/integration/_fixtures.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 +116 -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 +226 -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 +323 -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 +170 -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 +146 -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 +163 -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 +157 -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 +241 -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 +186 -0
- package/dist/session/__tests__/integration/retention-archive.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 +200 -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 +180 -0
- package/dist/session/__tests__/integration/tenant-isolation.test.js.map +1 -0
- package/dist/session/errors.d.ts +60 -0
- package/dist/session/errors.d.ts.map +1 -0
- package/dist/session/errors.js +50 -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 +243 -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 +100 -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 +230 -0
- package/dist/session/handoff/__tests__/single.test.js.map +1 -0
- package/dist/session/handoff/assignment.d.ts +59 -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 +47 -0
- package/dist/session/handoff/broadcast.d.ts.map +1 -0
- package/dist/session/handoff/broadcast.js +296 -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 +62 -0
- package/dist/session/handoff/single.d.ts.map +1 -0
- package/dist/session/handoff/single.js +217 -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 +67 -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 +8 -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 +59 -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/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 +98 -0
- package/dist/session/migration/id-prefix.d.ts.map +1 -0
- package/dist/session/migration/id-prefix.js +116 -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 +252 -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 +269 -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/conversation/memory.d.ts +22 -0
- package/dist/store/conversation/memory.d.ts.map +1 -1
- package/dist/store/conversation/memory.js +22 -0
- package/dist/store/conversation/memory.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 +240 -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 +217 -0
- package/dist/store/session/__tests__/memory.test.js.map +1 -0
- package/dist/store/session/disk.d.ts +85 -0
- package/dist/store/session/disk.d.ts.map +1 -0
- package/dist/store/session/disk.js +757 -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 +11 -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 +48 -0
- package/dist/store/session/memory.d.ts.map +1 -0
- package/dist/store/session/memory.js +322 -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/tools/builtins/__tests__/structuredOutput.example.d.ts +1 -1
- package/dist/types/agent/base.d.ts +28 -1
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/task.d.ts +50 -2
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/agent/task.js.map +1 -1
- package/dist/types/conversation/index.d.ts +7 -0
- package/dist/types/conversation/index.d.ts.map +1 -1
- package/dist/types/ids/index.d.ts +26 -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/run/config.d.ts +11 -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 +24 -1
- 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 +18 -0
- package/dist/types/session/ids.d.ts.map +1 -0
- package/dist/types/session/ids.js +12 -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 +188 -0
- package/dist/types/session/store.d.ts.map +1 -0
- package/dist/types/session/store.js +14 -0
- package/dist/types/session/store.js.map +1 -0
- package/dist/utils/id.d.ts +18 -1
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/id.js +42 -4
- package/dist/utils/id.js.map +1 -1
- package/package.json +1 -1
- package/src/agents/ReactiveAgent.ts +7 -3
- package/src/agents/RouterAgent.ts +5 -0
- package/src/agents/SupervisorAgent.ts +26 -6
- package/src/bridge/a2a/mapper.ts +7 -0
- package/src/bridge/a2a/task.ts +2 -2
- package/src/bridge/sse/mapper.ts +8 -1
- package/src/constants/a2a/index.ts +2 -2
- package/src/contracts/api.ts +23 -3
- package/src/contracts/index.ts +2 -0
- package/src/gateway/local.ts +6 -0
- package/src/index.ts +14 -0
- package/src/manager/agent/__tests__/lifecycle.test.ts +452 -0
- package/src/manager/agent/lifecycle.ts +434 -19
- package/src/manager/run/persistence.ts +20 -1
- package/src/run/reporter.ts +28 -0
- package/src/runtime/query/__tests__/context.test.ts +101 -0
- package/src/runtime/query/context.ts +106 -10
- package/src/runtime/query/events.ts +8 -0
- package/src/runtime/query/index.ts +41 -3
- package/src/session/__tests__/integration/_fixtures.ts +282 -0
- package/src/session/__tests__/integration/capacity-caps.test.ts +164 -0
- package/src/session/__tests__/integration/e2e-spawn.test.ts +278 -0
- package/src/session/__tests__/integration/event-stream-ordering.test.ts +403 -0
- package/src/session/__tests__/integration/handoff-broadcast-e2e.test.ts +245 -0
- package/src/session/__tests__/integration/handoff-illegal-transition.test.ts +179 -0
- package/src/session/__tests__/integration/handoff-single-e2e.test.ts +220 -0
- package/src/session/__tests__/integration/hierarchy-lifecycle.test.ts +237 -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 +318 -0
- package/src/session/__tests__/integration/retention-archive.test.ts +231 -0
- package/src/session/__tests__/integration/summary-materialization-e2e.test.ts +237 -0
- package/src/session/__tests__/integration/tenant-isolation.test.ts +282 -0
- package/src/session/errors.ts +70 -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 +350 -0
- package/src/session/handoff/__tests__/capacity.test.ts +123 -0
- package/src/session/handoff/__tests__/single.test.ts +316 -0
- package/src/session/handoff/assignment.ts +62 -0
- package/src/session/handoff/broadcast.ts +381 -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 +288 -0
- package/src/session/handoff/version.ts +59 -0
- package/src/session/hierarchy/__tests__/session.test.ts +92 -0
- package/src/session/hierarchy/actor.ts +17 -0
- package/src/session/hierarchy/index.ts +17 -0
- package/src/session/hierarchy/lineage.ts +15 -0
- package/src/session/hierarchy/project.ts +41 -0
- package/src/session/hierarchy/session.ts +97 -0
- package/src/session/hierarchy/sub-session.ts +92 -0
- package/src/session/hierarchy/tenant.ts +13 -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 +146 -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 +316 -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 +341 -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/conversation/memory.ts +23 -0
- package/src/store/session/__tests__/disk.test.ts +346 -0
- package/src/store/session/__tests__/memory.test.ts +327 -0
- package/src/store/session/disk.ts +920 -0
- package/src/store/session/index.ts +14 -0
- package/src/store/session/linkage.ts +80 -0
- package/src/store/session/memory.ts +400 -0
- package/src/store/session/messages.ts +21 -0
- package/src/types/agent/base.ts +31 -1
- package/src/types/agent/task.ts +58 -2
- package/src/types/conversation/index.ts +7 -0
- package/src/types/ids/index.ts +41 -3
- package/src/types/invocation/__tests__/state.test.ts +37 -29
- package/src/types/invocation/index.ts +26 -10
- package/src/types/run/config.ts +12 -1
- package/src/types/run/events.ts +36 -1
- package/src/types/run/index.ts +8 -0
- package/src/types/run/metadata.ts +24 -1
- package/src/types/run/status.ts +33 -0
- package/src/types/session/ids.ts +34 -0
- package/src/types/session/index.ts +28 -0
- package/src/types/session/store.ts +229 -0
- package/src/utils/id.ts +55 -4
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { EMPTY_TOKEN_USAGE } from '../../../constants/limits.js'
|
|
3
|
+
import { AgentRegistry } from '../../../registry/agent/definitions.js'
|
|
4
|
+
import {
|
|
5
|
+
DefaultCapacityValidator,
|
|
6
|
+
DelegationCapacityExceeded,
|
|
7
|
+
} from '../../../session/handoff/capacity.js'
|
|
8
|
+
import type { ActorRef } from '../../../session/hierarchy/actor.js'
|
|
9
|
+
import type { DeliverableRef } from '../../../session/summary/deliverable.js'
|
|
10
|
+
import { SessionSummaryMaterializer } from '../../../session/summary/materialize.js'
|
|
11
|
+
import { WorkspaceBackendRegistry } from '../../../session/workspace/registry.js'
|
|
12
|
+
import { InMemorySessionStore } from '../../../store/session/memory.js'
|
|
13
|
+
import type {
|
|
14
|
+
AgentCapabilities,
|
|
15
|
+
AgentInput,
|
|
16
|
+
AgentMetadata,
|
|
17
|
+
BaseAgentConfig,
|
|
18
|
+
BaseAgentResult,
|
|
19
|
+
} from '../../../types/agent/base.js'
|
|
20
|
+
import type { Agent } from '../../../types/agent/core.js'
|
|
21
|
+
import type { AgentDefinition } from '../../../types/agent/factory.js'
|
|
22
|
+
import type { AgentTaskContext, SendMessageOptions } from '../../../types/agent/task.js'
|
|
23
|
+
import type { AgentId, SessionId, TenantId, UserId } from '../../../types/ids/index.js'
|
|
24
|
+
import { createAssistantMessage } from '../../../types/message/index.js'
|
|
25
|
+
import type { RunEvent } from '../../../types/run/events.js'
|
|
26
|
+
import type { SummaryId } from '../../../types/session/ids.js'
|
|
27
|
+
import { ZERO_COST } from '../../../utils/cost.js'
|
|
28
|
+
import { AgentManager } from '../lifecycle.js'
|
|
29
|
+
|
|
30
|
+
const tenant = 'tnt_alpha' as TenantId
|
|
31
|
+
const otherTenant = 'tnt_beta' as TenantId
|
|
32
|
+
|
|
33
|
+
const capabilities: AgentCapabilities = {
|
|
34
|
+
supportsTools: false,
|
|
35
|
+
supportsStreaming: false,
|
|
36
|
+
supportsConcurrency: false,
|
|
37
|
+
supportsSubAgents: false,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function makeAgent(
|
|
41
|
+
id: string,
|
|
42
|
+
run: (input: AgentInput, config: BaseAgentConfig) => Promise<BaseAgentResult>,
|
|
43
|
+
): Agent<BaseAgentConfig, BaseAgentResult> {
|
|
44
|
+
const metadata: AgentMetadata = {
|
|
45
|
+
type: 'reactive',
|
|
46
|
+
id,
|
|
47
|
+
name: id,
|
|
48
|
+
version: '1.0.0',
|
|
49
|
+
category: 'test',
|
|
50
|
+
description: `test agent ${id}`,
|
|
51
|
+
capabilities,
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
type: 'reactive',
|
|
55
|
+
metadata,
|
|
56
|
+
run: async (input, config) => run(input, config),
|
|
57
|
+
cancel: async () => undefined,
|
|
58
|
+
getCapabilities: () => capabilities,
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function makeDefinition(agent: Agent<BaseAgentConfig, BaseAgentResult>): AgentDefinition {
|
|
63
|
+
return {
|
|
64
|
+
info: {
|
|
65
|
+
id: agent.metadata.id,
|
|
66
|
+
name: agent.metadata.name,
|
|
67
|
+
version: agent.metadata.version,
|
|
68
|
+
category: agent.metadata.category,
|
|
69
|
+
description: agent.metadata.description,
|
|
70
|
+
tools: [],
|
|
71
|
+
defaults: {
|
|
72
|
+
model: 'test',
|
|
73
|
+
tokenBudget: 1_000,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
typedAgent: agent,
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function successResult(): BaseAgentResult {
|
|
81
|
+
return {
|
|
82
|
+
runId: 'run_test' as import('../../../types/ids/index.js').RunId,
|
|
83
|
+
status: 'completed',
|
|
84
|
+
usage: { ...EMPTY_TOKEN_USAGE },
|
|
85
|
+
cost: { ...ZERO_COST },
|
|
86
|
+
iterations: 1,
|
|
87
|
+
durationMs: 1,
|
|
88
|
+
messages: [createAssistantMessage('child finished successfully')],
|
|
89
|
+
result: 'child finished successfully',
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function failureResult(error: string): BaseAgentResult {
|
|
94
|
+
return {
|
|
95
|
+
runId: 'run_test' as import('../../../types/ids/index.js').RunId,
|
|
96
|
+
status: 'failed',
|
|
97
|
+
usage: { ...EMPTY_TOKEN_USAGE },
|
|
98
|
+
cost: { ...ZERO_COST },
|
|
99
|
+
iterations: 1,
|
|
100
|
+
durationMs: 1,
|
|
101
|
+
messages: [],
|
|
102
|
+
lastError: error,
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function user(tid: TenantId = tenant): ActorRef {
|
|
107
|
+
return { kind: 'user', userId: 'usr_root' as UserId, tenantId: tid }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function agentActor(id: string, tid: TenantId = tenant): ActorRef {
|
|
111
|
+
return { kind: 'agent', agentId: id as AgentId, tenantId: tid }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
interface Harness {
|
|
115
|
+
store: InMemorySessionStore
|
|
116
|
+
materializer: SessionSummaryMaterializer
|
|
117
|
+
manager: AgentManager
|
|
118
|
+
parentSession: Awaited<ReturnType<InMemorySessionStore['createSession']>>
|
|
119
|
+
projectId: import('../../../types/session/ids.js').ProjectId
|
|
120
|
+
registry: AgentRegistry
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function buildHarness(
|
|
124
|
+
childAgent: Agent<BaseAgentConfig, BaseAgentResult>,
|
|
125
|
+
tenantId: TenantId = tenant,
|
|
126
|
+
): Promise<Harness> {
|
|
127
|
+
const store = new InMemorySessionStore()
|
|
128
|
+
const project = await store.createProject({ tenantId, name: 'p1' }, tenantId)
|
|
129
|
+
const parentSession = await store.createSession(
|
|
130
|
+
{ projectId: project.id, currentActor: user(tenantId) },
|
|
131
|
+
tenantId,
|
|
132
|
+
)
|
|
133
|
+
// Parent runs kick the session into 'active' so the materializer can
|
|
134
|
+
// flip it back to 'idle' once the child completes.
|
|
135
|
+
await store.updateSession({ ...parentSession, status: 'active' }, tenantId)
|
|
136
|
+
|
|
137
|
+
let summaryCounter = 0
|
|
138
|
+
const materializer = new SessionSummaryMaterializer({
|
|
139
|
+
store,
|
|
140
|
+
generateSummaryId: () => `sum_test_${++summaryCounter}` as SummaryId,
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
const registry = new AgentRegistry()
|
|
144
|
+
registry.register(makeDefinition(childAgent))
|
|
145
|
+
|
|
146
|
+
const manager = new AgentManager(registry, undefined, {
|
|
147
|
+
sessionStore: store,
|
|
148
|
+
summaryMaterializer: materializer,
|
|
149
|
+
workspaceRegistry: new WorkspaceBackendRegistry(),
|
|
150
|
+
capacity: new DefaultCapacityValidator(store),
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
store,
|
|
155
|
+
materializer,
|
|
156
|
+
manager,
|
|
157
|
+
parentSession: { ...parentSession, status: 'active' },
|
|
158
|
+
projectId: project.id,
|
|
159
|
+
registry,
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function buildContext(
|
|
164
|
+
parentSessionId: SessionId,
|
|
165
|
+
projectId: import('../../../types/session/ids.js').ProjectId,
|
|
166
|
+
tenantId: TenantId = tenant,
|
|
167
|
+
depth = 0,
|
|
168
|
+
): AgentTaskContext {
|
|
169
|
+
return {
|
|
170
|
+
parentRunId: 'run_parent' as import('../../../types/ids/index.js').RunId,
|
|
171
|
+
parentAgentId: 'parent-agent',
|
|
172
|
+
parentAbortController: new AbortController(),
|
|
173
|
+
depth,
|
|
174
|
+
budgetTracker: { total: 100_000, remaining: 100_000 },
|
|
175
|
+
tenantId,
|
|
176
|
+
sessionId: parentSessionId,
|
|
177
|
+
projectId,
|
|
178
|
+
parentActor: user(tenantId),
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function buildOptions(
|
|
183
|
+
agentId: string,
|
|
184
|
+
parentSessionId: SessionId,
|
|
185
|
+
projectId: import('../../../types/session/ids.js').ProjectId,
|
|
186
|
+
tenantId: TenantId = tenant,
|
|
187
|
+
): SendMessageOptions {
|
|
188
|
+
return {
|
|
189
|
+
agentId,
|
|
190
|
+
input: { messages: [], workingDirectory: '/tmp' },
|
|
191
|
+
parentSessionId,
|
|
192
|
+
tenantId,
|
|
193
|
+
projectId,
|
|
194
|
+
parentActor: user(tenantId),
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
async function waitForTask(
|
|
199
|
+
manager: AgentManager,
|
|
200
|
+
taskId: import('../../../types/ids/index.js').TaskId,
|
|
201
|
+
): Promise<void> {
|
|
202
|
+
await manager.waitForCompletion(taskId)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
describe('AgentManager.sendMessage — Phase 6 SubSession spawn', () => {
|
|
206
|
+
it('happy path: SubSession + Session + Summary, lineage stamped, status idle', async () => {
|
|
207
|
+
const childAgent = makeAgent('child-1', async () => successResult())
|
|
208
|
+
const harness = await buildHarness(childAgent)
|
|
209
|
+
const events: RunEvent[] = []
|
|
210
|
+
|
|
211
|
+
const listener = (e: RunEvent): void => {
|
|
212
|
+
events.push(e)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const task = await harness.manager.sendMessage(
|
|
216
|
+
buildOptions('child-1', harness.parentSession.id, harness.projectId),
|
|
217
|
+
buildContext(harness.parentSession.id, harness.projectId),
|
|
218
|
+
listener,
|
|
219
|
+
)
|
|
220
|
+
await waitForTask(harness.manager, task.taskId)
|
|
221
|
+
|
|
222
|
+
const spawnRecord = harness.manager.getSpawnRecord(task.taskId)
|
|
223
|
+
expect(spawnRecord).toBeDefined()
|
|
224
|
+
|
|
225
|
+
const childSession = await harness.store.getSession(spawnRecord!.childSessionId, tenant)
|
|
226
|
+
expect(childSession?.status).toBe('idle')
|
|
227
|
+
|
|
228
|
+
const subSession = await harness.store.getSubSession(spawnRecord!.subSessionId, tenant)
|
|
229
|
+
expect(subSession?.status).toBe('idle')
|
|
230
|
+
expect(subSession?.summaryRef).toBeDefined()
|
|
231
|
+
|
|
232
|
+
const summary = await harness.store.getSummary(spawnRecord!.childSessionId, tenant)
|
|
233
|
+
expect(summary).toBeDefined()
|
|
234
|
+
expect(summary?.materializedBy).toBe('kernel')
|
|
235
|
+
expect(summary?.agentSummary).toBe('child finished successfully')
|
|
236
|
+
|
|
237
|
+
// Events — spawn + idled both present with lineage.
|
|
238
|
+
const spawned = events.find((e) => e.type === 'subsession_spawned')
|
|
239
|
+
expect(spawned).toBeDefined()
|
|
240
|
+
if (spawned && 'lineage' in spawned) {
|
|
241
|
+
expect(spawned.lineage.parentSessionId).toBe(harness.parentSession.id)
|
|
242
|
+
expect(spawned.lineage.rootSessionId).toBe(harness.parentSession.id)
|
|
243
|
+
expect(spawned.lineage.depth).toBe(1)
|
|
244
|
+
expect(spawned.schemaVersion).toBe(2)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const idled = events.find((e) => e.type === 'subsession_idled')
|
|
248
|
+
expect(idled).toBeDefined()
|
|
249
|
+
if (idled && 'lineage' in idled) {
|
|
250
|
+
expect(idled.lineage.depth).toBe(1)
|
|
251
|
+
expect(idled.schemaVersion).toBe(2)
|
|
252
|
+
}
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
it('width: exceeding maxDelegationWidth (8) rejects with DelegationCapacityExceeded', async () => {
|
|
256
|
+
const childAgent = makeAgent('child-1', async () => successResult())
|
|
257
|
+
const harness = await buildHarness(childAgent)
|
|
258
|
+
|
|
259
|
+
// Pre-fill 8 direct sub-sessions under the parent, up to the default width cap.
|
|
260
|
+
for (let i = 0; i < 8; i++) {
|
|
261
|
+
const sibling = await harness.store.createSession(
|
|
262
|
+
{ projectId: harness.projectId, currentActor: agentActor('sibling') },
|
|
263
|
+
tenant,
|
|
264
|
+
)
|
|
265
|
+
await harness.store.createSubSession(
|
|
266
|
+
{
|
|
267
|
+
parentSessionId: harness.parentSession.id,
|
|
268
|
+
childSessionId: sibling.id,
|
|
269
|
+
kind: 'agent_spawn',
|
|
270
|
+
spawnedBy: user(),
|
|
271
|
+
},
|
|
272
|
+
tenant,
|
|
273
|
+
)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
await expect(
|
|
277
|
+
harness.manager.sendMessage(
|
|
278
|
+
buildOptions('child-1', harness.parentSession.id, harness.projectId),
|
|
279
|
+
buildContext(harness.parentSession.id, harness.projectId),
|
|
280
|
+
),
|
|
281
|
+
).rejects.toBeInstanceOf(DelegationCapacityExceeded)
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
it('depth: ancestry chain exceeding maxDelegationDepth (4) rejects with DelegationCapacityExceeded', async () => {
|
|
285
|
+
const childAgent = makeAgent('child-1', async () => successResult())
|
|
286
|
+
const harness = await buildHarness(childAgent)
|
|
287
|
+
|
|
288
|
+
// Build a chain root→c1→c2→c3→c4 and then try to spawn under c4 — the
|
|
289
|
+
// 5th delegation level exceeds the default depth cap of 4.
|
|
290
|
+
let parentId: SessionId = harness.parentSession.id
|
|
291
|
+
for (let i = 0; i < 4; i++) {
|
|
292
|
+
const child = await harness.store.createSession(
|
|
293
|
+
{ projectId: harness.projectId, currentActor: agentActor('c') },
|
|
294
|
+
tenant,
|
|
295
|
+
)
|
|
296
|
+
await harness.store.createSubSession(
|
|
297
|
+
{
|
|
298
|
+
parentSessionId: parentId,
|
|
299
|
+
childSessionId: child.id,
|
|
300
|
+
kind: 'agent_spawn',
|
|
301
|
+
spawnedBy: user(),
|
|
302
|
+
},
|
|
303
|
+
tenant,
|
|
304
|
+
)
|
|
305
|
+
parentId = child.id
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
await expect(
|
|
309
|
+
harness.manager.sendMessage(
|
|
310
|
+
buildOptions('child-1', parentId, harness.projectId),
|
|
311
|
+
buildContext(parentId, harness.projectId, tenant, 0),
|
|
312
|
+
),
|
|
313
|
+
).rejects.toBeInstanceOf(DelegationCapacityExceeded)
|
|
314
|
+
})
|
|
315
|
+
|
|
316
|
+
it('failure: SubSession marked failed; no summary materialized', async () => {
|
|
317
|
+
const childAgent = makeAgent('child-fail', async () => failureResult('boom'))
|
|
318
|
+
const harness = await buildHarness(childAgent)
|
|
319
|
+
|
|
320
|
+
const task = await harness.manager.sendMessage(
|
|
321
|
+
buildOptions('child-fail', harness.parentSession.id, harness.projectId),
|
|
322
|
+
buildContext(harness.parentSession.id, harness.projectId),
|
|
323
|
+
)
|
|
324
|
+
await waitForTask(harness.manager, task.taskId)
|
|
325
|
+
|
|
326
|
+
const spawnRecord = harness.manager.getSpawnRecord(task.taskId)
|
|
327
|
+
expect(spawnRecord).toBeDefined()
|
|
328
|
+
|
|
329
|
+
const subSession = await harness.store.getSubSession(spawnRecord!.subSessionId, tenant)
|
|
330
|
+
expect(subSession?.status).toBe('failed')
|
|
331
|
+
|
|
332
|
+
const summary = await harness.store.getSummary(spawnRecord!.childSessionId, tenant)
|
|
333
|
+
expect(summary).toBeNull()
|
|
334
|
+
})
|
|
335
|
+
|
|
336
|
+
it('child messages retrievable: sessionStore.drill returns the child transcript', async () => {
|
|
337
|
+
const childAgent = makeAgent('child-msgs', async () => {
|
|
338
|
+
const result = successResult()
|
|
339
|
+
return result
|
|
340
|
+
})
|
|
341
|
+
const harness = await buildHarness(childAgent)
|
|
342
|
+
|
|
343
|
+
const task = await harness.manager.sendMessage(
|
|
344
|
+
buildOptions('child-msgs', harness.parentSession.id, harness.projectId),
|
|
345
|
+
buildContext(harness.parentSession.id, harness.projectId),
|
|
346
|
+
)
|
|
347
|
+
await waitForTask(harness.manager, task.taskId)
|
|
348
|
+
|
|
349
|
+
const spawnRecord = harness.manager.getSpawnRecord(task.taskId)
|
|
350
|
+
expect(spawnRecord).toBeDefined()
|
|
351
|
+
|
|
352
|
+
// drill on the child session surfaces the session metadata — the child
|
|
353
|
+
// transcript would be persisted on the runtime path (RunPersistence) in
|
|
354
|
+
// a full run; here we assert the drill primitive resolves cleanly.
|
|
355
|
+
const drill = await harness.store.drill(spawnRecord!.childSessionId, tenant)
|
|
356
|
+
expect(drill).not.toBeNull()
|
|
357
|
+
expect(drill?.session.id).toBe(spawnRecord!.childSessionId)
|
|
358
|
+
expect(drill?.ancestry).toEqual([harness.parentSession.id, spawnRecord!.childSessionId])
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
it('lineage chain: 3-deep delegation carries correct rootSessionId + depth', async () => {
|
|
362
|
+
const childAgent = makeAgent('grandchild', async () => successResult())
|
|
363
|
+
const harness = await buildHarness(childAgent)
|
|
364
|
+
|
|
365
|
+
// Seed c1 under parentSession, c2 under c1.
|
|
366
|
+
const c1 = await harness.store.createSession(
|
|
367
|
+
{ projectId: harness.projectId, currentActor: agentActor('c1') },
|
|
368
|
+
tenant,
|
|
369
|
+
)
|
|
370
|
+
await harness.store.createSubSession(
|
|
371
|
+
{
|
|
372
|
+
parentSessionId: harness.parentSession.id,
|
|
373
|
+
childSessionId: c1.id,
|
|
374
|
+
kind: 'agent_spawn',
|
|
375
|
+
spawnedBy: user(),
|
|
376
|
+
},
|
|
377
|
+
tenant,
|
|
378
|
+
)
|
|
379
|
+
const c2 = await harness.store.createSession(
|
|
380
|
+
{ projectId: harness.projectId, currentActor: agentActor('c2') },
|
|
381
|
+
tenant,
|
|
382
|
+
)
|
|
383
|
+
await harness.store.createSubSession(
|
|
384
|
+
{
|
|
385
|
+
parentSessionId: c1.id,
|
|
386
|
+
childSessionId: c2.id,
|
|
387
|
+
kind: 'agent_spawn',
|
|
388
|
+
spawnedBy: user(),
|
|
389
|
+
},
|
|
390
|
+
tenant,
|
|
391
|
+
)
|
|
392
|
+
|
|
393
|
+
const events: RunEvent[] = []
|
|
394
|
+
const task = await harness.manager.sendMessage(
|
|
395
|
+
buildOptions('grandchild', c2.id, harness.projectId),
|
|
396
|
+
buildContext(c2.id, harness.projectId),
|
|
397
|
+
(e) => {
|
|
398
|
+
events.push(e)
|
|
399
|
+
},
|
|
400
|
+
)
|
|
401
|
+
await waitForTask(harness.manager, task.taskId)
|
|
402
|
+
|
|
403
|
+
const spawned = events.find((e) => e.type === 'subsession_spawned')
|
|
404
|
+
expect(spawned).toBeDefined()
|
|
405
|
+
if (spawned && 'lineage' in spawned) {
|
|
406
|
+
// Ancestry is root→c1→c2; newly spawned child is depth 3.
|
|
407
|
+
expect(spawned.lineage.depth).toBe(3)
|
|
408
|
+
expect(spawned.lineage.rootSessionId).toBe(harness.parentSession.id)
|
|
409
|
+
expect(spawned.lineage.parentSessionId).toBe(c2.id)
|
|
410
|
+
}
|
|
411
|
+
})
|
|
412
|
+
|
|
413
|
+
it('kernel-only summary: type system rejects agent-constructed SessionSummaryRef at recordSummary', async () => {
|
|
414
|
+
const childAgent = makeAgent('child-1', async () => successResult())
|
|
415
|
+
const harness = await buildHarness(childAgent)
|
|
416
|
+
|
|
417
|
+
// This compile-time assertion is enforced by `materializedBy: 'kernel'`
|
|
418
|
+
// being a literal on the SummaryRef type; an agent-constructed literal
|
|
419
|
+
// with `materializedBy: 'agent'` would be rejected by the type system.
|
|
420
|
+
// Runtime assertion that the type check is still in place:
|
|
421
|
+
const summary = await harness.materializer.materialize({
|
|
422
|
+
sessionId: harness.parentSession.id,
|
|
423
|
+
tenantId: tenant,
|
|
424
|
+
finalOutcome: { status: 'succeeded' },
|
|
425
|
+
agentSummary: 'kernel-only',
|
|
426
|
+
declaredDeliverables: [] as DeliverableRef[],
|
|
427
|
+
keyDecisions: [],
|
|
428
|
+
})
|
|
429
|
+
expect(summary.materializedBy).toBe('kernel')
|
|
430
|
+
})
|
|
431
|
+
|
|
432
|
+
it('cross-tenant spawn rejected at SendMessageOptions.tenantId mismatch', async () => {
|
|
433
|
+
const childAgent = makeAgent('child-1', async () => successResult())
|
|
434
|
+
const harness = await buildHarness(childAgent)
|
|
435
|
+
|
|
436
|
+
const mismatchedOptions: SendMessageOptions = {
|
|
437
|
+
...buildOptions('child-1', harness.parentSession.id, harness.projectId),
|
|
438
|
+
tenantId: otherTenant,
|
|
439
|
+
}
|
|
440
|
+
await expect(
|
|
441
|
+
harness.manager.sendMessage(
|
|
442
|
+
mismatchedOptions,
|
|
443
|
+
buildContext(harness.parentSession.id, harness.projectId, tenant),
|
|
444
|
+
),
|
|
445
|
+
).rejects.toThrow(/Tenant mismatch/)
|
|
446
|
+
})
|
|
447
|
+
})
|
|
448
|
+
|
|
449
|
+
// Phase 9 Known Delta #5: legacy compat mode removed — AgentManagerDeps is
|
|
450
|
+
// unconditional required. Prior `describe('AgentManager.sendMessage — legacy
|
|
451
|
+
// mode (no session deps)')` block deleted; every spawn now produces a
|
|
452
|
+
// SubSession + Session + WorkspaceRef triple (Convention #0).
|