@opencode/browse 0.0.15-dev.97 → 0.0.15-dev.98

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-afz4wktv.mjs";
108
+ } from "./main-bccm3dk2.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-y22dyw2e.mjs";
121
+ } from "./main-n0qm6500.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-b3w2ntyc.mjs";
147
+ } from "./main-hz7wj5ze.mjs";
148
148
  import"./main-vgzr4689.mjs";
149
149
  import {
150
150
  updateJson2,
151
151
  formatUpdateNotice2,
152
152
  updateNotice2
153
- } from "./main-azv7pxzm.mjs";
153
+ } from "./main-z0a00g4g.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-e0wy6qvy.mjs";
161
+ } from "./main-630yypmy.mjs";
162
162
  import {
163
163
  defaultJournalBaseDir,
164
164
  readJournalEntries,
165
165
  formatJournalEntry
166
- } from "./main-8fkq5dgw.mjs";
167
- import"./main-r62eef6t.mjs";
166
+ } from "./main-sr7x6ex2.mjs";
167
+ import"./main-y2e9e5kz.mjs";
168
168
  import {
169
169
  pipeArguments,
170
170
  dual,
@@ -5313,9 +5313,9 @@ function buildDoctorChecks(options) {
5313
5313
  }] : [],
5314
5314
  ...options.extensionResult.ok && options.extensionResult.value.processFaults !== undefined ? [{
5315
5315
  id: "relay-process-faults",
5316
- label: "relay Playwright faults",
5316
+ label: "relay process faults",
5317
5317
  status: options.extensionResult.value.processFaults.suppressed > 0 ? "warn" : "ok",
5318
- message: options.extensionResult.value.processFaults.suppressed > 0 ? `${options.extensionResult.value.processFaults.suppressed} uncaught Playwright fault(s) caught and survived${options.extensionResult.value.processFaults.lastMessage ? `; last: ${options.extensionResult.value.processFaults.lastMessage}` : ""}` : "none since the relay started"
5318
+ message: options.extensionResult.value.processFaults.suppressed > 0 ? `${options.extensionResult.value.processFaults.suppressed} uncaught fault(s) caught and survived${options.extensionResult.value.processFaults.lastMessage ? `; last: ${options.extensionResult.value.processFaults.lastMessage}` : ""}` : "none since the relay started"
5319
5319
  }] : [],
5320
5320
  {
5321
5321
  id: "targets-readable",
@@ -5821,7 +5821,7 @@ var status = make("status", {
5821
5821
  }
5822
5822
  if ((extensionStatus.processFaults?.suppressed ?? 0) > 0) {
5823
5823
  const faults = extensionStatus.processFaults;
5824
- yield* log(`Warning: the relay survived ${faults.suppressed} Playwright fault(s)${faults.lastAt ? `, last at ${faults.lastAt}` : ""}${faults.lastMessage ? `: ${faults.lastMessage}` : ""}. See the relay log.`);
5824
+ yield* log(`Warning: the relay survived ${faults.suppressed} process fault(s)${faults.lastAt ? `, last at ${faults.lastAt}` : ""}${faults.lastMessage ? `: ${faults.lastMessage}` : ""}. See the relay log.`);
5825
5825
  }
5826
5826
  if (extensionStatus.protocolVersion !== undefined && extensionStatus.protocolVersion !== null) {
5827
5827
  const compatibility = extensionStatus.protocolCompatible === false ? "incompatible" : "compatible";
@@ -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-fvd77dd5.mjs"));
5870
+ const { runMcpServer } = yield* promise(() => import("./mcp-q0wgd05d.mjs"));
5871
5871
  yield* runMcpServer;
5872
5872
  })).pipe(withDescription4("Run the browse MCP server over stdio"));
5873
5873
  registerCliCommand(400, () => tabs);
@@ -5888,7 +5888,7 @@ registerCliCommand(810, ({ packageRoot }) => make("doctor", {
5888
5888
  }
5889
5889
  })).pipe(withDescription4("Diagnose the local browse install and runtime")));
5890
5890
  registerCliCommand(820, () => make("skill", {}, fn("Cli.skill")(function* () {
5891
- const { skillText } = yield* promise(() => import("./skill-text-x30agn5m.mjs"));
5891
+ const { skillText } = yield* promise(() => import("./skill-text-28va391t.mjs"));
5892
5892
  yield* log(skillText.trimEnd());
5893
5893
  })).pipe(withDescription4("Print the browse agent skill text")));
5894
5894
  registerCliCommand(900, () => mcp);
