@opencode/browse 0.0.18-dev.192 → 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 (41) hide show
  1. package/dist/cli.mjs +62 -107
  2. package/package.json +13 -33
  3. package/dist/Runtime-tvxdkp60.mjs +0 -16
  4. package/dist/THIRD_PARTY_NOTICES.txt +0 -310
  5. package/dist/Undici-xgvbtsb1.mjs +0 -25295
  6. package/dist/cli-54nftqxr.mjs +0 -5939
  7. package/dist/coreBundle-mbshhes2.mjs +0 -8
  8. package/dist/helpers-yksnc17b.mjs +0 -70
  9. package/dist/index-kmxtpxxk.mjs +0 -13
  10. package/dist/legacy-runtime-e6y2jnc6.mjs +0 -134
  11. package/dist/main-4fw36c57.mjs +0 -160
  12. package/dist/main-4wycvga6.mjs +0 -797
  13. package/dist/main-c9qxrdzn.mjs +0 -73
  14. package/dist/main-d1th6z2h.mjs +0 -5395
  15. package/dist/main-de0xhbg0.mjs +0 -1269
  16. package/dist/main-dyya6jpy.mjs +0 -140
  17. package/dist/main-gexpjhk5.mjs +0 -32
  18. package/dist/main-h65pjrag.mjs +0 -11403
  19. package/dist/main-hh16893t.mjs +0 -5358
  20. package/dist/main-j98fzrvv.mjs +0 -68
  21. package/dist/main-jtgan144.mjs +0 -327
  22. package/dist/main-p44hff2a.mjs +0 -213
  23. package/dist/main-p8jk5985.mjs +0 -1750
  24. package/dist/main-p8q3wrpd.mjs +0 -342
  25. package/dist/main-pmfd055v.mjs +0 -63
  26. package/dist/main-q5w61fgh.mjs +0 -17
  27. package/dist/main-t8hspw29.mjs +0 -922
  28. package/dist/main-t8xtycpr.mjs +0 -227
  29. package/dist/main-tk4axre7.mjs +0 -39
  30. package/dist/main-w6180mxa.mjs +0 -161
  31. package/dist/main-wds0wcmt.mjs +0 -4
  32. package/dist/main-z4c819pg.mjs +0 -5512
  33. package/dist/main-zrjcdksk.mjs +0 -62
  34. package/dist/mcp-a2jkny55.mjs +0 -9466
  35. package/dist/migrate-p84kbr3y.mjs +0 -353
  36. package/dist/relay-e9q9hfc3.mjs +0 -18369
  37. package/dist/remove-stored-secrets-c90a5h72.mjs +0 -6
  38. package/dist/runtime-update-jj6pa7vd.mjs +0 -244
  39. package/dist/setup-p86ywb7k.mjs +0 -1051
  40. package/dist/update-rh24h3m1.mjs +0 -17
  41. package/dist/version-1p8wpyzk.mjs +0 -8
@@ -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.192", 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.192.zip", sha256: "b956b1111d8476de5d211732d78b4835dcf38910ef98714836cd5c1d48544238", size: 184460 }) {
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 };
@@ -1,32 +0,0 @@
1
- // src/agent-guide.ts
2
- var whatBrowseIs = `browse drives the user's real Chrome-family browser through the browse extension, so logins, extensions and open tabs are already there and the user can watch or take over.`;
3
- var inspectActVerify = `Use one loop: inspect, act, verify.
4
- - Inspect with \`await snapshot()\` before choosing anything. Prefer the returned refs: \`await ref("e12").click()\`. Fall back to accessible locators (\`page.getByRole(...)\`, \`getByLabel(...)\`), then CSS.
5
- - Act with the narrowest stable control, and keep dependent steps in one \`execute\` while transient UI is open.
6
- - Verify with a fresh page read (\`page.url()\`, a heading, or a new snapshot). A click that returned, or a handoff the user acknowledged, is not proof the task succeeded.`;
7
- var handoffAdvice = `When only a person can proceed — login, 2FA, passkey, captcha or payment confirmation — call \`handoff("what the user should do")\` and wait. Pass \`start\` for an action that itself blocks. Never solve a captcha yourself and never retry-loop a blocked site; if a challenge is interactive or the site refuses the visit, hand off or stop and tell the user.`;
8
- var sessionAdvice = `Each agent has its own current session when the client names the agent (OpenCode does), so bare calls don't land on another agent's page. When the client doesn't name agents, \`status\` reports \`sharedSession: true\` and all agents on this server share one current session, so when several (such as subagents) use it each should \`session_new\` its own and pass \`session\` on every call. When finished, \`session_reset\` (or \`session_delete\`) your own session; keep a session only when follow-up work is expected.`;
9
- var agentHelp = `AGENT GUIDE
10
- browse drives the user's real Chrome-family browser through the browse extension, so logins,
11
- extensions and open tabs are already there and the user can watch or take over. Agents normally
12
- use the MCP server (\`browse mcp\`); the same loop works from a terminal.
13
-
14
- Write one Playwright script to a file and run it:
15
- browse execute --file script.js
16
- It receives browser, context, page, state, snapshot(), ref() and handoff(). \`return\` a value to
17
- get it back.
18
-
19
- Inspect, act, verify:
20
- - \`await snapshot()\` before choosing anything; click the returned refs (\`await ref("e12").click()\`).
21
- - Fall back to accessible locators (\`page.getByRole(...)\`), then CSS.
22
- - Keep dependent steps in one script while transient UI is open.
23
- - Verify with a fresh page read (\`page.url()\`, a heading, a new snapshot); a click that returned
24
- proves nothing.
25
-
26
- When only a person can proceed (login, 2FA, passkey, captcha, payment), call
27
- \`handoff("what to do")\` and wait. Never solve a captcha yourself.
28
-
29
- Pass \`--session\` to keep one session across calls. \`browse session reset\` or \`browse session delete\`
30
- it when done; keep a session only for follow-up work.`;
31
-
32
- export { whatBrowseIs, inspectActVerify, handoffAdvice, sessionAdvice, agentHelp };