@opencode/browse 0.0.6-dev.17 → 0.0.6-dev.19
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-b4sbkefj.mjs → cli-22fe7etn.mjs} +771 -644
- package/dist/cli.mjs +9 -9
- package/dist/{relay-helpers-pjcbxs7p.mjs → helpers-rta4d2as.mjs} +1 -1
- package/dist/{main-4p2p9eey.mjs → main-2wrztakb.mjs} +4 -4
- package/dist/main-75rdz6bc.mjs +130 -0
- package/dist/{main-3qpkwaa7.mjs → main-8a245rm1.mjs} +24 -22
- package/dist/{main-e4stqtf2.mjs → main-90enpn5q.mjs} +1622 -1477
- package/dist/{main-kvmxefp1.mjs → main-knahxbey.mjs} +4 -4
- package/dist/main-ts9jjqs8.mjs +4 -0
- package/dist/{main-zwe0c783.mjs → main-xatp12cr.mjs} +10 -22
- package/dist/{main-g5mke6rn.mjs → main-yd50d95g.mjs} +120 -118
- package/dist/{mcp-2smdsn8z.mjs → mcp-p0mcjvq9.mjs} +584 -481
- package/dist/{relay-ns525pms.mjs → relay-tfvn856e.mjs} +15746 -15309
- package/dist/{runtime-update-0mddkfy5.mjs → runtime-update-pxbj49tf.mjs} +7 -8
- package/dist/{setup-f2qjnvre.mjs → setup-y8pd11b8.mjs} +813 -707
- package/dist/{update-cyy1grjj.mjs → update-5fx8t344.mjs} +2 -2
- package/dist/{version-wrebjhy7.mjs → version-cjhq7cm9.mjs} +1 -1
- package/package.json +1 -2
- package/dist/main-4bht27ry.mjs +0 -72
- package/dist/main-y7c1atbf.mjs +0 -4
package/dist/cli.mjs
CHANGED
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
// src/main.ts
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
var embeddedVersion = "0.0.6-dev.
|
|
5
|
+
var embeddedVersion = "0.0.6-dev.19";
|
|
6
6
|
var setupCommands = new Set(["install", "uninstall", "extension", "pair", "rollback", "set"]);
|
|
7
7
|
var command = process.argv[2];
|
|
8
8
|
var invokedAs = path.basename(process.argv[1] ?? "");
|
|
9
9
|
if (command === "--version" || command === "-v") {
|
|
10
|
-
const opencodeBrowserVersion = embeddedVersion ?? (await import("./version-
|
|
10
|
+
const opencodeBrowserVersion = embeddedVersion ?? (await import("./version-cjhq7cm9.mjs")).opencodeBrowserVersion;
|
|
11
11
|
process.stdout.write(`${opencodeBrowserVersion}
|
|
12
12
|
`);
|
|
13
|
-
} else if (invokedAs === "opencode-browser-mcp") {
|
|
13
|
+
} else if (invokedAs === "opencode-browser-mcp" || command === "mcp" && process.argv.length === 3) {
|
|
14
14
|
const { NodeRuntime } = await import("@effect/platform-node");
|
|
15
|
-
const { runMcpServer } = await import("./mcp-
|
|
15
|
+
const { runMcpServer } = await import("./mcp-p0mcjvq9.mjs");
|
|
16
16
|
runMcpServer.pipe(NodeRuntime.runMain);
|
|
17
17
|
} else if (command === "runtime-install" || command === "runtime-switch") {
|
|
18
|
-
const { runRuntimeInstall, runRuntimeSwitch } = await import("./runtime-update-
|
|
18
|
+
const { runRuntimeInstall, runRuntimeSwitch } = await import("./runtime-update-pxbj49tf.mjs");
|
|
19
19
|
await (command === "runtime-install" ? runRuntimeInstall : runRuntimeSwitch)(process.argv.slice(3));
|
|
20
20
|
} else if (command === "update") {
|
|
21
|
-
const { runUpdateCommand } = await import("./update-
|
|
21
|
+
const { runUpdateCommand } = await import("./update-5fx8t344.mjs");
|
|
22
22
|
await runUpdateCommand(process.argv.slice(3));
|
|
23
23
|
} else if (command && setupCommands.has(command)) {
|
|
24
|
-
const { runSetup } = await import("./setup-
|
|
24
|
+
const { runSetup } = await import("./setup-y8pd11b8.mjs");
|
|
25
25
|
await runSetup(command, process.argv.slice(3));
|
|
26
26
|
} else {
|
|
27
27
|
if (!command || command === "--help" || command === "-h") {
|
|
@@ -55,9 +55,9 @@ if (command === "--version" || command === "-v") {
|
|
|
55
55
|
`);
|
|
56
56
|
}
|
|
57
57
|
if (command === "status" && !process.argv.includes("--json")) {
|
|
58
|
-
const { printSetupStatus } = await import("./setup-
|
|
58
|
+
const { printSetupStatus } = await import("./setup-y8pd11b8.mjs");
|
|
59
59
|
printSetupStatus();
|
|
60
60
|
}
|
|
61
|
-
const { runCli } = await import("./cli-
|
|
61
|
+
const { runCli } = await import("./cli-22fe7etn.mjs");
|
|
62
62
|
runCli();
|
|
63
63
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
unpackedReloadAdvice,
|
|
3
2
|
dataRoot,
|
|
4
3
|
checkoutRoot,
|
|
5
4
|
cliCommand,
|
|
6
5
|
compareVersions,
|
|
7
6
|
npmRuntime,
|
|
8
|
-
autoUpdateStatus
|
|
9
|
-
|
|
7
|
+
autoUpdateStatus,
|
|
8
|
+
unpackedReloadAdvice
|
|
9
|
+
} from "./main-yd50d95g.mjs";
|
|
10
10
|
|
|
11
11
|
// src/update.ts
|
|
12
12
|
import { execFile, spawnSync } from "node:child_process";
|
|
@@ -312,7 +312,7 @@ function runUpdate(args, deps) {
|
|
|
312
312
|
async function runUpdateCommand2(args) {
|
|
313
313
|
const log = (line) => process.stdout.write(line + `
|
|
314
314
|
`);
|
|
315
|
-
const { runNpmUpdate } = await import("./runtime-update-
|
|
315
|
+
const { runNpmUpdate } = await import("./runtime-update-pxbj49tf.mjs");
|
|
316
316
|
if (await runNpmUpdate(args))
|
|
317
317
|
return;
|
|
318
318
|
if (args.includes("--check")) {
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import {
|
|
2
|
+
dataRoot
|
|
3
|
+
} from "./main-yd50d95g.mjs";
|
|
4
|
+
|
|
5
|
+
// src/relay/secrets.ts
|
|
6
|
+
import crypto2 from "node:crypto";
|
|
7
|
+
import fs2 from "node:fs";
|
|
8
|
+
import path2 from "node:path";
|
|
9
|
+
|
|
10
|
+
// src/fs-durability.ts
|
|
11
|
+
import { Predicate } from "effect";
|
|
12
|
+
import crypto from "node:crypto";
|
|
13
|
+
import fsSync from "node:fs";
|
|
14
|
+
import fs from "node:fs/promises";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
var unsupportedDirectorySyncCodes = new Set(["EPERM", "EINVAL", "ENOTSUP"]);
|
|
17
|
+
function isNodeError(error) {
|
|
18
|
+
return error instanceof Error && "code" in error;
|
|
19
|
+
}
|
|
20
|
+
function isUnsupportedDirectorySyncError(error) {
|
|
21
|
+
return isNodeError(error) && Predicate.isString(error.code) && unsupportedDirectorySyncCodes.has(error.code);
|
|
22
|
+
}
|
|
23
|
+
async function writeJsonFileAtomically(filePath, value, options = {}) {
|
|
24
|
+
const directory = path.dirname(filePath);
|
|
25
|
+
await fs.mkdir(directory, {
|
|
26
|
+
recursive: true,
|
|
27
|
+
...options.dirMode === undefined ? {} : { mode: options.dirMode }
|
|
28
|
+
});
|
|
29
|
+
if (options.dirMode !== undefined) {
|
|
30
|
+
await fs.chmod(directory, options.dirMode);
|
|
31
|
+
}
|
|
32
|
+
const temporaryPath = `${filePath}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
|
33
|
+
let renamed = false;
|
|
34
|
+
try {
|
|
35
|
+
await fs.writeFile(temporaryPath, `${JSON.stringify(value, null, 2)}
|
|
36
|
+
`, { mode: 384 });
|
|
37
|
+
await fs.rename(temporaryPath, filePath);
|
|
38
|
+
renamed = true;
|
|
39
|
+
await fs.chmod(filePath, 384);
|
|
40
|
+
} finally {
|
|
41
|
+
if (!renamed)
|
|
42
|
+
await fs.rm(temporaryPath, { force: true }).catch(() => {});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function ensurePrivateDirectorySync(directory) {
|
|
46
|
+
fsSync.mkdirSync(directory, { recursive: true, mode: 448 });
|
|
47
|
+
if (process.platform !== "win32")
|
|
48
|
+
fsSync.chmodSync(directory, 448);
|
|
49
|
+
}
|
|
50
|
+
function writePrivateJsonFileSync(filePath, value, options = {}) {
|
|
51
|
+
if (options.ensureParent)
|
|
52
|
+
ensurePrivateDirectorySync(path.dirname(filePath));
|
|
53
|
+
const temporaryPath = `${filePath}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
|
54
|
+
let renamed = false;
|
|
55
|
+
try {
|
|
56
|
+
fsSync.writeFileSync(temporaryPath, `${JSON.stringify(value, null, 2)}
|
|
57
|
+
`, { mode: 384 });
|
|
58
|
+
fsSync.renameSync(temporaryPath, filePath);
|
|
59
|
+
renamed = true;
|
|
60
|
+
if (process.platform !== "win32")
|
|
61
|
+
fsSync.chmodSync(filePath, 384);
|
|
62
|
+
} finally {
|
|
63
|
+
if (!renamed)
|
|
64
|
+
fsSync.rmSync(temporaryPath, { force: true });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/relay/secrets.ts
|
|
69
|
+
var relayTokenQueryParam = "opencodeBrowserToken";
|
|
70
|
+
var tokenPattern = /^[A-Za-z0-9_-]{43}$/;
|
|
71
|
+
function relayTokenPath(root = dataRoot()) {
|
|
72
|
+
return path2.join(root, "relay-token");
|
|
73
|
+
}
|
|
74
|
+
function relayToken(root = dataRoot()) {
|
|
75
|
+
return readOrCreateSecret(relayTokenPath(root), () => crypto2.randomBytes(32).toString("base64url"), (value) => tokenPattern.test(value));
|
|
76
|
+
}
|
|
77
|
+
function relayAuthorization(root = dataRoot()) {
|
|
78
|
+
return `Bearer ${relayToken(root)}`;
|
|
79
|
+
}
|
|
80
|
+
function secretsEqual(expected, actual) {
|
|
81
|
+
if (actual === undefined)
|
|
82
|
+
return false;
|
|
83
|
+
const a = crypto2.createHash("sha256").update(expected).digest();
|
|
84
|
+
const b = crypto2.createHash("sha256").update(actual).digest();
|
|
85
|
+
return crypto2.timingSafeEqual(a, b) && expected.length === actual.length;
|
|
86
|
+
}
|
|
87
|
+
function readOrCreateSecret(file, generate, valid) {
|
|
88
|
+
const existing = readSecret(file);
|
|
89
|
+
if (existing !== undefined && valid(existing))
|
|
90
|
+
return existing;
|
|
91
|
+
ensurePrivateDirectory(path2.dirname(file));
|
|
92
|
+
const temporary = `${file}.${process.pid}.${crypto2.randomUUID()}.tmp`;
|
|
93
|
+
fs2.writeFileSync(temporary, `${generate()}
|
|
94
|
+
`, { mode: 384 });
|
|
95
|
+
try {
|
|
96
|
+
if (existing === undefined) {
|
|
97
|
+
try {
|
|
98
|
+
fs2.linkSync(temporary, file);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
if (error.code !== "EEXIST")
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
fs2.renameSync(temporary, file);
|
|
105
|
+
}
|
|
106
|
+
} finally {
|
|
107
|
+
fs2.rmSync(temporary, { force: true });
|
|
108
|
+
}
|
|
109
|
+
const created = readSecret(file);
|
|
110
|
+
if (created === undefined || !valid(created))
|
|
111
|
+
throw new Error(`Could not create ${file}`);
|
|
112
|
+
return created;
|
|
113
|
+
}
|
|
114
|
+
function readSecret(file) {
|
|
115
|
+
try {
|
|
116
|
+
const stat = fs2.statSync(file);
|
|
117
|
+
if (process.platform !== "win32" && (stat.mode & 63) !== 0)
|
|
118
|
+
fs2.chmodSync(file, 384);
|
|
119
|
+
return fs2.readFileSync(file, "utf8").trim();
|
|
120
|
+
} catch (error) {
|
|
121
|
+
if (error.code === "ENOENT")
|
|
122
|
+
return;
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function ensurePrivateDirectory(directory = dataRoot()) {
|
|
127
|
+
ensurePrivateDirectorySync(directory);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export { isNodeError, isUnsupportedDirectorySyncError, writeJsonFileAtomically, ensurePrivateDirectorySync, writePrivateJsonFileSync, relayTokenQueryParam, relayToken, relayAuthorization, secretsEqual, ensurePrivateDirectory };
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
+
cliCommand,
|
|
3
|
+
installCommand,
|
|
4
|
+
npmRuntime,
|
|
2
5
|
unpackedExtensionId,
|
|
3
6
|
extensionReconnectAlarmPeriodMs,
|
|
4
7
|
extensionProtocolAdvice,
|
|
5
|
-
parseJsonObject
|
|
6
|
-
|
|
7
|
-
installCommand,
|
|
8
|
-
npmRuntime
|
|
9
|
-
} from "./main-g5mke6rn.mjs";
|
|
10
|
-
import {
|
|
11
|
-
opencodeBrowserBuildId2
|
|
12
|
-
} from "./main-y7c1atbf.mjs";
|
|
8
|
+
parseJsonObject
|
|
9
|
+
} from "./main-yd50d95g.mjs";
|
|
13
10
|
import {
|
|
14
11
|
relayAuthorization
|
|
15
|
-
} from "./main-
|
|
12
|
+
} from "./main-75rdz6bc.mjs";
|
|
13
|
+
import {
|
|
14
|
+
opencodeBrowserBuildId2
|
|
15
|
+
} from "./main-ts9jjqs8.mjs";
|
|
16
16
|
|
|
17
|
-
// src/relay
|
|
17
|
+
// src/relay/helpers.ts
|
|
18
18
|
import crypto from "node:crypto";
|
|
19
19
|
import { Effect, Option, Predicate, Schema as Schema2 } from "effect";
|
|
20
20
|
|
|
21
|
-
// src/relay
|
|
21
|
+
// src/relay/schema.ts
|
|
22
22
|
import { Schema } from "effect";
|
|
23
23
|
var SessionSummary = Schema.Struct({
|
|
24
24
|
id: Schema.String,
|
|
@@ -524,7 +524,7 @@ var ErrorEnvelope = Schema.Struct({
|
|
|
524
524
|
code: Schema.optionalKey(RelayErrorCode)
|
|
525
525
|
});
|
|
526
526
|
|
|
527
|
-
// src/relay
|
|
527
|
+
// src/relay/helpers.ts
|
|
528
528
|
var defaultHost2 = "127.0.0.1";
|
|
529
529
|
var defaultPort2 = 19988;
|
|
530
530
|
var stableUnpackedExtensionOrigin2 = `chrome-extension://${unpackedExtensionId}`;
|
|
@@ -946,7 +946,15 @@ async function dataUrlDocument2(url) {
|
|
|
946
946
|
return;
|
|
947
947
|
}
|
|
948
948
|
|
|
949
|
-
// src/relay
|
|
949
|
+
// src/relay/lifecycle.ts
|
|
950
|
+
import { Config as Config2, Effect as Effect3, Result, Schedule, Schema as Schema4 } from "effect";
|
|
951
|
+
import { spawn } from "node:child_process";
|
|
952
|
+
import crypto2 from "node:crypto";
|
|
953
|
+
import path from "node:path";
|
|
954
|
+
import process2 from "node:process";
|
|
955
|
+
import { fileURLToPath } from "node:url";
|
|
956
|
+
|
|
957
|
+
// src/relay/client.ts
|
|
950
958
|
import { NodeHttpClient } from "@effect/platform-node";
|
|
951
959
|
import { Config, Context, Effect as Effect2, Layer, Option as Option2, Schema as Schema3 } from "effect";
|
|
952
960
|
import { HttpClient, HttpClientRequest } from "effect/http";
|
|
@@ -1118,14 +1126,8 @@ function mcpClientPid() {
|
|
|
1118
1126
|
}
|
|
1119
1127
|
var layerFetchMcp = Layer.effect(Service, make({ clientPid: mcpClientPid() })).pipe(Layer.provide(NodeHttpClient.layerNodeHttp));
|
|
1120
1128
|
|
|
1121
|
-
// src/relay
|
|
1122
|
-
|
|
1123
|
-
import { spawn } from "node:child_process";
|
|
1124
|
-
import crypto2 from "node:crypto";
|
|
1125
|
-
import path from "node:path";
|
|
1126
|
-
import process2 from "node:process";
|
|
1127
|
-
import { fileURLToPath } from "node:url";
|
|
1128
|
-
var loadedCliEntrypoint = fileURLToPath(new URL(import.meta.url.endsWith(".ts") ? "./main.ts" : "./cli.mjs", import.meta.url));
|
|
1129
|
+
// src/relay/lifecycle.ts
|
|
1130
|
+
var loadedCliEntrypoint = fileURLToPath(new URL(import.meta.url.endsWith(".ts") ? "../main.ts" : "./cli.mjs", import.meta.url));
|
|
1129
1131
|
var clientInstanceId = crypto2.randomUUID();
|
|
1130
1132
|
function shouldWaitForExtensionReconnect(readiness) {
|
|
1131
1133
|
return readiness.started || readiness.waitForReconnect === true;
|
|
@@ -1408,7 +1410,7 @@ function managedRelayLaunch(entrypoint = loadedCliEntrypoint, executable = proce
|
|
|
1408
1410
|
}
|
|
1409
1411
|
function managedRelayEntrypoint(entrypoint) {
|
|
1410
1412
|
const name = path.basename(entrypoint);
|
|
1411
|
-
if (name === "
|
|
1413
|
+
if (name === "index.ts" || name === "opencode-browser-client.ts" || name === "cli.ts")
|
|
1412
1414
|
return path.join(path.dirname(entrypoint), "main.ts");
|
|
1413
1415
|
return entrypoint;
|
|
1414
1416
|
}
|