@tangle-network/agent-runtime 0.101.1 → 0.102.1

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 (78) hide show
  1. package/dist/agent.d.ts +1 -1
  2. package/dist/agent.js +5 -3
  3. package/dist/agent.js.map +1 -1
  4. package/dist/analyst-loop.d.ts +1 -1
  5. package/dist/candidate-execution/index.d.ts +13 -2
  6. package/dist/candidate-execution/index.js +8 -3
  7. package/dist/chunk-377GOJHJ.js +578 -0
  8. package/dist/chunk-377GOJHJ.js.map +1 -0
  9. package/dist/{chunk-DI677IPX.js → chunk-3DW5DEKQ.js} +3 -3
  10. package/dist/{chunk-KVJQV342.js → chunk-6MR4IJRW.js} +25 -1777
  11. package/dist/chunk-6MR4IJRW.js.map +1 -0
  12. package/dist/{chunk-RJPQLUDA.js → chunk-7FJJUC73.js} +336 -43
  13. package/dist/chunk-7FJJUC73.js.map +1 -0
  14. package/dist/{chunk-TA4RBJLE.js → chunk-CI7WS6S2.js} +5 -5
  15. package/dist/{chunk-U4PRAATQ.js → chunk-CK76OZPM.js} +3 -3
  16. package/dist/{chunk-KSBUSEUA.js → chunk-KJ2Q4T7F.js} +2 -2
  17. package/dist/{chunk-MAONWP4R.js → chunk-KPHTCHQ4.js} +611 -1419
  18. package/dist/chunk-KPHTCHQ4.js.map +1 -0
  19. package/dist/{chunk-BXZ7GPL4.js → chunk-KSM6GFHP.js} +2 -2
  20. package/dist/chunk-L5DST3QC.js +351 -0
  21. package/dist/chunk-L5DST3QC.js.map +1 -0
  22. package/dist/{chunk-HGSHPVJ6.js → chunk-LJLG734E.js} +200 -441
  23. package/dist/chunk-LJLG734E.js.map +1 -0
  24. package/dist/chunk-ROILMKDL.js +1338 -0
  25. package/dist/chunk-ROILMKDL.js.map +1 -0
  26. package/dist/{chunk-N2CEE5Q3.js → chunk-RTB3TC73.js} +3 -3
  27. package/dist/chunk-SQ3ZJH3Y.js +3082 -0
  28. package/dist/chunk-SQ3ZJH3Y.js.map +1 -0
  29. package/dist/chunk-UPWGXKXB.js +254 -0
  30. package/dist/chunk-UPWGXKXB.js.map +1 -0
  31. package/dist/{completion-gate-C80jiRfN.d.ts → completion-gate-C6dhVN-N.d.ts} +2 -2
  32. package/dist/{coordination-BFE3Den7.d.ts → coordination-D9l_YmwW.d.ts} +6 -6
  33. package/dist/environment-provider.d.ts +2 -2
  34. package/dist/{improve-g75IE2Cx.d.ts → improve-B40dRu0X.d.ts} +47 -19
  35. package/dist/index.d.ts +331 -23
  36. package/dist/index.js +544 -136
  37. package/dist/index.js.map +1 -1
  38. package/dist/intelligence.d.ts +63 -62
  39. package/dist/intelligence.js +62 -471
  40. package/dist/intelligence.js.map +1 -1
  41. package/dist/knowledge.d.ts +8 -8
  42. package/dist/knowledge.js +9 -7
  43. package/dist/{local-harness-ZqCx51u7.d.ts → local-harness-CtK9dSny.d.ts} +14 -2
  44. package/dist/{loop-runner-bin-Cn1N2rRo.d.ts → loop-runner-bin-PnWslIw4.d.ts} +2 -2
  45. package/dist/loop-runner-bin.d.ts +6 -6
  46. package/dist/loop-runner-bin.js +6 -4
  47. package/dist/loops.d.ts +231 -460
  48. package/dist/loops.js +58 -37
  49. package/dist/mcp/bin.js +2 -2
  50. package/dist/mcp/index.d.ts +184 -12
  51. package/dist/mcp/index.js +31 -9
  52. package/dist/mcp/index.js.map +1 -1
  53. package/dist/mcp/memory-bin.d.ts +1 -0
  54. package/dist/mcp/memory-bin.js +22 -0
  55. package/dist/mcp/memory-bin.js.map +1 -0
  56. package/dist/profiles.d.ts +3 -3
  57. package/dist/structural-rollout-D7xik9XR.d.ts +446 -0
  58. package/dist/{substrate-DO2GHNg2.d.ts → substrate-Dyiqmd3o.d.ts} +1 -1
  59. package/dist/{supervise-BLPI50-w.d.ts → supervise-BQdNAXtK.d.ts} +4 -4
  60. package/dist/testing.js +255 -211
  61. package/dist/testing.js.map +1 -1
  62. package/dist/{types-B3vAW0Oq.d.ts → types-CLat4bT9.d.ts} +1 -1
  63. package/dist/{types-CmnA2iL3.d.ts → types-D870JlH0.d.ts} +2 -2
  64. package/dist/{worktree-fanout-DCA3G4bO.d.ts → worktree-fanout-DsIR4d6w.d.ts} +234 -234
  65. package/package.json +6 -5
  66. package/dist/chunk-HGSHPVJ6.js.map +0 -1
  67. package/dist/chunk-IKGCKPDX.js +0 -1115
  68. package/dist/chunk-IKGCKPDX.js.map +0 -1
  69. package/dist/chunk-KVJQV342.js.map +0 -1
  70. package/dist/chunk-MAONWP4R.js.map +0 -1
  71. package/dist/chunk-RJPQLUDA.js.map +0 -1
  72. package/dist/{chunk-DI677IPX.js.map → chunk-3DW5DEKQ.js.map} +0 -0
  73. package/dist/{chunk-TA4RBJLE.js.map → chunk-CI7WS6S2.js.map} +0 -0
  74. package/dist/{chunk-U4PRAATQ.js.map → chunk-CK76OZPM.js.map} +0 -0
  75. package/dist/{chunk-KSBUSEUA.js.map → chunk-KJ2Q4T7F.js.map} +0 -0
  76. package/dist/{chunk-BXZ7GPL4.js.map → chunk-KSM6GFHP.js.map} +0 -0
  77. package/dist/{chunk-N2CEE5Q3.js.map → chunk-RTB3TC73.js.map} +0 -0
  78. package/dist/{sanitize-BTSsdBXw.d.ts → sanitize-DEbPNtyI.d.ts} +58 -58
