@aigne/agent-runtime 1.12.0-beta.5
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/LICENSE.md +26 -0
- package/README.md +79 -0
- package/dist/agent-runners/ai-runner.cjs +133 -0
- package/dist/agent-runners/ai-runner.d.cts +33 -0
- package/dist/agent-runners/ai-runner.d.cts.map +1 -0
- package/dist/agent-runners/ai-runner.d.mts +33 -0
- package/dist/agent-runners/ai-runner.d.mts.map +1 -0
- package/dist/agent-runners/ai-runner.mjs +134 -0
- package/dist/agent-runners/ai-runner.mjs.map +1 -0
- package/dist/agent-runners/ash-runner.cjs +272 -0
- package/dist/agent-runners/ash-runner.d.cts +30 -0
- package/dist/agent-runners/ash-runner.d.cts.map +1 -0
- package/dist/agent-runners/ash-runner.d.mts +30 -0
- package/dist/agent-runners/ash-runner.d.mts.map +1 -0
- package/dist/agent-runners/ash-runner.mjs +273 -0
- package/dist/agent-runners/ash-runner.mjs.map +1 -0
- package/dist/agent-runners/budget.cjs +71 -0
- package/dist/agent-runners/budget.d.cts +40 -0
- package/dist/agent-runners/budget.d.cts.map +1 -0
- package/dist/agent-runners/budget.d.mts +40 -0
- package/dist/agent-runners/budget.d.mts.map +1 -0
- package/dist/agent-runners/budget.mjs +67 -0
- package/dist/agent-runners/budget.mjs.map +1 -0
- package/dist/agent-runners/code-runner.cjs +61 -0
- package/dist/agent-runners/code-runner.mjs +61 -0
- package/dist/agent-runners/code-runner.mjs.map +1 -0
- package/dist/agent-runners/env-whitelist.cjs +36 -0
- package/dist/agent-runners/env-whitelist.d.cts +5 -0
- package/dist/agent-runners/env-whitelist.d.cts.map +1 -0
- package/dist/agent-runners/env-whitelist.d.mts +5 -0
- package/dist/agent-runners/env-whitelist.d.mts.map +1 -0
- package/dist/agent-runners/env-whitelist.mjs +36 -0
- package/dist/agent-runners/env-whitelist.mjs.map +1 -0
- package/dist/agent-runners/guide-rails.cjs +47 -0
- package/dist/agent-runners/guide-rails.d.cts +16 -0
- package/dist/agent-runners/guide-rails.d.cts.map +1 -0
- package/dist/agent-runners/guide-rails.d.mts +16 -0
- package/dist/agent-runners/guide-rails.d.mts.map +1 -0
- package/dist/agent-runners/guide-rails.mjs +48 -0
- package/dist/agent-runners/guide-rails.mjs.map +1 -0
- package/dist/agent-runners/hook-channel.cjs +55 -0
- package/dist/agent-runners/hook-channel.d.cts +38 -0
- package/dist/agent-runners/hook-channel.d.cts.map +1 -0
- package/dist/agent-runners/hook-channel.d.mts +38 -0
- package/dist/agent-runners/hook-channel.d.mts.map +1 -0
- package/dist/agent-runners/hook-channel.mjs +55 -0
- package/dist/agent-runners/hook-channel.mjs.map +1 -0
- package/dist/agent-runners/hooks.cjs +107 -0
- package/dist/agent-runners/hooks.d.cts +41 -0
- package/dist/agent-runners/hooks.d.cts.map +1 -0
- package/dist/agent-runners/hooks.d.mts +41 -0
- package/dist/agent-runners/hooks.d.mts.map +1 -0
- package/dist/agent-runners/hooks.mjs +107 -0
- package/dist/agent-runners/hooks.mjs.map +1 -0
- package/dist/agent-runners/memory-afs.cjs +342 -0
- package/dist/agent-runners/memory-afs.d.cts +221 -0
- package/dist/agent-runners/memory-afs.d.cts.map +1 -0
- package/dist/agent-runners/memory-afs.d.mts +221 -0
- package/dist/agent-runners/memory-afs.d.mts.map +1 -0
- package/dist/agent-runners/memory-afs.mjs +326 -0
- package/dist/agent-runners/memory-afs.mjs.map +1 -0
- package/dist/agent-runners/memory-archive.cjs +263 -0
- package/dist/agent-runners/memory-archive.d.cts +47 -0
- package/dist/agent-runners/memory-archive.d.cts.map +1 -0
- package/dist/agent-runners/memory-archive.d.mts +47 -0
- package/dist/agent-runners/memory-archive.d.mts.map +1 -0
- package/dist/agent-runners/memory-archive.mjs +257 -0
- package/dist/agent-runners/memory-archive.mjs.map +1 -0
- package/dist/agent-runners/orchestrator-runner.cjs +302 -0
- package/dist/agent-runners/orchestrator-runner.d.cts +23 -0
- package/dist/agent-runners/orchestrator-runner.d.cts.map +1 -0
- package/dist/agent-runners/orchestrator-runner.d.mts +23 -0
- package/dist/agent-runners/orchestrator-runner.d.mts.map +1 -0
- package/dist/agent-runners/orchestrator-runner.mjs +303 -0
- package/dist/agent-runners/orchestrator-runner.mjs.map +1 -0
- package/dist/agent-runners/orchestrator-state.cjs +68 -0
- package/dist/agent-runners/orchestrator-state.d.cts +23 -0
- package/dist/agent-runners/orchestrator-state.d.cts.map +1 -0
- package/dist/agent-runners/orchestrator-state.d.mts +23 -0
- package/dist/agent-runners/orchestrator-state.d.mts.map +1 -0
- package/dist/agent-runners/orchestrator-state.mjs +65 -0
- package/dist/agent-runners/orchestrator-state.mjs.map +1 -0
- package/dist/agent-runners/retry.cjs +30 -0
- package/dist/agent-runners/retry.d.cts +13 -0
- package/dist/agent-runners/retry.d.cts.map +1 -0
- package/dist/agent-runners/retry.d.mts +13 -0
- package/dist/agent-runners/retry.d.mts.map +1 -0
- package/dist/agent-runners/retry.mjs +30 -0
- package/dist/agent-runners/retry.mjs.map +1 -0
- package/dist/agent-runners/scratchpad-afs.cjs +276 -0
- package/dist/agent-runners/scratchpad-afs.d.cts +103 -0
- package/dist/agent-runners/scratchpad-afs.d.cts.map +1 -0
- package/dist/agent-runners/scratchpad-afs.d.mts +103 -0
- package/dist/agent-runners/scratchpad-afs.d.mts.map +1 -0
- package/dist/agent-runners/scratchpad-afs.mjs +271 -0
- package/dist/agent-runners/scratchpad-afs.mjs.map +1 -0
- package/dist/agent-runners/stream-router.cjs +72 -0
- package/dist/agent-runners/stream-router.d.cts +22 -0
- package/dist/agent-runners/stream-router.d.cts.map +1 -0
- package/dist/agent-runners/stream-router.d.mts +22 -0
- package/dist/agent-runners/stream-router.d.mts.map +1 -0
- package/dist/agent-runners/stream-router.mjs +72 -0
- package/dist/agent-runners/stream-router.mjs.map +1 -0
- package/dist/agent-runners/system-prompt.cjs +35 -0
- package/dist/agent-runners/system-prompt.d.cts +17 -0
- package/dist/agent-runners/system-prompt.d.cts.map +1 -0
- package/dist/agent-runners/system-prompt.d.mts +17 -0
- package/dist/agent-runners/system-prompt.d.mts.map +1 -0
- package/dist/agent-runners/system-prompt.mjs +34 -0
- package/dist/agent-runners/system-prompt.mjs.map +1 -0
- package/dist/agent-runners/team-modes/aggregates.cjs +36 -0
- package/dist/agent-runners/team-modes/aggregates.mjs +35 -0
- package/dist/agent-runners/team-modes/aggregates.mjs.map +1 -0
- package/dist/agent-runners/team-modes/iterate.cjs +46 -0
- package/dist/agent-runners/team-modes/iterate.mjs +47 -0
- package/dist/agent-runners/team-modes/iterate.mjs.map +1 -0
- package/dist/agent-runners/team-modes/parallel.cjs +59 -0
- package/dist/agent-runners/team-modes/parallel.mjs +60 -0
- package/dist/agent-runners/team-modes/parallel.mjs.map +1 -0
- package/dist/agent-runners/team-modes/reflection.cjs +155 -0
- package/dist/agent-runners/team-modes/reflection.mjs +156 -0
- package/dist/agent-runners/team-modes/reflection.mjs.map +1 -0
- package/dist/agent-runners/team-modes/sequential.cjs +63 -0
- package/dist/agent-runners/team-modes/sequential.mjs +64 -0
- package/dist/agent-runners/team-modes/sequential.mjs.map +1 -0
- package/dist/agent-runners/team-modes/utils.cjs +39 -0
- package/dist/agent-runners/team-modes/utils.mjs +36 -0
- package/dist/agent-runners/team-modes/utils.mjs.map +1 -0
- package/dist/agent-runners/team-runner.cjs +277 -0
- package/dist/agent-runners/team-runner.d.cts +34 -0
- package/dist/agent-runners/team-runner.d.cts.map +1 -0
- package/dist/agent-runners/team-runner.d.mts +34 -0
- package/dist/agent-runners/team-runner.d.mts.map +1 -0
- package/dist/agent-runners/team-runner.mjs +278 -0
- package/dist/agent-runners/team-runner.mjs.map +1 -0
- package/dist/agent-runners/template-context.cjs +32 -0
- package/dist/agent-runners/template-context.d.cts +43 -0
- package/dist/agent-runners/template-context.d.cts.map +1 -0
- package/dist/agent-runners/template-context.d.mts +43 -0
- package/dist/agent-runners/template-context.d.mts.map +1 -0
- package/dist/agent-runners/template-context.mjs +33 -0
- package/dist/agent-runners/template-context.mjs.map +1 -0
- package/dist/index.cjs +123 -0
- package/dist/index.d.cts +29 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.mjs +29 -0
- package/dist/program/agent-action.cjs +496 -0
- package/dist/program/agent-action.d.cts +42 -0
- package/dist/program/agent-action.d.cts.map +1 -0
- package/dist/program/agent-action.d.mts +42 -0
- package/dist/program/agent-action.d.mts.map +1 -0
- package/dist/program/agent-action.mjs +497 -0
- package/dist/program/agent-action.mjs.map +1 -0
- package/dist/program/agent-messages-tools.cjs +137 -0
- package/dist/program/agent-messages-tools.d.cts +59 -0
- package/dist/program/agent-messages-tools.d.cts.map +1 -0
- package/dist/program/agent-messages-tools.d.mts +59 -0
- package/dist/program/agent-messages-tools.d.mts.map +1 -0
- package/dist/program/agent-messages-tools.mjs +130 -0
- package/dist/program/agent-messages-tools.mjs.map +1 -0
- package/dist/program/agent-runner-registry.cjs +314 -0
- package/dist/program/agent-runner-registry.d.cts +52 -0
- package/dist/program/agent-runner-registry.d.cts.map +1 -0
- package/dist/program/agent-runner-registry.d.mts +52 -0
- package/dist/program/agent-runner-registry.d.mts.map +1 -0
- package/dist/program/agent-runner-registry.mjs +313 -0
- package/dist/program/agent-runner-registry.mjs.map +1 -0
- package/dist/program/agent-subscribe.cjs +72 -0
- package/dist/program/agent-subscribe.d.cts +18 -0
- package/dist/program/agent-subscribe.d.cts.map +1 -0
- package/dist/program/agent-subscribe.d.mts +18 -0
- package/dist/program/agent-subscribe.d.mts.map +1 -0
- package/dist/program/agent-subscribe.mjs +73 -0
- package/dist/program/agent-subscribe.mjs.map +1 -0
- package/dist/program/agent-tools.cjs +135 -0
- package/dist/program/agent-tools.d.cts +35 -0
- package/dist/program/agent-tools.d.cts.map +1 -0
- package/dist/program/agent-tools.d.mts +35 -0
- package/dist/program/agent-tools.d.mts.map +1 -0
- package/dist/program/agent-tools.mjs +136 -0
- package/dist/program/agent-tools.mjs.map +1 -0
- package/dist/program/manifest-nesting.cjs +57 -0
- package/dist/program/manifest-nesting.d.cts +13 -0
- package/dist/program/manifest-nesting.d.cts.map +1 -0
- package/dist/program/manifest-nesting.d.mts +13 -0
- package/dist/program/manifest-nesting.d.mts.map +1 -0
- package/dist/program/manifest-nesting.mjs +57 -0
- package/dist/program/manifest-nesting.mjs.map +1 -0
- package/dist/program/result-contract.cjs +55 -0
- package/dist/program/result-contract.d.cts +23 -0
- package/dist/program/result-contract.d.cts.map +1 -0
- package/dist/program/result-contract.d.mts +23 -0
- package/dist/program/result-contract.d.mts.map +1 -0
- package/dist/program/result-contract.mjs +51 -0
- package/dist/program/result-contract.mjs.map +1 -0
- package/dist/program/runner-error.cjs +71 -0
- package/dist/program/runner-error.d.cts +25 -0
- package/dist/program/runner-error.d.cts.map +1 -0
- package/dist/program/runner-error.d.mts +25 -0
- package/dist/program/runner-error.d.mts.map +1 -0
- package/dist/program/runner-error.mjs +72 -0
- package/dist/program/runner-error.mjs.map +1 -0
- package/dist/program/scoped-afs.cjs +538 -0
- package/dist/program/scoped-afs.d.cts +245 -0
- package/dist/program/scoped-afs.d.cts.map +1 -0
- package/dist/program/scoped-afs.d.mts +245 -0
- package/dist/program/scoped-afs.d.mts.map +1 -0
- package/dist/program/scoped-afs.mjs +531 -0
- package/dist/program/scoped-afs.mjs.map +1 -0
- package/dist/program/session-hierarchy.cjs +1 -0
- package/dist/program/session-hierarchy.d.cts +2 -0
- package/dist/program/session-hierarchy.d.mts +2 -0
- package/dist/program/session-hierarchy.mjs +3 -0
- package/dist/program/tool-discovery/ash-frontmatter.cjs +83 -0
- package/dist/program/tool-discovery/ash-frontmatter.d.cts +21 -0
- package/dist/program/tool-discovery/ash-frontmatter.d.cts.map +1 -0
- package/dist/program/tool-discovery/ash-frontmatter.d.mts +21 -0
- package/dist/program/tool-discovery/ash-frontmatter.d.mts.map +1 -0
- package/dist/program/tool-discovery/ash-frontmatter.mjs +84 -0
- package/dist/program/tool-discovery/ash-frontmatter.mjs.map +1 -0
- package/dist/program/tool-discovery/dot-path-resolver.cjs +60 -0
- package/dist/program/tool-discovery/dot-path-resolver.mjs +61 -0
- package/dist/program/tool-discovery/dot-path-resolver.mjs.map +1 -0
- package/dist/program/tool-discovery/skill-gate.cjs +36 -0
- package/dist/program/tool-discovery/skill-gate.d.cts +10 -0
- package/dist/program/tool-discovery/skill-gate.d.cts.map +1 -0
- package/dist/program/tool-discovery/skill-gate.d.mts +10 -0
- package/dist/program/tool-discovery/skill-gate.d.mts.map +1 -0
- package/dist/program/tool-discovery/skill-gate.mjs +35 -0
- package/dist/program/tool-discovery/skill-gate.mjs.map +1 -0
- package/dist/providers/basic/ash/dist/index.cjs +1809 -0
- package/dist/providers/basic/ash/dist/index.mjs +1807 -0
- package/dist/providers/basic/ash/dist/index.mjs.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
const require_index = require('../providers/basic/ash/dist/index.cjs');
|
|
2
|
+
const require_ash_frontmatter = require('./tool-discovery/ash-frontmatter.cjs');
|
|
3
|
+
const require_dot_path_resolver = require('./tool-discovery/dot-path-resolver.cjs');
|
|
4
|
+
const require_skill_gate = require('./tool-discovery/skill-gate.cjs');
|
|
5
|
+
let ufo = require("ufo");
|
|
6
|
+
|
|
7
|
+
//#region src/program/agent-tools.ts
|
|
8
|
+
/**
|
|
9
|
+
* Agent tool catalog compiler (S13).
|
|
10
|
+
*
|
|
11
|
+
* Orchestrates dot-path resolution, .ash frontmatter parsing, skill gating,
|
|
12
|
+
* and auto-registration of .actions/cancel + .actions/status into a unified
|
|
13
|
+
* tool catalog for the AI runner.
|
|
14
|
+
*
|
|
15
|
+
* All file I/O goes through AFS — never direct filesystem access.
|
|
16
|
+
*/
|
|
17
|
+
async function compileToolCatalog(afs, options) {
|
|
18
|
+
const { tools, blockletRoot, skillPaths, activeSkills, mountPath } = options;
|
|
19
|
+
const warnings = [];
|
|
20
|
+
const whitelist = [];
|
|
21
|
+
const localTools = [];
|
|
22
|
+
const barePaths = [];
|
|
23
|
+
const objectEntries = [];
|
|
24
|
+
for (const t of tools) if (typeof t === "string") barePaths.push(t);
|
|
25
|
+
else objectEntries.push(t);
|
|
26
|
+
const resolvedBare = require_dot_path_resolver.resolveDotPaths(barePaths, blockletRoot);
|
|
27
|
+
whitelist.push(...resolvedBare);
|
|
28
|
+
for (const entry of objectEntries) whitelist.push({
|
|
29
|
+
path: entry.path,
|
|
30
|
+
ops: require_index.withQueryPairing(entry.ops ?? [
|
|
31
|
+
"read",
|
|
32
|
+
"list",
|
|
33
|
+
"search"
|
|
34
|
+
]),
|
|
35
|
+
...entry.maxDepth != null ? { maxDepth: entry.maxDepth } : {}
|
|
36
|
+
});
|
|
37
|
+
for (const barePath of barePaths) if (isToolsDirectory(barePath)) {
|
|
38
|
+
const ashTools = await scanAshDirectory(afs, resolveToolsDir(barePath, blockletRoot), warnings);
|
|
39
|
+
localTools.push(...ashTools);
|
|
40
|
+
}
|
|
41
|
+
const allHelpers = [];
|
|
42
|
+
if (skillPaths?.length) for (const sp of skillPaths) {
|
|
43
|
+
const helpers = await discoverSkillHelpers(afs, resolveToolsDir(sp, blockletRoot), warnings);
|
|
44
|
+
allHelpers.push(...helpers);
|
|
45
|
+
}
|
|
46
|
+
const { merged, warnings: shadowWarnings } = require_skill_gate.mergeWithShadowing(localTools, require_skill_gate.filterByActiveSkills(allHelpers, activeSkills ?? /* @__PURE__ */ new Set()));
|
|
47
|
+
warnings.push(...shadowWarnings);
|
|
48
|
+
const agentActions = buildAgentActionTools(mountPath ?? blockletRoot);
|
|
49
|
+
return {
|
|
50
|
+
catalog: [...merged, ...agentActions].sort((a, b) => a.name.localeCompare(b.name)),
|
|
51
|
+
whitelist,
|
|
52
|
+
warnings,
|
|
53
|
+
helpers: allHelpers
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function isToolsDirectory(barePath) {
|
|
57
|
+
return (barePath.replace(/\/?\*\*\/?$/, "").replace(/\/$/, "").split("/").pop() ?? "") === "tools" || barePath.endsWith(".ash");
|
|
58
|
+
}
|
|
59
|
+
function resolveToolsDir(barePath, blockletRoot) {
|
|
60
|
+
const segments = barePath.replace(/\/?\*\*\/?$/, "").replace(/\/$/, "").split("/").filter(Boolean);
|
|
61
|
+
const resolved = [];
|
|
62
|
+
for (const part of segments) {
|
|
63
|
+
if (part === ".") continue;
|
|
64
|
+
if (part === "..") {
|
|
65
|
+
if (resolved.length === 0) throw new Error("TOOL_PATH_OUTSIDE_BLOCKLET");
|
|
66
|
+
resolved.pop();
|
|
67
|
+
} else resolved.push(part);
|
|
68
|
+
}
|
|
69
|
+
return (0, ufo.joinURL)(blockletRoot, ...resolved);
|
|
70
|
+
}
|
|
71
|
+
async function scanAshDirectory(afs, dirPath, warnings) {
|
|
72
|
+
let entries;
|
|
73
|
+
try {
|
|
74
|
+
entries = (await afs.list(dirPath)).list;
|
|
75
|
+
} catch {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
const tools = [];
|
|
79
|
+
for (const entry of entries) {
|
|
80
|
+
if (!entry.name.endsWith(".ash")) continue;
|
|
81
|
+
const result = await require_ash_frontmatter.parseFrontmatter(afs, (0, ufo.joinURL)(dirPath, entry.name));
|
|
82
|
+
if ("error" in result) {
|
|
83
|
+
warnings.push(`TOOL_FRONTMATTER_INVALID: ${result.error} in ${result.file}`);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
tools.push(result);
|
|
87
|
+
}
|
|
88
|
+
return tools;
|
|
89
|
+
}
|
|
90
|
+
async function discoverSkillHelpers(afs, skillsDir, warnings) {
|
|
91
|
+
let skillDirs;
|
|
92
|
+
try {
|
|
93
|
+
skillDirs = (await afs.list(skillsDir)).list;
|
|
94
|
+
} catch {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
const helpers = [];
|
|
98
|
+
for (const skillDir of skillDirs) {
|
|
99
|
+
if (skillDir.type !== "directory") continue;
|
|
100
|
+
const helpersDir = (0, ufo.joinURL)(skillsDir, skillDir.name, "helpers");
|
|
101
|
+
let helperFiles;
|
|
102
|
+
try {
|
|
103
|
+
helperFiles = (await afs.list(helpersDir)).list;
|
|
104
|
+
} catch {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
for (const file of helperFiles) {
|
|
108
|
+
if (!file.name.endsWith(".ash")) continue;
|
|
109
|
+
const result = await require_ash_frontmatter.parseFrontmatter(afs, (0, ufo.joinURL)(helpersDir, file.name));
|
|
110
|
+
if ("error" in result) {
|
|
111
|
+
warnings.push(`TOOL_FRONTMATTER_INVALID: ${result.error} in ${result.file}`);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
helpers.push({
|
|
115
|
+
skill: skillDir.name,
|
|
116
|
+
schema: result
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return helpers;
|
|
121
|
+
}
|
|
122
|
+
function buildAgentActionTools(mountPath) {
|
|
123
|
+
return [{
|
|
124
|
+
name: "agent_cancel",
|
|
125
|
+
description: `Cancel a running agent execution. Path: ${(0, ufo.joinURL)(mountPath, ".actions/cancel")}`,
|
|
126
|
+
filePath: (0, ufo.joinURL)(mountPath, ".actions/cancel")
|
|
127
|
+
}, {
|
|
128
|
+
name: "agent_status",
|
|
129
|
+
description: `Check the status of an agent execution. Path: ${(0, ufo.joinURL)(mountPath, ".actions/status")}`,
|
|
130
|
+
filePath: (0, ufo.joinURL)(mountPath, ".actions/status")
|
|
131
|
+
}];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
exports.compileToolCatalog = compileToolCatalog;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ToolSchema } from "./tool-discovery/ash-frontmatter.cjs";
|
|
2
|
+
import { SkillHelper } from "./tool-discovery/skill-gate.cjs";
|
|
3
|
+
import { ToolEntry } from "@aigne/afs-ash";
|
|
4
|
+
|
|
5
|
+
//#region src/program/agent-tools.d.ts
|
|
6
|
+
interface CatalogResult {
|
|
7
|
+
catalog: ToolSchema[];
|
|
8
|
+
whitelist: ToolEntry[];
|
|
9
|
+
warnings: string[];
|
|
10
|
+
helpers: SkillHelper[];
|
|
11
|
+
}
|
|
12
|
+
interface AFSLike {
|
|
13
|
+
read(path: string): Promise<string>;
|
|
14
|
+
list(path: string): Promise<{
|
|
15
|
+
list: Array<{
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
}>;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
interface CompileOptions {
|
|
22
|
+
tools: Array<string | {
|
|
23
|
+
path: string;
|
|
24
|
+
ops?: string[];
|
|
25
|
+
maxDepth?: number;
|
|
26
|
+
}>;
|
|
27
|
+
blockletRoot: string;
|
|
28
|
+
skillPaths?: string[];
|
|
29
|
+
activeSkills?: Set<string>;
|
|
30
|
+
mountPath?: string;
|
|
31
|
+
}
|
|
32
|
+
declare function compileToolCatalog(afs: AFSLike, options: CompileOptions): Promise<CatalogResult>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { CatalogResult, CompileOptions, compileToolCatalog };
|
|
35
|
+
//# sourceMappingURL=agent-tools.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tools.d.cts","names":[],"sources":["../../src/program/agent-tools.ts"],"mappings":";;;;;UAsBiB,aAAA;EACf,OAAA,EAAS,UAAA;EACT,SAAA,EAAW,SAAA;EACX,QAAA;EACA,OAAA,EAAS,WAAA;AAAA;AAAA,UAGD,OAAA;EACR,IAAA,CAAK,IAAA,WAAe,OAAA;EACpB,IAAA,CAAK,IAAA,WAAe,OAAA;IAAU,IAAA,EAAM,KAAA;MAAQ,IAAA;MAAc,IAAA;IAAA;EAAA;AAAA;AAAA,UAG3C,cAAA;EACf,KAAA,EAAO,KAAA;IAAiB,IAAA;IAAc,GAAA;IAAgB,QAAA;EAAA;EACtD,YAAA;EACA,UAAA;EACA,YAAA,GAAe,GAAA;EACf,SAAA;AAAA;AAAA,iBAGoB,kBAAA,CACpB,GAAA,EAAK,OAAA,EACL,OAAA,EAAS,cAAA,GACR,OAAA,CAAQ,aAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ToolSchema } from "./tool-discovery/ash-frontmatter.mjs";
|
|
2
|
+
import { SkillHelper } from "./tool-discovery/skill-gate.mjs";
|
|
3
|
+
import { ToolEntry } from "@aigne/afs-ash";
|
|
4
|
+
|
|
5
|
+
//#region src/program/agent-tools.d.ts
|
|
6
|
+
interface CatalogResult {
|
|
7
|
+
catalog: ToolSchema[];
|
|
8
|
+
whitelist: ToolEntry[];
|
|
9
|
+
warnings: string[];
|
|
10
|
+
helpers: SkillHelper[];
|
|
11
|
+
}
|
|
12
|
+
interface AFSLike {
|
|
13
|
+
read(path: string): Promise<string>;
|
|
14
|
+
list(path: string): Promise<{
|
|
15
|
+
list: Array<{
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
}>;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
interface CompileOptions {
|
|
22
|
+
tools: Array<string | {
|
|
23
|
+
path: string;
|
|
24
|
+
ops?: string[];
|
|
25
|
+
maxDepth?: number;
|
|
26
|
+
}>;
|
|
27
|
+
blockletRoot: string;
|
|
28
|
+
skillPaths?: string[];
|
|
29
|
+
activeSkills?: Set<string>;
|
|
30
|
+
mountPath?: string;
|
|
31
|
+
}
|
|
32
|
+
declare function compileToolCatalog(afs: AFSLike, options: CompileOptions): Promise<CatalogResult>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { CatalogResult, CompileOptions, compileToolCatalog };
|
|
35
|
+
//# sourceMappingURL=agent-tools.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tools.d.mts","names":[],"sources":["../../src/program/agent-tools.ts"],"mappings":";;;;;UAsBiB,aAAA;EACf,OAAA,EAAS,UAAA;EACT,SAAA,EAAW,SAAA;EACX,QAAA;EACA,OAAA,EAAS,WAAA;AAAA;AAAA,UAGD,OAAA;EACR,IAAA,CAAK,IAAA,WAAe,OAAA;EACpB,IAAA,CAAK,IAAA,WAAe,OAAA;IAAU,IAAA,EAAM,KAAA;MAAQ,IAAA;MAAc,IAAA;IAAA;EAAA;AAAA;AAAA,UAG3C,cAAA;EACf,KAAA,EAAO,KAAA;IAAiB,IAAA;IAAc,GAAA;IAAgB,QAAA;EAAA;EACtD,YAAA;EACA,UAAA;EACA,YAAA,GAAe,GAAA;EACf,SAAA;AAAA;AAAA,iBAGoB,kBAAA,CACpB,GAAA,EAAK,OAAA,EACL,OAAA,EAAS,cAAA,GACR,OAAA,CAAQ,aAAA"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { withQueryPairing } from "../providers/basic/ash/dist/index.mjs";
|
|
2
|
+
import { parseFrontmatter } from "./tool-discovery/ash-frontmatter.mjs";
|
|
3
|
+
import { resolveDotPaths } from "./tool-discovery/dot-path-resolver.mjs";
|
|
4
|
+
import { filterByActiveSkills, mergeWithShadowing } from "./tool-discovery/skill-gate.mjs";
|
|
5
|
+
import { joinURL } from "ufo";
|
|
6
|
+
|
|
7
|
+
//#region src/program/agent-tools.ts
|
|
8
|
+
/**
|
|
9
|
+
* Agent tool catalog compiler (S13).
|
|
10
|
+
*
|
|
11
|
+
* Orchestrates dot-path resolution, .ash frontmatter parsing, skill gating,
|
|
12
|
+
* and auto-registration of .actions/cancel + .actions/status into a unified
|
|
13
|
+
* tool catalog for the AI runner.
|
|
14
|
+
*
|
|
15
|
+
* All file I/O goes through AFS — never direct filesystem access.
|
|
16
|
+
*/
|
|
17
|
+
async function compileToolCatalog(afs, options) {
|
|
18
|
+
const { tools, blockletRoot, skillPaths, activeSkills, mountPath } = options;
|
|
19
|
+
const warnings = [];
|
|
20
|
+
const whitelist = [];
|
|
21
|
+
const localTools = [];
|
|
22
|
+
const barePaths = [];
|
|
23
|
+
const objectEntries = [];
|
|
24
|
+
for (const t of tools) if (typeof t === "string") barePaths.push(t);
|
|
25
|
+
else objectEntries.push(t);
|
|
26
|
+
const resolvedBare = resolveDotPaths(barePaths, blockletRoot);
|
|
27
|
+
whitelist.push(...resolvedBare);
|
|
28
|
+
for (const entry of objectEntries) whitelist.push({
|
|
29
|
+
path: entry.path,
|
|
30
|
+
ops: withQueryPairing(entry.ops ?? [
|
|
31
|
+
"read",
|
|
32
|
+
"list",
|
|
33
|
+
"search"
|
|
34
|
+
]),
|
|
35
|
+
...entry.maxDepth != null ? { maxDepth: entry.maxDepth } : {}
|
|
36
|
+
});
|
|
37
|
+
for (const barePath of barePaths) if (isToolsDirectory(barePath)) {
|
|
38
|
+
const ashTools = await scanAshDirectory(afs, resolveToolsDir(barePath, blockletRoot), warnings);
|
|
39
|
+
localTools.push(...ashTools);
|
|
40
|
+
}
|
|
41
|
+
const allHelpers = [];
|
|
42
|
+
if (skillPaths?.length) for (const sp of skillPaths) {
|
|
43
|
+
const helpers = await discoverSkillHelpers(afs, resolveToolsDir(sp, blockletRoot), warnings);
|
|
44
|
+
allHelpers.push(...helpers);
|
|
45
|
+
}
|
|
46
|
+
const { merged, warnings: shadowWarnings } = mergeWithShadowing(localTools, filterByActiveSkills(allHelpers, activeSkills ?? /* @__PURE__ */ new Set()));
|
|
47
|
+
warnings.push(...shadowWarnings);
|
|
48
|
+
const agentActions = buildAgentActionTools(mountPath ?? blockletRoot);
|
|
49
|
+
return {
|
|
50
|
+
catalog: [...merged, ...agentActions].sort((a, b) => a.name.localeCompare(b.name)),
|
|
51
|
+
whitelist,
|
|
52
|
+
warnings,
|
|
53
|
+
helpers: allHelpers
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function isToolsDirectory(barePath) {
|
|
57
|
+
return (barePath.replace(/\/?\*\*\/?$/, "").replace(/\/$/, "").split("/").pop() ?? "") === "tools" || barePath.endsWith(".ash");
|
|
58
|
+
}
|
|
59
|
+
function resolveToolsDir(barePath, blockletRoot) {
|
|
60
|
+
const segments = barePath.replace(/\/?\*\*\/?$/, "").replace(/\/$/, "").split("/").filter(Boolean);
|
|
61
|
+
const resolved = [];
|
|
62
|
+
for (const part of segments) {
|
|
63
|
+
if (part === ".") continue;
|
|
64
|
+
if (part === "..") {
|
|
65
|
+
if (resolved.length === 0) throw new Error("TOOL_PATH_OUTSIDE_BLOCKLET");
|
|
66
|
+
resolved.pop();
|
|
67
|
+
} else resolved.push(part);
|
|
68
|
+
}
|
|
69
|
+
return joinURL(blockletRoot, ...resolved);
|
|
70
|
+
}
|
|
71
|
+
async function scanAshDirectory(afs, dirPath, warnings) {
|
|
72
|
+
let entries;
|
|
73
|
+
try {
|
|
74
|
+
entries = (await afs.list(dirPath)).list;
|
|
75
|
+
} catch {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
const tools = [];
|
|
79
|
+
for (const entry of entries) {
|
|
80
|
+
if (!entry.name.endsWith(".ash")) continue;
|
|
81
|
+
const result = await parseFrontmatter(afs, joinURL(dirPath, entry.name));
|
|
82
|
+
if ("error" in result) {
|
|
83
|
+
warnings.push(`TOOL_FRONTMATTER_INVALID: ${result.error} in ${result.file}`);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
tools.push(result);
|
|
87
|
+
}
|
|
88
|
+
return tools;
|
|
89
|
+
}
|
|
90
|
+
async function discoverSkillHelpers(afs, skillsDir, warnings) {
|
|
91
|
+
let skillDirs;
|
|
92
|
+
try {
|
|
93
|
+
skillDirs = (await afs.list(skillsDir)).list;
|
|
94
|
+
} catch {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
const helpers = [];
|
|
98
|
+
for (const skillDir of skillDirs) {
|
|
99
|
+
if (skillDir.type !== "directory") continue;
|
|
100
|
+
const helpersDir = joinURL(skillsDir, skillDir.name, "helpers");
|
|
101
|
+
let helperFiles;
|
|
102
|
+
try {
|
|
103
|
+
helperFiles = (await afs.list(helpersDir)).list;
|
|
104
|
+
} catch {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
for (const file of helperFiles) {
|
|
108
|
+
if (!file.name.endsWith(".ash")) continue;
|
|
109
|
+
const result = await parseFrontmatter(afs, joinURL(helpersDir, file.name));
|
|
110
|
+
if ("error" in result) {
|
|
111
|
+
warnings.push(`TOOL_FRONTMATTER_INVALID: ${result.error} in ${result.file}`);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
helpers.push({
|
|
115
|
+
skill: skillDir.name,
|
|
116
|
+
schema: result
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return helpers;
|
|
121
|
+
}
|
|
122
|
+
function buildAgentActionTools(mountPath) {
|
|
123
|
+
return [{
|
|
124
|
+
name: "agent_cancel",
|
|
125
|
+
description: `Cancel a running agent execution. Path: ${joinURL(mountPath, ".actions/cancel")}`,
|
|
126
|
+
filePath: joinURL(mountPath, ".actions/cancel")
|
|
127
|
+
}, {
|
|
128
|
+
name: "agent_status",
|
|
129
|
+
description: `Check the status of an agent execution. Path: ${joinURL(mountPath, ".actions/status")}`,
|
|
130
|
+
filePath: joinURL(mountPath, ".actions/status")
|
|
131
|
+
}];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
export { compileToolCatalog };
|
|
136
|
+
//# sourceMappingURL=agent-tools.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tools.mjs","names":[],"sources":["../../src/program/agent-tools.ts"],"sourcesContent":["/**\n * Agent tool catalog compiler (S13).\n *\n * Orchestrates dot-path resolution, .ash frontmatter parsing, skill gating,\n * and auto-registration of .actions/cancel + .actions/status into a unified\n * tool catalog for the AI runner.\n *\n * All file I/O goes through AFS — never direct filesystem access.\n */\n\nimport { type ToolEntry, withQueryPairing } from \"@aigne/afs-ash\";\nimport { joinURL } from \"ufo\";\nimport { parseFrontmatter, type ToolSchema } from \"./tool-discovery/ash-frontmatter.js\";\nimport { resolveDotPaths } from \"./tool-discovery/dot-path-resolver.js\";\nimport {\n filterByActiveSkills,\n mergeWithShadowing,\n type SkillHelper,\n} from \"./tool-discovery/skill-gate.js\";\n\nexport type { ToolSchema } from \"./tool-discovery/ash-frontmatter.js\";\n\nexport interface CatalogResult {\n catalog: ToolSchema[];\n whitelist: ToolEntry[];\n warnings: string[];\n helpers: SkillHelper[];\n}\n\ninterface AFSLike {\n read(path: string): Promise<string>;\n list(path: string): Promise<{ list: Array<{ name: string; type: string }> }>;\n}\n\nexport interface CompileOptions {\n tools: Array<string | { path: string; ops?: string[]; maxDepth?: number }>;\n blockletRoot: string;\n skillPaths?: string[];\n activeSkills?: Set<string>;\n mountPath?: string;\n}\n\nexport async function compileToolCatalog(\n afs: AFSLike,\n options: CompileOptions,\n): Promise<CatalogResult> {\n const { tools, blockletRoot, skillPaths, activeSkills, mountPath } = options;\n const warnings: string[] = [];\n const whitelist: ToolEntry[] = [];\n const localTools: ToolSchema[] = [];\n\n const barePaths: string[] = [];\n const objectEntries: Array<{ path: string; ops?: string[]; maxDepth?: number }> = [];\n\n for (const t of tools) {\n if (typeof t === \"string\") {\n barePaths.push(t);\n } else {\n objectEntries.push(t);\n }\n }\n\n // 1. Resolve bare dot-paths to whitelist entries (throws on traversal)\n const resolvedBare = resolveDotPaths(barePaths, blockletRoot);\n whitelist.push(...resolvedBare);\n\n // 2. Pass-through object-form entries\n for (const entry of objectEntries) {\n whitelist.push({\n path: entry.path,\n // list grants pair with query (read-class collection view).\n ops: withQueryPairing(entry.ops ?? [\"read\", \"list\", \"search\"]),\n ...(entry.maxDepth != null ? { maxDepth: entry.maxDepth } : {}),\n });\n }\n\n // 3. Scan ./tools/ directories for .ash files\n for (const barePath of barePaths) {\n if (isToolsDirectory(barePath)) {\n const absDir = resolveToolsDir(barePath, blockletRoot);\n const ashTools = await scanAshDirectory(afs, absDir, warnings);\n localTools.push(...ashTools);\n }\n }\n\n // 4. Discover skill helpers\n const allHelpers: SkillHelper[] = [];\n if (skillPaths?.length) {\n for (const sp of skillPaths) {\n const absSkillsDir = resolveToolsDir(sp, blockletRoot);\n const helpers = await discoverSkillHelpers(afs, absSkillsDir, warnings);\n allHelpers.push(...helpers);\n }\n }\n\n // 5. Apply skill gate and merge with shadowing\n const activeHelpers = filterByActiveSkills(allHelpers, activeSkills ?? new Set());\n const { merged, warnings: shadowWarnings } = mergeWithShadowing(localTools, activeHelpers);\n warnings.push(...shadowWarnings);\n\n // 6. Auto-register .actions/cancel and .actions/status\n const agentActions = buildAgentActionTools(mountPath ?? blockletRoot);\n\n // 7. Combine and sort by name for deterministic output\n const catalog = [...merged, ...agentActions].sort((a, b) => a.name.localeCompare(b.name));\n\n return { catalog, whitelist, warnings, helpers: allHelpers };\n}\n\nfunction isToolsDirectory(barePath: string): boolean {\n const clean = barePath.replace(/\\/?\\*\\*\\/?$/, \"\").replace(/\\/$/, \"\");\n const lastSegment = clean.split(\"/\").pop() ?? \"\";\n return lastSegment === \"tools\" || barePath.endsWith(\".ash\");\n}\n\nfunction resolveToolsDir(barePath: string, blockletRoot: string): string {\n const stripped = barePath.replace(/\\/?\\*\\*\\/?$/, \"\").replace(/\\/$/, \"\");\n const segments = stripped.split(\"/\").filter(Boolean);\n const resolved: string[] = [];\n for (const part of segments) {\n if (part === \".\") continue;\n if (part === \"..\") {\n if (resolved.length === 0) throw new Error(\"TOOL_PATH_OUTSIDE_BLOCKLET\");\n resolved.pop();\n } else {\n resolved.push(part);\n }\n }\n return joinURL(blockletRoot, ...resolved);\n}\n\nasync function scanAshDirectory(\n afs: AFSLike,\n dirPath: string,\n warnings: string[],\n): Promise<ToolSchema[]> {\n let entries: Array<{ name: string; type: string }>;\n try {\n const result = await afs.list(dirPath);\n entries = result.list;\n } catch {\n return [];\n }\n\n const tools: ToolSchema[] = [];\n for (const entry of entries) {\n if (!entry.name.endsWith(\".ash\")) continue;\n const filePath = joinURL(dirPath, entry.name);\n const result = await parseFrontmatter(afs, filePath);\n if (\"error\" in result) {\n warnings.push(`TOOL_FRONTMATTER_INVALID: ${result.error} in ${result.file}`);\n continue;\n }\n tools.push(result);\n }\n\n return tools;\n}\n\nasync function discoverSkillHelpers(\n afs: AFSLike,\n skillsDir: string,\n warnings: string[],\n): Promise<SkillHelper[]> {\n let skillDirs: Array<{ name: string; type: string }>;\n try {\n const result = await afs.list(skillsDir);\n skillDirs = result.list;\n } catch {\n return [];\n }\n\n const helpers: SkillHelper[] = [];\n for (const skillDir of skillDirs) {\n if (skillDir.type !== \"directory\") continue;\n const helpersDir = joinURL(skillsDir, skillDir.name, \"helpers\");\n\n let helperFiles: Array<{ name: string; type: string }>;\n try {\n const result = await afs.list(helpersDir);\n helperFiles = result.list;\n } catch {\n continue;\n }\n\n for (const file of helperFiles) {\n if (!file.name.endsWith(\".ash\")) continue;\n const filePath = joinURL(helpersDir, file.name);\n const result = await parseFrontmatter(afs, filePath);\n if (\"error\" in result) {\n warnings.push(`TOOL_FRONTMATTER_INVALID: ${result.error} in ${result.file}`);\n continue;\n }\n helpers.push({ skill: skillDir.name, schema: result });\n }\n }\n\n return helpers;\n}\n\nfunction buildAgentActionTools(mountPath: string): ToolSchema[] {\n return [\n {\n name: \"agent_cancel\",\n description: `Cancel a running agent execution. Path: ${joinURL(mountPath, \".actions/cancel\")}`,\n filePath: joinURL(mountPath, \".actions/cancel\"),\n },\n {\n name: \"agent_status\",\n description: `Check the status of an agent execution. Path: ${joinURL(mountPath, \".actions/status\")}`,\n filePath: joinURL(mountPath, \".actions/status\"),\n },\n ];\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/program/manifest-nesting.ts
|
|
3
|
+
/**
|
|
4
|
+
* Returns true when a path looks relative-to-the-manifest-dir (would
|
|
5
|
+
* normally resolve against the manifest's containing directory). False
|
|
6
|
+
* for paths that are absolute (`/...`) or already rooted under
|
|
7
|
+
* `/packages/`.
|
|
8
|
+
*/
|
|
9
|
+
function isManifestRelative(p) {
|
|
10
|
+
if (typeof p !== "string" || p.length === 0) return false;
|
|
11
|
+
if (p.startsWith("/")) return false;
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Strip leading `./` and any redundant `/` so concatenating the prefix
|
|
16
|
+
* yields a clean path: `./<prefix>/<rest>`.
|
|
17
|
+
*/
|
|
18
|
+
function strip(p) {
|
|
19
|
+
return p.replace(/^\.?\/+/, "");
|
|
20
|
+
}
|
|
21
|
+
function joinSubdir(subdir, ref) {
|
|
22
|
+
return `./${subdir}/${strip(ref)}`;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Rebase a manifest's relative refs by prepending `subdir` (a path
|
|
26
|
+
* relative to `/packages/`, e.g. `agents/s6-sequential`).
|
|
27
|
+
*
|
|
28
|
+
* Empty / dot subdir = noop (returns the same object reference).
|
|
29
|
+
*/
|
|
30
|
+
function rebaseNestedManifest(manifest, subdir) {
|
|
31
|
+
const cleaned = subdir.replace(/^\.?\/+/, "").replace(/\/+$/, "");
|
|
32
|
+
if (cleaned === "" || cleaned === ".") return manifest;
|
|
33
|
+
const src = manifest;
|
|
34
|
+
const out = { ...src };
|
|
35
|
+
if (isManifestRelative(src.instructions)) out.instructions = joinSubdir(cleaned, src.instructions);
|
|
36
|
+
if (Array.isArray(src.members)) out.members = src.members.map((m) => isManifestRelative(m) ? joinSubdir(cleaned, m) : m);
|
|
37
|
+
if (isManifestRelative(src.actor)) out.actor = joinSubdir(cleaned, src.actor);
|
|
38
|
+
if (isManifestRelative(src.reviewer)) out.reviewer = joinSubdir(cleaned, src.reviewer);
|
|
39
|
+
for (const key of [
|
|
40
|
+
"planner",
|
|
41
|
+
"worker",
|
|
42
|
+
"completer"
|
|
43
|
+
]) {
|
|
44
|
+
const ref = src[key];
|
|
45
|
+
if (ref && typeof ref === "object" && !Array.isArray(ref)) {
|
|
46
|
+
const r = ref;
|
|
47
|
+
if (isManifestRelative(r.path)) out[key] = {
|
|
48
|
+
...r,
|
|
49
|
+
path: joinSubdir(cleaned, r.path)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
exports.rebaseNestedManifest = rebaseNestedManifest;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AgentManifest } from "@aigne/afs";
|
|
2
|
+
|
|
3
|
+
//#region src/program/manifest-nesting.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Rebase a manifest's relative refs by prepending `subdir` (a path
|
|
6
|
+
* relative to `/packages/`, e.g. `agents/s6-sequential`).
|
|
7
|
+
*
|
|
8
|
+
* Empty / dot subdir = noop (returns the same object reference).
|
|
9
|
+
*/
|
|
10
|
+
declare function rebaseNestedManifest<T extends AgentManifest>(manifest: T, subdir: string): T;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { rebaseNestedManifest };
|
|
13
|
+
//# sourceMappingURL=manifest-nesting.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-nesting.d.cts","names":[],"sources":["../../src/program/manifest-nesting.ts"],"mappings":";;;;;;;;;iBA0EgB,oBAAA,WAA+B,aAAA,CAAA,CAAe,QAAA,EAAU,CAAA,EAAG,MAAA,WAAiB,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AgentManifest } from "@aigne/afs";
|
|
2
|
+
|
|
3
|
+
//#region src/program/manifest-nesting.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Rebase a manifest's relative refs by prepending `subdir` (a path
|
|
6
|
+
* relative to `/packages/`, e.g. `agents/s6-sequential`).
|
|
7
|
+
*
|
|
8
|
+
* Empty / dot subdir = noop (returns the same object reference).
|
|
9
|
+
*/
|
|
10
|
+
declare function rebaseNestedManifest<T extends AgentManifest>(manifest: T, subdir: string): T;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { rebaseNestedManifest };
|
|
13
|
+
//# sourceMappingURL=manifest-nesting.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-nesting.d.mts","names":[],"sources":["../../src/program/manifest-nesting.ts"],"mappings":";;;;;;;;;iBA0EgB,oBAAA,WAA+B,aAAA,CAAA,CAAe,QAAA,EAAU,CAAA,EAAG,MAAA,WAAiB,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//#region src/program/manifest-nesting.ts
|
|
2
|
+
/**
|
|
3
|
+
* Returns true when a path looks relative-to-the-manifest-dir (would
|
|
4
|
+
* normally resolve against the manifest's containing directory). False
|
|
5
|
+
* for paths that are absolute (`/...`) or already rooted under
|
|
6
|
+
* `/packages/`.
|
|
7
|
+
*/
|
|
8
|
+
function isManifestRelative(p) {
|
|
9
|
+
if (typeof p !== "string" || p.length === 0) return false;
|
|
10
|
+
if (p.startsWith("/")) return false;
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Strip leading `./` and any redundant `/` so concatenating the prefix
|
|
15
|
+
* yields a clean path: `./<prefix>/<rest>`.
|
|
16
|
+
*/
|
|
17
|
+
function strip(p) {
|
|
18
|
+
return p.replace(/^\.?\/+/, "");
|
|
19
|
+
}
|
|
20
|
+
function joinSubdir(subdir, ref) {
|
|
21
|
+
return `./${subdir}/${strip(ref)}`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Rebase a manifest's relative refs by prepending `subdir` (a path
|
|
25
|
+
* relative to `/packages/`, e.g. `agents/s6-sequential`).
|
|
26
|
+
*
|
|
27
|
+
* Empty / dot subdir = noop (returns the same object reference).
|
|
28
|
+
*/
|
|
29
|
+
function rebaseNestedManifest(manifest, subdir) {
|
|
30
|
+
const cleaned = subdir.replace(/^\.?\/+/, "").replace(/\/+$/, "");
|
|
31
|
+
if (cleaned === "" || cleaned === ".") return manifest;
|
|
32
|
+
const src = manifest;
|
|
33
|
+
const out = { ...src };
|
|
34
|
+
if (isManifestRelative(src.instructions)) out.instructions = joinSubdir(cleaned, src.instructions);
|
|
35
|
+
if (Array.isArray(src.members)) out.members = src.members.map((m) => isManifestRelative(m) ? joinSubdir(cleaned, m) : m);
|
|
36
|
+
if (isManifestRelative(src.actor)) out.actor = joinSubdir(cleaned, src.actor);
|
|
37
|
+
if (isManifestRelative(src.reviewer)) out.reviewer = joinSubdir(cleaned, src.reviewer);
|
|
38
|
+
for (const key of [
|
|
39
|
+
"planner",
|
|
40
|
+
"worker",
|
|
41
|
+
"completer"
|
|
42
|
+
]) {
|
|
43
|
+
const ref = src[key];
|
|
44
|
+
if (ref && typeof ref === "object" && !Array.isArray(ref)) {
|
|
45
|
+
const r = ref;
|
|
46
|
+
if (isManifestRelative(r.path)) out[key] = {
|
|
47
|
+
...r,
|
|
48
|
+
path: joinSubdir(cleaned, r.path)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { rebaseNestedManifest };
|
|
57
|
+
//# sourceMappingURL=manifest-nesting.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-nesting.mjs","names":[],"sources":["../../src/program/manifest-nesting.ts"],"sourcesContent":["/**\n * Rebase relative refs in an AgentManifest that lives in a nested\n * directory under a blocklet's `/packages/` root.\n *\n * Why this exists:\n *\n * The team-runner / orchestrator-runner / instruction-loader resolve\n * relative paths against `/packages/`, not against the manifest's own\n * directory. That assumption holds when there's exactly one manifest\n * per blocklet (the legacy layout). Once a blocklet hosts multiple\n * nested agents at `agents/<n>/agent.{yml,json}`, every relative\n * ref inside those manifests would still try to resolve against\n * `/packages/` — and miss its sibling files.\n *\n * We deliberately keep the runners untouched: they're load-bearing for\n * every existing blocklet, and \"manifests live at /packages root\" is a\n * simple invariant. Instead, the blocklet manager calls\n * `rebaseNestedManifest(manifest, \"agents/<n>\")` once at registration\n * time, prepending the subdir to every relative ref so they resolve\n * against `/packages/` and still land in the right place.\n *\n * The resulting manifest is \"as if\" it lived at `/packages/` directly,\n * pointing into a deeper subtree.\n *\n * Refs that get rebased:\n *\n * - `instructions` — system-prompt path, read relative to manifest dir\n * - `members[]` — team members\n * - `actor` / `reviewer` — reflection roles\n * - `planner.path` / `worker.path` / `completer.path` — orchestrator\n * sub-agent refs (object form, only the `path` field rebased)\n *\n * Refs that are NOT touched (already absolute or non-relative):\n *\n * - `model` (typically `/dev/ai/.actions/chat`)\n * - paths starting with `/packages/` (already absolute)\n * - `tools[].path` (resolved separately by `resolveDotPaths` against\n * mountPath, with its own caller-relative semantics)\n *\n * The function is pure: returns a new manifest, never mutates the input.\n */\n\nimport type { AgentManifest } from \"@aigne/afs\";\n\n/**\n * Returns true when a path looks relative-to-the-manifest-dir (would\n * normally resolve against the manifest's containing directory). False\n * for paths that are absolute (`/...`) or already rooted under\n * `/packages/`.\n */\nfunction isManifestRelative(p: string | undefined): p is string {\n if (typeof p !== \"string\" || p.length === 0) return false;\n if (p.startsWith(\"/\")) return false;\n return true;\n}\n\n/**\n * Strip leading `./` and any redundant `/` so concatenating the prefix\n * yields a clean path: `./<prefix>/<rest>`.\n */\nfunction strip(p: string): string {\n return p.replace(/^\\.?\\/+/, \"\");\n}\n\nfunction joinSubdir(subdir: string, ref: string): string {\n return `./${subdir}/${strip(ref)}`;\n}\n\n/**\n * Rebase a manifest's relative refs by prepending `subdir` (a path\n * relative to `/packages/`, e.g. `agents/s6-sequential`).\n *\n * Empty / dot subdir = noop (returns the same object reference).\n */\nexport function rebaseNestedManifest<T extends AgentManifest>(manifest: T, subdir: string): T {\n const cleaned = subdir.replace(/^\\.?\\/+/, \"\").replace(/\\/+$/, \"\");\n if (cleaned === \"\" || cleaned === \".\") return manifest;\n\n // Cast to a permissive shape — manifest-shape varies by `type` and the\n // schema fields are heterogeneous. We touch each field defensively so\n // unrelated runtime types don't get accidentally rewritten.\n const src = manifest as unknown as Record<string, unknown>;\n const out: Record<string, unknown> = { ...src };\n\n if (isManifestRelative(src.instructions as string | undefined)) {\n out.instructions = joinSubdir(cleaned, src.instructions as string);\n }\n\n if (Array.isArray(src.members)) {\n out.members = (src.members as unknown[]).map((m) =>\n isManifestRelative(m as string | undefined) ? joinSubdir(cleaned, m as string) : m,\n );\n }\n\n if (isManifestRelative(src.actor as string | undefined)) {\n out.actor = joinSubdir(cleaned, src.actor as string);\n }\n if (isManifestRelative(src.reviewer as string | undefined)) {\n out.reviewer = joinSubdir(cleaned, src.reviewer as string);\n }\n\n for (const key of [\"planner\", \"worker\", \"completer\"] as const) {\n const ref = src[key];\n if (ref && typeof ref === \"object\" && !Array.isArray(ref)) {\n const r = ref as Record<string, unknown>;\n if (isManifestRelative(r.path as string | undefined)) {\n out[key] = { ...r, path: joinSubdir(cleaned, r.path as string) };\n }\n }\n }\n\n return out as T;\n}\n"],"mappings":";;;;;;;AAkDA,SAAS,mBAAmB,GAAoC;AAC9D,KAAI,OAAO,MAAM,YAAY,EAAE,WAAW,EAAG,QAAO;AACpD,KAAI,EAAE,WAAW,IAAI,CAAE,QAAO;AAC9B,QAAO;;;;;;AAOT,SAAS,MAAM,GAAmB;AAChC,QAAO,EAAE,QAAQ,WAAW,GAAG;;AAGjC,SAAS,WAAW,QAAgB,KAAqB;AACvD,QAAO,KAAK,OAAO,GAAG,MAAM,IAAI;;;;;;;;AASlC,SAAgB,qBAA8C,UAAa,QAAmB;CAC5F,MAAM,UAAU,OAAO,QAAQ,WAAW,GAAG,CAAC,QAAQ,QAAQ,GAAG;AACjE,KAAI,YAAY,MAAM,YAAY,IAAK,QAAO;CAK9C,MAAM,MAAM;CACZ,MAAM,MAA+B,EAAE,GAAG,KAAK;AAE/C,KAAI,mBAAmB,IAAI,aAAmC,CAC5D,KAAI,eAAe,WAAW,SAAS,IAAI,aAAuB;AAGpE,KAAI,MAAM,QAAQ,IAAI,QAAQ,CAC5B,KAAI,UAAW,IAAI,QAAsB,KAAK,MAC5C,mBAAmB,EAAwB,GAAG,WAAW,SAAS,EAAY,GAAG,EAClF;AAGH,KAAI,mBAAmB,IAAI,MAA4B,CACrD,KAAI,QAAQ,WAAW,SAAS,IAAI,MAAgB;AAEtD,KAAI,mBAAmB,IAAI,SAA+B,CACxD,KAAI,WAAW,WAAW,SAAS,IAAI,SAAmB;AAG5D,MAAK,MAAM,OAAO;EAAC;EAAW;EAAU;EAAY,EAAW;EAC7D,MAAM,MAAM,IAAI;AAChB,MAAI,OAAO,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,IAAI,EAAE;GACzD,MAAM,IAAI;AACV,OAAI,mBAAmB,EAAE,KAA2B,CAClD,KAAI,OAAO;IAAE,GAAG;IAAG,MAAM,WAAW,SAAS,EAAE,KAAe;IAAE;;;AAKtE,QAAO"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/program/result-contract.ts
|
|
3
|
+
/**
|
|
4
|
+
* S8 — Result contract utilities.
|
|
5
|
+
*
|
|
6
|
+
* stripSubAgentMeta: separates _meta from a sub-agent result so the parent
|
|
7
|
+
* LLM only sees the result value, while _meta flows through onToolProgress.
|
|
8
|
+
*
|
|
9
|
+
* sanitizeScratchPath: removes absolute filesystem prefixes, keeping only the
|
|
10
|
+
* AFS-relative portion.
|
|
11
|
+
*
|
|
12
|
+
* sanitizeMetaEnv: redacts env var values, keeping only names.
|
|
13
|
+
*/
|
|
14
|
+
function stripSubAgentMeta(data) {
|
|
15
|
+
if (!data || typeof data !== "object" || !("_meta" in data)) return {
|
|
16
|
+
result: data,
|
|
17
|
+
meta: null
|
|
18
|
+
};
|
|
19
|
+
const d = data;
|
|
20
|
+
return {
|
|
21
|
+
result: d.result !== void 0 ? d.result : null,
|
|
22
|
+
meta: d._meta ?? null
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function isSubAgentResult(data) {
|
|
26
|
+
return !!data && typeof data === "object" && "_meta" in data;
|
|
27
|
+
}
|
|
28
|
+
function sanitizeScratchPath(raw) {
|
|
29
|
+
if (raw.startsWith("/instance/") || raw.startsWith("/modules/")) return raw;
|
|
30
|
+
for (const marker of ["/instance/", "/modules/"]) {
|
|
31
|
+
const idx = raw.indexOf(marker);
|
|
32
|
+
if (idx >= 0) return raw.slice(idx);
|
|
33
|
+
}
|
|
34
|
+
return "[redacted]";
|
|
35
|
+
}
|
|
36
|
+
function sanitizeMetaEnv(env) {
|
|
37
|
+
const safe = {};
|
|
38
|
+
for (const key of Object.keys(env)) safe[key] = "[redacted]";
|
|
39
|
+
return safe;
|
|
40
|
+
}
|
|
41
|
+
function isJsonSafe(value) {
|
|
42
|
+
try {
|
|
43
|
+
JSON.stringify(value);
|
|
44
|
+
return true;
|
|
45
|
+
} catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
exports.isJsonSafe = isJsonSafe;
|
|
52
|
+
exports.isSubAgentResult = isSubAgentResult;
|
|
53
|
+
exports.sanitizeMetaEnv = sanitizeMetaEnv;
|
|
54
|
+
exports.sanitizeScratchPath = sanitizeScratchPath;
|
|
55
|
+
exports.stripSubAgentMeta = stripSubAgentMeta;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/program/result-contract.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* S8 — Result contract utilities.
|
|
4
|
+
*
|
|
5
|
+
* stripSubAgentMeta: separates _meta from a sub-agent result so the parent
|
|
6
|
+
* LLM only sees the result value, while _meta flows through onToolProgress.
|
|
7
|
+
*
|
|
8
|
+
* sanitizeScratchPath: removes absolute filesystem prefixes, keeping only the
|
|
9
|
+
* AFS-relative portion.
|
|
10
|
+
*
|
|
11
|
+
* sanitizeMetaEnv: redacts env var values, keeping only names.
|
|
12
|
+
*/
|
|
13
|
+
declare function stripSubAgentMeta(data: unknown): {
|
|
14
|
+
result: unknown;
|
|
15
|
+
meta: Record<string, unknown> | null;
|
|
16
|
+
};
|
|
17
|
+
declare function isSubAgentResult(data: unknown): boolean;
|
|
18
|
+
declare function sanitizeScratchPath(raw: string): string;
|
|
19
|
+
declare function sanitizeMetaEnv(env: Record<string, unknown>): Record<string, string>;
|
|
20
|
+
declare function isJsonSafe(value: unknown): boolean;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { isJsonSafe, isSubAgentResult, sanitizeMetaEnv, sanitizeScratchPath, stripSubAgentMeta };
|
|
23
|
+
//# sourceMappingURL=result-contract.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-contract.d.cts","names":[],"sources":["../../src/program/result-contract.ts"],"mappings":";;AAYA;;;;;;;;;;iBAAgB,iBAAA,CAAkB,IAAA;EAChC,MAAA;EACA,IAAA,EAAM,MAAA;AAAA;AAAA,iBAYQ,gBAAA,CAAiB,IAAA;AAAA,iBAIjB,mBAAA,CAAoB,GAAA;AAAA,iBASpB,eAAA,CAAgB,GAAA,EAAK,MAAA,oBAA0B,MAAA;AAAA,iBAQ/C,UAAA,CAAW,KAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/program/result-contract.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* S8 — Result contract utilities.
|
|
4
|
+
*
|
|
5
|
+
* stripSubAgentMeta: separates _meta from a sub-agent result so the parent
|
|
6
|
+
* LLM only sees the result value, while _meta flows through onToolProgress.
|
|
7
|
+
*
|
|
8
|
+
* sanitizeScratchPath: removes absolute filesystem prefixes, keeping only the
|
|
9
|
+
* AFS-relative portion.
|
|
10
|
+
*
|
|
11
|
+
* sanitizeMetaEnv: redacts env var values, keeping only names.
|
|
12
|
+
*/
|
|
13
|
+
declare function stripSubAgentMeta(data: unknown): {
|
|
14
|
+
result: unknown;
|
|
15
|
+
meta: Record<string, unknown> | null;
|
|
16
|
+
};
|
|
17
|
+
declare function isSubAgentResult(data: unknown): boolean;
|
|
18
|
+
declare function sanitizeScratchPath(raw: string): string;
|
|
19
|
+
declare function sanitizeMetaEnv(env: Record<string, unknown>): Record<string, string>;
|
|
20
|
+
declare function isJsonSafe(value: unknown): boolean;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { isJsonSafe, isSubAgentResult, sanitizeMetaEnv, sanitizeScratchPath, stripSubAgentMeta };
|
|
23
|
+
//# sourceMappingURL=result-contract.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-contract.d.mts","names":[],"sources":["../../src/program/result-contract.ts"],"mappings":";;AAYA;;;;;;;;;;iBAAgB,iBAAA,CAAkB,IAAA;EAChC,MAAA;EACA,IAAA,EAAM,MAAA;AAAA;AAAA,iBAYQ,gBAAA,CAAiB,IAAA;AAAA,iBAIjB,mBAAA,CAAoB,GAAA;AAAA,iBASpB,eAAA,CAAgB,GAAA,EAAK,MAAA,oBAA0B,MAAA;AAAA,iBAQ/C,UAAA,CAAW,KAAA"}
|