indusagi 0.12.6 → 0.12.7
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 +1 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -0
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/tools/bash.d.ts +45 -0
- package/dist/agent/tools/bash.d.ts.map +1 -0
- package/dist/agent/tools/bash.js +227 -0
- package/dist/agent/tools/bash.js.map +1 -0
- package/dist/agent/tools/edit-diff.d.ts +63 -0
- package/dist/agent/tools/edit-diff.d.ts.map +1 -0
- package/dist/agent/tools/edit-diff.js +241 -0
- package/dist/agent/tools/edit-diff.js.map +1 -0
- package/dist/agent/tools/edit.d.ts +37 -0
- package/dist/agent/tools/edit.d.ts.map +1 -0
- package/dist/agent/tools/edit.js +146 -0
- package/dist/agent/tools/edit.js.map +1 -0
- package/dist/agent/tools/find.d.ts +24 -0
- package/dist/agent/tools/find.d.ts.map +1 -0
- package/dist/agent/tools/find.js +132 -0
- package/dist/agent/tools/find.js.map +1 -0
- package/dist/agent/tools/grep.d.ts +43 -0
- package/dist/agent/tools/grep.d.ts.map +1 -0
- package/dist/agent/tools/grep.js +178 -0
- package/dist/agent/tools/grep.js.map +1 -0
- package/dist/agent/tools/index.d.ts +158 -0
- package/dist/agent/tools/index.d.ts.map +1 -0
- package/dist/agent/tools/index.js +128 -0
- package/dist/agent/tools/index.js.map +1 -0
- package/dist/agent/tools/ls.d.ts +38 -0
- package/dist/agent/tools/ls.d.ts.map +1 -0
- package/dist/agent/tools/ls.js +118 -0
- package/dist/agent/tools/ls.js.map +1 -0
- package/dist/agent/tools/path-utils.d.ts +8 -0
- package/dist/agent/tools/path-utils.d.ts.map +1 -0
- package/dist/agent/tools/path-utils.js +53 -0
- package/dist/agent/tools/path-utils.js.map +1 -0
- package/dist/agent/tools/read.d.ts +37 -0
- package/dist/agent/tools/read.d.ts.map +1 -0
- package/dist/agent/tools/read.js +168 -0
- package/dist/agent/tools/read.js.map +1 -0
- package/dist/agent/tools/task.d.ts +26 -0
- package/dist/agent/tools/task.d.ts.map +1 -0
- package/dist/agent/tools/task.js +30 -0
- package/dist/agent/tools/task.js.map +1 -0
- package/dist/agent/tools/todo-store.d.ts +20 -0
- package/dist/agent/tools/todo-store.d.ts.map +1 -0
- package/dist/agent/tools/todo-store.js +24 -0
- package/dist/agent/tools/todo-store.js.map +1 -0
- package/dist/agent/tools/todo.d.ts +26 -0
- package/dist/agent/tools/todo.d.ts.map +1 -0
- package/dist/agent/tools/todo.js +52 -0
- package/dist/agent/tools/todo.js.map +1 -0
- package/dist/agent/tools/truncate.d.ts +70 -0
- package/dist/agent/tools/truncate.d.ts.map +1 -0
- package/dist/agent/tools/truncate.js +205 -0
- package/dist/agent/tools/truncate.js.map +1 -0
- package/dist/agent/tools/utils/hook-runner.d.ts +9 -0
- package/dist/agent/tools/utils/hook-runner.d.ts.map +1 -0
- package/dist/agent/tools/utils/hook-runner.js +14 -0
- package/dist/agent/tools/utils/hook-runner.js.map +1 -0
- package/dist/agent/tools/utils/image-resize.d.ts +32 -0
- package/dist/agent/tools/utils/image-resize.d.ts.map +1 -0
- package/dist/agent/tools/utils/image-resize.js +42 -0
- package/dist/agent/tools/utils/image-resize.js.map +1 -0
- package/dist/agent/tools/utils/mime.d.ts +10 -0
- package/dist/agent/tools/utils/mime.d.ts.map +1 -0
- package/dist/agent/tools/utils/mime.js +48 -0
- package/dist/agent/tools/utils/mime.js.map +1 -0
- package/dist/agent/tools/utils/shell.d.ts +30 -0
- package/dist/agent/tools/utils/shell.d.ts.map +1 -0
- package/dist/agent/tools/utils/shell.js +137 -0
- package/dist/agent/tools/utils/shell.js.map +1 -0
- package/dist/agent/tools/webfetch.d.ts +34 -0
- package/dist/agent/tools/webfetch.d.ts.map +1 -0
- package/dist/agent/tools/webfetch.js +244 -0
- package/dist/agent/tools/webfetch.js.map +1 -0
- package/dist/agent/tools/websearch.d.ts +29 -0
- package/dist/agent/tools/websearch.d.ts.map +1 -0
- package/dist/agent/tools/websearch.js +69 -0
- package/dist/agent/tools/websearch.js.map +1 -0
- package/dist/agent/tools/write.d.ts +27 -0
- package/dist/agent/tools/write.d.ts.map +1 -0
- package/dist/agent/tools/write.js +78 -0
- package/dist/agent/tools/write.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { constants } from "fs";
|
|
3
|
+
import { access as fsAccess, readFile as fsReadFile } from "fs/promises";
|
|
4
|
+
import { formatDimensionNote, resizeImage } from "./utils/image-resize.js";
|
|
5
|
+
import { detectSupportedImageMimeTypeFromFile } from "./utils/mime.js";
|
|
6
|
+
import { resolveReadPath } from "./path-utils.js";
|
|
7
|
+
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead, } from "./truncate.js";
|
|
8
|
+
const readSchema = Type.Object({
|
|
9
|
+
path: Type.String({ description: "Path to the file to read (relative or absolute)" }),
|
|
10
|
+
offset: Type.Optional(Type.Number({ description: "Line number to start reading from (1-indexed)" })),
|
|
11
|
+
limit: Type.Optional(Type.Number({ description: "Maximum number of lines to read" })),
|
|
12
|
+
});
|
|
13
|
+
const defaultReadOperations = {
|
|
14
|
+
readFile: (path) => fsReadFile(path),
|
|
15
|
+
access: (path) => fsAccess(path, constants.R_OK),
|
|
16
|
+
detectImageMimeType: detectSupportedImageMimeTypeFromFile,
|
|
17
|
+
};
|
|
18
|
+
export function createReadTool(cwd, options) {
|
|
19
|
+
const autoResizeImages = options?.autoResizeImages ?? true;
|
|
20
|
+
const ops = options?.operations ?? defaultReadOperations;
|
|
21
|
+
return {
|
|
22
|
+
name: "read",
|
|
23
|
+
label: "read",
|
|
24
|
+
description: `Read the contents of a file. Supports text files and images (jpg, png, gif, webp). Images are sent as attachments. For text files, output is truncated to ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.`,
|
|
25
|
+
parameters: readSchema,
|
|
26
|
+
execute: async (_toolCallId, { path, offset, limit }, signal) => {
|
|
27
|
+
const absolutePath = resolveReadPath(path, cwd);
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
// Check if already aborted
|
|
30
|
+
if (signal?.aborted) {
|
|
31
|
+
reject(new Error("Operation aborted"));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let aborted = false;
|
|
35
|
+
// Set up abort handler
|
|
36
|
+
const onAbort = () => {
|
|
37
|
+
aborted = true;
|
|
38
|
+
reject(new Error("Operation aborted"));
|
|
39
|
+
};
|
|
40
|
+
if (signal) {
|
|
41
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
42
|
+
}
|
|
43
|
+
// Perform the read operation
|
|
44
|
+
(async () => {
|
|
45
|
+
try {
|
|
46
|
+
// Check if file exists
|
|
47
|
+
await ops.access(absolutePath);
|
|
48
|
+
// Check if aborted before reading
|
|
49
|
+
if (aborted) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const mimeType = ops.detectImageMimeType
|
|
53
|
+
? await ops.detectImageMimeType(absolutePath)
|
|
54
|
+
: undefined;
|
|
55
|
+
// Read the file based on type
|
|
56
|
+
let content;
|
|
57
|
+
let details;
|
|
58
|
+
if (mimeType) {
|
|
59
|
+
// Read as image (binary)
|
|
60
|
+
const buffer = await ops.readFile(absolutePath);
|
|
61
|
+
const base64 = buffer.toString("base64");
|
|
62
|
+
if (autoResizeImages) {
|
|
63
|
+
// Resize image if needed
|
|
64
|
+
const resized = await resizeImage({ type: "image", data: base64, mimeType });
|
|
65
|
+
const dimensionNote = formatDimensionNote(resized);
|
|
66
|
+
let textNote = `Read image file [${resized.mimeType}]`;
|
|
67
|
+
if (dimensionNote) {
|
|
68
|
+
textNote += `\n${dimensionNote}`;
|
|
69
|
+
}
|
|
70
|
+
content = [
|
|
71
|
+
{ type: "text", text: textNote },
|
|
72
|
+
{ type: "image", data: resized.data, mimeType: resized.mimeType },
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const textNote = `Read image file [${mimeType}]`;
|
|
77
|
+
content = [
|
|
78
|
+
{ type: "text", text: textNote },
|
|
79
|
+
{ type: "image", data: base64, mimeType },
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Read as text
|
|
85
|
+
const buffer = await ops.readFile(absolutePath);
|
|
86
|
+
const textContent = buffer.toString("utf-8");
|
|
87
|
+
const allLines = textContent.split("\n");
|
|
88
|
+
const totalFileLines = allLines.length;
|
|
89
|
+
// Apply offset if specified (1-indexed to 0-indexed)
|
|
90
|
+
const startLine = offset ? Math.max(0, offset - 1) : 0;
|
|
91
|
+
const startLineDisplay = startLine + 1; // For display (1-indexed)
|
|
92
|
+
// Check if offset is out of bounds
|
|
93
|
+
if (startLine >= allLines.length) {
|
|
94
|
+
throw new Error(`Offset ${offset} is beyond end of file (${allLines.length} lines total)`);
|
|
95
|
+
}
|
|
96
|
+
// If limit is specified by user, use it; otherwise we'll let truncateHead decide
|
|
97
|
+
let selectedContent;
|
|
98
|
+
let userLimitedLines;
|
|
99
|
+
if (limit !== undefined) {
|
|
100
|
+
const endLine = Math.min(startLine + limit, allLines.length);
|
|
101
|
+
selectedContent = allLines.slice(startLine, endLine).join("\n");
|
|
102
|
+
userLimitedLines = endLine - startLine;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
selectedContent = allLines.slice(startLine).join("\n");
|
|
106
|
+
}
|
|
107
|
+
// Apply truncation (respects both line and byte limits)
|
|
108
|
+
const truncation = truncateHead(selectedContent);
|
|
109
|
+
let outputText;
|
|
110
|
+
if (truncation.firstLineExceedsLimit) {
|
|
111
|
+
// First line at offset exceeds 30KB - tell model to use bash
|
|
112
|
+
const firstLineSize = formatSize(Buffer.byteLength(allLines[startLine], "utf-8"));
|
|
113
|
+
outputText = `[Line ${startLineDisplay} is ${firstLineSize}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${path} | head -c ${DEFAULT_MAX_BYTES}]`;
|
|
114
|
+
details = { truncation };
|
|
115
|
+
}
|
|
116
|
+
else if (truncation.truncated) {
|
|
117
|
+
// Truncation occurred - build actionable notice
|
|
118
|
+
const endLineDisplay = startLineDisplay + truncation.outputLines - 1;
|
|
119
|
+
const nextOffset = endLineDisplay + 1;
|
|
120
|
+
outputText = truncation.content;
|
|
121
|
+
if (truncation.truncatedBy === "lines") {
|
|
122
|
+
outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines}. Use offset=${nextOffset} to continue.]`;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue.]`;
|
|
126
|
+
}
|
|
127
|
+
details = { truncation };
|
|
128
|
+
}
|
|
129
|
+
else if (userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {
|
|
130
|
+
// User specified limit, there's more content, but no truncation
|
|
131
|
+
const remaining = allLines.length - (startLine + userLimitedLines);
|
|
132
|
+
const nextOffset = startLine + userLimitedLines + 1;
|
|
133
|
+
outputText = truncation.content;
|
|
134
|
+
outputText += `\n\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// No truncation, no user limit exceeded
|
|
138
|
+
outputText = truncation.content;
|
|
139
|
+
}
|
|
140
|
+
content = [{ type: "text", text: outputText }];
|
|
141
|
+
}
|
|
142
|
+
// Check if aborted after reading
|
|
143
|
+
if (aborted) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
// Clean up abort handler
|
|
147
|
+
if (signal) {
|
|
148
|
+
signal.removeEventListener("abort", onAbort);
|
|
149
|
+
}
|
|
150
|
+
resolve({ content, details });
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
// Clean up abort handler
|
|
154
|
+
if (signal) {
|
|
155
|
+
signal.removeEventListener("abort", onAbort);
|
|
156
|
+
}
|
|
157
|
+
if (!aborted) {
|
|
158
|
+
reject(error);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
})();
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/** Default read tool using process.cwd() - for backwards compatibility */
|
|
167
|
+
export const readTool = createReadTool(process.cwd());
|
|
168
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/agent/tools/read.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,oCAAoC,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAEV,YAAY,GACZ,MAAM,eAAe,CAAC;AAEvB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,iDAAiD,EAAE,CAAC;IACrF,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,+CAA+C,EAAE,CAAC,CAAC;IACpG,KAAK,EAAE,I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,CAAC,OAAO,EAAE,CAAC;4BACd,MAAM,CAAC,KAAK,CAAC,CAAC;wBACf,CAAC;oBACF,CAAC;gBACF,CAAC,CAAC,EAAE,CAAC;YACN,CAAC,CACD,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AgentTool } from "../types.js";
|
|
2
|
+
declare const taskSchema: import("@sinclair/typebox").TObject<{
|
|
3
|
+
description: import("@sinclair/typebox").TString;
|
|
4
|
+
prompt: import("@sinclair/typebox").TString;
|
|
5
|
+
subagent_type: import("@sinclair/typebox").TString;
|
|
6
|
+
task_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
7
|
+
}>;
|
|
8
|
+
export interface TaskToolDetails {
|
|
9
|
+
description: string;
|
|
10
|
+
prompt: string;
|
|
11
|
+
subagentType: string;
|
|
12
|
+
taskId?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface TaskToolOptions {
|
|
15
|
+
/** Custom options for task execution */
|
|
16
|
+
cwd?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function createTaskTool(options?: TaskToolOptions): AgentTool<typeof taskSchema, TaskToolDetails>;
|
|
19
|
+
export declare const taskTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
20
|
+
description: import("@sinclair/typebox").TString;
|
|
21
|
+
prompt: import("@sinclair/typebox").TString;
|
|
22
|
+
subagent_type: import("@sinclair/typebox").TString;
|
|
23
|
+
task_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
24
|
+
}>, TaskToolDetails>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,QAAA,MAAM,UAAU;;;;;EAUd,CAAC;AAEH,MAAM,WAAW,eAAe;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC/B,wCAAwC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,EAAE,eAAe,CAAC,CA4BvG;AAED,eAAO,MAAM,QAAQ;;;;;oBAAmB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
const taskSchema = Type.Object({
|
|
3
|
+
description: Type.String({ description: "A short (3-5 words) description of task" }),
|
|
4
|
+
prompt: Type.String({ description: "The task for subagent to perform" }),
|
|
5
|
+
subagent_type: Type.String({ description: "The type of specialized subagent to use for this task" }),
|
|
6
|
+
task_id: Type.Optional(Type.String({
|
|
7
|
+
description: "Only set to resume a previous task. The task will continue in the same subagent session as before.",
|
|
8
|
+
})),
|
|
9
|
+
});
|
|
10
|
+
export function createTaskTool(options) {
|
|
11
|
+
return {
|
|
12
|
+
name: "task",
|
|
13
|
+
label: "task",
|
|
14
|
+
description: "Launch a subagent to handle complex or multi-step work autonomously. When using this tool, provide a clear description, a detailed prompt, and subagent_type. Use task_id to resume a previous task.",
|
|
15
|
+
parameters: taskSchema,
|
|
16
|
+
execute: async (_toolCallId, { description, prompt, subagent_type, task_id }) => {
|
|
17
|
+
// This is a simplified version. The full implementation would:
|
|
18
|
+
// 1. Create or resume a subagent session
|
|
19
|
+
// 2. Run the prompt through the subagent
|
|
20
|
+
// 3. Return the output
|
|
21
|
+
const output = `Task: ${description}\n${prompt}`;
|
|
22
|
+
return {
|
|
23
|
+
content: [{ type: "text", text: output }],
|
|
24
|
+
details: { description, prompt, subagentType: subagent_type, taskId: task_id },
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export const taskTool = createTaskTool();
|
|
30
|
+
//# sourceMappingURL=task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../../src/agent/tools/task.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;IACpF,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;IACxE,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,uDAAuD,EAAE,CAAC;IACpG,OAAO,EAAE,IAAI,CAAC,QAAQ,CACrB,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EACV,oGAAoG;KACrG,CAAC,CACF;CACD,CAAC,CAAC;AAcH,MAAM,UAAU,cAAc,CAAC,OAAyB;IACvD,OAAO;QACN,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM;QACb,WAAW,EACV,sMAAsM;QACvM,UAAU,EAAE,UAAU;QACtB,OAAO,EAAE,KAAK,EACb,WAAW,EACX,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAK5C,EACA,EAAE;YACH,+DAA+D;YAC/D,yCAAyC;YACzC,yCAAyC;YACzC,uBAAuB;YAEvB,MAAM,MAAM,GAAG,SAAS,WAAW,KAAK,MAAM,EAAE,CAAC;YACjD,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gBACzC,OAAO,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE;aAC9E,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple Todo Store for the todo tool.
|
|
3
|
+
* Simplified version for indusagi agent framework.
|
|
4
|
+
*/
|
|
5
|
+
export declare const TODO_STATUSES: readonly ["pending", "in_progress", "completed", "cancelled"];
|
|
6
|
+
export type TodoStatus = (typeof TODO_STATUSES)[number];
|
|
7
|
+
export declare const TODO_PRIORITIES: readonly ["high", "medium", "low"];
|
|
8
|
+
export type TodoPriority = (typeof TODO_PRIORITIES)[number];
|
|
9
|
+
export interface TodoItem {
|
|
10
|
+
content: string;
|
|
11
|
+
status: TodoStatus;
|
|
12
|
+
priority: TodoPriority;
|
|
13
|
+
}
|
|
14
|
+
export declare class TodoStore {
|
|
15
|
+
private todos;
|
|
16
|
+
constructor(initialTodos?: TodoItem[]);
|
|
17
|
+
getTodos(): TodoItem[];
|
|
18
|
+
setTodos(todos: TodoItem[]): void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=todo-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo-store.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/todo-store.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,aAAa,+DAAgE,CAAC;AAC3F,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD,eAAO,MAAM,eAAe,oCAAqC,CAAC;AAClE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5D,MAAM,WAAW,QAAQ;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,YAAY,CAAC;CACvB;AAMD,qBAAa,SAAS;IACrB,OAAO,CAAC,KAAK,CAAkB;gBAEnB,YAAY,CAAC,EAAE,QAAQ,EAAE;IAMrC,QAAQ,IAAI,QAAQ,EAAE;IAItB,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI;CAGjC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple Todo Store for the todo tool.
|
|
3
|
+
* Simplified version for indusagi agent framework.
|
|
4
|
+
*/
|
|
5
|
+
export const TODO_STATUSES = ["pending", "in_progress", "completed", "cancelled"];
|
|
6
|
+
export const TODO_PRIORITIES = ["high", "medium", "low"];
|
|
7
|
+
function cloneTodos(todos) {
|
|
8
|
+
return todos.map((todo) => ({ ...todo }));
|
|
9
|
+
}
|
|
10
|
+
export class TodoStore {
|
|
11
|
+
constructor(initialTodos) {
|
|
12
|
+
this.todos = [];
|
|
13
|
+
if (initialTodos) {
|
|
14
|
+
this.todos = cloneTodos(initialTodos);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
getTodos() {
|
|
18
|
+
return cloneTodos(this.todos);
|
|
19
|
+
}
|
|
20
|
+
setTodos(todos) {
|
|
21
|
+
this.todos = cloneTodos(todos);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=todo-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo-store.js","sourceRoot":"","sources":["../../../src/agent/tools/todo-store.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,CAAU,CAAC;AAG3F,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAU,CAAC;AASlE,SAAS,UAAU,CAAC,KAAiB;IACpC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,OAAO,SAAS;IAGrB,YAAY,YAAyB;QAF7B,UAAK,GAAe,EAAE,CAAC;QAG9B,IAAI,YAAY,EAAE,CAAC;YAClB,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;QACvC,CAAC;IACF,CAAC;IAED,QAAQ;QACP,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,QAAQ,CAAC,KAAiB;QACzB,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AgentTool } from "../types.js";
|
|
2
|
+
import { TodoStore, type TodoItem } from "./todo-store.js";
|
|
3
|
+
declare const TodoReadSchema: import("@sinclair/typebox").TObject<{}>;
|
|
4
|
+
declare const TodoWriteSchema: import("@sinclair/typebox").TObject<{
|
|
5
|
+
todos: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
6
|
+
content: import("@sinclair/typebox").TString;
|
|
7
|
+
status: import("@sinclair/typebox").TUnsafe<"in_progress" | "completed" | "cancelled" | "pending">;
|
|
8
|
+
priority: import("@sinclair/typebox").TUnsafe<"low" | "medium" | "high">;
|
|
9
|
+
}>>;
|
|
10
|
+
}>;
|
|
11
|
+
export interface TodoToolDetails {
|
|
12
|
+
todos: TodoItem[];
|
|
13
|
+
incompleteCount: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function createTodoReadTool(store: TodoStore): AgentTool<typeof TodoReadSchema, TodoToolDetails>;
|
|
16
|
+
export declare function createTodoWriteTool(store: TodoStore): AgentTool<typeof TodoWriteSchema, TodoToolDetails>;
|
|
17
|
+
export declare const todoReadTool: AgentTool<import("@sinclair/typebox").TObject<{}>, TodoToolDetails>;
|
|
18
|
+
export declare const todoWriteTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
19
|
+
todos: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
20
|
+
content: import("@sinclair/typebox").TString;
|
|
21
|
+
status: import("@sinclair/typebox").TUnsafe<"in_progress" | "completed" | "cancelled" | "pending">;
|
|
22
|
+
priority: import("@sinclair/typebox").TUnsafe<"low" | "medium" | "high">;
|
|
23
|
+
}>>;
|
|
24
|
+
}>, TodoToolDetails>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=todo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/todo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAQ3D,QAAA,MAAM,cAAc,yCAAkB,CAAC;AACvC,QAAA,MAAM,eAAe;;;;;;EAEnB,CAAC;AAEH,MAAM,WAAW,eAAe;IAC/B,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACxB;AAUD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC,OAAO,cAAc,EAAE,eAAe,CAAC,CActG;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC,OAAO,eAAe,EAAE,eAAe,CAAC,CAexG;AAID,eAAO,MAAM,YAAY,qEAAmC,CAAC;AAC7D,eAAO,MAAM,aAAa;;;;;;oBAAoC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { StringEnum } from "../../ai/index.js";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { TodoStore } from "./todo-store.js";
|
|
4
|
+
const TodoItemSchema = Type.Object({
|
|
5
|
+
content: Type.String({ description: "Brief description of task" }),
|
|
6
|
+
status: StringEnum(["pending", "in_progress", "completed", "cancelled"]),
|
|
7
|
+
priority: StringEnum(["high", "medium", "low"]),
|
|
8
|
+
});
|
|
9
|
+
const TodoReadSchema = Type.Object({});
|
|
10
|
+
const TodoWriteSchema = Type.Object({
|
|
11
|
+
todos: Type.Array(TodoItemSchema, { description: "The updated todo list" }),
|
|
12
|
+
});
|
|
13
|
+
function formatTodos(todos) {
|
|
14
|
+
return JSON.stringify(todos, null, 2);
|
|
15
|
+
}
|
|
16
|
+
function countIncomplete(todos) {
|
|
17
|
+
return todos.filter((todo) => todo.status !== "completed").length;
|
|
18
|
+
}
|
|
19
|
+
export function createTodoReadTool(store) {
|
|
20
|
+
return {
|
|
21
|
+
name: "todoread",
|
|
22
|
+
label: "todoread",
|
|
23
|
+
description: "Read the current todo list. Returns items with content, status, and priority.",
|
|
24
|
+
parameters: TodoReadSchema,
|
|
25
|
+
execute: async () => {
|
|
26
|
+
const todos = store.getTodos();
|
|
27
|
+
return {
|
|
28
|
+
content: [{ type: "text", text: formatTodos(todos) }],
|
|
29
|
+
details: { todos, incompleteCount: countIncomplete(todos) },
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function createTodoWriteTool(store) {
|
|
35
|
+
return {
|
|
36
|
+
name: "todowrite",
|
|
37
|
+
label: "todowrite",
|
|
38
|
+
description: "Update the todo list. Provide the full list each time with content, status, and priority fields.",
|
|
39
|
+
parameters: TodoWriteSchema,
|
|
40
|
+
execute: async (_toolCallId, { todos }) => {
|
|
41
|
+
store.setTodos(todos);
|
|
42
|
+
return {
|
|
43
|
+
content: [{ type: "text", text: formatTodos(todos) }],
|
|
44
|
+
details: { todos: store.getTodos(), incompleteCount: countIncomplete(todos) },
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const defaultStore = new TodoStore();
|
|
50
|
+
export const todoReadTool = createTodoReadTool(defaultStore);
|
|
51
|
+
export const todoWriteTool = createTodoWriteTool(defaultStore);
|
|
52
|
+
//# sourceMappingURL=todo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo.js","sourceRoot":"","sources":["../../../src/agent/tools/todo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;AAE3D,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IAClC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;IAClE,MAAM,EAAE,UAAU,CAAC,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,CAAU,CAAC;IACjF,QAAQ,EAAE,UAAU,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAU,CAAC;CACxD,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACvC,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC;IACnC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;CAC3E,CAAC,CAAC;AAOH,SAAS,WAAW,CAAC,KAAiB;IACrC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,eAAe,CAAC,KAAiB;IACzC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAA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B,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared truncation utilities for tool outputs.
|
|
3
|
+
*
|
|
4
|
+
* Truncation is based on two independent limits - whichever is hit first wins:
|
|
5
|
+
* - Line limit (default: 2000 lines)
|
|
6
|
+
* - Byte limit (default: 50KB)
|
|
7
|
+
*
|
|
8
|
+
* Never returns partial lines (except bash tail truncation edge case).
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_MAX_LINES = 2000;
|
|
11
|
+
export declare const DEFAULT_MAX_BYTES: number;
|
|
12
|
+
export declare const GREP_MAX_LINE_LENGTH = 500;
|
|
13
|
+
export interface TruncationResult {
|
|
14
|
+
/** The truncated content */
|
|
15
|
+
content: string;
|
|
16
|
+
/** Whether truncation occurred */
|
|
17
|
+
truncated: boolean;
|
|
18
|
+
/** Which limit was hit: "lines", "bytes", or null if not truncated */
|
|
19
|
+
truncatedBy: "lines" | "bytes" | null;
|
|
20
|
+
/** Total number of lines in the original content */
|
|
21
|
+
totalLines: number;
|
|
22
|
+
/** Total number of bytes in the original content */
|
|
23
|
+
totalBytes: number;
|
|
24
|
+
/** Number of complete lines in the truncated output */
|
|
25
|
+
outputLines: number;
|
|
26
|
+
/** Number of bytes in the truncated output */
|
|
27
|
+
outputBytes: number;
|
|
28
|
+
/** Whether the last line was partially truncated (only for tail truncation edge case) */
|
|
29
|
+
lastLinePartial: boolean;
|
|
30
|
+
/** Whether the first line exceeded the byte limit (for head truncation) */
|
|
31
|
+
firstLineExceedsLimit: boolean;
|
|
32
|
+
/** The max lines limit that was applied */
|
|
33
|
+
maxLines: number;
|
|
34
|
+
/** The max bytes limit that was applied */
|
|
35
|
+
maxBytes: number;
|
|
36
|
+
}
|
|
37
|
+
export interface TruncationOptions {
|
|
38
|
+
/** Maximum number of lines (default: 2000) */
|
|
39
|
+
maxLines?: number;
|
|
40
|
+
/** Maximum number of bytes (default: 50KB) */
|
|
41
|
+
maxBytes?: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Format bytes as human-readable size.
|
|
45
|
+
*/
|
|
46
|
+
export declare function formatSize(bytes: number): string;
|
|
47
|
+
/**
|
|
48
|
+
* Truncate content from the head (keep first N lines/bytes).
|
|
49
|
+
* Suitable for file reads where you want to see the beginning.
|
|
50
|
+
*
|
|
51
|
+
* Never returns partial lines. If first line exceeds byte limit,
|
|
52
|
+
* returns empty content with firstLineExceedsLimit=true.
|
|
53
|
+
*/
|
|
54
|
+
export declare function truncateHead(content: string, options?: TruncationOptions): TruncationResult;
|
|
55
|
+
/**
|
|
56
|
+
* Truncate content from the tail (keep last N lines/bytes).
|
|
57
|
+
* Suitable for bash output where you want to see the end (errors, final results).
|
|
58
|
+
*
|
|
59
|
+
* May return partial first line if the last line of original content exceeds byte limit.
|
|
60
|
+
*/
|
|
61
|
+
export declare function truncateTail(content: string, options?: TruncationOptions): TruncationResult;
|
|
62
|
+
/**
|
|
63
|
+
* Truncate a single line to max characters, adding [truncated] suffix.
|
|
64
|
+
* Used for grep match lines.
|
|
65
|
+
*/
|
|
66
|
+
export declare function truncateLine(line: string, maxChars?: number): {
|
|
67
|
+
text: string;
|
|
68
|
+
wasTruncated: boolean;
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=truncate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truncate.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/truncate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,iBAAiB,QAAY,CAAC;AAC3C,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,MAAM,WAAW,gBAAgB;IAChC,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,WAAW,EAAE,OAAO,GAA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