@namzu/sdk 12.0.0 → 12.1.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 -0
- package/dist/agents/AbstractAgent.d.ts +20 -0
- package/dist/agents/AbstractAgent.d.ts.map +1 -1
- package/dist/agents/AbstractAgent.js +32 -0
- package/dist/agents/AbstractAgent.js.map +1 -1
- package/dist/agents/lock.d.ts.map +1 -1
- package/dist/agents/lock.js +8 -1
- package/dist/agents/lock.js.map +1 -1
- package/dist/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.d.ts +2 -0
- package/dist/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.d.ts.map +1 -0
- package/dist/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.js +137 -0
- package/dist/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.js.map +1 -0
- package/dist/gateway/local.d.ts.map +1 -1
- package/dist/gateway/local.js +25 -1
- package/dist/gateway/local.js.map +1 -1
- package/dist/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.d.ts +2 -0
- package/dist/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.d.ts.map +1 -0
- package/dist/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.js +101 -0
- package/dist/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.js.map +1 -0
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +21 -1
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/types/agent/core.d.ts +21 -0
- package/dist/types/agent/core.d.ts.map +1 -1
- package/dist/types/agent/factory.d.ts +18 -0
- package/dist/types/agent/factory.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/agents/AbstractAgent.ts +35 -0
- package/src/agents/lock.ts +10 -1
- package/src/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.ts +175 -0
- package/src/gateway/local.ts +25 -1
- package/src/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.ts +118 -0
- package/src/manager/agent/lifecycle.ts +21 -1
- package/src/types/agent/core.ts +22 -0
- package/src/types/agent/factory.ts +20 -0
package/src/types/agent/core.ts
CHANGED
|
@@ -17,6 +17,28 @@ export interface Agent<
|
|
|
17
17
|
|
|
18
18
|
run(input: AgentInput, config: TConfig, listener?: RunEventListener): Promise<TResult>
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* A shell of this agent that one run may have to itself.
|
|
22
|
+
*
|
|
23
|
+
* An agent instance holds per-run state — an abort controller, the id of
|
|
24
|
+
* the run in flight — and refuses a second concurrent `run` because of it.
|
|
25
|
+
* That refusal is correct for a host calling `run` twice on purpose: two
|
|
26
|
+
* overlapping runs would share one abort controller, so cancelling either
|
|
27
|
+
* kills both.
|
|
28
|
+
*
|
|
29
|
+
* It is wrong for delegation, which is why this exists. `AgentRegistry`
|
|
30
|
+
* hands out ONE instance per registered id, so a fan-out naming the same
|
|
31
|
+
* `agent_id` four times drove four runs at one shell: one worked and three
|
|
32
|
+
* died with `ConcurrentInvocationError`. The prescribed remedy — "construct
|
|
33
|
+
* a second instance" — was unreachable from there, because the definition
|
|
34
|
+
* owns the instance and the caller only has an id.
|
|
35
|
+
*
|
|
36
|
+
* OPTIONAL, and absence is safe: a manager that cannot get a fresh shell
|
|
37
|
+
* falls back to the shared one and the refusal stands, which is loud rather
|
|
38
|
+
* than wrong. `AbstractAgent` implements it for every agent built on it.
|
|
39
|
+
*/
|
|
40
|
+
forRun?(): Agent<TConfig, TResult>
|
|
41
|
+
|
|
20
42
|
cancel(): Promise<void>
|
|
21
43
|
getCapabilities(): AgentCapabilities
|
|
22
44
|
}
|
|
@@ -8,6 +8,26 @@ export type { AgentContextLevel } from './base.js'
|
|
|
8
8
|
export interface AgentDefinition {
|
|
9
9
|
info: AgentInfo
|
|
10
10
|
typedAgent: Agent<BaseAgentConfig, BaseAgentResult>
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Build a fresh agent for a single spawn.
|
|
14
|
+
*
|
|
15
|
+
* `typedAgent` is ONE instance, and an instance refuses a second
|
|
16
|
+
* concurrent run because it holds per-run state. So a delegation fan-out
|
|
17
|
+
* naming the same `agent_id` four times ran one child and lost three to
|
|
18
|
+
* `ConcurrentInvocationError` — while `create_task`'s own description tells
|
|
19
|
+
* a model that exactly this fan-out is the thing to do.
|
|
20
|
+
*
|
|
21
|
+
* The manager prefers this over `typedAgent` for every spawn. Supply it
|
|
22
|
+
* when your agent needs real construction arguments; agents built on
|
|
23
|
+
* `AbstractAgent` already get a working default from `Agent.forRun`, so
|
|
24
|
+
* most hosts need nothing here.
|
|
25
|
+
*
|
|
26
|
+
* `configBuilder` is not a substitute: it produces a fresh CONFIG per
|
|
27
|
+
* spawn, and the config was never the part being shared.
|
|
28
|
+
*/
|
|
29
|
+
createAgent?: () => Agent<BaseAgentConfig, BaseAgentResult>
|
|
30
|
+
|
|
11
31
|
configBuilder?: (options: AgentFactoryOptions) => BaseAgentConfig | Promise<BaseAgentConfig>
|
|
12
32
|
|
|
13
33
|
contextLevel?: AgentContextLevel
|