@opencode/browse 0.0.18-dev.193 → 0.0.18-dev.198

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 (45) hide show
  1. package/dist/cli.mjs +62 -117
  2. package/package.json +13 -33
  3. package/dist/Runtime-r9sev1rq.mjs +0 -16
  4. package/dist/THIRD_PARTY_NOTICES.txt +0 -310
  5. package/dist/Undici-xgvbtsb1.mjs +0 -25295
  6. package/dist/cli-ekwkvvmm.mjs +0 -5943
  7. package/dist/coreBundle-mbshhes2.mjs +0 -8
  8. package/dist/helpers-3ycvp75a.mjs +0 -71
  9. package/dist/index-xsb9s479.mjs +0 -13
  10. package/dist/legacy-runtime-v1sdjj5h.mjs +0 -135
  11. package/dist/log-yek648ak.mjs +0 -9
  12. package/dist/main-1qwrze1y.mjs +0 -140
  13. package/dist/main-2p0v71q0.mjs +0 -1752
  14. package/dist/main-3g7fdzbh.mjs +0 -5360
  15. package/dist/main-55a4gpef.mjs +0 -1261
  16. package/dist/main-693wwz19.mjs +0 -4
  17. package/dist/main-91vhk5de.mjs +0 -38
  18. package/dist/main-9t32k44b.mjs +0 -798
  19. package/dist/main-bv9nawja.mjs +0 -5191
  20. package/dist/main-cgnkhs2x.mjs +0 -35
  21. package/dist/main-esdgpebk.mjs +0 -161
  22. package/dist/main-fg5awggs.mjs +0 -5514
  23. package/dist/main-gexpjhk5.mjs +0 -32
  24. package/dist/main-gt2gskrq.mjs +0 -160
  25. package/dist/main-gw77et6v.mjs +0 -342
  26. package/dist/main-j98fzrvv.mjs +0 -68
  27. package/dist/main-kcw411ep.mjs +0 -891
  28. package/dist/main-nnfxg7re.mjs +0 -11403
  29. package/dist/main-pcqtqhgv.mjs +0 -64
  30. package/dist/main-pmfd055v.mjs +0 -63
  31. package/dist/main-pxs5m0kb.mjs +0 -329
  32. package/dist/main-qazf3bhk.mjs +0 -223
  33. package/dist/main-sf7vaxb6.mjs +0 -17
  34. package/dist/main-stf180y1.mjs +0 -229
  35. package/dist/main-tk4axre7.mjs +0 -39
  36. package/dist/main-zedq93ez.mjs +0 -215
  37. package/dist/main-zzggnpf4.mjs +0 -73
  38. package/dist/mcp-xfx04fxe.mjs +0 -9470
  39. package/dist/migrate-4rewxqd7.mjs +0 -354
  40. package/dist/relay-me036e19.mjs +0 -18765
  41. package/dist/remove-stored-secrets-ymhge5va.mjs +0 -6
  42. package/dist/runtime-update-hd2cvy1c.mjs +0 -246
  43. package/dist/setup-0hmbzam5.mjs +0 -1052
  44. package/dist/update-vnkjbc0e.mjs +0 -17
  45. package/dist/version-jn0h3rmc.mjs +0 -8
