@opencode/browse 0.0.17-dev.169 → 0.0.17-dev.171
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/{Runtime-qfc1eg1n.mjs → Runtime-jrg7sc9p.mjs} +1 -1
- package/dist/{cli-zx7g8fek.mjs → cli-n2yqdpef.mjs} +49 -49
- package/dist/cli.mjs +14 -14
- package/dist/{helpers-nxtpzjhw.mjs → helpers-na4s8h8f.mjs} +1 -1
- package/dist/{index-yaf37ery.mjs → index-j79y2me1.mjs} +2 -2
- package/dist/{legacy-runtime-rvcn5zs6.mjs → legacy-runtime-pef5jajn.mjs} +4 -4
- package/dist/{main-4074weqb.mjs → main-048kx59h.mjs} +1 -1
- package/dist/{main-wf904nhj.mjs → main-31mjsvtm.mjs} +2 -2
- package/dist/{main-w80ghbx8.mjs → main-3gx5fe95.mjs} +1 -1
- package/dist/{main-9bk4pprj.mjs → main-3mhynene.mjs} +1 -1
- package/dist/{main-m3xnn0cx.mjs → main-5snyxk65.mjs} +4 -4
- package/dist/{main-dwjfhfpm.mjs → main-6q5nqhy7.mjs} +1 -1
- package/dist/{main-v6hzbxjd.mjs → main-f98q5tcf.mjs} +12 -12
- package/dist/{main-sx7qpdfw.mjs → main-g13tfban.mjs} +3 -3
- package/dist/{main-6k1dq78p.mjs → main-gvzdjgte.mjs} +3 -3
- package/dist/main-hrrgcjhe.mjs +4 -0
- package/dist/{main-h55dwr1s.mjs → main-ma5ncx3b.mjs} +2 -2
- package/dist/{main-rvmzfmb7.mjs → main-qq7x2tgn.mjs} +5 -5
- package/dist/{main-jf7jberd.mjs → main-s3g4jwx5.mjs} +41 -41
- package/dist/{main-gbq7c729.mjs → main-t8c7aq8b.mjs} +3 -3
- package/dist/{main-xycdhwqs.mjs → main-wpt5ha44.mjs} +23 -23
- package/dist/{main-fs2ymcvd.mjs → main-x9vdxj9f.mjs} +18 -18
- package/dist/{mcp-37b0xgq0.mjs → mcp-eqfvz2d5.mjs} +60 -60
- package/dist/{migrate-49s4pykq.mjs → migrate-h0e3yv0y.mjs} +4 -4
- package/dist/{relay-jkgh5rzg.mjs → relay-9fsv094e.mjs} +306 -66
- package/dist/{runtime-update-9d3dsv6t.mjs → runtime-update-7m0tkybs.mjs} +7 -7
- package/dist/{setup-74nz1gqg.mjs → setup-ac6kjvgh.mjs} +7 -7
- package/dist/{skill-text-z1pce87x.mjs → skill-text-thdaq5mc.mjs} +14 -1
- package/dist/{supervisor-5pjptkgz.mjs → supervisor-638mhqwx.mjs} +3 -3
- package/dist/{update-n4sw8eht.mjs → update-tyrveejz.mjs} +3 -3
- package/dist/{version-2cadxvsa.mjs → version-njwyb4qk.mjs} +1 -1
- package/package.json +1 -1
- package/skills/browse/SKILL.md +14 -1
- package/dist/main-9xbcy9q0.mjs +0 -4
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
opencodeBrowserVersion2,
|
|
6
6
|
opencodeBrowserBuildId2
|
|
7
|
-
} from "./main-
|
|
7
|
+
} from "./main-hrrgcjhe.mjs";
|
|
8
8
|
import {
|
|
9
9
|
defaultRoots,
|
|
10
10
|
configRoot2,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
setStoredMode,
|
|
29
29
|
autoUpdateStatus,
|
|
30
30
|
createAutoUpdater
|
|
31
|
-
} from "./main-
|
|
31
|
+
} from "./main-t8c7aq8b.mjs";
|
|
32
32
|
import {
|
|
33
33
|
extensionProtocolVersion,
|
|
34
34
|
minExtensionProtocolVersion,
|
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
writePrivateJsonFileSync
|
|
53
53
|
} from "./main-4h7rfhhr.mjs";
|
|
54
54
|
import {
|
|
55
|
+
map,
|
|
55
56
|
withDefault,
|
|
56
57
|
option,
|
|
57
58
|
String2,
|
|
@@ -107,7 +108,7 @@ import {
|
|
|
107
108
|
dataUrlDocument2,
|
|
108
109
|
appendManagedRelayProcessLog,
|
|
109
110
|
relayLog
|
|
110
|
-
} from "./main-
|
|
111
|
+
} from "./main-x9vdxj9f.mjs";
|
|
111
112
|
import {
|
|
112
113
|
context,
|
|
113
114
|
pendingPairingCodeKeys,
|
|
@@ -125,7 +126,7 @@ import {
|
|
|
125
126
|
pairingSessionKey,
|
|
126
127
|
sessionProof,
|
|
127
128
|
wrapToken
|
|
128
|
-
} from "./main-
|
|
129
|
+
} from "./main-6q5nqhy7.mjs";
|
|
129
130
|
import {
|
|
130
131
|
makeUnsafe,
|
|
131
132
|
terminateChildProcess,
|
|
@@ -148,16 +149,16 @@ import {
|
|
|
148
149
|
checkNavigationUrl,
|
|
149
150
|
readSecret,
|
|
150
151
|
secretText
|
|
151
|
-
} from "./main-
|
|
152
|
+
} from "./main-g13tfban.mjs";
|
|
152
153
|
import {
|
|
153
154
|
defaultJournalBaseDir,
|
|
154
155
|
makeJournalEntry,
|
|
155
156
|
appendJournalEntry,
|
|
156
157
|
startJournalRetention
|
|
157
|
-
} from "./main-
|
|
158
|
+
} from "./main-5snyxk65.mjs";
|
|
158
159
|
import {
|
|
159
160
|
createUpdateWatcher2
|
|
160
|
-
} from "./main-
|
|
161
|
+
} from "./main-ma5ncx3b.mjs";
|
|
161
162
|
import {
|
|
162
163
|
SettingsInputError,
|
|
163
164
|
parseSettingChanges,
|
|
@@ -165,31 +166,31 @@ import {
|
|
|
165
166
|
settingsToExtension,
|
|
166
167
|
describeSettings,
|
|
167
168
|
describeChanges
|
|
168
|
-
} from "./main-
|
|
169
|
+
} from "./main-qq7x2tgn.mjs";
|
|
169
170
|
import {
|
|
170
171
|
relayHostname,
|
|
171
172
|
isLocalPeer,
|
|
172
173
|
installedDevExtension,
|
|
173
174
|
syncDevExtension
|
|
174
|
-
} from "./main-
|
|
175
|
+
} from "./main-31mjsvtm.mjs";
|
|
175
176
|
import {
|
|
176
177
|
currentTimeMillis,
|
|
177
178
|
value,
|
|
178
179
|
when,
|
|
179
180
|
orElse,
|
|
180
181
|
exhaustive
|
|
181
|
-
} from "./main-
|
|
182
|
+
} from "./main-048kx59h.mjs";
|
|
182
183
|
import {
|
|
183
184
|
relayTokenQueryParam,
|
|
184
185
|
relayToken,
|
|
185
186
|
secretsEqual,
|
|
186
187
|
ensurePrivateDirectory
|
|
187
|
-
} from "./main-
|
|
188
|
+
} from "./main-3gx5fe95.mjs";
|
|
188
189
|
import {
|
|
189
190
|
join,
|
|
190
191
|
interrupt,
|
|
191
192
|
makeUnsafe2
|
|
192
|
-
} from "./main-
|
|
193
|
+
} from "./main-s3g4jwx5.mjs";
|
|
193
194
|
import {
|
|
194
195
|
taggedEnum,
|
|
195
196
|
is2,
|
|
@@ -210,7 +211,7 @@ import {
|
|
|
210
211
|
Int2,
|
|
211
212
|
Defect,
|
|
212
213
|
TaggedError2
|
|
213
|
-
} from "./main-
|
|
214
|
+
} from "./main-f98q5tcf.mjs";
|
|
214
215
|
import {
|
|
215
216
|
isNone,
|
|
216
217
|
isSome,
|
|
@@ -252,7 +253,7 @@ import {
|
|
|
252
253
|
tap,
|
|
253
254
|
result,
|
|
254
255
|
exit,
|
|
255
|
-
|
|
256
|
+
map6,
|
|
256
257
|
asVoid2,
|
|
257
258
|
catch_,
|
|
258
259
|
catchCause,
|
|
@@ -289,7 +290,7 @@ import {
|
|
|
289
290
|
runSync,
|
|
290
291
|
fnUntraced,
|
|
291
292
|
fn
|
|
292
|
-
} from "./main-
|
|
293
|
+
} from "./main-wpt5ha44.mjs";
|
|
293
294
|
import {
|
|
294
295
|
isString,
|
|
295
296
|
isNumber,
|
|
@@ -845,6 +846,64 @@ class CdpClientPool {
|
|
|
845
846
|
}
|
|
846
847
|
}
|
|
847
848
|
|
|
849
|
+
// src/cdp/emulation.ts
|
|
850
|
+
var deviceMetricsClearRetryMs = 100;
|
|
851
|
+
function clearDeviceMetricsOverride(send, options = {}) {
|
|
852
|
+
const clear = send("Emulation.clearDeviceMetricsOverride", {});
|
|
853
|
+
return gen(function* () {
|
|
854
|
+
yield* clear;
|
|
855
|
+
yield* sleep(deviceMetricsClearRetryMs);
|
|
856
|
+
if (options.retry?.() === false)
|
|
857
|
+
return;
|
|
858
|
+
yield* clear;
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
class DeviceMetricsOverrides {
|
|
863
|
+
nextGeneration = 1;
|
|
864
|
+
entries = new Map;
|
|
865
|
+
mark(tabId, sessionId) {
|
|
866
|
+
const generation = this.nextGeneration++;
|
|
867
|
+
this.entries.set(tabId, { sessionId, generation });
|
|
868
|
+
return generation;
|
|
869
|
+
}
|
|
870
|
+
generation(tabId) {
|
|
871
|
+
return this.entries.get(tabId)?.generation ?? 0;
|
|
872
|
+
}
|
|
873
|
+
sessionId(tabId) {
|
|
874
|
+
return this.entries.get(tabId)?.sessionId;
|
|
875
|
+
}
|
|
876
|
+
isCurrent(tabId, generation) {
|
|
877
|
+
return this.generation(tabId) === generation;
|
|
878
|
+
}
|
|
879
|
+
take(sessionId) {
|
|
880
|
+
const taken = [];
|
|
881
|
+
for (const [tabId, entry] of this.entries) {
|
|
882
|
+
if (entry.sessionId !== sessionId)
|
|
883
|
+
continue;
|
|
884
|
+
entry.sessionId = undefined;
|
|
885
|
+
taken.push({ tabId, generation: entry.generation });
|
|
886
|
+
}
|
|
887
|
+
return taken;
|
|
888
|
+
}
|
|
889
|
+
clear(tabId, generation, sessionId) {
|
|
890
|
+
const entry = this.entries.get(tabId);
|
|
891
|
+
if (!entry || entry.generation !== generation)
|
|
892
|
+
return;
|
|
893
|
+
if (sessionId !== undefined && entry.sessionId !== undefined && entry.sessionId !== sessionId)
|
|
894
|
+
return;
|
|
895
|
+
entry.sessionId = undefined;
|
|
896
|
+
}
|
|
897
|
+
forget(tabId) {
|
|
898
|
+
this.entries.delete(tabId);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
function tabsToClearOnExecuteEnd(options) {
|
|
902
|
+
if (options.readOnly)
|
|
903
|
+
return [];
|
|
904
|
+
return options.overrides.take(options.sessionId).filter(({ tabId }) => options.canSee(tabId));
|
|
905
|
+
}
|
|
906
|
+
|
|
848
907
|
// src/cdp/visibility.ts
|
|
849
908
|
function canClientSeeTarget(options) {
|
|
850
909
|
if (options.targetOwnerSessionId === undefined) {
|
|
@@ -1866,6 +1925,7 @@ function safePageUrl(page) {
|
|
|
1866
1925
|
|
|
1867
1926
|
// src/execute/page-recovery.ts
|
|
1868
1927
|
var playwrightCloseTimeoutMs = 2000;
|
|
1928
|
+
var defaultActionTimeoutMs = 30000;
|
|
1869
1929
|
var playwrightConnectTimeoutMs = 15000;
|
|
1870
1930
|
var adoptedPageConnectTimeoutMs = 8000;
|
|
1871
1931
|
var sessionPageHealthCheckTimeoutMs = 3000;
|
|
@@ -2118,11 +2178,11 @@ async function waitForExactTarget(options) {
|
|
|
2118
2178
|
await (options.delay ?? delay)(retryInMs);
|
|
2119
2179
|
}
|
|
2120
2180
|
}
|
|
2121
|
-
function installClosedPageReplacementGuard(page, clearRecreatedFromClosedUrl) {
|
|
2181
|
+
function installClosedPageReplacementGuard(page, clearRecreatedFromClosedUrl, actionTimeoutMs = () => defaultActionTimeoutMs) {
|
|
2122
2182
|
page.setDefaultTimeout?.(2500);
|
|
2123
2183
|
const restoreTimeout = () => {
|
|
2124
2184
|
clearRecreatedFromClosedUrl();
|
|
2125
|
-
page.setDefaultTimeout?.(
|
|
2185
|
+
page.setDefaultTimeout?.(actionTimeoutMs());
|
|
2126
2186
|
};
|
|
2127
2187
|
if (typeof page.goto === "function") {
|
|
2128
2188
|
const originalGoto = page.goto.bind(page);
|
|
@@ -6948,6 +7008,8 @@ var downloadCapabilityErrorMessage = "Downloads are unavailable in browse extens
|
|
|
6948
7008
|
var downloadGuardedPages = new WeakSet;
|
|
6949
7009
|
var downloadGuardedContexts = new WeakSet;
|
|
6950
7010
|
var viewportZoomGuardedPages = new WeakSet;
|
|
7011
|
+
var viewportGuards = new WeakMap;
|
|
7012
|
+
var viewportRestoreTimeoutMs = 2000;
|
|
6951
7013
|
var explicitMediaOptions = [
|
|
6952
7014
|
["colorScheme", "prefers-color-scheme"],
|
|
6953
7015
|
["reducedMotion", "prefers-reduced-motion"],
|
|
@@ -7025,9 +7087,17 @@ function installViewportZoomGuard(options) {
|
|
|
7025
7087
|
}
|
|
7026
7088
|
if (typeof page.setViewportSize === "function") {
|
|
7027
7089
|
const originalSetViewportSize = page.setViewportSize.bind(page);
|
|
7090
|
+
const guard = { original: undefined, dirty: false };
|
|
7028
7091
|
Object.defineProperty(page, "setViewportSize", {
|
|
7029
7092
|
configurable: true,
|
|
7030
7093
|
value: async (size) => {
|
|
7094
|
+
guard.dirty = true;
|
|
7095
|
+
if (!guard.original) {
|
|
7096
|
+
const before = await withTimeout(page.evaluate(() => ({ width: window.innerWidth, height: window.innerHeight, outerWidth: window.outerWidth })), 1000).catch(() => timedOut);
|
|
7097
|
+
if (typeof before !== "symbol" && before.width <= before.outerWidth && before.outerWidth - before.width <= 40) {
|
|
7098
|
+
guard.original = { width: before.width, height: before.height };
|
|
7099
|
+
}
|
|
7100
|
+
}
|
|
7031
7101
|
await originalSetViewportSize(size);
|
|
7032
7102
|
try {
|
|
7033
7103
|
const measured = await withTimeout(page.evaluate(() => ({
|
|
@@ -7041,9 +7111,74 @@ function installViewportZoomGuard(options) {
|
|
|
7041
7111
|
} catch {}
|
|
7042
7112
|
}
|
|
7043
7113
|
});
|
|
7114
|
+
viewportGuards.set(page, guard);
|
|
7044
7115
|
}
|
|
7045
7116
|
viewportZoomGuardedPages.add(page);
|
|
7046
7117
|
}
|
|
7118
|
+
function forgetPlaywrightViewport(page) {
|
|
7119
|
+
try {
|
|
7120
|
+
const client = page;
|
|
7121
|
+
client._viewportSize = undefined;
|
|
7122
|
+
const server = client._connection?.toImpl?.(page);
|
|
7123
|
+
if (!server)
|
|
7124
|
+
return;
|
|
7125
|
+
server._emulatedSize = undefined;
|
|
7126
|
+
const mainFrameSession = server.delegate?._mainFrameSession;
|
|
7127
|
+
if (mainFrameSession)
|
|
7128
|
+
mainFrameSession._metricsOverride = undefined;
|
|
7129
|
+
} catch {}
|
|
7130
|
+
}
|
|
7131
|
+
async function restoreEmulatedViewport(page) {
|
|
7132
|
+
const guard = viewportGuards.get(page);
|
|
7133
|
+
if (!guard?.dirty)
|
|
7134
|
+
return;
|
|
7135
|
+
const original = guard.original;
|
|
7136
|
+
guard.dirty = false;
|
|
7137
|
+
guard.original = undefined;
|
|
7138
|
+
let cancelled = false;
|
|
7139
|
+
const restore = async () => {
|
|
7140
|
+
if (page.isClosed())
|
|
7141
|
+
return;
|
|
7142
|
+
const cdp = await page.context().newCDPSession(page);
|
|
7143
|
+
try {
|
|
7144
|
+
if (cancelled)
|
|
7145
|
+
return;
|
|
7146
|
+
const attempts = original ? 3 : 2;
|
|
7147
|
+
for (let attempt = 0;attempt < attempts; attempt++) {
|
|
7148
|
+
if (cancelled)
|
|
7149
|
+
return;
|
|
7150
|
+
await cdp.send("Emulation.clearDeviceMetricsOverride");
|
|
7151
|
+
await delay(120);
|
|
7152
|
+
if (cancelled)
|
|
7153
|
+
return;
|
|
7154
|
+
if (!original)
|
|
7155
|
+
continue;
|
|
7156
|
+
const measured = await withTimeout(page.evaluate(() => ({ width: window.innerWidth, height: window.innerHeight })), 500).catch(() => timedOut);
|
|
7157
|
+
if (typeof measured === "symbol")
|
|
7158
|
+
break;
|
|
7159
|
+
if (Math.abs(measured.width - original.width) <= 2 && Math.abs(measured.height - original.height) <= 2)
|
|
7160
|
+
break;
|
|
7161
|
+
}
|
|
7162
|
+
} finally {
|
|
7163
|
+
await cdp.detach().catch(() => {});
|
|
7164
|
+
}
|
|
7165
|
+
};
|
|
7166
|
+
const outcome = await withTimeout(restore(), viewportRestoreTimeoutMs).catch(() => timedOut);
|
|
7167
|
+
if (typeof outcome === "symbol")
|
|
7168
|
+
cancelled = true;
|
|
7169
|
+
forgetPlaywrightViewport(page);
|
|
7170
|
+
}
|
|
7171
|
+
async function withRestoredViewports(options) {
|
|
7172
|
+
try {
|
|
7173
|
+
return await options.run();
|
|
7174
|
+
} finally {
|
|
7175
|
+
let pages = [options.page];
|
|
7176
|
+
try {
|
|
7177
|
+
pages = Array.from(new Set([options.page, ...options.context.pages()]));
|
|
7178
|
+
} catch {}
|
|
7179
|
+
await Promise.all(pages.map((page) => restoreEmulatedViewport(page)));
|
|
7180
|
+
}
|
|
7181
|
+
}
|
|
7047
7182
|
|
|
7048
7183
|
// src/execute/default-page.ts
|
|
7049
7184
|
class DefaultPageHost {
|
|
@@ -7061,6 +7196,9 @@ class DefaultPageHost {
|
|
|
7061
7196
|
explicitMediaFeatures = new Map;
|
|
7062
7197
|
explicitMedia;
|
|
7063
7198
|
pendingWarnings = [];
|
|
7199
|
+
actionTimeoutMs = defaultActionTimeoutMs;
|
|
7200
|
+
actionTimeoutPages = new Set;
|
|
7201
|
+
actionTimeoutGuardedPage;
|
|
7064
7202
|
boundPageListeners;
|
|
7065
7203
|
onDefaultTargetChangeOption;
|
|
7066
7204
|
pageHealthCheckTimeoutMsOption;
|
|
@@ -7072,6 +7210,24 @@ class DefaultPageHost {
|
|
|
7072
7210
|
if (warning && !this.pendingWarnings.includes(warning))
|
|
7073
7211
|
this.pendingWarnings.push(warning);
|
|
7074
7212
|
}
|
|
7213
|
+
applyActionTimeout(page) {
|
|
7214
|
+
this.actionTimeoutPages.add(page);
|
|
7215
|
+
if (page === this.actionTimeoutGuardedPage)
|
|
7216
|
+
return;
|
|
7217
|
+
page.setDefaultTimeout?.(this.actionTimeoutMs);
|
|
7218
|
+
}
|
|
7219
|
+
restoreActionTimeout() {
|
|
7220
|
+
this.actionTimeoutMs = defaultActionTimeoutMs;
|
|
7221
|
+
for (const page of this.actionTimeoutPages) {
|
|
7222
|
+
if (page !== this.actionTimeoutGuardedPage)
|
|
7223
|
+
page.setDefaultTimeout?.(this.actionTimeoutMs);
|
|
7224
|
+
}
|
|
7225
|
+
this.actionTimeoutPages.clear();
|
|
7226
|
+
}
|
|
7227
|
+
releaseActionTimeoutGuard(page) {
|
|
7228
|
+
if (this.actionTimeoutGuardedPage === page)
|
|
7229
|
+
this.actionTimeoutGuardedPage = undefined;
|
|
7230
|
+
}
|
|
7075
7231
|
unbindDefaultPage(targetId, options = {}) {
|
|
7076
7232
|
this.clearPageListeners();
|
|
7077
7233
|
this.page = undefined;
|
|
@@ -7142,6 +7298,7 @@ class DefaultPageHost {
|
|
|
7142
7298
|
bindDefaultPage(page, targetId, ownsPage, notify) {
|
|
7143
7299
|
this.clearPageListeners();
|
|
7144
7300
|
this.page = page;
|
|
7301
|
+
this.applyActionTimeout(page);
|
|
7145
7302
|
if (targetId === undefined || targetId !== this.defaultPageTargetId) {
|
|
7146
7303
|
this.pageCrashed = false;
|
|
7147
7304
|
this.pageProtectedUi = false;
|
|
@@ -7169,7 +7326,8 @@ class DefaultPageHost {
|
|
|
7169
7326
|
if (this.page === page && frame === page.mainFrame()) {
|
|
7170
7327
|
this.pageCrashed = false;
|
|
7171
7328
|
this.recordNonBlankUrl(frame.url());
|
|
7172
|
-
|
|
7329
|
+
this.releaseActionTimeoutGuard(page);
|
|
7330
|
+
page.setDefaultTimeout?.(this.actionTimeoutMs);
|
|
7173
7331
|
if (this.explicitMediaFeatures.size > 0) {
|
|
7174
7332
|
applyExplicitMediaFeatures(page, this.explicitMedia, this.explicitMediaFeatures);
|
|
7175
7333
|
}
|
|
@@ -7266,9 +7424,11 @@ class DefaultPageHost {
|
|
|
7266
7424
|
const targetId = await resolvePageTargetId(page);
|
|
7267
7425
|
this.bindDefaultPage(page, targetId, true, true);
|
|
7268
7426
|
if (this.recreatedFromClosedUrl) {
|
|
7427
|
+
this.actionTimeoutGuardedPage = page;
|
|
7269
7428
|
installClosedPageReplacementGuard(page, () => {
|
|
7270
7429
|
this.recreatedFromClosedUrl = undefined;
|
|
7271
|
-
|
|
7430
|
+
this.releaseActionTimeoutGuard(page);
|
|
7431
|
+
}, () => this.actionTimeoutMs);
|
|
7272
7432
|
}
|
|
7273
7433
|
return page;
|
|
7274
7434
|
}
|
|
@@ -11387,7 +11547,9 @@ class ExecuteSandbox extends DefaultPageHost {
|
|
|
11387
11547
|
allowNode = executeAllowsNode();
|
|
11388
11548
|
snapshotRefs = { selectors: new Map };
|
|
11389
11549
|
networkCapture = new Recorder;
|
|
11550
|
+
viewportGuardContexts = new WeakSet;
|
|
11390
11551
|
secrets;
|
|
11552
|
+
actionTimeoutContext;
|
|
11391
11553
|
realm;
|
|
11392
11554
|
state;
|
|
11393
11555
|
constructor(options) {
|
|
@@ -11419,41 +11581,54 @@ class ExecuteSandbox extends DefaultPageHost {
|
|
|
11419
11581
|
execute(code, options = {}) {
|
|
11420
11582
|
return tryPromise({
|
|
11421
11583
|
try: async () => {
|
|
11422
|
-
|
|
11423
|
-
|
|
11424
|
-
|
|
11425
|
-
|
|
11584
|
+
this.actionTimeoutMs = options.actionTimeoutMs ?? defaultActionTimeoutMs;
|
|
11585
|
+
try {
|
|
11586
|
+
if (this.realm?.isStopped) {
|
|
11587
|
+
this.realm = this.createRealm();
|
|
11588
|
+
this.state = this.realm.state;
|
|
11589
|
+
this.pendingWarnings.push("The previous execute realm stopped; JavaScript state and pending callbacks were reset.");
|
|
11590
|
+
}
|
|
11591
|
+
if (!this.realm)
|
|
11592
|
+
for (const warning of pageVisibleApiSourceWarnings(code))
|
|
11593
|
+
this.addWarningOnce(warning);
|
|
11594
|
+
const globals = await this.getGlobals(options);
|
|
11595
|
+
return await withRestoredViewports({
|
|
11596
|
+
context: globals.context,
|
|
11597
|
+
page: globals.page,
|
|
11598
|
+
run: async () => {
|
|
11599
|
+
const { result, logs, logSummary, aftermath } = await runUserCode({
|
|
11600
|
+
code,
|
|
11601
|
+
globals,
|
|
11602
|
+
...this.realm ? { realm: this.realm } : {},
|
|
11603
|
+
onUnhandledRejection: (warning) => this.addWarningOnce(warning)
|
|
11604
|
+
}).then(async (completed) => ({ ...completed, aftermath: await this.withChallenge(globals.page, completed.aftermath, false) })).catch(async (error) => {
|
|
11605
|
+
if (!(error instanceof ExecuteCodeError) || !error.aftermath)
|
|
11606
|
+
throw error;
|
|
11607
|
+
throw new ExecuteCodeError(error.originalError, error.logs, error.logSummary, await this.withChallenge(globals.page, error.aftermath, true));
|
|
11608
|
+
});
|
|
11609
|
+
await this.networkCapture.settleForOutput();
|
|
11610
|
+
const extracted = extractExecuteMedia(result);
|
|
11611
|
+
const redactedValue = this.secrets.redactOutputValue(extracted.value);
|
|
11612
|
+
const jsonSafeResult = toJsonSafeValue(redactedValue);
|
|
11613
|
+
const bounded = boundExecuteResult(stringifyResult(redactedValue), jsonSafeResult.serializable ? jsonSafeResult.value : undefined, jsonSafeResult.serializable);
|
|
11614
|
+
const warnings = this.finalizeWarnings(logSummary, jsonValueWarning(redactedValue, jsonSafeResult), bounded.warning);
|
|
11615
|
+
return {
|
|
11616
|
+
text: bounded.text,
|
|
11617
|
+
...bounded.hasValue ? { value: bounded.value } : {},
|
|
11618
|
+
...extracted.media.length > 0 ? { media: extracted.media } : {},
|
|
11619
|
+
isError: false,
|
|
11620
|
+
logs: this.secrets.redactCaptureLogs(logs),
|
|
11621
|
+
logSummary,
|
|
11622
|
+
warnings,
|
|
11623
|
+
aftermath: this.secrets.redactCaptureAftermath(aftermath)
|
|
11624
|
+
};
|
|
11625
|
+
}
|
|
11626
|
+
});
|
|
11627
|
+
} finally {
|
|
11628
|
+
this.restoreActionTimeout();
|
|
11629
|
+
this.actionTimeoutContext?.setDefaultTimeout?.(defaultActionTimeoutMs);
|
|
11630
|
+
this.actionTimeoutContext = undefined;
|
|
11426
11631
|
}
|
|
11427
|
-
if (!this.realm)
|
|
11428
|
-
for (const warning of pageVisibleApiSourceWarnings(code))
|
|
11429
|
-
this.addWarningOnce(warning);
|
|
11430
|
-
const globals = await this.getGlobals(options);
|
|
11431
|
-
const { result, logs, logSummary, aftermath } = await runUserCode({
|
|
11432
|
-
code,
|
|
11433
|
-
globals,
|
|
11434
|
-
...this.realm ? { realm: this.realm } : {},
|
|
11435
|
-
onUnhandledRejection: (warning) => this.addWarningOnce(warning)
|
|
11436
|
-
}).then(async (completed) => ({ ...completed, aftermath: await this.withChallenge(globals.page, completed.aftermath, false) })).catch(async (error) => {
|
|
11437
|
-
if (!(error instanceof ExecuteCodeError) || !error.aftermath)
|
|
11438
|
-
throw error;
|
|
11439
|
-
throw new ExecuteCodeError(error.originalError, error.logs, error.logSummary, await this.withChallenge(globals.page, error.aftermath, true));
|
|
11440
|
-
});
|
|
11441
|
-
await this.networkCapture.settleForOutput();
|
|
11442
|
-
const extracted = extractExecuteMedia(result);
|
|
11443
|
-
const redactedValue = this.secrets.redactOutputValue(extracted.value);
|
|
11444
|
-
const jsonSafeResult = toJsonSafeValue(redactedValue);
|
|
11445
|
-
const bounded = boundExecuteResult(stringifyResult(redactedValue), jsonSafeResult.serializable ? jsonSafeResult.value : undefined, jsonSafeResult.serializable);
|
|
11446
|
-
const warnings = this.finalizeWarnings(logSummary, jsonValueWarning(redactedValue, jsonSafeResult), bounded.warning);
|
|
11447
|
-
return {
|
|
11448
|
-
text: bounded.text,
|
|
11449
|
-
...bounded.hasValue ? { value: bounded.value } : {},
|
|
11450
|
-
...extracted.media.length > 0 ? { media: extracted.media } : {},
|
|
11451
|
-
isError: false,
|
|
11452
|
-
logs: this.secrets.redactCaptureLogs(logs),
|
|
11453
|
-
logSummary,
|
|
11454
|
-
warnings,
|
|
11455
|
-
aftermath: this.secrets.redactCaptureAftermath(aftermath)
|
|
11456
|
-
};
|
|
11457
11632
|
},
|
|
11458
11633
|
catch: (cause) => {
|
|
11459
11634
|
if (cause instanceof ExecuteCodeError) {
|
|
@@ -11710,7 +11885,15 @@ class ExecuteSandbox extends DefaultPageHost {
|
|
|
11710
11885
|
page = await this.getSessionPage({ context, ...targetSelection ? { targetSelection } : {} });
|
|
11711
11886
|
}
|
|
11712
11887
|
installPageReadTimeout(page);
|
|
11713
|
-
|
|
11888
|
+
this.actionTimeoutContext = context;
|
|
11889
|
+
context.setDefaultTimeout?.(this.actionTimeoutMs);
|
|
11890
|
+
this.applyActionTimeout(page);
|
|
11891
|
+
this.installViewportGuards(context);
|
|
11892
|
+
this.networkCapture.bindPage(this.page);
|
|
11893
|
+
return { browser, context, page };
|
|
11894
|
+
}
|
|
11895
|
+
installViewportGuards(context) {
|
|
11896
|
+
const install = (page) => installViewportZoomGuard({
|
|
11714
11897
|
page,
|
|
11715
11898
|
explicitMediaFeatures: this.explicitMediaFeatures,
|
|
11716
11899
|
getExplicitMedia: () => this.explicitMedia,
|
|
@@ -11719,8 +11902,12 @@ class ExecuteSandbox extends DefaultPageHost {
|
|
|
11719
11902
|
},
|
|
11720
11903
|
addWarningOnce: (warning) => this.addWarningOnce(warning)
|
|
11721
11904
|
});
|
|
11722
|
-
|
|
11723
|
-
|
|
11905
|
+
for (const page of context.pages())
|
|
11906
|
+
install(page);
|
|
11907
|
+
if (!this.viewportGuardContexts.has(context)) {
|
|
11908
|
+
context.on("page", install);
|
|
11909
|
+
this.viewportGuardContexts.add(context);
|
|
11910
|
+
}
|
|
11724
11911
|
}
|
|
11725
11912
|
ensureSessionPage(label) {
|
|
11726
11913
|
return tryPromise({
|
|
@@ -13404,7 +13591,9 @@ function executeInSession(ctx, options) {
|
|
|
13404
13591
|
yield* ctx.setExecuting(session.id, true);
|
|
13405
13592
|
const stopSignal = makeUnsafe4();
|
|
13406
13593
|
const released = makeUnsafe4();
|
|
13407
|
-
const
|
|
13594
|
+
const chosenTimeoutMs = options.timeoutMs ?? ctx.hooks.executeTimeoutMs;
|
|
13595
|
+
const effectiveTimeoutMs = chosenTimeoutMs ?? defaultExecuteTimeoutMs;
|
|
13596
|
+
const actionTimeoutMs = chosenTimeoutMs === undefined ? undefined : chosenTimeoutMs === 0 ? 0 : Math.max(30000, chosenTimeoutMs);
|
|
13408
13597
|
let deadline;
|
|
13409
13598
|
const stopRunning = (message, diagnostic) => {
|
|
13410
13599
|
deadline?.cancel();
|
|
@@ -13428,8 +13617,11 @@ function executeInSession(ctx, options) {
|
|
|
13428
13617
|
let forced = false;
|
|
13429
13618
|
const startedAt = Date.now();
|
|
13430
13619
|
const result = yield* gen(function* () {
|
|
13431
|
-
const script = yield* session.sandbox.execute(options.code, {
|
|
13432
|
-
|
|
13620
|
+
const script = yield* session.sandbox.execute(options.code, {
|
|
13621
|
+
...options.targetSelection ? { targetSelection: options.targetSelection } : {},
|
|
13622
|
+
...actionTimeoutMs === undefined ? {} : { actionTimeoutMs }
|
|
13623
|
+
}).pipe(forkDetach({ startImmediately: true }));
|
|
13624
|
+
const first = yield* raceFirst(join(script).pipe(map6((value) => ({ settled: true, value }))), _await(stopSignal).pipe(map6((stop) => ({ settled: false, stop }))));
|
|
13433
13625
|
if (first.settled)
|
|
13434
13626
|
return first.value;
|
|
13435
13627
|
yield* ctx.endStoppedScript(session);
|
|
@@ -13743,7 +13935,7 @@ class OpenCodeBrowserSessions {
|
|
|
13743
13935
|
const session = this.sessions.get(id);
|
|
13744
13936
|
if (!session)
|
|
13745
13937
|
return succeed6(false);
|
|
13746
|
-
return session.sandbox.networkEnd(reason).pipe(
|
|
13938
|
+
return session.sandbox.networkEnd(reason).pipe(map6(({ cancelled }) => cancelled));
|
|
13747
13939
|
}
|
|
13748
13940
|
collectSessionIds(matches) {
|
|
13749
13941
|
const affectedSessionIds = [];
|
|
@@ -13798,6 +13990,13 @@ class OpenCodeBrowserSessions {
|
|
|
13798
13990
|
}));
|
|
13799
13991
|
yield* manager.releaseSessionTargetOwnership(session);
|
|
13800
13992
|
yield* manager.closeOpenCodeBrowserSession(session);
|
|
13993
|
+
yield* sync2(() => {
|
|
13994
|
+
try {
|
|
13995
|
+
manager.hooks.onSessionDeleted?.(id);
|
|
13996
|
+
} catch (error) {
|
|
13997
|
+
console.error("Session deleted hook failed", error);
|
|
13998
|
+
}
|
|
13999
|
+
});
|
|
13801
14000
|
return true;
|
|
13802
14001
|
})));
|
|
13803
14002
|
return { deleted, ...stopped ? { stopped } : {} };
|
|
@@ -13950,7 +14149,7 @@ class OpenCodeBrowserSessions {
|
|
|
13950
14149
|
targetIds.add(session.target.id);
|
|
13951
14150
|
if (Array.from(targetIds).some((id) => options.isTargetBusy?.(id)))
|
|
13952
14151
|
continue;
|
|
13953
|
-
const done = yield* manager.delete(session.id).pipe(
|
|
14152
|
+
const done = yield* manager.delete(session.id).pipe(map6((result) => result.deleted), orElseSucceed(() => false));
|
|
13954
14153
|
if (done)
|
|
13955
14154
|
reaped.push(session.id);
|
|
13956
14155
|
}
|
|
@@ -16425,6 +16624,7 @@ function createCdpDispatcher(options) {
|
|
|
16425
16624
|
navigationGuard,
|
|
16426
16625
|
ghostCursor,
|
|
16427
16626
|
tabActivity,
|
|
16627
|
+
deviceMetricsOverrides,
|
|
16428
16628
|
mainFrameIdsByTab,
|
|
16429
16629
|
blankNavigationWaiters,
|
|
16430
16630
|
sendDebuggerCommand,
|
|
@@ -16624,6 +16824,20 @@ function createCdpDispatcher(options) {
|
|
|
16624
16824
|
}
|
|
16625
16825
|
if (message.method === ghostCursorCommandMethod)
|
|
16626
16826
|
return yield* ghostCursor.command(tabId, message.params);
|
|
16827
|
+
if (message.method === "Emulation.clearDeviceMetricsOverride") {
|
|
16828
|
+
const clientSessionId = cdpClients.sessionId(socket);
|
|
16829
|
+
const owner = deviceMetricsOverrides.sessionId(tabId);
|
|
16830
|
+
if (clientSessionId !== undefined && owner !== undefined && owner !== clientSessionId) {
|
|
16831
|
+
return {};
|
|
16832
|
+
}
|
|
16833
|
+
const generation = deviceMetricsOverrides.generation(tabId);
|
|
16834
|
+
yield* clearDeviceMetricsOverride((method, params) => sendDebuggerCommand({ tabId, method, params }), { retry: () => deviceMetricsOverrides.isCurrent(tabId, generation) });
|
|
16835
|
+
deviceMetricsOverrides.clear(tabId, generation, clientSessionId);
|
|
16836
|
+
return {};
|
|
16837
|
+
}
|
|
16838
|
+
if (message.method === "Emulation.setDeviceMetricsOverride" && route.chromeSessionId === undefined) {
|
|
16839
|
+
deviceMetricsOverrides.mark(tabId, cdpClients.sessionId(socket));
|
|
16840
|
+
}
|
|
16627
16841
|
if (message.method === "Page.navigate" && route.chromeSessionId === undefined) {
|
|
16628
16842
|
const dataNavigation = yield* navigateTopFrameToDataUrl({
|
|
16629
16843
|
tabId,
|
|
@@ -16705,7 +16919,7 @@ function isMissingTabError(error) {
|
|
|
16705
16919
|
}
|
|
16706
16920
|
function createExtensionCommands(options) {
|
|
16707
16921
|
const { browsers } = options;
|
|
16708
|
-
const sendToBrowser = (link, command) => link.rpc.send(command).pipe(
|
|
16922
|
+
const sendToBrowser = (link, command) => link.rpc.send(command).pipe(map6((result2) => {
|
|
16709
16923
|
const tabId = getNumber2(result2, "tabId");
|
|
16710
16924
|
return tabId === undefined ? result2 : { ...result2, tabId: browsers.relayTabId(link, tabId) };
|
|
16711
16925
|
}));
|
|
@@ -17937,7 +18151,7 @@ function createRelaySettingsSync(options) {
|
|
|
17937
18151
|
sendRelaySettings();
|
|
17938
18152
|
};
|
|
17939
18153
|
const httpSettings = {
|
|
17940
|
-
get: () => extensionSettings("settings.get").pipe(
|
|
18154
|
+
get: () => extensionSettings("settings.get").pipe(map6((stored) => describeSettings(withRelaySettings(stored), userSettingOverrides()))),
|
|
17941
18155
|
set: (input) => gen(function* () {
|
|
17942
18156
|
const requested = yield* try_2({
|
|
17943
18157
|
try: () => parseSettingChanges(input),
|
|
@@ -18989,6 +19203,7 @@ class TabActivity {
|
|
|
18989
19203
|
}
|
|
18990
19204
|
|
|
18991
19205
|
// src/relay.ts
|
|
19206
|
+
var configuredExecuteTimeoutMs = Int("OPENCODE_BROWSER_EXECUTE_TIMEOUT_MS").pipe(option, map(getOrUndefined));
|
|
18992
19207
|
var startRelay = fn("Relay.start")(function* (options = {}) {
|
|
18993
19208
|
yield* installRelayProcessGuard;
|
|
18994
19209
|
return yield* acquireRelease(makeRelay(options), (server) => server.close());
|
|
@@ -19136,10 +19351,11 @@ var makeRelay = fnUntraced(function* (options = {}) {
|
|
|
19136
19351
|
browsersChanged,
|
|
19137
19352
|
cdpClientCount: () => cdpClients.size
|
|
19138
19353
|
});
|
|
19139
|
-
const executeTimeoutMs = yield*
|
|
19354
|
+
const executeTimeoutMs = yield* configuredExecuteTimeoutMs;
|
|
19140
19355
|
const keepaliveIntervalMs = yield* Int("OPENCODE_BROWSER_KEEPALIVE_MS").pipe(withDefault(20000));
|
|
19141
19356
|
const idleTabTtlMs = yield* Int("OPENCODE_BROWSER_IDLE_TAB_TTL_MS").pipe(withDefault(15 * 60000));
|
|
19142
19357
|
const journalBaseDir = defaultJournalBaseDir();
|
|
19358
|
+
const deviceMetricsOverrides = new DeviceMetricsOverrides;
|
|
19143
19359
|
const sessions = new OpenCodeBrowserSessions(endpointUrl, (id, onDefaultTargetChange) => new ExecuteSandbox({
|
|
19144
19360
|
endpointUrl,
|
|
19145
19361
|
authToken,
|
|
@@ -19171,8 +19387,29 @@ var makeRelay = fnUntraced(function* (options = {}) {
|
|
|
19171
19387
|
},
|
|
19172
19388
|
targetBrowserKey: (tabId) => browsers.ownerKey(tabId),
|
|
19173
19389
|
getUserAttachedPageUrls: (session) => registry.listRootTargets().filter((target) => target.owner === "user" && browsers.ownerKey(target.tabId) === session.browser?.key).map((target) => target.targetInfo.url || "about:blank"),
|
|
19174
|
-
executeTimeoutMs,
|
|
19175
|
-
onExecuteStateChange: (sessionId, executing) =>
|
|
19390
|
+
...executeTimeoutMs === undefined ? {} : { executeTimeoutMs },
|
|
19391
|
+
onExecuteStateChange: (sessionId, executing) => gen(function* () {
|
|
19392
|
+
yield* presentation.onSessionExecuteStateChange(sessionId, executing);
|
|
19393
|
+
if (executing)
|
|
19394
|
+
return;
|
|
19395
|
+
const tabs = tabsToClearOnExecuteEnd({
|
|
19396
|
+
overrides: deviceMetricsOverrides,
|
|
19397
|
+
readOnly: sessions.isReadOnly(sessionId),
|
|
19398
|
+
sessionId,
|
|
19399
|
+
canSee: (tabId) => {
|
|
19400
|
+
const target = registry.tabTargets.get(tabId);
|
|
19401
|
+
return target !== undefined && cdpRouter.canSessionSeeTarget(sessionId, target);
|
|
19402
|
+
}
|
|
19403
|
+
});
|
|
19404
|
+
for (const { tabId, generation } of tabs) {
|
|
19405
|
+
if (!deviceMetricsOverrides.isCurrent(tabId, generation))
|
|
19406
|
+
continue;
|
|
19407
|
+
yield* clearDeviceMetricsOverride((method, params) => sendDebuggerCommand({ tabId, method, params }), { retry: () => deviceMetricsOverrides.isCurrent(tabId, generation) }).pipe(timeoutOption("2 seconds"), ignore);
|
|
19408
|
+
}
|
|
19409
|
+
}),
|
|
19410
|
+
onSessionDeleted: (sessionId) => {
|
|
19411
|
+
deviceMetricsOverrides.take(sessionId);
|
|
19412
|
+
},
|
|
19176
19413
|
onExecuteRecord: (record) => {
|
|
19177
19414
|
const entry = makeJournalEntry({
|
|
19178
19415
|
sessionId: record.sessionId,
|
|
@@ -19373,6 +19610,7 @@ var makeRelay = fnUntraced(function* (options = {}) {
|
|
|
19373
19610
|
protectedFrames.forgetTab(tabId);
|
|
19374
19611
|
navigationGuard.forgetTab(tabId);
|
|
19375
19612
|
ghostCursor.forget(tabId);
|
|
19613
|
+
deviceMetricsOverrides.forget(tabId);
|
|
19376
19614
|
forgetTab(tabId);
|
|
19377
19615
|
for (const [sessionId, childTabId] of suppressedChildSessions) {
|
|
19378
19616
|
if (childTabId === tabId)
|
|
@@ -19503,6 +19741,7 @@ var makeRelay = fnUntraced(function* (options = {}) {
|
|
|
19503
19741
|
navigationGuard,
|
|
19504
19742
|
ghostCursor,
|
|
19505
19743
|
tabActivity,
|
|
19744
|
+
deviceMetricsOverrides,
|
|
19506
19745
|
mainFrameIdsByTab,
|
|
19507
19746
|
blankNavigationWaiters,
|
|
19508
19747
|
sendDebuggerCommand,
|
|
@@ -19647,6 +19886,7 @@ var makeRelay = fnUntraced(function* (options = {}) {
|
|
|
19647
19886
|
};
|
|
19648
19887
|
});
|
|
19649
19888
|
export {
|
|
19889
|
+
configuredExecuteTimeoutMs,
|
|
19650
19890
|
handleRelayProcessFault,
|
|
19651
19891
|
isBenignClosedSessionRejection,
|
|
19652
19892
|
relayProcessFaultSummary,
|