@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 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
import { LabeledScenarioStore, WorktreeAdapter, SurfaceProposer, ProfileDispatchFn } from '@tangle-network/agent-eval/campaign';
|
|
2
|
-
import { Scenario, SelfImproveOptions, SurfaceProposer as SurfaceProposer$1, MutableSurface, SelfImproveResult } from '@tangle-network/agent-eval/contract';
|
|
3
|
-
import { AgentProfile, ReasoningEffort } from '@tangle-network/agent-interface';
|
|
4
|
-
import { L as LocalHarness, C as CodexTokenUsage, a as CodexExecutionEvidence, b as LocalHarnessResult, r as runLocalHarness } from './local-harness-CtK9dSny.js';
|
|
5
|
-
import { AnalystFinding, CostLedgerHandle, MaximumCharge } from '@tangle-network/agent-eval';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* `improvementDriver` — the ONE reflective/agentic improvement proposer for
|
|
10
|
-
* agent-eval's improvement loop. It implements `SurfaceProposer` and owns
|
|
11
|
-
* the candidate lifecycle (worktree create → generate → finalize/discard,
|
|
12
|
-
* × populationSize); it delegates the only thing that genuinely varies — HOW
|
|
13
|
-
* a candidate change is produced — to a pluggable `CandidateGenerator`.
|
|
14
|
-
*
|
|
15
|
-
* There is no separate "analyst driver" vs "autoresearch driver": those are
|
|
16
|
-
* the SAME driver at two settings of a dial.
|
|
17
|
-
* - cheap reflective path → `reflectiveGenerator` (shots=1, no sandbox;
|
|
18
|
-
* applies pre-drafted patches)
|
|
19
|
-
* - full agentic path → `agenticGenerator` (shots=N, multi-shot
|
|
20
|
-
* verify-in-session loop; an agent reads code +
|
|
21
|
-
* report, edits, and re-tries on verifier failure)
|
|
22
|
-
* Both emit changes into a worktree the driver finalizes into a
|
|
23
|
-
* `CodeSurface{ worktreeRef }` the loop measures on the holdout. See
|
|
24
|
-
* agent-eval's `docs/design/self-improvement-engine.md`.
|
|
25
|
-
*
|
|
26
|
-
* @experimental
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/** The byte-producing seam — the ONE thing that differs between the cheap
|
|
30
|
-
* reflective path and the full agentic path. A generator makes (uncommitted)
|
|
31
|
-
* changes inside `worktreePath`; the driver commits them via the worktree
|
|
32
|
-
* adapter's `finalize`. */
|
|
33
|
-
interface CandidateGenerator {
|
|
34
|
-
kind: string;
|
|
35
|
-
/** Whether this generator can produce a candidate from an EMPTY findings set
|
|
36
|
-
* and no phase-2 report — i.e. it draws its change signal from the repo and
|
|
37
|
-
* the raw-trace filesystem context on disk, not only from pre-summarized
|
|
38
|
-
* findings. An agentic coder (`agenticGenerator`) sets this: the seed repo +
|
|
39
|
-
* raw traces ARE the signal, so it must still run the full `populationSize`
|
|
40
|
-
* when the distiller yielded nothing (this is the meta-harness contract — the
|
|
41
|
-
* agent diagnoses from the raw traces itself). A patch-applier
|
|
42
|
-
* (`reflectiveGenerator`) leaves it unset — with no findings there is no
|
|
43
|
-
* patch to draft, so the driver short-circuits rather than spin up worktrees
|
|
44
|
-
* for a guaranteed no-op. Default `false`. */
|
|
45
|
-
proposesWithoutFindings?: boolean;
|
|
46
|
-
generate(args: {
|
|
47
|
-
/** The candidate worktree — a clean checkout of the current incumbent. */
|
|
48
|
-
worktreePath: string;
|
|
49
|
-
/** Phase-2 research report (analyst findings + diff), opaque. */
|
|
50
|
-
report: unknown;
|
|
51
|
-
/** Findings resolved from the report or the loop context. */
|
|
52
|
-
findings: AnalystFinding[];
|
|
53
|
-
/** Handle to all captured data, to ground the change. */
|
|
54
|
-
dataset?: LabeledScenarioStore;
|
|
55
|
-
/** DEPTH: max iterations the generator may take (agentic uses this; the
|
|
56
|
-
* reflective generator ignores it). */
|
|
57
|
-
maxShots: number;
|
|
58
|
-
signal: AbortSignal;
|
|
59
|
-
/** Improvement-loop coordinates. Present when called through improvementDriver. */
|
|
60
|
-
generation?: number;
|
|
61
|
-
candidateIndex?: number;
|
|
62
|
-
/** Shared run-wide paid-call account supplied by agent-eval 0.117+. */
|
|
63
|
-
costLedger?: CostLedgerHandle;
|
|
64
|
-
/** Receipt attribution phase supplied alongside `costLedger`. */
|
|
65
|
-
costPhase?: string;
|
|
66
|
-
}): Promise<{
|
|
67
|
-
applied: boolean;
|
|
68
|
-
summary: string;
|
|
69
|
-
/** Short slug for the candidate. When present (with `rationale`), the
|
|
70
|
-
* driver returns a `ProposedCandidate` wrapper so the label survives to
|
|
71
|
-
* `GenerationRecord` and the emitted provenance. */
|
|
72
|
-
label?: string;
|
|
73
|
-
/** Why this change was proposed — bounded, derived from the findings the
|
|
74
|
-
* shot addressed. Paired with `label`. */
|
|
75
|
-
rationale?: string;
|
|
76
|
-
}>;
|
|
77
|
-
}
|
|
78
|
-
interface ImprovementDriverOptions {
|
|
79
|
-
worktree: WorktreeAdapter;
|
|
80
|
-
generator: CandidateGenerator;
|
|
81
|
-
/** Root ref for first-generation/direct callers. Default `main`.
|
|
82
|
-
* Later code generations retain the incumbent's original root. */
|
|
83
|
-
baseRef?: string;
|
|
84
|
-
}
|
|
85
|
-
interface ManagedImprovementDriver extends SurfaceProposer<AnalystFinding> {
|
|
86
|
-
/** Remove every owned candidate except explicitly retained finalized winners. */
|
|
87
|
-
cleanup(retainWorktreeRefs?: readonly string[]): Promise<void>;
|
|
88
|
-
}
|
|
89
|
-
/** The one reflective/agentic improvement proposer (`SurfaceProposer`): owns the candidate worktree lifecycle and delegates HOW a change is produced to a pluggable `CandidateGenerator`. */
|
|
90
|
-
declare function improvementDriver(opts: ImprovementDriverOptions): ManagedImprovementDriver;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
* `agenticGenerator` — the full-agentic `CandidateGenerator`: the
|
|
95
|
-
* `shots=N, sandbox=on` setting of the one `improvementDriver`. It runs a real
|
|
96
|
-
* coding harness (claude / codex / opencode) inside the candidate worktree the
|
|
97
|
-
* driver already created, letting the agent read the codebase + the research
|
|
98
|
-
* report and make the change in place. The driver then commits the worktree
|
|
99
|
-
* into a `CodeSurface`.
|
|
100
|
-
*
|
|
101
|
-
* Mechanism: identical to the proven Phase-2.8 in-process executor — spawn the
|
|
102
|
-
* harness as a subprocess with `cwd` = the worktree, on the same filesystem,
|
|
103
|
-
* so edits land in place (no sandbox-mount round-trip). `runLocalHarness` is
|
|
104
|
-
* the verified primitive. The OUTER sandbox is the improvement loop's own
|
|
105
|
-
* execution context; the generator does not nest a second sandbox per
|
|
106
|
-
* candidate (which would reintroduce a host↔sandbox worktree-transport
|
|
107
|
-
* problem that does not need solving here).
|
|
108
|
-
*
|
|
109
|
-
* `maxShots` is the DEPTH dial — a multi-shot verify-in-session loop, NOT the
|
|
110
|
-
* kernel `runAgentRounds`. Each shot runs one full harness session in the (persistent)
|
|
111
|
-
* worktree; between shots the loop refines based on what the last shot produced:
|
|
112
|
-
* - empty tree → "you changed nothing, make the edits" → retry
|
|
113
|
-
* - dirty + `verify` fails → feed the verifier's failure into the next shot
|
|
114
|
-
* (the worktree persists, so the harness RESUMES atop its own failing
|
|
115
|
-
* edits with the error in hand — no `--resume` session plumbing needed,
|
|
116
|
-
* and harness-agnostic across claude/codex/opencode)
|
|
117
|
-
* - dirty + `verify` ok (or no verifier configured) → return the candidate
|
|
118
|
-
* A candidate that never verifies within `maxShots` is discarded (`applied:
|
|
119
|
-
* false`), never shipped — if you configured a verifier, a non-passing tree is
|
|
120
|
-
* not a candidate. With no verifier the legacy behavior holds: first dirty shot
|
|
121
|
-
* is the candidate.
|
|
122
|
-
*
|
|
123
|
-
* @experimental
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
/** Dedicated ephemeral root for generic author-profile files. Every declared
|
|
127
|
-
* file must live below this root so cleanup cannot alter candidate-owned files. */
|
|
128
|
-
declare const AGENTIC_PROFILE_RESOURCE_ROOT = ".agent-runtime-profile-resources";
|
|
129
|
-
/** Outcome of verifying a candidate worktree. `feedback` (compiler errors,
|
|
130
|
-
* failing test output) is fed into the next shot when `ok` is false. */
|
|
131
|
-
interface VerifyResult {
|
|
132
|
-
ok: boolean;
|
|
133
|
-
feedback?: string;
|
|
134
|
-
}
|
|
135
|
-
/** Verifies the edited worktree. Sync or async; throws only on a setup fault
|
|
136
|
-
* (a candidate that fails verification returns `{ok:false}`, it does not
|
|
137
|
-
* throw). */
|
|
138
|
-
type Verifier = (worktreePath: string, signal?: AbortSignal) => Promise<VerifyResult> | VerifyResult;
|
|
139
|
-
interface AgenticGeneratorShotReceipt {
|
|
140
|
-
readonly generation: number | null;
|
|
141
|
-
readonly candidateIndex: number | null;
|
|
142
|
-
/** One-based shot number within this candidate. */
|
|
143
|
-
readonly shot: number;
|
|
144
|
-
readonly maxShots: number;
|
|
145
|
-
readonly harness: LocalHarness;
|
|
146
|
-
readonly model: string | null;
|
|
147
|
-
readonly reasoningEffort: ReasoningEffort | null;
|
|
148
|
-
readonly promptSha256: `sha256:${string}`;
|
|
149
|
-
readonly startedAt: string;
|
|
150
|
-
readonly completedAt: string;
|
|
151
|
-
readonly durationMs: number;
|
|
152
|
-
readonly exitCode: number | null;
|
|
153
|
-
readonly timedOut: boolean;
|
|
154
|
-
/** True when caller cancellation reached the author process; absent in older receipts. */
|
|
155
|
-
readonly aborted?: boolean;
|
|
156
|
-
readonly killedBySignal: NodeJS.Signals | null;
|
|
157
|
-
readonly stdoutBytes: number | null;
|
|
158
|
-
readonly stdoutSha256: `sha256:${string}` | null;
|
|
159
|
-
readonly stderrBytes: number | null;
|
|
160
|
-
readonly stderrSha256: `sha256:${string}` | null;
|
|
161
|
-
readonly usage: CodexTokenUsage | null;
|
|
162
|
-
/** Digest of the exact profile-file workspace plan applied for this shot. */
|
|
163
|
-
readonly profileWorkspacePlanDigest: string | null;
|
|
164
|
-
readonly profileWorkspaceFileCount: number;
|
|
165
|
-
/** Shared run-ledger call id for this exact shot. */
|
|
166
|
-
readonly costCallId: string | null;
|
|
167
|
-
/** Whether dollars came from the provider, the pricing table, or are unknown. */
|
|
168
|
-
readonly costBasis: 'provider-reported' | 'estimated-pricing' | 'unknown';
|
|
169
|
-
readonly costUsd: number | null;
|
|
170
|
-
/** True only for a provider-reported amount, never for a pricing estimate. */
|
|
171
|
-
readonly costUsdKnown: boolean;
|
|
172
|
-
readonly evidence: CodexExecutionEvidence | null;
|
|
173
|
-
readonly error: {
|
|
174
|
-
readonly name: string;
|
|
175
|
-
readonly message: string;
|
|
176
|
-
} | null;
|
|
177
|
-
}
|
|
178
|
-
/** Frozen exact harness result for an author shot: full streams, process state,
|
|
179
|
-
* token usage, and execution-policy evidence.
|
|
180
|
-
* The `onShotCompleted` callback receives `null` when execution failed before
|
|
181
|
-
* the harness returned. */
|
|
182
|
-
type AgenticGeneratorShotExecution = Readonly<Omit<LocalHarnessResult, 'usage' | 'evidence'> & {
|
|
183
|
-
readonly usage?: Readonly<CodexTokenUsage>;
|
|
184
|
-
readonly evidence?: Readonly<Omit<CodexExecutionEvidence, 'readDeniedPaths' | 'policy'>> & {
|
|
185
|
-
readonly readDeniedPaths: ReadonlyArray<string>;
|
|
186
|
-
readonly policy: Readonly<CodexExecutionEvidence['policy']>;
|
|
187
|
-
};
|
|
188
|
-
}>;
|
|
189
|
-
/** Worktree decision emitted before a completed shot is retried, accepted, or
|
|
190
|
-
* discarded. The callback runs while `worktreePath` is still available, so
|
|
191
|
-
* callers can persist the exact diff. */
|
|
192
|
-
type AgenticGeneratorShotDisposition = {
|
|
193
|
-
readonly kind: 'clean';
|
|
194
|
-
readonly worktreePath: string;
|
|
195
|
-
} | {
|
|
196
|
-
readonly kind: 'rejected';
|
|
197
|
-
readonly worktreePath: string;
|
|
198
|
-
readonly stage: 'raw-trace-evidence' | 'verification';
|
|
199
|
-
readonly feedback: string | null;
|
|
200
|
-
} | {
|
|
201
|
-
readonly kind: 'accepted';
|
|
202
|
-
readonly worktreePath: string;
|
|
203
|
-
readonly verified: boolean;
|
|
204
|
-
} | {
|
|
205
|
-
readonly kind: 'setup-error';
|
|
206
|
-
readonly worktreePath: string;
|
|
207
|
-
readonly stage: 'worktree-inspection' | 'raw-trace-evidence' | 'verification';
|
|
208
|
-
readonly error: {
|
|
209
|
-
readonly name: string;
|
|
210
|
-
readonly message: string;
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
interface AgenticGeneratorOptions {
|
|
214
|
-
/** Local coding harness to run in the worktree. Default `claude`. */
|
|
215
|
-
harness?: LocalHarness;
|
|
216
|
-
/** Author profile rendered through the canonical harness mapper. Required
|
|
217
|
-
* for reproducible Codex so model and reasoning settings are explicit. */
|
|
218
|
-
profile?: AgentProfile;
|
|
219
|
-
/** Run Codex with isolated configuration, exact prompt evidence, and required
|
|
220
|
-
* terminal token usage. Requires `harness: 'codex'` and `profile`. */
|
|
221
|
-
codexReproducible?: boolean;
|
|
222
|
-
/** Absolute paths reproducible Codex must not read. A function can derive
|
|
223
|
-
* candidate-specific paths after the driver creates its worktree. */
|
|
224
|
-
codexReadDeniedPaths?: ReadonlyArray<string> | ((worktreePath: string) => ReadonlyArray<string>);
|
|
225
|
-
/** Awaited once for every attempted author shot, including process failures.
|
|
226
|
-
* The second argument preserves the exact harness result, including stdout
|
|
227
|
-
* and stderr, before worktree inspection or verification can reject the
|
|
228
|
-
* shot. Throwing aborts the candidate so evidence persistence fails closed. */
|
|
229
|
-
onShotCompleted?: (receipt: AgenticGeneratorShotReceipt, execution: AgenticGeneratorShotExecution | null) => void | Promise<void>;
|
|
230
|
-
/** Awaited after worktree inspection and before the shot is accepted,
|
|
231
|
-
* retried, or discarded. Throwing aborts the candidate. */
|
|
232
|
-
onShotDisposition?: (receipt: AgenticGeneratorShotReceipt, disposition: AgenticGeneratorShotDisposition) => void | Promise<void>;
|
|
233
|
-
/** Optional hard upper bound passed to the run-wide CostLedger before each
|
|
234
|
-
* author shot. This MUST be enforced by the provider or executor; a planning
|
|
235
|
-
* estimate is not an admissible bound. Omit for an uncapped ledger. A capped
|
|
236
|
-
* ledger rejects before model dispatch when this is absent. */
|
|
237
|
-
maximumCharge?: MaximumCharge;
|
|
238
|
-
/** Per-shot wall-clock timeout (ms). Default = `runLocalHarness` default (5m). */
|
|
239
|
-
timeoutMs?: number;
|
|
240
|
-
/** Build the harness task prompt from the report + findings. Override for
|
|
241
|
-
* domain phrasing; the default turns findings into a concrete coder task. */
|
|
242
|
-
buildPrompt?: (args: {
|
|
243
|
-
report: unknown;
|
|
244
|
-
findings: AnalystFinding[];
|
|
245
|
-
}) => string;
|
|
246
|
-
/** Verify the worktree after each dirtying shot. When set, a candidate that
|
|
247
|
-
* fails verification is NOT returned — the failure feeds the next shot
|
|
248
|
-
* (verify-in-session), up to `maxShots`; a candidate that never verifies is
|
|
249
|
-
* discarded (`applied:false`), never shipped. Omitted ⇒ legacy behavior:
|
|
250
|
-
* the first dirty shot is the candidate. See `commandVerifier`. */
|
|
251
|
-
verify?: Verifier;
|
|
252
|
-
/** Test seam — inject the harness runner (defaults to `runLocalHarness`). */
|
|
253
|
-
runHarness?: typeof runLocalHarness;
|
|
254
|
-
/** Test seam — inject the worktree-dirty check (defaults to `git status`). */
|
|
255
|
-
isDirty?: (worktreePath: string) => boolean;
|
|
256
|
-
}
|
|
257
|
-
/** Full-agentic `CandidateGenerator` (the `shots=N, sandbox=on` setting): run a real coding harness inside the candidate worktree so the agent makes the change in place. */
|
|
258
|
-
declare function agenticGenerator(opts?: AgenticGeneratorOptions): CandidateGenerator;
|
|
259
|
-
/** Turn the analyst's findings (+ optional report) into a concrete coder task —
|
|
260
|
-
* the senior scientific-method framing shared with the tool/MCP build prompts. */
|
|
261
|
-
declare function defaultBuildPrompt(args: {
|
|
262
|
-
report: unknown;
|
|
263
|
-
findings: AnalystFinding[];
|
|
264
|
-
}): string;
|
|
265
|
-
/** A `Verifier` that runs a command in the worktree: exit 0 ⇒ ok, any other
|
|
266
|
-
* exit ⇒ failed with stdout+stderr as feedback. The common case — verify by
|
|
267
|
-
* `tsc --noEmit`, `pnpm build`, or a test command. A timeout is treated as a
|
|
268
|
-
* FAILED candidate (a change that hangs the build is a bad change); a missing
|
|
269
|
-
* binary or spawn fault throws (a setup bug, not a failed candidate — no
|
|
270
|
-
* silent fallback). */
|
|
271
|
-
declare function commandVerifier(command: string, args?: string[], timeoutMs?: number): Verifier;
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
*
|
|
275
|
-
* `improve` — the ONE public, surface-pluggable RSI verb.
|
|
276
|
-
*
|
|
277
|
-
* A thin facade over agent-eval's `selfImprove` (the held-out-gated closed
|
|
278
|
-
* loop). It removes the two things a caller otherwise has to know to drive the
|
|
279
|
-
* loop by hand: WHICH `MutableSurface` of the profile is being optimized, and
|
|
280
|
-
* WHICH `SurfaceProposer` mutates that surface. You name a `surface`; the
|
|
281
|
-
* facade picks the matching default proposer, extracts the baseline surface from
|
|
282
|
-
* the profile, and runs `selfImprove`. It returns a frozen candidate and never
|
|
283
|
-
* changes the input profile or caller-owned state.
|
|
284
|
-
*
|
|
285
|
-
* - `surface: 'prompt'` → `gepaProposer` mutates `profile.prompt.systemPrompt`.
|
|
286
|
-
* - `surface: 'skills'` → `skillOptProposer` mutates one named inline skill.
|
|
287
|
-
* - `surface: 'memory'` → `memoryCurationProposer` curates the profile's
|
|
288
|
-
* additional instructions as bounded durable lessons.
|
|
289
|
-
* - `surface: 'rollout-policy'` → `rolloutPolicyProposer` mutates the
|
|
290
|
-
* inference-time `StructuralRolloutPolicy` dials ({ k, repairRounds, testgen })
|
|
291
|
-
* persisted in `profile.extensions['structural-rollout']` — deterministic
|
|
292
|
-
* bounded neighbor enumeration; the held-out gate does the deciding. No-op
|
|
293
|
-
* (nothing proposed, nothing shipped) when the profile has no such extension.
|
|
294
|
-
* - `surface: 'agent-profile'` → caller-supplied proposer mutates the complete
|
|
295
|
-
* canonical AgentProfile JSON in one candidate.
|
|
296
|
-
* - `surface` ∈ {`tools`, `mcp`, `hooks`, `subagents`, `agent-profile`} → no zero-config default
|
|
297
|
-
* proposer exists (a code/config proposer needs caller-supplied wiring — a
|
|
298
|
-
* worktree repo root, a candidate generator, a serializer). The facade
|
|
299
|
-
* requires an explicit `opts.generator` for these and throws a `ConfigError`
|
|
300
|
-
* otherwise. This is a designed boundary, not a missing default: there is
|
|
301
|
-
* no safe value the facade could invent for those surfaces. Code instead
|
|
302
|
-
* requires `opts.code.repoRoot` and accepts only the runtime-owned
|
|
303
|
-
* `opts.code.generator` path so every isolated checkout can be released.
|
|
304
|
-
*
|
|
305
|
-
* Everything else (`scenarios`, `judge`, `agent`, `budget`, `llm`) passes
|
|
306
|
-
* straight through to `selfImprove`.
|
|
307
|
-
*
|
|
308
|
-
* @experimental
|
|
309
|
-
*/
|
|
310
|
-
|
|
311
|
-
/** The executable agent lever `improve` optimizes. Profile fields remain
|
|
312
|
-
* portable AgentProfile coordinates; implementation and orchestration files
|
|
313
|
-
* use the code surface so a winner can be sealed into an exact candidate.
|
|
314
|
-
* `rollout-policy` is the inference-time structuralRollout dials
|
|
315
|
-
* (`profile.extensions['structural-rollout']`). */
|
|
316
|
-
type ImproveSurface = 'prompt' | 'skills' | 'tools' | 'mcp' | 'hooks' | 'subagents' | 'agent-profile' | 'memory' | 'code' | 'rollout-policy';
|
|
317
|
-
interface ImproveOptions<TScenario extends Scenario, TArtifact> extends Omit<SelfImproveOptions<TScenario, TArtifact>, 'agent' | 'analyzeGeneration' | 'baselineSurface' | 'findings' | 'gate' | 'proposer'> {
|
|
318
|
-
/** Dispatch the mutable surface directly when the host already owns that seam.
|
|
319
|
-
* Exactly one of `agent` or `profileDispatch` is required. */
|
|
320
|
-
agent?: SelfImproveOptions<TScenario, TArtifact>['agent'];
|
|
321
|
-
/** Dispatch each baseline or candidate as its complete AgentProfile.
|
|
322
|
-
* Exactly one of `agent` or `profileDispatch` is required. */
|
|
323
|
-
profileDispatch?: ProfileDispatchFn<TScenario, TArtifact>;
|
|
324
|
-
/** Which profile lever to optimize. Default `'prompt'`. Selects the default
|
|
325
|
-
* generator + the baseline-surface extraction shape. */
|
|
326
|
-
surface?: ImproveSurface;
|
|
327
|
-
/** The `SurfaceProposer` that mutates a profile surface. When unset, the facade
|
|
328
|
-
* picks the default for prompt, skills, and memory; surfaces
|
|
329
|
-
* with no default REQUIRE this (fail-loud otherwise). Forbidden for code;
|
|
330
|
-
* use `code.generator` so the runtime owns candidate cleanup. */
|
|
331
|
-
generator?: SurfaceProposer$1;
|
|
332
|
-
/** Gate mode. `'holdout'` (default) runs the held-out promotion gate;
|
|
333
|
-
* `'none'` is a baseline-only run (`budget.generations = 0`). */
|
|
334
|
-
gate?: 'holdout' | 'none';
|
|
335
|
-
/** Restrict the run to this subset of models. When set, the reflection model
|
|
336
|
-
* (`llm.model`, or the default when unset) must be a member, or `improve()` throws
|
|
337
|
-
* a `ConfigError` before the generator is built. Unset = unrestricted. */
|
|
338
|
-
allowedModels?: readonly string[];
|
|
339
|
-
/** Per-generation findings producer passthrough (see selfImprove.analyzeGeneration).
|
|
340
|
-
* DEFAULT: with a real (non-`mem://`) `runDir`, the raw-trace distiller
|
|
341
|
-
* (`rawTraceDistiller`) — typed `AnalystFinding`s pointing the proposer at the
|
|
342
|
-
* prior generation's actual on-disk traces; for in-memory runs (no traces on
|
|
343
|
-
* disk to point at), the built-in failure distiller — the worst-scoring/errored
|
|
344
|
-
* cells distilled into typed `AnalystFinding`s for the NEXT proposal round.
|
|
345
|
-
* Pass your own producer to replace either; pass `null` to disable and keep the
|
|
346
|
-
* static `findings` all the way through. */
|
|
347
|
-
analyzeGeneration?: SelfImproveOptions<TScenario, TArtifact>['analyzeGeneration'] | null;
|
|
348
|
-
/** META-HARNESS mode: instead of the distilled findings, feed the proposer
|
|
349
|
-
* RAW-TRACE FILESYSTEM CONTEXT — the PATHS into the prior generation's
|
|
350
|
-
* real run traces under `runDir` (per-cell `spans.jsonl` event logs +
|
|
351
|
-
* `cached-result.json` scores + artifacts) plus a `grep`/`cat`-to-diagnose
|
|
352
|
-
* instruction — so the coding agent reads the actual failures itself rather than
|
|
353
|
-
* a pre-summary. Unset (default): raw-trace findings whenever the run is durable
|
|
354
|
-
* (a real `runDir` — that is where the traces live), the distilled failure digest
|
|
355
|
-
* otherwise; the `memory` surface always defaults to its curation distiller.
|
|
356
|
-
* `true` forces `rawTraceDistiller()` even for an in-memory run (it emits a loud
|
|
357
|
-
* warning finding instead of paths); `false` forces the digest distiller even
|
|
358
|
-
* with a real `runDir`. Ignored when `analyzeGeneration` is set explicitly
|
|
359
|
-
* (that wins) or is `null` (disabled). */
|
|
360
|
-
rawTraceContext?: boolean;
|
|
361
|
-
/** CODE-surface wiring: name `surface: 'code'`, point at a repo, and the
|
|
362
|
-
* facade assembles the whole candidate pipeline — an isolated incumbent plus git worktrees
|
|
363
|
-
* (`gitWorktreeAdapter`) driven by `improvementDriver` with the full agentic
|
|
364
|
-
* generator (a real coding harness edits each candidate worktree; a `verify`
|
|
365
|
-
* hook gates candidates before they are ever measured). Ignored when
|
|
366
|
-
* `opts.generator` is supplied. Required for every code run because a real
|
|
367
|
-
* repository and base ref are necessary to measure the incumbent. */
|
|
368
|
-
code?: ImproveCodeOptions;
|
|
369
|
-
/** Select the exact inline skill document to optimize. */
|
|
370
|
-
skills?: ImproveSkillsOptions;
|
|
371
|
-
/** Custom held-back-exam decision. The string `gate` above controls whether
|
|
372
|
-
* the exam runs; this callback controls how its evidence decides promotion. */
|
|
373
|
-
promotionGate?: SelfImproveOptions<TScenario, TArtifact>['gate'];
|
|
374
|
-
}
|
|
375
|
-
interface ImproveSkillsOptions {
|
|
376
|
-
/** `name` of one inline entry in `profile.resources.skills`. */
|
|
377
|
-
resourceName: string;
|
|
378
|
-
}
|
|
379
|
-
interface ImproveCodeOptions {
|
|
380
|
-
/** Repo root candidate worktrees fork from. */
|
|
381
|
-
repoRoot: string;
|
|
382
|
-
/** Base ref candidates fork from. Default `main`. */
|
|
383
|
-
baseRef?: string;
|
|
384
|
-
/** Directory worktrees are created under. Default `<repoRoot>/.worktrees`. */
|
|
385
|
-
worktreeDir?: string;
|
|
386
|
-
/** Git-compatible adapter override, primarily for tests. Candidate advancement
|
|
387
|
-
* still requires normal Git worktree and commit semantics. */
|
|
388
|
-
worktree?: WorktreeAdapter;
|
|
389
|
-
/** Coding harness the agentic generator runs in each worktree. Default `claude`. */
|
|
390
|
-
harness?: LocalHarness;
|
|
391
|
-
/** Verify a candidate worktree before it becomes a measurable surface; failures
|
|
392
|
-
* feed the next shot (see `agenticGenerator.verify` / `commandVerifier`). */
|
|
393
|
-
verify?: Verifier;
|
|
394
|
-
/** Per-shot wall-clock timeout for the harness (ms). */
|
|
395
|
-
timeoutMs?: number;
|
|
396
|
-
/** Byte-producer override — the test seam and the escape hatch for custom
|
|
397
|
-
* candidate production. When set, `harness`/`verify`/`timeoutMs` are unused. */
|
|
398
|
-
generator?: CandidateGenerator;
|
|
399
|
-
}
|
|
400
|
-
interface ImprovementCandidate {
|
|
401
|
-
/** Surface searched by this run. */
|
|
402
|
-
surface: ImproveSurface;
|
|
403
|
-
/** Exact winning value returned by agent-eval. */
|
|
404
|
-
value: MutableSurface;
|
|
405
|
-
/** Detached profile candidate when the surface maps directly to AgentProfile. */
|
|
406
|
-
profile?: AgentProfile;
|
|
407
|
-
}
|
|
408
|
-
interface ImproveResult<TScenario extends Scenario, TArtifact> {
|
|
409
|
-
/** Frozen candidate only. Live state is changed through an approved activation. */
|
|
410
|
-
candidate: ImprovementCandidate;
|
|
411
|
-
/** Held-out decision for this search result. */
|
|
412
|
-
decision: SelfImproveResult<TScenario, TArtifact>['gateDecision'];
|
|
413
|
-
/** Held-out lift (`winner − baseline` composite). Absent iff
|
|
414
|
-
* `budget.holdout === 'deferred'` — no held-out measurement ran, so there
|
|
415
|
-
* is no lift to report (never a fabricated 0). */
|
|
416
|
-
lift?: number;
|
|
417
|
-
/** Full `selfImprove` result for advanced inspection. For code runs,
|
|
418
|
-
* `raw.winner.surface.worktreeRef` remains live after return whether the
|
|
419
|
-
* candidate passed or held; call `dispose()` after consuming it. */
|
|
420
|
-
raw: SelfImproveResult<TScenario, TArtifact>;
|
|
421
|
-
/** Release resources owned by this result. Idempotent; currently disposes
|
|
422
|
-
* the returned code worktree and is a no-op for profile-only surfaces. */
|
|
423
|
-
dispose(): Promise<void>;
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Run the held-out-gated self-improvement loop on ONE profile surface.
|
|
427
|
-
*
|
|
428
|
-
* @example Optimize the system prompt, default holdout gate:
|
|
429
|
-
*
|
|
430
|
-
* const out = await improve(profile, findings, {
|
|
431
|
-
* surface: 'prompt',
|
|
432
|
-
* scenarios,
|
|
433
|
-
* judge,
|
|
434
|
-
* agent: (surface, scenario, ctx) => runAgent(surface, scenario, ctx.signal),
|
|
435
|
-
* })
|
|
436
|
-
* if (out.decision === 'ship') console.log(out.candidate)
|
|
437
|
-
*/
|
|
438
|
-
declare function improve<TScenario extends Scenario, TArtifact>(profile: AgentProfile, findings: unknown[], opts: ImproveOptions<TScenario, TArtifact>): Promise<ImproveResult<TScenario, TArtifact>>;
|
|
439
|
-
|
|
440
|
-
export { AGENTIC_PROFILE_RESOURCE_ROOT as A, type CandidateGenerator as C, type ImproveOptions as I, type ManagedImprovementDriver as M, type Verifier as V, type ImproveResult as a, type AgenticGeneratorOptions as b, type AgenticGeneratorShotDisposition as c, type AgenticGeneratorShotExecution as d, type AgenticGeneratorShotReceipt as e, type ImproveCodeOptions as f, type ImproveSkillsOptions as g, type ImproveSurface as h, type ImprovementCandidate as i, type ImprovementDriverOptions as j, type VerifyResult as k, agenticGenerator as l, commandVerifier as m, defaultBuildPrompt as n, improve as o, improvementDriver as p };
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { FindingSubject, AnalystFinding } from '@tangle-network/agent-eval';
|
|
2
|
-
import { I as ImprovementProposalSource } from './types-CmYCMbFT.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* `AgentSurfaces` — declarative map of the mutable file/directory paths
|
|
6
|
-
* the self-improvement loop can edit on behalf of an agent.
|
|
7
|
-
*
|
|
8
|
-
* The substrate uses this map to resolve every parsed `FindingSubject`
|
|
9
|
-
* (from agent-eval) to a real on-disk path. No per-vertical glue;
|
|
10
|
-
* no fabricated paths; no silent `existsSync(...)` skips that hide
|
|
11
|
-
* misconfiguration from the operator.
|
|
12
|
-
*
|
|
13
|
-
* Surfaces are validated at `defineAgent` time — missing paths fail
|
|
14
|
-
* loud with a list of every offender. A surface that's not needed
|
|
15
|
-
* (e.g. an agent with no RAG corpora) is simply omitted; the loop
|
|
16
|
-
* refuses to route those subjects rather than fabricating a target.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Surface declarations. Every path is repo-relative (or absolute) at
|
|
21
|
-
* `defineAgent` time. At resolution time, paths are joined against the
|
|
22
|
-
* agent's `repoRoot`.
|
|
23
|
-
*
|
|
24
|
-
* `systemPrompt`, `tools`, `personas` are DIRECTORIES; the loop appends
|
|
25
|
-
* `<section>.md`, `<tool>/README.md`, `<persona-id>.yaml` etc.
|
|
26
|
-
* `rubric`, `outputSchema` are SINGLE FILES; the loop edits them in
|
|
27
|
-
* place.
|
|
28
|
-
*
|
|
29
|
-
* `knowledge` is the agent-knowledge root (typically `.agent-knowledge`);
|
|
30
|
-
* `applyKnowledgeWriteBlocks` writes pages relative to it.
|
|
31
|
-
*
|
|
32
|
-
* Optional surfaces (`scaffolding`, `memory`, `rag`, `outputSchema`)
|
|
33
|
-
* can be omitted — the loop will reject findings targeting them with a
|
|
34
|
-
* clear log message instead of fabricating a path.
|
|
35
|
-
*/
|
|
36
|
-
interface AgentSurfaces {
|
|
37
|
-
/** Directory containing one markdown file per system-prompt section. */
|
|
38
|
-
systemPrompt: string;
|
|
39
|
-
/** Directory containing one subdir per tool (`<tool>/README.md`). */
|
|
40
|
-
tools: string;
|
|
41
|
-
/** Single file (TypeScript module) defining the rubric weights + dimensions. */
|
|
42
|
-
rubric: string;
|
|
43
|
-
/** Knowledge-base root; typically `.agent-knowledge`. */
|
|
44
|
-
knowledge: string;
|
|
45
|
-
/** Directory containing one YAML/JSON file per persona. */
|
|
46
|
-
personas: string;
|
|
47
|
-
/** Optional: directory containing scaffolding rules (precondition checks, retry policies). */
|
|
48
|
-
scaffolding?: string;
|
|
49
|
-
/** Optional: memory store path (JSONL / SQLite / DB). */
|
|
50
|
-
memory?: string;
|
|
51
|
-
/** Optional: directory containing RAG corpora (`<corpus>/<doc-id>.md`). */
|
|
52
|
-
rag?: string;
|
|
53
|
-
/** Optional: single file defining the output schema (Zod / JSON Schema). */
|
|
54
|
-
outputSchema?: string;
|
|
55
|
-
/** Optional: directory containing Agent Skill packages. */
|
|
56
|
-
skills?: string;
|
|
57
|
-
/** Optional: directory containing MCP server/tool configuration. */
|
|
58
|
-
mcp?: string;
|
|
59
|
-
/** Optional: directory containing hook definitions. */
|
|
60
|
-
hooks?: string;
|
|
61
|
-
/** Optional: directory containing subagent definitions. */
|
|
62
|
-
subagents?: string;
|
|
63
|
-
/** Optional: directory containing orchestration/workflow policies. */
|
|
64
|
-
workflows?: string;
|
|
65
|
-
/** Optional: single file containing rollout-policy settings. */
|
|
66
|
-
rolloutPolicy?: string;
|
|
67
|
-
/** Optional: single canonical AgentProfile file. */
|
|
68
|
-
agentProfile?: string;
|
|
69
|
-
/** Optional: source root for code findings. */
|
|
70
|
-
code?: string;
|
|
71
|
-
}
|
|
72
|
-
interface ResolvedSurface {
|
|
73
|
-
/** Absolute filesystem path the operator can `cat` / `vim`. */
|
|
74
|
-
absolutePath: string;
|
|
75
|
-
/** Repo-relative path for PR descriptions, diffs, audit logs. */
|
|
76
|
-
repoRelativePath: string;
|
|
77
|
-
/** Whether the path currently exists on disk. */
|
|
78
|
-
exists: boolean;
|
|
79
|
-
/** The substrate's intent: edit an existing file or create a new one. */
|
|
80
|
-
intent: 'edit-existing' | 'create-new';
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Resolve a parsed `FindingSubject` to the file path the substrate
|
|
84
|
-
* should edit (or create) on disk.
|
|
85
|
-
*
|
|
86
|
-
* Returns `null` when:
|
|
87
|
-
* - the subject targets a surface the agent didn't declare
|
|
88
|
-
* (e.g. `rag:*` when `surfaces.rag` is undefined), OR
|
|
89
|
-
* - the subject is a `cluster` (failure-mode emits these as evidence,
|
|
90
|
-
* not actionable mutations — they don't route to a file).
|
|
91
|
-
*
|
|
92
|
-
* Returns a `ResolvedSurface` with `intent: 'create-new'` when the
|
|
93
|
-
* subject names a path that doesn't yet exist (e.g. a new wiki page).
|
|
94
|
-
* The caller chooses whether to honour the create — for tightly-managed
|
|
95
|
-
* surfaces like `systemPrompt` it's usually a contract violation
|
|
96
|
-
* (the analyst named a section that doesn't exist); for `knowledge`
|
|
97
|
-
* it's the whole point.
|
|
98
|
-
*/
|
|
99
|
-
declare function resolveSubjectPath(subject: FindingSubject, surfaces: AgentSurfaces, repoRoot: string): ResolvedSurface | null;
|
|
100
|
-
/**
|
|
101
|
-
* Validate that every declared surface exists on disk under `repoRoot`.
|
|
102
|
-
*
|
|
103
|
-
* Returns an array of `SurfaceValidationIssue` — empty when all required
|
|
104
|
-
* surfaces resolve. `defineAgent` throws with the issues rendered, so
|
|
105
|
-
* a misconfigured manifest fails at startup (not at the first finding
|
|
106
|
-
* the loop produces 20 minutes later).
|
|
107
|
-
*/
|
|
108
|
-
interface SurfaceValidationIssue {
|
|
109
|
-
surface: keyof AgentSurfaces;
|
|
110
|
-
path: string;
|
|
111
|
-
reason: 'missing' | 'not-directory' | 'not-file';
|
|
112
|
-
}
|
|
113
|
-
/** Validate an `AgentSurfaces` map on disk — missing paths fail loud at `defineAgent` time instead of silently skipping self-improvement edits. */
|
|
114
|
-
declare function validateSurfaces(surfaces: AgentSurfaces, repoRoot: string): ReadonlyArray<SurfaceValidationIssue>;
|
|
115
|
-
/** Format a list of surface validation issues into a human-readable error string. */
|
|
116
|
-
declare function renderSurfaceIssues(issues: ReadonlyArray<SurfaceValidationIssue>, repoRoot: string): string;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Surface improvement proposer — resolves analyst findings into LLM-drafted
|
|
120
|
-
* candidate patches without changing the caller's repository.
|
|
121
|
-
*
|
|
122
|
-
* The proposer parses each finding's `subject` via
|
|
123
|
-
* `parseFindingSubject` (agent-eval), resolves it to a real file path
|
|
124
|
-
* via the agent's `AgentSurfaces`, reads the current content, and asks
|
|
125
|
-
* an LLM to draft a unified-diff patch given the finding + current
|
|
126
|
-
* content + per-kind editing-discipline rules.
|
|
127
|
-
*
|
|
128
|
-
* Fail-loud rules:
|
|
129
|
-
* - Findings whose subject doesn't parse → counted in `errors`.
|
|
130
|
-
* - Findings whose subject targets an undeclared surface → counted in
|
|
131
|
-
* `errors` with the offending kind in the message.
|
|
132
|
-
* - Findings whose target path doesn't exist AND the kind isn't a
|
|
133
|
-
* create-new variant (`new-tool`, `knowledge.wiki`) → counted in
|
|
134
|
-
* `errors` with the resolved path in the message.
|
|
135
|
-
* - LLM drafts that fail JSON-schema validation → counted in
|
|
136
|
-
* `errors` with the schema issue.
|
|
137
|
-
*
|
|
138
|
-
* No silent skips. Every dropped finding has a recorded reason the
|
|
139
|
-
* loop's report surfaces.
|
|
140
|
-
*/
|
|
141
|
-
|
|
142
|
-
interface SurfaceImprovementEdit {
|
|
143
|
-
/** Stable id derived from the source finding so re-proposals are idempotent. */
|
|
144
|
-
id: string;
|
|
145
|
-
/** The finding that produced this edit — for revert + audit trail. */
|
|
146
|
-
sourceFindingId: string;
|
|
147
|
-
/** Parsed subject; included so the apply step doesn't re-parse. */
|
|
148
|
-
subject: FindingSubject;
|
|
149
|
-
/** Resolved on-disk target. */
|
|
150
|
-
target: ResolvedSurface;
|
|
151
|
-
/** SHA-256 of the current file content the patch was drafted against. */
|
|
152
|
-
baseSha256: string;
|
|
153
|
-
/** Unified-diff patch the LLM drafted (relative to `target.absolutePath`). */
|
|
154
|
-
patch: string;
|
|
155
|
-
/** One-line summary the operator sees in the report / PR title. */
|
|
156
|
-
summary: string;
|
|
157
|
-
/** Multi-line rationale for the PR body — finding context + LLM reasoning. */
|
|
158
|
-
rationale: string;
|
|
159
|
-
/** Carry-forward from the finding so the apply gate can check the threshold. */
|
|
160
|
-
confidence: number;
|
|
161
|
-
/** Carry-forward severity for prioritization. */
|
|
162
|
-
severity: AnalystFinding['severity'];
|
|
163
|
-
}
|
|
164
|
-
interface CreateSurfaceImprovementProposerOptions {
|
|
165
|
-
surfaces: AgentSurfaces;
|
|
166
|
-
repoRoot: string;
|
|
167
|
-
/**
|
|
168
|
-
* LLM-draft callback. Given a finding + current file content + the
|
|
169
|
-
* resolved target, returns a unified-diff patch + summary + rationale.
|
|
170
|
-
*
|
|
171
|
-
* Required — the substrate doesn't ship a hardcoded prompt; the agent
|
|
172
|
-
* author picks the model (Haiku for cheap routine drafts, Sonnet for
|
|
173
|
-
* substantive prompt rewrites, etc.) via this callback.
|
|
174
|
-
*/
|
|
175
|
-
draftPatch: (input: DraftPatchInput) => Promise<DraftPatchOutput>;
|
|
176
|
-
/**
|
|
177
|
-
* When the resolved target doesn't exist, allow the substrate to
|
|
178
|
-
* CREATE the file (for `knowledge.wiki`, `new-tool` subjects). Default
|
|
179
|
-
* true for those kinds, false for `system-prompt` / `rubric` / etc.
|
|
180
|
-
* (named sections that don't exist are a contract violation, not a
|
|
181
|
-
* scaffolding opportunity).
|
|
182
|
-
*/
|
|
183
|
-
allowCreateForKinds?: ReadonlyArray<FindingSubject['kind']>;
|
|
184
|
-
}
|
|
185
|
-
interface DraftPatchInput {
|
|
186
|
-
finding: AnalystFinding;
|
|
187
|
-
subject: FindingSubject;
|
|
188
|
-
target: ResolvedSurface;
|
|
189
|
-
/** Current file content (empty string when `intent === 'create-new'`). */
|
|
190
|
-
currentContent: string;
|
|
191
|
-
}
|
|
192
|
-
interface DraftPatchOutput {
|
|
193
|
-
/** Unified diff against the current file content. Empty string skips this finding. */
|
|
194
|
-
patch: string;
|
|
195
|
-
/** One-line summary for the operator. */
|
|
196
|
-
summary: string;
|
|
197
|
-
/** Multi-line rationale for the PR body. */
|
|
198
|
-
rationale: string;
|
|
199
|
-
}
|
|
200
|
-
/** Resolve each finding to a real surface and draft a detached patch candidate. */
|
|
201
|
-
declare function createSurfaceImprovementProposer(opts: CreateSurfaceImprovementProposerOptions): ImprovementProposalSource<SurfaceImprovementEdit>;
|
|
202
|
-
|
|
203
|
-
export { type AgentSurfaces as A, type CreateSurfaceImprovementProposerOptions as C, type DraftPatchInput as D, type ResolvedSurface as R, type SurfaceImprovementEdit as S, type DraftPatchOutput as a, type SurfaceValidationIssue as b, createSurfaceImprovementProposer as c, resolveSubjectPath as d, renderSurfaceIssues as r, validateSurfaces as v };
|
package/dist/knowledge.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|