@tangle-network/agent-runtime 0.91.0 → 0.92.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 (86) hide show
  1. package/README.md +4 -2
  2. package/dist/agent.d.ts +3 -3
  3. package/dist/agent.js +106 -25
  4. package/dist/agent.js.map +1 -1
  5. package/dist/{mcp-serve-verifier-XsX8rkB9.d.ts → agentic-generator-B8oeE2Yv.d.ts} +6 -33
  6. package/dist/analyst-loop.d.ts +1 -1
  7. package/dist/candidate-execution/index.d.ts +104 -0
  8. package/dist/candidate-execution/index.js +34 -0
  9. package/dist/candidate-execution/index.js.map +1 -0
  10. package/dist/chunk-3D2RHC4K.js +73 -0
  11. package/dist/chunk-3D2RHC4K.js.map +1 -0
  12. package/dist/chunk-3MDZX7YU.js +125 -0
  13. package/dist/chunk-3MDZX7YU.js.map +1 -0
  14. package/dist/chunk-4FPXIMSI.js +659 -0
  15. package/dist/chunk-4FPXIMSI.js.map +1 -0
  16. package/dist/chunk-6O73TRHW.js +142 -0
  17. package/dist/chunk-6O73TRHW.js.map +1 -0
  18. package/dist/chunk-A62TP7SK.js +4784 -0
  19. package/dist/chunk-A62TP7SK.js.map +1 -0
  20. package/dist/{chunk-AD7JW4QG.js → chunk-BVVRQ4YC.js} +23 -1231
  21. package/dist/chunk-BVVRQ4YC.js.map +1 -0
  22. package/dist/chunk-FDJ7AHXG.js +1229 -0
  23. package/dist/chunk-FDJ7AHXG.js.map +1 -0
  24. package/dist/{chunk-FF77IBQM.js → chunk-FRBHUNQ7.js} +2 -141
  25. package/dist/chunk-FRBHUNQ7.js.map +1 -0
  26. package/dist/chunk-J2K6WIG6.js +2172 -0
  27. package/dist/chunk-J2K6WIG6.js.map +1 -0
  28. package/dist/{chunk-JRS3YSRZ.js → chunk-LQQPGRKT.js} +2 -2
  29. package/dist/{chunk-IOUUITQA.js → chunk-P6B3Z7PR.js} +3 -3
  30. package/dist/chunk-PH65PR4F.js +860 -0
  31. package/dist/chunk-PH65PR4F.js.map +1 -0
  32. package/dist/{chunk-7ON74BQO.js → chunk-R5GWDTM3.js} +2 -2
  33. package/dist/{chunk-DWWII6N2.js → chunk-TKJ3Q6CQ.js} +2 -2
  34. package/dist/{chunk-NC66AM3S.js → chunk-UO2L5VTP.js} +32 -1413
  35. package/dist/chunk-UO2L5VTP.js.map +1 -0
  36. package/dist/{chunk-BZF3KQ6G.js → chunk-VSWBYWFK.js} +4 -122
  37. package/dist/chunk-VSWBYWFK.js.map +1 -0
  38. package/dist/{completion-gate-DkAnUmpb.d.ts → completion-gate-BLaiN0-X.d.ts} +1 -1
  39. package/dist/{coordination-rRj5hjJK.d.ts → coordination-DxJ83oZA.d.ts} +12 -5
  40. package/dist/environment-provider.d.ts +2 -2
  41. package/dist/environment-provider.js +2 -1
  42. package/dist/improve-CUVCq7xg.d.ts +152 -0
  43. package/dist/{improvement-adapter-CDR8QNVM.d.ts → improvement-adapter-BieWeK5J.d.ts} +16 -0
  44. package/dist/index.d.ts +27 -1092
  45. package/dist/index.js +108 -6491
  46. package/dist/index.js.map +1 -1
  47. package/dist/intelligence.d.ts +160 -13
  48. package/dist/intelligence.js +534 -59
  49. package/dist/intelligence.js.map +1 -1
  50. package/dist/knowledge.d.ts +6 -6
  51. package/dist/knowledge.js +6 -4
  52. package/dist/lifecycle.d.ts +2 -1
  53. package/dist/lifecycle.js +5 -3
  54. package/dist/lifecycle.js.map +1 -1
  55. package/dist/{loop-runner-bin-DTbZVGfM.d.ts → loop-runner-bin-kKUNGLyV.d.ts} +2 -2
  56. package/dist/loop-runner-bin.d.ts +5 -5
  57. package/dist/loop-runner-bin.js +8 -5
  58. package/dist/loops.d.ts +16 -16
  59. package/dist/loops.js +47 -41
  60. package/dist/mcp/bin.js +6 -4
  61. package/dist/mcp/bin.js.map +1 -1
  62. package/dist/mcp/index.d.ts +8 -8
  63. package/dist/mcp/index.js +9 -6
  64. package/dist/mcp/index.js.map +1 -1
  65. package/dist/mcp-serve-verifier-Bg4C3p5S.d.ts +34 -0
  66. package/dist/{openai-tools-C4ZfUD4L.d.ts → openai-tools-E3woykz9.d.ts} +1 -1
  67. package/dist/prepare-Z08a4heC.d.ts +713 -0
  68. package/dist/profiles.d.ts +1 -1
  69. package/dist/{router-client-DJImUDlm.d.ts → sanitize-C9go6tXj.d.ts} +113 -1
  70. package/dist/{structural-rollout-MwlpgQ-6.d.ts → structural-rollout-DHGDbhvR.d.ts} +3 -3
  71. package/dist/{supervise-DPmYPk0j.d.ts → supervise-T2pazU3G.d.ts} +4 -4
  72. package/dist/{types-SyuwunY_.d.ts → types-B00NtbCs.d.ts} +1 -1
  73. package/dist/{types-eMNgWgFi.d.ts → types-DAdIm4AC.d.ts} +1 -1
  74. package/dist/{worktree-fanout-BDFQIO-Y.d.ts → worktree-fanout-BUb2Ag02.d.ts} +3 -3
  75. package/package.json +11 -6
  76. package/skills/build-with-agent-runtime/SKILL.md +1 -1
  77. package/dist/chunk-AD7JW4QG.js.map +0 -1
  78. package/dist/chunk-BZF3KQ6G.js.map +0 -1
  79. package/dist/chunk-FF77IBQM.js.map +0 -1
  80. package/dist/chunk-IVGYLCFH.js +0 -381
  81. package/dist/chunk-IVGYLCFH.js.map +0 -1
  82. package/dist/chunk-NC66AM3S.js.map +0 -1
  83. /package/dist/{chunk-JRS3YSRZ.js.map → chunk-LQQPGRKT.js.map} +0 -0
  84. /package/dist/{chunk-IOUUITQA.js.map → chunk-P6B3Z7PR.js.map} +0 -0
  85. /package/dist/{chunk-7ON74BQO.js.map → chunk-R5GWDTM3.js.map} +0 -0
  86. /package/dist/{chunk-DWWII6N2.js.map → chunk-TKJ3Q6CQ.js.map} +0 -0
