@askjo/camoufox-browser 1.0.3 → 1.0.5

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.
Files changed (2) hide show
  1. package/package.json +3 -1
  2. package/plugin.ts +228 -189
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askjo/camoufox-browser",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Headless browser automation server and OpenClaw plugin for AI agents - anti-detection, element refs, and session isolation",
5
5
  "main": "server-camoufox.js",
6
6
  "license": "MIT",
@@ -22,6 +22,8 @@
22
22
  "anti-detection",
23
23
  "ai-agent",
24
24
  "openclaw",
25
+ "clawdbot",
26
+ "moltbot",
25
27
  "playwright",
26
28
  "firefox"
27
29
  ],
package/plugin.ts CHANGED
@@ -13,14 +13,20 @@ interface PluginConfig {
13
13
  autoStart?: boolean;
14
14
  }
15
15
 
16
+ interface ToolResult {
17
+ content: Array<{ type: string; text: string }>;
18
+ }
19
+
16
20
  interface PluginApi {
17
- registerTool: (tool: {
18
- name: string;
19
- description: string;
20
- parameters: object;
21
- optional?: boolean;
22
- handler: (params: Record<string, unknown>) => Promise<unknown>;
23
- }) => void;
21
+ registerTool: (
22
+ tool: {
23
+ name: string;
24
+ description: string;
25
+ parameters: object;
26
+ execute: (id: string, params: Record<string, unknown>) => Promise<ToolResult>;
27
+ },
28
+ options?: { optional?: boolean }
29
+ ) => void;
24
30
  registerCommand: (cmd: {
25
31
  name: string;
26
32
  description: string;
@@ -55,218 +61,251 @@ async function fetchApi(
55
61
  return res.json();
56
62
  }
57
63
 
64
+ function toToolResult(data: unknown): ToolResult {
65
+ return {
66
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
67
+ };
68
+ }
69
+
58
70
  export default function register(api: PluginApi) {
59
71
  const baseUrl = api.config.url || "http://localhost:9377";
60
72
 
61
- api.registerTool({
62
- name: "camoufox_create_tab",
63
- description:
64
- "Create a new browser tab. Returns tabId for subsequent operations.",
65
- parameters: {
66
- type: "object",
67
- properties: {
68
- userId: { type: "string", description: "User identifier for session isolation" },
69
- listItemId: { type: "string", description: "Conversation/task identifier for tab grouping" },
70
- url: { type: "string", description: "Initial URL to navigate to" },
73
+ api.registerTool(
74
+ {
75
+ name: "camoufox_create_tab",
76
+ description:
77
+ "Create a new browser tab. Returns tabId for subsequent operations.",
78
+ parameters: {
79
+ type: "object",
80
+ properties: {
81
+ userId: { type: "string", description: "User identifier for session isolation" },
82
+ listItemId: { type: "string", description: "Conversation/task identifier for tab grouping" },
83
+ url: { type: "string", description: "Initial URL to navigate to" },
84
+ },
85
+ required: ["userId", "url"],
86
+ },
87
+ async execute(_id, params) {
88
+ const result = await fetchApi(baseUrl, "/tabs", {
89
+ method: "POST",
90
+ body: JSON.stringify(params),
91
+ });
92
+ return toToolResult(result);
71
93
  },
72
- required: ["userId", "url"],
73
- },
74
- optional: true,
75
- handler: async (params) => {
76
- return fetchApi(baseUrl, "/tabs", {
77
- method: "POST",
78
- body: JSON.stringify(params),
79
- });
80
94
  },
81
- });
95
+ { optional: true }
96
+ );
82
97
 
83
- api.registerTool({
84
- name: "camoufox_snapshot",
85
- description:
86
- "Get accessibility snapshot of a page with element refs (e1, e2, etc.) for interaction.",
87
- parameters: {
88
- type: "object",
89
- properties: {
90
- tabId: { type: "string", description: "Tab identifier" },
91
- userId: { type: "string", description: "User identifier" },
98
+ api.registerTool(
99
+ {
100
+ name: "camoufox_snapshot",
101
+ description:
102
+ "Get accessibility snapshot of a page with element refs (e1, e2, etc.) for interaction.",
103
+ parameters: {
104
+ type: "object",
105
+ properties: {
106
+ tabId: { type: "string", description: "Tab identifier" },
107
+ userId: { type: "string", description: "User identifier" },
108
+ },
109
+ required: ["tabId", "userId"],
110
+ },
111
+ async execute(_id, params) {
112
+ const { tabId, userId } = params as { tabId: string; userId: string };
113
+ const result = await fetchApi(baseUrl, `/tabs/${tabId}/snapshot?userId=${userId}`);
114
+ return toToolResult(result);
92
115
  },
93
- required: ["tabId", "userId"],
94
- },
95
- optional: true,
96
- handler: async (params) => {
97
- const { tabId, userId } = params as { tabId: string; userId: string };
98
- return fetchApi(baseUrl, `/tabs/${tabId}/snapshot?userId=${userId}`);
99
116
  },
100
- });
117
+ { optional: true }
118
+ );
101
119
 
102
- api.registerTool({
103
- name: "camoufox_click",
104
- description: "Click an element by ref (e.g., e1) or CSS selector.",
105
- parameters: {
106
- type: "object",
107
- properties: {
108
- tabId: { type: "string", description: "Tab identifier" },
109
- userId: { type: "string", description: "User identifier" },
110
- ref: { type: "string", description: "Element ref from snapshot (e.g., e1)" },
111
- selector: { type: "string", description: "CSS selector (alternative to ref)" },
120
+ api.registerTool(
121
+ {
122
+ name: "camoufox_click",
123
+ description: "Click an element by ref (e.g., e1) or CSS selector.",
124
+ parameters: {
125
+ type: "object",
126
+ properties: {
127
+ tabId: { type: "string", description: "Tab identifier" },
128
+ userId: { type: "string", description: "User identifier" },
129
+ ref: { type: "string", description: "Element ref from snapshot (e.g., e1)" },
130
+ selector: { type: "string", description: "CSS selector (alternative to ref)" },
131
+ },
132
+ required: ["tabId", "userId"],
133
+ },
134
+ async execute(_id, params) {
135
+ const { tabId, ...body } = params as { tabId: string } & Record<string, unknown>;
136
+ const result = await fetchApi(baseUrl, `/tabs/${tabId}/click`, {
137
+ method: "POST",
138
+ body: JSON.stringify(body),
139
+ });
140
+ return toToolResult(result);
112
141
  },
113
- required: ["tabId", "userId"],
114
- },
115
- optional: true,
116
- handler: async (params) => {
117
- const { tabId, ...body } = params as { tabId: string } & Record<string, unknown>;
118
- return fetchApi(baseUrl, `/tabs/${tabId}/click`, {
119
- method: "POST",
120
- body: JSON.stringify(body),
121
- });
122
142
  },
123
- });
143
+ { optional: true }
144
+ );
124
145
 
125
- api.registerTool({
126
- name: "camoufox_type",
127
- description: "Type text into an element.",
128
- parameters: {
129
- type: "object",
130
- properties: {
131
- tabId: { type: "string", description: "Tab identifier" },
132
- userId: { type: "string", description: "User identifier" },
133
- ref: { type: "string", description: "Element ref from snapshot (e.g., e2)" },
134
- selector: { type: "string", description: "CSS selector (alternative to ref)" },
135
- text: { type: "string", description: "Text to type" },
136
- pressEnter: { type: "boolean", description: "Press Enter after typing" },
146
+ api.registerTool(
147
+ {
148
+ name: "camoufox_type",
149
+ description: "Type text into an element.",
150
+ parameters: {
151
+ type: "object",
152
+ properties: {
153
+ tabId: { type: "string", description: "Tab identifier" },
154
+ userId: { type: "string", description: "User identifier" },
155
+ ref: { type: "string", description: "Element ref from snapshot (e.g., e2)" },
156
+ selector: { type: "string", description: "CSS selector (alternative to ref)" },
157
+ text: { type: "string", description: "Text to type" },
158
+ pressEnter: { type: "boolean", description: "Press Enter after typing" },
159
+ },
160
+ required: ["tabId", "userId", "text"],
161
+ },
162
+ async execute(_id, params) {
163
+ const { tabId, ...body } = params as { tabId: string } & Record<string, unknown>;
164
+ const result = await fetchApi(baseUrl, `/tabs/${tabId}/type`, {
165
+ method: "POST",
166
+ body: JSON.stringify(body),
167
+ });
168
+ return toToolResult(result);
137
169
  },
138
- required: ["tabId", "userId", "text"],
139
- },
140
- optional: true,
141
- handler: async (params) => {
142
- const { tabId, ...body } = params as { tabId: string } & Record<string, unknown>;
143
- return fetchApi(baseUrl, `/tabs/${tabId}/type`, {
144
- method: "POST",
145
- body: JSON.stringify(body),
146
- });
147
170
  },
148
- });
171
+ { optional: true }
172
+ );
149
173
 
150
- api.registerTool({
151
- name: "camoufox_navigate",
152
- description:
153
- "Navigate to a URL or use a search macro (@google_search, @youtube_search, etc.).",
154
- parameters: {
155
- type: "object",
156
- properties: {
157
- tabId: { type: "string", description: "Tab identifier" },
158
- userId: { type: "string", description: "User identifier" },
159
- url: { type: "string", description: "URL to navigate to" },
160
- macro: {
161
- type: "string",
162
- description: "Search macro (e.g., @google_search, @youtube_search)",
163
- enum: [
164
- "@google_search",
165
- "@youtube_search",
166
- "@amazon_search",
167
- "@reddit_search",
168
- "@wikipedia_search",
169
- "@twitter_search",
170
- "@yelp_search",
171
- "@spotify_search",
172
- "@netflix_search",
173
- "@linkedin_search",
174
- "@instagram_search",
175
- "@tiktok_search",
176
- "@twitch_search",
177
- ],
174
+ api.registerTool(
175
+ {
176
+ name: "camoufox_navigate",
177
+ description:
178
+ "Navigate to a URL or use a search macro (@google_search, @youtube_search, etc.).",
179
+ parameters: {
180
+ type: "object",
181
+ properties: {
182
+ tabId: { type: "string", description: "Tab identifier" },
183
+ userId: { type: "string", description: "User identifier" },
184
+ url: { type: "string", description: "URL to navigate to" },
185
+ macro: {
186
+ type: "string",
187
+ description: "Search macro (e.g., @google_search, @youtube_search)",
188
+ enum: [
189
+ "@google_search",
190
+ "@youtube_search",
191
+ "@amazon_search",
192
+ "@reddit_search",
193
+ "@wikipedia_search",
194
+ "@twitter_search",
195
+ "@yelp_search",
196
+ "@spotify_search",
197
+ "@netflix_search",
198
+ "@linkedin_search",
199
+ "@instagram_search",
200
+ "@tiktok_search",
201
+ "@twitch_search",
202
+ ],
203
+ },
204
+ query: { type: "string", description: "Search query (when using macro)" },
178
205
  },
179
- query: { type: "string", description: "Search query (when using macro)" },
206
+ required: ["tabId", "userId"],
207
+ },
208
+ async execute(_id, params) {
209
+ const { tabId, ...body } = params as { tabId: string } & Record<string, unknown>;
210
+ const result = await fetchApi(baseUrl, `/tabs/${tabId}/navigate`, {
211
+ method: "POST",
212
+ body: JSON.stringify(body),
213
+ });
214
+ return toToolResult(result);
180
215
  },
181
- required: ["tabId", "userId"],
182
- },
183
- optional: true,
184
- handler: async (params) => {
185
- const { tabId, ...body } = params as { tabId: string } & Record<string, unknown>;
186
- return fetchApi(baseUrl, `/tabs/${tabId}/navigate`, {
187
- method: "POST",
188
- body: JSON.stringify(body),
189
- });
190
216
  },
191
- });
217
+ { optional: true }
218
+ );
192
219
 
193
- api.registerTool({
194
- name: "camoufox_scroll",
195
- description: "Scroll the page.",
196
- parameters: {
197
- type: "object",
198
- properties: {
199
- tabId: { type: "string", description: "Tab identifier" },
200
- userId: { type: "string", description: "User identifier" },
201
- direction: { type: "string", enum: ["up", "down", "left", "right"] },
202
- amount: { type: "number", description: "Pixels to scroll" },
220
+ api.registerTool(
221
+ {
222
+ name: "camoufox_scroll",
223
+ description: "Scroll the page.",
224
+ parameters: {
225
+ type: "object",
226
+ properties: {
227
+ tabId: { type: "string", description: "Tab identifier" },
228
+ userId: { type: "string", description: "User identifier" },
229
+ direction: { type: "string", enum: ["up", "down", "left", "right"] },
230
+ amount: { type: "number", description: "Pixels to scroll" },
231
+ },
232
+ required: ["tabId", "userId", "direction"],
233
+ },
234
+ async execute(_id, params) {
235
+ const { tabId, ...body } = params as { tabId: string } & Record<string, unknown>;
236
+ const result = await fetchApi(baseUrl, `/tabs/${tabId}/scroll`, {
237
+ method: "POST",
238
+ body: JSON.stringify(body),
239
+ });
240
+ return toToolResult(result);
203
241
  },
204
- required: ["tabId", "userId", "direction"],
205
- },
206
- optional: true,
207
- handler: async (params) => {
208
- const { tabId, ...body } = params as { tabId: string } & Record<string, unknown>;
209
- return fetchApi(baseUrl, `/tabs/${tabId}/scroll`, {
210
- method: "POST",
211
- body: JSON.stringify(body),
212
- });
213
242
  },
214
- });
243
+ { optional: true }
244
+ );
215
245
 
216
- api.registerTool({
217
- name: "camoufox_screenshot",
218
- description: "Take a screenshot of the current page.",
219
- parameters: {
220
- type: "object",
221
- properties: {
222
- tabId: { type: "string", description: "Tab identifier" },
223
- userId: { type: "string", description: "User identifier" },
246
+ api.registerTool(
247
+ {
248
+ name: "camoufox_screenshot",
249
+ description: "Take a screenshot of the current page.",
250
+ parameters: {
251
+ type: "object",
252
+ properties: {
253
+ tabId: { type: "string", description: "Tab identifier" },
254
+ userId: { type: "string", description: "User identifier" },
255
+ },
256
+ required: ["tabId", "userId"],
257
+ },
258
+ async execute(_id, params) {
259
+ const { tabId, userId } = params as { tabId: string; userId: string };
260
+ const result = await fetchApi(baseUrl, `/tabs/${tabId}/screenshot?userId=${userId}`);
261
+ return toToolResult(result);
224
262
  },
225
- required: ["tabId", "userId"],
226
- },
227
- optional: true,
228
- handler: async (params) => {
229
- const { tabId, userId } = params as { tabId: string; userId: string };
230
- return fetchApi(baseUrl, `/tabs/${tabId}/screenshot?userId=${userId}`);
231
263
  },
232
- });
264
+ { optional: true }
265
+ );
233
266
 
234
- api.registerTool({
235
- name: "camoufox_close_tab",
236
- description: "Close a browser tab.",
237
- parameters: {
238
- type: "object",
239
- properties: {
240
- tabId: { type: "string", description: "Tab identifier" },
241
- userId: { type: "string", description: "User identifier" },
267
+ api.registerTool(
268
+ {
269
+ name: "camoufox_close_tab",
270
+ description: "Close a browser tab.",
271
+ parameters: {
272
+ type: "object",
273
+ properties: {
274
+ tabId: { type: "string", description: "Tab identifier" },
275
+ userId: { type: "string", description: "User identifier" },
276
+ },
277
+ required: ["tabId", "userId"],
278
+ },
279
+ async execute(_id, params) {
280
+ const { tabId, userId } = params as { tabId: string; userId: string };
281
+ const result = await fetchApi(baseUrl, `/tabs/${tabId}?userId=${userId}`, {
282
+ method: "DELETE",
283
+ });
284
+ return toToolResult(result);
242
285
  },
243
- required: ["tabId", "userId"],
244
- },
245
- optional: true,
246
- handler: async (params) => {
247
- const { tabId, userId } = params as { tabId: string; userId: string };
248
- return fetchApi(baseUrl, `/tabs/${tabId}?userId=${userId}`, {
249
- method: "DELETE",
250
- });
251
286
  },
252
- });
287
+ { optional: true }
288
+ );
253
289
 
254
- api.registerTool({
255
- name: "camoufox_list_tabs",
256
- description: "List all open tabs for a user.",
257
- parameters: {
258
- type: "object",
259
- properties: {
260
- userId: { type: "string", description: "User identifier" },
290
+ api.registerTool(
291
+ {
292
+ name: "camoufox_list_tabs",
293
+ description: "List all open tabs for a user.",
294
+ parameters: {
295
+ type: "object",
296
+ properties: {
297
+ userId: { type: "string", description: "User identifier" },
298
+ },
299
+ required: ["userId"],
300
+ },
301
+ async execute(_id, params) {
302
+ const { userId } = params as { userId: string };
303
+ const result = await fetchApi(baseUrl, `/tabs?userId=${userId}`);
304
+ return toToolResult(result);
261
305
  },
262
- required: ["userId"],
263
- },
264
- optional: true,
265
- handler: async (params) => {
266
- const { userId } = params as { userId: string };
267
- return fetchApi(baseUrl, `/tabs?userId=${userId}`);
268
306
  },
269
- });
307
+ { optional: true }
308
+ );
270
309
 
271
310
  api.registerCommand({
272
311
  name: "camoufox",