@@ -799,4 +799,4 @@ interface ExecCtx {
799
799
  parentSpanId?: string;
800
800
  }
801
801
 
802
- export { type AgentRunSpec as A, type LoopIterationEndedPayload as B, type LoopIterationStartedPayload as C, type Driver as D, type ExecCtx as E, type LoopPlanDescription as F, type LoopPlanPayload as G, type LoopStartedPayload as H, type Iteration as I, type LoopTeardownFailedPayload as J, type MountManifestEntry as K, type LoopTokenUsage as L, type MountRecorder as M, type RunProvenance as N, type OutputAdapter as O, type ValidationCtx as P, type RuntimeHooks as R, type SandboxClient as S, type Validator as V, type LoopSandboxPlacement as a, type LoopTraceEvent as b, type RuntimeDecisionEvidenceRef as c, type RuntimeDecisionKind as d, type RuntimeDecisionPoint as e, type RuntimeHookContext as f, type RuntimeHookErrorContext as g, type RuntimeHookEvent as h, type RuntimeHookPhase as i, type RuntimeHookTarget as j, type RuntimeRunHandle as k, type RuntimeRunPersistenceAdapter as l, type RuntimeRunRow as m, composeRuntimeHooks as n, defineRuntimeHooks as o, notifyRuntimeDecisionPoint as p, notifyRuntimeHookEvent as q, type LoopTraceEmitter as r, startRuntimeRun as s, type LoopWinner as t, type LoopLineageOptions as u, type LoopResult as v, type SelectionReceipt as w, type LoopDecisionPayload as x, type LoopEndedPayload as y, type LoopIterationDispatchPayload as z };
802
+ export { type AgentRunSpec as A, type LoopIterationEndedPayload as B, type LoopIterationStartedPayload as C, type Driver as D, type ExecCtx as E, type LoopPlanDescription as F, type LoopPlanPayload as G, type LoopStartedPayload as H, type Iteration as I, type LoopTeardownFailedPayload as J, type MountManifestEntry as K, type LoopTokenUsage as L, type MountRecorder as M, type RunProvenance as N, type OutputAdapter as O, type ValidationCtx as P, type RuntimeHooks as R, type SandboxClient as S, type Validator as V, type SelectionReceipt as a, type LoopSandboxPlacement as b, type LoopTraceEvent as c, type LoopTraceEmitter as d, type RuntimeDecisionEvidenceRef as e, type RuntimeDecisionKind as f, type RuntimeDecisionPoint as g, type RuntimeHookContext as h, type RuntimeHookErrorContext as i, type RuntimeHookEvent as j, type RuntimeHookPhase as k, type RuntimeHookTarget as l, type RuntimeRunHandle as m, type RuntimeRunPersistenceAdapter as n, type RuntimeRunRow as o, composeRuntimeHooks as p, defineRuntimeHooks as q, notifyRuntimeDecisionPoint as r, notifyRuntimeHookEvent as s, startRuntimeRun as t, type LoopWinner as u, type LoopLineageOptions as v, type LoopResult as w, type LoopDecisionPayload as x, type LoopEndedPayload as y, type LoopIterationDispatchPayload as z };
@@ -1,7 +1,7 @@
1
1
  import { DefaultVerdict } from '@tangle-network/agent-eval';
2
2
  import { AgentProfile } from '@tangle-network/agent-interface';
3
3
  import { BackendType } from '@tangle-network/sandbox';
4
- import { L as LoopTokenUsage, R as RuntimeHooks } from './types-B3vAW0Oq.js';
4
+ import { L as LoopTokenUsage, R as RuntimeHooks } from './types-CLat4bT9.js';
5
5
 
