@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
package/dist/index.js CHANGED
@@ -1,27 +1,14 @@
1
- import {
2
- RESEARCH_SUPERVISOR_SYSTEM_PROMPT,
3
- createAgentKnowledgeReadinessCheck,
4
- createSupervisedKnowledgeUpdater,
5
- formatSupervisedKnowledgeTask,
6
- knowledgeReadinessDeliverable,
7
- runKnowledgeImprovementJob,
8
- runSupervisedKnowledgeUpdate
9
- } from "./chunk-HGRW27YY.js";
10
- import "./chunk-5QOB7H74.js";
11
1
  import {
12
2
  FileAgentCandidateExecutionClaimStore,
13
3
  buildAgentCandidateBundle,
14
- captureAgentCandidateWorkspace,
15
- captureAgentCandidateWorkspaceFiles,
16
- createAgentCandidateWorkspacePort,
17
4
  createProtectedAgentCandidateModelPort,
18
5
  disposePreparedAgentCandidateExecution,
19
6
  recoverExpiredAgentCandidateExecution
20
- } from "./chunk-TVJQAYQM.js";
7
+ } from "./chunk-6XKPVJAZ.js";
21
8
  import {
22
9
  mcpToolsForRuntimeMcp,
23
10
  mcpToolsForRuntimeMcpSubset
24
- } from "./chunk-33OG2NN3.js";
11
+ } from "./chunk-WYC2XJF2.js";
25
12
  import {
26
13
  DEFAULT_ROUTER_BASE_URL,
27
14
  cleanModelId,
@@ -40,7 +27,7 @@ import {
40
27
  runLoopRunnerCli,
41
28
  selfImproveLoopRunner,
42
29
  worktreeLoopRunner
43
- } from "./chunk-XP5KDM3R.js";
30
+ } from "./chunk-SGQ4YIQW.js";
44
31
  import "./chunk-SGKPNBXE.js";
45
32
  import {
46
33
  CircuitBreakerState,
@@ -67,46 +54,69 @@ import {
67
54
  sleep,
68
55
  slugifySpeaker,
69
56
  turnId
70
- } from "./chunk-VYA2YEKA.js";
57
+ } from "./chunk-2KGAN2HM.js";
58
+ import "./chunk-FXF2OL34.js";
59
+ import {
60
+ InMemoryRuntimeSessionStore,
61
+ createIterableBackend,
62
+ createOpenAICompatibleBackend,
63
+ createSandboxPromptBackend,
64
+ normalizeBackendStreamEvent,
65
+ nowIso,
66
+ startOrResumeRuntimeSession,
67
+ touchSession
68
+ } from "./chunk-Q2JSAVQ3.js";
69
+ import {
70
+ RESEARCH_SUPERVISOR_SYSTEM_PROMPT,
71
+ buildKnowledgeImprovementExperimentBundles,
72
+ createAgentKnowledgeReadinessCheck,
73
+ createKnowledgeImprovementActivationExecutor,
74
+ createSupervisedKnowledgeUpdater,
75
+ formatSupervisedKnowledgeTask,
76
+ knowledgeReadinessDeliverable,
77
+ runKnowledgeImprovementJob,
78
+ runSupervisedKnowledgeUpdate
79
+ } from "./chunk-3XKSBI2U.js";
80
+ import "./chunk-5QOB7H74.js";
81
+ import {
82
+ captureAgentCandidateWorkspace,
83
+ captureAgentCandidateWorkspaceFiles,
84
+ createAgentCandidateWorkspacePort,
85
+ sealAgentCandidateBundle
86
+ } from "./chunk-BLQIYRVR.js";
71
87
  import {
72
- applyImprovementWinnerToProfile,
88
+ AGENTIC_PROFILE_RESOURCE_ROOT,
89
+ agenticGenerator,
90
+ commandVerifier,
73
91
  improve,
74
92
  improvementDriver,
75
93
  rawTraceDistiller
76
- } from "./chunk-PCURO3DL.js";
94
+ } from "./chunk-PSOCBNM3.js";
77
95
  import {
96
+ AGENT_CANDIDATE_EXECUTION_SUPPORT,
97
+ CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV,
98
+ CANDIDATE_KNOWLEDGE_ROOT_ENV,
78
99
  CANDIDATE_TRACE_ENV,
79
100
  CANDIDATE_TRACE_TAGS,
80
101
  InMemoryAgentCandidateExecutionClaimStore,
81
102
  applyExactAgentProfileDiff,
82
103
  candidateExecutionClaim,
104
+ candidateKnowledgeExecutionPaths,
83
105
  canonicalCandidateDigest,
84
106
  executePreparedAgentCandidate,
85
107
  parseExactAgentProfile,
86
108
  parseExactAgentProfileDiff,
87
109
  persistCandidateOutputArtifact,
88
110
  prepareAgentCandidateExecution,
89
- sealAgentCandidateBundle,
90
111
  verifyAgentCandidateBundle
91
- } from "./chunk-CNH7DF7Z.js";
92
- import "./chunk-U33YZ7B2.js";
112
+ } from "./chunk-YOLKCWRV.js";
93
113
  import {
94
114
  composeRuntimeHooks,
95
115
  defineRuntimeHooks,
96
116
  notifyRuntimeDecisionPoint,
97
117
  notifyRuntimeHookEvent
98
- } from "./chunk-C3UKLQ54.js";
118
+ } from "./chunk-UQ6PNNXM.js";
99
119
  import "./chunk-DPEUKJRO.js";
