@tangle-network/agent-runtime 0.94.13 → 0.96.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.
Files changed (110) hide show
  1. package/README.md +64 -15
  2. package/dist/activation-B0ZD7nfX.d.ts +63 -0
  3. package/dist/agent.d.ts +6 -193
  4. package/dist/agent.js +10 -234
  5. package/dist/agent.js.map +1 -1
  6. package/dist/analyst-loop.d.ts +7 -10
  7. package/dist/analyst-loop.js +1 -2
  8. package/dist/candidate-execution/index.d.ts +43 -16
  9. package/dist/candidate-execution/index.js +17 -8
  10. package/dist/{chunk-VYA2YEKA.js → chunk-2KGAN2HM.js} +83 -14
  11. package/dist/chunk-2KGAN2HM.js.map +1 -0
  12. package/dist/chunk-3XKSBI2U.js +474 -0
  13. package/dist/chunk-3XKSBI2U.js.map +1 -0
  14. package/dist/{chunk-TVJQAYQM.js → chunk-6XKPVJAZ.js} +107 -716
  15. package/dist/chunk-6XKPVJAZ.js.map +1 -0
  16. package/dist/chunk-BLQIYRVR.js +699 -0
  17. package/dist/chunk-BLQIYRVR.js.map +1 -0
  18. package/dist/{chunk-QDSOD7RC.js → chunk-FD2MBMOH.js} +13 -101
  19. package/dist/chunk-FD2MBMOH.js.map +1 -0
  20. package/dist/{chunk-U33YZ7B2.js → chunk-FXF2OL34.js} +8 -8
  21. package/dist/{chunk-EP6RVHMX.js → chunk-HZDEXTSL.js} +848 -2
  22. package/dist/chunk-HZDEXTSL.js.map +1 -0
  23. package/dist/{chunk-WIPGQ4GT.js → chunk-IMSNJSXH.js} +1 -1
  24. package/dist/{chunk-WIPGQ4GT.js.map → chunk-IMSNJSXH.js.map} +1 -1
  25. package/dist/{chunk-VSWBYWFK.js → chunk-M6MD6JBS.js} +20 -27
  26. package/dist/chunk-M6MD6JBS.js.map +1 -0
  27. package/dist/chunk-PSOCBNM3.js +2069 -0
  28. package/dist/chunk-PSOCBNM3.js.map +1 -0
  29. package/dist/{chunk-AEG3NGJ2.js → chunk-Q2JSAVQ3.js} +34 -2
  30. package/dist/chunk-Q2JSAVQ3.js.map +1 -0
  31. package/dist/{chunk-XP5KDM3R.js → chunk-SGQ4YIQW.js} +4 -4
  32. package/dist/{chunk-C3UKLQ54.js → chunk-UQ6PNNXM.js} +18 -10
  33. package/dist/chunk-UQ6PNNXM.js.map +1 -0
  34. package/dist/{chunk-33OG2NN3.js → chunk-WYC2XJF2.js} +2 -2
  35. package/dist/{chunk-ZEYAT33L.js → chunk-Y3SRWZMP.js} +2 -2
  36. package/dist/{chunk-CNH7DF7Z.js → chunk-YOLKCWRV.js} +1116 -591
  37. package/dist/chunk-YOLKCWRV.js.map +1 -0
  38. package/dist/{completion-gate-D1gX1-hg.d.ts → completion-gate-C80jiRfN.d.ts} +1 -1
  39. package/dist/conversation.d.ts +12 -1
  40. package/dist/conversation.js +2 -3
  41. package/dist/{coordination-Dr_axlAf.d.ts → coordination-BFE3Den7.d.ts} +10 -11
  42. package/dist/environment-provider.d.ts +2 -2
  43. package/dist/environment-provider.js +1 -2
  44. package/dist/{agentic-generator-DDMM45kZ.d.ts → improve-g75IE2Cx.d.ts} +152 -4
  45. package/dist/{improvement-adapter-BieWeK5J.d.ts → improvement-adapter-HAZz-7vK.d.ts} +8 -31
  46. package/dist/index.d.ts +55 -28
  47. package/dist/index.js +206 -82
  48. package/dist/index.js.map +1 -1
  49. package/dist/intelligence.d.ts +185 -120
  50. package/dist/intelligence.js +509 -345
  51. package/dist/intelligence.js.map +1 -1
  52. package/dist/knowledge.d.ts +40 -12
  53. package/dist/knowledge.js +13 -7
  54. package/dist/{loop-runner-bin-BRQSQdHa.d.ts → loop-runner-bin-Cn1N2rRo.d.ts} +3 -3
  55. package/dist/loop-runner-bin.d.ts +6 -6
  56. package/dist/loop-runner-bin.js +8 -10
  57. package/dist/loops.d.ts +13 -13
  58. package/dist/loops.js +6 -8
  59. package/dist/mcp/bin.js +5 -7
  60. package/dist/mcp/bin.js.map +1 -1
  61. package/dist/mcp/index.d.ts +6 -6
  62. package/dist/mcp/index.js +12 -14
  63. package/dist/mcp/index.js.map +1 -1
  64. package/dist/platform.js +0 -2
  65. package/dist/platform.js.map +1 -1
  66. package/dist/primeintellect/index.js +1 -2
  67. package/dist/primeintellect/index.js.map +1 -1
  68. package/dist/profile-DbfaMTdk.d.ts +233 -0
  69. package/dist/profiles.d.ts +1 -1
  70. package/dist/profiles.js +0 -1
  71. package/dist/profiles.js.map +1 -1
  72. package/dist/{supervise-DmYOug5f.d.ts → supervise-BLPI50-w.d.ts} +3 -3
  73. package/dist/{types-ByAYqlVb.d.ts → types-B3vAW0Oq.d.ts} +1 -1
  74. package/dist/{prepare-CtdtsFNG.d.ts → types-CWqfCO8s.d.ts} +67 -298
  75. package/dist/{types-BC3bZpH0.d.ts → types-CmYCMbFT.d.ts} +12 -54
  76. package/dist/{types-1d5QGK3t.d.ts → types-CmnA2iL3.d.ts} +3 -3
  77. package/dist/{worktree-fanout-CPprU-qI.d.ts → worktree-fanout-DCA3G4bO.d.ts} +3 -3
  78. package/package.json +14 -16
  79. package/skills/build-with-agent-runtime/SKILL.md +122 -213
  80. package/dist/chunk-6O73TRHW.js +0 -142
  81. package/dist/chunk-6O73TRHW.js.map +0 -1
  82. package/dist/chunk-AEG3NGJ2.js.map +0 -1
  83. package/dist/chunk-C3UKLQ54.js.map +0 -1
  84. package/dist/chunk-CNH7DF7Z.js.map +0 -1
  85. package/dist/chunk-D3H7F6L2.js +0 -626
  86. package/dist/chunk-D3H7F6L2.js.map +0 -1
  87. package/dist/chunk-DGUM43GV.js +0 -11
  88. package/dist/chunk-DGUM43GV.js.map +0 -1
  89. package/dist/chunk-EP6RVHMX.js.map +0 -1
  90. package/dist/chunk-HGRW27YY.js +0 -214
  91. package/dist/chunk-HGRW27YY.js.map +0 -1
  92. package/dist/chunk-ISTDY47H.js +0 -849
  93. package/dist/chunk-ISTDY47H.js.map +0 -1
  94. package/dist/chunk-PCURO3DL.js +0 -661
  95. package/dist/chunk-PCURO3DL.js.map +0 -1
  96. package/dist/chunk-QDSOD7RC.js.map +0 -1
  97. package/dist/chunk-TVJQAYQM.js.map +0 -1
  98. package/dist/chunk-VSWBYWFK.js.map +0 -1
  99. package/dist/chunk-VYA2YEKA.js.map +0 -1
  100. package/dist/generator-YkAQrOoD.d.ts +0 -382
  101. package/dist/improve-BN3HyXIO.d.ts +0 -172
  102. package/dist/lifecycle.d.ts +0 -870
  103. package/dist/lifecycle.js +0 -981
  104. package/dist/lifecycle.js.map +0 -1
  105. package/dist/mcp-serve-verifier-DQQDbuyz.d.ts +0 -34
  106. package/skills/agent-runtime-adoption/SKILL.md +0 -246
  107. /package/dist/{chunk-U33YZ7B2.js.map → chunk-FXF2OL34.js.map} +0 -0
  108. /package/dist/{chunk-XP5KDM3R.js.map → chunk-SGQ4YIQW.js.map} +0 -0
  109. /package/dist/{chunk-33OG2NN3.js.map → chunk-WYC2XJF2.js.map} +0 -0
  110. /package/dist/{chunk-ZEYAT33L.js.map → chunk-Y3SRWZMP.js.map} +0 -0
