@tangle-network/agent-runtime 0.52.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -16
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +5 -3
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/analyst-loop.js +2 -2
- package/dist/{chunk-COAVO6QB.js → chunk-2BDXWZUC.js} +5 -34
- package/dist/chunk-2BDXWZUC.js.map +1 -0
- package/dist/chunk-A73RADPB.js +281 -0
- package/dist/chunk-A73RADPB.js.map +1 -0
- package/dist/chunk-FRBWCJLP.js +396 -0
- package/dist/chunk-FRBWCJLP.js.map +1 -0
- package/dist/chunk-GRAGM4MC.js +72 -0
- package/dist/chunk-GRAGM4MC.js.map +1 -0
- package/dist/{chunk-2OU7ZQPD.js → chunk-JTH2FPCK.js} +3248 -456
- package/dist/chunk-JTH2FPCK.js.map +1 -0
- package/dist/{chunk-V2K35HF2.js → chunk-KJH62YEK.js} +2 -2
- package/dist/{chunk-HNUXAZIJ.js → chunk-P5OKDSLB.js} +2 -2
- package/dist/{chunk-GSUO5QS6.js → chunk-VLF5RHEQ.js} +2 -5
- package/dist/{chunk-GSUO5QS6.js.map → chunk-VLF5RHEQ.js.map} +1 -1
- package/dist/{chunk-7JITYN6T.js → chunk-XRYEZPR6.js} +18 -2
- package/dist/chunk-XRYEZPR6.js.map +1 -0
- package/dist/{coder-_YCf3BAK.d.ts → coder-CEkUFv8h.d.ts} +1 -1
- package/dist/{types-5MGt5KTY.d.ts → coordination-BMzskrUR.d.ts} +268 -2
- package/dist/{kb-gate-CHAyt4aI.d.ts → delegates-BPLIl8EC.d.ts} +491 -566
- package/dist/{delegation-profile-1GbW5yA3.d.ts → delegation-profile-Bvfro2m1.d.ts} +28 -2
- package/dist/index.d.ts +7 -7
- package/dist/index.js +25 -80
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +475 -5
- package/dist/intelligence.js +547 -3
- package/dist/intelligence.js.map +1 -1
- package/dist/kb-gate-CuzMYGYM.d.ts +76 -0
- package/dist/{loop-runner-bin-DFUNgpeK.d.ts → loop-runner-bin-BGpVVyXp.d.ts} +6 -27
- package/dist/loop-runner-bin.d.ts +5 -5
- package/dist/loop-runner-bin.js +6 -5
- package/dist/loops.d.ts +8 -5
- package/dist/loops.js +32 -8
- package/dist/mcp/bin.js +94 -30
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +10 -273
- package/dist/mcp/index.js +45 -365
- package/dist/mcp/index.js.map +1 -1
- package/dist/{openai-tools-D4HLDWgw.d.ts → openai-tools-CoeLQ7Uo.d.ts} +1 -1
- package/dist/profiles.d.ts +2 -2
- package/dist/profiles.js +4 -4
- package/dist/router-client-30Y_pca8.d.ts +120 -0
- package/dist/{run-loop-BIineL1T.d.ts → run-loop-DluzfJ2h.d.ts} +1 -1
- package/dist/runtime.d.ts +429 -131
- package/dist/runtime.js +32 -8
- package/dist/topology.d.ts +54 -1
- package/dist/topology.js +222 -0
- package/dist/topology.js.map +1 -1
- package/dist/{types-BEQsBhOE.d.ts → types-C8rNlxfV.d.ts} +6 -5
- package/dist/workflow.d.ts +2 -2
- package/dist/workflow.js +4 -2
- package/dist/workflow.js.map +1 -1
- package/package.json +5 -5
- package/skills/agent-runtime-adoption/SKILL.md +54 -46
- package/skills/build-with-agent-runtime/SKILL.md +12 -8
- package/skills/loop-writer/SKILL.md +9 -1
- package/skills/supervise/SKILL.md +24 -0
- package/dist/chunk-2OU7ZQPD.js.map +0 -1
- package/dist/chunk-4JI4BCBI.js +0 -623
- package/dist/chunk-4JI4BCBI.js.map +0 -1
- package/dist/chunk-7JITYN6T.js.map +0 -1
- package/dist/chunk-7SP2OVYZ.js +0 -908
- package/dist/chunk-7SP2OVYZ.js.map +0 -1
- package/dist/chunk-BERLUBAP.js +0 -1356
- package/dist/chunk-BERLUBAP.js.map +0 -1
- package/dist/chunk-COAVO6QB.js.map +0 -1
- package/dist/driver-DLI1io57.d.ts +0 -221
- /package/dist/{chunk-V2K35HF2.js.map → chunk-KJH62YEK.js.map} +0 -0
- /package/dist/{chunk-HNUXAZIJ.js.map → chunk-P5OKDSLB.js.map} +0 -0
package/dist/runtime.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { AgentProfile, BackendType, CreateSandboxOptions, SandboxInstance, SandboxEvent } from '@tangle-network/sandbox';
|
|
2
2
|
export { AgentProfile, CreateSandboxOptions, SandboxEvent, SandboxInstance } from '@tangle-network/sandbox';
|
|
3
|
-
import { R as ResultBlobStore,
|
|
4
|
-
export {
|
|
3
|
+
import { R as ResultBlobStore, p as SpawnJournal, N as NodeId, q as SpawnEvent, T as TreeView, r as Settled, s as AgentSpec, E as ExecutorRegistry, B as Budget, t as Agent, u as RootHandle, v as SupervisedResult, w as Spend, x as Scope, y as ExecutorFactory, z as Executor, U as UsageEvent, M as MakeWorkerAgent, D as Supervisor } from './coordination-BMzskrUR.js';
|
|
4
|
+
export { G as ExecutorContext, H as ExecutorResult, K as Handle, L as NodeSnapshot, O as NodeStatus, P as Restart, V as RootSignal, W as Runtime, X as SpawnOpts, Y as SupervisorOpts, Z as WidenGate } from './coordination-BMzskrUR.js';
|
|
5
5
|
import { R as RuntimeHooks } from './runtime-hooks-C7JwKb9E.js';
|
|
6
6
|
import { ChatClient, AnalystFinding, DefaultVerdict, AgentProfile as AgentProfile$1, AnalystRunInputs } from '@tangle-network/agent-eval';
|
|
7
7
|
export { DefaultVerdict } from '@tangle-network/agent-eval';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export { D as Driver, F as LoopDecisionPayload, G as LoopEndedPayload, H as LoopIterationDispatchPayload, J as LoopIterationEndedPayload, M as LoopIterationStartedPayload, a as LoopLineageOptions, N as LoopPlanDescription, P as LoopPlanPayload, e as LoopSandboxPlacement, Q as LoopStartedPayload, T as LoopTeardownFailedPayload, f as LoopTraceEmitter, g as LoopTraceEvent, L as LoopWinner, O as OutputAdapter, U as ValidationCtx, V as Validator } from './types-BEQsBhOE.js';
|
|
8
|
+
import { I as Iteration, S as SandboxClient, b as LoopResult, d as LoopTokenUsage, R as RuntimeStreamEvent, A as AgentRunSpec, E as ExecCtx } from './types-C8rNlxfV.js';
|
|
9
|
+
export { D as Driver, F as LoopDecisionPayload, G as LoopEndedPayload, H as LoopIterationDispatchPayload, J as LoopIterationEndedPayload, M as LoopIterationStartedPayload, a as LoopLineageOptions, N as LoopPlanDescription, P as LoopPlanPayload, f as LoopSandboxPlacement, Q as LoopStartedPayload, T as LoopTeardownFailedPayload, g as LoopTraceEmitter, e as LoopTraceEvent, L as LoopWinner, O as OutputAdapter, U as ValidationCtx, V as Validator } from './types-C8rNlxfV.js';
|
|
11
10
|
import { Scenario, ProfileDispatchFn } from '@tangle-network/agent-eval/campaign';
|
|
12
|
-
import { R as RunLoopOptions } from './run-loop-
|
|
13
|
-
export { c as createSandboxForSpec, d as defaultSelectWinner, r as runLoop } from './run-loop-
|
|
11
|
+
import { R as RunLoopOptions } from './run-loop-DluzfJ2h.js';
|
|
12
|
+
export { c as createSandboxForSpec, d as defaultSelectWinner, r as runLoop } from './run-loop-DluzfJ2h.js';
|
|
14
13
|
import { b as AnalystRegistryLike } from './types-p8dWBIXL.js';
|
|
14
|
+
import { R as RouterConfig, T as ToolSpec } from './router-client-30Y_pca8.js';
|
|
15
|
+
export { a as RouterChatResult, b as RouterChatToolsResult, c as RouterToolCall, d as RouterToolLoopResult, r as routerChatWithTools, e as routerChatWithUsage, f as routerToolLoop } from './router-client-30Y_pca8.js';
|
|
16
|
+
import './delegates-BPLIl8EC.js';
|
|
17
|
+
import './coder-CEkUFv8h.js';
|
|
18
|
+
import './substrate-CUgk7F7s.js';
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
21
|
* @experimental
|
|
@@ -310,6 +314,85 @@ interface IntentAudit {
|
|
|
310
314
|
declare const defaultAuditorInstruction: string;
|
|
311
315
|
declare function auditIntent(input: AuditIntentInput, opts: AuditIntentOptions): Promise<IntentAudit>;
|
|
312
316
|
|
|
317
|
+
/**
|
|
318
|
+
* @experimental
|
|
319
|
+
*
|
|
320
|
+
* Completion / satisfiability — the OTHER output of the pluggable analyst (the steer output
|
|
321
|
+
* is `AnalystFinding[]` via the `analyze` hook; this is the "is it done?" output via the
|
|
322
|
+
* `complete` hook). A `CompletionAnalyst` reads a node's trace and returns a `CompletionVerdict`
|
|
323
|
+
* the PARENT (driver) acts on: end the node, or keep going. It fits ANY node and composes to
|
|
324
|
+
* any depth — a 1-deep loop has one; an N-deep tree has one per node.
|
|
325
|
+
*
|
|
326
|
+
* The verdict's authority scales with its DETERMINISM (the thing that varies by task):
|
|
327
|
+
* - `deterministic` — build/test/lint pass, a proof checks, every claim's citation resolves:
|
|
328
|
+
* ground truth, the driver TRUSTS it and ends. Not an opinion.
|
|
329
|
+
* - `probabilistic` — a quality/soundness judgment (marketing, "the experiment is sound"):
|
|
330
|
+
* ADVISORY. It passes to the driver with its reasons; the driver validates (here: a
|
|
331
|
+
* confidence threshold; a richer driver may re-examine the reasons) before ending.
|
|
332
|
+
*
|
|
333
|
+
* Two stop-signal mechanisms, by node mode, both → one `CompletionVerdict`:
|
|
334
|
+
* - sandbox-agent (text stream): a unique per-node STOP SENTINEL the agent emits when done
|
|
335
|
+
* (`stopSentinel` / `sentinelCompletion`) — ralph-loop style; the seed makes it
|
|
336
|
+
* unguessable + attributable, so it can't be spuriously emitted or confused with content.
|
|
337
|
+
* - deterministic check (compile/test/citation/proof): `deterministicCompletion(check)` —
|
|
338
|
+
* a verifier over the output, never the judge verdict (selector ≠ judge holds).
|
|
339
|
+
*/
|
|
340
|
+
|
|
341
|
+
/** Trace-derived evidence for a completion claim — an artifact (output) or a verifier metric,
|
|
342
|
+
* never the judge's own verdict. Mirrors the steer-firewall's provenance discipline. */
|
|
343
|
+
interface CompletionEvidence {
|
|
344
|
+
kind: 'artifact' | 'metric';
|
|
345
|
+
uri: string;
|
|
346
|
+
}
|
|
347
|
+
/** The "is it done?" verdict an analyst returns to the parent. */
|
|
348
|
+
interface CompletionVerdict {
|
|
349
|
+
done: boolean;
|
|
350
|
+
/** How verifiable the claim is — sets whether the driver trusts it or validates it. */
|
|
351
|
+
determinism: 'deterministic' | 'probabilistic';
|
|
352
|
+
/** Why the analyst believes it is (or isn't) done — what the driver validates. */
|
|
353
|
+
reasons?: string;
|
|
354
|
+
/** 0..1, for probabilistic verdicts; the driver's validation threshold reads this. */
|
|
355
|
+
confidence?: number;
|
|
356
|
+
evidence?: ReadonlyArray<CompletionEvidence>;
|
|
357
|
+
}
|
|
358
|
+
/** Reads a node's trace → a completion verdict. Same input shape as the `analyze` hook, so
|
|
359
|
+
* ONE analyst node can back both channels (findings for steer, a verdict for stop). */
|
|
360
|
+
interface CompletionAnalyst<Task, Output> {
|
|
361
|
+
assess(input: {
|
|
362
|
+
task: Task;
|
|
363
|
+
history: ReadonlyArray<Iteration<Task, Output>>;
|
|
364
|
+
}): CompletionVerdict | Promise<CompletionVerdict>;
|
|
365
|
+
}
|
|
366
|
+
/** When a verdict authorizes the driver to END. Deterministic → trust (ground truth);
|
|
367
|
+
* probabilistic → validate by confidence threshold (the driver's check). */
|
|
368
|
+
interface CompletionPolicy {
|
|
369
|
+
/** Minimum confidence a PROBABILISTIC verdict must clear to end. Default 0.8. */
|
|
370
|
+
minConfidence?: number;
|
|
371
|
+
}
|
|
372
|
+
declare function completionAuthorizes(v: CompletionVerdict, policy?: CompletionPolicy): boolean;
|
|
373
|
+
/**
|
|
374
|
+
* A unique, attributable stop sentinel for a node (ralph-loop style). Deterministic from the
|
|
375
|
+
* seed (no Math.random — reproducible + attributable to the node); the agent is instructed to
|
|
376
|
+
* emit it VERBATIM when it judges itself done. Unguessable enough that content never trips it.
|
|
377
|
+
*/
|
|
378
|
+
declare function stopSentinel(seed: string): string;
|
|
379
|
+
/**
|
|
380
|
+
* Completion for a sandbox-agent node: done iff the latest output carries the node's stop
|
|
381
|
+
* sentinel. PROBABILISTIC (the agent's own self-judgment) — the driver validates it.
|
|
382
|
+
*/
|
|
383
|
+
declare function sentinelCompletion<Task>(sentinel: string, opts?: {
|
|
384
|
+
confidence?: number;
|
|
385
|
+
}): CompletionAnalyst<Task, string>;
|
|
386
|
+
/**
|
|
387
|
+
* Completion for a DETERMINISTIC check (build/test/lint/citation/proof): done iff the check
|
|
388
|
+
* passes. Ground truth — the driver ends directly, no validation. The check reads the output
|
|
389
|
+
* (a verifier), never the judge verdict — selector ≠ judge stays intact.
|
|
390
|
+
*/
|
|
391
|
+
declare function deterministicCompletion<Task, Output>(check: (output: Output, history: ReadonlyArray<Iteration<Task, Output>>) => {
|
|
392
|
+
passed: boolean;
|
|
393
|
+
reasons?: string;
|
|
394
|
+
}): CompletionAnalyst<Task, Output>;
|
|
395
|
+
|
|
313
396
|
/**
|
|
314
397
|
* @experimental
|
|
315
398
|
*
|
|
@@ -528,6 +611,12 @@ interface RunPersonifiedOptions<Task, D> {
|
|
|
528
611
|
/** Optional scope analyst threaded into the shape's ShapeContext so loopUntil/widen steer
|
|
529
612
|
* on trace-derived findings instead of the dormant empty default. */
|
|
530
613
|
readonly analyst?: ScopeAnalyst<D>;
|
|
614
|
+
/**
|
|
615
|
+
* Lifecycle stream sink, forwarded to `SupervisorOpts.hooks` so the root `Scope`'s
|
|
616
|
+
* `agent.spawn`/`agent.child` events flow to an observer (e.g. the Intelligence SDK's
|
|
617
|
+
* trace export). Absent ⇒ no stream (the run is silent, as today).
|
|
618
|
+
*/
|
|
619
|
+
readonly hooks?: RuntimeHooks;
|
|
531
620
|
}
|
|
532
621
|
/** The composed run signature. */
|
|
533
622
|
type RunPersonified = <Task, D>(options: RunPersonifiedOptions<Task, D>) => Promise<SupervisedResult<Outcome<D>>>;
|
|
@@ -818,8 +907,7 @@ interface ScopeAnalyst<D> {
|
|
|
818
907
|
*/
|
|
819
908
|
analyze(input: ScopeAnalyzeInput<D>): Promise<ReadonlyArray<AnalystFinding>>;
|
|
820
909
|
}
|
|
821
|
-
/** Input to a `ScopeAnalyst.analyze` — the root task framing + the children settled so far.
|
|
822
|
-
* reactive analogue of the old `AnalyzeInput { task, history }`. */
|
|
910
|
+
/** Input to a `ScopeAnalyst.analyze` — the root task framing + the children settled so far. */
|
|
823
911
|
interface ScopeAnalyzeInput<D> {
|
|
824
912
|
/** Opaque root-task framing (whatever the combinator was invoked with). */
|
|
825
913
|
readonly task: unknown;
|
|
@@ -1122,7 +1210,7 @@ declare function renderReport(findings: ReadonlyArray<AnalystFinding>): string;
|
|
|
1122
1210
|
*
|
|
1123
1211
|
* NOTE on the read side: harvesting is safe and cheap; *injecting* facts back into runs
|
|
1124
1212
|
* is the measured danger zone — naive unconditional priming tested NEGATIVE (−11.6pp,
|
|
1125
|
-
* context pollution;
|
|
1213
|
+
* context pollution; result now in .evolve/current.json + memory). Gate any priming design on its
|
|
1126
1214
|
* own A/B; the corpus's first consumers are operators and optimizers, not prompts.
|
|
1127
1215
|
*/
|
|
1128
1216
|
|
|
@@ -1588,16 +1676,14 @@ declare function createMcpEnvironment(opts: McpEnvironmentOptions): Environment;
|
|
|
1588
1676
|
/**
|
|
1589
1677
|
* @experimental
|
|
1590
1678
|
*
|
|
1591
|
-
* Analyst-on-scope (G1) — the
|
|
1592
|
-
* wire (`dynamic.ts`) onto the reactive `Scope`.
|
|
1679
|
+
* Analyst-on-scope (G1) — the analyze→findings→steer wire over the reactive `Scope`.
|
|
1593
1680
|
*
|
|
1594
|
-
* The
|
|
1595
|
-
*
|
|
1596
|
-
*
|
|
1597
|
-
*
|
|
1598
|
-
*
|
|
1599
|
-
*
|
|
1600
|
-
* findings through a single `SteerContext`.
|
|
1681
|
+
* The analyst runs over the children drained so far and hands its findings to the steer
|
|
1682
|
+
* decision behind a provenance firewall (`assertTraceDerivedFindings`) that keeps the external
|
|
1683
|
+
* write-only judge out of that decision (selector ≠ judge). The reactive `Scope` has no rounds:
|
|
1684
|
+
* a combinator's `act` asks a `ScopeAnalyst` to turn the children it has drained off
|
|
1685
|
+
* `scope.next()` SO FAR into `AnalystFinding[]`, and steers from THOSE findings through a single
|
|
1686
|
+
* `SteerContext`.
|
|
1601
1687
|
*
|
|
1602
1688
|
* The analyst itself is not a new type — it is "just an `Agent<unknown, AnalystFinding[]>`" the
|
|
1603
1689
|
* combinator spawns over a child's trace (harness `null`/`cli`). `createScopeAnalyst` spawns that
|
|
@@ -2035,117 +2121,6 @@ interface UsageSink {
|
|
|
2035
2121
|
*/
|
|
2036
2122
|
declare function reportLoopUsage<Task, Output, Decision>(cost: UsageSink, result: Pick<LoopResult<Task, Output, Decision>, 'costUsd' | 'tokenUsage'>, source?: string): void;
|
|
2037
2123
|
|
|
2038
|
-
/**
|
|
2039
|
-
* The one router chat client: direct OpenAI-compatible completions through the
|
|
2040
|
-
* Tangle router — the cheapest dial, no sandbox. Three layers: `routerChatWithUsage`
|
|
2041
|
-
* (chat-only), `routerChatWithTools` (one completion with function tools), and
|
|
2042
|
-
* `routerToolLoop` (the off-box agentic loop over tool-calling). Shared by the
|
|
2043
|
-
* built-in executors and the bench/lab harnesses.
|
|
2044
|
-
*
|
|
2045
|
-
* Reports REAL token usage so the backend-integrity guard sees a real backend.
|
|
2046
|
-
* Returns `undefined` usage when the provider omitted it — never a fabricated 0
|
|
2047
|
-
* (a phantom 0 reads as a free call downstream, which the gate would act on).
|
|
2048
|
-
*/
|
|
2049
|
-
interface RouterConfig {
|
|
2050
|
-
routerBaseUrl: string;
|
|
2051
|
-
routerKey: string;
|
|
2052
|
-
model: string;
|
|
2053
|
-
}
|
|
2054
|
-
interface RouterChatResult {
|
|
2055
|
-
content: string;
|
|
2056
|
-
/** REAL usage, or undefined when the provider reported none. */
|
|
2057
|
-
usage?: {
|
|
2058
|
-
input: number;
|
|
2059
|
-
output: number;
|
|
2060
|
-
};
|
|
2061
|
-
/** Derived from usage via `estimateCost` when the model is priced; else undefined. */
|
|
2062
|
-
costUsd?: number;
|
|
2063
|
-
}
|
|
2064
|
-
declare function routerChatWithUsage(cfg: RouterConfig, messages: Array<{
|
|
2065
|
-
role: string;
|
|
2066
|
-
content: string;
|
|
2067
|
-
}>, opts?: {
|
|
2068
|
-
temperature?: number;
|
|
2069
|
-
signal?: AbortSignal;
|
|
2070
|
-
maxTokens?: number;
|
|
2071
|
-
}): Promise<RouterChatResult>;
|
|
2072
|
-
/** A tool-call the model emitted (provider-neutral; mirrors the runtime's ToolCallRequest). */
|
|
2073
|
-
interface RouterToolCall {
|
|
2074
|
-
id: string;
|
|
2075
|
-
name: string;
|
|
2076
|
-
/** Raw JSON arguments string as emitted by the model. */
|
|
2077
|
-
arguments: string;
|
|
2078
|
-
}
|
|
2079
|
-
interface RouterChatToolsResult {
|
|
2080
|
-
content: string | null;
|
|
2081
|
-
toolCalls: RouterToolCall[];
|
|
2082
|
-
usage?: {
|
|
2083
|
-
input: number;
|
|
2084
|
-
output: number;
|
|
2085
|
-
};
|
|
2086
|
-
costUsd?: number;
|
|
2087
|
-
}
|
|
2088
|
-
/**
|
|
2089
|
-
* A router completion WITH tool-calling — the operator driver's LLM seam. Passes OpenAI-shape
|
|
2090
|
-
* `messages` (system/user/assistant-with-tool_calls/tool roles) + function `tools`, and returns the
|
|
2091
|
-
* assistant text plus the tool calls the model wants run. Same fail-loud + real-usage discipline as
|
|
2092
|
-
* `routerChatWithUsage`. `tool_choice: 'auto'` lets the model decide; the driver loops on the result.
|
|
2093
|
-
*/
|
|
2094
|
-
declare function routerChatWithTools(cfg: RouterConfig, messages: ReadonlyArray<Record<string, unknown>>, tools: ReadonlyArray<{
|
|
2095
|
-
type: 'function';
|
|
2096
|
-
function: {
|
|
2097
|
-
name: string;
|
|
2098
|
-
description?: string;
|
|
2099
|
-
parameters: unknown;
|
|
2100
|
-
};
|
|
2101
|
-
}>, opts?: {
|
|
2102
|
-
temperature?: number;
|
|
2103
|
-
signal?: AbortSignal;
|
|
2104
|
-
toolChoice?: 'auto' | 'required' | 'none';
|
|
2105
|
-
}): Promise<RouterChatToolsResult>;
|
|
2106
|
-
interface ToolSpec {
|
|
2107
|
-
type: 'function';
|
|
2108
|
-
function: {
|
|
2109
|
-
name: string;
|
|
2110
|
-
description?: string;
|
|
2111
|
-
parameters: unknown;
|
|
2112
|
-
};
|
|
2113
|
-
}
|
|
2114
|
-
interface RouterToolLoopResult {
|
|
2115
|
-
/** The model's final assistant text (the turn where it stopped calling tools, or the budget turn). */
|
|
2116
|
-
final: string;
|
|
2117
|
-
/** Inference turns spent (≤ maxTurns) — the equal-budget unit vs random@k. */
|
|
2118
|
-
turns: number;
|
|
2119
|
-
toolCalls: number;
|
|
2120
|
-
/** The behavior trace: each tool call + its result, in order. What a trace-analyst
|
|
2121
|
-
* steerer reads (behavior, never the verdict) to diagnose + redirect the next shot. */
|
|
2122
|
-
toolTrace: Array<{
|
|
2123
|
-
name: string;
|
|
2124
|
-
args: string;
|
|
2125
|
-
result: string;
|
|
2126
|
-
}>;
|
|
2127
|
-
usage: {
|
|
2128
|
-
input: number;
|
|
2129
|
-
output: number;
|
|
2130
|
-
};
|
|
2131
|
-
}
|
|
2132
|
-
/**
|
|
2133
|
-
* The tool-using router backend: a real agentic loop OVER the Tangle router (which
|
|
2134
|
-
* supports tool-calling), off-box — no sandbox. Each turn is one router completion
|
|
2135
|
-
* with `tools`; if the model emits tool_calls, `execute` runs them on the host and
|
|
2136
|
-
* their results are folded back as `tool` messages; the loop repeats until the
|
|
2137
|
-
* model answers without a tool call or the turn budget is hit. One turn = one
|
|
2138
|
-
* inference call, so `maxTurns` is the equal-compute unit against random@k.
|
|
2139
|
-
*
|
|
2140
|
-
* This is the depth substrate for agentic gates (the worker ACTS, observes the real
|
|
2141
|
-
* result, and continues) that the chat-only `routerChatWithUsage` cannot express.
|
|
2142
|
-
*/
|
|
2143
|
-
declare function routerToolLoop(cfg: RouterConfig, system: string, user: string, tools: ReadonlyArray<ToolSpec>, execute: (name: string, args: Record<string, unknown>) => Promise<string>, opts?: {
|
|
2144
|
-
maxTurns?: number;
|
|
2145
|
-
temperature?: number;
|
|
2146
|
-
signal?: AbortSignal;
|
|
2147
|
-
}): Promise<RouterToolLoopResult>;
|
|
2148
|
-
|
|
2149
2124
|
/**
|
|
2150
2125
|
* @experimental
|
|
2151
2126
|
*
|
|
@@ -2821,6 +2796,82 @@ declare function pickChampion(means: Record<string, {
|
|
|
2821
2796
|
declare function selectChampion(report: BenchmarkReport, fieldOrder: string[], policy: ChampionPolicy, epsilon: number): ChampionPick;
|
|
2822
2797
|
declare function runStrategyEvolution(cfg: StrategyEvolutionConfig): Promise<EvolutionReport>;
|
|
2823
2798
|
|
|
2799
|
+
/**
|
|
2800
|
+
* @experimental
|
|
2801
|
+
*
|
|
2802
|
+
* The completion-oracle: **settled ⟺ DELIVERED.**
|
|
2803
|
+
*
|
|
2804
|
+
* Foreman's one hard lesson (0/18 self-improvement deliverables) — "done" must mean a check
|
|
2805
|
+
* PASSED, not the agent's say-so. `gateOnDeliverable` wraps an `Executor` so its settlement
|
|
2806
|
+
* is `valid` ONLY when the deliverable check passes. The child still RUNS and settles (its
|
|
2807
|
+
* spend is conserved into the pool either way), but a child that ran WITHOUT delivering
|
|
2808
|
+
* settles `valid:false` — so a keep-best driver never counts it as done, and a gate never
|
|
2809
|
+
* inflates with self-judged wins.
|
|
2810
|
+
*
|
|
2811
|
+
* Dual-purpose by construction:
|
|
2812
|
+
* - product: the agent fleet only advances on real, checked deliverables.
|
|
2813
|
+
* - proof: the gate's `valid` is the honest settle — equal-k comparisons can't be gamed by an
|
|
2814
|
+
* arm that "ran" without producing the artifact.
|
|
2815
|
+
*
|
|
2816
|
+
* The check is a DEPLOYABLE oracle — a test command, a state verifier, the commit0 judge —
|
|
2817
|
+
* read off the child's output, never the model judging itself. A throwing check is
|
|
2818
|
+
* fail-closed (not delivered), never a crash.
|
|
2819
|
+
*/
|
|
2820
|
+
|
|
2821
|
+
interface DeliverableSpec<Out = unknown> {
|
|
2822
|
+
/** The deployable check that decides DELIVERED. `settled.valid ⟺ this resolves true`. */
|
|
2823
|
+
check: (out: Out) => boolean | Promise<boolean>;
|
|
2824
|
+
/** What the spawn was supposed to produce — surfaced in traces/reports. */
|
|
2825
|
+
describe?: string;
|
|
2826
|
+
}
|
|
2827
|
+
/**
|
|
2828
|
+
* Wrap an `Executor` so its settlement `valid` reflects the deliverable check, not the
|
|
2829
|
+
* inner verdict. Handles both `execute` shapes (one-shot `Promise<ExecutorResult>` and
|
|
2830
|
+
* streaming `AsyncIterable<UsageEvent>` + `resultArtifact()`); the check runs once the inner
|
|
2831
|
+
* executor has produced its output. The inner `score` is preserved; only `valid` is gated.
|
|
2832
|
+
*/
|
|
2833
|
+
declare function gateOnDeliverable<Out>(inner: Executor<Out>, deliverable: DeliverableSpec<Out>): Executor<Out>;
|
|
2834
|
+
|
|
2835
|
+
/**
|
|
2836
|
+
* @experimental
|
|
2837
|
+
*
|
|
2838
|
+
* The supervisor's intelligence is AUTHORING the agents it spawns — not pressing buttons.
|
|
2839
|
+
*
|
|
2840
|
+
* Every agent here is three things: instructions (system prompt), tools, and a model — its
|
|
2841
|
+
* `AgentProfile`. The supervisor's job is to WRITE those profiles: read the task, decompose it,
|
|
2842
|
+
* and for each sub-task author a tailored worker recipe. `supervisorSkill` is the how-to the
|
|
2843
|
+
* supervisor reads (its system prompt); `authoredWorker` builds a worker AGENT from a profile the
|
|
2844
|
+
* supervisor authored — the authored systemPrompt + model shape the worker's call.
|
|
2845
|
+
*
|
|
2846
|
+
* The skill is the single OPTIMIZABLE surface: edit it → the supervisor designs better agents.
|
|
2847
|
+
* That is the self-improvement lever (the prompt/skill lever), not the execution plumbing.
|
|
2848
|
+
*/
|
|
2849
|
+
|
|
2850
|
+
/** What the supervisor AUTHORS per sub-task — a worker recipe (a partial `AgentProfile`). */
|
|
2851
|
+
interface AuthoredProfile {
|
|
2852
|
+
name: string;
|
|
2853
|
+
/** The rich, task-specific instructions the supervisor wrote for THIS worker. */
|
|
2854
|
+
systemPrompt: string;
|
|
2855
|
+
/** The model the supervisor chose for this sub-task (falls back to the run default). */
|
|
2856
|
+
model?: string;
|
|
2857
|
+
}
|
|
2858
|
+
/** Narrow an untyped `spawn_worker` profile argument to an `AuthoredProfile`, or null if the
|
|
2859
|
+
* supervisor failed to author one (empty/placeholder profile — a skill violation worth catching). */
|
|
2860
|
+
declare function asAuthoredProfile(raw: unknown): AuthoredProfile | null;
|
|
2861
|
+
/** The supervisor SKILL — the how-to the supervisor reads (its system prompt). THE optimizable
|
|
2862
|
+
* surface: editing this changes how the supervisor designs every agent it spawns. */
|
|
2863
|
+
declare function supervisorSkill(opts?: {
|
|
2864
|
+
goal?: string;
|
|
2865
|
+
}): string;
|
|
2866
|
+
/** Build a worker AGENT from a profile the supervisor authored: the authored `systemPrompt` +
|
|
2867
|
+
* `model` shape the worker's one model call; the deliverable gates settlement (valid ⟺ delivered). */
|
|
2868
|
+
declare function authoredWorker(profile: AuthoredProfile, opts: {
|
|
2869
|
+
cfg: RouterConfig;
|
|
2870
|
+
taskPrompt: string;
|
|
2871
|
+
deliverable: DeliverableSpec;
|
|
2872
|
+
temperature?: number;
|
|
2873
|
+
}): Agent<unknown, unknown>;
|
|
2874
|
+
|
|
2824
2875
|
/**
|
|
2825
2876
|
* @experimental
|
|
2826
2877
|
*
|
|
@@ -2903,6 +2954,206 @@ declare function spendFromUsageEvents(events: UsageEvent[]): Spend;
|
|
|
2903
2954
|
*/
|
|
2904
2955
|
declare function createBudgetPool(root: Budget, now?: () => number): BudgetPool;
|
|
2905
2956
|
|
|
2957
|
+
/**
|
|
2958
|
+
* @experimental
|
|
2959
|
+
*
|
|
2960
|
+
* `coordinationDriverAgent` — the driver's BRAIN.
|
|
2961
|
+
*
|
|
2962
|
+
* The recursive driver-executor (`driver-executor.ts`) runs a driver `Agent.act` inside a
|
|
2963
|
+
* nested `Scope`; this is the intelligent `act`: it mounts the coordination MCP verbs
|
|
2964
|
+
* (`createCoordinationTools`) over that scope and runs an LLM tool-loop, so the driver
|
|
2965
|
+
* REASONS — spawn / observe / steer / await / stop — about how to drive its children,
|
|
2966
|
+
* instead of running a fixed script. Each turn: ask the driver LLM for tool calls, run them
|
|
2967
|
+
* against the live scope, fold the results back, repeat until the driver stops (no tool
|
|
2968
|
+
* calls) or the turn cap forces a keep-best finalize.
|
|
2969
|
+
*
|
|
2970
|
+
* Recursion composes through `makeWorkerAgent`: `spawn_worker` resolves a `profile` to a
|
|
2971
|
+
* worker LEAF or — when the profile is a driver — a `driverChild` wrapping ANOTHER
|
|
2972
|
+
* `coordinationDriverAgent` over its own nested scope (see `driver-executor.ts`). So an agent
|
|
2973
|
+
* drives an agent that drives an agent, each an LLM tool-loop, all on one conserved-budget
|
|
2974
|
+
* tree.
|
|
2975
|
+
*
|
|
2976
|
+
* Two seams are INJECTED so the loop runs offline with no creds and stays decoupled:
|
|
2977
|
+
* - `chat` (`DriverChat`) — one driver-LLM turn; a test drives a scripted mock, production
|
|
2978
|
+
* adapts the router's tool-calling.
|
|
2979
|
+
* - `systemPrompt` — the driver's stance (the agent-eval worker-driver prompt / the prompt
|
|
2980
|
+
* generator). Injected, never hardcoded — the prompt is a pluggable role.
|
|
2981
|
+
*/
|
|
2982
|
+
|
|
2983
|
+
/** One tool call the driver LLM asks for this turn. */
|
|
2984
|
+
interface DriverToolCall {
|
|
2985
|
+
readonly id?: string;
|
|
2986
|
+
readonly name: string;
|
|
2987
|
+
readonly arguments: Record<string, unknown>;
|
|
2988
|
+
}
|
|
2989
|
+
/** A turn in the driver↔tools conversation. Tool results ride back as `role: 'tool'`. */
|
|
2990
|
+
interface DriverMessage {
|
|
2991
|
+
readonly role: 'user' | 'assistant' | 'tool';
|
|
2992
|
+
readonly content: string;
|
|
2993
|
+
readonly toolCalls?: ReadonlyArray<DriverToolCall>;
|
|
2994
|
+
readonly toolCallId?: string;
|
|
2995
|
+
readonly name?: string;
|
|
2996
|
+
}
|
|
2997
|
+
/** What the driver LLM returns each turn. No `toolCalls` => the driver is finished. */
|
|
2998
|
+
interface DriverTurn {
|
|
2999
|
+
readonly toolCalls?: ReadonlyArray<DriverToolCall>;
|
|
3000
|
+
/** The driver's natural-language output — the answer when there are no tool calls. */
|
|
3001
|
+
readonly content?: string;
|
|
3002
|
+
}
|
|
3003
|
+
/** The injected driver-LLM seam: one turn over the conversation + the coordination tool specs. */
|
|
3004
|
+
interface DriverChat {
|
|
3005
|
+
next(input: {
|
|
3006
|
+
readonly system: string;
|
|
3007
|
+
readonly messages: ReadonlyArray<DriverMessage>;
|
|
3008
|
+
readonly tools: ReadonlyArray<{
|
|
3009
|
+
name: string;
|
|
3010
|
+
description: string;
|
|
3011
|
+
parameters: unknown;
|
|
3012
|
+
}>;
|
|
3013
|
+
}): Promise<DriverTurn>;
|
|
3014
|
+
}
|
|
3015
|
+
interface CoordinationDriverOptions {
|
|
3016
|
+
readonly name: string;
|
|
3017
|
+
/** The driver-LLM seam (scripted mock offline; router tool-calling in production). */
|
|
3018
|
+
readonly chat: DriverChat;
|
|
3019
|
+
/** Shared blob store — `observe_worker` reads settled outputs through it. */
|
|
3020
|
+
readonly blobs: ResultBlobStore;
|
|
3021
|
+
/** Resolve a spawned `profile` to a worker LEAF or a driver child (the recursion seam). */
|
|
3022
|
+
readonly makeWorkerAgent: MakeWorkerAgent;
|
|
3023
|
+
/** Per-child budget reserved from the conserved pool on each spawn. */
|
|
3024
|
+
readonly perWorker: Budget;
|
|
3025
|
+
/** The driver's stance — a string, or built from the task (the worker-driver prompt /
|
|
3026
|
+
* the generator). INJECTED so the prompt is a pluggable, optimizable role. */
|
|
3027
|
+
readonly systemPrompt: string | ((task: unknown) => string);
|
|
3028
|
+
/** Max driver turns before the loop force-finalizes on the best settled child. Default 16. */
|
|
3029
|
+
readonly maxTurns?: number;
|
|
3030
|
+
}
|
|
3031
|
+
/**
|
|
3032
|
+
* Build the intelligent recursive driver. Its `act` is the LLM tool-loop; spawn it as a
|
|
3033
|
+
* `driverChild` (`driver-executor.ts`) to run it inside a nested scope, recursively.
|
|
3034
|
+
*/
|
|
3035
|
+
declare function coordinationDriverAgent(opts: CoordinationDriverOptions): Agent<unknown, unknown>;
|
|
3036
|
+
|
|
3037
|
+
/**
|
|
3038
|
+
* @experimental
|
|
3039
|
+
*
|
|
3040
|
+
* Serve the coordination verbs (spawn_worker / await_next / observe_worker / steer_worker / stop)
|
|
3041
|
+
* as a real HTTP MCP server over a LIVE `Scope`. This is the keystone that lets a coding-harness
|
|
3042
|
+
* agent (opencode via the cli-bridge, claude-code, codex) BE the supervisor: it mounts this MCP
|
|
3043
|
+
* (`mcp.mcpServers.coordination`) and calls `spawn_worker` as a native tool, which lands on
|
|
3044
|
+
* `Scope.spawn` — a real box driving real boxes, not emulated function-tools.
|
|
3045
|
+
*
|
|
3046
|
+
* Transport: JSON-RPC over HTTP POST (the MCP streamable-HTTP shape — `application/json` for a
|
|
3047
|
+
* single response). The server is created INSIDE an agent's `act(task, scope)` so it fronts that
|
|
3048
|
+
* agent's live scope; tear it down when the act returns.
|
|
3049
|
+
*/
|
|
3050
|
+
|
|
3051
|
+
interface CoordinationMcpHandle {
|
|
3052
|
+
/** The URL an in-box harness mounts as `mcp.mcpServers.coordination.url`. */
|
|
3053
|
+
readonly url: string;
|
|
3054
|
+
readonly port: number;
|
|
3055
|
+
/** The coordination tools' settled-worker ledger (for the driver's finalize). */
|
|
3056
|
+
settled(): ReadonlyArray<{
|
|
3057
|
+
status: string;
|
|
3058
|
+
score?: number;
|
|
3059
|
+
valid?: boolean;
|
|
3060
|
+
outRef?: string;
|
|
3061
|
+
}>;
|
|
3062
|
+
isStopped(): boolean;
|
|
3063
|
+
close(): Promise<void>;
|
|
3064
|
+
}
|
|
3065
|
+
/** Stand up the coordination MCP over a live scope. The HOST address is `127.0.0.1` (the bridge runs
|
|
3066
|
+
* opencode locally, same host); pass `host` to bind elsewhere when the harness is remote. */
|
|
3067
|
+
declare function serveCoordinationMcp(opts: {
|
|
3068
|
+
scope: Scope<unknown>;
|
|
3069
|
+
blobs: ResultBlobStore;
|
|
3070
|
+
makeWorkerAgent: MakeWorkerAgent;
|
|
3071
|
+
perWorker: Budget;
|
|
3072
|
+
port?: number;
|
|
3073
|
+
host?: string;
|
|
3074
|
+
}): Promise<CoordinationMcpHandle>;
|
|
3075
|
+
|
|
3076
|
+
/**
|
|
3077
|
+
* @experimental
|
|
3078
|
+
*
|
|
3079
|
+
* The recursive driver-executor — the seam that lets a SPAWNED child be a DRIVER, so
|
|
3080
|
+
* agents drive agents drive agents over the one keystone atom.
|
|
3081
|
+
*
|
|
3082
|
+
* A spawned child resolves through the open registry to an `Executor`; the built-in
|
|
3083
|
+
* executors (router/inline, sandbox, cli) are LEAVES — `execute(task, signal)` runs the
|
|
3084
|
+
* work and settles. This executor is the recursive case: on `execute`, it mounts a NESTED
|
|
3085
|
+
* `Scope` (the scope hands it the mount via the `nested-scope` seam) over the SAME
|
|
3086
|
+
* conserved pool + shared journal/blobs + the same open registry, one `depth` deeper, then
|
|
3087
|
+
* runs the wrapped driver `Agent.act(task, nestedScope)`. The driver spawns its own
|
|
3088
|
+
* children into that nested scope; each resolves to EITHER a leaf executor (a worker child)
|
|
3089
|
+
* OR this same driver-executor (a driver child) — recursively. So a driver spawns a driver
|
|
3090
|
+
* spawns a worker, all on one budget-conserving tree.
|
|
3091
|
+
*
|
|
3092
|
+
* Why this preserves every keystone invariant (the scope owns the sharing; this executor
|
|
3093
|
+
* only runs the driver over what the scope mounts):
|
|
3094
|
+
* - Conserved budget: the nested scope reserves from the SAME `BudgetPool` the root owns
|
|
3095
|
+
* (the scope mounts it over `args.pool`), so `Σk` is conserved ACROSS depth by
|
|
3096
|
+
* construction — a deep tree cannot overspend the root ceiling (reserve-on-spawn fails
|
|
3097
|
+
* closed at any depth).
|
|
3098
|
+
* - Journal: the nested scope writes to its OWN tree key (`${journalRoot}/${nodeId}`) so
|
|
3099
|
+
* its cursor `seq`s never collide with the parent's in the per-tree uniqueness guard,
|
|
3100
|
+
* while every nested tree shares the one `SpawnJournal` — the whole recursion is one
|
|
3101
|
+
* journal, queryable tree by tree.
|
|
3102
|
+
* - Settlement bubbling: the driver child settles into its PARENT scope with the conserved
|
|
3103
|
+
* spend summed off its nested tree's settled events, so the parent's pool reconcile +
|
|
3104
|
+
* the supervisor's `spentTotal` see the whole sub-tree's spend rolled up — settlements
|
|
3105
|
+
* bubble to the root.
|
|
3106
|
+
* - Depth ceiling: the nested scope runs at `depth+1`, so the supervisor's `maxDepth`
|
|
3107
|
+
* (paired with the conserved pool per R3) fails a spawn closed once the recursion is too
|
|
3108
|
+
* deep — exactly as it does for a flat tree.
|
|
3109
|
+
*
|
|
3110
|
+
* Layering: pure keystone composition. It reuses the scope's `NestedScopeSeam` + the shared
|
|
3111
|
+
* `SpawnJournal`; it builds NO new budget, journal, or selection logic. The recursion rides
|
|
3112
|
+
* the existing atom.
|
|
3113
|
+
*/
|
|
3114
|
+
|
|
3115
|
+
/** The runtime tag the registry maps a driver child to. */
|
|
3116
|
+
declare const driverRuntime: "driver";
|
|
3117
|
+
/** A driver child's spec carries the `Agent` to run inside the nested scope. */
|
|
3118
|
+
interface DriverSpec extends AgentSpec {
|
|
3119
|
+
readonly driver: Agent<unknown, unknown>;
|
|
3120
|
+
/** The shared journal the nested tree is one tree key inside (so the executor can
|
|
3121
|
+
* begin its nested tree + sum its spend off the same record). */
|
|
3122
|
+
readonly journal: SpawnJournal;
|
|
3123
|
+
}
|
|
3124
|
+
/**
|
|
3125
|
+
* Mark + carry a driver `Agent` so the recursive registry resolves it to the
|
|
3126
|
+
* driver-executor. The returned agent is SPAWNED (never run directly): its
|
|
3127
|
+
* `executorSpec` is marked `role: 'driver'` and carries the driver agent + the shared
|
|
3128
|
+
* journal so the executor can run its `act` inside a nested scope. `act` fails loud if
|
|
3129
|
+
* called directly — a driver child runs THROUGH its nested-scope executor, never as a root.
|
|
3130
|
+
*/
|
|
3131
|
+
declare function driverChild<Out>(name: string, driver: Agent<unknown, Out>, journal: SpawnJournal): Agent<unknown, Out>;
|
|
3132
|
+
/** True when a spec is a driver child (carries the role marker + a driver Agent). */
|
|
3133
|
+
declare function isDriverSpec(spec: AgentSpec): spec is DriverSpec;
|
|
3134
|
+
/**
|
|
3135
|
+
* The recursive driver-executor factory. `withDriverExecutor` routes a child marked
|
|
3136
|
+
* `role: 'driver'` here; any other child resolves to a leaf built-in. On `execute`, it
|
|
3137
|
+
* reads the `nested-scope` seam the SCOPE seeded, mounts a nested `Scope` one `depth`
|
|
3138
|
+
* deeper over the shared pool/journal/blobs/registry, runs the driver
|
|
3139
|
+
* `Agent.act(task, nestedScope)`, and reports the conserved spend summed off the nested
|
|
3140
|
+
* tree's settled events — so the parent scope's reconcile rolls the whole sub-tree's spend
|
|
3141
|
+
* into the conserved total.
|
|
3142
|
+
*
|
|
3143
|
+
* A `down` from the nested driver (a thrown `act` or an aborted scope) propagates as a
|
|
3144
|
+
* thrown executor, which the parent scope types into a `down` settlement — the same
|
|
3145
|
+
* fail-loud-into-typed-down discipline a leaf gets.
|
|
3146
|
+
*/
|
|
3147
|
+
declare const driverExecutorFactory: ExecutorFactory<unknown>;
|
|
3148
|
+
/**
|
|
3149
|
+
* Register the driver-executor so a child marked `role: 'driver'` resolves to it. The base
|
|
3150
|
+
* registry resolves by harness alone (it does not read `role`), so a recursive run needs a
|
|
3151
|
+
* registry that routes the driver tag here FIRST. Returns a registry decorator: a
|
|
3152
|
+
* driver-role spec → the driver-executor; everything else → the base registry's resolution
|
|
3153
|
+
* (leaf built-ins + BYO).
|
|
3154
|
+
*/
|
|
3155
|
+
declare function withDriverExecutor(base: ExecutorRegistry): ExecutorRegistry;
|
|
3156
|
+
|
|
2906
3157
|
/**
|
|
2907
3158
|
* @experimental
|
|
2908
3159
|
*
|
|
@@ -3090,6 +3341,32 @@ interface ScopeArgs {
|
|
|
3090
3341
|
* (the topology viewer reads it). Undefined ⇒ the journal stays the only record. */
|
|
3091
3342
|
readonly hooks?: RuntimeHooks;
|
|
3092
3343
|
}
|
|
3344
|
+
/**
|
|
3345
|
+
* The recursion seam key. A `Scope` seeds a value of this on each child's
|
|
3346
|
+
* `ExecutorContext.seams` so a child whose executor is a DRIVER can mount a NESTED `Scope`
|
|
3347
|
+
* over the SAME conserved pool at `depth+1`. A leaf executor never reads it. Single-sourced
|
|
3348
|
+
* here so the scope and the driver-executor agree on the seam without a circular import.
|
|
3349
|
+
*/
|
|
3350
|
+
declare const nestedScopeSeamKey = "nested-scope";
|
|
3351
|
+
/**
|
|
3352
|
+
* The recursion seam value: mount a nested `Scope` for a driver child. `parentId` is the
|
|
3353
|
+
* driver child's own node id (so its children get `${nodeId}:s${ordinal}` ids and its
|
|
3354
|
+
* nested journal tree is namespaced under it); `root` is the journal tree key for the
|
|
3355
|
+
* nested tree (distinct from the parent's so cursor seqs never collide in the per-tree
|
|
3356
|
+
* guard). `depth` is `parent.depth + 1`. The nested scope shares the parent's `pool`
|
|
3357
|
+
* (conserved budget across depth), `journal`/`blobs` (one record), and `executors` (a
|
|
3358
|
+
* nested child resolves to leaf-or-driver through the same open registry).
|
|
3359
|
+
*/
|
|
3360
|
+
interface NestedScopeSeam {
|
|
3361
|
+
/** This scope's recursion depth — a nested scope runs at `depth + 1`. */
|
|
3362
|
+
readonly depth: number;
|
|
3363
|
+
/** The runtime recursion-depth ceiling, paired with the conserved pool (R3). */
|
|
3364
|
+
readonly maxDepth?: number;
|
|
3365
|
+
/** The journal tree key the parent scope writes to (used to namespace nested trees). */
|
|
3366
|
+
readonly journalRoot: NodeId;
|
|
3367
|
+
/** Mount a nested scope rooted at `nestedRoot`, parented at this driver child's node id. */
|
|
3368
|
+
mount(nestedRoot: NodeId, signal: AbortSignal): Scope<unknown>;
|
|
3369
|
+
}
|
|
3093
3370
|
declare function createScope<Out>(args: ScopeArgs): Scope<Out>;
|
|
3094
3371
|
/**
|
|
3095
3372
|
* The step-8 merge-boundary adapter (M4): rehydrate a `Settled.done` into the kernel's
|
|
@@ -3222,5 +3499,26 @@ declare function gitWorkspace(opts: GitWorkspaceOptions): Workspace;
|
|
|
3222
3499
|
* no staging area, and a first-class operation log (native resume/undo). Live use
|
|
3223
3500
|
* requires `jj` on the `Shell`'s host. */
|
|
3224
3501
|
declare function jjWorkspace(opts: GitWorkspaceOptions): Workspace;
|
|
3502
|
+
interface WorkspaceRun<T> {
|
|
3503
|
+
readonly valid: boolean;
|
|
3504
|
+
readonly value: T;
|
|
3505
|
+
/** Present when a commit was attempted (valid, or `commitOnInvalid`). */
|
|
3506
|
+
readonly commit?: WorkspaceCommit;
|
|
3507
|
+
}
|
|
3508
|
+
/**
|
|
3509
|
+
* Run a worker `body` inside a FRESH clone of a shared `Workspace`, then commit its work back
|
|
3510
|
+
* so the next worker (or the supervisor) builds on it. This is the seam that turns isolated
|
|
3511
|
+
* per-worker cwds into one compounding artifact — `body` gets a real materialized dir, its
|
|
3512
|
+
* delivery is committed to the shared ref iff it's valid (a conflict is returned, never thrown).
|
|
3513
|
+
* The clone is removed after; durable state lives only in the ref.
|
|
3514
|
+
*/
|
|
3515
|
+
declare function runInWorkspace<T>(ws: Workspace, body: (cwd: string) => Promise<{
|
|
3516
|
+
valid: boolean;
|
|
3517
|
+
value: T;
|
|
3518
|
+
message?: string;
|
|
3519
|
+
}>, opts?: {
|
|
3520
|
+
tmpPrefix?: string;
|
|
3521
|
+
commitOnInvalid?: boolean;
|
|
3522
|
+
}): Promise<WorkspaceRun<T>>;
|
|
3225
3523
|
|
|
3226
|
-
export { Agent, AgentRunSpec, AgentSpec, type AgenticOptions, type AgenticRunResult, type AgenticSurface, type AgenticTask, type AgenticTool, type AnytimeReport, type AnytimeStrategySummary, type AnytimeTaskCurve, type ArtifactHandle, type AssertTraceDerivedFindings, type AuditIntentInput, type AuditIntentOptions, type AuthorStrategyOptions, type AuthoredStrategy, type BenchmarkCell, type BenchmarkConfig, type BenchmarkLift, type BenchmarkReport, type BenchmarkStrategySummary, type BenchmarkTaskRow, type BridgeSeam, Budget, type BudgetPool, type BudgetReadout, type ChampionPick, type ChampionPolicy, type CheckpointCapableBox, type CliSeam, type CombinatorShape, type Corpus, type CorpusFilter, type CorpusRecord, type CreateScopeAnalystOptions, type CriuCapableClient, type DefinePersona, type DefinePersonaInput, type Deliverable, type Environment, type EqualKArm, type EqualKOnCost, type EqualKOnCostOptions, type EqualKVerdict, type EvolutionArchiveNode, type EvolutionAuthor, type EvolutionBandInfo, type EvolutionCandidate, type EvolutionGeneration, type EvolutionReport, ExecCtx, type ExecutorConfig, ExecutorFactory, ExecutorRegistry, type Fanout, type FanoutOptions, type FanoutSynthesis, FileCorpus, FileResultBlobStore, FileSpawnJournal, type FlatWidenGate, type ForkCapableBox, type GitWorkspaceOptions, type HarvestCorpusOptions, type HarvestFailure, type HarvestReport, InMemoryCorpus, InMemoryResultBlobStore, InMemorySpawnJournal, type IntentAudit, Iteration, type LoopDispatchOptions, type LoopOptionsForDispatch, LoopResult, type LoopShape, LoopTokenUsage, type LoopUntil, type LoopUntilSpec, type LoopUntilState, type McpEndpoint, type McpEnvironmentOptions, NodeId, type Observation, type ObserveInput, type ObserveOptions, type OpenSandboxRunOptions, type Outcome, type Panel, type PanelJudge, type PanelSpec, type PanelVerdict, type Persona, type PersonaContext, type PersonaExecutors, type Pipeline, type PipelineStage, type PromotionGateOptions, type PromotionVerdict, type RegistryAnalyzeProjection, type RenderCorpusToInstructions, type RenderCorpusToInstructionsOptions, type ReservationTicket, ResultBlobStore, RootHandle,
|
|
3524
|
+
export { Agent, AgentRunSpec, AgentSpec, type AgenticOptions, type AgenticRunResult, type AgenticSurface, type AgenticTask, type AgenticTool, type AnytimeReport, type AnytimeStrategySummary, type AnytimeTaskCurve, type ArtifactHandle, type AssertTraceDerivedFindings, type AuditIntentInput, type AuditIntentOptions, type AuthorStrategyOptions, type AuthoredProfile, type AuthoredStrategy, type BenchmarkCell, type BenchmarkConfig, type BenchmarkLift, type BenchmarkReport, type BenchmarkStrategySummary, type BenchmarkTaskRow, type BridgeSeam, Budget, type BudgetPool, type BudgetReadout, type ChampionPick, type ChampionPolicy, type CheckpointCapableBox, type CliSeam, type CombinatorShape, type CompletionAnalyst, type CompletionEvidence, type CompletionPolicy, type CompletionVerdict, type CoordinationDriverOptions, type CoordinationMcpHandle, type Corpus, type CorpusFilter, type CorpusRecord, type CreateScopeAnalystOptions, type CriuCapableClient, type DefinePersona, type DefinePersonaInput, type Deliverable, type DeliverableSpec, type DriverChat, type DriverMessage, type DriverToolCall, type DriverTurn, type Environment, type EqualKArm, type EqualKOnCost, type EqualKOnCostOptions, type EqualKVerdict, type EvolutionArchiveNode, type EvolutionAuthor, type EvolutionBandInfo, type EvolutionCandidate, type EvolutionGeneration, type EvolutionReport, ExecCtx, Executor, type ExecutorConfig, ExecutorFactory, ExecutorRegistry, type Fanout, type FanoutOptions, type FanoutSynthesis, FileCorpus, FileResultBlobStore, FileSpawnJournal, type FlatWidenGate, type ForkCapableBox, type GitWorkspaceOptions, type HarvestCorpusOptions, type HarvestFailure, type HarvestReport, InMemoryCorpus, InMemoryResultBlobStore, InMemorySpawnJournal, type IntentAudit, Iteration, type LoopDispatchOptions, type LoopOptionsForDispatch, LoopResult, type LoopShape, LoopTokenUsage, type LoopUntil, type LoopUntilSpec, type LoopUntilState, type McpEndpoint, type McpEnvironmentOptions, type NestedScopeSeam, NodeId, type Observation, type ObserveInput, type ObserveOptions, type OpenSandboxRunOptions, type Outcome, type Panel, type PanelJudge, type PanelSpec, type PanelVerdict, type Persona, type PersonaContext, type PersonaExecutors, type Pipeline, type PipelineStage, type PromotionGateOptions, type PromotionVerdict, type RegistryAnalyzeProjection, type RenderCorpusToInstructions, type RenderCorpusToInstructionsOptions, type ReservationTicket, ResultBlobStore, RootHandle, RouterConfig, type RouterSeam, type RouterToolsSeam, type RunAgenticOptions, RunLoopOptions, type RunPersonified, type RunPersonifiedOptions, type SandboxCapabilities, SandboxClient, type SandboxLineage, type SandboxLineageHandle, type SandboxRun, type SandboxSeam, Scope, type ScopeAnalyst, type ScopeAnalyzeInput, type ScopeWidenGate, type SessionCapableBox, Settled, type ShapeBudget, type ShapeContext, type ShapeRegistry, type Shell, type ShotPersona, type ShotSpec, SpawnEvent, SpawnJournal, Spend, type SteerContext, type Strategy, type StrategyCtx, type StrategyEvolutionConfig, type StrategyResult, SupervisedResult, Supervisor, type SurfaceScore, ToolSpec, type TrajectoryNode, type TrajectoryReport, type TrajectoryReportFn, type TrajectoryReportOptions, TreeView, type TurnResult, UsageEvent, type UsageSink, type VerifierEnvironmentOptions, type Verify, type VerifySpec, type WaterfallCollector, type WaterfallReport, type WaterfallSpan, type Widen, type WidenDecision, type WidenLineage, type WidenSpec, type Workspace, type WorkspaceCommit, type WorkspaceRun, acquireSandbox, adaptiveRefine, anytimeReport, asAuthoredProfile, assertStrategyContract, assertTraceDerivedFindings, auditIntent, authorStrategy, authoredWorker, breadthDriver, buildSteerContext, builtinShapes, completionAuthorizes, contentAddress, coordinationDriverAgent, createBudgetPool, createExecutor, createExecutorRegistry, createMcpEnvironment, createRootHandle, createSandboxLineage, createScope, createScopeAnalyst, createShapeRegistry, createSupervisor, createVerifierEnvironment, createWaterfallCollector, defaultAnalystInstruction, defaultAuditorInstruction, definePersona, defineStrategy, depthDriver, deterministicCompletion, discriminatingMeans, driverChild, driverExecutorFactory, driverRuntime, equalKOnCost, extractLlmCallEvent, fanout, flatWidenGate, gateOnDeliverable, gitWorkspace, harvestCorpus, inlineSandboxClient, isDriverSpec, jjWorkspace, localShell, loopDispatch, loopUntil, mapSandboxEvent, materializeTreeView, nestedScopeSeamKey, observe, openSandboxRun, panel, pickChampion, pipeline, printBenchmarkReport, probeSandboxCapabilities, promotionGate, refine, registerShape, registryScopeAnalyst, renderAnytimeTable, renderCorpusToInstructions, renderReport, replaySpawnTree, reportLoopUsage, runAgentic, runBenchmark, runInWorkspace, runPersonified, runStrategyEvolution, sample, sampleThenRefine, selectChampion, sentinelCompletion, serveCoordinationMcp, settledToIteration, spendFromUsageEvents, stopSentinel, strategyAuthorContract, supervisorSkill, trajectoryReport, verify, widen, withDriverExecutor };
|