@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.
- package/CHANGELOG.md +244 -0
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +14 -6
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/__tests__/a-policy-nobody-can-select.test.d.ts +2 -0
- package/dist/agents/__tests__/a-policy-nobody-can-select.test.d.ts.map +1 -0
- package/dist/agents/__tests__/a-policy-nobody-can-select.test.js +177 -0
- package/dist/agents/__tests__/a-policy-nobody-can-select.test.js.map +1 -0
- package/dist/gateway/__tests__/a-knob-nobody-can-turn.test.d.ts +2 -0
- package/dist/gateway/__tests__/a-knob-nobody-can-turn.test.d.ts.map +1 -0
- package/dist/gateway/__tests__/a-knob-nobody-can-turn.test.js +114 -0
- package/dist/gateway/__tests__/a-knob-nobody-can-turn.test.js.map +1 -0
- package/dist/gateway/local.d.ts.map +1 -1
- package/dist/gateway/local.js +19 -6
- package/dist/gateway/local.js.map +1 -1
- package/dist/manager/agent/__tests__/lifecycle.test.js +56 -0
- package/dist/manager/agent/__tests__/lifecycle.test.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +62 -33
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/plan/__tests__/a-plan-that-succeeded-is-not-failed.test.d.ts +2 -0
- package/dist/manager/plan/__tests__/a-plan-that-succeeded-is-not-failed.test.d.ts.map +1 -0
- package/dist/manager/plan/__tests__/a-plan-that-succeeded-is-not-failed.test.js +73 -0
- package/dist/manager/plan/__tests__/a-plan-that-succeeded-is-not-failed.test.js.map +1 -0
- package/dist/manager/plan/lifecycle.d.ts +48 -0
- package/dist/manager/plan/lifecycle.d.ts.map +1 -1
- package/dist/manager/plan/lifecycle.js +56 -0
- package/dist/manager/plan/lifecycle.js.map +1 -1
- package/dist/runtime/query/__tests__/the-plan-graph-reaches-a-host.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/the-plan-graph-reaches-a-host.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/the-plan-graph-reaches-a-host.test.js +62 -0
- package/dist/runtime/query/__tests__/the-plan-graph-reaches-a-host.test.js.map +1 -0
- package/dist/runtime/query/events.d.ts.map +1 -1
- package/dist/runtime/query/events.js +5 -0
- package/dist/runtime/query/events.js.map +1 -1
- package/dist/runtime/query/index.d.ts +0 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +0 -1
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +0 -17
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/store/task/disk.d.ts.map +1 -1
- package/dist/store/task/disk.js +14 -0
- package/dist/store/task/disk.js.map +1 -1
- package/dist/store/task/memory.d.ts.map +1 -1
- package/dist/store/task/memory.js +14 -0
- package/dist/store/task/memory.js.map +1 -1
- package/dist/tools/coordinator/__tests__/a-failed-worker-is-not-an-answer.test.d.ts +2 -0
- package/dist/tools/coordinator/__tests__/a-failed-worker-is-not-an-answer.test.d.ts.map +1 -0
- package/dist/tools/coordinator/__tests__/a-failed-worker-is-not-an-answer.test.js +101 -0
- package/dist/tools/coordinator/__tests__/a-failed-worker-is-not-an-answer.test.js.map +1 -0
- package/dist/tools/coordinator/__tests__/the-plan-a-human-approves.test.d.ts +2 -0
- package/dist/tools/coordinator/__tests__/the-plan-a-human-approves.test.d.ts.map +1 -0
- package/dist/tools/coordinator/__tests__/the-plan-a-human-approves.test.js +99 -0
- package/dist/tools/coordinator/__tests__/the-plan-a-human-approves.test.js.map +1 -0
- package/dist/tools/coordinator/agent.d.ts.map +1 -1
- package/dist/tools/coordinator/agent.js +17 -23
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +33 -3
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/coordinator/outcome.d.ts +60 -0
- package/dist/tools/coordinator/outcome.d.ts.map +1 -0
- package/dist/tools/coordinator/outcome.js +68 -0
- package/dist/tools/coordinator/outcome.js.map +1 -0
- package/dist/types/agent/gateway.d.ts +19 -2
- package/dist/types/agent/gateway.d.ts.map +1 -1
- package/dist/types/agent/supervisor.d.ts +38 -1
- package/dist/types/agent/supervisor.d.ts.map +1 -1
- package/dist/types/plan/index.d.ts +26 -0
- package/dist/types/plan/index.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +17 -0
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/events.js.map +1 -1
- package/dist/types/task/index.d.ts +19 -1
- package/dist/types/task/index.d.ts.map +1 -1
- package/dist/types/task/index.js +10 -1
- package/dist/types/task/index.js.map +1 -1
- package/package.json +1 -1
- package/src/agents/SupervisorAgent.ts +15 -9
- package/src/agents/__tests__/a-policy-nobody-can-select.test.ts +202 -0
- package/src/gateway/__tests__/a-knob-nobody-can-turn.test.ts +139 -0
- package/src/gateway/local.ts +19 -7
- package/src/manager/agent/__tests__/lifecycle.test.ts +74 -0
- package/src/manager/agent/lifecycle.ts +72 -42
- package/src/manager/plan/__tests__/a-plan-that-succeeded-is-not-failed.test.ts +88 -0
- package/src/manager/plan/lifecycle.ts +61 -0
- package/src/runtime/query/__tests__/the-plan-graph-reaches-a-host.test.ts +79 -0
- package/src/runtime/query/events.ts +5 -0
- package/src/runtime/query/index.ts +0 -6
- package/src/runtime/query/iteration/phases/context.ts +0 -19
- package/src/store/task/disk.ts +15 -0
- package/src/store/task/memory.ts +15 -0
- package/src/tools/coordinator/__tests__/a-failed-worker-is-not-an-answer.test.ts +133 -0
- package/src/tools/coordinator/__tests__/the-plan-a-human-approves.test.ts +121 -0
- package/src/tools/coordinator/agent.ts +17 -25
- package/src/tools/coordinator/index.ts +33 -3
- package/src/tools/coordinator/outcome.ts +70 -0
- package/src/types/agent/gateway.ts +19 -2
- package/src/types/agent/supervisor.ts +40 -1
- package/src/types/plan/index.ts +29 -0
- package/src/types/run/events.ts +17 -0
- 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
|
package/src/types/plan/index.ts
CHANGED
|
@@ -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
|
package/src/types/run/events.ts
CHANGED
|
@@ -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'
|
package/src/types/task/index.ts
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
import type { RunId, TaskId, TenantId } from '../ids/index.js'
|
|
2
2
|
|
|
3
|
-
|
|
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
|