@different-ai/opencode-browser 4.0.5 → 4.0.7
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/plugin.js +168 -85
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -12354,6 +12354,7 @@ function getPackageVersion() {
|
|
|
12354
12354
|
cachedVersion = "unknown";
|
|
12355
12355
|
return cachedVersion;
|
|
12356
12356
|
}
|
|
12357
|
+
var { schema } = tool;
|
|
12357
12358
|
var BASE_DIR = join(homedir(), ".opencode-browser");
|
|
12358
12359
|
var SOCKET_PATH = join(BASE_DIR, "broker.sock");
|
|
12359
12360
|
mkdirSync(BASE_DIR, { recursive: true });
|
|
@@ -12467,91 +12468,173 @@ function toolResultText(data, fallback) {
|
|
|
12467
12468
|
return JSON.stringify(data.content);
|
|
12468
12469
|
return fallback;
|
|
12469
12470
|
}
|
|
12470
|
-
var plugin = {
|
|
12471
|
-
|
|
12472
|
-
|
|
12473
|
-
tool
|
|
12474
|
-
|
|
12475
|
-
|
|
12476
|
-
|
|
12477
|
-
|
|
12478
|
-
|
|
12479
|
-
|
|
12480
|
-
|
|
12481
|
-
|
|
12482
|
-
|
|
12483
|
-
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12488
|
-
|
|
12489
|
-
|
|
12490
|
-
|
|
12491
|
-
|
|
12492
|
-
|
|
12493
|
-
|
|
12494
|
-
|
|
12495
|
-
|
|
12496
|
-
|
|
12497
|
-
|
|
12498
|
-
|
|
12499
|
-
|
|
12500
|
-
|
|
12501
|
-
|
|
12502
|
-
|
|
12503
|
-
|
|
12504
|
-
|
|
12505
|
-
|
|
12506
|
-
|
|
12507
|
-
|
|
12508
|
-
|
|
12509
|
-
|
|
12510
|
-
|
|
12511
|
-
|
|
12512
|
-
|
|
12513
|
-
|
|
12514
|
-
|
|
12515
|
-
|
|
12516
|
-
|
|
12517
|
-
|
|
12518
|
-
|
|
12519
|
-
|
|
12520
|
-
|
|
12521
|
-
|
|
12522
|
-
|
|
12523
|
-
|
|
12524
|
-
|
|
12525
|
-
|
|
12526
|
-
|
|
12527
|
-
|
|
12528
|
-
|
|
12529
|
-
|
|
12530
|
-
|
|
12531
|
-
|
|
12532
|
-
|
|
12533
|
-
|
|
12534
|
-
|
|
12535
|
-
|
|
12536
|
-
|
|
12537
|
-
|
|
12538
|
-
|
|
12539
|
-
|
|
12540
|
-
|
|
12541
|
-
|
|
12542
|
-
|
|
12543
|
-
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
|
|
12547
|
-
|
|
12548
|
-
|
|
12549
|
-
|
|
12550
|
-
|
|
12551
|
-
|
|
12552
|
-
|
|
12553
|
-
|
|
12554
|
-
|
|
12471
|
+
var plugin = async (ctx) => {
|
|
12472
|
+
console.log("[opencode-browser] Plugin loading...", { pid: process.pid });
|
|
12473
|
+
return {
|
|
12474
|
+
tool: {
|
|
12475
|
+
browser_debug: tool({
|
|
12476
|
+
description: "Debug plugin loading and connection status.",
|
|
12477
|
+
args: {},
|
|
12478
|
+
async execute(args, ctx2) {
|
|
12479
|
+
console.log("[opencode-browser] browser_debug called", { sessionId, pid: process.pid });
|
|
12480
|
+
return JSON.stringify({
|
|
12481
|
+
loaded: true,
|
|
12482
|
+
sessionId,
|
|
12483
|
+
pid: process.pid,
|
|
12484
|
+
pluginVersion: getPackageVersion(),
|
|
12485
|
+
timestamp: new Date().toISOString()
|
|
12486
|
+
});
|
|
12487
|
+
}
|
|
12488
|
+
}),
|
|
12489
|
+
browser_version: tool({
|
|
12490
|
+
description: "Return the installed @different-ai/opencode-browser plugin version.",
|
|
12491
|
+
args: {},
|
|
12492
|
+
async execute(args, ctx2) {
|
|
12493
|
+
return JSON.stringify({
|
|
12494
|
+
name: "@different-ai/opencode-browser",
|
|
12495
|
+
version: getPackageVersion(),
|
|
12496
|
+
sessionId,
|
|
12497
|
+
pid: process.pid
|
|
12498
|
+
});
|
|
12499
|
+
}
|
|
12500
|
+
}),
|
|
12501
|
+
browser_status: tool({
|
|
12502
|
+
description: "Check broker/native-host connection status and current tab claims.",
|
|
12503
|
+
args: {},
|
|
12504
|
+
async execute(args, ctx2) {
|
|
12505
|
+
const data = await brokerRequest("status", {});
|
|
12506
|
+
return JSON.stringify(data);
|
|
12507
|
+
}
|
|
12508
|
+
}),
|
|
12509
|
+
browser_get_tabs: tool({
|
|
12510
|
+
description: "List all open browser tabs",
|
|
12511
|
+
args: {},
|
|
12512
|
+
async execute(args, ctx2) {
|
|
12513
|
+
const data = await brokerRequest("tool", { tool: "get_tabs", args: {} });
|
|
12514
|
+
return toolResultText(data, "ok");
|
|
12515
|
+
}
|
|
12516
|
+
}),
|
|
12517
|
+
browser_navigate: tool({
|
|
12518
|
+
description: "Navigate to a URL in the browser",
|
|
12519
|
+
args: {
|
|
12520
|
+
url: schema.string(),
|
|
12521
|
+
tabId: schema.number().optional()
|
|
12522
|
+
},
|
|
12523
|
+
async execute({ url: url2, tabId }, ctx2) {
|
|
12524
|
+
const data = await brokerRequest("tool", { tool: "navigate", args: { url: url2, tabId } });
|
|
12525
|
+
return toolResultText(data, `Navigated to ${url2}`);
|
|
12526
|
+
}
|
|
12527
|
+
}),
|
|
12528
|
+
browser_click: tool({
|
|
12529
|
+
description: "Click an element on the page using a CSS selector",
|
|
12530
|
+
args: {
|
|
12531
|
+
selector: schema.string(),
|
|
12532
|
+
tabId: schema.number().optional()
|
|
12533
|
+
},
|
|
12534
|
+
async execute({ selector, tabId }, ctx2) {
|
|
12535
|
+
const data = await brokerRequest("tool", { tool: "click", args: { selector, tabId } });
|
|
12536
|
+
return toolResultText(data, `Clicked ${selector}`);
|
|
12537
|
+
}
|
|
12538
|
+
}),
|
|
12539
|
+
browser_type: tool({
|
|
12540
|
+
description: "Type text into an input element",
|
|
12541
|
+
args: {
|
|
12542
|
+
selector: schema.string(),
|
|
12543
|
+
text: schema.string(),
|
|
12544
|
+
clear: schema.boolean().optional(),
|
|
12545
|
+
tabId: schema.number().optional()
|
|
12546
|
+
},
|
|
12547
|
+
async execute({ selector, text, clear, tabId }, ctx2) {
|
|
12548
|
+
const data = await brokerRequest("tool", { tool: "type", args: { selector, text, clear, tabId } });
|
|
12549
|
+
return toolResultText(data, `Typed "${text}" into ${selector}`);
|
|
12550
|
+
}
|
|
12551
|
+
}),
|
|
12552
|
+
browser_screenshot: tool({
|
|
12553
|
+
description: "Take a screenshot of the current page. Returns base64 image data URL.",
|
|
12554
|
+
args: {
|
|
12555
|
+
tabId: schema.number().optional()
|
|
12556
|
+
},
|
|
12557
|
+
async execute({ tabId }, ctx2) {
|
|
12558
|
+
const data = await brokerRequest("tool", { tool: "screenshot", args: { tabId } });
|
|
12559
|
+
return toolResultText(data, "Screenshot failed");
|
|
12560
|
+
}
|
|
12561
|
+
}),
|
|
12562
|
+
browser_snapshot: tool({
|
|
12563
|
+
description: "Get an accessibility tree snapshot of the page.",
|
|
12564
|
+
args: {
|
|
12565
|
+
tabId: schema.number().optional()
|
|
12566
|
+
},
|
|
12567
|
+
async execute({ tabId }, ctx2) {
|
|
12568
|
+
const data = await brokerRequest("tool", { tool: "snapshot", args: { tabId } });
|
|
12569
|
+
return toolResultText(data, "Snapshot failed");
|
|
12570
|
+
}
|
|
12571
|
+
}),
|
|
12572
|
+
browser_scroll: tool({
|
|
12573
|
+
description: "Scroll the page or scroll an element into view",
|
|
12574
|
+
args: {
|
|
12575
|
+
selector: schema.string().optional(),
|
|
12576
|
+
x: schema.number().optional(),
|
|
12577
|
+
y: schema.number().optional(),
|
|
12578
|
+
tabId: schema.number().optional()
|
|
12579
|
+
},
|
|
12580
|
+
async execute({ selector, x, y, tabId }, ctx2) {
|
|
12581
|
+
const data = await brokerRequest("tool", { tool: "scroll", args: { selector, x, y, tabId } });
|
|
12582
|
+
return toolResultText(data, "Scrolled");
|
|
12583
|
+
}
|
|
12584
|
+
}),
|
|
12585
|
+
browser_wait: tool({
|
|
12586
|
+
description: "Wait for a specified duration",
|
|
12587
|
+
args: {
|
|
12588
|
+
ms: schema.number().optional(),
|
|
12589
|
+
tabId: schema.number().optional()
|
|
12590
|
+
},
|
|
12591
|
+
async execute({ ms, tabId }, ctx2) {
|
|
12592
|
+
const data = await brokerRequest("tool", { tool: "wait", args: { ms, tabId } });
|
|
12593
|
+
return toolResultText(data, "Waited");
|
|
12594
|
+
}
|
|
12595
|
+
}),
|
|
12596
|
+
browser_execute: tool({
|
|
12597
|
+
description: "Execute JavaScript code in the page context and return the result.",
|
|
12598
|
+
args: {
|
|
12599
|
+
code: schema.string(),
|
|
12600
|
+
tabId: schema.number().optional()
|
|
12601
|
+
},
|
|
12602
|
+
async execute({ code, tabId }, ctx2) {
|
|
12603
|
+
const data = await brokerRequest("tool", { tool: "execute_script", args: { code, tabId } });
|
|
12604
|
+
return toolResultText(data, "Execute failed");
|
|
12605
|
+
}
|
|
12606
|
+
}),
|
|
12607
|
+
browser_claim_tab: tool({
|
|
12608
|
+
description: "Claim a tab for this OpenCode session (per-tab ownership).",
|
|
12609
|
+
args: {
|
|
12610
|
+
tabId: schema.number(),
|
|
12611
|
+
force: schema.boolean().optional()
|
|
12612
|
+
},
|
|
12613
|
+
async execute({ tabId, force }, ctx2) {
|
|
12614
|
+
const data = await brokerRequest("claim_tab", { tabId, force });
|
|
12615
|
+
return JSON.stringify(data);
|
|
12616
|
+
}
|
|
12617
|
+
}),
|
|
12618
|
+
browser_release_tab: tool({
|
|
12619
|
+
description: "Release a previously claimed tab.",
|
|
12620
|
+
args: {
|
|
12621
|
+
tabId: schema.number()
|
|
12622
|
+
},
|
|
12623
|
+
async execute({ tabId }, ctx2) {
|
|
12624
|
+
const data = await brokerRequest("release_tab", { tabId });
|
|
12625
|
+
return JSON.stringify(data);
|
|
12626
|
+
}
|
|
12627
|
+
}),
|
|
12628
|
+
browser_list_claims: tool({
|
|
12629
|
+
description: "List current tab ownership claims.",
|
|
12630
|
+
args: {},
|
|
12631
|
+
async execute(args, ctx2) {
|
|
12632
|
+
const data = await brokerRequest("list_claims", {});
|
|
12633
|
+
return JSON.stringify(data);
|
|
12634
|
+
}
|
|
12635
|
+
})
|
|
12636
|
+
}
|
|
12637
|
+
};
|
|
12555
12638
|
};
|
|
12556
12639
|
var plugin_default = plugin;
|
|
12557
12640
|
export {
|