@namzu/sdk 8.0.0 → 10.0.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.
Files changed (104) hide show
  1. package/CHANGELOG.md +244 -0
  2. package/dist/agents/SupervisorAgent.d.ts.map +1 -1
  3. package/dist/agents/SupervisorAgent.js +14 -6
  4. package/dist/agents/SupervisorAgent.js.map +1 -1
  5. package/dist/agents/__tests__/a-policy-nobody-can-select.test.d.ts +2 -0
  6. package/dist/agents/__tests__/a-policy-nobody-can-select.test.d.ts.map +1 -0
  7. package/dist/agents/__tests__/a-policy-nobody-can-select.test.js +177 -0
  8. package/dist/agents/__tests__/a-policy-nobody-can-select.test.js.map +1 -0
  9. package/dist/gateway/__tests__/a-knob-nobody-can-turn.test.d.ts +2 -0
  10. package/dist/gateway/__tests__/a-knob-nobody-can-turn.test.d.ts.map +1 -0
  11. package/dist/gateway/__tests__/a-knob-nobody-can-turn.test.js +114 -0
  12. package/dist/gateway/__tests__/a-knob-nobody-can-turn.test.js.map +1 -0
  13. package/dist/gateway/local.d.ts.map +1 -1
  14. package/dist/gateway/local.js +19 -6
  15. package/dist/gateway/local.js.map +1 -1
  16. package/dist/manager/agent/__tests__/lifecycle.test.js +56 -0
  17. package/dist/manager/agent/__tests__/lifecycle.test.js.map +1 -1
  18. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  19. package/dist/manager/agent/lifecycle.js +62 -33
  20. package/dist/manager/agent/lifecycle.js.map +1 -1
  21. package/dist/manager/plan/__tests__/a-plan-that-succeeded-is-not-failed.test.d.ts +2 -0
  22. package/dist/manager/plan/__tests__/a-plan-that-succeeded-is-not-failed.test.d.ts.map +1 -0
  23. package/dist/manager/plan/__tests__/a-plan-that-succeeded-is-not-failed.test.js +73 -0
  24. package/dist/manager/plan/__tests__/a-plan-that-succeeded-is-not-failed.test.js.map +1 -0
  25. package/dist/manager/plan/lifecycle.d.ts +48 -0
  26. package/dist/manager/plan/lifecycle.d.ts.map +1 -1
  27. package/dist/manager/plan/lifecycle.js +56 -0
  28. package/dist/manager/plan/lifecycle.js.map +1 -1
  29. package/dist/runtime/query/__tests__/the-plan-graph-reaches-a-host.test.d.ts +2 -0
  30. package/dist/runtime/query/__tests__/the-plan-graph-reaches-a-host.test.d.ts.map +1 -0
  31. package/dist/runtime/query/__tests__/the-plan-graph-reaches-a-host.test.js +62 -0
  32. package/dist/runtime/query/__tests__/the-plan-graph-reaches-a-host.test.js.map +1 -0
  33. package/dist/runtime/query/events.d.ts.map +1 -1
  34. package/dist/runtime/query/events.js +5 -0
  35. package/dist/runtime/query/events.js.map +1 -1
  36. package/dist/runtime/query/index.d.ts +0 -1
  37. package/dist/runtime/query/index.d.ts.map +1 -1
  38. package/dist/runtime/query/index.js +0 -1
  39. package/dist/runtime/query/index.js.map +1 -1
  40. package/dist/runtime/query/iteration/phases/context.d.ts +0 -17
  41. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  42. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  43. package/dist/store/task/disk.d.ts.map +1 -1
  44. package/dist/store/task/disk.js +14 -0
  45. package/dist/store/task/disk.js.map +1 -1
  46. package/dist/store/task/memory.d.ts.map +1 -1
  47. package/dist/store/task/memory.js +14 -0
  48. package/dist/store/task/memory.js.map +1 -1
  49. package/dist/tools/coordinator/__tests__/a-failed-worker-is-not-an-answer.test.d.ts +2 -0
  50. package/dist/tools/coordinator/__tests__/a-failed-worker-is-not-an-answer.test.d.ts.map +1 -0
  51. package/dist/tools/coordinator/__tests__/a-failed-worker-is-not-an-answer.test.js +101 -0
  52. package/dist/tools/coordinator/__tests__/a-failed-worker-is-not-an-answer.test.js.map +1 -0
  53. package/dist/tools/coordinator/__tests__/the-plan-a-human-approves.test.d.ts +2 -0
  54. package/dist/tools/coordinator/__tests__/the-plan-a-human-approves.test.d.ts.map +1 -0
  55. package/dist/tools/coordinator/__tests__/the-plan-a-human-approves.test.js +99 -0
  56. package/dist/tools/coordinator/__tests__/the-plan-a-human-approves.test.js.map +1 -0
  57. package/dist/tools/coordinator/agent.d.ts.map +1 -1
  58. package/dist/tools/coordinator/agent.js +17 -23
  59. package/dist/tools/coordinator/agent.js.map +1 -1
  60. package/dist/tools/coordinator/index.d.ts.map +1 -1
  61. package/dist/tools/coordinator/index.js +33 -3
  62. package/dist/tools/coordinator/index.js.map +1 -1
  63. package/dist/tools/coordinator/outcome.d.ts +60 -0
  64. package/dist/tools/coordinator/outcome.d.ts.map +1 -0
  65. package/dist/tools/coordinator/outcome.js +68 -0
  66. package/dist/tools/coordinator/outcome.js.map +1 -0
  67. package/dist/types/agent/gateway.d.ts +19 -2
  68. package/dist/types/agent/gateway.d.ts.map +1 -1
  69. package/dist/types/agent/supervisor.d.ts +38 -1
  70. package/dist/types/agent/supervisor.d.ts.map +1 -1
  71. package/dist/types/plan/index.d.ts +26 -0
  72. package/dist/types/plan/index.d.ts.map +1 -1
  73. package/dist/types/run/events.d.ts +17 -0
  74. package/dist/types/run/events.d.ts.map +1 -1
  75. package/dist/types/run/events.js.map +1 -1
  76. package/dist/types/task/index.d.ts +19 -1
  77. package/dist/types/task/index.d.ts.map +1 -1
  78. package/dist/types/task/index.js +10 -1
  79. package/dist/types/task/index.js.map +1 -1
  80. package/package.json +1 -1
  81. package/src/agents/SupervisorAgent.ts +15 -9
  82. package/src/agents/__tests__/a-policy-nobody-can-select.test.ts +202 -0
  83. package/src/gateway/__tests__/a-knob-nobody-can-turn.test.ts +139 -0
  84. package/src/gateway/local.ts +19 -7
  85. package/src/manager/agent/__tests__/lifecycle.test.ts +74 -0
  86. package/src/manager/agent/lifecycle.ts +72 -42
  87. package/src/manager/plan/__tests__/a-plan-that-succeeded-is-not-failed.test.ts +88 -0
  88. package/src/manager/plan/lifecycle.ts +61 -0
  89. package/src/runtime/query/__tests__/the-plan-graph-reaches-a-host.test.ts +79 -0
  90. package/src/runtime/query/events.ts +5 -0
  91. package/src/runtime/query/index.ts +0 -6
  92. package/src/runtime/query/iteration/phases/context.ts +0 -19
  93. package/src/store/task/disk.ts +15 -0
  94. package/src/store/task/memory.ts +15 -0
  95. package/src/tools/coordinator/__tests__/a-failed-worker-is-not-an-answer.test.ts +133 -0
  96. package/src/tools/coordinator/__tests__/the-plan-a-human-approves.test.ts +121 -0
  97. package/src/tools/coordinator/agent.ts +17 -25
  98. package/src/tools/coordinator/index.ts +33 -3
  99. package/src/tools/coordinator/outcome.ts +70 -0
  100. package/src/types/agent/gateway.ts +19 -2
  101. package/src/types/agent/supervisor.ts +40 -1
  102. package/src/types/plan/index.ts +29 -0
  103. package/src/types/run/events.ts +17 -0
  104. package/src/types/task/index.ts +22 -3
