@opencode/browse 0.0.11-dev.76 → 0.0.11-dev.77

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.
Files changed (33) hide show
  1. package/dist/{cli-qpkh40gh.mjs → cli-mx6tbg2m.mjs} +63 -52
  2. package/dist/cli.mjs +30 -19
  3. package/dist/{helpers-kp0j46jt.mjs → helpers-hgm1z9h5.mjs} +2 -2
  4. package/dist/{index-0dcypq31.mjs → index-yzz55kxm.mjs} +1 -1
  5. package/dist/{main-brv9dhy5.mjs → main-1fdejpga.mjs} +9 -9
  6. package/dist/{main-ajza8egc.mjs → main-6chyyr6j.mjs} +44 -39
  7. package/dist/{main-rt6g5418.mjs → main-8z9d979q.mjs} +15 -15
  8. package/dist/{setup-j76yv51b.mjs → main-b7g6460c.mjs} +3608 -4406
  9. package/dist/{main-gevbt7h7.mjs → main-csnx585b.mjs} +151 -151
  10. package/dist/{main-nqmm7pdz.mjs → main-cymarjp4.mjs} +47 -47
  11. package/dist/main-j2ehvkhk.mjs +465 -0
  12. package/dist/main-r3a6053j.mjs +157 -0
  13. package/dist/main-s7017yah.mjs +161 -0
  14. package/dist/main-sjrzyg3x.mjs +73 -0
  15. package/dist/main-vgzr4689.mjs +61 -0
  16. package/dist/{main-eej5z0y5.mjs → main-zq79yb8r.mjs} +6 -6
  17. package/dist/main-zya5ttbr.mjs +4 -0
  18. package/dist/{mcp-sy8qgkyr.mjs → mcp-h0qcxhqc.mjs} +138 -137
  19. package/dist/migrate-pgckfkg5.mjs +233 -0
  20. package/dist/{relay-ateyg5ax.mjs → relay-gafgjtav.mjs} +128 -123
  21. package/dist/runtime-update-p2pnfdy1.mjs +156 -0
  22. package/dist/setup-fhhjnx9r.mjs +956 -0
  23. package/dist/{skill-text-x7sccp6h.mjs → skill-text-6p6scqwe.mjs} +2 -2
  24. package/dist/{supervisor-0rvjpf4e.mjs → supervisor-06t66v4t.mjs} +38 -17
  25. package/dist/{update-rbd2025v.mjs → update-7hagfdc0.mjs} +3 -3
  26. package/dist/{version-4cjr3wpp.mjs → version-hhcvk9wm.mjs} +1 -1
  27. package/package.json +1 -1
  28. package/skills/browse/SKILL.md +2 -2
  29. package/dist/main-7wgmq04v.mjs +0 -303
  30. package/dist/main-exnm62gg.mjs +0 -4
  31. package/dist/main-hm4fcpfz.mjs +0 -131
  32. package/dist/main-rn7hdcq2.mjs +0 -805
  33. package/dist/runtime-update-70gqzynp.mjs +0 -200
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  opencodeBrowserVersion2,
3
3
  opencodeBrowserBuildId2
