@opencode/browse 0.0.6-dev.18 → 0.0.6-dev.20
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/{cli-z00ttket.mjs → cli-anqhds1e.mjs} +771 -643
- package/dist/cli.mjs +8 -8
- package/dist/{relay-helpers-6a2vvzx9.mjs → helpers-n4k4pdag.mjs} +9 -9
- package/dist/{main-jjny7bmm.mjs → main-0nta0a2z.mjs} +200 -191
- package/dist/{main-9y22cffn.mjs → main-20ahaz2q.mjs} +3 -3
- package/dist/{main-w5sta7hq.mjs → main-3rsfghef.mjs} +4 -4
- package/dist/{main-d7rbre73.mjs → main-42qfr69q.mjs} +4 -4
- package/dist/main-arx3pfyn.mjs +4 -0
- package/dist/{main-0egy8naa.mjs → main-hywb9qbv.mjs} +5 -5
- package/dist/{main-ha5bnd77.mjs → main-ma25hhqh.mjs} +120 -118
- package/dist/{main-fkhwazsm.mjs → main-yd1d7qr1.mjs} +1708 -1532
- package/dist/{mcp-qh25n9s0.mjs → mcp-j9e2da4y.mjs} +584 -481
- package/dist/{relay-zs96tkfm.mjs → relay-cvhz2f0a.mjs} +16299 -15709
- package/dist/{runtime-update-8wte78jj.mjs → runtime-update-baranjc5.mjs} +5 -5
- package/dist/{setup-cqjdfcy0.mjs → setup-7shrgdza.mjs} +811 -705
- package/dist/{update-st5c8grg.mjs → update-vkspb2rz.mjs} +2 -2
- package/dist/{version-6g6gtnra.mjs → version-gfpqxbzm.mjs} +1 -1
- package/package.json +1 -2
- package/dist/main-ppz7sv9s.mjs +0 -4
|
@@ -1,113 +1,9 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var extensionReconnectAlarmPeriodMs = 30000;
|
|
8
|
-
var legacyExtensionProtocolVersion = 1;
|
|
9
|
-
function extensionProtocolCompatibility(value) {
|
|
10
|
-
const legacy = value === undefined;
|
|
11
|
-
const valid = typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
12
|
-
const version = valid ? value : legacy ? legacyExtensionProtocolVersion : null;
|
|
13
|
-
return { version, compatible: version !== null && version >= minExtensionProtocolVersion && version <= extensionProtocolVersion, legacy };
|
|
14
|
-
}
|
|
15
|
-
function extensionProtocolSkew(version) {
|
|
16
|
-
if (typeof version !== "number")
|
|
17
|
-
return;
|
|
18
|
-
if (version > extensionProtocolVersion)
|
|
19
|
-
return "extension-newer";
|
|
20
|
-
if (version < minExtensionProtocolVersion)
|
|
21
|
-
return "extension-older";
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
function extensionProtocolAdvice(version, commands, distribution) {
|
|
25
|
-
const skew = extensionProtocolSkew(version);
|
|
26
|
-
const versions = `extension protocol ${version ?? "unknown"}, this relay speaks ${minExtensionProtocolVersion === extensionProtocolVersion ? extensionProtocolVersion : `${minExtensionProtocolVersion} to ${extensionProtocolVersion}`}`;
|
|
27
|
-
if (skew === "extension-newer")
|
|
28
|
-
return `The Browse extension is newer than this browse CLI (${versions}). Update the CLI: run \`${commands.install}\` (an npm install with automatic updates also catches up by itself within a day), then restart opencode.`;
|
|
29
|
-
if (skew === "extension-older") {
|
|
30
|
-
const store = "The Chrome Web Store updates it within a few hours (to update now, open chrome://extensions, turn on Developer mode and click Update).";
|
|
31
|
-
const next = distribution === "unpacked" ? unpackedReloadAdvice : distribution === "store" ? store : `For an unpacked extension: ${unpackedReloadAdvice} For a store extension: ${store}`;
|
|
32
|
-
return `The Browse extension is older than this browse CLI (${versions}). ${next}`;
|
|
33
|
-
}
|
|
34
|
-
return `The Browse extension and this browse CLI don't speak the same protocol (${versions}). Run \`${commands.install}\` again and update the extension.`;
|
|
35
|
-
}
|
|
36
|
-
function makePageStatus(options) {
|
|
37
|
-
return {
|
|
38
|
-
state: options.state,
|
|
39
|
-
owner: options.targetOwner === "user" ? "user" : "session",
|
|
40
|
-
...options.sessionId ? { sessionId: options.sessionId } : {},
|
|
41
|
-
...options.sessionId && options.readOnly ? { readOnly: true } : {},
|
|
42
|
-
...options.message ? { message: options.message } : {},
|
|
43
|
-
...options.handoffId ? { handoffId: options.handoffId } : {},
|
|
44
|
-
...options.recording ? { recording: true } : {}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
var extensionCommandMethodValues = [
|
|
48
|
-
"ping",
|
|
49
|
-
"debugger.attach",
|
|
50
|
-
"debugger.detach",
|
|
51
|
-
"debugger.sendCommand",
|
|
52
|
-
"tabs.create",
|
|
53
|
-
"tabs.remove",
|
|
54
|
-
"tabs.group",
|
|
55
|
-
"tabs.ungroup",
|
|
56
|
-
"action.setAttached",
|
|
57
|
-
"action.setBadge",
|
|
58
|
-
"pageStatus.set",
|
|
59
|
-
"pageStatus.clear",
|
|
60
|
-
"runtime.reload",
|
|
61
|
-
"recording.start",
|
|
62
|
-
"recording.stop",
|
|
63
|
-
"recording.status",
|
|
64
|
-
"recording.cancel",
|
|
65
|
-
"tabs.cleanup",
|
|
66
|
-
"update.notice",
|
|
67
|
-
"relay.settings",
|
|
68
|
-
"settings.get",
|
|
69
|
-
"settings.set"
|
|
70
|
-
];
|
|
71
|
-
var extensionEventMethodValues = [
|
|
72
|
-
"protocol",
|
|
73
|
-
"hello",
|
|
74
|
-
"auth.code",
|
|
75
|
-
"auth.response",
|
|
76
|
-
"ready",
|
|
77
|
-
"toolbar.clicked",
|
|
78
|
-
"handoff.completed",
|
|
79
|
-
"debugger.event",
|
|
80
|
-
"debugger.attached",
|
|
81
|
-
"debugger.detached",
|
|
82
|
-
"tabs.removed",
|
|
83
|
-
"tabs.opened",
|
|
84
|
-
"pong",
|
|
85
|
-
"log",
|
|
86
|
-
"recording.cancelled",
|
|
87
|
-
"pageStatus.requested",
|
|
88
|
-
"settings"
|
|
89
|
-
];
|
|
90
|
-
function parseJsonObject(input) {
|
|
91
|
-
const parsed = JSON.parse(input);
|
|
92
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
93
|
-
throw new Error("Expected JSON object");
|
|
94
|
-
}
|
|
95
|
-
return parsed;
|
|
96
|
-
}
|
|
97
|
-
var extensionCommandMethods = new Set(extensionCommandMethodValues);
|
|
98
|
-
var extensionEventMethods = new Set(extensionEventMethodValues);
|
|
99
|
-
function isCdpRequest(input) {
|
|
100
|
-
return typeof input.id === "number" && typeof input.method === "string" && (input.params === undefined || isJsonObject(input.params)) && (input.sessionId === undefined || typeof input.sessionId === "string");
|
|
101
|
-
}
|
|
102
|
-
function isExtensionResponse(input) {
|
|
103
|
-
return typeof input.id === "number" && (input.result === undefined || isJsonObject(input.result)) && (input.error === undefined || typeof input.error === "string") && !(input.result !== undefined && input.error !== undefined);
|
|
104
|
-
}
|
|
105
|
-
function isExtensionEvent(input) {
|
|
106
|
-
return typeof input.method === "string" && extensionEventMethods.has(input.method) && (input.params === undefined || isJsonObject(input.params));
|
|
107
|
-
}
|
|
108
|
-
function isJsonObject(value) {
|
|
109
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
110
|
-
}
|
|
1
|
+
// src/update/auto-update.ts
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { chmodSync, closeSync, cpSync, existsSync, mkdirSync, openSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import path2 from "node:path";
|
|
6
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
111
7
|
|
|
112
8
|
// src/paths.ts
|
|
113
9
|
import fs from "node:fs";
|
|
@@ -147,7 +43,7 @@ function storeConfig(env = process.env, baked = { id: "mfnicocicmmlkpjnaffgihfjh
|
|
|
147
43
|
return id ? { id } : {};
|
|
148
44
|
}
|
|
149
45
|
var RELEASE_SERVICE = "https://anoma.ly/release";
|
|
150
|
-
function devExtension(baked = { file: "browse-extension-0.0.6-dev.
|
|
46
|
+
function devExtension(baked = { file: "browse-extension-0.0.6-dev.20.zip", sha256: "05ac10ddd60291753c1e7fd38a440660b2486d7e3f6117ad2de872f1931d521c", size: 39161 }) {
|
|
151
47
|
return baked && /^[0-9a-f]{64}$/.test(baked.sha256) && /^[\w.-]+\.zip$/.test(baked.file) ? baked : undefined;
|
|
152
48
|
}
|
|
153
49
|
var devExtensionUrl = (extension, env = process.env) => `${(env.OPENCODE_BROWSER_RELEASE_SERVICE || RELEASE_SERVICE).replace(/\/+$/, "")}/browse/files/${extension.sha256}/${extension.file}`;
|
|
@@ -157,12 +53,7 @@ function installCommand() {
|
|
|
157
53
|
return fromCheckout() ? `cd ${quoted(path.dirname(packageRoot()))} && bun run setup` : "npx @opencode/browse install";
|
|
158
54
|
}
|
|
159
55
|
|
|
160
|
-
// src/auto-update.ts
|
|
161
|
-
import { spawn } from "node:child_process";
|
|
162
|
-
import { chmodSync, closeSync, cpSync, existsSync, mkdirSync, openSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
163
|
-
import { createRequire } from "node:module";
|
|
164
|
-
import path2 from "node:path";
|
|
165
|
-
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
56
|
+
// src/update/auto-update.ts
|
|
166
57
|
var PACKAGE_NAME = "@opencode/browse";
|
|
167
58
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
168
59
|
var DEFAULT_REGISTRY = "https://registry.npmjs.org";
|
|
@@ -728,4 +619,115 @@ function spawnRuntimeChild(layout, entry, args, onExit, env = process.env) {
|
|
|
728
619
|
}
|
|
729
620
|
}
|
|
730
621
|
|
|
731
|
-
|
|
622
|
+
// src/protocol.ts
|
|
623
|
+
var extensionProtocolVersion = 3;
|
|
624
|
+
var minExtensionProtocolVersion = 3;
|
|
625
|
+
var unpackedExtensionId = "afeafocngkodbmaipcngoamamfmekgfo";
|
|
626
|
+
var unpackedReloadAdvice = "Reload Browse on your browser's extensions page (↻).";
|
|
627
|
+
var checkoutReloadPrefix = "Extension protocol incompatible: extension-older; reload ";
|
|
628
|
+
var extensionReconnectAlarmPeriodMs = 30000;
|
|
629
|
+
var legacyExtensionProtocolVersion = 1;
|
|
630
|
+
function extensionProtocolCompatibility(value) {
|
|
631
|
+
const legacy = value === undefined;
|
|
632
|
+
const valid = typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
633
|
+
const version = valid ? value : legacy ? legacyExtensionProtocolVersion : null;
|
|
634
|
+
return { version, compatible: version !== null && version >= minExtensionProtocolVersion && version <= extensionProtocolVersion, legacy };
|
|
635
|
+
}
|
|
636
|
+
function extensionProtocolSkew(version) {
|
|
637
|
+
if (typeof version !== "number")
|
|
638
|
+
return;
|
|
639
|
+
if (version > extensionProtocolVersion)
|
|
640
|
+
return "extension-newer";
|
|
641
|
+
if (version < minExtensionProtocolVersion)
|
|
642
|
+
return "extension-older";
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
function extensionProtocolAdvice(version, commands, distribution) {
|
|
646
|
+
const skew = extensionProtocolSkew(version);
|
|
647
|
+
const versions = `extension protocol ${version ?? "unknown"}, this relay speaks ${minExtensionProtocolVersion === extensionProtocolVersion ? extensionProtocolVersion : `${minExtensionProtocolVersion} to ${extensionProtocolVersion}`}`;
|
|
648
|
+
if (skew === "extension-newer")
|
|
649
|
+
return `The Browse extension is newer than this browse CLI (${versions}). Update the CLI: run \`${commands.install}\` (an npm install with automatic updates also catches up by itself within a day), then restart opencode.`;
|
|
650
|
+
if (skew === "extension-older") {
|
|
651
|
+
const store = "The Chrome Web Store updates it within a few hours (to update now, open chrome://extensions, turn on Developer mode and click Update).";
|
|
652
|
+
const next = distribution === "unpacked" ? unpackedReloadAdvice : distribution === "store" ? store : `For an unpacked extension: ${unpackedReloadAdvice} For a store extension: ${store}`;
|
|
653
|
+
return `The Browse extension is older than this browse CLI (${versions}). ${next}`;
|
|
654
|
+
}
|
|
655
|
+
return `The Browse extension and this browse CLI don't speak the same protocol (${versions}). Run \`${commands.install}\` again and update the extension.`;
|
|
656
|
+
}
|
|
657
|
+
function makePageStatus(options) {
|
|
658
|
+
return {
|
|
659
|
+
state: options.state,
|
|
660
|
+
owner: options.targetOwner === "user" ? "user" : "session",
|
|
661
|
+
...options.sessionId ? { sessionId: options.sessionId } : {},
|
|
662
|
+
...options.sessionId && options.readOnly ? { readOnly: true } : {},
|
|
663
|
+
...options.message ? { message: options.message } : {},
|
|
664
|
+
...options.handoffId ? { handoffId: options.handoffId } : {},
|
|
665
|
+
...options.recording ? { recording: true } : {}
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
var extensionCommandMethodValues = [
|
|
669
|
+
"ping",
|
|
670
|
+
"debugger.attach",
|
|
671
|
+
"debugger.detach",
|
|
672
|
+
"debugger.sendCommand",
|
|
673
|
+
"tabs.create",
|
|
674
|
+
"tabs.remove",
|
|
675
|
+
"tabs.group",
|
|
676
|
+
"tabs.ungroup",
|
|
677
|
+
"action.setAttached",
|
|
678
|
+
"action.setBadge",
|
|
679
|
+
"pageStatus.set",
|
|
680
|
+
"pageStatus.clear",
|
|
681
|
+
"runtime.reload",
|
|
682
|
+
"recording.start",
|
|
683
|
+
"recording.stop",
|
|
684
|
+
"recording.status",
|
|
685
|
+
"recording.cancel",
|
|
686
|
+
"tabs.cleanup",
|
|
687
|
+
"update.notice",
|
|
688
|
+
"relay.settings",
|
|
689
|
+
"settings.get",
|
|
690
|
+
"settings.set"
|
|
691
|
+
];
|
|
692
|
+
var extensionEventMethodValues = [
|
|
693
|
+
"protocol",
|
|
694
|
+
"hello",
|
|
695
|
+
"auth.code",
|
|
696
|
+
"auth.response",
|
|
697
|
+
"ready",
|
|
698
|
+
"toolbar.clicked",
|
|
699
|
+
"handoff.completed",
|
|
700
|
+
"debugger.event",
|
|
701
|
+
"debugger.attached",
|
|
702
|
+
"debugger.detached",
|
|
703
|
+
"tabs.removed",
|
|
704
|
+
"tabs.opened",
|
|
705
|
+
"pong",
|
|
706
|
+
"log",
|
|
707
|
+
"recording.cancelled",
|
|
708
|
+
"pageStatus.requested",
|
|
709
|
+
"settings"
|
|
710
|
+
];
|
|
711
|
+
function parseJsonObject(input) {
|
|
712
|
+
const parsed = JSON.parse(input);
|
|
713
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
714
|
+
throw new Error("Expected JSON object");
|
|
715
|
+
}
|
|
716
|
+
return parsed;
|
|
717
|
+
}
|
|
718
|
+
var extensionCommandMethods = new Set(extensionCommandMethodValues);
|
|
719
|
+
var extensionEventMethods = new Set(extensionEventMethodValues);
|
|
720
|
+
function isCdpRequest(input) {
|
|
721
|
+
return typeof input.id === "number" && typeof input.method === "string" && (input.params === undefined || isJsonObject(input.params)) && (input.sessionId === undefined || typeof input.sessionId === "string");
|
|
722
|
+
}
|
|
723
|
+
function isExtensionResponse(input) {
|
|
724
|
+
return typeof input.id === "number" && (input.result === undefined || isJsonObject(input.result)) && (input.error === undefined || typeof input.error === "string") && !(input.result !== undefined && input.error !== undefined);
|
|
725
|
+
}
|
|
726
|
+
function isExtensionEvent(input) {
|
|
727
|
+
return typeof input.method === "string" && extensionEventMethods.has(input.method) && (input.params === undefined || isJsonObject(input.params));
|
|
728
|
+
}
|
|
729
|
+
function isJsonObject(value) {
|
|
730
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
export { dataRoot, oldStoreMarker, fromCheckout, checkoutRoot, cliCommand, storeConfig, devExtension, devExtensionUrl, devExtensionFolder, storeUrl, installCommand, autoUpdateModes, runtimeLayout, versionEntry, channelOf, UPDATE_VERSION, compareVersions, readCurrent, writeCurrent, updateState, npmRuntime, autoUpdateOverride, storedMode, effectiveMode, setStoredMode, autoUpdateStatus, describeAutoUpdate, registryUrl, fetchPublished, installVersion, pruneVersions, switchVersion, createAutoUpdater, extensionProtocolVersion, minExtensionProtocolVersion, unpackedExtensionId, unpackedReloadAdvice, checkoutReloadPrefix, extensionReconnectAlarmPeriodMs, extensionProtocolCompatibility, extensionProtocolSkew, extensionProtocolAdvice, makePageStatus, parseJsonObject, isCdpRequest, isExtensionResponse, isExtensionEvent, isJsonObject };
|