@@ -10,7 +10,7 @@ import type { ToolRegistryContract } from '../tool/index.js'
10
10
  import type { VerificationGateConfig } from '../verification/index.js'
11
11
  import type { BaseAgentConfig, BaseAgentResult } from './base.js'
12
12
  import type { AgentFactoryOptions } from './factory.js'
13
- import type { TaskGateway } from './gateway.js'
13
+ import type { SiblingFailurePolicy, TaskGateway } from './gateway.js'
14
14
  import type { AgentManagerContract } from './manager.js'
15
15
  import type { WorkingMemoryProvider } from './working-memory.js'
16
16
 
@@ -72,6 +72,45 @@ export interface SupervisorAgentConfig extends BaseAgentConfig {
72
72
  */
73
73
  maxDepth?: number
74
74
 
75
+ /**
76
+ * How many tools may execute at once in one turn — which, for a
77
+ * supervisor, is how wide a fan-out actually runs.
78
+ *
79
+ * The kernel has honoured this all along and `ReactiveAgent` forwards it.
80
+ * It was missing here, so the agent whose entire job is delegation could
81
+ * not set the gate that bounds delegation, while the agent that does not
82
+ * delegate could. A host wanting a narrower fan-out had to reach past the
83
+ * supervisor to `drainQuery`.
84
+ *
85
+ * Absent leaves the kernel default. Note what it does and does not bound:
86
+ * it limits how many delegated children run CONCURRENTLY, not how many a
87
+ * turn may launch — a model that emits twenty `create_task` blocks still
88
+ * launches twenty, and they queue.
89
+ */
90
+ maxToolConcurrency?: number
91
+
92
+ /**
93
+ * What a failed child means for the siblings still running. Defaults to
94
+ * `'continue'`.
95
+ *
96
+ * `LocalTaskGateway` has honoured this since it was written, and the
97
+ * cancellation machinery behind `'cancel-siblings'` is complete — but the
98
+ * policy was a constructor argument on a gateway the supervisor builds
99
+ * itself, and the supervisor passed nothing. So every host in existence
100
+ * ran `'continue'`, and the only way to reach the other value was to
101
+ * construct the gateway by hand and hand it in. A policy nobody can select
102
+ * is not a policy.
103
+ *
104
+ * `'continue'` stays the default deliberately: partial results are usually
105
+ * worth having, and tearing down healthy siblings on any failure lets one
106
+ * flaky child waste four good ones. `'cancel-siblings'` is for a fan-out
107
+ * whose parts only mean something together — if one leg of a comparison
108
+ * dies, the others are spending budget on an answer nobody can use.
109
+ *
110
+ * Ignored when the host supplies its own `gateway`, which owns its policy.
111
+ */
112
+ siblingFailurePolicy?: SiblingFailurePolicy
113
+
75
114
  taskRouter?: TaskRouterConfig
76
115
 
77
116
  factoryOptions?: AgentFactoryOptions
@@ -18,7 +18,36 @@ export interface PlanStep {
18
18
  id: string
19
19
  description: string
20
20
  toolName?: string
21
+
22
+ /**
23
+ * Which agent this step is to be delegated to, when it is delegated at all.
24
+ *
25
+ * `approve_plan` invites the model to name an agent per step, and that
26
+ * answer was reduced to a boolean: the step got `toolName: 'create_task'`
27
+ * if any agent was named and nothing if not. So the human approving the
28
+ * plan was shown THAT a step delegates and never TO WHOM — while the model
29
+ * had said, and the approval is the one moment where the difference can
30
+ * still be acted on. Approving "delegate this" is not approving "delegate
31
+ * this to the agent with shell access".
32
+ *
33
+ * Typed rather than folded into {@link estimatedInput}, which is `unknown`:
34
+ * an approval gate's whole job is being readable, and a field a host has to
35
+ * cast before it can render is one a host renders wrong or not at all.
36
+ *
37
+ * Absent means the step is the orchestrator's own work, which is what
38
+ * omitting `agent_id` in `approve_plan` says.
39
+ */
40
+ agentId?: string
41
+
42
+ /**
43
+ * **No producer and no reader.** Nothing in the SDK writes this and
44
+ * nothing reads it; it is declared here and that is all. Noted rather
45
+ * than removed because it is on the published typings — see
46
+ * {@link agentId}, which is the field the plan approval path actually
47
+ * needed and did not have.
48
+ */
21
49
  estimatedInput?: unknown
50
+
22
51
  dependsOn: string[]
23
52
  status: 'pending' | 'running' | 'completed' | 'skipped' | 'failed'
24
53
  error?: string
@@ -461,6 +461,21 @@ type CoreRunEvent =
461
461
  taskId: TaskId
462
462
  subject: string
463
463
  status: TaskStatus
464
+ /**
465
+ * What this unit waits on, and who claims it.
466
+ *
467
+ * The store maintains a full dependency graph — `blocks` and
468
+ * `blockedBy` are mirrored on both ends, written under a lock, and
469
+ * deadlock-avoided — and none of it reached the wire. So a host
470
+ * could show a flat list of units and nothing about their order,
471
+ * while the model was already maintaining the order.
472
+ *
473
+ * Absent rather than empty when the unit depends on nothing, so a
474
+ * reader can tell "no dependencies" from an emitter that predates
475
+ * these fields.
476
+ */
477
+ blockedBy?: readonly TaskId[]
478
+ owner?: string
464
479
  }
465
480
  | {
466
481
  type: 'task_updated'
@@ -469,6 +484,8 @@ type CoreRunEvent =
469
484
  subject: string
470
485
  status: TaskStatus
471
486
  owner?: string
487
+ /** See `task_created`. Carried on updates because an edge can be added later. */
488
+ blockedBy?: readonly TaskId[]
472
489
  }
473
490
  | {
474
491
  type: 'plugin_hook_executing'
@@ -1,9 +1,27 @@
1
1
  import type { RunId, TaskId, TenantId } from '../ids/index.js'
2
2
 
3
- export type TaskStatus = 'pending' | 'in_progress' | 'completed'
4
-
3
+ /**
4
+ * `failed` exists because a unit that did not succeed had nowhere to say so.
5
+ *
6
+ * Delegation wrote a failed worker's task as `completed` with the failure
7
+ * encoded as prose in `description` — so a reader scanning statuses saw work
8
+ * that had been done, and only a reader of every description saw otherwise. A
9
+ * status nobody can set is a status nobody can act on: a dependent unit cannot
10
+ * decide whether to wait or give up, and a plan cannot report that it did not
11
+ * finish.
12
+ */
13
+ export type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed'
14
+
15
+ /**
16
+ * Terminal means "will not change on its own", not "succeeded".
17
+ *
18
+ * `failed` is terminal for the same reason `completed` is: nothing downstream
19
+ * should wait on it. That matters most to the blocker check in the task
20
+ * listing — a dependent unit blocked on something that failed would otherwise
21
+ * wait forever for a status that will never arrive.
22
+ */
5
23
  export function isTerminalTaskStatus(status: TaskStatus): boolean {
6
- return status === 'completed'
24
+ return status === 'completed' || status === 'failed'
7
25
  }
8
26
 
9
27
  export function assertTaskStatus(status: TaskStatus): void {
@@ -11,6 +29,7 @@ export function assertTaskStatus(status: TaskStatus): void {
11
29
  case 'pending':
12
30
  case 'in_progress':
13
31
  case 'completed':
32
+ case 'failed':
14
33
  return
15
34
  default: {
16
35
  const _exhaustive: never = status