package/README.md CHANGED
@@ -68,13 +68,15 @@ const result = await supervise(
68
68
 
69
69
  ### Improve an agent
70
70
 
71
- `improve` optimizes one part of an agent (its prompt, skills, or code) and **only ships a change if it beats the current agent on tasks it never practiced on**. Registering an agent for self-improvement cannot ship a worse candidate unless the caller supplies a bad measurement.
71
+ `improve` optimizes one part of an agent and **only ships a change if it beats the current agent on tasks it never practiced on**.
72
+ It accepts prompt, skill document, tool, MCP, hook, subagent, workflow, rollout-policy, whole-profile, and code surfaces through one call.
73
+ Prompt and skill-document optimization have built-in generators; structured surfaces take an explicit generator, and code runs from isolated incumbent and candidate checkouts.
72
74
 
73
75
  ```ts
74
76
  import { improve } from '@tangle-network/agent-runtime'
75
77
 
76
78
  const { profile, shipped, lift } = await improve(baseProfile, findings, {
77
- surface: 'prompt', // what to optimize: prompt | skills | code
79
+ surface: 'prompt', // or skills/tools/mcp/hooks/subagents/workflow/agent-profile/code
78
80
  gate: 'holdout', // certified on a held-back exam, never the practice set
79
81
  scenarios, judge, agent, // how to measure a candidate
80
82
  })
package/dist/agent.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as _tangle_network_agent_eval from '@tangle-network/agent-eval';
2
2
  import { TraceAnalystKindSpec, AnalystFinding } from '@tangle-network/agent-eval';
3
3
  import { A as ArtifactKind, C as CandidateGenerator, P as PromotionGate } from './generator-YkAQrOoD.js';
4
- import { b as RuntimeStreamEvent, S as SandboxClient, c as OutputAdapter, A as AgentRunSpec } from './types-SyuwunY_.js';
5
- import { A as AgentSurfaces } from './improvement-adapter-CDR8QNVM.js';
6
- export { C as CreateSurfaceImprovementAdapterOpts, D as DraftPatchInput, a as DraftPatchOutput, R as ResolvedSurface, S as SurfaceImprovementEdit, b as SurfaceValidationIssue, c as createSurfaceImprovementAdapter, r as renderSurfaceIssues, d as resolveSubjectPath, v as validateSurfaces } from './improvement-adapter-CDR8QNVM.js';
4
+ import { b as RuntimeStreamEvent, S as SandboxClient, d as OutputAdapter, e as AgentRunSpec } from './types-B00NtbCs.js';
5
+ import { A as AgentSurfaces } from './improvement-adapter-BieWeK5J.js';
6
+ export { C as CreateSurfaceImprovementAdapterOpts, D as DraftPatchInput, a as DraftPatchOutput, R as ResolvedSurface, S as SurfaceImprovementEdit, b as SurfaceValidationIssue, c as createSurfaceImprovementAdapter, r as renderSurfaceIssues, d as resolveSubjectPath, v as validateSurfaces } from './improvement-adapter-BieWeK5J.js';
7
7
  import { K as KnowledgeAdapter, a as RunAnalystLoopResult } from './types-BC3bZpH0.js';
8
8
  import { AgentProfile, AgentProfileFileMount, AgentProfileMcpServer } from '@tangle-network/agent-interface';
9
9
  import { SandboxEvent } from '@tangle-network/sandbox';
package/dist/agent.js CHANGED
@@ -1,10 +1,13 @@
1
- import "./chunk-AD7JW4QG.js";
1
+ import "./chunk-BVVRQ4YC.js";
2
+ import "./chunk-FDJ7AHXG.js";
2
3
  import {
3
4
  createSandboxForSpec
4
- } from "./chunk-NC66AM3S.js";
5
+ } from "./chunk-UO2L5VTP.js";
5
6
  import "./chunk-DPEUKJRO.js";
6
- import "./chunk-IVGYLCFH.js";
7
- import "./chunk-BZF3KQ6G.js";
7
+ import "./chunk-J2K6WIG6.js";
8
+ import "./chunk-3D2RHC4K.js";
9
+ import "./chunk-VSWBYWFK.js";
10
+ import "./chunk-3MDZX7YU.js";
8
11
  import {
9
12
  mapSandboxEvent
10
13
  } from "./chunk-FVJ7M3DA.js";
@@ -17,8 +20,8 @@ import {
17
20
  } from "./chunk-DGUM43GV.js";
18
21
 
19
22
  // src/agent/surfaces.ts
20
- import { existsSync } from "fs";
21
- import { isAbsolute, join } from "path";
23
+ import { existsSync, statSync } from "fs";
24
+ import { isAbsolute, join, relative, resolve, sep } from "path";
22
25
  function resolveSubjectPath(subject, surfaces, repoRoot) {
23
26
  const candidates = candidatePathsForSubject(subject, surfaces);
24
27
  if (candidates.length === 0) return null;
@@ -41,38 +44,80 @@ function candidatePathsForSubject(subject, surfaces) {
41
44
  switch (subject.kind) {
42
45
  case "knowledge.wiki":
43
46
  case "knowledge.stale":
44
- return [join(surfaces.knowledge, `${subject.slug}.md`)];
47
+ return optionalPath(safeJoin(surfaces.knowledge, `${subject.slug}.md`));
45
48
  case "knowledge.claim":
46
- return [join(surfaces.knowledge, "claims", `${slugify(subject.topic)}.md`)];
49
+ return optionalPath(safeJoin(surfaces.knowledge, "claims", `${slugify(subject.topic)}.md`));
47
50
  case "knowledge.raw":
48
- return [join(surfaces.knowledge, "raw", `${subject.sourceId}.md`)];
51
+ return optionalPath(safeJoin(surfaces.knowledge, "raw", `${subject.sourceId}.md`));
49
52
  case "system-prompt": {
50
53
  const slug = slugify(subject.section);
51
54
  return [
52
- join(surfaces.systemPrompt, `${slug}.md`),
53
- join(surfaces.systemPrompt, slug, "SKILL.md"),
54
- join(surfaces.systemPrompt, slug, "index.md")
55
- ];
55
+ safeJoin(surfaces.systemPrompt, `${slug}.md`),
56
+ safeJoin(surfaces.systemPrompt, slug, "SKILL.md"),
57
+ safeJoin(surfaces.systemPrompt, slug, "index.md")
58
+ ].filter((path) => path !== null);
59
+ }
60
+ case "skill": {
61
+ if (!surfaces.skills) return [];
62
+ return [
63
+ safeJoin(surfaces.skills, subject.name, "SKILL.md"),
64
+ safeJoin(surfaces.skills, `${subject.name}.md`)
65
+ ].filter((path) => path !== null);
56
66
  }
57
67
  case "tool-doc":
58
68
  if (subject.aspect) {
59
- return [join(surfaces.tools, subject.tool, `${slugify(subject.aspect)}.md`)];
69
+ return optionalPath(safeJoin(surfaces.tools, subject.tool, `${slugify(subject.aspect)}.md`));
60
70
  }
61
71
  return [
62
- join(surfaces.tools, subject.tool, "README.md"),
63
- join(surfaces.tools, `${subject.tool}.md`)
64
- ];
72
+ safeJoin(surfaces.tools, subject.tool, "README.md"),
73
+ safeJoin(surfaces.tools, `${subject.tool}.md`)
74
+ ].filter((path) => path !== null);
65
75
  case "new-tool":
66
- return [join(surfaces.tools, subject.name, "README.md")];
76
+ return optionalPath(safeJoin(surfaces.tools, subject.name, "README.md"));
77
+ case "mcp":
78
+ if (!surfaces.mcp) return [];
79
+ return subject.tool ? optionalPath(safeJoin(surfaces.mcp, subject.server, `${subject.tool}.md`)) : [
80
+ safeJoin(surfaces.mcp, `${subject.server}.json`),
81
+ safeJoin(surfaces.mcp, subject.server, "README.md")
82
+ ].filter((path) => path !== null);
83
+ case "hook":
84
+ if (!surfaces.hooks) return [];
85
+ return [
86
+ safeJoin(surfaces.hooks, `${subject.name}.md`),
87
+ safeJoin(surfaces.hooks, `${subject.name}.json`)
88
+ ].filter((path) => path !== null);
89
+ case "subagent":
90
+ if (!surfaces.subagents) return [];
91
+ return [
92
+ safeJoin(surfaces.subagents, `${subject.name}.md`),
93
+ safeJoin(surfaces.subagents, `${subject.name}.yaml`),
94
+ safeJoin(surfaces.subagents, `${subject.name}.json`)
95
+ ].filter((path) => path !== null);
96
+ case "workflow":
97
+ if (!surfaces.workflows) return [];
98
+ return [
99
+ safeJoin(surfaces.workflows, `${subject.name}.md`),
100
+ safeJoin(surfaces.workflows, `${subject.name}.yaml`),
101
+ safeJoin(surfaces.workflows, `${subject.name}.json`)
102
+ ].filter((path) => path !== null);
103
+ case "rollout-policy":
104
+ return surfaces.rolloutPolicy ? [surfaces.rolloutPolicy] : [];
105
+ case "agent-profile":
106
+ return surfaces.agentProfile ? [surfaces.agentProfile] : [];
107
+ case "code": {
108
+ if (!surfaces.code) return [];
109
+ const path = safeJoin(surfaces.code, subject.path);
110
+ return path ? [path] : [];
111
+ }
67
112
  case "rag":
68
113
  if (!surfaces.rag) return [];
69
- return [join(surfaces.rag, subject.corpus, `${subject.docId}.md`)];
114
+ return optionalPath(safeJoin(surfaces.rag, subject.corpus, `${subject.docId}.md`));
70
115
  case "memory":
71
116
  if (!surfaces.memory) return [];
72
- return [join(surfaces.memory, `${slugify(subject.key)}.json`)];
117
+ return optionalPath(safeJoin(surfaces.memory, `${slugify(subject.key)}.json`));
73
118
  case "scaffolding":
74
119
  if (!surfaces.scaffolding) return [];
75
- return [join(surfaces.scaffolding, `${slugify(subject.concern)}.md`)];
120
+ return optionalPath(safeJoin(surfaces.scaffolding, `${slugify(subject.concern)}.md`));
76
121
  case "output-schema":
77
122
  if (!surfaces.outputSchema) return [];
78
123
  return [surfaces.outputSchema];
@@ -83,6 +128,17 @@ function candidatePathsForSubject(subject, surfaces) {
83
128
  return [];
84
129
  }
85
130
  }
131
+ function safeJoin(root, ...children) {
132
+ if (children.some((child) => child.includes("\0") || isAbsolute(child))) return null;
133
+ const rootAbsolute = resolve(root);
134
+ const targetAbsolute = resolve(rootAbsolute, ...children);
135
+ const escaped = relative(rootAbsolute, targetAbsolute);
136
+ if (escaped === ".." || escaped.startsWith(`..${sep}`) || isAbsolute(escaped)) return null;
137
+ return join(root, ...children);
138
+ }
139
+ function optionalPath(path) {
140
+ return path ? [path] : [];
141
+ }
86
142
  function slugify(s) {
87
143
  return s.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 200) || "untitled";
88
144
  }
@@ -95,8 +151,22 @@ function validateSurfaces(surfaces, repoRoot) {
95
151
  "knowledge"
96
152
  ];
97
153
  const fileSurfaces = ["rubric"];
98
- const optionalDirSurfaces = ["scaffolding", "memory", "rag"];
99
- const optionalFileSurfaces = ["outputSchema"];
154
+ const optionalDirSurfaces = [
155
+ "scaffolding",
156
+ "memory",
157
+ "rag",
158
+ "skills",
159
+ "mcp",
160
+ "hooks",
161
+ "subagents",
162
+ "workflows",
163
+ "code"
164
+ ];
165
+ const optionalFileSurfaces = [
166
+ "outputSchema",
167
+ "rolloutPolicy",
168
+ "agentProfile"
169
+ ];
100
170
  for (const key of dirSurfaces) {
101
171
  const p = surfaces[key];
102
172
  if (!p) {
@@ -106,6 +176,8 @@ function validateSurfaces(surfaces, repoRoot) {
106
176
  const abs = isAbsolute(p) ? p : join(repoRoot, p);
107
177
  if (!existsSync(abs)) {
108
178
  issues.push({ surface: key, path: p, reason: "missing" });
179
+ } else if (!statSync(abs).isDirectory()) {
180
+ issues.push({ surface: key, path: p, reason: "not-directory" });
109
181
  }
110
182
  }
111
183
  for (const key of fileSurfaces) {
@@ -117,6 +189,8 @@ function validateSurfaces(surfaces, repoRoot) {
117
189
  const abs = isAbsolute(p) ? p : join(repoRoot, p);
118
190
  if (!existsSync(abs)) {
119
191
  issues.push({ surface: key, path: p, reason: "missing" });
192
+ } else if (!statSync(abs).isFile()) {
193
+ issues.push({ surface: key, path: p, reason: "not-file" });
120
194
  }
121
195
  }
122
196
  for (const key of [...optionalDirSurfaces, ...optionalFileSurfaces]) {
@@ -125,6 +199,13 @@ function validateSurfaces(surfaces, repoRoot) {
125
199
  const abs = isAbsolute(p) ? p : join(repoRoot, p);
126
200
  if (!existsSync(abs)) {
127
201
  issues.push({ surface: key, path: p, reason: "missing" });
202
+ continue;
203
+ }
204
+ const expectedDirectory = optionalDirSurfaces.includes(key);
205
+ if (expectedDirectory && !statSync(abs).isDirectory()) {
206
+ issues.push({ surface: key, path: p, reason: "not-directory" });
207
+ } else if (!expectedDirectory && !statSync(abs).isFile()) {
208
+ issues.push({ surface: key, path: p, reason: "not-file" });
128
209
  }
129
210
  }
130
211
  return issues;
@@ -669,8 +750,8 @@ function createSandboxAct(options) {
669
750
  const raw = [];
670
751
  let settle;
671
752
  let fail;
672
- const output = new Promise((resolve, reject) => {
673
- settle = resolve;
753
+ const output = new Promise((resolve2, reject) => {
754
+ settle = resolve2;
674
755
  fail = reject;
675
756
  });
676
757
  output.catch(() => {