100
- import {
101
- InMemoryRuntimeSessionStore,
102
- createIterableBackend,
103
- createOpenAICompatibleBackend,
104
- createSandboxPromptBackend,
105
- newRuntimeSession,
106
- normalizeBackendStreamEvent,
107
- nowIso,
108
- touchSession
109
- } from "./chunk-AEG3NGJ2.js";
110
120
  import {
111
121
  INTELLIGENCE_WIRE_VERSION,
112
122
  buildLoopOtelSpans,
@@ -120,23 +130,12 @@ import {
120
130
  sanitizeAgentRuntimeEvent,
121
131
  sanitizeKnowledgeReadinessReport,
122
132
  sanitizeRuntimeStreamEvent
123
- } from "./chunk-ISTDY47H.js";
124
- import "./chunk-WIPGQ4GT.js";
125
- import "./chunk-VSWBYWFK.js";
133
+ } from "./chunk-HZDEXTSL.js";
134
+ import "./chunk-IMSNJSXH.js";
135
+ import "./chunk-M6MD6JBS.js";
126
136
  import "./chunk-3MDZX7YU.js";
127
- import "./chunk-QDSOD7RC.js";
137
+ import "./chunk-FD2MBMOH.js";
128
138
  import "./chunk-M22PL4GH.js";
