@tangle-network/agent-runtime 0.197.1 → 0.198.2
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 +1 -2
- package/dist/{improve-DZs0KXhK.d.ts → activation-DFRTurvU.d.ts} +99 -5
- package/dist/{activation-BxMZybuo.js → activation-IBEVN3VI.js} +2 -2
- package/dist/{activation-BxMZybuo.js.map → activation-IBEVN3VI.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/candidate-execution/index.d.ts +370 -2
- package/dist/candidate-execution/index.js +828 -4
- package/dist/candidate-execution/index.js.map +1 -0
- package/dist/{coordination-driver-zkCrfEbS.js → coordination-driver-NFvZ5ofi.js} +57 -26
- package/dist/coordination-driver-NFvZ5ofi.js.map +1 -0
- package/dist/{delegate-DHeUYU5E.js → delegate-dN5yooEj.js} +2 -2
- package/dist/{delegate-DHeUYU5E.js.map → delegate-dN5yooEj.js.map} +1 -1
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +4 -5
- package/dist/durable.js.map +1 -1
- package/dist/{graph-51SJOEcw.js → graph-CgCVtMuz.js} +3 -3
- package/dist/{graph-51SJOEcw.js.map → graph-CgCVtMuz.js.map} +1 -1
- package/dist/{improvement-cycle-Tw5nYT5R.js → improvement-cycle-Cfu6kDOs.js} +8 -10
- package/dist/{improvement-cycle-Tw5nYT5R.js.map → improvement-cycle-Cfu6kDOs.js.map} +1 -1
- package/dist/{index-CYOJsxSg.d.ts → index-CMTUgh-T.d.ts} +9 -11
- package/dist/index.d.ts +694 -16
- package/dist/index.js +1780 -17
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +3 -7
- package/dist/intelligence.js +5 -6
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +2 -5
- package/dist/kernel.js +8 -10
- package/dist/{loop-runner-bin-DwrSB04m.d.ts → loop-runner-bin-CAf1OQot.d.ts} +3 -3
- package/dist/{loop-runner-bin-2LQSjRTB.js → loop-runner-bin-WQniYJ8C.js} +3 -3
- package/dist/{loop-runner-bin-2LQSjRTB.js.map → loop-runner-bin-WQniYJ8C.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +2 -3
- package/dist/mcp/index.js +4 -5
- package/dist/mcp/index.js.map +1 -1
- package/dist/{prepare-DDGp0-rW.js → prepare-CAO1yXov.js} +2407 -2407
- package/dist/prepare-CAO1yXov.js.map +1 -0
- package/dist/{protected-model-port-DxFN8DLS.js → protected-model-port-B5avcRiQ.js} +2 -2
- package/dist/{protected-model-port-DxFN8DLS.js.map → protected-model-port-B5avcRiQ.js.map} +1 -1
- package/dist/{provision-supervisor-CpMMShE_.js → provision-supervisor-BxsIaJ35.js} +3 -6
- package/dist/{provision-supervisor-CpMMShE_.js.map → provision-supervisor-BxsIaJ35.js.map} +1 -1
- package/dist/{redact-Cbl2O-4N.js → redact-DqfB7oB4.js} +5233 -2526
- package/dist/redact-DqfB7oB4.js.map +1 -0
- package/dist/{runtime-BSFz2z7h.js → runtime-CHEtvaTY.js} +427 -23
- package/dist/runtime-CHEtvaTY.js.map +1 -0
- package/dist/{server-COXa19sp.js → server-ccGua5tH.js} +4 -4
- package/dist/{server-COXa19sp.js.map → server-ccGua5tH.js.map} +1 -1
- package/dist/{types-DFLZMaeh.d.ts → stream-agent-turn-CLOQr497.d.ts} +1986 -6
- package/dist/{structural-rollout-DPbZWgEm.js → structural-rollout-BmDuXyR9.js} +1101 -8
- package/dist/structural-rollout-BmDuXyR9.js.map +1 -0
- package/dist/{supervise-b93YUaka.js → supervise-DVt8-TI-.js} +9 -5
- package/dist/supervise-DVt8-TI-.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +13 -13
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{workspace-archive-Ybomp7AN.js → workspace-archive-BMOnloFf.js} +3 -3
- package/dist/{workspace-archive-Ybomp7AN.js.map → workspace-archive-BMOnloFf.js.map} +1 -1
- package/package.json +1 -28
- package/dist/activation-DyWB0K6E.d.ts +0 -98
- package/dist/authored-code-URmkdgjv.js +0 -37
- package/dist/authored-code-URmkdgjv.js.map +0 -1
- package/dist/candidate-execution-nvqVIMyS.js +0 -829
- package/dist/candidate-execution-nvqVIMyS.js.map +0 -1
- package/dist/conversation-BxJ0SIBM.js +0 -1363
- package/dist/conversation-BxJ0SIBM.js.map +0 -1
- package/dist/conversation.d.ts +0 -2
- package/dist/conversation.js +0 -2
- package/dist/coordination-driver-zkCrfEbS.js.map +0 -1
- package/dist/environment-provider-1fKZh2zl.js +0 -2281
- package/dist/environment-provider-1fKZh2zl.js.map +0 -1
- package/dist/environment-provider-B-I2jlQy.d.ts +0 -143
- package/dist/environment-provider.d.ts +0 -2
- package/dist/environment-provider.js +0 -2
- package/dist/graph.d.ts +0 -753
- package/dist/graph.js +0 -2111
- package/dist/graph.js.map +0 -1
- package/dist/index-CUosKU4N.d.ts +0 -372
- package/dist/index-D9mb6fn2.d.ts +0 -691
- package/dist/index-ZnxSe6iK.d.ts +0 -138
- package/dist/jsonl-file-BEpaEYjT.js +0 -141
- package/dist/jsonl-file-BEpaEYjT.js.map +0 -1
- package/dist/knowledge-B_MsOtDG.js +0 -428
- package/dist/knowledge-B_MsOtDG.js.map +0 -1
- package/dist/knowledge.d.ts +0 -2
- package/dist/knowledge.js +0 -2
- package/dist/materialization-Cy0oM8tb.js +0 -672
- package/dist/materialization-Cy0oM8tb.js.map +0 -1
- package/dist/prepare-DDGp0-rW.js.map +0 -1
- package/dist/primeintellect/index.d.ts +0 -218
- package/dist/primeintellect/index.js +0 -739
- package/dist/primeintellect/index.js.map +0 -1
- package/dist/redact-Cbl2O-4N.js.map +0 -1
- package/dist/runtime-0xNaV6TJ.d.ts +0 -1699
- package/dist/runtime-BSFz2z7h.js.map +0 -1
- package/dist/stream-agent-turn-Dt5mZpc3.js +0 -1103
- package/dist/stream-agent-turn-Dt5mZpc3.js.map +0 -1
- package/dist/stream-agent-turn-urHpmO_Z.d.ts +0 -160
- package/dist/structural-rollout-DPbZWgEm.js.map +0 -1
- package/dist/supervise-b93YUaka.js.map +0 -1
package/dist/graph.d.ts
DELETED
|
@@ -1,753 +0,0 @@
|
|
|
1
|
-
import { Fn as PromptHandle, In as PromptRegistry, Sd as WorkerSpawnContext, Sn as AgentGraph, Ys as SupervisorFinalizer, ad as MakeWorkerAgent, kn as RunGraphOptions, ls as SupervisorAgentDeps, qp as DeliverableSpec } from "./index-CYOJsxSg.js";
|
|
2
|
-
import { B as Scope, H as SpawnEvent, M as ResultBlobStore, U as SpawnJournal, i as Budget, q as Spend, t as Agent } from "./types-DFLZMaeh.js";
|
|
3
|
-
import { c as ExecutorConfig } from "./runtime-0xNaV6TJ.js";
|
|
4
|
-
import { AgentProfile } from "@tangle-network/agent-interface";
|
|
5
|
-
//#region src/runtime/authored-code.d.ts
|
|
6
|
-
interface AuthoredCodeOptions {
|
|
7
|
-
/** Import specifiers an authored module may name. Empty (the default) bans every import. A
|
|
8
|
-
* specifier admits ANY import form of that module (named, namespace, default) — the lint
|
|
9
|
-
* gates WHICH module, not the syntax used to reach it. */
|
|
10
|
-
readonly allowedImports?: ReadonlyArray<string>;
|
|
11
|
-
/** Names the refusal, e.g. `code mode (node-1)`. Defaults to `authored code`. */
|
|
12
|
-
readonly context?: string;
|
|
13
|
-
}
|
|
14
|
-
/** Refuse the obvious escapes in authored source. See the module doc for what this is NOT. */
|
|
15
|
-
declare function assertAuthoredCode(code: string, options?: AuthoredCodeOptions): void;
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/runtime/graph/condition.d.ts
|
|
18
|
-
/** The leaf comparison operators; `exists`/`truthy` are unary, the rest compare against `value`. */
|
|
19
|
-
declare const CONDITION_OPS: readonly ["eq", "neq", "gt", "gte", "lt", "lte", "in", "contains", "exists", "truthy"];
|
|
20
|
-
type ConditionOp = (typeof CONDITION_OPS)[number];
|
|
21
|
-
interface ConditionLeaf {
|
|
22
|
-
/** Dotted path with `[N]` indexing into the guard context, e.g. `out.findings[0].severity`. */
|
|
23
|
-
readonly path: string;
|
|
24
|
-
readonly op: ConditionOp;
|
|
25
|
-
readonly value?: unknown;
|
|
26
|
-
}
|
|
27
|
-
type Condition = ConditionLeaf | {
|
|
28
|
-
readonly all: ReadonlyArray<Condition>;
|
|
29
|
-
} | {
|
|
30
|
-
readonly any: ReadonlyArray<Condition>;
|
|
31
|
-
} | {
|
|
32
|
-
readonly not: Condition;
|
|
33
|
-
};
|
|
34
|
-
/** Validate shape, bounds, and per-leaf path/operator rules; returns the input for chaining. */
|
|
35
|
-
declare function validateCondition(raw: unknown, context: string): Condition;
|
|
36
|
-
/** Walk a validated condition over a context to a boolean. Never throws on data shape. */
|
|
37
|
-
declare function evaluateCondition(condition: Condition, context: unknown): boolean;
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/runtime/graph/registry.d.ts
|
|
40
|
-
/**
|
|
41
|
-
* `Registry<T>` — the ONE name→thing shape for the graph engine.
|
|
42
|
-
*
|
|
43
|
-
* The kernel grew fourteen of these (agent-runtime#978) that differ in three properties:
|
|
44
|
-
* whether names can be listed, what a miss does, and whether the table is global. This one
|
|
45
|
-
* fixes all three — enumerable, a miss is refused BY NAME listing what is registered, and every
|
|
46
|
-
* registry is per-instance — and it is lifted from `AgentEnvironmentProviderRegistry`, the
|
|
47
|
-
* richest and best-tested of the fourteen, not invented.
|
|
48
|
-
*
|
|
49
|
-
* Entries are addressed by a versioned handle, `<id>/v<n>`, the same way the prompt registry
|
|
50
|
-
* addresses directives. A graph names a kind by handle; a host registers exact versions; a
|
|
51
|
-
* missing version is refused, never served by a newer one.
|
|
52
|
-
*/
|
|
53
|
-
/** A versioned name: what a graph writes and what a host registers. */
|
|
54
|
-
interface RegistryHandle {
|
|
55
|
-
readonly id: string;
|
|
56
|
-
readonly version: number;
|
|
57
|
-
}
|
|
58
|
-
/** `<id>/v<n>` — the only spelling a handle has on the wire, in a journal, or in an error. */
|
|
59
|
-
declare function formatRegistryHandle(handle: RegistryHandle): string;
|
|
60
|
-
/** Parse the wire spelling back. Refuses anything that is not exactly `<id>/v<n>`. */
|
|
61
|
-
declare function parseRegistryHandle(text: string, context: string): RegistryHandle;
|
|
62
|
-
/** Anything a registry holds carries its own handle, so the table cannot drift from the entry. */
|
|
63
|
-
interface Registered extends RegistryHandle {}
|
|
64
|
-
interface Registry<T extends Registered> {
|
|
65
|
-
/** Add one entry. A second entry under the same handle is refused unless `replace` is set —
|
|
66
|
-
* silently shadowing a registered kind is how a key no caller could produce once survived. */
|
|
67
|
-
register(entry: T, options?: {
|
|
68
|
-
readonly replace?: boolean;
|
|
69
|
-
}): void;
|
|
70
|
-
has(handle: RegistryHandle): boolean;
|
|
71
|
-
get(handle: RegistryHandle): T | undefined;
|
|
72
|
-
/** The entry, or a refusal that names the handle AND lists every registered handle — a miss
|
|
73
|
-
* must be diagnosable from its message alone. */
|
|
74
|
-
require(handle: RegistryHandle, context?: string): T;
|
|
75
|
-
/** Every registered handle, sorted, as wire spellings. The thing the fourteen predecessors
|
|
76
|
-
* mostly could not do and four callers needed. */
|
|
77
|
-
names(): string[];
|
|
78
|
-
/** Every entry, in `names()` order. */
|
|
79
|
-
entries(): T[];
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Create a registry. Per-instance by construction: two engines in one process may hold
|
|
83
|
-
* different kind sets, a test is hermetic, and a run can print its own table. There is
|
|
84
|
-
* deliberately no module-level singleton — `builtinShapes` was the one mutable global in the
|
|
85
|
-
* kernel and it had zero tests.
|
|
86
|
-
*/
|
|
87
|
-
declare function createRegistry<T extends Registered>(label: string, seed?: Iterable<T>): Registry<T>;
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region src/runtime/graph/kind.d.ts
|
|
90
|
-
/** A JSON Schema document as the kernel already spells it: an opaque record, validated by the
|
|
91
|
-
* consumer's own validator, published verbatim. */
|
|
92
|
-
type JsonSchema = Readonly<Record<string, unknown>>;
|
|
93
|
-
/**
|
|
94
|
-
* One declared port on a node. Ports are how a `data` edge binds one node's output to another's
|
|
95
|
-
* input with a type the compiler can check structurally before any spend. A node has two implicit
|
|
96
|
-
* output ports beside its declared ones: `out` (its result) and `trace` (its `WorkerTraceEvidence`
|
|
97
|
-
* by `traceRef`); only an `analyzes` edge may bind `trace`.
|
|
98
|
-
*/
|
|
99
|
-
interface PortSpec {
|
|
100
|
-
readonly name: string;
|
|
101
|
-
readonly schema: JsonSchema;
|
|
102
|
-
readonly description?: string;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* What a kind declares it needs from the host. The engine never imports a host capability; it
|
|
106
|
-
* knows only that a kind SAID it needs something under this name and the host PROVIDED something
|
|
107
|
-
* under it. The context a kind receives is narrowed to exactly its declaration — an undeclared
|
|
108
|
-
* effect is `undefined`, never a service locator.
|
|
109
|
-
*/
|
|
110
|
-
/** What a nesting kind needs from its host: run one graph, on the host's own kinds and effects.
|
|
111
|
-
* Declared here (not imported from the scheduler) so the contract module stays dependency-free. */
|
|
112
|
-
interface GraphHost {
|
|
113
|
-
runNested(graph: unknown, task: string, options: {
|
|
114
|
-
readonly budget: unknown;
|
|
115
|
-
readonly perNode?: unknown;
|
|
116
|
-
readonly runId: string;
|
|
117
|
-
readonly signal?: AbortSignal;
|
|
118
|
-
}): Promise<{
|
|
119
|
-
readonly kind: string;
|
|
120
|
-
readonly out?: unknown;
|
|
121
|
-
}>;
|
|
122
|
-
}
|
|
123
|
-
type EffectName = string;
|
|
124
|
-
type EffectContext<Effects extends ReadonlyArray<EffectName>> = Readonly<{ [K in Effects[number]]: unknown; }>;
|
|
125
|
-
/**
|
|
126
|
-
* What happens to a node that was IN FLIGHT when the process died. A settled node is never a
|
|
127
|
-
* per-kind choice — it restores from its content-addressed `outRef` on replay. `'restart'` re-runs
|
|
128
|
-
* from the journaled `inputRef`; `'resume'` is legal only for a kind whose executor can re-attach
|
|
129
|
-
* to the live process (the bridge backend's session re-attachment is the existing instance).
|
|
130
|
-
*/
|
|
131
|
-
type OnCrash = 'restart' | 'resume';
|
|
132
|
-
/**
|
|
133
|
-
* Whether a kind's spend enters the conserved pool. `'metered'`: the executor reports `Spend` and
|
|
134
|
-
* settling without one is an ENGINE ERROR — never "free". `'exempt'`: the whole reservation is
|
|
135
|
-
* refunded on settle, keeping the node out of Σk by construction (the kernel's `budgetExempt`).
|
|
136
|
-
*/
|
|
137
|
-
type BudgetMode = 'metered' | 'exempt';
|
|
138
|
-
/** The validated declaration every kind provides. `Config` is the per-node config shape;
|
|
139
|
-
* `Effects` is the tuple of host capabilities it declares, so the context `run` receives is typed
|
|
140
|
-
* to exactly that tuple. */
|
|
141
|
-
interface NodeKind<Config = unknown, Effects extends ReadonlyArray<EffectName> = ReadonlyArray<EffectName>> extends Registered {
|
|
142
|
-
/** Kind id, e.g. `agent`, `integration.invoke`. With `version`, forms the handle `<id>/v<n>`. */
|
|
143
|
-
readonly id: string;
|
|
144
|
-
readonly version: number;
|
|
145
|
-
readonly description: string;
|
|
146
|
-
/** Validate and narrow one node's config. Throw `ValidationError` to refuse; the compiler
|
|
147
|
-
* surfaces the message with the node id prefixed. */
|
|
148
|
-
readonly validateConfig: (raw: unknown, context: string) => Config;
|
|
149
|
-
/** The portable form of `validateConfig`'s accepted shape, for manifests and hosts. */
|
|
150
|
-
readonly configSchema: JsonSchema;
|
|
151
|
-
/** Declared input ports; a `data` edge may bind only these. Empty for a source node. */
|
|
152
|
-
readonly inputs: ReadonlyArray<PortSpec>;
|
|
153
|
-
/** Declared output ports beside the implicit `out` and `trace`. */
|
|
154
|
-
readonly outputs: ReadonlyArray<PortSpec>;
|
|
155
|
-
/** Host capabilities this kind reaches for, by name. The context is narrowed to exactly these. */
|
|
156
|
-
readonly effects: Effects;
|
|
157
|
-
readonly onCrash: OnCrash;
|
|
158
|
-
readonly budget: BudgetMode;
|
|
159
|
-
/**
|
|
160
|
-
* Build the agent for one node instance. The kernel spawns it under `Scope.spawn`, so it is
|
|
161
|
-
* authorized, classified, journaled, pooled and gated like any child — the kind owns only what
|
|
162
|
-
* the agent DOES. `profile` is the node's pinned profile (an `agent`/`supervisor` kind runs it;
|
|
163
|
-
* a `script` kind may ignore it); `inputs` are the resolved, content-addressed port values;
|
|
164
|
-
* `effects` is the narrowed host context; `spawn` is the kernel's per-spawn context when the
|
|
165
|
-
* kind needs it (a supervisor kind threads it into `nodeContext`).
|
|
166
|
-
*/
|
|
167
|
-
readonly run: (args: {
|
|
168
|
-
readonly config: Config;
|
|
169
|
-
readonly profile: AgentProfile;
|
|
170
|
-
readonly inputs: Readonly<Record<string, unknown>>;
|
|
171
|
-
readonly effects: EffectContext<Effects>;
|
|
172
|
-
readonly spawn?: WorkerSpawnContext;
|
|
173
|
-
/** The engine hosting this node, for a kind that runs a graph of its own (`subgraph`). The
|
|
174
|
-
* scheduler supplies it; a kind that does not nest ignores it. */
|
|
175
|
-
readonly host?: GraphHost;
|
|
176
|
-
}) => Agent<unknown, unknown>;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* A kind of ANY config shape — what a registry holds and what every engine signature accepts.
|
|
180
|
-
*
|
|
181
|
-
* `NodeKind<Config>` puts `Config` in a parameter position (`run({ config })`), so it is
|
|
182
|
-
* contravariant: an array of differently-configured kinds is not assignable to
|
|
183
|
-
* `ReadonlyArray<NodeKind<unknown>>`, and every caller composing a heterogeneous kind set would
|
|
184
|
-
* need a cast. That cost belongs here, once, not at each consumer: a registry is heterogeneous by
|
|
185
|
-
* definition, and each kind validates its own config at its own boundary through
|
|
186
|
-
* `validateConfig`, which is where the type is actually enforced.
|
|
187
|
-
*/
|
|
188
|
-
type AnyNodeKind = NodeKind<any, ReadonlyArray<EffectName>>;
|
|
189
|
-
/** Per-node flags a graph author sets; they are node properties, not kinds (agent-runtime#970). */
|
|
190
|
-
interface NodeFlags {
|
|
191
|
-
/** An oracle — a judge, grader, auditor, trace analyst — may be bound only by an `analyzes`
|
|
192
|
-
* edge. The compiler refuses a `delegates` or `data` edge INTO an oracle: an edge to a grader
|
|
193
|
-
* leaks the rubric. */
|
|
194
|
-
readonly oracle?: boolean;
|
|
195
|
-
/** `script` only: pure over `(config, inputs)` ⇒ budget exempt, output restorable on replay,
|
|
196
|
-
* runs in-process. A pure script that settles with a different `outRef` for the same inputs
|
|
197
|
-
* has lied, and the first replay mismatch is an engine error. */
|
|
198
|
-
readonly pure?: boolean;
|
|
199
|
-
}
|
|
200
|
-
/** Validate a kind declaration at registration — so a malformed kind is refused by name once,
|
|
201
|
-
* not at the first node that uses it. */
|
|
202
|
-
declare function validateNodeKind(kind: AnyNodeKind, context?: string): AnyNodeKind;
|
|
203
|
-
/** The handle a graph writes to name this kind. */
|
|
204
|
-
declare function kindHandle(kind: Pick<NodeKind, 'id' | 'version'>): RegistryHandle;
|
|
205
|
-
/**
|
|
206
|
-
* Narrow a host's effect table to exactly what one kind declared. Anything the kind did not
|
|
207
|
-
* declare is absent — `undefined` on read — so a kind cannot reach past its declaration, and the
|
|
208
|
-
* engine can list a graph's required effects before spending a token.
|
|
209
|
-
*/
|
|
210
|
-
declare function narrowEffects<Effects extends ReadonlyArray<EffectName>>(declared: Effects, provided: Readonly<Record<string, unknown>>, context: string): EffectContext<Effects>;
|
|
211
|
-
//#endregion
|
|
212
|
-
//#region src/runtime/graph/projection.d.ts
|
|
213
|
-
type Projection = {
|
|
214
|
-
readonly path: string;
|
|
215
|
-
} | {
|
|
216
|
-
readonly pick: ReadonlyArray<string>;
|
|
217
|
-
} | {
|
|
218
|
-
readonly map: string;
|
|
219
|
-
} | {
|
|
220
|
-
readonly filter: Condition;
|
|
221
|
-
} | {
|
|
222
|
-
readonly first: true;
|
|
223
|
-
} | {
|
|
224
|
-
readonly last: true;
|
|
225
|
-
} | {
|
|
226
|
-
readonly count: true;
|
|
227
|
-
};
|
|
228
|
-
/** Validate a projection: exactly one known operator, its argument well-formed. */
|
|
229
|
-
declare function validateProjection(raw: unknown, context: string): Projection;
|
|
230
|
-
/**
|
|
231
|
-
* Apply a validated projection to an admitted payload. Collection operators over a non-array
|
|
232
|
-
* refuse by name — a shape the author did not expect is a graph defect, not an empty result.
|
|
233
|
-
*/
|
|
234
|
-
declare function applyProjection(value: unknown, projection: Projection, context: string): unknown;
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region src/runtime/graph/definition.d.ts
|
|
237
|
-
/** Which gating-edge outcomes release a node (adopted from ADC, agent-runtime#968). */
|
|
238
|
-
declare const JOIN_RULES: readonly ["all", "any", "any_failed", "all_done"];
|
|
239
|
-
type JoinRule = (typeof JOIN_RULES)[number];
|
|
240
|
-
/** ADC-compatible visit backstop: nothing may be ENTERED more than this many times. */
|
|
241
|
-
declare const DEFAULT_MAX_NODE_VISITS = 25;
|
|
242
|
-
/** The hard ceiling an author's `maxVisits`/`maxNodeVisits` override may reach. */
|
|
243
|
-
declare const MAX_MAX_NODE_VISITS = 100;
|
|
244
|
-
type GraphEdgeKind = 'delegates' | 'analyzes' | 'data';
|
|
245
|
-
interface EngineGraphNode {
|
|
246
|
-
readonly id: string;
|
|
247
|
-
/** `<id>/v<n>` into the engine's kind registry. */
|
|
248
|
-
readonly kind: string;
|
|
249
|
-
/** This node's config, validated by its kind's `validateConfig` at compile. */
|
|
250
|
-
readonly config?: unknown;
|
|
251
|
-
/** Per-node flags — properties of the node, never of its kind (agent-runtime#970). */
|
|
252
|
-
readonly flags?: NodeFlags;
|
|
253
|
-
/** Node-level port declarations, merged OVER the kind's. A kind whose surface depends on its
|
|
254
|
-
* config (a script) declares ports here; a typed kind's declared ports stay authoritative. */
|
|
255
|
-
readonly ports?: {
|
|
256
|
-
readonly inputs?: ReadonlyArray<PortSpec>;
|
|
257
|
-
readonly outputs?: ReadonlyArray<PortSpec>;
|
|
258
|
-
};
|
|
259
|
-
/** Which inbound gating-edge outcomes release this node. Default `all`. */
|
|
260
|
-
readonly join?: JoinRule;
|
|
261
|
-
/** Entered more than this many times fails the run `cycle-budget-exceeded`. */
|
|
262
|
-
readonly maxVisits?: number;
|
|
263
|
-
/** This node's completion check; a terminal without one (or a kind/graph default) refuses. */
|
|
264
|
-
readonly deliverable?: DeliverableSpec<unknown>;
|
|
265
|
-
/** Force-mark a terminal. Absent, a node with no outbound gating edge is terminal. */
|
|
266
|
-
readonly terminal?: boolean;
|
|
267
|
-
/** Force a node out of (or into) the run's entry set. Absent, a node with no inbound edge is an
|
|
268
|
-
* entry, and the declared root always is. A node another node SPAWNS — the `runGraph` preset's
|
|
269
|
-
* workers and analysts — sets `false`: the scheduler must never enter it on its own. */
|
|
270
|
-
readonly entry?: boolean;
|
|
271
|
-
/** Profile fields merged over the engine-authored `{ name: id }` for this node's spawns. */
|
|
272
|
-
readonly profile?: Readonly<Partial<AgentProfile>>;
|
|
273
|
-
/** Per-instance reservation for this node's spawns; falls back to the run's `perNode`. */
|
|
274
|
-
readonly budget?: Budget;
|
|
275
|
-
}
|
|
276
|
-
interface EngineGraphEdge {
|
|
277
|
-
/** Stable id for the ledger; defaults to `<from>-><to>#<ordinal>`. */
|
|
278
|
-
readonly id?: string;
|
|
279
|
-
readonly kind: GraphEdgeKind;
|
|
280
|
-
readonly from: {
|
|
281
|
-
readonly node: string;
|
|
282
|
-
readonly port?: string;
|
|
283
|
-
};
|
|
284
|
-
readonly to: {
|
|
285
|
-
readonly node: string;
|
|
286
|
-
readonly port?: string;
|
|
287
|
-
};
|
|
288
|
-
/** Evaluated over the source's settle context; absent = satisfied by completion. */
|
|
289
|
-
readonly guard?: Condition;
|
|
290
|
-
/** `data` edges only: ONE pure reshape of the admitted payload. */
|
|
291
|
-
readonly projection?: Projection;
|
|
292
|
-
/** Refuses the traversal past this many firings (ledgered `unpropagated`); `0` closes the edge from the start. */
|
|
293
|
-
readonly maxTraversals?: number;
|
|
294
|
-
/** `delegates`/`analyzes`: the versioned directive appended to the target's task. */
|
|
295
|
-
readonly directive?: PromptHandle;
|
|
296
|
-
}
|
|
297
|
-
interface EngineGraphSpec {
|
|
298
|
-
readonly nodes: ReadonlyArray<EngineGraphNode>;
|
|
299
|
-
readonly edges: ReadonlyArray<EngineGraphEdge>;
|
|
300
|
-
/** Root node for the graph-level completion check. Defaults to the single entry node. */
|
|
301
|
-
readonly root?: string;
|
|
302
|
-
/** Becomes the ROOT node's completion check when the root declares none (#973). */
|
|
303
|
-
readonly deliverable?: DeliverableSpec<unknown>;
|
|
304
|
-
readonly maxNodeVisits?: number;
|
|
305
|
-
}
|
|
306
|
-
//#endregion
|
|
307
|
-
//#region src/runtime/graph/engine.d.ts
|
|
308
|
-
interface GraphEngineOptions {
|
|
309
|
-
/** Kinds to register beside the core set. A host adds its own here; nothing is global. */
|
|
310
|
-
readonly kinds?: ReadonlyArray<AnyNodeKind>;
|
|
311
|
-
/** The host's effect table, by name. A kind receives only the effects it declared. */
|
|
312
|
-
readonly effects?: Readonly<Record<EffectName, unknown>>;
|
|
313
|
-
/** The core set. Injected so a test can substitute, and so the engine never imports a
|
|
314
|
-
* backend-specific factory at module load. */
|
|
315
|
-
readonly coreKinds: ReadonlyArray<AnyNodeKind>;
|
|
316
|
-
}
|
|
317
|
-
interface GraphEngine {
|
|
318
|
-
readonly kinds: Registry<AnyNodeKind>;
|
|
319
|
-
readonly effects: Readonly<Record<EffectName, unknown>>;
|
|
320
|
-
/** Every effect name any registered kind declares — what a host must provide for this engine's
|
|
321
|
-
* whole kind set to be runnable. Listed, never discovered mid-run. */
|
|
322
|
-
requiredEffects(): string[];
|
|
323
|
-
/** The declared effects no host value covers. Empty means every registered kind is runnable. */
|
|
324
|
-
missingEffects(): string[];
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Build one engine: a kind registry seeded with the core kinds plus the host's, and the host's
|
|
328
|
-
* effect values. Every kind is validated by name at construction, so a malformed host kind fails
|
|
329
|
-
* here, never at its first node.
|
|
330
|
-
*/
|
|
331
|
-
declare function createGraphEngine(options: GraphEngineOptions): GraphEngine;
|
|
332
|
-
//#endregion
|
|
333
|
-
//#region src/runtime/graph/compile.d.ts
|
|
334
|
-
interface CompiledEdge {
|
|
335
|
-
readonly id: string;
|
|
336
|
-
readonly spec: EngineGraphEdge;
|
|
337
|
-
readonly fromPort: string;
|
|
338
|
-
readonly toPort: string;
|
|
339
|
-
}
|
|
340
|
-
/** `delegates` is the one MODEL-fired edge kind (agent-runtime#971): its payload is a directive and
|
|
341
|
-
* its target is spawned by the source supervisor through the coordination protocol, not released
|
|
342
|
-
* by the scheduler. `data` and `analyzes` are engine-fired. */
|
|
343
|
-
declare function isEngineFired(edge: CompiledEdge): boolean;
|
|
344
|
-
interface CompiledNode {
|
|
345
|
-
readonly id: string;
|
|
346
|
-
readonly kind: NodeKind;
|
|
347
|
-
readonly config: unknown;
|
|
348
|
-
readonly join: JoinRule;
|
|
349
|
-
readonly maxVisits: number;
|
|
350
|
-
readonly oracle: boolean;
|
|
351
|
-
readonly pure: boolean;
|
|
352
|
-
readonly terminal: boolean;
|
|
353
|
-
/** The check this node must pass to count DELIVERED; resolved per #973. */
|
|
354
|
-
readonly deliverable?: DeliverableSpec<unknown>;
|
|
355
|
-
readonly inbound: ReadonlyArray<CompiledEdge>;
|
|
356
|
-
readonly outbound: ReadonlyArray<CompiledEdge>;
|
|
357
|
-
/** Spawned by a supervisor through a `delegates` edge, never entered by the scheduler. */
|
|
358
|
-
readonly modelFired: boolean;
|
|
359
|
-
readonly spec: EngineGraphSpec['nodes'][number];
|
|
360
|
-
}
|
|
361
|
-
interface CompiledGraph {
|
|
362
|
-
readonly nodes: ReadonlyMap<string, CompiledNode>;
|
|
363
|
-
readonly edges: ReadonlyArray<CompiledEdge>;
|
|
364
|
-
readonly entries: ReadonlyArray<string>;
|
|
365
|
-
readonly terminals: ReadonlyArray<string>;
|
|
366
|
-
readonly root: string;
|
|
367
|
-
readonly maxNodeVisits: number;
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Bounded structural acceptance: does a value of `source`'s shape fit `target`? Schemas with no
|
|
371
|
-
* `type` accept anything; object targets require their `required` properties to be present and
|
|
372
|
-
* accepted when the source declares properties. Depth-bounded — this is a compile-time tripwire,
|
|
373
|
-
* not a full JSON Schema validator.
|
|
374
|
-
*/
|
|
375
|
-
declare function schemaAccepts(source: JsonSchema, target: JsonSchema, depth?: number): boolean;
|
|
376
|
-
/**
|
|
377
|
-
* Lower an authored graph against an engine's kind registry into the schedulable form, refusing
|
|
378
|
-
* every structural defect before any spend.
|
|
379
|
-
*/
|
|
380
|
-
declare function compileGraph(engine: GraphEngine, spec: EngineGraphSpec, context?: string): CompiledGraph;
|
|
381
|
-
//#endregion
|
|
382
|
-
//#region src/runtime/graph/scheduler-types.d.ts
|
|
383
|
-
/** Result vocabulary shared by the scheduler and the fold (agent-runtime#973, #974, #976). */
|
|
384
|
-
type GraphRunReason = 'all-children-down' | 'budget-exhausted' | 'aborted' | 'driver-failed' | 'cycle-budget-exceeded' | 'unreachable-terminal';
|
|
385
|
-
/** One node settlement as the graph result reports it. */
|
|
386
|
-
interface GraphNodeSettle {
|
|
387
|
-
readonly node: string;
|
|
388
|
-
readonly visit: number;
|
|
389
|
-
/** Run-wide settle ordinal. `GraphRunResult.settles` is sorted by it, so the array reads in the
|
|
390
|
-
* order the run actually settled — not grouped by node, which is what a reader assumes and
|
|
391
|
-
* what the first consumer of this API tripped on. */
|
|
392
|
-
readonly seq: number;
|
|
393
|
-
readonly status: 'done' | 'down';
|
|
394
|
-
/** The node's completion check verdict; `undefined` when the node declares no check. */
|
|
395
|
-
readonly valid?: boolean;
|
|
396
|
-
readonly out?: unknown;
|
|
397
|
-
readonly outRef?: string;
|
|
398
|
-
readonly reason?: string;
|
|
399
|
-
}
|
|
400
|
-
/** One ledgered edge firing (or refusal) — the run's observable data flow. */
|
|
401
|
-
interface GraphEdgeTraversal {
|
|
402
|
-
readonly edge: string;
|
|
403
|
-
readonly kind: 'delegates' | 'analyzes' | 'data';
|
|
404
|
-
readonly from: string;
|
|
405
|
-
readonly to: string;
|
|
406
|
-
readonly traversal: number;
|
|
407
|
-
readonly outcome: 'delivered' | 'empty' | 'unpropagated';
|
|
408
|
-
readonly directive?: string;
|
|
409
|
-
readonly port?: string;
|
|
410
|
-
readonly reason?: string;
|
|
411
|
-
}
|
|
412
|
-
type GraphRunResult = {
|
|
413
|
-
readonly kind: 'winner';
|
|
414
|
-
readonly out: unknown;
|
|
415
|
-
readonly terminals: ReadonlyArray<GraphNodeSettle>;
|
|
416
|
-
readonly settles: ReadonlyArray<GraphNodeSettle>;
|
|
417
|
-
readonly ledger: ReadonlyArray<GraphEdgeTraversal>;
|
|
418
|
-
} | {
|
|
419
|
-
readonly kind: 'no-winner';
|
|
420
|
-
readonly reason: GraphRunReason;
|
|
421
|
-
readonly error?: {
|
|
422
|
-
readonly name: string;
|
|
423
|
-
readonly message: string;
|
|
424
|
-
};
|
|
425
|
-
readonly terminals: ReadonlyArray<GraphNodeSettle>;
|
|
426
|
-
readonly settles: ReadonlyArray<GraphNodeSettle>;
|
|
427
|
-
readonly ledger: ReadonlyArray<GraphEdgeTraversal>;
|
|
428
|
-
/** Nodes provably stuck when the run ended: every upstream settled, no release possible. */
|
|
429
|
-
readonly unreachable: ReadonlyArray<string>;
|
|
430
|
-
} | {
|
|
431
|
-
/** Every live branch parked on a host wake: a legitimate terminal state for an offline run.
|
|
432
|
-
* Restart over the same journal and `resume(token, payload)` to continue (#976). */
|
|
433
|
-
readonly kind: 'suspended';
|
|
434
|
-
readonly tokens: ReadonlyArray<string>;
|
|
435
|
-
readonly terminals: ReadonlyArray<GraphNodeSettle>;
|
|
436
|
-
readonly settles: ReadonlyArray<GraphNodeSettle>;
|
|
437
|
-
readonly ledger: ReadonlyArray<GraphEdgeTraversal>;
|
|
438
|
-
};
|
|
439
|
-
//#endregion
|
|
440
|
-
//#region src/runtime/graph/fold.d.ts
|
|
441
|
-
type FoldEdgeState = 'pending' | 'satisfied' | 'dead' | 'failed';
|
|
442
|
-
interface FoldEdge {
|
|
443
|
-
state: FoldEdgeState;
|
|
444
|
-
/** Set by a `join-state` whose wave this edge was pending inside; cleared when the in-flight
|
|
445
|
-
* completion it refers to settles (absorbed, never re-released). */
|
|
446
|
-
consumedOnce: boolean;
|
|
447
|
-
/** Delivered consumptions — what the per-edge cap counts. */
|
|
448
|
-
traversals: number;
|
|
449
|
-
/** How many of the source's settles this edge has accounted for — by a journaled verdict or by
|
|
450
|
-
* an absorption. The idempotence key: a kill between a settle and its verdicts re-judges ONLY
|
|
451
|
-
* the unaccounted edges on restart, never a judged or absorbed one twice. */
|
|
452
|
-
judgedSourceSettles: number;
|
|
453
|
-
/** The admitted source payload this state reflects (the source settle's outRef). */
|
|
454
|
-
payloadRef?: string;
|
|
455
|
-
capped: boolean;
|
|
456
|
-
}
|
|
457
|
-
type FoldInstanceStatus = 'released' | 'live' | 'done' | 'down' | 'suspended';
|
|
458
|
-
interface FoldInstance {
|
|
459
|
-
readonly node: string;
|
|
460
|
-
readonly instance: string;
|
|
461
|
-
readonly visit: number;
|
|
462
|
-
inputRef?: string;
|
|
463
|
-
status: FoldInstanceStatus;
|
|
464
|
-
settle?: GraphNodeSettle;
|
|
465
|
-
/**
|
|
466
|
-
* Whether this instance's release consumed its wave — the `join-state` the
|
|
467
|
-
* scheduler journals AFTER the envelope pin. A restart that finds a
|
|
468
|
-
* released instance without it completes the half-journaled release rather
|
|
469
|
-
* than leaving the gating edges satisfied, which would release the node a
|
|
470
|
-
* second time and execute it twice.
|
|
471
|
-
*/
|
|
472
|
-
waveConsumed?: boolean;
|
|
473
|
-
}
|
|
474
|
-
interface FoldSuspension {
|
|
475
|
-
readonly token: string;
|
|
476
|
-
readonly node: string;
|
|
477
|
-
readonly instance: string;
|
|
478
|
-
readonly onExpire: 'wait' | 'fail' | 'default';
|
|
479
|
-
readonly expiresAtMs?: number;
|
|
480
|
-
readonly defaultRef?: string;
|
|
481
|
-
status: 'pending' | 'woken' | 'expired';
|
|
482
|
-
}
|
|
483
|
-
interface FoldNode {
|
|
484
|
-
visits: number;
|
|
485
|
-
blocked: boolean;
|
|
486
|
-
settles: GraphNodeSettle[];
|
|
487
|
-
}
|
|
488
|
-
interface GraphFoldState {
|
|
489
|
-
/** Next settle ordinal; the fold is the only writer, so replay reproduces the same order. */
|
|
490
|
-
settleSeq: {
|
|
491
|
-
value: number;
|
|
492
|
-
};
|
|
493
|
-
readonly nodes: Map<string, FoldNode>;
|
|
494
|
-
readonly edges: Map<string, FoldEdge>;
|
|
495
|
-
/** Every node instance the journal knows, keyed by `<node>#<visit>`. */
|
|
496
|
-
readonly instances: Map<string, FoldInstance>;
|
|
497
|
-
/** Kernel node id → engine instance label, from `spawned`. */
|
|
498
|
-
readonly spawnedIds: Map<string, string>;
|
|
499
|
-
readonly suspensions: Map<string, FoldSuspension>;
|
|
500
|
-
readonly exhaustedEdges: Set<string>;
|
|
501
|
-
}
|
|
502
|
-
/** The reducer's zero: every node unvisited, every edge pending, nothing suspended. */
|
|
503
|
-
declare function emptyFoldState(compiled: CompiledGraph): GraphFoldState;
|
|
504
|
-
/**
|
|
505
|
-
* Apply ONE journal event. The live scheduler calls this right after each append; the restart path
|
|
506
|
-
* calls it over the loaded journal. Unknown kernel events are ignored — the engine folds only what
|
|
507
|
-
* it understands, exactly as the kernel's replay skips the engine's events.
|
|
508
|
-
*/
|
|
509
|
-
declare function applyGraphFoldEvent(state: GraphFoldState, ev: SpawnEvent, compiled: CompiledGraph): void;
|
|
510
|
-
/** Fold a loaded journal (append order) into scheduler state. */
|
|
511
|
-
declare function foldGraphJournal(events: ReadonlyArray<SpawnEvent>, compiled: CompiledGraph): GraphFoldState;
|
|
512
|
-
//#endregion
|
|
513
|
-
//#region src/runtime/graph/join.d.ts
|
|
514
|
-
interface GatingEdge {
|
|
515
|
-
readonly edge: CompiledEdge;
|
|
516
|
-
readonly folded: FoldEdge | undefined;
|
|
517
|
-
}
|
|
518
|
-
interface JoinDecision {
|
|
519
|
-
/** Whether the node releases now. */
|
|
520
|
-
readonly release: boolean;
|
|
521
|
-
/** The edges whose outcomes produced this release — the ones a traversal cap judges. */
|
|
522
|
-
readonly consuming: ReadonlyArray<GatingEdge>;
|
|
523
|
-
/** Whether the node can never release again on this wave (recorded like skipped-by-guard). */
|
|
524
|
-
readonly blocked: boolean;
|
|
525
|
-
}
|
|
526
|
-
/** Decide whether a node's gating edges release it, and which of them the release consumes. */
|
|
527
|
-
declare function decideJoin(rule: JoinRule, gating: ReadonlyArray<GatingEdge>): JoinDecision;
|
|
528
|
-
//#endregion
|
|
529
|
-
//#region src/runtime/graph/kinds.d.ts
|
|
530
|
-
interface AgentKindConfig {
|
|
531
|
-
/** Where this node's profile runs. Omit to inherit the engine's default backend. */
|
|
532
|
-
readonly backend?: ExecutorConfig;
|
|
533
|
-
/** This node's completion check. Omit to inherit the graph's terminal check. */
|
|
534
|
-
readonly deliverable?: DeliverableSpec<unknown>;
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
* One profile, one run: the kernel's leaf, exactly as `supervise()` derives it from `backend`.
|
|
538
|
-
* The model cannot decide this — it is what gets run.
|
|
539
|
-
*/
|
|
540
|
-
declare function agentKind(defaults: {
|
|
541
|
-
readonly backend?: ExecutorConfig;
|
|
542
|
-
readonly deliverable?: DeliverableSpec<unknown>;
|
|
543
|
-
}): NodeKind<AgentKindConfig>;
|
|
544
|
-
interface SupervisorKindConfig {
|
|
545
|
-
/** Per-child budget reserved from the pool on each spawn this supervisor makes. */
|
|
546
|
-
readonly perWorker: SupervisorAgentDeps['perWorker'];
|
|
547
|
-
readonly maxLiveWorkers?: number;
|
|
548
|
-
}
|
|
549
|
-
/**
|
|
550
|
-
* The thing that DECIDES: a nested `supervisorAgent` with the coordination verbs. Its children
|
|
551
|
-
* are its own tree — the graph sees one node in, one `Settled` out. A `subgraph` constrains what
|
|
552
|
-
* it may spawn; without one it is free-form under `profileSecurity` and `allowedModels`.
|
|
553
|
-
*/
|
|
554
|
-
declare function supervisorKind(deps: {
|
|
555
|
-
readonly blobs: SupervisorAgentDeps['blobs'];
|
|
556
|
-
readonly makeWorkerAgent: MakeWorkerAgent;
|
|
557
|
-
readonly router?: SupervisorAgentDeps['router'];
|
|
558
|
-
readonly driveHarness?: SupervisorAgentDeps['driveHarness'];
|
|
559
|
-
}): NodeKind<SupervisorKindConfig>;
|
|
560
|
-
/** The caller code a `script` node runs. Receives the resolved inputs; returns the output. */
|
|
561
|
-
type ScriptBody = (inputs: Readonly<Record<string, unknown>>, signal: AbortSignal) => Promise<unknown> | unknown;
|
|
562
|
-
interface ScriptKindConfig {
|
|
563
|
-
readonly body: ScriptBody;
|
|
564
|
-
/**
|
|
565
|
-
* `pure: true` is the promise that the output is a function of `(config, inputs)` alone: the
|
|
566
|
-
* node is then budget-exempt, its output restorable on replay by content address, and it runs
|
|
567
|
-
* in-process. A pure script that settles with a different `outRef` for the same inputs has
|
|
568
|
-
* lied, and the first replay mismatch is an engine error.
|
|
569
|
-
*/
|
|
570
|
-
readonly pure?: boolean;
|
|
571
|
-
/** For a metered script: what it spent. Omit on a pure script. A metered script that reports
|
|
572
|
-
* nothing is metered as NOTHING-KNOWN, never as free. */
|
|
573
|
-
readonly spent?: Spend;
|
|
574
|
-
}
|
|
575
|
-
/**
|
|
576
|
-
* Caller code as a node. The one kind with no kernel primitive behind it: the kernel has no
|
|
577
|
-
* "data→data with no execution" concept (agent-runtime#970 fact-finding), so this is new. It is
|
|
578
|
-
* still a leaf `Agent` carrying an `Executor`, so the journal, the gate and the pool treat it like
|
|
579
|
-
* any other node.
|
|
580
|
-
*/
|
|
581
|
-
declare function scriptKind(): NodeKind<ScriptKindConfig>;
|
|
582
|
-
/**
|
|
583
|
-
* A node carrying its own graph: the constraint on what a supervisor may spawn at depth>1. Its
|
|
584
|
-
* executor is a nested engine run; that needs the scheduler (#980), so until then this kind is
|
|
585
|
-
* registered and REFUSES at run time by name rather than being absent — a graph that names it
|
|
586
|
-
* compiles, and the refusal says exactly what is missing.
|
|
587
|
-
*/
|
|
588
|
-
/** Config for a nesting node: the inner graph, and the pool the inner run is given. */
|
|
589
|
-
interface SubgraphKindConfig {
|
|
590
|
-
readonly graph: unknown;
|
|
591
|
-
/** The inner run's conserved pool. Its spend is the inner pool's, never re-charged here. */
|
|
592
|
-
readonly budget?: unknown;
|
|
593
|
-
readonly perNode?: unknown;
|
|
594
|
-
}
|
|
595
|
-
/** A node carrying its own graph: it runs as a full engine run on the host's kinds and effects. */
|
|
596
|
-
declare function subgraphKind(): NodeKind<SubgraphKindConfig>;
|
|
597
|
-
//#endregion
|
|
598
|
-
//#region src/runtime/graph/ledger.d.ts
|
|
599
|
-
interface EdgeLedger {
|
|
600
|
-
readonly entries: ReadonlyArray<GraphEdgeTraversal>;
|
|
601
|
-
record(edge: CompiledEdge, traversal: number, outcome: GraphEdgeTraversal['outcome'], reason?: string): Promise<void>;
|
|
602
|
-
}
|
|
603
|
-
/** Open a ledger for one run; its ordinals continue past whatever a prior process recorded. */
|
|
604
|
-
declare function createEdgeLedger(args: {
|
|
605
|
-
readonly journal: SpawnJournal;
|
|
606
|
-
readonly runId: string;
|
|
607
|
-
readonly now: () => number;
|
|
608
|
-
readonly startSeq: number;
|
|
609
|
-
}): EdgeLedger;
|
|
610
|
-
//#endregion
|
|
611
|
-
//#region src/runtime/graph/preset-run-graph.d.ts
|
|
612
|
-
/** The kind id the root node carries: a supervisor holding the whole `AgentGraph`. */
|
|
613
|
-
declare const RUN_GRAPH_ROOT_KIND = "supervisor/v1";
|
|
614
|
-
/**
|
|
615
|
-
* Compile an `AgentGraph` into the engine graph that describes it. Pure: nothing runs, nothing is
|
|
616
|
-
* registered, no executor is built. A `delegates` edge is MODEL-fired (#971) — its target is
|
|
617
|
-
* spawned by the supervisor through the coordination protocol — so every worker node is marked
|
|
618
|
-
* `entry: false`, which is exactly what the engine's scheduler would honour if this graph were
|
|
619
|
-
* handed to it.
|
|
620
|
-
*/
|
|
621
|
-
declare function graphFromRunGraph(graph: AgentGraph, options: RunGraphOptions): EngineGraphSpec;
|
|
622
|
-
//#endregion
|
|
623
|
-
//#region src/runtime/graph/result.d.ts
|
|
624
|
-
type FinalizerChoice = 'bestDelivered' | 'collectDelivered' | SupervisorFinalizer;
|
|
625
|
-
/** Every node settlement with its output rehydrated and its completion check applied. */
|
|
626
|
-
declare function materializeSettles(compiled: CompiledGraph, state: GraphFoldState, blobs: ResultBlobStore, outCache: ReadonlyMap<string, unknown>): Promise<GraphNodeSettle[]>;
|
|
627
|
-
/** Turn a finished run into its result: rehydrate, reduce the terminals, classify a no-winner. */
|
|
628
|
-
declare function assembleGraphResult(args: {
|
|
629
|
-
readonly compiled: CompiledGraph;
|
|
630
|
-
readonly state: GraphFoldState;
|
|
631
|
-
readonly blobs: ResultBlobStore;
|
|
632
|
-
readonly scope: Scope<unknown>;
|
|
633
|
-
readonly outCache: ReadonlyMap<string, unknown>;
|
|
634
|
-
readonly ledger: ReadonlyArray<GraphEdgeTraversal>;
|
|
635
|
-
readonly finalizer?: FinalizerChoice;
|
|
636
|
-
readonly failure?: {
|
|
637
|
-
readonly reason: GraphRunReason;
|
|
638
|
-
readonly error?: {
|
|
639
|
-
name: string;
|
|
640
|
-
message: string;
|
|
641
|
-
};
|
|
642
|
-
};
|
|
643
|
-
readonly aborted: boolean;
|
|
644
|
-
}): Promise<GraphRunResult>;
|
|
645
|
-
//#endregion
|
|
646
|
-
//#region src/runtime/graph/run-context.d.ts
|
|
647
|
-
/** Engine-appended `woken` ordinals start here — far above any kernel cursor counter, so the two
|
|
648
|
-
* counters can advance independently without ever colliding. */
|
|
649
|
-
declare const ENGINE_WOKEN_SEQ_BASE = 10000000;
|
|
650
|
-
interface GraphRunContext {
|
|
651
|
-
readonly runId: string;
|
|
652
|
-
readonly journal: SpawnJournal;
|
|
653
|
-
readonly blobs: ResultBlobStore;
|
|
654
|
-
readonly scope: Scope<unknown>;
|
|
655
|
-
readonly abort: AbortController;
|
|
656
|
-
readonly state: GraphFoldState;
|
|
657
|
-
readonly resuming: boolean;
|
|
658
|
-
/** Journal events present before this process started; empty on a fresh run. */
|
|
659
|
-
readonly prior: ReadonlyArray<SpawnEvent>;
|
|
660
|
-
/** Next engine fold-event ordinal, and next engine `woken` ordinal. */
|
|
661
|
-
readonly engineSeq: number;
|
|
662
|
-
readonly engineWokenSeq: number;
|
|
663
|
-
/** Ledger ordinals already used by a prior process. */
|
|
664
|
-
readonly ledgerSeq: number;
|
|
665
|
-
}
|
|
666
|
-
/** Begin or resume a run's journaled tree, pool, scope and folded state. */
|
|
667
|
-
declare function openGraphRun(args: {
|
|
668
|
-
readonly compiled: CompiledGraph;
|
|
669
|
-
readonly runId: string;
|
|
670
|
-
readonly budget: Budget;
|
|
671
|
-
readonly journal?: SpawnJournal;
|
|
672
|
-
readonly blobs?: ResultBlobStore;
|
|
673
|
-
readonly now: () => number;
|
|
674
|
-
readonly resume?: boolean;
|
|
675
|
-
readonly signal?: AbortSignal;
|
|
676
|
-
readonly onAbort: (listener: () => void) => void;
|
|
677
|
-
}): Promise<GraphRunContext>;
|
|
678
|
-
//#endregion
|
|
679
|
-
//#region src/runtime/graph/admit.d.ts
|
|
680
|
-
/**
|
|
681
|
-
* Edge payload admission (agent-runtime#971): every value crossing an edge is JSON round-tripped,
|
|
682
|
-
* `undefined` stripped to absence, and a non-representable value (a cycle, a BigInt, a function)
|
|
683
|
-
* becomes a RECORD of that fact. This is the kernel's existing findings-guard rule, and it is what
|
|
684
|
-
* makes `inputRef` stable and `onCrash: 'restart'` well defined — a degraded record beats a
|
|
685
|
-
* vanished edge.
|
|
686
|
-
*/
|
|
687
|
-
declare function admitPayload(value: unknown): unknown;
|
|
688
|
-
//#endregion
|
|
689
|
-
//#region src/runtime/graph/suspension.d.ts
|
|
690
|
-
declare const SUSPEND_MARK = "__graphSuspension";
|
|
691
|
-
/** What a kind's executor returns to park its node until a host wakes it. */
|
|
692
|
-
interface SuspensionRequest {
|
|
693
|
-
readonly [SUSPEND_MARK]: true;
|
|
694
|
-
readonly onExpire: 'wait' | 'fail' | 'default';
|
|
695
|
-
/** Milliseconds from the suspension's journaling instant; absent with `onExpire: 'wait'`. */
|
|
696
|
-
readonly expiresInMs?: number;
|
|
697
|
-
readonly default?: unknown;
|
|
698
|
-
}
|
|
699
|
-
/** Build a suspension request. `wait` never expires; `fail` settles the node down at its deadline;
|
|
700
|
-
* `default` resolves with the given payload. */
|
|
701
|
-
declare function suspended(options?: {
|
|
702
|
-
readonly onExpire?: 'wait' | 'fail' | 'default';
|
|
703
|
-
readonly expiresInMs?: number;
|
|
704
|
-
readonly default?: unknown;
|
|
705
|
-
}): SuspensionRequest;
|
|
706
|
-
/** Whether a node's output is a park request rather than its result. */
|
|
707
|
-
declare function isSuspensionRequest(value: unknown): value is SuspensionRequest;
|
|
708
|
-
/** Content-addressed over the run identity, so a restart recomputes it and needs no token table. */
|
|
709
|
-
declare function mintSuspensionToken(runId: string, instance: string): string;
|
|
710
|
-
/** The journal id one suspension's `waiting`/`woken` pair shares. */
|
|
711
|
-
declare function suspensionNodeId(token: string): string;
|
|
712
|
-
/** The token inside a suspension node id, or `undefined` for any other id. */
|
|
713
|
-
declare function tokenFromSuspensionNodeId(id: string): string | undefined;
|
|
714
|
-
//#endregion
|
|
715
|
-
//#region src/runtime/graph/scheduler.d.ts
|
|
716
|
-
interface GraphRunOptions {
|
|
717
|
-
/** The run's conserved pool. */
|
|
718
|
-
readonly budget: Budget;
|
|
719
|
-
/** Default per-instance reservation for nodes that declare no `budget` of their own.
|
|
720
|
-
* Required when any such node exists — the engine invents no split. */
|
|
721
|
-
readonly perNode?: Budget;
|
|
722
|
-
readonly journal?: SpawnJournal;
|
|
723
|
-
readonly blobs?: ResultBlobStore;
|
|
724
|
-
/** Resolves `delegates`/`analyzes` directives; required when any edge carries one. */
|
|
725
|
-
readonly prompts?: PromptRegistry;
|
|
726
|
-
/** How terminal settles reduce to `out`. Default `bestDelivered`. */
|
|
727
|
-
readonly finalizer?: FinalizerChoice;
|
|
728
|
-
readonly signal?: AbortSignal;
|
|
729
|
-
readonly now?: () => number;
|
|
730
|
-
readonly runId?: string;
|
|
731
|
-
/** Continue an existing journaled run. An existing tree without this refuses, like the kernel. */
|
|
732
|
-
readonly resume?: boolean;
|
|
733
|
-
/** Hold a fully-suspended run open for live `resume()` calls instead of returning
|
|
734
|
-
* `{ kind: 'suspended' }`. Offline callers leave this off and restart later (#976). */
|
|
735
|
-
readonly waitForWakes?: boolean;
|
|
736
|
-
}
|
|
737
|
-
/** A live run: await `done`; deliver host wakes through `resume`/`expire` (#976). */
|
|
738
|
-
interface GraphRunHandle {
|
|
739
|
-
readonly done: Promise<GraphRunResult>;
|
|
740
|
-
resume(token: string, payload: unknown): Promise<void>;
|
|
741
|
-
expire(token: string): Promise<void>;
|
|
742
|
-
}
|
|
743
|
-
/** Run a graph to its result: `createGraphRun` awaited — the one-call form for a run that needs no
|
|
744
|
-
* live host wakes. */
|
|
745
|
-
declare function runEngineGraph(engine: GraphEngine, spec: EngineGraphSpec | CompiledGraph, task: string, options: GraphRunOptions): Promise<GraphRunResult>;
|
|
746
|
-
/**
|
|
747
|
-
* Start (or resume) a graph run and return its handle: await `done` for the result; deliver host
|
|
748
|
-
* wakes through `resume`/`expire` while it runs (#976).
|
|
749
|
-
*/
|
|
750
|
-
declare function createGraphRun(engine: GraphEngine, spec: EngineGraphSpec | CompiledGraph, task: string, options: GraphRunOptions): GraphRunHandle;
|
|
751
|
-
//#endregion
|
|
752
|
-
export { type AgentKindConfig, type AnyNodeKind, type AuthoredCodeOptions, type BudgetMode, CONDITION_OPS, type CompiledEdge, type CompiledGraph, type CompiledNode, type Condition, type ConditionLeaf, type ConditionOp, DEFAULT_MAX_NODE_VISITS, ENGINE_WOKEN_SEQ_BASE, type EdgeLedger, type EffectContext, type EffectName, type EngineGraphEdge, type EngineGraphNode, type EngineGraphSpec, type FinalizerChoice, type FoldEdge, type FoldEdgeState, type FoldInstance, type FoldInstanceStatus, type FoldNode, type FoldSuspension, type GatingEdge, type GraphEdgeKind, type GraphEdgeTraversal, type GraphEngine, type GraphEngineOptions, type GraphFoldState, type GraphHost, type GraphNodeSettle, type GraphRunContext, type GraphRunHandle, type GraphRunOptions, type GraphRunReason, type GraphRunResult, JOIN_RULES, type JoinDecision, type JoinRule, type JsonSchema, MAX_MAX_NODE_VISITS, type NodeFlags, type NodeKind, type OnCrash, type PortSpec, type Projection, RUN_GRAPH_ROOT_KIND, type Registered, type Registry, type RegistryHandle, type ScriptBody, type ScriptKindConfig, type SubgraphKindConfig, type SupervisorKindConfig, type SuspensionRequest, admitPayload, agentKind, applyGraphFoldEvent, applyProjection, assembleGraphResult, assertAuthoredCode, compileGraph, createEdgeLedger, createGraphEngine, createGraphRun, createRegistry, decideJoin, emptyFoldState, evaluateCondition, foldGraphJournal, formatRegistryHandle, graphFromRunGraph, isEngineFired, isSuspensionRequest, kindHandle, materializeSettles, mintSuspensionToken, narrowEffects, openGraphRun, parseRegistryHandle, runEngineGraph, schemaAccepts, scriptKind, subgraphKind, supervisorKind, suspended, suspensionNodeId, tokenFromSuspensionNodeId, validateCondition, validateNodeKind, validateProjection };
|
|
753
|
-
//# sourceMappingURL=graph.d.ts.map
|