@tangle-network/agent-runtime 0.95.0 → 0.97.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.
Files changed (86) hide show
  1. package/README.md +64 -15
  2. package/dist/activation-B0ZD7nfX.d.ts +63 -0
  3. package/dist/agent.d.ts +5 -169
  4. package/dist/agent.js +8 -229
  5. package/dist/agent.js.map +1 -1
  6. package/dist/analyst-loop.d.ts +6 -9
  7. package/dist/analyst-loop.js +1 -2
  8. package/dist/candidate-execution/index.js +6 -7
  9. package/dist/chunk-3XKSBI2U.js +474 -0
  10. package/dist/chunk-3XKSBI2U.js.map +1 -0
  11. package/dist/{chunk-6YBA64Z2.js → chunk-6XKPVJAZ.js} +5 -18
  12. package/dist/chunk-6XKPVJAZ.js.map +1 -0
  13. package/dist/{chunk-MKGRLDWB.js → chunk-BLQIYRVR.js} +17 -2
  14. package/dist/chunk-BLQIYRVR.js.map +1 -0
  15. package/dist/{chunk-QDSOD7RC.js → chunk-FD2MBMOH.js} +13 -101
  16. package/dist/chunk-FD2MBMOH.js.map +1 -0
  17. package/dist/{chunk-YLUOTX6U.js → chunk-FXF2OL34.js} +7 -7
  18. package/dist/{chunk-EP6RVHMX.js → chunk-HZDEXTSL.js} +848 -2
  19. package/dist/chunk-HZDEXTSL.js.map +1 -0
  20. package/dist/chunk-PSOCBNM3.js +2069 -0
  21. package/dist/chunk-PSOCBNM3.js.map +1 -0
  22. package/dist/{chunk-BPGXIKK7.js → chunk-SGQ4YIQW.js} +4 -4
  23. package/dist/{chunk-IADLKE7I.js → chunk-UQ6PNNXM.js} +5 -7
  24. package/dist/{chunk-IADLKE7I.js.map → chunk-UQ6PNNXM.js.map} +1 -1
  25. package/dist/{chunk-Z5I642SY.js → chunk-WYC2XJF2.js} +2 -2
  26. package/dist/{chunk-ZEYAT33L.js → chunk-Y3SRWZMP.js} +2 -2
  27. package/dist/{chunk-WTZ37EQY.js → chunk-YOLKCWRV.js} +197 -90
  28. package/dist/chunk-YOLKCWRV.js.map +1 -0
  29. package/dist/conversation.js +0 -1
  30. package/dist/environment-provider.js +0 -1
  31. package/dist/{agentic-generator-hCaQRAes.d.ts → improve-g75IE2Cx.d.ts} +152 -3
  32. package/dist/{improvement-adapter-BieWeK5J.d.ts → improvement-adapter-HAZz-7vK.d.ts} +8 -31
  33. package/dist/index.d.ts +41 -11
  34. package/dist/index.js +180 -51
  35. package/dist/index.js.map +1 -1
  36. package/dist/intelligence.d.ts +16 -9
  37. package/dist/intelligence.js +13 -8
  38. package/dist/intelligence.js.map +1 -1
  39. package/dist/knowledge.d.ts +30 -13
  40. package/dist/knowledge.js +11 -10
  41. package/dist/{loop-runner-bin-BIQldFS8.d.ts → loop-runner-bin-Cn1N2rRo.d.ts} +1 -1
  42. package/dist/loop-runner-bin.d.ts +2 -2
  43. package/dist/loop-runner-bin.js +6 -8
  44. package/dist/loops.d.ts +1 -1
  45. package/dist/loops.js +4 -6
  46. package/dist/mcp/bin.js +3 -5
  47. package/dist/mcp/bin.js.map +1 -1
  48. package/dist/mcp/index.js +10 -12
  49. package/dist/mcp/index.js.map +1 -1
  50. package/dist/platform.js +0 -2
  51. package/dist/platform.js.map +1 -1
  52. package/dist/primeintellect/index.js +0 -1
  53. package/dist/primeintellect/index.js.map +1 -1
  54. package/dist/profiles.js +0 -1
  55. package/dist/profiles.js.map +1 -1
  56. package/dist/{types-BC3bZpH0.d.ts → types-CmYCMbFT.d.ts} +12 -54
  57. package/package.json +8 -13
  58. package/skills/build-with-agent-runtime/SKILL.md +122 -213
  59. package/dist/chunk-6O73TRHW.js +0 -142
  60. package/dist/chunk-6O73TRHW.js.map +0 -1
  61. package/dist/chunk-6YBA64Z2.js.map +0 -1
  62. package/dist/chunk-AP7CPGMZ.js +0 -334
  63. package/dist/chunk-AP7CPGMZ.js.map +0 -1
  64. package/dist/chunk-DGUM43GV.js +0 -11
  65. package/dist/chunk-DGUM43GV.js.map +0 -1
  66. package/dist/chunk-DHCHL6OG.js +0 -625
  67. package/dist/chunk-DHCHL6OG.js.map +0 -1
  68. package/dist/chunk-EP6RVHMX.js.map +0 -1
  69. package/dist/chunk-G55QE4IQ.js +0 -1137
  70. package/dist/chunk-G55QE4IQ.js.map +0 -1
  71. package/dist/chunk-ISTDY47H.js +0 -849
  72. package/dist/chunk-ISTDY47H.js.map +0 -1
  73. package/dist/chunk-MKGRLDWB.js.map +0 -1
  74. package/dist/chunk-QDSOD7RC.js.map +0 -1
  75. package/dist/chunk-WTZ37EQY.js.map +0 -1
  76. package/dist/generator-YkAQrOoD.d.ts +0 -382
  77. package/dist/improve-B-UYaEH5.d.ts +0 -172
  78. package/dist/lifecycle.d.ts +0 -870
  79. package/dist/lifecycle.js +0 -981
  80. package/dist/lifecycle.js.map +0 -1
  81. package/dist/mcp-serve-verifier-Bs_n0xPc.d.ts +0 -34
  82. package/skills/agent-runtime-adoption/SKILL.md +0 -246
  83. /package/dist/{chunk-YLUOTX6U.js.map → chunk-FXF2OL34.js.map} +0 -0
  84. /package/dist/{chunk-BPGXIKK7.js.map → chunk-SGQ4YIQW.js.map} +0 -0
  85. /package/dist/{chunk-Z5I642SY.js.map → chunk-WYC2XJF2.js.map} +0 -0
  86. /package/dist/{chunk-ZEYAT33L.js.map → chunk-Y3SRWZMP.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1,30 +1,14 @@
1
- import {
2
- RESEARCH_SUPERVISOR_SYSTEM_PROMPT,
3
- createAgentKnowledgeReadinessCheck,
4
- createSupervisedKnowledgeUpdater,
5
- formatSupervisedKnowledgeTask,
6
- knowledgeReadinessDeliverable,
7
- runKnowledgeImprovementJob,
8
- runSupervisedKnowledgeUpdate
9
- } from "./chunk-AP7CPGMZ.js";
10
- import "./chunk-5QOB7H74.js";
11
1
  import {
12
2
  FileAgentCandidateExecutionClaimStore,
13
3
  buildAgentCandidateBundle,
14
4
  createProtectedAgentCandidateModelPort,
15
5
  disposePreparedAgentCandidateExecution,
16
- recoverExpiredAgentCandidateExecution,
17
- sealAgentCandidateBundle
18
- } from "./chunk-6YBA64Z2.js";
19
- import {
20
- captureAgentCandidateWorkspace,
21
- captureAgentCandidateWorkspaceFiles,
22
- createAgentCandidateWorkspacePort
23
- } from "./chunk-MKGRLDWB.js";
6
+ recoverExpiredAgentCandidateExecution
7
+ } from "./chunk-6XKPVJAZ.js";
24
8
  import {
25
9
  mcpToolsForRuntimeMcp,
26
10
  mcpToolsForRuntimeMcpSubset
27
- } from "./chunk-Z5I642SY.js";
11
+ } from "./chunk-WYC2XJF2.js";
28
12
  import {
29
13
  DEFAULT_ROUTER_BASE_URL,
30
14
  cleanModelId,
@@ -43,7 +27,7 @@ import {
43
27
  runLoopRunnerCli,
44
28
  selfImproveLoopRunner,
45
29
  worktreeLoopRunner
46
- } from "./chunk-BPGXIKK7.js";
30
+ } from "./chunk-SGQ4YIQW.js";
47
31
  import "./chunk-SGKPNBXE.js";
