@opencode/browse 0.0.13 → 0.0.14-dev.87
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-z3twnjj8.mjs → cli-epthh991.mjs} +9 -9
- package/dist/cli.mjs +11 -11
- package/dist/{helpers-3rnbhy2z.mjs → helpers-zxck525m.mjs} +1 -1
- package/dist/{main-38m5vgda.mjs → main-4avkdmzd.mjs} +2 -2
- package/dist/{main-wkc2xnnr.mjs → main-4qd7wzb5.mjs} +5 -5
- package/dist/{main-yn6cakhj.mjs → main-4r0wgxtf.mjs} +1 -1
- package/dist/{main-v2vj92y4.mjs → main-5aymyfdh.mjs} +2 -2
- package/dist/{main-3a03qxjf.mjs → main-cmq71n09.mjs} +2 -2
- package/dist/{main-7brfgshh.mjs → main-dk43bgqt.mjs} +1 -1
- package/dist/{main-vvmcnhwj.mjs → main-dm2decgk.mjs} +3 -3
- package/dist/main-e4wynyjq.mjs +4 -0
- package/dist/{main-jqyfjaa7.mjs → main-eq3ptjam.mjs} +3 -3
- package/dist/{main-0wgs0y9r.mjs → main-ptn0nanz.mjs} +284 -35
- package/dist/{mcp-5xfqr37f.mjs → mcp-479trmbn.mjs} +6 -6
- package/dist/{migrate-j03hae8h.mjs → migrate-1kj40mtj.mjs} +4 -4
- package/dist/{relay-33kr8a9a.mjs → relay-x14pkmgm.mjs} +9 -9
- package/dist/{runtime-update-564pdwp9.mjs → runtime-update-gvn1fmm9.mjs} +71 -6
- package/dist/{setup-7sjv6php.mjs → setup-2gb33k05.mjs} +6 -6
- package/dist/{supervisor-gftc3pf4.mjs → supervisor-rtm4mamf.mjs} +3 -3
- package/dist/{update-m9185wc0.mjs → update-2vzc881k.mjs} +3 -3
- package/dist/{version-hp4vybq1.mjs → version-q2kbn8pp.mjs} +1 -1
- package/package.json +1 -1
- package/dist/main-j1c8tenv.mjs +0 -4
|
@@ -105,7 +105,7 @@ import {
|
|
|
105
105
|
import {
|
|
106
106
|
opencodeBrowserVersion2,
|
|
107
107
|
opencodeBrowserBuildId2
|
|
108
|
-
} from "./main-
|
|
108
|
+
} from "./main-e4wynyjq.mjs";
|
|
109
109
|
import {
|
|
110
110
|
configRoot2,
|
|
111
111
|
dataRoot,
|
|
@@ -118,7 +118,7 @@ import {
|
|
|
118
118
|
devExtension,
|
|
119
119
|
installCommand,
|
|
120
120
|
autoUpdateStatus
|
|
121
|
-
} from "./main-
|
|
121
|
+
} from "./main-ptn0nanz.mjs";
|
|
122
122
|
import {
|
|
123
123
|
extensionProtocolVersion,
|
|
124
124
|
extensionProtocolAdvice
|
|
@@ -144,13 +144,13 @@ import {
|
|
|
144
144
|
ensureExtensionConnected,
|
|
145
145
|
stoppedRelayStatus,
|
|
146
146
|
statusCollections
|
|
147
|
-
} from "./main-
|
|
147
|
+
} from "./main-eq3ptjam.mjs";
|
|
148
148
|
import"./main-vgzr4689.mjs";
|
|
149
149
|
import {
|
|
150
150
|
updateJson2,
|
|
151
151
|
formatUpdateNotice2,
|
|
152
152
|
updateNotice2
|
|
153
|
-
} from "./main-
|
|
153
|
+
} from "./main-4qd7wzb5.mjs";
|
|
154
154
|
import {
|
|
155
155
|
settingKeys,
|
|
156
156
|
formatSettings,
|
|
@@ -158,13 +158,13 @@ import {
|
|
|
158
158
|
addSecret,
|
|
159
159
|
listSecrets,
|
|
160
160
|
removeSecret
|
|
161
|
-
} from "./main-
|
|
161
|
+
} from "./main-4avkdmzd.mjs";
|
|
162
162
|
import {
|
|
163
163
|
defaultJournalBaseDir,
|
|
164
164
|
readJournalEntries,
|
|
165
165
|
formatJournalEntry
|
|
166
|
-
} from "./main-
|
|
167
|
-
import"./main-
|
|
166
|
+
} from "./main-5aymyfdh.mjs";
|
|
167
|
+
import"./main-dk43bgqt.mjs";
|
|
168
168
|
import {
|
|
169
169
|
pipeArguments,
|
|
170
170
|
dual,
|
|
@@ -5867,7 +5867,7 @@ var status = make("status", {
|
|
|
5867
5867
|
}
|
|
5868
5868
|
})).pipe(withDescription4("Show relay, extension, and target status"));
|
|
5869
5869
|
var mcp = make("mcp", {}, fn("Cli.mcp")(function* () {
|
|
5870
|
-
const { runMcpServer } = yield* promise(() => import("./mcp-
|
|
5870
|
+
const { runMcpServer } = yield* promise(() => import("./mcp-479trmbn.mjs"));
|
|
5871
5871
|
yield* runMcpServer;
|
|
5872
5872
|
})).pipe(withDescription4("Run the browse MCP server over stdio"));
|
|
5873
5873
|
registerCliCommand(400, () => tabs);
|
|
@@ -6315,7 +6315,7 @@ registerCliCommand(710, () => flightRecorder);
|
|
|
6315
6315
|
|
|
6316
6316
|
// src/cli/relay.ts
|
|
6317
6317
|
var serve = make("serve", {}, fn("Cli.serve")(function* () {
|
|
6318
|
-
const [{ startRelay }, { parseAdditionalExtensionOrigins }] = yield* promise(() => Promise.all([import("./relay-
|
|
6318
|
+
const [{ startRelay }, { parseAdditionalExtensionOrigins }] = yield* promise(() => Promise.all([import("./relay-x14pkmgm.mjs"), import("./helpers-zxck525m.mjs")]));
|
|
6319
6319
|
const port = yield* portConfig;
|
|
6320
6320
|
const additionalExtensionOrigins = parseAdditionalExtensionOrigins(yield* extensionOriginsConfig);
|
|
6321
6321
|
yield* scoped(gen(function* () {
|
package/dist/cli.mjs
CHANGED
|
@@ -4,36 +4,36 @@
|
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import path from "node:path";
|
|
7
|
-
var embeddedVersion = "0.0.
|
|
7
|
+
var embeddedVersion = "0.0.14-dev.87";
|
|
8
8
|
var setupCommands = new Set(["install", "uninstall", "extension", "pair", "set"]);
|
|
9
9
|
var command = process.argv[2];
|
|
10
10
|
var invokedAs = path.basename(process.argv[1] ?? "");
|
|
11
11
|
var legacyDataRoot = process.platform === "win32" ? path.join(process.env.LOCALAPPDATA ?? path.join(os.homedir(), "AppData", "Local"), "opencode-browser") : path.join(process.env.XDG_DATA_HOME ?? path.join(os.homedir(), ".local", "share"), "opencode-browser");
|
|
12
12
|
if (command !== "--version" && command !== "-v" && !process.env.OPENCODE_BROWSER_HOME && [path.join(os.homedir(), ".browse"), legacyDataRoot].some((root) => fs.existsSync(root))) {
|
|
13
13
|
try {
|
|
14
|
-
const { migrateLegacy } = await import("./migrate-
|
|
14
|
+
const { migrateLegacy } = await import("./migrate-1kj40mtj.mjs");
|
|
15
15
|
migrateLegacy();
|
|
16
16
|
} catch {}
|
|
17
17
|
}
|
|
18
18
|
if (command === "--version" || command === "-v") {
|
|
19
|
-
const opencodeBrowserVersion = embeddedVersion ?? (await import("./version-
|
|
19
|
+
const opencodeBrowserVersion = embeddedVersion ?? (await import("./version-q2kbn8pp.mjs")).opencodeBrowserVersion;
|
|
20
20
|
process.stdout.write(`${opencodeBrowserVersion}
|
|
21
21
|
`);
|
|
22
|
-
} else if (command === "mcp" && process.env.OPENCODE_BROWSER_MCP_DIRECT !== "1" && (await import("./supervisor-
|
|
23
|
-
const { runBinaryMcp } = await import("./supervisor-
|
|
22
|
+
} else if (command === "mcp" && process.env.OPENCODE_BROWSER_MCP_DIRECT !== "1" && (await import("./supervisor-rtm4mamf.mjs")).supervisesMcp()) {
|
|
23
|
+
const { runBinaryMcp } = await import("./supervisor-rtm4mamf.mjs");
|
|
24
24
|
await runBinaryMcp(process.argv.slice(3));
|
|
25
25
|
} else if (invokedAs === "opencode-browser-mcp" || command === "mcp" && process.argv.length === 3) {
|
|
26
26
|
const { NodeRuntime } = await import("./index-yzz55kxm.mjs");
|
|
27
|
-
const { runMcpServer } = await import("./mcp-
|
|
27
|
+
const { runMcpServer } = await import("./mcp-479trmbn.mjs");
|
|
28
28
|
runMcpServer.pipe(NodeRuntime.runMain);
|
|
29
29
|
} else if (command === "self-update" || command === "runtime-switch") {
|
|
30
|
-
const { runSelfUpdate, runRuntimeSwitch } = await import("./runtime-update-
|
|
30
|
+
const { runSelfUpdate, runRuntimeSwitch } = await import("./runtime-update-gvn1fmm9.mjs");
|
|
31
31
|
await (command === "self-update" ? runSelfUpdate : runRuntimeSwitch)(process.argv.slice(3));
|
|
32
32
|
} else if (command === "update") {
|
|
33
|
-
const { runUpdateCommand } = await import("./update-
|
|
33
|
+
const { runUpdateCommand } = await import("./update-2vzc881k.mjs");
|
|
34
34
|
await runUpdateCommand(process.argv.slice(3));
|
|
35
35
|
} else if (command && setupCommands.has(command)) {
|
|
36
|
-
const { runSetup } = await import("./setup-
|
|
36
|
+
const { runSetup } = await import("./setup-2gb33k05.mjs");
|
|
37
37
|
await runSetup(command, process.argv.slice(3));
|
|
38
38
|
} else {
|
|
39
39
|
if (!command || command === "--help" || command === "-h") {
|
|
@@ -70,9 +70,9 @@ executable in ~/.local/bin (or $XDG_BIN_HOME).
|
|
|
70
70
|
`);
|
|
71
71
|
}
|
|
72
72
|
if (command === "status" && !process.argv.includes("--json")) {
|
|
73
|
-
const { printSetupStatus } = await import("./setup-
|
|
73
|
+
const { printSetupStatus } = await import("./setup-2gb33k05.mjs");
|
|
74
74
|
printSetupStatus();
|
|
75
75
|
}
|
|
76
|
-
const { runCli } = await import("./cli-
|
|
76
|
+
const { runCli } = await import("./cli-epthh991.mjs");
|
|
77
77
|
runCli();
|
|
78
78
|
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
parseTargetSelection2,
|
|
13
13
|
getObject2,
|
|
14
14
|
getString2
|
|
15
|
-
} from "./main-
|
|
15
|
+
} from "./main-eq3ptjam.mjs";
|
|
16
16
|
import {
|
|
17
17
|
isNodeError,
|
|
18
18
|
writeJsonFileAtomically
|
|
@@ -131,7 +131,7 @@ import {
|
|
|
131
131
|
import {
|
|
132
132
|
dataRoot,
|
|
133
133
|
cliCommand
|
|
134
|
-
} from "./main-
|
|
134
|
+
} from "./main-ptn0nanz.mjs";
|
|
135
135
|
|
|
136
136
|
// node_modules/effect/dist/Semaphore.js
|
|
137
137
|
var makeUnsafe = (permits) => new SemaphoreImpl(permits);
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
compiledBinary,
|
|
4
4
|
checkoutRoot,
|
|
5
5
|
cliCommand,
|
|
6
|
-
compareVersions,
|
|
7
6
|
installedRuntime2,
|
|
8
|
-
autoUpdateStatus
|
|
9
|
-
|
|
7
|
+
autoUpdateStatus,
|
|
8
|
+
updateAvailable
|
|
9
|
+
} from "./main-ptn0nanz.mjs";
|
|
10
10
|
import {
|
|
11
11
|
unpackedReloadAdvice
|
|
12
12
|
} from "./main-mrew6jy8.mjs";
|
|
@@ -139,7 +139,7 @@ function npmUpdateNotice() {
|
|
|
139
139
|
return false;
|
|
140
140
|
const status = autoUpdateStatus({ runtime });
|
|
141
141
|
const latest = status.latest;
|
|
142
|
-
if (!latest ||
|
|
142
|
+
if (!latest || !updateAvailable(status) || status.effective === "off")
|
|
143
143
|
return;
|
|
144
144
|
if (status.effective === "on" && !status.lastError)
|
|
145
145
|
return;
|
|
@@ -315,7 +315,7 @@ function runUpdate(args, deps) {
|
|
|
315
315
|
async function runUpdateCommand2(args) {
|
|
316
316
|
const log = (line) => process.stdout.write(line + `
|
|
317
317
|
`);
|
|
318
|
-
const { runInstalledUpdate } = await import("./runtime-update-
|
|
318
|
+
const { runInstalledUpdate } = await import("./runtime-update-gvn1fmm9.mjs");
|
|
319
319
|
if (await runInstalledUpdate(args))
|
|
320
320
|
return;
|
|
321
321
|
if (compiledBinary()) {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./main-vgzr4689.mjs";
|
|
4
4
|
import {
|
|
5
5
|
isValidSessionId2
|
|
6
|
-
} from "./main-
|
|
6
|
+
} from "./main-eq3ptjam.mjs";
|
|
7
7
|
import {
|
|
8
8
|
isSome,
|
|
9
9
|
decodeUnknownOption,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "./main-csnx585b.mjs";
|
|
18
18
|
import {
|
|
19
19
|
stateRoot
|
|
20
|
-
} from "./main-
|
|
20
|
+
} from "./main-ptn0nanz.mjs";
|
|
21
21
|
|
|
22
22
|
// src/session-manager/journal.ts
|
|
23
23
|
import fs from "node:fs";
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
bundledPairingCodeTtlMs,
|
|
6
6
|
mintPairingCode,
|
|
7
7
|
writeExtensionPairing
|
|
8
|
-
} from "./main-
|
|
8
|
+
} from "./main-4r0wgxtf.mjs";
|
|
9
9
|
import {
|
|
10
10
|
configRoot2,
|
|
11
11
|
cacheRoot,
|
|
12
12
|
devExtensionUrl,
|
|
13
13
|
devExtensionFolder
|
|
14
|
-
} from "./main-
|
|
14
|
+
} from "./main-ptn0nanz.mjs";
|
|
15
15
|
|
|
16
16
|
// src/setup/dev-extension.ts
|
|
17
17
|
import { createHash } from "node:crypto";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
opencodeBrowserVersion2
|
|
3
|
-
} from "./main-
|
|
3
|
+
} from "./main-e4wynyjq.mjs";
|
|
4
4
|
import {
|
|
5
5
|
configRoot2,
|
|
6
6
|
dataRoot,
|
|
@@ -18,10 +18,10 @@ import {
|
|
|
18
18
|
storeUrl,
|
|
19
19
|
installedVersion,
|
|
20
20
|
runCommand
|
|
21
|
-
} from "./main-
|
|
21
|
+
} from "./main-ptn0nanz.mjs";
|
|
22
22
|
import {
|
|
23
23
|
formatPairingCode
|
|
24
|
-
} from "./main-
|
|
24
|
+
} from "./main-4r0wgxtf.mjs";
|
|
25
25
|
import {
|
|
26
26
|
unpackedExtensionId
|
|
27
27
|
} from "./main-mrew6jy8.mjs";
|
|
@@ -107,7 +107,7 @@ import {
|
|
|
107
107
|
} from "./main-csnx585b.mjs";
|
|
108
108
|
import {
|
|
109
109
|
opencodeBrowserBuildId2
|
|
110
|
-
} from "./main-
|
|
110
|
+
} from "./main-e4wynyjq.mjs";
|
|
111
111
|
import {
|
|
112
112
|
compiledBinary,
|
|
113
113
|
scriptEntry,
|
|
@@ -116,10 +116,10 @@ import {
|
|
|
116
116
|
compareVersions,
|
|
117
117
|
installedRuntime2,
|
|
118
118
|
installedVersion
|
|
119
|
-
} from "./main-
|
|
119
|
+
} from "./main-ptn0nanz.mjs";
|
|
120
120
|
import {
|
|
121
121
|
relayAuthorization
|
|
122
|
-
} from "./main-
|
|
122
|
+
} from "./main-dk43bgqt.mjs";
|
|
123
123
|
import {
|
|
124
124
|
dual,
|
|
125
125
|
memoize,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
opencodeBrowserVersion2
|
|
3
|
-
} from "./main-
|
|
3
|
+
} from "./main-e4wynyjq.mjs";
|
|
4
4
|
|
|
5
5
|
// src/paths.ts
|
|
6
6
|
import fs from "node:fs";
|
|
@@ -55,7 +55,7 @@ function cliInstall() {
|
|
|
55
55
|
return { kind: "binary", binary: installedBinary() ?? process.execPath, pathEnv: process.env.PATH };
|
|
56
56
|
if (fromCheckout())
|
|
57
57
|
return { kind: "checkout", bundle: path.join(packageRoot(), "dist", "cli.mjs") };
|
|
58
|
-
return { kind: "npm", version: "0.0.
|
|
58
|
+
return { kind: "npm", version: "0.0.14-dev.87", npx: /[/\\]_npx[/\\]/.test(process.argv[1] ?? "") };
|
|
59
59
|
}
|
|
60
60
|
function cliPrefix(install = cliInstall()) {
|
|
61
61
|
if (install.kind === "binary") {
|
|
@@ -77,7 +77,7 @@ function storeConfig(env = process.env, baked = { id: "mfnicocicmmlkpjnaffgihfjh
|
|
|
77
77
|
return id ? { id } : {};
|
|
78
78
|
}
|
|
79
79
|
var RELEASE_SERVICE = "https://anoma.ly/release";
|
|
80
|
-
function devExtension(baked =
|
|
80
|
+
function devExtension(baked = { file: "browse-extension-0.0.14-dev.87.zip", sha256: "c2cc7660cb287577b751900e077cc3e085d601f1699f15172a944d1bbcdd0935", size: 182576 }) {
|
|
81
81
|
return baked && /^[0-9a-f]{64}$/.test(baked.sha256) && /^[\w.-]+\.zip$/.test(baked.file) ? baked : undefined;
|
|
82
82
|
}
|
|
83
83
|
var devExtensionUrl = (extension, env = process.env) => `${(env.OPENCODE_BROWSER_RELEASE_SERVICE || RELEASE_SERVICE).replace(/\/+$/, "")}/browse/files/${extension.sha256}/${extension.file}`;
|
|
@@ -89,24 +89,234 @@ function installCommand() {
|
|
|
89
89
|
|
|
90
90
|
// src/update/auto-update.ts
|
|
91
91
|
import { spawn, spawnSync } from "node:child_process";
|
|
92
|
-
import { chmodSync, closeSync, existsSync, mkdirSync, mkdtempSync, openSync, readFileSync, renameSync, rmSync, realpathSync, writeFileSync } from "node:fs";
|
|
92
|
+
import { chmodSync as chmodSync2, closeSync, existsSync, mkdirSync as mkdirSync2, mkdtempSync, openSync, readFileSync as readFileSync2, renameSync, rmSync, realpathSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
93
93
|
import os2 from "node:os";
|
|
94
|
+
import path3 from "node:path";
|
|
95
|
+
|
|
96
|
+
// src/update/release-service.ts
|
|
97
|
+
import crypto from "node:crypto";
|
|
98
|
+
import { chmodSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
94
99
|
import path2 from "node:path";
|
|
100
|
+
function serviceTarget(target) {
|
|
101
|
+
return target.replace(/^darwin-/, "macos-");
|
|
102
|
+
}
|
|
103
|
+
function runningServiceTarget() {
|
|
104
|
+
return globalThis.__OPENCODE_BROWSER_TARGET__ ? serviceTarget(globalThis.__OPENCODE_BROWSER_TARGET__) : undefined;
|
|
105
|
+
}
|
|
106
|
+
function releaseChannel(channel) {
|
|
107
|
+
if (channel === "dev" || channel === "beta" || channel === "stable")
|
|
108
|
+
return channel;
|
|
109
|
+
return "stable";
|
|
110
|
+
}
|
|
111
|
+
var releaseService = (env = process.env) => (env.OPENCODE_BROWSER_RELEASE_SERVICE?.trim() || RELEASE_SERVICE).replace(/\/+$/, "");
|
|
112
|
+
var NAME = /^[a-z][a-z0-9-]{0,31}$/;
|
|
113
|
+
var SHA256 = /^[0-9a-f]{64}$/;
|
|
114
|
+
var VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
115
|
+
var record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
116
|
+
var text = (value, pattern) => typeof value === "string" && (!pattern || pattern.test(value)) ? value : undefined;
|
|
117
|
+
var integer = (value, min, max = Number.MAX_SAFE_INTEGER) => typeof value === "number" && Number.isSafeInteger(value) && value >= min && value <= max ? value : undefined;
|
|
118
|
+
var https = (value) => {
|
|
119
|
+
const url = text(value);
|
|
120
|
+
if (!url)
|
|
121
|
+
return;
|
|
122
|
+
try {
|
|
123
|
+
return new URL(url).protocol === "https:" ? url : undefined;
|
|
124
|
+
} catch {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
function parseManifest(value) {
|
|
129
|
+
const raw = record(value);
|
|
130
|
+
const release = record(raw?.release);
|
|
131
|
+
if (!raw || !release || raw.schema !== 1)
|
|
132
|
+
return;
|
|
133
|
+
const app = text(raw.app, NAME);
|
|
134
|
+
const artifact = text(raw.artifact, NAME);
|
|
135
|
+
const channel = text(raw.channel, NAME);
|
|
136
|
+
const sequence = integer(raw.sequence, 1);
|
|
137
|
+
const version = text(release.version, VERSION);
|
|
138
|
+
const rollout = integer(release.rollout_percent, 0, 100);
|
|
139
|
+
if (!app || !artifact || !channel || sequence === undefined || !version || rollout === undefined)
|
|
140
|
+
return;
|
|
141
|
+
if (typeof raw.published_at !== "string")
|
|
142
|
+
return;
|
|
143
|
+
if (release.required !== undefined && release.required !== false && release.required !== true)
|
|
144
|
+
return;
|
|
145
|
+
const targets = {};
|
|
146
|
+
const rawTargets = record(release.targets);
|
|
147
|
+
if (!rawTargets || Object.keys(rawTargets).length > 64)
|
|
148
|
+
return;
|
|
149
|
+
for (const [name, item] of Object.entries(rawTargets)) {
|
|
150
|
+
const target = record(item);
|
|
151
|
+
const url = text(target?.url);
|
|
152
|
+
const size = integer(target?.size, 0);
|
|
153
|
+
const sha256 = text(target?.sha256, SHA256);
|
|
154
|
+
if (!url || size === undefined || !sha256)
|
|
155
|
+
return;
|
|
156
|
+
targets[name] = { url, size, sha256 };
|
|
157
|
+
}
|
|
158
|
+
if (!Array.isArray(release.distributions) || release.distributions.length > 32)
|
|
159
|
+
return;
|
|
160
|
+
const distributions = [];
|
|
161
|
+
for (const item of release.distributions) {
|
|
162
|
+
const distribution = record(item);
|
|
163
|
+
const kind = text(distribution?.kind, NAME);
|
|
164
|
+
if (!distribution || !kind)
|
|
165
|
+
return;
|
|
166
|
+
const distributionVersion = distribution.version === undefined ? undefined : text(distribution.version, VERSION);
|
|
167
|
+
const command = distribution.command === undefined ? undefined : text(distribution.command);
|
|
168
|
+
if (distribution.version !== undefined && !distributionVersion || distribution.command !== undefined && !command)
|
|
169
|
+
return;
|
|
170
|
+
distributions.push({ kind, ...distributionVersion ? { version: distributionVersion } : {}, ...command ? { command } : {} });
|
|
171
|
+
}
|
|
172
|
+
const notes_url = release.notes_url === undefined ? undefined : https(release.notes_url);
|
|
173
|
+
if (release.notes_url !== undefined && !notes_url)
|
|
174
|
+
return;
|
|
175
|
+
return {
|
|
176
|
+
schema: 1,
|
|
177
|
+
app,
|
|
178
|
+
artifact,
|
|
179
|
+
channel,
|
|
180
|
+
sequence,
|
|
181
|
+
release: {
|
|
182
|
+
version,
|
|
183
|
+
...notes_url ? { notes_url } : {},
|
|
184
|
+
rollout_percent: rollout,
|
|
185
|
+
required: release.required === true,
|
|
186
|
+
targets,
|
|
187
|
+
distributions
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function decide(input) {
|
|
192
|
+
let manifest;
|
|
193
|
+
try {
|
|
194
|
+
manifest = parseManifest(JSON.parse(input.manifest));
|
|
195
|
+
} catch {
|
|
196
|
+
return { action: "reject", reason: "malformed" };
|
|
197
|
+
}
|
|
198
|
+
if (!manifest)
|
|
199
|
+
return { action: "reject", reason: "malformed" };
|
|
200
|
+
if (manifest.app !== input.app)
|
|
201
|
+
return { action: "reject", reason: "wrong_app" };
|
|
202
|
+
if (manifest.artifact !== input.artifact)
|
|
203
|
+
return { action: "reject", reason: "wrong_artifact" };
|
|
204
|
+
if (manifest.channel !== input.channel)
|
|
205
|
+
return { action: "reject", reason: "wrong_channel" };
|
|
206
|
+
const release = manifest.release;
|
|
207
|
+
let candidate = release.version;
|
|
208
|
+
let target;
|
|
209
|
+
let distribution;
|
|
210
|
+
if (input.install.distribution === "direct") {
|
|
211
|
+
target = release.targets[input.install.target];
|
|
212
|
+
if (!target)
|
|
213
|
+
return { action: "none", reason: "no_target" };
|
|
214
|
+
} else if (input.install.distribution !== "unknown") {
|
|
215
|
+
distribution = release.distributions.find((item) => item.kind === input.install.distribution);
|
|
216
|
+
if (!distribution)
|
|
217
|
+
return { action: "none", reason: "distribution_unlisted" };
|
|
218
|
+
if (!distribution.version)
|
|
219
|
+
return { action: "none", reason: "distribution_pending" };
|
|
220
|
+
candidate = distribution.version;
|
|
221
|
+
}
|
|
222
|
+
const running = target && input.install.sha256 !== undefined ? input.install.sha256 === target.sha256 : candidate === input.install.version;
|
|
223
|
+
if (running)
|
|
224
|
+
return { action: "none", reason: "up_to_date" };
|
|
225
|
+
const act = (reason) => target ? { action: "install", reason, version: candidate, target } : {
|
|
226
|
+
action: "notify",
|
|
227
|
+
reason,
|
|
228
|
+
version: candidate,
|
|
229
|
+
distribution: input.install.distribution,
|
|
230
|
+
...distribution?.command ? { command: distribution.command } : {},
|
|
231
|
+
...release.notes_url ? { notes_url: release.notes_url } : {}
|
|
232
|
+
};
|
|
233
|
+
if (input.install.channel !== undefined && input.install.channel !== input.channel)
|
|
234
|
+
return act("switch");
|
|
235
|
+
if (release.required)
|
|
236
|
+
return act("required");
|
|
237
|
+
if (input.install.rolloutBucket < release.rollout_percent)
|
|
238
|
+
return act("update");
|
|
239
|
+
return { action: "none", reason: "rollout_deferred" };
|
|
240
|
+
}
|
|
241
|
+
async function fetchManifest(options) {
|
|
242
|
+
const service = (options.service ?? releaseService()).replace(/\/+$/, "");
|
|
243
|
+
const response = await (options.fetch ?? fetch)(`${service}/browse/cli/${options.channel}.json`, {
|
|
244
|
+
headers: {
|
|
245
|
+
"user-agent": `browse/${options.channel}/${options.version}/cli`,
|
|
246
|
+
...options.etag ? { "if-none-match": options.etag } : {}
|
|
247
|
+
},
|
|
248
|
+
signal: AbortSignal.timeout(30000)
|
|
249
|
+
});
|
|
250
|
+
if (response.status === 304)
|
|
251
|
+
return { status: "unchanged" };
|
|
252
|
+
if (response.status === 404)
|
|
253
|
+
return { status: "missing" };
|
|
254
|
+
if (!response.ok)
|
|
255
|
+
throw new Error(`the release service answered ${response.status} for browse/cli/${options.channel}`);
|
|
256
|
+
const etag = response.headers.get("etag");
|
|
257
|
+
return { status: "manifest", text: await response.text(), ...etag ? { etag } : {} };
|
|
258
|
+
}
|
|
259
|
+
async function checkRelease(options) {
|
|
260
|
+
const manifest = await fetchManifest({
|
|
261
|
+
channel: options.channel,
|
|
262
|
+
version: options.version,
|
|
263
|
+
...options.etag ? { etag: options.etag } : {},
|
|
264
|
+
...options.service ? { service: options.service } : {},
|
|
265
|
+
...options.fetch ? { fetch: options.fetch } : {}
|
|
266
|
+
});
|
|
267
|
+
if (manifest.status !== "manifest")
|
|
268
|
+
return manifest;
|
|
269
|
+
const decision = decide({
|
|
270
|
+
app: "browse",
|
|
271
|
+
artifact: "cli",
|
|
272
|
+
channel: options.channel,
|
|
273
|
+
manifest: manifest.text,
|
|
274
|
+
install: {
|
|
275
|
+
version: options.version,
|
|
276
|
+
target: options.target,
|
|
277
|
+
distribution: "direct",
|
|
278
|
+
rolloutBucket: rolloutBucket(options.stateDir)
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
let releaseVersion = options.version;
|
|
282
|
+
try {
|
|
283
|
+
releaseVersion = parseManifest(JSON.parse(manifest.text))?.release.version ?? options.version;
|
|
284
|
+
} catch {}
|
|
285
|
+
return { status: "manifest", releaseVersion, decision, ...manifest.etag ? { etag: manifest.etag } : {} };
|
|
286
|
+
}
|
|
287
|
+
function rolloutBucket(root = stateRoot()) {
|
|
288
|
+
const file = path2.join(root, "rollout-bucket");
|
|
289
|
+
try {
|
|
290
|
+
const saved = Number(readFileSync(file, "utf8").trim());
|
|
291
|
+
if (Number.isInteger(saved) && saved >= 0 && saved < 100)
|
|
292
|
+
return saved;
|
|
293
|
+
} catch {}
|
|
294
|
+
const bucket = crypto.randomInt(100);
|
|
295
|
+
try {
|
|
296
|
+
mkdirSync(root, { recursive: true, mode: 448 });
|
|
297
|
+
writeFileSync(file, `${bucket}
|
|
298
|
+
`, { mode: 384 });
|
|
299
|
+
chmodSync(file, 384);
|
|
300
|
+
} catch {}
|
|
301
|
+
return bucket;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// src/update/auto-update.ts
|
|
95
305
|
var PACKAGE_NAME = "@opencode/browse";
|
|
96
|
-
var
|
|
306
|
+
var HOUR_MS = 60 * 60 * 1000;
|
|
97
307
|
var DEFAULT_REGISTRY = "https://registry.npmjs.org";
|
|
98
308
|
var INSTALL_SCRIPT = "https://opencode.ai/browse/install";
|
|
99
309
|
var INSTALL_SCRIPT_WINDOWS = "https://opencode.ai/browse/install.ps1";
|
|
100
310
|
var autoUpdateModes = ["on", "notify", "off"];
|
|
101
|
-
var UPDATE_VERSION = /^(\d+)\.(\d+)\.(\d+)(?:-dev\.(\d+)(?:\.(\d+))?)?$/;
|
|
102
|
-
var channelOf = (version) => version.includes("-dev.") ? "dev" : "latest";
|
|
311
|
+
var UPDATE_VERSION = /^(\d+)\.(\d+)\.(\d+)(?:-(dev|beta)\.(\d+)(?:\.(\d+))?)?$/;
|
|
312
|
+
var channelOf = (version) => version.includes("-dev.") ? "dev" : version.includes("-beta.") ? "beta" : "latest";
|
|
103
313
|
function compareVersions(left, right) {
|
|
104
314
|
const parse = (value) => {
|
|
105
315
|
const match = UPDATE_VERSION.exec(value);
|
|
106
316
|
if (!match)
|
|
107
317
|
return;
|
|
108
|
-
const
|
|
109
|
-
return [Number(match[1]), Number(match[2]), Number(match[3]),
|
|
318
|
+
const stage = match[4] === undefined ? 2 : match[4] === "beta" ? 1 : 0;
|
|
319
|
+
return [Number(match[1]), Number(match[2]), Number(match[3]), stage, Number(match[5] ?? 0), Number(match[6] ?? 0)];
|
|
110
320
|
};
|
|
111
321
|
const a = parse(left);
|
|
112
322
|
const b = parse(right);
|
|
@@ -129,8 +339,8 @@ function installKind(entry = process.argv[1] ?? "", checkout = fromCheckout()) {
|
|
|
129
339
|
}
|
|
130
340
|
var packageVersion = (entry) => {
|
|
131
341
|
try {
|
|
132
|
-
const manifest =
|
|
133
|
-
const version = JSON.parse(
|
|
342
|
+
const manifest = path3.join(path3.dirname(path3.dirname(entry)), "package.json");
|
|
343
|
+
const version = JSON.parse(readFileSync2(manifest, "utf8")).version;
|
|
134
344
|
return typeof version === "string" ? version : undefined;
|
|
135
345
|
} catch {
|
|
136
346
|
return;
|
|
@@ -163,20 +373,20 @@ function installedVersion(runtime) {
|
|
|
163
373
|
}
|
|
164
374
|
return packageVersion(runtime.entry);
|
|
165
375
|
}
|
|
166
|
-
var autoUpdateStatePath = () =>
|
|
376
|
+
var autoUpdateStatePath = () => path3.join(stateRoot(), "auto-update.json");
|
|
167
377
|
function readJson(file) {
|
|
168
378
|
try {
|
|
169
|
-
return JSON.parse(
|
|
379
|
+
return JSON.parse(readFileSync2(file, "utf8"));
|
|
170
380
|
} catch {
|
|
171
381
|
return;
|
|
172
382
|
}
|
|
173
383
|
}
|
|
174
384
|
function writeJsonAtomic(file, value) {
|
|
175
|
-
|
|
385
|
+
mkdirSync2(path3.dirname(file), { recursive: true, mode: 448 });
|
|
176
386
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
177
|
-
|
|
387
|
+
writeFileSync2(temporary, JSON.stringify(value, null, 2) + `
|
|
178
388
|
`, { mode: 384 });
|
|
179
|
-
|
|
389
|
+
chmodSync2(temporary, 384);
|
|
180
390
|
renameSync(temporary, file);
|
|
181
391
|
}
|
|
182
392
|
function readState() {
|
|
@@ -237,14 +447,19 @@ function describeAutoUpdate(status) {
|
|
|
237
447
|
return "Updates: not an installed runtime";
|
|
238
448
|
const mode = { on: "automatic", notify: "notify only", off: "off" }[status.effective];
|
|
239
449
|
const parts = [`${mode}${status.overriddenBy ? ` (set by ${status.overriddenBy})` : ""}`, `channel ${status.channel ?? "latest"}`];
|
|
240
|
-
if (
|
|
450
|
+
if (updateAvailable(status))
|
|
241
451
|
parts.push(`${status.latest} available; the installer runs when no agent is using the browser`);
|
|
242
452
|
if (status.lastError)
|
|
243
453
|
parts.push(`last attempt failed: ${status.lastError.message}`);
|
|
244
454
|
return `Updates: ${parts.join("; ")}`;
|
|
245
455
|
}
|
|
456
|
+
function updateAvailable(status) {
|
|
457
|
+
if (!status.latest || !status.version)
|
|
458
|
+
return false;
|
|
459
|
+
return status.install === "binary" ? status.latest !== status.version : compareVersions(status.latest, status.version) > 0;
|
|
460
|
+
}
|
|
246
461
|
var runCommand = (command, args, options = {}) => new Promise((resolve) => {
|
|
247
|
-
const npmCli = process.platform === "win32" && command === "npm" ?
|
|
462
|
+
const npmCli = process.platform === "win32" && command === "npm" ? path3.join(path3.dirname(process.execPath), "node_modules", "npm", "bin", "npm-cli.js") : undefined;
|
|
248
463
|
const [file, argv] = npmCli && existsSync(npmCli) ? [process.execPath, [npmCli, ...args]] : [command, args];
|
|
249
464
|
const child = spawn(file, argv, { env: options.env ?? process.env, stdio: ["ignore", "pipe", "pipe"] });
|
|
250
465
|
let stdout = "";
|
|
@@ -299,16 +514,16 @@ async function runInstaller(options) {
|
|
|
299
514
|
return version;
|
|
300
515
|
}
|
|
301
516
|
const scriptUrl = env.OPENCODE_BROWSER_INSTALL_SCRIPT || (platform === "win32" ? INSTALL_SCRIPT_WINDOWS : INSTALL_SCRIPT);
|
|
302
|
-
const script = existsSync(scriptUrl) ?
|
|
517
|
+
const script = existsSync(scriptUrl) ? readFileSync2(scriptUrl, "utf8") : await (options.fetch ?? fetch)(scriptUrl, { signal: AbortSignal.timeout(60000) }).then(async (response) => {
|
|
303
518
|
if (!response.ok)
|
|
304
519
|
throw new Error(`couldn't download the installer (${response.status})`);
|
|
305
520
|
return response.text();
|
|
306
521
|
});
|
|
307
|
-
const directory = mkdtempSync(
|
|
308
|
-
const file =
|
|
522
|
+
const directory = mkdtempSync(path3.join(os2.tmpdir(), "browse-install-"));
|
|
523
|
+
const file = path3.join(directory, platform === "win32" ? "install.ps1" : "install");
|
|
309
524
|
const args = [...options.version ? ["--version", options.version] : options.channel ? ["--channel", options.channel] : [], "--no-setup"];
|
|
310
525
|
try {
|
|
311
|
-
|
|
526
|
+
writeFileSync2(file, script, { mode: platform === "win32" ? 384 : 448 });
|
|
312
527
|
const command = platform === "win32" ? "powershell.exe" : "sh";
|
|
313
528
|
const argv = platform === "win32" ? ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", file, ...args] : [file, ...args];
|
|
314
529
|
const installed = await run(command, argv, { timeoutMs: 10 * 60000, env });
|
|
@@ -342,11 +557,42 @@ function createAutoUpdater(deps) {
|
|
|
342
557
|
const now = deps.now ?? Date.now;
|
|
343
558
|
const { runtime } = deps;
|
|
344
559
|
const running = runtime.version;
|
|
345
|
-
const checkIntervalMs = Number(env.OPENCODE_BROWSER_AUTO_UPDATE_INTERVAL_MS) ||
|
|
560
|
+
const checkIntervalMs = Math.min(Number(env.OPENCODE_BROWSER_AUTO_UPDATE_INTERVAL_MS) || HOUR_MS, HOUR_MS);
|
|
346
561
|
const spawnChild = deps.spawnChild ?? ((args, onExit) => spawnRuntimeChild(runtime, args, onExit, env));
|
|
347
562
|
let busy = false;
|
|
348
563
|
let switching;
|
|
349
564
|
let timer;
|
|
565
|
+
async function checkBinary(state, channel) {
|
|
566
|
+
const target = runningServiceTarget();
|
|
567
|
+
if (!target)
|
|
568
|
+
throw new Error("this install has no release service target");
|
|
569
|
+
const serviceChannel = releaseChannel(channel);
|
|
570
|
+
const result = await checkRelease({
|
|
571
|
+
version: running,
|
|
572
|
+
channel: serviceChannel,
|
|
573
|
+
target,
|
|
574
|
+
...state.etag ? { etag: state.etag } : {},
|
|
575
|
+
...deps.fetch ? { fetch: deps.fetch } : {}
|
|
576
|
+
});
|
|
577
|
+
if (result.status === "unchanged") {
|
|
578
|
+
deps.log("autoupdate.unchanged", { channel: serviceChannel, running });
|
|
579
|
+
return updateState(({ failed: _failed, ...rest }) => ({ ...rest, checkedAt: now() }));
|
|
580
|
+
}
|
|
581
|
+
if (result.status === "missing") {
|
|
582
|
+
deps.log("autoupdate.no_release", { channel: serviceChannel, running });
|
|
583
|
+
return updateState(({ failed: _failed, latest: _latest, etag: _etag, ...rest }) => ({ ...rest, checkedAt: now() }));
|
|
584
|
+
}
|
|
585
|
+
const decision = result.decision;
|
|
586
|
+
if (decision.action === "reject")
|
|
587
|
+
throw new Error(`the ${serviceChannel} manifest was rejected: ${decision.reason}`);
|
|
588
|
+
deps.log("autoupdate.checked", { channel: serviceChannel, current: result.releaseVersion, running, decision: decision.reason });
|
|
589
|
+
return updateState(({ failed: _failed, latest: _latest, etag: _etag, ...rest }) => ({
|
|
590
|
+
...rest,
|
|
591
|
+
checkedAt: now(),
|
|
592
|
+
...result.etag ? { etag: result.etag } : {},
|
|
593
|
+
...decision.action === "install" ? { latest: decision.version } : {}
|
|
594
|
+
}));
|
|
595
|
+
}
|
|
350
596
|
async function tick() {
|
|
351
597
|
if (switching && (now() - switching.startedAt > SWITCH_TIMEOUT_MS || switching.pid !== undefined && !processAlive(switching.pid))) {
|
|
352
598
|
deps.log("autoupdate.switch_abandoned", { pid: switching.pid });
|
|
@@ -363,17 +609,20 @@ function createAutoUpdater(deps) {
|
|
|
363
609
|
if (!state.checkedAt || now() - state.checkedAt >= checkIntervalMs || now() < state.checkedAt) {
|
|
364
610
|
const channel = channelOf(running);
|
|
365
611
|
try {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
612
|
+
if (runtime.kind === "binary") {
|
|
613
|
+
state = await checkBinary(state, channel);
|
|
614
|
+
} else {
|
|
615
|
+
const published = await fetchPublished({ registry: await registryUrl(deps.run, env), channel, ...deps.fetch ? { fetch: deps.fetch } : {} });
|
|
616
|
+
state = updateState(({ failed: _failed, ...rest }) => ({ ...rest, checkedAt: now(), latest: published.version }));
|
|
617
|
+
deps.log("autoupdate.checked", { channel, latest: published.version, running });
|
|
618
|
+
}
|
|
369
619
|
} catch (error) {
|
|
370
|
-
state = updateState((rest) => ({ ...rest, checkedAt: now(), failed: error.message }));
|
|
620
|
+
state = updateState(({ latest: _latest, ...rest }) => ({ ...rest, checkedAt: now(), failed: error.message }));
|
|
371
621
|
deps.log("autoupdate.check_failed", { error: error.message });
|
|
372
622
|
}
|
|
373
623
|
deps.onChange?.();
|
|
374
624
|
}
|
|
375
|
-
const
|
|
376
|
-
const wanted = latest && compareVersions(latest, running) > 0 ? latest : undefined;
|
|
625
|
+
const wanted = runtime.kind === "binary" ? state.latest : state.latest && compareVersions(state.latest, running) > 0 ? state.latest : undefined;
|
|
377
626
|
if (!wanted || mode !== "on")
|
|
378
627
|
return;
|
|
379
628
|
const installing = state.installing;
|
|
@@ -384,12 +633,12 @@ function createAutoUpdater(deps) {
|
|
|
384
633
|
const installed = installedVersion(runtime);
|
|
385
634
|
state = updateState(({ installing: _installing, ...rest }) => ({
|
|
386
635
|
...rest,
|
|
387
|
-
...installed &&
|
|
636
|
+
...installed && installed !== running ? {} : { lastError: { message: "the installer stopped without finishing", at: new Date(now()).toISOString(), version: installing.version } }
|
|
388
637
|
}));
|
|
389
638
|
deps.log("autoupdate.installer_gone", { version: installing.version });
|
|
390
639
|
}
|
|
391
640
|
const installed = installedVersion(runtime);
|
|
392
|
-
if (installed
|
|
641
|
+
if (installed === wanted) {
|
|
393
642
|
if (!deps.isIdle())
|
|
394
643
|
return;
|
|
395
644
|
switching = { pid: undefined, startedAt: now() };
|
|
@@ -444,9 +693,9 @@ function createAutoUpdater(deps) {
|
|
|
444
693
|
}
|
|
445
694
|
function spawnRuntimeChild(runtime, args, onExit, env = process.env) {
|
|
446
695
|
const { OPENCODE_BROWSER_MANAGED_RELAY: _managed, OPENCODE_BROWSER_RESTART_REQUEST_ID: _request, ...rest } = env;
|
|
447
|
-
const directory =
|
|
448
|
-
|
|
449
|
-
const log = openSync(
|
|
696
|
+
const directory = path3.join(stateRoot(), "logs");
|
|
697
|
+
mkdirSync2(directory, { recursive: true, mode: 448 });
|
|
698
|
+
const log = openSync(path3.join(directory, "auto-update.log"), "a", 384);
|
|
450
699
|
try {
|
|
451
700
|
const [file, ...prefix] = entryCommand(runtime.entry);
|
|
452
701
|
const child = spawn(file, [...prefix, ...args], { detached: true, stdio: ["ignore", log, log], env: rest });
|
|
@@ -462,4 +711,4 @@ function spawnRuntimeChild(runtime, args, onExit, env = process.env) {
|
|
|
462
711
|
}
|
|
463
712
|
}
|
|
464
713
|
|
|
465
|
-
export { configRoot2, dataRoot, stateRoot, cacheRoot, binRoot, installedBinaryPath, oldStoreMarker, fromCheckout, compiledBinary, binaryPackage, binaryName, scriptEntry, entryCommand, runningEntry, checkoutRoot, cliCommand, PUBLIC_STORE_ID, storeConfig, devExtension, devExtensionUrl, devExtensionFolder, storeUrl, installCommand, autoUpdateModes, UPDATE_VERSION, channelOf, compareVersions, installedRuntime2, installedVersion, updateState, autoUpdateOverride, storedMode, effectiveMode, setStoredMode, autoUpdateStatus, describeAutoUpdate, runCommand, registryUrl, fetchPublished, runInstaller, createAutoUpdater };
|
|
714
|
+
export { configRoot2, dataRoot, stateRoot, cacheRoot, binRoot, installedBinaryPath, oldStoreMarker, fromCheckout, compiledBinary, binaryPackage, binaryName, scriptEntry, entryCommand, runningEntry, checkoutRoot, cliCommand, PUBLIC_STORE_ID, storeConfig, devExtension, devExtensionUrl, devExtensionFolder, storeUrl, installCommand, runningServiceTarget, releaseChannel, checkRelease, autoUpdateModes, UPDATE_VERSION, channelOf, compareVersions, installedRuntime2, installedVersion, updateState, autoUpdateOverride, storedMode, effectiveMode, setStoredMode, autoUpdateStatus, describeAutoUpdate, updateAvailable, runCommand, registryUrl, fetchPublished, runInstaller, createAutoUpdater };
|
|
@@ -256,11 +256,11 @@ import {
|
|
|
256
256
|
} from "./main-csnx585b.mjs";
|
|
257
257
|
import {
|
|
258
258
|
opencodeBrowserVersion2
|
|
259
|
-
} from "./main-
|
|
259
|
+
} from "./main-e4wynyjq.mjs";
|
|
260
260
|
import {
|
|
261
261
|
cliCommand,
|
|
262
262
|
autoUpdateStatus
|
|
263
|
-
} from "./main-
|
|
263
|
+
} from "./main-ptn0nanz.mjs";
|
|
264
264
|
import"./main-mrew6jy8.mjs";
|
|
265
265
|
import {
|
|
266
266
|
option,
|
|
@@ -280,12 +280,12 @@ import {
|
|
|
280
280
|
relayBuildProblem,
|
|
281
281
|
ensureRelay,
|
|
282
282
|
ensureExtensionConnected
|
|
283
|
-
} from "./main-
|
|
283
|
+
} from "./main-eq3ptjam.mjs";
|
|
284
284
|
import"./main-vgzr4689.mjs";
|
|
285
285
|
import {
|
|
286
286
|
updateJson2,
|
|
287
287
|
createUpdateWatcher2
|
|
288
|
-
} from "./main-
|
|
288
|
+
} from "./main-4qd7wzb5.mjs";
|
|
289
289
|
import {
|
|
290
290
|
makeUnsafe,
|
|
291
291
|
make,
|
|
@@ -369,7 +369,7 @@ import {
|
|
|
369
369
|
mcpErrorMessage2,
|
|
370
370
|
toolResult,
|
|
371
371
|
listSecrets
|
|
372
|
-
} from "./main-
|
|
372
|
+
} from "./main-4avkdmzd.mjs";
|
|
373
373
|
import {
|
|
374
374
|
Clock,
|
|
375
375
|
type,
|
|
@@ -384,7 +384,7 @@ import {
|
|
|
384
384
|
orElse,
|
|
385
385
|
exhaustive
|
|
386
386
|
} from "./main-8z9d979q.mjs";
|
|
387
|
-
import"./main-
|
|
387
|
+
import"./main-dk43bgqt.mjs";
|
|
388
388
|
import {
|
|
389
389
|
pipeArguments,
|
|
390
390
|
dual,
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
browseServerCommand,
|
|
7
7
|
editAgentConfig,
|
|
8
8
|
configureMcp
|
|
9
|
-
} from "./main-
|
|
10
|
-
import"./main-
|
|
9
|
+
} from "./main-dm2decgk.mjs";
|
|
10
|
+
import"./main-e4wynyjq.mjs";
|
|
11
11
|
import {
|
|
12
12
|
configRoot2,
|
|
13
13
|
dataRoot,
|
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
cacheRoot,
|
|
16
16
|
binRoot,
|
|
17
17
|
binaryName
|
|
18
|
-
} from "./main-
|
|
18
|
+
} from "./main-ptn0nanz.mjs";
|
|
19
19
|
import"./main-vgzr4689.mjs";
|
|
20
|
-
import"./main-
|
|
20
|
+
import"./main-4r0wgxtf.mjs";
|
|
21
21
|
import"./main-mrew6jy8.mjs";
|
|
22
22
|
|
|
23
23
|
// src/setup/migrate.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
opencodeBrowserVersion2,
|
|
3
3
|
opencodeBrowserBuildId2
|
|
4
|
-
} from "./main-
|
|
4
|
+
} from "./main-e4wynyjq.mjs";
|
|
5
5
|
import {
|
|
6
6
|
dataRoot,
|
|
7
7
|
stateRoot,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
setStoredMode,
|
|
21
21
|
autoUpdateStatus,
|
|
22
22
|
createAutoUpdater
|
|
23
|
-
} from "./main-
|
|
23
|
+
} from "./main-ptn0nanz.mjs";
|
|
24
24
|
import {
|
|
25
25
|
extensionProtocolVersion,
|
|
26
26
|
minExtensionProtocolVersion,
|
|
@@ -95,7 +95,7 @@ import {
|
|
|
95
95
|
isRestrictedTarget2,
|
|
96
96
|
isRestrictedUrl2,
|
|
97
97
|
dataUrlDocument2
|
|
98
|
-
} from "./main-
|
|
98
|
+
} from "./main-eq3ptjam.mjs";
|
|
99
99
|
import {
|
|
100
100
|
context,
|
|
101
101
|
pendingPairingCodeKeys,
|
|
@@ -113,7 +113,7 @@ import {
|
|
|
113
113
|
pairingSessionKey,
|
|
114
114
|
sessionProof,
|
|
115
115
|
wrapToken
|
|
116
|
-
} from "./main-
|
|
116
|
+
} from "./main-4r0wgxtf.mjs";
|
|
117
117
|
import {
|
|
118
118
|
makeUnsafe,
|
|
119
119
|
SettingsInputError,
|
|
@@ -141,22 +141,22 @@ import {
|
|
|
141
141
|
checkNavigationUrl,
|
|
142
142
|
readSecret,
|
|
143
143
|
secretText
|
|
144
|
-
} from "./main-
|
|
144
|
+
} from "./main-4avkdmzd.mjs";
|
|
145
145
|
import {
|
|
146
146
|
defaultJournalBaseDir,
|
|
147
147
|
makeJournalEntry,
|
|
148
148
|
appendJournalEntry,
|
|
149
149
|
startJournalRetention
|
|
150
|
-
} from "./main-
|
|
150
|
+
} from "./main-5aymyfdh.mjs";
|
|
151
151
|
import {
|
|
152
152
|
createUpdateWatcher2
|
|
153
|
-
} from "./main-
|
|
153
|
+
} from "./main-4qd7wzb5.mjs";
|
|
154
154
|
import {
|
|
155
155
|
relayHostname,
|
|
156
156
|
isLocalPeer,
|
|
157
157
|
installedDevExtension,
|
|
158
158
|
syncDevExtension
|
|
159
|
-
} from "./main-
|
|
159
|
+
} from "./main-cmq71n09.mjs";
|
|
160
160
|
import {
|
|
161
161
|
currentTimeMillis,
|
|
162
162
|
value,
|
|
@@ -268,7 +268,7 @@ import {
|
|
|
268
268
|
relayToken,
|
|
269
269
|
secretsEqual,
|
|
270
270
|
ensurePrivateDirectory
|
|
271
|
-
} from "./main-
|
|
271
|
+
} from "./main-dk43bgqt.mjs";
|
|
272
272
|
import {
|
|
273
273
|
isString,
|
|
274
274
|
isNumber,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import"./main-
|
|
1
|
+
import"./main-e4wynyjq.mjs";
|
|
2
2
|
import {
|
|
3
3
|
cliCommand,
|
|
4
4
|
installCommand,
|
|
5
|
+
runningServiceTarget,
|
|
6
|
+
releaseChannel,
|
|
7
|
+
checkRelease,
|
|
5
8
|
UPDATE_VERSION,
|
|
6
9
|
channelOf,
|
|
7
10
|
compareVersions,
|
|
@@ -12,14 +15,14 @@ import {
|
|
|
12
15
|
registryUrl,
|
|
13
16
|
fetchPublished,
|
|
14
17
|
runInstaller
|
|
15
|
-
} from "./main-
|
|
18
|
+
} from "./main-ptn0nanz.mjs";
|
|
16
19
|
import"./main-mrew6jy8.mjs";
|
|
17
20
|
import {
|
|
18
21
|
Service,
|
|
19
22
|
layerFetch,
|
|
20
23
|
restartRelay,
|
|
21
24
|
startManagedRelay
|
|
22
|
-
} from "./main-
|
|
25
|
+
} from "./main-eq3ptjam.mjs";
|
|
23
26
|
import"./main-vgzr4689.mjs";
|
|
24
27
|
import {
|
|
25
28
|
succeed6,
|
|
@@ -29,7 +32,7 @@ import {
|
|
|
29
32
|
provide3,
|
|
30
33
|
runPromise
|
|
31
34
|
} from "./main-csnx585b.mjs";
|
|
32
|
-
import"./main-
|
|
35
|
+
import"./main-dk43bgqt.mjs";
|
|
33
36
|
|
|
34
37
|
// src/update/runtime-update.ts
|
|
35
38
|
var log = (line) => process.stdout.write(line + `
|
|
@@ -38,7 +41,7 @@ async function switchTo(runtime, version, options) {
|
|
|
38
41
|
const installed = installedVersion(runtime);
|
|
39
42
|
if (!installed)
|
|
40
43
|
return `${runtime.entry} doesn't report a version`;
|
|
41
|
-
if (
|
|
44
|
+
if (installed !== version)
|
|
42
45
|
return `${version} isn't installed`;
|
|
43
46
|
const program = gen(function* () {
|
|
44
47
|
const relay = yield* Service;
|
|
@@ -66,6 +69,64 @@ async function runInstalledUpdate(args, runtime = installedRuntime2()) {
|
|
|
66
69
|
return true;
|
|
67
70
|
}
|
|
68
71
|
const channel = channelOf(runtime.version);
|
|
72
|
+
if (runtime.kind === "binary") {
|
|
73
|
+
const target = runningServiceTarget();
|
|
74
|
+
if (!target) {
|
|
75
|
+
log("✗ This executable isn't a released browse build, so it has no release channel to follow.");
|
|
76
|
+
process.exitCode = 1;
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
const serviceChannel = releaseChannel(channel);
|
|
80
|
+
const answer = await checkRelease({ version: runtime.version, channel: serviceChannel, target }).catch((error) => error);
|
|
81
|
+
if (answer instanceof Error) {
|
|
82
|
+
log(`✗ Couldn't check for updates: ${answer.message}`);
|
|
83
|
+
process.exitCode = 1;
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
if (answer.status === "missing") {
|
|
87
|
+
log(`✗ There is no ${serviceChannel} release of browse yet.`);
|
|
88
|
+
process.exitCode = 1;
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
if (answer.status === "unchanged") {
|
|
92
|
+
log(`✓ Up to date: ${runtime.version} is the current ${serviceChannel} release.`);
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
const decision = answer.decision;
|
|
96
|
+
if (decision.action === "reject") {
|
|
97
|
+
log(`✗ The ${serviceChannel} release manifest was rejected (${decision.reason}). Try again later.`);
|
|
98
|
+
process.exitCode = 1;
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
if (decision.action === "none") {
|
|
102
|
+
updateState(({ failed: _failed, latest: _latest, ...state }) => ({ ...state, checkedAt: Date.now() }));
|
|
103
|
+
log(decision.reason === "rollout_deferred" ? `✓ Up to date: ${runtime.version}; the ${serviceChannel} release ${answer.releaseVersion} is still rolling out.` : `✓ Up to date: ${runtime.version} is the current ${serviceChannel} release.`);
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
updateState(({ failed: _failed, ...state }) => ({ ...state, checkedAt: Date.now(), latest: decision.version, ...answer.etag ? { etag: answer.etag } : {} }));
|
|
107
|
+
if (args.includes("--check")) {
|
|
108
|
+
log(`Update available: ${decision.version} (you have ${runtime.version}). Run \`${cliCommand("update")}\` to install it.`);
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
log(`Installing ${decision.version} (you have ${runtime.version})…`);
|
|
112
|
+
const installed = await runInstaller({ runtime, channel: serviceChannel }).catch((error) => {
|
|
113
|
+
log(`✗ ${error.message}`);
|
|
114
|
+
process.exitCode = 1;
|
|
115
|
+
return;
|
|
116
|
+
});
|
|
117
|
+
if (!installed)
|
|
118
|
+
return true;
|
|
119
|
+
updateState(({ installing: _installing, ...state }) => ({ ...state, lastUpdate: { from: runtime.version, to: installed, at: new Date().toISOString() } }));
|
|
120
|
+
const refused = await switchTo({ ...runtime, version: installed }, installed, { force: args.includes("--force") });
|
|
121
|
+
if (refused) {
|
|
122
|
+
const automatic = effectiveMode() === "on";
|
|
123
|
+
log(`! Installed ${installed}, but the relay didn't restart (${refused}).`);
|
|
124
|
+
log(automatic ? " It keeps running the old version until no agent is using the browser, then restarts." : ` When no agent is using the browser, run \`${cliCommand("update")}\` again.`);
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
log(`✓ Updated ${runtime.version} → ${installed}.`);
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
69
130
|
const published = await fetchPublished({ registry: await registryUrl(), channel }).catch((error) => error);
|
|
70
131
|
if (published instanceof Error) {
|
|
71
132
|
log(`✗ Couldn't check for updates: ${published.message}`);
|
|
@@ -116,7 +177,11 @@ async function runSelfUpdate(args) {
|
|
|
116
177
|
return;
|
|
117
178
|
}
|
|
118
179
|
try {
|
|
119
|
-
const
|
|
180
|
+
const installChannel = releaseChannel(channel ?? channelOf(version));
|
|
181
|
+
const installed = await runInstaller({
|
|
182
|
+
runtime,
|
|
183
|
+
...runtime.kind === "binary" ? { channel: installChannel } : { version, ...channel ? { channel } : {} }
|
|
184
|
+
});
|
|
120
185
|
log(`${new Date().toISOString()} installed ${installed}`);
|
|
121
186
|
} catch (error) {
|
|
122
187
|
updateState(({ installing, ...state }) => {
|
|
@@ -61,10 +61,10 @@ import {
|
|
|
61
61
|
installRuntime,
|
|
62
62
|
installedRuntime,
|
|
63
63
|
manualMcpEntry
|
|
64
|
-
} from "./main-
|
|
64
|
+
} from "./main-dm2decgk.mjs";
|
|
65
65
|
import {
|
|
66
66
|
opencodeBrowserBuildId2
|
|
67
|
-
} from "./main-
|
|
67
|
+
} from "./main-e4wynyjq.mjs";
|
|
68
68
|
import {
|
|
69
69
|
installedBinaryPath,
|
|
70
70
|
oldStoreMarker,
|
|
@@ -78,7 +78,7 @@ import {
|
|
|
78
78
|
autoUpdateStatus,
|
|
79
79
|
describeAutoUpdate,
|
|
80
80
|
runCommand
|
|
81
|
-
} from "./main-
|
|
81
|
+
} from "./main-ptn0nanz.mjs";
|
|
82
82
|
import"./main-vgzr4689.mjs";
|
|
83
83
|
import {
|
|
84
84
|
pairingCodeTtlMs,
|
|
@@ -92,7 +92,7 @@ import {
|
|
|
92
92
|
revokeBrowserToken,
|
|
93
93
|
legacyPairingCode,
|
|
94
94
|
removeLegacyPairingCode
|
|
95
|
-
} from "./main-
|
|
95
|
+
} from "./main-4r0wgxtf.mjs";
|
|
96
96
|
import {
|
|
97
97
|
unpackedExtensionId,
|
|
98
98
|
extensionProtocolSkew,
|
|
@@ -103,10 +103,10 @@ import {
|
|
|
103
103
|
readRelayConfig,
|
|
104
104
|
writeRelayConfig,
|
|
105
105
|
syncDevExtension
|
|
106
|
-
} from "./main-
|
|
106
|
+
} from "./main-cmq71n09.mjs";
|
|
107
107
|
import {
|
|
108
108
|
relayAuthorization
|
|
109
|
-
} from "./main-
|
|
109
|
+
} from "./main-dk43bgqt.mjs";
|
|
110
110
|
|
|
111
111
|
// src/setup.ts
|
|
112
112
|
import { mkdirSync as mkdirSync2, rmSync as rmSync2, writeFileSync } from "node:fs";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import"./main-
|
|
1
|
+
import"./main-e4wynyjq.mjs";
|
|
2
2
|
import {
|
|
3
3
|
entryCommand,
|
|
4
4
|
installedRuntime2,
|
|
5
5
|
installedVersion
|
|
6
|
-
} from "./main-
|
|
6
|
+
} from "./main-ptn0nanz.mjs";
|
|
7
7
|
|
|
8
8
|
// src/mcp/supervisor.ts
|
|
9
9
|
import { spawn } from "node:child_process";
|
|
@@ -33,7 +33,7 @@ async function runBinaryMcp(args) {
|
|
|
33
33
|
const runtime = installedRuntime2();
|
|
34
34
|
if (!runtime || runtime.kind === "npx") {
|
|
35
35
|
process.env[directEnvironmentVariable] = "1";
|
|
36
|
-
const { runCli } = await import("./cli-
|
|
36
|
+
const { runCli } = await import("./cli-epthh991.mjs");
|
|
37
37
|
return runCli();
|
|
38
38
|
}
|
|
39
39
|
const REPLAY = "opencode-browser-shim-initialize";
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
updateNotice2,
|
|
5
5
|
createUpdateWatcher2,
|
|
6
6
|
runUpdateCommand2
|
|
7
|
-
} from "./main-
|
|
7
|
+
} from "./main-4qd7wzb5.mjs";
|
|
8
8
|
import"./main-mrew6jy8.mjs";
|
|
9
|
-
import"./main-
|
|
10
|
-
import"./main-
|
|
9
|
+
import"./main-ptn0nanz.mjs";
|
|
10
|
+
import"./main-e4wynyjq.mjs";
|
|
11
11
|
export {
|
|
12
12
|
createUpdateWatcher2 as createUpdateWatcher,
|
|
13
13
|
formatUpdateNotice2 as formatUpdateNotice,
|
package/package.json
CHANGED
package/dist/main-j1c8tenv.mjs
DELETED