@askjo/camofox-browser 1.3.0 → 1.4.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/plugin.ts CHANGED
@@ -432,6 +432,29 @@ export default function register(api: PluginApi) {
432
432
  },
433
433
  }));
434
434
 
435
+ api.registerTool((ctx: ToolContext) => ({
436
+ name: "camofox_evaluate",
437
+ description:
438
+ "Execute JavaScript in a Camoufox tab's page context. Returns the result of the expression. Use for injecting scripts, reading page state, or calling web app APIs.",
439
+ parameters: {
440
+ type: "object",
441
+ properties: {
442
+ tabId: { type: "string", description: "Tab identifier" },
443
+ expression: { type: "string", description: "JavaScript expression to evaluate in the page context" },
444
+ },
445
+ required: ["tabId", "expression"],
446
+ },
447
+ async execute(_id, params) {
448
+ const { tabId, expression } = params as { tabId: string; expression: string };
449
+ const userId = ctx.agentId || fallbackUserId;
450
+ const result = await fetchApi(baseUrl, `/tabs/${tabId}/evaluate`, {
451
+ method: "POST",
452
+ body: { userId, expression },
453
+ });
454
+ return toToolResult(result);
455
+ },
456
+ }));
457
+
435
458
  api.registerTool((ctx: ToolContext) => ({
436
459
  name: "camofox_list_tabs",
437
460
  description: "List all open Camoufox tabs for a user.",
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Sync openclaw.plugin.json version with package.json.
4
+ * Run via: npm run version:sync
5
+ * Auto-runs on npm version via the "version" lifecycle script.
6
+ */
7
+
8
+ import { readFile, writeFile } from 'node:fs/promises';
9
+ import { fileURLToPath } from 'node:url';
10
+ import { dirname, join } from 'node:path';
11
+
12
+ const __dirname = dirname(fileURLToPath(import.meta.url));
13
+ const root = join(__dirname, '..');
14
+
15
+ const pkg = JSON.parse(await readFile(join(root, 'package.json'), 'utf8'));
16
+ const pluginPath = join(root, 'openclaw.plugin.json');
17
+ const plugin = JSON.parse(await readFile(pluginPath, 'utf8'));
18
+
19
+ if (plugin.version !== pkg.version) {
20
+ plugin.version = pkg.version;
21
+ await writeFile(pluginPath, JSON.stringify(plugin, null, 2) + '\n');
22
+ console.log(`openclaw.plugin.json version synced to ${pkg.version}`);
23
+ } else {
24
+ console.log(`openclaw.plugin.json already at ${pkg.version}`);
25
+ }