ai-agent-test 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -0
- package/bin/ai +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +250 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/ask_user_followup.d.ts +14 -0
- package/dist/tools/ask_user_followup.d.ts.map +1 -0
- package/dist/tools/ask_user_followup.js +21 -0
- package/dist/tools/ask_user_followup.js.map +1 -0
- package/dist/tools/bash.d.ts +21 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +31 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/compilation_check.d.ts +21 -0
- package/dist/tools/compilation_check.d.ts.map +1 -0
- package/dist/tools/compilation_check.js +39 -0
- package/dist/tools/compilation_check.js.map +1 -0
- package/dist/tools/edit.d.ts +34 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +60 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/index.d.ts +173 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +29 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/internet_search.d.ts +27 -0
- package/dist/tools/internet_search.d.ts.map +1 -0
- package/dist/tools/internet_search.js +73 -0
- package/dist/tools/internet_search.js.map +1 -0
- package/dist/tools/read.d.ts +23 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/read.js +67 -0
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/record_progress.d.ts +14 -0
- package/dist/tools/record_progress.d.ts.map +1 -0
- package/dist/tools/record_progress.js +15 -0
- package/dist/tools/record_progress.js.map +1 -0
- package/dist/tools/write.d.ts +26 -0
- package/dist/tools/write.d.ts.map +1 -0
- package/dist/tools/write.js +39 -0
- package/dist/tools/write.js.map +1 -0
- package/dist/utils/system.d.ts +4 -0
- package/dist/utils/system.d.ts.map +1 -0
- package/dist/utils/system.js +34 -0
- package/dist/utils/system.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
export declare const toolNames: {
|
|
2
|
+
readonly askUserFollowup: "ask_user_followup";
|
|
3
|
+
readonly recordProgress: "record_progress";
|
|
4
|
+
readonly bash: "bash";
|
|
5
|
+
readonly internetSearch: "internet_search";
|
|
6
|
+
readonly read: "read";
|
|
7
|
+
readonly write: "write";
|
|
8
|
+
readonly edit: "edit";
|
|
9
|
+
readonly compilationCheck: "compilation_check";
|
|
10
|
+
};
|
|
11
|
+
export declare const tools: {
|
|
12
|
+
readonly ask_user_followup: {
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: import("zod").ZodObject<{
|
|
15
|
+
question: import("zod").ZodString;
|
|
16
|
+
}, import("zod/v4/core").$strip>;
|
|
17
|
+
execute: ({ question }: {
|
|
18
|
+
question: string;
|
|
19
|
+
}) => Promise<{
|
|
20
|
+
success: boolean;
|
|
21
|
+
output: string;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
readonly record_progress: {
|
|
25
|
+
description: string;
|
|
26
|
+
inputSchema: import("zod").ZodObject<{
|
|
27
|
+
progress: import("zod").ZodNumber;
|
|
28
|
+
}, import("zod/v4/core").$strip>;
|
|
29
|
+
execute: ({ progress }: {
|
|
30
|
+
progress: number;
|
|
31
|
+
}) => Promise<{
|
|
32
|
+
success: boolean;
|
|
33
|
+
output: number;
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
readonly bash: {
|
|
37
|
+
description: string;
|
|
38
|
+
inputSchema: import("zod").ZodObject<{
|
|
39
|
+
command: import("zod").ZodString;
|
|
40
|
+
}, import("zod/v4/core").$strip>;
|
|
41
|
+
execute: ({ command }: {
|
|
42
|
+
command: string;
|
|
43
|
+
}) => Promise<{
|
|
44
|
+
success: boolean;
|
|
45
|
+
output: string;
|
|
46
|
+
error?: never;
|
|
47
|
+
stderr?: never;
|
|
48
|
+
} | {
|
|
49
|
+
success: boolean;
|
|
50
|
+
error: any;
|
|
51
|
+
stderr: any;
|
|
52
|
+
output?: never;
|
|
53
|
+
}>;
|
|
54
|
+
};
|
|
55
|
+
readonly internet_search: {
|
|
56
|
+
description: string;
|
|
57
|
+
inputSchema: import("zod").ZodObject<{
|
|
58
|
+
query: import("zod").ZodString;
|
|
59
|
+
searchCount: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
60
|
+
maxReadBodyLength: import("zod").ZodNumber;
|
|
61
|
+
}, import("zod/v4/core").$strip>;
|
|
62
|
+
execute: ({ searchCount, query, maxReadBodyLength, }: {
|
|
63
|
+
searchCount: number;
|
|
64
|
+
query: string;
|
|
65
|
+
maxReadBodyLength?: number;
|
|
66
|
+
}) => Promise<{
|
|
67
|
+
success: boolean;
|
|
68
|
+
error: string;
|
|
69
|
+
output?: never;
|
|
70
|
+
metadata?: never;
|
|
71
|
+
} | {
|
|
72
|
+
success: boolean;
|
|
73
|
+
output: string;
|
|
74
|
+
metadata: {
|
|
75
|
+
maxReadBodyLength: number | undefined;
|
|
76
|
+
};
|
|
77
|
+
error?: never;
|
|
78
|
+
}>;
|
|
79
|
+
};
|
|
80
|
+
readonly read: {
|
|
81
|
+
description: string;
|
|
82
|
+
inputSchema: import("zod").ZodObject<{
|
|
83
|
+
path: import("zod").ZodString;
|
|
84
|
+
offset: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
85
|
+
limit: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
86
|
+
}, import("zod/v4/core").$strip>;
|
|
87
|
+
execute: ({ path: filePath, offset, limit, }: {
|
|
88
|
+
path: string;
|
|
89
|
+
offset?: number;
|
|
90
|
+
limit?: number;
|
|
91
|
+
}) => Promise<{
|
|
92
|
+
success: boolean;
|
|
93
|
+
output: string;
|
|
94
|
+
error?: never;
|
|
95
|
+
} | {
|
|
96
|
+
success: boolean;
|
|
97
|
+
error: any;
|
|
98
|
+
output?: never;
|
|
99
|
+
}>;
|
|
100
|
+
};
|
|
101
|
+
readonly write: {
|
|
102
|
+
description: string;
|
|
103
|
+
inputSchema: import("zod").ZodObject<{
|
|
104
|
+
path: import("zod").ZodString;
|
|
105
|
+
content: import("zod").ZodString;
|
|
106
|
+
}, import("zod/v4/core").$strip>;
|
|
107
|
+
execute: ({ path: filePath, content, }: {
|
|
108
|
+
path: string;
|
|
109
|
+
content: string;
|
|
110
|
+
}) => Promise<{
|
|
111
|
+
success: boolean;
|
|
112
|
+
output: string;
|
|
113
|
+
metadata: {
|
|
114
|
+
path: string;
|
|
115
|
+
size: number;
|
|
116
|
+
};
|
|
117
|
+
error?: never;
|
|
118
|
+
} | {
|
|
119
|
+
success: boolean;
|
|
120
|
+
error: any;
|
|
121
|
+
output?: never;
|
|
122
|
+
metadata?: never;
|
|
123
|
+
}>;
|
|
124
|
+
};
|
|
125
|
+
readonly edit: {
|
|
126
|
+
description: string;
|
|
127
|
+
inputSchema: import("zod").ZodObject<{
|
|
128
|
+
path: import("zod").ZodString;
|
|
129
|
+
edits: import("zod").ZodArray<import("zod").ZodObject<{
|
|
130
|
+
oldText: import("zod").ZodString;
|
|
131
|
+
newText: import("zod").ZodString;
|
|
132
|
+
}, import("zod/v4/core").$strip>>;
|
|
133
|
+
}, import("zod/v4/core").$strip>;
|
|
134
|
+
execute: ({ path: filePath, edits, }: {
|
|
135
|
+
path: string;
|
|
136
|
+
edits: import("./edit.js").Edit[];
|
|
137
|
+
}) => Promise<{
|
|
138
|
+
success: boolean;
|
|
139
|
+
output: string;
|
|
140
|
+
metadata: {
|
|
141
|
+
path: string;
|
|
142
|
+
editsCount: number;
|
|
143
|
+
totalEdits: number;
|
|
144
|
+
};
|
|
145
|
+
error?: never;
|
|
146
|
+
} | {
|
|
147
|
+
success: boolean;
|
|
148
|
+
error: any;
|
|
149
|
+
output?: never;
|
|
150
|
+
metadata?: never;
|
|
151
|
+
}>;
|
|
152
|
+
};
|
|
153
|
+
readonly compilation_check: {
|
|
154
|
+
description: string;
|
|
155
|
+
inputSchema: import("zod").ZodObject<{
|
|
156
|
+
command: import("zod").ZodString;
|
|
157
|
+
}, import("zod/v4/core").$strip>;
|
|
158
|
+
execute: ({ command }: {
|
|
159
|
+
command: string;
|
|
160
|
+
}) => Promise<{
|
|
161
|
+
success: boolean;
|
|
162
|
+
output: string;
|
|
163
|
+
error?: never;
|
|
164
|
+
stderr?: never;
|
|
165
|
+
} | {
|
|
166
|
+
success: boolean;
|
|
167
|
+
error: any;
|
|
168
|
+
output: any;
|
|
169
|
+
stderr: any;
|
|
170
|
+
}>;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,SAAS;;;;;;;;;CASZ,CAAC;AAEX,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BASJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;kBANb,CAAF;iBAAoB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMQ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { askUserFollowup } from "./ask_user_followup.js";
|
|
2
|
+
import { recordProgress } from "./record_progress.js";
|
|
3
|
+
import { bashTool } from "./bash.js";
|
|
4
|
+
import { internetSearch } from "./internet_search.js";
|
|
5
|
+
import { readTool } from "./read.js";
|
|
6
|
+
import { writeTool } from "./write.js";
|
|
7
|
+
import { editTool } from "./edit.js";
|
|
8
|
+
import { compilationCheckTool } from "./compilation_check.js";
|
|
9
|
+
export const toolNames = {
|
|
10
|
+
askUserFollowup: "ask_user_followup",
|
|
11
|
+
recordProgress: "record_progress",
|
|
12
|
+
bash: "bash",
|
|
13
|
+
internetSearch: "internet_search",
|
|
14
|
+
read: "read",
|
|
15
|
+
write: "write",
|
|
16
|
+
edit: "edit",
|
|
17
|
+
compilationCheck: "compilation_check",
|
|
18
|
+
};
|
|
19
|
+
export const tools = {
|
|
20
|
+
[toolNames.askUserFollowup]: askUserFollowup,
|
|
21
|
+
[toolNames.recordProgress]: recordProgress,
|
|
22
|
+
[toolNames.bash]: bashTool,
|
|
23
|
+
[toolNames.internetSearch]: internetSearch,
|
|
24
|
+
[toolNames.read]: readTool,
|
|
25
|
+
[toolNames.write]: writeTool,
|
|
26
|
+
[toolNames.edit]: editTool,
|
|
27
|
+
[toolNames.compilationCheck]: compilationCheckTool,
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,eAAe,EAAE,mBAAmB;IACpC,cAAc,EAAE,iBAAiB;IACjC,IAAI,EAAE,MAAM;IACZ,cAAc,EAAE,iBAAiB;IACjC,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,gBAAgB,EAAE,mBAAmB;CAC7B,CAAC;AAEX,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,eAAe;IAC5C,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,cAAc;IAC1C,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,QAAQ;IAC1B,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,cAAc;IAC1C,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,QAAQ;IAC1B,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,SAAS;IAC5B,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,QAAQ;IAC1B,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,oBAAoB;CACxB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const internetSearch: {
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: z.ZodObject<{
|
|
5
|
+
query: z.ZodString;
|
|
6
|
+
searchCount: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
7
|
+
maxReadBodyLength: z.ZodNumber;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
execute: ({ searchCount, query, maxReadBodyLength, }: {
|
|
10
|
+
searchCount: number;
|
|
11
|
+
query: string;
|
|
12
|
+
maxReadBodyLength?: number;
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
success: boolean;
|
|
15
|
+
error: string;
|
|
16
|
+
output?: never;
|
|
17
|
+
metadata?: never;
|
|
18
|
+
} | {
|
|
19
|
+
success: boolean;
|
|
20
|
+
output: string;
|
|
21
|
+
metadata: {
|
|
22
|
+
maxReadBodyLength: number | undefined;
|
|
23
|
+
};
|
|
24
|
+
error?: never;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=internet_search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internet_search.d.ts","sourceRoot":"","sources":["../../src/tools/internet_search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,cAAc;;;;;;;0DAuBtB;QACD,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,EAAE,MAAM,CAAC;QACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B;;;;;;;;;;;;;CAyEF,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { JSDOM } from "jsdom";
|
|
3
|
+
import { assert } from "console";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
export const internetSearch = {
|
|
6
|
+
description: "Search the internet. IMPORTANT: If the 'output' is truncated or missing key details, call this tool again with a significantly higher 'maxReadBodyLength' (e.g., 5000 or 10000) to see more content.",
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
query: z.string().describe("The search query"),
|
|
9
|
+
searchCount: z
|
|
10
|
+
.number()
|
|
11
|
+
.max(5)
|
|
12
|
+
.default(3)
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("Number of search results to return (default 3, max 5). More results may provide more information but will take longer to fetch and process."),
|
|
15
|
+
maxReadBodyLength: z
|
|
16
|
+
.number()
|
|
17
|
+
.describe("Number of characters to return from the fetched webpage body content. recommend to start with 2500"),
|
|
18
|
+
}),
|
|
19
|
+
execute: async ({ searchCount, query, maxReadBodyLength, }) => {
|
|
20
|
+
const apiKey = process.env.BRAVE_API_KEY || "";
|
|
21
|
+
assert(apiKey, "BRAVE_API_KEY environment variable is required for internetSearch tool");
|
|
22
|
+
const url = `https://api.search.brave.com/res/v1/web/search?${new URLSearchParams({ q: query, count: searchCount.toString() })}`;
|
|
23
|
+
console.log(chalk.yellow(`\n[tool calling - internet_search] Search: ${query}`));
|
|
24
|
+
const response = await fetch(url, {
|
|
25
|
+
headers: {
|
|
26
|
+
Accept: "application/json",
|
|
27
|
+
"Accept-Encoding": "gzip",
|
|
28
|
+
"X-Subscription-Token": apiKey,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
console.log(chalk.red(`\n[tool calling - internet_search] ⚠️ Search API error: ${response.status} ${response.statusText}`));
|
|
33
|
+
return {
|
|
34
|
+
success: false,
|
|
35
|
+
error: `Search API error: ${response.status} ${response.statusText}`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const data = await response.json();
|
|
39
|
+
const { results } = data.web || {};
|
|
40
|
+
if (!results || results.length === 0) {
|
|
41
|
+
console.log(chalk.red("[tool calling - internet_search] ⚠️ No search results found"));
|
|
42
|
+
return {
|
|
43
|
+
success: false,
|
|
44
|
+
error: "No search results found",
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const contents = await Promise.all(results.map(async (result, index) => {
|
|
48
|
+
console.log(chalk.green(`[tool calling - internet_search] Result ${index + 1}: ${result.title} - ${result.url}`));
|
|
49
|
+
const html = await fetch(result.url, {
|
|
50
|
+
headers: {
|
|
51
|
+
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
|
|
52
|
+
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
|
53
|
+
},
|
|
54
|
+
}).then((res) => res.text());
|
|
55
|
+
const dom = new JSDOM(html, { url });
|
|
56
|
+
const body = dom.window.document.body.textContent || "";
|
|
57
|
+
return {
|
|
58
|
+
url: result.url,
|
|
59
|
+
title: result.title,
|
|
60
|
+
body: body.slice(0, maxReadBodyLength),
|
|
61
|
+
};
|
|
62
|
+
}));
|
|
63
|
+
// console.log("[return tool result]");
|
|
64
|
+
return {
|
|
65
|
+
success: true,
|
|
66
|
+
output: `${JSON.stringify(contents, null, 2)}\n\n[WARNING: Content truncated at current maxReadBodyLength: ${maxReadBodyLength} characters. Increase maxReadBodyLength to see more.]`,
|
|
67
|
+
metadata: {
|
|
68
|
+
maxReadBodyLength,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=internet_search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internet_search.js","sourceRoot":"","sources":["../../src/tools/internet_search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,WAAW,EACT,sMAAsM;IACxM,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QAC9C,WAAW,EAAE,CAAC;aACX,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,OAAO,CAAC,CAAC,CAAC;aACV,QAAQ,EAAE;aACV,QAAQ,CACP,6IAA6I,CAC9I;QACH,iBAAiB,EAAE,CAAC;aACjB,MAAM,EAAE;aACR,QAAQ,CACP,oGAAoG,CACrG;KACJ,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,EACd,WAAW,EACX,KAAK,EACL,iBAAiB,GAKlB,EAAE,EAAE;QACH,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC;QAC/C,MAAM,CACJ,MAAM,EACN,wEAAwE,CACzE,CAAC;QAEF,MAAM,GAAG,GAAG,kDAAkD,IAAI,eAAe,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC;QAEjI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,8CAA8C,KAAK,EAAE,CAAC,CAAC,CAAC;QACjF,MA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;oBACtE,MAAM,EACJ,iEAAiE;iBACpE;aACF,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;YAC7B,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACrC,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;YACxD,OAAO;gBACL,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC;aACvC,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;QACF,uCAAuC;QACvC,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,iEAAiE,iBAAiB,uDAAuD;YACrL,QAAQ,EAAE;gBACR,iBAAiB;aAClB;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const readTool: {
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: z.ZodObject<{
|
|
5
|
+
path: z.ZodString;
|
|
6
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
execute: ({ path: filePath, offset, limit, }: {
|
|
10
|
+
path: string;
|
|
11
|
+
offset?: number;
|
|
12
|
+
limit?: number;
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
success: boolean;
|
|
15
|
+
output: string;
|
|
16
|
+
error?: never;
|
|
17
|
+
} | {
|
|
18
|
+
success: boolean;
|
|
19
|
+
error: any;
|
|
20
|
+
output?: never;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,QAAQ;;;;;;;kDAsBhB;QACD,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB;;;;;;;;;CA+DF,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
export const readTool = {
|
|
6
|
+
description: "Read a file and return its contents. Useful for viewing source code, configuration files, documentation, or any text-based files.",
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
path: z.string().describe("The path to the file to read"),
|
|
9
|
+
offset: z
|
|
10
|
+
.number()
|
|
11
|
+
.optional()
|
|
12
|
+
.describe("The line number to start reading from (1-indexed). Default is 1 (start of file)."),
|
|
13
|
+
limit: z
|
|
14
|
+
.number()
|
|
15
|
+
.optional()
|
|
16
|
+
.describe("Maximum number of lines to read. If not specified, reads the entire file."),
|
|
17
|
+
}),
|
|
18
|
+
execute: async ({ path: filePath, offset = 1, limit, }) => {
|
|
19
|
+
console.log(chalk.yellow(`\n[tool calling - read] Reading file: ${filePath} (offset: ${offset}, limit: ${limit ?? "none"})`));
|
|
20
|
+
try {
|
|
21
|
+
// Resolve the path relative to current working directory
|
|
22
|
+
const fullPath = path.resolve(filePath);
|
|
23
|
+
if (!fs.existsSync(fullPath)) {
|
|
24
|
+
return {
|
|
25
|
+
success: false,
|
|
26
|
+
error: `File not found: ${fullPath}`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const content = fs.readFileSync(fullPath, "utf-8");
|
|
30
|
+
const lines = content.split("\n");
|
|
31
|
+
// Calculate start and end indices
|
|
32
|
+
const startIndex = Math.max(0, offset - 1);
|
|
33
|
+
const endIndex = limit
|
|
34
|
+
? Math.min(lines.length, startIndex + limit)
|
|
35
|
+
: lines.length;
|
|
36
|
+
if (startIndex >= lines.length) {
|
|
37
|
+
return {
|
|
38
|
+
success: true,
|
|
39
|
+
output: `File "${fullPath}" has ${lines.length} lines. Offset ${offset} is beyond file end.`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const selectedLines = lines.slice(startIndex, endIndex);
|
|
43
|
+
const resultContent = selectedLines.join("\n");
|
|
44
|
+
let metadata = `\n\n[Read tool metadata:`;
|
|
45
|
+
metadata += `\n File: ${fullPath}`;
|
|
46
|
+
metadata += `\n Total lines in file: ${lines.length}`;
|
|
47
|
+
metadata += `\n Offset: ${offset}`;
|
|
48
|
+
if (limit) {
|
|
49
|
+
metadata += `\n Limit: ${limit}`;
|
|
50
|
+
}
|
|
51
|
+
metadata += `\n Lines returned: ${selectedLines.length}`;
|
|
52
|
+
metadata += `\n]`;
|
|
53
|
+
return {
|
|
54
|
+
success: true,
|
|
55
|
+
output: resultContent + metadata,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
console.error(chalk.red(`[tool calling - read] ⚠️ Failed to read file: ${error.message}`));
|
|
60
|
+
return {
|
|
61
|
+
success: false,
|
|
62
|
+
error: error.message,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IA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
export declare const recordProgress: {
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: z.ZodObject<{
|
|
5
|
+
progress: z.ZodNumber;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
execute: ({ progress }: {
|
|
8
|
+
progress: number;
|
|
9
|
+
}) => Promise<{
|
|
10
|
+
success: boolean;
|
|
11
|
+
output: number;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=record_progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record_progress.d.ts","sourceRoot":"","sources":["../../src/tools/record_progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,cAAc;;;;;4BAUK;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE;;;;CAQnD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
export const recordProgress = {
|
|
4
|
+
description: "REQUIRED: Call this tool after EVERY tool call to update your progress (0-100). You must call this before calling any other tool and before calling deliver_final_answer.",
|
|
5
|
+
inputSchema: z.object({
|
|
6
|
+
progress: z
|
|
7
|
+
.number()
|
|
8
|
+
.describe("Your current progress as a percentage (0-100). This helps track how close you are to the final answer."),
|
|
9
|
+
}),
|
|
10
|
+
execute: async ({ progress }) => {
|
|
11
|
+
console.log(chalk.yellow(`\n[tool calling - record_progress] Current progress: ${progress}%`));
|
|
12
|
+
return { success: true, output: progress };
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=record_progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record_progress.js","sourceRoot":"","sources":["../../src/tools/record_progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,WAAW,EACT,2KAA2K;IAC7K,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,QAAQ,EAAE,CAAC;aACR,MAAM,EAAE;aACR,QAAQ,CACP,wGAAwG,CACzG;KACJ,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAwB,EAAE,EAAE;QACpD,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,MAAM,CACV,wDAAwD,QAAQ,GAAG,CACpE,CACF,CAAC;QACF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAC7C,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const writeTool: {
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: z.ZodObject<{
|
|
5
|
+
path: z.ZodString;
|
|
6
|
+
content: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
execute: ({ path: filePath, content, }: {
|
|
9
|
+
path: string;
|
|
10
|
+
content: string;
|
|
11
|
+
}) => Promise<{
|
|
12
|
+
success: boolean;
|
|
13
|
+
output: string;
|
|
14
|
+
metadata: {
|
|
15
|
+
path: string;
|
|
16
|
+
size: number;
|
|
17
|
+
};
|
|
18
|
+
error?: never;
|
|
19
|
+
} | {
|
|
20
|
+
success: boolean;
|
|
21
|
+
error: any;
|
|
22
|
+
output?: never;
|
|
23
|
+
metadata?: never;
|
|
24
|
+
}>;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/tools/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,SAAS;;;;;;4CAUjB;QACD,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB;;;;;;;;;;;;;;CAkCF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
export const writeTool = {
|
|
6
|
+
description: "WRITE FILE CONTENTS ENTIRELY. Overwrites the entire existing file content with new content. Use this ONLY when you need to replace the complete file contents or create a new file. Not suitable for targeted changes to specific parts of a file.",
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
path: z.string().describe("The path to the file to write"),
|
|
9
|
+
content: z.string().describe("The content to write to the file"),
|
|
10
|
+
}),
|
|
11
|
+
execute: async ({ path: filePath, content, }) => {
|
|
12
|
+
console.log(chalk.yellow(`\n[tool calling - write] Writing to file: ${filePath}`));
|
|
13
|
+
try {
|
|
14
|
+
const fullPath = path.resolve(filePath);
|
|
15
|
+
// Ensure directory exists
|
|
16
|
+
const dirPath = path.dirname(fullPath);
|
|
17
|
+
if (!fs.existsSync(dirPath)) {
|
|
18
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
fs.writeFileSync(fullPath, content, "utf-8");
|
|
21
|
+
return {
|
|
22
|
+
success: true,
|
|
23
|
+
output: `File "${fullPath}" written successfully.`,
|
|
24
|
+
metadata: {
|
|
25
|
+
path: fullPath,
|
|
26
|
+
size: content.length,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.error(chalk.red(`[tool calling - write] ⚠️ Failed to write file: ${error.message}`));
|
|
32
|
+
return {
|
|
33
|
+
success: false,
|
|
34
|
+
error: error.message,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.js","source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AC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CAAC,mDAAmD,KAAK,CAAC,OAAO,EAAE,CAAC,CAC9E,CAAC;YACF,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,CAAC,OAAO;aACrB,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/utils/system.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAYvC,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,QAIxC;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,QAoBnD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
// Log file setup
|
|
4
|
+
const logDir = path.join(process.cwd(), "logs");
|
|
5
|
+
if (!fs.existsSync(logDir)) {
|
|
6
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
7
|
+
}
|
|
8
|
+
const logFile = path.join(logDir, `agent-${new Date().toISOString().split("T")[0]}.log`);
|
|
9
|
+
export function logToFile(message) {
|
|
10
|
+
const timestamp = new Date().toISOString();
|
|
11
|
+
const logEntry = `[${timestamp}] ${message}\n`;
|
|
12
|
+
fs.appendFileSync(logFile, logEntry);
|
|
13
|
+
}
|
|
14
|
+
export function logMessages(messages) {
|
|
15
|
+
logToFile("\n--- Current Messages ---");
|
|
16
|
+
messages.forEach((msg, idx) => {
|
|
17
|
+
logToFile(`Message ${idx}: ${msg.role}`);
|
|
18
|
+
if (Array.isArray(msg.content)) {
|
|
19
|
+
msg.content.forEach((c) => {
|
|
20
|
+
if (c.type === "text")
|
|
21
|
+
logToFile(` [Text] ${c.text.substring(0, 100)}...`);
|
|
22
|
+
else if (c.type === "tool-call")
|
|
23
|
+
logToFile(` [Tool Call] ${c.toolName}`);
|
|
24
|
+
else if (c.type === "tool-result")
|
|
25
|
+
logToFile(` [Tool Result] ${c.toolName}`);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
logToFile(` Content: ${typeof msg.content === "string" ? msg.content.substring(0, 100) : JSON.stringify(msg.content)}`);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
logToFile("--- End Messages ---\n");
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/utils/system.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,iBAAiB;AACjB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;AAChD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;IAC3B,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC5C,CAAC;AACD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CACvB,MAAM,EACN,SAAS,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CACtD,CAAC;AAEF,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAI,SAAS,KAAK,OAAO,IAAI,CAAC;IAC/C,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,WA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bin/ai"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"bin"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
19
|
+
"prepare": "husky",
|
|
20
|
+
"lint": "oxlint . --ignore-pattern dist/",
|
|
21
|
+
"publish": "rm -rf dist && npm run build && npm publish"
|
|
22
|
+
},
|
|
23
|
+
"author": "",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"description": "",
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/jsdom": "^28.0.1",
|
|
28
|
+
"@types/node": "^25.5.0",
|
|
29
|
+
"husky": "^9.1.7",
|
|
30
|
+
"oxlint": "^1.57.0",
|
|
31
|
+
"tsx": "^4.21.0",
|
|
32
|
+
"typescript": "^5.9.3"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@ai-sdk/google": "^3.0.58",
|
|
36
|
+
"@ai-sdk/openai": "^3.0.50",
|
|
37
|
+
"ai": "^6.0.146",
|
|
38
|
+
"chalk": "^5.6.2",
|
|
39
|
+
"jsdom": "^29.0.1",
|
|
40
|
+
"zod": "^4.3.6"
|
|
41
|
+
}
|
|
42
|
+
}
|