@tangle-network/agent-runtime 0.92.0 → 0.93.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -4
- package/dist/agent.js +47 -45
- package/dist/agent.js.map +1 -1
- package/dist/candidate-execution/index.d.ts +48 -4
- package/dist/candidate-execution/index.js +6 -2
- package/dist/{chunk-A62TP7SK.js → chunk-26WCEARH.js} +295 -40
- package/dist/chunk-26WCEARH.js.map +1 -0
- package/dist/{chunk-PH65PR4F.js → chunk-3VU2OWOY.js} +106 -2
- package/dist/chunk-3VU2OWOY.js.map +1 -0
- package/dist/{chunk-I7WVPJBZ.js → chunk-BVVRQ4YC.js} +4 -4
- package/dist/{chunk-3BE7KTMU.js → chunk-FDJ7AHXG.js} +2 -2
- package/dist/{chunk-APVPRF4Y.js → chunk-J2K6WIG6.js} +13 -7
- package/dist/{chunk-APVPRF4Y.js.map → chunk-J2K6WIG6.js.map} +1 -1
- package/dist/{chunk-7VJJJ2T2.js → chunk-LQQPGRKT.js} +2 -2
- package/dist/{chunk-IGGZGKJD.js → chunk-P6B3Z7PR.js} +3 -3
- package/dist/{chunk-GDAQUFG6.js → chunk-R5GWDTM3.js} +2 -2
- package/dist/{chunk-AUEIDTR3.js → chunk-TKJ3Q6CQ.js} +2 -2
- package/dist/{chunk-6O5USWVH.js → chunk-UO2L5VTP.js} +2 -2
- package/dist/{chunk-RSWM2ZKM.js → chunk-VMHKMNEU.js} +40 -11
- package/dist/chunk-VMHKMNEU.js.map +1 -0
- package/dist/{improve-CUVCq7xg.d.ts → improve-DDhQaaJT.d.ts} +17 -5
- package/dist/index.d.ts +3 -3
- package/dist/index.js +14 -10
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +6 -8
- package/dist/intelligence.js +25 -134
- package/dist/intelligence.js.map +1 -1
- package/dist/knowledge.js +3 -3
- package/dist/loop-runner-bin.js +5 -5
- package/dist/loops.js +4 -4
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.js +6 -6
- package/dist/{prepare-Z08a4heC.d.ts → prepare-DiVGKcwS.d.ts} +7 -2
- package/package.json +33 -19
- package/skills/build-with-agent-runtime/SKILL.md +2 -1
- package/dist/chunk-A62TP7SK.js.map +0 -1
- package/dist/chunk-PH65PR4F.js.map +0 -1
- package/dist/chunk-RSWM2ZKM.js.map +0 -1
- /package/dist/{chunk-I7WVPJBZ.js.map → chunk-BVVRQ4YC.js.map} +0 -0
- /package/dist/{chunk-3BE7KTMU.js.map → chunk-FDJ7AHXG.js.map} +0 -0
- /package/dist/{chunk-7VJJJ2T2.js.map → chunk-LQQPGRKT.js.map} +0 -0
- /package/dist/{chunk-IGGZGKJD.js.map → chunk-P6B3Z7PR.js.map} +0 -0
- /package/dist/{chunk-GDAQUFG6.js.map → chunk-R5GWDTM3.js.map} +0 -0
- /package/dist/{chunk-AUEIDTR3.js.map → chunk-TKJ3Q6CQ.js.map} +0 -0
- /package/dist/{chunk-6O5USWVH.js.map → chunk-UO2L5VTP.js.map} +0 -0
package/README.md
CHANGED
|
@@ -69,22 +69,32 @@ const result = await supervise(
|
|
|
69
69
|
### Improve an agent
|
|
70
70
|
|
|
71
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
|
|
72
|
+
It accepts prompt, skill document, curated memory, tool, MCP, hook, subagent, workflow, rollout-policy, whole-profile, and code surfaces through one call.
|
|
73
|
+
Prompt, skill-document, memory, and rollout-policy optimization have built-in generators; structured surfaces take an explicit generator, and code runs from isolated incumbent and candidate checkouts.
|
|
74
74
|
|
|
75
75
|
```ts
|
|
76
76
|
import { improve } from '@tangle-network/agent-runtime'
|
|
77
77
|
|
|
78
78
|
const { profile, shipped, lift } = await improve(baseProfile, findings, {
|
|
79
|
-
surface: 'prompt', // or skills/tools/mcp/hooks/subagents/workflow/agent-profile/code
|
|
79
|
+
surface: 'prompt', // or skills/memory/tools/mcp/hooks/subagents/workflow/agent-profile/rollout-policy/code
|
|
80
80
|
gate: 'holdout', // certified on a held-back exam, never the practice set
|
|
81
81
|
scenarios, judge, agent, // how to measure a candidate
|
|
82
82
|
})
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
+
Curated memory is an external lesson document, not a knowledge store. Supply its current text and persist only the promoted winner:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
await improve(baseProfile, findings, {
|
|
89
|
+
surface: 'memory',
|
|
90
|
+
memory: { document: currentLessons, writeBack: saveLessons },
|
|
91
|
+
scenarios, judge, agent,
|
|
92
|
+
})
|
|
93
|
+
```
|
|
94
|
+
|
|
85
95
|
### Improve a knowledge base
|
|
86
96
|
|
|
87
|
-
`runKnowledgeImprovementJob` is the runtime-owned front door for KB, wiki, memory-backed, and RAG improvement jobs. It creates a candidate copy, runs supervised agents against it, checks readiness through `@tangle-network/agent-knowledge`, measures spend and timing, and promotes only when the candidate passes.
|
|
97
|
+
`runKnowledgeImprovementJob` is the runtime-owned front door for KB, wiki, memory-backed, and RAG improvement jobs. It creates a candidate copy, runs supervised agents against it, checks readiness through `@tangle-network/agent-knowledge`, measures spend and timing, and promotes only when the candidate passes. Use `improve(..., { surface: 'memory' })` for the agent's curated lesson document; use this job for source, retrieval, and knowledge-store changes.
|
|
88
98
|
|
|
89
99
|
```ts
|
|
90
100
|
import { runKnowledgeImprovementJob } from '@tangle-network/agent-runtime/knowledge'
|
package/dist/agent.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "./chunk-
|
|
2
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-BVVRQ4YC.js";
|
|
2
|
+
import "./chunk-FDJ7AHXG.js";
|
|
3
3
|
import {
|
|
4
4
|
createSandboxForSpec
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-UO2L5VTP.js";
|
|
6
6
|
import "./chunk-DPEUKJRO.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-J2K6WIG6.js";
|
|
8
8
|
import "./chunk-3D2RHC4K.js";
|
|
9
9
|
import "./chunk-VSWBYWFK.js";
|
|
10
10
|
import "./chunk-3MDZX7YU.js";
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
|
|
22
22
|
// src/agent/surfaces.ts
|
|
23
23
|
import { existsSync, statSync } from "fs";
|
|
24
|
-
import { isAbsolute, join } from "path";
|
|
24
|
+
import { isAbsolute, join, relative, resolve, sep } from "path";
|
|
25
25
|
function resolveSubjectPath(subject, surfaces, repoRoot) {
|
|
26
26
|
const candidates = candidatePathsForSubject(subject, surfaces);
|
|
27
27
|
if (candidates.length === 0) return null;
|
|
@@ -44,62 +44,62 @@ function candidatePathsForSubject(subject, surfaces) {
|
|
|
44
44
|
switch (subject.kind) {
|
|
45
45
|
case "knowledge.wiki":
|
|
46
46
|
case "knowledge.stale":
|
|
47
|
-
return
|
|
47
|
+
return optionalPath(safeJoin(surfaces.knowledge, `${subject.slug}.md`));
|
|
48
48
|
case "knowledge.claim":
|
|
49
|
-
return
|
|
49
|
+
return optionalPath(safeJoin(surfaces.knowledge, "claims", `${slugify(subject.topic)}.md`));
|
|
50
50
|
case "knowledge.raw":
|
|
51
|
-
return optionalPath(safeJoin(
|
|
51
|
+
return optionalPath(safeJoin(surfaces.knowledge, "raw", `${subject.sourceId}.md`));
|
|
52
52
|
case "system-prompt": {
|
|
53
53
|
const slug = slugify(subject.section);
|
|
54
54
|
return [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
];
|
|
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
59
|
}
|
|
60
60
|
case "skill": {
|
|
61
61
|
if (!surfaces.skills) return [];
|
|
62
62
|
return [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
];
|
|
63
|
+
safeJoin(surfaces.skills, subject.name, "SKILL.md"),
|
|
64
|
+
safeJoin(surfaces.skills, `${subject.name}.md`)
|
|
65
|
+
].filter((path) => path !== null);
|
|
66
66
|
}
|
|
67
67
|
case "tool-doc":
|
|
68
68
|
if (subject.aspect) {
|
|
69
|
-
return
|
|
69
|
+
return optionalPath(safeJoin(surfaces.tools, subject.tool, `${slugify(subject.aspect)}.md`));
|
|
70
70
|
}
|
|
71
71
|
return [
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
];
|
|
72
|
+
safeJoin(surfaces.tools, subject.tool, "README.md"),
|
|
73
|
+
safeJoin(surfaces.tools, `${subject.tool}.md`)
|
|
74
|
+
].filter((path) => path !== null);
|
|
75
75
|
case "new-tool":
|
|
76
|
-
return
|
|
76
|
+
return optionalPath(safeJoin(surfaces.tools, subject.name, "README.md"));
|
|
77
77
|
case "mcp":
|
|
78
78
|
if (!surfaces.mcp) return [];
|
|
79
|
-
return subject.tool ?
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
];
|
|
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
83
|
case "hook":
|
|
84
84
|
if (!surfaces.hooks) return [];
|
|
85
85
|
return [
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
];
|
|
86
|
+
safeJoin(surfaces.hooks, `${subject.name}.md`),
|
|
87
|
+
safeJoin(surfaces.hooks, `${subject.name}.json`)
|
|
88
|
+
].filter((path) => path !== null);
|
|
89
89
|
case "subagent":
|
|
90
90
|
if (!surfaces.subagents) return [];
|
|
91
91
|
return [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
];
|
|
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
96
|
case "workflow":
|
|
97
97
|
if (!surfaces.workflows) return [];
|
|
98
98
|
return [
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
];
|
|
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
103
|
case "rollout-policy":
|
|
104
104
|
return surfaces.rolloutPolicy ? [surfaces.rolloutPolicy] : [];
|
|
105
105
|
case "agent-profile":
|
|
@@ -111,13 +111,13 @@ function candidatePathsForSubject(subject, surfaces) {
|
|
|
111
111
|
}
|
|
112
112
|
case "rag":
|
|
113
113
|
if (!surfaces.rag) return [];
|
|
114
|
-
return optionalPath(safeJoin(
|
|
114
|
+
return optionalPath(safeJoin(surfaces.rag, subject.corpus, `${subject.docId}.md`));
|
|
115
115
|
case "memory":
|
|
116
116
|
if (!surfaces.memory) return [];
|
|
117
|
-
return
|
|
117
|
+
return optionalPath(safeJoin(surfaces.memory, `${slugify(subject.key)}.json`));
|
|
118
118
|
case "scaffolding":
|
|
119
119
|
if (!surfaces.scaffolding) return [];
|
|
120
|
-
return
|
|
120
|
+
return optionalPath(safeJoin(surfaces.scaffolding, `${slugify(subject.concern)}.md`));
|
|
121
121
|
case "output-schema":
|
|
122
122
|
if (!surfaces.outputSchema) return [];
|
|
123
123
|
return [surfaces.outputSchema];
|
|
@@ -128,11 +128,13 @@ function candidatePathsForSubject(subject, surfaces) {
|
|
|
128
128
|
return [];
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
function safeJoin(root,
|
|
132
|
-
if (child.includes("\0") || isAbsolute(child)) return null;
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
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);
|
|
136
138
|
}
|
|
137
139
|
function optionalPath(path) {
|
|
138
140
|
return path ? [path] : [];
|
|
@@ -748,8 +750,8 @@ function createSandboxAct(options) {
|
|
|
748
750
|
const raw = [];
|
|
749
751
|
let settle;
|
|
750
752
|
let fail;
|
|
751
|
-
const output = new Promise((
|
|
752
|
-
settle =
|
|
753
|
+
const output = new Promise((resolve2, reject) => {
|
|
754
|
+
settle = resolve2;
|
|
753
755
|
fail = reject;
|
|
754
756
|
});
|
|
755
757
|
output.catch(() => {
|