@@ -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-gm2rz6ag.mjs"), import("./helpers-j683tr91.mjs")]));
6318
+ const [{ startRelay }, { parseAdditionalExtensionOrigins }] = yield* promise(() => Promise.all([import("./relay-pg3r3re0.mjs"), import("./helpers-5bz1ykzf.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,7 +4,7 @@
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.15-dev.97";
7
+ var embeddedVersion = "0.0.15-dev.98";
8
8
  var setupCommands = new Set(["install", "uninstall", "extension", "pair", "set"]);
9
9
  var command = process.argv[2];
10
10
  var args = process.argv.slice(3);
@@ -16,29 +16,29 @@ var preCliHelp = askedForHelp && (command === "update" || command !== undefined
16
16
  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");
17
17
  if (command !== "--version" && command !== "-v" && !askedForHelp && !process.env.OPENCODE_BROWSER_HOME && [path.join(os.homedir(), ".browse"), legacyDataRoot].some((root) => fs.existsSync(root))) {
18
18
  try {
19
- const { migrateLegacy } = await import("./migrate-mbbpx6fe.mjs");
19
+ const { migrateLegacy } = await import("./migrate-tmsm0mc7.mjs");
20
20
  migrateLegacy();
21
21
  } catch {}
22
22
  }
23
23
  if (command === "--version" || command === "-v") {
24
- const opencodeBrowserVersion = embeddedVersion ?? (await import("./version-hwm41j2w.mjs")).opencodeBrowserVersion;
24
+ const opencodeBrowserVersion = embeddedVersion ?? (await import("./version-t3shmxrb.mjs")).opencodeBrowserVersion;
25
25
  process.stdout.write(`${opencodeBrowserVersion}
26
26
  `);
27
- } else if (command === "mcp" && process.env.OPENCODE_BROWSER_MCP_DIRECT !== "1" && (await import("./supervisor-e5k91ga8.mjs")).supervisesMcp()) {
28
- const { runBinaryMcp } = await import("./supervisor-e5k91ga8.mjs");
27
+ } else if (command === "mcp" && process.env.OPENCODE_BROWSER_MCP_DIRECT !== "1" && (await import("./supervisor-p0agjsxt.mjs")).supervisesMcp()) {
28
+ const { runBinaryMcp } = await import("./supervisor-p0agjsxt.mjs");
29
29
  await runBinaryMcp(process.argv.slice(3));
30
30
  } else if (invokedAs === "opencode-browser-mcp" || command === "mcp" && process.argv.length === 3) {
31
31
  const { NodeRuntime } = await import("./index-yzz55kxm.mjs");
32
- const { runMcpServer } = await import("./mcp-fvd77dd5.mjs");
32
+ const { runMcpServer } = await import("./mcp-q0wgd05d.mjs");
33
33
  runMcpServer.pipe(NodeRuntime.runMain);
34
34
  } else if (command === "self-update" || command === "runtime-switch") {
35
- const { runSelfUpdate, runRuntimeSwitch } = await import("./runtime-update-yr9prapz.mjs");
35
+ const { runSelfUpdate, runRuntimeSwitch } = await import("./runtime-update-65ffn31x.mjs");
36
36
  await (command === "self-update" ? runSelfUpdate : runRuntimeSwitch)(process.argv.slice(3));
37
37
  } else if (command === "update" && !askedForHelp) {
38
- const { runUpdateCommand } = await import("./update-mk60neam.mjs");
38
+ const { runUpdateCommand } = await import("./update-rrk7rh0w.mjs");
39
39
  await runUpdateCommand(process.argv.slice(3));
40
40
  } else if (command && setupCommands.has(command) && !askedForHelp) {
41
- const { runSetup } = await import("./setup-wq76tmbx.mjs");
41
+ const { runSetup } = await import("./setup-wkp99mwd.mjs");
42
42
  await runSetup(command, process.argv.slice(3));
43
43
  } else {
44
44
  if (preCliHelp || !command || command === "--help" || command === "-h") {
@@ -75,9 +75,9 @@ executable in ~/.local/bin (or $XDG_BIN_HOME).
75
75
  `);
76
76
  }
77
77
  if (command === "status" && !askedForHelp && !process.argv.includes("--json")) {
78
- const { printSetupStatus } = await import("./setup-wq76tmbx.mjs");
78
+ const { printSetupStatus } = await import("./setup-wkp99mwd.mjs");
79
79
  printSetupStatus();
80
80
  }
81
- const { runCli } = await import("./cli-t7r3wnv8.mjs");
81
+ const { runCli } = await import("./cli-yw23xxk6.mjs");
82
82
  runCli(preCliHelp ? ["--help"] : undefined);
83
83
  }
@@ -31,7 +31,7 @@ import {
31
31
  isRestrictedTarget2,
32
32
  isRestrictedUrl2,
33
33
  dataUrlDocument2
34
- } from "./main-b3w2ntyc.mjs";
34
+ } from "./main-hz7wj5ze.mjs";
35
35
  import"./main-vgzr4689.mjs";
36
36
  import"./main-mrew6jy8.mjs";
37
37
  export {
@@ -12,7 +12,7 @@ import {
12
12
  parseTargetSelection2,
13
13
  getObject2,
14
14
  getString2
15
- } from "./main-b3w2ntyc.mjs";
15
+ } from "./main-hz7wj5ze.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-y22dyw2e.mjs";
134
+ } from "./main-n0qm6500.mjs";
135
135
 
136
136
  // node_modules/effect/dist/Semaphore.js
137
137
  var makeUnsafe = (permits) => new SemaphoreImpl(permits);
@@ -0,0 +1,4 @@
1
+ // src/version.ts
2
+ var opencodeBrowserVersion2 = "0.0.15-dev.98";
3
+ var opencodeBrowserBuildId2 = "2026-11-07T10:05:51.506Z";
4
+ export { opencodeBrowserVersion2, opencodeBrowserBuildId2 };
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  dataRoot,
6
6
  stateRoot
7
- } from "./main-y22dyw2e.mjs";
7
+ } from "./main-n0qm6500.mjs";
8
8
 
9
9
  // src/relay/browser-pairing.ts
10
10
  import crypto from "node:crypto";
@@ -107,7 +107,7 @@ import {
107
107
  } from "./main-csnx585b.mjs";
108
108
  import {
109
109
  opencodeBrowserBuildId2
110
- } from "./main-afz4wktv.mjs";
110
+ } from "./main-bccm3dk2.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-y22dyw2e.mjs";
119
+ } from "./main-n0qm6500.mjs";
120
120
  import {
121
121
  relayAuthorization
122
- } from "./main-r62eef6t.mjs";
122
+ } from "./main-y2e9e5kz.mjs";
123
123
  import {
124
124
  dual,
125
125
  memoize,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  opencodeBrowserVersion2
3
- } from "./main-afz4wktv.mjs";
3
+ } from "./main-bccm3dk2.mjs";
4
4
 
5
5
  // src/paths.ts
6
6
  import fs from "node:fs";
@@ -63,7 +63,7 @@ function cliInstall() {
63
63
  return { kind: "binary", binary: installedBinary() ?? process.execPath, pathEnv: process.env.PATH };
64
64
  if (fromCheckout())
65
65
  return { kind: "checkout", bundle: path.join(packageRoot(), "dist", "cli.mjs") };
66
- return { kind: "npm", version: "0.0.15-dev.97", npx: /[/\\]_npx[/\\]/.test(process.argv[1] ?? "") };
66
+ return { kind: "npm", version: "0.0.15-dev.98", npx: /[/\\]_npx[/\\]/.test(process.argv[1] ?? "") };
67
67
  }
68
68
  function cliPrefix(install = cliInstall()) {
69
69
  if (install.kind === "binary") {
@@ -85,7 +85,7 @@ function storeConfig(env = process.env, baked = { id: "mfnicocicmmlkpjnaffgihfjh
85
85
  return id ? { id } : {};
86
86
  }
87
87
  var RELEASE_SERVICE = "https://anoma.ly/release";
88
- function devExtension(baked = { file: "browse-extension-0.0.15-dev.97.zip", sha256: "d0de60bf022a22de12a2b466a3a5d9d9d617bce9abeed60d8574c7e0a5ef1396", size: 182646 }) {
88
+ function devExtension(baked = { file: "browse-extension-0.0.15-dev.98.zip", sha256: "863b4905d0d025246f5005db04d215760d4aa3c08250fda8bb8e66ab27203082", size: 182645 }) {
89
89
  return baked && /^[0-9a-f]{64}$/.test(baked.sha256) && /^[\w.-]+\.zip$/.test(baked.file) ? baked : undefined;
90
90
  }
91
91
  var devExtensionUrl = (extension, env = process.env) => `${(env.OPENCODE_BROWSER_RELEASE_SERVICE || RELEASE_SERVICE).replace(/\/+$/, "")}/browse/files/${extension.sha256}/${extension.file}`;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  opencodeBrowserVersion2
3
- } from "./main-afz4wktv.mjs";
3
+ } from "./main-bccm3dk2.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-y22dyw2e.mjs";
21
+ } from "./main-n0qm6500.mjs";
22
22
  import {
23
23
  formatPairingCode
24
- } from "./main-7n3prtjk.mjs";
24
+ } from "./main-br0znez7.mjs";
25
25
  import {
26
26
  unpackedExtensionId
27
27
  } from "./main-mrew6jy8.mjs";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./main-vgzr4689.mjs";
4
4
  import {
5
5
  isValidSessionId2
6
- } from "./main-b3w2ntyc.mjs";
6
+ } from "./main-hz7wj5ze.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-y22dyw2e.mjs";
20
+ } from "./main-n0qm6500.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-7n3prtjk.mjs";
8
+ } from "./main-br0znez7.mjs";
9
9
  import {
10
10
  configRoot2,
11
11
  cacheRoot,
12
12
  devExtensionUrl,
13
13
  devExtensionFolder
14
- } from "./main-y22dyw2e.mjs";
14
+ } from "./main-n0qm6500.mjs";
15
15
 
16
16
  // src/setup/dev-extension.ts
17
17
  import { createHash } from "node:crypto";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./main-vgzr4689.mjs";
4
4
  import {
5
5
  dataRoot
6
- } from "./main-y22dyw2e.mjs";
6
+ } from "./main-n0qm6500.mjs";
7
7
 
8
8
  // src/relay/secrets.ts
9
9
  import crypto from "node:crypto";
@@ -6,7 +6,7 @@ import {
6
6
  installedRuntime2,
7
7
  autoUpdateStatus,
8
8
  updateAvailable
9
- } from "./main-y22dyw2e.mjs";
9
+ } from "./main-n0qm6500.mjs";
10
10
  import {
11
11
  unpackedReloadAdvice
12
12
  } from "./main-mrew6jy8.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 { runInstalledUpdate } = await import("./runtime-update-yr9prapz.mjs");
318
+ const { runInstalledUpdate } = await import("./runtime-update-65ffn31x.mjs");
319
319
  if (await runInstalledUpdate(args))
320
320
  return;
321
321
  if (compiledBinary()) {
@@ -256,11 +256,11 @@ import {
256
256
  } from "./main-csnx585b.mjs";
257
257
  import {
258
258
  opencodeBrowserVersion2
259
- } from "./main-afz4wktv.mjs";
259
+ } from "./main-bccm3dk2.mjs";
260
260
  import {
261
261
  cliCommand,
262
262
  autoUpdateStatus
263
- } from "./main-y22dyw2e.mjs";
263
+ } from "./main-n0qm6500.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-b3w2ntyc.mjs";
283
+ } from "./main-hz7wj5ze.mjs";
284
284
  import"./main-vgzr4689.mjs";
285
285
  import {
286
286
  updateJson2,
287
287
  createUpdateWatcher2
288
- } from "./main-azv7pxzm.mjs";
288
+ } from "./main-z0a00g4g.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-e0wy6qvy.mjs";
372
+ } from "./main-630yypmy.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-r62eef6t.mjs";
387
+ import"./main-y2e9e5kz.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-d0vkm24t.mjs";
10
- import"./main-afz4wktv.mjs";
9
+ } from "./main-nf4p3mes.mjs";
10
+ import"./main-bccm3dk2.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-y22dyw2e.mjs";
18
+ } from "./main-n0qm6500.mjs";
19
19
  import"./main-vgzr4689.mjs";
20
- import"./main-7n3prtjk.mjs";
20
+ import"./main-br0znez7.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-afz4wktv.mjs";
4
+ } from "./main-bccm3dk2.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-y22dyw2e.mjs";
23
+ } from "./main-n0qm6500.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-b3w2ntyc.mjs";
98
+ } from "./main-hz7wj5ze.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-7n3prtjk.mjs";
116
+ } from "./main-br0znez7.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-e0wy6qvy.mjs";
144
+ } from "./main-630yypmy.mjs";
145
145
  import {
146
146
  defaultJournalBaseDir,
147
147
  makeJournalEntry,
148
148
  appendJournalEntry,
149
149
  startJournalRetention
150
- } from "./main-8fkq5dgw.mjs";
150
+ } from "./main-sr7x6ex2.mjs";
151
151
  import {
152
152
  createUpdateWatcher2
153
- } from "./main-azv7pxzm.mjs";
153
+ } from "./main-z0a00g4g.mjs";
154
154
  import {
155
155
  relayHostname,
156
156
  isLocalPeer,
157
157
  installedDevExtension,
158
158
  syncDevExtension
159
- } from "./main-fed0em2f.mjs";
159
+ } from "./main-x58yhgrq.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-r62eef6t.mjs";
271
+ } from "./main-y2e9e5kz.mjs";
272
272
  import {
273
273
  isString,
274
274
  isNumber,
@@ -2288,7 +2288,7 @@ function challengeWarning(outcome) {
2288
2288
  // src/execute-realm.ts
2289
2289
  import buffer2 from "node:buffer";
2290
2290
  import crypto5 from "node:crypto";
2291
- import util3 from "node:util";
2291
+ import util4 from "node:util";
2292
2292
  import vm3 from "node:vm";
2293
2293
 
2294
2294
  // src/execute-realm/file-roots.ts
@@ -2668,12 +2668,68 @@ import inspector from "node:inspector";
2668
2668
  import module from "node:module";
2669
2669
  import net from "node:net";
2670
2670
  import os3 from "node:os";
2671
+ import { AsyncLocalStorage } from "node:async_hooks";
2671
2672
  import tls from "node:tls";
2672
- import util2 from "node:util";
2673
+ import util3 from "node:util";
2673
2674
  import v8 from "node:v8";
2674
2675
  import vm from "node:vm";
2675
2676
  import workerThreads from "node:worker_threads";
2676
2677
  import * as acorn from "acorn";
2678
+
2679
+ // src/execute-realm/rejection-text.ts
2680
+ import util2 from "node:util";
2681
+ var placeholder = "reason not shown";
2682
+ var nativeStackGetter = Object.getOwnPropertyDescriptor(new Error, "stack")?.get;
2683
+ function safeErrorMessage(value, maxLength = 300) {
2684
+ if (typeof value === "string")
2685
+ return value.length > 0 ? value.slice(0, maxLength) : placeholder;
2686
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint" || typeof value === "symbol") {
2687
+ return String(value).slice(0, maxLength);
2688
+ }
2689
+ if (!isSafeNativeError(value))
2690
+ return placeholder;
2691
+ const message = ownDataProperty(value, "message");
2692
+ return typeof message === "string" && message.length > 0 ? message.slice(0, maxLength) : placeholder;
2693
+ }
2694
+ function safeErrorStack(value) {
2695
+ if (!isSafeHostError(value))
2696
+ return;
2697
+ const descriptor = Object.getOwnPropertyDescriptor(value, "stack");
2698
+ if (descriptor === undefined)
2699
+ return;
2700
+ if ("value" in descriptor)
2701
+ return typeof descriptor.value === "string" ? descriptor.value : undefined;
2702
+ if (descriptor.get === undefined || descriptor.get !== nativeStackGetter)
2703
+ return;
2704
+ try {
2705
+ const stack = descriptor.get.call(value);
2706
+ return typeof stack === "string" ? stack : undefined;
2707
+ } catch {
2708
+ return;
2709
+ }
2710
+ }
2711
+ function isSafeNativeError(value) {
2712
+ return typeof value === "object" && value !== null && !util2.types.isProxy(value) && util2.types.isNativeError(value);
2713
+ }
2714
+ function isSafeHostError(value) {
2715
+ if (!isSafeNativeError(value))
2716
+ return false;
2717
+ let prototype = Object.getPrototypeOf(value);
2718
+ for (let depth = 0;prototype !== null && depth < 32; depth += 1) {
2719
+ if (prototype === Error.prototype)
2720
+ return true;
2721
+ if (util2.types.isProxy(prototype))
2722
+ return false;
2723
+ prototype = Object.getPrototypeOf(prototype);
2724
+ }
2725
+ return false;
2726
+ }
2727
+ function ownDataProperty(value, key) {
2728
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
2729
+ return descriptor !== undefined && "value" in descriptor ? descriptor.value : undefined;
2730
+ }
2731
+
2732
+ // src/execute-realm/membrane-policy.ts
2677
2733
  var deniedHostValues = new Map([
2678
2734
  [process, "process"],
2679
2735
  [globalThis, "the relay's global object"],
@@ -2697,9 +2753,9 @@ var deniedHostValues = new Map([
2697
2753
  [workerThreads, "worker_threads"],
2698
2754
  [globalThis.fetch, "Node fetch"],
2699
2755
  [eval, "eval"],
2700
- [util2.inspect, "host object inspection"],
2701
- [util2.format, "host object formatting"],
2702
- [util2.formatWithOptions, "host object formatting"],
2756
+ [util3.inspect, "host object inspection"],
2757
+ [util3.format, "host object formatting"],
2758
+ [util3.formatWithOptions, "host object formatting"],
2703
2759
  [crypto4.setEngine, "loading native crypto engines"],
2704
2760
  [events2.setMaxListeners, "changing shared event-emitter defaults or prototypes"],
2705
2761
  ...[crypto4.pbkdf2Sync, crypto4.scryptSync, crypto4.hkdfSync, crypto4.generateKeyPairSync, crypto4.generateKeySync, crypto4.generatePrimeSync, crypto4.checkPrimeSync].map((fn) => [fn, `crypto.${fn.name} (blocks the relay; use the async version)`])
@@ -2805,56 +2861,111 @@ function isObjectLike(value) {
2805
2861
  return typeof value === "object" && value !== null || typeof value === "function";
2806
2862
  }
2807
2863
  var isHiddenKey = (key) => typeof key === "string" && key.startsWith("_");
2808
- var activeRealm;
2809
- var promiseRealms = new WeakMap;
2864
+ var activeOwner;
2865
+ var rejectionContext = new AsyncLocalStorage;
2866
+ var promiseOwners = new WeakMap;
2810
2867
  var stopPromiseHook;
2811
- function trackPromisesOf(realm) {
2812
- const previous = activeRealm;
2813
- activeRealm = realm;
2814
- if (process.versions.bun) {
2815
- const entered = { realm, at: Date.now() };
2816
- lastRealm = entered;
2817
- return () => {
2818
- activeRealm = previous;
2819
- entered.at = Date.now();
2820
- };
2821
- }
2822
- if (!stopPromiseHook) {
2823
- stopPromiseHook = v8.promiseHooks.createHook({ init(promise) {
2824
- if (activeRealm)
2825
- promiseRealms.set(promise, activeRealm);
2868
+ var promiseHookUsers = 0;
2869
+ function enterRejectionOwner(owner) {
2870
+ const previous = activeOwner;
2871
+ activeOwner = owner;
2872
+ return () => {
2873
+ activeOwner = previous;
2874
+ };
2875
+ }
2876
+ function runWithRejectionOwner(owner, run) {
2877
+ return rejectionContext.run(owner, () => {
2878
+ const restore = enterRejectionOwner(owner);
2879
+ try {
2880
+ return run();
2881
+ } finally {
2882
+ restore();
2883
+ }
2884
+ });
2885
+ }
2886
+ function retainPromiseHook() {
2887
+ promiseHookUsers += 1;
2888
+ if (promiseHookUsers === 1) {
2889
+ stopPromiseHook = v8.promiseHooks.createHook({ init(promise, parent) {
2890
+ const owner = activeOwner ?? rejectionContext.getStore() ?? (parent ? promiseOwners.get(parent) : undefined);
2891
+ if (owner)
2892
+ promiseOwners.set(promise, owner);
2826
2893
  } });
2827
2894
  }
2895
+ let released = false;
2828
2896
  return () => {
2829
- activeRealm = previous;
2830
- if (!activeRealm && stopPromiseHook) {
2897
+ if (released)
2898
+ return;
2899
+ released = true;
2900
+ promiseHookUsers -= 1;
2901
+ if (promiseHookUsers === 0 && stopPromiseHook) {
2831
2902
  stopPromiseHook();
2832
2903
  stopPromiseHook = undefined;
2833
2904
  }
2834
2905
  };
2835
2906
  }
2907
+ function trackPromisesOf(owner) {
2908
+ const restoreOwner = enterRejectionOwner(owner);
2909
+ if (process.versions.bun) {
2910
+ const entered = { owner, at: Date.now() };
2911
+ lastOwner = entered;
2912
+ return () => {
2913
+ restoreOwner();
2914
+ entered.at = Date.now();
2915
+ };
2916
+ }
2917
+ const releaseHook = retainPromiseHook();
2918
+ return () => {
2919
+ restoreOwner();
2920
+ releaseHook();
2921
+ };
2922
+ }
2836
2923
  var realmsByPromisePrototype = new WeakMap;
2837
- var lastRealm;
2838
- var lastRealmWindowMs = 1000;
2924
+ var lastOwner;
2925
+ var lastOwnerWindowMs = 1000;
2839
2926
  function registerRealmPromisePrototype(prototype, realm) {
2840
2927
  if (process.versions.bun)
2841
2928
  realmsByPromisePrototype.set(prototype, realm);
2842
2929
  }
2843
- function bunRejectionRealm(promise) {
2844
- const byPrototype = realmsByPromisePrototype.get(Object.getPrototypeOf(promise));
2845
- if (byPrototype)
2846
- return byPrototype;
2847
- if (!lastRealm || lastRealm.realm.isStopped)
2930
+ function bunRejectionOwner(promise) {
2931
+ if (!lastOwner || lastOwner.owner.isStopped)
2848
2932
  return;
2849
- return activeRealm === lastRealm.realm || Date.now() - lastRealm.at <= lastRealmWindowMs ? lastRealm.realm : undefined;
2933
+ return activeOwner === lastOwner.owner || Date.now() - lastOwner.at <= lastOwnerWindowMs ? lastOwner.owner : undefined;
2850
2934
  }
2851
- function handleExecuteRealmRejection(promise) {
2852
- const realm = promiseRealms.get(promise) ?? (process.versions.bun ? bunRejectionRealm(promise) : undefined);
2853
- if (!realm)
2935
+ function handleExecuteRealmRejection(promise, reason) {
2936
+ const byPrototype = process.versions.bun ? realmsByPromisePrototype.get(Object.getPrototypeOf(promise)) : undefined;
2937
+ const exact = promiseOwners.get(promise) ?? byPrototype;
2938
+ const owner = exact ?? (process.versions.bun ? bunRejectionOwner(promise) : undefined);
2939
+ if (!owner)
2854
2940
  return false;
2855
- realm.dispose(new Error("Unhandled execute rejection; JavaScript state will reset before the next execute"));
2941
+ owner.handleUnhandledRejection(reason, exact !== undefined);
2856
2942
  return true;
2857
2943
  }
2944
+ function unhandledExecuteRejectionWarning(detail, certain) {
2945
+ if (!certain) {
2946
+ return "Execute code may have started a promise that rejected and was never awaited. The rejection was contained and the relay kept running; await the promise or handle its rejection to return the error from execute.";
2947
+ }
2948
+ return `Execute code started a promise that rejected and was never awaited: ${detail}. The rejection was contained and the relay kept running; await the promise or handle its rejection to return the error from execute.`;
2949
+ }
2950
+ function handleRealmUnhandledRejection(realm, cause, certain, warn, pending) {
2951
+ if (realm.isStopped)
2952
+ return;
2953
+ const description = certain ? rejectionDescription(realm, cause) : "a rejected promise";
2954
+ if (!pending) {
2955
+ try {
2956
+ warn?.(unhandledExecuteRejectionWarning(description, certain));
2957
+ } catch {}
2958
+ }
2959
+ realm.dispose(new Error(`Unhandled execute rejection: ${description}; JavaScript state will reset before the next execute`));
2960
+ }
2961
+ function rejectionDescription(realm, cause) {
2962
+ if (isObjectLike(cause)) {
2963
+ const host = realm.hostValueForSandboxValue(cause);
2964
+ if (host !== undefined)
2965
+ return safeErrorMessage(host);
2966
+ }
2967
+ return safeErrorMessage(cause);
2968
+ }
2858
2969
  var thrownByRealm = new WeakMap;
2859
2970
  function tagThrownByRealm(value, realm) {
2860
2971
  if (!thrownByRealm.has(value))
@@ -2987,11 +3098,13 @@ class ExecuteRealm {
2987
3098
  entryScript;
2988
3099
  global;
2989
3100
  onHostCall;
3101
+ onUnhandledRejection;
2990
3102
  refuseDynamicImport = () => {
2991
3103
  throw new this.SandboxError("import() is not available in execute code");
2992
3104
  };
2993
3105
  constructor(options = {}) {
2994
3106
  this.onHostCall = options.onHostCall;
3107
+ this.onUnhandledRejection = options.onUnhandledRejection;
2995
3108
  const importModuleDynamically = this.refuseDynamicImport;
2996
3109
  const dontContextify = vm3.constants?.DONT_CONTEXTIFY;
2997
3110
  this.context = vm3.createContext(dontContextify ?? Object.create(null), {
@@ -3036,6 +3149,12 @@ class ExecuteRealm {
3036
3149
  get isStopped() {
3037
3150
  return this.stopped !== undefined;
3038
3151
  }
3152
+ handleUnhandledRejection(cause, certain) {
3153
+ handleRealmUnhandledRejection(this, cause, certain, this.onUnhandledRejection, this.pendingRuns.size > 0);
3154
+ }
3155
+ hostValueForSandboxValue(value) {
3156
+ return isObjectLike(value) ? this.hostBySandboxProxy.get(value) : undefined;
3157
+ }
3039
3158
  enter(entry) {
3040
3159
  if (this.stopped)
3041
3160
  throw this.stopped;
@@ -3154,7 +3273,7 @@ class ExecuteRealm {
3154
3273
  throw this.sandboxError(`${denied} is not available in execute code. Set ${allowNodeEnvironmentVariable}=1 for full Node access.`);
3155
3274
  if (this.isSandboxNative(value))
3156
3275
  return value;
3157
- if (util3.types.isPromise(value))
3276
+ if (util4.types.isPromise(value))
3158
3277
  return this.toSandboxPromise(value);
3159
3278
  if (Buffer.isBuffer(value)) {
3160
3279
  const copy = Buffer.alloc(value.length);
@@ -3163,11 +3282,11 @@ class ExecuteRealm {
3163
3282
  this.sandboxProxyByHost.set(value, proxy);
3164
3283
  return proxy;
3165
3284
  }
3166
- if (util3.types.isArrayBuffer(value)) {
3285
+ if (util4.types.isArrayBuffer(value)) {
3167
3286
  const SandboxUint8Array = this.sandboxIntrinsics.Uint8Array;
3168
3287
  return new SandboxUint8Array(new Uint8Array(value)).buffer;
3169
3288
  }
3170
- if (util3.types.isTypedArray(value) && !Buffer.isBuffer(value)) {
3289
+ if (util4.types.isTypedArray(value) && !Buffer.isBuffer(value)) {
3171
3290
  const name = Object.prototype.toString.call(value).slice(8, -1);
3172
3291
  const Constructor = this.sandboxIntrinsics[name] ?? this.sandboxIntrinsics.Uint8Array;
3173
3292
  return new Constructor(value);
@@ -3177,7 +3296,7 @@ class ExecuteRealm {
3177
3296
  throw this.sandboxError(deniedClass);
3178
3297
  if (!this.forceProxy.has(value) && typeof value === "object") {
3179
3298
  const prototype = Reflect.getPrototypeOf(value);
3180
- if (Array.isArray(value) && prototype === Array.prototype || util3.types.isArgumentsObject(value)) {
3299
+ if (Array.isArray(value) && prototype === Array.prototype || util4.types.isArgumentsObject(value)) {
3181
3300
  const output = [];
3182
3301
  Reflect.setPrototypeOf(output, this.sandboxArrayPrototype);
3183
3302
  seen.set(value, output);
@@ -3186,7 +3305,7 @@ class ExecuteRealm {
3186
3305
  output[index] = this.toSandbox(array[index], seen);
3187
3306
  return output;
3188
3307
  }
3189
- if ((prototype === Object.prototype || prototype === null) && !Object.hasOwn(value, "constructor") && !util3.types.isProxy(value)) {
3308
+ if ((prototype === Object.prototype || prototype === null) && !Object.hasOwn(value, "constructor") && !util4.types.isProxy(value)) {
3190
3309
  const output = Object.create(prototype === null ? null : this.sandboxObjectPrototype);
3191
3310
  seen.set(value, output);
3192
3311
  for (const key of Object.keys(value)) {
@@ -3438,16 +3557,16 @@ class ExecuteRealm {
3438
3557
  }
3439
3558
  }
3440
3559
  copyToHost(value, seen) {
3441
- if (util3.types.isPromise(value))
3560
+ if (util4.types.isPromise(value))
3442
3561
  return this.toHostPromise(value);
3443
- if (util3.types.isDate(value))
3562
+ if (util4.types.isDate(value))
3444
3563
  return new Date(Date.prototype.getTime.call(value));
3445
- if (util3.types.isRegExp(value)) {
3564
+ if (util4.types.isRegExp(value)) {
3446
3565
  const source = Reflect.get(value, "source");
3447
3566
  const flags = Reflect.get(value, "flags");
3448
3567
  return new RegExp(String(source), String(flags));
3449
3568
  }
3450
- if (util3.types.isNativeError(value) || value instanceof this.SandboxError) {
3569
+ if (util4.types.isNativeError(value) || value instanceof this.SandboxError) {
3451
3570
  const name = String(Reflect.get(value, "name") ?? "Error");
3452
3571
  const output = new Error(String(Reflect.get(value, "message") ?? ""));
3453
3572
  seen.set(value, output);
@@ -3465,26 +3584,26 @@ class ExecuteRealm {
3465
3584
  Object.defineProperty(output, "cause", { value: this.toHost(cause, seen), configurable: true, writable: true });
3466
3585
  return output;
3467
3586
  }
3468
- if (util3.types.isMap(value)) {
3587
+ if (util4.types.isMap(value)) {
3469
3588
  const output = new Map;
3470
3589
  seen.set(value, output);
3471
3590
  Map.prototype.forEach.call(value, (item, key) => output.set(this.toHost(key, seen), this.toHost(item, seen)));
3472
3591
  return output;
3473
3592
  }
3474
- if (util3.types.isSet(value)) {
3593
+ if (util4.types.isSet(value)) {
3475
3594
  const output = new Set;
3476
3595
  seen.set(value, output);
3477
3596
  Set.prototype.forEach.call(value, (item) => output.add(this.toHost(item, seen)));
3478
3597
  return output;
3479
3598
  }
3480
- if (util3.types.isArrayBuffer(value))
3599
+ if (util4.types.isArrayBuffer(value))
3481
3600
  return new Uint8Array(new Uint8Array(value)).buffer;
3482
- if (util3.types.isTypedArray(value)) {
3601
+ if (util4.types.isTypedArray(value)) {
3483
3602
  const name = Object.prototype.toString.call(value).slice(8, -1);
3484
3603
  const Constructor = globalThis[name] ?? Uint8Array;
3485
3604
  return new Constructor(value);
3486
3605
  }
3487
- if (Array.isArray(value) || util3.types.isArgumentsObject(value)) {
3606
+ if (Array.isArray(value) || util4.types.isArgumentsObject(value)) {
3488
3607
  const output = [];
3489
3608
  seen.set(value, output);
3490
3609
  const array = value;
@@ -3615,6 +3734,45 @@ import https2 from "node:https";
3615
3734
  import os4 from "node:os";
3616
3735
  import * as acorn2 from "acorn";
3617
3736
 
3737
+ // src/execute/rejection-scope.ts
3738
+ var defaultRejectionOwnershipExpiryMs = 10 * 60000;
3739
+
3740
+ class ExecuteRejectionScope {
3741
+ releaseHook;
3742
+ expiry;
3743
+ expiryMs;
3744
+ onRejection;
3745
+ constructor(options = {}) {
3746
+ this.onRejection = options.onRejection;
3747
+ this.expiryMs = options.expiryMs ?? defaultRejectionOwnershipExpiryMs;
3748
+ }
3749
+ begin() {
3750
+ if (process.versions.bun || this.releaseHook)
3751
+ return;
3752
+ this.releaseHook = retainPromiseHook();
3753
+ this.expiry = setTimeout(() => this.end(), this.expiryMs);
3754
+ this.expiry.unref?.();
3755
+ }
3756
+ invoke(run) {
3757
+ if (process.versions.bun)
3758
+ return run();
3759
+ return runWithRejectionOwner(this, run);
3760
+ }
3761
+ end() {
3762
+ if (this.expiry !== undefined) {
3763
+ clearTimeout(this.expiry);
3764
+ this.expiry = undefined;
3765
+ }
3766
+ this.releaseHook?.();
3767
+ this.releaseHook = undefined;
3768
+ }
3769
+ handleUnhandledRejection(cause, certain) {
3770
+ try {
3771
+ this.onRejection?.(unhandledExecuteRejectionWarning(safeErrorMessage(cause), certain));
3772
+ } catch {}
3773
+ }
3774
+ }
3775
+
3618
3776
  // src/execute/console.ts
3619
3777
  var sessions = new WeakMap;
3620
3778
  var listeners = new WeakMap;
@@ -3675,7 +3833,7 @@ function describe(arg) {
3675
3833
  }
3676
3834
 
3677
3835
  // src/execute/log-capture.ts
3678
- import util4 from "node:util";
3836
+ import util5 from "node:util";
3679
3837
  var maxCapturedPageLogs = 50;
3680
3838
  var maxCapturedScriptLogs = 100;
3681
3839
  function createExecuteLogCapture(limits = {}) {
@@ -3864,7 +4022,7 @@ function formatLogValue(value) {
3864
4022
  if (isString(value)) {
3865
4023
  return value;
3866
4024
  }
3867
- return util4.inspect(value, { depth: 4, colors: false, maxArrayLength: 100, maxStringLength: 1000 });
4025
+ return util5.inspect(value, { depth: 4, colors: false, maxArrayLength: 100, maxStringLength: 1000 });
3868
4026
  }
3869
4027
 
3870
4028
  // src/execute/target-selection.ts
@@ -4369,7 +4527,7 @@ var sandboxGlobalKeys = [
4369
4527
  "pageConsole",
4370
4528
  "secrets"
4371
4529
  ];
4372
- async function runUserCode({ code, globals, realm }) {
4530
+ async function runUserCode({ code, globals, realm, onUnhandledRejection }) {
4373
4531
  const logCapture = createExecuteLogCapture();
4374
4532
  const navigations = [];
4375
4533
  const onConsole = (message) => {
@@ -4432,8 +4590,14 @@ ${wrapCodeWithModuleAliases(code, Object.keys(sandboxModules))}
4432
4590
  const AsyncFunction = async function() {}.constructor;
4433
4591
  const fn = new AsyncFunction("console", ...sandboxGlobalKeys, `${wrapCodeWithModuleAliases(code, Object.keys(nodeModules))}
4434
4592
  //# sourceURL=${executeFilename}`);
4435
- const result = await fn(...values);
4436
- return { result, ...buildResultMetadata() };
4593
+ const scope = process.versions.bun || !onUnhandledRejection ? undefined : new ExecuteRejectionScope({ onRejection: onUnhandledRejection });
4594
+ scope?.begin();
4595
+ try {
4596
+ const result = await (scope ? scope.invoke(() => fn(...values)) : fn(...values));
4597
+ return { result, ...buildResultMetadata() };
4598
+ } finally {
4599
+ scope?.end();
4600
+ }
4437
4601
  } catch (cause) {
4438
4602
  const error = cause instanceof Error ? cause : new Error("execute sandbox code", { cause });
4439
4603
  const metadata = buildResultMetadata();
@@ -4847,7 +5011,7 @@ class DefaultPageHost {
4847
5011
  }
4848
5012
 
4849
5013
  // src/execute/result-formatting.ts
4850
- import util5 from "node:util";
5014
+ import util6 from "node:util";
4851
5015
  var maxExecuteResultChars = 1e5;
4852
5016
  function boundExecuteResult(text, value, hasValue) {
4853
5017
  const valueChars = hasValue && value !== null && typeof value === "object" ? safeJsonStringify(value)?.length ?? 0 : typeof value === "string" ? value.length : 0;
@@ -4869,7 +5033,7 @@ function stringifyResult(result) {
4869
5033
  if (result === undefined) {
4870
5034
  return "undefined";
4871
5035
  }
4872
- return util5.inspect(result, { depth: 3, colors: false, maxArrayLength: 50, maxStringLength: 4000 });
5036
+ return util6.inspect(result, { depth: 3, colors: false, maxArrayLength: 50, maxStringLength: 4000 });
4873
5037
  }
4874
5038
  var maxJsonSafeDepth = 8;
4875
5039
  var maxJsonSafeBytes = 32 * 1024;
@@ -9859,7 +10023,8 @@ class ExecuteSandbox extends DefaultPageHost {
9859
10023
  return new ExecuteRealm({
9860
10024
  onHostCall: (fn, receiver, args) => {
9861
10025
  this.addWarningOnce(pageVisibleApiWarning(fn, receiver, args));
9862
- }
10026
+ },
10027
+ onUnhandledRejection: (warning) => this.addWarningOnce(warning)
9863
10028
  });
9864
10029
  }
9865
10030
  execute(code, options = {}) {
@@ -9874,7 +10039,12 @@ class ExecuteSandbox extends DefaultPageHost {
9874
10039
  for (const warning of pageVisibleApiSourceWarnings(code))
9875
10040
  this.addWarningOnce(warning);
9876
10041
  const globals = await this.getGlobals(options);
9877
- const { result, logs, logSummary, aftermath } = await runUserCode({ code, globals, ...this.realm ? { realm: this.realm } : {} }).then(async (completed) => ({ ...completed, aftermath: await this.withChallenge(globals.page, completed.aftermath, false) })).catch(async (error) => {
10042
+ const { result, logs, logSummary, aftermath } = await runUserCode({
10043
+ code,
10044
+ globals,
10045
+ ...this.realm ? { realm: this.realm } : {},
10046
+ onUnhandledRejection: (warning) => this.addWarningOnce(warning)
10047
+ }).then(async (completed) => ({ ...completed, aftermath: await this.withChallenge(globals.page, completed.aftermath, false) })).catch(async (error) => {
9878
10048
  if (!(error instanceof ExecuteCodeError) || !error.aftermath)
9879
10049
  throw error;
9880
10050
  throw new ExecuteCodeError(error.originalError, error.logs, error.logSummary, await this.withChallenge(globals.page, error.aftermath, true));
@@ -14623,26 +14793,8 @@ function replayTargetCreated(options) {
14623
14793
 
14624
14794
  // src/relay/process-guard.ts
14625
14795
  import http4 from "node:http";
14626
- var installRelayProcessGuard = acquireRelease(sync2(() => {
14627
- const onUncaughtException = (error, origin) => {
14628
- if (handleExecuteRealmException(error))
14629
- return;
14630
- handleRelayProcessFault("uncaughtException", error, { origin });
14631
- };
14632
- const onUnhandledRejection = (reason, promise) => {
14633
- if (handleExecuteRealmRejection(promise))
14634
- return;
14635
- handleRelayProcessFault("unhandledRejection", reason, { promise });
14636
- };
14637
- process.on("uncaughtException", onUncaughtException);
14638
- process.on("unhandledRejection", onUnhandledRejection);
14639
- return { onUncaughtException, onUnhandledRejection };
14640
- }), (handlers) => {
14641
- return sync2(() => {
14642
- process.off("uncaughtException", handlers.onUncaughtException);
14643
- process.off("unhandledRejection", handlers.onUnhandledRejection);
14644
- });
14645
- });
14796
+
14797
+ // src/relay/process-faults.ts
14646
14798
  var suppressedProcessFaults = { count: 0 };
14647
14799
  function relayProcessFaultSummary() {
14648
14800
  return {
@@ -14654,21 +14806,25 @@ function relayProcessFaultSummary() {
14654
14806
  function shouldSuppressRelayProcessFault(cause) {
14655
14807
  if (isPatchrightProtocolError(cause))
14656
14808
  return true;
14657
- const errorText = cause instanceof Error ? `${cause.message}
14658
- ${cause.stack ?? ""}` : String(cause);
14809
+ const errorText = `${safeErrorMessage(cause)}
14810
+ ${safeErrorStack(cause) ?? ""}`;
14659
14811
  return /playwright-core|patchright-core|coreBundle|Duplicate target/i.test(errorText);
14660
14812
  }
14661
14813
  function isPatchrightProtocolError(cause) {
14662
- return cause instanceof Error && Object.hasOwn(cause, "method") && Object.hasOwn(cause, "logs") && "type" in cause && (cause.type === "error" || cause.type === "closed" || cause.type === "crashed");
14814
+ if (!isSafeHostError(cause))
14815
+ return false;
14816
+ const type = Object.getOwnPropertyDescriptor(cause, "type")?.value;
14817
+ return Object.getOwnPropertyDescriptor(cause, "method") !== undefined && Object.getOwnPropertyDescriptor(cause, "logs") !== undefined && (type === "error" || type === "closed" || type === "crashed");
14663
14818
  }
14664
14819
  function isBenignClosedSessionRejection(cause) {
14665
- if (!(cause instanceof Error))
14820
+ if (!isSafeHostError(cause))
14666
14821
  return false;
14667
- if (!isPatchrightProtocolError(cause) && !/patchright-core|playwright-core|coreBundle/.test(cause.stack ?? ""))
14822
+ if (!isPatchrightProtocolError(cause) && !/patchright-core|playwright-core|coreBundle/.test(safeErrorStack(cause) ?? ""))
14668
14823
  return false;
14669
- return /^Protocol error \([\w.]+\): .*(session closed|Target closed|Extension disconnected|extension is not connected|Unknown CDP session|Detached while handling command|Relay closed)/i.test(cause.message);
14824
+ return /^Protocol error \([\w.]+\): .*(session closed|Target closed|Extension disconnected|extension is not connected|Unknown CDP session|Detached while handling command|Relay closed)/i.test(safeErrorMessage(cause));
14670
14825
  }
14671
14826
  var benignRejections = { count: 0, logged: 0, lastLogAt: 0 };
14827
+ var unattributedRejections = { count: 0, logged: 0, lastLogAt: 0 };
14672
14828
  function handleRelayProcessFault(kind, cause, detail, options = {}) {
14673
14829
  if (kind === "unhandledRejection" && isBenignClosedSessionRejection(cause)) {
14674
14830
  benignRejections.count += 1;
@@ -14677,31 +14833,46 @@ function handleRelayProcessFault(kind, cause, detail, options = {}) {
14677
14833
  const since = benignRejections.count - benignRejections.logged;
14678
14834
  benignRejections.lastLogAt = now;
14679
14835
  benignRejections.logged = benignRejections.count;
14680
- relayLog("process.benignRejections", { count: since, total: benignRejections.count, example: cause.message.slice(0, 160) });
14836
+ relayLog("process.benignRejections", { count: since, total: benignRejections.count, example: safeErrorMessage(cause).slice(0, 160) });
14681
14837
  }
14682
14838
  return;
14683
14839
  }
14684
14840
  if (shouldSuppressRelayProcessFault(cause)) {
14685
14841
  suppressedProcessFaults.count += 1;
14686
14842
  suppressedProcessFaults.lastAt = new Date().toISOString();
14687
- suppressedProcessFaults.lastMessage = (cause instanceof Error ? cause.message : String(cause)).slice(0, 300);
14843
+ suppressedProcessFaults.lastMessage = safeErrorMessage(cause).slice(0, 300);
14688
14844
  logProcessFault(kind, cause, detail, "keeping relay alive");
14689
14845
  return;
14690
14846
  }
14847
+ if (kind === "unhandledRejection") {
14848
+ const description = safeErrorMessage(cause);
14849
+ suppressedProcessFaults.count += 1;
14850
+ suppressedProcessFaults.lastAt = new Date().toISOString();
14851
+ suppressedProcessFaults.lastMessage = description.slice(0, 300);
14852
+ unattributedRejections.count += 1;
14853
+ const now = Date.now();
14854
+ if (description !== unattributedRejections.lastMessage || now - unattributedRejections.lastLogAt >= 60000) {
14855
+ const since = unattributedRejections.count - unattributedRejections.logged;
14856
+ unattributedRejections.lastLogAt = now;
14857
+ unattributedRejections.logged = unattributedRejections.count;
14858
+ unattributedRejections.lastMessage = description;
14859
+ logProcessFault(kind, cause, { suppressed: since }, "keeping relay alive; an unhandled rejection never stops the relay");
14860
+ }
14861
+ return;
14862
+ }
14691
14863
  logProcessFault(kind, cause, detail, "not a known Playwright dispatch fault; rethrowing");
14692
14864
  const rethrow = options.rethrow ?? rethrowProcessFault;
14693
14865
  rethrow(cause);
14694
14866
  }
14695
14867
  function rethrowProcessFault(cause) {
14696
- if (cause instanceof Error) {
14868
+ if (isSafeHostError(cause)) {
14697
14869
  throw cause;
14698
14870
  }
14699
- throw new Error(String(cause));
14871
+ throw new Error(safeErrorMessage(cause));
14700
14872
  }
14701
14873
  function logProcessFault(kind, cause, detail, disposition) {
14702
- const errorText = cause instanceof Error ? cause.stack ?? cause.message : String(cause);
14703
14874
  const message = `[browse relay] ${kind}; ${disposition}
14704
- ${errorText}`;
14875
+ ${safeErrorStack(cause) ?? safeErrorMessage(cause)}`;
14705
14876
  console.error(message);
14706
14877
  if (process.env.OPENCODE_BROWSER_MANAGED_RELAY === "1")
14707
14878
  appendManagedRelayProcessLog(message);
@@ -14712,6 +14883,30 @@ ${errorText}`;
14712
14883
  function debugEnvironmentEnabled(value) {
14713
14884
  return value !== undefined && ["1", "true", "yes", "on"].includes(value.toLowerCase());
14714
14885
  }
14886
+
14887
+ // src/relay/process-guard.ts
14888
+ var installRelayProcessGuard = acquireRelease(sync2(() => {
14889
+ const onUncaughtException = (error, origin) => {
14890
+ if (handleExecuteRealmException(error))
14891
+ return;
14892
+ handleRelayProcessFault("uncaughtException", error, { origin });
14893
+ };
14894
+ const onUnhandledRejection = (reason, promise) => {
14895
+ if (handleExecuteRealmRejection(promise, reason)) {
14896
+ relayLog("process.executeRejection");
14897
+ return;
14898
+ }
14899
+ handleRelayProcessFault("unhandledRejection", reason, {});
14900
+ };
14901
+ process.on("uncaughtException", onUncaughtException);
14902
+ process.on("unhandledRejection", onUnhandledRejection);
14903
+ return { onUncaughtException, onUnhandledRejection };
14904
+ }), (handlers) => {
14905
+ return sync2(() => {
14906
+ process.off("uncaughtException", handlers.onUncaughtException);
14907
+ process.off("unhandledRejection", handlers.onUnhandledRejection);
14908
+ });
14909
+ });
14715
14910
  function processAlive2(pid) {
14716
14911
  try {
14717
14912
  process.kill(pid, 0);
@@ -1,4 +1,4 @@
1
- import"./main-afz4wktv.mjs";
1
+ import"./main-bccm3dk2.mjs";
2
2
  import {
3
3
  cliCommand,
4
4
  installCommand,
@@ -15,14 +15,14 @@ import {
15
15
  registryUrl,
16
16
  fetchPublished,
17
17
  runInstaller
18
- } from "./main-y22dyw2e.mjs";
18
+ } from "./main-n0qm6500.mjs";
19
19
  import"./main-mrew6jy8.mjs";
20
20
  import {
21
21
  Service,
22
22
  layerFetch,
23
23
  restartRelay,
24
24
  startManagedRelay
25
- } from "./main-b3w2ntyc.mjs";
25
+ } from "./main-hz7wj5ze.mjs";
26
26
  import"./main-vgzr4689.mjs";
27
27
  import {
28
28
  succeed6,
@@ -32,7 +32,7 @@ import {
32
32
  provide3,
33
33
  runPromise
34
34
  } from "./main-csnx585b.mjs";
35
- import"./main-r62eef6t.mjs";
35
+ import"./main-y2e9e5kz.mjs";
36
36
 
37
37
  // src/update/runtime-update.ts
38
38
  var log = (line) => process.stdout.write(line + `
@@ -63,10 +63,10 @@ import {
63
63
  installRuntime,
64
64
  installedRuntime,
65
65
  manualMcpEntry
66
- } from "./main-d0vkm24t.mjs";
66
+ } from "./main-nf4p3mes.mjs";
67
67
  import {
68
68
  opencodeBrowserBuildId2
69
- } from "./main-afz4wktv.mjs";
69
+ } from "./main-bccm3dk2.mjs";
70
70
  import {
71
71
  installedBinaryPath,
72
72
  installerBinaryPath,
@@ -82,7 +82,7 @@ import {
82
82
  autoUpdateStatus,
83
83
  describeAutoUpdate,
84
84
  runCommand
85
- } from "./main-y22dyw2e.mjs";
85
+ } from "./main-n0qm6500.mjs";
86
86
  import"./main-vgzr4689.mjs";
87
87
  import {
88
88
  pairingCodeTtlMs,
@@ -96,7 +96,7 @@ import {
96
96
  revokeBrowserToken,
97
97
  legacyPairingCode,
98
98
  removeLegacyPairingCode
99
- } from "./main-7n3prtjk.mjs";
99
+ } from "./main-br0znez7.mjs";
100
100
  import {
101
101
  unpackedExtensionId,
102
102
  extensionProtocolSkew,
@@ -107,10 +107,10 @@ import {
107
107
  readRelayConfig,
108
108
  writeRelayConfig,
109
109
  syncDevExtension
110
- } from "./main-fed0em2f.mjs";
110
+ } from "./main-x58yhgrq.mjs";
111
111
  import {
112
112
  relayAuthorization
113
- } from "./main-r62eef6t.mjs";
113
+ } from "./main-y2e9e5kz.mjs";
114
114
 
115
115
  // src/setup.ts
116
116
  import { mkdirSync as mkdirSync2, rmSync as rmSync2, writeFileSync } from "node:fs";
@@ -215,6 +215,12 @@ values between calls on \`state\`. A single run without an \`await\` is stopped
215
215
  about 2 seconds; split heavy loops with
216
216
  \`await new Promise(r => setTimeout(r, 0))\` or do the work in the page.
217
217
 
218
+ Await promises: a rejection with no handler never stops the relay. A running call
219
+ gets the error; a later one resets the realm and warns on the next call (a
220
+ one-shot \`--rm\` session is already gone). Full Node mode has no realm to reset.
221
+ \`await files.write(...)\` and \`await page.goto(...)\` put the error in the call
222
+ that caused it.
223
+
218
224
  It runs in a restricted JavaScript realm, not a sandbox. It shares the relay's
219
225
  process, so it is not a security boundary: treat code as running as you. There
220
226
  is no \`process\`, \`require\`, \`import()\`, \`eval\`, \`fs\`, \`os\`,
@@ -1,9 +1,9 @@
1
- import"./main-afz4wktv.mjs";
1
+ import"./main-bccm3dk2.mjs";
2
2
  import {
3
3
  entryCommand,
4
4
  installedRuntime2,
5
5
  installedVersion
6
- } from "./main-y22dyw2e.mjs";
6
+ } from "./main-n0qm6500.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-t7r3wnv8.mjs");
36
+ const { runCli } = await import("./cli-yw23xxk6.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-azv7pxzm.mjs";
7
+ } from "./main-z0a00g4g.mjs";
8
8
  import"./main-mrew6jy8.mjs";
9
- import"./main-y22dyw2e.mjs";
10
- import"./main-afz4wktv.mjs";
9
+ import"./main-n0qm6500.mjs";
10
+ import"./main-bccm3dk2.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-afz4wktv.mjs";
4
+ } from "./main-bccm3dk2.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.15-dev.97",
3
+ "version": "0.0.15-dev.98",
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",
@@ -214,6 +214,12 @@ values between calls on `state`. A single run without an `await` is stopped afte
214
214
  about 2 seconds; split heavy loops with
215
215
  `await new Promise(r => setTimeout(r, 0))` or do the work in the page.
216
216
 
217
+ Await promises: a rejection with no handler never stops the relay. A running call
218
+ gets the error; a later one resets the realm and warns on the next call (a
219
+ one-shot `--rm` session is already gone). Full Node mode has no realm to reset.
220
+ `await files.write(...)` and `await page.goto(...)` put the error in the call
221
+ that caused it.
222
+
217
223
  It runs in a restricted JavaScript realm, not a sandbox. It shares the relay's
218
224
  process, so it is not a security boundary: treat code as running as you. There
219
225
  is no `process`, `require`, `import()`, `eval`, `fs`, `os`,
@@ -1,4 +0,0 @@
1
- // src/version.ts
2
- var opencodeBrowserVersion2 = "0.0.15-dev.97";
3
- var opencodeBrowserBuildId2 = "2026-11-07T09:32:07.029Z";
4
- export { opencodeBrowserVersion2, opencodeBrowserBuildId2 };