@opencode/browse 0.0.11-dev.75 → 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.
- package/dist/{cli-5980z4hc.mjs → cli-mx6tbg2m.mjs} +63 -52
- package/dist/cli.mjs +30 -19
- package/dist/{helpers-h1mvscyw.mjs → helpers-hgm1z9h5.mjs} +2 -2
- package/dist/{index-0dcypq31.mjs → index-yzz55kxm.mjs} +1 -1
- package/dist/{main-d1hydckg.mjs → main-1fdejpga.mjs} +9 -9
- package/dist/{main-tcae6pr3.mjs → main-6chyyr6j.mjs} +44 -39
- package/dist/{main-rt6g5418.mjs → main-8z9d979q.mjs} +15 -15
- package/dist/{setup-q1sfzdr9.mjs → main-b7g6460c.mjs} +3608 -4406
- package/dist/{main-gevbt7h7.mjs → main-csnx585b.mjs} +151 -151
- package/dist/{main-j38051kb.mjs → main-cymarjp4.mjs} +47 -47
- package/dist/main-j2ehvkhk.mjs +465 -0
- package/dist/main-r3a6053j.mjs +157 -0
- package/dist/main-s7017yah.mjs +161 -0
- package/dist/main-sjrzyg3x.mjs +73 -0
- package/dist/main-vgzr4689.mjs +61 -0
- package/dist/{main-5vffh0gd.mjs → main-zq79yb8r.mjs} +6 -6
- package/dist/main-zya5ttbr.mjs +4 -0
- package/dist/{mcp-x1vq2n6t.mjs → mcp-h0qcxhqc.mjs} +138 -137
- package/dist/migrate-pgckfkg5.mjs +233 -0
- package/dist/{relay-94r2w21z.mjs → relay-gafgjtav.mjs} +191 -129
- package/dist/runtime-update-p2pnfdy1.mjs +156 -0
- package/dist/setup-fhhjnx9r.mjs +956 -0
- package/dist/{skill-text-x7sccp6h.mjs → skill-text-6p6scqwe.mjs} +2 -2
- package/dist/{supervisor-e2w15458.mjs → supervisor-06t66v4t.mjs} +38 -17
- package/dist/{update-c8xwkt5v.mjs → update-7hagfdc0.mjs} +3 -3
- package/dist/{version-0jtmhnzb.mjs → version-hhcvk9wm.mjs} +1 -1
- package/package.json +1 -1
- package/skills/browse/SKILL.md +2 -2
- package/dist/main-jkq3ey3t.mjs +0 -805
- package/dist/main-nhr7bg32.mjs +0 -131
- package/dist/main-s5mqta5j.mjs +0 -303
- package/dist/main-wpbmhp3v.mjs +0 -4
- package/dist/runtime-update-g516gc7h.mjs +0 -200
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
opencodeBrowserVersion2,
|
|
3
3
|
opencodeBrowserBuildId2
|
|
4
|
-
} from "./main-
|
|
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
|
-
|
|
17
|
+
installedRuntime2,
|
|
17
18
|
autoUpdateOverride,
|
|
18
19
|
storedMode,
|
|
19
20
|
setStoredMode,
|
|
20
21
|
autoUpdateStatus,
|
|
21
22
|
createAutoUpdater
|
|
22
|
-
} from "./main-
|
|
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
|
-
|
|
44
|
-
relayToken,
|
|
45
|
-
secretsEqual,
|
|
46
|
-
ensurePrivateDirectory
|
|
47
|
-
} from "./main-nhr7bg32.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-
|
|
98
|
+
} from "./main-6chyyr6j.mjs";
|
|
102
99
|
import {
|
|
103
|
-
|
|
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
|
-
|
|
122
|
-
syncDevExtension
|
|
123
|
-
} from "./main-s5mqta5j.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-
|
|
144
|
+
} from "./main-cymarjp4.mjs";
|
|
152
145
|
import {
|
|
153
146
|
defaultJournalBaseDir,
|
|
154
147
|
makeJournalEntry,
|
|
155
148
|
appendJournalEntry,
|
|
156
149
|
startJournalRetention
|
|
157
|
-
} from "./main-
|
|
150
|
+
} from "./main-zq79yb8r.mjs";
|
|
158
151
|
import {
|
|
159
152
|
createUpdateWatcher2
|
|
160
|
-
} from "./main-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
261
|
+
TaggedError2,
|
|
262
|
+
join,
|
|
263
|
+
interrupt3,
|
|
264
|
+
makeUnsafe5
|
|
265
|
+
} from "./main-csnx585b.mjs";
|
|
260
266
|
import {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
420
|
+
return finish(fail5(new Error(browserUnresponsive)));
|
|
416
421
|
}
|
|
417
422
|
this.probeLiveness(socket);
|
|
418
|
-
finish(
|
|
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(
|
|
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(
|
|
438
|
+
finish(fail5(new Error(`send extension command: ${command.method}`, { cause: error })));
|
|
434
439
|
}
|
|
435
440
|
});
|
|
436
441
|
} catch (error) {
|
|
437
|
-
finish(
|
|
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
|
-
}) :
|
|
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
|
|
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(
|
|
1996
|
+
function normalizeOrigin(value2) {
|
|
1992
1997
|
let url;
|
|
1993
1998
|
try {
|
|
1994
|
-
url = new URL(
|
|
1999
|
+
url = new URL(value2);
|
|
1995
2000
|
} catch (cause) {
|
|
1996
2001
|
throw new AuthenticatedOriginError({
|
|
1997
|
-
message: `Invalid authenticated origin: ${
|
|
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: ${
|
|
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: ${
|
|
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,
|
|
2033
|
-
const url = new URL(
|
|
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(
|
|
2047
|
+
function pageOrigin(value2) {
|
|
2043
2048
|
try {
|
|
2044
|
-
return new URL(
|
|
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: () =>
|
|
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) =>
|
|
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
|
-
}),
|
|
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 =
|
|
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
|
|
5248
|
-
if (!
|
|
5252
|
+
const value2 = element.getAttribute(attribute);
|
|
5253
|
+
if (!value2)
|
|
5249
5254
|
continue;
|
|
5250
|
-
const candidate = `[${attribute}="${CSS.escape(
|
|
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:
|
|
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*
|
|
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
|
|
6592
|
-
if (
|
|
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(
|
|
6600
|
-
if (
|
|
6601
|
-
return
|
|
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(
|
|
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: () =>
|
|
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
|
|
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 =
|
|
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*
|
|
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*
|
|
11739
|
+
yield* fail4(result2, cleanup.failure);
|
|
11735
11740
|
return;
|
|
11736
11741
|
}
|
|
11737
11742
|
}
|
|
11738
|
-
yield*
|
|
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(
|
|
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: () =>
|
|
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(
|
|
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()) :
|
|
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
|
|
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" ?
|
|
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: () =>
|
|
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
|
|
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
|
|
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(
|
|
12593
|
-
if (
|
|
12597
|
+
function optionalInteger(value2, field) {
|
|
12598
|
+
if (value2 === undefined) {
|
|
12594
12599
|
return;
|
|
12595
12600
|
}
|
|
12596
|
-
if (!isNumber(
|
|
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
|
|
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] =
|
|
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] =
|
|
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] =
|
|
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] =
|
|
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] =
|
|
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:
|
|
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) {
|
|
@@ -14233,9 +14238,66 @@ var alwaysBlocked = new Map([
|
|
|
14233
14238
|
["Network.deleteCookies", "it would delete the user's cookies and can log them out"],
|
|
14234
14239
|
["Storage.clearDataForOrigin", "it would erase a site's cookies and stored data in the user's browser"],
|
|
14235
14240
|
["Storage.clearDataForStorageKey", "it would erase a site's stored data in the user's browser"],
|
|
14236
|
-
["Browser.close", "it would close the user's browser"]
|
|
14241
|
+
["Browser.close", "it would close the user's browser"],
|
|
14242
|
+
["Browser.grantPermissions", "it would grant a site permissions the user never approved"],
|
|
14243
|
+
["Browser.setPermission", "it would change a site permission without the user's approval"],
|
|
14244
|
+
["Browser.resetPermissions", "it would reset the user's site permissions"]
|
|
14245
|
+
]);
|
|
14246
|
+
var readOnlyAllowedMethods = new Set([
|
|
14247
|
+
"Browser.getVersion",
|
|
14248
|
+
"Browser.getWindowForTarget",
|
|
14249
|
+
"Browser.setDownloadBehavior",
|
|
14250
|
+
"Target.attachToBrowserTarget",
|
|
14251
|
+
"Target.attachToTarget",
|
|
14252
|
+
"Target.detachFromTarget",
|
|
14253
|
+
"Target.getTargetInfo",
|
|
14254
|
+
"Target.getTargets",
|
|
14255
|
+
"Target.setAutoAttach",
|
|
14256
|
+
"Target.setDiscoverTargets",
|
|
14257
|
+
"Page.getFrameTree",
|
|
14258
|
+
"Page.getLayoutMetrics",
|
|
14259
|
+
"Page.getNavigationHistory",
|
|
14260
|
+
"Page.getResourceTree",
|
|
14261
|
+
"Page.captureScreenshot",
|
|
14262
|
+
"Page.addScriptToEvaluateOnNewDocument",
|
|
14263
|
+
"Page.createIsolatedWorld",
|
|
14264
|
+
"Page.setLifecycleEventsEnabled",
|
|
14265
|
+
"Runtime.callFunctionOn",
|
|
14266
|
+
"Runtime.evaluate",
|
|
14267
|
+
"Runtime.getProperties",
|
|
14268
|
+
"Runtime.releaseObject",
|
|
14269
|
+
"Runtime.releaseObjectGroup",
|
|
14270
|
+
"Runtime.runIfWaitingForDebugger",
|
|
14271
|
+
"Accessibility.getAXNodeAndAncestors",
|
|
14272
|
+
"Accessibility.getFullAXTree",
|
|
14273
|
+
"Accessibility.getPartialAXTree",
|
|
14274
|
+
"Accessibility.getRootAXNode",
|
|
14275
|
+
"Accessibility.queryAXTree",
|
|
14276
|
+
"DOM.describeNode",
|
|
14277
|
+
"DOM.getAttributes",
|
|
14278
|
+
"DOM.getBoxModel",
|
|
14279
|
+
"DOM.getContentQuads",
|
|
14280
|
+
"DOM.getDocument",
|
|
14281
|
+
"DOM.getFrameOwner",
|
|
14282
|
+
"DOM.getNodeForLocation",
|
|
14283
|
+
"DOM.querySelector",
|
|
14284
|
+
"DOM.querySelectorAll",
|
|
14285
|
+
"DOM.resolveNode",
|
|
14286
|
+
"Network.getAllCookies",
|
|
14287
|
+
"Network.getCookies",
|
|
14288
|
+
"Storage.getCookies",
|
|
14289
|
+
"Emulation.setEmulatedMedia",
|
|
14290
|
+
"Emulation.setFocusEmulationEnabled",
|
|
14291
|
+
"Network.setCacheDisabled"
|
|
14237
14292
|
]);
|
|
14238
|
-
var
|
|
14293
|
+
var readOnlySubscriptionDomains = ["Accessibility.", "DOM.", "Log.", "Network.", "Page.", "Performance.", "Runtime."];
|
|
14294
|
+
function isReadOnlyAllowed(method) {
|
|
14295
|
+
if (readOnlyAllowedMethods.has(method))
|
|
14296
|
+
return true;
|
|
14297
|
+
if (!method.endsWith(".enable") && !method.endsWith(".disable"))
|
|
14298
|
+
return false;
|
|
14299
|
+
return readOnlySubscriptionDomains.some((domain) => method.startsWith(domain));
|
|
14300
|
+
}
|
|
14239
14301
|
var allowAllCookiesEnvironmentVariable = "OPENCODE_BROWSER_ALLOW_ALL_COOKIES";
|
|
14240
14302
|
var allowsAllCookies = () => process.env[allowAllCookiesEnvironmentVariable] === "1";
|
|
14241
14303
|
var allowsForeground = () => process.env.OPENCODE_BROWSER_ALLOW_FOREGROUND === "1";
|
|
@@ -14404,6 +14466,10 @@ function guardCdpMethod(context) {
|
|
|
14404
14466
|
if (context.method.startsWith("WebAuthn.")) {
|
|
14405
14467
|
return `browse blocked ${context.method}: agents can't drive WebAuthn or add virtual authenticators. This command is always blocked by the relay.`;
|
|
14406
14468
|
}
|
|
14469
|
+
if (context.readOnly && !isReadOnlyAllowed(context.method)) {
|
|
14470
|
+
const session = context.sessionId ? `Session ${context.sessionId}` : "This session";
|
|
14471
|
+
return `${session} is read-only: ${context.method} is blocked because this tab is read-only. Read-only sessions can take snapshots and screenshots, read page information and subscribe to events. Use a session created without --read-only to interact with pages.`;
|
|
14472
|
+
}
|
|
14407
14473
|
if (context.method === "Page.bringToFront" && !allowsForeground()) {
|
|
14408
14474
|
return "browse blocked Page.bringToFront: it raises the user's browser window over their work. Use handoff() when the user needs to act in the tab, or set OPENCODE_BROWSER_ALLOW_FOREGROUND=1 on the relay to allow it.";
|
|
14409
14475
|
}
|
|
@@ -14428,10 +14494,6 @@ function guardCdpMethod(context) {
|
|
|
14428
14494
|
return `browse blocked Network.loadNetworkResource: it loads URLs with the user's credentials outside the page's same-origin policy, so only the hosts of this session's attached pages (${formatAllowedHosts(hosts)}) are allowed. Set ${allowAllStorageEnvironmentVariable}=1 on the relay to allow it.`;
|
|
14429
14495
|
}
|
|
14430
14496
|
}
|
|
14431
|
-
if (context.readOnly && readOnlyBlockedPrefixes.some((prefix) => context.method.startsWith(prefix))) {
|
|
14432
|
-
const session = context.sessionId ? `Session ${context.sessionId}` : "This session";
|
|
14433
|
-
return `${session} is read-only: ${context.method} is blocked. Use a session created without --read-only to interact with pages.`;
|
|
14434
|
-
}
|
|
14435
14497
|
return null;
|
|
14436
14498
|
}
|
|
14437
14499
|
function scopeCdpResult(options) {
|
|
@@ -14796,7 +14858,7 @@ function createCdpDispatcher(options) {
|
|
|
14796
14858
|
const routeCdpCommand = fn("Relay.routeCdpCommand")(function* (socket, message) {
|
|
14797
14859
|
const clientOpenCodeBrowserSessionId = cdpClients.sessionId(socket);
|
|
14798
14860
|
if (!shutdownControl.accepting && (!cdpClients.isSandbox(socket) || !clientOpenCodeBrowserSessionId || !sessions.hasPendingWork(clientOpenCodeBrowserSessionId))) {
|
|
14799
|
-
return yield*
|
|
14861
|
+
return yield* fail5(new Error("Relay is draining for an explicit restart"));
|
|
14800
14862
|
}
|
|
14801
14863
|
const guardMessage = guardCdpMethod({
|
|
14802
14864
|
method: message.method,
|
|
@@ -14806,7 +14868,7 @@ function createCdpDispatcher(options) {
|
|
|
14806
14868
|
pageUrls: () => cdpRouter.visibleRoots(socket).map((target) => target.targetInfo.url)
|
|
14807
14869
|
});
|
|
14808
14870
|
if (guardMessage) {
|
|
14809
|
-
return yield*
|
|
14871
|
+
return yield* fail5(new Error(guardMessage));
|
|
14810
14872
|
}
|
|
14811
14873
|
if (message.method === "Page.navigate" || message.method === "Target.createTarget") {
|
|
14812
14874
|
const tabSessionId = message.method === "Page.navigate" ? (() => {
|
|
@@ -14822,7 +14884,7 @@ function createCdpDispatcher(options) {
|
|
|
14822
14884
|
sessionId: tabSessionId ?? clientOpenCodeBrowserSessionId
|
|
14823
14885
|
}));
|
|
14824
14886
|
if (refusal)
|
|
14825
|
-
return yield*
|
|
14887
|
+
return yield* fail5(new Error(refusal));
|
|
14826
14888
|
}
|
|
14827
14889
|
if (message.method === "Browser.getVersion") {
|
|
14828
14890
|
return {
|
|
@@ -14853,7 +14915,7 @@ function createCdpDispatcher(options) {
|
|
|
14853
14915
|
if (message.method === "Target.setAutoAttach" && message.sessionId && registry.targets.has(message.sessionId)) {
|
|
14854
14916
|
const target = cdpRouter.rootForSession(socket, message.sessionId);
|
|
14855
14917
|
if (!target) {
|
|
14856
|
-
return yield*
|
|
14918
|
+
return yield* fail5(new Error(`Target not found: ${message.sessionId}`));
|
|
14857
14919
|
}
|
|
14858
14920
|
const result = yield* sendDebuggerCommand({ tabId: target.tabId, method: "Target.setAutoAttach", params: message.params ?? {} });
|
|
14859
14921
|
replayChildTargetsForParent({ socket, parentSessionId: target.sessionId, registry, clients: cdpClients });
|
|
@@ -14879,7 +14941,7 @@ function createCdpDispatcher(options) {
|
|
|
14879
14941
|
replayChildFrameNavigation({ socket, registry, target });
|
|
14880
14942
|
return { sessionId: target.sessionId };
|
|
14881
14943
|
}
|
|
14882
|
-
return yield*
|
|
14944
|
+
return yield* fail5(new Error(`Target not found: ${targetId}`));
|
|
14883
14945
|
}
|
|
14884
14946
|
if (message.method === "Target.getTargetInfo") {
|
|
14885
14947
|
const targetId = getString2(message.params, "targetId") ?? "";
|
|
@@ -14890,7 +14952,7 @@ function createCdpDispatcher(options) {
|
|
|
14890
14952
|
if (!target) {
|
|
14891
14953
|
if (!targetId && !message.sessionId)
|
|
14892
14954
|
return {};
|
|
14893
|
-
return yield*
|
|
14955
|
+
return yield* fail5(new Error(`Target not found: ${targetId || message.sessionId || "unknown"}`));
|
|
14894
14956
|
}
|
|
14895
14957
|
return { targetInfo: target.targetInfo };
|
|
14896
14958
|
}
|
|
@@ -14967,7 +15029,7 @@ function createCdpDispatcher(options) {
|
|
|
14967
15029
|
return fnUntraced(function* (socket, raw) {
|
|
14968
15030
|
const message = parseJsonObject(raw);
|
|
14969
15031
|
if (!isCdpRequest(message)) {
|
|
14970
|
-
return yield*
|
|
15032
|
+
return yield* fail5(new Error("Invalid CDP request"));
|
|
14971
15033
|
}
|
|
14972
15034
|
const frameTreeSent = message.method === "Page.getFrameTree" ? admitFrameTreeResponse(socket, message.sessionId) : undefined;
|
|
14973
15035
|
debugLog?.(`cdp<- ${cdpClients.sessionId(socket) ?? "raw"} #${message.id} ${message.method} ${message.sessionId ?? ""}`);
|
|
@@ -15019,11 +15081,11 @@ function createExtensionCommands(options) {
|
|
|
15019
15081
|
if (tabId !== undefined) {
|
|
15020
15082
|
const owner = browsers.browserTab(tabId);
|
|
15021
15083
|
if (!owner)
|
|
15022
|
-
return
|
|
15084
|
+
return fail5(new Error("browse extension is not connected"));
|
|
15023
15085
|
return sendToBrowser(owner.link, { ...command, params: { ...command.params, tabId: owner.tabId } });
|
|
15024
15086
|
}
|
|
15025
15087
|
const target = link ?? browsers.defaultLink();
|
|
15026
|
-
return target ? sendToBrowser(target, command) :
|
|
15088
|
+
return target ? sendToBrowser(target, command) : fail5(new Error("browse extension is not connected"));
|
|
15027
15089
|
};
|
|
15028
15090
|
const sendExtensionBestEffort = (command, link) => {
|
|
15029
15091
|
runPromise(ignore(sendToExtension(command, link))).catch(() => {});
|
|
@@ -15036,13 +15098,13 @@ function createExtensionCommands(options) {
|
|
|
15036
15098
|
const sendToEach = (command) => gen(function* () {
|
|
15037
15099
|
const links = browsers.list().filter((link) => link.rpc.connected);
|
|
15038
15100
|
if (links.length === 0)
|
|
15039
|
-
return yield*
|
|
15101
|
+
return yield* fail5(new Error("browse extension is not connected"));
|
|
15040
15102
|
const results = yield* forEach(links, (link) => result(sendToBrowser(link, command)), { concurrency: "unbounded" });
|
|
15041
15103
|
const succeeded = results.find(isSuccess);
|
|
15042
15104
|
if (succeeded)
|
|
15043
15105
|
return succeeded.success;
|
|
15044
15106
|
const failed = results.find(isFailure);
|
|
15045
|
-
return yield*
|
|
15107
|
+
return yield* fail5(failed?.failure ?? new Error("browse extension is not connected"));
|
|
15046
15108
|
});
|
|
15047
15109
|
return { sendToExtension, sendExtensionBestEffort, sendToEveryBrowser, sendToEach };
|
|
15048
15110
|
}
|
|
@@ -16002,7 +16064,7 @@ function createRelayHousekeeping(options) {
|
|
|
16002
16064
|
const first = registry.targetsByTargetId.get(targetId);
|
|
16003
16065
|
if (!first || first.owner !== "relay")
|
|
16004
16066
|
return;
|
|
16005
|
-
const deadline = (yield*
|
|
16067
|
+
const deadline = (yield* currentTimeMillis) + releaseTargetGraceMs;
|
|
16006
16068
|
while (true) {
|
|
16007
16069
|
const target = registry.targetsByTargetId.get(targetId);
|
|
16008
16070
|
if (!target || target.owner !== "relay")
|
|
@@ -16012,7 +16074,7 @@ function createRelayHousekeeping(options) {
|
|
|
16012
16074
|
yield* sendToExtension({ method: "tabs.remove", params: { tabId: target.tabId } });
|
|
16013
16075
|
return;
|
|
16014
16076
|
}
|
|
16015
|
-
const remaining = deadline - (yield*
|
|
16077
|
+
const remaining = deadline - (yield* currentTimeMillis);
|
|
16016
16078
|
if (remaining <= 0)
|
|
16017
16079
|
return;
|
|
16018
16080
|
yield* sleep(Math.min(50, remaining));
|
|
@@ -16177,7 +16239,7 @@ function createRelaySettingsSync(options) {
|
|
|
16177
16239
|
const extensionSettings = (method, values) => gen(function* () {
|
|
16178
16240
|
if (!browsers.connected) {
|
|
16179
16241
|
const rejected = handshake.rejectedProtocol();
|
|
16180
|
-
return yield*
|
|
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."));
|
|
16181
16243
|
}
|
|
16182
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));
|
|
16183
16245
|
return settingsFromExtension(result);
|
|
@@ -16667,7 +16729,7 @@ class RootTargetLifecycle {
|
|
|
16667
16729
|
run;
|
|
16668
16730
|
static make = fn("RootTargetLifecycle.make")(function* (options) {
|
|
16669
16731
|
const scope = yield* make6();
|
|
16670
|
-
const run = runForkWith(yield*
|
|
16732
|
+
const run = runForkWith(yield* context2());
|
|
16671
16733
|
return yield* acquireRelease(sync2(() => new RootTargetLifecycle(options, scope, run)), (lifecycle) => lifecycle.close());
|
|
16672
16734
|
});
|
|
16673
16735
|
tabs = new Map;
|
|
@@ -16802,7 +16864,7 @@ class RootTargetLifecycle {
|
|
|
16802
16864
|
const lifecycle = this;
|
|
16803
16865
|
return suspend2(() => {
|
|
16804
16866
|
if (lifecycle.closing)
|
|
16805
|
-
return
|
|
16867
|
+
return fail5(new Error("Relay is closing"));
|
|
16806
16868
|
const generation = expectedGeneration ?? lifecycle.options.extension.generation(tabId);
|
|
16807
16869
|
const work = lifecycle.tabWork(tabId);
|
|
16808
16870
|
const revision = work.revision;
|
|
@@ -16841,14 +16903,14 @@ class RootTargetLifecycle {
|
|
|
16841
16903
|
return yield* new GenerationChanged({ message: "Root target generation changed during reconciliation" });
|
|
16842
16904
|
});
|
|
16843
16905
|
step(transition, effect) {
|
|
16844
|
-
return this.check(transition).pipe(andThen(effect), catch_((error) => this.check(transition).pipe(andThen(
|
|
16906
|
+
return this.check(transition).pipe(andThen(effect), catch_((error) => this.check(transition).pipe(andThen(fail5(error)))), tap(() => this.check(transition)));
|
|
16845
16907
|
}
|
|
16846
16908
|
command(transition, method, params = {}) {
|
|
16847
16909
|
const send = this.options.extension.send({ method: "debugger.sendCommand", params: { tabId: transition.tabId, method, params } });
|
|
16848
16910
|
const timeoutMs = transition.timeoutMs;
|
|
16849
16911
|
return this.step(transition, timeoutMs === undefined ? send : send.pipe(timeoutOrElse({
|
|
16850
16912
|
duration: timeoutMs,
|
|
16851
|
-
orElse: () =>
|
|
16913
|
+
orElse: () => fail5(new InventoryTimeout({ message: `${method} did not answer within ${timeoutMs} ms while reconciling tab ${transition.tabId}` }))
|
|
16852
16914
|
})));
|
|
16853
16915
|
}
|
|
16854
16916
|
attachUnlocked = fnUntraced(function* (transition, options) {
|
|
@@ -16863,7 +16925,7 @@ class RootTargetLifecycle {
|
|
|
16863
16925
|
const result = yield* this.command(transition, "Target.getTargetInfo");
|
|
16864
16926
|
const reportedTargetInfo = getTargetInfo2(result.targetInfo);
|
|
16865
16927
|
if (!reportedTargetInfo)
|
|
16866
|
-
return yield*
|
|
16928
|
+
return yield* fail5(new Error("Target.getTargetInfo did not return targetInfo"));
|
|
16867
16929
|
const targetInfo = options.openerTargetId && !reportedTargetInfo.openerId ? { ...reportedTargetInfo, openerId: options.openerTargetId } : reportedTargetInfo;
|
|
16868
16930
|
const restored = options.opencodeBrowserSessionId ? undefined : this.options.sessions.persistedTargetOwner(targetInfo.targetId);
|
|
16869
16931
|
const opencodeBrowserSessionId = options.opencodeBrowserSessionId ?? restored?.sessionId;
|
|
@@ -16887,7 +16949,7 @@ class RootTargetLifecycle {
|
|
|
16887
16949
|
yield* this.check(transition);
|
|
16888
16950
|
const targetInfo = getTargetInfo2(result.targetInfo);
|
|
16889
16951
|
if (!targetInfo) {
|
|
16890
|
-
return yield*
|
|
16952
|
+
return yield* fail5(new Error(staged ? "Unable to verify staged root target" : "Unable to verify committed root target"));
|
|
16891
16953
|
}
|
|
16892
16954
|
if (staged?.targetInfo.targetId === targetInfo.targetId) {
|
|
16893
16955
|
yield* this.finish(transition, staged);
|
|
@@ -16910,11 +16972,11 @@ class RootTargetLifecycle {
|
|
|
16910
16972
|
yield* this.command(transition, "Target.setAutoAttach", autoAttachParams ?? { autoAttach: true, waitForDebuggerOnStart: false, flatten: true });
|
|
16911
16973
|
const result = yield* this.command(transition, "Target.getTargetInfo");
|
|
16912
16974
|
if (getTargetInfo2(result.targetInfo)?.targetId !== target.targetInfo.targetId) {
|
|
16913
|
-
return yield*
|
|
16975
|
+
return yield* fail5(new Error(`Root target changed while preparing ${target.targetInfo.targetId}`));
|
|
16914
16976
|
}
|
|
16915
16977
|
const change = registry.commitStagedRootTarget(target.tabId, target.sessionId);
|
|
16916
16978
|
if (!change)
|
|
16917
|
-
return yield*
|
|
16979
|
+
return yield* fail5(new Error(`Staged root target changed before commit: ${target.targetInfo.targetId}`));
|
|
16918
16980
|
transition.root = change.target;
|
|
16919
16981
|
transition.staged = undefined;
|
|
16920
16982
|
if (change.kind === "replaced") {
|
|
@@ -17409,7 +17471,7 @@ var makeRelay = fnUntraced(function* (options = {}) {
|
|
|
17409
17471
|
},
|
|
17410
17472
|
checkBrowserResponsive: (key) => {
|
|
17411
17473
|
const link = browsers.byKey(key);
|
|
17412
|
-
return link ? link.rpc.send({ method: "ping" }).pipe(asVoid2) :
|
|
17474
|
+
return link ? link.rpc.send({ method: "ping" }).pipe(asVoid2) : fail5(new Error("The browser disconnected before execution."));
|
|
17413
17475
|
},
|
|
17414
17476
|
targetBrowserKey: (tabId) => browsers.ownerKey(tabId),
|
|
17415
17477
|
getUserAttachedPageUrls: (session) => registry.listRootTargets().filter((target) => target.owner === "user" && browsers.ownerKey(target.tabId) === session.browser?.key).map((target) => target.targetInfo.url || "about:blank"),
|
|
@@ -17503,7 +17565,7 @@ var makeRelay = fnUntraced(function* (options = {}) {
|
|
|
17503
17565
|
const restartTimeoutMs = yield* Int("OPENCODE_BROWSER_RESTART_TIMEOUT_MS").pipe(withDefault(1e4));
|
|
17504
17566
|
const clientGoneGraceMs = yield* Int("OPENCODE_BROWSER_CLIENT_GONE_GRACE_MS").pipe(withDefault(60000));
|
|
17505
17567
|
const restartRequestId = yield* option(String2("OPENCODE_BROWSER_RESTART_REQUEST_ID"));
|
|
17506
|
-
const lifecycleLogPath = path14.join(
|
|
17568
|
+
const lifecycleLogPath = path14.join(stateRoot(), "relays", String(port), "lifecycle.jsonl");
|
|
17507
17569
|
const audit = (event) => try_(() => appendRelayLifecycleEvent(lifecycleLogPath, event));
|
|
17508
17570
|
function setProtectedUi(tabId, protectedUi) {
|
|
17509
17571
|
const changed = registry.markRootTargetProtectedUi(tabId, protectedUi);
|
|
@@ -17553,18 +17615,18 @@ var makeRelay = fnUntraced(function* (options = {}) {
|
|
|
17553
17615
|
const session = sessionId && sessions.sessions.get(sessionId);
|
|
17554
17616
|
if (session) {
|
|
17555
17617
|
const link = handshake.resolveSessionBrowser(undefined, session);
|
|
17556
|
-
return "error" in link ?
|
|
17618
|
+
return "error" in link ? fail5(new Error(link.error)) : succeed6(link);
|
|
17557
17619
|
}
|
|
17558
17620
|
const existing = sessionId ? registry.listRootTargets().find((target) => target.opencodeBrowserSessionId === sessionId && target.owner === "relay") : undefined;
|
|
17559
17621
|
const link = (existing && browsers.browserTab(existing.tabId)?.link) ?? browsers.defaultLink();
|
|
17560
|
-
return link ? succeed6(link) :
|
|
17622
|
+
return link ? succeed6(link) : fail5(new Error("browse extension is not connected"));
|
|
17561
17623
|
});
|
|
17562
17624
|
const createAndAttachTab = fnUntraced(function* (createOptions) {
|
|
17563
17625
|
const link = yield* sessionBrowser(createOptions.opencodeBrowserSessionId);
|
|
17564
17626
|
const result = yield* sendToExtension({ method: "tabs.create", params: { url: createOptions.url, active: createOptions.active, ...agentWindow ? { window: agentWindow } : {} } }, link);
|
|
17565
17627
|
const tabId = getNumber2(result, "tabId");
|
|
17566
17628
|
if (!tabId)
|
|
17567
|
-
return yield*
|
|
17629
|
+
return yield* fail5(new Error("tabs.create did not return a tabId"));
|
|
17568
17630
|
announceTab(tabId);
|
|
17569
17631
|
return yield* rootLifecycle.attach({
|
|
17570
17632
|
tabId,
|
|
@@ -17781,7 +17843,7 @@ var makeRelay = fnUntraced(function* (options = {}) {
|
|
|
17781
17843
|
yield* catch_(listenHttpServer2({ server: httpServer, host: listenHost, port }), (error) => {
|
|
17782
17844
|
return gen(function* () {
|
|
17783
17845
|
yield* cleanup();
|
|
17784
|
-
return yield*
|
|
17846
|
+
return yield* fail5(error);
|
|
17785
17847
|
});
|
|
17786
17848
|
});
|
|
17787
17849
|
yield* sync2(() => pruneStaleExecuteFilesDirectories());
|
|
@@ -17816,7 +17878,7 @@ var makeRelay = fnUntraced(function* (options = {}) {
|
|
|
17816
17878
|
relayReady = true;
|
|
17817
17879
|
updates.refresh();
|
|
17818
17880
|
startTimers();
|
|
17819
|
-
const runtime = managed ?
|
|
17881
|
+
const runtime = managed ? installedRuntime2() : undefined;
|
|
17820
17882
|
if (runtime) {
|
|
17821
17883
|
autoUpdater = createAutoUpdater({
|
|
17822
17884
|
runtime,
|
|
@@ -17839,7 +17901,7 @@ var makeRelay = fnUntraced(function* (options = {}) {
|
|
|
17839
17901
|
relayLog("relay.ready", { url: endpointUrl, version: opencodeBrowserVersion2, build: opencodeBrowserBuildId2, pid: process.pid, managed });
|
|
17840
17902
|
}), (error) => gen(function* () {
|
|
17841
17903
|
yield* cleanup();
|
|
17842
|
-
return yield*
|
|
17904
|
+
return yield* fail5(error);
|
|
17843
17905
|
}));
|
|
17844
17906
|
return {
|
|
17845
17907
|
url: endpointUrl,
|