@different-ai/opencode-browser 2.0.0 → 2.0.1

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 +1 -1
  2. package/src/plugin.ts +15 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@different-ai/opencode-browser",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Browser automation plugin for OpenCode. Control your real Chrome browser with existing logins and cookies.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/plugin.ts CHANGED
@@ -19,9 +19,11 @@ import { join } from "path";
19
19
  const WS_PORT = 19222;
20
20
  const BASE_DIR = join(homedir(), ".opencode-browser");
21
21
  const LOCK_FILE = join(BASE_DIR, "lock.json");
22
+ const SCREENSHOTS_DIR = join(BASE_DIR, "screenshots");
22
23
 
23
- // Ensure base dir exists
24
+ // Ensure directories exist
24
25
  mkdirSync(BASE_DIR, { recursive: true });
26
+ mkdirSync(SCREENSHOTS_DIR, { recursive: true });
25
27
 
26
28
  // Session state
27
29
  const sessionId = Math.random().toString(36).slice(2);
@@ -376,17 +378,26 @@ export const BrowserPlugin: Plugin = async (ctx) => {
376
378
  }),
377
379
 
378
380
  browser_screenshot: tool({
379
- description: "Take a screenshot of the current page",
381
+ description: "Take a screenshot of the current page. Saves to ~/.opencode-browser/screenshots/ and returns the file path.",
380
382
  args: {
381
383
  tabId: tool.schema.optional(tool.schema.number({ description: "Optional tab ID" })),
384
+ name: tool.schema.optional(tool.schema.string({ description: "Optional name for the screenshot file (without extension)" })),
382
385
  },
383
386
  async execute(args) {
384
387
  const result = await executeCommand("screenshot", args);
385
- // Return as base64 image
388
+
386
389
  if (result && result.startsWith("data:image")) {
390
+ // Extract base64 data and save to file
387
391
  const base64Data = result.replace(/^data:image\/\w+;base64,/, "");
388
- return { type: "image", data: base64Data, mimeType: "image/png" };
392
+ const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
393
+ const filename = args.name ? `${args.name}.png` : `screenshot-${timestamp}.png`;
394
+ const filepath = join(SCREENSHOTS_DIR, filename);
395
+
396
+ writeFileSync(filepath, Buffer.from(base64Data, "base64"));
397
+
398
+ return `Screenshot saved: ${filepath}`;
389
399
  }
400
+
390
401
  return result;
391
402
  },
392
403
  }),