@opencode/browse 0.0.9-dev.46 → 0.0.9-dev.52

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.
@@ -105,7 +105,7 @@ import {
105
105
  import {
106
106
  opencodeBrowserVersion2,
107
107
  opencodeBrowserBuildId2
108
- } from "./main-fncfesnk.mjs";
108
+ } from "./main-zvx10nrr.mjs";
109
109
  import {
110
110
  dataRoot,
111
111
  fromCheckout,
@@ -115,7 +115,7 @@ import {
115
115
  devExtension,
116
116
  installCommand,
117
117
  autoUpdateStatus
118
- } from "./main-8swhctfm.mjs";
118
+ } from "./main-n3xppv8v.mjs";
119
119
  import {
120
120
  extensionProtocolVersion,
121
121
  extensionProtocolAdvice
@@ -141,13 +141,13 @@ import {
141
141
  ensureExtensionConnected,
142
142
  stoppedRelayStatus,
143
143
  statusCollections
144
- } from "./main-5d3jp8nt.mjs";
145
- import"./main-f26j1c9z.mjs";
144
+ } from "./main-gp9sk766.mjs";
145
+ import"./main-7afts994.mjs";
146
146
  import {
147
147
  updateJson2,
148
148
  formatUpdateNotice2,
149
149
  updateNotice2
150
- } from "./main-ggdb0qpg.mjs";
150
+ } from "./main-d361tmsv.mjs";
151
151
  import {
152
152
  settingKeys,
153
153
  formatSettings,
@@ -155,12 +155,12 @@ import {
155
155
  addSecret,
156
156
  listSecrets,
157
157
  removeSecret
158
- } from "./main-dvpamwsv.mjs";
158
+ } from "./main-aynhkkq5.mjs";
159
159
  import {
160
160
  defaultJournalBaseDir,
161
161
  readJournalEntries,
162
162
  formatJournalEntry
163
- } from "./main-j6339pqr.mjs";
163
+ } from "./main-0x6hkn0k.mjs";
164
164
  import {
165
165
  pipeArguments,
166
166
  dual,
@@ -5540,6 +5540,7 @@ var exitWith = (code) => sync2(() => {
5540
5540
  });
5541
5541
  var hostErrorTags = new Set([
5542
5542
  "RelayClient.RelayUnreachable",
5543
+ "RelayClient.RelayTimedOut",
5543
5544
  "RelayLifecycle.RelayStartFailed",
5544
5545
  "RelayLifecycle.ExtensionDisconnected"
5545
5546
  ]);
@@ -5855,7 +5856,7 @@ var status = make("status", {
5855
5856
  }
5856
5857
  })).pipe(withDescription4("Show relay, extension, and target status"));
5857
5858
  var mcp = make("mcp", {}, fn("Cli.mcp")(function* () {
5858
- const { runMcpServer } = yield* promise(() => import("./mcp-ydp4fdqj.mjs"));
5859
+ const { runMcpServer } = yield* promise(() => import("./mcp-wfz4t9xs.mjs"));
5859
5860
  yield* runMcpServer;
5860
5861
  })).pipe(withDescription4("Run the browse MCP server over stdio"));
5861
5862
  registerCliCommand(400, () => tabs);
@@ -6303,7 +6304,7 @@ registerCliCommand(710, () => flightRecorder);
6303
6304
 
6304
6305
  // src/cli/relay.ts
