@tangle-network/agent-runtime 0.52.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -16
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +5 -3
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/analyst-loop.js +2 -2
- package/dist/{chunk-COAVO6QB.js → chunk-2BDXWZUC.js} +5 -34
- package/dist/chunk-2BDXWZUC.js.map +1 -0
- package/dist/chunk-A73RADPB.js +281 -0
- package/dist/chunk-A73RADPB.js.map +1 -0
- package/dist/chunk-FRBWCJLP.js +396 -0
- package/dist/chunk-FRBWCJLP.js.map +1 -0
- package/dist/chunk-GRAGM4MC.js +72 -0
- package/dist/chunk-GRAGM4MC.js.map +1 -0
- package/dist/{chunk-2OU7ZQPD.js → chunk-JTH2FPCK.js} +3248 -456
- package/dist/chunk-JTH2FPCK.js.map +1 -0
- package/dist/{chunk-V2K35HF2.js → chunk-KJH62YEK.js} +2 -2
- package/dist/{chunk-HNUXAZIJ.js → chunk-P5OKDSLB.js} +2 -2
- package/dist/{chunk-GSUO5QS6.js → chunk-VLF5RHEQ.js} +2 -5
- package/dist/{chunk-GSUO5QS6.js.map → chunk-VLF5RHEQ.js.map} +1 -1
- package/dist/{chunk-7JITYN6T.js → chunk-XRYEZPR6.js} +18 -2
- package/dist/chunk-XRYEZPR6.js.map +1 -0
- package/dist/{coder-_YCf3BAK.d.ts → coder-CEkUFv8h.d.ts} +1 -1
- package/dist/{types-5MGt5KTY.d.ts → coordination-BMzskrUR.d.ts} +268 -2
- package/dist/{kb-gate-CHAyt4aI.d.ts → delegates-BPLIl8EC.d.ts} +491 -566
- package/dist/{delegation-profile-1GbW5yA3.d.ts → delegation-profile-Bvfro2m1.d.ts} +28 -2
- package/dist/index.d.ts +7 -7
- package/dist/index.js +25 -80
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +475 -5
- package/dist/intelligence.js +547 -3
- package/dist/intelligence.js.map +1 -1
- package/dist/kb-gate-CuzMYGYM.d.ts +76 -0
- package/dist/{loop-runner-bin-DFUNgpeK.d.ts → loop-runner-bin-BGpVVyXp.d.ts} +6 -27
- package/dist/loop-runner-bin.d.ts +5 -5
- package/dist/loop-runner-bin.js +6 -5
- package/dist/loops.d.ts +8 -5
- package/dist/loops.js +32 -8
- package/dist/mcp/bin.js +94 -30
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +10 -273
- package/dist/mcp/index.js +45 -365
- package/dist/mcp/index.js.map +1 -1
- package/dist/{openai-tools-D4HLDWgw.d.ts → openai-tools-CoeLQ7Uo.d.ts} +1 -1
- package/dist/profiles.d.ts +2 -2
- package/dist/profiles.js +4 -4
- package/dist/router-client-30Y_pca8.d.ts +120 -0
- package/dist/{run-loop-BIineL1T.d.ts → run-loop-DluzfJ2h.d.ts} +1 -1
- package/dist/runtime.d.ts +429 -131
- package/dist/runtime.js +32 -8
- package/dist/topology.d.ts +54 -1
- package/dist/topology.js +222 -0
- package/dist/topology.js.map +1 -1
- package/dist/{types-BEQsBhOE.d.ts → types-C8rNlxfV.d.ts} +6 -5
- package/dist/workflow.d.ts +2 -2
- package/dist/workflow.js +4 -2
- package/dist/workflow.js.map +1 -1
- package/package.json +5 -5
- package/skills/agent-runtime-adoption/SKILL.md +54 -46
- package/skills/build-with-agent-runtime/SKILL.md +12 -8
- package/skills/loop-writer/SKILL.md +9 -1
- package/skills/supervise/SKILL.md +24 -0
- package/dist/chunk-2OU7ZQPD.js.map +0 -1
- package/dist/chunk-4JI4BCBI.js +0 -623
- package/dist/chunk-4JI4BCBI.js.map +0 -1
- package/dist/chunk-7JITYN6T.js.map +0 -1
- package/dist/chunk-7SP2OVYZ.js +0 -908
- package/dist/chunk-7SP2OVYZ.js.map +0 -1
- package/dist/chunk-BERLUBAP.js +0 -1356
- package/dist/chunk-BERLUBAP.js.map +0 -1
- package/dist/chunk-COAVO6QB.js.map +0 -1
- package/dist/driver-DLI1io57.d.ts +0 -221
- /package/dist/{chunk-V2K35HF2.js.map → chunk-KJH62YEK.js.map} +0 -0
- /package/dist/{chunk-HNUXAZIJ.js.map → chunk-P5OKDSLB.js.map} +0 -0
|
@@ -1,123 +1,9 @@
|
|
|
1
|
-
import { C as CoderOutput, b as CoderTask } from './coder-
|
|
2
|
-
import {
|
|
1
|
+
import { C as CoderOutput, b as CoderTask } from './coder-CEkUFv8h.js';
|
|
2
|
+
import { g as LoopTraceEmitter, e as LoopTraceEvent, S as SandboxClient, A as AgentRunSpec } from './types-C8rNlxfV.js';
|
|
3
3
|
import { SandboxEvent, SandboxInstance } from '@tangle-network/sandbox';
|
|
4
4
|
import { AgentEvalError } from '@tangle-network/agent-eval';
|
|
5
5
|
import { a as UiLens, U as UiFinding } from './substrate-CUgk7F7s.js';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* @experimental
|
|
9
|
-
*
|
|
10
|
-
* Persistence port for the MCP delegation queue.
|
|
11
|
-
*
|
|
12
|
-
* `DelegationTaskQueue` keeps its working set in memory (status/history
|
|
13
|
-
* reads stay synchronous) and journals every record mutation through a
|
|
14
|
-
* `DelegationStore`. `DelegationTaskQueue.restore({ store })` is the load
|
|
15
|
-
* path: it reads the full record set once at construction and rehydrates
|
|
16
|
-
* the queue from it. After that the store only sees writes.
|
|
17
|
-
*
|
|
18
|
-
* Records MUST be JSON-safe — `FileDelegationStore` round-trips them
|
|
19
|
-
* through `JSON.stringify`/`JSON.parse`, so a `Date`, `Map`, or function
|
|
20
|
-
* smuggled into `args`/`result` would corrupt the journal.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/** @experimental */
|
|
24
|
-
interface DelegationStore {
|
|
25
|
-
/**
|
|
26
|
-
* Read every persisted record. Called once, by
|
|
27
|
-
* `DelegationTaskQueue.restore`, before any write. A missing backing
|
|
28
|
-
* file is an empty store; an unparseable one throws
|
|
29
|
-
* `DelegationStateCorruptError`.
|
|
30
|
-
*/
|
|
31
|
-
loadAll(): Promise<DelegationRecord[]>;
|
|
32
|
-
/** Insert or replace the record keyed by `record.taskId`. */
|
|
33
|
-
upsert(record: DelegationRecord): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Resolve an idempotency key to the taskId that claimed it, if any.
|
|
36
|
-
* The queue serves submit-time dedupe from its rehydrated in-memory
|
|
37
|
-
* index; this read exists for consumers that share a store across
|
|
38
|
-
* processes without holding the full record set.
|
|
39
|
-
*/
|
|
40
|
-
lookupIdempotencyKey(key: string): Promise<string | undefined>;
|
|
41
|
-
/** Delete the named records — the retention-cap eviction path. */
|
|
42
|
-
remove(taskIds: readonly string[]): Promise<void>;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* The persisted delegation state exists but cannot be parsed into
|
|
46
|
-
* records. Fail loud: silently starting empty over a corrupt journal
|
|
47
|
-
* would erase delegation history and re-run idempotent work. Opt into
|
|
48
|
-
* recovery explicitly via `FileDelegationStoreOptions.recoverCorrupt`
|
|
49
|
-
* (the bin maps `AGENT_RUNTIME_DELEGATION_STATE_RECOVER=1` onto it),
|
|
50
|
-
* which archives the corrupt file and starts fresh.
|
|
51
|
-
*
|
|
52
|
-
* @experimental
|
|
53
|
-
*/
|
|
54
|
-
declare class DelegationStateCorruptError extends AgentEvalError {
|
|
55
|
-
constructor(message: string, options?: {
|
|
56
|
-
cause?: unknown;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* A delegation-store read or write failed (filesystem error, store
|
|
61
|
-
* called before `loadAll`, ...). Once the queue observes one, it stops
|
|
62
|
-
* accepting new submissions — accepting work it cannot journal would
|
|
63
|
-
* silently demote durable mode to in-memory mode.
|
|
64
|
-
*
|
|
65
|
-
* @experimental
|
|
66
|
-
*/
|
|
67
|
-
declare class DelegationPersistenceError extends AgentEvalError {
|
|
68
|
-
constructor(message: string, options?: {
|
|
69
|
-
cause?: unknown;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
/** @experimental */
|
|
73
|
-
declare class InMemoryDelegationStore implements DelegationStore {
|
|
74
|
-
private readonly records;
|
|
75
|
-
loadAll(): Promise<DelegationRecord[]>;
|
|
76
|
-
upsert(record: DelegationRecord): Promise<void>;
|
|
77
|
-
lookupIdempotencyKey(key: string): Promise<string | undefined>;
|
|
78
|
-
remove(taskIds: readonly string[]): Promise<void>;
|
|
79
|
-
}
|
|
80
|
-
/** @experimental */
|
|
81
|
-
interface FileDelegationStoreOptions {
|
|
82
|
-
/** Absolute path of the JSON state file. Parent directories are created on first write. */
|
|
83
|
-
filePath: string;
|
|
84
|
-
/**
|
|
85
|
-
* When the state file exists but cannot be parsed, archive it to
|
|
86
|
-
* `<filePath>.corrupt-<timestamp>` and start empty instead of
|
|
87
|
-
* throwing `DelegationStateCorruptError`. Default false.
|
|
88
|
-
*/
|
|
89
|
-
recoverCorrupt?: boolean;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* JSON-file persistence for the delegation queue. Each write serializes
|
|
93
|
-
* the full record set and lands it atomically (write to a sibling tmp
|
|
94
|
-
* file, then `rename`), so readers never observe a torn file — a crash
|
|
95
|
-
* mid-write leaves the previous snapshot intact. Writes are serialized
|
|
96
|
-
* internally; concurrent `upsert`/`remove` calls cannot interleave.
|
|
97
|
-
*
|
|
98
|
-
* Built for the MCP server's scale (one stdio process, hundreds of
|
|
99
|
-
* records): full-snapshot writes keep the format trivially inspectable
|
|
100
|
-
* and corruption-detectable without a database dependency.
|
|
101
|
-
*
|
|
102
|
-
* @experimental
|
|
103
|
-
*/
|
|
104
|
-
declare class FileDelegationStore implements DelegationStore {
|
|
105
|
-
private readonly filePath;
|
|
106
|
-
private readonly recoverCorrupt;
|
|
107
|
-
private readonly records;
|
|
108
|
-
private loaded;
|
|
109
|
-
private writeTail;
|
|
110
|
-
private tmpSeq;
|
|
111
|
-
constructor(options: FileDelegationStoreOptions);
|
|
112
|
-
loadAll(): Promise<DelegationRecord[]>;
|
|
113
|
-
upsert(record: DelegationRecord): Promise<void>;
|
|
114
|
-
lookupIdempotencyKey(key: string): Promise<string | undefined>;
|
|
115
|
-
remove(taskIds: readonly string[]): Promise<void>;
|
|
116
|
-
private assertLoaded;
|
|
117
|
-
private enqueueWrite;
|
|
118
|
-
private writeSnapshot;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
7
|
/**
|
|
122
8
|
* @experimental
|
|
123
9
|
*
|
|
@@ -209,16 +95,418 @@ interface DelegationTraceCollector {
|
|
|
209
95
|
settle(): void;
|
|
210
96
|
}
|
|
211
97
|
/** @experimental */
|
|
212
|
-
declare function createDelegationTraceCollector(onSpans: (spans: DelegationTraceSpan[]) => void): DelegationTraceCollector;
|
|
98
|
+
declare function createDelegationTraceCollector(onSpans: (spans: DelegationTraceSpan[]) => void): DelegationTraceCollector;
|
|
99
|
+
/**
|
|
100
|
+
* Fan one `LoopTraceEvent` stream into several emitters — e.g. the
|
|
101
|
+
* process-wide OTEL exporter AND the per-delegation journal collector.
|
|
102
|
+
* `undefined` entries are skipped; returns `undefined` when nothing is left
|
|
103
|
+
* so callers keep the kernel's "no emitter, no events" fast path.
|
|
104
|
+
*
|
|
105
|
+
* @experimental
|
|
106
|
+
*/
|
|
107
|
+
declare function composeLoopTraceEmitters(...emitters: ReadonlyArray<LoopTraceEmitter | undefined>): LoopTraceEmitter | undefined;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @experimental
|
|
111
|
+
*
|
|
112
|
+
* MCP delegation tool surface — the typed inputs/outputs the product agent
|
|
113
|
+
* sees over the wire. These types are the contract; the JSON schemas under
|
|
114
|
+
* `tools/*` mirror them for the MCP `tools/list` advertisement.
|
|
115
|
+
*
|
|
116
|
+
* Async semantics: `delegate_code` + `delegate_research` return a `taskId`
|
|
117
|
+
* immediately. The product agent polls `delegation_status` until the task
|
|
118
|
+
* transitions to `completed` | `failed` | `cancelled`. `delegate_feedback`
|
|
119
|
+
* + `delegation_history` are synchronous reads / writes against the local
|
|
120
|
+
* task queue + feedback store.
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
/** @experimental */
|
|
124
|
+
type DelegationProfile = 'coder' | 'researcher' | 'ui-auditor';
|
|
125
|
+
/** @experimental */
|
|
126
|
+
type DelegationStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
127
|
+
/**
|
|
128
|
+
* Minimal `CoderTask` overrides exposed over the MCP wire. The full
|
|
129
|
+
* `CoderTask` carries fields the kernel synthesizes from `goal` +
|
|
130
|
+
* `repoRoot` — the agent only edits the few that materially gate
|
|
131
|
+
* validator behavior.
|
|
132
|
+
*
|
|
133
|
+
* @experimental
|
|
134
|
+
*/
|
|
135
|
+
interface DelegateCodeConfig {
|
|
136
|
+
testCmd?: string;
|
|
137
|
+
typecheckCmd?: string;
|
|
138
|
+
forbiddenPaths?: string[];
|
|
139
|
+
maxDiffLines?: number;
|
|
140
|
+
}
|
|
141
|
+
/** @experimental */
|
|
142
|
+
interface DelegateCodeArgs {
|
|
143
|
+
/** Natural-language description of what the coder must accomplish. */
|
|
144
|
+
goal: string;
|
|
145
|
+
/** Absolute path inside the sandbox where the repo lives. */
|
|
146
|
+
repoRoot: string;
|
|
147
|
+
/** Optional free-form context the agent surfaces in the prompt prelude. */
|
|
148
|
+
contextHint?: string;
|
|
149
|
+
/**
|
|
150
|
+
* When > 1, dispatches `multiHarnessCoderFanout` across N harnesses
|
|
151
|
+
* (claude-code, codex, opencode-glm) and picks the highest-scoring
|
|
152
|
+
* passing patch. Default 1.
|
|
153
|
+
*/
|
|
154
|
+
variants?: number;
|
|
155
|
+
/** Validator + prompt overrides the agent knows for this repo. */
|
|
156
|
+
config?: DelegateCodeConfig;
|
|
157
|
+
/** Multi-tenant scope (customer-id, workspace-id). */
|
|
158
|
+
namespace?: string;
|
|
159
|
+
}
|
|
160
|
+
/** @experimental */
|
|
161
|
+
interface DelegateCodeResult {
|
|
162
|
+
taskId: string;
|
|
163
|
+
/** Best-effort hint — coder loops can take minutes-to-hours. */
|
|
164
|
+
estimatedDurationMs?: number;
|
|
165
|
+
}
|
|
166
|
+
/** @experimental */
|
|
167
|
+
type ResearchSource = 'web' | 'corpus' | 'twitter' | 'github' | 'docs';
|
|
168
|
+
/** @experimental */
|
|
169
|
+
interface DelegateResearchConfig {
|
|
170
|
+
recencyWindow?: {
|
|
171
|
+
since?: string;
|
|
172
|
+
until?: string;
|
|
173
|
+
};
|
|
174
|
+
maxItems?: number;
|
|
175
|
+
minConfidence?: number;
|
|
176
|
+
}
|
|
177
|
+
/** @experimental */
|
|
178
|
+
interface DelegateResearchArgs {
|
|
179
|
+
question: string;
|
|
180
|
+
namespace: string;
|
|
181
|
+
scope?: string;
|
|
182
|
+
sources?: ResearchSource[];
|
|
183
|
+
variants?: number;
|
|
184
|
+
config?: DelegateResearchConfig;
|
|
185
|
+
}
|
|
186
|
+
/** @experimental */
|
|
187
|
+
interface DelegateResearchResult {
|
|
188
|
+
taskId: string;
|
|
189
|
+
estimatedDurationMs?: number;
|
|
190
|
+
}
|
|
191
|
+
/** @experimental */
|
|
192
|
+
interface FeedbackRefersTo {
|
|
193
|
+
kind: 'delegation' | 'artifact' | 'outcome';
|
|
194
|
+
/** For `'delegation'`, this is the taskId. */
|
|
195
|
+
ref: string;
|
|
196
|
+
}
|
|
197
|
+
/** @experimental */
|
|
198
|
+
interface FeedbackRating {
|
|
199
|
+
/** [0, 1]. */
|
|
200
|
+
score: number;
|
|
201
|
+
label?: 'good' | 'bad' | 'neutral' | 'mixed';
|
|
202
|
+
notes: string;
|
|
203
|
+
}
|
|
204
|
+
/** @experimental */
|
|
205
|
+
interface DelegateFeedbackArgs {
|
|
206
|
+
refersTo: FeedbackRefersTo;
|
|
207
|
+
rating: FeedbackRating;
|
|
208
|
+
by: 'agent' | 'user' | 'downstream-judge';
|
|
209
|
+
/** ISO timestamp; defaults to server clock when omitted. */
|
|
210
|
+
capturedAt?: string;
|
|
211
|
+
namespace?: string;
|
|
212
|
+
}
|
|
213
|
+
/** @experimental */
|
|
214
|
+
interface DelegateFeedbackResult {
|
|
215
|
+
recorded: true;
|
|
216
|
+
id: string;
|
|
217
|
+
}
|
|
218
|
+
/** @experimental */
|
|
219
|
+
interface DelegationStatusArgs {
|
|
220
|
+
taskId: string;
|
|
221
|
+
/**
|
|
222
|
+
* Return the delegation's compact loop-trace span tree alongside the
|
|
223
|
+
* status. Default false — status polls stay light; opt in when you need
|
|
224
|
+
* the topology (which iterations ran, where they were placed, what each
|
|
225
|
+
* cost) rather than just the state machine.
|
|
226
|
+
*/
|
|
227
|
+
includeTrace?: boolean;
|
|
228
|
+
}
|
|
229
|
+
/** @experimental */
|
|
230
|
+
interface DelegationProgress {
|
|
231
|
+
iteration: number;
|
|
232
|
+
phase: string;
|
|
233
|
+
}
|
|
234
|
+
/** @experimental */
|
|
235
|
+
interface DelegationError {
|
|
236
|
+
message: string;
|
|
237
|
+
kind: string;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Polymorphic `result` field: `CoderOutput` when the underlying profile
|
|
241
|
+
* is `'coder'`, a structurally-typed research output when `'researcher'`.
|
|
242
|
+
* The MCP wire carries it as JSON either way.
|
|
243
|
+
*
|
|
244
|
+
* @experimental
|
|
245
|
+
*/
|
|
246
|
+
type DelegationResultPayload = {
|
|
247
|
+
profile: 'coder';
|
|
248
|
+
output: CoderOutput;
|
|
249
|
+
} | {
|
|
250
|
+
profile: 'researcher';
|
|
251
|
+
output: ResearchOutputShape;
|
|
252
|
+
} | {
|
|
253
|
+
profile: 'ui-auditor';
|
|
254
|
+
output: UiAuditorDelegationOutput;
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Wire-shape of a completed UI-audit delegation. The `findings` array
|
|
258
|
+
* contains every finding persisted to the workspace during the run,
|
|
259
|
+
* already enriched with `id` and `createdAt` by the writer. `workspaceDir`
|
|
260
|
+
* is the absolute path to the workspace; `indexFile` is the workspace-
|
|
261
|
+
* relative path to the regenerated index.md.
|
|
262
|
+
*
|
|
263
|
+
* @experimental
|
|
264
|
+
*/
|
|
265
|
+
interface UiAuditorDelegationOutput {
|
|
266
|
+
workspaceDir: string;
|
|
267
|
+
indexFile: string;
|
|
268
|
+
findings: UiFinding[];
|
|
269
|
+
/** Total iterations the loop ran for this delegation. */
|
|
270
|
+
iterations: number;
|
|
271
|
+
}
|
|
272
|
+
/** @experimental */
|
|
273
|
+
type UiAuditLensFilter = readonly UiLens[];
|
|
274
|
+
/** Optional per-route capture spec the agent surfaces over the wire. */
|
|
275
|
+
interface DelegateUiAuditRoute {
|
|
276
|
+
/** Stable route name (used in screenshot filenames + finding metadata). */
|
|
277
|
+
name: string;
|
|
278
|
+
/** Fully-qualified URL. */
|
|
279
|
+
url: string;
|
|
280
|
+
/** Viewports to capture at. Defaults to `[{ width: 1280, height: 800 }]`. */
|
|
281
|
+
viewports?: readonly {
|
|
282
|
+
width: number;
|
|
283
|
+
height: number;
|
|
284
|
+
}[];
|
|
285
|
+
/** Default false. Full-page captures for the broad lenses. */
|
|
286
|
+
fullPage?: boolean;
|
|
287
|
+
/** Selector to wait for before capture. */
|
|
288
|
+
waitFor?: string;
|
|
289
|
+
}
|
|
290
|
+
/** @experimental */
|
|
291
|
+
interface DelegateUiAuditConfig {
|
|
292
|
+
/**
|
|
293
|
+
* Lenses to iterate. Default: every lens except `'other'`. Order is
|
|
294
|
+
* preserved — the driver iterates lens-by-lens.
|
|
295
|
+
*/
|
|
296
|
+
lenses?: UiAuditLensFilter;
|
|
297
|
+
/** Maximum total iterations across all (lens × route) pairs. Default 33 (11 lenses × 3 routes). */
|
|
298
|
+
maxIterations?: number;
|
|
299
|
+
/** Maximum concurrent iterations within a single plan() round. Default 2. */
|
|
300
|
+
maxConcurrency?: number;
|
|
301
|
+
/** Free-form product context surfaced to the judge. */
|
|
302
|
+
productContext?: string;
|
|
303
|
+
}
|
|
304
|
+
/** @experimental */
|
|
305
|
+
interface DelegateUiAuditArgs {
|
|
306
|
+
/** Workspace root for the audit (absolute path). */
|
|
307
|
+
workspaceDir: string;
|
|
308
|
+
/** Routes to audit. Must be non-empty. */
|
|
309
|
+
routes: readonly DelegateUiAuditRoute[];
|
|
310
|
+
/** Multi-tenant scope. */
|
|
311
|
+
namespace?: string;
|
|
312
|
+
config?: DelegateUiAuditConfig;
|
|
313
|
+
}
|
|
314
|
+
/** @experimental */
|
|
315
|
+
interface DelegateUiAuditResult {
|
|
316
|
+
taskId: string;
|
|
317
|
+
estimatedDurationMs?: number;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Loose shape of a research output over the wire — the substrate cannot
|
|
321
|
+
* import the `ResearchOutput` type from agent-knowledge without inducing
|
|
322
|
+
* a dependency cycle, so the MCP layer treats it structurally.
|
|
323
|
+
*
|
|
324
|
+
* @experimental
|
|
325
|
+
*/
|
|
326
|
+
interface ResearchOutputShape {
|
|
327
|
+
items: unknown[];
|
|
328
|
+
citations: unknown[];
|
|
329
|
+
proposedWrites: unknown[];
|
|
330
|
+
gaps?: string[];
|
|
331
|
+
notes?: string;
|
|
332
|
+
[key: string]: unknown;
|
|
333
|
+
}
|
|
334
|
+
/** @experimental */
|
|
335
|
+
interface DelegationStatusResult {
|
|
336
|
+
taskId: string;
|
|
337
|
+
profile: DelegationProfile;
|
|
338
|
+
status: DelegationStatus;
|
|
339
|
+
progress?: DelegationProgress;
|
|
340
|
+
result?: DelegationResultPayload;
|
|
341
|
+
error?: DelegationError;
|
|
342
|
+
costUsd?: number;
|
|
343
|
+
startedAt: string;
|
|
344
|
+
completedAt?: string;
|
|
345
|
+
/** Compact loop-trace span tree; present only when `includeTrace: true` was passed and spans were recorded. */
|
|
346
|
+
trace?: DelegationTraceSpan[];
|
|
347
|
+
/** Present when oldest trace spans were dropped to honor the trace caps. */
|
|
348
|
+
traceTruncated?: true;
|
|
349
|
+
/** Inherited trace identity recorded at submit — join key into the caller's trace. */
|
|
350
|
+
traceId?: string;
|
|
351
|
+
/** Caller span that dispatched the delegation, when one was inherited. */
|
|
352
|
+
parentSpanId?: string;
|
|
353
|
+
}
|
|
354
|
+
/** @experimental */
|
|
355
|
+
interface DelegationHistoryArgs {
|
|
356
|
+
namespace?: string;
|
|
357
|
+
profile?: DelegationProfile;
|
|
358
|
+
/** ISO date — only delegations started at-or-after `since` are returned. */
|
|
359
|
+
since?: string;
|
|
360
|
+
/** Default 50. Hard cap 500. */
|
|
361
|
+
limit?: number;
|
|
362
|
+
}
|
|
363
|
+
/** @experimental */
|
|
364
|
+
interface DelegationFeedbackSnapshot {
|
|
365
|
+
id: string;
|
|
366
|
+
score: number;
|
|
367
|
+
label?: FeedbackRating['label'];
|
|
368
|
+
by: DelegateFeedbackArgs['by'];
|
|
369
|
+
notes: string;
|
|
370
|
+
capturedAt: string;
|
|
371
|
+
}
|
|
372
|
+
/** @experimental */
|
|
373
|
+
interface DelegationHistoryEntry {
|
|
374
|
+
taskId: string;
|
|
375
|
+
profile: DelegationProfile;
|
|
376
|
+
namespace?: string;
|
|
377
|
+
args: DelegateCodeArgs | DelegateResearchArgs | DelegateUiAuditArgs;
|
|
378
|
+
status: DelegationStatus;
|
|
379
|
+
feedback?: DelegationFeedbackSnapshot[];
|
|
380
|
+
costUsd?: number;
|
|
381
|
+
startedAt: string;
|
|
382
|
+
completedAt?: string;
|
|
383
|
+
/**
|
|
384
|
+
* True when the record carries a journaled loop trace. History stays
|
|
385
|
+
* light by design — fetch the spans via
|
|
386
|
+
* `delegation_status { taskId, includeTrace: true }`.
|
|
387
|
+
*/
|
|
388
|
+
hasTrace: boolean;
|
|
389
|
+
/** Inherited trace identity recorded at submit — join key into the caller's trace. */
|
|
390
|
+
traceId?: string;
|
|
391
|
+
}
|
|
392
|
+
/** @experimental */
|
|
393
|
+
interface DelegationHistoryResult {
|
|
394
|
+
delegations: DelegationHistoryEntry[];
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* @experimental
|
|
399
|
+
*
|
|
400
|
+
* Persistence port for the MCP delegation queue.
|
|
401
|
+
*
|
|
402
|
+
* `DelegationTaskQueue` keeps its working set in memory (status/history
|
|
403
|
+
* reads stay synchronous) and journals every record mutation through a
|
|
404
|
+
* `DelegationStore`. `DelegationTaskQueue.restore({ store })` is the load
|
|
405
|
+
* path: it reads the full record set once at construction and rehydrates
|
|
406
|
+
* the queue from it. After that the store only sees writes.
|
|
407
|
+
*
|
|
408
|
+
* Records MUST be JSON-safe — `FileDelegationStore` round-trips them
|
|
409
|
+
* through `JSON.stringify`/`JSON.parse`, so a `Date`, `Map`, or function
|
|
410
|
+
* smuggled into `args`/`result` would corrupt the journal.
|
|
411
|
+
*/
|
|
412
|
+
|
|
413
|
+
/** @experimental */
|
|
414
|
+
interface DelegationStore {
|
|
415
|
+
/**
|
|
416
|
+
* Read every persisted record. Called once, by
|
|
417
|
+
* `DelegationTaskQueue.restore`, before any write. A missing backing
|
|
418
|
+
* file is an empty store; an unparseable one throws
|
|
419
|
+
* `DelegationStateCorruptError`.
|
|
420
|
+
*/
|
|
421
|
+
loadAll(): Promise<DelegationRecord[]>;
|
|
422
|
+
/** Insert or replace the record keyed by `record.taskId`. */
|
|
423
|
+
upsert(record: DelegationRecord): Promise<void>;
|
|
424
|
+
/**
|
|
425
|
+
* Resolve an idempotency key to the taskId that claimed it, if any.
|
|
426
|
+
* The queue serves submit-time dedupe from its rehydrated in-memory
|
|
427
|
+
* index; this read exists for consumers that share a store across
|
|
428
|
+
* processes without holding the full record set.
|
|
429
|
+
*/
|
|
430
|
+
lookupIdempotencyKey(key: string): Promise<string | undefined>;
|
|
431
|
+
/** Delete the named records — the retention-cap eviction path. */
|
|
432
|
+
remove(taskIds: readonly string[]): Promise<void>;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* The persisted delegation state exists but cannot be parsed into
|
|
436
|
+
* records. Fail loud: silently starting empty over a corrupt journal
|
|
437
|
+
* would erase delegation history and re-run idempotent work. Opt into
|
|
438
|
+
* recovery explicitly via `FileDelegationStoreOptions.recoverCorrupt`
|
|
439
|
+
* (the bin maps `AGENT_RUNTIME_DELEGATION_STATE_RECOVER=1` onto it),
|
|
440
|
+
* which archives the corrupt file and starts fresh.
|
|
441
|
+
*
|
|
442
|
+
* @experimental
|
|
443
|
+
*/
|
|
444
|
+
declare class DelegationStateCorruptError extends AgentEvalError {
|
|
445
|
+
constructor(message: string, options?: {
|
|
446
|
+
cause?: unknown;
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* A delegation-store read or write failed (filesystem error, store
|
|
451
|
+
* called before `loadAll`, ...). Once the queue observes one, it stops
|
|
452
|
+
* accepting new submissions — accepting work it cannot journal would
|
|
453
|
+
* silently demote durable mode to in-memory mode.
|
|
454
|
+
*
|
|
455
|
+
* @experimental
|
|
456
|
+
*/
|
|
457
|
+
declare class DelegationPersistenceError extends AgentEvalError {
|
|
458
|
+
constructor(message: string, options?: {
|
|
459
|
+
cause?: unknown;
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
/** @experimental */
|
|
463
|
+
declare class InMemoryDelegationStore implements DelegationStore {
|
|
464
|
+
private readonly records;
|
|
465
|
+
loadAll(): Promise<DelegationRecord[]>;
|
|
466
|
+
upsert(record: DelegationRecord): Promise<void>;
|
|
467
|
+
lookupIdempotencyKey(key: string): Promise<string | undefined>;
|
|
468
|
+
remove(taskIds: readonly string[]): Promise<void>;
|
|
469
|
+
}
|
|
470
|
+
/** @experimental */
|
|
471
|
+
interface FileDelegationStoreOptions {
|
|
472
|
+
/** Absolute path of the JSON state file. Parent directories are created on first write. */
|
|
473
|
+
filePath: string;
|
|
474
|
+
/**
|
|
475
|
+
* When the state file exists but cannot be parsed, archive it to
|
|
476
|
+
* `<filePath>.corrupt-<timestamp>` and start empty instead of
|
|
477
|
+
* throwing `DelegationStateCorruptError`. Default false.
|
|
478
|
+
*/
|
|
479
|
+
recoverCorrupt?: boolean;
|
|
480
|
+
}
|
|
213
481
|
/**
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
* `
|
|
217
|
-
*
|
|
482
|
+
* JSON-file persistence for the delegation queue. Each write serializes
|
|
483
|
+
* the full record set and lands it atomically (write to a sibling tmp
|
|
484
|
+
* file, then `rename`), so readers never observe a torn file — a crash
|
|
485
|
+
* mid-write leaves the previous snapshot intact. Writes are serialized
|
|
486
|
+
* internally; concurrent `upsert`/`remove` calls cannot interleave.
|
|
487
|
+
*
|
|
488
|
+
* Built for the MCP server's scale (one stdio process, hundreds of
|
|
489
|
+
* records): full-snapshot writes keep the format trivially inspectable
|
|
490
|
+
* and corruption-detectable without a database dependency.
|
|
218
491
|
*
|
|
219
492
|
* @experimental
|
|
220
493
|
*/
|
|
221
|
-
declare
|
|
494
|
+
declare class FileDelegationStore implements DelegationStore {
|
|
495
|
+
private readonly filePath;
|
|
496
|
+
private readonly recoverCorrupt;
|
|
497
|
+
private readonly records;
|
|
498
|
+
private loaded;
|
|
499
|
+
private writeTail;
|
|
500
|
+
private tmpSeq;
|
|
501
|
+
constructor(options: FileDelegationStoreOptions);
|
|
502
|
+
loadAll(): Promise<DelegationRecord[]>;
|
|
503
|
+
upsert(record: DelegationRecord): Promise<void>;
|
|
504
|
+
lookupIdempotencyKey(key: string): Promise<string | undefined>;
|
|
505
|
+
remove(taskIds: readonly string[]): Promise<void>;
|
|
506
|
+
private assertLoaded;
|
|
507
|
+
private enqueueWrite;
|
|
508
|
+
private writeSnapshot;
|
|
509
|
+
}
|
|
222
510
|
|
|
223
511
|
/**
|
|
224
512
|
* OTEL span exporter — streams LoopTraceEvents to an OTLP/HTTP collector.
|
|
@@ -354,386 +642,98 @@ interface EvalRunGeneration {
|
|
|
354
642
|
surface?: unknown;
|
|
355
643
|
/** Per-scenario results; empty until the generation is measured. */
|
|
356
644
|
cells?: unknown[];
|
|
357
|
-
/** Mean composite score (0 when unmeasured — pair with labels.measured). */
|
|
358
|
-
compositeMean: number;
|
|
359
|
-
costUsd: number;
|
|
360
|
-
durationMs: number;
|
|
361
|
-
}
|
|
362
|
-
interface EvalRunEvent {
|
|
363
|
-
runId: string;
|
|
364
|
-
runDir: string;
|
|
365
|
-
/** ISO timestamp. */
|
|
366
|
-
timestamp: string;
|
|
367
|
-
status: 'started' | 'baseline-complete' | 'generation-complete' | 'gate-decided' | 'finished' | 'errored';
|
|
368
|
-
labels?: Record<string, string>;
|
|
369
|
-
baseline?: EvalRunGeneration;
|
|
370
|
-
generations?: EvalRunGeneration[];
|
|
371
|
-
gateDecision?: 'ship' | 'hold' | 'need_more_work' | 'model_ceiling' | 'arch_ceiling';
|
|
372
|
-
holdoutLift?: number;
|
|
373
|
-
totalCostUsd: number;
|
|
374
|
-
totalDurationMs: number;
|
|
375
|
-
errorMessage?: string;
|
|
376
|
-
}
|
|
377
|
-
interface EvalRunsExportConfig {
|
|
378
|
-
/** Bearer key — tenant is resolved server-side from it. Reads TANGLE_API_KEY. */
|
|
379
|
-
apiKey?: string;
|
|
380
|
-
/** Intelligence base. Reads INTELLIGENCE_BASE env, else prod. */
|
|
381
|
-
base?: string;
|
|
382
|
-
/** Idempotency-Key header (e.g. the runId) — safe retries + upsert. */
|
|
383
|
-
idempotencyKey?: string;
|
|
384
|
-
}
|
|
385
|
-
interface EvalRunsExportResult {
|
|
386
|
-
ok: boolean;
|
|
387
|
-
status: number;
|
|
388
|
-
accepted: number;
|
|
389
|
-
rejected: Array<{
|
|
390
|
-
index: number;
|
|
391
|
-
reason: string;
|
|
392
|
-
}>;
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Ship self-improvement eval-run events to Tangle Intelligence. Unlike the
|
|
396
|
-
* best-effort span exporter, this RESOLVES with the ingest verdict (accepted /
|
|
397
|
-
* rejected per event) so a consumer's loop can assert its provenance landed.
|
|
398
|
-
* Throws only on a missing key or network failure.
|
|
399
|
-
*/
|
|
400
|
-
declare function exportEvalRuns(events: EvalRunEvent[], config?: EvalRunsExportConfig): Promise<EvalRunsExportResult>;
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* @experimental
|
|
404
|
-
*
|
|
405
|
-
* Trace context propagation for MCP subprocess.
|
|
406
|
-
*
|
|
407
|
-
* When the MCP server is launched as a child process by a sandbox harness,
|
|
408
|
-
* the parent passes trace context via environment variables:
|
|
409
|
-
*
|
|
410
|
-
* TRACE_ID=<current-run-trace-id>
|
|
411
|
-
* PARENT_SPAN_ID=<span-that-dispatched-the-delegation>
|
|
412
|
-
*
|
|
413
|
-
* The MCP server reads these at startup and uses them as the root of its
|
|
414
|
-
* internal trace tree. All spans emitted by `runLoop` invocations inside
|
|
415
|
-
* the MCP are children of the parent's delegation span.
|
|
416
|
-
*
|
|
417
|
-
* When these env vars are absent, the MCP generates a fresh trace root —
|
|
418
|
-
* the server operates standalone without trace joining.
|
|
419
|
-
*/
|
|
420
|
-
|
|
421
|
-
interface TraceContext {
|
|
422
|
-
/** Trace id inherited from the parent process, or a fresh one. */
|
|
423
|
-
traceId: string;
|
|
424
|
-
/** Parent span id from the delegation that launched this MCP server. */
|
|
425
|
-
parentSpanId?: string;
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Read trace context from the process environment.
|
|
429
|
-
* Returns a context with inherited ids or a freshly generated root.
|
|
430
|
-
*/
|
|
431
|
-
declare function readTraceContextFromEnv(): TraceContext;
|
|
432
|
-
/**
|
|
433
|
-
* Create a LoopTraceEmitter that:
|
|
434
|
-
* 1. Parents all spans under the inherited PARENT_SPAN_ID.
|
|
435
|
-
* 2. Exports spans to OTEL when OTEL_EXPORTER_OTLP_ENDPOINT is set.
|
|
436
|
-
*
|
|
437
|
-
* Returns both the emitter and the optional exporter handle for shutdown.
|
|
438
|
-
*/
|
|
439
|
-
declare function createPropagatingTraceEmitter(ctx: TraceContext): {
|
|
440
|
-
emitter: LoopTraceEmitter;
|
|
441
|
-
exporter: OtelExporter | undefined;
|
|
442
|
-
context: TraceContext;
|
|
443
|
-
};
|
|
444
|
-
/**
|
|
445
|
-
* Build env vars to pass to a child MCP subprocess so it inherits the
|
|
446
|
-
* current trace context.
|
|
447
|
-
*/
|
|
448
|
-
declare function traceContextToEnv(ctx: TraceContext): Record<string, string>;
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* @experimental
|
|
452
|
-
*
|
|
453
|
-
* MCP delegation tool surface — the typed inputs/outputs the product agent
|
|
454
|
-
* sees over the wire. These types are the contract; the JSON schemas under
|
|
455
|
-
* `tools/*` mirror them for the MCP `tools/list` advertisement.
|
|
456
|
-
*
|
|
457
|
-
* Async semantics: `delegate_code` + `delegate_research` return a `taskId`
|
|
458
|
-
* immediately. The product agent polls `delegation_status` until the task
|
|
459
|
-
* transitions to `completed` | `failed` | `cancelled`. `delegate_feedback`
|
|
460
|
-
* + `delegation_history` are synchronous reads / writes against the local
|
|
461
|
-
* task queue + feedback store.
|
|
462
|
-
*/
|
|
463
|
-
|
|
464
|
-
/** @experimental */
|
|
465
|
-
type DelegationProfile = 'coder' | 'researcher' | 'ui-auditor';
|
|
466
|
-
/** @experimental */
|
|
467
|
-
type DelegationStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
468
|
-
/**
|
|
469
|
-
* Minimal `CoderTask` overrides exposed over the MCP wire. The full
|
|
470
|
-
* `CoderTask` carries fields the kernel synthesizes from `goal` +
|
|
471
|
-
* `repoRoot` — the agent only edits the few that materially gate
|
|
472
|
-
* validator behavior.
|
|
473
|
-
*
|
|
474
|
-
* @experimental
|
|
475
|
-
*/
|
|
476
|
-
interface DelegateCodeConfig {
|
|
477
|
-
testCmd?: string;
|
|
478
|
-
typecheckCmd?: string;
|
|
479
|
-
forbiddenPaths?: string[];
|
|
480
|
-
maxDiffLines?: number;
|
|
481
|
-
}
|
|
482
|
-
/** @experimental */
|
|
483
|
-
interface DelegateCodeArgs {
|
|
484
|
-
/** Natural-language description of what the coder must accomplish. */
|
|
485
|
-
goal: string;
|
|
486
|
-
/** Absolute path inside the sandbox where the repo lives. */
|
|
487
|
-
repoRoot: string;
|
|
488
|
-
/** Optional free-form context the agent surfaces in the prompt prelude. */
|
|
489
|
-
contextHint?: string;
|
|
490
|
-
/**
|
|
491
|
-
* When > 1, dispatches `multiHarnessCoderFanout` across N harnesses
|
|
492
|
-
* (claude-code, codex, opencode-glm) and picks the highest-scoring
|
|
493
|
-
* passing patch. Default 1.
|
|
494
|
-
*/
|
|
495
|
-
variants?: number;
|
|
496
|
-
/** Validator + prompt overrides the agent knows for this repo. */
|
|
497
|
-
config?: DelegateCodeConfig;
|
|
498
|
-
/** Multi-tenant scope (customer-id, workspace-id). */
|
|
499
|
-
namespace?: string;
|
|
500
|
-
}
|
|
501
|
-
/** @experimental */
|
|
502
|
-
interface DelegateCodeResult {
|
|
503
|
-
taskId: string;
|
|
504
|
-
/** Best-effort hint — coder loops can take minutes-to-hours. */
|
|
505
|
-
estimatedDurationMs?: number;
|
|
506
|
-
}
|
|
507
|
-
/** @experimental */
|
|
508
|
-
type ResearchSource = 'web' | 'corpus' | 'twitter' | 'github' | 'docs';
|
|
509
|
-
/** @experimental */
|
|
510
|
-
interface DelegateResearchConfig {
|
|
511
|
-
recencyWindow?: {
|
|
512
|
-
since?: string;
|
|
513
|
-
until?: string;
|
|
514
|
-
};
|
|
515
|
-
maxItems?: number;
|
|
516
|
-
minConfidence?: number;
|
|
517
|
-
}
|
|
518
|
-
/** @experimental */
|
|
519
|
-
interface DelegateResearchArgs {
|
|
520
|
-
question: string;
|
|
521
|
-
namespace: string;
|
|
522
|
-
scope?: string;
|
|
523
|
-
sources?: ResearchSource[];
|
|
524
|
-
variants?: number;
|
|
525
|
-
config?: DelegateResearchConfig;
|
|
526
|
-
}
|
|
527
|
-
/** @experimental */
|
|
528
|
-
interface DelegateResearchResult {
|
|
529
|
-
taskId: string;
|
|
530
|
-
estimatedDurationMs?: number;
|
|
531
|
-
}
|
|
532
|
-
/** @experimental */
|
|
533
|
-
interface FeedbackRefersTo {
|
|
534
|
-
kind: 'delegation' | 'artifact' | 'outcome';
|
|
535
|
-
/** For `'delegation'`, this is the taskId. */
|
|
536
|
-
ref: string;
|
|
537
|
-
}
|
|
538
|
-
/** @experimental */
|
|
539
|
-
interface FeedbackRating {
|
|
540
|
-
/** [0, 1]. */
|
|
541
|
-
score: number;
|
|
542
|
-
label?: 'good' | 'bad' | 'neutral' | 'mixed';
|
|
543
|
-
notes: string;
|
|
544
|
-
}
|
|
545
|
-
/** @experimental */
|
|
546
|
-
interface DelegateFeedbackArgs {
|
|
547
|
-
refersTo: FeedbackRefersTo;
|
|
548
|
-
rating: FeedbackRating;
|
|
549
|
-
by: 'agent' | 'user' | 'downstream-judge';
|
|
550
|
-
/** ISO timestamp; defaults to server clock when omitted. */
|
|
551
|
-
capturedAt?: string;
|
|
552
|
-
namespace?: string;
|
|
553
|
-
}
|
|
554
|
-
/** @experimental */
|
|
555
|
-
interface DelegateFeedbackResult {
|
|
556
|
-
recorded: true;
|
|
557
|
-
id: string;
|
|
558
|
-
}
|
|
559
|
-
/** @experimental */
|
|
560
|
-
interface DelegationStatusArgs {
|
|
561
|
-
taskId: string;
|
|
562
|
-
/**
|
|
563
|
-
* Return the delegation's compact loop-trace span tree alongside the
|
|
564
|
-
* status. Default false — status polls stay light; opt in when you need
|
|
565
|
-
* the topology (which iterations ran, where they were placed, what each
|
|
566
|
-
* cost) rather than just the state machine.
|
|
567
|
-
*/
|
|
568
|
-
includeTrace?: boolean;
|
|
645
|
+
/** Mean composite score (0 when unmeasured — pair with labels.measured). */
|
|
646
|
+
compositeMean: number;
|
|
647
|
+
costUsd: number;
|
|
648
|
+
durationMs: number;
|
|
569
649
|
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
650
|
+
interface EvalRunEvent {
|
|
651
|
+
runId: string;
|
|
652
|
+
runDir: string;
|
|
653
|
+
/** ISO timestamp. */
|
|
654
|
+
timestamp: string;
|
|
655
|
+
status: 'started' | 'baseline-complete' | 'generation-complete' | 'gate-decided' | 'finished' | 'errored';
|
|
656
|
+
labels?: Record<string, string>;
|
|
657
|
+
baseline?: EvalRunGeneration;
|
|
658
|
+
generations?: EvalRunGeneration[];
|
|
659
|
+
gateDecision?: 'ship' | 'hold' | 'need_more_work' | 'model_ceiling' | 'arch_ceiling';
|
|
660
|
+
holdoutLift?: number;
|
|
661
|
+
totalCostUsd: number;
|
|
662
|
+
totalDurationMs: number;
|
|
663
|
+
errorMessage?: string;
|
|
574
664
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
665
|
+
interface EvalRunsExportConfig {
|
|
666
|
+
/** Bearer key — tenant is resolved server-side from it. Reads TANGLE_API_KEY. */
|
|
667
|
+
apiKey?: string;
|
|
668
|
+
/** Intelligence base. Reads INTELLIGENCE_BASE env, else prod. */
|
|
669
|
+
base?: string;
|
|
670
|
+
/** Idempotency-Key header (e.g. the runId) — safe retries + upsert. */
|
|
671
|
+
idempotencyKey?: string;
|
|
672
|
+
}
|
|
673
|
+
interface EvalRunsExportResult {
|
|
674
|
+
ok: boolean;
|
|
675
|
+
status: number;
|
|
676
|
+
accepted: number;
|
|
677
|
+
rejected: Array<{
|
|
678
|
+
index: number;
|
|
679
|
+
reason: string;
|
|
680
|
+
}>;
|
|
579
681
|
}
|
|
580
682
|
/**
|
|
581
|
-
*
|
|
582
|
-
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
* @experimental
|
|
683
|
+
* Ship self-improvement eval-run events to Tangle Intelligence. Unlike the
|
|
684
|
+
* best-effort span exporter, this RESOLVES with the ingest verdict (accepted /
|
|
685
|
+
* rejected per event) so a consumer's loop can assert its provenance landed.
|
|
686
|
+
* Throws only on a missing key or network failure.
|
|
586
687
|
*/
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
output: CoderOutput;
|
|
590
|
-
} | {
|
|
591
|
-
profile: 'researcher';
|
|
592
|
-
output: ResearchOutputShape;
|
|
593
|
-
} | {
|
|
594
|
-
profile: 'ui-auditor';
|
|
595
|
-
output: UiAuditorDelegationOutput;
|
|
596
|
-
};
|
|
688
|
+
declare function exportEvalRuns(events: EvalRunEvent[], config?: EvalRunsExportConfig): Promise<EvalRunsExportResult>;
|
|
689
|
+
|
|
597
690
|
/**
|
|
598
|
-
* Wire-shape of a completed UI-audit delegation. The `findings` array
|
|
599
|
-
* contains every finding persisted to the workspace during the run,
|
|
600
|
-
* already enriched with `id` and `createdAt` by the writer. `workspaceDir`
|
|
601
|
-
* is the absolute path to the workspace; `indexFile` is the workspace-
|
|
602
|
-
* relative path to the regenerated index.md.
|
|
603
|
-
*
|
|
604
691
|
* @experimental
|
|
692
|
+
*
|
|
693
|
+
* Trace context propagation for MCP subprocess.
|
|
694
|
+
*
|
|
695
|
+
* When the MCP server is launched as a child process by a sandbox harness,
|
|
696
|
+
* the parent passes trace context via environment variables:
|
|
697
|
+
*
|
|
698
|
+
* TRACE_ID=<current-run-trace-id>
|
|
699
|
+
* PARENT_SPAN_ID=<span-that-dispatched-the-delegation>
|
|
700
|
+
*
|
|
701
|
+
* The MCP server reads these at startup and uses them as the root of its
|
|
702
|
+
* internal trace tree. All spans emitted by `runLoop` invocations inside
|
|
703
|
+
* the MCP are children of the parent's delegation span.
|
|
704
|
+
*
|
|
705
|
+
* When these env vars are absent, the MCP generates a fresh trace root —
|
|
706
|
+
* the server operates standalone without trace joining.
|
|
605
707
|
*/
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
/**
|
|
611
|
-
|
|
612
|
-
}
|
|
613
|
-
/** @experimental */
|
|
614
|
-
type UiAuditLensFilter = readonly UiLens[];
|
|
615
|
-
/** Optional per-route capture spec the agent surfaces over the wire. */
|
|
616
|
-
interface DelegateUiAuditRoute {
|
|
617
|
-
/** Stable route name (used in screenshot filenames + finding metadata). */
|
|
618
|
-
name: string;
|
|
619
|
-
/** Fully-qualified URL. */
|
|
620
|
-
url: string;
|
|
621
|
-
/** Viewports to capture at. Defaults to `[{ width: 1280, height: 800 }]`. */
|
|
622
|
-
viewports?: readonly {
|
|
623
|
-
width: number;
|
|
624
|
-
height: number;
|
|
625
|
-
}[];
|
|
626
|
-
/** Default false. Full-page captures for the broad lenses. */
|
|
627
|
-
fullPage?: boolean;
|
|
628
|
-
/** Selector to wait for before capture. */
|
|
629
|
-
waitFor?: string;
|
|
630
|
-
}
|
|
631
|
-
/** @experimental */
|
|
632
|
-
interface DelegateUiAuditConfig {
|
|
633
|
-
/**
|
|
634
|
-
* Lenses to iterate. Default: every lens except `'other'`. Order is
|
|
635
|
-
* preserved — the driver iterates lens-by-lens.
|
|
636
|
-
*/
|
|
637
|
-
lenses?: UiAuditLensFilter;
|
|
638
|
-
/** Maximum total iterations across all (lens × route) pairs. Default 33 (11 lenses × 3 routes). */
|
|
639
|
-
maxIterations?: number;
|
|
640
|
-
/** Maximum concurrent iterations within a single plan() round. Default 2. */
|
|
641
|
-
maxConcurrency?: number;
|
|
642
|
-
/** Free-form product context surfaced to the judge. */
|
|
643
|
-
productContext?: string;
|
|
644
|
-
}
|
|
645
|
-
/** @experimental */
|
|
646
|
-
interface DelegateUiAuditArgs {
|
|
647
|
-
/** Workspace root for the audit (absolute path). */
|
|
648
|
-
workspaceDir: string;
|
|
649
|
-
/** Routes to audit. Must be non-empty. */
|
|
650
|
-
routes: readonly DelegateUiAuditRoute[];
|
|
651
|
-
/** Multi-tenant scope. */
|
|
652
|
-
namespace?: string;
|
|
653
|
-
config?: DelegateUiAuditConfig;
|
|
654
|
-
}
|
|
655
|
-
/** @experimental */
|
|
656
|
-
interface DelegateUiAuditResult {
|
|
657
|
-
taskId: string;
|
|
658
|
-
estimatedDurationMs?: number;
|
|
708
|
+
|
|
709
|
+
interface TraceContext {
|
|
710
|
+
/** Trace id inherited from the parent process, or a fresh one. */
|
|
711
|
+
traceId: string;
|
|
712
|
+
/** Parent span id from the delegation that launched this MCP server. */
|
|
713
|
+
parentSpanId?: string;
|
|
659
714
|
}
|
|
660
715
|
/**
|
|
661
|
-
*
|
|
662
|
-
*
|
|
663
|
-
|
|
716
|
+
* Read trace context from the process environment.
|
|
717
|
+
* Returns a context with inherited ids or a freshly generated root.
|
|
718
|
+
*/
|
|
719
|
+
declare function readTraceContextFromEnv(): TraceContext;
|
|
720
|
+
/**
|
|
721
|
+
* Create a LoopTraceEmitter that:
|
|
722
|
+
* 1. Parents all spans under the inherited PARENT_SPAN_ID.
|
|
723
|
+
* 2. Exports spans to OTEL when OTEL_EXPORTER_OTLP_ENDPOINT is set.
|
|
664
724
|
*
|
|
665
|
-
*
|
|
725
|
+
* Returns both the emitter and the optional exporter handle for shutdown.
|
|
666
726
|
*/
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
taskId: string;
|
|
678
|
-
profile: DelegationProfile;
|
|
679
|
-
status: DelegationStatus;
|
|
680
|
-
progress?: DelegationProgress;
|
|
681
|
-
result?: DelegationResultPayload;
|
|
682
|
-
error?: DelegationError;
|
|
683
|
-
costUsd?: number;
|
|
684
|
-
startedAt: string;
|
|
685
|
-
completedAt?: string;
|
|
686
|
-
/** Compact loop-trace span tree; present only when `includeTrace: true` was passed and spans were recorded. */
|
|
687
|
-
trace?: DelegationTraceSpan[];
|
|
688
|
-
/** Present when oldest trace spans were dropped to honor the trace caps. */
|
|
689
|
-
traceTruncated?: true;
|
|
690
|
-
/** Inherited trace identity recorded at submit — join key into the caller's trace. */
|
|
691
|
-
traceId?: string;
|
|
692
|
-
/** Caller span that dispatched the delegation, when one was inherited. */
|
|
693
|
-
parentSpanId?: string;
|
|
694
|
-
}
|
|
695
|
-
/** @experimental */
|
|
696
|
-
interface DelegationHistoryArgs {
|
|
697
|
-
namespace?: string;
|
|
698
|
-
profile?: DelegationProfile;
|
|
699
|
-
/** ISO date — only delegations started at-or-after `since` are returned. */
|
|
700
|
-
since?: string;
|
|
701
|
-
/** Default 50. Hard cap 500. */
|
|
702
|
-
limit?: number;
|
|
703
|
-
}
|
|
704
|
-
/** @experimental */
|
|
705
|
-
interface DelegationFeedbackSnapshot {
|
|
706
|
-
id: string;
|
|
707
|
-
score: number;
|
|
708
|
-
label?: FeedbackRating['label'];
|
|
709
|
-
by: DelegateFeedbackArgs['by'];
|
|
710
|
-
notes: string;
|
|
711
|
-
capturedAt: string;
|
|
712
|
-
}
|
|
713
|
-
/** @experimental */
|
|
714
|
-
interface DelegationHistoryEntry {
|
|
715
|
-
taskId: string;
|
|
716
|
-
profile: DelegationProfile;
|
|
717
|
-
namespace?: string;
|
|
718
|
-
args: DelegateCodeArgs | DelegateResearchArgs | DelegateUiAuditArgs;
|
|
719
|
-
status: DelegationStatus;
|
|
720
|
-
feedback?: DelegationFeedbackSnapshot[];
|
|
721
|
-
costUsd?: number;
|
|
722
|
-
startedAt: string;
|
|
723
|
-
completedAt?: string;
|
|
724
|
-
/**
|
|
725
|
-
* True when the record carries a journaled loop trace. History stays
|
|
726
|
-
* light by design — fetch the spans via
|
|
727
|
-
* `delegation_status { taskId, includeTrace: true }`.
|
|
728
|
-
*/
|
|
729
|
-
hasTrace: boolean;
|
|
730
|
-
/** Inherited trace identity recorded at submit — join key into the caller's trace. */
|
|
731
|
-
traceId?: string;
|
|
732
|
-
}
|
|
733
|
-
/** @experimental */
|
|
734
|
-
interface DelegationHistoryResult {
|
|
735
|
-
delegations: DelegationHistoryEntry[];
|
|
736
|
-
}
|
|
727
|
+
declare function createPropagatingTraceEmitter(ctx: TraceContext): {
|
|
728
|
+
emitter: LoopTraceEmitter;
|
|
729
|
+
exporter: OtelExporter | undefined;
|
|
730
|
+
context: TraceContext;
|
|
731
|
+
};
|
|
732
|
+
/**
|
|
733
|
+
* Build env vars to pass to a child MCP subprocess so it inherits the
|
|
734
|
+
* current trace context.
|
|
735
|
+
*/
|
|
736
|
+
declare function traceContextToEnv(ctx: TraceContext): Record<string, string>;
|
|
737
737
|
|
|
738
738
|
/**
|
|
739
739
|
* @experimental
|
|
@@ -1493,79 +1493,4 @@ interface SettleDetachedCoderTurnOptions {
|
|
|
1493
1493
|
*/
|
|
1494
1494
|
declare function settleDetachedCoderTurn(turn: DetachedTurn, options: SettleDetachedCoderTurnOptions): Promise<CoderOutput>;
|
|
1495
1495
|
|
|
1496
|
-
|
|
1497
|
-
* @experimental
|
|
1498
|
-
*
|
|
1499
|
-
* `createKbGate` — the valid-only knowledge-base growth gate, distilled from
|
|
1500
|
-
* physim's KB-research subsystem. A research-in-a-loop delegate (or any KB
|
|
1501
|
-
* writer) runs candidate facts through this before persisting, so the KB grows
|
|
1502
|
-
* with ONLY grounded facts — hallucinated, unsourced, or laundered claims are
|
|
1503
|
-
* vetoed at the gate.
|
|
1504
|
-
*
|
|
1505
|
-
* Fail-closed by construction: every judge must `accept`; the FIRST veto wins
|
|
1506
|
-
* and the fact is rejected. The non-negotiable floor (always on, can't be
|
|
1507
|
-
* disabled) is the **passage-present guard** — a fact's `verbatimPassage` MUST
|
|
1508
|
-
* literally appear in its `sourceText`. That single check kills the dominant
|
|
1509
|
-
* failure mode (a confident claim decoupled from any real source).
|
|
1510
|
-
*
|
|
1511
|
-
* Pure + dependency-free: it operates on fact candidates, not on a store, so it
|
|
1512
|
-
* composes with `@tangle-network/agent-knowledge` or any persistence layer
|
|
1513
|
-
* without importing it. The remediation policy (correct-on-veto vs
|
|
1514
|
-
* escalate-as-unverified) is the caller's — this returns the verdict; it never
|
|
1515
|
-
* drops a fact silently.
|
|
1516
|
-
*/
|
|
1517
|
-
/** @experimental A fact proposed for the KB, with its grounding. */
|
|
1518
|
-
interface FactCandidate {
|
|
1519
|
-
/** The atomic claim text. */
|
|
1520
|
-
claim: string;
|
|
1521
|
-
/** Optional extracted value (number or string) the claim asserts. */
|
|
1522
|
-
value?: string | number;
|
|
1523
|
-
/** Verbatim span lifted from the source that backs the claim. */
|
|
1524
|
-
verbatimPassage: string;
|
|
1525
|
-
/** The raw source text the passage must be grounded in. */
|
|
1526
|
-
sourceText: string;
|
|
1527
|
-
/** Where the fact claims to come from — checked for circular/self citations. */
|
|
1528
|
-
citation?: string;
|
|
1529
|
-
}
|
|
1530
|
-
/** @experimental */
|
|
1531
|
-
interface FactJudgeVerdict {
|
|
1532
|
-
accept: boolean;
|
|
1533
|
-
reason?: string;
|
|
1534
|
-
}
|
|
1535
|
-
/** @experimental A pluggable fact validator. Throw is NOT allowed — return a
|
|
1536
|
-
* verdict; a thrown judge is a programmer error, not a veto. */
|
|
1537
|
-
interface FactJudge {
|
|
1538
|
-
name: string;
|
|
1539
|
-
judge(candidate: FactCandidate): FactJudgeVerdict | Promise<FactJudgeVerdict>;
|
|
1540
|
-
}
|
|
1541
|
-
/** @experimental */
|
|
1542
|
-
interface KbGateResult {
|
|
1543
|
-
accepted: boolean;
|
|
1544
|
-
/** Name of the judge that vetoed; undefined when accepted. */
|
|
1545
|
-
vetoedBy?: string;
|
|
1546
|
-
reason?: string;
|
|
1547
|
-
}
|
|
1548
|
-
/** @experimental */
|
|
1549
|
-
interface CreateKbGateOptions {
|
|
1550
|
-
/** Extra judges appended after the built-in floor (e.g. an LLM judge). */
|
|
1551
|
-
judges?: FactJudge[];
|
|
1552
|
-
/** Minimum verbatim-passage length. Default 12 — kills empty/stub passages. */
|
|
1553
|
-
minPassageChars?: number;
|
|
1554
|
-
/**
|
|
1555
|
-
* Citation tokens that denote a SELF-generated artifact (e.g. `'spec'`,
|
|
1556
|
-
* `'cad_params'`, `'requirements'`). A citation naming one is circular
|
|
1557
|
-
* (laundering) — the fact cites a derived artifact, not a real source.
|
|
1558
|
-
* Default `[]` (no circular check unless the consumer declares its kinds).
|
|
1559
|
-
*/
|
|
1560
|
-
selfArtifactKinds?: string[];
|
|
1561
|
-
}
|
|
1562
|
-
/**
|
|
1563
|
-
* @experimental
|
|
1564
|
-
*
|
|
1565
|
-
* Build a fail-closed KB gate. The returned function runs the built-in floor
|
|
1566
|
-
* (passage-non-empty → passage-present → value-in-passage → no-circular-citation)
|
|
1567
|
-
* then any consumer judges, returning on the first veto.
|
|
1568
|
-
*/
|
|
1569
|
-
declare function createKbGate(options?: CreateKbGateOptions): (candidate: FactCandidate) => Promise<KbGateResult>;
|
|
1570
|
-
|
|
1571
|
-
export { type DetachedSessionRefParts as $, type DelegateRunCtx as A, type DelegateUiAuditConfig as B, type CoderReviewer as C, type DelegateCodeArgs as D, type DelegateUiAuditRoute as E, type FactCandidate as F, type DelegationError as G, type DelegationHistoryEntry as H, DelegationPersistenceError as I, type DelegationProfile as J, type DelegationProgress as K, type DelegationRecord as L, type DelegationResultPayload as M, type DelegationResumeContext as N, type DelegationResumeDriver as O, type DelegationResumeTick as P, type DelegationRunContext as Q, type ResearcherDelegate as R, DelegationStateCorruptError as S, type TraceContext as T, type UiAuditorDelegate as U, type DelegationStatus as V, type DelegationStore as W, type DelegationTaskQueueOptions as X, type DelegationTraceCaps as Y, type DelegationTraceCollector as Z, type DelegationTraceSpan as _, type CoderWinnerSelection as a, type DetachedTurn as a0, type DriveTurnCapableBox as a1, type DriveTurnResumeDriverOptions as a2, type DriveTurnTick as a3, type FactJudge as a4, type FactJudgeVerdict as a5, type FeedbackRating as a6, type FeedbackRefersTo as a7, FileDelegationStore as a8, type FileDelegationStoreOptions as a9, runDetachedTurn as aA, settleDetachedCoderTurn as aB, traceContextToEnv as aC, type EvalRunEvent as aD, type EvalRunGeneration as aE, type EvalRunsExportConfig as aF, type EvalRunsExportResult as aG, INTELLIGENCE_WIRE_VERSION as aH, type LoopSpanNode as aI, type OtelAttribute as aJ, type OtelExportConfig as aK, type OtelExporter as aL, type OtelSpan as aM, buildLoopOtelSpans as aN, buildLoopSpanNodes as aO, createOtelExporter as aP, exportEvalRuns as aQ, loopEventToOtelSpan as aR, type FleetWorkspaceExecutorOptions as aa, InMemoryDelegationStore as ab, type KbGateResult as ac, type ResearchOutputShape as ad, type RunDetachedTurnOptions as ae, type SettleDetachedCoderTurnOptions as af, type SiblingSandboxExecutorOptions as ag, type SubmitInput as ah, type SubmitOutput as ai, type UiAuditorDelegationOutput as aj, buildDelegationTraceSpans as ak, capDelegationTrace as al, coderTaskFromArgs as am, composeLoopTraceEmitters as an, createDefaultCoderDelegate as ao, createDelegationTraceCollector as ap, createDriveTurnResumeDriver as aq, createFleetWorkspaceExecutor as ar, createKbGate as as, createPropagatingTraceEmitter as at, createSiblingSandboxExecutor as au, detachedTurnEvents as av, formatDetachedSessionRef as aw, hashIdempotencyInput as ax, parseDetachedSessionRef as ay, readTraceContextFromEnv as az, type CreateKbGateOptions as b, type FleetHandle as c, type DelegationExecutor as d, type DelegateFeedbackArgs as e, type DelegationFeedbackSnapshot as f, DelegationTaskQueue as g, type CoderDelegate as h, type DelegateCodeResult as i, type DelegateFeedbackResult as j, type ResearchSource as k, type DelegateResearchArgs as l, type DelegateResearchResult as m, type DelegateUiAuditArgs as n, type DelegateUiAuditResult as o, type DelegationHistoryResult as p, type DelegationHistoryArgs as q, type DelegationStatusResult as r, type DelegationStatusArgs as s, type CappedDelegationTrace as t, type CoderReview as u, type CreateDefaultCoderDelegateOptions as v, DELEGATION_TRACE_MAX_BYTES as w, DELEGATION_TRACE_MAX_SPANS as x, type DelegateCodeConfig as y, type DelegateResearchConfig as z };
|
|
1496
|
+
export { type DriveTurnCapableBox as $, type DelegateUiAuditRoute as A, type DelegationError as B, type CoderReviewer as C, type DelegateCodeArgs as D, type DelegationHistoryEntry as E, type FleetHandle as F, DelegationPersistenceError as G, type DelegationProfile as H, type DelegationProgress as I, type DelegationRecord as J, type DelegationResultPayload as K, type DelegationResumeContext as L, type DelegationResumeDriver as M, type DelegationResumeTick as N, type DelegationRunContext as O, DelegationStateCorruptError as P, type DelegationStatus as Q, type ResearcherDelegate as R, type DelegationStore as S, type TraceContext as T, type UiAuditorDelegate as U, type DelegationTaskQueueOptions as V, type DelegationTraceCaps as W, type DelegationTraceCollector as X, type DelegationTraceSpan as Y, type DetachedSessionRefParts as Z, type DetachedTurn as _, type CoderWinnerSelection as a, type DriveTurnResumeDriverOptions as a0, type DriveTurnTick as a1, type FeedbackRating as a2, type FeedbackRefersTo as a3, FileDelegationStore as a4, type FileDelegationStoreOptions as a5, type FleetWorkspaceExecutorOptions as a6, InMemoryDelegationStore as a7, type ResearchOutputShape as a8, type RunDetachedTurnOptions as a9, type EvalRunsExportResult as aA, INTELLIGENCE_WIRE_VERSION as aB, type LoopSpanNode as aC, type OtelAttribute as aD, type OtelExportConfig as aE, type OtelExporter as aF, type OtelSpan as aG, buildLoopOtelSpans as aH, buildLoopSpanNodes as aI, createOtelExporter as aJ, exportEvalRuns as aK, loopEventToOtelSpan as aL, type SettleDetachedCoderTurnOptions as aa, type SiblingSandboxExecutorOptions as ab, type SubmitInput as ac, type SubmitOutput as ad, type UiAuditorDelegationOutput as ae, buildDelegationTraceSpans as af, capDelegationTrace as ag, coderTaskFromArgs as ah, composeLoopTraceEmitters as ai, createDefaultCoderDelegate as aj, createDelegationTraceCollector as ak, createDriveTurnResumeDriver as al, createFleetWorkspaceExecutor as am, createPropagatingTraceEmitter as an, createSiblingSandboxExecutor as ao, detachedTurnEvents as ap, formatDetachedSessionRef as aq, hashIdempotencyInput as ar, parseDetachedSessionRef as as, readTraceContextFromEnv as at, runDetachedTurn as au, settleDetachedCoderTurn as av, traceContextToEnv as aw, type EvalRunEvent as ax, type EvalRunGeneration as ay, type EvalRunsExportConfig as az, type DelegateFeedbackArgs as b, type DelegationFeedbackSnapshot as c, DelegationTaskQueue as d, type CoderDelegate as e, type DelegationExecutor as f, type DelegateCodeResult as g, type DelegateFeedbackResult as h, type ResearchSource as i, type DelegateResearchArgs as j, type DelegateResearchResult as k, type DelegateUiAuditArgs as l, type DelegateUiAuditResult as m, type DelegationHistoryResult as n, type DelegationHistoryArgs as o, type DelegationStatusResult as p, type DelegationStatusArgs as q, type CappedDelegationTrace as r, type CoderReview as s, type CreateDefaultCoderDelegateOptions as t, DELEGATION_TRACE_MAX_BYTES as u, DELEGATION_TRACE_MAX_SPANS as v, type DelegateCodeConfig as w, type DelegateResearchConfig as x, type DelegateRunCtx as y, type DelegateUiAuditConfig as z };
|