@@ -1,10 +1,5 @@
1
- import { AgentCandidateBundle, AgentCandidateArtifactRef, AgentCandidateTermination, AgentCandidateTaskOutcomeEvidence, Sha256Digest, AgentCandidateContainer, AgentCandidateOciPlatform, AgentCandidateGitHubRepository, AgentCandidateWorkspaceSnapshotEvidence, AgentCandidateResolvedModel, AgentCandidateAttemptPolicy, AgentCandidateExecutionLimits, AgentCandidateModelAccessNetwork, AgentCandidateCapturedArtifact, AgentCandidateWorkspaceManifestMaterial, AgentCandidateProfilePlanEvidence, AgentCandidateExecutionPlanEvidence, AgentCandidateMaterializationReceipt, AgentCandidateInstructionDelivery, AgentCandidateKnowledgeRef, AgentCandidateEffectiveMemory, AgentCandidateRunReceipt, AgentCandidateSpend, ReasoningEffort } from '@tangle-network/agent-interface';
2
1
  import { BenchmarkEvaluation, TraceStore } from '@tangle-network/agent-eval';
3
-
4
- /** Exact candidate wire shape before the runtime computes its canonical digest. */
5
- type AgentCandidateBundleInput = Omit<AgentCandidateBundle, 'digest'>;
6
- /** Validate and content-address a candidate bundle before it crosses an approval boundary. */
7
- declare function sealAgentCandidateBundle(input: AgentCandidateBundleInput): AgentCandidateBundle;
2
+ import { AgentCandidateArtifactRef, AgentCandidateTermination, AgentCandidateTaskOutcomeMaterial, AgentCandidateTaskOutcomeEvidence, AgentCandidateTaskOutputSpec, Sha256Digest, AgentCandidateContainer, AgentCandidateOciPlatform, AgentCandidateGitHubRepository, AgentCandidateWorkspaceSnapshotEvidence, AgentCandidateBundle, AgentCandidateResolvedModel, AgentCandidateAttemptPolicy, AgentCandidateExecutionLimits, AgentCandidateModelAccessNetwork, AgentCandidateModelSettlementCall, AgentCandidateCapturedArtifact, AgentCandidateWorkspaceManifestMaterial, AgentCandidateBenchmarkSuite, AgentCandidateBenchmarkTask, AgentCandidateProfilePlanEvidence, AgentCandidateProfileActivation, AgentCandidateExecutionPlanEvidence, AgentCandidateMaterializationReceipt, AgentCandidateInstructionDelivery, AgentCandidateKnowledgeRef, AgentCandidateEffectiveMemory, AgentCandidateRunReceipt, AgentCandidateFixedSpend, AgentCandidateRunCell } from '@tangle-network/agent-interface';
8
3
 
9
4
  declare const verifiedCandidateBrand: unique symbol;
10
5
  declare const preparedCandidateBrand: unique symbol;
@@ -13,7 +8,7 @@ declare const verifiedTaskOutcomeBrand: unique symbol;
13
8
  interface AgentCandidateArtifactPort {
14
9
  read(ref: AgentCandidateArtifactRef): Promise<Uint8Array>;
15
10
  }
16
- type AgentCandidateOutputPurpose = 'candidate-workspace-manifest' | 'candidate-workspace-archive' | 'task-manifest' | 'task-archive' | 'task-patch' | 'task-outcome' | 'memory-after-manifest' | 'memory-after-archive' | 'grader-evidence' | 'benchmark-result' | 'model-settlement' | 'trace' | 'executor-capture' | 'run-receipt' | 'failure-evidence';
11
+ type AgentCandidateOutputPurpose = 'execution-plan' | 'materialization-receipt' | 'candidate-workspace-manifest' | 'candidate-workspace-archive' | 'task-manifest' | 'task-archive' | 'task-patch' | 'task-output' | 'task-outcome' | 'memory-after-manifest' | 'memory-after-archive' | 'grader-evidence' | 'benchmark-result' | 'model-settlement' | 'trace' | 'executor-native-evidence' | 'executor-capture' | 'run-receipt' | 'knowledge-retrieval-config' | 'knowledge-evaluation' | 'failure-evidence';
17
12
  /** Durable content-addressed evidence store controlled only by the evaluator. */
