@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,227 +0,0 @@
1
- import {
2
- isNodeError,
3
- isValidSessionId2
4
- } from "./main-t8hspw29.mjs";
5
- import {
6
- stateRoot
7
- } from "./main-dyya6jpy.mjs";
8
- import {
9
- decodeUnknownOption,
10
- optionalKey,
11
- String3,
12
- Number2,
13
- Boolean3,
14
- Struct,
15
- ArraySchema,
16
- NullOr
17
- } from "./main-z4c819pg.mjs";
18
- import {
19
- isSome
20
- } from "./main-d1th6z2h.mjs";
21
-
22
- // src/session-manager/journal.ts
23
- import fs from "node:fs";
24
- import path from "node:path";
25
- var JournalEntry = Struct({
26
- ts: String3,
27
- sessionId: String3,
28
- code: String3,
29
- isError: Boolean3,
30
- durationMs: Number2,
31
- resultPreview: String3,
32
- logCount: Number2,
33
- startUrl: optionalKey(NullOr(String3)),
34
- endUrl: optionalKey(NullOr(String3)),
35
- navigations: optionalKey(ArraySchema(String3)),
36
- warnings: optionalKey(ArraySchema(String3)),
37
- diagnostic: optionalKey(String3),
38
- handoffs: optionalKey(Number2)
39
- });
40
- var decodeJournalEntry = decodeUnknownOption(JournalEntry);
41
- var defaultJournalBaseDir = () => {
42
- return path.join(stateRoot(), "sessions");
43
- };
44
- function journalPathForSession(baseDir, sessionId) {
45
- return path.join(baseDir, sessionId, "journal.jsonl");
46
- }
47
- var maxJournalCodeLength = 2000;
48
- var maxJournalPreviewLength = 400;
49
- var maxJournalDiagnosticLength = 240;
50
- function truncateForJournal(text, maxLength) {
51
- if (text.length <= maxLength) {
52
- return text;
53
- }
54
- return `${text.slice(0, maxLength)}… [truncated ${text.length - maxLength} chars]`;
55
- }
56
- var redacted = "[REDACTED]";
57
- var sensitiveWord = String.raw`(?:pass(?:word|wd|code|phrase)?|pwd|otp|one[-_ ]?time|2fa|mfa|totp|pin|code|token|secret|api[-_]?key|access[-_]?key|private[-_]?key|auth(?:orization)?|credential|session|cookie|bearer|cvv|cvc|card[-_ ]?number)`;
58
- var stringLiteral = String.raw`(?:"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'|\`(?:[^\`\\]|\\.)*\`)`;
59
- var affix = String.raw`{0,64}`;
60
- var sensitiveAssignment = new RegExp(String.raw`(["'\`]?[\w$-]${affix}${sensitiveWord}[\w$-]${affix}["'\`]?\s*[:=]\s*)${stringLiteral}`, "gi");
61
- var valueCall = new RegExp(String.raw`(\.(?:fill|type|pressSequentially|setInputValue)\s*\((?:\s*${stringLiteral}\s*,)?\s*|\bfillInput\s*\([^;\n]*?,\s*)${stringLiteral}`, "gi");
62
- var sensitiveLine = new RegExp(sensitiveWord, "i");
63
- var valueProperty = new RegExp(String.raw`(\bvalue\s*:\s*)${stringLiteral}`, "gi");
64
- var sensitiveQuery = new RegExp(String.raw`([?&#][\w.-]${affix}${sensitiveWord}[\w.-]${affix}=)[^&#\s"'\`]+`, "gi");
65
- var tokenPatterns = [
66
- /\beyJ[\w-]{8,}\.[\w-]{8,}\.[\w-]{8,}/g,
67
- /\b(?:Bearer|Basic)\s+[\w~+/.=-]{12,}/gi,
68
- /\b(?:sk|pk|rk|ghp|gho|ghs|ghu|github_pat|xox[abprs]|glpat|AKIA|ASIA)[-_][\w-]{12,}/g
69
- ];
70
- function redactJournalText(text) {
71
- let output = text.replace(sensitiveAssignment, `$1"${redacted}"`);
72
- output = output.split(`
73
- `).map((line) => {
74
- if (!sensitiveLine.test(line))
75
- return line;
76
- return line.replace(valueCall, `$1"${redacted}"`).replace(valueProperty, `$1"${redacted}"`);
77
- }).join(`
78
- `);
79
- output = output.replace(sensitiveQuery, `$1${redacted}`);
80
- for (const pattern of tokenPatterns)
81
- output = output.replace(pattern, redacted);
82
- return output;
83
- }
84
- function makeJournalEntry(options) {
85
- return {
86
- ts: new Date().toISOString(),
87
- sessionId: options.sessionId,
88
- code: truncateForJournal(redactJournalText(options.code), maxJournalCodeLength),
89
- isError: options.isError,
90
- durationMs: options.durationMs,
91
- resultPreview: truncateForJournal(redactJournalText(options.resultText), maxJournalPreviewLength),
92
- logCount: options.logCount,
93
- ...options.startUrl === undefined ? {} : { startUrl: redactNullableUrl(options.startUrl) },
94
- ...options.endUrl === undefined ? {} : { endUrl: redactNullableUrl(options.endUrl) },
95
- ...options.navigations && options.navigations.length > 0 ? { navigations: options.navigations.map(redactJournalText) } : {},
96
- ...options.warnings && options.warnings.length > 0 ? { warnings: options.warnings.map(redactJournalText) } : {},
97
- ...options.diagnostic ? { diagnostic: truncateForJournal(redactJournalText(options.diagnostic), maxJournalDiagnosticLength) } : {},
98
- ...options.handoffs ? { handoffs: options.handoffs } : {}
99
- };
100
- }
101
- function redactNullableUrl(url) {
102
- return url === null ? null : redactJournalText(url);
103
- }
104
- async function appendJournalEntry(options) {
105
- const filePath = journalPathForSession(options.baseDir, options.entry.sessionId);
106
- await fs.promises.mkdir(options.baseDir, { recursive: true, mode: 448 });
107
- await fs.promises.chmod(options.baseDir, 448);
108
- await fs.promises.mkdir(path.dirname(filePath), { recursive: true, mode: 448 });
109
- await fs.promises.chmod(path.dirname(filePath), 448);
110
- await fs.promises.appendFile(filePath, `${JSON.stringify(options.entry)}
111
- `, { encoding: "utf8", mode: 384 });
112
- await fs.promises.chmod(filePath, 384);
113
- }
114
- var defaultJournalRetentionMs = 14 * 24 * 60 * 60 * 1000;
115
- var defaultJournalMaxCount = 200;
116
- async function pruneSessionJournals(options) {
117
- const maxAgeMs = options.maxAgeMs ?? defaultJournalRetentionMs;
118
- const maxCount = options.maxCount ?? defaultJournalMaxCount;
119
- const now = options.now ?? Date.now();
120
- let names;
121
- try {
122
- names = await fs.promises.readdir(options.baseDir);
123
- } catch (error) {
124
- if (isNodeError(error) && error.code === "ENOENT")
125
- return [];
126
- throw error;
127
- }
128
- await fs.promises.chmod(options.baseDir, 448);
129
- const candidates = [];
130
- for (const id of names) {
131
- if (!isValidSessionId2(id))
132
- continue;
133
- const directory = path.join(options.baseDir, id);
134
- const stat = await fs.promises.lstat(directory).catch(() => {
135
- return;
136
- });
137
- if (!stat?.isDirectory())
138
- continue;
139
- const journal = await fs.promises.lstat(path.join(directory, "journal.jsonl")).catch(() => {
140
- return;
141
- });
142
- candidates.push({ id, directory, modifiedAt: Math.max(stat.mtimeMs, journal?.mtimeMs ?? 0) });
143
- }
144
- const removed = [];
145
- const kept = [];
146
- for (const candidate of candidates) {
147
- if (!options.isLive(candidate.id) && now - candidate.modifiedAt > maxAgeMs)
148
- removed.push(candidate.id);
149
- else
150
- kept.push(candidate);
151
- }
152
- const removable = kept.filter((candidate) => !options.isLive(candidate.id)).sort((left, right) => left.modifiedAt - right.modifiedAt);
153
- const excess = Math.max(0, kept.length - maxCount);
154
- const evicted = new Set(removable.slice(0, excess).map((candidate) => candidate.id));
155
- removed.push(...evicted);
156
- const removedSet = new Set(removed);
157
- for (const candidate of candidates) {
158
- if (removedSet.has(candidate.id)) {
159
- if (options.isLive(candidate.id)) {
160
- removedSet.delete(candidate.id);
161
- continue;
162
- }
163
- await fs.promises.rm(candidate.directory, { recursive: true, force: true });
164
- } else {
165
- await fs.promises.chmod(candidate.directory, 448).catch(() => {});
166
- await fs.promises.chmod(path.join(candidate.directory, "journal.jsonl"), 384).catch(() => {});
167
- }
168
- }
169
- return removed.filter((id) => removedSet.has(id));
170
- }
171
- var journalPruneIntervalMs = 6 * 60 * 60 * 1000;
172
- function startJournalRetention(options) {
173
- const prune = () => {
174
- pruneSessionJournals(options).catch((error) => options.onError?.(error));
175
- };
176
- prune();
177
- const interval = setInterval(prune, journalPruneIntervalMs);
178
- interval.unref();
179
- return () => clearInterval(interval);
180
- }
181
- async function readJournalEntries(options) {
182
- const filePath = journalPathForSession(options.baseDir, options.sessionId);
183
- let raw;
184
- try {
185
- raw = await fs.promises.readFile(filePath, "utf8");
186
- } catch (error) {
187
- if (isNodeError(error) && error.code === "ENOENT") {
188
- return [];
189
- }
190
- throw error;
191
- }
192
- return parseJournalLines(raw).slice(-options.limit);
193
- }
194
- function parseJournalLines(raw) {
195
- const entries = [];
196
- for (const line of raw.split(`
197
- `)) {
198
- const trimmed = line.trim();
199
- if (!trimmed) {
200
- continue;
201
- }
202
- let parsed;
203
- try {
204
- parsed = JSON.parse(trimmed);
205
- } catch {
206
- continue;
207
- }
208
- const decoded = decodeJournalEntry(parsed);
209
- if (isSome(decoded)) {
210
- entries.push(decoded.value);
211
- }
212
- }
213
- return entries;
214
- }
215
- function formatJournalEntry(entry) {
216
- const time = entry.ts.slice(11, 19) || entry.ts;
217
- const status = entry.isError ? "ERR" : "ok ";
218
- const codePreview = entry.code.replace(/\s+/g, " ").trim().slice(0, 80);
219
- const urlPart = entry.endUrl ? ` ${entry.endUrl}` : "";
220
- const navPart = entry.navigations && entry.navigations.length > 0 ? ` nav=${entry.navigations.length}` : "";
221
- const handoffPart = entry.handoffs ? ` handoffs=${entry.handoffs}` : "";
222
- const warningPart = entry.warnings && entry.warnings.length > 0 ? ` warnings=${entry.warnings.length}` : "";
223
- const diagnosticPart = entry.diagnostic ? ` diagnostic=${entry.diagnostic}` : "";
224
- return `${time} ${status} ${String(entry.durationMs).padStart(5)}ms${urlPart}${navPart}${handoffPart}${warningPart}${diagnosticPart} ${codePreview}`;
225
- }
226
-
227
- export { defaultJournalBaseDir, makeJournalEntry, appendJournalEntry, startJournalRetention, readJournalEntries, formatJournalEntry };
@@ -1,39 +0,0 @@
1
- // src/cli/output.ts
2
- import { writeSync } from "node:fs";
3
- var ExitCode = { ok: 0, failure: 1, usage: 2, auth: 3, host: 4 };
4
- var failure = (command, code, message, options = {}) => ({
5
- ok: false,
6
- command,
7
- checkedAt: new Date().toISOString(),
8
- error: {
9
- code,
10
- message,
11
- ...options.hint ? { hint: options.hint } : {},
12
- exitCode: options.exitCode ?? ExitCode.failure
13
- }
14
- });
15
- var takeJsonFlag = (argv) => ({
16
- json: argv.includes("--json"),
17
- argv: argv.filter((arg) => arg !== "--json")
18
- });
19
- var pause = new Int32Array(new SharedArrayBuffer(4));
20
- var writeStdout = (text, fd = 1) => {
21
- const buffer = Buffer.from(text);
22
- let offset = 0;
23
- while (offset < buffer.length) {
24
- try {
25
- offset += writeSync(fd, buffer, offset, buffer.length - offset);
26
- } catch (error) {
27
- const code = error.code;
28
- if (code === "EPIPE")
29
- return;
30
- if (code !== "EAGAIN")
31
- throw error;
32
- Atomics.wait(pause, 0, 0, 2);
33
- }
34
- }
35
- };
36
- var printJson = (value) => writeStdout(`${JSON.stringify(value, null, 2)}
37
- `);
38
-
39
- export { ExitCode, failure, takeJsonFlag, writeStdout, printJson };
@@ -1,161 +0,0 @@
1
- import {
2
- writePrivateJsonFileSync
3
- } from "./main-t8hspw29.mjs";
4
- import {
5
- bundledPairingCodeTtlMs,
6
- mintPairingCode,
7
- writeExtensionPairing
8
- } from "./main-4fw36c57.mjs";
9
- import {
10
- configRoot2,
11
- cacheRoot,
12
- devExtensionUrl,
13
- devExtensionFolder
14
- } from "./main-dyya6jpy.mjs";
15
-
16
- // src/setup/dev-extension.ts
17
- import { createHash } from "node:crypto";
18
- import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
19
- import path from "node:path";
20
- import { crc32, inflateRawSync } from "node:zlib";
21
- var devExtensionRecord = (root = cacheRoot()) => path.join(root, "extension.json");
22
- function installedDevExtension(root = cacheRoot()) {
23
- try {
24
- const record = JSON.parse(readFileSync(devExtensionRecord(root), "utf8"));
25
- return typeof record.sha256 === "string" && existsSync(path.join(devExtensionFolder(root), "manifest.json")) ? record : undefined;
26
- } catch {
27
- return;
28
- }
29
- }
30
- async function syncDevExtension(extension, options = {}) {
31
- const root = options.root ?? cacheRoot();
32
- const folder = devExtensionFolder(root);
33
- if (installedDevExtension(root)?.sha256 === extension.sha256)
34
- return "current";
35
- const url = devExtensionUrl(extension, options.env);
36
- const response = await (options.fetch ?? fetch)(url, { signal: AbortSignal.timeout(120000), headers: { "user-agent": "browse/dev" } });
37
- if (!response.ok)
38
- throw new Error(`downloading the dev extension from ${url} failed: HTTP ${response.status}`);
39
- const zip = Buffer.from(await response.arrayBuffer());
40
- const sha256 = createHash("sha256").update(zip).digest("hex");
41
- if (zip.length !== extension.size || sha256 !== extension.sha256)
42
- throw new Error(`the dev extension from ${url} isn't the one this version was built with (sha256 ${sha256}, ${zip.length} bytes)`);
43
- mkdirSync(root, { recursive: true });
44
- const staging = path.join(root, `.extension-${process.pid}-${Date.now()}`);
45
- const old = `${staging}-old`;
46
- rmSync(staging, { recursive: true, force: true });
47
- try {
48
- for (const entry of unzip(zip)) {
49
- const target = path.join(staging, ...entry.name.split("/"));
50
- mkdirSync(path.dirname(target), { recursive: true });
51
- if (!entry.directory)
52
- writeFileSync(target, entry.data);
53
- }
54
- const manifest = JSON.parse(readFileSync(path.join(staging, "manifest.json"), "utf8"));
55
- if (!manifest.key)
56
- throw new Error("the dev extension has no manifest key, so it wouldn't have browse's unpacked ID");
57
- writeExtensionPairing(staging, mintPairingCode(undefined, { ttlMs: bundledPairingCodeTtlMs }), options.port);
58
- const build = (() => {
59
- try {
60
- return JSON.parse(readFileSync(path.join(staging, "build.json"), "utf8")).build;
61
- } catch {
62
- return;
63
- }
64
- })();
65
- if (existsSync(folder))
66
- renameSync(folder, old);
67
- renameSync(staging, folder);
68
- const version = manifest.version_name ?? manifest.version;
69
- const record = { ...version ? { version } : {}, file: extension.file, sha256, ...build ? { build } : {}, installedAt: new Date().toISOString() };
70
- writeFileSync(devExtensionRecord(root), JSON.stringify(record, null, 2) + `
71
- `);
72
- return "updated";
73
- } finally {
74
- rmSync(staging, { recursive: true, force: true });
75
- rmSync(old, { recursive: true, force: true });
76
- }
77
- }
78
- function unzip(zip) {
79
- let end = -1;
80
- for (let offset = zip.length - 22;offset >= Math.max(0, zip.length - 22 - 65535); offset--)
81
- if (zip.readUInt32LE(offset) === 101010256) {
82
- end = offset;
83
- break;
84
- }
85
- if (end < 0)
86
- throw new Error("not a zip archive");
87
- const count = zip.readUInt16LE(end + 10);
88
- let offset = zip.readUInt32LE(end + 16);
89
- const entries = [];
90
- for (let index = 0;index < count; index++) {
91
- if (zip.readUInt32LE(offset) !== 33639248)
92
- throw new Error("corrupt zip central directory");
93
- const method = zip.readUInt16LE(offset + 10);
94
- const crc = zip.readUInt32LE(offset + 16);
95
- const compressed = zip.readUInt32LE(offset + 20);
96
- const size = zip.readUInt32LE(offset + 24);
97
- const nameLength = zip.readUInt16LE(offset + 28);
98
- const extraLength = zip.readUInt16LE(offset + 30);
99
- const commentLength = zip.readUInt16LE(offset + 32);
100
- const mode = zip.readUInt32LE(offset + 38) >>> 16;
101
- const local = zip.readUInt32LE(offset + 42);
102
- const name = zip.toString("utf8", offset + 46, offset + 46 + nameLength);
103
- offset += 46 + nameLength + extraLength + commentLength;
104
- if (!name || name.startsWith("/") || name.includes("\\") || name.split("/").some((part) => part === ".." || part === "."))
105
- throw new Error(`unsafe path in zip: ${JSON.stringify(name)}`);
106
- if ((mode & 61440) === 40960)
107
- throw new Error(`symbolic link in zip: ${name}`);
108
- if (compressed === 4294967295 || size === 4294967295)
109
- throw new Error("ZIP64 archives aren't supported");
110
- const directory = name.endsWith("/");
111
- if (directory) {
112
- entries.push({ name: name.slice(0, -1), directory, data: Buffer.alloc(0) });
113
- continue;
114
- }
115
- if (zip.readUInt32LE(local) !== 67324752)
116
- throw new Error(`corrupt zip entry ${name}`);
117
- const start = local + 30 + zip.readUInt16LE(local + 26) + zip.readUInt16LE(local + 28);
118
- const raw = zip.subarray(start, start + compressed);
119
- const data = method === 0 ? Buffer.from(raw) : method === 8 ? inflateRawSync(raw) : undefined;
120
- if (!data)
121
- throw new Error(`unsupported compression method ${method} for ${name}`);
122
- if (data.length !== size || crc32(data) !== crc)
123
- throw new Error(`zip entry ${name} is corrupt`);
124
- entries.push({ name, directory, data });
125
- }
126
- return entries;
127
- }
128
-
129
- // src/relay/config.ts
130
- import fs from "node:fs";
131
- import path2 from "node:path";
132
- var relayConfigPath = (root = configRoot2()) => path2.join(root, "config.json");
133
- function parseHostname(input) {
134
- if (typeof input !== "string")
135
- return;
136
- const value = input.trim().toLowerCase();
137
- if (value === "127.0.0.1" || value === "localhost")
138
- return "127.0.0.1";
139
- if (value === "0.0.0.0")
140
- return "0.0.0.0";
141
- return;
142
- }
143
- function readRelayConfig(root = configRoot2()) {
144
- try {
145
- const value = JSON.parse(fs.readFileSync(relayConfigPath(root), "utf8"));
146
- const hostname = parseHostname(value?.hostname);
147
- return hostname === undefined ? {} : { hostname };
148
- } catch {
149
- return {};
150
- }
151
- }
152
- function writeRelayConfig(config, root = configRoot2()) {
153
- writePrivateJsonFileSync(relayConfigPath(root), config, { ensureParent: true });
154
- }
155
- var relayHostname = (root = configRoot2()) => readRelayConfig(root).hostname ?? "127.0.0.1";
156
- function isLocalPeer(socket) {
157
- const remote = socket.remoteAddress?.replace(/^::ffff:/, "");
158
- return remote !== undefined && (remote === "::1" || remote.startsWith("127."));
159
- }
160
-
161
- export { installedDevExtension, syncDevExtension, parseHostname, readRelayConfig, writeRelayConfig, relayHostname, isLocalPeer };
@@ -1,4 +0,0 @@
1
- // src/version.ts
2
- var opencodeBrowserVersion2 = "0.0.18-dev.192";
3
- var opencodeBrowserBuildId2 = "2026-11-14T18:41:00.716Z";
4
- export { opencodeBrowserVersion2, opencodeBrowserBuildId2 };