@tangle-network/agent-runtime 0.105.0 → 0.106.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- 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-CiOCyRHb.js +743 -0
- package/dist/backends-CiOCyRHb.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-BpLQZGPH.js +1265 -0
- package/dist/conversation-BpLQZGPH.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 -1058
- package/dist/index.js +2106 -2082
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +768 -889
- package/dist/intelligence.js +1466 -1367
- 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-CRagyuNb.js +268 -0
- package/dist/loop-runner-bin-CRagyuNb.js.map +1 -0
- package/dist/loop-runner-bin.d.ts +2 -15
- 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 -436
- 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 +149 -145
- package/dist/primeintellect/index.js +626 -1003
- 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-5zM5XxLr.js +5408 -0
- package/dist/runtime-5zM5XxLr.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 +44 -56
- package/skills/build-with-agent-runtime/SKILL.md +1 -0
- 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-2VZYRB55.js +0 -834
- package/dist/chunk-2VZYRB55.js.map +0 -1
- package/dist/chunk-3MDZX7YU.js +0 -125
- package/dist/chunk-3MDZX7YU.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-C5RTIBNZ.js +0 -48
- package/dist/chunk-C5RTIBNZ.js.map +0 -1
- package/dist/chunk-CTRA64LY.js +0 -680
- package/dist/chunk-CTRA64LY.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-H5QPIZNX.js +0 -907
- package/dist/chunk-H5QPIZNX.js.map +0 -1
- package/dist/chunk-HLKC4UYB.js +0 -3514
- package/dist/chunk-HLKC4UYB.js.map +0 -1
- package/dist/chunk-HNP72PNU.js +0 -192
- package/dist/chunk-HNP72PNU.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-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-OPVWXJ2H.js +0 -75
- package/dist/chunk-OPVWXJ2H.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-RDOAVVHY.js +0 -699
- package/dist/chunk-RDOAVVHY.js.map +0 -1
- package/dist/chunk-SGKPNBXE.js +0 -60
- package/dist/chunk-SGKPNBXE.js.map +0 -1
- package/dist/chunk-SMQXZGLZ.js +0 -351
- package/dist/chunk-SMQXZGLZ.js.map +0 -1
- package/dist/chunk-UHEZW5BU.js +0 -2918
- package/dist/chunk-UHEZW5BU.js.map +0 -1
- package/dist/chunk-UPWGXKXB.js +0 -254
- package/dist/chunk-UPWGXKXB.js.map +0 -1
- package/dist/chunk-VISA6CI3.js +0 -200
- package/dist/chunk-VISA6CI3.js.map +0 -1
- package/dist/chunk-WMTCUOQL.js +0 -474
- package/dist/chunk-WMTCUOQL.js.map +0 -1
- package/dist/chunk-WRTOVNN4.js +0 -4728
- package/dist/chunk-WRTOVNN4.js.map +0 -1
- package/dist/chunk-WSTRQZYQ.js +0 -5576
- package/dist/chunk-WSTRQZYQ.js.map +0 -1
- package/dist/chunk-XBG2W2VW.js +0 -6434
- package/dist/chunk-XBG2W2VW.js.map +0 -1
- package/dist/chunk-YEJR7IXO.js +0 -68
- package/dist/chunk-YEJR7IXO.js.map +0 -1
- package/dist/chunk-YJZA2BIK.js +0 -1338
- package/dist/chunk-YJZA2BIK.js.map +0 -1
- package/dist/completion-gate-BMy5LGoP.d.ts +0 -256
- package/dist/conversation.js.map +0 -1
- package/dist/coordination-BZZSVYpZ.d.ts +0 -2570
- package/dist/environment-provider.js.map +0 -1
- package/dist/improvement-adapter-HAZz-7vK.d.ts +0 -203
- package/dist/knowledge.js.map +0 -1
- package/dist/local-harness-BDNcl6jI.d.ts +0 -175
- package/dist/loop-runner-bin-68aoM9-7.d.ts +0 -199
- 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-B4t-OQjL.d.ts +0 -271
- package/dist/redact-BuFjxBUJ.d.ts +0 -481
- package/dist/sanitize-DEbPNtyI.d.ts +0 -328
- package/dist/structural-rollout-DEh6CEsa.d.ts +0 -446
- package/dist/supervise-4_48wwvy.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-DxhAWr5Z.d.ts +0 -999
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
import { W as WorkerProgress, S as Scope, a as Settled, b as ResultBlobStore, B as Budget, A as Agent, c as SpawnJournal, d as WaitProbeRegistry, e as SupervisedResult } from './types-CvNwMzQt.js';
|
|
2
|
-
import { M as MakeWorkerAgent, A as AnalystRegistry, W as WorkerWatchOptions, E as ExecutorConfig } from './coordination-BZZSVYpZ.js';
|
|
3
|
-
import { R as RouterConfig, T as ToolLoopChat, a as ToolLoopCompactionOptions } from './sanitize-DEbPNtyI.js';
|
|
4
|
-
import { D as DeliverableSpec } from './completion-gate-BMy5LGoP.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* PROGRESS-BASED STOP RULES — end a long-horizon run for the right reason.
|
|
9
|
-
*
|
|
10
|
-
* Every existing bound is a CEILING: iterations, tokens, dollars, an absolute deadline, a turn
|
|
11
|
-
* cap. A ceiling answers "may this run continue?" and never "is this run still getting anywhere?".
|
|
12
|
-
* So a supervision tree that stopped learning at settle 4 keeps buying workers until it hits a
|
|
13
|
-
* wall — the run ends on exhaustion, and the operator cannot tell a run that finished from a run
|
|
14
|
-
* that ran out.
|
|
15
|
-
*
|
|
16
|
-
* A stop rule reads the run's own PROGRESS and decides. Three signals feed it:
|
|
17
|
-
* - the objective curve over settled work (best-so-far, from `anytime.ts` — see below),
|
|
18
|
-
* - the LIVE worker feed (`WorkerProgress`: `idleMs`, `stalled`, `turns`, `tokens`),
|
|
19
|
-
* - tree-level shape (how many are in flight, how many are waiting, when the last settle landed).
|
|
20
|
-
*
|
|
21
|
-
* ── Two boundaries this module holds deliberately ───────────────────────────────────────────────
|
|
22
|
-
*
|
|
23
|
-
* ENFORCEMENT lives here; THRESHOLDS do not. "Stop after 5 settles with no improvement" is a
|
|
24
|
-
* judgment about a domain — how noisy its scores are, how expensive a worker is, how much a late
|
|
25
|
-
* breakthrough is worth. That belongs to the caller (a loop, a bench, a product). Every rule below
|
|
26
|
-
* takes its thresholds as required options with no hidden defaults for the numbers that decide;
|
|
27
|
-
* the module ships the MECHANISM and refuses to ship the judgment.
|
|
28
|
-
*
|
|
29
|
-
* A stop rule can only ADD a stop, never remove one. The driver evaluates the hard ceilings
|
|
30
|
-
* (`poolStarved`, `deadlinePassed`, abort, the driver's own stop) FIRST and independently; the
|
|
31
|
-
* rule is consulted only when they all say "continue". So no rule can talk a run past its budget.
|
|
32
|
-
*
|
|
33
|
-
* ── What is reused, not re-derived ──────────────────────────────────────────────────────────────
|
|
34
|
-
*
|
|
35
|
-
* `anytime.ts` already computed best-so-far curves, their area, and plateau detection — but only
|
|
36
|
-
* after a run was over, from waterfall spans. Rather than write a second copy for the live path,
|
|
37
|
-
* `bestSoFar` / `areaUnderCurve` / `plateauLength` were extracted there and are imported here. A
|
|
38
|
-
* stop rule that calls a run plateaued therefore agrees, number for number, with the report that
|
|
39
|
-
* later judges whether stopping was right.
|
|
40
|
-
*
|
|
41
|
-
* @experimental
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/** One settled unit of work, reduced to what a stop rule reads. `objective` is the run's own
|
|
45
|
-
* quality signal (a verdict score, a test pass-rate, a judge rating); `undefined` = this
|
|
46
|
-
* settlement produced no measurable objective (it failed, or nothing scored it). */
|
|
47
|
-
interface ProgressSample {
|
|
48
|
-
readonly id: string;
|
|
49
|
-
/** Epoch ms the settlement was observed. */
|
|
50
|
-
readonly at: number;
|
|
51
|
-
readonly objective?: number;
|
|
52
|
-
/** True when the settlement passed its deliverable check — a scored-but-undelivered result is
|
|
53
|
-
* not progress. */
|
|
54
|
-
readonly delivered: boolean;
|
|
55
|
-
}
|
|
56
|
-
/** The read-model a `StopRule` decides from — the run's progress, not its budget. */
|
|
57
|
-
interface ProgressView {
|
|
58
|
-
readonly now: number;
|
|
59
|
-
/** Settlements observed so far, in the order they landed. */
|
|
60
|
-
readonly settles: number;
|
|
61
|
-
/** Of those, how many passed their deliverable check. */
|
|
62
|
-
readonly delivered: number;
|
|
63
|
-
/** Best-so-far objective after each settlement (`anytime.bestSoFar`). */
|
|
64
|
-
readonly curve: ReadonlyArray<number>;
|
|
65
|
-
/** The current best objective; `0` when nothing has scored. */
|
|
66
|
-
readonly best: number;
|
|
67
|
-
/** Mean of the best-so-far curve — how EARLY the run climbed (`anytime.areaUnderCurve`). */
|
|
68
|
-
readonly auc: number;
|
|
69
|
-
/** Epoch ms of the most recent settlement; `0` when none has landed. */
|
|
70
|
-
readonly lastSettleAt: number;
|
|
71
|
-
/** Epoch ms of the most recent improvement in best-so-far; `0` when none. */
|
|
72
|
-
readonly lastImprovementAt: number;
|
|
73
|
-
/** Settlements since the last improvement — `0` right after one improves. */
|
|
74
|
-
readonly settlesSinceImprovement: number;
|
|
75
|
-
/** Live read of every non-terminal worker (the `Scope.progress` feed). Empty when the caller
|
|
76
|
-
* supplied no scope. */
|
|
77
|
-
readonly workers: ReadonlyArray<WorkerProgress>;
|
|
78
|
-
/** Nodes running or acquiring. */
|
|
79
|
-
readonly inFlight: number;
|
|
80
|
-
/** Armed wait-state nodes — deliberately separate from `inFlight`: a tree whose only remaining
|
|
81
|
-
* nodes are waits is NOT stalled, it is waiting on the world. */
|
|
82
|
-
readonly waiting: number;
|
|
83
|
-
}
|
|
84
|
-
/** A stop rule's answer. `reason` is required when stopping — a run that ends must be able to say
|
|
85
|
-
* why in the result, and an unexplained early stop is indistinguishable from a bug. */
|
|
86
|
-
type StopDecision = {
|
|
87
|
-
readonly stop: false;
|
|
88
|
-
} | {
|
|
89
|
-
readonly stop: true;
|
|
90
|
-
readonly reason: string;
|
|
91
|
-
};
|
|
92
|
-
/** Evaluated from the progress feed, never from the budget. Pure and synchronous: it is called on
|
|
93
|
-
* the driver's hot path, once per turn. */
|
|
94
|
-
type StopRule = (view: ProgressView) => StopDecision;
|
|
95
|
-
/** Accumulates settlements and materializes a `ProgressView`. Idempotent by settlement id, so a
|
|
96
|
-
* caller may re-push its whole roster every turn (the driver does exactly that) without
|
|
97
|
-
* double-counting or moving a recorded timestamp. */
|
|
98
|
-
interface ProgressTracker {
|
|
99
|
-
/** Record a settlement. A second call with the same `id` is ignored. Returns true when it was
|
|
100
|
-
* new. */
|
|
101
|
-
record(sample: ProgressSample): boolean;
|
|
102
|
-
/** Materialize the view. Pass the live `Scope` to include the worker feed and tree shape. */
|
|
103
|
-
view(scope?: Scope<unknown>, opts?: {
|
|
104
|
-
readonly stallAfterMs?: number;
|
|
105
|
-
}): ProgressView;
|
|
106
|
-
/** Evaluate a rule against the current view. */
|
|
107
|
-
evaluate(rule: StopRule, scope?: Scope<unknown>, opts?: {
|
|
108
|
-
readonly stallAfterMs?: number;
|
|
109
|
-
}): StopDecision;
|
|
110
|
-
/** The samples recorded so far, in order. */
|
|
111
|
-
samples(): ReadonlyArray<ProgressSample>;
|
|
112
|
-
}
|
|
113
|
-
interface ProgressTrackerOptions {
|
|
114
|
-
/** Clock for `view().now`. Defaults to `Date.now`. */
|
|
115
|
-
readonly now?: () => number;
|
|
116
|
-
/** Treat a settlement that did NOT pass its deliverable check as having no objective. Default
|
|
117
|
-
* true — "scored 0.9 but never delivered" is not progress, and counting it as progress is the
|
|
118
|
-
* exact way a plateau rule gets talked out of firing. */
|
|
119
|
-
readonly requireDelivered?: boolean;
|
|
120
|
-
/** How much the best-so-far must rise for a settlement to count as an IMPROVEMENT. Default 0
|
|
121
|
-
* (any strict rise counts). Raise it to ignore score noise. */
|
|
122
|
-
readonly minImprovement?: number;
|
|
123
|
-
}
|
|
124
|
-
/** Build the settled-work ledger a `StopRule` decides from: record each settlement (idempotent by
|
|
125
|
-
* id) and materialize a `ProgressView` combining the best-so-far curve with the live worker feed. */
|
|
126
|
-
declare function createProgressTracker(opts?: ProgressTrackerOptions): ProgressTracker;
|
|
127
|
-
/** Build a `ProgressSample` from a scope settlement. The objective is the verdict score and
|
|
128
|
-
* `delivered` is the verdict's `valid` — the SAME single delivery signal `finalizeBestDelivered`
|
|
129
|
-
* and `defaultSelectWinner` use, so "progress" and "winner" cannot disagree. */
|
|
130
|
-
declare function sampleFromSettled(settled: Settled<unknown>, at: number): ProgressSample;
|
|
131
|
-
interface NoProgressForOptions {
|
|
132
|
-
/** Stop when this many ms have passed since the last SETTLEMENT. Omit to not bound on time. */
|
|
133
|
-
readonly ms?: number;
|
|
134
|
-
/** Stop when this many settlements have landed with no improvement in best-so-far. Omit to not
|
|
135
|
-
* bound on settles. */
|
|
136
|
-
readonly settles?: number;
|
|
137
|
-
/** Never stop before this many settlements have landed — the warm-up that stops a rule from
|
|
138
|
-
* firing on an empty run. Default 1. */
|
|
139
|
-
readonly minSettles?: number;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* "Nothing new has happened." Fires when the run has produced no new settled work for `ms`, or no
|
|
143
|
-
* IMPROVEMENT over the last `settles` settlements.
|
|
144
|
-
*
|
|
145
|
-
* A tree whose only remaining nodes are armed WAITS is exempt from the time bound: a run waiting
|
|
146
|
-
* on CI is not a run that stopped making progress, and killing it there would defeat mechanic C.
|
|
147
|
-
*/
|
|
148
|
-
declare function noProgressFor(opts: NoProgressForOptions): StopRule;
|
|
149
|
-
interface PlateauOptions {
|
|
150
|
-
/** How many trailing settlements to judge. The rule fires when the whole window failed to lift
|
|
151
|
-
* the best-so-far by more than `minDelta`. */
|
|
152
|
-
readonly window: number;
|
|
153
|
-
/** The rise that counts as an improvement — the domain's noise floor. `0` means any strict rise
|
|
154
|
-
* counts. */
|
|
155
|
-
readonly minDelta: number;
|
|
156
|
-
/** Never fire before this many settlements. Defaults to `window` (so the first decision is made
|
|
157
|
-
* on a full window, not on a partial one). */
|
|
158
|
-
readonly minSettles?: number;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* "The objective has stopped climbing." Fires when the best-so-far curve has risen by no more than
|
|
162
|
-
* `minDelta` across the last `window` settlements.
|
|
163
|
-
*
|
|
164
|
-
* Built on `anytime.plateauLength` — the same plateau math the post-run anytime report uses, so a
|
|
165
|
-
* rule that stops a run and a report that grades the decision cannot disagree about whether the
|
|
166
|
-
* run was flat.
|
|
167
|
-
*/
|
|
168
|
-
declare function plateau(opts: PlateauOptions): StopRule;
|
|
169
|
-
interface AllWorkersStalledOptions {
|
|
170
|
-
/** Require at least this many live workers before the rule can fire — one stalled worker in a
|
|
171
|
-
* one-worker tree is a weaker signal than a whole fleet going quiet. Default 1. */
|
|
172
|
-
readonly minWorkers?: number;
|
|
173
|
-
/** Idle time that counts as stalled, passed through to the live progress read. Omit = the
|
|
174
|
-
* runtime default (`DEFAULT_STALL_AFTER_MS`). */
|
|
175
|
-
readonly stallAfterMs?: number;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* "Everyone is stuck." Fires when every live worker reads `stalled` — no metered activity for
|
|
179
|
-
* longer than the stall threshold — and none of the tree is merely waiting.
|
|
180
|
-
*
|
|
181
|
-
* `stalled` is a derived read at observation time, never a background watchdog; this rule only
|
|
182
|
-
* reads it. A tree with armed waits never fires: waiting is not stalling.
|
|
183
|
-
*/
|
|
184
|
-
declare function allWorkersStalled(opts?: AllWorkersStalledOptions): StopRule;
|
|
185
|
-
/** Stop when ANY rule stops — the ordinary composition (each rule is a separate reason to end). */
|
|
186
|
-
declare function anyOf(...rules: ReadonlyArray<StopRule>): StopRule;
|
|
187
|
-
/** Stop only when EVERY rule stops — for a conservative gate that needs corroboration. */
|
|
188
|
-
declare function allOf(...rules: ReadonlyArray<StopRule>): StopRule;
|
|
189
|
-
|
|
190
|
-
/** The supervisor's profile — the subset of an `AgentProfile` that selects + shapes its brain.
|
|
191
|
-
* `harness` is the backend-as-data discriminant; `systemPrompt` is the standing instruction. */
|
|
192
|
-
interface SupervisorProfile {
|
|
193
|
-
readonly name?: string;
|
|
194
|
-
/** null/undefined → router brain (in-process tool-loop); a coding-CLI harness → sandboxed brain. */
|
|
195
|
-
readonly harness?: string | null;
|
|
196
|
-
/** The router model when the brain is router-driven (falls back to the deps router config). */
|
|
197
|
-
readonly model?: string;
|
|
198
|
-
/** The standing instructions ("you delegate, you do not solve"). */
|
|
199
|
-
readonly systemPrompt?: string;
|
|
200
|
-
}
|
|
201
|
-
/** How to run a sandboxed harness as the DRIVER, with the coordination verbs mounted — the substrate
|
|
202
|
-
* seam the caller supplies (mirrors `makeWorkerAgent` for spawned children). It runs `profile` on
|
|
203
|
-
* `task` in its backend (sandbox / cli-bridge) with `coordinationMcpUrl` mounted as an MCP server,
|
|
204
|
-
* so the harness calls spawn_agent / await_event / stop as native tools over the live scope. */
|
|
205
|
-
type DriveHarness = (args: {
|
|
206
|
-
readonly profile: SupervisorProfile;
|
|
207
|
-
readonly task: unknown;
|
|
208
|
-
readonly scope: Scope<unknown>;
|
|
209
|
-
readonly coordinationMcpUrl: string;
|
|
210
|
-
}) => Promise<void>;
|
|
211
|
-
interface SupervisorAgentDeps {
|
|
212
|
-
readonly blobs: ResultBlobStore;
|
|
213
|
-
/** Resolve a spawned worker `profile` to a leaf agent — the recursion seam (same for both arms). */
|
|
214
|
-
readonly makeWorkerAgent: MakeWorkerAgent;
|
|
215
|
-
/** Per-child budget reserved from the conserved pool on each spawn. */
|
|
216
|
-
readonly perWorker: Budget;
|
|
217
|
-
/** Hard cap on simultaneously-LIVE workers across both arms — `spawn_agent` fails closed once
|
|
218
|
-
* this many are in flight (a concurrency fence on top of the conserved-pool fence; bounds live
|
|
219
|
-
* boxes/sandboxes, not total work). Omit/`<= 0` = no cap. */
|
|
220
|
-
readonly maxLiveWorkers?: number;
|
|
221
|
-
/** Router substrate for a router-brained supervisor (`harness` null). The profile's model wins. */
|
|
222
|
-
readonly router?: RouterConfig;
|
|
223
|
-
/** Inject the brain directly (tests / advanced) instead of resolving `routerBrain` from the profile. */
|
|
224
|
-
readonly brain?: ToolLoopChat;
|
|
225
|
-
/** Required for a sandboxed-harness supervisor (`harness` set): runs the harness as the driver. */
|
|
226
|
-
readonly driveHarness?: DriveHarness;
|
|
227
|
-
/** WORK tools the supervisor may call DIRECTLY (router arm) — so it can do simple work ITSELF and
|
|
228
|
-
* only delegate when it needs parallelism. Pair with `executeExtraTool`. */
|
|
229
|
-
readonly extraTools?: ReadonlyArray<{
|
|
230
|
-
readonly name: string;
|
|
231
|
-
readonly description?: string;
|
|
232
|
-
readonly parameters: Record<string, unknown>;
|
|
233
|
-
}>;
|
|
234
|
-
/** Runs an `extraTools` call; null/undefined falls through to the coordination dispatch. */
|
|
235
|
-
readonly executeExtraTool?: (name: string, args: Record<string, unknown>) => Promise<string | null | undefined>;
|
|
236
|
-
/** Analyst lenses available to the driver (both arms). Required for `analyzeOnSettle`. */
|
|
237
|
-
readonly analysts?: AnalystRegistry;
|
|
238
|
-
/** Analyst kinds run on each worker-settle → a `finding` the driver composes its next steer from
|
|
239
|
-
* (the self-improving UP-leg). Unset/empty = status quo (no analyst feed). Requires `analysts`. */
|
|
240
|
-
readonly analyzeOnSettle?: ReadonlyArray<string>;
|
|
241
|
-
/** Run the ONLINE detector panel over each worker's LIVE tool trace (both arms) so the driver
|
|
242
|
-
* learns a worker is looping mid-run instead of at settle. Omit = no online watching. */
|
|
243
|
-
readonly watchWorkers?: WorkerWatchOptions;
|
|
244
|
-
/** Idle time after which `observe_agent` reports a worker as stalled. Omit = runtime default. */
|
|
245
|
-
readonly stallAfterMs?: number;
|
|
246
|
-
/** PROGRESS-derived stop rule (router arm). Ends a run that has stopped learning BEFORE it
|
|
247
|
-
* exhausts a ceiling; it can never keep a run alive past one. Build it with `plateau` /
|
|
248
|
-
* `noProgressFor` / `allWorkersStalled` from `supervise/stop-rules` — the thresholds are the
|
|
249
|
-
* caller's judgment. Omit = ceilings only. */
|
|
250
|
-
readonly stopRule?: StopRule;
|
|
251
|
-
/** One-shot notification of WHY a `stopRule` ended the run. */
|
|
252
|
-
readonly onProgressStop?: (reason: string) => void;
|
|
253
|
-
readonly maxTurns?: number;
|
|
254
|
-
/** Give the supervisor brain a chapter-lifecycle on its OWN context window (router arm only) — it
|
|
255
|
-
* distills its coordination transcript to a compact progress note once it exceeds the threshold,
|
|
256
|
-
* instead of re-billing the whole thing every turn. See `DriverAgentOptions.compaction`. */
|
|
257
|
-
readonly compaction?: ToolLoopCompactionOptions;
|
|
258
|
-
}
|
|
259
|
-
/** Build a supervisor `Agent` from its profile: the brain resolves from `profile.harness` (backend-as-data), the same resolution rule as every worker. */
|
|
260
|
-
declare function supervisorAgent(profile: SupervisorProfile, deps: SupervisorAgentDeps): Agent<unknown, unknown>;
|
|
261
|
-
|
|
262
|
-
/** Build the worker seam from a backend (WHERE workers run) + an optional completion oracle (the
|
|
263
|
-
* deliverable check that makes "settled ⟺ delivered" true — the guard against "ran but didn't
|
|
264
|
-
* deliver"). The ONE place a backend becomes a spawnable worker. */
|
|
265
|
-
declare function workerFromBackend(backend: ExecutorConfig, deliverable?: DeliverableSpec<unknown>): MakeWorkerAgent;
|
|
266
|
-
interface SuperviseOptions {
|
|
267
|
-
/** The conserved compute pool for the whole run. */
|
|
268
|
-
readonly budget: Budget;
|
|
269
|
-
/** WHERE workers run — derives the worker seam. Provide this OR an explicit `makeWorkerAgent`. */
|
|
270
|
-
readonly backend?: ExecutorConfig;
|
|
271
|
-
/** The completion oracle for backend-derived workers (settled ⟺ delivered). Strongly recommended:
|
|
272
|
-
* without it the supervisor trusts a worker's self-report — exactly the "ran but didn't deliver"
|
|
273
|
-
* failure mode of a static orchestrator. */
|
|
274
|
-
readonly deliverable?: DeliverableSpec<unknown>;
|
|
275
|
-
/** Override the worker seam directly (tests / advanced) instead of deriving it from `backend`. */
|
|
276
|
-
readonly makeWorkerAgent?: MakeWorkerAgent;
|
|
277
|
-
/** The supervisor's router substrate (`harness` null). The profile's model wins. */
|
|
278
|
-
readonly router?: RouterConfig;
|
|
279
|
-
/** Inject the supervisor brain directly (tests / advanced). */
|
|
280
|
-
readonly brain?: ToolLoopChat;
|
|
281
|
-
/** Run a sandboxed-harness supervisor (`harness` set). */
|
|
282
|
-
readonly driveHarness?: DriveHarness;
|
|
283
|
-
/** WORK tools the supervisor may call DIRECTLY — so a recursive atom can ACT (do simple work
|
|
284
|
-
* itself) OR SPAWN (delegate when it needs parallelism), not be a pure manager. Pair with
|
|
285
|
-
* `executeExtraTool`. Router arm only (`harness` null). */
|
|
286
|
-
readonly extraTools?: ReadonlyArray<{
|
|
287
|
-
readonly name: string;
|
|
288
|
-
readonly description?: string;
|
|
289
|
-
readonly parameters: Record<string, unknown>;
|
|
290
|
-
}>;
|
|
291
|
-
/** Runs an `extraTools` call; null/undefined falls through to the coordination dispatch. */
|
|
292
|
-
readonly executeExtraTool?: (name: string, args: Record<string, unknown>) => Promise<string | null | undefined>;
|
|
293
|
-
/** Per-child budget reserved on each spawn. Defaults to a quarter of the pool's tokens. */
|
|
294
|
-
readonly perWorker?: Budget;
|
|
295
|
-
/** Hard cap on simultaneously-LIVE workers — `spawn_agent` fails closed once this many are in
|
|
296
|
-
* flight. The conserved pool bounds TOTAL work; this bounds SIMULTANEOUS work (live boxes/
|
|
297
|
-
* sandboxes a real fleet runs at once). Omit/`<= 0` = no cap (the pool stays the only fence). */
|
|
298
|
-
readonly maxLiveWorkers?: number;
|
|
299
|
-
/** Analyst lenses available to the driver. Required for `analyzeOnSettle`. Unset → status quo
|
|
300
|
-
* (the driver receives settled worker outputs, no analyst findings). */
|
|
301
|
-
readonly analysts?: AnalystRegistry;
|
|
302
|
-
/** Analyst kind ids run AUTOMATICALLY when a worker settles `done` — each re-enters as a `finding`
|
|
303
|
-
* the driver pulls (`await_event`) and composes its next steer from. The self-improving UP-leg,
|
|
304
|
-
* threaded to the driver at this level (propagate to sub-drivers via a recursive `makeWorkerAgent`).
|
|
305
|
-
* Omit/empty = status quo (no analyst feed). Requires `analysts`. */
|
|
306
|
-
readonly analyzeOnSettle?: ReadonlyArray<string>;
|
|
307
|
-
/**
|
|
308
|
-
* Watch every worker's LIVE tool trace with the online detector panel and raise a `finding` the
|
|
309
|
-
* moment one loops or error-storms — so the supervisor learns it mid-run (via `await_event`)
|
|
310
|
-
* instead of at settle. Pairs with a steerable worker: the finding is the evidence, `steer_agent`
|
|
311
|
-
* is the correction. Requires a backend whose executor exposes a trace source (the steerable
|
|
312
|
-
* sandbox worker and the pi wrapper do); other runtimes are simply not watched.
|
|
313
|
-
*
|
|
314
|
-
* Omit = off (status quo — no online watching, no extra events).
|
|
315
|
-
*/
|
|
316
|
-
readonly watchWorkers?: WorkerWatchOptions;
|
|
317
|
-
/** Idle time after which `observe_agent` reports a running worker as `stalled`. A derived read
|
|
318
|
-
* at observation time — nothing is killed or retried. Omit = the runtime default. */
|
|
319
|
-
readonly stallAfterMs?: number;
|
|
320
|
-
/** Worker output store. Defaults to in-memory. */
|
|
321
|
-
readonly blobs?: ResultBlobStore;
|
|
322
|
-
/**
|
|
323
|
-
* Make the run DURABLE: journal + result blobs are file-backed under this directory
|
|
324
|
-
* (`createFileRunContext`), fsynced per write, and the supervisor reads the prior tree first.
|
|
325
|
-
* Re-running with the same `runDir` AND the same `runId` resumes — the children that already
|
|
326
|
-
* settled are replayed onto `Scope.resume` with their real outputs, and the scope's counters
|
|
327
|
-
* continue past the journaled maxima. Unset = in-memory, fresh every call.
|
|
328
|
-
*
|
|
329
|
-
* What that does and does not buy you, precisely: the run's history survives the process and is
|
|
330
|
-
* replayable, and a resumed run never corrupts the tree. It does NOT by itself make the built-in
|
|
331
|
-
* supervisor brain skip committed work — `supervisorAgent`'s driver does not read
|
|
332
|
-
* `Scope.resume`, so out of the box a resumed run re-spawns children it already paid for. Only a
|
|
333
|
-
* root `Agent.act` that reads `scope.resume.settled` (as the durable-resume test's root does)
|
|
334
|
-
* turns durability into work-skipping. Wiring that into the default brain is separate work.
|
|
335
|
-
*
|
|
336
|
-
* `runId` matters here: it defaults to the constant `'supervise'`, which is fine for a single
|
|
337
|
-
* resumable run per directory but collides across concurrent runs sharing one `runDir`.
|
|
338
|
-
*/
|
|
339
|
-
readonly runDir?: string;
|
|
340
|
-
/** Override the spawn journal directly (advanced; `runDir` is the ordinary durable path). Pair
|
|
341
|
-
* with `blobs` — a journal whose result payloads live in a different store cannot replay. */
|
|
342
|
-
readonly journal?: SpawnJournal;
|
|
343
|
-
/** Predicate registry for `poll` wait-states (`Scope.wait`). A `poll` names its predicate so the
|
|
344
|
-
* wait survives a restart; this is what the name resolves against. Unset ⇒ `poll` waits are
|
|
345
|
-
* refused `unknown-probe` and `timer` waits still work. */
|
|
346
|
-
readonly probes?: WaitProbeRegistry;
|
|
347
|
-
/**
|
|
348
|
-
* PROGRESS-derived stop rule (router-brained supervisor). Ends a run that has stopped LEARNING
|
|
349
|
-
* before it exhausts a ceiling — the answer to "a run should end because it is done or stuck,
|
|
350
|
-
* not because it ran out". It composes with the budget guards and can never override one.
|
|
351
|
-
*
|
|
352
|
-
* Build it from `supervise/stop-rules`: `plateau({window, minDelta})`,
|
|
353
|
-
* `noProgressFor({ms, settles})`, `allWorkersStalled({...})`, combined with `anyOf`/`allOf`. The
|
|
354
|
-
* thresholds are policy and stay with you; the enforcement lives in the runtime. Omit = ceilings
|
|
355
|
-
* only (unchanged behavior).
|
|
356
|
-
*/
|
|
357
|
-
readonly stopRule?: StopRule;
|
|
358
|
-
/** One-shot notification of WHY a `stopRule` ended the run — so a caller records the reason
|
|
359
|
-
* instead of inferring an early stop from an unexhausted budget. */
|
|
360
|
-
readonly onProgressStop?: (reason: string) => void;
|
|
361
|
-
readonly maxDepth?: number;
|
|
362
|
-
readonly maxTurns?: number;
|
|
363
|
-
/** Give the supervisor brain a chapter-lifecycle on its OWN context window (router arm only): once
|
|
364
|
-
* its coordination transcript exceeds `thresholdTokens` it distills to a compact progress note and
|
|
365
|
-
* continues, instead of re-billing the whole transcript every turn (the cost that makes the LLM-brain
|
|
366
|
-
* front door lose to a dumb-Ralph respawn). The live `Scope` roster is the durable state across
|
|
367
|
-
* chapters. Default off. `distill` defaults to a brain self-summary + the settled-worker roster. */
|
|
368
|
-
readonly compaction?: ToolLoopCompactionOptions;
|
|
369
|
-
readonly runId?: string;
|
|
370
|
-
readonly now?: () => number;
|
|
371
|
-
/** Restrict the run to this subset of models. When set, every configured model — the
|
|
372
|
-
* supervisor router model, the profile's model, and the backend's model — must be a member,
|
|
373
|
-
* or `supervise()` throws a `ConfigError` before any compute is spent. Unset = unrestricted. */
|
|
374
|
-
readonly allowedModels?: readonly string[];
|
|
375
|
-
}
|
|
376
|
-
/** One-call supervisor: build + run a supervisor from its profile with sensible defaults; the raw `supervisorAgent` + `createSupervisor().run` seams stay available for power use. */
|
|
377
|
-
declare function supervise(profile: SupervisorProfile, task: unknown, opts: SuperviseOptions): Promise<SupervisedResult<unknown>>;
|
|
378
|
-
|
|
379
|
-
export { type AllWorkersStalledOptions as A, type DriveHarness as D, type NoProgressForOptions as N, type PlateauOptions as P, type StopRule as S, type SupervisorProfile as a, type ProgressSample as b, type ProgressTracker as c, type ProgressTrackerOptions as d, type ProgressView as e, type StopDecision as f, type SuperviseOptions as g, type SupervisorAgentDeps as h, allOf as i, allWorkersStalled as j, anyOf as k, createProgressTracker as l, supervise as m, noProgressFor as n, supervisorAgent as o, plateau as p, sampleFromSettled as s, workerFromBackend as w };
|