sdkwork-browser-agent 1.0.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 +228 -0
- package/README.zh.md +228 -0
- package/dist/agent-Bpxmkz8W.d.ts +197 -0
- package/dist/agent-kexkkI13.d.cts +197 -0
- package/dist/browser/agent-Bpxmkz8W.d.ts +197 -0
- package/dist/browser/chunk-7W2JJCSS.js +276 -0
- package/dist/browser/chunk-7W2JJCSS.js.map +1 -0
- package/dist/browser/chunk-BHRFRGR7.js +144 -0
- package/dist/browser/chunk-BHRFRGR7.js.map +1 -0
- package/dist/browser/chunk-CLP6UNSV.js +285 -0
- package/dist/browser/chunk-CLP6UNSV.js.map +1 -0
- package/dist/browser/chunk-HXLRBB7S.js +1569 -0
- package/dist/browser/chunk-HXLRBB7S.js.map +1 -0
- package/dist/browser/chunk-VJEFLRZT.js +1720 -0
- package/dist/browser/chunk-VJEFLRZT.js.map +1 -0
- package/dist/browser/index.d.ts +842 -0
- package/dist/browser/index.js +3293 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/llm/index.d.ts +235 -0
- package/dist/browser/llm/index.js +29 -0
- package/dist/browser/llm/index.js.map +1 -0
- package/dist/browser/mcp/index.d.ts +63 -0
- package/dist/browser/mcp/index.js +9 -0
- package/dist/browser/mcp/index.js.map +1 -0
- package/dist/browser/provider-Dna36xA-.d.ts +105 -0
- package/dist/browser/skills/index.d.ts +401 -0
- package/dist/browser/skills/index.js +31 -0
- package/dist/browser/skills/index.js.map +1 -0
- package/dist/browser/storage/index.d.ts +64 -0
- package/dist/browser/storage/index.js +15 -0
- package/dist/browser/storage/index.js.map +1 -0
- package/dist/browser/tools/index.d.ts +45 -0
- package/dist/browser/tools/index.js +15 -0
- package/dist/browser/tools/index.js.map +1 -0
- package/dist/browser/types-CG5I-byI.d.ts +30 -0
- package/dist/chunk-56J3IBXZ.js +144 -0
- package/dist/chunk-56J3IBXZ.js.map +1 -0
- package/dist/chunk-5XTVS5MB.js +1720 -0
- package/dist/chunk-5XTVS5MB.js.map +1 -0
- package/dist/chunk-6AYIRBGI.js +166 -0
- package/dist/chunk-6AYIRBGI.js.map +1 -0
- package/dist/chunk-C2EYJHXW.cjs +276 -0
- package/dist/chunk-C2EYJHXW.cjs.map +1 -0
- package/dist/chunk-HOZQ445W.cjs +166 -0
- package/dist/chunk-HOZQ445W.cjs.map +1 -0
- package/dist/chunk-KZNZ6CGD.cjs +144 -0
- package/dist/chunk-KZNZ6CGD.cjs.map +1 -0
- package/dist/chunk-XFMT5ZA4.js +276 -0
- package/dist/chunk-XFMT5ZA4.js.map +1 -0
- package/dist/chunk-XPGICLEJ.cjs +1720 -0
- package/dist/chunk-XPGICLEJ.cjs.map +1 -0
- package/dist/index.cjs +1311 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +395 -0
- package/dist/index.d.ts +395 -0
- package/dist/index.js +1311 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/index.cjs +29 -0
- package/dist/llm/index.cjs.map +1 -0
- package/dist/llm/index.d.cts +235 -0
- package/dist/llm/index.d.ts +235 -0
- package/dist/llm/index.js +29 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/mcp/index.cjs +9 -0
- package/dist/mcp/index.cjs.map +1 -0
- package/dist/mcp/index.d.cts +63 -0
- package/dist/mcp/index.d.ts +63 -0
- package/dist/mcp/index.js +9 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/node/agent-Bpxmkz8W.d.ts +197 -0
- package/dist/node/agent-kexkkI13.d.cts +197 -0
- package/dist/node/chunk-7W2JJCSS.js +276 -0
- package/dist/node/chunk-7W2JJCSS.js.map +1 -0
- package/dist/node/chunk-BHRFRGR7.js +144 -0
- package/dist/node/chunk-BHRFRGR7.js.map +1 -0
- package/dist/node/chunk-CLP6UNSV.js +285 -0
- package/dist/node/chunk-CLP6UNSV.js.map +1 -0
- package/dist/node/chunk-HXLRBB7S.js +1569 -0
- package/dist/node/chunk-HXLRBB7S.js.map +1 -0
- package/dist/node/chunk-IYG37UN3.cjs +144 -0
- package/dist/node/chunk-IYG37UN3.cjs.map +1 -0
- package/dist/node/chunk-JF33ZOMB.cjs +285 -0
- package/dist/node/chunk-JF33ZOMB.cjs.map +1 -0
- package/dist/node/chunk-KXXS33G3.cjs +276 -0
- package/dist/node/chunk-KXXS33G3.cjs.map +1 -0
- package/dist/node/chunk-MTFOABGC.cjs +1720 -0
- package/dist/node/chunk-MTFOABGC.cjs.map +1 -0
- package/dist/node/chunk-VJEFLRZT.js +1720 -0
- package/dist/node/chunk-VJEFLRZT.js.map +1 -0
- package/dist/node/chunk-YDHQCPSN.cjs +1569 -0
- package/dist/node/chunk-YDHQCPSN.cjs.map +1 -0
- package/dist/node/index.cjs +3293 -0
- package/dist/node/index.cjs.map +1 -0
- package/dist/node/index.d.cts +842 -0
- package/dist/node/index.d.ts +842 -0
- package/dist/node/index.js +3293 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/llm/index.cjs +29 -0
- package/dist/node/llm/index.cjs.map +1 -0
- package/dist/node/llm/index.d.cts +235 -0
- package/dist/node/llm/index.d.ts +235 -0
- package/dist/node/llm/index.js +29 -0
- package/dist/node/llm/index.js.map +1 -0
- package/dist/node/mcp/index.cjs +9 -0
- package/dist/node/mcp/index.cjs.map +1 -0
- package/dist/node/mcp/index.d.cts +63 -0
- package/dist/node/mcp/index.d.ts +63 -0
- package/dist/node/mcp/index.js +9 -0
- package/dist/node/mcp/index.js.map +1 -0
- package/dist/node/provider-Dna36xA-.d.cts +105 -0
- package/dist/node/provider-Dna36xA-.d.ts +105 -0
- package/dist/node/skills/index.cjs +31 -0
- package/dist/node/skills/index.cjs.map +1 -0
- package/dist/node/skills/index.d.cts +401 -0
- package/dist/node/skills/index.d.ts +401 -0
- package/dist/node/skills/index.js +31 -0
- package/dist/node/skills/index.js.map +1 -0
- package/dist/node/storage/index.cjs +15 -0
- package/dist/node/storage/index.cjs.map +1 -0
- package/dist/node/storage/index.d.cts +64 -0
- package/dist/node/storage/index.d.ts +64 -0
- package/dist/node/storage/index.js +15 -0
- package/dist/node/storage/index.js.map +1 -0
- package/dist/node/tools/index.cjs +15 -0
- package/dist/node/tools/index.cjs.map +1 -0
- package/dist/node/tools/index.d.cts +45 -0
- package/dist/node/tools/index.d.ts +45 -0
- package/dist/node/tools/index.js +15 -0
- package/dist/node/tools/index.js.map +1 -0
- package/dist/node/types-CG5I-byI.d.cts +30 -0
- package/dist/node/types-CG5I-byI.d.ts +30 -0
- package/dist/provider-Dna36xA-.d.cts +105 -0
- package/dist/provider-Dna36xA-.d.ts +105 -0
- package/dist/skills/index.cjs +15 -0
- package/dist/skills/index.cjs.map +1 -0
- package/dist/skills/index.d.cts +43 -0
- package/dist/skills/index.d.ts +43 -0
- package/dist/skills/index.js +15 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/tools/index.cjs +15 -0
- package/dist/tools/index.cjs.map +1 -0
- package/dist/tools/index.d.cts +45 -0
- package/dist/tools/index.d.ts +45 -0
- package/dist/tools/index.js +15 -0
- package/dist/tools/index.js.map +1 -0
- package/package.json +150 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
// src/tools/registry.ts
|
|
2
|
+
var ToolRegistry = class {
|
|
3
|
+
tools = /* @__PURE__ */ new Map();
|
|
4
|
+
categories = /* @__PURE__ */ new Map();
|
|
5
|
+
constructor(_config = {}) {
|
|
6
|
+
void _config;
|
|
7
|
+
}
|
|
8
|
+
register(tool) {
|
|
9
|
+
this.tools.set(tool.name, tool);
|
|
10
|
+
if (tool.metadata?.category) {
|
|
11
|
+
const category = tool.metadata.category;
|
|
12
|
+
if (!this.categories.has(category)) {
|
|
13
|
+
this.categories.set(category, /* @__PURE__ */ new Set());
|
|
14
|
+
}
|
|
15
|
+
this.categories.get(category).add(tool.name);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
unregister(name) {
|
|
19
|
+
const tool = this.tools.get(name);
|
|
20
|
+
if (!tool) return false;
|
|
21
|
+
if (tool.metadata?.category) {
|
|
22
|
+
this.categories.get(tool.metadata.category)?.delete(name);
|
|
23
|
+
}
|
|
24
|
+
return this.tools.delete(name);
|
|
25
|
+
}
|
|
26
|
+
get(name) {
|
|
27
|
+
return this.tools.get(name);
|
|
28
|
+
}
|
|
29
|
+
has(name) {
|
|
30
|
+
return this.tools.has(name);
|
|
31
|
+
}
|
|
32
|
+
list() {
|
|
33
|
+
return Array.from(this.tools.values());
|
|
34
|
+
}
|
|
35
|
+
listNames() {
|
|
36
|
+
return Array.from(this.tools.keys());
|
|
37
|
+
}
|
|
38
|
+
findByCategory(category) {
|
|
39
|
+
const names = this.categories.get(category);
|
|
40
|
+
if (!names) return [];
|
|
41
|
+
return Array.from(names).map((name) => this.tools.get(name)).filter((tool) => tool !== void 0);
|
|
42
|
+
}
|
|
43
|
+
findByTag(tag) {
|
|
44
|
+
return this.list().filter((tool) => tool.metadata?.tags?.includes(tag));
|
|
45
|
+
}
|
|
46
|
+
findByConfirmation(needsConfirmation) {
|
|
47
|
+
return this.list().filter(
|
|
48
|
+
(tool) => (tool.metadata?.requiresConfirmation ?? false) === needsConfirmation
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
search(query) {
|
|
52
|
+
const lowerQuery = query.toLowerCase();
|
|
53
|
+
return this.list().filter(
|
|
54
|
+
(tool) => tool.name.toLowerCase().includes(lowerQuery) || tool.description.toLowerCase().includes(lowerQuery) || tool.metadata?.tags?.some((tag) => tag.toLowerCase().includes(lowerQuery))
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
async execute(name, input, context) {
|
|
58
|
+
const tool = this.tools.get(name);
|
|
59
|
+
if (!tool) {
|
|
60
|
+
return {
|
|
61
|
+
content: [{ type: "error", text: `Tool '${name}' not found in registry` }],
|
|
62
|
+
isError: true
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return tool.execute(input, context);
|
|
66
|
+
}
|
|
67
|
+
clear() {
|
|
68
|
+
this.tools.clear();
|
|
69
|
+
this.categories.clear();
|
|
70
|
+
}
|
|
71
|
+
getCategories() {
|
|
72
|
+
return Array.from(this.categories.keys());
|
|
73
|
+
}
|
|
74
|
+
getStats() {
|
|
75
|
+
return {
|
|
76
|
+
total: this.tools.size,
|
|
77
|
+
categories: this.categories.size,
|
|
78
|
+
requireConfirmation: this.list().filter((t) => t.metadata?.requiresConfirmation).length
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// src/tools/builtin.ts
|
|
84
|
+
var fileReadTool = {
|
|
85
|
+
name: "file_read",
|
|
86
|
+
description: "Read content from a file (Node.js only)",
|
|
87
|
+
parameters: {
|
|
88
|
+
type: "object",
|
|
89
|
+
properties: {
|
|
90
|
+
path: {
|
|
91
|
+
type: "string",
|
|
92
|
+
description: "Path to the file"
|
|
93
|
+
},
|
|
94
|
+
encoding: {
|
|
95
|
+
type: "string",
|
|
96
|
+
description: "File encoding",
|
|
97
|
+
default: "utf-8"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
required: ["path"]
|
|
101
|
+
},
|
|
102
|
+
execute: async (input) => {
|
|
103
|
+
if (typeof window !== "undefined") {
|
|
104
|
+
return {
|
|
105
|
+
content: [{ type: "error", text: "File operations not supported in browser" }],
|
|
106
|
+
isError: true
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
const fs = await import("fs/promises");
|
|
111
|
+
const { path, encoding = "utf-8" } = input;
|
|
112
|
+
const content = await fs.readFile(path, { encoding });
|
|
113
|
+
return {
|
|
114
|
+
content: [{ type: "text", text: content }]
|
|
115
|
+
};
|
|
116
|
+
} catch (error) {
|
|
117
|
+
return {
|
|
118
|
+
content: [
|
|
119
|
+
{
|
|
120
|
+
type: "error",
|
|
121
|
+
text: error instanceof Error ? error.message : "Failed to read file"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
isError: true
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
metadata: {
|
|
129
|
+
category: "filesystem",
|
|
130
|
+
tags: ["file", "read"],
|
|
131
|
+
version: "1.0.0"
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
var fileWriteTool = {
|
|
135
|
+
name: "file_write",
|
|
136
|
+
description: "Write content to a file (Node.js only)",
|
|
137
|
+
parameters: {
|
|
138
|
+
type: "object",
|
|
139
|
+
properties: {
|
|
140
|
+
path: {
|
|
141
|
+
type: "string",
|
|
142
|
+
description: "Path to the file"
|
|
143
|
+
},
|
|
144
|
+
content: {
|
|
145
|
+
type: "string",
|
|
146
|
+
description: "Content to write"
|
|
147
|
+
},
|
|
148
|
+
encoding: {
|
|
149
|
+
type: "string",
|
|
150
|
+
description: "File encoding",
|
|
151
|
+
default: "utf-8"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
required: ["path", "content"]
|
|
155
|
+
},
|
|
156
|
+
execute: async (input) => {
|
|
157
|
+
if (typeof window !== "undefined") {
|
|
158
|
+
return {
|
|
159
|
+
content: [{ type: "error", text: "File operations not supported in browser" }],
|
|
160
|
+
isError: true
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const fs = await import("fs/promises");
|
|
165
|
+
const {
|
|
166
|
+
path,
|
|
167
|
+
content,
|
|
168
|
+
encoding = "utf-8"
|
|
169
|
+
} = input;
|
|
170
|
+
await fs.writeFile(path, content, { encoding });
|
|
171
|
+
return {
|
|
172
|
+
content: [{ type: "text", text: `Successfully wrote to ${path}` }]
|
|
173
|
+
};
|
|
174
|
+
} catch (error) {
|
|
175
|
+
return {
|
|
176
|
+
content: [
|
|
177
|
+
{
|
|
178
|
+
type: "error",
|
|
179
|
+
text: error instanceof Error ? error.message : "Failed to write file"
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
isError: true
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
metadata: {
|
|
187
|
+
category: "filesystem",
|
|
188
|
+
tags: ["file", "write"],
|
|
189
|
+
requiresConfirmation: true,
|
|
190
|
+
version: "1.0.0"
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
var httpRequestTool = {
|
|
194
|
+
name: "http_request",
|
|
195
|
+
description: "Make HTTP requests",
|
|
196
|
+
parameters: {
|
|
197
|
+
type: "object",
|
|
198
|
+
properties: {
|
|
199
|
+
url: {
|
|
200
|
+
type: "string",
|
|
201
|
+
description: "URL to request"
|
|
202
|
+
},
|
|
203
|
+
method: {
|
|
204
|
+
type: "string",
|
|
205
|
+
description: "HTTP method",
|
|
206
|
+
enum: ["GET", "POST", "PUT", "DELETE", "PATCH"],
|
|
207
|
+
default: "GET"
|
|
208
|
+
},
|
|
209
|
+
headers: {
|
|
210
|
+
type: "object",
|
|
211
|
+
description: "Request headers"
|
|
212
|
+
},
|
|
213
|
+
body: {
|
|
214
|
+
type: "string",
|
|
215
|
+
description: "Request body"
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
required: ["url"]
|
|
219
|
+
},
|
|
220
|
+
execute: async (input) => {
|
|
221
|
+
try {
|
|
222
|
+
const {
|
|
223
|
+
url,
|
|
224
|
+
method = "GET",
|
|
225
|
+
headers,
|
|
226
|
+
body
|
|
227
|
+
} = input;
|
|
228
|
+
const response = await fetch(url, {
|
|
229
|
+
method,
|
|
230
|
+
headers,
|
|
231
|
+
body
|
|
232
|
+
});
|
|
233
|
+
const text = await response.text();
|
|
234
|
+
return {
|
|
235
|
+
content: [
|
|
236
|
+
{
|
|
237
|
+
type: "text",
|
|
238
|
+
text: `Status: ${response.status}
|
|
239
|
+
|
|
240
|
+
${text}`
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
metadata: {
|
|
244
|
+
status: response.status,
|
|
245
|
+
statusText: response.statusText,
|
|
246
|
+
headers: Object.fromEntries(response.headers.entries())
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
} catch (error) {
|
|
250
|
+
return {
|
|
251
|
+
content: [
|
|
252
|
+
{
|
|
253
|
+
type: "error",
|
|
254
|
+
text: error instanceof Error ? error.message : "HTTP request failed"
|
|
255
|
+
}
|
|
256
|
+
],
|
|
257
|
+
isError: true
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
metadata: {
|
|
262
|
+
category: "network",
|
|
263
|
+
tags: ["http", "request", "api"],
|
|
264
|
+
version: "1.0.0"
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
var builtInTools = [fileReadTool, fileWriteTool, httpRequestTool];
|
|
268
|
+
|
|
269
|
+
export {
|
|
270
|
+
ToolRegistry,
|
|
271
|
+
fileReadTool,
|
|
272
|
+
fileWriteTool,
|
|
273
|
+
httpRequestTool,
|
|
274
|
+
builtInTools
|
|
275
|
+
};
|
|
276
|
+
//# sourceMappingURL=chunk-XFMT5ZA4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tools/registry.ts","../src/tools/builtin.ts"],"sourcesContent":["/**\n * Tool Registry for managing and discovering tools\n */\n\nimport { Tool, ToolOutput, ExecutionContext } from '../core/agent';\n\nexport interface ToolRegistryConfig {\n autoDiscover?: boolean;\n toolDirectory?: string;\n}\n\nexport class ToolRegistry {\n private tools = new Map<string, Tool>();\n private categories = new Map<string, Set<string>>();\n\n constructor(_config: ToolRegistryConfig = {}) {\n // Config stored for future use\n void _config;\n }\n\n register(tool: Tool): void {\n this.tools.set(tool.name, tool);\n\n // Categorize tool\n if (tool.metadata?.category) {\n const category = tool.metadata.category;\n if (!this.categories.has(category)) {\n this.categories.set(category, new Set());\n }\n this.categories.get(category)!.add(tool.name);\n }\n }\n\n unregister(name: string): boolean {\n const tool = this.tools.get(name);\n if (!tool) return false;\n\n // Remove from categories\n if (tool.metadata?.category) {\n this.categories.get(tool.metadata.category)?.delete(name);\n }\n\n return this.tools.delete(name);\n }\n\n get(name: string): Tool | undefined {\n return this.tools.get(name);\n }\n\n has(name: string): boolean {\n return this.tools.has(name);\n }\n\n list(): Tool[] {\n return Array.from(this.tools.values());\n }\n\n listNames(): string[] {\n return Array.from(this.tools.keys());\n }\n\n findByCategory(category: string): Tool[] {\n const names = this.categories.get(category);\n if (!names) return [];\n return Array.from(names)\n .map(name => this.tools.get(name))\n .filter((tool): tool is Tool => tool !== undefined);\n }\n\n findByTag(tag: string): Tool[] {\n return this.list().filter(tool => tool.metadata?.tags?.includes(tag));\n }\n\n findByConfirmation(needsConfirmation: boolean): Tool[] {\n return this.list().filter(\n tool => (tool.metadata?.requiresConfirmation ?? false) === needsConfirmation\n );\n }\n\n search(query: string): Tool[] {\n const lowerQuery = query.toLowerCase();\n return this.list().filter(\n tool =>\n tool.name.toLowerCase().includes(lowerQuery) ||\n tool.description.toLowerCase().includes(lowerQuery) ||\n tool.metadata?.tags?.some(tag => tag.toLowerCase().includes(lowerQuery))\n );\n }\n\n async execute(name: string, input: unknown, context: ExecutionContext): Promise<ToolOutput> {\n const tool = this.tools.get(name);\n if (!tool) {\n return {\n content: [{ type: 'error', text: `Tool '${name}' not found in registry` }],\n isError: true,\n };\n }\n return tool.execute(input, context);\n }\n\n clear(): void {\n this.tools.clear();\n this.categories.clear();\n }\n\n getCategories(): string[] {\n return Array.from(this.categories.keys());\n }\n\n getStats(): { total: number; categories: number; requireConfirmation: number } {\n return {\n total: this.tools.size,\n categories: this.categories.size,\n requireConfirmation: this.list().filter(t => t.metadata?.requiresConfirmation).length,\n };\n }\n}\n","/**\n * Built-in Tools\n */\n\nimport { Tool } from '../core/agent';\n\nexport const fileReadTool: Tool = {\n name: 'file_read',\n description: 'Read content from a file (Node.js only)',\n parameters: {\n type: 'object',\n properties: {\n path: {\n type: 'string',\n description: 'Path to the file',\n },\n encoding: {\n type: 'string',\n description: 'File encoding',\n default: 'utf-8',\n },\n },\n required: ['path'],\n },\n execute: async input => {\n // Check if running in Node.js\n if (typeof window !== 'undefined') {\n return {\n content: [{ type: 'error', text: 'File operations not supported in browser' }],\n isError: true,\n };\n }\n\n try {\n // Dynamic import to avoid browser bundling issues\n const fs = await import('fs/promises');\n const { path, encoding = 'utf-8' } = input as { path: string; encoding?: string };\n const content = await fs.readFile(path, { encoding: encoding as BufferEncoding });\n return {\n content: [{ type: 'text', text: content }],\n };\n } catch (error) {\n return {\n content: [\n {\n type: 'error',\n text: error instanceof Error ? error.message : 'Failed to read file',\n },\n ],\n isError: true,\n };\n }\n },\n metadata: {\n category: 'filesystem',\n tags: ['file', 'read'],\n version: '1.0.0',\n },\n};\n\nexport const fileWriteTool: Tool = {\n name: 'file_write',\n description: 'Write content to a file (Node.js only)',\n parameters: {\n type: 'object',\n properties: {\n path: {\n type: 'string',\n description: 'Path to the file',\n },\n content: {\n type: 'string',\n description: 'Content to write',\n },\n encoding: {\n type: 'string',\n description: 'File encoding',\n default: 'utf-8',\n },\n },\n required: ['path', 'content'],\n },\n execute: async input => {\n if (typeof window !== 'undefined') {\n return {\n content: [{ type: 'error', text: 'File operations not supported in browser' }],\n isError: true,\n };\n }\n\n try {\n const fs = await import('fs/promises');\n const {\n path,\n content,\n encoding = 'utf-8',\n } = input as {\n path: string;\n content: string;\n encoding?: string;\n };\n await fs.writeFile(path, content, { encoding: encoding as BufferEncoding });\n return {\n content: [{ type: 'text', text: `Successfully wrote to ${path}` }],\n };\n } catch (error) {\n return {\n content: [\n {\n type: 'error',\n text: error instanceof Error ? error.message : 'Failed to write file',\n },\n ],\n isError: true,\n };\n }\n },\n metadata: {\n category: 'filesystem',\n tags: ['file', 'write'],\n requiresConfirmation: true,\n version: '1.0.0',\n },\n};\n\nexport const httpRequestTool: Tool = {\n name: 'http_request',\n description: 'Make HTTP requests',\n parameters: {\n type: 'object',\n properties: {\n url: {\n type: 'string',\n description: 'URL to request',\n },\n method: {\n type: 'string',\n description: 'HTTP method',\n enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],\n default: 'GET',\n },\n headers: {\n type: 'object',\n description: 'Request headers',\n },\n body: {\n type: 'string',\n description: 'Request body',\n },\n },\n required: ['url'],\n },\n execute: async input => {\n try {\n const {\n url,\n method = 'GET',\n headers,\n body,\n } = input as {\n url: string;\n method?: string;\n headers?: Record<string, string>;\n body?: string;\n };\n\n const response = await fetch(url, {\n method,\n headers,\n body,\n });\n\n const text = await response.text();\n\n return {\n content: [\n {\n type: 'text',\n text: `Status: ${response.status}\\n\\n${text}`,\n },\n ],\n metadata: {\n status: response.status,\n statusText: response.statusText,\n headers: Object.fromEntries(response.headers.entries()),\n },\n };\n } catch (error) {\n return {\n content: [\n {\n type: 'error',\n text: error instanceof Error ? error.message : 'HTTP request failed',\n },\n ],\n isError: true,\n };\n }\n },\n metadata: {\n category: 'network',\n tags: ['http', 'request', 'api'],\n version: '1.0.0',\n },\n};\n\nexport const builtInTools = [fileReadTool, fileWriteTool, httpRequestTool];\n"],"mappings":";AAWO,IAAM,eAAN,MAAmB;AAAA,EAChB,QAAQ,oBAAI,IAAkB;AAAA,EAC9B,aAAa,oBAAI,IAAyB;AAAA,EAElD,YAAY,UAA8B,CAAC,GAAG;AAE5C,SAAK;AAAA,EACP;AAAA,EAEA,SAAS,MAAkB;AACzB,SAAK,MAAM,IAAI,KAAK,MAAM,IAAI;AAG9B,QAAI,KAAK,UAAU,UAAU;AAC3B,YAAM,WAAW,KAAK,SAAS;AAC/B,UAAI,CAAC,KAAK,WAAW,IAAI,QAAQ,GAAG;AAClC,aAAK,WAAW,IAAI,UAAU,oBAAI,IAAI,CAAC;AAAA,MACzC;AACA,WAAK,WAAW,IAAI,QAAQ,EAAG,IAAI,KAAK,IAAI;AAAA,IAC9C;AAAA,EACF;AAAA,EAEA,WAAW,MAAuB;AAChC,UAAM,OAAO,KAAK,MAAM,IAAI,IAAI;AAChC,QAAI,CAAC,KAAM,QAAO;AAGlB,QAAI,KAAK,UAAU,UAAU;AAC3B,WAAK,WAAW,IAAI,KAAK,SAAS,QAAQ,GAAG,OAAO,IAAI;AAAA,IAC1D;AAEA,WAAO,KAAK,MAAM,OAAO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