@tangle-network/agent-runtime 0.102.2 → 0.103.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.
- package/README.md +73 -10
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +5 -5
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/candidate-execution/index.d.ts +5 -41
- package/dist/candidate-execution/index.js +8 -6
- package/dist/{chunk-QCXD7NHM.js → chunk-3LJF5XSE.js} +79 -334
- package/dist/chunk-3LJF5XSE.js.map +1 -0
- package/dist/{chunk-3DW5DEKQ.js → chunk-5AITUUHO.js} +3 -3
- package/dist/{chunk-SQ3ZJH3Y.js → chunk-6WZZXQV5.js} +467 -23
- package/dist/chunk-6WZZXQV5.js.map +1 -0
- package/dist/{chunk-SCOHHMKU.js → chunk-AAN2MB2X.js} +3 -3
- package/dist/{chunk-KSM6GFHP.js → chunk-B7K7V22Y.js} +2 -2
- package/dist/{chunk-ZUCUAFVF.js → chunk-EAQ5YRRY.js} +1382 -62
- package/dist/chunk-EAQ5YRRY.js.map +1 -0
- package/dist/chunk-ISPWRSEC.js +408 -0
- package/dist/chunk-ISPWRSEC.js.map +1 -0
- package/dist/{chunk-7FJJUC73.js → chunk-LFM4JBRW.js} +29 -6
- package/dist/{chunk-7FJJUC73.js.map → chunk-LFM4JBRW.js.map} +1 -1
- package/dist/{chunk-ROILMKDL.js → chunk-QYCKIV6C.js} +3 -3
- package/dist/{chunk-LJLG734E.js → chunk-SBTWKPVR.js} +10 -11
- package/dist/{chunk-LJLG734E.js.map → chunk-SBTWKPVR.js.map} +1 -1
- package/dist/{chunk-CK76OZPM.js → chunk-SNSMRT6H.js} +56 -386
- package/dist/chunk-SNSMRT6H.js.map +1 -0
- package/dist/{chunk-EKUMRQNR.js → chunk-TUSOOIDV.js} +2 -2
- package/dist/{chunk-J6V6DWWS.js → chunk-ZOYN3JR5.js} +5 -5
- package/dist/{chunk-377GOJHJ.js → chunk-ZXICDSAK.js} +333 -4
- package/dist/chunk-ZXICDSAK.js.map +1 -0
- package/dist/{completion-gate-C6dhVN-N.d.ts → completion-gate-DLINnrkM.d.ts} +1 -1
- package/dist/{coordination-D9l_YmwW.d.ts → coordination-DTehA977.d.ts} +250 -8
- package/dist/environment-provider.d.ts +2 -2
- package/dist/index.d.ts +12 -12
- package/dist/index.js +17 -15
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +26 -8
- package/dist/intelligence.js +24 -7
- package/dist/intelligence.js.map +1 -1
- package/dist/knowledge.d.ts +6 -6
- package/dist/knowledge.js +9 -9
- package/dist/{loop-runner-bin-PnWslIw4.d.ts → loop-runner-bin-DhIXsLAd.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +5 -5
- package/dist/loop-runner-bin.js +6 -6
- package/dist/loops.d.ts +305 -148
- package/dist/loops.js +82 -14
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +6 -6
- package/dist/mcp/index.js +6 -6
- package/dist/profiles.d.ts +1 -1
- package/dist/{profile-DbfaMTdk.d.ts → protected-model-port-DzkUY3HQ.d.ts} +41 -3
- package/dist/{structural-rollout-D7xik9XR.d.ts → structural-rollout-BFPIy3iw.d.ts} +3 -3
- package/dist/supervise-Cp8bNcJi.d.ts +379 -0
- package/dist/testing.js +10 -10
- package/dist/testing.js.map +1 -1
- package/dist/{types-CWqfCO8s.d.ts → types-Cbp72qyu.d.ts} +1 -1
- package/dist/{types-CLat4bT9.d.ts → types-DK11_O4L.d.ts} +1 -1
- package/dist/types-lZTE_LBd.d.ts +957 -0
- package/dist/{worktree-fanout-DsIR4d6w.d.ts → worktree-fanout-DiiJWjJO.d.ts} +17 -5
- package/package.json +5 -4
- package/skills/build-with-agent-runtime/SKILL.md +7 -5
- package/skills/generate-eval/SKILL.md +45 -52
- package/skills/loop-writer/SKILL.md +79 -147
- package/skills/supervise/SKILL.md +33 -14
- package/dist/chunk-377GOJHJ.js.map +0 -1
- package/dist/chunk-CK76OZPM.js.map +0 -1
- package/dist/chunk-IMSNJSXH.js +0 -73
- package/dist/chunk-IMSNJSXH.js.map +0 -1
- package/dist/chunk-QCXD7NHM.js.map +0 -1
- package/dist/chunk-SQ3ZJH3Y.js.map +0 -1
- package/dist/chunk-ZUCUAFVF.js.map +0 -1
- package/dist/supervise-BQdNAXtK.d.ts +0 -131
- package/dist/types-D870JlH0.d.ts +0 -500
- /package/dist/{chunk-3DW5DEKQ.js.map → chunk-5AITUUHO.js.map} +0 -0
- /package/dist/{chunk-SCOHHMKU.js.map → chunk-AAN2MB2X.js.map} +0 -0
- /package/dist/{chunk-KSM6GFHP.js.map → chunk-B7K7V22Y.js.map} +0 -0
- /package/dist/{chunk-ROILMKDL.js.map → chunk-QYCKIV6C.js.map} +0 -0
- /package/dist/{chunk-EKUMRQNR.js.map → chunk-TUSOOIDV.js.map} +0 -0
- /package/dist/{chunk-J6V6DWWS.js.map → chunk-ZOYN3JR5.js.map} +0 -0
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { S as Scope, a as ResultBlobStore, B as Budget, A as Agent, b as SupervisedResult } from './types-D870JlH0.js';
|
|
2
|
-
import { M as MakeWorkerAgent, A as AnalystRegistry, E as ExecutorConfig } from './coordination-D9l_YmwW.js';
|
|
3
|
-
import { R as RouterConfig, T as ToolLoopChat, a as ToolLoopCompactionOptions } from './sanitize-DEbPNtyI.js';
|
|
4
|
-
import { D as DeliverableSpec } from './completion-gate-C6dhVN-N.js';
|
|
5
|
-
|
|
6
|
-
/** The supervisor's profile — the subset of an `AgentProfile` that selects + shapes its brain.
|
|
7
|
-
* `harness` is the backend-as-data discriminant; `systemPrompt` is the standing instruction. */
|
|
8
|
-
interface SupervisorProfile {
|
|
9
|
-
readonly name?: string;
|
|
10
|
-
/** null/undefined → router brain (in-process tool-loop); a coding-CLI harness → sandboxed brain. */
|
|
11
|
-
readonly harness?: string | null;
|
|
12
|
-
/** The router model when the brain is router-driven (falls back to the deps router config). */
|
|
13
|
-
readonly model?: string;
|
|
14
|
-
/** The standing instructions ("you delegate, you do not solve"). */
|
|
15
|
-
readonly systemPrompt?: string;
|
|
16
|
-
}
|
|
17
|
-
/** How to run a sandboxed harness as the DRIVER, with the coordination verbs mounted — the substrate
|
|
18
|
-
* seam the caller supplies (mirrors `makeWorkerAgent` for spawned children). It runs `profile` on
|
|
19
|
-
* `task` in its backend (sandbox / cli-bridge) with `coordinationMcpUrl` mounted as an MCP server,
|
|
20
|
-
* so the harness calls spawn_agent / await_event / stop as native tools over the live scope. */
|
|
21
|
-
type DriveHarness = (args: {
|
|
22
|
-
readonly profile: SupervisorProfile;
|
|
23
|
-
readonly task: unknown;
|
|
24
|
-
readonly scope: Scope<unknown>;
|
|
25
|
-
readonly coordinationMcpUrl: string;
|
|
26
|
-
}) => Promise<void>;
|
|
27
|
-
interface SupervisorAgentDeps {
|
|
28
|
-
readonly blobs: ResultBlobStore;
|
|
29
|
-
/** Resolve a spawned worker `profile` to a leaf agent — the recursion seam (same for both arms). */
|
|
30
|
-
readonly makeWorkerAgent: MakeWorkerAgent;
|
|
31
|
-
/** Per-child budget reserved from the conserved pool on each spawn. */
|
|
32
|
-
readonly perWorker: Budget;
|
|
33
|
-
/** Hard cap on simultaneously-LIVE workers across both arms — `spawn_agent` fails closed once
|
|
34
|
-
* this many are in flight (a concurrency fence on top of the conserved-pool fence; bounds live
|
|
35
|
-
* boxes/sandboxes, not total work). Omit/`<= 0` = no cap. */
|
|
36
|
-
readonly maxLiveWorkers?: number;
|
|
37
|
-
/** Router substrate for a router-brained supervisor (`harness` null). The profile's model wins. */
|
|
38
|
-
readonly router?: RouterConfig;
|
|
39
|
-
/** Inject the brain directly (tests / advanced) instead of resolving `routerBrain` from the profile. */
|
|
40
|
-
readonly brain?: ToolLoopChat;
|
|
41
|
-
/** Required for a sandboxed-harness supervisor (`harness` set): runs the harness as the driver. */
|
|
42
|
-
readonly driveHarness?: DriveHarness;
|
|
43
|
-
/** WORK tools the supervisor may call DIRECTLY (router arm) — so it can do simple work ITSELF and
|
|
44
|
-
* only delegate when it needs parallelism. Pair with `executeExtraTool`. */
|
|
45
|
-
readonly extraTools?: ReadonlyArray<{
|
|
46
|
-
readonly name: string;
|
|
47
|
-
readonly description?: string;
|
|
48
|
-
readonly parameters: Record<string, unknown>;
|
|
49
|
-
}>;
|
|
50
|
-
/** Runs an `extraTools` call; null/undefined falls through to the coordination dispatch. */
|
|
51
|
-
readonly executeExtraTool?: (name: string, args: Record<string, unknown>) => Promise<string | null | undefined>;
|
|
52
|
-
/** Analyst lenses available to the driver (both arms). Required for `analyzeOnSettle`. */
|
|
53
|
-
readonly analysts?: AnalystRegistry;
|
|
54
|
-
/** Analyst kinds run on each worker-settle → a `finding` the driver composes its next steer from
|
|
55
|
-
* (the self-improving UP-leg). Unset/empty = status quo (no analyst feed). Requires `analysts`. */
|
|
56
|
-
readonly analyzeOnSettle?: ReadonlyArray<string>;
|
|
57
|
-
readonly maxTurns?: number;
|
|
58
|
-
/** Give the supervisor brain a chapter-lifecycle on its OWN context window (router arm only) — it
|
|
59
|
-
* distills its coordination transcript to a compact progress note once it exceeds the threshold,
|
|
60
|
-
* instead of re-billing the whole thing every turn. See `DriverAgentOptions.compaction`. */
|
|
61
|
-
readonly compaction?: ToolLoopCompactionOptions;
|
|
62
|
-
}
|
|
63
|
-
/** Build a supervisor `Agent` from its profile: the brain resolves from `profile.harness` (backend-as-data), the same resolution rule as every worker. */
|
|
64
|
-
declare function supervisorAgent(profile: SupervisorProfile, deps: SupervisorAgentDeps): Agent<unknown, unknown>;
|
|
65
|
-
|
|
66
|
-
/** Build the worker seam from a backend (WHERE workers run) + an optional completion oracle (the
|
|
67
|
-
* deliverable check that makes "settled ⟺ delivered" true — the guard against "ran but didn't
|
|
68
|
-
* deliver"). The ONE place a backend becomes a spawnable worker. */
|
|
69
|
-
declare function workerFromBackend(backend: ExecutorConfig, deliverable?: DeliverableSpec<unknown>): MakeWorkerAgent;
|
|
70
|
-
interface SuperviseOptions {
|
|
71
|
-
/** The conserved compute pool for the whole run. */
|
|
72
|
-
readonly budget: Budget;
|
|
73
|
-
/** WHERE workers run — derives the worker seam. Provide this OR an explicit `makeWorkerAgent`. */
|
|
74
|
-
readonly backend?: ExecutorConfig;
|
|
75
|
-
/** The completion oracle for backend-derived workers (settled ⟺ delivered). Strongly recommended:
|
|
76
|
-
* without it the supervisor trusts a worker's self-report — exactly the "ran but didn't deliver"
|
|
77
|
-
* failure mode of a static orchestrator. */
|
|
78
|
-
readonly deliverable?: DeliverableSpec<unknown>;
|
|
79
|
-
/** Override the worker seam directly (tests / advanced) instead of deriving it from `backend`. */
|
|
80
|
-
readonly makeWorkerAgent?: MakeWorkerAgent;
|
|
81
|
-
/** The supervisor's router substrate (`harness` null). The profile's model wins. */
|
|
82
|
-
readonly router?: RouterConfig;
|
|
83
|
-
/** Inject the supervisor brain directly (tests / advanced). */
|
|
84
|
-
readonly brain?: ToolLoopChat;
|
|
85
|
-
/** Run a sandboxed-harness supervisor (`harness` set). */
|
|
86
|
-
readonly driveHarness?: DriveHarness;
|
|
87
|
-
/** WORK tools the supervisor may call DIRECTLY — so a recursive atom can ACT (do simple work
|
|
88
|
-
* itself) OR SPAWN (delegate when it needs parallelism), not be a pure manager. Pair with
|
|
89
|
-
* `executeExtraTool`. Router arm only (`harness` null). */
|
|
90
|
-
readonly extraTools?: ReadonlyArray<{
|
|
91
|
-
readonly name: string;
|
|
92
|
-
readonly description?: string;
|
|
93
|
-
readonly parameters: Record<string, unknown>;
|
|
94
|
-
}>;
|
|
95
|
-
/** Runs an `extraTools` call; null/undefined falls through to the coordination dispatch. */
|
|
96
|
-
readonly executeExtraTool?: (name: string, args: Record<string, unknown>) => Promise<string | null | undefined>;
|
|
97
|
-
/** Per-child budget reserved on each spawn. Defaults to a quarter of the pool's tokens. */
|
|
98
|
-
readonly perWorker?: Budget;
|
|
99
|
-
/** Hard cap on simultaneously-LIVE workers — `spawn_agent` fails closed once this many are in
|
|
100
|
-
* flight. The conserved pool bounds TOTAL work; this bounds SIMULTANEOUS work (live boxes/
|
|
101
|
-
* sandboxes a real fleet runs at once). Omit/`<= 0` = no cap (the pool stays the only fence). */
|
|
102
|
-
readonly maxLiveWorkers?: number;
|
|
103
|
-
/** Analyst lenses available to the driver. Required for `analyzeOnSettle`. Unset → status quo
|
|
104
|
-
* (the driver receives settled worker outputs, no analyst findings). */
|
|
105
|
-
readonly analysts?: AnalystRegistry;
|
|
106
|
-
/** Analyst kind ids run AUTOMATICALLY when a worker settles `done` — each re-enters as a `finding`
|
|
107
|
-
* the driver pulls (`await_event`) and composes its next steer from. The self-improving UP-leg,
|
|
108
|
-
* threaded to the driver at this level (propagate to sub-drivers via a recursive `makeWorkerAgent`).
|
|
109
|
-
* Omit/empty = status quo (no analyst feed). Requires `analysts`. */
|
|
110
|
-
readonly analyzeOnSettle?: ReadonlyArray<string>;
|
|
111
|
-
/** Worker output store. Defaults to in-memory. */
|
|
112
|
-
readonly blobs?: ResultBlobStore;
|
|
113
|
-
readonly maxDepth?: number;
|
|
114
|
-
readonly maxTurns?: number;
|
|
115
|
-
/** Give the supervisor brain a chapter-lifecycle on its OWN context window (router arm only): once
|
|
116
|
-
* its coordination transcript exceeds `thresholdTokens` it distills to a compact progress note and
|
|
117
|
-
* continues, instead of re-billing the whole transcript every turn (the cost that makes the LLM-brain
|
|
118
|
-
* front door lose to a dumb-Ralph respawn). The live `Scope` roster is the durable state across
|
|
119
|
-
* chapters. Default off. `distill` defaults to a brain self-summary + the settled-worker roster. */
|
|
120
|
-
readonly compaction?: ToolLoopCompactionOptions;
|
|
121
|
-
readonly runId?: string;
|
|
122
|
-
readonly now?: () => number;
|
|
123
|
-
/** Restrict the run to this subset of models. When set, every configured model — the
|
|
124
|
-
* supervisor router model, the profile's model, and the backend's model — must be a member,
|
|
125
|
-
* or `supervise()` throws a `ConfigError` before any compute is spent. Unset = unrestricted. */
|
|
126
|
-
readonly allowedModels?: readonly string[];
|
|
127
|
-
}
|
|
128
|
-
/** One-call supervisor: build + run a supervisor from its profile with sensible defaults; the raw `supervisorAgent` + `createSupervisor().run` seams stay available for power use. */
|
|
129
|
-
declare function supervise(profile: SupervisorProfile, task: unknown, opts: SuperviseOptions): Promise<SupervisedResult<unknown>>;
|
|
130
|
-
|
|
131
|
-
export { type DriveHarness as D, type SupervisorProfile as S, type SuperviseOptions as a, type SupervisorAgentDeps as b, supervisorAgent as c, supervise as s, workerFromBackend as w };
|
package/dist/types-D870JlH0.d.ts
DELETED
|
@@ -1,500 +0,0 @@
|
|
|
1
|
-
import { DefaultVerdict } from '@tangle-network/agent-eval';
|
|
2
|
-
import { AgentProfile } from '@tangle-network/agent-interface';
|
|
3
|
-
import { BackendType } from '@tangle-network/sandbox';
|
|
4
|
-
import { L as LoopTokenUsage, R as RuntimeHooks } from './types-CLat4bT9.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* Recursive execution atom — the FROZEN type surface (the keystone contract).
|
|
9
|
-
*
|
|
10
|
-
* One self-similar `Agent` atom runs inside a budget-conserving reactive `Scope`,
|
|
11
|
-
* orchestrated by a `Supervisor` over an event-sourced `SpawnJournal`. A leaf is an
|
|
12
|
-
* `Agent` that never calls `scope.spawn`; a driver is an `Agent` that spawns and runs
|
|
13
|
-
* a policy over its children's streaming results.
|
|
14
|
-
*
|
|
15
|
-
* Two invariants the surface exists to make enforceable:
|
|
16
|
-
* - Budget is an atomically-reserved CONSERVED pool, so `Σk(treatment) ≡ Σk(blind)` by
|
|
17
|
-
* construction (reserve-on-spawn, refund-unspent-on-settle, fail-closed admission).
|
|
18
|
-
* - The journal records a content-addressed `outRef` per child result, so replay
|
|
19
|
-
* rehydrates the exact `Settled` the driver branched on (the replay invariant below).
|
|
20
|
-
*
|
|
21
|
-
* The leaf RUNTIME is one OPEN `Executor` interface, not a closed `inline|sandbox|cli`
|
|
22
|
-
* union the call site switches on. The built-ins (router/inline, sandbox, cli) are the
|
|
23
|
-
* initial IMPLEMENTATIONS; any user agent is first-class the moment it implements the
|
|
24
|
-
* interface. The interface IS the extension point — no per-vendor adapters live here.
|
|
25
|
-
*
|
|
26
|
-
* Layering: substrate types (`DefaultVerdict`) come from `@tangle-network/agent-eval`;
|
|
27
|
-
* runtime-shaped types (everything else) live here. Pure types/interfaces only — this
|
|
28
|
-
* module typechecks standalone and is imported by every keystone impl.
|
|
29
|
-
*
|
|
30
|
-
* @experimental
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* One self-similar atom. A leaf is an `Agent` that never calls `scope.spawn`; a driver
|
|
35
|
-
* is an `Agent` whose `act` spawns children and reacts to them via `scope.next()`. An
|
|
36
|
-
* analyst is an `Agent` whose task is "read these traces → findings" — `where` it runs
|
|
37
|
-
* is its executor, not a separate type.
|
|
38
|
-
*
|
|
39
|
-
* `act` MUST be replay-safe: it may read `verdict`, `spent`, and `out` (rehydrated by
|
|
40
|
-
* `outRef`) off each `Settled`; it MUST NOT read `Date.now`, `Math.random`, or any
|
|
41
|
-
* unordered collection. `scope.next()` delivers strictly in recorded `seq` order.
|
|
42
|
-
*/
|
|
43
|
-
interface Agent<Task, Out> {
|
|
44
|
-
readonly name: string;
|
|
45
|
-
act(task: Task, scope: Scope<Out>): Promise<Out>;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* The leaf runtime — ONE open interface, not a closed union. `execute` returns a
|
|
49
|
-
* `Promise<ExecutorResult>` for one-shot executors OR an `AsyncIterable<UsageEvent>` for
|
|
50
|
-
* streaming ones; a streaming executor reports incremental normalized usage as it runs
|
|
51
|
-
* (the budget pool reconciles against it) and exposes its terminal artifact via
|
|
52
|
-
* `resultArtifact()`. Both shapes normalize usage to `UsageEvent` so the conserved pool
|
|
53
|
-
* meters every runtime identically.
|
|
54
|
-
*
|
|
55
|
-
* Built-in implementations (in `runtime.ts`, NOT variants here): router/inline (a direct
|
|
56
|
-
* Router/HTTP inference call, no box), sandbox (COMPOSES `runLoop` as a leaf, forwarding
|
|
57
|
-
* PR #150's optional `lineage` passthrough — does NOT reinvent checkpoint/fork), cli
|
|
58
|
-
* (Halo/RLM subprocess; `budgetExempt`, excluded from equal-k by construction). A user's
|
|
59
|
-
* own agent (mastra/agno/raw HTTP/anything) is first-class by implementing this interface.
|
|
60
|
-
*/
|
|
61
|
-
interface Executor<Out> {
|
|
62
|
-
/** Stable runtime tag for traces + the equal-k exemption check. */
|
|
63
|
-
readonly runtime: Runtime;
|
|
64
|
-
/**
|
|
65
|
-
* When true, this executor's spend is NOT metered against the conserved pool and its
|
|
66
|
-
* iterations are excluded from the equal-k assertion (a `cli` subprocess without
|
|
67
|
-
* token accounting). Fail-loud everywhere else: a metered executor MUST report usage.
|
|
68
|
-
*/
|
|
69
|
-
readonly budgetExempt?: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* One-shot → resolves a `ExecutorResult`; streaming → yields incremental `UsageEvent`s and
|
|
72
|
-
* the terminal artifact is read from `resultArtifact()` after the stream drains.
|
|
73
|
-
* `signal` is the spawn-scoped abort (chains the acquire lifecycle for sandbox).
|
|
74
|
-
*/
|
|
75
|
-
execute(task: unknown, signal: AbortSignal): Promise<ExecutorResult<Out>> | AsyncIterable<UsageEvent>;
|
|
76
|
-
/**
|
|
77
|
-
* Optional inbox: receive an out-of-band message from the driver mid-run (the `send`/`steer_agent`
|
|
78
|
-
* verb). A streaming executor drains pending messages between turns and folds them into the next
|
|
79
|
-
* step (a steer / interrupt / resume). A one-shot executor that can't be steered mid-flight omits
|
|
80
|
-
* this; `Scope.send` then returns `false` for it. Never throws — a malformed message is the
|
|
81
|
-
* executor's to ignore.
|
|
82
|
-
*/
|
|
83
|
-
deliver?(msg: unknown): void;
|
|
84
|
-
/**
|
|
85
|
-
* Tear the executor's resources down. `grace` mirrors the OTP shutdown spec
|
|
86
|
-
* (`'brutalKill'` = immediate, a number = ms grace, `'infinity'` = await clean exit).
|
|
87
|
-
*/
|
|
88
|
-
teardown(grace: number | 'brutalKill' | 'infinity'): Promise<{
|
|
89
|
-
destroyed: boolean;
|
|
90
|
-
}>;
|
|
91
|
-
/**
|
|
92
|
-
* The replay source (B1): the content-addressed `outRef` + the materialized output the
|
|
93
|
-
* driver branched on, its verdict, and the conserved spend. Read once, after settle.
|
|
94
|
-
*/
|
|
95
|
-
resultArtifact(): {
|
|
96
|
-
outRef: string;
|
|
97
|
-
out: Out;
|
|
98
|
-
verdict?: DefaultVerdict;
|
|
99
|
-
spent: Spend;
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* A driver-executor's OWN-inference subtree total (rolled up from its nested tree's `metered`
|
|
103
|
-
* events) — the parent scope journals it as a `metered` event for this node on settle, on BOTH
|
|
104
|
-
* the done AND the down/crash paths, so a crashed sub-driver's partial inference still re-homes
|
|
105
|
-
* (the pool already debited it via `observe`; the journal must match). NOT reconciled, so it never
|
|
106
|
-
* trips the reservation clamp. Read on settle, valid after `execute` resolves OR throws. Leaf
|
|
107
|
-
* executors omit it (returns `undefined`).
|
|
108
|
-
*/
|
|
109
|
-
metered?(): Spend | undefined;
|
|
110
|
-
}
|
|
111
|
-
/** Terminal artifact of a one-shot `Executor.execute`. */
|
|
112
|
-
interface ExecutorResult<Out> {
|
|
113
|
-
outRef: string;
|
|
114
|
-
out: Out;
|
|
115
|
-
verdict?: DefaultVerdict;
|
|
116
|
-
spent: Spend;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Normalized usage event — the single channel every executor reports through, so the
|
|
120
|
-
* conserved pool meters all runtimes identically. `tokens` carries `LoopTokenUsage`'s
|
|
121
|
-
* `{ input, output }`; `usd` is a SEPARATE channel (never folded into tokens).
|
|
122
|
-
*/
|
|
123
|
-
type UsageEvent = {
|
|
124
|
-
kind: 'tokens';
|
|
125
|
-
input: number;
|
|
126
|
-
output: number;
|
|
127
|
-
} | {
|
|
128
|
-
kind: 'cost';
|
|
129
|
-
usd: number;
|
|
130
|
-
} | {
|
|
131
|
-
kind: 'iteration';
|
|
132
|
-
};
|
|
133
|
-
/** The runtime tag of a `Executor` impl. Open by intent: custom runtimes use their own string name.
|
|
134
|
-
* External executors can register additional runtime strings without widening this type. */
|
|
135
|
-
type Runtime = 'router' | 'inline' | 'sandbox' | 'cli' | (string & {});
|
|
136
|
-
/**
|
|
137
|
-
* `AgentProfile` does NOT carry a `harness`/backend field — `harness` lives on the
|
|
138
|
-
* sandbox SDK's `BackendConfig`, not the portable profile. So an agent is mapped to its
|
|
139
|
-
* executor through this MINIMAL wrapper, never by fabricating a field onto `AgentProfile`.
|
|
140
|
-
*
|
|
141
|
-
* Resolution (in `runtime.ts`):
|
|
142
|
-
* - `executor` present → BYO: use it verbatim (a user's own `Executor`).
|
|
143
|
-
* - `harness === null` → router/inline: a direct Router call, no box.
|
|
144
|
-
* - `harness` is a `BackendType` → sandbox: compose `runLoop` against `profile` on that backend.
|
|
145
|
-
* Fail loud on an unresolvable spec (no executor and an unknown harness).
|
|
146
|
-
*/
|
|
147
|
-
interface AgentSpec {
|
|
148
|
-
readonly profile: AgentProfile;
|
|
149
|
-
/** `null` selects router/inline; a `BackendType` selects the sandboxed harness. */
|
|
150
|
-
readonly harness: BackendType | null;
|
|
151
|
-
/** Bring-your-own executor: when set, overrides harness-based resolution entirely. */
|
|
152
|
-
readonly executor?: Executor<unknown>;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Builds a fresh `Executor` for one spawn from the resolved spec. Per-spawn (not
|
|
156
|
-
* shared) so each child owns its own box/abort/teardown lifecycle. A BYO factory lets a
|
|
157
|
-
* user supply construction args without pre-instantiating.
|
|
158
|
-
*/
|
|
159
|
-
type ExecutorFactory<Out> = (spec: AgentSpec, ctx: ExecutorContext) => Executor<Out>;
|
|
160
|
-
/** Construction context handed to a `ExecutorFactory` — the seams a built-in needs
|
|
161
|
-
* (sandbox client for the sandbox executor, router config for router/inline) without
|
|
162
|
-
* the factory reaching into module globals. */
|
|
163
|
-
interface ExecutorContext {
|
|
164
|
-
readonly signal: AbortSignal;
|
|
165
|
-
/** Opaque seams the registry threads through; a built-in narrows what it needs. */
|
|
166
|
-
readonly seams: Readonly<Record<string, unknown>>;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* The OPEN resolver: maps an `AgentSpec` to a `ExecutorFactory`. The default
|
|
170
|
-
* registry resolves the three built-ins AND accepts a BYO `executor`/factory; callers
|
|
171
|
-
* register more runtimes by name. NOT a closed switch — registration is the extension
|
|
172
|
-
* point, mirroring the open `Executor` interface.
|
|
173
|
-
*/
|
|
174
|
-
interface ExecutorRegistry {
|
|
175
|
-
/** Register a factory for a named runtime. Throws on a duplicate name (fail loud). */
|
|
176
|
-
register<Out>(runtime: Runtime, factory: ExecutorFactory<Out>): void;
|
|
177
|
-
/**
|
|
178
|
-
* Resolve a spec to a factory. Precedence: a BYO `spec.executor` → a trivial factory
|
|
179
|
-
* returning it; else `harness === null` → the `'router'` factory; else a registered
|
|
180
|
-
* factory for the harness-derived runtime. Returns a typed outcome — the caller
|
|
181
|
-
* inspects `succeeded` before `value` (no silent fallback).
|
|
182
|
-
*/
|
|
183
|
-
resolve<Out>(spec: AgentSpec): {
|
|
184
|
-
succeeded: true;
|
|
185
|
-
value: ExecutorFactory<Out>;
|
|
186
|
-
} | {
|
|
187
|
-
succeeded: false;
|
|
188
|
-
error: string;
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
/** A budget envelope on a spawn or the root. All ceilings; the pool reserves against them. */
|
|
192
|
-
interface Budget {
|
|
193
|
-
readonly maxIterations: number;
|
|
194
|
-
readonly maxTokens: number;
|
|
195
|
-
readonly maxUsd?: number;
|
|
196
|
-
readonly deadlineMs?: number;
|
|
197
|
-
}
|
|
198
|
-
/** Conserved spend, reconciled from the normalized `UsageEvent` stream. Tokens and usd
|
|
199
|
-
* are separate channels (never folded). */
|
|
200
|
-
interface Spend {
|
|
201
|
-
iterations: number;
|
|
202
|
-
tokens: LoopTokenUsage;
|
|
203
|
-
/** Dollar accounting is known unless explicitly false. A false value must not be treated as $0
|
|
204
|
-
* when enforcing a dollar-denominated comparison or limit. */
|
|
205
|
-
usdKnown?: boolean;
|
|
206
|
-
usd: number;
|
|
207
|
-
ms: number;
|
|
208
|
-
}
|
|
209
|
-
/** OTP child-spec restart class. */
|
|
210
|
-
type Restart = 'temporary' | 'transient' | 'permanent';
|
|
211
|
-
/** `'acquiring'` is first-class (M1): a node spends real time + reaps an orphan box
|
|
212
|
-
* during sandbox acquire BEFORE it is `running`, so abort must be defined over it. */
|
|
213
|
-
type NodeStatus = 'pending' | 'acquiring' | 'running' | 'done' | 'failed' | 'cancelled';
|
|
214
|
-
/** Deterministic node id — `${parent}:s${seq}` from the cursor order, never wall-clock. */
|
|
215
|
-
type NodeId = string;
|
|
216
|
-
interface SpawnOpts {
|
|
217
|
-
readonly budget: Budget;
|
|
218
|
-
readonly label: string;
|
|
219
|
-
readonly restart?: Restart;
|
|
220
|
-
/** Teardown grace handed to the executor when this node is reaped. */
|
|
221
|
-
readonly shutdown?: number | 'brutalKill' | 'infinity';
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* A live child handle. `abort()` is defined over the ACQUIRE lifecycle: it chains into
|
|
225
|
-
* the `acquireSandbox` signal and reaps a find-by-name orphan box, so a node aborted
|
|
226
|
-
* mid-acquire never leaks (M1).
|
|
227
|
-
*/
|
|
228
|
-
interface Handle<Out> {
|
|
229
|
-
readonly id: NodeId;
|
|
230
|
-
readonly label: string;
|
|
231
|
-
readonly status: NodeStatus;
|
|
232
|
-
abort(reason?: string): void;
|
|
233
|
-
/** Phantom: binds the handle to the child's output type so `spawn<C>` returns a
|
|
234
|
-
* `Handle<C>` distinct from a `Handle<other>`. Type-only — never present at runtime. */
|
|
235
|
-
readonly __out?: Out;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* A settled child, delivered by `scope.next()`. `seq` is the monotonic cursor order
|
|
239
|
-
* `next()` yielded this settlement (B2) — NOT wall-clock — and replay delivers strictly
|
|
240
|
-
* in `seq` order. `outRef` rehydrates `out` from the `ResultBlobStore` on replay.
|
|
241
|
-
*/
|
|
242
|
-
type Settled<Out> = {
|
|
243
|
-
kind: 'done';
|
|
244
|
-
handle: Handle<Out>;
|
|
245
|
-
out: Out;
|
|
246
|
-
outRef: string;
|
|
247
|
-
verdict?: DefaultVerdict;
|
|
248
|
-
spent: Spend;
|
|
249
|
-
seq: number;
|
|
250
|
-
} | {
|
|
251
|
-
kind: 'down';
|
|
252
|
-
handle: Handle<Out>;
|
|
253
|
-
reason: string;
|
|
254
|
-
/** True = infrastructure failure (excluded from merge `n` / equal-k), not a bad result. */
|
|
255
|
-
infra: boolean;
|
|
256
|
-
restartCount: number;
|
|
257
|
-
seq: number;
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* The budget-conserving reactive scope an `Agent.act` runs inside. `spawn` reserves
|
|
261
|
-
* budget atomically from the shared pool and fails closed when the pool cannot cover it.
|
|
262
|
-
* `next()` waits for one settlement from this scope's live set; `view` reads live state,
|
|
263
|
-
* not the replay log.
|
|
264
|
-
*/
|
|
265
|
-
interface Scope<Out> {
|
|
266
|
-
/**
|
|
267
|
-
* Spawn a child. Reserves `opts.budget` from the conserved pool atomically; refunds the
|
|
268
|
-
* unspent remainder on settle. Returns a typed outcome — fail-closed on an exhausted
|
|
269
|
-
* pool or an exceeded depth ceiling (the caller inspects `ok` before `handle`).
|
|
270
|
-
*/
|
|
271
|
-
spawn<C extends Out>(agent: Agent<unknown, C>, task: unknown, opts: SpawnOpts): {
|
|
272
|
-
ok: true;
|
|
273
|
-
handle: Handle<C>;
|
|
274
|
-
} | {
|
|
275
|
-
ok: false;
|
|
276
|
-
reason: 'budget-exhausted' | 'depth-exceeded';
|
|
277
|
-
};
|
|
278
|
-
/** ray.wait n=1 over this scope's in-memory live set; resolves as each child settles;
|
|
279
|
-
* `null` when the live set is empty. */
|
|
280
|
-
next(): Promise<Settled<Out> | null>;
|
|
281
|
-
/**
|
|
282
|
-
* Non-blocking twin of `next()`: deliver an ALREADY-settled, undelivered child, or `null`
|
|
283
|
-
* when none is ready — never awaits a live child. The driver's post-loop drain reads this so
|
|
284
|
-
* a child that settled while the driver was busy (or after it stopped pulling) still reaches
|
|
285
|
-
* the finalize ledger instead of being silently lost.
|
|
286
|
-
*/
|
|
287
|
-
nextResolved(): Promise<Settled<Out> | null>;
|
|
288
|
-
/**
|
|
289
|
-
* Steer a RUNNING child out-of-band — deliver a message to its executor's inbox (the driver's
|
|
290
|
-
* `send` verb: next-instruction, interrupt, or resume). Returns `true` if the message was
|
|
291
|
-
* delivered to a live child whose executor accepts delivery, `false` otherwise (unknown id,
|
|
292
|
-
* already settled, or an executor with no inbox). The executor drains its inbox between turns;
|
|
293
|
-
* a leaf that does not implement `deliver` simply cannot be steered mid-flight. In-process this
|
|
294
|
-
* is a direct call; the sandbox/Agent-Bus transports surface the SAME verb as an MCP tool.
|
|
295
|
-
*/
|
|
296
|
-
send(nodeId: NodeId, msg: unknown): boolean;
|
|
297
|
-
/** This scope's abort signal — aborted when the run is cancelled, a breaker trips, the pool
|
|
298
|
-
* is exhausted, or a parent scope cascades. A long-running driver `act` over this scope reads
|
|
299
|
-
* it to break promptly (the conserved pool + driver-stop are the other bounds). A nested
|
|
300
|
-
* scope carries its own signal, chained off its driver child's abort. */
|
|
301
|
-
readonly signal: AbortSignal;
|
|
302
|
-
/**
|
|
303
|
-
* Meter the driver's OWN compute against the conserved pool — its inference turns, which are
|
|
304
|
-
* real tokens/usd but not a spawned child (no reserve/reconcile). A direct `free → committed`
|
|
305
|
-
* debit, so equal-k counts the driver's tokens AND the in-loop budget guard (`budget.tokensLeft`)
|
|
306
|
-
* halts a driver that thinks the pool dry. `detail` rides an `agent.turn` trace event for live
|
|
307
|
-
* observability (turn index, tool calls, cumulative spend). It also journals a `metered` event —
|
|
308
|
-
* the durable twin of the pool debit (as `settled` is the twin of `reconcile`) — so every
|
|
309
|
-
* journal-based cost reader (`spentFromJournal`, `trajectoryReport`) sums driver inference
|
|
310
|
-
* automatically. A leaf never calls this; a driver meters each chat turn and awaits it (the
|
|
311
|
-
* metered event is cost-critical, so it lands before the join-barrier roll-up).
|
|
312
|
-
*/
|
|
313
|
-
meter(spend: Spend, detail?: Record<string, unknown>): Promise<void>;
|
|
314
|
-
/** The live tree — reads the in-memory nursery, not the journal. */
|
|
315
|
-
readonly view: TreeView;
|
|
316
|
-
/** Conserved-pool readouts (post-reservation). */
|
|
317
|
-
readonly budget: Readonly<{
|
|
318
|
-
tokensLeft: number;
|
|
319
|
-
usdLeft: number;
|
|
320
|
-
usdCapped: boolean;
|
|
321
|
-
deadlineMs: number;
|
|
322
|
-
reservedTokens: number;
|
|
323
|
-
}>;
|
|
324
|
-
}
|
|
325
|
-
interface NodeSnapshot {
|
|
326
|
-
readonly id: NodeId;
|
|
327
|
-
readonly parent?: NodeId;
|
|
328
|
-
readonly label: string;
|
|
329
|
-
readonly status: NodeStatus;
|
|
330
|
-
readonly runtime: Runtime;
|
|
331
|
-
readonly budget: Budget;
|
|
332
|
-
/** Conserved spend so far for this node. */
|
|
333
|
-
readonly spent: Spend;
|
|
334
|
-
/** `outRef` once the node is `done` (the replay/result pointer). */
|
|
335
|
-
readonly outRef?: string;
|
|
336
|
-
}
|
|
337
|
-
/** The live tree — what `scope.view` / `RootHandle.view()` materialize for a viewer. */
|
|
338
|
-
interface TreeView {
|
|
339
|
-
readonly root: NodeId;
|
|
340
|
-
readonly nodes: ReadonlyArray<NodeSnapshot>;
|
|
341
|
-
/** Count of nodes in `running` or `acquiring` — the "what's in flow?" answer. */
|
|
342
|
-
readonly inFlight: number;
|
|
343
|
-
}
|
|
344
|
-
/** Journaled spawn-tree events (B1/B2). `seq` is the cursor order; `at` is an ISO
|
|
345
|
-
* timestamp for human inspection only (NOT a replay input). */
|
|
346
|
-
type SpawnEvent = {
|
|
347
|
-
kind: 'spawned';
|
|
348
|
-
id: NodeId;
|
|
349
|
-
parent?: NodeId;
|
|
350
|
-
label: string;
|
|
351
|
-
budget: Budget;
|
|
352
|
-
runtime: Runtime;
|
|
353
|
-
seq: number;
|
|
354
|
-
at: string;
|
|
355
|
-
} | {
|
|
356
|
-
kind: 'settled';
|
|
357
|
-
id: NodeId;
|
|
358
|
-
status: 'done' | 'down';
|
|
359
|
-
/** Content-addressed result pointer; rehydrates `out` from `ResultBlobStore`. */
|
|
360
|
-
outRef?: string;
|
|
361
|
-
verdict?: DefaultVerdict;
|
|
362
|
-
spent: Spend;
|
|
363
|
-
infra?: boolean;
|
|
364
|
-
seq: number;
|
|
365
|
-
at: string;
|
|
366
|
-
} | {
|
|
367
|
-
kind: 'cancelled';
|
|
368
|
-
id: NodeId;
|
|
369
|
-
reason: string;
|
|
370
|
-
seq: number;
|
|
371
|
-
at: string;
|
|
372
|
-
} | {
|
|
373
|
-
/** A driver's OWN inference spend, journaled separately from spawned-child work — the journal
|
|
374
|
-
* TWIN of `BudgetPool.observe`, exactly as `settled` is the twin of `reconcile`. So every
|
|
375
|
-
* journal-based cost reader sums it automatically — the journal is the single cost ledger.
|
|
376
|
-
* It carries spend only and is NOT a settlement: replay + `materializeTreeView` skip it for
|
|
377
|
-
* structure, and its `seq` lives outside the cursor-uniqueness namespace. A
|
|
378
|
-
* driver re-homes its nested subtree's metered total up to its parent (like settled spend),
|
|
379
|
-
* so summing any sub-tree root yields that sub-tree's true driver-inference cost. */
|
|
380
|
-
kind: 'metered';
|
|
381
|
-
id: NodeId;
|
|
382
|
-
spend: Spend;
|
|
383
|
-
seq: number;
|
|
384
|
-
at: string;
|
|
385
|
-
};
|
|
386
|
-
/**
|
|
387
|
-
* The spawn-tree event source (mirrors `ConversationJournal`'s begin/append/load shape).
|
|
388
|
-
* `loadTree` returns events for inspection and completed-settlement replay, not live process
|
|
389
|
-
* recovery; `appendEvent` runs only AFTER the event is observed-committed (never speculative).
|
|
390
|
-
*/
|
|
391
|
-
interface SpawnJournal {
|
|
392
|
-
loadTree(root: NodeId): Promise<SpawnEvent[] | undefined>;
|
|
393
|
-
beginTree(root: NodeId, at: string): Promise<void>;
|
|
394
|
-
appendEvent(root: NodeId, ev: SpawnEvent): Promise<void>;
|
|
395
|
-
}
|
|
396
|
-
/** Content-addressed result blobs (the `outRef` → artifact map) backing the replay
|
|
397
|
-
* invariant. Split from the journal so the journal stays small (decisions) and the
|
|
398
|
-
* payloads (evidence) live where a viewer/replayer rehydrates them. */
|
|
399
|
-
interface ResultBlobStore {
|
|
400
|
-
put(outRef: string, artifact: unknown): Promise<void>;
|
|
401
|
-
get(outRef: string): Promise<unknown | undefined>;
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* Owns the conserved pool, the spawn log, the abort cascade, the OTP intensity breaker,
|
|
405
|
-
* and the root handle. `run` executes the root `Agent` to completion; `attach` wires a
|
|
406
|
-
* live `RootHandle` (the Q2 substrate the chat/pi-viz client later consumes).
|
|
407
|
-
*/
|
|
408
|
-
interface Supervisor<Task, Out> {
|
|
409
|
-
run(root: Agent<Task, Out>, task: Task, opts: SupervisorOpts): Promise<SupervisedResult<Out>>;
|
|
410
|
-
attach(h: RootHandle<Out>): void;
|
|
411
|
-
}
|
|
412
|
-
interface SupervisorOpts {
|
|
413
|
-
/** The root conserved-pool ceiling (tokens + usd + iterations + deadline). */
|
|
414
|
-
readonly budget: Budget;
|
|
415
|
-
/** Trace-correlation root + the journal/blob root key. */
|
|
416
|
-
readonly runId: NodeId;
|
|
417
|
-
/** Event source — defaults to the in-memory journal in the impl; pass JSONL/FS for durability. */
|
|
418
|
-
readonly journal: SpawnJournal;
|
|
419
|
-
/** Result payload store backing `outRef` rehydration. */
|
|
420
|
-
readonly blobs: ResultBlobStore;
|
|
421
|
-
/** Executor resolution — the open registry mapping `AgentSpec` → `Executor`. */
|
|
422
|
-
readonly executors: ExecutorRegistry;
|
|
423
|
-
/** Runtime recursion-depth ceiling (paired with the conserved pool per R3). */
|
|
424
|
-
readonly maxDepth?: number;
|
|
425
|
-
/**
|
|
426
|
-
* OTP intensity breaker: more than `maxRestarts` child restarts within `withinMs`
|
|
427
|
-
* trips the supervisor to `no-winner` rather than restarting forever.
|
|
428
|
-
*/
|
|
429
|
-
readonly maxRestarts?: number;
|
|
430
|
-
readonly withinMs?: number;
|
|
431
|
-
readonly now?: () => number;
|
|
432
|
-
readonly signal?: AbortSignal;
|
|
433
|
-
/** Lifecycle stream sink, threaded into the root `Scope` so every `spawn`/settle emits on the
|
|
434
|
-
* same `agent.spawn`/`agent.child` stream `runLoop` feeds — one observable recursive tree. */
|
|
435
|
-
readonly hooks?: RuntimeHooks;
|
|
436
|
-
}
|
|
437
|
-
/** Typed terminal result (M2) — a no-winner is NEVER coerced to a best-effort output. */
|
|
438
|
-
type SupervisedResult<Out> = {
|
|
439
|
-
kind: 'winner';
|
|
440
|
-
out: Out;
|
|
441
|
-
outRef: string;
|
|
442
|
-
verdict?: DefaultVerdict;
|
|
443
|
-
tree: TreeView;
|
|
444
|
-
spentTotal: Spend;
|
|
445
|
-
/** Where `spentTotal` went: `driverInference` = the drivers' own chat turns (metered via
|
|
446
|
-
* `Scope.meter`); `childWork` = every spawned child's reconciled spend (the journal sum).
|
|
447
|
-
* `driverInference + childWork === spentTotal`. Present whenever any driver metered. */
|
|
448
|
-
spentBreakdown?: {
|
|
449
|
-
driverInference: Spend;
|
|
450
|
-
childWork: Spend;
|
|
451
|
-
};
|
|
452
|
-
} | {
|
|
453
|
-
kind: 'no-winner';
|
|
454
|
-
reason: 'all-children-down' | 'budget-exhausted' | 'aborted';
|
|
455
|
-
tree: TreeView;
|
|
456
|
-
downCount: number;
|
|
457
|
-
/** The conserved spend incurred before the run failed — real cost is paid even when no
|
|
458
|
-
* worker delivers, so the caller always learns what the delegation actually spent. Summed
|
|
459
|
-
* off the same journal the `winner` path reads. */
|
|
460
|
-
spentTotal: Spend;
|
|
461
|
-
};
|
|
462
|
-
/** Live root handle — the substrate a chat/pi-viz client attaches to (Q2). `signal`
|
|
463
|
-
* delivers an out-of-band message to the running root; `view()` materializes the tree. */
|
|
464
|
-
interface RootHandle<Out> {
|
|
465
|
-
view(): TreeView;
|
|
466
|
-
signal(msg: RootSignal): void;
|
|
467
|
-
abort(reason?: string): void;
|
|
468
|
-
/** Phantom: binds the handle to the supervised run's output type. Type-only — never
|
|
469
|
-
* present at runtime; lets `attach(h: RootHandle<Out>)` stay output-typed. */
|
|
470
|
-
readonly __out?: Out;
|
|
471
|
-
}
|
|
472
|
-
/** Out-of-band message to a running root. Open by intent — a client extends it. */
|
|
473
|
-
type RootSignal = {
|
|
474
|
-
kind: 'pause';
|
|
475
|
-
} | {
|
|
476
|
-
kind: 'resume';
|
|
477
|
-
} | {
|
|
478
|
-
kind: 'cancel';
|
|
479
|
-
reason?: string;
|
|
480
|
-
} | {
|
|
481
|
-
kind: 'ask';
|
|
482
|
-
question: string;
|
|
483
|
-
};
|
|
484
|
-
/**
|
|
485
|
-
* The progressive-widening gate (MCTS-PW). Decides whether a settled child is
|
|
486
|
-
* `promising` enough to spawn another under the remaining pool. DEFAULTS TO FLAT
|
|
487
|
-
* (`shouldWiden` always false) so a gate run never widens and the selector≠judge
|
|
488
|
-
* firewall conflict (R2) stays dormant. When widening IS enabled, `promising` MUST be
|
|
489
|
-
* derived from TRACE findings (`analyses`), never raw `verdict` — or the gate carries
|
|
490
|
-
* an explicit, argued `judgeExempt: true` (the documented escape hatch, off by default).
|
|
491
|
-
*/
|
|
492
|
-
interface WidenGate<Out> {
|
|
493
|
-
/** Default impl returns false for every settlement (flat — never widens). */
|
|
494
|
-
shouldWiden(settled: Settled<Out>, budget: Scope<Out>['budget']): boolean;
|
|
495
|
-
/** When true, widening may read `verdict` directly (collides with the steer firewall —
|
|
496
|
-
* must be explicitly argued per cell, never defaulted on). */
|
|
497
|
-
readonly judgeExempt?: boolean;
|
|
498
|
-
}
|
|
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, 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 };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|