48
32
  import {
49
33
  CircuitBreakerState,
@@ -71,12 +55,43 @@ import {
71
55
  slugifySpeaker,
72
56
  turnId
73
57
  } from "./chunk-2KGAN2HM.js";
58
+ import "./chunk-FXF2OL34.js";
74
59
  import {
75
- applyImprovementWinnerToProfile,
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";
87
+ import {
88
+ AGENTIC_PROFILE_RESOURCE_ROOT,
89
+ agenticGenerator,
90
+ commandVerifier,
76
91
  improve,
77
92
  improvementDriver,
78
93
  rawTraceDistiller
79
- } from "./chunk-G55QE4IQ.js";
94
+ } from "./chunk-PSOCBNM3.js";
80
95
  import {
81
96
  AGENT_CANDIDATE_EXECUTION_SUPPORT,
82
97
  CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV,
@@ -94,25 +109,14 @@ import {
94
109
  persistCandidateOutputArtifact,
95
110
  prepareAgentCandidateExecution,
96
111
  verifyAgentCandidateBundle
97
- } from "./chunk-WTZ37EQY.js";
98
- import "./chunk-YLUOTX6U.js";
112
+ } from "./chunk-YOLKCWRV.js";
99
113
  import {
100
114
  composeRuntimeHooks,
101
115
  defineRuntimeHooks,
102
116
  notifyRuntimeDecisionPoint,
103
117
  notifyRuntimeHookEvent
104
- } from "./chunk-IADLKE7I.js";
118
+ } from "./chunk-UQ6PNNXM.js";
105
119
  import "./chunk-DPEUKJRO.js";
