@aigne/core 1.72.0-beta.3 → 1.72.0-beta.4
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/CHANGELOG.md +20 -0
- package/lib/cjs/agents/agent.d.ts +31 -1
- package/lib/cjs/agents/agent.js +13 -0
- package/lib/cjs/agents/ai-agent.d.ts +7 -0
- package/lib/cjs/agents/ai-agent.js +85 -3
- package/lib/cjs/agents/image-agent.d.ts +17 -1
- package/lib/cjs/agents/image-agent.js +16 -0
- package/lib/cjs/agents/image-model.d.ts +4 -4
- package/lib/cjs/agents/mcp-agent.d.ts +17 -0
- package/lib/cjs/agents/mcp-agent.js +18 -0
- package/lib/cjs/agents/team-agent.d.ts +55 -0
- package/lib/cjs/agents/team-agent.js +31 -0
- package/lib/cjs/agents/transform-agent.d.ts +12 -0
- package/lib/cjs/agents/transform-agent.js +13 -0
- package/lib/cjs/agents/video-model.d.ts +4 -4
- package/lib/cjs/loader/agent-yaml.d.ts +5 -67
- package/lib/cjs/loader/agent-yaml.js +4 -139
- package/lib/cjs/loader/agents.d.ts +4 -0
- package/lib/cjs/loader/agents.js +17 -0
- package/lib/cjs/loader/index.d.ts +18 -14
- package/lib/cjs/loader/index.js +20 -81
- package/lib/cjs/loader/schema.d.ts +21 -6
- package/lib/cjs/loader/schema.js +60 -1
- package/lib/cjs/prompt/prompt-builder.js +0 -1
- package/lib/cjs/prompt/skills/afs/agent-skill/agent-skill.d.ts +17 -0
- package/lib/cjs/prompt/skills/afs/agent-skill/agent-skill.js +63 -0
- package/lib/cjs/prompt/skills/afs/agent-skill/skill-loader.d.ts +13 -0
- package/lib/cjs/prompt/skills/afs/agent-skill/skill-loader.js +61 -0
- package/lib/cjs/prompt/skills/afs/delete.js +15 -3
- package/lib/cjs/prompt/skills/afs/edit.js +30 -7
- package/lib/cjs/prompt/skills/afs/exec.js +17 -6
- package/lib/cjs/prompt/skills/afs/index.js +4 -1
- package/lib/cjs/prompt/skills/afs/list.js +26 -10
- package/lib/cjs/prompt/skills/afs/read.js +14 -3
- package/lib/cjs/prompt/skills/afs/rename.js +18 -4
- package/lib/cjs/prompt/skills/afs/search.js +21 -5
- package/lib/cjs/prompt/skills/afs/write.js +18 -4
- package/lib/cjs/prompt/template.d.ts +23 -23
- package/lib/dts/agents/agent.d.ts +31 -1
- package/lib/dts/agents/ai-agent.d.ts +7 -0
- package/lib/dts/agents/image-agent.d.ts +17 -1
- package/lib/dts/agents/image-model.d.ts +4 -4
- package/lib/dts/agents/mcp-agent.d.ts +17 -0
- package/lib/dts/agents/team-agent.d.ts +55 -0
- package/lib/dts/agents/transform-agent.d.ts +12 -0
- package/lib/dts/agents/video-model.d.ts +4 -4
- package/lib/dts/aigne/context.d.ts +2 -2
- package/lib/dts/loader/agent-yaml.d.ts +5 -67
- package/lib/dts/loader/agents.d.ts +4 -0
- package/lib/dts/loader/index.d.ts +18 -14
- package/lib/dts/loader/schema.d.ts +21 -6
- package/lib/dts/prompt/skills/afs/agent-skill/agent-skill.d.ts +17 -0
- package/lib/dts/prompt/skills/afs/agent-skill/skill-loader.d.ts +13 -0
- package/lib/dts/prompt/template.d.ts +25 -25
- package/lib/esm/agents/agent.d.ts +31 -1
- package/lib/esm/agents/agent.js +13 -0
- package/lib/esm/agents/ai-agent.d.ts +7 -0
- package/lib/esm/agents/ai-agent.js +85 -3
- package/lib/esm/agents/image-agent.d.ts +17 -1
- package/lib/esm/agents/image-agent.js +16 -0
- package/lib/esm/agents/image-model.d.ts +4 -4
- package/lib/esm/agents/mcp-agent.d.ts +17 -0
- package/lib/esm/agents/mcp-agent.js +18 -0
- package/lib/esm/agents/team-agent.d.ts +55 -0
- package/lib/esm/agents/team-agent.js +31 -0
- package/lib/esm/agents/transform-agent.d.ts +12 -0
- package/lib/esm/agents/transform-agent.js +13 -0
- package/lib/esm/agents/video-model.d.ts +4 -4
- package/lib/esm/aigne/context.d.ts +2 -2
- package/lib/esm/loader/agent-yaml.d.ts +5 -67
- package/lib/esm/loader/agent-yaml.js +4 -138
- package/lib/esm/loader/agents.d.ts +4 -0
- package/lib/esm/loader/agents.js +14 -0
- package/lib/esm/loader/index.d.ts +18 -14
- package/lib/esm/loader/index.js +21 -81
- package/lib/esm/loader/schema.d.ts +21 -6
- package/lib/esm/loader/schema.js +57 -0
- package/lib/esm/prompt/prompt-builder.js +1 -2
- package/lib/esm/prompt/skills/afs/agent-skill/agent-skill.d.ts +17 -0
- package/lib/esm/prompt/skills/afs/agent-skill/agent-skill.js +59 -0
- package/lib/esm/prompt/skills/afs/agent-skill/skill-loader.d.ts +13 -0
- package/lib/esm/prompt/skills/afs/agent-skill/skill-loader.js +53 -0
- package/lib/esm/prompt/skills/afs/delete.js +15 -3
- package/lib/esm/prompt/skills/afs/edit.js +30 -7
- package/lib/esm/prompt/skills/afs/exec.js +17 -6
- package/lib/esm/prompt/skills/afs/index.js +4 -1
- package/lib/esm/prompt/skills/afs/list.js +26 -10
- package/lib/esm/prompt/skills/afs/read.js +14 -3
- package/lib/esm/prompt/skills/afs/rename.js +18 -4
- package/lib/esm/prompt/skills/afs/search.js +21 -5
- package/lib/esm/prompt/skills/afs/write.js +18 -4
- package/lib/esm/prompt/template.d.ts +25 -25
- package/package.json +5 -4
package/lib/cjs/loader/schema.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.imageModelSchema = exports.chatModelSchema = exports.defaultInputSchema = exports.inputOutputSchema = void 0;
|
|
3
|
+
exports.getInstructionsSchema = exports.imageModelSchema = exports.chatModelSchema = exports.defaultInputSchema = exports.inputOutputSchema = void 0;
|
|
4
4
|
exports.optionalize = optionalize;
|
|
5
5
|
exports.camelizeSchema = camelizeSchema;
|
|
6
6
|
exports.preprocessSchema = preprocessSchema;
|
|
7
|
+
exports.instructionsToPromptBuilder = instructionsToPromptBuilder;
|
|
7
8
|
const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
|
|
8
9
|
const yaml_1 = require("yaml");
|
|
9
10
|
const zod_1 = require("zod");
|
|
10
11
|
const agent_js_1 = require("../agents/agent.js");
|
|
12
|
+
const chat_model_js_1 = require("../agents/chat-model.js");
|
|
13
|
+
const prompt_builder_js_1 = require("../prompt/prompt-builder.js");
|
|
14
|
+
const template_js_1 = require("../prompt/template.js");
|
|
11
15
|
const camelize_js_1 = require("../utils/camelize.js");
|
|
12
16
|
const type_utils_js_1 = require("../utils/type-utils.js");
|
|
13
17
|
const inputOutputSchema = ({ path }) => {
|
|
@@ -101,3 +105,58 @@ function camelizeSchema(schema, { shallow = true } = {}) {
|
|
|
101
105
|
function preprocessSchema(fn, schema) {
|
|
102
106
|
return zod_1.z.preprocess(fn, schema);
|
|
103
107
|
}
|
|
108
|
+
const instructionItemSchema = camelizeSchema(zod_1.z.union([
|
|
109
|
+
zod_1.z.object({
|
|
110
|
+
role: chat_model_js_1.roleSchema.default("system"),
|
|
111
|
+
url: zod_1.z.string(),
|
|
112
|
+
cacheControl: optionalize(zod_1.z.object({
|
|
113
|
+
type: zod_1.z.literal("ephemeral"),
|
|
114
|
+
ttl: optionalize(zod_1.z.union([zod_1.z.literal("5m"), zod_1.z.literal("1h")])),
|
|
115
|
+
})),
|
|
116
|
+
}),
|
|
117
|
+
zod_1.z.object({
|
|
118
|
+
role: chat_model_js_1.roleSchema.default("system"),
|
|
119
|
+
content: zod_1.z.string(),
|
|
120
|
+
cacheControl: optionalize(zod_1.z.object({
|
|
121
|
+
type: zod_1.z.literal("ephemeral"),
|
|
122
|
+
ttl: optionalize(zod_1.z.union([zod_1.z.literal("5m"), zod_1.z.literal("1h")])),
|
|
123
|
+
})),
|
|
124
|
+
}),
|
|
125
|
+
]));
|
|
126
|
+
const parseInstructionItem = ({ filepath }) => async ({ role, cacheControl, ...v }) => {
|
|
127
|
+
if (role === "tool")
|
|
128
|
+
throw new Error(`'tool' role is not allowed in instruction item in agent file ${filepath}`);
|
|
129
|
+
if ("content" in v && typeof v.content === "string") {
|
|
130
|
+
return { role, content: v.content, path: filepath, cacheControl };
|
|
131
|
+
}
|
|
132
|
+
if ("url" in v && typeof v.url === "string") {
|
|
133
|
+
const url = index_js_1.nodejs.path.isAbsolute(v.url)
|
|
134
|
+
? v.url
|
|
135
|
+
: index_js_1.nodejs.path.join(index_js_1.nodejs.path.dirname(filepath), v.url);
|
|
136
|
+
return index_js_1.nodejs.fs
|
|
137
|
+
.readFile(url, "utf8")
|
|
138
|
+
.then((content) => ({ role, content, path: url, cacheControl }));
|
|
139
|
+
}
|
|
140
|
+
throw new Error(`Invalid instruction item in agent file ${filepath}. Expected 'content' or 'url' property`);
|
|
141
|
+
};
|
|
142
|
+
const getInstructionsSchema = ({ filepath }) => zod_1.z
|
|
143
|
+
.union([zod_1.z.string(), instructionItemSchema, zod_1.z.array(instructionItemSchema)])
|
|
144
|
+
.transform(async (v) => {
|
|
145
|
+
if (typeof v === "string")
|
|
146
|
+
return [{ role: "system", content: v, path: filepath }];
|
|
147
|
+
if (Array.isArray(v)) {
|
|
148
|
+
return Promise.all(v.map((item) => parseInstructionItem({ filepath })(item)));
|
|
149
|
+
}
|
|
150
|
+
return [await parseInstructionItem({ filepath })(v)];
|
|
151
|
+
});
|
|
152
|
+
exports.getInstructionsSchema = getInstructionsSchema;
|
|
153
|
+
function instructionsToPromptBuilder(instructions) {
|
|
154
|
+
return new prompt_builder_js_1.PromptBuilder({
|
|
155
|
+
instructions: typeof instructions === "string"
|
|
156
|
+
? instructions
|
|
157
|
+
: template_js_1.ChatMessagesTemplate.from((0, template_js_1.parseChatMessages)(instructions.map((i) => ({
|
|
158
|
+
...i,
|
|
159
|
+
options: { workingDir: index_js_1.nodejs.path.dirname(i.path) },
|
|
160
|
+
})))),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
@@ -119,7 +119,6 @@ class PromptBuilder {
|
|
|
119
119
|
const afs = options.agent?.afs;
|
|
120
120
|
if (afs && options.agent?.historyConfig?.disabled !== true) {
|
|
121
121
|
const historyModule = (await afs.listModules()).find((m) => m.module instanceof afs_history_1.AFSHistory);
|
|
122
|
-
messages.push(await template_js_1.SystemMessageTemplate.from(await (0, afs_builtin_prompt_js_1.getAFSSystemPrompt)(afs)).format({}));
|
|
123
122
|
if (historyModule) {
|
|
124
123
|
const history = await afs.list(historyModule.path, {
|
|
125
124
|
limit: options.agent?.maxRetrieveMemoryCount || 10,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Agent, type AgentOptions, type Message } from "../../../../agents/agent.js";
|
|
2
|
+
import type { Skill } from "./skill-loader.js";
|
|
3
|
+
export interface SkillToolInput extends Message {
|
|
4
|
+
skill: string;
|
|
5
|
+
args?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SkillToolOutput extends Message {
|
|
8
|
+
result: string;
|
|
9
|
+
}
|
|
10
|
+
export interface SkillToolOptions extends AgentOptions<SkillToolInput, SkillToolOutput> {
|
|
11
|
+
agentSkills: Skill[];
|
|
12
|
+
}
|
|
13
|
+
export declare class AgentSkill extends Agent<SkillToolInput, SkillToolOutput> {
|
|
14
|
+
constructor(options: SkillToolOptions);
|
|
15
|
+
private agentSkills;
|
|
16
|
+
process(input: SkillToolInput): Promise<SkillToolOutput>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgentSkill = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const agent_js_1 = require("../../../../agents/agent.js");
|
|
6
|
+
const skillToolInputSchema = zod_1.z.object({
|
|
7
|
+
skill: zod_1.z.string().describe("The name of the skill agent to invoke."),
|
|
8
|
+
args: zod_1.z.string().optional().describe("The arguments to pass to the skill."),
|
|
9
|
+
});
|
|
10
|
+
class AgentSkill extends agent_js_1.Agent {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
super({
|
|
13
|
+
name: "Skill",
|
|
14
|
+
taskTitle: "Invoke {{skill}}: {{args}}",
|
|
15
|
+
...options,
|
|
16
|
+
description: `\
|
|
17
|
+
Execute a skill within the main conversation
|
|
18
|
+
|
|
19
|
+
<skills_instructions>
|
|
20
|
+
When users ask you to perform tasks, check if any of the available skills below can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge.
|
|
21
|
+
|
|
22
|
+
When users ask you to run a "slash command" or reference "/" (e.g., "/commit", "/review-pr"), they are referring to a skill. Use this tool to invoke the corresponding skill.
|
|
23
|
+
|
|
24
|
+
User: "run /commit" Assistant: [Calls Skill tool with skill: "commit"]
|
|
25
|
+
How to invoke:
|
|
26
|
+
|
|
27
|
+
Use this tool with the skill name and optional arguments
|
|
28
|
+
|
|
29
|
+
Important:
|
|
30
|
+
|
|
31
|
+
When a skill is relevant, you must invoke this tool IMMEDIATELY as your first action
|
|
32
|
+
NEVER just announce or mention a skill in your text response without actually calling this tool
|
|
33
|
+
This is a BLOCKING REQUIREMENT: invoke the relevant Skill tool BEFORE generating any other response about the task
|
|
34
|
+
Only use skills listed in <available_skills> below
|
|
35
|
+
Do not invoke a skill that is already running
|
|
36
|
+
Do not use this tool for built-in CLI commands (like /help, /clear, etc.)
|
|
37
|
+
</skills_instructions>
|
|
38
|
+
|
|
39
|
+
<available_skills>
|
|
40
|
+
${options.agentSkills.map((s) => `${s.name}: ${s.description}`).join("\n\n")}
|
|
41
|
+
</available_skills>
|
|
42
|
+
`,
|
|
43
|
+
inputSchema: skillToolInputSchema,
|
|
44
|
+
});
|
|
45
|
+
this.agentSkills = options.agentSkills;
|
|
46
|
+
}
|
|
47
|
+
agentSkills;
|
|
48
|
+
async process(input) {
|
|
49
|
+
const skill = this.agentSkills.find((s) => s.name === input.skill);
|
|
50
|
+
if (!skill)
|
|
51
|
+
throw new Error(`Skill not found: ${input.skill}`);
|
|
52
|
+
return {
|
|
53
|
+
result: `\
|
|
54
|
+
Base directory for this skill: ${skill.path}
|
|
55
|
+
|
|
56
|
+
${skill.content}
|
|
57
|
+
|
|
58
|
+
${input.args ? `ARGUMENTS: ${input.args ?? "None"}` : ""}
|
|
59
|
+
`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.AgentSkill = AgentSkill;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AFS } from "@aigne/afs";
|
|
2
|
+
import { AgentSkill } from "./agent-skill.js";
|
|
3
|
+
export interface Skill {
|
|
4
|
+
path: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
content: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function loadSkill(path: string): Promise<Skill>;
|
|
10
|
+
export declare function loadSkills(paths: string[]): Promise<Skill[]>;
|
|
11
|
+
export declare function loadAgentSkillFromAFS({ afs, }: {
|
|
12
|
+
afs: AFS;
|
|
13
|
+
}): Promise<AgentSkill | undefined>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadSkill = loadSkill;
|
|
7
|
+
exports.loadSkills = loadSkills;
|
|
8
|
+
exports.loadAgentSkillFromAFS = loadAgentSkillFromAFS;
|
|
9
|
+
const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
|
|
10
|
+
const front_matter_1 = __importDefault(require("front-matter"));
|
|
11
|
+
const agent_skill_js_1 = require("./agent-skill.js");
|
|
12
|
+
function parseSkill(content, path) {
|
|
13
|
+
const meta = (0, front_matter_1.default)(content);
|
|
14
|
+
return {
|
|
15
|
+
path,
|
|
16
|
+
name: meta.attributes.name,
|
|
17
|
+
description: meta.attributes.description,
|
|
18
|
+
content: meta.body,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
async function loadSkill(path) {
|
|
22
|
+
const entry = index_js_1.nodejs.path.join(path, "SKILL.md");
|
|
23
|
+
const skill = await index_js_1.nodejs.fs.readFile(entry, "utf-8");
|
|
24
|
+
return parseSkill(skill, path);
|
|
25
|
+
}
|
|
26
|
+
async function loadSkills(paths) {
|
|
27
|
+
const skills = [];
|
|
28
|
+
for (const path of paths) {
|
|
29
|
+
const skill = await loadSkill(path);
|
|
30
|
+
skills.push(skill);
|
|
31
|
+
}
|
|
32
|
+
return skills;
|
|
33
|
+
}
|
|
34
|
+
async function loadAgentSkillFromAFS({ afs, }) {
|
|
35
|
+
const modules = await afs.listModules();
|
|
36
|
+
const filtered = modules.filter(({ module: m }) => "options" in m &&
|
|
37
|
+
typeof m.options === "object" &&
|
|
38
|
+
m.options &&
|
|
39
|
+
"agentSkills" in m.options &&
|
|
40
|
+
m.options.agentSkills === true);
|
|
41
|
+
if (!filtered.length)
|
|
42
|
+
return;
|
|
43
|
+
const skills = [];
|
|
44
|
+
for (const module of filtered) {
|
|
45
|
+
const data = (await afs.list(module.path, {
|
|
46
|
+
pattern: "**/SKILL.md",
|
|
47
|
+
})).data;
|
|
48
|
+
for (const entry of data) {
|
|
49
|
+
const { data: file } = await afs.read(entry.path);
|
|
50
|
+
if (typeof file?.content !== "string")
|
|
51
|
+
continue;
|
|
52
|
+
const skill = parseSkill(file.content, index_js_1.nodejs.path.dirname(entry.path));
|
|
53
|
+
skills.push(skill);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (!skills.length)
|
|
57
|
+
return;
|
|
58
|
+
return new agent_skill_js_1.AgentSkill({
|
|
59
|
+
agentSkills: skills,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -7,15 +7,27 @@ class AFSDeleteAgent extends base_js_1.AFSSkillBase {
|
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_delete",
|
|
10
|
-
description:
|
|
10
|
+
description: `Permanently delete files or directories from the Agentic File System (AFS)
|
|
11
|
+
- Removes files or directories at the specified AFS path
|
|
12
|
+
- Supports recursive deletion for directories with contents
|
|
13
|
+
- Use with caution as deletion is permanent
|
|
14
|
+
|
|
15
|
+
Usage:
|
|
16
|
+
- The path must be an absolute AFS path starting with "/" (e.g., "/docs/old-file.md", "/temp")
|
|
17
|
+
- This is NOT a local system file path - it operates within the AFS virtual file system
|
|
18
|
+
- To delete a directory, you MUST set recursive=true
|
|
19
|
+
- Deleting a non-empty directory without recursive=true will fail
|
|
20
|
+
- This operation cannot be undone`,
|
|
11
21
|
...options,
|
|
12
22
|
inputSchema: zod_1.z.object({
|
|
13
|
-
path: zod_1.z
|
|
23
|
+
path: zod_1.z
|
|
24
|
+
.string()
|
|
25
|
+
.describe("Absolute AFS path to delete (e.g., '/docs/old-file.md', '/temp'). Must start with '/'"),
|
|
14
26
|
recursive: zod_1.z
|
|
15
27
|
.boolean()
|
|
16
28
|
.optional()
|
|
17
29
|
.default(false)
|
|
18
|
-
.describe("
|
|
30
|
+
.describe("MUST be set to true to delete directories. Default: false (files only)"),
|
|
19
31
|
}),
|
|
20
32
|
outputSchema: zod_1.z.object({
|
|
21
33
|
status: zod_1.z.string(),
|
|
@@ -7,19 +7,42 @@ class AFSEditAgent extends base_js_1.AFSSkillBase {
|
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_edit",
|
|
10
|
-
description:
|
|
10
|
+
description: `Apply precise line-based patches to modify files in the Agentic File System (AFS)
|
|
11
|
+
- Performs targeted edits using line numbers without rewriting the entire file
|
|
12
|
+
- Supports both replacing and deleting line ranges
|
|
13
|
+
- Multiple patches can be applied in a single operation
|
|
14
|
+
|
|
15
|
+
Usage:
|
|
16
|
+
- The path must be an absolute AFS path starting with "/" (e.g., "/docs/readme.md")
|
|
17
|
+
- This is NOT a local system file path - it operates within the AFS virtual file system
|
|
18
|
+
- IMPORTANT: You MUST use afs_read with withLineNumbers=true before editing to get accurate line numbers
|
|
19
|
+
- Line numbers are 0-based: first line is 0, second line is 1, etc.
|
|
20
|
+
- The range [start_line, end_line) is exclusive on end_line`,
|
|
11
21
|
...options,
|
|
12
22
|
inputSchema: zod_1.z.object({
|
|
13
|
-
path: zod_1.z
|
|
23
|
+
path: zod_1.z
|
|
24
|
+
.string()
|
|
25
|
+
.describe("Absolute AFS path to the file to edit (e.g., '/docs/readme.md'). Must start with '/'"),
|
|
14
26
|
patches: zod_1.z
|
|
15
27
|
.array(zod_1.z.object({
|
|
16
|
-
start_line: zod_1.z
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
start_line: zod_1.z
|
|
29
|
+
.number()
|
|
30
|
+
.int()
|
|
31
|
+
.describe("Start line number (0-based, inclusive). First line is 0"),
|
|
32
|
+
end_line: zod_1.z
|
|
33
|
+
.number()
|
|
34
|
+
.int()
|
|
35
|
+
.describe("End line number (0-based, exclusive). To edit line 5 only, use start_line=5, end_line=6"),
|
|
36
|
+
replace: zod_1.z
|
|
37
|
+
.string()
|
|
38
|
+
.optional()
|
|
39
|
+
.describe("New content to insert. Omit when delete=true"),
|
|
40
|
+
delete: zod_1.z
|
|
41
|
+
.boolean()
|
|
42
|
+
.describe("Set to true to delete the line range. Set to false to replace with 'replace' content"),
|
|
20
43
|
}))
|
|
21
44
|
.min(1)
|
|
22
|
-
.describe("
|
|
45
|
+
.describe("Array of patches to apply. Each patch specifies a line range and the operation (delete or replace)"),
|
|
23
46
|
}),
|
|
24
47
|
outputSchema: zod_1.z.object({
|
|
25
48
|
status: zod_1.z.string(),
|
|
@@ -7,14 +7,25 @@ class AFSExecAgent extends base_js_1.AFSSkillBase {
|
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_exec",
|
|
10
|
-
description: `
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
description: `Execute files marked as executable in the Agentic File System (AFS)
|
|
11
|
+
- Runs executable entries (functions, agents, skills) registered at a given AFS path
|
|
12
|
+
- Passes arguments to the executable and returns its output
|
|
13
|
+
- Use this to invoke dynamic functionality stored in AFS
|
|
14
|
+
|
|
15
|
+
Usage:
|
|
16
|
+
- The path must be an absolute AFS path to an executable entry (e.g., "/skills/summarize", "/agents/translator")
|
|
17
|
+
- This is NOT a local system file path - it operates within the AFS virtual file system
|
|
18
|
+
- Use afs_list to discover available executables (look for entries with execute metadata)
|
|
19
|
+
- Arguments must be a valid JSON string matching the executable's input schema
|
|
20
|
+
- The executable's input/output schema can be found in its metadata`,
|
|
14
21
|
...options,
|
|
15
22
|
inputSchema: zod_1.z.object({
|
|
16
|
-
path: zod_1.z
|
|
17
|
-
|
|
23
|
+
path: zod_1.z
|
|
24
|
+
.string()
|
|
25
|
+
.describe("Absolute AFS path to the executable (e.g., '/skills/summarize'). Must start with '/'"),
|
|
26
|
+
args: zod_1.z
|
|
27
|
+
.string()
|
|
28
|
+
.describe('JSON string of arguments matching the executable\'s input schema (e.g., \'{"text": "hello"}\')'),
|
|
18
29
|
}),
|
|
19
30
|
outputSchema: zod_1.z.object({
|
|
20
31
|
data: zod_1.z.record(zod_1.z.any()),
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAFSSkills = getAFSSkills;
|
|
4
|
+
const type_utils_js_1 = require("../../../utils/type-utils.js");
|
|
5
|
+
const skill_loader_js_1 = require("./agent-skill/skill-loader.js");
|
|
4
6
|
const delete_js_1 = require("./delete.js");
|
|
5
7
|
const edit_js_1 = require("./edit.js");
|
|
6
8
|
const exec_js_1 = require("./exec.js");
|
|
@@ -19,5 +21,6 @@ async function getAFSSkills(afs) {
|
|
|
19
21
|
new delete_js_1.AFSDeleteAgent({ afs }),
|
|
20
22
|
new rename_js_1.AFSRenameAgent({ afs }),
|
|
21
23
|
new exec_js_1.AFSExecAgent({ afs }),
|
|
22
|
-
|
|
24
|
+
await (0, skill_loader_js_1.loadAgentSkillFromAFS)({ afs }),
|
|
25
|
+
].filter(type_utils_js_1.isNonNullable);
|
|
23
26
|
}
|
|
@@ -7,26 +7,42 @@ class AFSListAgent extends base_js_1.AFSSkillBase {
|
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_list",
|
|
10
|
-
description:
|
|
10
|
+
description: `List contents within the Agentic File System (AFS)
|
|
11
|
+
- Returns files and directories at the specified AFS path
|
|
12
|
+
- Supports recursive listing with configurable depth
|
|
13
|
+
- Supports glob pattern filtering to match specific files
|
|
14
|
+
- By default respects .gitignore rules to filter out ignored files
|
|
15
|
+
- Use this tool when you need to explore AFS contents or understand file organization
|
|
16
|
+
|
|
17
|
+
Usage:
|
|
18
|
+
- The path must be an absolute AFS path starting with "/" (e.g., "/", "/docs", "/memory/user")
|
|
19
|
+
- This is NOT a local system file path - it operates within the AFS virtual file system
|
|
20
|
+
- Use maxDepth to control recursion depth (default: 1, current directory only)
|
|
21
|
+
- Use pattern to filter entries by glob pattern:
|
|
22
|
+
- "*.ts" - match TypeScript files in current directory
|
|
23
|
+
- "**/*.js" - match all JavaScript files recursively
|
|
24
|
+
- "src/**/*.{ts,tsx}" - match TypeScript files in src directory
|
|
25
|
+
- Results are filtered by .gitignore by default; set disableGitignore to include ignored files`,
|
|
11
26
|
...options,
|
|
12
27
|
inputSchema: zod_1.z.object({
|
|
13
|
-
path: zod_1.z
|
|
28
|
+
path: zod_1.z
|
|
29
|
+
.string()
|
|
30
|
+
.describe("Absolute AFS path to list (e.g., '/', '/docs', '/memory/user'). Must start with '/'"),
|
|
14
31
|
options: zod_1.z
|
|
15
32
|
.object({
|
|
16
|
-
maxDepth: zod_1.z
|
|
33
|
+
maxDepth: zod_1.z
|
|
34
|
+
.number()
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Maximum depth of directory recursion. 1 = current directory only, 2 = include subdirectories, etc. Default: 1"),
|
|
17
37
|
disableGitignore: zod_1.z
|
|
18
38
|
.boolean()
|
|
19
39
|
.optional()
|
|
20
|
-
.describe("
|
|
40
|
+
.describe("Set to true to include files normally ignored by .gitignore rules. Default: false (respects .gitignore)"),
|
|
21
41
|
maxChildren: zod_1.z
|
|
22
42
|
.number()
|
|
23
43
|
.optional()
|
|
24
|
-
.describe("Maximum number of
|
|
25
|
-
|
|
26
|
-
.union([zod_1.z.literal("simple-list"), zod_1.z.literal("tree")])
|
|
27
|
-
.optional()
|
|
28
|
-
.default("simple-list")
|
|
29
|
-
.describe("Output format, either 'simple-list', or 'tree', default is 'simple-list'"),
|
|
44
|
+
.describe("Maximum number of entries to return per directory. Useful for large directories to avoid overwhelming output"),
|
|
45
|
+
pattern: zod_1.z.string().optional().describe("Glob pattern to filter entries by path"),
|
|
30
46
|
})
|
|
31
47
|
.optional(),
|
|
32
48
|
}),
|
|
@@ -7,14 +7,25 @@ class AFSReadAgent extends base_js_1.AFSSkillBase {
|
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_read",
|
|
10
|
-
description:
|
|
10
|
+
description: `Read file contents from the Agentic File System (AFS)
|
|
11
|
+
- Returns the complete content of a file at the specified AFS path
|
|
12
|
+
- Supports line numbers output for precise editing references
|
|
13
|
+
- Use this tool when you need to review, analyze, or understand file content
|
|
14
|
+
|
|
15
|
+
Usage:
|
|
16
|
+
- The path must be an absolute AFS path starting with "/" (e.g., "/docs/readme.md", "/memory/user/notes")
|
|
17
|
+
- This is NOT a local system file path - it operates within the AFS virtual file system
|
|
18
|
+
- IMPORTANT: You MUST set withLineNumbers to true before using afs_edit, as line numbers are required for precise edits
|
|
19
|
+
- Returns the file's content along with metadata (id, path, timestamps, etc.)`,
|
|
11
20
|
...options,
|
|
12
21
|
inputSchema: zod_1.z.object({
|
|
13
|
-
path: zod_1.z
|
|
22
|
+
path: zod_1.z
|
|
23
|
+
.string()
|
|
24
|
+
.describe("Absolute AFS path to the file to read (e.g., '/docs/readme.md'). Must start with '/'"),
|
|
14
25
|
withLineNumbers: zod_1.z
|
|
15
26
|
.boolean()
|
|
16
27
|
.optional()
|
|
17
|
-
.describe("
|
|
28
|
+
.describe("MUST be set to true before using afs_edit. Adds line numbers to output (format: '1| line content')"),
|
|
18
29
|
}),
|
|
19
30
|
outputSchema: zod_1.z.object({
|
|
20
31
|
status: zod_1.z.string(),
|
|
@@ -7,16 +7,30 @@ class AFSRenameAgent extends base_js_1.AFSSkillBase {
|
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_rename",
|
|
10
|
-
description:
|
|
10
|
+
description: `Rename or move files and directories within the Agentic File System (AFS)
|
|
11
|
+
- Renames a file or directory to a new name
|
|
12
|
+
- Can also move files/directories to a different location
|
|
13
|
+
- Optionally overwrites existing files at the destination
|
|
14
|
+
|
|
15
|
+
Usage:
|
|
16
|
+
- Both paths must be absolute AFS paths starting with "/" (e.g., "/docs/old-name.md" -> "/docs/new-name.md")
|
|
17
|
+
- This is NOT a local system file path - it operates within the AFS virtual file system
|
|
18
|
+
- To move a file, specify a different directory in newPath (e.g., "/docs/file.md" -> "/archive/file.md")
|
|
19
|
+
- If newPath already exists, the operation will fail unless overwrite=true
|
|
20
|
+
- Moving directories moves all contents recursively`,
|
|
11
21
|
...options,
|
|
12
22
|
inputSchema: zod_1.z.object({
|
|
13
|
-
oldPath: zod_1.z
|
|
14
|
-
|
|
23
|
+
oldPath: zod_1.z
|
|
24
|
+
.string()
|
|
25
|
+
.describe("Current absolute AFS path (e.g., '/docs/old-name.md'). Must start with '/'"),
|
|
26
|
+
newPath: zod_1.z
|
|
27
|
+
.string()
|
|
28
|
+
.describe("New absolute AFS path (e.g., '/docs/new-name.md'). Must start with '/'"),
|
|
15
29
|
overwrite: zod_1.z
|
|
16
30
|
.boolean()
|
|
17
31
|
.optional()
|
|
18
32
|
.default(false)
|
|
19
|
-
.describe("
|
|
33
|
+
.describe("Set to true to overwrite if destination already exists. Default: false (fails if exists)"),
|
|
20
34
|
}),
|
|
21
35
|
outputSchema: zod_1.z.object({
|
|
22
36
|
status: zod_1.z.string(),
|
|
@@ -7,18 +7,34 @@ class AFSSearchAgent extends base_js_1.AFSSkillBase {
|
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_search",
|
|
10
|
-
description:
|
|
10
|
+
description: `Search file contents within the Agentic File System (AFS)
|
|
11
|
+
- Searches for files containing specific text, keywords, or patterns
|
|
12
|
+
- Returns matching entries with their content and metadata
|
|
13
|
+
- Supports case-sensitive and case-insensitive search modes
|
|
14
|
+
- Use this tool when you need to find files by their content
|
|
15
|
+
|
|
16
|
+
Usage:
|
|
17
|
+
- The path must be an absolute AFS path starting with "/" (e.g., "/", "/docs", "/memory")
|
|
18
|
+
- This is NOT a local system file path - it operates within the AFS virtual file system
|
|
19
|
+
- The query can be keywords, phrases, or text patterns to search for
|
|
20
|
+
- Use limit to control the number of results returned
|
|
21
|
+
- Search is case-insensitive by default; set caseSensitive to true for exact case matching`,
|
|
11
22
|
...options,
|
|
12
23
|
inputSchema: zod_1.z.object({
|
|
13
|
-
path: zod_1.z
|
|
14
|
-
|
|
24
|
+
path: zod_1.z
|
|
25
|
+
.string()
|
|
26
|
+
.describe("Absolute AFS path to search in (e.g., '/', '/docs', '/memory'). Must start with '/'"),
|
|
27
|
+
query: zod_1.z.string().describe("Text, keywords, or patterns to search for in file contents"),
|
|
15
28
|
options: zod_1.z
|
|
16
29
|
.object({
|
|
17
|
-
limit: zod_1.z
|
|
30
|
+
limit: zod_1.z
|
|
31
|
+
.number()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("Maximum number of results to return. Useful for limiting output size"),
|
|
18
34
|
caseSensitive: zod_1.z
|
|
19
35
|
.boolean()
|
|
20
36
|
.optional()
|
|
21
|
-
.describe("
|
|
37
|
+
.describe("Set to true for case-sensitive matching. Default: false (case-insensitive)"),
|
|
22
38
|
})
|
|
23
39
|
.optional(),
|
|
24
40
|
}),
|
|
@@ -7,16 +7,30 @@ class AFSWriteAgent extends base_js_1.AFSSkillBase {
|
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_write",
|
|
10
|
-
description:
|
|
10
|
+
description: `Write or create files in the Agentic File System (AFS)
|
|
11
|
+
- Creates a new file or overwrites an existing file with the provided content
|
|
12
|
+
- Supports append mode to add content to the end of existing files
|
|
13
|
+
- Use this tool when creating new files or completely replacing file contents
|
|
14
|
+
|
|
15
|
+
Usage:
|
|
16
|
+
- The path must be an absolute AFS path starting with "/" (e.g., "/docs/new-file.md", "/memory/user/notes")
|
|
17
|
+
- This is NOT a local system file path - it operates within the AFS virtual file system
|
|
18
|
+
- By default, this tool overwrites the entire file content
|
|
19
|
+
- Use append mode to add content to the end of an existing file without replacing it
|
|
20
|
+
- For partial edits to existing files, prefer using afs_edit instead`,
|
|
11
21
|
...options,
|
|
12
22
|
inputSchema: zod_1.z.object({
|
|
13
|
-
path: zod_1.z
|
|
14
|
-
|
|
23
|
+
path: zod_1.z
|
|
24
|
+
.string()
|
|
25
|
+
.describe("Absolute AFS path for the file to write (e.g., '/docs/new-file.md'). Must start with '/'"),
|
|
26
|
+
content: zod_1.z
|
|
27
|
+
.string()
|
|
28
|
+
.describe("The content to write to the file. In overwrite mode, this replaces the entire file"),
|
|
15
29
|
append: zod_1.z
|
|
16
30
|
.boolean()
|
|
17
31
|
.optional()
|
|
18
32
|
.default(false)
|
|
19
|
-
.describe("
|
|
33
|
+
.describe("Set to true to append content to the end of an existing file. Default: false (overwrites entire file)"),
|
|
20
34
|
}),
|
|
21
35
|
outputSchema: zod_1.z.object({
|
|
22
36
|
status: zod_1.z.string(),
|