@namzu/sdk 0.2.0 → 0.4.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 +74 -2
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +3 -2
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +5 -2
- 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/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 +4 -3
- 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/contracts/api.d.ts +6 -38
- 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 -5
- 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/index.d.ts +2 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/manager/agent/__tests__/lifecycle.test.js +27 -13
- package/dist/manager/agent/__tests__/lifecycle.test.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts +9 -0
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +93 -31
- 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 +3 -1
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +5 -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/registry/tool/execute.js +1 -1
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/runtime/query/__tests__/context.test.js +8 -7
- package/dist/runtime/query/__tests__/context.test.js.map +1 -1
- 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 +12 -21
- package/dist/runtime/query/context.d.ts.map +1 -1
- package/dist/runtime/query/context.js +3 -1
- package/dist/runtime/query/context.js.map +1 -1
- package/dist/runtime/query/index.d.ts +13 -15
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +2 -1
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +1 -1
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/session/__tests__/integration/_fixtures.d.ts +11 -4
- package/dist/session/__tests__/integration/_fixtures.d.ts.map +1 -1
- package/dist/session/__tests__/integration/_fixtures.js +23 -6
- package/dist/session/__tests__/integration/_fixtures.js.map +1 -1
- 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.js +13 -6
- package/dist/session/__tests__/integration/capacity-caps.test.js.map +1 -1
- package/dist/session/__tests__/integration/e2e-spawn.test.js +14 -2
- package/dist/session/__tests__/integration/e2e-spawn.test.js.map +1 -1
- package/dist/session/__tests__/integration/event-stream-ordering.test.js +14 -7
- package/dist/session/__tests__/integration/event-stream-ordering.test.js.map +1 -1
- package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.js +26 -14
- package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.js.map +1 -1
- package/dist/session/__tests__/integration/handoff-illegal-transition.test.js +30 -20
- package/dist/session/__tests__/integration/handoff-illegal-transition.test.js.map +1 -1
- package/dist/session/__tests__/integration/handoff-single-e2e.test.js +25 -9
- package/dist/session/__tests__/integration/handoff-single-e2e.test.js.map +1 -1
- package/dist/session/__tests__/integration/hierarchy-lifecycle.test.js +11 -10
- package/dist/session/__tests__/integration/hierarchy-lifecycle.test.js.map +1 -1
- package/dist/session/__tests__/integration/prev-artifact-dag.test.js +5 -4
- package/dist/session/__tests__/integration/prev-artifact-dag.test.js.map +1 -1
- package/dist/session/__tests__/integration/retention-archive.test.js +3 -2
- package/dist/session/__tests__/integration/retention-archive.test.js.map +1 -1
- 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.js +2 -1
- package/dist/session/__tests__/integration/summary-materialization-e2e.test.js.map +1 -1
- package/dist/session/__tests__/integration/tenant-isolation.test.js +14 -5
- package/dist/session/__tests__/integration/tenant-isolation.test.js.map +1 -1
- package/dist/session/errors.d.ts +79 -0
- package/dist/session/errors.d.ts.map +1 -1
- package/dist/session/errors.js +57 -0
- package/dist/session/errors.js.map +1 -1
- package/dist/session/handoff/__tests__/broadcast.test.js +49 -31
- package/dist/session/handoff/__tests__/broadcast.test.js.map +1 -1
- package/dist/session/handoff/__tests__/capacity.test.js +21 -18
- package/dist/session/handoff/__tests__/capacity.test.js.map +1 -1
- package/dist/session/handoff/__tests__/single.test.js +39 -30
- package/dist/session/handoff/__tests__/single.test.js.map +1 -1
- package/dist/session/handoff/assignment.d.ts +13 -1
- package/dist/session/handoff/assignment.d.ts.map +1 -1
- package/dist/session/handoff/broadcast.d.ts +7 -0
- package/dist/session/handoff/broadcast.d.ts.map +1 -1
- package/dist/session/handoff/broadcast.js +16 -1
- package/dist/session/handoff/broadcast.js.map +1 -1
- package/dist/session/handoff/single.d.ts +7 -0
- package/dist/session/handoff/single.d.ts.map +1 -1
- package/dist/session/handoff/single.js +13 -1
- package/dist/session/handoff/single.js.map +1 -1
- package/dist/session/hierarchy/__tests__/session.test.js +2 -0
- package/dist/session/hierarchy/__tests__/session.test.js.map +1 -1
- package/dist/session/hierarchy/index.d.ts +1 -0
- package/dist/session/hierarchy/index.d.ts.map +1 -1
- package/dist/session/hierarchy/index.js.map +1 -1
- package/dist/session/hierarchy/session.d.ts +15 -3
- package/dist/session/hierarchy/session.d.ts.map +1 -1
- package/dist/session/hierarchy/session.js.map +1 -1
- 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/migration/id-prefix.d.ts +8 -13
- package/dist/session/migration/id-prefix.d.ts.map +1 -1
- package/dist/session/migration/id-prefix.js +8 -13
- package/dist/session/migration/id-prefix.js.map +1 -1
- package/dist/session/retention/__tests__/archive.test.js +3 -2
- package/dist/session/retention/__tests__/archive.test.js.map +1 -1
- package/dist/session/summary/__tests__/materialize.test.js +4 -3
- package/dist/session/summary/__tests__/materialize.test.js.map +1 -1
- 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.js +32 -5
- package/dist/store/session/__tests__/disk.test.js.map +1 -1
- package/dist/store/session/__tests__/memory.test.js +50 -9
- package/dist/store/session/__tests__/memory.test.js.map +1 -1
- package/dist/store/session/disk.d.ts +2 -1
- package/dist/store/session/disk.d.ts.map +1 -1
- package/dist/store/session/disk.js +61 -0
- package/dist/store/session/disk.js.map +1 -1
- package/dist/store/session/index.d.ts.map +1 -1
- package/dist/store/session/index.js +3 -4
- package/dist/store/session/index.js.map +1 -1
- package/dist/store/session/memory.d.ts +2 -1
- package/dist/store/session/memory.d.ts.map +1 -1
- package/dist/store/session/memory.js +13 -0
- package/dist/store/session/memory.js.map +1 -1
- 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/telemetry/runtime-accessors.d.ts +4 -0
- package/dist/telemetry/runtime-accessors.d.ts.map +1 -0
- package/dist/telemetry/runtime-accessors.js +17 -0
- package/dist/telemetry/runtime-accessors.js.map +1 -0
- package/dist/types/agent/base.d.ts +17 -21
- 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 +18 -11
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/ids/index.d.ts +5 -9
- package/dist/types/ids/index.d.ts.map +1 -1
- package/dist/types/ids/index.js +4 -4
- package/dist/types/ids/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 +6 -5
- package/dist/types/run/config.d.ts.map +1 -1
- package/dist/types/run/metadata.d.ts +5 -18
- package/dist/types/run/metadata.d.ts.map +1 -1
- package/dist/types/session/ids.d.ts +4 -13
- package/dist/types/session/ids.d.ts.map +1 -1
- package/dist/types/session/ids.js +3 -6
- package/dist/types/session/ids.js.map +1 -1
- package/dist/types/session/index.d.ts +1 -1
- package/dist/types/session/index.d.ts.map +1 -1
- package/dist/types/session/store.d.ts +32 -10
- package/dist/types/session/store.d.ts.map +1 -1
- package/dist/types/session/store.js +3 -8
- package/dist/types/session/store.js.map +1 -1
- 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 +1 -12
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/id.js +3 -23
- package/dist/utils/id.js.map +1 -1
- package/package.json +11 -20
- package/src/agents/ReactiveAgent.ts +3 -2
- package/src/agents/SupervisorAgent.ts +5 -2
- package/src/bridge/a2a/index.ts +0 -1
- package/src/bridge/a2a/message.ts +0 -32
- package/src/bridge/a2a/task.ts +8 -7
- package/src/contracts/api.ts +6 -42
- package/src/contracts/ids.ts +1 -1
- package/src/contracts/index.ts +2 -8
- package/src/contracts/schemas.ts +1 -8
- package/src/index.ts +3 -15
- package/src/manager/agent/__tests__/lifecycle.test.ts +34 -13
- package/src/manager/agent/lifecycle.ts +114 -35
- package/src/manager/index.ts +3 -0
- package/src/manager/run/persistence.ts +7 -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/registry/tool/execute.ts +1 -1
- package/src/runtime/query/__tests__/context.test.ts +9 -8
- package/src/runtime/query/context-cache.ts +4 -4
- package/src/runtime/query/context.ts +15 -22
- package/src/runtime/query/index.ts +16 -17
- package/src/runtime/query/iteration/index.ts +1 -1
- package/src/session/__tests__/integration/_fixtures.ts +36 -8
- package/src/session/__tests__/integration/archive-gate.test.ts +288 -0
- package/src/session/__tests__/integration/capacity-caps.test.ts +13 -6
- package/src/session/__tests__/integration/e2e-spawn.test.ts +20 -2
- package/src/session/__tests__/integration/event-stream-ordering.test.ts +14 -7
- package/src/session/__tests__/integration/handoff-broadcast-e2e.test.ts +39 -13
- package/src/session/__tests__/integration/handoff-illegal-transition.test.ts +54 -19
- package/src/session/__tests__/integration/handoff-single-e2e.test.ts +40 -9
- package/src/session/__tests__/integration/hierarchy-lifecycle.test.ts +13 -10
- package/src/session/__tests__/integration/prev-artifact-dag.test.ts +12 -5
- package/src/session/__tests__/integration/retention-archive.test.ts +5 -3
- package/src/session/__tests__/integration/spawn-rollback.test.ts +313 -0
- package/src/session/__tests__/integration/summary-materialization-e2e.test.ts +4 -2
- package/src/session/__tests__/integration/tenant-isolation.test.ts +16 -6
- package/src/session/errors.ts +89 -0
- package/src/session/handoff/__tests__/broadcast.test.ts +56 -28
- package/src/session/handoff/__tests__/capacity.test.ts +26 -20
- package/src/session/handoff/__tests__/single.test.ts +45 -28
- package/src/session/handoff/assignment.ts +13 -1
- package/src/session/handoff/broadcast.ts +26 -1
- package/src/session/handoff/single.ts +23 -1
- package/src/session/hierarchy/__tests__/session.test.ts +9 -1
- package/src/session/hierarchy/index.ts +1 -0
- package/src/session/hierarchy/session.ts +15 -3
- package/src/session/hierarchy/thread.ts +55 -0
- package/src/session/migration/id-prefix.ts +8 -13
- package/src/session/retention/__tests__/archive.test.ts +5 -3
- package/src/session/summary/__tests__/materialize.test.ts +6 -4
- package/src/store/index.ts +0 -3
- package/src/store/session/__tests__/disk.test.ts +57 -6
- package/src/store/session/__tests__/memory.test.ts +84 -9
- package/src/store/session/disk.ts +57 -1
- package/src/store/session/index.ts +3 -4
- package/src/store/session/memory.ts +13 -1
- 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/telemetry/runtime-accessors.ts +19 -0
- package/src/types/agent/base.ts +17 -21
- package/src/types/agent/factory.ts +8 -3
- package/src/types/agent/task.ts +19 -11
- package/src/types/ids/index.ts +8 -15
- package/src/types/rag/retrieval.ts +4 -3
- package/src/types/run/config.ts +6 -5
- package/src/types/run/metadata.ts +5 -18
- package/src/types/session/ids.ts +4 -15
- package/src/types/session/index.ts +1 -2
- package/src/types/session/store.ts +34 -11
- package/src/types/thread/index.ts +5 -0
- package/src/types/thread/store.ts +92 -0
- package/src/utils/id.ts +3 -24
- package/dist/provider/telemetry/setup.d.ts +0 -19
- package/dist/provider/telemetry/setup.d.ts.map +0 -1
- package/dist/provider/telemetry/setup.js +0 -102
- package/dist/provider/telemetry/setup.js.map +0 -1
- package/dist/store/conversation/memory.d.ts +0 -43
- package/dist/store/conversation/memory.d.ts.map +0 -1
- package/dist/store/conversation/memory.js +0 -108
- package/dist/store/conversation/memory.js.map +0 -1
- package/dist/telemetry/index.d.ts +0 -6
- package/dist/telemetry/index.d.ts.map +0 -1
- package/dist/telemetry/index.js +0 -4
- package/dist/telemetry/index.js.map +0 -1
- package/dist/telemetry/metrics.d.ts +0 -8
- package/dist/telemetry/metrics.d.ts.map +0 -1
- package/dist/telemetry/metrics.js +0 -53
- package/dist/telemetry/metrics.js.map +0 -1
- package/dist/types/conversation/index.d.ts +0 -14
- 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/dist/types/telemetry/index.d.ts +0 -10
- package/dist/types/telemetry/index.d.ts.map +0 -1
- package/dist/types/telemetry/index.js +0 -2
- package/dist/types/telemetry/index.js.map +0 -1
- package/src/provider/telemetry/setup.ts +0 -125
- package/src/store/conversation/memory.ts +0 -144
- package/src/telemetry/index.ts +0 -14
- package/src/telemetry/metrics.ts +0 -69
- package/src/types/conversation/index.ts +0 -15
- package/src/types/telemetry/index.ts +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@namzu/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Open-source AI agent SDK with a built-in runtime. Nothing between you and your agents.",
|
|
5
5
|
"license": "FSL-1.1-MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
@@ -34,23 +34,20 @@
|
|
|
34
34
|
"access": "public",
|
|
35
35
|
"provenance": true
|
|
36
36
|
},
|
|
37
|
-
"
|
|
37
|
+
"peerDependencies": {
|
|
38
38
|
"@opentelemetry/api": "^1.9.0",
|
|
39
|
-
"@opentelemetry/exporter-metrics-otlp-http": "^0.57.0",
|
|
40
|
-
"@opentelemetry/exporter-trace-otlp-http": "^0.57.0",
|
|
41
|
-
"@opentelemetry/resources": "^1.30.0",
|
|
42
|
-
"@opentelemetry/sdk-metrics": "^1.30.0",
|
|
43
|
-
"@opentelemetry/sdk-node": "^0.57.0",
|
|
44
|
-
"@opentelemetry/sdk-trace-node": "^1.30.0",
|
|
45
|
-
"@opentelemetry/semantic-conventions": "^1.30.0",
|
|
46
39
|
"zod": "^3.23.0",
|
|
47
40
|
"zod-to-json-schema": "^3.23.0"
|
|
48
41
|
},
|
|
49
42
|
"devDependencies": {
|
|
50
43
|
"@biomejs/biome": "^1.9.4",
|
|
44
|
+
"@opentelemetry/api": "^1.9.0",
|
|
51
45
|
"@types/node": "^22.19.17",
|
|
46
|
+
"knip": "^6.4.1",
|
|
52
47
|
"typescript": "^5.5.0",
|
|
53
|
-
"vitest": "^2.0.0"
|
|
48
|
+
"vitest": "^2.0.0",
|
|
49
|
+
"zod": "^3.23.0",
|
|
50
|
+
"zod-to-json-schema": "^3.23.0"
|
|
54
51
|
},
|
|
55
52
|
"scripts": {
|
|
56
53
|
"build": "tsc --build",
|
|
@@ -60,13 +57,7 @@
|
|
|
60
57
|
"format": "biome format --write src/",
|
|
61
58
|
"test": "vitest run --passWithNoTests",
|
|
62
59
|
"typecheck": "tsc --noEmit",
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"release:minor": "bash scripts/release.sh minor",
|
|
66
|
-
"release:major": "bash scripts/release.sh major",
|
|
67
|
-
"release:rc": "bash scripts/release.sh rc",
|
|
68
|
-
"release:beta": "bash scripts/release.sh beta",
|
|
69
|
-
"release:stable": "bash scripts/release.sh stable",
|
|
70
|
-
"release:dry": "bash scripts/release.sh patch --dry-run"
|
|
60
|
+
"knip": "knip",
|
|
61
|
+
"knip:production": "knip --production"
|
|
71
62
|
}
|
|
72
63
|
}
|
|
@@ -32,9 +32,9 @@ export class ReactiveAgent extends AbstractAgent<ReactiveAgentConfig, ReactiveAg
|
|
|
32
32
|
): Promise<ReactiveAgentResult> {
|
|
33
33
|
const startTime = Date.now()
|
|
34
34
|
|
|
35
|
-
if (!config.sessionId || !config.projectId || !config.tenantId) {
|
|
35
|
+
if (!config.sessionId || !config.threadId || !config.projectId || !config.tenantId) {
|
|
36
36
|
throw new Error(
|
|
37
|
-
'ReactiveAgent requires sessionId, projectId, and tenantId in config (session-hierarchy.md §12.1).',
|
|
37
|
+
'ReactiveAgent requires sessionId, threadId, projectId, and tenantId in config (session-hierarchy.md §12.1).',
|
|
38
38
|
)
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -61,6 +61,7 @@ export class ReactiveAgent extends AbstractAgent<ReactiveAgentConfig, ReactiveAg
|
|
|
61
61
|
agentName: this.metadata.name,
|
|
62
62
|
workingDirectory: input.workingDirectory,
|
|
63
63
|
sessionId: config.sessionId,
|
|
64
|
+
threadId: config.threadId,
|
|
64
65
|
projectId: config.projectId,
|
|
65
66
|
tenantId: config.tenantId,
|
|
66
67
|
parentRunId: config.parentRunId,
|
|
@@ -43,12 +43,13 @@ export class SupervisorAgent extends AbstractAgent<SupervisorAgentConfig, Superv
|
|
|
43
43
|
const startTime = Date.now()
|
|
44
44
|
const runId = this.createRunId()
|
|
45
45
|
|
|
46
|
-
if (!config.sessionId || !config.projectId || !config.tenantId) {
|
|
46
|
+
if (!config.sessionId || !config.threadId || !config.projectId || !config.tenantId) {
|
|
47
47
|
throw new Error(
|
|
48
|
-
'SupervisorAgent requires sessionId, projectId, and tenantId in config (session-hierarchy.md §12.1).',
|
|
48
|
+
'SupervisorAgent requires sessionId, threadId, projectId, and tenantId in config (session-hierarchy.md §12.1).',
|
|
49
49
|
)
|
|
50
50
|
}
|
|
51
51
|
const sessionId = config.sessionId
|
|
52
|
+
const threadId = config.threadId
|
|
52
53
|
const projectId = config.projectId
|
|
53
54
|
const tenantId = config.tenantId
|
|
54
55
|
|
|
@@ -84,6 +85,7 @@ export class SupervisorAgent extends AbstractAgent<SupervisorAgentConfig, Superv
|
|
|
84
85
|
},
|
|
85
86
|
factoryOptions: mergedFactoryOptions,
|
|
86
87
|
tenantId,
|
|
88
|
+
threadId,
|
|
87
89
|
sessionId,
|
|
88
90
|
projectId,
|
|
89
91
|
parentActor,
|
|
@@ -138,6 +140,7 @@ export class SupervisorAgent extends AbstractAgent<SupervisorAgentConfig, Superv
|
|
|
138
140
|
messages: input.messages,
|
|
139
141
|
signal: input.signal,
|
|
140
142
|
sessionId,
|
|
143
|
+
threadId,
|
|
141
144
|
projectId,
|
|
142
145
|
tenantId,
|
|
143
146
|
runId,
|
package/src/bridge/a2a/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ThreadMessage } from '../../contracts/index.js'
|
|
2
1
|
import type { A2AMessage, A2AMessageRole, A2APart, TextPart } from '../../types/a2a/index.js'
|
|
3
2
|
import type { Message, MessageRole } from '../../types/message/index.js'
|
|
4
3
|
|
|
@@ -48,37 +47,6 @@ export function messageToA2A(msg: Message): A2AMessage {
|
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
export function threadMessageToA2A(msg: ThreadMessage): A2AMessage {
|
|
52
|
-
const parts: A2APart[] = []
|
|
53
|
-
|
|
54
|
-
if (msg.content) {
|
|
55
|
-
parts.push({ kind: 'text', text: msg.content })
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (msg.tool_calls) {
|
|
59
|
-
for (const tc of msg.tool_calls) {
|
|
60
|
-
parts.push({
|
|
61
|
-
kind: 'data',
|
|
62
|
-
data: {
|
|
63
|
-
toolCallId: tc.id,
|
|
64
|
-
name: tc.function.name,
|
|
65
|
-
arguments: tc.function.arguments,
|
|
66
|
-
},
|
|
67
|
-
mimeType: 'application/x-namzu-tool-call',
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (parts.length === 0) {
|
|
73
|
-
parts.push({ kind: 'text', text: '' })
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
role: toA2ARole(msg.role),
|
|
78
|
-
parts,
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
50
|
export function extractTextFromA2AMessage(msg: A2AMessage): string {
|
|
83
51
|
return msg.parts
|
|
84
52
|
.filter((p): p is TextPart => p.kind === 'text')
|
package/src/bridge/a2a/task.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RUN_STATUS_TO_A2A, TERMINAL_STATES } from '../../constants/a2a/index.js'
|
|
2
|
-
import type { Run, RunConfig,
|
|
2
|
+
import type { Run, RunConfig, WireRunStatus } from '../../contracts/index.js'
|
|
3
3
|
import type {
|
|
4
4
|
A2AArtifact,
|
|
5
5
|
A2AMessage,
|
|
@@ -8,7 +8,8 @@ import type {
|
|
|
8
8
|
A2ATaskState,
|
|
9
9
|
A2ATaskStatus,
|
|
10
10
|
} from '../../types/a2a/index.js'
|
|
11
|
-
import {
|
|
11
|
+
import type { Message } from '../../types/message/index.js'
|
|
12
|
+
import { extractTextFromA2AMessage, messageToA2A } from './message.js'
|
|
12
13
|
|
|
13
14
|
export function isTerminalState(state: A2ATaskState): boolean {
|
|
14
15
|
return TERMINAL_STATES.has(state)
|
|
@@ -53,12 +54,12 @@ function buildArtifacts(run: Run): A2AArtifact[] | undefined {
|
|
|
53
54
|
]
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
export function runToA2ATask(run: Run, messages?: readonly
|
|
57
|
+
export function runToA2ATask(run: Run, messages?: readonly Message[]): A2ATask {
|
|
57
58
|
return {
|
|
58
59
|
id: run.id,
|
|
59
|
-
contextId: run.
|
|
60
|
+
contextId: run.project_id ?? undefined,
|
|
60
61
|
status: buildTaskStatus(run),
|
|
61
|
-
history: messages?.map(
|
|
62
|
+
history: messages?.map(messageToA2A),
|
|
62
63
|
artifacts: buildArtifacts(run),
|
|
63
64
|
metadata: {
|
|
64
65
|
agent_id: run.agent_id,
|
|
@@ -71,7 +72,7 @@ export function runToA2ATask(run: Run, messages?: readonly ThreadMessage[]): A2A
|
|
|
71
72
|
export interface CreateRunFromA2A {
|
|
72
73
|
readonly agentId: string
|
|
73
74
|
readonly input: string
|
|
74
|
-
readonly
|
|
75
|
+
readonly projectId?: string
|
|
75
76
|
readonly config: RunConfig
|
|
76
77
|
}
|
|
77
78
|
|
|
@@ -99,7 +100,7 @@ export function a2aMessageToCreateRun(
|
|
|
99
100
|
return {
|
|
100
101
|
agentId,
|
|
101
102
|
input,
|
|
102
|
-
|
|
103
|
+
projectId: params.contextId,
|
|
103
104
|
config,
|
|
104
105
|
}
|
|
105
106
|
}
|
package/src/contracts/api.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentCapabilities, AgentType } from '../types/agent/base.js'
|
|
2
2
|
import type { MessageRole } from '../types/message/index.js'
|
|
3
3
|
import type { StopReason } from '../types/run/events.js'
|
|
4
|
-
import type {
|
|
4
|
+
import type { ProjectId, RunId, SessionId } from './ids.js'
|
|
5
5
|
|
|
6
6
|
export type { MessageRole, StopReason, AgentType, AgentCapabilities }
|
|
7
7
|
|
|
@@ -27,14 +27,6 @@ export interface AgentInfo {
|
|
|
27
27
|
capabilities?: AgentCapabilities
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export interface Thread {
|
|
31
|
-
id: ThreadId
|
|
32
|
-
created_at: ISOTimestamp
|
|
33
|
-
updated_at: ISOTimestamp
|
|
34
|
-
metadata: Record<string, string>
|
|
35
|
-
message_count: number
|
|
36
|
-
}
|
|
37
|
-
|
|
38
30
|
export interface ToolCallInfo {
|
|
39
31
|
id: string
|
|
40
32
|
type: 'function'
|
|
@@ -44,23 +36,6 @@ export interface ToolCallInfo {
|
|
|
44
36
|
}
|
|
45
37
|
}
|
|
46
38
|
|
|
47
|
-
export interface ThreadMessage {
|
|
48
|
-
id: MessageId
|
|
49
|
-
thread_id: ThreadId
|
|
50
|
-
role: MessageRole
|
|
51
|
-
content: string | null
|
|
52
|
-
created_at: ISOTimestamp
|
|
53
|
-
run_id?: RunId
|
|
54
|
-
tool_call_id?: string
|
|
55
|
-
tool_calls?: ToolCallInfo[]
|
|
56
|
-
metadata?: Record<string, unknown>
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface CreateThreadRequest {
|
|
60
|
-
metadata?: Record<string, string>
|
|
61
|
-
messages?: CreateMessageRequest[]
|
|
62
|
-
}
|
|
63
|
-
|
|
64
39
|
export interface CreateMessageRequest {
|
|
65
40
|
role: 'user'
|
|
66
41
|
content: string
|
|
@@ -71,14 +46,10 @@ export interface CreateMessageRequest {
|
|
|
71
46
|
* Wire-side run status for HTTP / A2A / SSE payloads.
|
|
72
47
|
*
|
|
73
48
|
* Distinct from the domain {@link import('../types/run/status.js').RunStatus}
|
|
74
|
-
* which models the kernel state machine
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* `
|
|
78
|
-
*
|
|
79
|
-
* Renamed from `RunStatus` to `WireRunStatus` in 0.2.0 to disambiguate from
|
|
80
|
-
* the domain enum; a deprecated alias `RunStatus = WireRunStatus` is retained
|
|
81
|
-
* at the bottom of this module for one migration window.
|
|
49
|
+
* which models the kernel state machine. The wire enum collapses domain
|
|
50
|
+
* variants onto the HTTP-facing shape (e.g. domain `succeeded` → wire
|
|
51
|
+
* `completed`; domain `awaiting_hitl*` → wire `running`; domain
|
|
52
|
+
* `awaiting_subsession` → wire `running`).
|
|
82
53
|
*/
|
|
83
54
|
export type WireRunStatus =
|
|
84
55
|
| 'queued'
|
|
@@ -96,7 +67,7 @@ export type RunStopReason = StopReason
|
|
|
96
67
|
|
|
97
68
|
export interface Run {
|
|
98
69
|
id: RunId
|
|
99
|
-
|
|
70
|
+
project_id: ProjectId | null
|
|
100
71
|
session_id?: SessionId
|
|
101
72
|
agent_id: string
|
|
102
73
|
agent_name?: string
|
|
@@ -234,10 +205,3 @@ export interface ApiError {
|
|
|
234
205
|
param?: string
|
|
235
206
|
}
|
|
236
207
|
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* @deprecated Use {@link WireRunStatus}. Alias retained for one migration
|
|
240
|
-
* window (0.2.x); scheduled for removal in 0.3.0. Renamed to disambiguate
|
|
241
|
-
* from the domain `RunStatus` in `../types/run/status.js`.
|
|
242
|
-
*/
|
|
243
|
-
export type RunStatus = WireRunStatus
|
package/src/contracts/ids.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { ProjectId, RunId, MessageId, SessionId } from '../types/ids/index.js'
|
package/src/contracts/index.ts
CHANGED
|
@@ -10,14 +10,9 @@ export type {
|
|
|
10
10
|
ISOTimestamp,
|
|
11
11
|
AgentDefaults,
|
|
12
12
|
AgentInfo,
|
|
13
|
-
Thread,
|
|
14
13
|
ToolCallInfo,
|
|
15
|
-
ThreadMessage,
|
|
16
|
-
CreateThreadRequest,
|
|
17
14
|
CreateMessageRequest,
|
|
18
15
|
WireRunStatus,
|
|
19
|
-
/** @deprecated Use {@link WireRunStatus}. */
|
|
20
|
-
RunStatus,
|
|
21
16
|
RunStopReason,
|
|
22
17
|
Run,
|
|
23
18
|
RunHierarchyNode,
|
|
@@ -34,15 +29,14 @@ export type {
|
|
|
34
29
|
ApiError,
|
|
35
30
|
} from './api.js'
|
|
36
31
|
|
|
37
|
-
export type {
|
|
32
|
+
export type { ProjectId, RunId, MessageId, SessionId } from './ids.js'
|
|
38
33
|
|
|
39
34
|
export {
|
|
40
|
-
|
|
35
|
+
ProjectIdSchema,
|
|
41
36
|
RunIdSchema,
|
|
42
37
|
MessageIdSchema,
|
|
43
38
|
RunConfigSchema,
|
|
44
39
|
CreateMessageSchema,
|
|
45
|
-
CreateThreadSchema,
|
|
46
40
|
CreateRunSchema,
|
|
47
41
|
CreateStatelessRunSchema,
|
|
48
42
|
PaginationSchema,
|
package/src/contracts/schemas.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const ProjectIdSchema = z.string().regex(/^prj_[a-z0-9]+$/, 'Invalid project ID format')
|
|
4
4
|
export const RunIdSchema = z.string().regex(/^run_[a-z0-9]+$/, 'Invalid run ID format')
|
|
5
5
|
export const MessageIdSchema = z.string().regex(/^msg_[a-z0-9]+$/, 'Invalid message ID format')
|
|
6
6
|
|
|
@@ -24,13 +24,6 @@ export const CreateMessageSchema = z
|
|
|
24
24
|
})
|
|
25
25
|
.strict()
|
|
26
26
|
|
|
27
|
-
export const CreateThreadSchema = z
|
|
28
|
-
.object({
|
|
29
|
-
metadata: z.record(z.string()).optional(),
|
|
30
|
-
messages: z.array(CreateMessageSchema).optional(),
|
|
31
|
-
})
|
|
32
|
-
.strict()
|
|
33
|
-
|
|
34
27
|
export const CreateRunSchema = z
|
|
35
28
|
.object({
|
|
36
29
|
agent_id: z.string().min(1, 'agent_id is required'),
|
package/src/index.ts
CHANGED
|
@@ -37,12 +37,10 @@ export * from './types/task/index.js'
|
|
|
37
37
|
export * from './types/plan/index.js'
|
|
38
38
|
export * from './types/hitl/index.js'
|
|
39
39
|
export * from './types/rag/index.js'
|
|
40
|
-
export * from './types/telemetry/index.js'
|
|
41
40
|
export * from './types/execution/index.js'
|
|
42
41
|
export * from './types/connector/index.js'
|
|
43
42
|
export * from './types/skills/index.js'
|
|
44
43
|
export * from './types/a2a/index.js'
|
|
45
|
-
export * from './types/conversation/index.js'
|
|
46
44
|
export * from './types/router/index.js'
|
|
47
45
|
export * from './types/advisory/index.js'
|
|
48
46
|
export * from './types/memory/index.js'
|
|
@@ -140,8 +138,6 @@ export {
|
|
|
140
138
|
InMemoryTaskStore,
|
|
141
139
|
DiskTaskStore,
|
|
142
140
|
type DiskTaskStoreConfig,
|
|
143
|
-
InMemoryConversationStore,
|
|
144
|
-
type InMemoryConversationStoreConfig,
|
|
145
141
|
InMemoryMemoryIndex,
|
|
146
142
|
InMemoryMemoryStore,
|
|
147
143
|
DiskMemoryStore,
|
|
@@ -300,7 +296,6 @@ export {
|
|
|
300
296
|
runStatusToA2AState,
|
|
301
297
|
a2aMessageToCreateRun,
|
|
302
298
|
messageToA2A,
|
|
303
|
-
threadMessageToA2A,
|
|
304
299
|
extractTextFromA2AMessage,
|
|
305
300
|
a2aMessageToInput,
|
|
306
301
|
mapRunToA2AEvent,
|
|
@@ -330,16 +325,9 @@ export type { CoordinatorToolsOptions, TaskLaunchedCallback } from './tools/coor
|
|
|
330
325
|
|
|
331
326
|
export { InMemoryCredentialVault } from './vault/index.js'
|
|
332
327
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
getTelemetry,
|
|
337
|
-
getTracer,
|
|
338
|
-
getMeter,
|
|
339
|
-
createPlatformMetrics,
|
|
340
|
-
} from './telemetry/index.js'
|
|
341
|
-
export type { PlatformMetrics } from './telemetry/index.js'
|
|
342
|
-
export * from './telemetry/attributes.js'
|
|
328
|
+
// Telemetry runtime surface moved to `@namzu/telemetry` in 0.4.0.
|
|
329
|
+
// See docs/migration/0.4.md. Consumers import from `@namzu/telemetry`
|
|
330
|
+
// and `@namzu/telemetry/attributes` instead of the SDK barrel.
|
|
343
331
|
|
|
344
332
|
// Session hierarchy runtime primitives (Phase 9 — public API freeze for 0.2.0).
|
|
345
333
|
// Convention #4: root barrel imports sub-barrels only, never concrete files.
|
|
@@ -10,6 +10,7 @@ import type { DeliverableRef } from '../../../session/summary/deliverable.js'
|
|
|
10
10
|
import { SessionSummaryMaterializer } from '../../../session/summary/materialize.js'
|
|
11
11
|
import { WorkspaceBackendRegistry } from '../../../session/workspace/registry.js'
|
|
12
12
|
import { InMemorySessionStore } from '../../../store/session/memory.js'
|
|
13
|
+
import { InMemoryThreadStore } from '../../../store/thread/memory.js'
|
|
13
14
|
import type {
|
|
14
15
|
AgentCapabilities,
|
|
15
16
|
AgentInput,
|
|
@@ -23,8 +24,9 @@ import type { AgentTaskContext, SendMessageOptions } from '../../../types/agent/
|
|
|
23
24
|
import type { AgentId, SessionId, TenantId, UserId } from '../../../types/ids/index.js'
|
|
24
25
|
import { createAssistantMessage } from '../../../types/message/index.js'
|
|
25
26
|
import type { RunEvent } from '../../../types/run/events.js'
|
|
26
|
-
import type { SummaryId } from '../../../types/session/ids.js'
|
|
27
|
+
import type { SummaryId, ThreadId } from '../../../types/session/ids.js'
|
|
27
28
|
import { ZERO_COST } from '../../../utils/cost.js'
|
|
29
|
+
import { ThreadManager } from '../../thread/lifecycle.js'
|
|
28
30
|
import { AgentManager } from '../lifecycle.js'
|
|
29
31
|
|
|
30
32
|
const tenant = 'tnt_alpha' as TenantId
|
|
@@ -113,10 +115,13 @@ function agentActor(id: string, tid: TenantId = tenant): ActorRef {
|
|
|
113
115
|
|
|
114
116
|
interface Harness {
|
|
115
117
|
store: InMemorySessionStore
|
|
118
|
+
threadStore: InMemoryThreadStore
|
|
119
|
+
threadManager: ThreadManager
|
|
116
120
|
materializer: SessionSummaryMaterializer
|
|
117
121
|
manager: AgentManager
|
|
118
122
|
parentSession: Awaited<ReturnType<InMemorySessionStore['createSession']>>
|
|
119
123
|
projectId: import('../../../types/session/ids.js').ProjectId
|
|
124
|
+
threadId: ThreadId
|
|
120
125
|
registry: AgentRegistry
|
|
121
126
|
}
|
|
122
127
|
|
|
@@ -125,9 +130,15 @@ async function buildHarness(
|
|
|
125
130
|
tenantId: TenantId = tenant,
|
|
126
131
|
): Promise<Harness> {
|
|
127
132
|
const store = new InMemorySessionStore()
|
|
133
|
+
const threadStore = new InMemoryThreadStore()
|
|
134
|
+
const threadManager = new ThreadManager({ threadStore, sessionStore: store })
|
|
128
135
|
const project = await store.createProject({ tenantId, name: 'p1' }, tenantId)
|
|
136
|
+
const thread = await threadStore.createThread(
|
|
137
|
+
{ projectId: project.id, title: 'lifecycle-test' },
|
|
138
|
+
tenantId,
|
|
139
|
+
)
|
|
129
140
|
const parentSession = await store.createSession(
|
|
130
|
-
{ projectId: project.id, currentActor: user(tenantId) },
|
|
141
|
+
{ threadId: thread.id, projectId: project.id, currentActor: user(tenantId) },
|
|
131
142
|
tenantId,
|
|
132
143
|
)
|
|
133
144
|
// Parent runs kick the session into 'active' so the materializer can
|
|
@@ -148,14 +159,18 @@ async function buildHarness(
|
|
|
148
159
|
summaryMaterializer: materializer,
|
|
149
160
|
workspaceRegistry: new WorkspaceBackendRegistry(),
|
|
150
161
|
capacity: new DefaultCapacityValidator(store),
|
|
162
|
+
threadManager,
|
|
151
163
|
})
|
|
152
164
|
|
|
153
165
|
return {
|
|
154
166
|
store,
|
|
167
|
+
threadStore,
|
|
168
|
+
threadManager,
|
|
155
169
|
materializer,
|
|
156
170
|
manager,
|
|
157
171
|
parentSession: { ...parentSession, status: 'active' },
|
|
158
172
|
projectId: project.id,
|
|
173
|
+
threadId: thread.id,
|
|
159
174
|
registry,
|
|
160
175
|
}
|
|
161
176
|
}
|
|
@@ -163,6 +178,7 @@ async function buildHarness(
|
|
|
163
178
|
function buildContext(
|
|
164
179
|
parentSessionId: SessionId,
|
|
165
180
|
projectId: import('../../../types/session/ids.js').ProjectId,
|
|
181
|
+
threadId: ThreadId,
|
|
166
182
|
tenantId: TenantId = tenant,
|
|
167
183
|
depth = 0,
|
|
168
184
|
): AgentTaskContext {
|
|
@@ -173,6 +189,7 @@ function buildContext(
|
|
|
173
189
|
depth,
|
|
174
190
|
budgetTracker: { total: 100_000, remaining: 100_000 },
|
|
175
191
|
tenantId,
|
|
192
|
+
threadId,
|
|
176
193
|
sessionId: parentSessionId,
|
|
177
194
|
projectId,
|
|
178
195
|
parentActor: user(tenantId),
|
|
@@ -214,7 +231,7 @@ describe('AgentManager.sendMessage — Phase 6 SubSession spawn', () => {
|
|
|
214
231
|
|
|
215
232
|
const task = await harness.manager.sendMessage(
|
|
216
233
|
buildOptions('child-1', harness.parentSession.id, harness.projectId),
|
|
217
|
-
buildContext(harness.parentSession.id, harness.projectId),
|
|
234
|
+
buildContext(harness.parentSession.id, harness.projectId, harness.threadId),
|
|
218
235
|
listener,
|
|
219
236
|
)
|
|
220
237
|
await waitForTask(harness.manager, task.taskId)
|
|
@@ -259,7 +276,11 @@ describe('AgentManager.sendMessage — Phase 6 SubSession spawn', () => {
|
|
|
259
276
|
// Pre-fill 8 direct sub-sessions under the parent, up to the default width cap.
|
|
260
277
|
for (let i = 0; i < 8; i++) {
|
|
261
278
|
const sibling = await harness.store.createSession(
|
|
262
|
-
{
|
|
279
|
+
{
|
|
280
|
+
threadId: harness.threadId,
|
|
281
|
+
projectId: harness.projectId,
|
|
282
|
+
currentActor: agentActor('sibling'),
|
|
283
|
+
},
|
|
263
284
|
tenant,
|
|
264
285
|
)
|
|
265
286
|
await harness.store.createSubSession(
|
|
@@ -276,7 +297,7 @@ describe('AgentManager.sendMessage — Phase 6 SubSession spawn', () => {
|
|
|
276
297
|
await expect(
|
|
277
298
|
harness.manager.sendMessage(
|
|
278
299
|
buildOptions('child-1', harness.parentSession.id, harness.projectId),
|
|
279
|
-
buildContext(harness.parentSession.id, harness.projectId),
|
|
300
|
+
buildContext(harness.parentSession.id, harness.projectId, harness.threadId),
|
|
280
301
|
),
|
|
281
302
|
).rejects.toBeInstanceOf(DelegationCapacityExceeded)
|
|
282
303
|
})
|
|
@@ -290,7 +311,7 @@ describe('AgentManager.sendMessage — Phase 6 SubSession spawn', () => {
|
|
|
290
311
|
let parentId: SessionId = harness.parentSession.id
|
|
291
312
|
for (let i = 0; i < 4; i++) {
|
|
292
313
|
const child = await harness.store.createSession(
|
|
293
|
-
{ projectId: harness.projectId, currentActor: agentActor('c') },
|
|
314
|
+
{ threadId: harness.threadId, projectId: harness.projectId, currentActor: agentActor('c') },
|
|
294
315
|
tenant,
|
|
295
316
|
)
|
|
296
317
|
await harness.store.createSubSession(
|
|
@@ -308,7 +329,7 @@ describe('AgentManager.sendMessage — Phase 6 SubSession spawn', () => {
|
|
|
308
329
|
await expect(
|
|
309
330
|
harness.manager.sendMessage(
|
|
310
331
|
buildOptions('child-1', parentId, harness.projectId),
|
|
311
|
-
buildContext(parentId, harness.projectId, tenant, 0),
|
|
332
|
+
buildContext(parentId, harness.projectId, harness.threadId, tenant, 0),
|
|
312
333
|
),
|
|
313
334
|
).rejects.toBeInstanceOf(DelegationCapacityExceeded)
|
|
314
335
|
})
|
|
@@ -319,7 +340,7 @@ describe('AgentManager.sendMessage — Phase 6 SubSession spawn', () => {
|
|
|
319
340
|
|
|
320
341
|
const task = await harness.manager.sendMessage(
|
|
321
342
|
buildOptions('child-fail', harness.parentSession.id, harness.projectId),
|
|
322
|
-
buildContext(harness.parentSession.id, harness.projectId),
|
|
343
|
+
buildContext(harness.parentSession.id, harness.projectId, harness.threadId),
|
|
323
344
|
)
|
|
324
345
|
await waitForTask(harness.manager, task.taskId)
|
|
325
346
|
|
|
@@ -342,7 +363,7 @@ describe('AgentManager.sendMessage — Phase 6 SubSession spawn', () => {
|
|
|
342
363
|
|
|
343
364
|
const task = await harness.manager.sendMessage(
|
|
344
365
|
buildOptions('child-msgs', harness.parentSession.id, harness.projectId),
|
|
345
|
-
buildContext(harness.parentSession.id, harness.projectId),
|
|
366
|
+
buildContext(harness.parentSession.id, harness.projectId, harness.threadId),
|
|
346
367
|
)
|
|
347
368
|
await waitForTask(harness.manager, task.taskId)
|
|
348
369
|
|
|
@@ -364,7 +385,7 @@ describe('AgentManager.sendMessage — Phase 6 SubSession spawn', () => {
|
|
|
364
385
|
|
|
365
386
|
// Seed c1 under parentSession, c2 under c1.
|
|
366
387
|
const c1 = await harness.store.createSession(
|
|
367
|
-
{ projectId: harness.projectId, currentActor: agentActor('c1') },
|
|
388
|
+
{ threadId: harness.threadId, projectId: harness.projectId, currentActor: agentActor('c1') },
|
|
368
389
|
tenant,
|
|
369
390
|
)
|
|
370
391
|
await harness.store.createSubSession(
|
|
@@ -377,7 +398,7 @@ describe('AgentManager.sendMessage — Phase 6 SubSession spawn', () => {
|
|
|
377
398
|
tenant,
|
|
378
399
|
)
|
|
379
400
|
const c2 = await harness.store.createSession(
|
|
380
|
-
{ projectId: harness.projectId, currentActor: agentActor('c2') },
|
|
401
|
+
{ threadId: harness.threadId, projectId: harness.projectId, currentActor: agentActor('c2') },
|
|
381
402
|
tenant,
|
|
382
403
|
)
|
|
383
404
|
await harness.store.createSubSession(
|
|
@@ -393,7 +414,7 @@ describe('AgentManager.sendMessage — Phase 6 SubSession spawn', () => {
|
|
|
393
414
|
const events: RunEvent[] = []
|
|
394
415
|
const task = await harness.manager.sendMessage(
|
|
395
416
|
buildOptions('grandchild', c2.id, harness.projectId),
|
|
396
|
-
buildContext(c2.id, harness.projectId),
|
|
417
|
+
buildContext(c2.id, harness.projectId, harness.threadId),
|
|
397
418
|
(e) => {
|
|
398
419
|
events.push(e)
|
|
399
420
|
},
|
|
@@ -440,7 +461,7 @@ describe('AgentManager.sendMessage — Phase 6 SubSession spawn', () => {
|
|
|
440
461
|
await expect(
|
|
441
462
|
harness.manager.sendMessage(
|
|
442
463
|
mismatchedOptions,
|
|
443
|
-
buildContext(harness.parentSession.id, harness.projectId, tenant),
|
|
464
|
+
buildContext(harness.parentSession.id, harness.projectId, harness.threadId, tenant),
|
|
444
465
|
),
|
|
445
466
|
).rejects.toThrow(/Tenant mismatch/)
|
|
446
467
|
})
|