6305
6306
  var serve = make("serve", {}, fn("Cli.serve")(function* () {
6306
- const [{ startRelay }, { parseAdditionalExtensionOrigins }] = yield* promise(() => Promise.all([import("./relay-t9nsa55h.mjs"), import("./helpers-pnmc9ra4.mjs")]));
6307
+ const [{ startRelay }, { parseAdditionalExtensionOrigins }] = yield* promise(() => Promise.all([import("./relay-mkd990bm.mjs"), import("./helpers-ckt0t3m8.mjs")]));
6307
6308
  const port = yield* portConfig;
6308
6309
  const additionalExtensionOrigins = parseAdditionalExtensionOrigins(yield* extensionOriginsConfig);
6309
6310
  yield* scoped(gen(function* () {
package/dist/cli.mjs CHANGED
@@ -2,29 +2,29 @@
2
2
 
3
3
  // src/main.ts
4
4
  import path from "node:path";
5
- var embeddedVersion = "0.0.9-dev.46";
5
+ var embeddedVersion = "0.0.9-dev.52";
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-k3yz6ejy.mjs")).opencodeBrowserVersion;
10
+ const opencodeBrowserVersion = embeddedVersion ?? (await import("./version-ya6z11zf.mjs")).opencodeBrowserVersion;
11
11
  process.stdout.write(`${opencodeBrowserVersion}
12
12
  `);
13
+ } else if (command === "mcp" && globalThis.__OPENCODE_BROWSER_COMPILED__ && process.env.OPENCODE_BROWSER_MCP_DIRECT !== "1") {
14
+ const { runBinaryMcp } = await import("./supervisor-bs6k2zwy.mjs");
15
+ await runBinaryMcp(process.argv.slice(3));
13
16
  } else if (invokedAs === "opencode-browser-mcp" || command === "mcp" && process.argv.length === 3) {
14
17
  const { NodeRuntime } = await import("./index-8v65jg3n.mjs");
15
- const { runMcpServer } = await import("./mcp-ydp4fdqj.mjs");
18
+ const { runMcpServer } = await import("./mcp-wfz4t9xs.mjs");
16
19
  runMcpServer.pipe(NodeRuntime.runMain);
17
- } else if (command === "mcp" && globalThis.__OPENCODE_BROWSER_COMPILED__ && process.env.OPENCODE_BROWSER_MCP_DIRECT !== "1") {
18
- const { runBinaryMcp } = await import("./supervisor-hq59hw07.mjs");
19
- await runBinaryMcp(process.argv.slice(3));
20
20
  } else if (command === "runtime-install" || command === "runtime-switch") {
21
- const { runRuntimeInstall, runRuntimeSwitch } = await import("./runtime-update-t6cn08nr.mjs");
21
+ const { runRuntimeInstall, runRuntimeSwitch } = await import("./runtime-update-sae52vzk.mjs");
22
22
  await (command === "runtime-install" ? runRuntimeInstall : runRuntimeSwitch)(process.argv.slice(3));
23
23
  } else if (command === "update") {
24
- const { runUpdateCommand } = await import("./update-tbp3x80r.mjs");
24
+ const { runUpdateCommand } = await import("./update-v6t1c2ex.mjs");
25
25
  await runUpdateCommand(process.argv.slice(3));
26
26
  } else if (command && setupCommands.has(command)) {
27
- const { runSetup } = await import("./setup-3x096ts8.mjs");
27
+ const { runSetup } = await import("./setup-wgpg9g9s.mjs");
28
28
  await runSetup(command, process.argv.slice(3));
29
29
  } else {
30
30
  if (!command || command === "--help" || command === "-h") {
@@ -59,9 +59,9 @@ if (command === "--version" || command === "-v") {
59
59
  `);
60
60
  }
61
61
  if (command === "status" && !process.argv.includes("--json")) {
62
- const { printSetupStatus } = await import("./setup-3x096ts8.mjs");
62
+ const { printSetupStatus } = await import("./setup-wgpg9g9s.mjs");
63
63
  printSetupStatus();
64
64
  }
65
- const { runCli } = await import("./cli-1bwberh6.mjs");
65
+ const { runCli } = await import("./cli-hhwgz33c.mjs");
66
66
  runCli();
67
67
  }
@@ -31,8 +31,8 @@ import {
31
31
  isRestrictedTarget2,
32
32
  isRestrictedUrl2,
33
33
  dataUrlDocument2
34
- } from "./main-5d3jp8nt.mjs";
35
- import"./main-f26j1c9z.mjs";
34
+ } from "./main-gp9sk766.mjs";
35
+ import"./main-7afts994.mjs";
36
36
  import"./main-3gthmkzw.mjs";
37
37
  export {
38
38
  HttpRouteError2 as HttpRouteError,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  isNodeError
3
- } from "./main-f26j1c9z.mjs";
3
+ } from "./main-7afts994.mjs";
4
4
  import {
5
5
  isValidSessionId2
6
- } from "./main-5d3jp8nt.mjs";
6
+ } from "./main-gp9sk766.mjs";
7
7
  import {
8
8
  isSome,
9
9
  decodeUnknownOption,
@@ -17,7 +17,7 @@ import {
17
17
  } from "./main-ta3yc4kx.mjs";
18
18
  import {
19
19
  dataRoot
20
- } from "./main-8swhctfm.mjs";
20
+ } from "./main-n3xppv8v.mjs";
21
21
 
22
22
  // src/session-manager/journal.ts
23
23
  import fs from "node:fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  dataRoot
3
- } from "./main-8swhctfm.mjs";
3
+ } from "./main-n3xppv8v.mjs";
4
4
  import {
5
5
  isString
6
6
  } from "./main-yf9xhpn4.mjs";
@@ -2,11 +2,11 @@ import {
2
2
  parseTargetSelection2,
3
3
  getObject2,
4
4
  getString2
5
- } from "./main-5d3jp8nt.mjs";
5
+ } from "./main-gp9sk766.mjs";
6
6
  import {
7
7
  isNodeError,
8
8
  writeJsonFileAtomically
9
- } from "./main-f26j1c9z.mjs";
9
+ } from "./main-7afts994.mjs";
10
10
  import {
11
11
  getStackTraceLimit,
12
12
  setStackTraceLimit,
@@ -105,7 +105,7 @@ import {
105
105
  import {
106
106
  dataRoot,
107
107
  cliCommand
108
- } from "./main-8swhctfm.mjs";
108
+ } from "./main-n3xppv8v.mjs";
109
109
  import {
110
110
  pipeArguments,
111
111
  identity,
@@ -2723,4 +2723,4 @@ function secretText(secret) {
2723
2723
  return secret.kind === "totp" ? totpCode(secret.value) : secret.value;
2724
2724
  }
2725
2725
 
2726
- export { makeUnsafe, make, isStreamSchema, getStreamSchemas, ClientAbort, ServerClient, make2, exitSchema, isWrapper, make3, Implementation, ClientCapabilities, INVALID_REQUEST_ERROR_CODE, METHOD_NOT_FOUND_ERROR_CODE, INVALID_PARAMS_ERROR_CODE, INTERNAL_ERROR_CODE, HEADER_MISMATCH_ERROR_CODE, ParseError, InvalidRequest, MethodNotFound, InvalidParams, InternalError, McpError, Ping, Initialize, CancelledNotification, ProgressNotification, ResourceListChangedNotification, ResourceUpdatedNotification, Prompt, TextContent, PromptListChangedNotification, Tool, CallToolResult, ToolListChangedNotification, LoggingLevel, LoggingMessageNotification, CreateMessage, ListRootsResult, ListRoots, Elicit, McpReverseOperationUnsupported, McpReverseOperationError, McpRequestContext, McpServerClient, McpServerClientMiddleware, ServerNotificationRpcs, EnabledWhen, settingKeys, settingSpecs, securityVariables, SettingsInputError, parseSettingChanges, settingsFromExtension, settingsToExtension, describeSettings, describeChanges, formatSettings, browsersNote2, mcpUpdateNote2, objectSchema, emptyInputSchema, sessionSchemaProperty, sessionAliasSchemaProperty, sessionOnlyInputSchema, ensureSessionExists, parseExecuteArguments, parseAdoptArguments, requiredStringField, optionalStringField, optionalBooleanField, optionalPositiveIntegerField, optionalStringArrayField, requireObject, toolResultForValue2, mcpErrorMessage2, toolResult, terminateChildProcess, SecretCollector, looksLikeTokenSegment, AuthProfileError, read, readOptional, withLock, write, status, run, OriginPatternError, parseOriginPatterns, normalizeOriginPatterns, isPrivateAddress, explicitlyAllowsHost, checkUrl, checkNavigationUrl, readSecret, addSecret, listSecrets, removeSecret, secretText };
2726
+ export { makeUnsafe, make, settingKeys, settingSpecs, securityVariables, SettingsInputError, parseSettingChanges, settingsFromExtension, settingsToExtension, describeSettings, describeChanges, formatSettings, isStreamSchema, getStreamSchemas, ClientAbort, ServerClient, make2, exitSchema, isWrapper, make3, Implementation, ClientCapabilities, INVALID_REQUEST_ERROR_CODE, METHOD_NOT_FOUND_ERROR_CODE, INVALID_PARAMS_ERROR_CODE, INTERNAL_ERROR_CODE, HEADER_MISMATCH_ERROR_CODE, ParseError, InvalidRequest, MethodNotFound, InvalidParams, InternalError, McpError, Ping, Initialize, CancelledNotification, ProgressNotification, ResourceListChangedNotification, ResourceUpdatedNotification, Prompt, TextContent, PromptListChangedNotification, Tool, CallToolResult, ToolListChangedNotification, LoggingLevel, LoggingMessageNotification, CreateMessage, ListRootsResult, ListRoots, Elicit, McpReverseOperationUnsupported, McpReverseOperationError, McpRequestContext, McpServerClient, McpServerClientMiddleware, ServerNotificationRpcs, EnabledWhen, browsersNote2, mcpUpdateNote2, objectSchema, emptyInputSchema, sessionSchemaProperty, sessionAliasSchemaProperty, sessionOnlyInputSchema, ensureSessionExists, parseExecuteArguments, parseAdoptArguments, requiredStringField, optionalStringField, optionalBooleanField, optionalPositiveIntegerField, optionalStringArrayField, requireObject, toolResultForValue2, mcpErrorMessage2, toolResult, terminateChildProcess, SecretCollector, looksLikeTokenSegment, AuthProfileError, read, readOptional, withLock, write, status, run, OriginPatternError, parseOriginPatterns, normalizeOriginPatterns, isPrivateAddress, explicitlyAllowsHost, checkUrl, checkNavigationUrl, readSecret, addSecret, listSecrets, removeSecret, secretText };
@@ -6,7 +6,7 @@ import {
6
6
  compareVersions,
7
7
  npmRuntime,
8
8
  autoUpdateStatus
9
- } from "./main-8swhctfm.mjs";
9
+ } from "./main-n3xppv8v.mjs";
10
10
  import {
11
11
  unpackedReloadAdvice
12
12
  } from "./main-3gthmkzw.mjs";
@@ -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 { runNpmUpdate } = await import("./runtime-update-t6cn08nr.mjs");
318
+ const { runNpmUpdate } = await import("./runtime-update-sae52vzk.mjs");
319
319
  if (await runNpmUpdate(args))
320
320
  return;
321
321
  if (compiledBinary()) {
@@ -6,7 +6,7 @@ import {
6
6
  } from "./main-3gthmkzw.mjs";
7
7
  import {
8
8
  relayAuthorization
9
- } from "./main-f26j1c9z.mjs";
9
+ } from "./main-7afts994.mjs";
10
10
  import {
11
11
  assignProperty,
12
12
  PipeInspectableProto,
@@ -39,6 +39,7 @@ import {
39
39
  try_,
40
40
  fromResult,
41
41
  flatMap3,
42
+ andThen,
42
43
  result,
43
44
  map5,
44
45
  catch_,
@@ -47,6 +48,10 @@ import {
47
48
  orDie,
48
49
  tapError,
49
50
  retry,
51
+ timeoutOrElse,
52
+ sleep,
53
+ raceFirst,
54
+ forever,
50
55
  fnUntraced,
51
56
  fn,
52
57
  mapEager,
@@ -103,14 +108,14 @@ import {
103
108
  } from "./main-ta3yc4kx.mjs";
104
109
  import {
105
110
  opencodeBrowserBuildId2
106
- } from "./main-fncfesnk.mjs";
111
+ } from "./main-zvx10nrr.mjs";
107
112
  import {
108
113
  compiledBinary,
109
114
  scriptEntry,
110
115
  cliCommand,
111
116
  installCommand,
112
117
  npmRuntime
113
- } from "./main-8swhctfm.mjs";
118
+ } from "./main-n3xppv8v.mjs";
114
119
  import {
115
120
  dual,
116
121
  memoize,
@@ -1299,7 +1304,7 @@ async function dataUrlDocument2(url) {
1299
1304
  }
1300
1305
 
1301
1306
  // src/relay/lifecycle.ts
1302
- import { spawn } from "node:child_process";
1307
+ import { execFileSync, spawn } from "node:child_process";
1303
1308
  import crypto2 from "node:crypto";
1304
1309
  import path from "node:path";
1305
1310
  import process2 from "node:process";
@@ -1325,6 +1330,9 @@ class RelayRejected extends TaggedError2()("RelayClient.RelayRejected", {
1325
1330
  }) {
1326
1331
  }
1327
1332
 
1333
+ class RelayTimedOut extends TaggedError2()("RelayClient.RelayTimedOut", { message: String3, path: String3 }) {
1334
+ }
1335
+
1328
1336
  class RelayDecodeFailed extends TaggedError2()("RelayClient.RelayDecodeFailed", {
1329
1337
  message: String3,
1330
1338
  path: String3,
@@ -1394,12 +1402,16 @@ var make3 = fn("RelayClient.make")(function* (options) {
1394
1402
  const authorized = setHeader(request, "authorization", authorization);
1395
1403
  return options?.clientPid === undefined ? authorized : setHeader(authorized, "opencode-browser-client-pid", String(options.clientPid));
1396
1404
  };
1397
- const getJson = (path, schema) => suspend2(() => httpClient.execute(authorize(get2(new URL(path, endpoint))))).pipe(mapError(transportError(path)), flatMap3((response) => handleResponse(response, path, schema)));
1405
+ const getJson = (path, schema) => suspend2(() => httpClient.execute(authorize(get2(new URL(path, endpoint))))).pipe(mapError(transportError(path)), flatMap3((response) => handleResponse(response, path, schema)), timeoutOrElse({ duration: 5000, orElse: () => fail4(new RelayTimedOut({
1406
+ message: `The relay on port ${new URL(endpoint).port} isn't answering (${path} timed out).`,
1407
+ path
1408
+ })) }));
1409
+ const checkWhileWaiting = sleep(30000).pipe(andThen(getJson("/version", RelayVersion)), forever);
1398
1410
  const postJson = (path, body, schema) => post(new URL(path, endpoint)).pipe(bodyJson(body), mapError((cause) => new RelayEncodeFailed({
1399
1411
  message: `Could not encode relay request for ${path}`,
1400
1412
  path,
1401
1413
  cause
1402
- })), flatMap3((request) => httpClient.execute(authorize(request)).pipe(mapError(transportError(path)), flatMap3((response) => handleResponse(response, path, schema)))));
1414
+ })), flatMap3((request) => httpClient.execute(authorize(request)).pipe(mapError(transportError(path)), flatMap3((response) => handleResponse(response, path, schema)), raceFirst(checkWhileWaiting))));
1403
1415
  const recordingTargetBody = (target) => ({
1404
1416
  ...target.sessionId ? { sessionId: target.sessionId } : {},
1405
1417
  ...target.tabId === undefined ? {} : { tabId: target.tabId }
@@ -1690,10 +1702,16 @@ function startManagedRelay(entrypoint = loadedCliEntrypoint, executable = proces
1690
1702
  }
1691
1703
  const launch = managedRelayLaunch(entrypoint, executable, execArgv);
1692
1704
  const { OPENCODE_BROWSER_RESTART_REQUEST_ID: _inheritedRestartRequestId, ...env } = relayEnvironment(process2.env);
1705
+ const childEnv = { ...env, OPENCODE_BROWSER_MANAGED_RELAY: "1", ...options.restartRequestId ? { OPENCODE_BROWSER_RESTART_REQUEST_ID: options.restartRequestId } : {} };
1706
+ if (process2.platform === "win32") {
1707
+ const args = launch.args.map((s) => `"${s.replace(/(\\*)"/g, "$1$1\\\"").replace(/(\\+)$/, "$1$1")}"`).join(" ");
1708
+ execFileSync(path.join(process2.env.SystemRoot, "System32/WindowsPowerShell/v1.0/powershell.exe"), ["-NoProfile", "-NonInteractive", "-Command", "Start-Process -ErrorAction Stop -WindowStyle Hidden -FilePath $env:BROWSE_EXE -ArgumentList $env:BROWSE_ARGS"], { env: { ...childEnv, BROWSE_EXE: launch.executable, BROWSE_ARGS: args }, windowsHide: true, stdio: "ignore" });
1709
+ return;
1710
+ }
1693
1711
  const child = spawn(launch.executable, launch.args, {
1694
1712
  detached: true,
1695
1713
  stdio: "ignore",
1696
- env: { ...env, OPENCODE_BROWSER_MANAGED_RELAY: "1", ...options.restartRequestId ? { OPENCODE_BROWSER_RESTART_REQUEST_ID: options.restartRequestId } : {} }
1714
+ env: childEnv
1697
1715
  });
1698
1716
  child.unref();
1699
1717
  },
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  opencodeBrowserVersion2
3
- } from "./main-fncfesnk.mjs";
3
+ } from "./main-zvx10nrr.mjs";
4
4
 
