@polpo-ai/tools 0.2.4
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/adapters/node-filesystem.d.ts +12 -0
- package/dist/adapters/node-filesystem.d.ts.map +1 -0
- package/dist/adapters/node-filesystem.js +46 -0
- package/dist/adapters/node-filesystem.js.map +1 -0
- package/dist/adapters/node-shell.d.ts +5 -0
- package/dist/adapters/node-shell.d.ts.map +1 -0
- package/dist/adapters/node-shell.js +34 -0
- package/dist/adapters/node-shell.js.map +1 -0
- package/dist/audio-tools.d.ts +42 -0
- package/dist/audio-tools.d.ts.map +1 -0
- package/dist/audio-tools.js +552 -0
- package/dist/audio-tools.js.map +1 -0
- package/dist/browser-tools.d.ts +36 -0
- package/dist/browser-tools.d.ts.map +1 -0
- package/dist/browser-tools.js +525 -0
- package/dist/browser-tools.js.map +1 -0
- package/dist/coding-tools.d.ts +99 -0
- package/dist/coding-tools.d.ts.map +1 -0
- package/dist/coding-tools.js +434 -0
- package/dist/coding-tools.js.map +1 -0
- package/dist/docx-tools.d.ts +22 -0
- package/dist/docx-tools.d.ts.map +1 -0
- package/dist/docx-tools.js +236 -0
- package/dist/docx-tools.js.map +1 -0
- package/dist/email-tools.d.ts +34 -0
- package/dist/email-tools.d.ts.map +1 -0
- package/dist/email-tools.js +787 -0
- package/dist/email-tools.js.map +1 -0
- package/dist/excel-tools.d.ts +25 -0
- package/dist/excel-tools.d.ts.map +1 -0
- package/dist/excel-tools.js +409 -0
- package/dist/excel-tools.js.map +1 -0
- package/dist/http-tools.d.ts +23 -0
- package/dist/http-tools.d.ts.map +1 -0
- package/dist/http-tools.js +214 -0
- package/dist/http-tools.js.map +1 -0
- package/dist/image-tools.d.ts +40 -0
- package/dist/image-tools.d.ts.map +1 -0
- package/dist/image-tools.js +522 -0
- package/dist/image-tools.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/memory-tools.d.ts +19 -0
- package/dist/memory-tools.d.ts.map +1 -0
- package/dist/memory-tools.js +104 -0
- package/dist/memory-tools.js.map +1 -0
- package/dist/outcome-tools.d.ts +25 -0
- package/dist/outcome-tools.d.ts.map +1 -0
- package/dist/outcome-tools.js +191 -0
- package/dist/outcome-tools.js.map +1 -0
- package/dist/path-sandbox.d.ts +28 -0
- package/dist/path-sandbox.d.ts.map +1 -0
- package/dist/path-sandbox.js +58 -0
- package/dist/path-sandbox.js.map +1 -0
- package/dist/pdf-tools.d.ts +25 -0
- package/dist/pdf-tools.d.ts.map +1 -0
- package/dist/pdf-tools.js +363 -0
- package/dist/pdf-tools.js.map +1 -0
- package/dist/phone-tools.d.ts +27 -0
- package/dist/phone-tools.d.ts.map +1 -0
- package/dist/phone-tools.js +577 -0
- package/dist/phone-tools.js.map +1 -0
- package/dist/safe-env.d.ts +26 -0
- package/dist/safe-env.d.ts.map +1 -0
- package/dist/safe-env.js +76 -0
- package/dist/safe-env.js.map +1 -0
- package/dist/search-tools.d.ts +22 -0
- package/dist/search-tools.d.ts.map +1 -0
- package/dist/search-tools.js +205 -0
- package/dist/search-tools.js.map +1 -0
- package/dist/ssrf-guard.d.ts +17 -0
- package/dist/ssrf-guard.d.ts.map +1 -0
- package/dist/ssrf-guard.js +95 -0
- package/dist/ssrf-guard.js.map +1 -0
- package/dist/types.d.ts +21 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/vault-tools.d.ts +26 -0
- package/dist/vault-tools.d.ts.map +1 -0
- package/dist/vault-tools.js +86 -0
- package/dist/vault-tools.js.map +1 -0
- package/dist/whatsapp-tools.d.ts +18 -0
- package/dist/whatsapp-tools.d.ts.map +1 -0
- package/dist/whatsapp-tools.js +206 -0
- package/dist/whatsapp-tools.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser automation tools powered by agent-browser.
|
|
3
|
+
*
|
|
4
|
+
* Uses the agent-browser CLI (https://github.com/vercel-labs/agent-browser)
|
|
5
|
+
* via child_process with --json output for structured results.
|
|
6
|
+
*
|
|
7
|
+
* The agent-browser CLI manages a daemon process that keeps the browser alive
|
|
8
|
+
* between commands, making sequential tool calls fast (no cold-start per command).
|
|
9
|
+
*
|
|
10
|
+
* Requires `agent-browser` to be installed globally or in PATH.
|
|
11
|
+
* Install: `npm install -g agent-browser && agent-browser install`
|
|
12
|
+
*
|
|
13
|
+
* Session isolation: Each agent gets its own browser session via --session flag,
|
|
14
|
+
* preventing cross-agent interference when multiple agents use browser tools.
|
|
15
|
+
*/
|
|
16
|
+
import { execSync, spawn as spawnChild } from "node:child_process";
|
|
17
|
+
import { resolve } from "node:path";
|
|
18
|
+
import { Type } from "@sinclair/typebox";
|
|
19
|
+
const MAX_OUTPUT_BYTES = 50_000;
|
|
20
|
+
const DEFAULT_TIMEOUT = 30_000;
|
|
21
|
+
/**
|
|
22
|
+
* Cleanup an agent-browser session: close the session.
|
|
23
|
+
* Profile data is automatically persisted by agent-browser when --profile is used.
|
|
24
|
+
* Called by the engine on agent exit.
|
|
25
|
+
*/
|
|
26
|
+
export async function cleanupAgentBrowserSession(session) {
|
|
27
|
+
try {
|
|
28
|
+
execSync(`agent-browser --session ${session} close`, {
|
|
29
|
+
encoding: "utf-8",
|
|
30
|
+
timeout: 10_000,
|
|
31
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Already closed
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// ─── Helpers ───
|
|
39
|
+
/** Execute agent-browser CLI command and return parsed result */
|
|
40
|
+
function execBrowser(args, options = {}) {
|
|
41
|
+
const sessionArgs = options.session ? ["--session", options.session] : [];
|
|
42
|
+
const profileArgs = options.profileDir ? ["--profile", options.profileDir] : [];
|
|
43
|
+
const cmd = ["agent-browser", ...sessionArgs, ...profileArgs, ...args, "--json"].join(" ");
|
|
44
|
+
try {
|
|
45
|
+
const raw = execSync(cmd, {
|
|
46
|
+
encoding: "utf-8",
|
|
47
|
+
timeout: options.timeout ?? DEFAULT_TIMEOUT,
|
|
48
|
+
cwd: options.cwd,
|
|
49
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
50
|
+
}).trim();
|
|
51
|
+
try {
|
|
52
|
+
const parsed = JSON.parse(raw);
|
|
53
|
+
return { success: parsed.success ?? true, data: parsed.data ?? parsed, raw };
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return { success: true, data: raw, raw };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
const stderr = err.stderr?.toString() ?? "";
|
|
61
|
+
const stdout = err.stdout?.toString() ?? "";
|
|
62
|
+
return { success: false, error: stderr || stdout || err.message, raw: stderr || stdout };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Execute agent-browser command async with signal support */
|
|
66
|
+
function execBrowserAsync(args, options = {}) {
|
|
67
|
+
return new Promise((resolve) => {
|
|
68
|
+
const sessionArgs = options.session ? ["--session", options.session] : [];
|
|
69
|
+
const profileArgs = options.profileDir ? ["--profile", options.profileDir] : [];
|
|
70
|
+
const fullArgs = [...sessionArgs, ...profileArgs, ...args, "--json"];
|
|
71
|
+
const child = spawnChild("agent-browser", fullArgs, {
|
|
72
|
+
cwd: options.cwd,
|
|
73
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
74
|
+
});
|
|
75
|
+
const chunks = [];
|
|
76
|
+
let killed = false;
|
|
77
|
+
const timer = setTimeout(() => {
|
|
78
|
+
killed = true;
|
|
79
|
+
child.kill("SIGTERM");
|
|
80
|
+
}, options.timeout ?? DEFAULT_TIMEOUT);
|
|
81
|
+
const onAbort = () => { killed = true; child.kill("SIGTERM"); };
|
|
82
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
83
|
+
child.stdout.on("data", (d) => chunks.push(d));
|
|
84
|
+
child.stderr.on("data", (d) => chunks.push(d));
|
|
85
|
+
child.on("close", (code) => {
|
|
86
|
+
clearTimeout(timer);
|
|
87
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
88
|
+
let raw = Buffer.concat(chunks).toString("utf-8").trim();
|
|
89
|
+
if (raw.length > MAX_OUTPUT_BYTES) {
|
|
90
|
+
raw = raw.slice(-MAX_OUTPUT_BYTES) + "\n[truncated]";
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const parsed = JSON.parse(raw);
|
|
94
|
+
resolve({ success: parsed.success ?? (code === 0), data: parsed.data ?? parsed, raw });
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
resolve({ success: code === 0, data: raw, raw });
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
child.on("error", (err) => {
|
|
101
|
+
clearTimeout(timer);
|
|
102
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
103
|
+
resolve({ success: false, error: err.message, raw: err.message });
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function browserResult(result) {
|
|
108
|
+
if (!result.success) {
|
|
109
|
+
return {
|
|
110
|
+
content: [{ type: "text", text: `Browser error: ${result.error ?? result.raw}` }],
|
|
111
|
+
details: { error: result.error ?? result.raw },
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const text = typeof result.data === "string" ? result.data : JSON.stringify(result.data, null, 2);
|
|
115
|
+
return {
|
|
116
|
+
content: [{ type: "text", text: text.slice(0, MAX_OUTPUT_BYTES) }],
|
|
117
|
+
details: result.data,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
// ─── Tool: browser_navigate ───
|
|
121
|
+
const BrowserNavigateSchema = Type.Object({
|
|
122
|
+
url: Type.String({ description: "URL to navigate to (e.g. 'https://example.com')" }),
|
|
123
|
+
});
|
|
124
|
+
function createBrowserNavigateTool(session, profileDir) {
|
|
125
|
+
return {
|
|
126
|
+
name: "browser_navigate",
|
|
127
|
+
label: "Browser Navigate",
|
|
128
|
+
description: "Open a URL in the browser. Launches the browser if not already running.",
|
|
129
|
+
parameters: BrowserNavigateSchema,
|
|
130
|
+
async execute(_id, params, signal) {
|
|
131
|
+
const result = await execBrowserAsync(["open", params.url], { session, profileDir, signal });
|
|
132
|
+
return browserResult(result);
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
// ─── Tool: browser_snapshot ───
|
|
137
|
+
const BrowserSnapshotSchema = Type.Object({
|
|
138
|
+
interactive_only: Type.Optional(Type.Boolean({ description: "Only show interactive elements (buttons, inputs, links)" })),
|
|
139
|
+
compact: Type.Optional(Type.Boolean({ description: "Remove empty structural elements" })),
|
|
140
|
+
max_depth: Type.Optional(Type.Number({ description: "Limit tree depth" })),
|
|
141
|
+
selector: Type.Optional(Type.String({ description: "Scope snapshot to a CSS selector" })),
|
|
142
|
+
});
|
|
143
|
+
function createBrowserSnapshotTool(session, profileDir) {
|
|
144
|
+
return {
|
|
145
|
+
name: "browser_snapshot",
|
|
146
|
+
label: "Browser Snapshot",
|
|
147
|
+
description: "Get the accessibility tree of the current page with element refs (e.g. @e1, @e2). " +
|
|
148
|
+
"Use refs to interact with elements. Best way to understand page structure for AI.",
|
|
149
|
+
parameters: BrowserSnapshotSchema,
|
|
150
|
+
async execute(_id, params, signal) {
|
|
151
|
+
const args = ["snapshot"];
|
|
152
|
+
if (params.interactive_only)
|
|
153
|
+
args.push("-i");
|
|
154
|
+
if (params.compact)
|
|
155
|
+
args.push("-c");
|
|
156
|
+
if (params.max_depth)
|
|
157
|
+
args.push("-d", String(params.max_depth));
|
|
158
|
+
if (params.selector)
|
|
159
|
+
args.push("-s", params.selector);
|
|
160
|
+
const result = await execBrowserAsync(args, { session, profileDir, signal, timeout: 15_000 });
|
|
161
|
+
return browserResult(result);
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
// ─── Tool: browser_click ───
|
|
166
|
+
const BrowserClickSchema = Type.Object({
|
|
167
|
+
selector: Type.String({ description: "Element ref from snapshot (e.g. '@e2') or CSS selector" }),
|
|
168
|
+
});
|
|
169
|
+
function createBrowserClickTool(session, profileDir) {
|
|
170
|
+
return {
|
|
171
|
+
name: "browser_click",
|
|
172
|
+
label: "Browser Click",
|
|
173
|
+
description: "Click an element. Use refs from snapshot (e.g. @e2) for reliable targeting.",
|
|
174
|
+
parameters: BrowserClickSchema,
|
|
175
|
+
async execute(_id, params, signal) {
|
|
176
|
+
const result = await execBrowserAsync(["click", params.selector], { session, profileDir, signal });
|
|
177
|
+
return browserResult(result);
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
// ─── Tool: browser_fill ───
|
|
182
|
+
const BrowserFillSchema = Type.Object({
|
|
183
|
+
selector: Type.String({ description: "Element ref from snapshot (e.g. '@e3') or CSS selector" }),
|
|
184
|
+
text: Type.String({ description: "Text to fill into the input" }),
|
|
185
|
+
});
|
|
186
|
+
function createBrowserFillTool(session, profileDir) {
|
|
187
|
+
return {
|
|
188
|
+
name: "browser_fill",
|
|
189
|
+
label: "Browser Fill",
|
|
190
|
+
description: "Clear an input field and type new text. Use refs from snapshot for targeting.",
|
|
191
|
+
parameters: BrowserFillSchema,
|
|
192
|
+
async execute(_id, params, signal) {
|
|
193
|
+
const result = await execBrowserAsync(["fill", params.selector, params.text], { session, profileDir, signal });
|
|
194
|
+
return browserResult(result);
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
// ─── Tool: browser_type ───
|
|
199
|
+
const BrowserTypeSchema = Type.Object({
|
|
200
|
+
selector: Type.String({ description: "Element ref or CSS selector" }),
|
|
201
|
+
text: Type.String({ description: "Text to type (appends to existing content)" }),
|
|
202
|
+
});
|
|
203
|
+
function createBrowserTypeTool(session, profileDir) {
|
|
204
|
+
return {
|
|
205
|
+
name: "browser_type",
|
|
206
|
+
label: "Browser Type",
|
|
207
|
+
description: "Type text into an element without clearing it first. Use for appending text.",
|
|
208
|
+
parameters: BrowserTypeSchema,
|
|
209
|
+
async execute(_id, params, signal) {
|
|
210
|
+
const result = await execBrowserAsync(["type", params.selector, params.text], { session, profileDir, signal });
|
|
211
|
+
return browserResult(result);
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
// ─── Tool: browser_press ───
|
|
216
|
+
const BrowserPressSchema = Type.Object({
|
|
217
|
+
key: Type.String({ description: "Key to press (e.g. 'Enter', 'Tab', 'Control+a', 'Escape')" }),
|
|
218
|
+
});
|
|
219
|
+
function createBrowserPressTool(session, profileDir) {
|
|
220
|
+
return {
|
|
221
|
+
name: "browser_press",
|
|
222
|
+
label: "Browser Press Key",
|
|
223
|
+
description: "Press a keyboard key. Supports modifiers like 'Control+a', 'Shift+Enter'.",
|
|
224
|
+
parameters: BrowserPressSchema,
|
|
225
|
+
async execute(_id, params, signal) {
|
|
226
|
+
const result = await execBrowserAsync(["press", params.key], { session, profileDir, signal });
|
|
227
|
+
return browserResult(result);
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
// ─── Tool: browser_screenshot ───
|
|
232
|
+
const BrowserScreenshotSchema = Type.Object({
|
|
233
|
+
path: Type.Optional(Type.String({ description: "File path to save screenshot (default: auto-generated temp path)" })),
|
|
234
|
+
full_page: Type.Optional(Type.Boolean({ description: "Capture full page, not just viewport" })),
|
|
235
|
+
});
|
|
236
|
+
function createBrowserScreenshotTool(session, cwd, profileDir) {
|
|
237
|
+
return {
|
|
238
|
+
name: "browser_screenshot",
|
|
239
|
+
label: "Browser Screenshot",
|
|
240
|
+
description: "Take a screenshot of the current page. Returns the file path of the saved image.",
|
|
241
|
+
parameters: BrowserScreenshotSchema,
|
|
242
|
+
async execute(_id, params, signal) {
|
|
243
|
+
const args = ["screenshot"];
|
|
244
|
+
if (params.path)
|
|
245
|
+
args.push(resolve(cwd, params.path));
|
|
246
|
+
if (params.full_page)
|
|
247
|
+
args.push("--full");
|
|
248
|
+
const result = await execBrowserAsync(args, { session, profileDir, signal });
|
|
249
|
+
return browserResult(result);
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
// ─── Tool: browser_get ───
|
|
254
|
+
const BrowserGetSchema = Type.Object({
|
|
255
|
+
what: Type.Union([
|
|
256
|
+
Type.Literal("text"),
|
|
257
|
+
Type.Literal("html"),
|
|
258
|
+
Type.Literal("value"),
|
|
259
|
+
Type.Literal("title"),
|
|
260
|
+
Type.Literal("url"),
|
|
261
|
+
], { description: "What to retrieve: text, html, value, title, or url" }),
|
|
262
|
+
selector: Type.Optional(Type.String({ description: "Element ref or CSS selector (required for text/html/value)" })),
|
|
263
|
+
});
|
|
264
|
+
function createBrowserGetTool(session, profileDir) {
|
|
265
|
+
return {
|
|
266
|
+
name: "browser_get",
|
|
267
|
+
label: "Browser Get Info",
|
|
268
|
+
description: "Get information from the browser: element text/html/value, page title, or current URL.",
|
|
269
|
+
parameters: BrowserGetSchema,
|
|
270
|
+
async execute(_id, params, signal) {
|
|
271
|
+
const args = ["get", params.what];
|
|
272
|
+
if (params.selector)
|
|
273
|
+
args.push(params.selector);
|
|
274
|
+
const result = await execBrowserAsync(args, { session, profileDir, signal });
|
|
275
|
+
return browserResult(result);
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
// ─── Tool: browser_select ───
|
|
280
|
+
const BrowserSelectSchema = Type.Object({
|
|
281
|
+
selector: Type.String({ description: "Element ref or CSS selector for the <select> element" }),
|
|
282
|
+
value: Type.String({ description: "Option value to select" }),
|
|
283
|
+
});
|
|
284
|
+
function createBrowserSelectTool(session, profileDir) {
|
|
285
|
+
return {
|
|
286
|
+
name: "browser_select",
|
|
287
|
+
label: "Browser Select",
|
|
288
|
+
description: "Select an option from a dropdown <select> element.",
|
|
289
|
+
parameters: BrowserSelectSchema,
|
|
290
|
+
async execute(_id, params, signal) {
|
|
291
|
+
const result = await execBrowserAsync(["select", params.selector, params.value], { session, profileDir, signal });
|
|
292
|
+
return browserResult(result);
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
// ─── Tool: browser_hover ───
|
|
297
|
+
const BrowserHoverSchema = Type.Object({
|
|
298
|
+
selector: Type.String({ description: "Element ref or CSS selector to hover" }),
|
|
299
|
+
});
|
|
300
|
+
function createBrowserHoverTool(session, profileDir) {
|
|
301
|
+
return {
|
|
302
|
+
name: "browser_hover",
|
|
303
|
+
label: "Browser Hover",
|
|
304
|
+
description: "Hover over an element to trigger hover states, tooltips, or dropdown menus.",
|
|
305
|
+
parameters: BrowserHoverSchema,
|
|
306
|
+
async execute(_id, params, signal) {
|
|
307
|
+
const result = await execBrowserAsync(["hover", params.selector], { session, profileDir, signal });
|
|
308
|
+
return browserResult(result);
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
// ─── Tool: browser_scroll ───
|
|
313
|
+
const BrowserScrollSchema = Type.Object({
|
|
314
|
+
direction: Type.Union([
|
|
315
|
+
Type.Literal("up"),
|
|
316
|
+
Type.Literal("down"),
|
|
317
|
+
Type.Literal("left"),
|
|
318
|
+
Type.Literal("right"),
|
|
319
|
+
], { description: "Scroll direction" }),
|
|
320
|
+
pixels: Type.Optional(Type.Number({ description: "Number of pixels to scroll (default: varies)" })),
|
|
321
|
+
});
|
|
322
|
+
function createBrowserScrollTool(session, profileDir) {
|
|
323
|
+
return {
|
|
324
|
+
name: "browser_scroll",
|
|
325
|
+
label: "Browser Scroll",
|
|
326
|
+
description: "Scroll the page in a direction. Useful for loading lazy content or navigating long pages.",
|
|
327
|
+
parameters: BrowserScrollSchema,
|
|
328
|
+
async execute(_id, params, signal) {
|
|
329
|
+
const args = ["scroll", params.direction];
|
|
330
|
+
if (params.pixels)
|
|
331
|
+
args.push(String(params.pixels));
|
|
332
|
+
const result = await execBrowserAsync(args, { session, profileDir, signal });
|
|
333
|
+
return browserResult(result);
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
// ─── Tool: browser_wait ───
|
|
338
|
+
const BrowserWaitSchema = Type.Object({
|
|
339
|
+
selector: Type.Optional(Type.String({ description: "CSS selector or ref to wait for" })),
|
|
340
|
+
text: Type.Optional(Type.String({ description: "Wait for text to appear on page" })),
|
|
341
|
+
url: Type.Optional(Type.String({ description: "Wait for URL pattern (glob)" })),
|
|
342
|
+
timeout_ms: Type.Optional(Type.Number({ description: "Wait for milliseconds" })),
|
|
343
|
+
load_state: Type.Optional(Type.Union([
|
|
344
|
+
Type.Literal("load"),
|
|
345
|
+
Type.Literal("domcontentloaded"),
|
|
346
|
+
Type.Literal("networkidle"),
|
|
347
|
+
], { description: "Wait for load state" })),
|
|
348
|
+
});
|
|
349
|
+
function createBrowserWaitTool(session, profileDir) {
|
|
350
|
+
return {
|
|
351
|
+
name: "browser_wait",
|
|
352
|
+
label: "Browser Wait",
|
|
353
|
+
description: "Wait for an element, text, URL pattern, or load state. Use after navigation or actions that trigger async content.",
|
|
354
|
+
parameters: BrowserWaitSchema,
|
|
355
|
+
async execute(_id, params, signal) {
|
|
356
|
+
const args = ["wait"];
|
|
357
|
+
if (params.selector)
|
|
358
|
+
args.push(params.selector);
|
|
359
|
+
if (params.text)
|
|
360
|
+
args.push("--text", params.text);
|
|
361
|
+
if (params.url)
|
|
362
|
+
args.push("--url", params.url);
|
|
363
|
+
if (params.timeout_ms)
|
|
364
|
+
args.push(String(params.timeout_ms));
|
|
365
|
+
if (params.load_state)
|
|
366
|
+
args.push("--load", params.load_state);
|
|
367
|
+
const result = await execBrowserAsync(args, { session, profileDir, signal, timeout: 60_000 });
|
|
368
|
+
return browserResult(result);
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
// ─── Tool: browser_eval ───
|
|
373
|
+
const BrowserEvalSchema = Type.Object({
|
|
374
|
+
javascript: Type.String({ description: "JavaScript code to execute in the browser page context" }),
|
|
375
|
+
});
|
|
376
|
+
function createBrowserEvalTool(session, profileDir) {
|
|
377
|
+
return {
|
|
378
|
+
name: "browser_eval",
|
|
379
|
+
label: "Browser Evaluate JS",
|
|
380
|
+
description: "Execute JavaScript in the browser page context and return the result. " +
|
|
381
|
+
"Use for reading DOM properties, manipulating the page, or extracting data not available via snapshot.",
|
|
382
|
+
parameters: BrowserEvalSchema,
|
|
383
|
+
async execute(_id, params, signal) {
|
|
384
|
+
// Use base64 encoding for safe transport of complex JS
|
|
385
|
+
const b64 = Buffer.from(params.javascript).toString("base64");
|
|
386
|
+
const result = await execBrowserAsync(["eval", b64, "-b"], { session, profileDir, signal });
|
|
387
|
+
return browserResult(result);
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
// ─── Tool: browser_close ───
|
|
392
|
+
const BrowserCloseSchema = Type.Object({});
|
|
393
|
+
function createBrowserCloseTool(session) {
|
|
394
|
+
return {
|
|
395
|
+
name: "browser_close",
|
|
396
|
+
label: "Browser Close",
|
|
397
|
+
description: "Close the browser session. Profile data (cookies, login) is saved automatically.",
|
|
398
|
+
parameters: BrowserCloseSchema,
|
|
399
|
+
async execute(_id, _params, signal) {
|
|
400
|
+
const result = await execBrowserAsync(["close"], { session, signal });
|
|
401
|
+
return browserResult(result);
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
// ─── Tool: browser_back / browser_forward / browser_reload ───
|
|
406
|
+
const BrowserNavActionSchema = Type.Object({});
|
|
407
|
+
function createBrowserBackTool(session, profileDir) {
|
|
408
|
+
return {
|
|
409
|
+
name: "browser_back",
|
|
410
|
+
label: "Browser Back",
|
|
411
|
+
description: "Navigate back in browser history.",
|
|
412
|
+
parameters: BrowserNavActionSchema,
|
|
413
|
+
async execute(_id, _params, signal) {
|
|
414
|
+
return browserResult(await execBrowserAsync(["back"], { session, profileDir, signal }));
|
|
415
|
+
},
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function createBrowserForwardTool(session, profileDir) {
|
|
419
|
+
return {
|
|
420
|
+
name: "browser_forward",
|
|
421
|
+
label: "Browser Forward",
|
|
422
|
+
description: "Navigate forward in browser history.",
|
|
423
|
+
parameters: BrowserNavActionSchema,
|
|
424
|
+
async execute(_id, _params, signal) {
|
|
425
|
+
return browserResult(await execBrowserAsync(["forward"], { session, profileDir, signal }));
|
|
426
|
+
},
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
function createBrowserReloadTool(session, profileDir) {
|
|
430
|
+
return {
|
|
431
|
+
name: "browser_reload",
|
|
432
|
+
label: "Browser Reload",
|
|
433
|
+
description: "Reload the current page.",
|
|
434
|
+
parameters: BrowserNavActionSchema,
|
|
435
|
+
async execute(_id, _params, signal) {
|
|
436
|
+
return browserResult(await execBrowserAsync(["reload"], { session, profileDir, signal }));
|
|
437
|
+
},
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
// ─── Tool: browser_tabs ───
|
|
441
|
+
const BrowserTabsSchema = Type.Object({
|
|
442
|
+
action: Type.Union([
|
|
443
|
+
Type.Literal("list"),
|
|
444
|
+
Type.Literal("new"),
|
|
445
|
+
Type.Literal("switch"),
|
|
446
|
+
Type.Literal("close"),
|
|
447
|
+
], { description: "Tab action: list, new, switch, or close" }),
|
|
448
|
+
index: Type.Optional(Type.Number({ description: "Tab index for switch/close actions" })),
|
|
449
|
+
url: Type.Optional(Type.String({ description: "URL to open in new tab" })),
|
|
450
|
+
});
|
|
451
|
+
function createBrowserTabsTool(session, profileDir) {
|
|
452
|
+
return {
|
|
453
|
+
name: "browser_tabs",
|
|
454
|
+
label: "Browser Tabs",
|
|
455
|
+
description: "Manage browser tabs: list open tabs, open new tab, switch to tab, or close tab.",
|
|
456
|
+
parameters: BrowserTabsSchema,
|
|
457
|
+
async execute(_id, params, signal) {
|
|
458
|
+
const args = ["tab"];
|
|
459
|
+
switch (params.action) {
|
|
460
|
+
case "list":
|
|
461
|
+
break;
|
|
462
|
+
case "new":
|
|
463
|
+
args.push("new");
|
|
464
|
+
if (params.url)
|
|
465
|
+
args.push(params.url);
|
|
466
|
+
break;
|
|
467
|
+
case "switch":
|
|
468
|
+
if (params.index !== undefined)
|
|
469
|
+
args.push(String(params.index));
|
|
470
|
+
break;
|
|
471
|
+
case "close":
|
|
472
|
+
args.push("close");
|
|
473
|
+
if (params.index !== undefined)
|
|
474
|
+
args.push(String(params.index));
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
const result = await execBrowserAsync(args, { session, profileDir, signal });
|
|
478
|
+
return browserResult(result);
|
|
479
|
+
},
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
export const ALL_BROWSER_TOOL_NAMES = [
|
|
483
|
+
"browser_navigate", "browser_snapshot", "browser_click", "browser_fill",
|
|
484
|
+
"browser_type", "browser_press", "browser_screenshot", "browser_get",
|
|
485
|
+
"browser_select", "browser_hover", "browser_scroll", "browser_wait",
|
|
486
|
+
"browser_eval", "browser_close", "browser_back", "browser_forward",
|
|
487
|
+
"browser_reload", "browser_tabs",
|
|
488
|
+
];
|
|
489
|
+
/**
|
|
490
|
+
* Create browser automation tools powered by agent-browser CLI.
|
|
491
|
+
*
|
|
492
|
+
* @param cwd - Working directory for resolving relative file paths (screenshots)
|
|
493
|
+
* @param session - Browser session name for isolation (default: agent name or "default")
|
|
494
|
+
* @param allowedTools - Optional filter: only include tools with these names
|
|
495
|
+
* @param profileDir - Persistent browser profile directory. Passed as --profile to agent-browser.
|
|
496
|
+
* Stores cookies, localStorage, auth state across sessions.
|
|
497
|
+
* Typically `.polpo/browser-profiles/<agent>/`.
|
|
498
|
+
*/
|
|
499
|
+
export function createBrowserTools(cwd, session = "default", allowedTools, profileDir) {
|
|
500
|
+
const factories = {
|
|
501
|
+
browser_navigate: () => createBrowserNavigateTool(session, profileDir),
|
|
502
|
+
browser_snapshot: () => createBrowserSnapshotTool(session, profileDir),
|
|
503
|
+
browser_click: () => createBrowserClickTool(session, profileDir),
|
|
504
|
+
browser_fill: () => createBrowserFillTool(session, profileDir),
|
|
505
|
+
browser_type: () => createBrowserTypeTool(session, profileDir),
|
|
506
|
+
browser_press: () => createBrowserPressTool(session, profileDir),
|
|
507
|
+
browser_screenshot: () => createBrowserScreenshotTool(session, cwd, profileDir),
|
|
508
|
+
browser_get: () => createBrowserGetTool(session, profileDir),
|
|
509
|
+
browser_select: () => createBrowserSelectTool(session, profileDir),
|
|
510
|
+
browser_hover: () => createBrowserHoverTool(session, profileDir),
|
|
511
|
+
browser_scroll: () => createBrowserScrollTool(session, profileDir),
|
|
512
|
+
browser_wait: () => createBrowserWaitTool(session, profileDir),
|
|
513
|
+
browser_eval: () => createBrowserEvalTool(session, profileDir),
|
|
514
|
+
browser_close: () => createBrowserCloseTool(session),
|
|
515
|
+
browser_back: () => createBrowserBackTool(session, profileDir),
|
|
516
|
+
browser_forward: () => createBrowserForwardTool(session, profileDir),
|
|
517
|
+
browser_reload: () => createBrowserReloadTool(session, profileDir),
|
|
518
|
+
browser_tabs: () => createBrowserTabsTool(session, profileDir),
|
|
519
|
+
};
|
|
520
|
+
const names = allowedTools
|
|
521
|
+
? ALL_BROWSER_TOOL_NAMES.filter(n => allowedTools.some(a => a.toLowerCase() === n))
|
|
522
|
+
: ALL_BROWSER_TOOL_NAMES;
|
|
523
|
+
return names.map(n => factories[n]());
|
|
524
|
+
}
|
|
525
|
+
//# sourceMappingURL=browser-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-tools.js","sourceRoot":"","sources":["../src/browser-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACh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C,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;QACnF,CAAC,CAAC,sBAAsB,CAAC;IAE3B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard coding tools for the native pi adapter.
|
|
3
|
+
* Each tool implements pi-agent-core's AgentTool interface with TypeBox schemas.
|
|
4
|
+
*
|
|
5
|
+
* All file-based tools enforce path sandboxing when allowedPaths is provided.
|
|
6
|
+
* The bash tool runs with cwd set to the agent's primary working directory.
|
|
7
|
+
*/
|
|
8
|
+
import type { FileSystem } from "@polpo-ai/core/filesystem";
|
|
9
|
+
import type { Shell } from "@polpo-ai/core/shell";
|
|
10
|
+
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
11
|
+
import type { ResolvedVault } from "./types.js";
|
|
12
|
+
import type { WhatsAppStore } from "./types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Check if a tool name matches an allowed pattern.
|
|
15
|
+
* Supports exact match and trailing wildcard: "browser_*" matches "browser_navigate".
|
|
16
|
+
*/
|
|
17
|
+
export declare function matchToolPattern(pattern: string, toolName: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Expand wildcard patterns in an allowedTools list against all known tool names.
|
|
20
|
+
* E.g. ["browser_*", "http_fetch"] → ["browser_navigate", "browser_click", ..., "http_fetch"].
|
|
21
|
+
* Non-wildcard entries pass through as-is (even if not in allNames — factory will just skip them).
|
|
22
|
+
*/
|
|
23
|
+
export declare function expandToolWildcards(allowedTools: string[], allNames: readonly string[]): string[];
|
|
24
|
+
/** Tool name to filter by in allowedTools config */
|
|
25
|
+
type CodingToolName = "read" | "write" | "edit" | "bash" | "glob" | "grep" | "ls";
|
|
26
|
+
/**
|
|
27
|
+
* Create the standard set of coding tools scoped to a working directory.
|
|
28
|
+
* If allowedTools is provided, only those tools are included.
|
|
29
|
+
* If allowedPaths is provided, file-based tools enforce path sandboxing.
|
|
30
|
+
*
|
|
31
|
+
* Core tools (always included regardless of allowedTools):
|
|
32
|
+
* - read, write, edit, bash, glob, grep, ls
|
|
33
|
+
* - register_outcome
|
|
34
|
+
* - http_fetch, http_download
|
|
35
|
+
* - vault_get, vault_list (when vault is provided)
|
|
36
|
+
*/
|
|
37
|
+
export declare function createCodingTools(cwd: string, allowedTools?: string[], allowedPaths?: string[], outputDir?: string, vault?: ResolvedVault, fs?: FileSystem, shell?: Shell): AgentTool<any>[];
|
|
38
|
+
export type { BrowserToolName } from "./browser-tools.js";
|
|
39
|
+
export type { HttpToolName } from "./http-tools.js";
|
|
40
|
+
export type { EmailToolName } from "./email-tools.js";
|
|
41
|
+
export type { OutcomeToolName } from "./outcome-tools.js";
|
|
42
|
+
export type { VaultToolName } from "./vault-tools.js";
|
|
43
|
+
export type { ImageToolName } from "./image-tools.js";
|
|
44
|
+
export type { AudioToolName } from "./audio-tools.js";
|
|
45
|
+
export type { ExcelToolName } from "./excel-tools.js";
|
|
46
|
+
export type { PdfToolName } from "./pdf-tools.js";
|
|
47
|
+
export type { DocxToolName } from "./docx-tools.js";
|
|
48
|
+
export type { SearchToolName } from "./search-tools.js";
|
|
49
|
+
export type { WhatsAppToolName } from "./whatsapp-tools.js";
|
|
50
|
+
export type { PhoneToolName } from "./phone-tools.js";
|
|
51
|
+
export type InkToolName = string;
|
|
52
|
+
/** All known tool names across all categories */
|
|
53
|
+
export type ExtendedToolName = CodingToolName | import("./browser-tools.js").BrowserToolName | import("./http-tools.js").HttpToolName | import("./email-tools.js").EmailToolName | import("./outcome-tools.js").OutcomeToolName | import("./vault-tools.js").VaultToolName | import("./image-tools.js").ImageToolName | import("./audio-tools.js").AudioToolName | import("./excel-tools.js").ExcelToolName | import("./pdf-tools.js").PdfToolName | import("./docx-tools.js").DocxToolName | import("./search-tools.js").SearchToolName | import("./whatsapp-tools.js").WhatsAppToolName | import("./phone-tools.js").PhoneToolName | InkToolName;
|
|
54
|
+
/** All available tool names for documentation/config validation */
|
|
55
|
+
export declare const ALL_EXTENDED_TOOL_NAMES: string[];
|
|
56
|
+
export interface CreateAllToolsOptions {
|
|
57
|
+
/** Working directory for the agent */
|
|
58
|
+
cwd: string;
|
|
59
|
+
/** Tool name filter — only include tools with these names.
|
|
60
|
+
* Extended tools are auto-loaded when their names appear here (e.g. "browser_*", "email_*", "image_*", "video_*", "audio_*", "excel_*", "pdf_*", "docx_*").
|
|
61
|
+
* If omitted, only core coding tools are included. */
|
|
62
|
+
allowedTools?: string[];
|
|
63
|
+
/** Filesystem sandbox paths */
|
|
64
|
+
allowedPaths?: string[];
|
|
65
|
+
/** Browser session name for isolation (default: "default"). */
|
|
66
|
+
browserSession?: string;
|
|
67
|
+
/** Browser profile directory for agent-browser persistent state (cookies, localStorage).
|
|
68
|
+
* Typically `.polpo/browser-profiles/<agent>/`. Passed as --profile to agent-browser. */
|
|
69
|
+
browserProfileDir?: string;
|
|
70
|
+
/** Resolved vault credentials for the agent */
|
|
71
|
+
vault?: ResolvedVault;
|
|
72
|
+
/** Allowed recipient email domains for email_send. */
|
|
73
|
+
emailAllowedDomains?: string[];
|
|
74
|
+
/** Per-task output directory for deliverables. Passed to outcome tools. */
|
|
75
|
+
outputDir?: string;
|
|
76
|
+
/** WhatsApp message store (for whatsapp_* tools). */
|
|
77
|
+
whatsappStore?: WhatsAppStore;
|
|
78
|
+
/** WhatsApp send function (for whatsapp_send tool). */
|
|
79
|
+
whatsappSendMessage?: (jid: string, text: string) => Promise<string | undefined>;
|
|
80
|
+
/** Polpo directory (.polpo/) for Ink tools. */
|
|
81
|
+
polpoDir?: string;
|
|
82
|
+
/** FileSystem implementation (default: NodeFileSystem). */
|
|
83
|
+
fs?: FileSystem;
|
|
84
|
+
/** Shell implementation (default: NodeShell). */
|
|
85
|
+
shell?: Shell;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Create all available tools for an agent, including extended tool categories.
|
|
89
|
+
*
|
|
90
|
+
* Core tools (always included): read, write, edit, bash, glob, grep, ls,
|
|
91
|
+
* register_outcome, http_fetch, http_download, vault_get, vault_list.
|
|
92
|
+
*
|
|
93
|
+
* Extended categories must be explicitly enabled via allowedTools patterns.
|
|
94
|
+
*
|
|
95
|
+
* When allowedTools is provided, it acts as a filter across ALL categories — any tool whose name
|
|
96
|
+
* appears in allowedTools will be included (and its category auto-enabled).
|
|
97
|
+
*/
|
|
98
|
+
export declare function createAllTools(options: CreateAllToolsOptions): Promise<AgentTool<any>[]>;
|
|
99
|
+
//# sourceMappingURL=coding-tools.d.ts.map
|