6
6
  /**
7
7
  *
@@ -497,4 +497,4 @@ interface WidenGate<Out> {
497
497
  readonly judgeExempt?: boolean;
498
498
  }
499
499
 
500
- export type { Agent as A, Budget as B, ExecutorFactory as E, NodeId as N, Runtime as R, Scope as S, TreeView as T, UsageEvent as U, WidenGate as W, ResultBlobStore as a, SupervisedResult as b, Executor as c, AgentSpec as d, ExecutorRegistry as e, SpawnJournal as f, RootHandle as g, Settled as h, Spend as i, SpawnEvent as j, Supervisor as k, ExecutorContext as l, ExecutorResult as m, SupervisorOpts as n };
500
+ export type { Agent as A, Budget as B, ExecutorFactory as E, NodeId as N, Runtime as R, Scope as S, TreeView as T, UsageEvent as U, WidenGate as W, ResultBlobStore as a, SupervisedResult as b, Executor as c, Settled as d, Spend as e, AgentSpec as f, SpawnJournal as g, ExecutorRegistry as h, RootHandle as i, SpawnEvent as j, Supervisor as k, ExecutorContext as l, ExecutorResult as m, SupervisorOpts as n };
@@ -1,239 +1,10 @@
1
1
  import { AgentProfile } from '@tangle-network/agent-interface';
2
2
  import { AnalystFinding, DefaultVerdict } from '@tangle-network/agent-eval';
3
- import { d as AgentSpec, e as ExecutorRegistry, B as Budget, A as Agent, f as SpawnJournal, a as ResultBlobStore, g as RootHandle, b as SupervisedResult, N as NodeId, h as Settled, i as Spend, S as Scope, c as Executor } from './types-CmnA2iL3.js';
4
- import { R as RuntimeHooks, I as Iteration } from './types-B3vAW0Oq.js';
3
+ import { N as NodeId, d as Settled, e as Spend, f as AgentSpec, S as Scope, g as SpawnJournal, a as ResultBlobStore, h as ExecutorRegistry, B as Budget, A as Agent, i as RootHandle, b as SupervisedResult, c as Executor } from './types-D870JlH0.js';
4
+ import { I as Iteration, R as RuntimeHooks } from './types-CLat4bT9.js';
5
5
  import { BackendType } from '@tangle-network/sandbox';
6
- import { W as WorktreeHarnessResult, G as GitRunner, a as WorktreeCheckRunner, D as DeliverableSpec } from './completion-gate-C80jiRfN.js';
7
- import { L as LocalHarness, r as runLocalHarness } from './local-harness-ZqCx51u7.js';
8
-
9
- /**
10
- *
11
- * The personify layer — the "act like X" knob on top of the recursive keystone.
12
- *
13
- * The keystone (`src/loops/supervise/`) is pure STRUCTURE: a recursive `Agent` atom inside
14
- * a budget-conserving `Scope`, an `ExecutorRegistry` mapping an `AgentSpec` to a runtime,
15
- * and a `Supervisor` that runs a root agent to a typed `SupervisedResult`. It carries no
16
- * CONTENT — no model, no prompt, no goal framing, no notion of "who this loop is".
17
- *
18
- * This layer adds exactly that content seam without inventing a second engine:
19
- * - A `Persona` is a thin record: the root `AgentSpec` (profile + harness + optional BYO
20
- * executor), a root `directive` (the goal framing handed to the chosen shape), a
21
- * `context` blob (who the loop is acting as), and the executor seams the registry needs.
22
- * `definePersona` builds it; it is data, not behavior.
23
- * - A `LoopShape` is a reusable act-body FACTORY: `(ctx: ShapeContext) => Agent`. The shape
24
- * owns the STRUCTURE (how to decompose / fan out / verify / synthesize); the persona's
25
- * content parameterizes it. A new shape is ONE file + one `registerShape` call.
26
- * - `Outcome<D>` is the contract every shape synthesizes into: a finished deliverable OR a
27
- * list of concrete blockers — "100% done or 100%-defined blockers", never a vague middle.
28
- *
29
- * Layering: this module imports ONLY keystone runtime types (`./supervise/types`) and the
30
- * substrate `AgentProfile`/`BackendType`. It typechecks standalone — no impl, no engine.
31
- * Extensibility is structural: `Persona` carries an open `extensions` bag so a later
32
- * world-model / memory field is additive (a new optional key), never a breaking change.
33
- *
34
- * @experimental
35
- */
36
-
37
- /**
38
- * The terminal contract Drew wants: a loop returns a FINISHED deliverable, or the concrete
39
- * list of blockers that stopped it — never a half-done best-effort coercion. A `blocked`
40
- * outcome with an empty `blockers` list is a contract violation (a shape that can't finish
41
- * MUST name why); impls fail loud on it rather than emitting a vacuous block.
42
- *
43
- * `Outcome` is the `Out` type a personified `Agent`/`Supervisor` is parameterized by, so the
44
- * keystone's typed `SupervisedResult<Outcome<D>>` carries it end to end with no coercion.
45
- */
46
- type Outcome<D> = {
47
- kind: 'done';
48
- deliverable: D;
49
- } | {
50
- kind: 'blocked';
51
- blockers: string[];
52
- };
53
- /**
54
- * The "act like X" record. A thin composition over the keystone's `AgentSpec`: it pairs the
55
- * root spec (the executor mapping for the root agent the shape builds) with the CONTENT a
56
- * shape consumes — the goal framing (`directive`) and who the loop is acting as (`context`).
57
- *
58
- * The framework never reads `directive`/`context` semantically; it threads them to the shape
59
- * verbatim through `ShapeContext`. This is the rule the mandate names: the FRAMEWORK is
60
- * structure, the PERSONA carries model/prompt/tools/directive. No model name, prompt, or
61
- * persona string is ever hardcoded in a shape or the engine.
62
- *
63
- * `D` is the deliverable type this persona's loops produce; it flows into `Outcome<D>`.
64
- */
65
- interface Persona<D = unknown> {
66
- /** Stable persona name — used as the trace/journal label root, never as content. */
67
- readonly name: string;
68
- /**
69
- * The root agent's executor mapping (profile + harness + optional BYO executor). The
70
- * shape's root `Agent` carries THIS as its `executorSpec`; child specs the shape spawns
71
- * are derived from / resolved against the same persona registry (see `ShapeContext`).
72
- */
73
- readonly root: AgentSpec;
74
- /** The goal framing handed to the shape — the "what to achieve", not "how". */
75
- readonly directive: string;
76
- /** Who the loop is acting as — the opaque persona context blob the shape may inject into
77
- * child tasks. Opaque to the framework; only the persona's profiles/prompts interpret it. */
78
- readonly context: PersonaContext;
79
- /**
80
- * The executor seams (router endpoint+key, sandbox client, cli bin) the built-in runtimes
81
- * read off `ExecutorContext.seams`, OR a fully pre-configured registry. The supervisor
82
- * threads an EMPTY seam bag to the root scope, so a persona that uses built-in metered
83
- * runtimes MUST supply a registry whose factories close over their seams (or BYO executors
84
- * on each `AgentSpec`). Carried here so `runPersonified` can build `SupervisorOpts.executors`.
85
- */
86
- readonly executors: PersonaExecutors;
87
- /**
88
- * Forward-compatible extension bag — a later world-model / memory / tool-budget field is an
89
- * additive key here, never a breaking change to the `Persona` shape. Opaque to the engine.
90
- */
91
- readonly extensions?: Readonly<Record<string, unknown>>;
92
- /** Phantom: binds the persona to its deliverable type so `runPersonified` infers `D` from
93
- * the persona and the chosen shape must agree. Type-only — never present at runtime. */
94
- readonly __deliverable?: D;
95
- }
96
- /** The persona context blob — who the loop is acting as. Open by intent: a persona names its
97
- * own role/audience/constraints; the framework treats it as opaque content. */
98
- interface PersonaContext {
99
- /** The role the loop embodies ("senior staff engineer", "equity research analyst", …). */
100
- readonly role: string;
101
- /** Optional freeform framing the persona's prompts/profiles consume. */
102
- readonly notes?: string;
103
- /** Open content bag — persona-specific fields a shape's child tasks may carry. */
104
- readonly [key: string]: unknown;
105
- }
106
- /**
107
- * How a persona supplies executor resolution. Either a pre-built registry (factories already
108
- * closed over their seams) OR the raw seam bag the engine uses to construct a registry +
109
- * thread the seams onto each spawn. Exactly one is required — fail loud if neither is set.
110
- */
111
- interface PersonaExecutors {
112
- /** A registry whose factories already capture their seams. Highest precedence. */
113
- readonly registry?: ExecutorRegistry;
114
- /** Raw seams to thread onto built-in runtimes (`router`/`sandbox`/`cli` keys). */
115
- readonly seams?: Readonly<Record<string, unknown>>;
116
- }
117
- /** The minimal input to build a `Persona`. Mirrors `Persona` but lets the builder default
118
- * the executors-supplied invariant check and freeze the record. */
119
- interface DefinePersonaInput<D = unknown> {
120
- readonly name: string;
121
- readonly root: AgentSpec;
122
- readonly directive: string;
123
- readonly context: PersonaContext;
124
- readonly executors: PersonaExecutors;
125
- readonly extensions?: Readonly<Record<string, unknown>>;
126
- /** Phantom: pins the input's deliverable type so `definePersona<D>` returns a `Persona<D>`
127
- * the caller's shape must agree with. Type-only — never supplied at a call site. */
128
- readonly __deliverable?: D;
129
- }
130
- /** Builds a frozen `Persona`, failing loud on the executors-supplied invariant (neither a
131
- * registry nor seams = an unresolvable persona). Pure — no I/O, no engine. */
132
- type DefinePersona = <D = unknown>(input: DefinePersonaInput<D>) => Persona<D>;
133
- /**
134
- * Budget knobs a shape reads to size its fanout/children WITHOUT owning the conserved pool.
135
- * The root budget lives on `SupervisorOpts.budget`; the shape only needs the per-child
136
- * sizing hints + the fanout width it is allowed to open. All ceilings — the pool reserves
137
- * against them and fails closed, so an over-eager shape can never overspend.
138
- */
139
- interface ShapeBudget {
140
- /** Per-child spawn budget the shape reserves for each leaf/sub-loop it opens. */
141
- readonly perChild: Budget;
142
- /** Max children a fanout step may open in one round (the shape's structural width). */
143
- readonly fanout: number;
144
- }
145
- /**
146
- * The construction context a `LoopShape` factory receives. Carries the persona's resolved
147
- * executor seams + the budget knobs, plus the ONE helper a shape needs to spawn a child
148
- * through the keystone: `spawnChild` resolves an `AgentSpec` (or a persona-derived child
149
- * profile) into an `Agent` the shape hands to `scope.spawn`. The shape never touches the
150
- * registry directly — it asks the context, keeping resolution single-sourced.
151
- */
152
- interface ShapeContext<D = unknown> {
153
- readonly persona: Persona<D>;
154
- readonly budget: ShapeBudget;
155
- /**
156
- * Wrap an `AgentSpec` into a leaf `Agent` carrying it as `executorSpec`, so the shape can
157
- * `scope.spawn(spawnChild(spec), task, opts)`. `name` labels the child for traces. The
158
- * returned agent's `act` is never invoked by the keystone (it is spawned, not run) — the
159
- * spec drives the resolved `Executor`; `act` exists only to satisfy the `Agent` shape.
160
- */
161
- spawnChild(name: string, spec: AgentSpec): Agent<unknown, Outcome<D>>;
162
- /** Derive a child `AgentSpec` from the persona's root spec with an overridden profile —
163
- * the seam a shape uses to give a worker a narrower role/prompt than the root persona. */
164
- childSpec(profile: AgentProfile, harness?: BackendType | null): AgentSpec;
165
- /** The scope analyst (selector≠judge firewall) the combinator steers from. Absent ⇒ the
166
- * dormant default (empty findings → gates read deliverables/state only). */
167
- readonly analyst?: ScopeAnalyst<D>;
168
- }
169
- /**
170
- * A reusable act-body factory. Given the persona's content + seams (`ShapeContext`), it
171
- * returns the root `Agent<Task, Outcome<D>>` whose `act` decomposes the task, fans out
172
- * children through `scope.spawn`, verifies/selects across their settlements (selector≠judge:
173
- * via `settledToIteration` + `defaultSelectWinner`, never re-ranking behind the driver), and
174
- * synthesizes the terminal `Outcome<D>`. The shape is STRUCTURE; the persona is CONTENT.
175
- */
176
- type LoopShape<Task, D> = (ctx: ShapeContext<D>) => Agent<Task, Outcome<D>>;
177
- /**
178
- * The open shape registry — the extension point that makes a new loop-shape ONE file + one
179
- * `registerShape` call with zero edits elsewhere. `resolve` returns a typed outcome (inspect
180
- * `succeeded` before `value`); `register` fails loud on a duplicate name.
181
- */
182
- interface ShapeRegistry {
183
- register<Task, D>(name: string, factory: LoopShape<Task, D>): void;
184
- resolve<Task, D>(name: string): {
185
- succeeded: true;
186
- value: LoopShape<Task, D>;
187
- } | {
188
- succeeded: false;
189
- error: string;
190
- };
191
- /** The registered shape names — for diagnostics + a fail-loud "unknown shape" message. */
192
- names(): string[];
193
- }
194
- /**
195
- * The end-to-end entrypoint. Builds the persona's root `Agent` from the chosen shape, then
196
- * runs it through a fresh `createSupervisor` over the persona's executors + the supplied
197
- * budget/journal/blobs. Returns the keystone's typed `SupervisedResult<Outcome<D>>` — a
198
- * `winner` carries the synthesized `Outcome<D>`; a `no-winner` is never coerced into one.
199
- *
200
- * `shape` is either a resolved `LoopShape` or a registered shape NAME (resolved through the
201
- * default registry). The journal/blobs default to in-memory impls in the engine when omitted
202
- * (durable FS impls are passed explicitly for a persisted run).
203
- */
204
- interface RunPersonifiedOptions<Task, D> {
205
- readonly persona: Persona<D>;
206
- /** A resolved shape factory OR a registered shape name. */
207
- readonly shape: LoopShape<Task, D> | string;
208
- readonly task: Task;
209
- readonly budget: Budget;
210
- /** Per-child sizing + fanout width handed to the shape. Defaults derive from `budget`. */
211
- readonly shapeBudget?: Partial<ShapeBudget>;
212
- /** Trace/journal root key. Defaults to the persona name + a run discriminator in the engine. */
213
- readonly runId?: string;
214
- readonly journal?: SpawnJournal;
215
- readonly blobs?: ResultBlobStore;
216
- /** Runtime recursion-depth ceiling, paired with the conserved pool. */
217
- readonly maxDepth?: number;
218
- /** OTP intensity breaker bounds, forwarded to the supervisor verbatim. */
219
- readonly maxRestarts?: number;
220
- readonly withinMs?: number;
221
- /** A live root handle to attach (view/signal/abort) before the run starts. */
222
- readonly handle?: RootHandle<Outcome<D>>;
223
- readonly now?: () => number;
224
- readonly signal?: AbortSignal;
225
- /** Optional scope analyst threaded into the shape's ShapeContext so loopUntil/widen steer
226
- * on trace-derived findings instead of the dormant empty default. */
227
- readonly analyst?: ScopeAnalyst<D>;
228
- /**
229
- * Lifecycle stream sink, forwarded to `SupervisorOpts.hooks` so the root `Scope`'s
230
- * `agent.spawn`/`agent.child` events flow to an observer (e.g. the Intelligence SDK's
231
- * trace export). Absent ⇒ no stream (the run is silent, as today).
232
- */
233
- readonly hooks?: RuntimeHooks;
234
- }
235
- /** The composed run signature. */
236
- type RunPersonified = <Task, D>(options: RunPersonifiedOptions<Task, D>) => Promise<SupervisedResult<Outcome<D>>>;
6
+ import { W as WorktreeHarnessResult, G as GitRunner, a as WorktreeCheckRunner, D as DeliverableSpec } from './completion-gate-C6dhVN-N.js';
7
+ import { L as LocalHarness, r as runLocalHarness } from './local-harness-CtK9dSny.js';
237
8
 