106
- import {
107
- InMemoryRuntimeSessionStore,
108
- createIterableBackend,
109
- createOpenAICompatibleBackend,
110
- createSandboxPromptBackend,
111
- normalizeBackendStreamEvent,
112
- nowIso,
113
- startOrResumeRuntimeSession,
114
- touchSession
115
- } from "./chunk-Q2JSAVQ3.js";
116
120
  import {
117
121
  INTELLIGENCE_WIRE_VERSION,
118
122
  buildLoopOtelSpans,
@@ -126,23 +130,12 @@ import {
126
130
  sanitizeAgentRuntimeEvent,
127
131
  sanitizeKnowledgeReadinessReport,
128
132
  sanitizeRuntimeStreamEvent
129
- } from "./chunk-ISTDY47H.js";
133
+ } from "./chunk-HZDEXTSL.js";
130
134
  import "./chunk-IMSNJSXH.js";
131
135
  import "./chunk-M6MD6JBS.js";
132
136
  import "./chunk-3MDZX7YU.js";
133
- import "./chunk-QDSOD7RC.js";
137
+ import "./chunk-FD2MBMOH.js";
134
138
  import "./chunk-M22PL4GH.js";
135
- import {
136
- mcpBuildPrompt,
137
- mcpServeVerifier,
138
- toolBuildPrompt
139
- } from "./chunk-6O73TRHW.js";
140
- import {
141
- AGENTIC_PROFILE_RESOURCE_ROOT,
142
- agenticGenerator,
143
- commandVerifier
144
- } from "./chunk-DHCHL6OG.js";
145
- import "./chunk-EP6RVHMX.js";
146
139
  import {
147
140
  AgentEvalError,
148
141
  BackendTransportError,
@@ -153,7 +146,6 @@ import {
153
146
  RuntimeRunStateError,
154
147
  ValidationError
155
148
  } from "./chunk-YEJR7IXO.js";
156
- import "./chunk-DGUM43GV.js";
157
149
 
158
150
  // src/durable/chat-engine.ts
159
151
  var encoder = new TextEncoder();
@@ -241,6 +233,142 @@ function deriveExecutionId(input) {
241
233
  return `${input.projectId}:${input.sessionId}:${input.turnIndex}`;
242
234
  }
243
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
+
244
372
  // src/improvement/profile-diff-proposer.ts
245
373
  import { canonicalJson } from "@tangle-network/agent-eval";
246
374
  import {
@@ -311,7 +439,7 @@ function reflectiveGenerator(opts) {
311
439
  return {
312
440
  kind: "reflective",
313
441
  async generate({ worktreePath, findings }) {
314
- const batch = await opts.improvementAdapter.proposeFromFindings(findings);
442
+ const batch = await opts.improvementProposalSource.proposeFromFindings(findings);
315
443
  if (batch.edits.length === 0) return { applied: false, summary: "" };
316
444
  let applied = 0;
317
445
  for (const edit of batch.edits) {
@@ -1415,11 +1543,11 @@ export {
1415
1543
  ValidationError,
1416
1544
  agenticGenerator,
1417
1545
  applyExactAgentProfileDiff,
1418
- applyImprovementWinnerToProfile,
1419
1546
  applyRunRecordDefaults,
1420
1547
  auditLoopRunner,
1421
1548
  buildAgentCandidateBundle,
1422
1549
  buildForwardHeaders,
1550
+ buildKnowledgeImprovementExperimentBundles,
1423
1551
  buildLoopOtelSpans,
1424
1552
  buildLoopSpanNodes,
1425
1553
  buildRuntimeEventOtelSpans,
@@ -1435,6 +1563,7 @@ export {
1435
1563
  createAgentKnowledgeReadinessCheck,
1436
1564
  createConversationBackend,
1437
1565
  createIterableBackend,
1566
+ createKnowledgeImprovementActivationExecutor,
1438
1567
  createOpenAICompatibleBackend,
1439
1568
  createOtelExporter,
1440
1569
  createProtectedAgentCandidateModelPort,