129
- import {
130
- mcpBuildPrompt,
131
- mcpServeVerifier,
132
- toolBuildPrompt
133
- } from "./chunk-6O73TRHW.js";
134
- import {
135
- AGENTIC_PROFILE_RESOURCE_ROOT,
136
- agenticGenerator,
137
- commandVerifier
138
- } from "./chunk-D3H7F6L2.js";
139
- import "./chunk-EP6RVHMX.js";
140
139
  import {
141
140
  AgentEvalError,
142
141
  BackendTransportError,
@@ -145,10 +144,8 @@ import {
145
144
  NotFoundError,
146
145
  PlannerError,
147
146
  RuntimeRunStateError,
148
- SessionMismatchError,
149
147
  ValidationError
150
148
  } from "./chunk-YEJR7IXO.js";
151
- import "./chunk-DGUM43GV.js";
152
149
 
153
150
  // src/durable/chat-engine.ts
154
151
  var encoder = new TextEncoder();
@@ -236,6 +233,142 @@ function deriveExecutionId(input) {
236
233
  return `${input.projectId}:${input.sessionId}:${input.turnIndex}`;
237
234
  }
238
235
 
236
+ // src/improvement/build-prompts.ts
237
+ function findingLines(findings) {
238
+ return findings.map((f) => {
239
+ const where = f.subject ? ` [${f.subject}]` : "";
240
+ const action = f.recommended_action ? ` \u2192 ${f.recommended_action}` : "";
241
+ return `- (${f.severity})${where} ${f.claim}${action}`;
242
+ });
243
+ }
244
+ function toolBuildPrompt(args) {
245
+ return [
246
+ "You are building a new TOOL for this codebase to address the gaps below.",
247
+ "Write the tool as a small, self-contained module PLUS tests that exercise it.",
248
+ "The tool must compile and its tests must pass \u2014 they will be run automatically;",
249
+ "if verification fails you will get the error and another attempt. Do not commit;",
250
+ "leave the changes in the working tree.",
251
+ "",
252
+ "Gaps the tool should close:",
253
+ ...findingLines(args.findings)
254
+ ].join("\n");
255
+ }
256
+ function mcpBuildPrompt(args) {
257
+ return [
258
+ "You are building a new MCP SERVER (Model Context Protocol) that exposes",
259
+ "tool(s) addressing the gaps below, so any harness can mount it.",
260
+ "Requirements that WILL be checked by booting the server:",
261
+ "- it starts over stdio and answers the MCP `initialize` handshake,",
262
+ "- `tools/list` returns at least one tool with a valid input schema.",
263
+ "Newline-delimited JSON-RPC 2.0, protocol version 2024-11-05. Include a start",
264
+ "command (e.g. a package.json `start` script or a clear entrypoint). If the",
265
+ "boot-and-probe fails you will get the error and another attempt. Do not",
266
+ "commit; leave the changes in the working tree.",
267
+ "",
268
+ "Capabilities the server should provide:",
269
+ ...findingLines(args.findings)
270
+ ].join("\n");
271
+ }
272
+
273
+ // src/improvement/mcp-serve-verifier.ts
274
+ import { spawn } from "child_process";
275
+ import { createInterface } from "readline";
276
+ var PROTOCOL_VERSION = "2024-11-05";
277
+ function mcpServeVerifier(spec) {
278
+ const timeoutMs = spec.timeoutMs ?? 3e4;
279
+ const minTools = spec.minTools ?? 1;
280
+ return (worktreePath) => new Promise((resolve, reject) => {
281
+ const child = spawn(spec.command, spec.args ?? [], {
282
+ cwd: worktreePath,
283
+ stdio: ["pipe", "pipe", "pipe"],
284
+ env: { ...process.env, ...spec.env }
285
+ });
286
+ const stderr = [];
287
+ let settled = false;
288
+ let nextId = 1;
289
+ const initId = nextId++;
290
+ let listId = -1;
291
+ const settle = (fn) => {
292
+ if (settled) return;
293
+ settled = true;
294
+ clearTimeout(timer);
295
+ rl.close();
296
+ child.kill("SIGKILL");
297
+ fn();
298
+ };
299
+ const withStderr = (msg) => stderr.length > 0 ? `${msg}
300
+ stderr:
301
+ ${stderr.join("").slice(-2e3)}` : msg;
302
+ const pass = () => settle(() => resolve({ ok: true }));
303
+ const failCandidate = (msg) => settle(() => resolve({ ok: false, feedback: withStderr(msg) }));
304
+ const setupFault = (err) => settle(() => reject(err));
305
+ const failStdin = (err) => failCandidate(`writing to MCP server stdin failed: ${err.message}`);
306
+ const send = (msg) => {
307
+ try {
308
+ child.stdin.write(`${JSON.stringify(msg)}
309
+ `);
310
+ return true;
311
+ } catch (err) {
312
+ failStdin(err);
313
+ return false;
314
+ }
315
+ };
316
+ child.on("error", (err) => {
317
+ const code = err.code;
318
+ setupFault(
319
+ code === "ENOENT" ? new Error(
320
+ `mcpServeVerifier: '${spec.command}' not found in PATH (setup bug, not a failed candidate)`
321
+ ) : new Error(`mcpServeVerifier: '${spec.command}' failed to spawn: ${err.message}`)
322
+ );
323
+ });
324
+ child.on("exit", (code, signal) => {
325
+ failCandidate(`MCP server exited (code ${code}, signal ${signal}) before serving`);
326
+ });
327
+ child.stdin.on("error", failStdin);
328
+ child.stderr.on("data", (d) => stderr.push(String(d)));
329
+ const rl = createInterface({ input: child.stdout });
330
+ rl.on("line", (line) => {
331
+ let msg;
332
+ try {
333
+ msg = JSON.parse(line);
334
+ } catch {
335
+ return;
336
+ }
337
+ if (!msg || typeof msg !== "object") return;
338
+ if (msg.id === initId) {
339
+ if (msg.error) return failCandidate(`initialize errored: ${JSON.stringify(msg.error)}`);
340
+ if (!send({ jsonrpc: "2.0", method: "notifications/initialized" })) return;
341
+ listId = nextId++;
342
+ send({ jsonrpc: "2.0", id: listId, method: "tools/list" });
343
+ return;
344
+ }
345
+ if (msg.id === listId) {
346
+ if (msg.error) return failCandidate(`tools/list errored: ${JSON.stringify(msg.error)}`);
347
+ const tools = msg.result?.tools;
348
+ if (!Array.isArray(tools)) return failCandidate("tools/list result has no tools array");
349
+ if (tools.length < minTools) {
350
+ return failCandidate(`tools/list returned ${tools.length} tool(s), need >= ${minTools}`);
351
+ }
352
+ return pass();
353
+ }
354
+ });
355
+ const timer = setTimeout(
356
+ () => failCandidate(`MCP server did not complete the handshake within ${timeoutMs}ms`),
357
+ timeoutMs
358
+ );
359
+ send({
360
+ jsonrpc: "2.0",
361
+ id: initId,
362
+ method: "initialize",
363
+ params: {
364
+ protocolVersion: PROTOCOL_VERSION,
365
+ capabilities: {},
366
+ clientInfo: { name: "agent-runtime-mcp-verify", version: "0" }
367
+ }
368
+ });
369
+ });
370
+ }
371
+
239
372
  // src/improvement/profile-diff-proposer.ts
240
373
  import { canonicalJson } from "@tangle-network/agent-eval";
241
374
  import {
@@ -256,13 +389,13 @@ function profileDiffProposer(options) {
256
389
  const candidates = [];
257
390
  const normalizedBaseline = applyExactAgentProfileDiff(
258
391
  profile,
259
- { schemaVersion: 1, kind: "agent-profile-diff" },
392
+ { kind: "agent-profile-diff" },
260
393
  "profile diff baseline"
261
394
  );
262
395
  const seen = /* @__PURE__ */ new Set([canonicalJson(normalizedBaseline)]);
263
396
  for (const [index, proposal] of proposals.entries()) {
264
397
  if (candidates.length >= ctx.populationSize || ctx.signal.aborted) break;
265
- const diff = parseExactAgentProfileDiff(proposal.diff, `profile diff proposal ${index}`);
398
+ const diff = parseExactAgentProfileDiff(proposal, `profile diff proposal ${index}`);
266
399
  const axes = changedAgentProfileAxes(diff);
267
400
  if (axes.length === 0) continue;
268
401
  const candidate = applyExactAgentProfileDiff(
@@ -275,16 +408,16 @@ function profileDiffProposer(options) {
275
408
  seen.add(surface);
276
409
  candidates.push({
277
410
  surface,
278
- label: proposal.label ?? diff.title ?? diff.id ?? `Change ${axes.join(", ")}`,
279
- rationale: candidateRationale(proposal, diff, axes)
411
+ label: diff.title ?? diff.id ?? `Change ${axes.join(", ")}`,
412
+ rationale: candidateRationale(diff, axes)
280
413
  });
281
414
  }
282
415
  return candidates;
283
416
  }
284
417
  };
285
418
  }
286
- function candidateRationale(proposal, diff, axes) {
287
- const reason = proposal.rationale ?? diff.rationale ?? `Changes profile axes: ${axes.join(", ")}.`;
419
+ function candidateRationale(diff, axes) {
420
+ const reason = diff.rationale ?? `Changes profile axes: ${axes.join(", ")}.`;
288
421
  const source = diff.source ? [diff.source.kind, ...diff.source.artifacts ?? []].join(" \xB7 ") : "source unspecified";
289
422
  return `${reason} Source: ${source}. Diff: ${canonicalCandidateDigest(diff)}.`;
290
423
  }
@@ -306,7 +439,7 @@ function reflectiveGenerator(opts) {
306
439
  return {
307
440
  kind: "reflective",
308
441
  async generate({ worktreePath, findings }) {
309
- const batch = await opts.improvementAdapter.proposeFromFindings(findings);
442
+ const batch = await opts.improvementProposalSource.proposeFromFindings(findings);
310
443
  if (batch.edits.length === 0) return { applied: false, summary: "" };
311
444
  let applied = 0;
312
445
  for (const edit of batch.edits) {
@@ -557,19 +690,16 @@ async function* runAgentTaskStream(options) {
557
690
  return;
558
691
  }
559
692
  const store = options.sessionStore;
560
- const existing = options.sessionId ? await store?.get(options.sessionId) : void 0;
561
- const shouldResume = Boolean(options.resume && existing);
562
- let session = shouldResume && existing ? await resumeBackendSession(options.backend, existing, input, {
563
- task,
564
- knowledge,
565
- signal: options.signal
566
- }) : await startBackendSession(
567
- options.backend,
693
+ const opened = await startOrResumeRuntimeSession({
694
+ backend: options.backend,
568
695
  input,
569
- { task, knowledge, signal: options.signal },
570
- options.sessionId
571
- );
572
- await store?.put(session);
696
+ context: { task, knowledge, signal: options.signal },
697
+ store,
698
+ sessionId: options.sessionId,
699
+ resume: options.resume
700
+ });
701
+ let session = opened.session;
702
+ const shouldResume = opened.resumed;
573
703
  const sessionEvent = streamEvent({
574
704
  type: shouldResume ? "session_resumed" : "session_created",
575
705
  task,
@@ -587,7 +717,7 @@ async function* runAgentTaskStream(options) {
587
717
  yield backendStart;
588
718
  let finalText = "";
589
719
  try {
590
- for await (const rawEvent of options.backend.stream(input, {
720
+ for await (const rawEvent of options.backend.stream(opened.input, {
591
721
  task,
592
722
  knowledge,
593
723
  session,
@@ -709,17 +839,6 @@ async function runKnowledgePreflightStream(task, questions, acquisitionPlans, pr
709
839
  function streamEvent(event) {
710
840
  return { ...event, timestamp: nowIso() };
711
841
  }
712
- async function startBackendSession(backend, input, context, requestedSessionId) {
713
- if (backend.start) return backend.start(input, { ...context, requestedSessionId });
714
- return newRuntimeSession(backend.kind, requestedSessionId);
715
- }
716
- async function resumeBackendSession(backend, session, input, context) {
717
- if (session.backend !== backend.kind) {
718
- throw new SessionMismatchError(session.backend, backend.kind);
719
- }
720
- if (backend.resume) return backend.resume(session, input, context);
721
- return touchSession({ ...session, status: "active" });
722
- }
723
842
  function buildReadiness(task, provider) {
724
843
  if (provider?.buildReadiness) return provider.buildReadiness(task);
725
844
  return scoreKnowledgeReadiness({
@@ -1394,8 +1513,11 @@ function randomSuffix2(len = 8) {
1394
1513
  }
1395
1514
  export {
1396
1515
  AGENTIC_PROFILE_RESOURCE_ROOT,
1516
+ AGENT_CANDIDATE_EXECUTION_SUPPORT,
1397
1517
  AgentEvalError,
1398
1518
  BackendTransportError,
1519
+ CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV,
1520
+ CANDIDATE_KNOWLEDGE_ROOT_ENV,
1399
1521
  CANDIDATE_TRACE_ENV,
1400
1522
  CANDIDATE_TRACE_TAGS,
1401
1523
  CircuitBreakerState,
@@ -1421,15 +1543,16 @@ export {
1421
1543
  ValidationError,
1422
1544
  agenticGenerator,
1423
1545
  applyExactAgentProfileDiff,
1424
- applyImprovementWinnerToProfile,
1425
1546
  applyRunRecordDefaults,
1426
1547
  auditLoopRunner,
1427
1548
  buildAgentCandidateBundle,
1428
1549
  buildForwardHeaders,
1550
+ buildKnowledgeImprovementExperimentBundles,
1429
1551
  buildLoopOtelSpans,
1430
1552
  buildLoopSpanNodes,
1431
1553
  buildRuntimeEventOtelSpans,
1432
1554
  candidateExecutionClaim,
1555
+ candidateKnowledgeExecutionPaths,
1433
1556
  captureAgentCandidateWorkspace,
1434
1557
  captureAgentCandidateWorkspaceFiles,
1435
1558
  cleanModelId,
@@ -1440,6 +1563,7 @@ export {
1440
1563
  createAgentKnowledgeReadinessCheck,
1441
1564
  createConversationBackend,
1442
1565
  createIterableBackend,
1566
+ createKnowledgeImprovementActivationExecutor,
1443
1567
  createOpenAICompatibleBackend,
1444
1568
  createOtelExporter,
1445
1569
  createProtectedAgentCandidateModelPort,