@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.
Files changed (35) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/dist/agents/AbstractAgent.d.ts +20 -0
  3. package/dist/agents/AbstractAgent.d.ts.map +1 -1
  4. package/dist/agents/AbstractAgent.js +32 -0
  5. package/dist/agents/AbstractAgent.js.map +1 -1
  6. package/dist/agents/lock.d.ts.map +1 -1
  7. package/dist/agents/lock.js +8 -1
  8. package/dist/agents/lock.js.map +1 -1
  9. package/dist/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.d.ts +2 -0
  10. package/dist/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.d.ts.map +1 -0
  11. package/dist/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.js +137 -0
  12. package/dist/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.js.map +1 -0
  13. package/dist/gateway/local.d.ts.map +1 -1
  14. package/dist/gateway/local.js +25 -1
  15. package/dist/gateway/local.js.map +1 -1
  16. package/dist/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.d.ts +2 -0
  17. package/dist/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.d.ts.map +1 -0
  18. package/dist/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.js +101 -0
  19. package/dist/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.js.map +1 -0
  20. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  21. package/dist/manager/agent/lifecycle.js +21 -1
  22. package/dist/manager/agent/lifecycle.js.map +1 -1
  23. package/dist/types/agent/core.d.ts +21 -0
  24. package/dist/types/agent/core.d.ts.map +1 -1
  25. package/dist/types/agent/factory.d.ts +18 -0
  26. package/dist/types/agent/factory.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/src/agents/AbstractAgent.ts +35 -0
  29. package/src/agents/lock.ts +10 -1
  30. package/src/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.ts +175 -0
  31. package/src/gateway/local.ts +25 -1
  32. package/src/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.ts +118 -0
  33. package/src/manager/agent/lifecycle.ts +21 -1
  34. package/src/types/agent/core.ts +22 -0
  35. package/src/types/agent/factory.ts +20 -0
@@ -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