@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.
- package/dist/cli.mjs +62 -117
- package/package.json +13 -33
- package/dist/Runtime-r9sev1rq.mjs +0 -16
- package/dist/THIRD_PARTY_NOTICES.txt +0 -310
- package/dist/Undici-xgvbtsb1.mjs +0 -25295
- package/dist/cli-ekwkvvmm.mjs +0 -5943
- package/dist/coreBundle-mbshhes2.mjs +0 -8
- package/dist/helpers-3ycvp75a.mjs +0 -71
- package/dist/index-xsb9s479.mjs +0 -13
- package/dist/legacy-runtime-v1sdjj5h.mjs +0 -135
- package/dist/log-yek648ak.mjs +0 -9
- package/dist/main-1qwrze1y.mjs +0 -140
- package/dist/main-2p0v71q0.mjs +0 -1752
- package/dist/main-3g7fdzbh.mjs +0 -5360
- package/dist/main-55a4gpef.mjs +0 -1261
- package/dist/main-693wwz19.mjs +0 -4
- package/dist/main-91vhk5de.mjs +0 -38
- package/dist/main-9t32k44b.mjs +0 -798
- package/dist/main-bv9nawja.mjs +0 -5191
- package/dist/main-cgnkhs2x.mjs +0 -35
- package/dist/main-esdgpebk.mjs +0 -161
- package/dist/main-fg5awggs.mjs +0 -5514
- package/dist/main-gexpjhk5.mjs +0 -32
- package/dist/main-gt2gskrq.mjs +0 -160
- package/dist/main-gw77et6v.mjs +0 -342
- package/dist/main-j98fzrvv.mjs +0 -68
- package/dist/main-kcw411ep.mjs +0 -891
- package/dist/main-nnfxg7re.mjs +0 -11403
- package/dist/main-pcqtqhgv.mjs +0 -64
- package/dist/main-pmfd055v.mjs +0 -63
- package/dist/main-pxs5m0kb.mjs +0 -329
- package/dist/main-qazf3bhk.mjs +0 -223
- package/dist/main-sf7vaxb6.mjs +0 -17
- package/dist/main-stf180y1.mjs +0 -229
- package/dist/main-tk4axre7.mjs +0 -39
- package/dist/main-zedq93ez.mjs +0 -215
- package/dist/main-zzggnpf4.mjs +0 -73
- package/dist/mcp-xfx04fxe.mjs +0 -9470
- package/dist/migrate-4rewxqd7.mjs +0 -354
- package/dist/relay-me036e19.mjs +0 -18765
- package/dist/remove-stored-secrets-ymhge5va.mjs +0 -6
- package/dist/runtime-update-hd2cvy1c.mjs +0 -246
- package/dist/setup-0hmbzam5.mjs +0 -1052
- package/dist/update-vnkjbc0e.mjs +0 -17
- package/dist/version-jn0h3rmc.mjs +0 -8
package/dist/main-cgnkhs2x.mjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ensurePrivateDirectorySync
|
|
3
|
-
} from "./main-91vhk5de.mjs";
|
|
4
|
-
import {
|
|
5
|
-
stateRoot
|
|
6
|
-
} from "./main-1qwrze1y.mjs";
|
|
7
|
-
|
|
8
|
-
// src/relay/log.ts
|
|
9
|
-
import fs from "node:fs";
|
|
10
|
-
import os from "node:os";
|
|
11
|
-
import path from "node:path";
|
|
12
|
-
var maxLogBytes = 1e6;
|
|
13
|
-
var maxEntryCharacters = 64000;
|
|
14
|
-
function managedRelayLogPath(home = os.homedir()) {
|
|
15
|
-
return path.join(stateRoot(home), "logs", "relay.log");
|
|
16
|
-
}
|
|
17
|
-
function appendManagedRelayProcessLog2(message, home = os.homedir()) {
|
|
18
|
-
try {
|
|
19
|
-
const logPath = managedRelayLogPath(home);
|
|
20
|
-
ensurePrivateDirectorySync(path.dirname(logPath));
|
|
21
|
-
const entry = `${new Date().toISOString()} ${message.slice(0, maxEntryCharacters)}
|
|
22
|
-
`;
|
|
23
|
-
const stat = fs.statSync(logPath, { throwIfNoEntry: false });
|
|
24
|
-
if (stat && stat.size + Buffer.byteLength(entry) > maxLogBytes)
|
|
25
|
-
fs.renameSync(logPath, `${logPath}.1`);
|
|
26
|
-
fs.appendFileSync(logPath, entry, { encoding: "utf8", mode: 384 });
|
|
27
|
-
fs.chmodSync(logPath, 384);
|
|
28
|
-
} catch {}
|
|
29
|
-
}
|
|
30
|
-
function relayLog2(event, fields = {}) {
|
|
31
|
-
const detail = Object.entries(fields).filter(([, value]) => value !== undefined).map(([key, value]) => `${key}=${typeof value === "string" && !/\s/.test(value) ? value : JSON.stringify(value)}`).join(" ");
|
|
32
|
-
appendManagedRelayProcessLog2(detail ? `${event} ${detail}` : event);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { appendManagedRelayProcessLog2, relayLog2 };
|
package/dist/main-esdgpebk.mjs
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
writePrivateJsonFileSync
|
|
3
|
-
} from "./main-91vhk5de.mjs";
|
|
4
|
-
import {
|
|
5
|
-
bundledPairingCodeTtlMs,
|
|
6
|
-
mintPairingCode,
|
|
7
|
-
writeExtensionPairing
|
|
8
|
-
} from "./main-gt2gskrq.mjs";
|
|
9
|
-
import {
|
|
10
|
-
configRoot2,
|
|
11
|
-
cacheRoot,
|
|
12
|
-
devExtensionUrl,
|
|
13
|
-
devExtensionFolder
|
|
14
|
-
} from "./main-1qwrze1y.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 };
|