18
13
  interface AgentCandidateOutputArtifactPort extends AgentCandidateArtifactPort {
19
14
  /** Must be idempotent for identical bytes and return only a durable S3/IPFS locator. */
@@ -105,11 +100,6 @@ interface AgentCandidateModelPort {
105
100
  }
106
101
  /** Limits mechanically enforced by the evaluator-owned model gateway. */
107
102
  type AgentCandidateModelLimits = Pick<AgentCandidateExecutionLimits, 'maxModelCalls' | 'maxInputTokens' | 'maxOutputTokens' | 'maxCostUsd'>;
108
- interface AgentCandidateBenchmarkGraderIdentity {
109
- name: string;
110
- version: string;
111
- artifact: AgentCandidateArtifactRef;
112
- }
113
103
  interface AgentCandidateProtectedModelReservation {
114
104
  preparationId: string;
115
105
  digest: Sha256Digest;
@@ -124,29 +114,11 @@ interface AgentCandidateProtectedModelActivation {
124
114
  /** Injected only into the trusted executor after all pre-launch checks pass. */
125
115
  env: Readonly<Record<string, string>>;
126
116
  }
127
- /** One evaluator-gateway call in the final, revoked model-access ledger. */
128
- interface AgentCandidateProtectedModelCall {
129
- callId: string;
130
- /** Router-generated public response identity. */
131
- generationId: string;
132
- /** Exact protected agent-eval LLM span produced from the router ledger. */
133
- traceSpanId: string;
134
- status: 'succeeded' | 'failed';
135
- model: string;
136
- startedAtMs: number;
137
- endedAtMs: number;
138
- inputTokens: number;
139
- outputTokens: number;
140
- cachedInputTokens: number;
141
- reasoningTokens: number;
142
- /** Integer billionths of one US dollar; avoids floating-point ledger drift. */
143
- costUsdNanos: number;
144
- }
145
117
  interface AgentCandidateProtectedModelSettlement {
146
118
  preparationId: string;
147
119
  grantDigest: Sha256Digest;
148
120
  closed: true;
149
- calls: readonly AgentCandidateProtectedModelCall[];
121
+ calls: readonly AgentCandidateModelSettlementCall[];
150
122
  }
151
123
  interface AgentCandidateMemoryResetResult {
152
124
  preparationId: string;
@@ -204,26 +176,12 @@ interface AgentCandidateExecutionPorts extends AgentCandidateVerificationPorts {
204
176
  models: AgentCandidateModelPort;
205
177
  memory: AgentCandidateMemoryPort;
206
178
  }
179
+ /** Runtime placement for one exact cell from a signed candidate experiment. */
207
180
  interface AgentCandidateTaskExecution {
208
181
  executionId: string;
209
- benchmark: string;
210
- benchmarkVersion: string;
211
- taskId: string;
212
- splitDigest: Sha256Digest;
213
- /** Exact agent-visible task instruction. The runtime rejects malformed Unicode. */
214
- instruction: string;
215
- repository: {
216
- identity: string;
217
- rootIdentity: string;
218
- baseCommit: string;
219
- baseTree: string;
220
- };
221
- attempt: AgentCandidateAttemptPolicy;
222
- model: {
223
- requested: string;
224
- reasoningEffort: ReasoningEffort;
225
- };
226
- grader: AgentCandidateBenchmarkGraderIdentity;
182
+ runCell: AgentCandidateRunCell;
183
+ benchmarkSuite: AgentCandidateBenchmarkSuite;
184
+ task: AgentCandidateBenchmarkTask;
227
185
  /** Absolute paths inside the evaluator-owned execution environment. */
228
186
  executionRoots: {
229
187
  taskRoot: string;
@@ -235,9 +193,6 @@ interface AgentCandidateTaskExecution {
235
193
  candidateRoot?: string;
236
194
  profileRoot: string;
237
195
  };
238
- workspace: AgentCandidateWorkspaceSnapshotEvidence;
239
- evaluatorTaskContainer?: ResolvedAgentCandidateContainer;
240
- limits: AgentCandidateExecutionLimits;
241
196
  }
242
197
  interface VerifiedAgentCandidate {
243
198
  readonly bundle: AgentCandidateBundle;
@@ -277,6 +232,10 @@ interface PreparedAgentCandidateTrace {
277
232
  }
278
233
  interface PreparedAgentCandidateExecution {
279
234
  readonly bundle: AgentCandidateBundle;
235
+ readonly benchmark: {
236
+ readonly suite: AgentCandidateBenchmarkSuite;
237
+ readonly task: AgentCandidateBenchmarkTask;
238
+ };
280
239
  readonly executionId: string;
281
240
  readonly roots: {
282
241
  execution: {
@@ -294,6 +253,7 @@ interface PreparedAgentCandidateExecution {
294
253
  bytes: Uint8Array;
295
254
  written: readonly string[];
296
255
  };
256
+ readonly profileActivation: AgentCandidateProfileActivation;
297
257
  readonly executionPlan: {
298
258
  value: AgentCandidateExecutionPlanEvidence;
299
259
  bytes: Uint8Array;
@@ -307,41 +267,61 @@ interface PreparedAgentCandidateExecution {
307
267
  readonly memory: AgentCandidateEffectiveMemory;
308
268
  readonly [preparedCandidateBrand]: true;
309
269
  }
270
+
310
271
  interface AgentCandidateProtectedRunCapture {
311
272
  executionId: string;
312
273
  termination: AgentCandidateTermination;
313
274
  }
314
275
  /** Raw evaluator capture made only after the candidate process is dead. */
315
- interface AgentCandidateExecutorTaskOutcomeCapture {
276
+ type AgentCandidateExecutorTaskOutcomeCapture = {
277
+ readonly kind: 'workspace';
316
278
  /** Claimed final tree. The runtime recomputes it independently from `gitDiff`. */
317
- resultTree: string;
279
+ readonly resultTree: string;
318
280
  /** Complete evaluator-captured workspace description after candidate execution. */
319
- afterState: AgentCandidateWorkspaceManifestMaterial;
281
+ readonly afterState: AgentCandidateWorkspaceManifestMaterial;
320
282
  /** Reproducible workspace archive corresponding to `afterState`. */
321
- archive: Uint8Array;
283
+ readonly archive: Uint8Array;
322
284
  /** Exact binary patch from the signed task base to `afterState`. */
323
- gitDiff: Uint8Array;
324
- }
285
+ readonly gitDiff: Uint8Array;
286
+ } | {
287
+ readonly kind: 'output';
288
+ /** Exact evaluator-captured final output bytes. */
289
+ readonly bytes: Uint8Array;
290
+ };
325
291
  /** Raw isolated-memory capture made only after access has been revoked. */
326
292
  interface AgentCandidateExecutorMemoryCapture {
327
293
  readonly afterState: AgentCandidateWorkspaceManifestMaterial;
328
294
  readonly archive: Uint8Array;
329
295
  }
330
- /** Idempotent executor result after process death and trace drain. */
296
+ /** Replayable evaluator result captured only after process death and trace drain. */
331
297
  interface AgentCandidateExecutorFinalCapture {
332
- readonly stopped: true;
333
298
  readonly taskOutcome?: AgentCandidateExecutorTaskOutcomeCapture;
334
299
  /** Required only when the prepared candidate uses isolated task memory. */
335
300
  readonly memoryAfter?: AgentCandidateExecutorMemoryCapture;
301
+ /** Executor-native bytes preserved when a fresh worker cannot reconstruct a verified outcome. */
302
+ readonly evidence?: Uint8Array;
336
303
  }
337
- /** Branded task outcome that has survived independent patch and tree verification. */
338
- interface VerifiedAgentCandidateTaskOutcome {
339
- readonly evidence: AgentCandidateTaskOutcomeEvidence & {
340
- readonly artifact: AgentCandidateArtifactRef;
304
+ type PersistedTaskOutcomeEvidence<Kind extends AgentCandidateTaskOutcomeMaterial['outcome']['kind']> = Omit<AgentCandidateTaskOutcomeEvidence, 'material'> & {
305
+ readonly artifact: AgentCandidateArtifactRef;
306
+ readonly material: Omit<AgentCandidateTaskOutcomeMaterial, 'outcome'> & {
307
+ readonly outcome: Extract<AgentCandidateTaskOutcomeMaterial['outcome'], {
308
+ kind: Kind;
309
+ }>;
341
310
  };
311
+ };
312
+ /** Branded task outcome that has survived independent evaluator verification. */
313
+ type VerifiedAgentCandidateTaskOutcome = {
314
+ readonly kind: 'workspace';
315
+ readonly evidence: PersistedTaskOutcomeEvidence<'workspace'>;
342
316
  readonly patch: Uint8Array;
343
317
  readonly [verifiedTaskOutcomeBrand]: true;
344
- }
318
+ } | {
319
+ readonly kind: 'output';
320
+ readonly evidence: PersistedTaskOutcomeEvidence<'output'>;
321
+ readonly spec: AgentCandidateTaskOutputSpec;
322
+ readonly bytes: Uint8Array;
323
+ readonly [verifiedTaskOutcomeBrand]: true;
324
+ };
345
325
  /**
346
326
  * Evaluator-owned executable grader, pinned by immutable implementation bytes.
347
327
  *
@@ -384,6 +364,7 @@ interface AgentCandidateBenchmarkGraderPort {
384
364
  /** One detached request passed to the trusted environment-specific executor. */
385
365
  interface AgentCandidateExecutorRequest {
386
366
  readonly executionId: string;
367
+ readonly benchmark: PreparedAgentCandidateExecution['benchmark'];
387
368
  /** Immutable bytes from which the executor creates fresh isolated workspaces. */
388
369
  readonly inputs: {
389
370
  readonly task: AgentCandidateExecutorWorkspaceInput;
@@ -394,6 +375,7 @@ interface AgentCandidateExecutorRequest {
394
375
  };
395
376
  readonly roots: PreparedAgentCandidateExecution['roots']['execution'];
396
377
  readonly profilePlan: PreparedAgentCandidateExecution['profilePlan'];
378
+ readonly profileActivation: AgentCandidateProfileActivation;
397
379
  readonly executionPlan: PreparedAgentCandidateExecution['executionPlan'];
398
380
  readonly materializationReceipt: CanonicalCandidateDocument<AgentCandidateMaterializationReceipt>;
399
381
  readonly launch: PreparedAgentCandidateLaunch;
@@ -403,7 +385,7 @@ interface AgentCandidateExecutorRequest {
403
385
  readonly hardLimits: Pick<AgentCandidateExecutionLimits, 'timeoutMs'>;
404
386
  /** Validity bound checked against protected traces; generic black-box executors cannot preempt it. */
405
387
  readonly observedLimits: Pick<AgentCandidateExecutionLimits, 'maxSteps'>;
406
- readonly knowledge?: PreparedAgentCandidateExecution['knowledge'];
388
+ readonly knowledge?: PreparedAgentCandidateKnowledge;
407
389
  readonly trace: PreparedAgentCandidateTrace;
408
390
  readonly memory: AgentCandidateEffectiveMemory;
409
391
  }
@@ -423,21 +405,29 @@ interface AgentCandidateExecutorPort {
423
405
  /** Absolute epoch-millisecond deadline owned by the runtime. */
424
406
  deadlineAtMs: number;
425
407
  }): Promise<AgentCandidateProtectedRunCapture>;
426
- /**
427
- * Kill any process/container still associated with the request, drain trace
428
- * writes, and capture the final task workspace before teardown.
429
- * The runtime calls this on success, failure, and timeout before model settlement.
430
- * Implementations must be idempotent and concurrency-safe for this exact
431
- * execution/plan pair because a fresh worker may repeat crash recovery.
432
- */
433
- stopAndCapture(request: AgentCandidateExecutorStopRequest, context: {
408
+ /** Kill the exact process/container and drain trace writes. Must be idempotent. */
409
+ stop(request: AgentCandidateExecutorStopRequest, context: {
434
410
  traceStore: TraceStore;
435
411
  reason: 'completed' | 'failed' | 'timeout';
436
412
  /** Aborted at the frozen execution deadline or evaluator cleanup deadline. */
437
413
  signal: AbortSignal;
438
414
  /** Absolute execution deadline; a later stop acknowledgement cannot produce success. */
439
415
  deadlineAtMs: number;
416
+ }): Promise<{
417
+ readonly stopped: true;
418
+ }>;
419
+ /** Capture immutable final evidence after stop. Must be replayable by a fresh worker. */
420
+ capture(request: AgentCandidateExecutorStopRequest, context: {
421
+ traceStore: TraceStore;
422
+ /** Aborted at the frozen execution deadline or evaluator cleanup deadline. */
423
+ signal: AbortSignal;
440
424
  }): Promise<AgentCandidateExecutorFinalCapture>;
425
+ /** Remove evaluator-owned execution resources after final capture. Must be idempotent. */
426
+ dispose?(request: AgentCandidateExecutorStopRequest, context: {
427
+ signal: AbortSignal;
428
+ }): Promise<{
429
+ readonly disposed: true;
430
+ }>;
441
431
  }
442
432
  /** Opaque process identity used for termination without re-exposing launch credentials. */
443
433
  interface AgentCandidateExecutorStopRequest {
@@ -453,6 +443,7 @@ interface AgentCandidateExecutorWorkspaceFile {
453
443
  readonly mode: number;
454
444
  readonly bytes: Uint8Array;
455
445
  }
446
+ /** One exact profile file supplied to an evaluator-owned executor. */
456
447
  interface AgentCandidateExecutorProfileFile {
457
448
  readonly path: string;
458
449
  readonly mode: number;
@@ -479,7 +470,7 @@ type AgentCandidateRunFinalization = {
479
470
  termination?: AgentCandidateTermination;
480
471
  };
481
472
  /** Independent evaluator-gateway usage, even when execution or trace capture failed. */
482
- usage: AgentCandidateSpend | null;
473
+ usage: AgentCandidateFixedSpend | null;
483
474
  };
484
475
  /** Protected trace tags that bind a run to one prepared candidate execution. */
485
476
  declare const CANDIDATE_TRACE_TAGS: {
@@ -497,226 +488,4 @@ declare const CANDIDATE_TRACE_ENV: {
497
488
  readonly traceRunId: "TANGLE_TRACE_RUN_ID";
498
489
  };
499
490
 
500
- /** Durable one-shot lifecycle for candidate execution attempts. */
501
-
502
- /** Non-secret identities a trusted recovery worker needs to close an abandoned attempt. */
503
- interface AgentCandidateExecutionCleanupHandles {
504
- readonly preparationId: string;
505
- readonly modelGrantDigest: Sha256Digest;
506
- readonly resolvedModel: AgentCandidateResolvedModel;
507
- readonly traceRunId: string;
508
- readonly cleanupTimeoutMs: number;
509
- readonly memory?: {
510
- readonly accessDigest: Sha256Digest;
511
- readonly effectiveNamespace: string;
512
- };
513
- }
514
- /** Immutable signed identity stored for one execution attempt. */
515
- interface AgentCandidateExecutionClaim {
516
- readonly executionId: string;
517
- readonly attempt: number;
518
- readonly maxAttempts: number;
519
- readonly retryPolicy: AgentCandidateAttemptPolicy['retryPolicy'];
520
- readonly bundleDigest: Sha256Digest;
521
- readonly executionPlanDigest: Sha256Digest;
522
- /** Frozen plan identity with only attempt number and per-attempt grant identity normalized. */
523
- readonly retryLineageDigest: Sha256Digest;
524
- /** The winning lease stops authorizing a new terminal write at this instant. */
525
- readonly leaseExpiresAtMs: number;
526
- /** Frozen budget for task verification, executable grading, and receipt construction. */
527
- readonly resultTimeoutMs: number;
528
- /** Non-secret handles retained so an expired attempt can be closed and reconciled. */
529
- readonly cleanup: AgentCandidateExecutionCleanupHandles;
530
- }
531
- /** Secret capability required to finish the acquired attempt. */
532
- interface AgentCandidateExecutionLease {
533
- readonly executionId: string;
534
- readonly attempt: number;
535
- readonly token: string;
536
- readonly expiresAtMs: number;
537
- }
538
- /** Only the first class is retryable, and only when the closed model ledger has zero calls. */
539
- type AgentCandidateExecutionFailureClass = 'pre-model-infrastructure' | 'execution' | 'post-model-infrastructure' | 'unknown';
540
- /** Exact fixed-point usage proven by the closed evaluator model ledger. */
541
- interface AgentCandidateExecutionUsage {
542
- readonly costUsdNanos: number;
543
- readonly inputTokens: number;
544
- readonly outputTokens: number;
545
- readonly cachedInputTokens: number;
546
- readonly reasoningTokens: number;
547
- readonly modelCalls: number;
548
- }
549
- /** Evaluator-owned terminal facts staged durably before the terminal CAS. */
550
- type AgentCandidateExecutionTerminalResult = {
551
- readonly schemaVersion: 1;
552
- readonly status: 'succeeded';
553
- readonly usage: AgentCandidateExecutionUsage;
554
- readonly modelSettlement: AgentCandidateArtifactRef;
555
- readonly taskOutcome: AgentCandidateArtifactRef;
556
- readonly benchmarkResult: AgentCandidateArtifactRef;
557
- readonly runReceipt: AgentCandidateArtifactRef;
558
- } | {
559
- readonly schemaVersion: 1;
560
- readonly status: 'failed';
561
- readonly failureClass: AgentCandidateExecutionFailureClass;
562
- readonly usage: AgentCandidateExecutionUsage;
563
- readonly modelSettlement: AgentCandidateArtifactRef;
564
- readonly failureEvidence?: AgentCandidateArtifactRef;
565
- };
566
- /** Durable terminal record for one acquired execution attempt. */
567
- type AgentCandidateExecutionTerminalRecord = AgentCandidateExecutionTerminalResult & {
568
- readonly executionId: string;
569
- readonly attempt: number;
570
- readonly bundleDigest: Sha256Digest;
571
- readonly executionPlanDigest: Sha256Digest;
572
- /** RFC 8785 SHA-256 of this record with `terminalDigest` omitted. */
573
- readonly terminalDigest: Sha256Digest;
574
- };
575
- /** Monotonic durable phase: the second value means candidate code could have started. */
576
- type AgentCandidateExecutionPhase = 'claimed' | 'candidate-may-run';
577
- /** Trusted, independently observed closure facts for one expired winning lease. */
578
- interface AgentCandidateExecutionRecoveryEvidence {
579
- readonly failureClass: AgentCandidateExecutionFailureClass;
580
- readonly usage: AgentCandidateExecutionUsage;
581
- readonly modelSettlement: AgentCandidateArtifactRef;
582
- readonly failureEvidence?: AgentCandidateArtifactRef;
583
- readonly process: {
584
- readonly stopped: true;
585
- readonly executionPlanDigest: Sha256Digest;
586
- };
587
- readonly model: {
588
- readonly closed: true;
589
- readonly preparationId: string;
590
- readonly grantDigest: Sha256Digest;
591
- };
592
- readonly memory?: {
593
- readonly closed: true;
594
- readonly preparationId: string;
595
- readonly accessDigest: Sha256Digest;
596
- readonly effectiveNamespace: string;
597
- };
598
- }
599
- interface AgentCandidateExecutionAttemptRef {
600
- readonly executionId: string;
601
- readonly attempt: number;
602
- }
603
- /** Persisted state available to a fresh trusted recovery worker after a crash. */
604
- interface AgentCandidateExecutionAttemptRecord {
605
- readonly claim: AgentCandidateExecutionClaim;
606
- readonly phase: AgentCandidateExecutionPhase;
607
- /** Durable outbox content written before the terminal compare-and-set. */
608
- readonly staged?: AgentCandidateExecutionTerminalRecord;
609
- readonly terminal?: AgentCandidateExecutionTerminalRecord;
610
- }
611
- /** Result of atomically claiming one execution attempt. */
612
- type AgentCandidateExecutionClaimResult = {
613
- readonly acquired: true;
614
- readonly claim: AgentCandidateExecutionClaim;
615
- readonly lease: AgentCandidateExecutionLease;
616
- } | {
617
- readonly acquired: false;
618
- readonly reason: 'already-claimed';
619
- /** The durable winner already occupying this execution-attempt slot. */
620
- readonly claim: AgentCandidateExecutionClaim;
621
- /** True only when every signed claim field matches the durable winner. */
622
- readonly exactReplay: boolean;
623
- } | {
624
- readonly acquired: false;
625
- readonly reason: 'retry-not-eligible';
626
- readonly claim: AgentCandidateExecutionClaim;
627
- readonly detail: AgentCandidateRetryRejection;
628
- };
629
- /** Result of atomically recording an attempt's terminal facts. */
630
- type AgentCandidateExecutionFinishResult = {
631
- readonly finished: true;
632
- readonly terminal: AgentCandidateExecutionTerminalRecord;
633
- } | {
634
- readonly finished: false;
635
- readonly terminal: AgentCandidateExecutionTerminalRecord;
636
- /** True when a repeated finish supplied the same terminal digest. */
637
- readonly exactReplay: boolean;
638
- };
639
- /** Result of durably staging the one immutable terminal outbox entry. */
640
- type AgentCandidateExecutionStageResult = {
641
- readonly staged: true;
642
- readonly terminal: AgentCandidateExecutionTerminalRecord;
643
- } | {
644
- readonly staged: false;
645
- readonly terminal: AgentCandidateExecutionTerminalRecord;
646
- readonly exactReplay: boolean;
647
- };
648
- /** Result of crossing the irreversible candidate-may-run boundary. */
649
- type AgentCandidateExecutionPhaseResult = {
650
- readonly marked: true;
651
- readonly phase: 'candidate-may-run';
652
- } | {
653
- readonly marked: false;
654
- readonly phase: 'candidate-may-run';
655
- };
656
- type AgentCandidateRetryRejection = 'prior-attempt-missing' | 'prior-attempt-running' | 'prior-attempt-succeeded' | 'prior-attempt-spent-model-calls' | 'prior-attempt-not-pre-model-infrastructure' | 'retry-lineage-mismatch';
657
- /**
658
- * Atomic one-shot store for candidate execution attempts.
659
- *
660
- * Implementations must linearize both methods across every process sharing the
661
- * store. Terminal publication is deliberately two-step: `stageTerminal`
662
- * fsyncs the complete immutable outbox record, then `finish` publishes exactly
663
- * those staged bytes by digest. A crash between the two leaves recoverable
664
- * evidence rather than an ambiguous completed run.
665
- */
666
- interface AgentCandidateExecutionClaimStore {
667
- tryClaim(claim: AgentCandidateExecutionClaim): Promise<AgentCandidateExecutionClaimResult>;
668
- getAttempt(attempt: AgentCandidateExecutionAttemptRef): Promise<AgentCandidateExecutionAttemptRecord | undefined>;
669
- /** Persist the point after which candidate code may have run. */
670
- markCandidateMayRun(lease: AgentCandidateExecutionLease): Promise<AgentCandidateExecutionPhaseResult>;
671
- /** Fsync the complete terminal record into the durable outbox. */
672
- stageTerminal(lease: AgentCandidateExecutionLease, result: AgentCandidateExecutionTerminalResult): Promise<AgentCandidateExecutionStageResult>;
673
- /** Publish exactly the staged terminal identified by `terminalDigest`. */
674
- finish(lease: AgentCandidateExecutionLease, terminalDigest: Sha256Digest): Promise<AgentCandidateExecutionFinishResult>;
675
- /**
676
- * Write a failed terminal only after the lease expired and a trusted worker
677
- * independently proved process death plus model and memory closure.
678
- */
679
- recoverExpired(attempt: AgentCandidateExecutionAttemptRef, evidence: AgentCandidateExecutionRecoveryEvidence): Promise<AgentCandidateExecutionFinishResult>;
680
- }
681
- interface InMemoryAgentCandidateExecutionClaimStoreOptions {
682
- /** Testable evaluator clock; defaults to `Date.now`. */
683
- now?: () => number;
684
- }
685
- /** Single-process lifecycle implementation. */
686
- declare class InMemoryAgentCandidateExecutionClaimStore implements AgentCandidateExecutionClaimStore {
687
- private readonly claims;
688
- private readonly now;
689
- constructor(options?: InMemoryAgentCandidateExecutionClaimStoreOptions);
690
- tryClaim(requested: AgentCandidateExecutionClaim): Promise<AgentCandidateExecutionClaimResult>;
691
- getAttempt(requestedAttempt: AgentCandidateExecutionAttemptRef): Promise<AgentCandidateExecutionAttemptRecord | undefined>;
692
- markCandidateMayRun(requestedLease: AgentCandidateExecutionLease): Promise<AgentCandidateExecutionPhaseResult>;
693
- stageTerminal(requestedLease: AgentCandidateExecutionLease, result: AgentCandidateExecutionTerminalResult): Promise<AgentCandidateExecutionStageResult>;
694
- finish(requestedLease: AgentCandidateExecutionLease, requestedTerminalDigest: Sha256Digest): Promise<AgentCandidateExecutionFinishResult>;
695
- recoverExpired(requestedAttempt: AgentCandidateExecutionAttemptRef, evidence: AgentCandidateExecutionRecoveryEvidence): Promise<AgentCandidateExecutionFinishResult>;
696
- private requireClaim;
697
- }
698
-
699
- interface ExecutePreparedAgentCandidateOptions {
700
- executor: AgentCandidateExecutorPort;
701
- grader: AgentCandidateBenchmarkGraderPort;
702
- outputArtifacts: AgentCandidateOutputArtifactPort;
703
- traceStore: TraceStore;
704
- /** Long-lived evaluator-owned store shared by every process that can run this benchmark. */
705
- claimStore: AgentCandidateExecutionClaimStore;
706
- /** Maximum time to prove process death and revoke protected access after a run ends. */
707
- cleanupTimeoutMs?: number;
708
- /** Maximum time for task verification, executable grading, and receipt construction. */
709
- resultTimeoutMs?: number;
710
- }
711
- /** Executes and finalizes one durably claimed candidate without exposing an unproven result. */
712
- declare function executePreparedAgentCandidate(prepared: PreparedAgentCandidateExecution, options: ExecutePreparedAgentCandidateOptions): Promise<AgentCandidateRunFinalization>;
713
-
714
- interface PrepareAgentCandidateExecutionOptions {
715
- cleanupTimeoutMs?: number;
716
- /** Maximum time for task verification, executable grading, and receipt construction. */
717
- resultTimeoutMs?: number;
718
- }
719
- /** Materializes a verified candidate into one immutable evaluator-owned execution plan. */
720
- declare function prepareAgentCandidateExecution(candidate: VerifiedAgentCandidate, task: AgentCandidateTaskExecution, ports: AgentCandidateExecutionPorts, options?: PrepareAgentCandidateExecutionOptions): Promise<PreparedAgentCandidateExecution>;
721
-
722
- export { InMemoryAgentCandidateExecutionClaimStore as $, type AgentCandidateBundleInput as A, type AgentCandidateExecutorProfileFile as B, type AgentCandidateExecutorRequest as C, type AgentCandidateExecutorStopRequest as D, type ExecutePreparedAgentCandidateOptions as E, type AgentCandidateExecutorTaskOutcomeCapture as F, type AgentCandidateExecutorWorkspaceFile as G, type AgentCandidateExecutorWorkspaceInput as H, type AgentCandidateMemoryPort as I, type AgentCandidateMemoryResetResult as J, type AgentCandidateModelLimits as K, type AgentCandidateModelPort as L, type AgentCandidateOutputArtifactPort as M, type AgentCandidateOutputPurpose as N, type AgentCandidateProtectedModelActivation as O, type PrepareAgentCandidateExecutionOptions as P, type AgentCandidateProtectedModelCall as Q, type AgentCandidateProtectedModelReservation as R, type AgentCandidateProtectedModelSettlement as S, type AgentCandidateProtectedRunCapture as T, type AgentCandidateRepositoryPort as U, type AgentCandidateRetryRejection as V, type AgentCandidateVerificationPorts as W, type AgentCandidateWorkspacePort as X, CANDIDATE_TRACE_ENV as Y, CANDIDATE_TRACE_TAGS as Z, type CanonicalCandidateDocument as _, type AgentCandidateTaskExecution as a, type PreparedAgentCandidateExecution as a0, type PreparedAgentCandidateInstruction as a1, type PreparedAgentCandidateKnowledge as a2, type PreparedAgentCandidateLaunch as a3, type PreparedAgentCandidateTrace as a4, type ResolvedAgentCandidateContainer as a5, type VerifiedAgentCandidate as a6, type VerifiedAgentCandidateTaskOutcome as a7, executePreparedAgentCandidate as a8, prepareAgentCandidateExecution as a9, sealAgentCandidateBundle as aa, type AgentCandidateExecutionPorts as b, type AgentCandidateRunFinalization as c, type AgentCandidateArtifactPort as d, type AgentCandidateBenchmarkGraderIdentity as e, type AgentCandidateBenchmarkGraderPort as f, type AgentCandidateContainerPort as g, type AgentCandidateExecutionAttemptRecord as h, type AgentCandidateExecutionAttemptRef as i, type AgentCandidateExecutionClaim as j, type AgentCandidateExecutionClaimResult as k, type AgentCandidateExecutionClaimStore as l, type AgentCandidateExecutionCleanupHandles as m, type AgentCandidateExecutionFailureClass as n, type AgentCandidateExecutionFinishResult as o, type AgentCandidateExecutionLease as p, type AgentCandidateExecutionPhase as q, type AgentCandidateExecutionPhaseResult as r, type AgentCandidateExecutionRecoveryEvidence as s, type AgentCandidateExecutionStageResult as t, type AgentCandidateExecutionTerminalRecord as u, type AgentCandidateExecutionTerminalResult as v, type AgentCandidateExecutionUsage as w, type AgentCandidateExecutorFinalCapture as x, type AgentCandidateExecutorMemoryCapture as y, type AgentCandidateExecutorPort as z };
491
+ export { type AgentCandidateExecutorPort as A, type AgentCandidateWorkspacePort as B, CANDIDATE_TRACE_ENV as C, CANDIDATE_TRACE_TAGS as D, type CanonicalCandidateDocument as E, type PreparedAgentCandidateInstruction as F, type PreparedAgentCandidateKnowledge as G, type PreparedAgentCandidateLaunch as H, type PreparedAgentCandidateTrace as I, type VerifiedAgentCandidateTaskOutcome as J, type PreparedAgentCandidateExecution as P, type ResolvedAgentCandidateContainer as R, type VerifiedAgentCandidate as V, type AgentCandidateBenchmarkGraderPort as a, type AgentCandidateOutputArtifactPort as b, type AgentCandidateRunFinalization as c, type AgentCandidateTaskExecution as d, type AgentCandidateExecutionPorts as e, type AgentCandidateArtifactPort as f, type AgentCandidateContainerPort as g, type AgentCandidateExecutorFinalCapture as h, type AgentCandidateExecutorMemoryCapture as i, type AgentCandidateExecutorProfileFile as j, type AgentCandidateExecutorRequest as k, type AgentCandidateExecutorStopRequest as l, type AgentCandidateExecutorTaskOutcomeCapture as m, type AgentCandidateExecutorWorkspaceFile as n, type AgentCandidateExecutorWorkspaceInput as o, type AgentCandidateMemoryPort as p, type AgentCandidateMemoryResetResult as q, type AgentCandidateModelLimits as r, type AgentCandidateModelPort as s, type AgentCandidateOutputPurpose as t, type AgentCandidateProtectedModelActivation as u, type AgentCandidateProtectedModelReservation as v, type AgentCandidateProtectedModelSettlement as w, type AgentCandidateProtectedRunCapture as x, type AgentCandidateRepositoryPort as y, type AgentCandidateVerificationPorts as z };
@@ -6,33 +6,22 @@ import { AnalystFinding, AnalystRunInputs, AnalystRunResult, AnalystRunEvent, Fi
6
6
  * The orchestrator is the one call agent apps reach for. It binds:
7
7
  * - the AnalystRegistry + a chosen set of analyst kinds
8
8
  * - a FindingsStore (durable JSONL ledger + cross-run diff)
9
- * - an optional KnowledgeAdapter (closes the analysis → wiki side)
10
- * - an optional ImprovementAdapter (closes the analysis → prompt /
11
- * tool / scaffolding side)
9
+ * - an optional knowledge proposal source
10
+ * - an optional agent-surface proposal source
12
11
  *
13
12
  * Adapters keep agent-runtime decoupled from the specific storage
14
13
  * implementation. Consumers wire agent-knowledge once at app init.
15
14
  */
16
15
 
17
16
  /** Knowledge-side bridge — consumers wire `proposeFromFindings` from agent-knowledge. */
18
- interface KnowledgeAdapter<TProposal = unknown> {
17
+ interface KnowledgeProposalSource<TProposal = unknown> {
19
18
  /**
20
19
  * Convert a findings batch into proposals. Returns the partitioned
21
- * result so the loop can report (and optionally fail on) malformed
20
+ * result so the loop can report malformed
22
21
  * findings. Implementations SHOULD honour the convention "non-
23
22
  * knowledge subjects return null and are counted in `skipped`."
24
23
  */
25
24
  proposeFromFindings(findings: ReadonlyArray<AnalystFinding>): Promise<KnowledgeProposalBatch<TProposal>> | KnowledgeProposalBatch<TProposal>;
26
- /**
27
- * Optional auto-apply. The loop calls this only when
28
- * `autoApply.knowledge` is true AND the proposal's source-finding
29
- * confidence ≥ `autoApply.knowledgeConfidenceThreshold`. Anything
30
- * below the threshold is returned in the report but never written.
31
- */
32
- apply?(proposals: ReadonlyArray<TProposal>): Promise<{
33
- written: string[];
34
- warnings: string[];
35
- }>;
36
25
  }
37
26
  interface KnowledgeProposalBatch<TProposal = unknown> {
38
27
  proposals: TProposal[];
@@ -43,13 +32,9 @@ interface KnowledgeProposalBatch<TProposal = unknown> {
43
32
  message: string;
44
33
  }>;
45
34
  }
46
- /** Improvement-side bridge — proposes / applies prompt + tool + scaffolding edits. */
47
- interface ImprovementAdapter<TEdit = unknown> {
35
+ /** Agent-surface bridge — proposes prompt, skill, tool, and scaffolding edits. */
36
+ interface ImprovementProposalSource<TEdit = unknown> {
48
37
  proposeFromFindings(findings: ReadonlyArray<AnalystFinding>): Promise<ImprovementEditBatch<TEdit>> | ImprovementEditBatch<TEdit>;
49
- apply?(edits: ReadonlyArray<TEdit>): Promise<{
50
- applied: string[];
51
- warnings: string[];
52
- }>;
53
38
  }
54
39
  interface ImprovementEditBatch<TEdit = unknown> {
55
40
  edits: TEdit[];
@@ -60,17 +45,6 @@ interface ImprovementEditBatch<TEdit = unknown> {
60
45
  message: string;
61
46
  }>;
62
47
  }
63
- /** Tunable safety rails for auto-apply. */
64
- interface AutoApplyPolicy {
65
- /** When true AND `knowledgeAdapter.apply` exists, write knowledge proposals. */
66
- knowledge?: boolean;
67
- /** Minimum source-finding confidence required to auto-apply a knowledge proposal. */
68
- knowledgeConfidenceThreshold?: number;
69
- /** When true AND `improvementAdapter.apply` exists, apply improvement edits. */
70
- improvement?: boolean;
71
- /** Minimum source-finding confidence required to auto-apply an improvement edit. */
72
- improvementConfidenceThreshold?: number;
73
- }
74
48
  interface RunAnalystLoopOpts {
75
49
  /** The run id of the work being analysed. */
76
50
  runId: string;
@@ -94,18 +68,16 @@ interface RunAnalystLoopOpts {
94
68
  /** Strategy for forwarding prior findings into `ctx.priorFindings`. */
95
69
  priorFindingsStrategy?: 'per-kind' | 'wildcard' | 'none';
96
70
  /** Knowledge-side bridge — usually `agent-knowledge`'s `proposeFromFindings`. */
97
- knowledgeAdapter?: KnowledgeAdapter;
98
- /** Improvement-side bridge — usually a consumer-specific prompt/tool diff producer. */
99
- improvementAdapter?: ImprovementAdapter;
100
- /** Auto-apply rails. Default off; review-then-apply is the safer default. */
101
- autoApply?: AutoApplyPolicy;
71
+ knowledgeProposalSource?: KnowledgeProposalSource;
72
+ /** Agent-surface bridge — usually a prompt, skill, or tool diff producer. */
73
+ improvementProposalSource?: ImprovementProposalSource;
102
74
  /** Optional logger. Defaults to `console.log` for `[analyst-loop]` lines. */
103
75
  log?: (msg: string, fields?: Record<string, unknown>) => void;
104
76
  /**
105
77
  * Event sink for live progress. Called for every phase of the loop:
106
78
  * baseline resolution, registry events forwarded from `runStream`,
107
- * ledger persistence, diff, knowledge / improvement proposals +
108
- * apply outcomes, and the terminal `loop-completed`. Awaited so
79
+ * ledger persistence, diff, knowledge / improvement proposals, and
80
+ * the terminal `loop-completed`. Awaited so
109
81
  * slow sinks (SSE write, JSONL append) apply backpressure.
110
82
  *
111
83
  * The callback MUST NOT throw — exceptions propagate and abort the
@@ -123,25 +95,21 @@ interface RunAnalystLoopResult<TProposal = unknown, TEdit = unknown> {
123
95
  }
124
96
  interface KnowledgeReport<TProposal = unknown> {
125
97
  proposals: TProposal[];
126
- applied: string[];
127
98
  skipped: number;
128
99
  errors: Array<{
129
100
  findingId: string;
130
101
  subject: string;
131
102
  message: string;
132
103
  }>;
133
- withheld_for_review: number;
134
104
  }
135
105
  interface ImprovementReport<TEdit = unknown> {
136
106
  edits: TEdit[];
137
- applied: string[];
138
107
  skipped: number;
139
108
  errors: Array<{
140
109
  findingId: string;
141
110
  subject: string;
142
111
  message: string;
143
112
  }>;
144
- withheld_for_review: number;
145
113
  }
146
114
  /**
147
115
  * Narrowed shape we accept for `AnalystRegistry` so the orchestrator
@@ -220,26 +188,16 @@ type AnalystLoopEvent = {
220
188
  proposalCount: number;
221
189
  skipped: number;
222
190
  errors: number;
223
- } | {
224
- type: 'knowledge-applied';
225
- runId: string;
226
- writtenCount: number;
227
- withheldForReview: number;
228
191
  } | {
229
192
  type: 'improvement-proposed';
230
193
  runId: string;
231
194
  editCount: number;
232
195
  skipped: number;
233
196
  errors: number;
234
- } | {
235
- type: 'improvement-applied';
236
- runId: string;
237
- appliedCount: number;
238
- withheldForReview: number;
239
197
  } | {
240
198
  type: 'loop-completed';
241
199
  runId: string;
242
200
  durationMs: number;
243
201
  };
244
202
 
245
- export type { AnalystLoopEvent as A, FindingsStoreLike as F, ImprovementAdapter as I, KnowledgeAdapter as K, RunAnalystLoopOpts as R, RunAnalystLoopResult as a, AnalystRegistryLike as b, AnalystRegistryStreamingLike as c, AutoApplyPolicy as d, ImprovementEditBatch as e, ImprovementReport as f, KnowledgeProposalBatch as g, KnowledgeReport as h };
203
+ export type { AnalystLoopEvent as A, FindingsStoreLike as F, ImprovementProposalSource as I, KnowledgeProposalBatch as K, RunAnalystLoopOpts as R, RunAnalystLoopResult as a, AnalystRegistryLike as b, AnalystRegistryStreamingLike as c, ImprovementEditBatch as d, ImprovementReport as e, KnowledgeProposalSource as f, KnowledgeReport as g };