@crowgentai/emo-tools 0.0.0-stage → 0.1.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 +43 -2
- package/dist/fs.d.ts +8 -0
- package/dist/fs.d.ts.map +1 -0
- package/dist/fs.js +197 -0
- package/dist/fs.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/load.d.ts +12 -0
- package/dist/load.d.ts.map +1 -0
- package/dist/load.js +35 -0
- package/dist/load.js.map +1 -0
- package/dist/memory.d.ts +6 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +76 -0
- package/dist/memory.js.map +1 -0
- package/dist/registry.d.ts +9 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +17 -0
- package/dist/registry.js.map +1 -0
- package/dist/shell.d.ts +3 -0
- package/dist/shell.d.ts.map +1 -0
- package/dist/shell.js +34 -0
- package/dist/shell.js.map +1 -0
- package/dist/skill.d.ts +4 -0
- package/dist/skill.d.ts.map +1 -0
- package/dist/skill.js +25 -0
- package/dist/skill.js.map +1 -0
- package/dist/todo.d.ts +3 -0
- package/dist/todo.d.ts.map +1 -0
- package/dist/todo.js +35 -0
- package/dist/todo.js.map +1 -0
- package/docs/api.md +77 -0
- package/package.json +53 -4
package/README.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @crowgentai/emo-tools
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The built-in tool set: files, shell, memory, todos and skills — each a plain
|
|
4
|
+
`ToolDefinition` you can register in your own agent, or replace.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @crowgentai/emo-tools
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { buildRegistry, loadRegistry, ToolRegistry } from "@crowgentai/emo-tools";
|
|
12
|
+
|
|
13
|
+
const registry = buildRegistry(settings); // read_file, write_file, edit_file, list_dir, glob,
|
|
14
|
+
// search_files, run_command, memory_*, todo_*
|
|
15
|
+
registry.names();
|
|
16
|
+
registry.get("read_file")?.run({ path: "README.md" }, ctx);
|
|
17
|
+
|
|
18
|
+
// everything, including skills, plugins, MCP and LSP tools:
|
|
19
|
+
const loaded = await loadRegistry(settings);
|
|
20
|
+
loaded.registry.list();
|
|
21
|
+
await loaded.close();
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Every tool takes a `ToolContext` (`cwd`, `sessionId`, `mode`, `memory`, `todos?`, `signal?`)
|
|
25
|
+
and returns a string for the model. Tools declare a `permission` (`read`, `write`, `exec`,
|
|
26
|
+
`network`, `memory`) which the agent policy checks — `read` and `memory` are always allowed,
|
|
27
|
+
`plan` mode blocks `write`, `exec` and `network`.
|
|
28
|
+
|
|
29
|
+
## What is inside
|
|
30
|
+
|
|
31
|
+
| Tool | Permission | Notes |
|
|
32
|
+
| --- | --- | --- |
|
|
33
|
+
| `read_file` | read | numbered lines, `offset` / `limit` |
|
|
34
|
+
| `write_file` | write | creates parent directories |
|
|
35
|
+
| `edit_file` | write | exact-match replace, refuses ambiguity unless `replace_all` |
|
|
36
|
+
| `list_dir` | read | sorted `dir`/`file` listing |
|
|
37
|
+
| `glob` | read | substring or `*` wildcard over workspace paths |
|
|
38
|
+
| `search_files` | read | regex over file contents, `path:line:` output |
|
|
39
|
+
| `run_command` | exec | shell with timeout and 10 MB buffer cap |
|
|
40
|
+
| `memory_save`, `memory_search`, `memory_list`, `memory_forget` | memory | long-term memory |
|
|
41
|
+
| `todo_write`, `todo_read` | memory / read | session task list |
|
|
42
|
+
| `skill` | read | returns a skill body by name |
|
|
43
|
+
|
|
44
|
+
See [docs/api.md](docs/api.md) for signatures and the registry API.
|
package/dist/fs.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ToolDefinition } from "@crowgentai/emo-core";
|
|
2
|
+
export declare const readFileTool: ToolDefinition;
|
|
3
|
+
export declare const writeFileTool: ToolDefinition;
|
|
4
|
+
export declare const editFileTool: ToolDefinition;
|
|
5
|
+
export declare const listDirTool: ToolDefinition;
|
|
6
|
+
export declare const searchFilesTool: ToolDefinition;
|
|
7
|
+
export declare const globTool: ToolDefinition;
|
|
8
|
+
//# sourceMappingURL=fs.d.ts.map
|
package/dist/fs.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAqB3D,eAAO,MAAM,YAAY,EAAE,cAyB1B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,cAmB3B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cA6B1B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,cAmBzB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,cA2C7B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,cA0BtB,CAAC"}
|
package/dist/fs.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { relative, resolvePath } from "@crowgentai/emo-core";
|
|
4
|
+
const IGNORED = new Set(["node_modules", ".git", "dist", "build", "coverage", ".emo", ".next"]);
|
|
5
|
+
async function walk(root, out, depth) {
|
|
6
|
+
if (depth > 12)
|
|
7
|
+
return;
|
|
8
|
+
let entries;
|
|
9
|
+
try {
|
|
10
|
+
entries = await fs.readdir(root, { withFileTypes: true });
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
for (const entry of entries) {
|
|
16
|
+
if (IGNORED.has(entry.name))
|
|
17
|
+
continue;
|
|
18
|
+
const full = path.join(root, entry.name);
|
|
19
|
+
if (entry.isDirectory())
|
|
20
|
+
await walk(full, out, depth + 1);
|
|
21
|
+
else if (entry.isFile())
|
|
22
|
+
out.push(full);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export const readFileTool = {
|
|
26
|
+
name: "read_file",
|
|
27
|
+
permission: "read",
|
|
28
|
+
description: "Read a UTF-8 text file. Optionally slice with line offset and limit. Returns numbered lines.",
|
|
29
|
+
parameters: {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {
|
|
32
|
+
path: { type: "string", description: "File path, absolute or relative to the working directory." },
|
|
33
|
+
offset: { type: "integer", description: "Zero-based line offset to start at." },
|
|
34
|
+
limit: { type: "integer", description: "Maximum number of lines to return." },
|
|
35
|
+
},
|
|
36
|
+
required: ["path"],
|
|
37
|
+
},
|
|
38
|
+
async run(args, ctx) {
|
|
39
|
+
const target = resolvePath(ctx.cwd, String(args.path));
|
|
40
|
+
const raw = await fs.readFile(target, "utf8");
|
|
41
|
+
const lines = raw.split("\n");
|
|
42
|
+
const offset = Math.max(0, Number(args.offset ?? 0));
|
|
43
|
+
const limit = args.limit === undefined ? lines.length : Math.max(0, Number(args.limit));
|
|
44
|
+
if (offset >= lines.length)
|
|
45
|
+
return `(offset ${offset} beyond end of file, ${lines.length} lines total)`;
|
|
46
|
+
return lines
|
|
47
|
+
.slice(offset, offset + limit)
|
|
48
|
+
.map((line, index) => `${offset + index + 1}\t${line}`)
|
|
49
|
+
.join("\n");
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
export const writeFileTool = {
|
|
53
|
+
name: "write_file",
|
|
54
|
+
permission: "write",
|
|
55
|
+
description: "Create or overwrite a text file with the given content. Creates parent directories.",
|
|
56
|
+
parameters: {
|
|
57
|
+
type: "object",
|
|
58
|
+
properties: {
|
|
59
|
+
path: { type: "string", description: "File path, absolute or relative to the working directory." },
|
|
60
|
+
content: { type: "string", description: "Full file content to write." },
|
|
61
|
+
},
|
|
62
|
+
required: ["path", "content"],
|
|
63
|
+
},
|
|
64
|
+
async run(args, ctx) {
|
|
65
|
+
const target = resolvePath(ctx.cwd, String(args.path));
|
|
66
|
+
const content = String(args.content ?? "");
|
|
67
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
68
|
+
await fs.writeFile(target, content, "utf8");
|
|
69
|
+
return `wrote ${content.length} bytes to ${relative(ctx.cwd, target)}`;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
export const editFileTool = {
|
|
73
|
+
name: "edit_file",
|
|
74
|
+
permission: "write",
|
|
75
|
+
description: "Replace exact text in a file. Fails if the search text is missing or ambiguous unless replace_all is true.",
|
|
76
|
+
parameters: {
|
|
77
|
+
type: "object",
|
|
78
|
+
properties: {
|
|
79
|
+
path: { type: "string", description: "File path, absolute or relative to the working directory." },
|
|
80
|
+
search: { type: "string", description: "Exact text to find." },
|
|
81
|
+
replace: { type: "string", description: "Replacement text." },
|
|
82
|
+
replace_all: { type: "boolean", description: "Replace every occurrence instead of the first." },
|
|
83
|
+
},
|
|
84
|
+
required: ["path", "search", "replace"],
|
|
85
|
+
},
|
|
86
|
+
async run(args, ctx) {
|
|
87
|
+
const target = resolvePath(ctx.cwd, String(args.path));
|
|
88
|
+
const search = String(args.search);
|
|
89
|
+
const replace = String(args.replace);
|
|
90
|
+
const all = Boolean(args.replace_all);
|
|
91
|
+
const raw = await fs.readFile(target, "utf8");
|
|
92
|
+
const occurrences = raw.split(search).length - 1;
|
|
93
|
+
if (occurrences === 0)
|
|
94
|
+
return `error: search text not found in ${relative(ctx.cwd, target)}`;
|
|
95
|
+
if (occurrences > 1 && !all) {
|
|
96
|
+
return `error: search text matches ${occurrences} times; set replace_all or provide more context`;
|
|
97
|
+
}
|
|
98
|
+
const updated = all ? raw.split(search).join(replace) : raw.replace(search, replace);
|
|
99
|
+
await fs.writeFile(target, updated, "utf8");
|
|
100
|
+
return `replaced ${all ? occurrences : 1} occurrence(s) in ${relative(ctx.cwd, target)}`;
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
export const listDirTool = {
|
|
104
|
+
name: "list_dir",
|
|
105
|
+
permission: "read",
|
|
106
|
+
description: "List files and directories at a path.",
|
|
107
|
+
parameters: {
|
|
108
|
+
type: "object",
|
|
109
|
+
properties: {
|
|
110
|
+
path: { type: "string", description: "Directory path, defaults to the working directory." },
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
async run(args, ctx) {
|
|
114
|
+
const target = resolvePath(ctx.cwd, String(args.path ?? "."));
|
|
115
|
+
const entries = await fs.readdir(target, { withFileTypes: true });
|
|
116
|
+
if (entries.length === 0)
|
|
117
|
+
return "(empty directory)";
|
|
118
|
+
return entries
|
|
119
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
120
|
+
.map((entry) => `${entry.isDirectory() ? "dir " : "file"} ${entry.name}`)
|
|
121
|
+
.join("\n");
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
export const searchFilesTool = {
|
|
125
|
+
name: "search_files",
|
|
126
|
+
permission: "read",
|
|
127
|
+
description: "Search file contents with a regular expression across the workspace. Returns path:line matches.",
|
|
128
|
+
parameters: {
|
|
129
|
+
type: "object",
|
|
130
|
+
properties: {
|
|
131
|
+
pattern: { type: "string", description: "JavaScript regular expression source." },
|
|
132
|
+
path: { type: "string", description: "Directory to search, defaults to the working directory." },
|
|
133
|
+
max_results: { type: "integer", description: "Maximum number of matches to return, defaults to 50." },
|
|
134
|
+
},
|
|
135
|
+
required: ["pattern"],
|
|
136
|
+
},
|
|
137
|
+
async run(args, ctx) {
|
|
138
|
+
const root = resolvePath(ctx.cwd, String(args.path ?? "."));
|
|
139
|
+
const limit = Math.max(1, Number(args.max_results ?? 50));
|
|
140
|
+
let regex;
|
|
141
|
+
try {
|
|
142
|
+
regex = new RegExp(String(args.pattern));
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
return `error: invalid regex (${err.message})`;
|
|
146
|
+
}
|
|
147
|
+
const files = [];
|
|
148
|
+
await walk(root, files, 0);
|
|
149
|
+
const results = [];
|
|
150
|
+
for (const file of files) {
|
|
151
|
+
if (results.length >= limit)
|
|
152
|
+
break;
|
|
153
|
+
let content;
|
|
154
|
+
try {
|
|
155
|
+
content = await fs.readFile(file, "utf8");
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const lines = content.split("\n");
|
|
161
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
162
|
+
if (regex.test(lines[index])) {
|
|
163
|
+
results.push(`${relative(ctx.cwd, file)}:${index + 1}: ${lines[index].trim().slice(0, 200)}`);
|
|
164
|
+
if (results.length >= limit)
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return results.length > 0 ? results.join("\n") : "no matches";
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
export const globTool = {
|
|
173
|
+
name: "glob",
|
|
174
|
+
permission: "read",
|
|
175
|
+
description: "List files in the workspace whose path contains a substring or matches a simple wildcard pattern.",
|
|
176
|
+
parameters: {
|
|
177
|
+
type: "object",
|
|
178
|
+
properties: {
|
|
179
|
+
pattern: { type: "string", description: "Substring or wildcard pattern such as *.ts or src/*/index.ts." },
|
|
180
|
+
path: { type: "string", description: "Directory to search, defaults to the working directory." },
|
|
181
|
+
},
|
|
182
|
+
required: ["pattern"],
|
|
183
|
+
},
|
|
184
|
+
async run(args, ctx) {
|
|
185
|
+
const root = resolvePath(ctx.cwd, String(args.path ?? "."));
|
|
186
|
+
const pattern = String(args.pattern);
|
|
187
|
+
const regex = new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join(".*")}$`);
|
|
188
|
+
const files = [];
|
|
189
|
+
await walk(root, files, 0);
|
|
190
|
+
const matches = files
|
|
191
|
+
.map((file) => relative(ctx.cwd, file))
|
|
192
|
+
.filter((file) => (pattern.includes("*") ? regex.test(file) : file.includes(pattern)))
|
|
193
|
+
.sort();
|
|
194
|
+
return matches.length > 0 ? matches.slice(0, 200).join("\n") : "no matches";
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
//# sourceMappingURL=fs.js.map
|
package/dist/fs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE7D,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEhG,KAAK,UAAU,IAAI,CAAC,IAAY,EAAE,GAAa,EAAE,KAAa;IAC5D,IAAI,KAAK,GAAG,EAAE;QAAE,OAAO;IACvB,IAAI,OAAmC,CAAC;IACxC,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;IACT,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;YAAE,SAAS;QACtC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,KAAK,CAAC,WAAW,EAAE;YAAE,MAAM,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;aACrD,IAAI,KAAK,CAAC,MAAM,EAAE;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC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G,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;IAC9E,CAAC;CACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Settings } from "@crowgentai/emo-core";
|
|
2
|
+
import { ToolRegistry } from "./registry.js";
|
|
3
|
+
export * from "./registry.js";
|
|
4
|
+
export * from "./fs.js";
|
|
5
|
+
export * from "./shell.js";
|
|
6
|
+
export * from "./memory.js";
|
|
7
|
+
export * from "./todo.js";
|
|
8
|
+
export * from "./skill.js";
|
|
9
|
+
export * from "./load.js";
|
|
10
|
+
export declare function buildRegistry(settings: Settings): ToolRegistry;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAM1B,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY,CAe9D"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ToolRegistry } from "./registry.js";
|
|
2
|
+
export * from "./registry.js";
|
|
3
|
+
export * from "./fs.js";
|
|
4
|
+
export * from "./shell.js";
|
|
5
|
+
export * from "./memory.js";
|
|
6
|
+
export * from "./todo.js";
|
|
7
|
+
export * from "./skill.js";
|
|
8
|
+
export * from "./load.js";
|
|
9
|
+
import { editFileTool, globTool, listDirTool, readFileTool, searchFilesTool, writeFileTool } from "./fs.js";
|
|
10
|
+
import { runCommandTool } from "./shell.js";
|
|
11
|
+
import { memoryForgetTool, memoryListTool, memorySaveTool, memorySearchTool } from "./memory.js";
|
|
12
|
+
import { createTodoTools } from "./todo.js";
|
|
13
|
+
export function buildRegistry(settings) {
|
|
14
|
+
const registry = new ToolRegistry()
|
|
15
|
+
.register(readFileTool)
|
|
16
|
+
.register(writeFileTool)
|
|
17
|
+
.register(editFileTool)
|
|
18
|
+
.register(listDirTool)
|
|
19
|
+
.register(globTool)
|
|
20
|
+
.register(searchFilesTool)
|
|
21
|
+
.register(runCommandTool(settings.commandTimeoutMs))
|
|
22
|
+
.register(memorySaveTool)
|
|
23
|
+
.register(memorySearchTool)
|
|
24
|
+
.register(memoryListTool)
|
|
25
|
+
.register(memoryForgetTool);
|
|
26
|
+
for (const tool of createTodoTools())
|
|
27
|
+
registry.register(tool);
|
|
28
|
+
return registry;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5G,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACjG,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,UAAU,aAAa,CAAC,QAAkB;IAC9C,MAAM,QAAQ,GAAG,IAAI,YAAY,EAAE;SAChC,QAAQ,CAAC,YAAY,CAAC;SACtB,QAAQ,CAAC,aAAa,CAAC;SACvB,QAAQ,CAAC,YAAY,CAAC;SACtB,QAAQ,CAAC,WAAW,CAAC;SACrB,QAAQ,CAAC,QAAQ,CAAC;SAClB,QAAQ,CAAC,eAAe,CAAC;SACzB,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;SACnD,QAAQ,CAAC,cAAc,CAAC;SACxB,QAAQ,CAAC,gBAAgB,CAAC;SAC1B,QAAQ,CAAC,cAAc,CAAC;SACxB,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAC9B,KAAK,MAAM,IAAI,IAAI,eAAe,EAAE;QAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC9D,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/load.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Settings } from "@crowgentai/emo-core";
|
|
2
|
+
import type { ToolRegistry } from "./registry.js";
|
|
3
|
+
import { type Skill } from "@crowgentai/emo-skills";
|
|
4
|
+
import { type LoadedExtensions } from "@crowgentai/emo-extensions";
|
|
5
|
+
export interface LoadedRegistry {
|
|
6
|
+
registry: ToolRegistry;
|
|
7
|
+
skills: Skill[];
|
|
8
|
+
extensions: LoadedExtensions;
|
|
9
|
+
close(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare function loadRegistry(settings: Settings): Promise<LoadedRegistry>;
|
|
12
|
+
//# sourceMappingURL=load.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAInF,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,YAAY,CAAC;IACvB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,CA2B9E"}
|
package/dist/load.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { buildRegistry } from "./index.js";
|
|
2
|
+
import { createSkillTool } from "./skill.js";
|
|
3
|
+
import { loadSkills } from "@crowgentai/emo-skills";
|
|
4
|
+
import { loadExtensions } from "@crowgentai/emo-extensions";
|
|
5
|
+
import { loadMcpTools } from "@crowgentai/emo-mcp";
|
|
6
|
+
import { loadLspTools } from "@crowgentai/emo-lsp";
|
|
7
|
+
export async function loadRegistry(settings) {
|
|
8
|
+
const registry = buildRegistry(settings);
|
|
9
|
+
const skills = await loadSkills(settings);
|
|
10
|
+
if (skills.length > 0)
|
|
11
|
+
registry.register(createSkillTool(skills));
|
|
12
|
+
const extensions = await loadExtensions(settings);
|
|
13
|
+
for (const tool of extensions.tools)
|
|
14
|
+
registry.register(tool);
|
|
15
|
+
const closers = [];
|
|
16
|
+
const mcp = await loadMcpTools(settings);
|
|
17
|
+
for (const tool of mcp.tools)
|
|
18
|
+
registry.register(tool);
|
|
19
|
+
closers.push(mcp.close);
|
|
20
|
+
const lsp = await loadLspTools(settings);
|
|
21
|
+
for (const tool of lsp.tools)
|
|
22
|
+
registry.register(tool);
|
|
23
|
+
closers.push(lsp.close);
|
|
24
|
+
return {
|
|
25
|
+
registry,
|
|
26
|
+
skills,
|
|
27
|
+
extensions,
|
|
28
|
+
async close() {
|
|
29
|
+
await extensions.close();
|
|
30
|
+
for (const closer of closers)
|
|
31
|
+
await closer().catch(() => { });
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=load.js.map
|
package/dist/load.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAc,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAyB,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AASnD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAkB;IACnD,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IAEzC,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC1C,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IAElE,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;IAClD,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,KAAK;QAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE7D,MAAM,OAAO,GAA+B,EAAE,CAAC;IAC/C,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK;QAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACtD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAExB,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK;QAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACtD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAExB,OAAO;QACL,QAAQ;QACR,MAAM;QACN,UAAU;QACV,KAAK,CAAC,KAAK;YACT,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;YACzB,KAAK,MAAM,MAAM,IAAI,OAAO;gBAAE,MAAM,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC/D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/memory.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ToolDefinition } from "@crowgentai/emo-core";
|
|
2
|
+
export declare const memorySaveTool: ToolDefinition;
|
|
3
|
+
export declare const memorySearchTool: ToolDefinition;
|
|
4
|
+
export declare const memoryListTool: ToolDefinition;
|
|
5
|
+
export declare const memoryForgetTool: ToolDefinition;
|
|
6
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAOzE,eAAO,MAAM,cAAc,EAAE,cAsB5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,cAgB9B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAc5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,cAe9B,CAAC"}
|
package/dist/memory.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
function format(record) {
|
|
2
|
+
const tags = record.tags.length > 0 ? ` [${record.tags.join(", ")}]` : "";
|
|
3
|
+
return `${record.id} (${record.createdAt})${tags} ${record.text}`;
|
|
4
|
+
}
|
|
5
|
+
export const memorySaveTool = {
|
|
6
|
+
name: "memory_save",
|
|
7
|
+
permission: "memory",
|
|
8
|
+
description: "Persist a durable fact about the project or user into long-term memory for future sessions.",
|
|
9
|
+
parameters: {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {
|
|
12
|
+
text: { type: "string", description: "The fact to remember." },
|
|
13
|
+
tags: { type: "array", items: { type: "string" }, description: "Optional tags." },
|
|
14
|
+
importance: { type: "integer", description: "Importance from 1 to 5." },
|
|
15
|
+
},
|
|
16
|
+
required: ["text"],
|
|
17
|
+
},
|
|
18
|
+
async run(args, ctx) {
|
|
19
|
+
const tags = Array.isArray(args.tags) ? args.tags.map(String) : [];
|
|
20
|
+
const record = await ctx.memory.add(String(args.text), {
|
|
21
|
+
tags,
|
|
22
|
+
importance: Number(args.importance ?? 1),
|
|
23
|
+
sessionId: ctx.sessionId,
|
|
24
|
+
});
|
|
25
|
+
return `saved ${record.id}`;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export const memorySearchTool = {
|
|
29
|
+
name: "memory_search",
|
|
30
|
+
permission: "memory",
|
|
31
|
+
description: "Search long-term memory for facts relevant to a query.",
|
|
32
|
+
parameters: {
|
|
33
|
+
type: "object",
|
|
34
|
+
properties: {
|
|
35
|
+
query: { type: "string", description: "Search query." },
|
|
36
|
+
limit: { type: "integer", description: "Maximum results, defaults to 10." },
|
|
37
|
+
},
|
|
38
|
+
required: ["query"],
|
|
39
|
+
},
|
|
40
|
+
async run(args, ctx) {
|
|
41
|
+
const results = await ctx.memory.search(String(args.query), Number(args.limit ?? 10));
|
|
42
|
+
return results.length > 0 ? results.map(format).join("\n") : "no memories found";
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
export const memoryListTool = {
|
|
46
|
+
name: "memory_list",
|
|
47
|
+
permission: "memory",
|
|
48
|
+
description: "List the most recent long-term memory records.",
|
|
49
|
+
parameters: {
|
|
50
|
+
type: "object",
|
|
51
|
+
properties: {
|
|
52
|
+
limit: { type: "integer", description: "Maximum results, defaults to 20." },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
async run(args, ctx) {
|
|
56
|
+
const results = await ctx.memory.list(Number(args.limit ?? 20));
|
|
57
|
+
return results.length > 0 ? results.map(format).join("\n") : "memory is empty";
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
export const memoryForgetTool = {
|
|
61
|
+
name: "memory_forget",
|
|
62
|
+
permission: "memory",
|
|
63
|
+
description: "Delete a long-term memory record by id.",
|
|
64
|
+
parameters: {
|
|
65
|
+
type: "object",
|
|
66
|
+
properties: {
|
|
67
|
+
id: { type: "string", description: "Memory id to delete." },
|
|
68
|
+
},
|
|
69
|
+
required: ["id"],
|
|
70
|
+
},
|
|
71
|
+
async run(args, ctx) {
|
|
72
|
+
const removed = await ctx.memory.forget(String(args.id));
|
|
73
|
+
return removed ? `forgot ${args.id}` : `error: memory not found: ${args.id}`;
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAEA,SAAS,MAAM,CAAC,MAAoB;IAClC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,OAAO,GAAG,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,SAAS,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;AACpE,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,IAAI,EAAE,aAAa;IACnB,UAAU,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AAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE;SAC5D;QACD,QAAQ,EAAE,CAAC,IAAI,CAAC;KACjB;IACD,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG;QACjB,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACzD,OAAO,OAAO,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,4BAA4B,IAAI,CAAC,EAAE,EAAE,CAAC;IAC/E,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ToolDefinition } from "@crowgentai/emo-core";
|
|
2
|
+
export declare class ToolRegistry {
|
|
3
|
+
private readonly tools;
|
|
4
|
+
register(tool: ToolDefinition): this;
|
|
5
|
+
get(name: string): ToolDefinition | undefined;
|
|
6
|
+
list(): ToolDefinition[];
|
|
7
|
+
names(): string[];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqC;IAE3D,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAKpC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI7C,IAAI,IAAI,cAAc,EAAE;IAIxB,KAAK,IAAI,MAAM,EAAE;CAGlB"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class ToolRegistry {
|
|
2
|
+
tools = new Map();
|
|
3
|
+
register(tool) {
|
|
4
|
+
this.tools.set(tool.name, tool);
|
|
5
|
+
return this;
|
|
6
|
+
}
|
|
7
|
+
get(name) {
|
|
8
|
+
return this.tools.get(name);
|
|
9
|
+
}
|
|
10
|
+
list() {
|
|
11
|
+
return [...this.tools.values()];
|
|
12
|
+
}
|
|
13
|
+
names() {
|
|
14
|
+
return [...this.tools.keys()];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,YAAY;IACN,KAAK,GAAG,IAAI,GAAG,EAA0B,CAAC;IAE3D,QAAQ,CAAC,IAAoB;QAC3B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI;QACF,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAClC,CAAC;IAED,KAAK;QACH,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IAChC,CAAC;CACF"}
|
package/dist/shell.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,wBAAgB,cAAc,CAAC,gBAAgB,EAAE,MAAM,GAAG,cAAc,CAgCvE"}
|
package/dist/shell.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { exec } from "node:child_process";
|
|
2
|
+
export function runCommandTool(defaultTimeoutMs) {
|
|
3
|
+
return {
|
|
4
|
+
name: "run_command",
|
|
5
|
+
permission: "exec",
|
|
6
|
+
description: "Run a shell command in the working directory. Returns exit code, stdout, and stderr.",
|
|
7
|
+
parameters: {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
command: { type: "string", description: "Shell command to execute." },
|
|
11
|
+
timeout_ms: { type: "integer", description: "Timeout in milliseconds." },
|
|
12
|
+
},
|
|
13
|
+
required: ["command"],
|
|
14
|
+
},
|
|
15
|
+
run(args, ctx) {
|
|
16
|
+
const command = String(args.command);
|
|
17
|
+
const timeout = Number(args.timeout_ms ?? defaultTimeoutMs);
|
|
18
|
+
return new Promise((resolve) => {
|
|
19
|
+
exec(command, { cwd: ctx.cwd, timeout, maxBuffer: 10 * 1024 * 1024, env: process.env }, (error, stdout, stderr) => {
|
|
20
|
+
const code = error && typeof error.code === "number" ? error.code : error ? 1 : 0;
|
|
21
|
+
const parts = [`exit=${code}`];
|
|
22
|
+
if (stdout.trim())
|
|
23
|
+
parts.push(`stdout:\n${stdout.trimEnd()}`);
|
|
24
|
+
if (stderr.trim())
|
|
25
|
+
parts.push(`stderr:\n${stderr.trimEnd()}`);
|
|
26
|
+
if (error && code === 1 && !stdout && !stderr)
|
|
27
|
+
parts.push(`error: ${error.message}`);
|
|
28
|
+
resolve(parts.join("\n"));
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,MAAM,UAAU,cAAc,CAAC,gBAAwB;IACrD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,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,EAAE,CAAC,CAAC;oBAC9D,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM;wBAAE,KAAK,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;oBACrF,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC5B,CAAC,CACF,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/skill.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../src/skill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAiB,KAAK,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEnE,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,cAAc,CAsB/D"}
|
package/dist/skill.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readSkillBody } from "@crowgentai/emo-skills";
|
|
2
|
+
export function createSkillTool(skills) {
|
|
3
|
+
return {
|
|
4
|
+
name: "skill",
|
|
5
|
+
description: "Load the full instructions for a named skill before performing that kind of task.",
|
|
6
|
+
parameters: {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
name: { type: "string", description: "Skill name." },
|
|
10
|
+
},
|
|
11
|
+
required: ["name"],
|
|
12
|
+
},
|
|
13
|
+
permission: "read",
|
|
14
|
+
async run(args) {
|
|
15
|
+
const name = String(args.name);
|
|
16
|
+
const skill = skills.find((entry) => entry.name === name);
|
|
17
|
+
if (!skill) {
|
|
18
|
+
const available = skills.map((entry) => entry.name).join(", ") || "none";
|
|
19
|
+
return `error: unknown skill "${name}". Available: ${available}`;
|
|
20
|
+
}
|
|
21
|
+
return await readSkillBody(skill);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=skill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill.js","sourceRoot":"","sources":["../src/skill.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAc,MAAM,wBAAwB,CAAC;AAEnE,MAAM,UAAU,eAAe,CAAC,MAAe;IAC7C,OAAO;QACL,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,mFAAmF;QAChG,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE;aACrD;YACD,QAAQ,EAAE,CAAC,MAAM,CAAC;SACnB;QACD,UAAU,EAAE,MAAM;QAClB,KAAK,CAAC,GAAG,CAAC,IAAI;YACZ,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;YAC1D,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC;gBACzE,OAAO,yBAAyB,IAAI,iBAAiB,SAAS,EAAE,CAAC;YACnE,CAAC;YACD,OAAO,MAAM,aAAa,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/todo.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo.d.ts","sourceRoot":"","sources":["../src/todo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D,wBAAgB,eAAe,IAAI,cAAc,EAAE,CAgClD"}
|
package/dist/todo.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const unsaved = new Map();
|
|
2
|
+
export function createTodoTools() {
|
|
3
|
+
const write = {
|
|
4
|
+
name: "todo_write",
|
|
5
|
+
description: "Replace the session task list with the provided items.",
|
|
6
|
+
parameters: {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
items: { type: "array", items: { type: "string" }, description: "Ordered task items." },
|
|
10
|
+
},
|
|
11
|
+
required: ["items"],
|
|
12
|
+
},
|
|
13
|
+
permission: "memory",
|
|
14
|
+
async run(args, ctx) {
|
|
15
|
+
const items = Array.isArray(args.items) ? args.items.map(String) : [];
|
|
16
|
+
if (ctx.todos)
|
|
17
|
+
await ctx.todos.set(items);
|
|
18
|
+
else
|
|
19
|
+
unsaved.set(ctx.sessionId, items);
|
|
20
|
+
return items.length > 0 ? items.map((item, index) => `${index + 1}. ${item}`).join("\n") : "(cleared)";
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
const read = {
|
|
24
|
+
name: "todo_read",
|
|
25
|
+
description: "Read the session task list.",
|
|
26
|
+
parameters: { type: "object", properties: {} },
|
|
27
|
+
permission: "read",
|
|
28
|
+
async run(_args, ctx) {
|
|
29
|
+
const items = ctx.todos ? ctx.todos.items : unsaved.get(ctx.sessionId) ?? [];
|
|
30
|
+
return items.length > 0 ? items.map((item, index) => `${index + 1}. ${item}`).join("\n") : "(empty)";
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
return [write, read];
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=todo.js.map
|
package/dist/todo.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo.js","sourceRoot":"","sources":["../src/todo.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;AAE5C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AAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YAC7E,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACvG,CAAC;KACF,CAAC;IAEF,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACvB,CAAC"}
|
package/docs/api.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @crowgentai/emo-tools API
|
|
2
|
+
|
|
3
|
+
## Registry
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { ToolRegistry } from "@crowgentai/emo-tools";
|
|
7
|
+
|
|
8
|
+
const registry = new ToolRegistry()
|
|
9
|
+
.register(readFileTool)
|
|
10
|
+
.register(writeFileTool);
|
|
11
|
+
|
|
12
|
+
registry.get("read_file"); // ToolDefinition | undefined
|
|
13
|
+
registry.names(); // string[]
|
|
14
|
+
registry.list(); // ToolDefinition[] — what the model is shown
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Registering a tool with an existing name replaces it, which is the simplest way to
|
|
18
|
+
override a built-in.
|
|
19
|
+
|
|
20
|
+
## Building the default set
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { buildRegistry } from "@crowgentai/emo-tools";
|
|
24
|
+
|
|
25
|
+
const registry = buildRegistry(settings); // uses settings.commandTimeoutMs for run_command
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Loading everything
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { loadRegistry } from "@crowgentai/emo-tools";
|
|
32
|
+
|
|
33
|
+
const loaded = await loadRegistry(settings);
|
|
34
|
+
|
|
35
|
+
interface LoadedRegistry {
|
|
36
|
+
registry: ToolRegistry;
|
|
37
|
+
skills: Skill[];
|
|
38
|
+
extensions: LoadedExtensions;
|
|
39
|
+
close(): Promise<void>; // disposes extensions, MCP servers and LSP servers
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`loadRegistry` adds, in order: the built-in set, a `skill` tool when skills exist, tools
|
|
44
|
+
from `.emo/plugins`, `mcp__*` tools from `settings.mcpServers`, and `lsp_diagnostics` from
|
|
45
|
+
`settings.lspServers`.
|
|
46
|
+
|
|
47
|
+
## Individual tools
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import {
|
|
51
|
+
readFileTool, writeFileTool, editFileTool, listDirTool, globTool, searchFilesTool,
|
|
52
|
+
runCommandTool, memorySaveTool, memorySearchTool, memoryListTool, memoryForgetTool,
|
|
53
|
+
createTodoTools, createSkillTool,
|
|
54
|
+
} from "@crowgentai/emo-tools";
|
|
55
|
+
|
|
56
|
+
const tools = [runCommandTool(120_000), ...createTodoTools(), createSkillTool(skills)];
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Tool arguments are validated by the model-facing JSON schema, not by the tool itself:
|
|
60
|
+
each `run` coerces what it needs and returns a string, including for errors
|
|
61
|
+
(`"error: ..."`), so a bad call never throws into the agent loop.
|
|
62
|
+
|
|
63
|
+
## ToolContext
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
interface ToolContext {
|
|
67
|
+
cwd: string; // workspace root for relative paths
|
|
68
|
+
sessionId: string;
|
|
69
|
+
mode: "plan" | "build";
|
|
70
|
+
memory: MemoryStore; // used by memory_* tools
|
|
71
|
+
todos?: { items: string[]; set(items: string[]): Promise<void> };
|
|
72
|
+
signal?: AbortSignal;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`todo_write` persists through `ctx.todos` when present and falls back to an in-memory map
|
|
77
|
+
keyed by `sessionId` otherwise.
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crowgentai/emo-tools",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Built-in agent tools: files, shell, memory, todos and skills.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/crowgent/emo.git",
|
|
10
|
+
"directory": "packages/tools"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/crowgent/emo#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/crowgent/emo/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"agent",
|
|
18
|
+
"ai",
|
|
19
|
+
"llm",
|
|
20
|
+
"emo",
|
|
21
|
+
"tools"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=20"
|
|
25
|
+
},
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"README.md",
|
|
37
|
+
"docs"
|
|
38
|
+
],
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.json",
|
|
44
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
45
|
+
"test": "node --import tsx --test \"test/*.test.ts\"",
|
|
46
|
+
"prepublishOnly": "npm run build"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@crowgentai/emo-core": "^0.1.0",
|
|
50
|
+
"@crowgentai/emo-skills": "^0.1.0",
|
|
51
|
+
"@crowgentai/emo-extensions": "^0.1.0",
|
|
52
|
+
"@crowgentai/emo-mcp": "^0.1.0",
|
|
53
|
+
"@crowgentai/emo-lsp": "^0.1.0"
|
|
54
|
+
}
|
|
55
|
+
}
|