@@ -1,8 +0,0 @@
1
- // src/execute/coreBundle.ts
2
- import { chromium, errors, selectors } from "patchright-core";
3
- import { default as default2 } from "patchright-core/lib/coreBundle";
4
- export {
5
- chromium,
6
- errors,
7
- default2 as internals
8
- };
@@ -1,71 +0,0 @@
1
- import {
2
- HttpRouteError2,
3
- formatHostForUrl2,
4
- listenHttpServer2,
5
- closeHttpServer2,
6
- closeWebSocketServer2,
7
- logCloseError2,
8
- sendJson2,
9
- readJsonBody2,
10
- stableUnpackedExtensionOrigin2,
11
- chromeExtensionOriginForPath2,
12
- parseAdditionalExtensionOrigins2,
13
- validateHostHeader2,
14
- validateBrowserFetchSite2,
15
- validateWebSocketOrigin2,
16
- defaultHost2,
17
- defaultPort2,
18
- optionalSessionId2,
19
- isValidSessionId2,
20
- requiredSessionId2,
21
- parseTargetSelection2,
22
- generateSessionId2,
23
- sendCdpResponse2,
24
- sendCdpEvent2,
25
- getObject2,
26
- getString2,
27
- createTargetUrl2,
28
- getNumber2,
29
- getIdText2,
30
- headerValue2,
31
- getTargetInfo2,
32
- isRestrictedTarget2,
33
- isRestrictedUrl2,
34
- dataUrlDocument2
35
- } from "./main-kcw411ep.mjs";
36
- import"./main-91vhk5de.mjs";
37
- export {
38
- HttpRouteError2 as HttpRouteError,
39
- chromeExtensionOriginForPath2 as chromeExtensionOriginForPath,
40
- closeHttpServer2 as closeHttpServer,
41
- closeWebSocketServer2 as closeWebSocketServer,
42
- createTargetUrl2 as createTargetUrl,
43
- dataUrlDocument2 as dataUrlDocument,
44
- defaultHost2 as defaultHost,
45
- defaultPort2 as defaultPort,
46
- formatHostForUrl2 as formatHostForUrl,
47
- generateSessionId2 as generateSessionId,
48
- getIdText2 as getIdText,
49
- getNumber2 as getNumber,
50
- getObject2 as getObject,
51
- getString2 as getString,
52
- getTargetInfo2 as getTargetInfo,
53
- headerValue2 as headerValue,
54
- isRestrictedTarget2 as isRestrictedTarget,
55
- isRestrictedUrl2 as isRestrictedUrl,
56
- isValidSessionId2 as isValidSessionId,
57
- listenHttpServer2 as listenHttpServer,
58
- logCloseError2 as logCloseError,
59
- optionalSessionId2 as optionalSessionId,
60
- parseAdditionalExtensionOrigins2 as parseAdditionalExtensionOrigins,
61
- parseTargetSelection2 as parseTargetSelection,
62
- readJsonBody2 as readJsonBody,
63
- requiredSessionId2 as requiredSessionId,
64
- sendCdpEvent2 as sendCdpEvent,
65
- sendCdpResponse2 as sendCdpResponse,
66
- sendJson2 as sendJson,
67
- stableUnpackedExtensionOrigin2 as stableUnpackedExtensionOrigin,
68
- validateBrowserFetchSite2 as validateBrowserFetchSite,
69
- validateHostHeader2 as validateHostHeader,
70
- validateWebSocketOrigin2 as validateWebSocketOrigin
71
- };
@@ -1,13 +0,0 @@
1
- import {
2
- exports_NodeHttpClient,
3
- exports_NodeRuntime,
4
- exports_NodeStdio,
5
- exports_NodeServices
6
- } from "./main-3g7fdzbh.mjs";
7
- import"./main-pcqtqhgv.mjs";
8
- export {
9
- exports_NodeHttpClient as NodeHttpClient,
10
- exports_NodeRuntime as NodeRuntime,
11
- exports_NodeServices as NodeServices,
12
- exports_NodeStdio as NodeStdio
13
- };
@@ -1,135 +0,0 @@
1
- import"./main-91vhk5de.mjs";
2
- import {
3
- channelOf,
4
- installedRuntime2
5
- } from "./main-9t32k44b.mjs";
6
- import"./main-kcw411ep.mjs";
7
- import {
8
- legacyRuntimeActive,
9
- insidePath,
10
- samePath2
11
- } from "./main-pmfd055v.mjs";
12
- import {
13
- opencodeBrowserVersion2
14
- } from "./main-693wwz19.mjs";
15
- import {
16
- relayPortPinned,
17
- resolveRelayPort,
18
- probeRelayPort
19
- } from "./main-zedq93ez.mjs";
20
- import {
21
- installerBinaryPath,
22
- compiledBinary
23
- } from "./main-1qwrze1y.mjs";
24
-
25
- // src/setup/legacy-runtime.ts
26
- import fs from "node:fs";
27
- import net from "node:net";
28
- import os from "node:os";
29
- import path from "node:path";
30
- var FORWARDER = "// browse: this old runtime folder runs the current install";
31
- var legacyEntry = (root, version) => path.join(root, "runtime", "versions", version, "node_modules", "@opencode", "browse", "dist", "cli.mjs");
32
- function currentInstall(options = {}) {
33
- if (!(options.compiled ?? compiledBinary()))
34
- return installedRuntime2();
35
- const binary = installerBinaryPath(options.home);
36
- return realpath(binary) === realpath(options.execPath ?? process.execPath) ? { kind: "binary", entry: binary, version: opencodeBrowserVersion2 } : undefined;
37
- }
38
- var pending;
39
- async function prepareLegacyTakeover(legacy, options = {}) {
40
- const env = options.env ?? process.env;
41
- const install = "install" in options ? options.install : currentInstall();
42
- if (!legacy || !legacyRuntimeActive(legacy) || !install || install.kind === "npx" || insidePath(install.entry, legacy.root))
43
- return false;
44
- if (env.OPENCODE_BROWSER_HOME && !samePath2(env.OPENCODE_BROWSER_HOME, legacy.root))
45
- return false;
46
- const port = options.relayPort ?? (Number(env.OPENCODE_BROWSER_PORT) || resolveRelayPort());
47
- if (options.pinned ?? relayPortPinned(env)) {
48
- if (await portInUse(port))
49
- return false;
50
- } else {
51
- const owner = await probeRelayPort(port);
52
- if (owner === "browse" || owner === "nobody" && await portInUse(port))
53
- return false;
54
- }
55
- const home = options.home ?? os.homedir();
56
- const { copyLegacyData } = await import("./migrate-4rewxqd7.mjs");
57
- delete env.OPENCODE_BROWSER_HOME;
58
- copyLegacyData(home);
59
- pending = { legacy, install, home };
60
- return true;
61
- }
62
- async function commitLegacyTakeover(now = Date.now()) {
63
- if (!pending)
64
- return false;
65
- const { legacy, install, home } = pending;
66
- pending = undefined;
67
- try {
68
- if (!adoptLegacyRuntime(legacy, install, now))
69
- return false;
70
- const { migrateLegacy } = await import("./migrate-4rewxqd7.mjs");
71
- migrateLegacy(home, now);
72
- return true;
73
- } catch {
74
- return false;
75
- }
76
- }
77
- function adoptLegacyRuntime(legacy, runtime = currentInstall(), now = Date.now()) {
78
- if (!legacy || !legacyRuntimeActive(legacy) || !runtime || runtime.kind === "npx" || insidePath(runtime.entry, legacy.root))
79
- return false;
80
- const entry = legacyEntry(legacy.root, runtime.version);
81
- if (!fs.existsSync(entry) || fs.readFileSync(entry, "utf8").includes(FORWARDER))
82
- writeForwarder(entry, runtime);
83
- writeAtomic(path.join(legacy.root, "runtime", "current.json"), JSON.stringify({
84
- version: runtime.version,
85
- previous: legacy.version,
86
- channel: channelOf(runtime.version),
87
- switchedAt: new Date(now).toISOString(),
88
- movedTo: runtime.entry
89
- }, null, 2) + `
90
- `, 384);
91
- return true;
92
- }
93
- function writeForwarder(entry, runtime) {
94
- const packageDir = path.dirname(path.dirname(entry));
95
- fs.mkdirSync(path.dirname(entry), { recursive: true });
96
- writeAtomic(path.join(packageDir, "package.json"), JSON.stringify({ name: "@opencode/browse", version: runtime.version, private: true }) + `
97
- `);
98
- const target = JSON.stringify(runtime.entry);
99
- const run = runtime.kind === "binary" ? [
100
- `import { spawn } from "node:child_process"`,
101
- `const child = spawn(${target}, process.argv.slice(2), { stdio: "inherit" })`,
102
- `for (const signal of ["SIGTERM", "SIGINT"]) process.on(signal, () => child.kill(signal))`,
103
- `child.on("exit", (code, signal) => { process.exitCode = code ?? (signal ? 1 : 0) })`
104
- ] : [
105
- `import { pathToFileURL } from "node:url"`,
106
- `process.argv[1] = ${target}`,
107
- `await import(pathToFileURL(${target}).href)`
108
- ];
109
- writeAtomic(entry, ["#!/usr/bin/env node", `${FORWARDER} (${runtime.kind}). Don't edit.`, ...run, ""].join(`
110
- `));
111
- }
112
- function realpath(file) {
113
- try {
114
- return fs.realpathSync(file);
115
- } catch {
116
- return path.resolve(file);
117
- }
118
- }
119
- function portInUse(port) {
120
- return new Promise((resolve) => {
121
- const socket = net.connect({ host: "127.0.0.1", port });
122
- socket.setTimeout(1000, () => (socket.destroy(), resolve(true)));
123
- socket.once("connect", () => (socket.destroy(), resolve(true)));
124
- socket.once("error", (error) => resolve(error.code !== "ECONNREFUSED"));
125
- });
126
- }
127
- function writeAtomic(file, text, mode = 420) {
128
- const temporary = `${file}.${process.pid}.tmp`;
129
- fs.writeFileSync(temporary, text, { mode });
130
- fs.renameSync(temporary, file);
131
- }
132
- export {
133
- commitLegacyTakeover,
134
- prepareLegacyTakeover
135
- };
@@ -1,9 +0,0 @@
1
- import {
2
- appendManagedRelayProcessLog2,
3
- relayLog2
4
- } from "./main-cgnkhs2x.mjs";
5
- import"./main-91vhk5de.mjs";
6
- export {
7
- appendManagedRelayProcessLog2 as appendManagedRelayProcessLog,
8
- relayLog2 as relayLog
9
- };
@@ -1,140 +0,0 @@
1
- // src/paths.ts
2
- import fs from "node:fs";
3
- import os from "node:os";
4
- import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- var override = (home) => home === os.homedir() && process.env.OPENCODE_BROWSER_HOME ? process.env.OPENCODE_BROWSER_HOME : undefined;
7
- var xdgRoot = (variable, fallback, home) => {
8
- const configured = home === os.homedir() ? process.env[variable] : undefined;
9
- return path.join(configured && path.isAbsolute(configured) ? configured : path.join(home, fallback), "browse");
10
- };
11
- function defaultConfigRoot(home = os.homedir()) {
12
- return xdgRoot("XDG_CONFIG_HOME", ".config", home);
13
- }
14
- function defaultRoots(home = os.homedir()) {
15
- return {
16
- config: defaultConfigRoot(home),
17
- data: xdgRoot("XDG_DATA_HOME", ".local/share", home),
18
- state: xdgRoot("XDG_STATE_HOME", ".local/state", home),
19
- cache: xdgRoot("XDG_CACHE_HOME", ".cache", home)
20
- };
21
- }
22
- function configRoot2(home = os.homedir()) {
23
- return override(home) ?? defaultConfigRoot(home);
24
- }
25
- function dataRoot(home = os.homedir()) {
26
- return override(home) ?? xdgRoot("XDG_DATA_HOME", ".local/share", home);
27
- }
28
- function stateRoot(home = os.homedir()) {
29
- return override(home) ?? xdgRoot("XDG_STATE_HOME", ".local/state", home);
30
- }
31
- function cacheRoot(home = os.homedir()) {
32
- return override(home) ?? xdgRoot("XDG_CACHE_HOME", ".cache", home);
33
- }
34
- function installerBinRoot(home = os.homedir()) {
35
- const configured = home === os.homedir() ? process.env.XDG_BIN_HOME : undefined;
36
- return configured && path.isAbsolute(configured) ? configured : path.join(home, ".local", "bin");
37
- }
38
- function binRoot(home = os.homedir()) {
39
- if (override(home))
40
- return path.join(override(home), "bin");
41
- return installerBinRoot(home);
42
- }
43
- var installedBinaryPath = (home = os.homedir()) => path.join(binRoot(home), binaryName());
44
- var installerBinaryPath = (home = os.homedir()) => path.join(installerBinRoot(home), binaryName());
45
- var defaultSettingsPath = (home = os.homedir()) => path.join(defaultConfigRoot(home), "settings.json");
46
- var packageRoot = () => path.dirname(path.dirname(fileURLToPath(import.meta.url)));
47
- var oldStoreMarker = () => path.join(stateRoot(), "old-store-extension");
48
- function fromCheckout() {
49
- return !compiledBinary() && fs.existsSync(path.join(packageRoot(), "src", "main.ts"));
50
- }
51
- var compiledBinary = () => globalThis.__OPENCODE_BROWSER_COMPILED__ === true;
52
- var binaryName = (platform = process.platform) => platform === "win32" ? "browse.exe" : "browse";
53
- var scriptEntry = (entry) => /\.[cm]?[jt]s$/.test(entry);
54
- var entryCommand = (entry, node = process.execPath) => scriptEntry(entry) ? [node, entry] : [entry];
55
- var windowsShellShim = (entry, pathModule) => /\.(cmd|bat)$/i.test(entry) || pathModule.extname(entry) === "" && !pathModule.isAbsolute(entry) && !/[\\/]/.test(entry);
56
- var npxEntry = (entry) => /(^|\/)_npx\//.test(entry.replaceAll("\\", "/"));
57
- function resolveWindowsShim(entry, node = process.execPath, options = {}) {
58
- const pathModule = options.pathModule ?? path.win32;
59
- const exists = options.existsSync ?? fs.existsSync;
60
- if (!windowsShellShim(entry, pathModule))
61
- return;
62
- const shimmed = /\.(cmd|bat)$/i.test(entry);
63
- const withFolder = shimmed && (pathModule.isAbsolute(entry) || /[\\/]/.test(entry));
64
- const directories = withFolder ? [pathModule.dirname(entry)] : (options.env ?? process.env).PATH?.split(";").map((directory) => directory.trim().replace(/^"(.*)"$/, "$1")).filter(Boolean) ?? [];
65
- for (const directory of directories) {
66
- if (!shimmed) {
67
- const executable = pathModule.join(directory, `${entry}.exe`);
68
- if (exists(executable))
69
- return [executable];
70
- }
71
- const shim = withFolder ? entry : pathModule.join(directory, shimmed ? entry : `${entry}.cmd`);
72
- if (!exists(shim))
73
- continue;
74
- const script = pathModule.join(directory, "node_modules", "@opencode", "browse", "dist", "cli.mjs");
75
- if (exists(script))
76
- return [node, script];
77
- }
78
- return;
79
- }
80
- function entrySpawnCommand(entry, node = process.execPath, options = {}) {
81
- if (scriptEntry(entry))
82
- return [node, entry];
83
- const pathModule = options.pathModule ?? path.win32;
84
- if ((options.platform ?? process.platform) !== "win32" || !windowsShellShim(entry, pathModule))
85
- return [entry];
86
- const resolved = resolveWindowsShim(entry, node, options);
87
- if (resolved)
88
- return resolved;
89
- const running = options.running ?? runningEntry();
90
- const compiled = options.compiled ?? compiledBinary();
91
- const checkout = options.checkout ?? fromCheckout();
92
- return !compiled && !checkout && scriptEntry(running) && !npxEntry(running) ? [node, running] : [entry];
93
- }
94
- function installedBinary() {
95
- const binary = installedBinaryPath();
96
- return fs.existsSync(binary) ? binary : undefined;
97
- }
98
- var runningEntry = () => compiledBinary() ? process.execPath : process.argv[1];
99
- function checkoutRoot() {
100
- return fromCheckout() ? path.dirname(packageRoot()) : undefined;
101
- }
102
- var quoted = (value) => /^[\w@%+=:,./-]+$/.test(value) ? value : JSON.stringify(value);
103
- function cliInstall() {
104
- if (compiledBinary())
105
- return { kind: "binary", binary: installedBinary() ?? process.execPath, pathEnv: process.env.PATH };
106
- if (fromCheckout())
107
- return { kind: "checkout", bundle: path.join(packageRoot(), "dist", "cli.mjs") };
108
- return { kind: "npm", version: "0.0.18-dev.193", npx: /[/\\]_npx[/\\]/.test(process.argv[1] ?? "") };
109
- }
110
- function cliPrefix(install = cliInstall()) {
111
- if (install.kind === "binary") {
112
- const dir = path.dirname(install.binary);
113
- const onPath = (install.pathEnv ?? "").split(path.delimiter).some((entry) => entry && path.resolve(entry) === dir);
114
- return onPath ? "browse" : quoted(install.binary);
115
- }
116
- if (install.kind === "checkout")
117
- return `node ${quoted(install.bundle)}`;
118
- if (install.npx)
119
- return install.version?.includes("-dev.") ? "npx @opencode/browse@dev" : "npx @opencode/browse";
120
- return "browse";
121
- }
122
- var cliCommand = (args, install = cliInstall()) => `${cliPrefix(install)} ${args}`;
123
- var STORE_ITEM_ID = /^[a-p]{32}$/;
124
- var PUBLIC_STORE_ID = "mfnicocicmmlkpjnaffgihfjhdgjkdjg";
125
- function storeConfig(env = process.env, baked = { id: "mfnicocicmmlkpjnaffgihfjhdgjkdjg" }) {
126
- const id = [env.OPENCODE_BROWSER_STORE_ID, baked?.id].find((value) => value && STORE_ITEM_ID.test(value));
127
- return id ? { id } : {};
128
- }
129
- var RELEASE_SERVICE = "https://anoma.ly/release";
130
- function devExtension(baked = { file: "browse-extension-0.0.18-dev.193.zip", sha256: "60a78f7e99d0e0368890acc1bb9d2e2a57b14b06ff8a9b48a20ed73f403b3b17", size: 184498 }) {
131
- return baked && /^[0-9a-f]{64}$/.test(baked.sha256) && /^[\w.-]+\.zip$/.test(baked.file) ? baked : undefined;
132
- }
133
- var devExtensionUrl = (extension, env = process.env) => `${(env.OPENCODE_BROWSER_RELEASE_SERVICE || RELEASE_SERVICE).replace(/\/+$/, "")}/browse/files/${extension.sha256}/${extension.file}`;
134
- var devExtensionFolder = (root = cacheRoot()) => path.join(root, "extension");
135
- var storeUrl = (id) => `https://chromewebstore.google.com/detail/${id}`;
136
- function installCommand() {
137
- return fromCheckout() ? `cd ${quoted(path.dirname(packageRoot()))} && bun run setup` : cliCommand("install");
138
- }
139
-
140
- export { defaultRoots, configRoot2, dataRoot, stateRoot, cacheRoot, binRoot, installedBinaryPath, installerBinaryPath, defaultSettingsPath, oldStoreMarker, fromCheckout, compiledBinary, binaryName, scriptEntry, entryCommand, resolveWindowsShim, entrySpawnCommand, installedBinary, runningEntry, checkoutRoot, cliPrefix, cliCommand, PUBLIC_STORE_ID, storeConfig, RELEASE_SERVICE, devExtension, devExtensionUrl, devExtensionFolder, storeUrl, installCommand };