open-multi-agent-kit 0.93.0 → 0.94.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -1
- package/README.md +3 -2
- package/dist/core/agent-session.d.ts +7 -14
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +78 -347
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/github-star-nudge.d.ts +15 -0
- package/dist/core/github-star-nudge.d.ts.map +1 -0
- package/dist/core/github-star-nudge.js +21 -0
- package/dist/core/github-star-nudge.js.map +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +11 -1
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/sandbox/default-policy.d.ts +14 -0
- package/dist/core/sandbox/default-policy.d.ts.map +1 -0
- package/dist/core/sandbox/default-policy.js +58 -0
- package/dist/core/sandbox/default-policy.js.map +1 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-bash-runtime.d.ts +62 -0
- package/dist/core/session-bash-runtime.d.ts.map +1 -0
- package/dist/core/session-bash-runtime.js +167 -0
- package/dist/core/session-bash-runtime.js.map +1 -0
- package/dist/core/session-bash-service.d.ts +61 -0
- package/dist/core/session-bash-service.d.ts.map +1 -0
- package/dist/core/session-bash-service.js +155 -0
- package/dist/core/session-bash-service.js.map +1 -0
- package/dist/core/session-compaction-service.d.ts +48 -0
- package/dist/core/session-compaction-service.d.ts.map +1 -0
- package/dist/core/session-compaction-service.js +250 -0
- package/dist/core/session-compaction-service.js.map +1 -0
- package/dist/core/settings-manager.d.ts +5 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +9 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills-catalog-cache.d.ts +25 -0
- package/dist/core/skills-catalog-cache.d.ts.map +1 -0
- package/dist/core/skills-catalog-cache.js +123 -0
- package/dist/core/skills-catalog-cache.js.map +1 -0
- package/dist/core/skills.d.ts +6 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +25 -4
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +4 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +3 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +3 -2
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/diagnostics.d.ts +29 -0
- package/dist/core/tools/diagnostics.d.ts.map +1 -0
- package/dist/core/tools/diagnostics.js +325 -0
- package/dist/core/tools/diagnostics.js.map +1 -0
- package/dist/core/tools/index.d.ts +2 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +18 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/verified-bash-adapter.d.ts +18 -1
- package/dist/core/verified-bash-adapter.d.ts.map +1 -1
- package/dist/core/verified-bash-adapter.js +38 -1
- package/dist/core/verified-bash-adapter.js.map +1 -1
- package/dist/core/verified-bash-runtime.d.ts +13 -0
- package/dist/core/verified-bash-runtime.d.ts.map +1 -0
- package/dist/core/verified-bash-runtime.js +81 -0
- package/dist/core/verified-bash-runtime.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +2 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +55 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/types/evidence.d.ts +1 -1
- package/dist/types/evidence.d.ts.map +1 -1
- package/dist/types/evidence.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +31 -5
- package/dist/utils/frontmatter.js.map +1 -1
- package/docs/environment-variables.md +4 -0
- package/docs/sdk.md +10 -4
- package/docs/settings.md +11 -0
- package/docs/usage.md +1 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +15 -15
- package/package.json +5 -5
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compiler-backed diagnostics tool (LSP-class value via project-native checkers).
|
|
3
|
+
*
|
|
4
|
+
* Routes per language to the checker the project already uses and normalizes
|
|
5
|
+
* output to `SEVERITY path:line:col message`. Fail-soft by construction: a
|
|
6
|
+
* missing checker, missing project marker, or checker crash reports `skipped`
|
|
7
|
+
* for that language instead of throwing. Results are TTL-cached (5 s) since
|
|
8
|
+
* project-wide checks are expensive.
|
|
9
|
+
*
|
|
10
|
+
* | language | checker (first found) | scope |
|
|
11
|
+
* |------------|------------------------------------------|-------------------|
|
|
12
|
+
* | typescript | `tsc --noEmit -p <nearest tsconfig>` | project |
|
|
13
|
+
* | python | `pyright --outputjson` / `ruff check` | file or project |
|
|
14
|
+
* | go | `go vet ./...` | module |
|
|
15
|
+
* | rust | `cargo check --message-format short` | workspace |
|
|
16
|
+
*/
|
|
17
|
+
import { spawn } from "node:child_process";
|
|
18
|
+
import { existsSync } from "node:fs";
|
|
19
|
+
import { join } from "node:path";
|
|
20
|
+
import { Type } from "typebox";
|
|
21
|
+
import { wrapToolDefinition } from "./tool-definition-wrapper.js";
|
|
22
|
+
const diagnosticsSchema = Type.Object({
|
|
23
|
+
path: Type.Optional(Type.String({ description: "Restrict diagnostics to this file (relative to cwd)" })),
|
|
24
|
+
language: Type.Optional(Type.Union([
|
|
25
|
+
Type.Literal("auto"),
|
|
26
|
+
Type.Literal("typescript"),
|
|
27
|
+
Type.Literal("python"),
|
|
28
|
+
Type.Literal("go"),
|
|
29
|
+
Type.Literal("rust"),
|
|
30
|
+
], {
|
|
31
|
+
description: "Language to check; auto detects from path extension and project markers",
|
|
32
|
+
})),
|
|
33
|
+
timeout: Type.Optional(Type.Number({ description: "Per-language timeout in seconds (default 90)" })),
|
|
34
|
+
});
|
|
35
|
+
const CACHE_TTL_MS = 5_000;
|
|
36
|
+
const MAX_DIAGNOSTICS = 50;
|
|
37
|
+
const DEFAULT_TIMEOUT_MS = 90_000;
|
|
38
|
+
const cache = new Map();
|
|
39
|
+
function commandExists(command) {
|
|
40
|
+
return new Promise((resolve) => {
|
|
41
|
+
const probe = spawn("sh", ["-c", `command -v ${command}`], { stdio: "ignore" });
|
|
42
|
+
probe.on("close", (code) => resolve(code === 0));
|
|
43
|
+
probe.on("error", () => resolve(false));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function run(command, args, cwd, timeoutMs) {
|
|
47
|
+
return new Promise((resolve) => {
|
|
48
|
+
const child = spawn(command, args, { cwd, stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
|
|
49
|
+
let out = "";
|
|
50
|
+
const timer = setTimeout(() => {
|
|
51
|
+
child.kill("SIGKILL");
|
|
52
|
+
}, timeoutMs);
|
|
53
|
+
child.stdout.on("data", (d) => {
|
|
54
|
+
if (out.length < 4 * 1024 * 1024)
|
|
55
|
+
out += d.toString("utf8");
|
|
56
|
+
});
|
|
57
|
+
child.stderr.on("data", (d) => {
|
|
58
|
+
if (out.length < 4 * 1024 * 1024)
|
|
59
|
+
out += d.toString("utf8");
|
|
60
|
+
});
|
|
61
|
+
child.on("close", (code) => {
|
|
62
|
+
clearTimeout(timer);
|
|
63
|
+
resolve({ code, out });
|
|
64
|
+
});
|
|
65
|
+
child.on("error", () => {
|
|
66
|
+
clearTimeout(timer);
|
|
67
|
+
resolve({ code: null, out });
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function nearestMarker(cwd, names) {
|
|
72
|
+
// ponytail: project markers live at the session root in this harness; walk up
|
|
73
|
+
// at most 4 levels for nested worktrees.
|
|
74
|
+
let dir = cwd;
|
|
75
|
+
for (let level = 0; level <= 4; level++) {
|
|
76
|
+
for (const name of names) {
|
|
77
|
+
if (existsSync(join(dir, name)))
|
|
78
|
+
return dir;
|
|
79
|
+
}
|
|
80
|
+
const parent = join(dir, "..");
|
|
81
|
+
if (parent === dir)
|
|
82
|
+
return undefined;
|
|
83
|
+
dir = parent;
|
|
84
|
+
}
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
const TS_ERROR = /^(?<path>.+?)\((?<line>\d+),(?<col>\d+)\): error TS\d+: (?<msg>.+)$/;
|
|
88
|
+
function parseTsc(out, language) {
|
|
89
|
+
const lines = [];
|
|
90
|
+
for (const raw of out.split("\n")) {
|
|
91
|
+
const match = TS_ERROR.exec(raw.trim());
|
|
92
|
+
if (match?.groups) {
|
|
93
|
+
lines.push({
|
|
94
|
+
language,
|
|
95
|
+
severity: "error",
|
|
96
|
+
path: match.groups.path,
|
|
97
|
+
line: Number(match.groups.line),
|
|
98
|
+
column: Number(match.groups.col),
|
|
99
|
+
message: match.groups.msg.trim(),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return lines;
|
|
104
|
+
}
|
|
105
|
+
const PYRIGHT_ISSUE = /^(?<path>.+?):(?<line>\d+):(?<col>\d+) - (?<sev>error|warning|information): (?<msg>.+)$/;
|
|
106
|
+
function parsePyright(out) {
|
|
107
|
+
const lines = [];
|
|
108
|
+
// pyright --outputjson wraps issues in JSON; fall back to the text form when absent.
|
|
109
|
+
try {
|
|
110
|
+
const parsed = JSON.parse(out);
|
|
111
|
+
for (const issue of parsed.generalDiagnostics ?? []) {
|
|
112
|
+
lines.push({
|
|
113
|
+
language: "python",
|
|
114
|
+
severity: issue.severity === "error" ? "error" : issue.severity === "warning" ? "warning" : "info",
|
|
115
|
+
path: issue.file,
|
|
116
|
+
line: issue.range.start.line + 1,
|
|
117
|
+
column: issue.range.start.character + 1,
|
|
118
|
+
message: issue.message,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return lines;
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
for (const raw of out.split("\n")) {
|
|
125
|
+
const match = PYRIGHT_ISSUE.exec(raw.trim());
|
|
126
|
+
if (match?.groups) {
|
|
127
|
+
lines.push({
|
|
128
|
+
language: "python",
|
|
129
|
+
severity: match.groups.sev === "error" ? "error" : match.groups.sev === "warning" ? "warning" : "info",
|
|
130
|
+
path: match.groups.path,
|
|
131
|
+
line: Number(match.groups.line),
|
|
132
|
+
column: Number(match.groups.col),
|
|
133
|
+
message: match.groups.msg.trim(),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return lines;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const RUFF_ISSUE = /^(?<path>.+?):(?<line>\d+):(?<col>\d+): (?<msg>.+)$/;
|
|
141
|
+
function parseRuff(out) {
|
|
142
|
+
const lines = [];
|
|
143
|
+
for (const raw of out.split("\n")) {
|
|
144
|
+
const match = RUFF_ISSUE.exec(raw.trim());
|
|
145
|
+
if (match?.groups) {
|
|
146
|
+
lines.push({
|
|
147
|
+
language: "python",
|
|
148
|
+
severity: "warning",
|
|
149
|
+
path: match.groups.path,
|
|
150
|
+
line: Number(match.groups.line),
|
|
151
|
+
column: Number(match.groups.col),
|
|
152
|
+
message: match.groups.msg.trim(),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return lines;
|
|
157
|
+
}
|
|
158
|
+
const GO_VET = /^(?:#\s+\S+\s+)?(?<path>.+?\.go):(?<line>\d+):(?<col>\d+): (?<msg>.+)$/;
|
|
159
|
+
function parseGoVet(out) {
|
|
160
|
+
const lines = [];
|
|
161
|
+
for (const raw of out.split("\n")) {
|
|
162
|
+
const match = GO_VET.exec(raw.trim());
|
|
163
|
+
if (match?.groups) {
|
|
164
|
+
lines.push({
|
|
165
|
+
language: "go",
|
|
166
|
+
severity: "error",
|
|
167
|
+
path: match.groups.path,
|
|
168
|
+
line: Number(match.groups.line),
|
|
169
|
+
column: Number(match.groups.col),
|
|
170
|
+
message: match.groups.msg.trim(),
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return lines;
|
|
175
|
+
}
|
|
176
|
+
const CARGO_SHORT = /^(?<path>.+?):(?<line>\d+):(?<col>\d+): (?<msg>.+)$/;
|
|
177
|
+
function parseCargo(out) {
|
|
178
|
+
const lines = [];
|
|
179
|
+
for (const raw of out.split("\n")) {
|
|
180
|
+
const match = CARGO_SHORT.exec(raw.trim());
|
|
181
|
+
if (match?.groups) {
|
|
182
|
+
const sev = match.groups.msg.startsWith("warning") ? "warning" : "error";
|
|
183
|
+
lines.push({
|
|
184
|
+
language: "rust",
|
|
185
|
+
severity: sev,
|
|
186
|
+
path: match.groups.path,
|
|
187
|
+
line: Number(match.groups.line),
|
|
188
|
+
column: Number(match.groups.col),
|
|
189
|
+
message: match.groups.msg.trim(),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return lines;
|
|
194
|
+
}
|
|
195
|
+
async function checkTypeScript(cwd, path, timeoutMs) {
|
|
196
|
+
const root = nearestMarker(cwd, ["tsconfig.json", "tsconfig.build.json"]);
|
|
197
|
+
if (!root)
|
|
198
|
+
return { lines: [], skippedReason: "no tsconfig found" };
|
|
199
|
+
const tsc = join(cwd, "node_modules", ".bin", "tsc");
|
|
200
|
+
const localBin = existsSync(tsc) ? tsc : join(root, "node_modules", ".bin", "tsc");
|
|
201
|
+
const bin = existsSync(localBin) ? localBin : "tsc";
|
|
202
|
+
const config = existsSync(join(root, "tsconfig.json")) ? "tsconfig.json" : "tsconfig.build.json";
|
|
203
|
+
const { code, out } = await run(bin, ["--noEmit", "-p", config, "--pretty", "false"], root, timeoutMs);
|
|
204
|
+
if (code === null)
|
|
205
|
+
return { lines: [], skippedReason: "tsc spawn failed" };
|
|
206
|
+
return { lines: parseTsc(out, "typescript").filter((d) => !path || d.path.includes(path)) };
|
|
207
|
+
}
|
|
208
|
+
async function checkPython(cwd, path, timeoutMs) {
|
|
209
|
+
const target = path ?? ".";
|
|
210
|
+
if (await commandExists("pyright")) {
|
|
211
|
+
const { code, out } = await run("pyright", ["--outputjson", target], cwd, timeoutMs);
|
|
212
|
+
if (code === null)
|
|
213
|
+
return { lines: [], skippedReason: "pyright spawn failed" };
|
|
214
|
+
return { lines: parsePyright(out) };
|
|
215
|
+
}
|
|
216
|
+
if (await commandExists("ruff")) {
|
|
217
|
+
const { code, out } = await run("ruff", ["check", "--no-cache", target], cwd, timeoutMs);
|
|
218
|
+
if (code === null)
|
|
219
|
+
return { lines: [], skippedReason: "ruff spawn failed" };
|
|
220
|
+
return { lines: parseRuff(out) };
|
|
221
|
+
}
|
|
222
|
+
return { lines: [], skippedReason: "pyright/ruff not installed" };
|
|
223
|
+
}
|
|
224
|
+
async function checkGo(cwd, path, timeoutMs) {
|
|
225
|
+
const root = nearestMarker(cwd, ["go.mod"]);
|
|
226
|
+
if (!root)
|
|
227
|
+
return { lines: [], skippedReason: "no go.mod found" };
|
|
228
|
+
if (!(await commandExists("go")))
|
|
229
|
+
return { lines: [], skippedReason: "go not installed" };
|
|
230
|
+
const { code, out } = await run("go", ["vet", "./..."], root, timeoutMs);
|
|
231
|
+
if (code === null)
|
|
232
|
+
return { lines: [], skippedReason: "go vet spawn failed" };
|
|
233
|
+
return { lines: parseGoVet(out).filter((d) => !path || d.path.includes(path)) };
|
|
234
|
+
}
|
|
235
|
+
async function checkRust(cwd, path, timeoutMs) {
|
|
236
|
+
const root = nearestMarker(cwd, ["Cargo.toml"]);
|
|
237
|
+
if (!root)
|
|
238
|
+
return { lines: [], skippedReason: "no Cargo.toml found" };
|
|
239
|
+
if (!(await commandExists("cargo")))
|
|
240
|
+
return { lines: [], skippedReason: "cargo not installed" };
|
|
241
|
+
const { code, out } = await run("cargo", ["check", "--quiet", "--message-format", "short"], root, timeoutMs);
|
|
242
|
+
if (code === null)
|
|
243
|
+
return { lines: [], skippedReason: "cargo spawn failed" };
|
|
244
|
+
return { lines: parseCargo(out).filter((d) => !path || d.path.includes(path)) };
|
|
245
|
+
}
|
|
246
|
+
const CHECKERS = {
|
|
247
|
+
typescript: checkTypeScript,
|
|
248
|
+
python: checkPython,
|
|
249
|
+
go: checkGo,
|
|
250
|
+
rust: checkRust,
|
|
251
|
+
};
|
|
252
|
+
function detectLanguages(cwd, path) {
|
|
253
|
+
if (path) {
|
|
254
|
+
if (/\.tsx?$/.test(path))
|
|
255
|
+
return ["typescript"];
|
|
256
|
+
if (/\.py$/.test(path))
|
|
257
|
+
return ["python"];
|
|
258
|
+
if (/\.go$/.test(path))
|
|
259
|
+
return ["go"];
|
|
260
|
+
if (/\.rs$/.test(path))
|
|
261
|
+
return ["rust"];
|
|
262
|
+
}
|
|
263
|
+
const detected = [];
|
|
264
|
+
if (nearestMarker(cwd, ["tsconfig.json", "tsconfig.build.json"]))
|
|
265
|
+
detected.push("typescript");
|
|
266
|
+
if (nearestMarker(cwd, ["pyproject.toml", "setup.py", "setup.cfg", "requirements.txt"]))
|
|
267
|
+
detected.push("python");
|
|
268
|
+
if (nearestMarker(cwd, ["go.mod"]))
|
|
269
|
+
detected.push("go");
|
|
270
|
+
if (nearestMarker(cwd, ["Cargo.toml"]))
|
|
271
|
+
detected.push("rust");
|
|
272
|
+
return detected.length > 0 ? detected : ["typescript", "python", "go", "rust"];
|
|
273
|
+
}
|
|
274
|
+
async function checkLanguage(language, cwd, path, timeoutMs) {
|
|
275
|
+
const key = `${language}${cwd}${path ?? ""}`;
|
|
276
|
+
const cached = cache.get(key);
|
|
277
|
+
if (cached && Date.now() - cached.at < CACHE_TTL_MS)
|
|
278
|
+
return cached.result;
|
|
279
|
+
const result = await CHECKERS[language](cwd, path, timeoutMs);
|
|
280
|
+
if (cache.size >= 16) {
|
|
281
|
+
const oldest = cache.keys().next().value;
|
|
282
|
+
if (oldest !== undefined)
|
|
283
|
+
cache.delete(oldest);
|
|
284
|
+
}
|
|
285
|
+
cache.set(key, { at: Date.now(), result });
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
export function createDiagnosticsToolDefinition(cwd) {
|
|
289
|
+
return {
|
|
290
|
+
name: "diagnostics",
|
|
291
|
+
label: "diagnostics",
|
|
292
|
+
description: "Run the project's own type/lint checkers (tsc, pyright/ruff, go vet, cargo check) and return normalized diagnostics. Missing checkers or missing project markers are reported as skipped, never as tool errors.",
|
|
293
|
+
promptSnippet: "Get compiler/lint diagnostics for the workspace or a file",
|
|
294
|
+
parameters: diagnosticsSchema,
|
|
295
|
+
async execute(_toolCallId, { path, language, timeout }) {
|
|
296
|
+
const timeoutMs = timeout !== undefined && timeout > 0 ? timeout * 1000 : DEFAULT_TIMEOUT_MS;
|
|
297
|
+
const languages = language && language !== "auto" ? [language] : detectLanguages(cwd, path);
|
|
298
|
+
const settled = await Promise.all(languages.map((lang) => checkLanguage(lang, cwd, path, timeoutMs)));
|
|
299
|
+
const diagnostics = [];
|
|
300
|
+
const skipped = [];
|
|
301
|
+
for (let index = 0; index < languages.length; index++) {
|
|
302
|
+
const result = settled[index];
|
|
303
|
+
if (result.skippedReason)
|
|
304
|
+
skipped.push({ language: languages[index], reason: result.skippedReason });
|
|
305
|
+
diagnostics.push(...result.lines);
|
|
306
|
+
}
|
|
307
|
+
const capped = diagnostics.slice(0, MAX_DIAGNOSTICS);
|
|
308
|
+
const counts = {};
|
|
309
|
+
for (const d of diagnostics)
|
|
310
|
+
counts[d.language] = (counts[d.language] ?? 0) + 1;
|
|
311
|
+
const text = capped.length === 0 && skipped.length === 0
|
|
312
|
+
? "No diagnostics."
|
|
313
|
+
: [
|
|
314
|
+
...capped.map((d) => `${d.severity.toUpperCase()} ${d.path}:${d.line}:${d.column} ${d.message} (${d.language})`),
|
|
315
|
+
...(diagnostics.length > capped.length ? [`... ${diagnostics.length - capped.length} more`] : []),
|
|
316
|
+
...skipped.map((s) => `${s.language}: skipped (${s.reason})`),
|
|
317
|
+
].join("\n");
|
|
318
|
+
return { content: [{ type: "text", text }], details: { diagnostics: capped, skipped, counts } };
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
export function createDiagnosticsTool(cwd) {
|
|
323
|
+
return wrapToolDefinition(createDiagnosticsToolDefinition(cwd));
|
|
324
|
+
}
|
|
325
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../../src/core/tools/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,qDAAqD,EAAE,CAAC,CAAC;IACxG,QAAQ,EAAE,IAAI,CAAC,QAAQ,CACtB,IAAI,CAAC,KAAK,CACT;QACC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QACpB,IAAI,CAAC,OAAO,CA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,CAAC;AAAA,CACF;AAED,MAAM,UAAU,qBAAqB,CAAC,GAAW,EAAuC;IACvF,OAAO,kBAAkB,CAAC,+BAA+B,CAAC,GAAG,CAAC,CAAC,CAAC;AAAA,CAChE","sourcesContent":["/**\n * Compiler-backed diagnostics tool (LSP-class value via project-native checkers).\n *\n * Routes per language to the checker the project already uses and normalizes\n * output to `SEVERITY path:line:col message`. Fail-soft by construction: a\n * missing checker, missing project marker, or checker crash reports `skipped`\n * for that language instead of throwing. Results are TTL-cached (5 s) since\n * project-wide checks are expensive.\n *\n * | language | checker (first found) | scope |\n * |------------|------------------------------------------|-------------------|\n * | typescript | `tsc --noEmit -p <nearest tsconfig>` | project |\n * | python | `pyright --outputjson` / `ruff check` | file or project |\n * | go | `go vet ./...` | module |\n * | rust | `cargo check --message-format short` | workspace |\n */\nimport { spawn } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { AgentTool } from \"omk-agent-core\";\nimport { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst diagnosticsSchema = Type.Object({\n\tpath: Type.Optional(Type.String({ description: \"Restrict diagnostics to this file (relative to cwd)\" })),\n\tlanguage: Type.Optional(\n\t\tType.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"auto\"),\n\t\t\t\tType.Literal(\"typescript\"),\n\t\t\t\tType.Literal(\"python\"),\n\t\t\t\tType.Literal(\"go\"),\n\t\t\t\tType.Literal(\"rust\"),\n\t\t\t],\n\t\t\t{\n\t\t\t\tdescription: \"Language to check; auto detects from path extension and project markers\",\n\t\t\t},\n\t\t),\n\t),\n\ttimeout: Type.Optional(Type.Number({ description: \"Per-language timeout in seconds (default 90)\" })),\n});\n\nexport type DiagnosticsToolInput = Static<typeof diagnosticsSchema>;\n\nexport interface DiagnosticLine {\n\treadonly language: string;\n\treadonly severity: \"error\" | \"warning\" | \"info\";\n\treadonly path: string;\n\treadonly line: number;\n\treadonly column: number;\n\treadonly message: string;\n}\n\nexport interface DiagnosticsToolDetails {\n\treadonly diagnostics: readonly DiagnosticLine[];\n\treadonly skipped: readonly { language: string; reason: string }[];\n\treadonly counts: Record<string, number>;\n}\n\nconst CACHE_TTL_MS = 5_000;\nconst MAX_DIAGNOSTICS = 50;\nconst DEFAULT_TIMEOUT_MS = 90_000;\n\nconst cache = new Map<string, { at: number; result: LanguageResult }>();\n\ninterface LanguageResult {\n\treadonly lines: readonly DiagnosticLine[];\n\treadonly skippedReason?: string;\n}\n\nfunction commandExists(command: string): Promise<boolean> {\n\treturn new Promise((resolve) => {\n\t\tconst probe = spawn(\"sh\", [\"-c\", `command -v ${command}`], { stdio: \"ignore\" });\n\t\tprobe.on(\"close\", (code) => resolve(code === 0));\n\t\tprobe.on(\"error\", () => resolve(false));\n\t});\n}\n\nfunction run(\n\tcommand: string,\n\targs: readonly string[],\n\tcwd: string,\n\ttimeoutMs: number,\n): Promise<{ code: number | null; out: string }> {\n\treturn new Promise((resolve) => {\n\t\tconst child = spawn(command, args, { cwd, stdio: [\"ignore\", \"pipe\", \"pipe\"], windowsHide: true });\n\t\tlet out = \"\";\n\t\tconst timer = setTimeout(() => {\n\t\t\tchild.kill(\"SIGKILL\");\n\t\t}, timeoutMs);\n\t\tchild.stdout.on(\"data\", (d: Buffer) => {\n\t\t\tif (out.length < 4 * 1024 * 1024) out += d.toString(\"utf8\");\n\t\t});\n\t\tchild.stderr.on(\"data\", (d: Buffer) => {\n\t\t\tif (out.length < 4 * 1024 * 1024) out += d.toString(\"utf8\");\n\t\t});\n\t\tchild.on(\"close\", (code) => {\n\t\t\tclearTimeout(timer);\n\t\t\tresolve({ code, out });\n\t\t});\n\t\tchild.on(\"error\", () => {\n\t\t\tclearTimeout(timer);\n\t\t\tresolve({ code: null, out });\n\t\t});\n\t});\n}\n\nfunction nearestMarker(cwd: string, names: readonly string[]): string | undefined {\n\t// ponytail: project markers live at the session root in this harness; walk up\n\t// at most 4 levels for nested worktrees.\n\tlet dir = cwd;\n\tfor (let level = 0; level <= 4; level++) {\n\t\tfor (const name of names) {\n\t\t\tif (existsSync(join(dir, name))) return dir;\n\t\t}\n\t\tconst parent = join(dir, \"..\");\n\t\tif (parent === dir) return undefined;\n\t\tdir = parent;\n\t}\n\treturn undefined;\n}\n\nconst TS_ERROR = /^(?<path>.+?)\\((?<line>\\d+),(?<col>\\d+)\\): error TS\\d+: (?<msg>.+)$/;\n\nfunction parseTsc(out: string, language: string): DiagnosticLine[] {\n\tconst lines: DiagnosticLine[] = [];\n\tfor (const raw of out.split(\"\\n\")) {\n\t\tconst match = TS_ERROR.exec(raw.trim());\n\t\tif (match?.groups) {\n\t\t\tlines.push({\n\t\t\t\tlanguage,\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: match.groups.path,\n\t\t\t\tline: Number(match.groups.line),\n\t\t\t\tcolumn: Number(match.groups.col),\n\t\t\t\tmessage: match.groups.msg.trim(),\n\t\t\t});\n\t\t}\n\t}\n\treturn lines;\n}\n\nconst PYRIGHT_ISSUE = /^(?<path>.+?):(?<line>\\d+):(?<col>\\d+) - (?<sev>error|warning|information): (?<msg>.+)$/;\n\nfunction parsePyright(out: string): DiagnosticLine[] {\n\tconst lines: DiagnosticLine[] = [];\n\t// pyright --outputjson wraps issues in JSON; fall back to the text form when absent.\n\ttry {\n\t\tconst parsed = JSON.parse(out) as {\n\t\t\tgeneralDiagnostics?: {\n\t\t\t\tfile: string;\n\t\t\t\tseverity: string;\n\t\t\t\trange: { start: { line: number; character: number } };\n\t\t\t\tmessage: string;\n\t\t\t}[];\n\t\t};\n\t\tfor (const issue of parsed.generalDiagnostics ?? []) {\n\t\t\tlines.push({\n\t\t\t\tlanguage: \"python\",\n\t\t\t\tseverity: issue.severity === \"error\" ? \"error\" : issue.severity === \"warning\" ? \"warning\" : \"info\",\n\t\t\t\tpath: issue.file,\n\t\t\t\tline: issue.range.start.line + 1,\n\t\t\t\tcolumn: issue.range.start.character + 1,\n\t\t\t\tmessage: issue.message,\n\t\t\t});\n\t\t}\n\t\treturn lines;\n\t} catch {\n\t\tfor (const raw of out.split(\"\\n\")) {\n\t\t\tconst match = PYRIGHT_ISSUE.exec(raw.trim());\n\t\t\tif (match?.groups) {\n\t\t\t\tlines.push({\n\t\t\t\t\tlanguage: \"python\",\n\t\t\t\t\tseverity: match.groups.sev === \"error\" ? \"error\" : match.groups.sev === \"warning\" ? \"warning\" : \"info\",\n\t\t\t\t\tpath: match.groups.path,\n\t\t\t\t\tline: Number(match.groups.line),\n\t\t\t\t\tcolumn: Number(match.groups.col),\n\t\t\t\t\tmessage: match.groups.msg.trim(),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn lines;\n\t}\n}\n\nconst RUFF_ISSUE = /^(?<path>.+?):(?<line>\\d+):(?<col>\\d+): (?<msg>.+)$/;\n\nfunction parseRuff(out: string): DiagnosticLine[] {\n\tconst lines: DiagnosticLine[] = [];\n\tfor (const raw of out.split(\"\\n\")) {\n\t\tconst match = RUFF_ISSUE.exec(raw.trim());\n\t\tif (match?.groups) {\n\t\t\tlines.push({\n\t\t\t\tlanguage: \"python\",\n\t\t\t\tseverity: \"warning\",\n\t\t\t\tpath: match.groups.path,\n\t\t\t\tline: Number(match.groups.line),\n\t\t\t\tcolumn: Number(match.groups.col),\n\t\t\t\tmessage: match.groups.msg.trim(),\n\t\t\t});\n\t\t}\n\t}\n\treturn lines;\n}\n\nconst GO_VET = /^(?:#\\s+\\S+\\s+)?(?<path>.+?\\.go):(?<line>\\d+):(?<col>\\d+): (?<msg>.+)$/;\n\nfunction parseGoVet(out: string): DiagnosticLine[] {\n\tconst lines: DiagnosticLine[] = [];\n\tfor (const raw of out.split(\"\\n\")) {\n\t\tconst match = GO_VET.exec(raw.trim());\n\t\tif (match?.groups) {\n\t\t\tlines.push({\n\t\t\t\tlanguage: \"go\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: match.groups.path,\n\t\t\t\tline: Number(match.groups.line),\n\t\t\t\tcolumn: Number(match.groups.col),\n\t\t\t\tmessage: match.groups.msg.trim(),\n\t\t\t});\n\t\t}\n\t}\n\treturn lines;\n}\n\nconst CARGO_SHORT = /^(?<path>.+?):(?<line>\\d+):(?<col>\\d+): (?<msg>.+)$/;\n\nfunction parseCargo(out: string): DiagnosticLine[] {\n\tconst lines: DiagnosticLine[] = [];\n\tfor (const raw of out.split(\"\\n\")) {\n\t\tconst match = CARGO_SHORT.exec(raw.trim());\n\t\tif (match?.groups) {\n\t\t\tconst sev = match.groups.msg.startsWith(\"warning\") ? \"warning\" : \"error\";\n\t\t\tlines.push({\n\t\t\t\tlanguage: \"rust\",\n\t\t\t\tseverity: sev,\n\t\t\t\tpath: match.groups.path,\n\t\t\t\tline: Number(match.groups.line),\n\t\t\t\tcolumn: Number(match.groups.col),\n\t\t\t\tmessage: match.groups.msg.trim(),\n\t\t\t});\n\t\t}\n\t}\n\treturn lines;\n}\n\nasync function checkTypeScript(cwd: string, path: string | undefined, timeoutMs: number): Promise<LanguageResult> {\n\tconst root = nearestMarker(cwd, [\"tsconfig.json\", \"tsconfig.build.json\"]);\n\tif (!root) return { lines: [], skippedReason: \"no tsconfig found\" };\n\tconst tsc = join(cwd, \"node_modules\", \".bin\", \"tsc\");\n\tconst localBin = existsSync(tsc) ? tsc : join(root, \"node_modules\", \".bin\", \"tsc\");\n\tconst bin = existsSync(localBin) ? localBin : \"tsc\";\n\tconst config = existsSync(join(root, \"tsconfig.json\")) ? \"tsconfig.json\" : \"tsconfig.build.json\";\n\tconst { code, out } = await run(bin, [\"--noEmit\", \"-p\", config, \"--pretty\", \"false\"], root, timeoutMs);\n\tif (code === null) return { lines: [], skippedReason: \"tsc spawn failed\" };\n\treturn { lines: parseTsc(out, \"typescript\").filter((d) => !path || d.path.includes(path)) };\n}\n\nasync function checkPython(cwd: string, path: string | undefined, timeoutMs: number): Promise<LanguageResult> {\n\tconst target = path ?? \".\";\n\tif (await commandExists(\"pyright\")) {\n\t\tconst { code, out } = await run(\"pyright\", [\"--outputjson\", target], cwd, timeoutMs);\n\t\tif (code === null) return { lines: [], skippedReason: \"pyright spawn failed\" };\n\t\treturn { lines: parsePyright(out) };\n\t}\n\tif (await commandExists(\"ruff\")) {\n\t\tconst { code, out } = await run(\"ruff\", [\"check\", \"--no-cache\", target], cwd, timeoutMs);\n\t\tif (code === null) return { lines: [], skippedReason: \"ruff spawn failed\" };\n\t\treturn { lines: parseRuff(out) };\n\t}\n\treturn { lines: [], skippedReason: \"pyright/ruff not installed\" };\n}\n\nasync function checkGo(cwd: string, path: string | undefined, timeoutMs: number): Promise<LanguageResult> {\n\tconst root = nearestMarker(cwd, [\"go.mod\"]);\n\tif (!root) return { lines: [], skippedReason: \"no go.mod found\" };\n\tif (!(await commandExists(\"go\"))) return { lines: [], skippedReason: \"go not installed\" };\n\tconst { code, out } = await run(\"go\", [\"vet\", \"./...\"], root, timeoutMs);\n\tif (code === null) return { lines: [], skippedReason: \"go vet spawn failed\" };\n\treturn { lines: parseGoVet(out).filter((d) => !path || d.path.includes(path)) };\n}\n\nasync function checkRust(cwd: string, path: string | undefined, timeoutMs: number): Promise<LanguageResult> {\n\tconst root = nearestMarker(cwd, [\"Cargo.toml\"]);\n\tif (!root) return { lines: [], skippedReason: \"no Cargo.toml found\" };\n\tif (!(await commandExists(\"cargo\"))) return { lines: [], skippedReason: \"cargo not installed\" };\n\tconst { code, out } = await run(\"cargo\", [\"check\", \"--quiet\", \"--message-format\", \"short\"], root, timeoutMs);\n\tif (code === null) return { lines: [], skippedReason: \"cargo spawn failed\" };\n\treturn { lines: parseCargo(out).filter((d) => !path || d.path.includes(path)) };\n}\n\nconst CHECKERS = {\n\ttypescript: checkTypeScript,\n\tpython: checkPython,\n\tgo: checkGo,\n\trust: checkRust,\n} as const;\n\ntype Language = keyof typeof CHECKERS;\n\nfunction detectLanguages(cwd: string, path: string | undefined): Language[] {\n\tif (path) {\n\t\tif (/\\.tsx?$/.test(path)) return [\"typescript\"];\n\t\tif (/\\.py$/.test(path)) return [\"python\"];\n\t\tif (/\\.go$/.test(path)) return [\"go\"];\n\t\tif (/\\.rs$/.test(path)) return [\"rust\"];\n\t}\n\tconst detected: Language[] = [];\n\tif (nearestMarker(cwd, [\"tsconfig.json\", \"tsconfig.build.json\"])) detected.push(\"typescript\");\n\tif (nearestMarker(cwd, [\"pyproject.toml\", \"setup.py\", \"setup.cfg\", \"requirements.txt\"])) detected.push(\"python\");\n\tif (nearestMarker(cwd, [\"go.mod\"])) detected.push(\"go\");\n\tif (nearestMarker(cwd, [\"Cargo.toml\"])) detected.push(\"rust\");\n\treturn detected.length > 0 ? detected : [\"typescript\", \"python\", \"go\", \"rust\"];\n}\n\nasync function checkLanguage(\n\tlanguage: Language,\n\tcwd: string,\n\tpath: string | undefined,\n\ttimeoutMs: number,\n): Promise<LanguageResult> {\n\tconst key = `${language}${cwd}${path ?? \"\"}`;\n\tconst cached = cache.get(key);\n\tif (cached && Date.now() - cached.at < CACHE_TTL_MS) return cached.result;\n\tconst result = await CHECKERS[language](cwd, path, timeoutMs);\n\tif (cache.size >= 16) {\n\t\tconst oldest = cache.keys().next().value;\n\t\tif (oldest !== undefined) cache.delete(oldest);\n\t}\n\tcache.set(key, { at: Date.now(), result });\n\treturn result;\n}\n\nexport function createDiagnosticsToolDefinition(\n\tcwd: string,\n): ToolDefinition<typeof diagnosticsSchema, DiagnosticsToolDetails> {\n\treturn {\n\t\tname: \"diagnostics\",\n\t\tlabel: \"diagnostics\",\n\t\tdescription:\n\t\t\t\"Run the project's own type/lint checkers (tsc, pyright/ruff, go vet, cargo check) and return normalized diagnostics. Missing checkers or missing project markers are reported as skipped, never as tool errors.\",\n\t\tpromptSnippet: \"Get compiler/lint diagnostics for the workspace or a file\",\n\t\tparameters: diagnosticsSchema,\n\t\tasync execute(_toolCallId, { path, language, timeout }: DiagnosticsToolInput) {\n\t\t\tconst timeoutMs = timeout !== undefined && timeout > 0 ? timeout * 1000 : DEFAULT_TIMEOUT_MS;\n\t\t\tconst languages = language && language !== \"auto\" ? [language] : detectLanguages(cwd, path);\n\t\t\tconst settled = await Promise.all(languages.map((lang) => checkLanguage(lang, cwd, path, timeoutMs)));\n\t\t\tconst diagnostics: DiagnosticLine[] = [];\n\t\t\tconst skipped: { language: string; reason: string }[] = [];\n\t\t\tfor (let index = 0; index < languages.length; index++) {\n\t\t\t\tconst result = settled[index];\n\t\t\t\tif (result.skippedReason) skipped.push({ language: languages[index], reason: result.skippedReason });\n\t\t\t\tdiagnostics.push(...result.lines);\n\t\t\t}\n\t\t\tconst capped = diagnostics.slice(0, MAX_DIAGNOSTICS);\n\t\t\tconst counts: Record<string, number> = {};\n\t\t\tfor (const d of diagnostics) counts[d.language] = (counts[d.language] ?? 0) + 1;\n\t\t\tconst text =\n\t\t\t\tcapped.length === 0 && skipped.length === 0\n\t\t\t\t\t? \"No diagnostics.\"\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t...capped.map(\n\t\t\t\t\t\t\t\t(d) =>\n\t\t\t\t\t\t\t\t\t`${d.severity.toUpperCase()} ${d.path}:${d.line}:${d.column} ${d.message} (${d.language})`,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t...(diagnostics.length > capped.length ? [`... ${diagnostics.length - capped.length} more`] : []),\n\t\t\t\t\t\t\t...skipped.map((s) => `${s.language}: skipped (${s.reason})`),\n\t\t\t\t\t\t].join(\"\\n\");\n\t\t\treturn { content: [{ type: \"text\", text }], details: { diagnostics: capped, skipped, counts } };\n\t\t},\n\t};\n}\n\nexport function createDiagnosticsTool(cwd: string): AgentTool<typeof diagnosticsSchema> {\n\treturn wrapToolDefinition(createDiagnosticsToolDefinition(cwd));\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, createBashTool, createBashToolDefinition, createLocalBashOperations, } from "./bash.ts";
|
|
2
|
+
export { createDiagnosticsTool, createDiagnosticsToolDefinition, type DiagnosticLine, type DiagnosticsToolDetails, type DiagnosticsToolInput, } from "./diagnostics.ts";
|
|
2
3
|
export { createEditTool, createEditToolDefinition, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, } from "./edit.ts";
|
|
3
4
|
export { withFileMutationQueue } from "./file-mutation-queue.ts";
|
|
4
5
|
export { createFindTool, createFindToolDefinition, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, } from "./find.ts";
|
|
@@ -18,7 +19,7 @@ import { type ReadToolOptions } from "./read.ts";
|
|
|
18
19
|
import { type WriteToolOptions } from "./write.ts";
|
|
19
20
|
export type Tool = AgentTool<any>;
|
|
20
21
|
export type ToolDef = ToolDefinition<any, any>;
|
|
21
|
-
export type ToolName = "read" | "bash" | "edit" | "write" | "grep" | "find" | "ls";
|
|
22
|
+
export type ToolName = "read" | "bash" | "edit" | "write" | "grep" | "find" | "ls" | "diagnostics";
|
|
22
23
|
export declare const allToolNames: Set<ToolName>;
|
|
23
24
|
export interface ToolsOptions {
|
|
24
25
|
read?: ReadToolOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,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AE,YAAY,GAAG,IAAI,EAAE,CAO7E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO/E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAU1F","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"omk-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\";\nexport const allToolNames: Set<ToolName> = new Set([\"read\", \"bash\", \"edit\", \"write\", \"grep\", \"find\", \"ls\"]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,qBAAqB,EACrB,+BAA+B,EAC/B,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB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E,CAO5F;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAWvG;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO7E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO/E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAW1F","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateDiagnosticsTool,\n\tcreateDiagnosticsToolDefinition,\n\ttype DiagnosticLine,\n\ttype DiagnosticsToolDetails,\n\ttype DiagnosticsToolInput,\n} from \"./diagnostics.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"omk-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createDiagnosticsTool, createDiagnosticsToolDefinition } from \"./diagnostics.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\" | \"diagnostics\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"diagnostics\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"diagnostics\":\n\t\t\treturn createDiagnosticsToolDefinition(cwd);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"diagnostics\":\n\t\t\treturn createDiagnosticsTool(cwd);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tdiagnostics: createDiagnosticsToolDefinition(cwd),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tdiagnostics: createDiagnosticsTool(cwd),\n\t};\n}\n"]}
|
package/dist/core/tools/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { createBashTool, createBashToolDefinition, createLocalBashOperations, } from "./bash.js";
|
|
2
|
+
export { createDiagnosticsTool, createDiagnosticsToolDefinition, } from "./diagnostics.js";
|
|
2
3
|
export { createEditTool, createEditToolDefinition, } from "./edit.js";
|
|
3
4
|
export { withFileMutationQueue } from "./file-mutation-queue.js";
|
|
4
5
|
export { createFindTool, createFindToolDefinition, } from "./find.js";
|
|
@@ -8,13 +9,23 @@ export { createReadTool, createReadToolDefinition, } from "./read.js";
|
|
|
8
9
|
export { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead, truncateLine, truncateTail, } from "./truncate.js";
|
|
9
10
|
export { createWriteTool, createWriteToolDefinition, } from "./write.js";
|
|
10
11
|
import { createBashTool, createBashToolDefinition } from "./bash.js";
|
|
12
|
+
import { createDiagnosticsTool, createDiagnosticsToolDefinition } from "./diagnostics.js";
|
|
11
13
|
import { createEditTool, createEditToolDefinition } from "./edit.js";
|
|
12
14
|
import { createFindTool, createFindToolDefinition } from "./find.js";
|
|
13
15
|
import { createGrepTool, createGrepToolDefinition } from "./grep.js";
|
|
14
16
|
import { createLsTool, createLsToolDefinition } from "./ls.js";
|
|
15
17
|
import { createReadTool, createReadToolDefinition } from "./read.js";
|
|
16
18
|
import { createWriteTool, createWriteToolDefinition } from "./write.js";
|
|
17
|
-
export const allToolNames = new Set([
|
|
19
|
+
export const allToolNames = new Set([
|
|
20
|
+
"read",
|
|
21
|
+
"bash",
|
|
22
|
+
"edit",
|
|
23
|
+
"write",
|
|
24
|
+
"grep",
|
|
25
|
+
"find",
|
|
26
|
+
"ls",
|
|
27
|
+
"diagnostics",
|
|
28
|
+
]);
|
|
18
29
|
export function createToolDefinition(toolName, cwd, options) {
|
|
19
30
|
switch (toolName) {
|
|
20
31
|
case "read":
|
|
@@ -31,6 +42,8 @@ export function createToolDefinition(toolName, cwd, options) {
|
|
|
31
42
|
return createFindToolDefinition(cwd, options?.find);
|
|
32
43
|
case "ls":
|
|
33
44
|
return createLsToolDefinition(cwd, options?.ls);
|
|
45
|
+
case "diagnostics":
|
|
46
|
+
return createDiagnosticsToolDefinition(cwd);
|
|
34
47
|
default:
|
|
35
48
|
throw new Error(`Unknown tool name: ${toolName}`);
|
|
36
49
|
}
|
|
@@ -51,6 +64,8 @@ export function createTool(toolName, cwd, options) {
|
|
|
51
64
|
return createFindTool(cwd, options?.find);
|
|
52
65
|
case "ls":
|
|
53
66
|
return createLsTool(cwd, options?.ls);
|
|
67
|
+
case "diagnostics":
|
|
68
|
+
return createDiagnosticsTool(cwd);
|
|
54
69
|
default:
|
|
55
70
|
throw new Error(`Unknown tool name: ${toolName}`);
|
|
56
71
|
}
|
|
@@ -80,6 +95,7 @@ export function createAllToolDefinitions(cwd, options) {
|
|
|
80
95
|
grep: createGrepToolDefinition(cwd, options?.grep),
|
|
81
96
|
find: createFindToolDefinition(cwd, options?.find),
|
|
82
97
|
ls: createLsToolDefinition(cwd, options?.ls),
|
|
98
|
+
diagnostics: createDiagnosticsToolDefinition(cwd),
|
|
83
99
|
};
|
|
84
100
|
}
|
|
85
101
|
export function createCodingTools(cwd, options) {
|
|
@@ -107,6 +123,7 @@ export function createAllTools(cwd, options) {
|
|
|
107
123
|
grep: createGrepTool(cwd, options?.grep),
|
|
108
124
|
find: createFindTool(cwd, options?.find),
|
|
109
125
|
ls: createLsTool(cwd, options?.ls),
|
|
126
|
+
diagnostics: createDiagnosticsTool(cwd),
|
|
110
127
|
};
|
|
111
128
|
}
|
|
112
129
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","s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C;QACxC,KAAK,EAAE,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC;QAC3C,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;KAClC,CAAC;AAAA,CACF","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"omk-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\";\nexport const allToolNames: Set<ToolName> = new Set([\"read\", \"bash\", \"edit\", \"write\", \"grep\", \"find\", \"ls\"]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,qBAAqB,EACrB,+BAA+B,GAI/B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,M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AAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;QAClC,WAAW,EAAE,qBAAqB,CAAC,GAAG,CAAC;KACvC,CAAC;AAAA,CACF","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateDiagnosticsTool,\n\tcreateDiagnosticsToolDefinition,\n\ttype DiagnosticLine,\n\ttype DiagnosticsToolDetails,\n\ttype DiagnosticsToolInput,\n} from \"./diagnostics.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"omk-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createDiagnosticsTool, createDiagnosticsToolDefinition } from \"./diagnostics.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\" | \"diagnostics\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"diagnostics\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"diagnostics\":\n\t\t\treturn createDiagnosticsToolDefinition(cwd);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"diagnostics\":\n\t\t\treturn createDiagnosticsTool(cwd);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tdiagnostics: createDiagnosticsToolDefinition(cwd),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tdiagnostics: createDiagnosticsTool(cwd),\n\t};\n}\n"]}
|
|
@@ -16,6 +16,10 @@ export interface VerifiedBashExecutionRequest {
|
|
|
16
16
|
readonly executor?: "bash-tool" | "ci-runner";
|
|
17
17
|
readonly toolCallId?: string;
|
|
18
18
|
readonly signal?: AbortSignal;
|
|
19
|
+
/** Optional process env forwarded to BashOperations.exec (session PI_*, spawnHook). */
|
|
20
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
21
|
+
/** Optional live output fan-out; receipt capture still runs independently. */
|
|
22
|
+
readonly onData?: (data: Buffer) => void;
|
|
19
23
|
}
|
|
20
24
|
export type VerifiedLocalBashExecutionRequest = Omit<VerifiedBashExecutionRequest, "operations" | "shell"> & {
|
|
21
25
|
readonly shellPath?: string;
|
|
@@ -26,11 +30,24 @@ export declare class VerifiedBashAdapterError extends Error {
|
|
|
26
30
|
constructor(message: string);
|
|
27
31
|
}
|
|
28
32
|
/**
|
|
29
|
-
* Bind
|
|
33
|
+
* Bind a caller-trusted BashOperations execution to a receipt.
|
|
34
|
+
* Default session/CLI paths enable this adapter unless `OMK_VERIFIED_BASH=0`.
|
|
30
35
|
* BashOperations exposes a combined output stream, so the policy records the
|
|
31
36
|
* redacted bounded stream as stdout and leaves stderr empty by construction.
|
|
32
37
|
*/
|
|
33
38
|
export declare function executeVerifiedBash(request: VerifiedBashExecutionRequest): Promise<VerifiedEvidenceExecutionResult>;
|
|
34
39
|
/** Bind OMK's first-party local shell backend to the verified bash adapter. */
|
|
35
40
|
export declare function executeVerifiedLocalBash(request: VerifiedLocalBashExecutionRequest): Promise<VerifiedEvidenceExecutionResult>;
|
|
41
|
+
export interface VerifiedBashOperationsBinding {
|
|
42
|
+
readonly evidenceExecutor: VerifiedEvidenceExecutor;
|
|
43
|
+
readonly goalId: string;
|
|
44
|
+
readonly laneId?: string;
|
|
45
|
+
readonly shell: string;
|
|
46
|
+
readonly workspaceScope?: WorkspaceScope;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Wrap BashOperations so each exec is receipt-bound. Used by AgentSession to
|
|
50
|
+
* inject the default-on verified path into createBashTool without circular imports.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createVerifiedBashOperations(inner: BashOperations, binding: VerifiedBashOperationsBinding): BashOperations;
|
|
36
53
|
//# sourceMappingURL=verified-bash-adapter.d.ts.map
|