4
- } from "./main-exnm62gg.mjs";
4
+ } from "./main-zya5ttbr.mjs";
5
5
  import {
6
6
  dataRoot,
7
+ stateRoot,
7
8
  oldStoreMarker,
8
9
  fromCheckout,
9
10
  cliCommand,
@@ -13,13 +14,13 @@ import {
13
14
  storeUrl,
14
15
  installCommand,
15
16
  autoUpdateModes,
16
- npmRuntime,
17
+ installedRuntime2,
17
18
  autoUpdateOverride,
18
19
  storedMode,
19
20
  setStoredMode,
20
21
  autoUpdateStatus,
21
22
  createAutoUpdater
22
- } from "./main-rn7hdcq2.mjs";
23
+ } from "./main-j2ehvkhk.mjs";
23
24
  import {
24
25
  extensionProtocolVersion,
25
26
  minExtensionProtocolVersion,
@@ -39,12 +40,8 @@ import {
39
40
  isUnsupportedDirectorySyncError,
40
41
  writeJsonFileAtomically,
41
42
  ensurePrivateDirectorySync,
42
- writePrivateJsonFileSync,
43
- relayTokenQueryParam,
44
- relayToken,
45
- secretsEqual,
46
- ensurePrivateDirectory
47
- } from "./main-hm4fcpfz.mjs";
43
+ writePrivateJsonFileSync
44
+ } from "./main-vgzr4689.mjs";
48
45
  import {
49
46
  withDefault,
50
47
  option,
@@ -98,11 +95,9 @@ import {
98
95
  isRestrictedTarget2,
99
96
  isRestrictedUrl2,
100
97
  dataUrlDocument2
101
- } from "./main-ajza8egc.mjs";
98
+ } from "./main-6chyyr6j.mjs";
102
99
  import {
103
- relayHostname,
104
- isLocalPeer,
105
- context2,
100
+ context,
106
101
  pendingPairingCodeKeys,
107
102
  consumePairingCode,
108
103
  recordPairingFailure,
@@ -117,10 +112,8 @@ import {
117
112
  ecdhExchange,
118
113
  pairingSessionKey,
119
114
  sessionProof,
120
- wrapToken,
121
- installedDevExtension,
122
- syncDevExtension
123
- } from "./main-7wgmq04v.mjs";
115
+ wrapToken
116
+ } from "./main-r3a6053j.mjs";
124
117
  import {
125
118
  makeUnsafe,
126
119
  SettingsInputError,
@@ -148,16 +141,29 @@ import {
148
141
  checkNavigationUrl,
149
142
  readSecret,
150
143
  secretText
151
- } from "./main-nqmm7pdz.mjs";
144
+ } from "./main-cymarjp4.mjs";
152
145
  import {
153
146
  defaultJournalBaseDir,
154
147
  makeJournalEntry,
155
148
  appendJournalEntry,
156
149
  startJournalRetention
157
- } from "./main-eej5z0y5.mjs";
150
+ } from "./main-zq79yb8r.mjs";
158
151
  import {
159
152
  createUpdateWatcher2
160
- } from "./main-brv9dhy5.mjs";
153
+ } from "./main-1fdejpga.mjs";
154
+ import {
155
+ relayHostname,
156
+ isLocalPeer,
157
+ installedDevExtension,
158
+ syncDevExtension
159
+ } from "./main-s7017yah.mjs";
160
+ import {
161
+ currentTimeMillis,
162
+ value,
163
+ when,
164
+ orElse,
165
+ exhaustive
166
+ } from "./main-8z9d979q.mjs";
161
167
  import {
162
168
  isNone,
163
169
  isSome,
@@ -174,7 +180,7 @@ import {
174
180
  make5,
175
181
  _await,
176
182
  done,
177
- fail3,
183
+ fail4,
178
184
  succeed4,
179
185
  doneUnsafe,
180
186
  make6,
@@ -193,7 +199,7 @@ import {
193
199
  callback2,
194
200
  never,
195
201
  gen,
196
- fail4,
202
+ fail5,
197
203
  try_,
198
204
  flatMap3,
199
205
  andThen,
@@ -216,7 +222,7 @@ import {
216
222
  raceFirst,
217
223
  match3,
218
224
  matchEffect,
219
- context,
225
+ context2,
220
226
  scoped,
221
227
  acquireRelease,
222
228
  acquireUseRelease,
@@ -235,10 +241,7 @@ import {
235
241
  runSync,
236
242
  fnUntraced,
237
243
  fn,
238
- join,
239
- interrupt3,
240
- makeUnsafe5,
241
- is,
244
+ is2,
242
245
  decodeUnknownEffect2,
243
246
  decodeUnknownOption,
244
247
  decodeUnknownSync,
@@ -255,15 +258,17 @@ import {
255
258
  TaggedUnion,
256
259
  Int2,
257
260
  Defect,
258
- TaggedError2
259
- } from "./main-gevbt7h7.mjs";
261
+ TaggedError2,
262
+ join,
263
+ interrupt3,
264
+ makeUnsafe5
265
+ } from "./main-csnx585b.mjs";
260
266
  import {
261
- currentTimeMillis2,
262
- value2,
263
- when2,
264
- orElse,
265
- exhaustive
266
- } from "./main-rt6g5418.mjs";
267
+ relayTokenQueryParam,
268
+ relayToken,
269
+ secretsEqual,
270
+ ensurePrivateDirectory
271
+ } from "./main-sjrzyg3x.mjs";
267
272
  import {
268
273
  isString,
269
274
  isNumber,
@@ -386,11 +391,11 @@ class ExtensionRpc {
386
391
  return callback2((resume) => {
387
392
  const socket = this.socket;
388
393
  if (this.protocolCompatible === false) {
389
- resume(fail4(new Error(extensionProtocolAdvice(this.protocolVersion, { install: installCommand() }))));
394
+ resume(fail5(new Error(extensionProtocolAdvice(this.protocolVersion, { install: installCommand() }))));
390
395
  return void_3;
391
396
  }
392
397
  if (!socket || socket.readyState !== WebSocket.OPEN || !this.acceptsEvents) {
393
- resume(fail4(new Error("browse extension is not connected")));
398
+ resume(fail5(new Error("browse extension is not connected")));
394
399
  return void_3;
395
400
  }
396
401
  const id = this.nextRequestId++;
@@ -412,10 +417,10 @@ class ExtensionRpc {
412
417
  if (this.replies !== replies)
413
418
  return finish(succeed6({}));
414
419
  this.unresponsive = true;
415
- return finish(fail4(new Error(browserUnresponsive)));
420
+ return finish(fail5(new Error(browserUnresponsive)));
416
421
  }
417
422
  this.probeLiveness(socket);
418
- finish(fail4(new Error(`Extension command timed out after ${timeoutMs}ms: ${command.method}`)));
423
+ finish(fail5(new Error(`Extension command timed out after ${timeoutMs}ms: ${command.method}`)));
419
424
  }, timeoutMs);
420
425
  const debuggerTabId = command.method === "debugger.sendCommand" && isNumber(command.params?.tabId) ? command.params.tabId : undefined;
421
426
  this.pendingRequests.set(id, {
@@ -423,18 +428,18 @@ class ExtensionRpc {
423
428
  finish(succeed6(value));
424
429
  },
425
430
  reject: (error) => {
426
- finish(fail4(error));
431
+ finish(fail5(error));
427
432
  },
428
433
  ...debuggerTabId === undefined ? {} : { debuggerTabId }
429
434
  });
430
435
  try {
431
436
  socket.send(JSON.stringify(message), (error) => {
432
437
  if (error) {
433
- finish(fail4(new Error(`send extension command: ${command.method}`, { cause: error })));
438
+ finish(fail5(new Error(`send extension command: ${command.method}`, { cause: error })));
434
439
  }
435
440
  });
436
441
  } catch (error) {
437
- finish(fail4(new Error(`send extension command: ${command.method}`, { cause: error })));
442
+ finish(fail5(new Error(`send extension command: ${command.method}`, { cause: error })));
438
443
  }
439
444
  return sync2(() => {
440
445
  completed = true;
@@ -1618,7 +1623,7 @@ class CdpRuntime {
1618
1623
  method: "Runtime.enable",
1619
1624
  params,
1620
1625
  ...route.chromeSessionId === undefined ? {} : { sessionId: route.chromeSessionId }
1621
- }) : fail4(new Error("CDP target changed before Runtime.enable"))), client && requester ? {
1626
+ }) : fail5(new Error("CDP target changed before Runtime.enable"))), client && requester ? {
1622
1627
  replay: () => {
1623
1628
  const frameId = rootFrame();
1624
1629
  return frameId !== undefined && this.replayCached(client, route, frameId);
@@ -1986,28 +1991,28 @@ var requestJson = fn("AuthenticatedOrigin.requestJson")(function* (page, request
1986
1991
  cause
1987
1992
  })
1988
1993
  }).pipe(uninterruptible);
1989
- return value2(pageResult).pipe(when2({ kind: "OriginMismatch" }, ({ expectedOrigin, actualOrigin }) => AuthenticatedJsonOutcome.cases.OriginMismatch.make({ expectedOrigin, actualOrigin })), when2({ kind: "HttpError" }, ({ status }) => AuthenticatedJsonOutcome.cases.HttpError.make({ status })), when2({ kind: "ResponseTooLarge" }, ({ status, maxResponseBytes }) => AuthenticatedJsonOutcome.cases.ResponseTooLarge.make({ status, maxResponseBytes })), when2({ kind: "Success" }, ({ status, value }) => AuthenticatedJsonOutcome.cases.Success.make({ status, value })), when2({ kind: "InvalidJson" }, ({ status }) => AuthenticatedJsonOutcome.cases.InvalidJson.make({ status })), when2({ kind: "RequestFailed" }, ({ outcome }) => AuthenticatedJsonOutcome.cases.RequestFailed.make({ outcome })), exhaustive);
1994
+ return value(pageResult).pipe(when({ kind: "OriginMismatch" }, ({ expectedOrigin, actualOrigin }) => AuthenticatedJsonOutcome.cases.OriginMismatch.make({ expectedOrigin, actualOrigin })), when({ kind: "HttpError" }, ({ status }) => AuthenticatedJsonOutcome.cases.HttpError.make({ status })), when({ kind: "ResponseTooLarge" }, ({ status, maxResponseBytes }) => AuthenticatedJsonOutcome.cases.ResponseTooLarge.make({ status, maxResponseBytes })), when({ kind: "Success" }, ({ status, value: value2 }) => AuthenticatedJsonOutcome.cases.Success.make({ status, value: value2 })), when({ kind: "InvalidJson" }, ({ status }) => AuthenticatedJsonOutcome.cases.InvalidJson.make({ status })), when({ kind: "RequestFailed" }, ({ outcome }) => AuthenticatedJsonOutcome.cases.RequestFailed.make({ outcome })), exhaustive);
1990
1995
  });
1991
- function normalizeOrigin(value) {
1996
+ function normalizeOrigin(value2) {
1992
1997
  let url;
1993
1998
  try {
1994
- url = new URL(value);
1999
+ url = new URL(value2);
1995
2000
  } catch (cause) {
1996
2001
  throw new AuthenticatedOriginError({
1997
- message: `Invalid authenticated origin: ${value}`,
2002
+ message: `Invalid authenticated origin: ${value2}`,
1998
2003
  reason: "invalid-request",
1999
2004
  cause
2000
2005
  });
2001
2006
  }
2002
2007
  if (url.protocol !== "https:" && url.protocol !== "http:" || url.username || url.password) {
2003
2008
  throw new AuthenticatedOriginError({
2004
- message: `Authenticated origin must be an HTTP(S) origin without credentials: ${value}`,
2009
+ message: `Authenticated origin must be an HTTP(S) origin without credentials: ${value2}`,
2005
2010
  reason: "invalid-request"
2006
2011
  });
2007
2012
  }
2008
2013
  if (url.pathname !== "/" || url.search || url.hash) {
2009
2014
  throw new AuthenticatedOriginError({
2010
- message: `Authenticated origin must not include a path, query, or fragment: ${value}`,
2015
+ message: `Authenticated origin must not include a path, query, or fragment: ${value2}`,
2011
2016
  reason: "invalid-request"
2012
2017
  });
2013
2018
  }
@@ -2029,8 +2034,8 @@ function resolveRequestUrl(origin, path) {
2029
2034
  }
2030
2035
  return url.toString();
2031
2036
  }
2032
- function resolveStartUrl(origin, value) {
2033
- const url = new URL(value, origin);
2037
+ function resolveStartUrl(origin, value2) {
2038
+ const url = new URL(value2, origin);
2034
2039
  if (url.origin !== origin) {
2035
2040
  throw new AuthenticatedOriginError({
2036
2041
  message: `Authenticated origin startUrl must stay on ${origin}`,
@@ -2039,9 +2044,9 @@ function resolveStartUrl(origin, value) {
2039
2044
  }
2040
2045
  return url.toString();
2041
2046
  }
2042
- function pageOrigin(value) {
2047
+ function pageOrigin(value2) {
2043
2048
  try {
2044
- return new URL(value).origin;
2049
+ return new URL(value2).origin;
2045
2050
  } catch {
2046
2051
  return "null";
2047
2052
  }
@@ -4024,7 +4029,7 @@ var runPlaywrightOperation = fn("Execute.playwrightOperation")((options) => tryP
4024
4029
  catch: (cause) => operationFailure(options.label, cause)
4025
4030
  }).pipe(timeoutOrElse({
4026
4031
  duration: options.timeoutMs,
4027
- orElse: () => fail4(new PlaywrightOperationError({
4032
+ orElse: () => fail5(new PlaywrightOperationError({
4028
4033
  message: `${options.label} timed out after ${options.timeoutMs}ms`,
4029
4034
  operation: options.label,
4030
4035
  reason: "timeout"
@@ -5201,10 +5206,10 @@ async function startDemonstrationRecorder(page) {
5201
5206
  function formatDemonstrationCode(options) {
5202
5207
  const lines = [
5203
5208
  `// Recorded from ${options.startedUrl}`,
5204
- ...options.steps.map((step) => value2(step).pipe(when2({ kind: "navigation" }, ({ url }) => `// Navigated to ${url}`), when2({ kind: "click" }, ({ selector, role, name }) => {
5209
+ ...options.steps.map((step) => value(step).pipe(when({ kind: "navigation" }, ({ url }) => `// Navigated to ${url}`), when({ kind: "click" }, ({ selector, role, name }) => {
5205
5210
  const description = role && name ? ` // ${role} ${JSON.stringify(name)}` : "";
5206
5211
  return `await page.locator(${JSON.stringify(selector)}).click()${description}`;
5207
- }), when2({ kind: "fill" }, ({ selector, value, redacted }) => redacted ? `// Fill ${JSON.stringify(selector)} from an approved secret source.` : `await page.locator(${JSON.stringify(selector)}).fill(${JSON.stringify(value)})`), when2({ kind: "check" }, ({ selector, checked }) => `await page.locator(${JSON.stringify(selector)}).${checked ? "check" : "uncheck"}()`), when2({ kind: "select" }, ({ selector, value }) => `await page.locator(${JSON.stringify(selector)}).selectOption(${JSON.stringify(value)})`), exhaustive)),
5212
+ }), when({ kind: "fill" }, ({ selector, value: value2, redacted }) => redacted ? `// Fill ${JSON.stringify(selector)} from an approved secret source.` : `await page.locator(${JSON.stringify(selector)}).fill(${JSON.stringify(value2)})`), when({ kind: "check" }, ({ selector, checked }) => `await page.locator(${JSON.stringify(selector)}).${checked ? "check" : "uncheck"}()`), when({ kind: "select" }, ({ selector, value: value2 }) => `await page.locator(${JSON.stringify(selector)}).selectOption(${JSON.stringify(value2)})`), exhaustive)),
5208
5213
  "return { url: page.url(), title: await page.title() }"
5209
5214
  ];
5210
5215
  return lines.join(`
@@ -5228,7 +5233,7 @@ function appendStep(steps, next) {
5228
5233
  return;
5229
5234
  steps.push(next);
5230
5235
  }
5231
- var isDemonstrationStep = is(DemonstrationStep);
5236
+ var isDemonstrationStep = is2(DemonstrationStep);
5232
5237
  function installDemonstrationListeners(options) {
5233
5238
  const world = globalThis;
5234
5239
  if (world.__opencodeBrowserDemonstration?.id === options.recorderId)
@@ -5244,10 +5249,10 @@ function installDemonstrationListeners(options) {
5244
5249
  if (id)
5245
5250
  return `#${CSS.escape(id)}`;
5246
5251
  for (const attribute of ["data-testid", "data-test", "name", "aria-label"]) {
5247
- const value = element.getAttribute(attribute);
5248
- if (!value)
5252
+ const value2 = element.getAttribute(attribute);
5253
+ if (!value2)
5249
5254
  continue;
5250
- const candidate = `[${attribute}="${CSS.escape(value)}"]`;
5255
+ const candidate = `[${attribute}="${CSS.escape(value2)}"]`;
5251
5256
  if (document.querySelectorAll(candidate).length === 1)
5252
5257
  return candidate;
5253
5258
  }
@@ -6439,7 +6444,7 @@ function inputDispatchMouseEventToGhostCursorAction(params) {
6439
6444
  }
6440
6445
  const button = parseButton(params.button);
6441
6446
  return {
6442
- type: value2(type).pipe(when2("mousePressed", () => "down"), when2("mouseReleased", () => "up"), when2("mouseMoved", () => "move"), exhaustive),
6447
+ type: value(type).pipe(when("mousePressed", () => "down"), when("mouseReleased", () => "up"), when("mouseMoved", () => "move"), exhaustive),
6443
6448
  x: params.x,
6444
6449
  y: params.y,
6445
6450
  button
@@ -6494,7 +6499,7 @@ class GhostCursorTabs {
6494
6499
  command = fnUntraced(function* (tabId, params) {
6495
6500
  const operation = params?.op;
6496
6501
  if (!isString(operation) || !ghostCursorOperations.has(operation)) {
6497
- return yield* fail4(new Error(`Unknown ghost cursor operation: ${String(operation)}`));
6502
+ return yield* fail5(new Error(`Unknown ghost cursor operation: ${String(operation)}`));
6498
6503
  }
6499
6504
  const payload = params?.payload ?? null;
6500
6505
  const state = this.state(tabId);
@@ -6588,17 +6593,17 @@ class GhostCursorTabs {
6588
6593
  return;
6589
6594
  }
6590
6595
  const result = yield* evaluate(`${api} ? ${invoke} : ${JSON.stringify(missingGhostCursor)}`);
6591
- const value = isObject(result) && "result" in result && isObject(result.result) && "value" in result.result ? result.result.value : undefined;
6592
- if (value !== missingGhostCursor)
6596
+ const value2 = isObject(result) && "result" in result && isObject(result.result) && "value" in result.result ? result.result.value : undefined;
6597
+ if (value2 !== missingGhostCursor)
6593
6598
  return;
6594
6599
  yield* evaluate(`${ghostCursorClientSource}
6595
6600
  ${invoke}`);
6596
6601
  });
6597
6602
  }
6598
6603
  var missingGhostCursor = "__missing__";
6599
- function parseButton(value) {
6600
- if (value === "left" || value === "right" || value === "middle" || value === "none") {
6601
- return value;
6604
+ function parseButton(value2) {
6605
+ if (value2 === "left" || value2 === "right" || value2 === "middle" || value2 === "none") {
6606
+ return value2;
6602
6607
  }
6603
6608
  return "none";
6604
6609
  }
@@ -9768,7 +9773,7 @@ import path7 from "node:path";
9768
9773
  var maxLogBytes = 1e6;
9769
9774
  var maxEntryCharacters = 64000;
9770
9775
  function managedRelayLogPath(home = os5.homedir()) {
9771
- return path7.join(dataRoot(home), "logs", "relay.log");
9776
+ return path7.join(stateRoot(home), "logs", "relay.log");
9772
9777
  }
9773
9778
  function appendManagedRelayProcessLog(message, home = os5.homedir()) {
9774
9779
  try {
@@ -11274,7 +11279,7 @@ class RelayShutdown {
11274
11279
  yield* control.options.settle;
11275
11280
  }).pipe(timeoutOrElse({
11276
11281
  duration: control.options.timeoutMs ?? 1e4,
11277
- orElse: () => fail4(control.busyError("timeout"))
11282
+ orElse: () => fail5(control.busyError("timeout"))
11278
11283
  }));
11279
11284
  }
11280
11285
  close() {
@@ -11288,7 +11293,7 @@ class RelayShutdown {
11288
11293
  const control = this;
11289
11294
  return acquireUseRelease(suspend2(() => {
11290
11295
  if (!control.accepting)
11291
- return fail4(control.busyError());
11296
+ return fail5(control.busyError());
11292
11297
  return sync2(() => control.retain());
11293
11298
  }), () => effect, (release) => sync2(release));
11294
11299
  }
@@ -11365,7 +11370,7 @@ class RelayShutdown {
11365
11370
  const reason = typeof busy === "object" ? busy.reason : busy;
11366
11371
  const detail = typeof busy === "object" ? busy.detail : undefined;
11367
11372
  const force = cliCommand("relay restart --force");
11368
- const message = value2(reason).pipe(when2("raw-clients", () => `Relay has ${detail ?? "raw CDP clients attached"}; disconnect them, or run \`${force}\` to disconnect them and restart`), when2("recordings", () => `Relay has ${detail ?? "active recordings or network captures"}; stop them, or run \`${force}\` to end them (discarding what they captured) and restart`), when2("timeout", () => "Relay restart timed out waiting for accepted work; the relay is still running"), when2("changed", () => "Relay changed while preparing restart; it is still running, retry the restart"), orElse(() => "Relay is draining for an explicit restart; retry after it completes"));
11373
+ const message = value(reason).pipe(when("raw-clients", () => `Relay has ${detail ?? "raw CDP clients attached"}; disconnect them, or run \`${force}\` to disconnect them and restart`), when("recordings", () => `Relay has ${detail ?? "active recordings or network captures"}; stop them, or run \`${force}\` to end them (discarding what they captured) and restart`), when("timeout", () => "Relay restart timed out waiting for accepted work; the relay is still running"), when("changed", () => "Relay changed while preparing restart; it is still running, retry the restart"), orElse(() => "Relay is draining for an explicit restart; retry after it completes"));
11369
11374
  return new RelayShutdownError({ reason: "busy", message });
11370
11375
  }
11371
11376
  }
@@ -11619,7 +11624,7 @@ class SessionAdmission {
11619
11624
  yield* rollback();
11620
11625
  this.schedulePersistence();
11621
11626
  yield* this.flushPersistence().pipe(ignore);
11622
- return yield* fail4(error);
11627
+ return yield* fail5(error);
11623
11628
  })));
11624
11629
  }
11625
11630
  beginDrain() {
@@ -11731,11 +11736,11 @@ function adoptTargetForSession(context, options) {
11731
11736
  if (context.sessions.get(session.id) === session && (resolved.created || state !== "pending")) {
11732
11737
  const cleanup = yield* result(cleanupSettledAdoption(context, session, resolved.created, previousTarget, previousRelayClosed));
11733
11738
  if (isFailure(cleanup)) {
11734
- yield* fail3(result2, cleanup.failure);
11739
+ yield* fail4(result2, cleanup.failure);
11735
11740
  return;
11736
11741
  }
11737
11742
  }
11738
- yield* fail3(result2, error);
11743
+ yield* fail4(result2, error);
11739
11744
  }),
11740
11745
  onSuccess: () => void_3
11741
11746
  })));
@@ -11743,7 +11748,7 @@ function adoptTargetForSession(context, options) {
11743
11748
  yield* context.admission.forkTracked(worker, session.id);
11744
11749
  return yield* restore(_await(result2).pipe(timeoutOrElse({
11745
11750
  duration: timeoutMs,
11746
- orElse: () => cancel.pipe(andThen(fail4(timeoutError)))
11751
+ orElse: () => cancel.pipe(andThen(fail5(timeoutError)))
11747
11752
  }), onInterrupt(() => cancel)));
11748
11753
  })));
11749
11754
  }
@@ -11792,7 +11797,7 @@ function withLifecycleTimeout(hooks, effect, label) {
11792
11797
  const timeoutMs = hooks.lifecycleTimeoutMs ?? 1e4;
11793
11798
  return effect.pipe(timeoutOrElse({
11794
11799
  duration: timeoutMs,
11795
- orElse: () => fail4(sessionError("timeout", `${label} timed out after ${timeoutMs}ms`))
11800
+ orElse: () => fail5(sessionError("timeout", `${label} timed out after ${timeoutMs}ms`))
11796
11801
  }));
11797
11802
  }
11798
11803
  function closeSessionSettledWithTimeout(admission, hooks, session, closeSettled) {
@@ -11889,7 +11894,7 @@ function executeInSession(ctx, options) {
11889
11894
  return { result: resultWithHint, session: createdSummary(session, resolved.created) };
11890
11895
  });
11891
11896
  const worker = session.executeSemaphore.withPermit(operation.pipe(matchEffect({
11892
- onFailure: (error) => (resolved.created ? ctx.cleanupCreatedSession(session) : void_3).pipe(andThen(fail3(response, error))),
11897
+ onFailure: (error) => (resolved.created ? ctx.cleanupCreatedSession(session) : void_3).pipe(andThen(fail4(response, error))),
11893
11898
  onSuccess: (value) => (options.removeAfterExecute ? ctx.cleanupCreatedSession(session) : void_3).pipe(andThen(succeed4(response, value)))
11894
11899
  })));
11895
11900
  const workerFiber = yield* ctx.admission.forkTracked(worker, session.id);
@@ -12263,7 +12268,7 @@ class OpenCodeBrowserSessions {
12263
12268
  }
12264
12269
  networkStatus(id) {
12265
12270
  const session = this.sessions.get(id);
12266
- return session ? succeed6(session.sandbox.networkStatus()) : fail4(sessionError("not-found", `Session not found: ${id}`, id));
12271
+ return session ? succeed6(session.sandbox.networkStatus()) : fail5(sessionError("not-found", `Session not found: ${id}`, id));
12267
12272
  }
12268
12273
  networkStop(id, options = {}) {
12269
12274
  return this.withSessionOperation(id, "network stop", (session) => session.sandbox.networkStop(options));
@@ -12279,7 +12284,7 @@ class OpenCodeBrowserSessions {
12279
12284
  return this.admission.withAdmission(id, suspend2(() => {
12280
12285
  const session = manager.sessions.get(id);
12281
12286
  if (!session)
12282
- return fail4(sessionError("not-found", `Session not found: ${id}`, id));
12287
+ return fail5(sessionError("not-found", `Session not found: ${id}`, id));
12283
12288
  return (beforePermit ? beforePermit(session) : void_3).pipe(andThen(manager.withLifecyclePermit(session, operation, gen(function* () {
12284
12289
  if (manager.sessions.get(id) !== session) {
12285
12290
  return yield* sessionError("inactive", `Session is no longer active: ${id}`, id);
@@ -12298,7 +12303,7 @@ class OpenCodeBrowserSessions {
12298
12303
  session.updatedAt = new Date().toISOString();
12299
12304
  yield* manager.admission.commitPersistence();
12300
12305
  return result;
12301
- }), (session) => session.readOnly && request.method !== "GET" ? fail4(sessionError("invalid-request", `Read-only session ${sessionId} cannot make ${request.method} authenticated requests`, sessionId)) : void_3);
12306
+ }), (session) => session.readOnly && request.method !== "GET" ? fail5(sessionError("invalid-request", `Read-only session ${sessionId} cannot make ${request.method} authenticated requests`, sessionId)) : void_3);
12302
12307
  }
12303
12308
  execute(options) {
12304
12309
  return executeInSession(this.executionContext, options);
@@ -12403,7 +12408,7 @@ class OpenCodeBrowserSessions {
12403
12408
  catch: (cause) => cause
12404
12409
  }).pipe(timeoutOrElse({
12405
12410
  duration: this.hooks.journalTimeoutMs ?? 2000,
12406
- orElse: () => fail4(new Error(`Session journal write timed out after ${this.hooks.journalTimeoutMs ?? 2000}ms`))
12411
+ orElse: () => fail5(new Error(`Session journal write timed out after ${this.hooks.journalTimeoutMs ?? 2000}ms`))
12407
12412
  }), catch_((error) => sync2(() => {
12408
12413
  console.error("Session execute-record hook failed", error);
12409
12414
  })), asVoid2);
@@ -12523,14 +12528,14 @@ class OpenCodeBrowserSessions {
12523
12528
  const timeout = sessionError("timeout", `Session ${operation} timed out waiting for active execute in ${session.id}`, session.id);
12524
12529
  return raceFirst(session.executeSemaphore.withPermit(suspend2(() => {
12525
12530
  if (state === "timed-out")
12526
- return fail4(timeout);
12531
+ return fail5(timeout);
12527
12532
  state = "started";
12528
12533
  return effect;
12529
12534
  }).pipe(uninterruptible)), sleep(this.hooks.lifecycleTimeoutMs ?? 1e4).pipe(flatMap3(() => {
12530
12535
  if (state === "started")
12531
12536
  return never;
12532
12537
  state = "timed-out";
12533
- return fail4(timeout);
12538
+ return fail5(timeout);
12534
12539
  })));
12535
12540
  });
12536
12541
  }
@@ -12589,14 +12594,14 @@ function decodeRequest(schema, body, label) {
12589
12594
  code: "invalid-request"
12590
12595
  })));
12591
12596
  }
12592
- function optionalInteger(value, field) {
12593
- if (value === undefined) {
12597
+ function optionalInteger(value2, field) {
12598
+ if (value2 === undefined) {
12594
12599
  return;
12595
12600
  }
12596
- if (!isNumber(value) || !Number.isInteger(value)) {
12601
+ if (!isNumber(value2) || !Number.isInteger(value2)) {
12597
12602
  throw new HttpRouteError2({ message: `${field} must be an integer`, status: 400, code: "invalid-request" });
12598
12603
  }
12599
- return value;
12604
+ return value2;
12600
12605
  }
12601
12606
  function relayHttpError(error) {
12602
12607
  const routeError = (message, status, code) => new HttpRouteError2({ message, status, code });
@@ -12607,26 +12612,26 @@ function relayHttpError(error) {
12607
12612
  return error;
12608
12613
  }
12609
12614
  if (error instanceof SessionError) {
12610
- const [status, code] = value2(error.reason).pipe(when2("already-exists", () => [409, "session-already-exists"]), when2("browser-unavailable", () => [503, "browser-unavailable"]), when2("inactive", () => [409, "session-inactive"]), when2("invalid-request", () => [400, "invalid-request"]), when2("not-found", () => [404, "session-not-found"]), when2("target-owned", () => [409, "target-owned"]), when2("timeout", () => [409, "session-timeout"]), when2("setup-failed", () => [500, "setup-failed"]), exhaustive);
12615
+ const [status, code] = value(error.reason).pipe(when("already-exists", () => [409, "session-already-exists"]), when("browser-unavailable", () => [503, "browser-unavailable"]), when("inactive", () => [409, "session-inactive"]), when("invalid-request", () => [400, "invalid-request"]), when("not-found", () => [404, "session-not-found"]), when("target-owned", () => [409, "target-owned"]), when("timeout", () => [409, "session-timeout"]), when("setup-failed", () => [500, "setup-failed"]), exhaustive);
12611
12616
  return routeError(error.message, status, code);
12612
12617
  }
12613
12618
  if (error instanceof NetworkCaptureError) {
12614
- const [status, code] = value2(error.reason).pipe(when2("invalid-options", () => [400, "invalid-request"]), when2("already-active", () => [409, "capture-conflict"]), when2("inactive", () => [409, "capture-conflict"]), orElse(() => [500, "internal"]));
12619
+ const [status, code] = value(error.reason).pipe(when("invalid-options", () => [400, "invalid-request"]), when("already-active", () => [409, "capture-conflict"]), when("inactive", () => [409, "capture-conflict"]), orElse(() => [500, "internal"]));
12615
12620
  return routeError(error.message, status, code);
12616
12621
  }
12617
12622
  if (error instanceof AuthProfileError) {
12618
- const [status, code] = value2(error.reason).pipe(when2("invalid-name", () => [400, "invalid-request"]), when2("not-found", () => [404, "auth-profile-not-found"]), orElse(() => [500, "internal"]));
12623
+ const [status, code] = value(error.reason).pipe(when("invalid-name", () => [400, "invalid-request"]), when("not-found", () => [404, "auth-profile-not-found"]), orElse(() => [500, "internal"]));
12619
12624
  return routeError(error.message, status, code);
12620
12625
  }
12621
12626
  if (error instanceof AuthenticatedOriginError) {
12622
12627
  return routeError(error.message, error.reason === "invalid-request" ? 400 : 500, error.reason === "invalid-request" ? "invalid-request" : "setup-failed");
12623
12628
  }
12624
12629
  if (error instanceof TargetSelectionError) {
12625
- const [status, code] = value2(error.reason).pipe(when2("invalid", () => [400, "invalid-request"]), when2("not-found", () => [404, "target-not-found"]), when2("ambiguous", () => [409, "target-ambiguous"]), exhaustive);
12630
+ const [status, code] = value(error.reason).pipe(when("invalid", () => [400, "invalid-request"]), when("not-found", () => [404, "target-not-found"]), when("ambiguous", () => [409, "target-ambiguous"]), exhaustive);
12626
12631
  return routeError(error.message, status, code);
12627
12632
  }
12628
12633
  if (error instanceof TargetOwnershipError) {
12629
- const [status, code] = value2(error.reason).pipe(when2("not-found", () => [404, "target-not-found"]), when2("owned", () => [409, "target-owned"]), when2("generation-changed", () => [409, "target-changed"]), exhaustive);
12634
+ const [status, code] = value(error.reason).pipe(when("not-found", () => [404, "target-not-found"]), when("owned", () => [409, "target-owned"]), when("generation-changed", () => [409, "target-changed"]), exhaustive);
12630
12635
  return routeError(error.message, status, code);
12631
12636
  }
12632
12637
  return routeError(error instanceof Error ? error.message : String(error), 500, "internal");
@@ -13794,7 +13799,7 @@ function createHttpRequestHandler(options) {
13794
13799
  sendJson2(response, { error: hostError }, 403);
13795
13800
  return;
13796
13801
  }
13797
- const compatibility = { extensionProtocol: { min: minExtensionProtocolVersion, version: extensionProtocolVersion }, pairing: context2 };
13802
+ const compatibility = { extensionProtocol: { min: minExtensionProtocolVersion, version: extensionProtocolVersion }, pairing: context };
13798
13803
  const installHint = request.headers["x-browse-install"] === "probe" && Date.now() < installWaitingUntil ? { installWaiting: true } : {};
13799
13804
  const fetchSiteError = validateBrowserFetchSite2(request);
13800
13805
  if (fetchSiteError) {
@@ -14853,7 +14858,7 @@ function createCdpDispatcher(options) {
14853
14858
  const routeCdpCommand = fn("Relay.routeCdpCommand")(function* (socket, message) {
14854
14859
  const clientOpenCodeBrowserSessionId = cdpClients.sessionId(socket);
14855
14860
  if (!shutdownControl.accepting && (!cdpClients.isSandbox(socket) || !clientOpenCodeBrowserSessionId || !sessions.hasPendingWork(clientOpenCodeBrowserSessionId))) {
14856
- return yield* fail4(new Error("Relay is draining for an explicit restart"));
14861
+ return yield* fail5(new Error("Relay is draining for an explicit restart"));
14857
14862
  }
14858
14863
  const guardMessage = guardCdpMethod({
14859
14864
  method: message.method,
@@ -14863,7 +14868,7 @@ function createCdpDispatcher(options) {
14863
14868
  pageUrls: () => cdpRouter.visibleRoots(socket).map((target) => target.targetInfo.url)
14864
14869
  });
14865
14870
  if (guardMessage) {
14866
- return yield* fail4(new Error(guardMessage));
14871
+ return yield* fail5(new Error(guardMessage));
14867
14872
  }
14868
14873
  if (message.method === "Page.navigate" || message.method === "Target.createTarget") {
14869
14874
  const tabSessionId = message.method === "Page.navigate" ? (() => {
@@ -14879,7 +14884,7 @@ function createCdpDispatcher(options) {
14879
14884
  sessionId: tabSessionId ?? clientOpenCodeBrowserSessionId
14880
14885
  }));
14881
14886
  if (refusal)
14882
- return yield* fail4(new Error(refusal));
14887
+ return yield* fail5(new Error(refusal));
14883
14888
  }
14884
14889
  if (message.method === "Browser.getVersion") {
14885
14890
  return {
@@ -14910,7 +14915,7 @@ function createCdpDispatcher(options) {
14910
14915
  if (message.method === "Target.setAutoAttach" && message.sessionId && registry.targets.has(message.sessionId)) {
14911
14916
  const target = cdpRouter.rootForSession(socket, message.sessionId);
14912
14917
  if (!target) {
14913
- return yield* fail4(new Error(`Target not found: ${message.sessionId}`));
14918
+ return yield* fail5(new Error(`Target not found: ${message.sessionId}`));
14914
14919
  }
14915
14920
  const result = yield* sendDebuggerCommand({ tabId: target.tabId, method: "Target.setAutoAttach", params: message.params ?? {} });
14916
14921
  replayChildTargetsForParent({ socket, parentSessionId: target.sessionId, registry, clients: cdpClients });
@@ -14936,7 +14941,7 @@ function createCdpDispatcher(options) {
14936
14941
  replayChildFrameNavigation({ socket, registry, target });
14937
14942
  return { sessionId: target.sessionId };
14938
14943
  }
14939
- return yield* fail4(new Error(`Target not found: ${targetId}`));
14944
+ return yield* fail5(new Error(`Target not found: ${targetId}`));
14940
14945
  }
14941
14946
  if (message.method === "Target.getTargetInfo") {
14942
14947
  const targetId = getString2(message.params, "targetId") ?? "";
@@ -14947,7 +14952,7 @@ function createCdpDispatcher(options) {
14947
14952
  if (!target) {
14948
14953
  if (!targetId && !message.sessionId)
14949
14954
  return {};
14950
- return yield* fail4(new Error(`Target not found: ${targetId || message.sessionId || "unknown"}`));
14955
+ return yield* fail5(new Error(`Target not found: ${targetId || message.sessionId || "unknown"}`));
14951
14956
  }
14952
14957
  return { targetInfo: target.targetInfo };
14953
14958
  }
@@ -15024,7 +15029,7 @@ function createCdpDispatcher(options) {
15024
15029
  return fnUntraced(function* (socket, raw) {
15025
15030
  const message = parseJsonObject(raw);
15026
15031
  if (!isCdpRequest(message)) {
15027
- return yield* fail4(new Error("Invalid CDP request"));
15032
+ return yield* fail5(new Error("Invalid CDP request"));
15028
15033
  }
15029
15034
  const frameTreeSent = message.method === "Page.getFrameTree" ? admitFrameTreeResponse(socket, message.sessionId) : undefined;
15030
15035
  debugLog?.(`cdp<- ${cdpClients.sessionId(socket) ?? "raw"} #${message.id} ${message.method} ${message.sessionId ?? ""}`);
@@ -15076,11 +15081,11 @@ function createExtensionCommands(options) {
15076
15081
  if (tabId !== undefined) {
15077
15082
  const owner = browsers.browserTab(tabId);
15078
15083
  if (!owner)
15079
- return fail4(new Error("browse extension is not connected"));
15084
+ return fail5(new Error("browse extension is not connected"));
15080
15085
  return sendToBrowser(owner.link, { ...command, params: { ...command.params, tabId: owner.tabId } });
15081
15086
  }
15082
15087
  const target = link ?? browsers.defaultLink();
15083
- return target ? sendToBrowser(target, command) : fail4(new Error("browse extension is not connected"));
15088
+ return target ? sendToBrowser(target, command) : fail5(new Error("browse extension is not connected"));
15084
15089
  };
15085
15090
  const sendExtensionBestEffort = (command, link) => {
15086
15091
  runPromise(ignore(sendToExtension(command, link))).catch(() => {});
@@ -15093,13 +15098,13 @@ function createExtensionCommands(options) {
15093
15098
  const sendToEach = (command) => gen(function* () {
15094
15099
  const links = browsers.list().filter((link) => link.rpc.connected);
15095
15100
  if (links.length === 0)
15096
- return yield* fail4(new Error("browse extension is not connected"));
15101
+ return yield* fail5(new Error("browse extension is not connected"));
15097
15102
  const results = yield* forEach(links, (link) => result(sendToBrowser(link, command)), { concurrency: "unbounded" });
15098
15103
  const succeeded = results.find(isSuccess);
15099
15104
  if (succeeded)
15100
15105
  return succeeded.success;
15101
15106
  const failed = results.find(isFailure);
15102
- return yield* fail4(failed?.failure ?? new Error("browse extension is not connected"));
15107
+ return yield* fail5(failed?.failure ?? new Error("browse extension is not connected"));
15103
15108
  });
15104
15109
  return { sendToExtension, sendExtensionBestEffort, sendToEveryBrowser, sendToEach };
15105
15110
  }
@@ -16059,7 +16064,7 @@ function createRelayHousekeeping(options) {
16059
16064
  const first = registry.targetsByTargetId.get(targetId);
16060
16065
  if (!first || first.owner !== "relay")
16061
16066
  return;
16062
- const deadline = (yield* currentTimeMillis2) + releaseTargetGraceMs;
16067
+ const deadline = (yield* currentTimeMillis) + releaseTargetGraceMs;
16063
16068
  while (true) {
16064
16069
  const target = registry.targetsByTargetId.get(targetId);
16065
16070
  if (!target || target.owner !== "relay")
@@ -16069,7 +16074,7 @@ function createRelayHousekeeping(options) {
16069
16074
  yield* sendToExtension({ method: "tabs.remove", params: { tabId: target.tabId } });
16070
16075
  return;
16071
16076
  }
16072
- const remaining = deadline - (yield* currentTimeMillis2);
16077
+ const remaining = deadline - (yield* currentTimeMillis);
16073
16078
  if (remaining <= 0)
16074
16079
  return;
16075
16080
  yield* sleep(Math.min(50, remaining));
@@ -16234,7 +16239,7 @@ function createRelaySettingsSync(options) {
16234
16239
  const extensionSettings = (method, values) => gen(function* () {
16235
16240
  if (!browsers.connected) {
16236
16241
  const rejected = handshake.rejectedProtocol();
16237
- return yield* fail4(new Error(rejected ? handshake.mismatchAdvice(rejected.version) : "The browse extension isn't connected, so its settings can't be read or changed. Ask the user to open the browser with the extension; its options page shows whether it's connected."));
16242
+ return yield* fail5(new Error(rejected ? handshake.mismatchAdvice(rejected.version) : "The browse extension isn't connected, so its settings can't be read or changed. Ask the user to open the browser with the extension; its options page shows whether it's connected."));
16238
16243
  }
16239
16244
  const result = yield* sendToExtension({ method, ...values ? { params: { values } } : {} }).pipe(mapError((error) => /Invalid extension command/.test(error.message) ? new Error(`The connected browse extension is too old to read or change settings from here. Update browse (\`${installCommand()}\`) and reload the extension, or change them on its options page.`) : error));
16240
16245
  return settingsFromExtension(result);
@@ -16724,7 +16729,7 @@ class RootTargetLifecycle {
16724
16729
  run;
16725
16730
  static make = fn("RootTargetLifecycle.make")(function* (options) {
16726
16731
  const scope = yield* make6();
16727
- const run = runForkWith(yield* context());
16732
+ const run = runForkWith(yield* context2());
16728
16733
  return yield* acquireRelease(sync2(() => new RootTargetLifecycle(options, scope, run)), (lifecycle) => lifecycle.close());
16729
16734
  });
16730
16735
  tabs = new Map;
@@ -16859,7 +16864,7 @@ class RootTargetLifecycle {
16859
16864
  const lifecycle = this;
16860
16865
  return suspend2(() => {
16861
16866
  if (lifecycle.closing)
16862
- return fail4(new Error("Relay is closing"));
16867
+ return fail5(new Error("Relay is closing"));
16863
16868
  const generation = expectedGeneration ?? lifecycle.options.extension.generation(tabId);
16864
16869
  const work = lifecycle.tabWork(tabId);
16865
16870
  const revision = work.revision;
@@ -16898,14 +16903,14 @@ class RootTargetLifecycle {
16898
16903
  return yield* new GenerationChanged({ message: "Root target generation changed during reconciliation" });
16899
16904
  });
16900
16905
  step(transition, effect) {
16901
- return this.check(transition).pipe(andThen(effect), catch_((error) => this.check(transition).pipe(andThen(fail4(error)))), tap(() => this.check(transition)));
16906
+ return this.check(transition).pipe(andThen(effect), catch_((error) => this.check(transition).pipe(andThen(fail5(error)))), tap(() => this.check(transition)));
16902
16907
  }
16903
16908
  command(transition, method, params = {}) {
16904
16909
  const send = this.options.extension.send({ method: "debugger.sendCommand", params: { tabId: transition.tabId, method, params } });
16905
16910
  const timeoutMs = transition.timeoutMs;
16906
16911
  return this.step(transition, timeoutMs === undefined ? send : send.pipe(timeoutOrElse({
16907
16912
  duration: timeoutMs,
16908
- orElse: () => fail4(new InventoryTimeout({ message: `${method} did not answer within ${timeoutMs} ms while reconciling tab ${transition.tabId}` }))
16913
+ orElse: () => fail5(new InventoryTimeout({ message: `${method} did not answer within ${timeoutMs} ms while reconciling tab ${transition.tabId}` }))
16909
16914
  })));
16910
16915
  }
16911
16916
  attachUnlocked = fnUntraced(function* (transition, options) {
@@ -16920,7 +16925,7 @@ class RootTargetLifecycle {
16920
16925
  const result = yield* this.command(transition, "Target.getTargetInfo");
16921
16926
  const reportedTargetInfo = getTargetInfo2(result.targetInfo);
16922
16927
  if (!reportedTargetInfo)
16923
- return yield* fail4(new Error("Target.getTargetInfo did not return targetInfo"));
16928
+ return yield* fail5(new Error("Target.getTargetInfo did not return targetInfo"));
16924
16929
  const targetInfo = options.openerTargetId && !reportedTargetInfo.openerId ? { ...reportedTargetInfo, openerId: options.openerTargetId } : reportedTargetInfo;
16925
16930
  const restored = options.opencodeBrowserSessionId ? undefined : this.options.sessions.persistedTargetOwner(targetInfo.targetId);
16926
16931
  const opencodeBrowserSessionId = options.opencodeBrowserSessionId ?? restored?.sessionId;
@@ -16944,7 +16949,7 @@ class RootTargetLifecycle {
16944
16949
  yield* this.check(transition);
16945
16950
  const targetInfo = getTargetInfo2(result.targetInfo);
16946
16951
  if (!targetInfo) {
16947
- return yield* fail4(new Error(staged ? "Unable to verify staged root target" : "Unable to verify committed root target"));
16952
+ return yield* fail5(new Error(staged ? "Unable to verify staged root target" : "Unable to verify committed root target"));
16948
16953
  }
16949
16954
  if (staged?.targetInfo.targetId === targetInfo.targetId) {
16950
16955
  yield* this.finish(transition, staged);
@@ -16967,11 +16972,11 @@ class RootTargetLifecycle {
16967
16972
  yield* this.command(transition, "Target.setAutoAttach", autoAttachParams ?? { autoAttach: true, waitForDebuggerOnStart: false, flatten: true });
16968
16973
  const result = yield* this.command(transition, "Target.getTargetInfo");
16969
16974
  if (getTargetInfo2(result.targetInfo)?.targetId !== target.targetInfo.targetId) {
16970
- return yield* fail4(new Error(`Root target changed while preparing ${target.targetInfo.targetId}`));
16975
+ return yield* fail5(new Error(`Root target changed while preparing ${target.targetInfo.targetId}`));
16971
16976
  }
16972
16977
  const change = registry.commitStagedRootTarget(target.tabId, target.sessionId);
16973
16978
  if (!change)
16974
- return yield* fail4(new Error(`Staged root target changed before commit: ${target.targetInfo.targetId}`));
16979
+ return yield* fail5(new Error(`Staged root target changed before commit: ${target.targetInfo.targetId}`));
16975
16980
  transition.root = change.target;
16976
16981
  transition.staged = undefined;
16977
16982
  if (change.kind === "replaced") {
@@ -17466,7 +17471,7 @@ var makeRelay = fnUntraced(function* (options = {}) {
17466
17471
  },
17467
17472
  checkBrowserResponsive: (key) => {
17468
17473
  const link = browsers.byKey(key);
17469
- return link ? link.rpc.send({ method: "ping" }).pipe(asVoid2) : fail4(new Error("The browser disconnected before execution."));
17474
+ return link ? link.rpc.send({ method: "ping" }).pipe(asVoid2) : fail5(new Error("The browser disconnected before execution."));
17470
17475
  },
17471
17476
  targetBrowserKey: (tabId) => browsers.ownerKey(tabId),
17472
17477
  getUserAttachedPageUrls: (session) => registry.listRootTargets().filter((target) => target.owner === "user" && browsers.ownerKey(target.tabId) === session.browser?.key).map((target) => target.targetInfo.url || "about:blank"),
@@ -17560,7 +17565,7 @@ var makeRelay = fnUntraced(function* (options = {}) {
17560
17565
  const restartTimeoutMs = yield* Int("OPENCODE_BROWSER_RESTART_TIMEOUT_MS").pipe(withDefault(1e4));
17561
17566
  const clientGoneGraceMs = yield* Int("OPENCODE_BROWSER_CLIENT_GONE_GRACE_MS").pipe(withDefault(60000));
17562
17567
  const restartRequestId = yield* option(String2("OPENCODE_BROWSER_RESTART_REQUEST_ID"));
17563
- const lifecycleLogPath = path14.join(path14.dirname(defaultSessionCatalogPath(port)), "lifecycle.jsonl");
17568
+ const lifecycleLogPath = path14.join(stateRoot(), "relays", String(port), "lifecycle.jsonl");
17564
17569
  const audit = (event) => try_(() => appendRelayLifecycleEvent(lifecycleLogPath, event));
17565
17570
  function setProtectedUi(tabId, protectedUi) {
17566
17571
  const changed = registry.markRootTargetProtectedUi(tabId, protectedUi);
@@ -17610,18 +17615,18 @@ var makeRelay = fnUntraced(function* (options = {}) {
17610
17615
  const session = sessionId && sessions.sessions.get(sessionId);
17611
17616
  if (session) {
17612
17617
  const link = handshake.resolveSessionBrowser(undefined, session);
17613
- return "error" in link ? fail4(new Error(link.error)) : succeed6(link);
17618
+ return "error" in link ? fail5(new Error(link.error)) : succeed6(link);
17614
17619
  }
17615
17620
  const existing = sessionId ? registry.listRootTargets().find((target) => target.opencodeBrowserSessionId === sessionId && target.owner === "relay") : undefined;
17616
17621
  const link = (existing && browsers.browserTab(existing.tabId)?.link) ?? browsers.defaultLink();
17617
- return link ? succeed6(link) : fail4(new Error("browse extension is not connected"));
17622
+ return link ? succeed6(link) : fail5(new Error("browse extension is not connected"));
17618
17623
  });
17619
17624
  const createAndAttachTab = fnUntraced(function* (createOptions) {
17620
17625
  const link = yield* sessionBrowser(createOptions.opencodeBrowserSessionId);
17621
17626
  const result = yield* sendToExtension({ method: "tabs.create", params: { url: createOptions.url, active: createOptions.active, ...agentWindow ? { window: agentWindow } : {} } }, link);
17622
17627
  const tabId = getNumber2(result, "tabId");
17623
17628
  if (!tabId)
17624
- return yield* fail4(new Error("tabs.create did not return a tabId"));
17629
+ return yield* fail5(new Error("tabs.create did not return a tabId"));
17625
17630
  announceTab(tabId);
17626
17631
  return yield* rootLifecycle.attach({
17627
17632
  tabId,
@@ -17838,7 +17843,7 @@ var makeRelay = fnUntraced(function* (options = {}) {
17838
17843
  yield* catch_(listenHttpServer2({ server: httpServer, host: listenHost, port }), (error) => {
17839
17844
  return gen(function* () {
17840
17845
  yield* cleanup();
17841
- return yield* fail4(error);
17846
+ return yield* fail5(error);
17842
17847
  });
17843
17848
  });
17844
17849
  yield* sync2(() => pruneStaleExecuteFilesDirectories());
@@ -17873,7 +17878,7 @@ var makeRelay = fnUntraced(function* (options = {}) {
17873
17878
  relayReady = true;
17874
17879
  updates.refresh();
17875
17880
  startTimers();
17876
- const runtime = managed ? npmRuntime() : undefined;
17881
+ const runtime = managed ? installedRuntime2() : undefined;
17877
17882
  if (runtime) {
17878
17883
  autoUpdater = createAutoUpdater({
17879
17884
  runtime,
@@ -17896,7 +17901,7 @@ var makeRelay = fnUntraced(function* (options = {}) {
17896
17901
  relayLog("relay.ready", { url: endpointUrl, version: opencodeBrowserVersion2, build: opencodeBrowserBuildId2, pid: process.pid, managed });
17897
17902
  }), (error) => gen(function* () {
17898
17903
  yield* cleanup();
17899
- return yield* fail4(error);
17904
+ return yield* fail5(error);
17900
17905
  }));
17901
17906
  return {
17902
17907
  url: endpointUrl,