@aexol/spectral 0.9.158 → 0.9.160
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/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +29 -5
- package/dist/extensions/desktop-screenshot/index.d.ts.map +1 -1
- package/dist/extensions/desktop-screenshot/index.js +46 -39
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/memory/tool-output-compressor.d.ts +8 -2
- package/dist/memory/tool-output-compressor.d.ts.map +1 -1
- package/dist/memory/tool-output-compressor.js +8 -83
- package/dist/sdk/coding-agent/core/compaction/policy.js +6 -6
- package/dist/sdk/coding-agent/core/extensions/index.d.ts +2 -2
- package/dist/sdk/coding-agent/core/extensions/index.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/extensions/index.js +1 -1
- package/dist/sdk/coding-agent/core/extensions/types.d.ts +3 -44
- package/dist/sdk/coding-agent/core/extensions/types.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/extensions/types.js +0 -12
- package/dist/sdk/coding-agent/core/package-manager.d.ts +0 -15
- package/dist/sdk/coding-agent/core/package-manager.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/package-manager.js +0 -80
- package/dist/sdk/coding-agent/core/sdk.d.ts +2 -2
- package/dist/sdk/coding-agent/core/sdk.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/sdk.js +3 -3
- package/dist/sdk/coding-agent/core/tools/bash-blocklist.js +1 -1
- package/dist/sdk/coding-agent/core/tools/index.d.ts +1 -13
- package/dist/sdk/coding-agent/core/tools/index.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/tools/index.js +0 -44
- package/dist/sdk/coding-agent/index.d.ts +4 -4
- package/dist/sdk/coding-agent/index.d.ts.map +1 -1
- package/dist/sdk/coding-agent/index.js +3 -3
- package/dist/server/agent-bridge.d.ts.map +1 -1
- package/dist/server/agent-bridge.js +1 -0
- package/package.json +1 -1
- package/dist/sdk/coding-agent/core/tools/edit.d.ts +0 -45
- package/dist/sdk/coding-agent/core/tools/edit.d.ts.map +0 -1
- package/dist/sdk/coding-agent/core/tools/edit.js +0 -216
- package/dist/sdk/coding-agent/core/tools/grep.d.ts +0 -37
- package/dist/sdk/coding-agent/core/tools/grep.d.ts.map +0 -1
- package/dist/sdk/coding-agent/core/tools/grep.js +0 -288
- package/dist/sdk/coding-agent/core/tools/ls.d.ts +0 -37
- package/dist/sdk/coding-agent/core/tools/ls.d.ts.map +0 -1
- package/dist/sdk/coding-agent/core/tools/ls.js +0 -156
- package/dist/sdk/coding-agent/core/tools/write.d.ts +0 -23
- package/dist/sdk/coding-agent/core/tools/write.d.ts.map +0 -1
- package/dist/sdk/coding-agent/core/tools/write.js +0 -134
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAIX,SAAS,EAET,MAAM,4BAA4B,CAAC;AAUpC,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACN,KAAK,WAAW,EAKhB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOrD,OAAO,KAAK,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAIX,SAAS,EAET,MAAM,4BAA4B,CAAC;AAUpC,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACN,KAAK,WAAW,EAKhB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOrD,OAAO,KAAK,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AAsG7G;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACxC,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC,GAC9F,MAAM,CAYR;AAgID;;;GAGG;AACH,wBAAgB,oCAAoC,CACnD,cAAc,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,GAChD,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC,CAK3D;AAED,wBAAgB,oBAAoB,CACnC,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAC/B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,YAAY,EACjB,GAAG,EAAE,gBAAgB,GACnB,SAAS,EAAE,CAqCb;AA8aD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACxC,GAAG,EAAE,YAAY,EACjB,IAAI,CAAC,EAAE;IACN,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,GACC,IAAI,CAgaN"}
|
package/dist/agent/index.js
CHANGED
|
@@ -53,6 +53,12 @@ const MAX_CONCURRENCY = 4;
|
|
|
53
53
|
* Defaults to 4 hours. Override via SPECTRAL_SUBAGENT_TIMEOUT_MS env var.
|
|
54
54
|
*/
|
|
55
55
|
const SUBAGENT_TIMEOUT_MS = Number(process.env.SPECTRAL_SUBAGENT_TIMEOUT_MS) || 4 * 60 * 60 * 1000;
|
|
56
|
+
/**
|
|
57
|
+
* Max chars of subagent final output forwarded to the parent LLM as
|
|
58
|
+
* `tool_result.content`. 0 (default) = no limit, consistent with single mode.
|
|
59
|
+
* Override via SPECTRAL_SUBAGENT_OUTPUT_LIMIT env var.
|
|
60
|
+
*/
|
|
61
|
+
const SUBAGENT_OUTPUT_LIMIT = parseInt(process.env.SPECTRAL_SUBAGENT_OUTPUT_LIMIT || "0", 10);
|
|
56
62
|
// ---------------------------------------------------------------------------
|
|
57
63
|
// Helpers — formatting
|
|
58
64
|
// ---------------------------------------------------------------------------
|
|
@@ -154,6 +160,18 @@ function getFinalOutput(messages) {
|
|
|
154
160
|
}
|
|
155
161
|
return "";
|
|
156
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Truncates subagent final output text. When `limit` is 0 (default), the full
|
|
165
|
+
* text is returned unchanged, matching single-mode behavior. When `limit` > 0,
|
|
166
|
+
* the text is sliced to `limit` chars and suffixed with `"..."` if it exceeds
|
|
167
|
+
* the limit (preserving the historical truncation contract).
|
|
168
|
+
*/
|
|
169
|
+
function truncateOutput(text, limit) {
|
|
170
|
+
if (limit > 0 && text.length > limit) {
|
|
171
|
+
return text.slice(0, limit) + "...";
|
|
172
|
+
}
|
|
173
|
+
return text;
|
|
174
|
+
}
|
|
157
175
|
// ---------------------------------------------------------------------------
|
|
158
176
|
// Helpers — model resolution
|
|
159
177
|
// ---------------------------------------------------------------------------
|
|
@@ -433,7 +451,7 @@ async function runSingleAgent(defaultCwd, agents, agentName, task, cwd, step, si
|
|
|
433
451
|
},
|
|
434
452
|
afterToolCall: async ({ toolCall, args, result, isError }) => {
|
|
435
453
|
try {
|
|
436
|
-
const content = compressSubagentToolResult(toolCall.name, args, result);
|
|
454
|
+
const content = compressSubagentToolResult(toolCall.name, args, result, ctx);
|
|
437
455
|
return content ? { content, details: result.details, isError, terminate: result.terminate } : undefined;
|
|
438
456
|
}
|
|
439
457
|
catch {
|
|
@@ -772,11 +790,18 @@ export default function subagentExtension(ext, opts) {
|
|
|
772
790
|
}
|
|
773
791
|
previousOutput = getFinalOutput(result.messages);
|
|
774
792
|
}
|
|
793
|
+
const chainSummaries = results.map((r, idx) => {
|
|
794
|
+
const output = truncateOutput(getFinalOutput(r.messages) || "(no output)", SUBAGENT_OUTPUT_LIMIT);
|
|
795
|
+
const status = r.exitCode === 0
|
|
796
|
+
? "completed"
|
|
797
|
+
: "failed";
|
|
798
|
+
return `[step ${idx + 1} - ${r.agent}] ${status}:\n${output}`;
|
|
799
|
+
});
|
|
775
800
|
return {
|
|
776
801
|
content: [
|
|
777
802
|
{
|
|
778
803
|
type: "text",
|
|
779
|
-
text:
|
|
804
|
+
text: `Chain completed (${results.length} step${results.length > 1 ? "s" : ""})\n\n${chainSummaries.join("\n\n")}`,
|
|
780
805
|
},
|
|
781
806
|
],
|
|
782
807
|
details: makeDetails("chain")(results),
|
|
@@ -834,9 +859,8 @@ export default function subagentExtension(ext, opts) {
|
|
|
834
859
|
});
|
|
835
860
|
const successCount = results.filter((r) => r.exitCode === 0).length;
|
|
836
861
|
const summaries = results.map((r) => {
|
|
837
|
-
const output = getFinalOutput(r.messages);
|
|
838
|
-
|
|
839
|
-
return `[${r.agent}] ${r.exitCode === 0 ? "completed" : "failed"}: ${preview || "(no output)"}`;
|
|
862
|
+
const output = truncateOutput(getFinalOutput(r.messages), SUBAGENT_OUTPUT_LIMIT);
|
|
863
|
+
return `[${r.agent}] ${r.exitCode === 0 ? "completed" : "failed"}:\n${output || "(no output)"}`;
|
|
840
864
|
});
|
|
841
865
|
return {
|
|
842
866
|
content: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/desktop-screenshot/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/desktop-screenshot/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAQH,OAAO,KAAK,EAEX,YAAY,EAEZ,MAAM,iCAAiC,CAAC;AA8dzC,wBAA8B,0BAA0B,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAoFzF"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* extension automatically analyzes with a vision model.
|
|
14
14
|
*/
|
|
15
15
|
import { execFile } from "node:child_process";
|
|
16
|
+
import crossSpawn from "cross-spawn";
|
|
16
17
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
17
18
|
import { tmpdir } from "node:os";
|
|
18
19
|
import { join } from "node:path";
|
|
@@ -246,6 +247,35 @@ function linuxWindowScreenshot(windowId, options) {
|
|
|
246
247
|
// ===========================================================================
|
|
247
248
|
// Windows (PowerShell)
|
|
248
249
|
// ===========================================================================
|
|
250
|
+
/**
|
|
251
|
+
* Run a PowerShell script file and return its stdout as a string.
|
|
252
|
+
*
|
|
253
|
+
* Uses `cross-spawn` instead of Node's `execFile` because, on Windows,
|
|
254
|
+
* `execFile` does not resolve commands through PATHEXT and requires a fully
|
|
255
|
+
* populated PATH. Inside Electron/desktop sandboxes the PATH is often trimmed,
|
|
256
|
+
* which leads to `spawn powershell.exe ENOENT`. `cross-spawn` resolves the
|
|
257
|
+
* executable via PATHEXT/PATH like a shell would.
|
|
258
|
+
*
|
|
259
|
+
* `-Sta` is passed so the single-threaded apartment required by
|
|
260
|
+
* System.Windows.Forms / CopyFromScreen is initialized even in sessions that
|
|
261
|
+
* default to MTA (avoids COM failures).
|
|
262
|
+
*/
|
|
263
|
+
function runPowerShell(psPath) {
|
|
264
|
+
return new Promise((resolve, reject) => {
|
|
265
|
+
const child = crossSpawn("powershell.exe", ["-NoProfile", "-Sta", "-ExecutionPolicy", "Bypass", "-File", psPath], { timeout: 15000, windowsHide: true });
|
|
266
|
+
let stdout = "";
|
|
267
|
+
let stderr = "";
|
|
268
|
+
child.stdout?.on("data", (chunk) => { stdout += chunk.toString(); });
|
|
269
|
+
child.stderr?.on("data", (chunk) => { stderr += chunk.toString(); });
|
|
270
|
+
child.on("error", reject);
|
|
271
|
+
child.on("close", (code) => {
|
|
272
|
+
if (code === 0)
|
|
273
|
+
return resolve(stdout);
|
|
274
|
+
const tail = stderr.trim() || `exited with code ${code}`;
|
|
275
|
+
reject(new Error(`powershell.exe ${tail}`));
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
}
|
|
249
279
|
function listWin32Windows() {
|
|
250
280
|
const psLines = [
|
|
251
281
|
'Add-Type @"',
|
|
@@ -284,19 +314,15 @@ function listWin32Windows() {
|
|
|
284
314
|
const psScript = psLines.join("\r\n");
|
|
285
315
|
const psPath = join(tmpDir(), `${randomUUID()}.ps1`);
|
|
286
316
|
writeFileSync(psPath, psScript, "utf-8");
|
|
287
|
-
return
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
windows.push({ id, owner, title: titleParts.join("\t") });
|
|
297
|
-
}
|
|
298
|
-
resolve(windows);
|
|
299
|
-
});
|
|
317
|
+
return runPowerShell(psPath).then((stdout) => {
|
|
318
|
+
const windows = [];
|
|
319
|
+
for (const line of stdout.trim().split("\n").filter(Boolean)) {
|
|
320
|
+
const [id, owner, ...titleParts] = line.split("\t");
|
|
321
|
+
if (!id || !owner)
|
|
322
|
+
continue;
|
|
323
|
+
windows.push({ id, owner, title: titleParts.join("\t") });
|
|
324
|
+
}
|
|
325
|
+
return windows;
|
|
300
326
|
});
|
|
301
327
|
}
|
|
302
328
|
function win32FullScreenshot(options) {
|
|
@@ -321,25 +347,17 @@ function win32FullScreenshot(options) {
|
|
|
321
347
|
const psScript = psLines.join("\r\n");
|
|
322
348
|
const psPath = join(tmpDir(), `${randomUUID()}.ps1`);
|
|
323
349
|
writeFileSync(psPath, psScript, "utf-8");
|
|
324
|
-
return
|
|
325
|
-
execFile("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", psPath], { timeout: 15000 }, (err) => {
|
|
326
|
-
if (err)
|
|
327
|
-
return reject(new Error(`Screenshot failed: ${err.message}`));
|
|
328
|
-
try {
|
|
329
|
-
resolve(readFileSync(outPath));
|
|
330
|
-
}
|
|
331
|
-
catch (e) {
|
|
332
|
-
reject(e);
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
});
|
|
350
|
+
return runPowerShell(psPath).then(() => readFileSync(outPath), (err) => { throw new Error(`Screenshot failed: ${err.message}`); });
|
|
336
351
|
}
|
|
337
352
|
function win32WindowScreenshot(hwnd, options) {
|
|
338
353
|
const format = options.format ?? "png";
|
|
339
354
|
const formatUpper = format.toUpperCase();
|
|
340
355
|
const imageFormat = (formatUpper === "JPG" || formatUpper === "JPEG") ? "Jpeg" : "Png";
|
|
341
|
-
//
|
|
342
|
-
|
|
356
|
+
// Normalize hwnd to hex regardless of input format: Number() parses both
|
|
357
|
+
// decimal (65882) and hex ("0x10132"), then toString(16) yields the hex
|
|
358
|
+
// digits to feed into [IntPtr]::new(0x...). Without this, a decimal hwnd
|
|
359
|
+
// was inserted verbatim producing 0x65882 (wrong pointer).
|
|
360
|
+
const hwndHex = Number(hwnd).toString(16);
|
|
343
361
|
const outPath = join(tmpDir(), `${randomUUID()}.${format}`);
|
|
344
362
|
const psLines = [
|
|
345
363
|
"Add-Type -AssemblyName System.Drawing",
|
|
@@ -376,18 +394,7 @@ function win32WindowScreenshot(hwnd, options) {
|
|
|
376
394
|
const psScript = psLines.join("\r\n");
|
|
377
395
|
const psPath = join(tmpDir(), `${randomUUID()}.ps1`);
|
|
378
396
|
writeFileSync(psPath, psScript, "utf-8");
|
|
379
|
-
return
|
|
380
|
-
execFile("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", psPath], { timeout: 15000 }, (err) => {
|
|
381
|
-
if (err)
|
|
382
|
-
return reject(new Error(`Window screenshot failed: ${err.message}`));
|
|
383
|
-
try {
|
|
384
|
-
resolve(readFileSync(outPath));
|
|
385
|
-
}
|
|
386
|
-
catch (e) {
|
|
387
|
-
reject(e);
|
|
388
|
-
}
|
|
389
|
-
});
|
|
390
|
-
});
|
|
397
|
+
return runPowerShell(psPath).then(() => readFileSync(outPath), (err) => { throw new Error(`Window screenshot failed: ${err.message}`); });
|
|
391
398
|
}
|
|
392
399
|
// ===========================================================================
|
|
393
400
|
// Unified API
|
package/dist/index.d.ts
CHANGED
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
37
|
export type { ExtensionAPI, ToolDefinition } from "./sdk/coding-agent/index.js";
|
|
38
|
-
export type { AfterProviderResponseEvent, AgentEndEvent, AgentStartEvent, BashToolCallEvent, BashToolResultEvent, BeforeAgentStartEvent, BeforeProviderRequestEvent, ContextEvent, CustomToolCallEvent, CustomToolResultEvent,
|
|
38
|
+
export type { AfterProviderResponseEvent, AgentEndEvent, AgentStartEvent, BashToolCallEvent, BashToolResultEvent, BeforeAgentStartEvent, BeforeProviderRequestEvent, ContextEvent, CustomToolCallEvent, CustomToolResultEvent, ExtensionEvent, InputEvent, MessageEndEvent, MessageStartEvent, MessageUpdateEvent, ModelSelectEvent, ReadToolCallEvent, ReadToolResultEvent, ResourcesDiscoverEvent, SessionBeforeCompactEvent, SessionBeforeForkEvent, SessionBeforeSwitchEvent, SessionBeforeTreeEvent, SessionCompactEvent, SessionEvent, SessionShutdownEvent, SessionStartEvent, SessionTreeEvent, ToolCallEvent, ToolExecutionEndEvent, ToolExecutionStartEvent, ToolExecutionUpdateEvent, ToolResultEvent, TurnEndEvent, TurnStartEvent, UserBashEvent, } from "./sdk/coding-agent/index.js";
|
|
39
39
|
export type { BeforeAgentStartEventResult, BeforeProviderRequestEventResult, ContextEventResult, InputEventResult, ResourcesDiscoverResult, SessionBeforeCompactResult, SessionBeforeForkResult, SessionBeforeSwitchResult, SessionBeforeTreeResult, ToolCallEventResult, UserBashEventResult, } from "./sdk/coding-agent/index.js";
|
|
40
40
|
export type { ExtensionCommandContext, ExtensionContext, ReplacedSessionContext, } from "./sdk/coding-agent/index.js";
|
|
41
41
|
export type { ProviderConfig, ProviderModelConfig, } from "./sdk/coding-agent/index.js";
|
|
42
42
|
export { defineTool } from "./sdk/coding-agent/index.js";
|
|
43
|
-
export { isBashToolResult,
|
|
43
|
+
export { isBashToolResult, isReadToolResult, isToolCallEventType, } from "./sdk/coding-agent/index.js";
|
|
44
44
|
export type { AgentToolResult, AgentToolUpdateCallback, BuildSystemPromptOptions, CompactOptions, ExecOptions, ExecResult, InputSource, ToolExecutionMode, } from "./sdk/coding-agent/index.js";
|
|
45
45
|
export type { Extension, ExtensionActions, ExtensionError, ExtensionFactory, ExtensionFlag, ExtensionHandler, ExtensionRuntime, ExtensionShortcut, ExtensionUIContext, LoadExtensionsResult, RegisteredCommand, RegisteredTool, ResolvedCommand, ToolInfo, } from "./sdk/coding-agent/index.js";
|
|
46
46
|
export { agentLoop, agentLoopContinue, } from "./sdk/agent-core/index.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAMH,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAMhF,YAAY,EACV,0BAA0B,EAC1B,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC1B,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAMH,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAMhF,YAAY,EACV,0BAA0B,EAC1B,aAAa,EACb,eA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B,EACpB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,QAAQ,GACT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EACL,SAAS,EACT,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,YAAY,EACZ,UAAU,EACV,eAAe,EACf,YAAY,EACZ,SAAS,EACT,aAAa,EACb,QAAQ,GACT,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,OAAO,EACP,KAAK,EACL,WAAW,EACX,eAAe,EACf,QAAQ,EACR,iBAAiB,GAClB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ export { defineTool } from "./sdk/coding-agent/index.js";
|
|
|
41
41
|
// ---------------------------------------------------------------------------
|
|
42
42
|
// Type guards for tool result events.
|
|
43
43
|
// ---------------------------------------------------------------------------
|
|
44
|
-
export { isBashToolResult,
|
|
44
|
+
export { isBashToolResult, isReadToolResult, isToolCallEventType, } from "./sdk/coding-agent/index.js";
|
|
45
45
|
// Native agent loop — exposed so extensions can drive the host model in-process
|
|
46
46
|
// (e.g. the changelog_describe tool) instead of shelling out to a child script
|
|
47
47
|
// with a hardcoded provider call.
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
* - Docker/build output: collapse progress lines
|
|
30
30
|
*/
|
|
31
31
|
import type { ExtensionAPI } from "../sdk/coding-agent/index.js";
|
|
32
|
+
import type { ExtensionContext } from "../sdk/coding-agent/core/extensions/types.js";
|
|
32
33
|
import { type ToolOutputCompressorPolicy } from "../sdk/coding-agent/core/compaction/policy.js";
|
|
33
34
|
import type { Runtime } from "./runtime.js";
|
|
34
35
|
export type CompressorConfig = ToolOutputCompressorPolicy;
|
|
@@ -51,7 +52,12 @@ export interface ToolOutputCompressionTelemetry {
|
|
|
51
52
|
}
|
|
52
53
|
export declare function getToolOutputCompressionTelemetry(runtime: Runtime): ToolOutputCompressionTelemetry;
|
|
53
54
|
export declare function resetToolOutputCompressionTelemetry(runtime: Runtime): void;
|
|
54
|
-
/** Compress a subagent tool result without using the parent Runtime or extension lifecycle.
|
|
55
|
+
/** Compress a subagent tool result without using the parent Runtime or extension lifecycle.
|
|
56
|
+
*
|
|
57
|
+
* Accepts an optional extension context so the runtime compaction policy is honored
|
|
58
|
+
* (same path as registerToolOutputCompressor). When omitted, falls back to
|
|
59
|
+
* DEFAULT_COMPRESSOR_CONFIG to stay backward compatible with existing callers/tests.
|
|
60
|
+
*/
|
|
55
61
|
export declare function compressSubagentToolResult(toolName: string, input: unknown, result: {
|
|
56
62
|
content: Array<{
|
|
57
63
|
type: string;
|
|
@@ -59,7 +65,7 @@ export declare function compressSubagentToolResult(toolName: string, input: unkn
|
|
|
59
65
|
data?: string;
|
|
60
66
|
mimeType?: string;
|
|
61
67
|
}>;
|
|
62
|
-
}): Array<{
|
|
68
|
+
}, ctx?: Pick<ExtensionContext, "settingsManager">): Array<{
|
|
63
69
|
type: "text";
|
|
64
70
|
text: string;
|
|
65
71
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-output-compressor.d.ts","sourceRoot":"","sources":["../../src/memory/tool-output-compressor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-output-compressor.d.ts","sourceRoot":"","sources":["../../src/memory/tool-output-compressor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAEX,gBAAgB,EAIhB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAGN,KAAK,0BAA0B,EAC/B,MAAM,+CAA+C,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MA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AC,GAAG,SAAS,CAYvG;AAED,wBAAgB,4BAA4B,CAC3C,GAAG,EAAE,YAAY,EACjB,OAAO,EAAE,OAAO,GACd,IAAI,CAkCN"}
|
|
@@ -619,64 +619,6 @@ function summarizePathTree(content) {
|
|
|
619
619
|
const summary = lines.join("\n");
|
|
620
620
|
return summary.length < content.length ? summary : undefined;
|
|
621
621
|
}
|
|
622
|
-
// ============================================================================
|
|
623
|
-
// Ls Compressor
|
|
624
|
-
// ============================================================================
|
|
625
|
-
function compressLsOutput(event, config) {
|
|
626
|
-
let content = event.content
|
|
627
|
-
.filter((c) => c.type === "text")
|
|
628
|
-
.map((c) => c.text)
|
|
629
|
-
.join("\n");
|
|
630
|
-
if (!content)
|
|
631
|
-
return "";
|
|
632
|
-
if (config.stripAnsi) {
|
|
633
|
-
content = stripAnsi(content);
|
|
634
|
-
}
|
|
635
|
-
const lines = content.split("\n");
|
|
636
|
-
if (lines.length > config.maxLsLines) {
|
|
637
|
-
return summarizePathTree(content) ?? content;
|
|
638
|
-
}
|
|
639
|
-
return content;
|
|
640
|
-
}
|
|
641
|
-
// ============================================================================
|
|
642
|
-
// Grep Compressor
|
|
643
|
-
// ============================================================================
|
|
644
|
-
function compressGrepOutput(event, config) {
|
|
645
|
-
let content = event.content
|
|
646
|
-
.filter((c) => c.type === "text")
|
|
647
|
-
.map((c) => c.text)
|
|
648
|
-
.join("\n");
|
|
649
|
-
if (!content)
|
|
650
|
-
return "";
|
|
651
|
-
if (config.stripAnsi) {
|
|
652
|
-
content = stripAnsi(content);
|
|
653
|
-
}
|
|
654
|
-
// Group matches by file
|
|
655
|
-
const lines = content.split("\n");
|
|
656
|
-
const byFile = new Map();
|
|
657
|
-
for (const line of lines) {
|
|
658
|
-
const trimmed = line.trim();
|
|
659
|
-
if (!trimmed)
|
|
660
|
-
continue;
|
|
661
|
-
// Standard grep format: "file:line:text"
|
|
662
|
-
const colonIdx = trimmed.indexOf(":");
|
|
663
|
-
if (colonIdx > 0) {
|
|
664
|
-
const file = trimmed.slice(0, colonIdx);
|
|
665
|
-
byFile.set(file, (byFile.get(file) ?? 0) + 1);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
if (byFile.size > 1 && lines.length > config.maxSearchLines) {
|
|
669
|
-
// Group by file with count, show first few matches per file
|
|
670
|
-
const grouped = [];
|
|
671
|
-
for (const [file, count] of [...byFile.entries()].sort(([a], [b]) => a.localeCompare(b))) {
|
|
672
|
-
const fileMatches = lines.filter((l) => l.startsWith(file));
|
|
673
|
-
const preview = fileMatches.slice(0, 3).join("\n ");
|
|
674
|
-
grouped.push(`${file} (${count} matches):\n ${preview}${count > 3 ? `\n ... +${count - 3} more` : ""}`);
|
|
675
|
-
}
|
|
676
|
-
return grouped.join("\n\n");
|
|
677
|
-
}
|
|
678
|
-
return content;
|
|
679
|
-
}
|
|
680
622
|
const statsByRuntime = new WeakMap();
|
|
681
623
|
function createTelemetry() {
|
|
682
624
|
return { events: 0, originalChars: 0, compressedChars: 0, byTool: {} };
|
|
@@ -746,23 +688,24 @@ function compressedContentResult(runtime, event, toolName, original, compressed)
|
|
|
746
688
|
content: [...event.content.filter((c) => c.type !== "text"), { type: "text", text: replacementText }],
|
|
747
689
|
};
|
|
748
690
|
}
|
|
749
|
-
/** Compress a subagent tool result without using the parent Runtime or extension lifecycle.
|
|
750
|
-
|
|
691
|
+
/** Compress a subagent tool result without using the parent Runtime or extension lifecycle.
|
|
692
|
+
*
|
|
693
|
+
* Accepts an optional extension context so the runtime compaction policy is honored
|
|
694
|
+
* (same path as registerToolOutputCompressor). When omitted, falls back to
|
|
695
|
+
* DEFAULT_COMPRESSOR_CONFIG to stay backward compatible with existing callers/tests.
|
|
696
|
+
*/
|
|
697
|
+
export function compressSubagentToolResult(toolName, input, result, ctx) {
|
|
751
698
|
const safeInput = input && typeof input === "object" && !Array.isArray(input) ? input : {};
|
|
752
699
|
const text = result.content.filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text).join("\n");
|
|
753
700
|
if (!text || text.startsWith("[tool-output-compressor "))
|
|
754
701
|
return undefined;
|
|
755
702
|
const event = { content: result.content, input: safeInput, toolName };
|
|
756
703
|
let compressed;
|
|
757
|
-
const config = DEFAULT_COMPRESSOR_CONFIG;
|
|
704
|
+
const config = ctx ? resolveCompressorConfig(ctx) : DEFAULT_COMPRESSOR_CONFIG;
|
|
758
705
|
if (toolName === "read")
|
|
759
706
|
compressed = compressReadOutput(event, config);
|
|
760
707
|
else if (toolName === "bash")
|
|
761
708
|
compressed = compressBashOutput(event, config);
|
|
762
|
-
else if (toolName === "ls")
|
|
763
|
-
compressed = compressLsOutput(event, config);
|
|
764
|
-
else if (toolName === "grep")
|
|
765
|
-
compressed = compressGrepOutput(event, config);
|
|
766
709
|
if (!compressed || compressed === text)
|
|
767
710
|
return undefined;
|
|
768
711
|
const compressedContent = result.content.map((part) => part.type === "text" ? { type: "text", text: part.text ?? "" } : part.type === "image" && part.data && part.mimeType ? { type: "image", data: part.data, mimeType: part.mimeType } : undefined).filter((part) => part !== undefined && part.type !== "text");
|
|
@@ -792,24 +735,6 @@ export function registerToolOutputCompressor(ext, runtime) {
|
|
|
792
735
|
const compressed = compressBashOutput(event, config);
|
|
793
736
|
return compressedContentResult(runtime, event, "bash", original, compressed);
|
|
794
737
|
}
|
|
795
|
-
if (_event.toolName === "ls") {
|
|
796
|
-
const event = _event;
|
|
797
|
-
const original = event.content
|
|
798
|
-
.filter((c) => c.type === "text")
|
|
799
|
-
.map((c) => c.text)
|
|
800
|
-
.join("\n");
|
|
801
|
-
const compressed = compressLsOutput(event, config);
|
|
802
|
-
return compressedContentResult(runtime, event, "ls", original, compressed);
|
|
803
|
-
}
|
|
804
|
-
if (_event.toolName === "grep") {
|
|
805
|
-
const event = _event;
|
|
806
|
-
const original = event.content
|
|
807
|
-
.filter((c) => c.type === "text")
|
|
808
|
-
.map((c) => c.text)
|
|
809
|
-
.join("\n");
|
|
810
|
-
const compressed = compressGrepOutput(event, config);
|
|
811
|
-
return compressedContentResult(runtime, event, "grep", original, compressed);
|
|
812
|
-
}
|
|
813
738
|
// Unknown tool types: do nothing
|
|
814
739
|
return;
|
|
815
740
|
});
|
|
@@ -28,13 +28,13 @@ export const DEFAULT_COMPACTION_POLICY = {
|
|
|
28
28
|
},
|
|
29
29
|
toolOutputCompressor: {
|
|
30
30
|
enabled: true,
|
|
31
|
-
maxResultChars:
|
|
32
|
-
maxReadLines:
|
|
33
|
-
maxLsLines:
|
|
34
|
-
maxSearchLines:
|
|
31
|
+
maxResultChars: 24_000,
|
|
32
|
+
maxReadLines: 1_500,
|
|
33
|
+
maxLsLines: 300,
|
|
34
|
+
maxSearchLines: 600,
|
|
35
35
|
stripAnsi: true,
|
|
36
|
-
stripComments:
|
|
37
|
-
testFailuresOnly:
|
|
36
|
+
stripComments: false,
|
|
37
|
+
testFailuresOnly: false,
|
|
38
38
|
compactGit: true,
|
|
39
39
|
},
|
|
40
40
|
truncationContinuation: {
|
|
@@ -6,7 +6,7 @@ export type { SourceInfo } from "../source-info.js";
|
|
|
6
6
|
export { createExtensionRuntime, discoverAndLoadExtensions, loadExtensionFromFactory, loadExtensions, } from "./loader.js";
|
|
7
7
|
export type { ExtensionErrorListener, ForkHandler, NavigateTreeHandler, NewSessionHandler, ShutdownHandler, SwitchSessionHandler, } from "./runner.js";
|
|
8
8
|
export { ExtensionRunner } from "./runner.js";
|
|
9
|
-
export type { AfterProviderResponseEvent, AgentEndEvent, AgentStartEvent, AgentToolResult, AgentToolUpdateCallback, BashToolCallEvent, BashToolResultEvent, BeforeAgentStartEvent, BeforeAgentStartEventResult, BeforeProviderRequestEvent, BeforeProviderRequestEventResult, BuildSystemPromptOptions, CompactOptions, ContextEvent, ContextEventResult, ContextUsage, CustomToolCallEvent, CustomToolResultEvent,
|
|
10
|
-
export { defineTool, isBashToolResult,
|
|
9
|
+
export type { AfterProviderResponseEvent, AgentEndEvent, AgentStartEvent, AgentToolResult, AgentToolUpdateCallback, BashToolCallEvent, BashToolResultEvent, BeforeAgentStartEvent, BeforeAgentStartEventResult, BeforeProviderRequestEvent, BeforeProviderRequestEventResult, BuildSystemPromptOptions, CompactOptions, ContextEvent, ContextEventResult, ContextUsage, CustomToolCallEvent, CustomToolResultEvent, ExecOptions, ExecResult, Extension, ExtensionActions, ExtensionAPI, ExtensionCommandContext, ExtensionCommandContextActions, ExtensionContext, ExtensionContextActions, ExtensionError, ExtensionEvent, ExtensionFactory, ExtensionFlag, ExtensionHandler, ExtensionRuntime, ExtensionShortcut, ExtensionUIContext, GetActiveToolsHandler, GetAllToolsHandler, GetCommandsHandler, GetThinkingLevelHandler, InputEvent, InputEventResult, InputSource, LoadExtensionsResult, MessageEndEvent, MessageStartEvent, MessageUpdateEvent, ModelSelectEvent, ModelSelectSource, ProviderConfig, ProviderModelConfig, ReadToolCallEvent, ReadToolResultEvent, RegisteredCommand, RegisteredTool, ReplacedSessionContext, ResolvedCommand, ResourcesDiscoverEvent, ResourcesDiscoverResult, SendMessageHandler, SendUserMessageHandler, SessionBeforeCompactEvent, SessionBeforeCompactResult, SessionBeforeForkEvent, SessionBeforeForkResult, SessionBeforeSwitchEvent, SessionBeforeSwitchResult, SessionBeforeTreeEvent, SessionBeforeTreeResult, SessionCompactEvent, SessionEvent, SessionShutdownEvent, SessionStartEvent, SessionTreeEvent, SetActiveToolsHandler, SetLabelHandler, SetModelHandler, SetThinkingLevelHandler, ToolCallEvent, ToolCallEventResult, ToolDefinition, ToolExecutionEndEvent, ToolExecutionMode, ToolExecutionStartEvent, ToolExecutionUpdateEvent, ToolInfo, ToolResultEvent, ToolResultEventResult, TreePreparation, TurnEndEvent, TurnStartEvent, UserBashEvent, UserBashEventResult, } from "./types.js";
|
|
10
|
+
export { defineTool, isBashToolResult, isReadToolResult, isToolCallEventType, } from "./types.js";
|
|
11
11
|
export { wrapRegisteredTool, wrapRegisteredTools } from "./wrapper.js";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/sdk/coding-agent/core/extensions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACjF,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACN,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EACX,sBAAsB,EACtB,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EACX,0BAA0B,EAC1B,aAAa,EACb,eAAe,EAEf,eAAe,EACf,uBAAuB,EAEvB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,0BAA0B,EAC1B,gCAAgC,EAChC,wBAAwB,EAExB,cAAc,EAEd,YAAY,EAEZ,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/sdk/coding-agent/core/extensions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACjF,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACN,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EACX,sBAAsB,EACtB,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EACX,0BAA0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,mBAAmB,GACnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACN,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
export { createExtensionRuntime, discoverAndLoadExtensions, loadExtensionFromFactory, loadExtensions, } from "./loader.js";
|
|
5
5
|
export { ExtensionRunner } from "./runner.js";
|
|
6
6
|
// Type guards
|
|
7
|
-
export { defineTool, isBashToolResult,
|
|
7
|
+
export { defineTool, isBashToolResult, isReadToolResult, isToolCallEventType, } from "./types.js";
|
|
8
8
|
export { wrapRegisteredTool, wrapRegisteredTools } from "./wrapper.js";
|
|
@@ -73,8 +73,7 @@ import type { SourceInfo } from "../source-info.js";
|
|
|
73
73
|
import type { SettingsManager } from "../settings-manager.js";
|
|
74
74
|
import type { BuildSystemPromptOptions } from "../system-prompt.js";
|
|
75
75
|
import type { BashOperations } from "../tools/bash.js";
|
|
76
|
-
import type {
|
|
77
|
-
import type { BashToolDetails, BashToolInput, EditToolInput, GrepToolDetails, GrepToolInput, LsToolDetails, LsToolInput, ReadToolDetails, ReadToolInput, WriteToolInput } from "../tools/index.js";
|
|
76
|
+
import type { BashToolDetails, BashToolInput, ReadToolDetails, ReadToolInput } from "../tools/index.js";
|
|
78
77
|
export type { ExecOptions, ExecResult } from "../exec.js";
|
|
79
78
|
export type { BuildSystemPromptOptions } from "../system-prompt.js";
|
|
80
79
|
export type { AgentToolResult, AgentToolUpdateCallback, ToolExecutionMode };
|
|
@@ -627,22 +626,6 @@ export interface ReadToolCallEvent extends ToolCallEventBase {
|
|
|
627
626
|
toolName: "read";
|
|
628
627
|
input: ReadToolInput;
|
|
629
628
|
}
|
|
630
|
-
export interface EditToolCallEvent extends ToolCallEventBase {
|
|
631
|
-
toolName: "edit";
|
|
632
|
-
input: EditToolInput;
|
|
633
|
-
}
|
|
634
|
-
export interface WriteToolCallEvent extends ToolCallEventBase {
|
|
635
|
-
toolName: "write";
|
|
636
|
-
input: WriteToolInput;
|
|
637
|
-
}
|
|
638
|
-
export interface GrepToolCallEvent extends ToolCallEventBase {
|
|
639
|
-
toolName: "grep";
|
|
640
|
-
input: GrepToolInput;
|
|
641
|
-
}
|
|
642
|
-
export interface LsToolCallEvent extends ToolCallEventBase {
|
|
643
|
-
toolName: "ls";
|
|
644
|
-
input: LsToolInput;
|
|
645
|
-
}
|
|
646
629
|
export interface CustomToolCallEvent extends ToolCallEventBase {
|
|
647
630
|
toolName: string;
|
|
648
631
|
input: Record<string, unknown>;
|
|
@@ -653,7 +636,7 @@ export interface CustomToolCallEvent extends ToolCallEventBase {
|
|
|
653
636
|
* `event.input` is mutable. Mutate it in place to patch tool arguments before execution.
|
|
654
637
|
* Later `tool_call` handlers see earlier mutations. No re-validation is performed after mutation.
|
|
655
638
|
*/
|
|
656
|
-
export type ToolCallEvent = BashToolCallEvent | ReadToolCallEvent |
|
|
639
|
+
export type ToolCallEvent = BashToolCallEvent | ReadToolCallEvent | CustomToolCallEvent;
|
|
657
640
|
interface ToolResultEventBase {
|
|
658
641
|
type: "tool_result";
|
|
659
642
|
toolCallId: string;
|
|
@@ -669,34 +652,14 @@ export interface ReadToolResultEvent extends ToolResultEventBase {
|
|
|
669
652
|
toolName: "read";
|
|
670
653
|
details: ReadToolDetails | undefined;
|
|
671
654
|
}
|
|
672
|
-
export interface EditToolResultEvent extends ToolResultEventBase {
|
|
673
|
-
toolName: "edit";
|
|
674
|
-
details: EditToolDetails | undefined;
|
|
675
|
-
}
|
|
676
|
-
export interface WriteToolResultEvent extends ToolResultEventBase {
|
|
677
|
-
toolName: "write";
|
|
678
|
-
details: undefined;
|
|
679
|
-
}
|
|
680
|
-
export interface GrepToolResultEvent extends ToolResultEventBase {
|
|
681
|
-
toolName: "grep";
|
|
682
|
-
details: GrepToolDetails | undefined;
|
|
683
|
-
}
|
|
684
|
-
export interface LsToolResultEvent extends ToolResultEventBase {
|
|
685
|
-
toolName: "ls";
|
|
686
|
-
details: LsToolDetails | undefined;
|
|
687
|
-
}
|
|
688
655
|
export interface CustomToolResultEvent extends ToolResultEventBase {
|
|
689
656
|
toolName: string;
|
|
690
657
|
details: unknown;
|
|
691
658
|
}
|
|
692
659
|
/** Fired after a tool executes. Can modify result. */
|
|
693
|
-
export type ToolResultEvent = BashToolResultEvent | ReadToolResultEvent |
|
|
660
|
+
export type ToolResultEvent = BashToolResultEvent | ReadToolResultEvent | CustomToolResultEvent;
|
|
694
661
|
export declare function isBashToolResult(e: ToolResultEvent): e is BashToolResultEvent;
|
|
695
662
|
export declare function isReadToolResult(e: ToolResultEvent): e is ReadToolResultEvent;
|
|
696
|
-
export declare function isEditToolResult(e: ToolResultEvent): e is EditToolResultEvent;
|
|
697
|
-
export declare function isWriteToolResult(e: ToolResultEvent): e is WriteToolResultEvent;
|
|
698
|
-
export declare function isGrepToolResult(e: ToolResultEvent): e is GrepToolResultEvent;
|
|
699
|
-
export declare function isLsToolResult(e: ToolResultEvent): e is LsToolResultEvent;
|
|
700
663
|
/**
|
|
701
664
|
* Type guard for narrowing ToolCallEvent by tool name.
|
|
702
665
|
*
|
|
@@ -719,10 +682,6 @@ export declare function isLsToolResult(e: ToolResultEvent): e is LsToolResultEve
|
|
|
719
682
|
*/
|
|
720
683
|
export declare function isToolCallEventType(toolName: "bash", event: ToolCallEvent): event is BashToolCallEvent;
|
|
721
684
|
export declare function isToolCallEventType(toolName: "read", event: ToolCallEvent): event is ReadToolCallEvent;
|
|
722
|
-
export declare function isToolCallEventType(toolName: "edit", event: ToolCallEvent): event is EditToolCallEvent;
|
|
723
|
-
export declare function isToolCallEventType(toolName: "write", event: ToolCallEvent): event is WriteToolCallEvent;
|
|
724
|
-
export declare function isToolCallEventType(toolName: "grep", event: ToolCallEvent): event is GrepToolCallEvent;
|
|
725
|
-
export declare function isToolCallEventType(toolName: "ls", event: ToolCallEvent): event is LsToolCallEvent;
|
|
726
685
|
export declare function isToolCallEventType<TName extends string, TInput extends Record<string, unknown>>(toolName: TName, event: ToolCallEvent): event is ToolCallEvent & {
|
|
727
686
|
toolName: TName;
|
|
728
687
|
input: TInput;
|