238
9
  /**
239
10
  *
@@ -767,6 +538,235 @@ interface EqualKOnCostOptions {
767
538
  /** `equalKOnCost(arms, opts)` — the cross-arm equal-compute check on conserved cost. */
768
539
  type EqualKOnCost = (arms: ReadonlyArray<EqualKArm>, options?: EqualKOnCostOptions) => EqualKVerdict;
769
540
 
541
+ /**
542
+ *
543
+ * The personify layer — the "act like X" knob on top of the recursive keystone.
544
+ *
545
+ * The keystone (`src/loops/supervise/`) is pure STRUCTURE: a recursive `Agent` atom inside
546
+ * a budget-conserving `Scope`, an `ExecutorRegistry` mapping an `AgentSpec` to a runtime,
547
+ * and a `Supervisor` that runs a root agent to a typed `SupervisedResult`. It carries no
548
+ * CONTENT — no model, no prompt, no goal framing, no notion of "who this loop is".
549
+ *
550
+ * This layer adds exactly that content seam without inventing a second engine:
551
+ * - A `Persona` is a thin record: the root `AgentSpec` (profile + harness + optional BYO
552
+ * executor), a root `directive` (the goal framing handed to the chosen shape), a
553
+ * `context` blob (who the loop is acting as), and the executor seams the registry needs.
554
+ * `definePersona` builds it; it is data, not behavior.
555
+ * - A `LoopShape` is a reusable act-body FACTORY: `(ctx: ShapeContext) => Agent`. The shape
556
+ * owns the STRUCTURE (how to decompose / fan out / verify / synthesize); the persona's
557
+ * content parameterizes it. A new shape is ONE file + one `registerShape` call.
558
+ * - `Outcome<D>` is the contract every shape synthesizes into: a finished deliverable OR a
559
+ * list of concrete blockers — "100% done or 100%-defined blockers", never a vague middle.
560
+ *
561
+ * Layering: this module imports ONLY keystone runtime types (`./supervise/types`) and the
562
+ * substrate `AgentProfile`/`BackendType`. It typechecks standalone — no impl, no engine.
563
+ * Extensibility is structural: `Persona` carries an open `extensions` bag so a later
564
+ * world-model / memory field is additive (a new optional key), never a breaking change.
565
+ *
566
+ * @experimental
567
+ */
568
+
569
+ /**
570
+ * The terminal contract Drew wants: a loop returns a FINISHED deliverable, or the concrete
571
+ * list of blockers that stopped it — never a half-done best-effort coercion. A `blocked`
572
+ * outcome with an empty `blockers` list is a contract violation (a shape that can't finish
573
+ * MUST name why); impls fail loud on it rather than emitting a vacuous block.
574
+ *
575
+ * `Outcome` is the `Out` type a personified `Agent`/`Supervisor` is parameterized by, so the
576
+ * keystone's typed `SupervisedResult<Outcome<D>>` carries it end to end with no coercion.
577
+ */
578
+ type Outcome<D> = {
579
+ kind: 'done';
580
+ deliverable: D;
581
+ } | {
582
+ kind: 'blocked';
583
+ blockers: string[];
584
+ };
585
+ /**
586
+ * The "act like X" record. A thin composition over the keystone's `AgentSpec`: it pairs the
587
+ * root spec (the executor mapping for the root agent the shape builds) with the CONTENT a
588
+ * shape consumes — the goal framing (`directive`) and who the loop is acting as (`context`).
589
+ *
590
+ * The framework never reads `directive`/`context` semantically; it threads them to the shape
591
+ * verbatim through `ShapeContext`. This is the rule the mandate names: the FRAMEWORK is
592
+ * structure, the PERSONA carries model/prompt/tools/directive. No model name, prompt, or
593
+ * persona string is ever hardcoded in a shape or the engine.
594
+ *
595
+ * `D` is the deliverable type this persona's loops produce; it flows into `Outcome<D>`.
596
+ */
597
+ interface Persona<D = unknown> {
598
+ /** Stable persona name — used as the trace/journal label root, never as content. */
599
+ readonly name: string;
600
+ /**
601
+ * The root agent's executor mapping (profile + harness + optional BYO executor). The
602
+ * shape's root `Agent` carries THIS as its `executorSpec`; child specs the shape spawns
603
+ * are derived from / resolved against the same persona registry (see `ShapeContext`).
604
+ */
605
+ readonly root: AgentSpec;
606
+ /** The goal framing handed to the shape — the "what to achieve", not "how". */
607
+ readonly directive: string;
608
+ /** Who the loop is acting as — the opaque persona context blob the shape may inject into
609
+ * child tasks. Opaque to the framework; only the persona's profiles/prompts interpret it. */
610
+ readonly context: PersonaContext;
611
+ /**
612
+ * The executor seams (router endpoint+key, sandbox client, cli bin) the built-in runtimes
613
+ * read off `ExecutorContext.seams`, OR a fully pre-configured registry. The supervisor
614
+ * threads an EMPTY seam bag to the root scope, so a persona that uses built-in metered
615
+ * runtimes MUST supply a registry whose factories close over their seams (or BYO executors
616
+ * on each `AgentSpec`). Carried here so `runPersonified` can build `SupervisorOpts.executors`.
617
+ */
618
+ readonly executors: PersonaExecutors;
619
+ /**
620
+ * Forward-compatible extension bag — a later world-model / memory / tool-budget field is an
621
+ * additive key here, never a breaking change to the `Persona` shape. Opaque to the engine.
622
+ */
623
+ readonly extensions?: Readonly<Record<string, unknown>>;
624
+ /** Phantom: binds the persona to its deliverable type so `runPersonified` infers `D` from
625
+ * the persona and the chosen shape must agree. Type-only — never present at runtime. */
626
+ readonly __deliverable?: D;
627
+ }
628
+ /** The persona context blob — who the loop is acting as. Open by intent: a persona names its
629
+ * own role/audience/constraints; the framework treats it as opaque content. */
630
+ interface PersonaContext {
631
+ /** The role the loop embodies ("senior staff engineer", "equity research analyst", …). */
632
+ readonly role: string;
633
+ /** Optional freeform framing the persona's prompts/profiles consume. */
634
+ readonly notes?: string;
635
+ /** Open content bag — persona-specific fields a shape's child tasks may carry. */
636
+ readonly [key: string]: unknown;
637
+ }
638
+ /**
639
+ * How a persona supplies executor resolution. Either a pre-built registry (factories already
640
+ * closed over their seams) OR the raw seam bag the engine uses to construct a registry +
641
+ * thread the seams onto each spawn. Exactly one is required — fail loud if neither is set.
642
+ */
643
+ interface PersonaExecutors {
644
+ /** A registry whose factories already capture their seams. Highest precedence. */
645
+ readonly registry?: ExecutorRegistry;
646
+ /** Raw seams to thread onto built-in runtimes (`router`/`sandbox`/`cli` keys). */
647
+ readonly seams?: Readonly<Record<string, unknown>>;
648
+ }
649
+ /** The minimal input to build a `Persona`. Mirrors `Persona` but lets the builder default
650
+ * the executors-supplied invariant check and freeze the record. */
651
+ interface DefinePersonaInput<D = unknown> {
652
+ readonly name: string;
653
+ readonly root: AgentSpec;
654
+ readonly directive: string;
655
+ readonly context: PersonaContext;
656
+ readonly executors: PersonaExecutors;
657
+ readonly extensions?: Readonly<Record<string, unknown>>;
658
+ /** Phantom: pins the input's deliverable type so `definePersona<D>` returns a `Persona<D>`
659
+ * the caller's shape must agree with. Type-only — never supplied at a call site. */
660
+ readonly __deliverable?: D;
661
+ }
662
+ /** Builds a frozen `Persona`, failing loud on the executors-supplied invariant (neither a
663
+ * registry nor seams = an unresolvable persona). Pure — no I/O, no engine. */
664
+ type DefinePersona = <D = unknown>(input: DefinePersonaInput<D>) => Persona<D>;
665
+ /**
666
+ * Budget knobs a shape reads to size its fanout/children WITHOUT owning the conserved pool.
667
+ * The root budget lives on `SupervisorOpts.budget`; the shape only needs the per-child
668
+ * sizing hints + the fanout width it is allowed to open. All ceilings — the pool reserves
669
+ * against them and fails closed, so an over-eager shape can never overspend.
670
+ */
671
+ interface ShapeBudget {
672
+ /** Per-child spawn budget the shape reserves for each leaf/sub-loop it opens. */
673
+ readonly perChild: Budget;
674
+ /** Max children a fanout step may open in one round (the shape's structural width). */
675
+ readonly fanout: number;
676
+ }
677
+ /**
678
+ * The construction context a `LoopShape` factory receives. Carries the persona's resolved
679
+ * executor seams + the budget knobs, plus the ONE helper a shape needs to spawn a child
680
+ * through the keystone: `spawnChild` resolves an `AgentSpec` (or a persona-derived child
681
+ * profile) into an `Agent` the shape hands to `scope.spawn`. The shape never touches the
682
+ * registry directly — it asks the context, keeping resolution single-sourced.
683
+ */
684
+ interface ShapeContext<D = unknown> {
685
+ readonly persona: Persona<D>;
686
+ readonly budget: ShapeBudget;
687
+ /**
688
+ * Wrap an `AgentSpec` into a leaf `Agent` carrying it as `executorSpec`, so the shape can
689
+ * `scope.spawn(spawnChild(spec), task, opts)`. `name` labels the child for traces. The
690
+ * returned agent's `act` is never invoked by the keystone (it is spawned, not run) — the
691
+ * spec drives the resolved `Executor`; `act` exists only to satisfy the `Agent` shape.
692
+ */
693
+ spawnChild(name: string, spec: AgentSpec): Agent<unknown, Outcome<D>>;
694
+ /** Derive a child `AgentSpec` from the persona's root spec with an overridden profile —
695
+ * the seam a shape uses to give a worker a narrower role/prompt than the root persona. */
696
+ childSpec(profile: AgentProfile, harness?: BackendType | null): AgentSpec;
697
+ /** The scope analyst (selector≠judge firewall) the combinator steers from. Absent ⇒ the
698
+ * dormant default (empty findings → gates read deliverables/state only). */
699
+ readonly analyst?: ScopeAnalyst<D>;
700
+ }
701
+ /**
702
+ * A reusable act-body factory. Given the persona's content + seams (`ShapeContext`), it
703
+ * returns the root `Agent<Task, Outcome<D>>` whose `act` decomposes the task, fans out
704
+ * children through `scope.spawn`, verifies/selects across their settlements (selector≠judge:
705
+ * via `settledToIteration` + `defaultSelectWinner`, never re-ranking behind the driver), and
706
+ * synthesizes the terminal `Outcome<D>`. The shape is STRUCTURE; the persona is CONTENT.
707
+ */
708
+ type LoopShape<Task, D> = (ctx: ShapeContext<D>) => Agent<Task, Outcome<D>>;
709
+ /**
710
+ * The open shape registry — the extension point that makes a new loop-shape ONE file + one
711
+ * `registerShape` call with zero edits elsewhere. `resolve` returns a typed outcome (inspect
712
+ * `succeeded` before `value`); `register` fails loud on a duplicate name.
713
+ */
714
+ interface ShapeRegistry {
715
+ register<Task, D>(name: string, factory: LoopShape<Task, D>): void;
716
+ resolve<Task, D>(name: string): {
717
+ succeeded: true;
718
+ value: LoopShape<Task, D>;
719
+ } | {
720
+ succeeded: false;
721
+ error: string;
722
+ };
723
+ /** The registered shape names — for diagnostics + a fail-loud "unknown shape" message. */
724
+ names(): string[];
725
+ }
726
+ /**
727
+ * The end-to-end entrypoint. Builds the persona's root `Agent` from the chosen shape, then
728
+ * runs it through a fresh `createSupervisor` over the persona's executors + the supplied
729
+ * budget/journal/blobs. Returns the keystone's typed `SupervisedResult<Outcome<D>>` — a
730
+ * `winner` carries the synthesized `Outcome<D>`; a `no-winner` is never coerced into one.
731
+ *
732
+ * `shape` is either a resolved `LoopShape` or a registered shape NAME (resolved through the
733
+ * default registry). The journal/blobs default to in-memory impls in the engine when omitted
734
+ * (durable FS impls are passed explicitly for a persisted run).
735
+ */
736
+ interface RunPersonifiedOptions<Task, D> {
737
+ readonly persona: Persona<D>;
738
+ /** A resolved shape factory OR a registered shape name. */
739
+ readonly shape: LoopShape<Task, D> | string;
740
+ readonly task: Task;
741
+ readonly budget: Budget;
742
+ /** Per-child sizing + fanout width handed to the shape. Defaults derive from `budget`. */
743
+ readonly shapeBudget?: Partial<ShapeBudget>;
744
+ /** Trace/journal root key. Defaults to the persona name + a run discriminator in the engine. */
745
+ readonly runId?: string;
746
+ readonly journal?: SpawnJournal;
747
+ readonly blobs?: ResultBlobStore;
748
+ /** Runtime recursion-depth ceiling, paired with the conserved pool. */
749
+ readonly maxDepth?: number;
750
+ /** OTP intensity breaker bounds, forwarded to the supervisor verbatim. */
751
+ readonly maxRestarts?: number;
752
+ readonly withinMs?: number;
753
+ /** A live root handle to attach (view/signal/abort) before the run starts. */
754
+ readonly handle?: RootHandle<Outcome<D>>;
755
+ readonly now?: () => number;
756
+ readonly signal?: AbortSignal;
757
+ /** Optional scope analyst threaded into the shape's ShapeContext so loopUntil/widen steer
758
+ * on trace-derived findings instead of the dormant empty default. */
759
+ readonly analyst?: ScopeAnalyst<D>;
760
+ /**
761
+ * Lifecycle stream sink, forwarded to `SupervisorOpts.hooks` so the root `Scope`'s
762
+ * `agent.spawn`/`agent.child` events flow to an observer (e.g. the Intelligence SDK's
763
+ * trace export). Absent ⇒ no stream (the run is silent, as today).
764
+ */
765
+ readonly hooks?: RuntimeHooks;
766
+ }
767
+ /** The composed run signature. */
768
+ type RunPersonified = <Task, D>(options: RunPersonifiedOptions<Task, D>) => Promise<SupervisedResult<Outcome<D>>>;
769
+
770
770
  /**
771
771
  *
772
772
  * The mechanical patch gate — the SINGLE source of the no-op / always-on secret-path floor /
@@ -984,4 +984,4 @@ interface WorktreeFanoutOptions extends PatchDeliverableOptions {
984
984
  */
