@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
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import { d as AgentTaskStatus, o as AgentRuntimeEvent, x as RuntimeStreamEvent } from "./types-C9j4qg6l.js";
|
|
2
|
+
import { ControlEvalResult, KnowledgeReadinessReport, KnowledgeRequirement } from "@tangle-network/agent-eval";
|
|
3
|
+
import { AgentProfile as AgentProfile$1 } from "@tangle-network/agent-interface";
|
|
4
|
+
import { ChildProcess } from "node:child_process";
|
|
5
|
+
//#region src/sanitize.d.ts
|
|
6
|
+
/** @stable */
|
|
7
|
+
interface RuntimeTelemetryOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Include raw task inputs. Off by default because task inputs often contain
|
|
10
|
+
* customer facts, credentials, source text, or internal IDs.
|
|
11
|
+
*/
|
|
12
|
+
includeInputs?: boolean;
|
|
13
|
+
/** Include requirement descriptions. Secret requirements are always redacted. */
|
|
14
|
+
includeRequirementDescriptions?: boolean;
|
|
15
|
+
/** Include evidence IDs. Off by default; counts are safer for shared reports. */
|
|
16
|
+
includeEvidenceIds?: boolean;
|
|
17
|
+
/** Include user answers from question preflight. Off by default. */
|
|
18
|
+
includeUserAnswers?: boolean;
|
|
19
|
+
/** Include action payloads and action results for control steps. Off by default. */
|
|
20
|
+
includeControlPayloads?: boolean;
|
|
21
|
+
/** Include task metadata. Off by default because metadata may carry IDs or policy internals. */
|
|
22
|
+
includeMetadata?: boolean;
|
|
23
|
+
/** Include eval detail/evidence strings. Off by default because validators may echo private input. */
|
|
24
|
+
includeEvalDetails?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** @stable */
|
|
27
|
+
interface SanitizedKnowledgeRequirement {
|
|
28
|
+
id: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
requiredFor: string[];
|
|
31
|
+
category: KnowledgeRequirement['category'];
|
|
32
|
+
acquisitionMode: KnowledgeRequirement['acquisitionMode'];
|
|
33
|
+
importance: KnowledgeRequirement['importance'];
|
|
34
|
+
freshness: KnowledgeRequirement['freshness'];
|
|
35
|
+
sensitivity: KnowledgeRequirement['sensitivity'];
|
|
36
|
+
confidenceNeeded: number;
|
|
37
|
+
currentConfidence: number;
|
|
38
|
+
evidenceCount: number;
|
|
39
|
+
evidenceIds?: string[];
|
|
40
|
+
fallbackPolicy: KnowledgeRequirement['fallbackPolicy'];
|
|
41
|
+
}
|
|
42
|
+
/** @stable */
|
|
43
|
+
interface SanitizedKnowledgeReadinessReport {
|
|
44
|
+
taskId: string;
|
|
45
|
+
readinessScore: number;
|
|
46
|
+
recommendedAction: KnowledgeReadinessReport['recommendedAction'];
|
|
47
|
+
severity: KnowledgeReadinessReport['severity'];
|
|
48
|
+
reason: string;
|
|
49
|
+
blockingMissingRequirements: SanitizedKnowledgeRequirement[];
|
|
50
|
+
nonBlockingGaps: SanitizedKnowledgeRequirement[];
|
|
51
|
+
evidenceCount: number;
|
|
52
|
+
evidenceIds?: string[];
|
|
53
|
+
missingRequirementIds: string[];
|
|
54
|
+
}
|
|
55
|
+
/** Strip PII and large blobs from a `KnowledgeReadinessReport` for safe telemetry emission. @stable */
|
|
56
|
+
declare function sanitizeKnowledgeReadinessReport(report: KnowledgeReadinessReport, options?: RuntimeTelemetryOptions): SanitizedKnowledgeReadinessReport;
|
|
57
|
+
/** Reduce an `AgentRuntimeEvent` to a PII-safe, serializable plain object for telemetry. @stable */
|
|
58
|
+
declare function sanitizeAgentRuntimeEvent<TState, TAction, TActionResult, TEval extends ControlEvalResult>(event: AgentRuntimeEvent<TState, TAction, TActionResult, TEval>, options?: RuntimeTelemetryOptions): Record<string, unknown>;
|
|
59
|
+
/** Reduce a `RuntimeStreamEvent` to a PII-safe, serializable plain object for telemetry. @stable */
|
|
60
|
+
declare function sanitizeRuntimeStreamEvent(event: RuntimeStreamEvent, options?: RuntimeTelemetryOptions): Record<string, unknown>;
|
|
61
|
+
/** @stable */
|
|
62
|
+
interface RuntimeEventCollector<TState = unknown, TAction = unknown, TActionResult = unknown, TEval extends ControlEvalResult = ControlEvalResult> {
|
|
63
|
+
onEvent: (event: AgentRuntimeEvent<TState, TAction, TActionResult, TEval>) => void;
|
|
64
|
+
events: Array<Record<string, unknown>>;
|
|
65
|
+
}
|
|
66
|
+
/** @stable */
|
|
67
|
+
type RuntimeStreamEventSink = (event: RuntimeStreamEvent) => void;
|
|
68
|
+
/** @stable */
|
|
69
|
+
interface RuntimeStreamEventSummary {
|
|
70
|
+
/** Total count of sanitized events collected. */
|
|
71
|
+
eventCount: number;
|
|
72
|
+
/** Count of events per `type`. Useful for log-line summaries. */
|
|
73
|
+
eventCountsByType: Record<string, number>;
|
|
74
|
+
/** First session id observed in a `session_created` / `session_resumed` event, if any. */
|
|
75
|
+
firstSessionId?: string;
|
|
76
|
+
/** Last `final` event's status, if a final event was observed. */
|
|
77
|
+
finalStatus?: AgentTaskStatus;
|
|
78
|
+
/** Last `final` event's reason, if a final event was observed. */
|
|
79
|
+
finalReason?: string;
|
|
80
|
+
/** Concatenated `text_delta.text` across the stream, even when payloads are redacted. */
|
|
81
|
+
finalText: string;
|
|
82
|
+
}
|
|
83
|
+
/** @stable */
|
|
84
|
+
interface RuntimeStreamEventCollector {
|
|
85
|
+
onEvent: RuntimeStreamEventSink;
|
|
86
|
+
events: Array<Record<string, unknown>>;
|
|
87
|
+
/** Snapshot of a small streaming-flavored summary derived from collected events. */
|
|
88
|
+
summary(): RuntimeStreamEventSummary;
|
|
89
|
+
}
|
|
90
|
+
/** Build an in-memory collector that sanitizes and accumulates `AgentRuntimeEvent`s for inspection. @stable */
|
|
91
|
+
declare function createRuntimeEventCollector<TState = unknown, TAction = unknown, TActionResult = unknown, TEval extends ControlEvalResult = ControlEvalResult>(options?: RuntimeTelemetryOptions): RuntimeEventCollector<TState, TAction, TActionResult, TEval>;
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* Streaming-event counterpart of `createRuntimeEventCollector`. Pass each
|
|
95
|
+
* event yielded by `runAgentTaskStream` through `onEvent` and read the
|
|
96
|
+
* sanitized copies off `events`; the same `RuntimeTelemetryOptions` redaction
|
|
97
|
+
* flags apply. Kept distinct from `createRuntimeEventCollector` because the
|
|
98
|
+
* stream and non-stream event shapes overlap on `type` literals — dispatching
|
|
99
|
+
* on `type` alone would misroute events.
|
|
100
|
+
*
|
|
101
|
+
* @stable
|
|
102
|
+
*/
|
|
103
|
+
declare function createRuntimeStreamEventCollector(options?: RuntimeTelemetryOptions): RuntimeStreamEventCollector;
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/runtime/tool-loop.d.ts
|
|
106
|
+
/** Provider-neutral conversation record accepted by a tool-loop brain. */
|
|
107
|
+
type ToolLoopMessageRecord = Record<string, unknown>;
|
|
108
|
+
/** One inference turn over the running conversation + the tool specs → the model's text, any
|
|
109
|
+
* tool calls, and token usage. The seam every brain satisfies. */
|
|
110
|
+
type ToolLoopChat = (messages: ReadonlyArray<ToolLoopMessageRecord>, tools: ReadonlyArray<ToolSpec>) => Promise<{
|
|
111
|
+
content?: string | null;
|
|
112
|
+
toolCalls: RouterToolCall[];
|
|
113
|
+
usage?: {
|
|
114
|
+
input: number;
|
|
115
|
+
output: number;
|
|
116
|
+
};
|
|
117
|
+
/** The turn's inference cost (usd) when the provider priced it — for callers that meter usd
|
|
118
|
+
* into a conserved pool (the supervisor brain). `runBrainLoop` itself ignores it. */
|
|
119
|
+
costUsd?: number;
|
|
120
|
+
}>;
|
|
121
|
+
/** Self-compaction — bound the loop's OWN context window the way a fresh-respawn (dumb-Ralph) loop
|
|
122
|
+
* does, but in place. A stateless chat API re-sends the WHOLE running conversation every turn, so an
|
|
123
|
+
* agent that accumulates dozens of turns of tool results re-bills its entire transcript on every
|
|
124
|
+
* inference — the context-overflow-one-level-up that the conserved budget pool cannot fix. With
|
|
125
|
+
* compaction set, once the conversation exceeds `thresholdTokens` the accumulated middle (every prior
|
|
126
|
+
* assistant turn + tool result) is distilled into ONE compact progress note and the conversation is
|
|
127
|
+
* reset to `[...head, digest]`: the preserved head (system + the original task) survives, the stale
|
|
128
|
+
* turn-by-turn history does not. The model keeps deciding; it stops re-billing the whole transcript.
|
|
129
|
+
* Fires at a CLEAN turn boundary (after a turn's tool results are folded in, before the next
|
|
130
|
+
* inference) so it never orphans an assistant `tool_calls` from its `tool` replies. */
|
|
131
|
+
interface ToolLoopCompaction {
|
|
132
|
+
/** Compact once the estimated token count of the conversation exceeds this. */
|
|
133
|
+
readonly thresholdTokens: number;
|
|
134
|
+
/** Distill the conversation into a compact progress note that REPLACES the middle. Receives the
|
|
135
|
+
* full conversation (so it can summarize everything done so far); returns the digest string. */
|
|
136
|
+
readonly distill: (messages: ReadonlyArray<ToolLoopMessageRecord>) => Promise<string> | string;
|
|
137
|
+
/** Leading messages preserved verbatim (system + the original task). Default 2. */
|
|
138
|
+
readonly preserveHead?: number;
|
|
139
|
+
/** Token estimator over the conversation. Default ≈ chars/4 (incl. tool-call arguments). */
|
|
140
|
+
readonly estimateTokens?: (messages: ReadonlyArray<ToolLoopMessageRecord>) => number;
|
|
141
|
+
/** Notified each time a compaction fires — for observability/metering. */
|
|
142
|
+
readonly onCompact?: (info: {
|
|
143
|
+
turn: number;
|
|
144
|
+
beforeTokens: number;
|
|
145
|
+
afterTokens: number;
|
|
146
|
+
}) => void;
|
|
147
|
+
}
|
|
148
|
+
/** Public supervisor-facing compaction config: same knobs as the primitive, but `distill` is optional
|
|
149
|
+
* because the supervisor has a default digest that combines a brain note with live worker state. */
|
|
150
|
+
type ToolLoopCompactionOptions = Omit<ToolLoopCompaction, 'distill'> & {
|
|
151
|
+
readonly distill?: ToolLoopCompaction['distill'];
|
|
152
|
+
};
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/runtime/router-client.d.ts
|
|
155
|
+
interface RouterConfig {
|
|
156
|
+
routerBaseUrl: string;
|
|
157
|
+
routerKey: string;
|
|
158
|
+
model: string;
|
|
159
|
+
/**
|
|
160
|
+
* Optional completion transport. When set, `routerChatWithUsage` / `routerChatWithTools` call it
|
|
161
|
+
* with the OpenAI-shape request body and use the parsed `/chat/completions` JSON it returns,
|
|
162
|
+
* INSTEAD of `fetch(routerBaseUrl + '/chat/completions')`. When absent the fetch path runs
|
|
163
|
+
* unchanged — the live router stays the default. The injection seam an offline benchmark uses to
|
|
164
|
+
* drive the worker with no network: a deterministic in-process responder satisfies it, no server.
|
|
165
|
+
*/
|
|
166
|
+
complete?: (body: Record<string, unknown>) => Promise<unknown>;
|
|
167
|
+
}
|
|
168
|
+
interface RouterChatResult {
|
|
169
|
+
/** The final answer, with any inline `<think>...</think>` block stripped into `reasoning`. */
|
|
170
|
+
content: string;
|
|
171
|
+
/**
|
|
172
|
+
* Thinking-model reasoning, when the provider surfaced it — either as a separate
|
|
173
|
+
* `reasoning`/`reasoning_content` message field (OpenRouter style) or inlined into
|
|
174
|
+
* `content` as a `<think>` block (Groq style). Undefined for non-thinking models.
|
|
175
|
+
* Downstream parsers that match single-token answers must read `content`, which is
|
|
176
|
+
* clean either way; before this split, Groq-style inlining made the same model look
|
|
177
|
+
* broken on one provider and fine on another.
|
|
178
|
+
*/
|
|
179
|
+
reasoning?: string;
|
|
180
|
+
/** REAL usage, or undefined when the provider reported none. */
|
|
181
|
+
usage?: {
|
|
182
|
+
input: number;
|
|
183
|
+
output: number;
|
|
184
|
+
};
|
|
185
|
+
/** Derived from usage via `estimateCost` when the model is priced; else undefined. */
|
|
186
|
+
costUsd?: number;
|
|
187
|
+
}
|
|
188
|
+
/** One OpenAI-compatible chat completion through the Tangle router, returning text + REAL token usage (`undefined` when the provider omits it — never a fabricated 0). */
|
|
189
|
+
declare function routerChatWithUsage(cfg: RouterConfig, messages: Array<{
|
|
190
|
+
role: string;
|
|
191
|
+
content: string;
|
|
192
|
+
}>, opts?: {
|
|
193
|
+
temperature?: number;
|
|
194
|
+
signal?: AbortSignal;
|
|
195
|
+
maxTokens?: number;
|
|
196
|
+
/**
|
|
197
|
+
* Reasoning control for thinking models, forwarded as `reasoning_effort`.
|
|
198
|
+
* 'none' is the load-bearing value: binary/single-token decisions (routing,
|
|
199
|
+
* gating) on a thinking model otherwise burn the whole token budget inside
|
|
200
|
+
* the think block — on slow backends (CPU-local) that turns into a client
|
|
201
|
+
* timeout, not just waste. Providers that ignore the field are handled by
|
|
202
|
+
* the reasoning/content split in `parseChatResult`.
|
|
203
|
+
*/
|
|
204
|
+
reasoningEffort?: 'none' | 'low' | 'medium' | 'high';
|
|
205
|
+
}): Promise<RouterChatResult>;
|
|
206
|
+
/** A tool-call the model emitted (provider-neutral; mirrors the runtime's ToolCallRequest). */
|
|
207
|
+
interface RouterToolCall {
|
|
208
|
+
id: string;
|
|
209
|
+
name: string;
|
|
210
|
+
/** Raw JSON arguments string as emitted by the model. */
|
|
211
|
+
arguments: string;
|
|
212
|
+
}
|
|
213
|
+
interface RouterChatToolsResult {
|
|
214
|
+
content: string | null;
|
|
215
|
+
toolCalls: RouterToolCall[];
|
|
216
|
+
usage?: {
|
|
217
|
+
input: number;
|
|
218
|
+
output: number;
|
|
219
|
+
};
|
|
220
|
+
costUsd?: number;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* A router completion WITH tool-calling — the operator driver's LLM seam. Passes OpenAI-shape
|
|
224
|
+
* `messages` (system/user/assistant-with-tool_calls/tool roles) + function `tools`, and returns the
|
|
225
|
+
* assistant text plus the tool calls the model wants run. Same fail-loud + real-usage discipline as
|
|
226
|
+
* `routerChatWithUsage`. `tool_choice: 'auto'` lets the model decide; the driver loops on the result.
|
|
227
|
+
*/
|
|
228
|
+
declare function routerChatWithTools(cfg: RouterConfig, messages: ReadonlyArray<Record<string, unknown>>, tools: ReadonlyArray<{
|
|
229
|
+
type: 'function';
|
|
230
|
+
function: {
|
|
231
|
+
name: string;
|
|
232
|
+
description?: string;
|
|
233
|
+
parameters: unknown;
|
|
234
|
+
};
|
|
235
|
+
}>, opts?: {
|
|
236
|
+
temperature?: number;
|
|
237
|
+
signal?: AbortSignal;
|
|
238
|
+
toolChoice?: 'auto' | 'required' | 'none';
|
|
239
|
+
maxTokens?: number;
|
|
240
|
+
}): Promise<RouterChatToolsResult>;
|
|
241
|
+
interface ToolSpec {
|
|
242
|
+
type: 'function';
|
|
243
|
+
function: {
|
|
244
|
+
name: string;
|
|
245
|
+
description?: string;
|
|
246
|
+
parameters: unknown;
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
interface RouterToolLoopResult {
|
|
250
|
+
/** The model's final assistant text (the turn where it stopped calling tools, or the budget turn). */
|
|
251
|
+
final: string;
|
|
252
|
+
/** Inference turns spent (≤ maxTurns) — the equal-budget unit vs random@k. */
|
|
253
|
+
turns: number;
|
|
254
|
+
toolCalls: number;
|
|
255
|
+
/** The behavior trace: each tool call + its result, in order. What a trace-analyst
|
|
256
|
+
* steerer reads (behavior, never the verdict) to diagnose + redirect the next shot. */
|
|
257
|
+
toolTrace: Array<{
|
|
258
|
+
name: string;
|
|
259
|
+
args: string;
|
|
260
|
+
result: string;
|
|
261
|
+
}>;
|
|
262
|
+
usage: {
|
|
263
|
+
input: number;
|
|
264
|
+
output: number;
|
|
265
|
+
};
|
|
266
|
+
/** The full conversation after the loop (seed + every assistant/tool turn). Lets a caller
|
|
267
|
+
* CARRY the messages into the next shot (depth continuation) and read the trajectory. */
|
|
268
|
+
messages: Array<Record<string, unknown>>;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* The tool-using router backend: a real agentic loop OVER the Tangle router (which
|
|
272
|
+
* supports tool-calling), off-box — no sandbox. Each turn is one router completion
|
|
273
|
+
* with `tools`; if the model emits tool_calls, `execute` runs them on the host and
|
|
274
|
+
* their results are folded back as `tool` messages; the loop repeats until the
|
|
275
|
+
* model answers without a tool call or the turn budget is hit. One turn = one
|
|
276
|
+
* inference call, so `maxTurns` is the equal-compute unit against random@k.
|
|
277
|
+
*
|
|
278
|
+
* This is the depth substrate for agentic gates (the worker ACTS, observes the real
|
|
279
|
+
* result, and continues) that the chat-only `routerChatWithUsage` cannot express.
|
|
280
|
+
*/
|
|
281
|
+
declare function routerToolLoop(cfg: RouterConfig, system: string, user: string, tools: ReadonlyArray<ToolSpec>, execute: (name: string, args: Record<string, unknown>) => Promise<string>, opts?: {
|
|
282
|
+
maxTurns?: number;
|
|
283
|
+
temperature?: number;
|
|
284
|
+
signal?: AbortSignal;
|
|
285
|
+
maxTokens?: number;
|
|
286
|
+
/** Seed the loop with an existing conversation (depth continuation) instead of
|
|
287
|
+
* `[system, user]`. When set, `system`/`user` are ignored. The array is copied. */
|
|
288
|
+
initialMessages?: ReadonlyArray<Record<string, unknown>>;
|
|
289
|
+
}): Promise<RouterToolLoopResult>;
|
|
290
|
+
/**
|
|
291
|
+
* The router as a supervisor BRAIN: the canonical `ToolLoopChat` seam backed by the router's
|
|
292
|
+
* tool-calling. The driver's spawn/observe/steer/await/stop turns become real router tool-calls.
|
|
293
|
+
* The turnkey production brain — tests script a mock `ToolLoopChat`; production passes
|
|
294
|
+
* `routerBrain(cfg)`. No message translation: the loop already speaks the router's OpenAI shape.
|
|
295
|
+
*/
|
|
296
|
+
declare function routerBrain(cfg: RouterConfig, opts?: {
|
|
297
|
+
temperature?: number;
|
|
298
|
+
}): ToolLoopChat;
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region src/mcp/local-harness.d.ts
|
|
301
|
+
/** Local coding harness available inside the sandbox. */
|
|
302
|
+
type LocalHarness = 'claude' | 'codex' | 'opencode';
|
|
303
|
+
/** @experimental */
|
|
304
|
+
interface RunLocalHarnessOptions {
|
|
305
|
+
harness: LocalHarness;
|
|
306
|
+
/** Working directory for the subprocess (typically a worktree path). */
|
|
307
|
+
cwd: string;
|
|
308
|
+
/** Prompt forwarded as the harness CLI's task argument. */
|
|
309
|
+
taskPrompt: string;
|
|
310
|
+
/**
|
|
311
|
+
* Pre-built command + args (e.g. from `harnessInvocation` so the full authored
|
|
312
|
+
* `AgentProfile` — systemPrompt + model — reaches the harness). When set it OVERRIDES the
|
|
313
|
+
* default prompt-only `buildArgs(taskPrompt)` path; `command` defaults to the harness's
|
|
314
|
+
* default binary when only `args` is supplied. When absent the legacy prompt-only shape
|
|
315
|
+
* is used unchanged.
|
|
316
|
+
*/
|
|
317
|
+
invocation?: {
|
|
318
|
+
command?: string;
|
|
319
|
+
args: ReadonlyArray<string>;
|
|
320
|
+
};
|
|
321
|
+
/** Allow autonomous Claude edits without an interactive permission prompt.
|
|
322
|
+
* Use only when `cwd` is an isolated candidate worktree. */
|
|
323
|
+
dangerouslySkipPermissions?: boolean;
|
|
324
|
+
/** Isolate Codex from ambient configuration/instructions and require JSONL token usage.
|
|
325
|
+
* The invocation should come from `harnessInvocation(..., { codexReproducible: true })`. */
|
|
326
|
+
codexReproducible?: boolean;
|
|
327
|
+
/** Absolute host paths that reproducible Codex must not read. The normalized set is compiled
|
|
328
|
+
* into the controlled permission profile and its digest is returned in execution evidence. */
|
|
329
|
+
codexReadDeniedPaths?: ReadonlyArray<string>;
|
|
330
|
+
/** Wall-clock kill deadline (ms). Default 5 min. Subprocess SIGTERMed on expiry. */
|
|
331
|
+
timeoutMs?: number;
|
|
332
|
+
/** Newest stdout/stderr bytes retained per stream. Default 64 MiB. */
|
|
333
|
+
maxOutputBytes?: number;
|
|
334
|
+
/** Caller cancellation. SIGTERM is sent on abort. */
|
|
335
|
+
signal?: AbortSignal;
|
|
336
|
+
/** Override env (defaults to inheriting from the parent). */
|
|
337
|
+
env?: NodeJS.ProcessEnv;
|
|
338
|
+
/**
|
|
339
|
+
* Test seam — inject a custom spawner so unit tests can mock the
|
|
340
|
+
* subprocess without touching the OS. Defaults to node's `child_process.spawn`.
|
|
341
|
+
*/
|
|
342
|
+
spawn?: (command: string, args: ReadonlyArray<string>, opts: {
|
|
343
|
+
cwd: string;
|
|
344
|
+
env: NodeJS.ProcessEnv;
|
|
345
|
+
stdio: 'pipe';
|
|
346
|
+
detached: boolean;
|
|
347
|
+
}) => ChildProcess;
|
|
348
|
+
/** Test seam for locating the native Codex executable before it is staged in the worktree. */
|
|
349
|
+
resolveCodexExecutable?: (command: string, env: NodeJS.ProcessEnv) => Promise<string>;
|
|
350
|
+
}
|
|
351
|
+
/** Exact aggregate usage emitted by Codex's terminal `turn.completed` JSONL event. */
|
|
352
|
+
interface CodexTokenUsage {
|
|
353
|
+
inputTokens: number;
|
|
354
|
+
cachedInputTokens: number;
|
|
355
|
+
outputTokens: number;
|
|
356
|
+
reasoningOutputTokens: number;
|
|
357
|
+
}
|
|
358
|
+
/** Isolation settings asserted before a reproducible Codex run is allowed to start. */
|
|
359
|
+
interface CodexExecutionPolicy {
|
|
360
|
+
sessionPersistence: 'ephemeral';
|
|
361
|
+
userConfig: false;
|
|
362
|
+
rules: false;
|
|
363
|
+
projectInstructions: false;
|
|
364
|
+
skillInstructions: false;
|
|
365
|
+
appInstructions: false;
|
|
366
|
+
toolSuggestions: false;
|
|
367
|
+
multiAgentInstructions: false;
|
|
368
|
+
sandbox: 'workspace-write';
|
|
369
|
+
permissionProfile: 'agent_runtime_reproducible';
|
|
370
|
+
approvalPolicy: 'never';
|
|
371
|
+
shellNetwork: false;
|
|
372
|
+
webSearch: false;
|
|
373
|
+
serviceTier: 'default';
|
|
374
|
+
shellEnvironment: 'core-filtered';
|
|
375
|
+
loginShell: false;
|
|
376
|
+
credentialsReadable: false;
|
|
377
|
+
hostHomeReadable: false;
|
|
378
|
+
procEnvironment: 'private-sanitized';
|
|
379
|
+
sensitiveEnvironmentNamesVisible: false;
|
|
380
|
+
parentRepoRead: false;
|
|
381
|
+
gitMetadata: false;
|
|
382
|
+
temporaryDirectory: 'workspace-private';
|
|
383
|
+
stagedExecutable: 'static-elf-read-only';
|
|
384
|
+
callerReadDeniedPaths: 'enforced';
|
|
385
|
+
containerSockets: false;
|
|
386
|
+
}
|
|
387
|
+
/** Zero-model-call evidence for the exact Codex process about to run. */
|
|
388
|
+
interface CodexExecutionEvidence {
|
|
389
|
+
cliVersion: string;
|
|
390
|
+
executableSha256: string;
|
|
391
|
+
/** SHA-256 of the exact composed prompt argument proved present in the rendered prompt. */
|
|
392
|
+
requestedPromptSha256: string;
|
|
393
|
+
effectivePromptSha256: string;
|
|
394
|
+
nonPromptArgsSha256: string;
|
|
395
|
+
controlledConfigSha256: string;
|
|
396
|
+
/** Sorted normalized paths compiled into the permission profile. */
|
|
397
|
+
readDeniedPaths: string[];
|
|
398
|
+
readDeniedPathsSha256: string;
|
|
399
|
+
readDeniedPathCount: number;
|
|
400
|
+
policy: CodexExecutionPolicy;
|
|
401
|
+
}
|
|
402
|
+
/** @experimental */
|
|
403
|
+
interface LocalHarnessResult {
|
|
404
|
+
/** OS exit code. `null` when killed before exit. */
|
|
405
|
+
exitCode: number | null;
|
|
406
|
+
/** Concatenated stdout. */
|
|
407
|
+
stdout: string;
|
|
408
|
+
/** Concatenated stderr. */
|
|
409
|
+
stderr: string;
|
|
410
|
+
/** Set when the process exited via signal (timeout / abort). */
|
|
411
|
+
killedBySignal: NodeJS.Signals | null;
|
|
412
|
+
/** Wall-clock duration ms (spawn → exit). */
|
|
413
|
+
durationMs: number;
|
|
414
|
+
/** Set when timeoutMs elapsed before exit. */
|
|
415
|
+
timedOut: boolean;
|
|
416
|
+
/**
|
|
417
|
+
* Set when the caller's AbortSignal fired before this result settled.
|
|
418
|
+
* Optional so injected runners and stored results from older releases remain valid.
|
|
419
|
+
*/
|
|
420
|
+
aborted?: boolean;
|
|
421
|
+
/** Present for a reproducible Codex run; parsed from the real terminal JSONL event. */
|
|
422
|
+
usage?: CodexTokenUsage;
|
|
423
|
+
/** Present for reproducible Codex runs; generated and checked before model execution. */
|
|
424
|
+
evidence?: CodexExecutionEvidence;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Spawn a local coding harness CLI as a subprocess + collect its output.
|
|
428
|
+
*
|
|
429
|
+
* NOT responsible for parsing the harness's output or extracting a diff —
|
|
430
|
+
* the in-process executor's `streamPrompt` orchestrates `git diff` against
|
|
431
|
+
* the worktree after this resolves. This function is intentionally narrow:
|
|
432
|
+
* spawn, wait, capture, return.
|
|
433
|
+
*
|
|
434
|
+
* Fails loud — throws when:
|
|
435
|
+
* - `cwd` doesn't exist (subprocess emits ENOENT; surfaced as Error)
|
|
436
|
+
* - the harness binary is not on PATH (ENOENT)
|
|
437
|
+
* - the caller signal was already aborted before process launch
|
|
438
|
+
*
|
|
439
|
+
* Does NOT throw when:
|
|
440
|
+
* - the subprocess exits non-zero (`result.exitCode` carries the code)
|
|
441
|
+
* - a non-reproducible subprocess is aborted / timed out (`result.aborted` /
|
|
442
|
+
* `result.timedOut` carries the reason even when a TERM-aware child exits zero)
|
|
443
|
+
*
|
|
444
|
+
* Reproducible Codex additionally requires a terminal usage event. If cancellation
|
|
445
|
+
* prevents that event, this rejects with `CodexExecutionDiagnosticError` instead of
|
|
446
|
+
* returning an incomplete reproducibility receipt.
|
|
447
|
+
*
|
|
448
|
+
* @experimental
|
|
449
|
+
*/
|
|
450
|
+
declare function runLocalHarness(options: RunLocalHarnessOptions): Promise<LocalHarnessResult>;
|
|
451
|
+
/** Parse and validate the one terminal usage event emitted by `codex exec --json`. */
|
|
452
|
+
declare function parseCodexTokenUsage(stdout: string): CodexTokenUsage;
|
|
453
|
+
//#endregion
|
|
454
|
+
export { createRuntimeEventCollector as A, RuntimeEventCollector as C, RuntimeTelemetryOptions as D, RuntimeStreamEventSummary as E, sanitizeAgentRuntimeEvent as M, sanitizeKnowledgeReadinessReport as N, SanitizedKnowledgeReadinessReport as O, sanitizeRuntimeStreamEvent as P, ToolLoopMessageRecord as S, RuntimeStreamEventSink as T, routerChatWithUsage as _, LocalHarnessResult as a, ToolLoopCompaction as b, runLocalHarness as c, RouterConfig as d, RouterToolCall as f, routerChatWithTools as g, routerBrain as h, LocalHarness as i, createRuntimeStreamEventCollector as j, SanitizedKnowledgeRequirement as k, RouterChatResult as l, ToolSpec as m, CodexExecutionPolicy as n, RunLocalHarnessOptions as o, RouterToolLoopResult as p, CodexTokenUsage as r, parseCodexTokenUsage as s, CodexExecutionEvidence as t, RouterChatToolsResult as u, routerToolLoop as v, RuntimeStreamEventCollector as w, ToolLoopCompactionOptions as x, ToolLoopChat as y };
|
|
455
|
+
//# sourceMappingURL=local-harness-Dh8PJ0ot.d.ts.map
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { d as RunAnalystLoopOpts, f as RunAnalystLoopResult } from "./types-Cja5OTGh.js";
|
|
2
|
+
import { R as Budget } from "./environment-provider-IUGU3epE.js";
|
|
3
|
+
import { E as WorktreeFanoutOptions, G as WorktreePatchArtifact, T as AuthoredHarness, no as WinnerStrategy } from "./index-DruSKs3Z.js";
|
|
4
|
+
import { n as FactCandidate, t as CreateKbGateOptions } from "./kb-gate-C8z2juK8.js";
|
|
5
|
+
//#region src/loop-runner.d.ts
|
|
6
|
+
/** All valid delegated-loop mode names — used for validation and CLI surfaces. @experimental */
|
|
7
|
+
declare const DELEGATED_LOOP_MODES: readonly ["code", "review", "research", "audit", "self-improve"];
|
|
8
|
+
/** @experimental */
|
|
9
|
+
type DelegatedLoopMode = (typeof DELEGATED_LOOP_MODES)[number];
|
|
10
|
+
/** Type guard — returns true when `value` is a valid `DelegatedLoopMode` string. @experimental */
|
|
11
|
+
declare function isDelegatedLoopMode(value: unknown): value is DelegatedLoopMode;
|
|
12
|
+
/** @experimental A pre-configured loop for one mode. Returns the mode's raw
|
|
13
|
+
* output; the dispatcher wraps it in a {@link DelegatedLoopResult}. */
|
|
14
|
+
type DelegatedLoopRunner<T = unknown> = (signal: AbortSignal) => Promise<T>;
|
|
15
|
+
/** @experimental Mode → configured runner. Partial: only register the modes a
|
|
16
|
+
* given product/routine actually uses. */
|
|
17
|
+
type DelegatedLoopRegistry = Partial<Record<DelegatedLoopMode, DelegatedLoopRunner>>;
|
|
18
|
+
/** @experimental Uniform result — never throws from a registered runner; a
|
|
19
|
+
* thrown engine becomes `{ ok: false, error }` so a routine can record + move on. */
|
|
20
|
+
interface DelegatedLoopResult<T = unknown> {
|
|
21
|
+
mode: DelegatedLoopMode;
|
|
22
|
+
ok: boolean;
|
|
23
|
+
output?: T;
|
|
24
|
+
error?: string;
|
|
25
|
+
durationMs: number;
|
|
26
|
+
}
|
|
27
|
+
/** @experimental */
|
|
28
|
+
interface RunDelegatedLoopOptions {
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
/** Clock override for deterministic tests. */
|
|
31
|
+
now?: () => number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* Dispatch a configured loop by mode. Fails loud (throws `ConfigError`) when no
|
|
36
|
+
* runner is registered for the mode — a routine pointed at an unwired mode is a
|
|
37
|
+
* config bug, not a silent no-op. A runner that throws is captured as
|
|
38
|
+
* `{ ok: false }` so unattended runs record the failure rather than crash.
|
|
39
|
+
*
|
|
40
|
+
* @experimental
|
|
41
|
+
*/
|
|
42
|
+
declare function runDelegatedLoop<T = unknown>(mode: DelegatedLoopMode, registry: DelegatedLoopRegistry, options?: RunDelegatedLoopOptions): Promise<DelegatedLoopResult<T>>;
|
|
43
|
+
/** @experimental Options for the local-repo `code` runner over the GENERIC recursive path. */
|
|
44
|
+
interface WorktreeLoopRunnerOptions {
|
|
45
|
+
/** Absolute path to the local git checkout each worktree is cut from. */
|
|
46
|
+
repoRoot: string;
|
|
47
|
+
/** The instruction handed to every authored harness (composed under each profile's systemPrompt). */
|
|
48
|
+
taskPrompt: string;
|
|
49
|
+
/** The supervisor-authored harness profiles — one fanout item (one worktree-CLI leaf) each. */
|
|
50
|
+
harnesses: ReadonlyArray<AuthoredHarness>;
|
|
51
|
+
/** Conserved budget pool bounding the fanout (equal-k holds by construction). */
|
|
52
|
+
budget: Budget;
|
|
53
|
+
/** Shell command run in each worktree to derive the tests-PASS signal. */
|
|
54
|
+
testCmd?: string;
|
|
55
|
+
/** Shell command run in each worktree to derive the typecheck-PASS signal. */
|
|
56
|
+
typecheckCmd?: string;
|
|
57
|
+
/** Which verification signals the deliverable REQUIRES present-and-passing (default none). */
|
|
58
|
+
require?: ReadonlyArray<'tests' | 'typecheck'>;
|
|
59
|
+
/** Diff-size cap (lines). */
|
|
60
|
+
maxDiffLines?: number;
|
|
61
|
+
/** Literal path prefixes the patch must not touch (the secret-floor is always on regardless). */
|
|
62
|
+
forbiddenPaths?: string[];
|
|
63
|
+
/** Winner-selection strategy among gated candidates. Default `highest-score`. */
|
|
64
|
+
winnerStrategy?: WinnerStrategy;
|
|
65
|
+
/** Test seams forwarded to the worktree-CLI leaves so the runner drives offline. */
|
|
66
|
+
runGit?: WorktreeFanoutOptions['runGit'];
|
|
67
|
+
runHarness?: WorktreeFanoutOptions['runHarness'];
|
|
68
|
+
runCommand?: WorktreeFanoutOptions['runCommand'];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* `code` mode on the GENERIC recursive path: author one `AgentProfile` per harness, run them as a
|
|
73
|
+
* `worktreeFanout` (N `createWorktreeCliExecutor` leaves, each `gateOnDeliverable`) through
|
|
74
|
+
* `runPersonified` on the keystone Supervisor. The sandbox-session counterpart that drives the in-box
|
|
75
|
+
* harness over a `SandboxClient` is `detachedSessionDelegate` (`./mcp/delegates`); here there is no
|
|
76
|
+
* `runAgentRounds` driver, no role-coupled delegate — the harness list is the fanout, the gate is
|
|
77
|
+
* `patchDelivered`,
|
|
78
|
+
* the winner is the shared valid-only selector (NOT `defaultSelectWinner`, whose non-valid fallback
|
|
79
|
+
* would surface an ungated patch). Equal-k holds by the conserved budget pool. Returns the winning
|
|
80
|
+
* patch artifact, or throws when no candidate is delivered (fail loud, never a vacuous done).
|
|
81
|
+
*
|
|
82
|
+
* @experimental
|
|
83
|
+
*/
|
|
84
|
+
declare function worktreeLoopRunner(options: WorktreeLoopRunnerOptions): DelegatedLoopRunner<WorktreePatchArtifact>;
|
|
85
|
+
/** @experimental A fact rejected at the KB gate — surfaced, never dropped. */
|
|
86
|
+
interface VetoedFact {
|
|
87
|
+
candidate: FactCandidate;
|
|
88
|
+
vetoedBy?: string;
|
|
89
|
+
reason?: string;
|
|
90
|
+
}
|
|
91
|
+
/** @experimental */
|
|
92
|
+
interface ResearchLoopResult {
|
|
93
|
+
/** Facts that passed the fail-closed gate — safe to write to the KB. */
|
|
94
|
+
accepted: FactCandidate[];
|
|
95
|
+
/** Facts the gate vetoed in the final round — escalate, do not silently drop. */
|
|
96
|
+
vetoed: VetoedFact[];
|
|
97
|
+
/** Research rounds actually run. */
|
|
98
|
+
rounds: number;
|
|
99
|
+
}
|
|
100
|
+
/** @experimental Options for the default `research` runner. */
|
|
101
|
+
interface ResearchLoopRunnerOptions {
|
|
102
|
+
/**
|
|
103
|
+
* The research engine (the consumer's web/doc searcher + extractor). Called
|
|
104
|
+
* each round with the prior round's vetoes so it can re-research the gaps.
|
|
105
|
+
* Returns fact candidates carrying their grounding (`verbatimPassage` +
|
|
106
|
+
* `sourceText`).
|
|
107
|
+
*/
|
|
108
|
+
research: (round: number, vetoed: VetoedFact[]) => Promise<FactCandidate[]>;
|
|
109
|
+
/** Gate config (extra judges, self-artifact kinds, …). The floor is always on. */
|
|
110
|
+
gate?: CreateKbGateOptions;
|
|
111
|
+
/** Max research rounds (correct-on-veto remediation). Default 1. */
|
|
112
|
+
maxRounds?: number;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* `research` mode — research-in-a-loop with valid-only KB growth.
|
|
116
|
+
*
|
|
117
|
+
* Each round: research → gate every candidate (fail-closed; passage MUST be in
|
|
118
|
+
* the source) → accept the clean ones → re-research the vetoed ones next round,
|
|
119
|
+
* up to `maxRounds`. Vetoed facts in the final round are RETURNED (escalate,
|
|
120
|
+
* never silently dropped) so the caller audits vs retries.
|
|
121
|
+
*
|
|
122
|
+
* @experimental
|
|
123
|
+
*/
|
|
124
|
+
declare function researchLoopRunner(o: ResearchLoopRunnerOptions): DelegatedLoopRunner<ResearchLoopResult>;
|
|
125
|
+
/**
|
|
126
|
+
* `audit` mode — analyst loop over captured trace/run data.
|
|
127
|
+
*
|
|
128
|
+
* @experimental
|
|
129
|
+
*/
|
|
130
|
+
declare function auditLoopRunner<TProposal = unknown, TEdit = unknown>(options: RunAnalystLoopOpts): DelegatedLoopRunner<RunAnalystLoopResult<TProposal, TEdit>>;
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/loop-runner-bin.d.ts
|
|
133
|
+
/** @experimental Parsed CLI invocation. */
|
|
134
|
+
interface LoopRunnerCliArgs {
|
|
135
|
+
mode: string;
|
|
136
|
+
/** Loads the registry — the bin wires this from `--config`; tests inject a stub. */
|
|
137
|
+
loadRegistry: () => Promise<DelegatedLoopRegistry> | DelegatedLoopRegistry;
|
|
138
|
+
now?: () => number;
|
|
139
|
+
}
|
|
140
|
+
/** @experimental */
|
|
141
|
+
interface LoopRunnerCliResult {
|
|
142
|
+
exitCode: number;
|
|
143
|
+
result?: DelegatedLoopResult;
|
|
144
|
+
error?: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
*
|
|
148
|
+
* Pure CLI core (no process / argv / IO) so it's unit-testable: validate the
|
|
149
|
+
* mode, load the registry, dispatch, map to an exit code (0 ok / 1 failed /
|
|
150
|
+
* 2 usage). Exported for embedding in custom runners + tests.
|
|
151
|
+
*
|
|
152
|
+
* @experimental
|
|
153
|
+
*/
|
|
154
|
+
declare function runLoopRunnerCli(args: LoopRunnerCliArgs): Promise<LoopRunnerCliResult>;
|
|
155
|
+
/** Parse `--mode X --config Y` from an argv tail (`process.argv.slice(2)`). */
|
|
156
|
+
declare function parseLoopRunnerArgv(argv: string[]): {
|
|
157
|
+
mode?: string;
|
|
158
|
+
config?: string;
|
|
159
|
+
};
|
|
160
|
+
//#endregion
|
|
161
|
+
export { researchLoopRunner as _, DELEGATED_LOOP_MODES as a, DelegatedLoopResult as c, ResearchLoopRunnerOptions as d, RunDelegatedLoopOptions as f, isDelegatedLoopMode as g, auditLoopRunner as h, runLoopRunnerCli as i, DelegatedLoopRunner as l, WorktreeLoopRunnerOptions as m, LoopRunnerCliResult as n, DelegatedLoopMode as o, VetoedFact as p, parseLoopRunnerArgv as r, DelegatedLoopRegistry as s, LoopRunnerCliArgs as t, ResearchLoopResult as u, runDelegatedLoop as v, worktreeLoopRunner as y };
|
|
162
|
+
//# sourceMappingURL=loop-runner-bin-BXsFEUcf.d.ts.map
|