@tangle-network/agent-runtime 0.104.0 → 0.106.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 +176 -42
- package/dist/activation-CRjVfOiy.js +203 -0
- package/dist/activation-CRjVfOiy.js.map +1 -0
- package/dist/activation-DyWB0K6E.d.ts +98 -0
- package/dist/agent.d.ts +216 -234
- package/dist/agent.js +615 -547
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop-DGdtVENg.js +517 -0
- package/dist/analyst-loop-DGdtVENg.js.map +1 -0
- package/dist/analyst-loop.d.ts +10 -43
- package/dist/analyst-loop.js +2 -11
- package/dist/backends-Dy8NujB4.js +713 -0
- package/dist/backends-Dy8NujB4.js.map +1 -0
- package/dist/candidate-execution/index.d.ts +4 -192
- package/dist/candidate-execution/index.js +5 -66
- package/dist/candidate-execution-DqMbv1rU.js +488 -0
- package/dist/candidate-execution-DqMbv1rU.js.map +1 -0
- package/dist/coder-yhVWbdWc.js +40 -0
- package/dist/coder-yhVWbdWc.js.map +1 -0
- package/dist/conversation-XucG_K3l.js +1265 -0
- package/dist/conversation-XucG_K3l.js.map +1 -0
- package/dist/conversation.d.ts +2 -804
- package/dist/conversation.js +2 -55
- package/dist/environment-provider-CfLUmKmf.js +1168 -0
- package/dist/environment-provider-CfLUmKmf.js.map +1 -0
- package/dist/environment-provider-IUGU3epE.d.ts +964 -0
- package/dist/environment-provider.d.ts +2 -78
- package/dist/environment-provider.js +2 -18
- package/dist/errors-DEAvWQPy.js +111 -0
- package/dist/errors-DEAvWQPy.js.map +1 -0
- package/dist/improvement-adapter-Cr5TBSji.d.ts +166 -0
- package/dist/improvement-cycle-C095kS_g.js +2624 -0
- package/dist/improvement-cycle-C095kS_g.js.map +1 -0
- package/dist/index-BGdxAwfO.d.ts +838 -0
- package/dist/index-C-FYUuFG.d.ts +193 -0
- package/dist/index-CbNM40xG.d.ts +140 -0
- package/dist/index-DruSKs3Z.d.ts +7224 -0
- package/dist/index-Efjb3nrQ.d.ts +671 -0
- package/dist/index.d.ts +14 -1134
- package/dist/index.js +2134 -1972
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +776 -888
- package/dist/intelligence.js +1466 -1410
- package/dist/intelligence.js.map +1 -1
- package/dist/{kb-gate-CwHO0vz6.d.ts → kb-gate-C8z2juK8.d.ts} +33 -31
- package/dist/kb-gate-DpaSwXVx.js +80 -0
- package/dist/kb-gate-DpaSwXVx.js.map +1 -0
- package/dist/knowledge-Ku-mPP4f.js +433 -0
- package/dist/knowledge-Ku-mPP4f.js.map +1 -0
- package/dist/knowledge.d.ts +2 -150
- package/dist/knowledge.js +2 -40
- package/dist/local-harness-Dh8PJ0ot.d.ts +455 -0
- package/dist/loop-runner-bin-BXsFEUcf.d.ts +162 -0
- package/dist/loop-runner-bin-BwjQ1NfH.js +268 -0
- package/dist/loop-runner-bin-BwjQ1NfH.js.map +1 -0
- package/dist/loop-runner-bin.d.ts +2 -17
- package/dist/loop-runner-bin.js +2 -24
- package/dist/loops.d.ts +5 -4164
- package/dist/loops.js +8 -419
- package/dist/mcp/bin.d.ts +1 -1
- package/dist/mcp/bin.js +116 -146
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +295 -437
- package/dist/mcp/index.js +1242 -1177
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/memory-bin.d.ts +1 -1
- package/dist/mcp/memory-bin.js +37 -16
- package/dist/mcp/memory-bin.js.map +1 -1
- package/dist/memory-server-DL6cE2Ag.js +234 -0
- package/dist/memory-server-DL6cE2Ag.js.map +1 -0
- package/dist/model-resolution-Btd9iIKV.js +98 -0
- package/dist/model-resolution-Btd9iIKV.js.map +1 -0
- package/dist/openai-tools-B68JaOCx.d.ts +24 -0
- package/dist/openai-tools-CKLy1C7M.js +44 -0
- package/dist/openai-tools-CKLy1C7M.js.map +1 -0
- package/dist/otel-export-D34IQW1C.js +843 -0
- package/dist/otel-export-D34IQW1C.js.map +1 -0
- package/dist/platform.d.ts +188 -185
- package/dist/platform.js +185 -218
- package/dist/platform.js.map +1 -1
- package/dist/prepare-B53sPV7M.js +4292 -0
- package/dist/prepare-B53sPV7M.js.map +1 -0
- package/dist/primeintellect/index.d.ts +150 -147
- package/dist/primeintellect/index.js +626 -1004
- package/dist/primeintellect/index.js.map +1 -1
- package/dist/profiles.d.ts +296 -490
- package/dist/profiles.js +722 -749
- package/dist/profiles.js.map +1 -1
- package/dist/protected-model-port-BLPH5VVv.js +722 -0
- package/dist/protected-model-port-BLPH5VVv.js.map +1 -0
- package/dist/protected-model-port-BP6Z4eau.d.ts +283 -0
- package/dist/protected-redaction--F3v1oo8.js +200 -0
- package/dist/protected-redaction--F3v1oo8.js.map +1 -0
- package/dist/redact-D-u-rrcn.js +82 -0
- package/dist/redact-D-u-rrcn.js.map +1 -0
- package/dist/redact-kbIOjfjM.d.ts +452 -0
- package/dist/researcher-CoVqNhfI.js +433 -0
- package/dist/researcher-CoVqNhfI.js.map +1 -0
- package/dist/runtime-BG0BziaP.js +5408 -0
- package/dist/runtime-BG0BziaP.js.map +1 -0
- package/dist/sandbox-events-DeI5xX8P.js +316 -0
- package/dist/sandbox-events-DeI5xX8P.js.map +1 -0
- package/dist/spawn-journal-CwPvKUTa.js +456 -0
- package/dist/spawn-journal-CwPvKUTa.js.map +1 -0
- package/dist/structural-rollout-IXUEplky.js +1445 -0
- package/dist/structural-rollout-IXUEplky.js.map +1 -0
- package/dist/substrate-B0TYNrXn.js +27 -0
- package/dist/substrate-B0TYNrXn.js.map +1 -0
- package/dist/{substrate-Dyiqmd3o.d.ts → substrate-BcnuSHXm.d.ts} +57 -54
- package/dist/supervise-BiRutHS9.js +7321 -0
- package/dist/supervise-BiRutHS9.js.map +1 -0
- package/dist/supervisor-DTKhF-RV.js +3826 -0
- package/dist/supervisor-DTKhF-RV.js.map +1 -0
- package/dist/testing.d.ts +4 -3
- package/dist/testing.js +2478 -2637
- package/dist/testing.js.map +1 -1
- package/dist/tool-server-RcWgLIsL.js +141 -0
- package/dist/tool-server-RcWgLIsL.js.map +1 -0
- package/dist/trace-propagation-CJJC7SVB.js +57 -0
- package/dist/trace-propagation-CJJC7SVB.js.map +1 -0
- package/dist/types-BaIpb0XT.d.ts +492 -0
- package/dist/types-BevOjfTY.d.ts +765 -0
- package/dist/types-C9j4qg6l.d.ts +500 -0
- package/dist/types-Cja5OTGh.d.ts +190 -0
- package/dist/util-MVgdwuIS.js +145 -0
- package/dist/util-MVgdwuIS.js.map +1 -0
- package/dist/workspace-archive-BosQiotA.js +575 -0
- package/dist/workspace-archive-BosQiotA.js.map +1 -0
- package/package.json +43 -55
- package/skills/build-with-agent-runtime/SKILL.md +16 -9
- package/skills/loop-writer/SKILL.md +1 -1
- package/dist/activation-Cm-9MMX1.d.ts +0 -69
- package/dist/analyst-loop.js.map +0 -1
- package/dist/backends-BO4Jqoe2.d.ts +0 -134
- package/dist/candidate-execution/index.js.map +0 -1
- package/dist/chunk-2KGAN2HM.js +0 -1256
- package/dist/chunk-2KGAN2HM.js.map +0 -1
- package/dist/chunk-2QJSNOGK.js +0 -48
- package/dist/chunk-2QJSNOGK.js.map +0 -1
- package/dist/chunk-2UABGGUB.js +0 -474
- package/dist/chunk-2UABGGUB.js.map +0 -1
- package/dist/chunk-2VZYRB55.js +0 -834
- package/dist/chunk-2VZYRB55.js.map +0 -1
- package/dist/chunk-2X65HYMI.js +0 -3526
- package/dist/chunk-2X65HYMI.js.map +0 -1
- package/dist/chunk-3MDZX7YU.js +0 -125
- package/dist/chunk-3MDZX7YU.js.map +0 -1
- package/dist/chunk-3PPVCS75.js +0 -199
- package/dist/chunk-3PPVCS75.js.map +0 -1
- package/dist/chunk-5HNDYWUT.js +0 -6424
- package/dist/chunk-5HNDYWUT.js.map +0 -1
- package/dist/chunk-5IBQAPVB.js +0 -29
- package/dist/chunk-5IBQAPVB.js.map +0 -1
- package/dist/chunk-5QOB7H74.js +0 -387
- package/dist/chunk-5QOB7H74.js.map +0 -1
- package/dist/chunk-ATDFUJYI.js +0 -4728
- package/dist/chunk-ATDFUJYI.js.map +0 -1
- package/dist/chunk-B7K7V22Y.js +0 -699
- package/dist/chunk-B7K7V22Y.js.map +0 -1
- package/dist/chunk-DPEUKJRO.js +0 -27
- package/dist/chunk-DPEUKJRO.js.map +0 -1
- package/dist/chunk-FD2MBMOH.js +0 -494
- package/dist/chunk-FD2MBMOH.js.map +0 -1
- package/dist/chunk-FJI3EXU3.js +0 -2402
- package/dist/chunk-FJI3EXU3.js.map +0 -1
- package/dist/chunk-HAO4CXHP.js +0 -200
- package/dist/chunk-HAO4CXHP.js.map +0 -1
- package/dist/chunk-ISPWRSEC.js +0 -408
- package/dist/chunk-ISPWRSEC.js.map +0 -1
- package/dist/chunk-KRBFHMV6.js +0 -1228
- package/dist/chunk-KRBFHMV6.js.map +0 -1
- package/dist/chunk-L5DST3QC.js +0 -351
- package/dist/chunk-L5DST3QC.js.map +0 -1
- package/dist/chunk-M22PL4GH.js +0 -171
- package/dist/chunk-M22PL4GH.js.map +0 -1
- package/dist/chunk-NURIQBJQ.js +0 -72
- package/dist/chunk-NURIQBJQ.js.map +0 -1
- package/dist/chunk-PZZKQVQV.js +0 -52
- package/dist/chunk-PZZKQVQV.js.map +0 -1
- package/dist/chunk-Q2JSAVQ3.js +0 -671
- package/dist/chunk-Q2JSAVQ3.js.map +0 -1
- package/dist/chunk-SBTWKPVR.js +0 -5576
- package/dist/chunk-SBTWKPVR.js.map +0 -1
- package/dist/chunk-SGKPNBXE.js +0 -60
- package/dist/chunk-SGKPNBXE.js.map +0 -1
- package/dist/chunk-SNSMRT6H.js +0 -680
- package/dist/chunk-SNSMRT6H.js.map +0 -1
- package/dist/chunk-STJEHM5F.js +0 -1338
- package/dist/chunk-STJEHM5F.js.map +0 -1
- package/dist/chunk-UPWGXKXB.js +0 -254
- package/dist/chunk-UPWGXKXB.js.map +0 -1
- package/dist/chunk-YEJR7IXO.js +0 -68
- package/dist/chunk-YEJR7IXO.js.map +0 -1
- package/dist/chunk-ZXICDSAK.js +0 -907
- package/dist/chunk-ZXICDSAK.js.map +0 -1
- package/dist/completion-gate-Bv47cOnn.d.ts +0 -256
- package/dist/conversation.js.map +0 -1
- package/dist/coordination-CxtzMxSM.d.ts +0 -2570
- package/dist/environment-provider.js.map +0 -1
- package/dist/improve--2A0gK1-.d.ts +0 -440
- package/dist/improvement-adapter-HAZz-7vK.d.ts +0 -203
- package/dist/knowledge.js.map +0 -1
- package/dist/local-harness-CtK9dSny.d.ts +0 -175
- package/dist/loop-runner-bin-DUOGtvOl.d.ts +0 -207
- package/dist/loop-runner-bin.js.map +0 -1
- package/dist/loops.js.map +0 -1
- package/dist/openai-tools-fnj6SRVg.d.ts +0 -46
- package/dist/protected-model-port-DzkUY3HQ.d.ts +0 -271
- package/dist/sanitize-DEbPNtyI.d.ts +0 -328
- package/dist/structural-rollout-C4mabf87.d.ts +0 -446
- package/dist/supervise-7q9F5brx.d.ts +0 -379
- package/dist/types-BCoemcXU.d.ts +0 -802
- package/dist/types-BwoZWq-i.d.ts +0 -510
- package/dist/types-Cbp72qyu.d.ts +0 -491
- package/dist/types-CmYCMbFT.d.ts +0 -203
- package/dist/types-CvNwMzQt.d.ts +0 -957
- package/dist/worktree-fanout-WsOzt8qu.d.ts +0 -999
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
import { R as RuntimeHooks, S as SelectionReceipt } from './types-BCoemcXU.js';
|
|
2
|
-
import { C as Corpus, O as Outcome } from './worktree-fanout-WsOzt8qu.js';
|
|
3
|
-
import { A as Agent, B as Budget, S as Scope } from './types-CvNwMzQt.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The general agentic primitive — sequential (depth) and parallel (breadth) over a shared,
|
|
7
|
-
* checkable artifact, driven through the keystone Supervisor as one recursive `Agent.act`.
|
|
8
|
-
*
|
|
9
|
-
* The domain lives behind ONE seam — `AgenticSurface` (open an artifact, list tools, call a tool,
|
|
10
|
-
* score the artifact, close it). EnterpriseOps implements it (seed a gym DB, MCP tools, SQL
|
|
11
|
-
* verifier); Commit0/AppWorld/terminal-bench implement it the same way (a repo workspace, shell
|
|
12
|
-
* tools, the test suite). The drivers below are domain-blind: they run over any surface.
|
|
13
|
-
*
|
|
14
|
-
* Two shapes, the agent's POMDP rollout as the unit:
|
|
15
|
-
* - DEPTH one persistent artifact carried across shots. Each shot the agent works the tool loop;
|
|
16
|
-
* between shots a trace-analyst (selector≠judge: reads the trajectory, never the score)
|
|
17
|
-
* steers the resumed session toward what's unfinished. shot n stands on shot n-1's
|
|
18
|
-
* artifact state + history. This is continuation — long-horizon, same artifact.
|
|
19
|
-
* - BREADTH K independent artifacts, each a fresh rollout, the deployable verifier picks the best.
|
|
20
|
-
*
|
|
21
|
-
* Both are an `Agent` whose `act` spawns leaf shots through `scope.spawn` and reacts via
|
|
22
|
-
* `scope.next()` — so the conserved budget pool meters them (equal-k by construction), the journal
|
|
23
|
-
* records the tree, and the same primitive nests. `runAgentic` runs the chosen driver through
|
|
24
|
-
* `createSupervisor().run`. The leaf (one shot over a handle) is resolved per-spawn from a
|
|
25
|
-
* surface-closed registry — the open `Executor` seam, not bespoke per-benchmark glue.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
interface AgenticTask {
|
|
29
|
-
readonly id: string;
|
|
30
|
-
readonly systemPrompt: string;
|
|
31
|
-
readonly userPrompt: string;
|
|
32
|
-
/** Opaque domain payload the surface reads (EOPS: servers/verifiers/tools). Drivers never read it. */
|
|
33
|
-
readonly meta?: Record<string, unknown>;
|
|
34
|
-
}
|
|
35
|
-
interface ArtifactHandle {
|
|
36
|
-
readonly id: string;
|
|
37
|
-
readonly surface: string;
|
|
38
|
-
/** Opaque per-artifact context the surface stashes (EOPS: the seeded gym server + db id). */
|
|
39
|
-
readonly ctx?: unknown;
|
|
40
|
-
}
|
|
41
|
-
interface AgenticTool {
|
|
42
|
-
readonly type: 'function';
|
|
43
|
-
readonly function: {
|
|
44
|
-
name: string;
|
|
45
|
-
description?: string;
|
|
46
|
-
parameters: Record<string, unknown>;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
interface SurfaceScore {
|
|
50
|
-
passes: number;
|
|
51
|
-
total: number;
|
|
52
|
-
/** Checks excluded as malformed (data defect, not the agent). `total === 0` ⇒ unscoreable. */
|
|
53
|
-
errored: number;
|
|
54
|
-
}
|
|
55
|
-
/** A stateful, checkable environment an agent operates over with tools. Open behind one interface. */
|
|
56
|
-
interface AgenticSurface {
|
|
57
|
-
readonly name: string;
|
|
58
|
-
open(task: AgenticTask): Promise<ArtifactHandle>;
|
|
59
|
-
tools(task: AgenticTask, handle: ArtifactHandle): Promise<AgenticTool[]>;
|
|
60
|
-
call(handle: ArtifactHandle, name: string, args: Record<string, unknown>): Promise<string>;
|
|
61
|
-
score(task: AgenticTask, handle: ArtifactHandle): Promise<SurfaceScore>;
|
|
62
|
-
close(handle: ArtifactHandle): Promise<void>;
|
|
63
|
-
}
|
|
64
|
-
interface AgenticOptions {
|
|
65
|
-
routerBaseUrl: string;
|
|
66
|
-
routerKey: string;
|
|
67
|
-
model: string;
|
|
68
|
-
/** Optional completion transport (see `RouterConfig.complete`): when set, BOTH legs of an
|
|
69
|
-
* offline run use it instead of `fetch`-ing the router — the worker's tool loop (threaded into
|
|
70
|
-
* its `routerToolLoop` cfg) AND the analyst's critic (its `ChatClient` is bound to this same
|
|
71
|
-
* transport). One injected responder serves both, as a localhost mock endpoint would. Absent ⇒
|
|
72
|
-
* the live router fetch path (the default). */
|
|
73
|
-
complete?: (body: Record<string, unknown>) => Promise<unknown>;
|
|
74
|
-
temperature?: number;
|
|
75
|
-
/** Completion cap per worker turn — REQUIRED for thinking models (they burn unbounded
|
|
76
|
-
* budgets on reasoning and return empty content without it). Omitted ⇒ provider default. */
|
|
77
|
-
maxTokens?: number;
|
|
78
|
-
/** Turns the agent may take within ONE shot before the driver intervenes. */
|
|
79
|
-
innerTurns?: number;
|
|
80
|
-
/** The depth STEERER's analyst instruction (observe()'s system prompt). The knob a
|
|
81
|
-
* prompt optimizer (GEPA) tunes — the analyst IS the steerer. Omitted ⇒ the default. */
|
|
82
|
-
analystInstruction?: string;
|
|
83
|
-
/** The critic's model — lets the analyst be a stronger (or cheaper) model than the
|
|
84
|
-
* worker. Omitted ⇒ the worker's `model`. */
|
|
85
|
-
analystModel?: string;
|
|
86
|
-
/** Across-run learning: when set, the analyst's observe() pass appends trace-derived
|
|
87
|
-
* facts here (the flywheel write side). Read-back is opt-in via `corpusReadback`
|
|
88
|
-
* because unconditional priming can pollute context on some domains. */
|
|
89
|
-
corpus?: Corpus;
|
|
90
|
-
/** Tags written onto learned facts (and used by the caller's priming query). */
|
|
91
|
-
corpusTags?: string[];
|
|
92
|
-
/** In-context learning: when set, query `corpus` before each depth shot and inject
|
|
93
|
-
* the top trace-derived facts as guidance for the active run. No corpus means no read-back. */
|
|
94
|
-
corpusReadback?: CorpusReadbackOptions;
|
|
95
|
-
}
|
|
96
|
-
interface CorpusReadbackOptions {
|
|
97
|
-
/** Minimum confidence for a fact to be injected. Default 0.7. */
|
|
98
|
-
minConfidence?: number;
|
|
99
|
-
/** Extra tags a fact must carry, in addition to `corpusTags`. */
|
|
100
|
-
tags?: ReadonlyArray<string>;
|
|
101
|
-
/** Max facts injected per shot. Default 3. */
|
|
102
|
-
maxFacts?: number;
|
|
103
|
-
/** Default false: only facts tagged `audience:agent` are injected into the worker. */
|
|
104
|
-
includeOperatorFacts?: boolean;
|
|
105
|
-
}
|
|
106
|
-
type Msg$1 = Record<string, unknown>;
|
|
107
|
-
interface ShotResult {
|
|
108
|
-
messages: Msg$1[];
|
|
109
|
-
score: number;
|
|
110
|
-
passes: number;
|
|
111
|
-
total: number;
|
|
112
|
-
completions: number;
|
|
113
|
-
toolErrors: number;
|
|
114
|
-
}
|
|
115
|
-
interface AgenticRunResult {
|
|
116
|
-
/** The strategy name (built-in 'depth'/'breadth' or a custom strategy's name). */
|
|
117
|
-
mode: string;
|
|
118
|
-
score: number;
|
|
119
|
-
resolved: boolean;
|
|
120
|
-
completions: number;
|
|
121
|
-
/** DEPTH: score after each shot — the progress-over-rounds curve. BREADTH: best-so-far per rollout. */
|
|
122
|
-
progression: number[];
|
|
123
|
-
shots: number;
|
|
124
|
-
/** The cost vector, stamped by `runAgentic` from the Supervisor's conserved pool: real
|
|
125
|
-
* router tokens, priced usd (0 when the model is unpriced — never fabricated), wall ms. */
|
|
126
|
-
usd: number;
|
|
127
|
-
ms: number;
|
|
128
|
-
tokens: {
|
|
129
|
-
input: number;
|
|
130
|
-
output: number;
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
/** DEPTH: one persistent artifact, carried across analyst-steered shots. */
|
|
134
|
-
declare function depthStrategy(surface: AgenticSurface, task: AgenticTask, opts: AgenticOptions, cfg: {
|
|
135
|
-
maxShots: number;
|
|
136
|
-
}): Agent<unknown, Outcome<unknown>>;
|
|
137
|
-
/** BREADTH: K independent rollouts (each own artifact), verifier picks the best. */
|
|
138
|
-
declare function breadthStrategy(_surface: AgenticSurface, task: AgenticTask, opts: AgenticOptions, cfg: {
|
|
139
|
-
width: number;
|
|
140
|
-
}): Agent<unknown, Outcome<unknown>>;
|
|
141
|
-
/**
|
|
142
|
-
* A Strategy is HOW you spend the compute budget to beat the Environment's check — it
|
|
143
|
-
* builds the driver `Agent` the Supervisor runs. This is the OPEN extension point: a dev
|
|
144
|
-
* authors their own by implementing `driver()` to return an Agent whose `act()` spawns
|
|
145
|
-
* shots/analysts via `scope.spawn` / `scope.next` / `scope.send`. The two built-ins are
|
|
146
|
-
* the reference implementations to copy:
|
|
147
|
-
* sample — K INDEPENDENT attempts, keep the best-verifying (best-of-N / resample).
|
|
148
|
-
* refine — attempt → observe() reads the trace → steer the next → repeat (iterate).
|
|
149
|
-
* (A multi-agent "team" is just a Strategy whose driver spawns several different agents.)
|
|
150
|
-
*/
|
|
151
|
-
interface Strategy {
|
|
152
|
-
readonly name: string;
|
|
153
|
-
driver(surface: AgenticSurface, task: AgenticTask, opts: AgenticOptions, budget: number): Agent<unknown, Outcome<unknown>>;
|
|
154
|
-
}
|
|
155
|
-
/** Built-in `Strategy`: K independent attempts, keep the best-verifying (best-of-N / resample). */
|
|
156
|
-
declare const sample: Strategy;
|
|
157
|
-
/** Built-in `Strategy`: attempt → `observe()` reads the trace → steer the next attempt → repeat (deepen one lineage). */
|
|
158
|
-
declare const refine: Strategy;
|
|
159
|
-
/** A role for one shot — multi-agent loops (researcher + engineer, a panel of k
|
|
160
|
-
* researchers) give each shot its own system prompt and optionally its own model. */
|
|
161
|
-
interface ShotPersona {
|
|
162
|
-
/** Replaces the task's systemPrompt for a FRESH shot; on a carried conversation it is
|
|
163
|
-
* injected as a hand-off message (the transcript's earlier roles stay intact). */
|
|
164
|
-
systemPrompt?: string;
|
|
165
|
-
/** Per-shot model override (e.g. a stronger model for the engineer shot). */
|
|
166
|
-
model?: string;
|
|
167
|
-
}
|
|
168
|
-
interface ShotSpec {
|
|
169
|
-
/** present ⇒ continue this artifact (depth); absent ⇒ the shot opens a fresh one (sample/restart). */
|
|
170
|
-
handle?: ArtifactHandle;
|
|
171
|
-
messages?: Msg$1[];
|
|
172
|
-
steer?: string;
|
|
173
|
-
persona?: ShotPersona;
|
|
174
|
-
/** Restrict THIS shot to a subset of the domain's tools (by name) — focus a shot on
|
|
175
|
-
* the relevant capabilities. Restriction-only; unknown names throw. Omitted ⇒ all. */
|
|
176
|
-
tools?: string[];
|
|
177
|
-
}
|
|
178
|
-
interface StrategyResult {
|
|
179
|
-
score: number;
|
|
180
|
-
resolved: boolean;
|
|
181
|
-
completions: number;
|
|
182
|
-
progression: number[];
|
|
183
|
-
shots: number;
|
|
184
|
-
}
|
|
185
|
-
/** Artifact lifecycle a strategy may manage itself — open/close ONLY. Raw `call`/`score`
|
|
186
|
-
* are withheld: scores reach the body solely through `shot()`'s ShotResult (the
|
|
187
|
-
* harness-verified channel), so a body cannot peek the check or fabricate around it. */
|
|
188
|
-
interface StrategyArtifacts {
|
|
189
|
-
readonly name: string;
|
|
190
|
-
open(task: AgenticTask): Promise<ArtifactHandle>;
|
|
191
|
-
close(handle: ArtifactHandle): Promise<void>;
|
|
192
|
-
}
|
|
193
|
-
/** What a strategy body composes with: the artifact lifecycle, the budget, and the two steps. */
|
|
194
|
-
interface StrategyCtx {
|
|
195
|
-
/** Open/close artifacts the body manages itself (e.g. one persistent handle for depth). */
|
|
196
|
-
readonly surface: StrategyArtifacts;
|
|
197
|
-
readonly task: AgenticTask;
|
|
198
|
-
readonly opts: AgenticOptions;
|
|
199
|
-
readonly budget: number;
|
|
200
|
-
readonly scope: Scope<Outcome<unknown>>;
|
|
201
|
-
/** Run ONE worker shot; its harness-scored result, or null if it went down. */
|
|
202
|
-
shot(spec?: ShotSpec): Promise<ShotResult | null>;
|
|
203
|
-
/** The firewalled critic reads the trajectory → a steer string, or null on COMPLETE/down. */
|
|
204
|
-
critique(messages: Msg$1[]): Promise<string | null>;
|
|
205
|
-
/** The RAW analyst channel: the firewalled critic answers `instruction` over the
|
|
206
|
-
* trajectory verbatim — no findings extraction, so verdict-shaped formats
|
|
207
|
-
* (CONTINUE/STOP decisions, calibrated predictions) survive. Same firewall:
|
|
208
|
-
* trajectory in, never scores. Null when the analyst went down. */
|
|
209
|
-
consult(messages: Msg$1[], instruction: string): Promise<string | null>;
|
|
210
|
-
/** The tools THIS artifact's task actually offers (names + descriptions only — never
|
|
211
|
-
* the implementations). Tool sets vary per task on heterogeneous domains; a strategy
|
|
212
|
-
* that restricts shots MUST select from this list, never from hardcoded names. */
|
|
213
|
-
listTools(handle: ArtifactHandle): Promise<Array<{
|
|
214
|
-
name: string;
|
|
215
|
-
description?: string;
|
|
216
|
-
}>>;
|
|
217
|
-
}
|
|
218
|
-
/** Author a Strategy from the composable steps — the open, compact way. */
|
|
219
|
-
declare function defineStrategy(name: string, run: (ctx: StrategyCtx) => Promise<StrategyResult>): Strategy;
|
|
220
|
-
/** A NEW strategy, authored from the steps (~20 lines): refine, but when a steered shot
|
|
221
|
-
* fails to improve the score it ABANDONS that line and restarts fresh (branch-when-stuck)
|
|
222
|
-
* — the widen/MCTS idea the depth-stuck failure motivated. Scored keep-best (the best
|
|
223
|
-
* checkpoint across all lines), the deployable metric. This is the "experts build BETTER
|
|
224
|
-
* optimizations" path: a new technique, compact, with zero Supervisor ceremony. */
|
|
225
|
-
declare const adaptiveRefine: Strategy;
|
|
226
|
-
/** The explore-then-exploit MIX: spend ⌈budget/2⌉ on independent samples (kept open),
|
|
227
|
-
* then refine the best-verifying line with the remaining budget. Sample's basin escape +
|
|
228
|
-
* refine's accumulation — the third built-in, authored from the public steps. */
|
|
229
|
-
declare const sampleThenRefine: Strategy;
|
|
230
|
-
interface RunAgenticOptions extends AgenticOptions {
|
|
231
|
-
surface: AgenticSurface;
|
|
232
|
-
task: AgenticTask;
|
|
233
|
-
/** Lifecycle observability — every spawn/settle (shots, analysts) streams here live.
|
|
234
|
-
* The seam online watchdogs/route-auditors subscribe to. */
|
|
235
|
-
hooks?: RuntimeHooks;
|
|
236
|
-
/** A Strategy (the open way) — author/pass your own. Overrides `mode` when present. */
|
|
237
|
-
strategy?: Strategy;
|
|
238
|
-
/** Built-in shorthand: 'depth'→refine, 'breadth'→sample. Default 'depth'. */
|
|
239
|
-
mode?: 'depth' | 'breadth';
|
|
240
|
-
/** budget: refine→max shots; sample→rollout width. */
|
|
241
|
-
budget: number;
|
|
242
|
-
rootBudget?: Budget;
|
|
243
|
-
}
|
|
244
|
-
/** Run a Strategy through the keystone Supervisor — `Agent.act` over a conserved-budget Scope. */
|
|
245
|
-
declare function runAgentic(opts: RunAgenticOptions): Promise<AgenticRunResult>;
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* structuralRollout — the measured structural lever as a fourth member of the
|
|
249
|
-
* sample/refine/sampleThenRefine strategy family: k independent samples, selection by
|
|
250
|
-
* TASK-VISIBLE checks only, then a guarded self-repair loop steered by the checks'
|
|
251
|
-
* failure output. Design: docs/design/structural-rollout-integration.md; measured basis
|
|
252
|
-
* (bench/src/hev-structural.mts, bench/src/mbpp-structural.mts): +8.5..+21.3pp hidden-test
|
|
253
|
-
* lift across Llama-3-8B/Qwen2.5-7B × HumanEval/MBPP, null only at saturation.
|
|
254
|
-
*
|
|
255
|
-
* Honesty invariants carried over from the proven rigs:
|
|
256
|
-
* - Visible checks are generated from task-visible information only, BEFORE any
|
|
257
|
-
* candidate exists, and FROZEN for every sample and repair round of the task.
|
|
258
|
-
* - OFFICIAL checks (shown in the task itself) rank lexicographically above
|
|
259
|
-
* model-AUTHORED guesses. This ordering is measured, not stylistic: authored guesses
|
|
260
|
-
* run 17–70% wrong depending on model × spec richness, and unweighted they flipped
|
|
261
|
-
* selection NEGATIVE on MBPP (6 noisy guesses outvoting the one reliable check).
|
|
262
|
-
* - A candidate that crashed before the checks could run ranks below one that ran and
|
|
263
|
-
* failed everything.
|
|
264
|
-
* - Repair sees ONLY the checks' failure output, and never displaces a candidate that
|
|
265
|
-
* passes more official checks with one that passes fewer (wrong visible examples
|
|
266
|
-
* poison repair at saturation — the glm /47,/116 regressions).
|
|
267
|
-
*
|
|
268
|
-
* Placement rule: this is an INFERENCE-TIME capability (it wraps the model call via the
|
|
269
|
-
* strategy seam). It does not belong in improve()/selfImprove (training-time); improve()
|
|
270
|
-
* may later tune `StructuralRolloutPolicy` as an optimizable surface.
|
|
271
|
-
*/
|
|
272
|
-
|
|
273
|
-
type Msg = Record<string, unknown>;
|
|
274
|
-
/** The rollout's compute recipe — promoted from the proven rigs' env vars (K/REPAIRS/
|
|
275
|
-
* TESTGEN/DIVERSE/TEMPERATURE). Defaults are the measured sweet spot: repair value
|
|
276
|
-
* concentrates at low k (~+12pp at k=1, +1–3pp at k=5), so `k=5, repairRounds=2` is the
|
|
277
|
-
* full recipe and `k=1, repairRounds=2` the low-compute preset. */
|
|
278
|
-
interface StructuralRolloutPolicy {
|
|
279
|
-
/** Independent samples per task (selection breadth). */
|
|
280
|
-
k: number;
|
|
281
|
-
/** Repair shots after selection, each steered by the checks' failure output. */
|
|
282
|
-
repairRounds: number;
|
|
283
|
-
/** Model-authored visible checks requested per task; 0 disables authoring. */
|
|
284
|
-
testgen: number;
|
|
285
|
-
/** Per-slot strategy-lens prefixes on the k samples (attacks the all-k-fail bucket).
|
|
286
|
-
* Measured as a paired null (+0.6pp) — kept as an optional knob, off by default. */
|
|
287
|
-
diverse?: boolean;
|
|
288
|
-
/** Sampling temperature for every shot of this strategy; omitted ⇒ the worker default. */
|
|
289
|
-
temperature?: number;
|
|
290
|
-
}
|
|
291
|
-
/** The measured default recipe: 5 samples, 2 guarded repair rounds, 6 authored checks. */
|
|
292
|
-
declare const defaultStructuralRolloutPolicy: StructuralRolloutPolicy;
|
|
293
|
-
/** One task-visible executable check (e.g. a single-line Python assert). */
|
|
294
|
-
interface VisibleCheck {
|
|
295
|
-
code: string;
|
|
296
|
-
/** 'official' = shown in the task itself (docstring example, shown assert);
|
|
297
|
-
* 'authored' = the model's own guess. Official outranks authored in selection. */
|
|
298
|
-
kind: 'official' | 'authored';
|
|
299
|
-
}
|
|
300
|
-
/** What a CheckSource composes with. `consult` is the strategy family's raw analyst
|
|
301
|
-
* channel (metered by the conserved pool, offline-injectable via `opts.complete`) —
|
|
302
|
-
* check authoring goes through it rather than a bespoke model client. */
|
|
303
|
-
interface CheckSourceCtx {
|
|
304
|
-
/** Authored-check budget for this task (`policy.testgen`). */
|
|
305
|
-
count: number;
|
|
306
|
-
/** The symbol authored checks must reference; undefined ⇒ authoring is skipped
|
|
307
|
-
* (no guesses beats guesses pinned to nothing). */
|
|
308
|
-
entrySymbol?: string;
|
|
309
|
-
/** One metered LLM call: instruction in, reply text out, null when the channel went
|
|
310
|
-
* down. The task's visible prompt is included by the channel itself. */
|
|
311
|
-
consult(instruction: string): Promise<string | null>;
|
|
312
|
-
}
|
|
313
|
-
/** Produces the task's visible checks. MUST derive them from agent-visible information
|
|
314
|
-
* only, before any candidate exists — the strategy freezes the returned set for every
|
|
315
|
-
* sample and repair round of the task. */
|
|
316
|
-
interface CheckSource {
|
|
317
|
-
generate(task: AgenticTask, ctx: CheckSourceCtx): Promise<VisibleCheck[]>;
|
|
318
|
-
}
|
|
319
|
-
/** The proven authored-assert filter (lifted from the rigs' generateTests): keep only
|
|
320
|
-
* single-line, paren-balanced asserts that reference the entry symbol — malformed lines
|
|
321
|
-
* are dropped here rather than poisoning every candidate's score identically. */
|
|
322
|
-
declare function filterAuthoredAsserts(reply: string, entrySymbol: string, count: number): string[];
|
|
323
|
-
/** Default authored-check source: one metered LLM call per task, before sampling,
|
|
324
|
-
* filtered through `filterAuthoredAsserts`. Returns [] (no signal, never a fabricated
|
|
325
|
-
* check) when the budget is 0, no entry symbol resolves, or the channel went down. */
|
|
326
|
-
declare function modelAuthoredChecks(overrides?: {
|
|
327
|
-
count?: number;
|
|
328
|
-
}): CheckSource;
|
|
329
|
-
/** Official checks the surface stashed on the task (e.g. MBPP's shown assert). Reads
|
|
330
|
-
* `task.meta[key]` as a string array; anything else means no official checks. */
|
|
331
|
-
declare function officialChecksFromMeta(key?: string): CheckSource;
|
|
332
|
-
/** Concatenate check sources (official first by convention — ordering does not affect
|
|
333
|
-
* scoring, which reads each check's `kind`). */
|
|
334
|
-
declare function composeCheckSources(...sources: CheckSource[]): CheckSource;
|
|
335
|
-
/** The symbol authored checks are pinned to: `task.meta.entryPoint` when the surface
|
|
336
|
-
* provides it, else the LAST `def name(` in the visible prompt (a code-completion stub
|
|
337
|
-
* lists helpers first, the entry stub last). Undefined ⇒ authoring is skipped. */
|
|
338
|
-
declare function resolveEntrySymbol(task: AgenticTask): string | undefined;
|
|
339
|
-
/** How one candidate fared against the frozen visible checks, split by check kind. */
|
|
340
|
-
interface CheckOutcome {
|
|
341
|
-
passedOfficial: number;
|
|
342
|
-
totalOfficial: number;
|
|
343
|
-
passedAuthored: number;
|
|
344
|
-
totalAuthored: number;
|
|
345
|
-
/** The checks' failure report — the ONLY feedback the repair loop may see. */
|
|
346
|
-
failureOutput: string;
|
|
347
|
-
/** True when the candidate crashed before any check could run — ranks below a
|
|
348
|
-
* candidate that ran and failed everything. */
|
|
349
|
-
crashed?: boolean;
|
|
350
|
-
}
|
|
351
|
-
/** Minimal exec channel the default runner needs. `SandboxInstance` (and therefore
|
|
352
|
-
* `ValidationCtx.box`) satisfies it structurally. */
|
|
353
|
-
interface CheckExecChannel {
|
|
354
|
-
exec(command: string, options?: {
|
|
355
|
-
timeoutMs?: number;
|
|
356
|
-
}): Promise<{
|
|
357
|
-
exitCode: number;
|
|
358
|
-
stdout: string;
|
|
359
|
-
stderr: string;
|
|
360
|
-
}>;
|
|
361
|
-
}
|
|
362
|
-
interface CheckRunContext {
|
|
363
|
-
task: AgenticTask;
|
|
364
|
-
/** Live exec channel for this run (`ValidationCtx.box` / a sandbox instance). */
|
|
365
|
-
box?: CheckExecChannel;
|
|
366
|
-
signal?: AbortSignal;
|
|
367
|
-
}
|
|
368
|
-
/** Executes the frozen checks against one candidate. Implementations MUST fail loud
|
|
369
|
-
* (throw) when they cannot execute — a silent zero poisons selection. */
|
|
370
|
-
interface CheckRunner {
|
|
371
|
-
run(candidate: string, checks: VisibleCheck[], ctx: CheckRunContext): Promise<CheckOutcome>;
|
|
372
|
-
}
|
|
373
|
-
/** Default CheckRunner backend: pipes the check program into `python3` over the sandbox
|
|
374
|
-
* exec channel (`ctx.box`, or one bound at construction). Never shells out to docker
|
|
375
|
-
* itself — the jail is the sandbox's concern. No channel ⇒ throws; it must never
|
|
376
|
-
* silently score 0. Empty check sets short-circuit to a no-signal outcome (nothing to
|
|
377
|
-
* execute, so no channel is required). */
|
|
378
|
-
declare function sandboxCheckRunner(options?: {
|
|
379
|
-
box?: CheckExecChannel;
|
|
380
|
-
python?: string;
|
|
381
|
-
timeoutMs?: number;
|
|
382
|
-
}): CheckRunner;
|
|
383
|
-
/** The selection order: crash < ran; then official pass-fraction; authored guesses only
|
|
384
|
-
* break ties. Returns > 0 when `a` outranks `b`. Strictly lexicographic — on MBPP,
|
|
385
|
-
* letting 6 noisy guesses outvote the one official check flipped selection negative. */
|
|
386
|
-
declare function compareCheckOutcomes(a: CheckOutcome, b: CheckOutcome): number;
|
|
387
|
-
/** Display scalar for receipts/reports (the rigs' `visibleScore` shape): crash = -1,
|
|
388
|
-
* else official fraction + 0.001 × authored fraction. Selection itself uses the exact
|
|
389
|
-
* lexicographic comparator, never this scalar. */
|
|
390
|
-
declare function visibleCheckScore(o: CheckOutcome): number;
|
|
391
|
-
/** Argmax by `compareCheckOutcomes`, FIRST index wins ties (deterministic; with zero
|
|
392
|
-
* visible coverage every candidate ties at no-signal and index 0 is the blind pick). */
|
|
393
|
-
declare function selectBestIndex(outcomes: ReadonlyArray<CheckOutcome>): number;
|
|
394
|
-
/** The repair keep-best guard: a challenger displaces the incumbent only when it is
|
|
395
|
-
* strictly better in the selection order AND passes at least as many official checks.
|
|
396
|
-
* The raw-count clause is deliberate belt-and-braces over the comparator (a custom
|
|
397
|
-
* runner can report shifted totals): repair must NEVER replace a candidate that passes
|
|
398
|
-
* more official checks with one that passes fewer. */
|
|
399
|
-
declare function canDisplace(challenger: CheckOutcome, incumbent: CheckOutcome): boolean;
|
|
400
|
-
/** The candidate a shot produced, read from its conversation: the LAST `submit_answer`
|
|
401
|
-
* tool-call argument (verifier environments submit the artifact explicitly), else the
|
|
402
|
-
* latest assistant reply's fenced code block — preferring a block containing a `def`,
|
|
403
|
-
* because repair replies echo the failure report in a bare fence BEFORE the fixed code
|
|
404
|
-
* (the rigs' extractRepairCode lesson) — else the latest non-empty assistant text. */
|
|
405
|
-
declare function defaultExtractCandidate(messages: ReadonlyArray<Msg>): string;
|
|
406
|
-
type RepairStop = 'already-passing' | 'no-signal' | 'repaired-pass' | 'rounds-exhausted' | 'no-candidates';
|
|
407
|
-
/** The body's deliverable — a `StrategyResult` plus selection provenance. The extra
|
|
408
|
-
* fields ride through `defineStrategy`'s deliverable spread onto `AgenticRunResult`
|
|
409
|
-
* (score/resolved stay harness-verified, exactly as for every authored strategy). */
|
|
410
|
-
interface StructuralRolloutResult extends StrategyResult {
|
|
411
|
-
/** One receipt per scored candidate (k samples, then repairs), `SelectionReceipt`
|
|
412
|
-
* shaped like the kernel's (`types.ts`), selector 'driver'. */
|
|
413
|
-
selection: SelectionReceipt[];
|
|
414
|
-
repairStop: RepairStop;
|
|
415
|
-
officialChecks: number;
|
|
416
|
-
authoredChecks: number;
|
|
417
|
-
}
|
|
418
|
-
interface StructuralRolloutConfig {
|
|
419
|
-
/** Knobs; missing fields take the measured defaults (k=5, repairRounds=2, testgen=6). */
|
|
420
|
-
policy?: Partial<StructuralRolloutPolicy>;
|
|
421
|
-
/** Where the visible checks come from. Default: official checks from
|
|
422
|
-
* `task.meta.visibleChecks` composed with `modelAuthoredChecks()`. */
|
|
423
|
-
checkSource?: CheckSource;
|
|
424
|
-
/** How candidates are measured. Default `sandboxCheckRunner()` — it needs an exec
|
|
425
|
-
* channel (bind one to the runner, or pass `box` here) and fails loud without one. */
|
|
426
|
-
checkRunner?: CheckRunner;
|
|
427
|
-
/** Exec channel threaded into every check run of this strategy (a sandbox instance /
|
|
428
|
-
* `ValidationCtx.box`). The strategy seam itself carries no sandbox, so the caller
|
|
429
|
-
* who owns one supplies it here or binds it into the runner. */
|
|
430
|
-
box?: CheckExecChannel;
|
|
431
|
-
/** Candidate extraction from a shot's conversation. Default `defaultExtractCandidate`. */
|
|
432
|
-
extractCandidate?: (messages: ReadonlyArray<Msg>) => string;
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Build the structuralRollout `Strategy`: k shots → score each by the frozen visible
|
|
436
|
-
* checks (official above authored, crash lowest) → argmax with first-index tie-break →
|
|
437
|
-
* up to `repairRounds` repair shots steered by the failure output, keep-best under the
|
|
438
|
-
* official-check guard. Authored via `defineStrategy`, so the deliverable score stays
|
|
439
|
-
* harness-verified and every shot is metered by the conserved pool.
|
|
440
|
-
*
|
|
441
|
-
* Budget note: `runAgentic`'s `budget` sizes the pool — pass at least
|
|
442
|
-
* `k + repairRounds + 1` so the samples, repairs, and the check-author consult all admit.
|
|
443
|
-
*/
|
|
444
|
-
declare function structuralRollout(config?: StructuralRolloutConfig): Strategy;
|
|
445
|
-
|
|
446
|
-
export { type AgenticSurface as A, defaultStructuralRolloutPolicy as B, type CheckExecChannel as C, defineStrategy as D, depthStrategy as E, filterAuthoredAsserts as F, modelAuthoredChecks as G, officialChecksFromMeta as H, refine as I, resolveEntrySymbol as J, runAgentic as K, sample as L, sampleThenRefine as M, sandboxCheckRunner as N, selectBestIndex as O, structuralRollout as P, visibleCheckScore as Q, type RepairStop as R, type StructuralRolloutPolicy as S, type VisibleCheck as V, type AgenticTask as a, type AgenticOptions as b, type Strategy as c, type ArtifactHandle as d, type SurfaceScore as e, type AgenticTool as f, type AgenticRunResult as g, type CheckOutcome as h, type CheckRunContext as i, type CheckRunner as j, type CheckSource as k, type CheckSourceCtx as l, type CorpusReadbackOptions as m, type RunAgenticOptions as n, type ShotPersona as o, type ShotSpec as p, type StrategyCtx as q, type StrategyResult as r, type StructuralRolloutConfig as s, type StructuralRolloutResult as t, adaptiveRefine as u, breadthStrategy as v, canDisplace as w, compareCheckOutcomes as x, composeCheckSources as y, defaultExtractCandidate as z };
|