985
985
  declare function worktreeFanout<Task>(options: WorktreeFanoutOptions): CombinatorShape<Task, WorktreePatchArtifact>;
986
986
 
987
- export { type Widen as $, type AuthoredHarness as A, type Panel as B, type CorpusRecord as C, type DefinePersonaInput as D, type EqualKArm as E, type FanoutOptions as F, type PanelJudge as G, type PanelVerdict as H, type PatchDeliverableOptions as I, type PersonaContext as J, type PersonaExecutors as K, type LoopUntilSpec as L, type Pipeline as M, type RenderCorpusToInstructions as N, type Outcome as O, type PanelSpec as P, type RunPersonified as Q, type RenderCorpusToInstructionsOptions as R, type ScopeAnalyzeInput as S, type TrajectoryReportOptions as T, type ShapeBudget as U, type VerifySpec as V, type WinnerStrategy as W, type ShapeContext as X, type TrajectoryNode as Y, type TrajectoryReportFn as Z, type Verify as _, type WorktreeFanoutOptions as a, type WidenDecision as a0, type WidenLineage as a1, type WorktreeCliExecutorOptions as a2, createWorktreeCliExecutor as a3, patchDelivered as a4, worktreeFanout as a5, type WorktreePatchArtifact as b, type Corpus as c, type AssertTraceDerivedFindings as d, type SteerContext as e, type ScopeAnalyst as f, type CombinatorShape as g, type ScopeWidenGate as h, type PipelineStage as i, type FanoutWinnerSelector as j, type WidenSpec as k, type CorpusFilter as l, type Persona as m, type RunPersonifiedOptions as n, type ShapeRegistry as o, type LoopShape as p, type EqualKOnCostOptions as q, type EqualKVerdict as r, type TrajectoryReport as s, type DefinePersona as t, type EqualKOnCost as u, type Fanout as v, type FanoutSynthesis as w, type FlatWidenGate as x, type LoopUntil as y, type LoopUntilState as z };
987
+ export { type Widen as $, type AuthoredHarness as A, type Panel as B, type Corpus as C, type DefinePersonaInput as D, type EqualKArm as E, type FanoutOptions as F, type PanelJudge as G, type PanelVerdict as H, type PatchDeliverableOptions as I, type PersonaContext as J, type PersonaExecutors as K, type LoopUntilSpec as L, type Pipeline as M, type RenderCorpusToInstructions as N, type Outcome as O, type PanelSpec as P, type RunPersonified as Q, type RenderCorpusToInstructionsOptions as R, type ScopeAnalyzeInput as S, type TrajectoryReportOptions as T, type ShapeBudget as U, type VerifySpec as V, type WinnerStrategy as W, type ShapeContext as X, type TrajectoryNode as Y, type TrajectoryReportFn as Z, type Verify as _, type WorktreeFanoutOptions as a, type WidenDecision as a0, type WidenLineage as a1, type WorktreeCliExecutorOptions as a2, createWorktreeCliExecutor as a3, patchDelivered as a4, worktreeFanout as a5, type WorktreePatchArtifact as b, type CorpusRecord as c, type AssertTraceDerivedFindings as d, type SteerContext as e, type ScopeAnalyst as f, type CombinatorShape as g, type ScopeWidenGate as h, type PipelineStage as i, type FanoutWinnerSelector as j, type WidenSpec as k, type CorpusFilter as l, type Persona as m, type RunPersonifiedOptions as n, type ShapeRegistry as o, type LoopShape as p, type EqualKOnCostOptions as q, type EqualKVerdict as r, type TrajectoryReport as s, type DefinePersona as t, type EqualKOnCost as u, type Fanout as v, type FanoutSynthesis as w, type FlatWidenGate as x, type LoopUntil as y, type LoopUntilState as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-runtime",
3
- "version": "0.101.1",
3
+ "version": "0.102.1",
4
4
  "description": "Shared task-lifecycle skeleton for agents: a recursive loop kernel for chat turns, one-shot tasks, and multi-attempt loops, with trace capture and eval-gated self-improvement. Domain behavior lives in adapters; scoring and ship-gates in @tangle-network/agent-eval.",
5
5
  "homepage": "https://github.com/tangle-network/agent-runtime#readme",
6
6
  "repository": {
@@ -87,6 +87,7 @@
87
87
  },
88
88
  "bin": {
89
89
  "agent-runtime-mcp": "./dist/mcp/bin.js",
90
+ "agent-runtime-memory-mcp": "./dist/mcp/memory-bin.js",
90
91
  "agent-runtime-loop": "./dist/loop-runner-bin.js"
91
92
  },
92
93
  "files": [
@@ -120,8 +121,8 @@
120
121
  },
121
122
  "devDependencies": {
122
123
  "@biomejs/biome": "^2.4.15",
123
- "@tangle-network/agent-eval": "0.122.8",
124
- "@tangle-network/agent-interface": "0.31.0",
124
+ "@tangle-network/agent-eval": "0.123.0",
125
+ "@tangle-network/agent-interface": "0.32.0",
125
126
  "@tangle-network/sandbox": "^0.11.1",
126
127
  "@types/node": "^25.9.3",
127
128
  "@types/tar-stream": "3.1.4",
@@ -152,8 +153,8 @@
152
153
  "license": "MIT",
153
154
  "packageManager": "pnpm@10.28.0",
154
155
  "peerDependencies": {
155
- "@tangle-network/agent-eval": ">=0.122.8 <0.123.0",
156
- "@tangle-network/agent-interface": ">=0.31.0 <0.32.0",
156
+ "@tangle-network/agent-eval": ">=0.122.8 <0.124.0",
157
+ "@tangle-network/agent-interface": ">=0.32.0 <0.33.0",
157
158
  "@tangle-network/sandbox": ">=0.11.1 <1.0.0",
158
159
  "playwright": "^1.40.0"
159
160
  },