5
5
  // src/update/auto-update.ts
6
6
  import { spawn } from "node:child_process";
@@ -70,7 +70,7 @@ function storeConfig(env = process.env, baked = { id: "mfnicocicmmlkpjnaffgihfjh
70
70
  return id ? { id } : {};
71
71
  }
72
72
  var RELEASE_SERVICE = "https://anoma.ly/release";
73
- function devExtension(baked = { file: "browse-extension-0.0.9-dev.46.zip", sha256: "94e02e16f3dd6dfca98054392aabd71aae48a3138d7d62359d71dedad95c0396", size: 184272 }) {
73
+ function devExtension(baked = { file: "browse-extension-0.0.9-dev.52.zip", sha256: "177c811de6fff477e2440d06e687ce1927310a1f1152f0b68154ae97b34390e5", size: 184272 }) {
74
74
  return baked && /^[0-9a-f]{64}$/.test(baked.sha256) && /^[\w.-]+\.zip$/.test(baked.file) ? baked : undefined;
75
75
  }
76
76
  var devExtensionUrl = (extension, env = process.env) => `${(env.OPENCODE_BROWSER_RELEASE_SERVICE || RELEASE_SERVICE).replace(/\/+$/, "")}/browse/files/${extension.sha256}/${extension.file}`;
@@ -269,6 +269,9 @@ async function registryUrl(run = runCommand, env = process.env) {
269
269
  const configured = override || (compiledBinary() ? "" : (await run("npm", ["config", "get", "registry"], { timeoutMs: 15000 })).stdout.trim());
270
270
  return /^https?:\/\//.test(configured) ? configured.replace(/\/+$/, "") : DEFAULT_REGISTRY;
271
271
  }
272
+
273
+ class InstallVerificationError extends Error {
274
+ }
272
275
  async function fetchPublished(options) {
273
276
  const request = options.fetch ?? fetch;
274
277
  const name = options.packageName ?? updatePackage();
@@ -329,24 +332,27 @@ async function installVersion(options) {
329
332
  else {
330
333
  const args = ["install", "--prefix", temporary, "--no-audit", "--no-fund", "--ignore-scripts", "--loglevel=error", ...options.registry ? [`--registry=${options.registry}`] : [], spec];
331
334
  const npm = await run("npm", args, { timeoutMs: 10 * 60000 });
332
- if (npm.status !== 0)
333
- throw new Error(`npm install ${spec} failed: ${(npm.stderr || npm.stdout).trim().split(`
334
- `).slice(-3).join(" ")}`);
335
+ if (npm.status !== 0) {
336
+ const output = npm.stderr || npm.stdout;
337
+ const message = `npm install ${spec} failed: ${output.trim().split(`
338
+ `).slice(-3).join(" ")}`;
339
+ throw /\bEINTEGRITY\b/.test(output) ? new InstallVerificationError(message) : new Error(message);
340
+ }
335
341
  }
336
342
  const installed = readJson(path2.join(temporary, "node_modules", "@opencode", "browse", "package.json"))?.version;
337
343
  if (!installed)
338
- throw new Error(`npm install ${spec} didn't install ${PACKAGE_NAME}`);
344
+ throw new InstallVerificationError(`npm install ${spec} didn't install ${PACKAGE_NAME}`);
339
345
  if (options.spec === undefined && installed !== options.version)
340
- throw new Error(`npm installed ${installed}, not ${options.version}`);
346
+ throw new InstallVerificationError(`npm installed ${installed}, not ${options.version}`);
341
347
  if (options.integrity) {
342
348
  const locked = readJson(path2.join(temporary, "package-lock.json"))?.packages?.["node_modules/@opencode/browse"];
343
349
  if (locked?.integrity !== options.integrity)
344
- throw new Error(`${PACKAGE_NAME}@${installed} installed with integrity ${locked?.integrity ?? "unknown"}, not the registry's ${options.integrity}`);
350
+ throw new InstallVerificationError(`${PACKAGE_NAME}@${installed} installed with integrity ${locked?.integrity ?? "unknown"}, not the registry's ${options.integrity}`);
345
351
  }
346
352
  const entry = path2.join(temporary, "node_modules", "@opencode", "browse", "dist", "cli.mjs");
347
353
  const reported = await run(options.node ?? process.execPath, [entry, "--version"], { timeoutMs: 30000, env: { ...process.env, OPENCODE_BROWSER_AUTOSTART: "0" } });
348
354
  if (reported.status !== 0 || reported.stdout.trim() !== installed)
349
- throw new Error(`${PACKAGE_NAME}@${installed} didn't run: \`--version\` printed ${JSON.stringify(reported.stdout.trim() || reported.stderr.trim()).slice(0, 200)}`);
355
+ throw new InstallVerificationError(`${PACKAGE_NAME}@${installed} didn't run: \`--version\` printed ${JSON.stringify(reported.stdout.trim() || reported.stderr.trim()).slice(0, 200)}`);
350
356
  const target = versionDirectory(layout, installed);
351
357
  rmSync(target, { recursive: true, force: true });
352
358
  renameSync(temporary, target);
@@ -379,16 +385,16 @@ async function installBinaryVersion(options) {
379
385
  const tgz = new Uint8Array(await response.arrayBuffer());
380
386
  const actual = `sha512-${createHash("sha512").update(tgz).digest("base64")}`;
381
387
  if (actual !== integrity)
382
- throw new Error(`${name}@${options.version} downloaded with integrity ${actual}, not the registry's ${integrity}`);
388
+ throw new InstallVerificationError(`${name}@${options.version} downloaded with integrity ${actual}, not the registry's ${integrity}`);
383
389
  const executable = tarFile(tgz, `package/bin/${binaryName()}`);
384
390
  if (!executable)
385
- throw new Error(`${name}@${options.version} has no bin/${binaryName()}`);
391
+ throw new InstallVerificationError(`${name}@${options.version} has no bin/${binaryName()}`);
386
392
  writeFileSync(file, executable);
387
393
  }
388
394
  chmodSync(file, 493);
389
395
  const reported = await run(file, ["--version"], { timeoutMs: 30000, env: { ...process.env, OPENCODE_BROWSER_AUTOSTART: "0" } });
390
396
  if (reported.status !== 0 || reported.stdout.trim() !== expected)
391
- throw new Error(`browse ${expected} didn't run: \`--version\` printed ${JSON.stringify(reported.stdout.trim() || reported.stderr.trim()).slice(0, 200)}`);
397
+ throw new InstallVerificationError(`browse ${expected} didn't run: \`--version\` printed ${JSON.stringify(reported.stdout.trim() || reported.stderr.trim()).slice(0, 200)}`);
392
398
  const target = versionDirectory(layout, expected);
393
399
  rmSync(target, { recursive: true, force: true });
394
400
  renameSync(temporary, target);
@@ -705,8 +711,15 @@ function createAutoUpdater(deps) {
705
711
  deps.log("autoupdate.installer_gone", { version: installing.version });
706
712
  }
707
713
  if (state.pending !== wanted) {
708
- if (state.lastError?.version === wanted && now() - Date.parse(state.lastError.at) < checkIntervalMs)
709
- return;
714
+ if (state.lastError?.version === wanted) {
715
+ const failure = state.lastError;
716
+ const attempts = failure.attempts ?? 1;
717
+ const backoff = (attempts <= 1 ? 15 : attempts === 2 ? 60 : 240) * 60000;
718
+ const delay = failure.verification ? checkIntervalMs : Math.min(backoff, checkIntervalMs);
719
+ const age = now() - Date.parse(failure.at);
720
+ if (age >= 0 && age < delay)
721
+ return;
722
+ }
710
723
  deps.log("autoupdate.installing", { version: wanted });
711
724
  const pid = spawnChild(["runtime-install", wanted, ...state.integrity ? ["--integrity", state.integrity] : []], (code) => {
712
725
  deps.log(code === 0 ? "autoupdate.installed" : "autoupdate.install_failed", { version: wanted, code });
@@ -769,4 +782,4 @@ function spawnRuntimeChild(layout, entry, args, onExit, env = process.env) {
769
782
  }
770
783
  }
771
784
 
772
- export { dataRoot, oldStoreMarker, fromCheckout, compiledBinary, binaryPackage, scriptEntry, entryCommand, runningEntry, checkoutRoot, cliCommand, PUBLIC_STORE_ID, storeConfig, devExtension, devExtensionUrl, devExtensionFolder, storeUrl, installCommand, autoUpdateModes, runtimeLayout, versionEntry, channelOf, UPDATE_VERSION, compareVersions, readCurrent, writeCurrent, updateState, npmRuntime, autoUpdateOverride, storedMode, effectiveMode, setStoredMode, autoUpdateStatus, describeAutoUpdate, registryUrl, fetchPublished, installVersion, pruneVersions, switchVersion, createAutoUpdater };
785
+ export { dataRoot, oldStoreMarker, fromCheckout, compiledBinary, binaryPackage, scriptEntry, entryCommand, runningEntry, checkoutRoot, cliCommand, PUBLIC_STORE_ID, storeConfig, devExtension, devExtensionUrl, devExtensionFolder, storeUrl, installCommand, autoUpdateModes, runtimeLayout, versionEntry, channelOf, UPDATE_VERSION, compareVersions, readCurrent, writeCurrent, updateState, npmRuntime, autoUpdateOverride, storedMode, effectiveMode, setStoredMode, autoUpdateStatus, describeAutoUpdate, registryUrl, InstallVerificationError, fetchPublished, installVersion, pruneVersions, switchVersion, createAutoUpdater };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  writePrivateJsonFileSync
3
- } from "./main-f26j1c9z.mjs";
3
+ } from "./main-7afts994.mjs";
4
4
  import {
5
5
  dataRoot,
6
6
  devExtensionUrl,
7
7
  devExtensionFolder
8
- } from "./main-8swhctfm.mjs";
8
+ } from "./main-n3xppv8v.mjs";
9
9
 
10
10
  // src/relay/browser-pairing.ts
11
11
  import crypto from "node:crypto";
@@ -0,0 +1,4 @@
1
+ // src/version.ts
2
+ var opencodeBrowserVersion2 = "0.0.9-dev.52";
3
+ var opencodeBrowserBuildId2 = "2026-11-05T01:13:45.077Z";
4
+ export { opencodeBrowserVersion2, opencodeBrowserBuildId2 };
@@ -258,10 +258,10 @@ import {
258
258
  } from "./main-ta3yc4kx.mjs";
259
259
  import {
260
260
  opencodeBrowserVersion2
261
- } from "./main-fncfesnk.mjs";
261
+ } from "./main-zvx10nrr.mjs";
262
262
  import {
263
263
  autoUpdateStatus
264
- } from "./main-8swhctfm.mjs";
264
+ } from "./main-n3xppv8v.mjs";
265
265
  import"./main-3gthmkzw.mjs";
266
266
  import {
267
267
  option,
@@ -272,15 +272,18 @@ import {
272
272
  relayBuildProblem,
273
273
  ensureRelay,
274
274
  ensureExtensionConnected
275
- } from "./main-5d3jp8nt.mjs";
276
- import"./main-f26j1c9z.mjs";
275
+ } from "./main-gp9sk766.mjs";
276
+ import"./main-7afts994.mjs";
277
277
  import {
278
278
  updateJson2,
279
279
  createUpdateWatcher2
280
- } from "./main-ggdb0qpg.mjs";
280
+ } from "./main-d361tmsv.mjs";
281
281
  import {
282
282
  makeUnsafe,
283
283
  make,
284
+ settingKeys,
285
+ settingSpecs,
286
+ securityVariables,
284
287
  isStreamSchema,
285
288
  getStreamSchemas,
286
289
  ClientAbort,
@@ -327,9 +330,6 @@ import {
327
330
  McpServerClientMiddleware,
328
331
  ServerNotificationRpcs,
329
332
  EnabledWhen,
330
- settingKeys,
331
- settingSpecs,
332
- securityVariables,
333
333
  browsersNote2,
334
334
  mcpUpdateNote2,
335
335
  objectSchema,
@@ -350,7 +350,7 @@ import {
350
350
  mcpErrorMessage2,
351
351
  toolResult,
352
352
  listSecrets
353
- } from "./main-dvpamwsv.mjs";
353
+ } from "./main-aynhkkq5.mjs";
354
354
  import {
355
355
  Clock,
356
356
  type,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  opencodeBrowserVersion2,
3
3
  opencodeBrowserBuildId2
4
- } from "./main-fncfesnk.mjs";
4
+ } from "./main-zvx10nrr.mjs";
5
5
  import {
6
6
  dataRoot,
7
7
  oldStoreMarker,
@@ -19,7 +19,7 @@ import {
19
19
  setStoredMode,
20
20
  autoUpdateStatus,
21
21
  createAutoUpdater
22
- } from "./main-8swhctfm.mjs";
22
+ } from "./main-n3xppv8v.mjs";
23
23
  import {
24
24
  extensionProtocolVersion,
25
25
  minExtensionProtocolVersion,
@@ -43,7 +43,7 @@ import {
43
43
  relayToken,
44
44
  secretsEqual,
45
45
  ensurePrivateDirectory
46
- } from "./main-f26j1c9z.mjs";
46
+ } from "./main-7afts994.mjs";
47
47
  import {
48
48
  withDefault,
49
49
  option,
@@ -97,7 +97,7 @@ import {
97
97
  isRestrictedTarget2,
98
98
  isRestrictedUrl2,
99
99
  dataUrlDocument2
100
- } from "./main-5d3jp8nt.mjs";
100
+ } from "./main-gp9sk766.mjs";
101
101
  import {
102
102
  relayHostname,
103
103
  isLocalPeer,
@@ -119,7 +119,7 @@ import {
119
119
  wrapToken,
120
120
  installedDevExtension,
121
121
  syncDevExtension
122
- } from "./main-8q3aab0f.mjs";
122
+ } from "./main-p18deahv.mjs";
123
123
  import {
124
124
  makeUnsafe,
125
125
  SettingsInputError,
@@ -147,16 +147,16 @@ import {
147
147
  checkNavigationUrl,
148
148
  readSecret,
149
149
  secretText
150
- } from "./main-dvpamwsv.mjs";
150
+ } from "./main-aynhkkq5.mjs";
151
151
  import {
152
152
  defaultJournalBaseDir,
153
153
  makeJournalEntry,
154
154
  appendJournalEntry,
155
155
  startJournalRetention
156
- } from "./main-j6339pqr.mjs";
156
+ } from "./main-0x6hkn0k.mjs";
157
157
  import {
158
158
  createUpdateWatcher2
159
- } from "./main-ggdb0qpg.mjs";
159
+ } from "./main-d361tmsv.mjs";
160
160
  import {
161
161
  isNone,
162
162
  isSome,
@@ -1,4 +1,4 @@
1
- import"./main-fncfesnk.mjs";
1
+ import"./main-zvx10nrr.mjs";
2
2
  import {
3
3
  cliCommand,
4
4
  installCommand,
@@ -13,19 +13,20 @@ import {
13
13
  npmRuntime,
14
14
  effectiveMode,
15
15
  registryUrl,
16
+ InstallVerificationError,
16
17
  fetchPublished,
17
18
  installVersion,
18
19
  pruneVersions,
19
20
  switchVersion
20
- } from "./main-8swhctfm.mjs";
21
+ } from "./main-n3xppv8v.mjs";
21
22
  import"./main-3gthmkzw.mjs";
22
23
  import {
23
24
  Service,
24
25
  layerFetch,
25
26
  restartRelay,
26
27
  startManagedRelay
27
- } from "./main-5d3jp8nt.mjs";
28
- import"./main-f26j1c9z.mjs";
28
+ } from "./main-gp9sk766.mjs";
29
+ import"./main-7afts994.mjs";
29
30
  import {
30
31
  succeed6,
31
32
  suspend2,
@@ -171,7 +172,8 @@ async function runRuntimeInstall(args) {
171
172
  } catch (error) {
172
173
  updateState(layout, ({ installing, ...state }) => {
173
174
  const still = clear(installing);
174
- return { ...state, ...still ? { installing: still } : {}, lastError: { message: error.message, at: new Date().toISOString(), version } };
175
+ const attempts = 1 + (state.lastError?.version === version ? state.lastError.attempts ?? 1 : 0);
176
+ return { ...state, ...still ? { installing: still } : {}, lastError: { message: error.message, at: new Date().toISOString(), version, attempts, verification: error instanceof InstallVerificationError } };
175
177
  });
176
178
  log(`${new Date().toISOString()} install of ${version} failed: ${error.message}`);
177
179
  process.exitCode = 1;
@@ -1,6 +1,7 @@
1
1
  import {
2
- opencodeBrowserVersion2
3
- } from "./main-fncfesnk.mjs";
2
+ opencodeBrowserVersion2,
3
+ opencodeBrowserBuildId2
4
+ } from "./main-zvx10nrr.mjs";
4
5
  import {
5
6
  dataRoot,
6
7
  oldStoreMarker,
@@ -25,10 +26,10 @@ import {
25
26
  installVersion,
26
27
  pruneVersions,
27
28
  switchVersion
28
- } from "./main-8swhctfm.mjs";
29
+ } from "./main-n3xppv8v.mjs";
29
30
  import {
30
31
  relayAuthorization
31
- } from "./main-f26j1c9z.mjs";
32
+ } from "./main-7afts994.mjs";
32
33
  import {
33
34
  parseHostname,
34
35
  readRelayConfig,
@@ -45,7 +46,7 @@ import {
45
46
  legacyPairingCode,
46
47
  removeLegacyPairingCode,
47
48
  syncDevExtension
48
- } from "./main-8q3aab0f.mjs";
49
+ } from "./main-p18deahv.mjs";
49
50
  import {
50
51
  unpackedExtensionId,
51
52
  extensionProtocolSkew,
@@ -11153,14 +11154,14 @@ function launcher(browser) {
11153
11154
  // src/setup/commands.ts
11154
11155
  import { spawnSync as spawnSync5 } from "node:child_process";
11155
11156
  import { randomUUID } from "node:crypto";
11156
- import { existsSync as existsSync5, mkdirSync as mkdirSync3, readdirSync as readdirSync3, rmSync as rmSync3 } from "node:fs";
11157
+ import { existsSync as existsSync5, mkdirSync as mkdirSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmSync as rmSync3 } from "node:fs";
11157
11158
  import { networkInterfaces } from "node:os";
11158
11159
  import path6 from "node:path";
11159
11160
  import { createInterface as createInterface2 } from "node:readline/promises";
11160
11161
 
11161
11162
  // src/setup/binary.ts
11162
11163
  import { spawnSync as spawnSync3 } from "node:child_process";
11163
- import { existsSync as existsSync3, mkdirSync, readdirSync as readdirSync2, readFileSync as readFileSync3, rmSync, statSync, writeFileSync } from "node:fs";
11164
+ import { existsSync as existsSync3, mkdirSync, readdirSync as readdirSync2, readFileSync as readFileSync3, rmdirSync, rmSync, statSync, writeFileSync } from "node:fs";
11164
11165
  import path4 from "node:path";
11165
11166
  async function installBinaryRuntime() {
11166
11167
  const binary = process.execPath;
@@ -11200,17 +11201,28 @@ function addToPath() {
11200
11201
  if ((process.env.PATH ?? "").split(path4.delimiter).some((entry) => path4.resolve(entry) === dir))
11201
11202
  return;
11202
11203
  if (process.platform === "win32") {
11203
- const script = `$p=[Environment]::GetEnvironmentVariable('Path','User'); if (-not ($p -split ';' -contains '${dir}')) { [Environment]::SetEnvironmentVariable('Path', ($(if ($p) { "$p;" } else { '' }) + '${dir}'), 'User') }`;
11204
- const done = spawnSync3("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], { stdio: "ignore" });
11205
- return done.status === 0 ? "Windows user PATH" : undefined;
11204
+ return editWindowsPath(dir, "add") ? "Windows user PATH" : undefined;
11206
11205
  }
11207
- const { candidates, line } = shellPath(dir);
11206
+ const { candidates, line, legacyLine } = shellPath(dir);
11208
11207
  const file = candidates.find((candidate) => existsSync3(candidate)) ?? candidates[0];
11209
11208
  try {
11210
11209
  const text = existsSync3(file) ? readFileSync3(file, "utf8") : "";
11211
11210
  if (text.split(`
11212
11211
  `).includes(line))
11213
11212
  return;
11213
+ if (text.includes(`
11214
+ # browse
11215
+ ${legacyLine}
11216
+ `)) {
11217
+ writeFileSync(file, text.replace(`
11218
+ # browse
11219
+ ${legacyLine}
11220
+ `, () => `
11221
+ # browse
11222
+ ${line}
11223
+ `));
11224
+ return file;
11225
+ }
11214
11226
  mkdirSync(path4.dirname(file), { recursive: true });
11215
11227
  writeFileSync(file, `${text && !text.endsWith(`
11216
11228
  `) ? `
@@ -11224,40 +11236,77 @@ ${line}
11224
11236
  return;
11225
11237
  }
11226
11238
  }
11239
+ function editWindowsPath(dir, action) {
11240
+ const script = `
11241
+ $ErrorActionPreference = 'Stop'
11242
+ $key = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey('Environment', $true)
11243
+ $raw = $key.GetValue('Path', $null, 'DoNotExpandEnvironmentNames')
11244
+ $kind = if ($null -eq $raw) { 'ExpandString' } else { $key.GetValueKind('Path') }
11245
+ $parts = $raw -split ';'
11246
+ $dir = $env:BROWSE_PATH_ENTRY
11247
+ ${action === "add" ? `if ($parts -contains $dir) { exit 0 }; $new = if ($raw) { "$raw;$dir" } else { $dir }` : `if ($parts -notcontains $dir) { exit 0 }; $new = ($parts -ne $dir) -join ';'`}
11248
+ $key.SetValue('Path', $new, [Microsoft.Win32.RegistryValueKind]$kind)
11249
+ $key.Close()
11250
+ # Notify Explorer so new shells see the change, as SetEnvironmentVariable(User) did.
11251
+ Add-Type -Namespace Browse -Name Env -MemberDefinition '[DllImport("user32.dll", CharSet=CharSet.Unicode)] public static extern IntPtr SendMessageTimeout(IntPtr hwnd, uint msg, UIntPtr w, string l, uint flags, uint ms, out UIntPtr result);'
11252
+ $result = [UIntPtr]::Zero
11253
+ [void][Browse.Env]::SendMessageTimeout([IntPtr]65535, 26, [UIntPtr]::Zero, 'Environment', 2, 500, [ref]$result)
11254
+ Write-Output 'changed'`;
11255
+ const done = spawnSync3("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
11256
+ env: { ...process.env, BROWSE_PATH_ENTRY: dir },
11257
+ windowsHide: true,
11258
+ encoding: "utf8"
11259
+ });
11260
+ if (done.status !== 0)
11261
+ log2(`! Couldn't ${action === "add" ? "add browse to" : "remove browse from"} your Windows user PATH: ${dir}`);
11262
+ return done.status === 0 && done.stdout.trim() === "changed";
11263
+ }
11227
11264
  function shellPath(dir) {
11228
11265
  const shell = path4.basename(process.env.SHELL ?? "sh");
11229
11266
  const zdot = process.env.ZDOTDIR ?? home;
11230
11267
  const candidates = shell === "fish" ? [path4.join(configRoot, "fish", "config.fish")] : shell === "zsh" ? [path4.join(zdot, ".zshrc"), path4.join(zdot, ".zshenv"), path4.join(configRoot, "zsh", ".zshrc")] : shell === "bash" ? [path4.join(home, ".bashrc"), path4.join(home, ".bash_profile"), path4.join(home, ".profile")] : [path4.join(home, ".profile")];
11231
- return { candidates, line: shell === "fish" ? `fish_add_path ${dir}` : `export PATH=${dir}:$PATH` };
11268
+ const fish = shell === "fish";
11269
+ const quoted = `'${(fish ? dir.replaceAll("\\", "\\\\") : dir).replaceAll("'", "'\\''")}'`;
11270
+ return { candidates, line: fish ? `fish_add_path ${quoted}` : `export PATH=${quoted}:"$PATH"`, legacyLine: fish ? `fish_add_path ${dir}` : `export PATH=${dir}:$PATH` };
11232
11271
  }
11233
11272
  function removeBinaryInstall(binary) {
11234
11273
  const dir = path4.dirname(binary);
11235
11274
  if (process.platform === "win32") {
11236
- const script = `$p=[Environment]::GetEnvironmentVariable('Path','User'); if ($p) { [Environment]::SetEnvironmentVariable('Path', (($p -split ';' | Where-Object { $_ -and $_ -ne '${dir}' }) -join ';'), 'User') }`;
11237
- spawnSync3("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], { stdio: "ignore" });
11275
+ editWindowsPath(dir, "remove");
11238
11276
  } else {
11239
- const { candidates, line } = shellPath(dir);
11277
+ const { candidates, line, legacyLine } = shellPath(dir);
11240
11278
  for (const file of candidates) {
11241
11279
  const text = readFileOr(file, "");
11242
- const block = `
11280
+ for (const entry of [line, legacyLine]) {
11281
+ const block = `
11243
11282
  # browse
11244
- ${line}
11283
+ ${entry}
11245
11284
  `;
11246
- if (text.includes(block))
11247
- writeFileSync(file, text.replace(`
11285
+ if (text.includes(block)) {
11286
+ writeFileSync(file, text.replace(`
11248
11287
  ${block}`, `
11249
11288
  `).replace(block, `
11250
11289
  `));
11290
+ break;
11291
+ }
11292
+ }
11251
11293
  }
11252
11294
  }
11253
- try {
11254
- rmSync(binary, { force: true });
11255
- if (readdirSync2(dir).length === 0)
11256
- rmSync(dir, { recursive: true, force: true });
11295
+ if (!existsSync3(dir))
11257
11296
  return;
11258
- } catch {
11259
- return binary;
11297
+ const prefix = path4.basename(binary) + ".old-";
11298
+ const stale = process.platform !== "win32" ? [] : readdirSync2(dir).filter((name) => name.startsWith(prefix) && /^(?:[a-f\d]{8}|\d{13})$/i.test(name.slice(prefix.length)));
11299
+ const left = [];
11300
+ for (const file of [binary, ...stale.map((name) => path4.join(dir, name))]) {
11301
+ try {
11302
+ rmSync(file, { force: true });
11303
+ } catch {
11304
+ left.push(file);
11305
+ }
11260
11306
  }
11307
+ if (readdirSync2(dir).length === 0)
11308
+ rmdirSync(dir);
11309
+ return left.length ? left.join(", ") : undefined;
11261
11310
  }
11262
11311
 
11263
11312
  // src/setup/guidance.ts
@@ -11684,8 +11733,64 @@ async function confirmSecretRemoval(args) {
11684
11733
  if (!/^y(es)?$/i.test(answer.trim()))
11685
11734
  fail("Uninstall cancelled; nothing was removed.");
11686
11735
  }
11736
+ async function stopInstalledRelay() {
11737
+ const base = relayBase();
11738
+ const audit = path6.join(files.dir, "relays", new URL(base).port, "lifecycle.jsonl");
11739
+ if (!existsSync5(audit))
11740
+ return;
11741
+ const probe = async () => {
11742
+ try {
11743
+ const response = await fetch(`${base}/version`, { redirect: "error", signal: AbortSignal.timeout(2000) });
11744
+ return response.ok ? await response.json() : undefined;
11745
+ } catch (error) {
11746
+ const e = error;
11747
+ if (error instanceof SyntaxError)
11748
+ return;
11749
+ if (["ECONNREFUSED", "ConnectionRefused"].includes(e.cause?.code ?? e.code ?? ""))
11750
+ return;
11751
+ throw error;
11752
+ }
11753
+ };
11754
+ const relay = await probe();
11755
+ if (!relay?.managed || !relay.instanceId)
11756
+ return;
11757
+ const ours = readFileSync5(audit, "utf8").trim().split(`
11758
+ `).some((line) => {
11759
+ const event = JSON.parse(line);
11760
+ return event._tag === "Ready" && event.instanceId === relay.instanceId;
11761
+ });
11762
+ if (!ours)
11763
+ return;
11764
+ if (relay.shutdownProtocol !== 2)
11765
+ throw new Error("Stop the legacy relay manually, then run uninstall again.");
11766
+ const response = await fetch(`${base}/shutdown`, {
11767
+ method: "POST",
11768
+ redirect: "error",
11769
+ headers: { ...relayHeaders(), "content-type": "application/json" },
11770
+ signal: AbortSignal.timeout(15000),
11771
+ body: JSON.stringify({
11772
+ instanceId: relay.instanceId,
11773
+ requestId: randomUUID(),
11774
+ reason: "explicit-restart",
11775
+ force: true,
11776
+ client: { kind: "cli", instanceId: randomUUID(), buildId: opencodeBrowserBuildId2 }
11777
+ })
11778
+ });
11779
+ if (!response.ok || !(await response.json()).stopping)
11780
+ throw new Error("The running relay refused shutdown. Stop it manually, then run uninstall again.");
11781
+ for (let n = 0;n < 100; n++) {
11782
+ const current = await probe();
11783
+ if (!current)
11784
+ return;
11785
+ if (current.instanceId !== relay.instanceId)
11786
+ throw new Error("Another relay started during uninstall; no files were removed.");
11787
+ await new Promise((resolve) => setTimeout(resolve, 50));
11788
+ }
11789
+ throw new Error("The relay is still stopping. Run uninstall again once it exits.");
11790
+ }
11687
11791
  async function uninstall(args) {
11688
11792
  await confirmSecretRemoval(args);
11793
+ await stopInstalledRelay();
11689
11794
  const host = removeLegacyHost();
11690
11795
  const settings = readJson(files.settings);
11691
11796
  const mcp = (settings?.opencodeConfigs ?? [configFile()]).flatMap((file) => [MCP_NAME, LEGACY_MCP_NAME].filter((name) => removeMcp(name, settings?.entry, file)));
@@ -11698,11 +11803,17 @@ async function uninstall(args) {
11698
11803
  }
11699
11804
  }
11700
11805
  const binary = readCurrent(layout)?.binary;
11701
- rmSync3(files.dir, { recursive: true, force: true });
11702
- log2(`✓ Removed ${files.dir}`);
11806
+ try {
11807
+ rmSync3(files.dir, { recursive: true, force: true });
11808
+ log2(`✓ Removed ${files.dir}`);
11809
+ } catch (error) {
11810
+ if (process.platform !== "win32" || !["EBUSY", "EPERM", "EACCES"].includes(error.code ?? ""))
11811
+ throw error;
11812
+ log2(`! Couldn't remove all of ${files.dir}; close running browse agents and remove the remaining files.`);
11813
+ }
11703
11814
  if (binary) {
11704
11815
  const left = removeBinaryInstall(binary);
11705
- log2(left ? `! Couldn't remove ${left} while it runs; delete it once your agents have stopped.` : `✓ Removed ${binary}`);
11816
+ log2(left ? `! Couldn't remove ${left}. After uninstall exits, close any browse agents using the file(s) and delete them.` : `✓ Removed ${binary}`);
11706
11817
  }
11707
11818
  if (host)
11708
11819
  log2("✓ Removed the native messaging host of an earlier version");
@@ -12051,7 +12162,7 @@ async function runSetup(command, args) {
12051
12162
  if (command === "set")
12052
12163
  return set(args);
12053
12164
  if (command === "rollback") {
12054
- const { runRollback } = await import("./runtime-update-t6cn08nr.mjs");
12165
+ const { runRollback } = await import("./runtime-update-sae52vzk.mjs");
12055
12166
  return runRollback(args);
12056
12167
  }
12057
12168
  }
@@ -1,9 +1,9 @@
1
- import"./main-fncfesnk.mjs";
1
+ import"./main-zvx10nrr.mjs";
2
2
  import {
3
3
  versionEntry,
4
4
  readCurrent,
5
5
  npmRuntime
6
- } from "./main-8swhctfm.mjs";
6
+ } from "./main-n3xppv8v.mjs";
7
7
 
8
8
  // src/mcp/supervisor.ts
9
9
  import { spawn } from "node:child_process";
@@ -14,7 +14,7 @@ async function runBinaryMcp(args) {
14
14
  const runtime = npmRuntime();
15
15
  if (!runtime) {
16
16
  process.env[directEnvironmentVariable] = "1";
17
- const { runCli } = await import("./cli-1bwberh6.mjs");
17
+ const { runCli } = await import("./cli-hhwgz33c.mjs");
18
18
  return runCli();
19
19
  }
20
20
  const { layout } = runtime;
@@ -4,10 +4,10 @@ import {
4
4
  updateNotice2,
5
5
  createUpdateWatcher2,
6
6
  runUpdateCommand2
7
- } from "./main-ggdb0qpg.mjs";
7
+ } from "./main-d361tmsv.mjs";
8
+ import"./main-n3xppv8v.mjs";
9
+ import"./main-zvx10nrr.mjs";
8
10
  import"./main-3gthmkzw.mjs";
9
- import"./main-8swhctfm.mjs";
10
- import"./main-fncfesnk.mjs";
11
11
  export {
12
12
  createUpdateWatcher2 as createUpdateWatcher,
13
13
  formatUpdateNotice2 as formatUpdateNotice,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  opencodeBrowserVersion2,
3
3
  opencodeBrowserBuildId2
4
- } from "./main-fncfesnk.mjs";
4
+ } from "./main-zvx10nrr.mjs";
5
5
  export {
6
6
  opencodeBrowserBuildId2 as opencodeBrowserBuildId,
7
7
  opencodeBrowserVersion2 as opencodeBrowserVersion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencode/browse",
3
- "version": "0.0.9-dev.46",
3
+ "version": "0.0.9-dev.52",
4
4
  "description": "browse: connect the extension to opencode, and drive your browser from any agent (CLI, MCP, Playwright).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,4 +0,0 @@
1
- // src/version.ts
2
- var opencodeBrowserVersion2 = "0.0.9-dev.46";
3
- var opencodeBrowserBuildId2 = "2026-11-05T00:52:24.607Z";
4
- export { opencodeBrowserVersion2, opencodeBrowserBuildId2 };