opendevbrowser 0.0.24 → 0.0.26
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/README.md +1 -1
- package/dist/browser/fingerprint/canary.d.ts.map +1 -1
- package/dist/{chunk-K2TEHJCV.js → chunk-AVQL6WAS.js} +2856 -694
- package/dist/chunk-AVQL6WAS.js.map +1 -0
- package/dist/{chunk-5I6TZRVS.js → chunk-GTTYIAI7.js} +1053 -474
- package/dist/chunk-GTTYIAI7.js.map +1 -0
- package/dist/cli/commands/daemon.d.ts +25 -0
- package/dist/cli/commands/daemon.d.ts.map +1 -1
- package/dist/cli/commands/inspiredesign.d.ts.map +1 -1
- package/dist/cli/commands/serve.d.ts +10 -13
- package/dist/cli/commands/serve.d.ts.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/daemon-client.d.ts +13 -0
- package/dist/cli/daemon-client.d.ts.map +1 -1
- package/dist/cli/daemon-commands.d.ts.map +1 -1
- package/dist/cli/daemon-status-policy.d.ts +6 -0
- package/dist/cli/daemon-status-policy.d.ts.map +1 -0
- package/dist/cli/daemon-status.d.ts +1 -0
- package/dist/cli/daemon-status.d.ts.map +1 -1
- package/dist/cli/daemon.d.ts +12 -2
- package/dist/cli/daemon.d.ts.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/index.js +188 -108
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/remote-manager.d.ts +8 -6
- package/dist/cli/remote-manager.d.ts.map +1 -1
- package/dist/cli/utils/http.d.ts.map +1 -1
- package/dist/daemon-fingerprint.json +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +147 -46
- package/dist/index.js.map +1 -1
- package/dist/inspiredesign/brief-expansion.d.ts +41 -0
- package/dist/inspiredesign/brief-expansion.d.ts.map +1 -0
- package/dist/inspiredesign/handoff.d.ts +3 -1
- package/dist/inspiredesign/handoff.d.ts.map +1 -1
- package/dist/opendevbrowser.d.ts.map +1 -1
- package/dist/opendevbrowser.js +147 -46
- package/dist/opendevbrowser.js.map +1 -1
- package/dist/providers/inspiredesign-capture-mode.d.ts +3 -0
- package/dist/providers/inspiredesign-capture-mode.d.ts.map +1 -0
- package/dist/providers/inspiredesign-capture.d.ts +8 -1
- package/dist/providers/inspiredesign-capture.d.ts.map +1 -1
- package/dist/providers/inspiredesign-contract.d.ts +30 -0
- package/dist/providers/inspiredesign-contract.d.ts.map +1 -1
- package/dist/providers/renderer.d.ts +2 -1
- package/dist/providers/renderer.d.ts.map +1 -1
- package/dist/providers/workflows.d.ts +2 -0
- package/dist/providers/workflows.d.ts.map +1 -1
- package/dist/{providers-6YVHKTOJ.js → providers-T2FQJCF6.js} +2 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/inspiredesign_run.d.ts.map +1 -1
- package/dist/tools/status.d.ts.map +1 -1
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
- package/skills/opendevbrowser-best-practices/SKILL.md +3 -2
- package/skills/opendevbrowser-design-agent/SKILL.md +1 -0
- package/skills/opendevbrowser-design-agent/assets/templates/inspiredesign-advanced-brief.v1.json +1370 -0
- package/skills/opendevbrowser-design-agent/scripts/validate-skill-assets.sh +2 -0
- package/dist/chunk-5I6TZRVS.js.map +0 -1
- package/dist/chunk-K2TEHJCV.js.map +0 -1
- /package/dist/{providers-6YVHKTOJ.js.map → providers-T2FQJCF6.js.map} +0 -0
|
@@ -8,6 +8,25 @@ import {
|
|
|
8
8
|
applyRuntimePreviewBridge
|
|
9
9
|
} from "./chunk-Y2KL55OG.js";
|
|
10
10
|
import {
|
|
11
|
+
CANVAS_BROWSER_VALIDATION_MODES,
|
|
12
|
+
CANVAS_GENERATION_PLAN_REQUIRED_FIELDS,
|
|
13
|
+
CANVAS_GOVERNANCE_BLOCK_KEYS,
|
|
14
|
+
CANVAS_INTERACTION_STATES,
|
|
15
|
+
CANVAS_KEYBOARD_NAVIGATION_MODES,
|
|
16
|
+
CANVAS_MOTION_LEVELS,
|
|
17
|
+
CANVAS_NAVIGATION_MODELS,
|
|
18
|
+
CANVAS_OPTIONAL_INHERITED_GOVERNANCE_KEYS,
|
|
19
|
+
CANVAS_PLAN_THEMES,
|
|
20
|
+
CANVAS_PLAN_VIEWPORTS,
|
|
21
|
+
CANVAS_PUBLIC_WARNING_CLASSES,
|
|
22
|
+
CANVAS_REDUCED_MOTION_POLICIES,
|
|
23
|
+
CANVAS_REQUIRED_MUTATION_GOVERNANCE_KEYS,
|
|
24
|
+
CANVAS_REQUIRED_SAVE_GOVERNANCE_KEYS,
|
|
25
|
+
CANVAS_SCHEMA_VERSION,
|
|
26
|
+
CANVAS_SESSION_MODES,
|
|
27
|
+
CANVAS_THEME_STRATEGIES,
|
|
28
|
+
CANVAS_VALIDATION_TARGET_BLOCK_ON_CODES,
|
|
29
|
+
CANVAS_VISUAL_DIRECTION_PROFILES,
|
|
11
30
|
ChallengeOrchestrator,
|
|
12
31
|
buildBlockerArtifacts,
|
|
13
32
|
buildMacroResolveSuccessHandoff,
|
|
@@ -28,7 +47,7 @@ import {
|
|
|
28
47
|
runResearchWorkflow,
|
|
29
48
|
runShoppingWorkflow,
|
|
30
49
|
toSnippet
|
|
31
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-AVQL6WAS.js";
|
|
32
51
|
import {
|
|
33
52
|
ProviderRuntimeError
|
|
34
53
|
} from "./chunk-FUSXMW3G.js";
|
|
@@ -1147,7 +1166,7 @@ function shouldRetry(error) {
|
|
|
1147
1166
|
return !/missing|invalid|unknown ref|no active target/i.test(message);
|
|
1148
1167
|
}
|
|
1149
1168
|
function sleep(ms) {
|
|
1150
|
-
return new Promise((
|
|
1169
|
+
return new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
1151
1170
|
}
|
|
1152
1171
|
|
|
1153
1172
|
// src/annotate/agent-inbox-store.ts
|
|
@@ -1907,7 +1926,7 @@ var buildCommandFailureMessage = (file, args2, stderr, signal) => {
|
|
|
1907
1926
|
}
|
|
1908
1927
|
return signal ? `Command failed: ${command} (${signal})` : `Command failed: ${command}`;
|
|
1909
1928
|
};
|
|
1910
|
-
var spawnFileAsync = (file, args2 = [], options = {}) => new Promise((
|
|
1929
|
+
var spawnFileAsync = (file, args2 = [], options = {}) => new Promise((resolve9, reject) => {
|
|
1911
1930
|
const encoding = options.encoding ?? "utf8";
|
|
1912
1931
|
const maxBuffer = options.maxBuffer ?? MAX_PROCESS_OUTPUT_BYTES;
|
|
1913
1932
|
const child = spawn(file, [...args2], { stdio: ["ignore", "pipe", "pipe"] });
|
|
@@ -1952,7 +1971,7 @@ var spawnFileAsync = (file, args2 = [], options = {}) => new Promise((resolve8,
|
|
|
1952
1971
|
child.on("error", fail);
|
|
1953
1972
|
child.on("close", (code, signal) => {
|
|
1954
1973
|
if (code === 0) {
|
|
1955
|
-
settle(() =>
|
|
1974
|
+
settle(() => resolve9({
|
|
1956
1975
|
stdout: decodeProcessOutput(stdout, encoding),
|
|
1957
1976
|
stderr: decodeProcessOutput(stderr, encoding)
|
|
1958
1977
|
}));
|
|
@@ -2684,14 +2703,14 @@ var OpsClient = class _OpsClient {
|
|
|
2684
2703
|
if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {
|
|
2685
2704
|
this.clearReconnectTimer();
|
|
2686
2705
|
this.socket = new WebSocket(this.url);
|
|
2687
|
-
await new Promise((
|
|
2706
|
+
await new Promise((resolve9, reject) => {
|
|
2688
2707
|
if (!this.socket) {
|
|
2689
2708
|
reject(new Error("Ops socket not created"));
|
|
2690
2709
|
return;
|
|
2691
2710
|
}
|
|
2692
2711
|
const onOpen = () => {
|
|
2693
2712
|
cleanup();
|
|
2694
|
-
|
|
2713
|
+
resolve9();
|
|
2695
2714
|
};
|
|
2696
2715
|
const onError = (error) => {
|
|
2697
2716
|
cleanup();
|
|
@@ -2718,13 +2737,13 @@ var OpsClient = class _OpsClient {
|
|
|
2718
2737
|
version: OPS_PROTOCOL_VERSION,
|
|
2719
2738
|
maxPayloadBytes: this.maxPayloadBytes
|
|
2720
2739
|
};
|
|
2721
|
-
const ack = await new Promise((
|
|
2740
|
+
const ack = await new Promise((resolve9, reject) => {
|
|
2722
2741
|
const timeoutId = setTimeout(() => {
|
|
2723
2742
|
reject(new Error("Ops handshake timeout"));
|
|
2724
2743
|
}, this.handshakeTimeoutMs);
|
|
2725
2744
|
const handler = (message) => {
|
|
2726
2745
|
clearTimeout(timeoutId);
|
|
2727
|
-
|
|
2746
|
+
resolve9(message);
|
|
2728
2747
|
};
|
|
2729
2748
|
this.waitForHelloAck(handler, reject);
|
|
2730
2749
|
try {
|
|
@@ -2775,7 +2794,7 @@ var OpsClient = class _OpsClient {
|
|
|
2775
2794
|
if (!socket || socket.readyState === WebSocket.CLOSED) {
|
|
2776
2795
|
return;
|
|
2777
2796
|
}
|
|
2778
|
-
this.disconnectPromise = new Promise((
|
|
2797
|
+
this.disconnectPromise = new Promise((resolve9) => {
|
|
2779
2798
|
let settled = false;
|
|
2780
2799
|
const finalize = () => {
|
|
2781
2800
|
if (settled) return;
|
|
@@ -2784,7 +2803,7 @@ var OpsClient = class _OpsClient {
|
|
|
2784
2803
|
socket.removeListener("close", onClose);
|
|
2785
2804
|
socket.removeListener("error", onError);
|
|
2786
2805
|
this.disconnectPromise = null;
|
|
2787
|
-
|
|
2806
|
+
resolve9();
|
|
2788
2807
|
};
|
|
2789
2808
|
const onClose = () => {
|
|
2790
2809
|
finalize();
|
|
@@ -2830,7 +2849,7 @@ var OpsClient = class _OpsClient {
|
|
|
2830
2849
|
if (Buffer.byteLength(serialized) > this.maxPayloadBytes) {
|
|
2831
2850
|
throw new Error("Ops request payload exceeded max size");
|
|
2832
2851
|
}
|
|
2833
|
-
return await new Promise((
|
|
2852
|
+
return await new Promise((resolve9, reject) => {
|
|
2834
2853
|
const timeoutId = setTimeout(() => {
|
|
2835
2854
|
this.pendingRequests.delete(requestId);
|
|
2836
2855
|
reject(new OpsRequestTimeoutError({
|
|
@@ -2841,7 +2860,7 @@ var OpsClient = class _OpsClient {
|
|
|
2841
2860
|
...typeof leaseId === "string" ? { leaseId } : {}
|
|
2842
2861
|
}));
|
|
2843
2862
|
}, timeoutMs);
|
|
2844
|
-
const resolvePending = (value) =>
|
|
2863
|
+
const resolvePending = (value) => resolve9(value);
|
|
2845
2864
|
this.pendingRequests.set(requestId, { resolve: resolvePending, reject, timeoutId });
|
|
2846
2865
|
try {
|
|
2847
2866
|
this.sendRaw(serialized);
|
|
@@ -2988,12 +3007,12 @@ var OpsClient = class _OpsClient {
|
|
|
2988
3007
|
}
|
|
2989
3008
|
const id2 = randomUUID5();
|
|
2990
3009
|
const ping = { type: "ops_ping", id: id2 };
|
|
2991
|
-
return await new Promise((
|
|
3010
|
+
return await new Promise((resolve9, reject) => {
|
|
2992
3011
|
const timeoutId = setTimeout(() => {
|
|
2993
3012
|
this.pendingPings.delete(id2);
|
|
2994
3013
|
reject(new Error("Ops ping timed out"));
|
|
2995
3014
|
}, this.pingTimeoutMs);
|
|
2996
|
-
this.pendingPings.set(id2, { resolve:
|
|
3015
|
+
this.pendingPings.set(id2, { resolve: resolve9, reject, timeoutId });
|
|
2997
3016
|
try {
|
|
2998
3017
|
this.send(ping);
|
|
2999
3018
|
} catch (error) {
|
|
@@ -3184,7 +3203,7 @@ var shouldAttachExtensionStartUrl = (request) => request.source === "social" ||
|
|
|
3184
3203
|
var SOCIAL_EXTENSION_MODE_ATTEMPTS = 3;
|
|
3185
3204
|
var resolveSocialExtensionModeAttempts = (request, preferredMode) => preferredMode === "extension" && request.source === "social" ? SOCIAL_EXTENSION_MODE_ATTEMPTS : 1;
|
|
3186
3205
|
var waitForSocialExtensionRetryGap = async () => {
|
|
3187
|
-
await new Promise((
|
|
3206
|
+
await new Promise((resolve9) => setTimeout(resolve9, SOCIAL_EXTENSION_RETRY_DELAY_MS));
|
|
3188
3207
|
};
|
|
3189
3208
|
var resolveFallbackNavigationWaitUntil = (source, mode) => source === "shopping" && mode === "managed_headed" ? "domcontentloaded" : "load";
|
|
3190
3209
|
var normalizeExtensionAttachUrl = (value) => {
|
|
@@ -3417,7 +3436,7 @@ var waitForFallbackCaptureDelay = async (delayMs, waitForTimeout) => {
|
|
|
3417
3436
|
await waitForTimeout(delayMs);
|
|
3418
3437
|
return;
|
|
3419
3438
|
}
|
|
3420
|
-
await new Promise((
|
|
3439
|
+
await new Promise((resolve9) => setTimeout(resolve9, delayMs));
|
|
3421
3440
|
};
|
|
3422
3441
|
var waitForFallbackPageToSettle = async (manager, sessionId, _source, timeoutMs) => {
|
|
3423
3442
|
if (typeof manager.waitForLoad !== "function") return;
|
|
@@ -5937,13 +5956,14 @@ function pushCanarySample(state, policy, sample) {
|
|
|
5937
5956
|
const samples = [...state.samples, sample].slice(-windowSize);
|
|
5938
5957
|
const averageScore = average(samples.map((entry) => Math.max(0, Math.min(100, entry.score))));
|
|
5939
5958
|
const minSamples = Math.max(1, policy.minSamples);
|
|
5959
|
+
const hadEligibleWindow = state.samples.length >= minSamples;
|
|
5940
5960
|
let action = "none";
|
|
5941
5961
|
let level = state.level;
|
|
5942
5962
|
if (samples.length >= minSamples) {
|
|
5943
|
-
if (averageScore >= policy.promoteThreshold) {
|
|
5963
|
+
if (averageScore >= policy.promoteThreshold && (!hadEligibleWindow || state.averageScore < policy.promoteThreshold)) {
|
|
5944
5964
|
level += 1;
|
|
5945
5965
|
action = "promote";
|
|
5946
|
-
} else if (averageScore <= policy.rollbackThreshold) {
|
|
5966
|
+
} else if (averageScore <= policy.rollbackThreshold && (!hadEligibleWindow || state.averageScore > policy.rollbackThreshold)) {
|
|
5947
5967
|
level = Math.max(0, level - 1);
|
|
5948
5968
|
action = "rollback";
|
|
5949
5969
|
}
|
|
@@ -6408,14 +6428,14 @@ var TargetManager = class {
|
|
|
6408
6428
|
}
|
|
6409
6429
|
};
|
|
6410
6430
|
var readWithTimeout = async (reader, timeoutMs = TARGET_INFO_TIMEOUT_MS) => {
|
|
6411
|
-
return await new Promise((
|
|
6412
|
-
const timeoutId = setTimeout(() =>
|
|
6431
|
+
return await new Promise((resolve9) => {
|
|
6432
|
+
const timeoutId = setTimeout(() => resolve9(void 0), timeoutMs);
|
|
6413
6433
|
reader().then((value) => {
|
|
6414
6434
|
clearTimeout(timeoutId);
|
|
6415
|
-
|
|
6435
|
+
resolve9(value);
|
|
6416
6436
|
}).catch(() => {
|
|
6417
6437
|
clearTimeout(timeoutId);
|
|
6418
|
-
|
|
6438
|
+
resolve9(void 0);
|
|
6419
6439
|
});
|
|
6420
6440
|
});
|
|
6421
6441
|
};
|
|
@@ -10328,13 +10348,13 @@ var BrowserManager = class {
|
|
|
10328
10348
|
state.inflight += 1;
|
|
10329
10349
|
return;
|
|
10330
10350
|
}
|
|
10331
|
-
await new Promise((
|
|
10351
|
+
await new Promise((resolve9, reject) => {
|
|
10332
10352
|
const enqueuedAt = Date.now();
|
|
10333
10353
|
const waiter = {
|
|
10334
10354
|
targetId,
|
|
10335
10355
|
enqueuedAt,
|
|
10336
10356
|
timeoutMs,
|
|
10337
|
-
resolve:
|
|
10357
|
+
resolve: resolve9,
|
|
10338
10358
|
reject,
|
|
10339
10359
|
timer: null
|
|
10340
10360
|
};
|
|
@@ -10379,8 +10399,8 @@ var BrowserManager = class {
|
|
|
10379
10399
|
const previous = this.targetQueues.get(queueKey) ?? Promise.resolve();
|
|
10380
10400
|
let releaseQueue = () => {
|
|
10381
10401
|
};
|
|
10382
|
-
const gate = new Promise((
|
|
10383
|
-
releaseQueue =
|
|
10402
|
+
const gate = new Promise((resolve9) => {
|
|
10403
|
+
releaseQueue = resolve9;
|
|
10384
10404
|
});
|
|
10385
10405
|
const tail = previous.then(() => gate, () => gate);
|
|
10386
10406
|
this.targetQueues.set(queueKey, tail);
|
|
@@ -10587,14 +10607,14 @@ var BrowserManager = class {
|
|
|
10587
10607
|
};
|
|
10588
10608
|
const pendingClick = {
|
|
10589
10609
|
dialogOpened: false,
|
|
10590
|
-
dialogHandled: new Promise((
|
|
10591
|
-
resolveDialogHandled =
|
|
10610
|
+
dialogHandled: new Promise((resolve9) => {
|
|
10611
|
+
resolveDialogHandled = resolve9;
|
|
10592
10612
|
}),
|
|
10593
10613
|
resolveDialogHandled: () => {
|
|
10594
10614
|
resolveDialogHandled();
|
|
10595
10615
|
},
|
|
10596
|
-
completed: new Promise((
|
|
10597
|
-
resolveCompleted =
|
|
10616
|
+
completed: new Promise((resolve9) => {
|
|
10617
|
+
resolveCompleted = resolve9;
|
|
10598
10618
|
}),
|
|
10599
10619
|
resolveCompleted: () => {
|
|
10600
10620
|
resolveCompleted();
|
|
@@ -11454,7 +11474,7 @@ function isExtensionRelayDisconnectError(detail) {
|
|
|
11454
11474
|
function isExtensionRelaySingleClientError(detail) {
|
|
11455
11475
|
return detail.toLowerCase().includes("only one cdp client supported");
|
|
11456
11476
|
}
|
|
11457
|
-
var delay2 = (ms) => new Promise((
|
|
11477
|
+
var delay2 = (ms) => new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
11458
11478
|
function truncateText(value, maxChars) {
|
|
11459
11479
|
if (value.length <= maxChars) {
|
|
11460
11480
|
return { text: value, truncated: false };
|
|
@@ -12490,7 +12510,7 @@ var OpsBrowserManager = class {
|
|
|
12490
12510
|
}
|
|
12491
12511
|
} catch {
|
|
12492
12512
|
}
|
|
12493
|
-
await new Promise((
|
|
12513
|
+
await new Promise((resolve9) => setTimeout(resolve9, 250));
|
|
12494
12514
|
}
|
|
12495
12515
|
return false;
|
|
12496
12516
|
}
|
|
@@ -13017,9 +13037,9 @@ async function runDirectAnnotate(manager, assets, request) {
|
|
|
13017
13037
|
await ensureAnnotationReady(page);
|
|
13018
13038
|
let readySeen = false;
|
|
13019
13039
|
const completionHandlers = getCompletionMap(page);
|
|
13020
|
-
const responsePromise = new Promise((
|
|
13040
|
+
const responsePromise = new Promise((resolve9) => {
|
|
13021
13041
|
completionHandlers.set(requestId, (message) => {
|
|
13022
|
-
|
|
13042
|
+
resolve9(mapCompletionToResponse(message, requestId));
|
|
13023
13043
|
});
|
|
13024
13044
|
});
|
|
13025
13045
|
const startResponse = await dispatchMessage(page, {
|
|
@@ -13037,10 +13057,10 @@ async function runDirectAnnotate(manager, assets, request) {
|
|
|
13037
13057
|
completionHandlers.delete(requestId);
|
|
13038
13058
|
throw new Error("Annotation start acknowledgement missing active bridge.");
|
|
13039
13059
|
}
|
|
13040
|
-
const timeoutPromise = new Promise((
|
|
13060
|
+
const timeoutPromise = new Promise((resolve9) => {
|
|
13041
13061
|
const timeoutId = setTimeout(() => {
|
|
13042
13062
|
clearTimeout(timeoutId);
|
|
13043
|
-
|
|
13063
|
+
resolve9({
|
|
13044
13064
|
version: 1,
|
|
13045
13065
|
requestId,
|
|
13046
13066
|
status: "error",
|
|
@@ -13048,10 +13068,10 @@ async function runDirectAnnotate(manager, assets, request) {
|
|
|
13048
13068
|
});
|
|
13049
13069
|
}, timeoutMs);
|
|
13050
13070
|
});
|
|
13051
|
-
const abortPromise = new Promise((
|
|
13071
|
+
const abortPromise = new Promise((resolve9) => {
|
|
13052
13072
|
if (!request.signal) return;
|
|
13053
13073
|
if (request.signal.aborted) {
|
|
13054
|
-
|
|
13074
|
+
resolve9({
|
|
13055
13075
|
version: 1,
|
|
13056
13076
|
requestId,
|
|
13057
13077
|
status: "cancelled",
|
|
@@ -13060,7 +13080,7 @@ async function runDirectAnnotate(manager, assets, request) {
|
|
|
13060
13080
|
return;
|
|
13061
13081
|
}
|
|
13062
13082
|
const onAbort = () => {
|
|
13063
|
-
|
|
13083
|
+
resolve9({
|
|
13064
13084
|
version: 1,
|
|
13065
13085
|
requestId,
|
|
13066
13086
|
status: "cancelled",
|
|
@@ -13483,7 +13503,7 @@ var AnnotationManager = class {
|
|
|
13483
13503
|
socket.close(1e3, "Annotation complete");
|
|
13484
13504
|
}
|
|
13485
13505
|
};
|
|
13486
|
-
const responsePromise = new Promise((
|
|
13506
|
+
const responsePromise = new Promise((resolve9, reject) => {
|
|
13487
13507
|
socket.on("message", (data) => {
|
|
13488
13508
|
const message = parseJson2(data);
|
|
13489
13509
|
if (!message || typeof message !== "object") return;
|
|
@@ -13492,7 +13512,7 @@ var AnnotationManager = class {
|
|
|
13492
13512
|
const response = record;
|
|
13493
13513
|
if (response.payload?.requestId === requestId) {
|
|
13494
13514
|
terminalResponse = response.payload;
|
|
13495
|
-
|
|
13515
|
+
resolve9(response.payload);
|
|
13496
13516
|
}
|
|
13497
13517
|
} else if (record.type === "annotationEvent") {
|
|
13498
13518
|
const event = record;
|
|
@@ -13507,11 +13527,11 @@ var AnnotationManager = class {
|
|
|
13507
13527
|
socket.on("error", (error) => reject(error));
|
|
13508
13528
|
socket.on("close", () => {
|
|
13509
13529
|
if (terminalResponse) {
|
|
13510
|
-
|
|
13530
|
+
resolve9(terminalResponse);
|
|
13511
13531
|
return;
|
|
13512
13532
|
}
|
|
13513
13533
|
if (commandName === "start" && readySeen) {
|
|
13514
|
-
|
|
13534
|
+
resolve9({
|
|
13515
13535
|
version: 1,
|
|
13516
13536
|
requestId,
|
|
13517
13537
|
status: "cancelled",
|
|
@@ -13523,11 +13543,11 @@ var AnnotationManager = class {
|
|
|
13523
13543
|
});
|
|
13524
13544
|
});
|
|
13525
13545
|
let timedOut = false;
|
|
13526
|
-
const timeoutPromise = new Promise((
|
|
13546
|
+
const timeoutPromise = new Promise((resolve9) => {
|
|
13527
13547
|
const id2 = setTimeout(() => {
|
|
13528
13548
|
clearTimeout(id2);
|
|
13529
13549
|
timedOut = true;
|
|
13530
|
-
|
|
13550
|
+
resolve9({
|
|
13531
13551
|
version: 1,
|
|
13532
13552
|
requestId,
|
|
13533
13553
|
status: "error",
|
|
@@ -13536,11 +13556,11 @@ var AnnotationManager = class {
|
|
|
13536
13556
|
}, timeoutMs);
|
|
13537
13557
|
});
|
|
13538
13558
|
let locallyAborted = false;
|
|
13539
|
-
const abortPromise = new Promise((
|
|
13559
|
+
const abortPromise = new Promise((resolve9) => {
|
|
13540
13560
|
if (!options.signal) return;
|
|
13541
13561
|
if (options.signal.aborted) {
|
|
13542
13562
|
locallyAborted = true;
|
|
13543
|
-
|
|
13563
|
+
resolve9({
|
|
13544
13564
|
version: 1,
|
|
13545
13565
|
requestId,
|
|
13546
13566
|
status: "cancelled",
|
|
@@ -13550,7 +13570,7 @@ var AnnotationManager = class {
|
|
|
13550
13570
|
}
|
|
13551
13571
|
const onAbort = () => {
|
|
13552
13572
|
locallyAborted = true;
|
|
13553
|
-
|
|
13573
|
+
resolve9({
|
|
13554
13574
|
version: 1,
|
|
13555
13575
|
requestId,
|
|
13556
13576
|
status: "cancelled",
|
|
@@ -13581,13 +13601,13 @@ var AnnotationManager = class {
|
|
|
13581
13601
|
}
|
|
13582
13602
|
};
|
|
13583
13603
|
var waitForSocketOpen = (socket, timeoutMs) => {
|
|
13584
|
-
return new Promise((
|
|
13604
|
+
return new Promise((resolve9, reject) => {
|
|
13585
13605
|
const timeout = setTimeout(() => {
|
|
13586
13606
|
reject(new Error("Annotation socket open timed out"));
|
|
13587
13607
|
}, timeoutMs);
|
|
13588
13608
|
socket.once("open", () => {
|
|
13589
13609
|
clearTimeout(timeout);
|
|
13590
|
-
|
|
13610
|
+
resolve9();
|
|
13591
13611
|
});
|
|
13592
13612
|
socket.once("error", (error) => {
|
|
13593
13613
|
clearTimeout(timeout);
|
|
@@ -13676,7 +13696,7 @@ var CanvasClient = class {
|
|
|
13676
13696
|
if (!this.socket || this.socket.readyState !== WebSocket3.OPEN) {
|
|
13677
13697
|
this.clearReconnectTimer();
|
|
13678
13698
|
this.socket = new WebSocket3(this.url);
|
|
13679
|
-
await new Promise((
|
|
13699
|
+
await new Promise((resolve9, reject) => {
|
|
13680
13700
|
if (!this.socket) {
|
|
13681
13701
|
reject(new Error("Canvas socket not created"));
|
|
13682
13702
|
return;
|
|
@@ -13691,7 +13711,7 @@ var CanvasClient = class {
|
|
|
13691
13711
|
}, this.handshakeTimeoutMs);
|
|
13692
13712
|
const onOpen = () => {
|
|
13693
13713
|
cleanup();
|
|
13694
|
-
|
|
13714
|
+
resolve9();
|
|
13695
13715
|
};
|
|
13696
13716
|
const onError = (error) => {
|
|
13697
13717
|
cleanup();
|
|
@@ -13726,7 +13746,7 @@ var CanvasClient = class {
|
|
|
13726
13746
|
version: CANVAS_PROTOCOL_VERSION,
|
|
13727
13747
|
maxPayloadBytes: this.maxPayloadBytes
|
|
13728
13748
|
};
|
|
13729
|
-
const ack = await new Promise((
|
|
13749
|
+
const ack = await new Promise((resolve9, reject) => {
|
|
13730
13750
|
const cleanup = () => {
|
|
13731
13751
|
clearTimeout(timeoutId);
|
|
13732
13752
|
this.socket?.removeListener("canvas_hello_ack", onAck);
|
|
@@ -13743,7 +13763,7 @@ var CanvasClient = class {
|
|
|
13743
13763
|
}, this.handshakeTimeoutMs);
|
|
13744
13764
|
const onAck = (message) => {
|
|
13745
13765
|
cleanup();
|
|
13746
|
-
|
|
13766
|
+
resolve9(message);
|
|
13747
13767
|
};
|
|
13748
13768
|
const onError = (message) => {
|
|
13749
13769
|
cleanup();
|
|
@@ -13819,13 +13839,13 @@ var CanvasClient = class {
|
|
|
13819
13839
|
if (Buffer.byteLength(serialized) > this.maxPayloadBytes) {
|
|
13820
13840
|
throw new Error("Canvas request payload exceeded max size");
|
|
13821
13841
|
}
|
|
13822
|
-
return await new Promise((
|
|
13842
|
+
return await new Promise((resolve9, reject) => {
|
|
13823
13843
|
const timeoutId = setTimeout(() => {
|
|
13824
13844
|
this.pendingRequests.delete(requestId);
|
|
13825
13845
|
reject(new Error("Canvas request timed out"));
|
|
13826
13846
|
}, timeoutMs);
|
|
13827
13847
|
timeoutId.unref?.();
|
|
13828
|
-
this.pendingRequests.set(requestId, { resolve: (value) =>
|
|
13848
|
+
this.pendingRequests.set(requestId, { resolve: (value) => resolve9(value), reject, timeoutId });
|
|
13829
13849
|
try {
|
|
13830
13850
|
this.sendRaw(serialized);
|
|
13831
13851
|
} catch (error) {
|
|
@@ -13954,7 +13974,7 @@ var CanvasClient = class {
|
|
|
13954
13974
|
}
|
|
13955
13975
|
const id2 = randomUUID14();
|
|
13956
13976
|
const ping = { type: "canvas_ping", id: id2 };
|
|
13957
|
-
await new Promise((
|
|
13977
|
+
await new Promise((resolve9, reject) => {
|
|
13958
13978
|
const timeoutId = setTimeout(() => {
|
|
13959
13979
|
this.pendingPings.delete(id2);
|
|
13960
13980
|
this.missedPongs += 1;
|
|
@@ -13964,7 +13984,7 @@ var CanvasClient = class {
|
|
|
13964
13984
|
reject(new Error("Canvas ping timed out"));
|
|
13965
13985
|
}, this.pingTimeoutMs);
|
|
13966
13986
|
timeoutId.unref?.();
|
|
13967
|
-
this.pendingPings.set(id2, { resolve:
|
|
13987
|
+
this.pendingPings.set(id2, { resolve: resolve9, reject, timeoutId });
|
|
13968
13988
|
try {
|
|
13969
13989
|
this.send(ping);
|
|
13970
13990
|
} catch (error) {
|
|
@@ -15301,17 +15321,17 @@ var Doc = class _Doc extends ObservableV2 {
|
|
|
15301
15321
|
this.isLoaded = false;
|
|
15302
15322
|
this.isSynced = false;
|
|
15303
15323
|
this.isDestroyed = false;
|
|
15304
|
-
this.whenLoaded = create4((
|
|
15324
|
+
this.whenLoaded = create4((resolve9) => {
|
|
15305
15325
|
this.on("load", () => {
|
|
15306
15326
|
this.isLoaded = true;
|
|
15307
|
-
|
|
15327
|
+
resolve9(this);
|
|
15308
15328
|
});
|
|
15309
15329
|
});
|
|
15310
|
-
const provideSyncedPromise = () => create4((
|
|
15330
|
+
const provideSyncedPromise = () => create4((resolve9) => {
|
|
15311
15331
|
const eventHandler = (isSynced) => {
|
|
15312
15332
|
if (isSynced === void 0 || isSynced === true) {
|
|
15313
15333
|
this.off("sync", eventHandler);
|
|
15314
|
-
|
|
15334
|
+
resolve9();
|
|
15315
15335
|
}
|
|
15316
15336
|
};
|
|
15317
15337
|
this.on("sync", eventHandler);
|
|
@@ -21497,133 +21517,6 @@ if (glo[importIdentifier] === true) {
|
|
|
21497
21517
|
}
|
|
21498
21518
|
glo[importIdentifier] = true;
|
|
21499
21519
|
|
|
21500
|
-
// src/canvas/types.ts
|
|
21501
|
-
var CANVAS_SCHEMA_VERSION = "1.0.0";
|
|
21502
|
-
var CANVAS_SESSION_MODES = ["low-fi-wireframe", "high-fi-live-edit", "dual-track", "document-only"];
|
|
21503
|
-
var CANVAS_GOVERNANCE_BLOCK_KEYS = [
|
|
21504
|
-
"intent",
|
|
21505
|
-
"generationPlan",
|
|
21506
|
-
"designLanguage",
|
|
21507
|
-
"contentModel",
|
|
21508
|
-
"layoutSystem",
|
|
21509
|
-
"typographySystem",
|
|
21510
|
-
"colorSystem",
|
|
21511
|
-
"surfaceSystem",
|
|
21512
|
-
"iconSystem",
|
|
21513
|
-
"motionSystem",
|
|
21514
|
-
"responsiveSystem",
|
|
21515
|
-
"accessibilityPolicy",
|
|
21516
|
-
"libraryPolicy",
|
|
21517
|
-
"runtimeBudgets"
|
|
21518
|
-
];
|
|
21519
|
-
var CANVAS_REQUIRED_MUTATION_GOVERNANCE_KEYS = [
|
|
21520
|
-
"intent",
|
|
21521
|
-
"generationPlan",
|
|
21522
|
-
"designLanguage",
|
|
21523
|
-
"contentModel",
|
|
21524
|
-
"layoutSystem",
|
|
21525
|
-
"typographySystem",
|
|
21526
|
-
"motionSystem",
|
|
21527
|
-
"responsiveSystem",
|
|
21528
|
-
"accessibilityPolicy"
|
|
21529
|
-
];
|
|
21530
|
-
var CANVAS_REQUIRED_SAVE_GOVERNANCE_KEYS = [
|
|
21531
|
-
"intent",
|
|
21532
|
-
"generationPlan",
|
|
21533
|
-
"designLanguage",
|
|
21534
|
-
"contentModel",
|
|
21535
|
-
"layoutSystem",
|
|
21536
|
-
"typographySystem",
|
|
21537
|
-
"colorSystem",
|
|
21538
|
-
"surfaceSystem",
|
|
21539
|
-
"iconSystem",
|
|
21540
|
-
"motionSystem",
|
|
21541
|
-
"responsiveSystem",
|
|
21542
|
-
"accessibilityPolicy",
|
|
21543
|
-
"libraryPolicy",
|
|
21544
|
-
"runtimeBudgets"
|
|
21545
|
-
];
|
|
21546
|
-
var CANVAS_OPTIONAL_INHERITED_GOVERNANCE_KEYS = [
|
|
21547
|
-
"colorSystem",
|
|
21548
|
-
"surfaceSystem",
|
|
21549
|
-
"iconSystem",
|
|
21550
|
-
"libraryPolicy",
|
|
21551
|
-
"runtimeBudgets"
|
|
21552
|
-
];
|
|
21553
|
-
var CANVAS_GENERATION_PLAN_REQUIRED_FIELDS = [
|
|
21554
|
-
"targetOutcome",
|
|
21555
|
-
"visualDirection",
|
|
21556
|
-
"layoutStrategy",
|
|
21557
|
-
"contentStrategy",
|
|
21558
|
-
"componentStrategy",
|
|
21559
|
-
"motionPosture",
|
|
21560
|
-
"responsivePosture",
|
|
21561
|
-
"accessibilityPosture",
|
|
21562
|
-
"validationTargets"
|
|
21563
|
-
];
|
|
21564
|
-
var CANVAS_VISUAL_DIRECTION_PROFILES = [
|
|
21565
|
-
"clean-room",
|
|
21566
|
-
"cinematic-minimal",
|
|
21567
|
-
"product-story",
|
|
21568
|
-
"commerce-system",
|
|
21569
|
-
"control-room",
|
|
21570
|
-
"ops-control",
|
|
21571
|
-
"auth-focused",
|
|
21572
|
-
"settings-system",
|
|
21573
|
-
"documentation"
|
|
21574
|
-
];
|
|
21575
|
-
var CANVAS_THEME_STRATEGIES = ["single-theme", "light-dark-parity", "multi-theme-system"];
|
|
21576
|
-
var CANVAS_NAVIGATION_MODELS = ["global-header", "sidebar", "tabbed", "contextual", "immersive"];
|
|
21577
|
-
var CANVAS_INTERACTION_STATES = [
|
|
21578
|
-
"default",
|
|
21579
|
-
"hover",
|
|
21580
|
-
"focus",
|
|
21581
|
-
"active",
|
|
21582
|
-
"disabled",
|
|
21583
|
-
"loading",
|
|
21584
|
-
"empty",
|
|
21585
|
-
"error",
|
|
21586
|
-
"success",
|
|
21587
|
-
"selected"
|
|
21588
|
-
];
|
|
21589
|
-
var CANVAS_PLAN_VIEWPORTS = ["desktop", "tablet", "mobile"];
|
|
21590
|
-
var CANVAS_PLAN_THEMES = ["light", "dark"];
|
|
21591
|
-
var CANVAS_MOTION_LEVELS = ["none", "minimal", "subtle", "expressive"];
|
|
21592
|
-
var CANVAS_REDUCED_MOTION_POLICIES = ["respect-user-preference", "static-alternative"];
|
|
21593
|
-
var CANVAS_KEYBOARD_NAVIGATION_MODES = ["full", "core-flows"];
|
|
21594
|
-
var CANVAS_BROWSER_VALIDATION_MODES = ["required", "optional"];
|
|
21595
|
-
var CANVAS_VALIDATION_TARGET_BLOCK_ON_CODES = [
|
|
21596
|
-
"missing-generation-plan",
|
|
21597
|
-
"invalid-generation-plan",
|
|
21598
|
-
"missing-governance-block",
|
|
21599
|
-
"missing-intent",
|
|
21600
|
-
"missing-design-language",
|
|
21601
|
-
"missing-content-model",
|
|
21602
|
-
"missing-typography-system",
|
|
21603
|
-
"missing-color-role",
|
|
21604
|
-
"missing-surface-policy",
|
|
21605
|
-
"missing-state-coverage",
|
|
21606
|
-
"missing-reduced-motion-policy",
|
|
21607
|
-
"missing-responsive-policy",
|
|
21608
|
-
"overflow",
|
|
21609
|
-
"token-missing",
|
|
21610
|
-
"broken-asset-reference",
|
|
21611
|
-
"contrast-failure",
|
|
21612
|
-
"hierarchy-weak",
|
|
21613
|
-
"asset-provenance-missing",
|
|
21614
|
-
"font-policy-missing",
|
|
21615
|
-
"font-load-failure",
|
|
21616
|
-
"reduced-motion-violation",
|
|
21617
|
-
"unresolved-component-binding",
|
|
21618
|
-
"icon-policy-violation",
|
|
21619
|
-
"library-policy-violation",
|
|
21620
|
-
"responsive-mismatch",
|
|
21621
|
-
"runtime-budget-exceeded",
|
|
21622
|
-
"unsupported-target",
|
|
21623
|
-
"export-warning"
|
|
21624
|
-
];
|
|
21625
|
-
var CANVAS_PUBLIC_WARNING_CLASSES = CANVAS_VALIDATION_TARGET_BLOCK_ON_CODES;
|
|
21626
|
-
|
|
21627
21520
|
// src/canvas/token-references.ts
|
|
21628
21521
|
var TOKEN_CSS_PREFIX = "--odb-token-";
|
|
21629
21522
|
function isRecord5(value) {
|
|
@@ -32047,8 +31940,8 @@ var CanvasManager = class {
|
|
|
32047
31940
|
}
|
|
32048
31941
|
continue;
|
|
32049
31942
|
}
|
|
32050
|
-
const awaited = await new Promise((
|
|
32051
|
-
subscription.waiters.push(
|
|
31943
|
+
const awaited = await new Promise((resolve9) => {
|
|
31944
|
+
subscription.waiters.push(resolve9);
|
|
32052
31945
|
});
|
|
32053
31946
|
if (awaited) {
|
|
32054
31947
|
yield awaited;
|
|
@@ -32077,14 +31970,14 @@ var CanvasManager = class {
|
|
|
32077
31970
|
reason: "subscription_replaced"
|
|
32078
31971
|
};
|
|
32079
31972
|
}
|
|
32080
|
-
return await new Promise((
|
|
31973
|
+
return await new Promise((resolve9) => {
|
|
32081
31974
|
let timeoutHandle = null;
|
|
32082
31975
|
const resolveWaiter = (event) => {
|
|
32083
31976
|
if (timeoutHandle) {
|
|
32084
31977
|
clearTimeout(timeoutHandle);
|
|
32085
31978
|
}
|
|
32086
31979
|
if (!event) {
|
|
32087
|
-
|
|
31980
|
+
resolve9({
|
|
32088
31981
|
eventType: "feedback.complete",
|
|
32089
31982
|
cursor: subscription.cursor,
|
|
32090
31983
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -32092,7 +31985,7 @@ var CanvasManager = class {
|
|
|
32092
31985
|
});
|
|
32093
31986
|
return;
|
|
32094
31987
|
}
|
|
32095
|
-
|
|
31988
|
+
resolve9(event);
|
|
32096
31989
|
};
|
|
32097
31990
|
subscription.waiters.push(resolveWaiter);
|
|
32098
31991
|
if (timeoutMs === void 0) {
|
|
@@ -32104,7 +31997,7 @@ var CanvasManager = class {
|
|
|
32104
31997
|
subscription.waiters.splice(waiterIndex, 1);
|
|
32105
31998
|
}
|
|
32106
31999
|
subscription.lastHeartbeatAt = Date.now();
|
|
32107
|
-
|
|
32000
|
+
resolve9({
|
|
32108
32001
|
eventType: "feedback.heartbeat",
|
|
32109
32002
|
cursor: subscription.cursor,
|
|
32110
32003
|
ts: new Date(subscription.lastHeartbeatAt).toISOString(),
|
|
@@ -34723,10 +34616,10 @@ var RelayServer = class _RelayServer {
|
|
|
34723
34616
|
}
|
|
34724
34617
|
socket.destroy();
|
|
34725
34618
|
});
|
|
34726
|
-
await new Promise((
|
|
34619
|
+
await new Promise((resolve9, reject) => {
|
|
34727
34620
|
this.server?.once("error", reject);
|
|
34728
34621
|
this.server?.listen(port, "127.0.0.1", () => {
|
|
34729
|
-
|
|
34622
|
+
resolve9();
|
|
34730
34623
|
});
|
|
34731
34624
|
});
|
|
34732
34625
|
const address = this.server.address();
|
|
@@ -34842,15 +34735,15 @@ var RelayServer = class _RelayServer {
|
|
|
34842
34735
|
error: { code: "invalid_request", message: "Duplicate annotation requestId." }
|
|
34843
34736
|
};
|
|
34844
34737
|
}
|
|
34845
|
-
return await new Promise((
|
|
34738
|
+
return await new Promise((resolve9) => {
|
|
34846
34739
|
const pending = {
|
|
34847
|
-
resolve:
|
|
34740
|
+
resolve: resolve9,
|
|
34848
34741
|
timeout: null,
|
|
34849
34742
|
readySeen: false
|
|
34850
34743
|
};
|
|
34851
34744
|
const timeout = setTimeout(() => {
|
|
34852
34745
|
this.annotationDirectPending.delete(command.requestId);
|
|
34853
|
-
|
|
34746
|
+
resolve9({
|
|
34854
34747
|
version: 1,
|
|
34855
34748
|
requestId: command.requestId,
|
|
34856
34749
|
status: "error",
|
|
@@ -35064,10 +34957,10 @@ var RelayServer = class _RelayServer {
|
|
|
35064
34957
|
response.writeHead(404);
|
|
35065
34958
|
response.end();
|
|
35066
34959
|
});
|
|
35067
|
-
await new Promise((
|
|
34960
|
+
await new Promise((resolve9, reject) => {
|
|
35068
34961
|
this.discoveryServer?.once("error", reject);
|
|
35069
34962
|
this.discoveryServer?.listen(this.configuredDiscoveryPort, "127.0.0.1", () => {
|
|
35070
|
-
|
|
34963
|
+
resolve9();
|
|
35071
34964
|
});
|
|
35072
34965
|
});
|
|
35073
34966
|
const address = this.discoveryServer.address();
|
|
@@ -36098,12 +35991,130 @@ function createOpenDevBrowserCore(options) {
|
|
|
36098
35991
|
};
|
|
36099
35992
|
}
|
|
36100
35993
|
|
|
35994
|
+
// src/cli/utils/http.ts
|
|
35995
|
+
var DEFAULT_HTTP_TIMEOUT_MS = 5e3;
|
|
35996
|
+
function isAbortError(error) {
|
|
35997
|
+
if (!error || typeof error !== "object") return false;
|
|
35998
|
+
return "name" in error && error.name === "AbortError";
|
|
35999
|
+
}
|
|
36000
|
+
var resolveTimeoutMs = (timeoutMs = DEFAULT_HTTP_TIMEOUT_MS) => {
|
|
36001
|
+
return Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : DEFAULT_HTTP_TIMEOUT_MS;
|
|
36002
|
+
};
|
|
36003
|
+
var createTimeoutError = (timeoutMs) => {
|
|
36004
|
+
return new Error(`Request timed out after ${timeoutMs}ms`);
|
|
36005
|
+
};
|
|
36006
|
+
var createTimedSignal = (timeoutMs, upstreamSignal) => {
|
|
36007
|
+
const controller = new AbortController();
|
|
36008
|
+
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
36009
|
+
let removeAbortListener;
|
|
36010
|
+
if (upstreamSignal) {
|
|
36011
|
+
if (upstreamSignal.aborted) {
|
|
36012
|
+
controller.abort(upstreamSignal.reason);
|
|
36013
|
+
} else {
|
|
36014
|
+
const onAbort = () => controller.abort(upstreamSignal.reason);
|
|
36015
|
+
upstreamSignal.addEventListener("abort", onAbort, { once: true });
|
|
36016
|
+
removeAbortListener = () => upstreamSignal.removeEventListener("abort", onAbort);
|
|
36017
|
+
}
|
|
36018
|
+
}
|
|
36019
|
+
return {
|
|
36020
|
+
signal: controller.signal,
|
|
36021
|
+
dispose: () => {
|
|
36022
|
+
clearTimeout(timeoutId);
|
|
36023
|
+
removeAbortListener?.();
|
|
36024
|
+
}
|
|
36025
|
+
};
|
|
36026
|
+
};
|
|
36027
|
+
var cancelResponseBody = (response) => {
|
|
36028
|
+
try {
|
|
36029
|
+
const cancelResult = response.body?.cancel?.();
|
|
36030
|
+
if (cancelResult instanceof Promise) {
|
|
36031
|
+
void cancelResult.catch(() => {
|
|
36032
|
+
});
|
|
36033
|
+
}
|
|
36034
|
+
} catch {
|
|
36035
|
+
}
|
|
36036
|
+
};
|
|
36037
|
+
var readResponseBodyWithTimeout = async (response, signal, timeoutMs, reader) => {
|
|
36038
|
+
let bodyCancelled = false;
|
|
36039
|
+
const cancelBody = () => {
|
|
36040
|
+
if (bodyCancelled) {
|
|
36041
|
+
return;
|
|
36042
|
+
}
|
|
36043
|
+
bodyCancelled = true;
|
|
36044
|
+
cancelResponseBody(response);
|
|
36045
|
+
};
|
|
36046
|
+
if (signal.aborted) {
|
|
36047
|
+
cancelBody();
|
|
36048
|
+
throw createTimeoutError(timeoutMs);
|
|
36049
|
+
}
|
|
36050
|
+
let removeAbortListener;
|
|
36051
|
+
const abortPromise = new Promise((_, reject) => {
|
|
36052
|
+
const onAbort = () => {
|
|
36053
|
+
cancelBody();
|
|
36054
|
+
reject(createTimeoutError(timeoutMs));
|
|
36055
|
+
};
|
|
36056
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
36057
|
+
removeAbortListener = () => signal.removeEventListener("abort", onAbort);
|
|
36058
|
+
});
|
|
36059
|
+
try {
|
|
36060
|
+
return await Promise.race([reader(), abortPromise]);
|
|
36061
|
+
} catch (error) {
|
|
36062
|
+
if (signal.aborted || isAbortError(error)) {
|
|
36063
|
+
cancelBody();
|
|
36064
|
+
throw createTimeoutError(timeoutMs);
|
|
36065
|
+
}
|
|
36066
|
+
throw error;
|
|
36067
|
+
} finally {
|
|
36068
|
+
removeAbortListener?.();
|
|
36069
|
+
}
|
|
36070
|
+
};
|
|
36071
|
+
async function fetchWithTimeout(input, init = {}, timeoutMs = DEFAULT_HTTP_TIMEOUT_MS) {
|
|
36072
|
+
const resolvedTimeout = resolveTimeoutMs(timeoutMs);
|
|
36073
|
+
const timedSignal = createTimedSignal(resolvedTimeout, init?.signal ?? void 0);
|
|
36074
|
+
try {
|
|
36075
|
+
return await fetch(input, { ...init, signal: timedSignal.signal });
|
|
36076
|
+
} catch (error) {
|
|
36077
|
+
if (isAbortError(error) || timedSignal.signal.aborted) {
|
|
36078
|
+
throw createTimeoutError(resolvedTimeout);
|
|
36079
|
+
}
|
|
36080
|
+
throw error;
|
|
36081
|
+
} finally {
|
|
36082
|
+
timedSignal.dispose();
|
|
36083
|
+
}
|
|
36084
|
+
}
|
|
36085
|
+
async function fetchWithTimeoutContext(input, init = {}, timeoutMs = DEFAULT_HTTP_TIMEOUT_MS) {
|
|
36086
|
+
const resolvedTimeout = resolveTimeoutMs(timeoutMs);
|
|
36087
|
+
const timedSignal = createTimedSignal(resolvedTimeout, init?.signal ?? void 0);
|
|
36088
|
+
try {
|
|
36089
|
+
const response = await fetch(input, { ...init, signal: timedSignal.signal });
|
|
36090
|
+
return {
|
|
36091
|
+
response,
|
|
36092
|
+
signal: timedSignal.signal,
|
|
36093
|
+
timeoutMs: resolvedTimeout,
|
|
36094
|
+
dispose: timedSignal.dispose
|
|
36095
|
+
};
|
|
36096
|
+
} catch (error) {
|
|
36097
|
+
timedSignal.dispose();
|
|
36098
|
+
if (isAbortError(error) || timedSignal.signal.aborted) {
|
|
36099
|
+
throw createTimeoutError(resolvedTimeout);
|
|
36100
|
+
}
|
|
36101
|
+
throw error;
|
|
36102
|
+
}
|
|
36103
|
+
}
|
|
36104
|
+
async function readResponseTextWithTimeout(response, signal, timeoutMs) {
|
|
36105
|
+
return await readResponseBodyWithTimeout(response, signal, timeoutMs, () => response.text());
|
|
36106
|
+
}
|
|
36107
|
+
async function readResponseJsonWithTimeout(response, signal, timeoutMs) {
|
|
36108
|
+
return await readResponseBodyWithTimeout(response, signal, timeoutMs, () => response.json());
|
|
36109
|
+
}
|
|
36110
|
+
|
|
36101
36111
|
// src/cli/daemon.ts
|
|
36102
36112
|
import { createServer as createServer2 } from "http";
|
|
36103
36113
|
import { createHash as createHash6, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
36104
36114
|
import { mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync3, unlinkSync, existsSync as existsSync6 } from "fs";
|
|
36105
36115
|
import { homedir as homedir7 } from "os";
|
|
36106
|
-
import { join as join16, resolve as resolve7 } from "path";
|
|
36116
|
+
import { basename as basename2, dirname as dirname8, join as join16, resolve as resolve7 } from "path";
|
|
36117
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
36107
36118
|
|
|
36108
36119
|
// src/cli/daemon-commands.ts
|
|
36109
36120
|
import { randomUUID as randomUUID22 } from "crypto";
|
|
@@ -36346,25 +36357,82 @@ function getBoolean(value) {
|
|
|
36346
36357
|
var INSPIREDESIGN_CAPTURE_TIMEOUT_MS = 3e4;
|
|
36347
36358
|
var INSPIREDESIGN_CAPTURE_MAX_CHARS = 12e3;
|
|
36348
36359
|
var ACTIVE_SESSION_COOKIE_REUSE_UNAVAILABLE_MESSAGE = "Deep capture only honors configured provider cookie sources; active session cookies are not reused.";
|
|
36360
|
+
var DOM_CAPTURE_HELPER_UNAVAILABLE_MESSAGE = "DOM capture helper unavailable in this execution lane.";
|
|
36361
|
+
var SNAPSHOT_CAPTURE_EMPTY_MESSAGE = "Snapshot capture returned empty content.";
|
|
36362
|
+
var CLONE_CAPTURE_EMPTY_MESSAGE = "Clone capture returned empty component and CSS previews.";
|
|
36363
|
+
var DOM_CAPTURE_EMPTY_MESSAGE = "DOM capture returned empty HTML.";
|
|
36364
|
+
var SKIPPED_AFTER_TRANSPORT_TIMEOUT_SUFFIX = "transport timeout.";
|
|
36349
36365
|
var createRemainingCaptureTimeout = (timeoutMs) => {
|
|
36350
36366
|
const startedAtMs = Date.now();
|
|
36351
|
-
|
|
36367
|
+
let firstRead = true;
|
|
36368
|
+
return () => {
|
|
36369
|
+
if (firstRead) {
|
|
36370
|
+
firstRead = false;
|
|
36371
|
+
return timeoutMs;
|
|
36372
|
+
}
|
|
36373
|
+
return Math.max(1, timeoutMs - Math.max(0, Date.now() - startedAtMs));
|
|
36374
|
+
};
|
|
36352
36375
|
};
|
|
36353
36376
|
var clampInspiredesignCaptureTimeout = (timeoutMs) => {
|
|
36354
36377
|
if (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs)) return INSPIREDESIGN_CAPTURE_TIMEOUT_MS;
|
|
36355
36378
|
return Math.max(1, Math.min(timeoutMs, INSPIREDESIGN_CAPTURE_TIMEOUT_MS));
|
|
36356
36379
|
};
|
|
36357
|
-
|
|
36358
|
-
if (
|
|
36380
|
+
function sanitizeInspiredesignCaptureText(value) {
|
|
36381
|
+
if (value === void 0) return void 0;
|
|
36359
36382
|
const redacted = redactSensitive(value);
|
|
36360
36383
|
return typeof redacted === "string" ? redacted : value;
|
|
36384
|
+
}
|
|
36385
|
+
var buildCaptureAttempt = (status, detail) => {
|
|
36386
|
+
const sanitizedDetail = sanitizeInspiredesignCaptureText(detail);
|
|
36387
|
+
return sanitizedDetail ? { status, detail: sanitizedDetail } : { status };
|
|
36388
|
+
};
|
|
36389
|
+
var detailFromCaptureError = (error, fallback) => {
|
|
36390
|
+
return error instanceof Error ? error.message : fallback;
|
|
36391
|
+
};
|
|
36392
|
+
var isTransportTimeoutError = (error, detail) => {
|
|
36393
|
+
if (error instanceof Error) {
|
|
36394
|
+
const code = error.code;
|
|
36395
|
+
if (error.name === "TimeoutError" || code === "ETIMEDOUT" || code === "ERR_HTTP_REQUEST_TIMEOUT") {
|
|
36396
|
+
return true;
|
|
36397
|
+
}
|
|
36398
|
+
}
|
|
36399
|
+
return /\btimed out after \d+ms\b/i.test(detail) || /exceeded timeout budget\./i.test(detail);
|
|
36400
|
+
};
|
|
36401
|
+
var isIgnorableNetworkIdleWaitError = (error) => {
|
|
36402
|
+
if (!(error instanceof Error)) {
|
|
36403
|
+
return false;
|
|
36404
|
+
}
|
|
36405
|
+
return /timed out|timeout/i.test(error.message);
|
|
36406
|
+
};
|
|
36407
|
+
var buildSkippedAfterTransportTimeoutAttempt = (label) => {
|
|
36408
|
+
return buildCaptureAttempt("skipped", `Skipped after ${label} ${SKIPPED_AFTER_TRANSPORT_TIMEOUT_SUFFIX}`);
|
|
36409
|
+
};
|
|
36410
|
+
var hasUsableCaptureText = (value) => {
|
|
36411
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
36361
36412
|
};
|
|
36362
36413
|
var resolveInspiredesignCaptureCookiePolicy = (options) => {
|
|
36363
36414
|
if (options.cookiePolicyOverride) return options.cookiePolicyOverride;
|
|
36364
36415
|
return options.useCookies === false ? "off" : "auto";
|
|
36365
36416
|
};
|
|
36366
|
-
var
|
|
36367
|
-
|
|
36417
|
+
var withCaptureDeadline = async (promise, timeoutMs, label) => {
|
|
36418
|
+
let clearDeadline = () => {
|
|
36419
|
+
};
|
|
36420
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
36421
|
+
const handle = setTimeout(() => reject(new Error(`Deep capture ${label} exceeded timeout budget.`)), timeoutMs);
|
|
36422
|
+
clearDeadline = () => clearTimeout(handle);
|
|
36423
|
+
});
|
|
36424
|
+
try {
|
|
36425
|
+
return await Promise.race([promise, timeoutPromise]);
|
|
36426
|
+
} finally {
|
|
36427
|
+
clearDeadline();
|
|
36428
|
+
}
|
|
36429
|
+
};
|
|
36430
|
+
var verifyRequiredCaptureCookies = async (manager, sessionId, url, importState, timeoutMs) => {
|
|
36431
|
+
const cookies = await withCaptureDeadline(
|
|
36432
|
+
manager.cookieList(sessionId, [url], void 0, timeoutMs),
|
|
36433
|
+
timeoutMs,
|
|
36434
|
+
"cookie verification"
|
|
36435
|
+
);
|
|
36368
36436
|
if (cookies.count > 0) return;
|
|
36369
36437
|
if (!importState.sourceConfigured) {
|
|
36370
36438
|
throw new Error(ACTIVE_SESSION_COOKIE_REUSE_UNAVAILABLE_MESSAGE);
|
|
@@ -36372,7 +36440,7 @@ var verifyRequiredCaptureCookies = async (manager, sessionId, url, importState)
|
|
|
36372
36440
|
const sourceDetail = importState.sourceMessage ? ` ${importState.sourceMessage}` : "";
|
|
36373
36441
|
throw new Error(`Deep capture requires observable cookies from the configured provider cookie source for the requested URL.${sourceDetail}`);
|
|
36374
36442
|
};
|
|
36375
|
-
var importConfiguredCaptureCookies = async (manager, sessionId, source) => {
|
|
36443
|
+
var importConfiguredCaptureCookies = async (manager, sessionId, source, timeoutMs) => {
|
|
36376
36444
|
if (!source || typeof manager.cookieImport !== "function") {
|
|
36377
36445
|
return {
|
|
36378
36446
|
sourceConfigured: Boolean(source),
|
|
@@ -36387,80 +36455,203 @@ var importConfiguredCaptureCookies = async (manager, sessionId, source) => {
|
|
|
36387
36455
|
sourceMessage: loaded.message
|
|
36388
36456
|
};
|
|
36389
36457
|
}
|
|
36390
|
-
await
|
|
36458
|
+
await withCaptureDeadline(
|
|
36459
|
+
manager.cookieImport(sessionId, loaded.cookies, false, void 0, timeoutMs),
|
|
36460
|
+
timeoutMs,
|
|
36461
|
+
"cookie import"
|
|
36462
|
+
);
|
|
36391
36463
|
return {
|
|
36392
36464
|
sourceConfigured: true,
|
|
36393
36465
|
sourceAvailable: loaded.available,
|
|
36394
36466
|
sourceMessage: loaded.message
|
|
36395
36467
|
};
|
|
36396
36468
|
};
|
|
36397
|
-
var
|
|
36398
|
-
let handle;
|
|
36469
|
+
var captureSnapshotArtifact = async (manager, sessionId, remainingTimeoutMs) => {
|
|
36399
36470
|
try {
|
|
36400
|
-
|
|
36401
|
-
|
|
36402
|
-
|
|
36403
|
-
|
|
36404
|
-
|
|
36405
|
-
|
|
36406
|
-
|
|
36407
|
-
|
|
36471
|
+
const snapshot = await withCaptureDeadline(
|
|
36472
|
+
manager.snapshot(
|
|
36473
|
+
sessionId,
|
|
36474
|
+
"actionables",
|
|
36475
|
+
INSPIREDESIGN_CAPTURE_MAX_CHARS,
|
|
36476
|
+
void 0,
|
|
36477
|
+
void 0,
|
|
36478
|
+
remainingTimeoutMs()
|
|
36479
|
+
),
|
|
36480
|
+
remainingTimeoutMs(),
|
|
36481
|
+
"snapshot capture"
|
|
36482
|
+
);
|
|
36483
|
+
const content = sanitizeInspiredesignCaptureText(snapshot.content) ?? "";
|
|
36484
|
+
if (!hasUsableCaptureText(content)) {
|
|
36485
|
+
return {
|
|
36486
|
+
attempt: buildCaptureAttempt("failed", SNAPSHOT_CAPTURE_EMPTY_MESSAGE)
|
|
36487
|
+
};
|
|
36488
|
+
}
|
|
36489
|
+
return {
|
|
36490
|
+
attempt: buildCaptureAttempt("captured"),
|
|
36491
|
+
snapshot: {
|
|
36492
|
+
content,
|
|
36493
|
+
refCount: snapshot.refCount,
|
|
36494
|
+
warnings: snapshot.warnings ?? []
|
|
36495
|
+
}
|
|
36496
|
+
};
|
|
36497
|
+
} catch (error) {
|
|
36498
|
+
const detail = detailFromCaptureError(error, "Snapshot capture failed.");
|
|
36499
|
+
return {
|
|
36500
|
+
attempt: buildCaptureAttempt("failed", detail),
|
|
36501
|
+
...isTransportTimeoutError(error, detail) ? { transportTimedOut: true } : {}
|
|
36502
|
+
};
|
|
36408
36503
|
}
|
|
36409
36504
|
};
|
|
36410
|
-
var
|
|
36411
|
-
|
|
36412
|
-
|
|
36413
|
-
|
|
36414
|
-
|
|
36415
|
-
|
|
36416
|
-
|
|
36417
|
-
|
|
36418
|
-
|
|
36419
|
-
|
|
36420
|
-
|
|
36421
|
-
|
|
36422
|
-
|
|
36423
|
-
|
|
36424
|
-
|
|
36425
|
-
|
|
36426
|
-
|
|
36427
|
-
|
|
36428
|
-
|
|
36429
|
-
|
|
36430
|
-
|
|
36431
|
-
|
|
36432
|
-
|
|
36433
|
-
|
|
36434
|
-
|
|
36505
|
+
var captureCloneArtifact = async (manager, sessionId, remainingTimeoutMs) => {
|
|
36506
|
+
try {
|
|
36507
|
+
const clone2 = await withCaptureDeadline(
|
|
36508
|
+
manager.clonePage(sessionId, void 0, remainingTimeoutMs()),
|
|
36509
|
+
remainingTimeoutMs(),
|
|
36510
|
+
"clone capture"
|
|
36511
|
+
);
|
|
36512
|
+
const componentPreview = sanitizeInspiredesignCaptureText(clone2.component) ?? "";
|
|
36513
|
+
const cssPreview = sanitizeInspiredesignCaptureText(clone2.css) ?? "";
|
|
36514
|
+
if (!hasUsableCaptureText(componentPreview) && !hasUsableCaptureText(cssPreview)) {
|
|
36515
|
+
return {
|
|
36516
|
+
attempt: buildCaptureAttempt("failed", CLONE_CAPTURE_EMPTY_MESSAGE)
|
|
36517
|
+
};
|
|
36518
|
+
}
|
|
36519
|
+
return {
|
|
36520
|
+
attempt: buildCaptureAttempt("captured"),
|
|
36521
|
+
clone: {
|
|
36522
|
+
componentPreview,
|
|
36523
|
+
cssPreview,
|
|
36524
|
+
warnings: clone2.warnings ?? []
|
|
36525
|
+
}
|
|
36526
|
+
};
|
|
36527
|
+
} catch (error) {
|
|
36528
|
+
const detail = detailFromCaptureError(error, "Clone capture failed.");
|
|
36529
|
+
return {
|
|
36530
|
+
attempt: buildCaptureAttempt("failed", detail),
|
|
36531
|
+
...isTransportTimeoutError(error, detail) ? { transportTimedOut: true } : {}
|
|
36532
|
+
};
|
|
36533
|
+
}
|
|
36534
|
+
};
|
|
36535
|
+
var captureDomArtifact = async (manager, sessionId, remainingTimeoutMs) => {
|
|
36536
|
+
if (typeof manager.clonePageHtmlWithOptions !== "function") {
|
|
36537
|
+
return {
|
|
36538
|
+
attempt: buildCaptureAttempt("skipped", DOM_CAPTURE_HELPER_UNAVAILABLE_MESSAGE)
|
|
36539
|
+
};
|
|
36540
|
+
}
|
|
36541
|
+
try {
|
|
36542
|
+
const dom = await withCaptureDeadline(
|
|
36543
|
+
manager.clonePageHtmlWithOptions(sessionId, void 0, void 0, remainingTimeoutMs()),
|
|
36544
|
+
remainingTimeoutMs(),
|
|
36545
|
+
"DOM capture"
|
|
36546
|
+
);
|
|
36547
|
+
const outerHTML = sanitizeInspiredesignCaptureText(dom.html) ?? "";
|
|
36548
|
+
if (!hasUsableCaptureText(outerHTML)) {
|
|
36549
|
+
return {
|
|
36550
|
+
attempt: buildCaptureAttempt("failed", DOM_CAPTURE_EMPTY_MESSAGE)
|
|
36551
|
+
};
|
|
36552
|
+
}
|
|
36553
|
+
return {
|
|
36554
|
+
attempt: buildCaptureAttempt("captured"),
|
|
36435
36555
|
dom: {
|
|
36436
|
-
outerHTML
|
|
36556
|
+
outerHTML,
|
|
36437
36557
|
truncated: false
|
|
36438
36558
|
}
|
|
36439
|
-
}
|
|
36440
|
-
|
|
36441
|
-
|
|
36442
|
-
|
|
36443
|
-
|
|
36444
|
-
|
|
36559
|
+
};
|
|
36560
|
+
} catch (error) {
|
|
36561
|
+
const detail = detailFromCaptureError(error, "DOM capture failed.");
|
|
36562
|
+
return {
|
|
36563
|
+
attempt: buildCaptureAttempt("failed", detail),
|
|
36564
|
+
...isTransportTimeoutError(error, detail) ? { transportTimedOut: true } : {}
|
|
36565
|
+
};
|
|
36566
|
+
}
|
|
36567
|
+
};
|
|
36568
|
+
var buildCaptureEvidence = (snapshot, clone2, dom) => {
|
|
36569
|
+
const attempts = {
|
|
36570
|
+
snapshot: snapshot.attempt,
|
|
36571
|
+
clone: clone2.attempt,
|
|
36572
|
+
dom: dom.attempt
|
|
36573
|
+
};
|
|
36574
|
+
return {
|
|
36575
|
+
...snapshot.snapshot ? { snapshot: snapshot.snapshot } : {},
|
|
36576
|
+
...dom.dom ? { dom: dom.dom } : {},
|
|
36577
|
+
...clone2.clone ? { clone: clone2.clone } : {},
|
|
36578
|
+
attempts
|
|
36445
36579
|
};
|
|
36446
36580
|
};
|
|
36581
|
+
var buildTransportTimeoutCaptureEvidence = (snapshot, clone2, label) => {
|
|
36582
|
+
const attempts = {
|
|
36583
|
+
snapshot: snapshot.attempt,
|
|
36584
|
+
clone: clone2?.attempt ?? buildSkippedAfterTransportTimeoutAttempt(label),
|
|
36585
|
+
dom: buildSkippedAfterTransportTimeoutAttempt(label)
|
|
36586
|
+
};
|
|
36587
|
+
return {
|
|
36588
|
+
...snapshot.snapshot ? { snapshot: snapshot.snapshot } : {},
|
|
36589
|
+
...clone2?.clone ? { clone: clone2.clone } : {},
|
|
36590
|
+
attempts
|
|
36591
|
+
};
|
|
36592
|
+
};
|
|
36593
|
+
var captureInspiredesignArtifacts = async (manager, sessionId, remainingTimeoutMs) => {
|
|
36594
|
+
const snapshot = await captureSnapshotArtifact(manager, sessionId, remainingTimeoutMs);
|
|
36595
|
+
if (snapshot.transportTimedOut) {
|
|
36596
|
+
return buildTransportTimeoutCaptureEvidence(snapshot, void 0, "snapshot capture");
|
|
36597
|
+
}
|
|
36598
|
+
const clone2 = await captureCloneArtifact(manager, sessionId, remainingTimeoutMs);
|
|
36599
|
+
if (clone2.transportTimedOut) {
|
|
36600
|
+
return buildTransportTimeoutCaptureEvidence(snapshot, clone2, "clone capture");
|
|
36601
|
+
}
|
|
36602
|
+
const dom = await captureDomArtifact(manager, sessionId, remainingTimeoutMs);
|
|
36603
|
+
return buildCaptureEvidence(snapshot, clone2, dom);
|
|
36604
|
+
};
|
|
36447
36605
|
async function captureInspiredesignReferenceFromManager(manager, url, options = {}) {
|
|
36448
36606
|
const cookiePolicy = resolveInspiredesignCaptureCookiePolicy(options);
|
|
36449
36607
|
const captureTimeoutMs = clampInspiredesignCaptureTimeout(options.timeoutMs);
|
|
36450
36608
|
const remainingTimeoutMs = createRemainingCaptureTimeout(captureTimeoutMs);
|
|
36451
|
-
const
|
|
36452
|
-
|
|
36453
|
-
|
|
36454
|
-
|
|
36455
|
-
|
|
36609
|
+
const launchTimeoutMs = remainingTimeoutMs();
|
|
36610
|
+
const session = await withCaptureDeadline(
|
|
36611
|
+
manager.launch({
|
|
36612
|
+
headless: true,
|
|
36613
|
+
startUrl: "about:blank",
|
|
36614
|
+
persistProfile: false,
|
|
36615
|
+
noExtension: true
|
|
36616
|
+
}, launchTimeoutMs),
|
|
36617
|
+
launchTimeoutMs,
|
|
36618
|
+
"session launch"
|
|
36619
|
+
);
|
|
36456
36620
|
try {
|
|
36457
|
-
const importState = cookiePolicy === "off" ? { sourceConfigured: false, sourceAvailable: false } : await importConfiguredCaptureCookies(
|
|
36621
|
+
const importState = cookiePolicy === "off" ? { sourceConfigured: false, sourceAvailable: false } : await importConfiguredCaptureCookies(
|
|
36622
|
+
manager,
|
|
36623
|
+
session.sessionId,
|
|
36624
|
+
options.cookieSource,
|
|
36625
|
+
remainingTimeoutMs()
|
|
36626
|
+
);
|
|
36458
36627
|
if (cookiePolicy === "required") {
|
|
36459
|
-
await verifyRequiredCaptureCookies(
|
|
36628
|
+
await verifyRequiredCaptureCookies(
|
|
36629
|
+
manager,
|
|
36630
|
+
session.sessionId,
|
|
36631
|
+
url,
|
|
36632
|
+
importState,
|
|
36633
|
+
remainingTimeoutMs()
|
|
36634
|
+
);
|
|
36460
36635
|
}
|
|
36461
36636
|
manager.setSessionChallengeAutomationMode?.(session.sessionId, options.challengeAutomationMode);
|
|
36462
|
-
|
|
36463
|
-
await
|
|
36637
|
+
const gotoTimeoutMs = remainingTimeoutMs();
|
|
36638
|
+
await withCaptureDeadline(
|
|
36639
|
+
manager.goto(session.sessionId, url, "load", gotoTimeoutMs),
|
|
36640
|
+
gotoTimeoutMs,
|
|
36641
|
+
"navigation"
|
|
36642
|
+
);
|
|
36643
|
+
const waitTimeoutMs = remainingTimeoutMs();
|
|
36644
|
+
try {
|
|
36645
|
+
await withCaptureDeadline(
|
|
36646
|
+
manager.waitForLoad(session.sessionId, "networkidle", waitTimeoutMs),
|
|
36647
|
+
waitTimeoutMs,
|
|
36648
|
+
"network idle wait"
|
|
36649
|
+
);
|
|
36650
|
+
} catch (error) {
|
|
36651
|
+
if (!isIgnorableNetworkIdleWaitError(error)) {
|
|
36652
|
+
throw error;
|
|
36653
|
+
}
|
|
36654
|
+
}
|
|
36464
36655
|
return await captureInspiredesignArtifacts(manager, session.sessionId, remainingTimeoutMs);
|
|
36465
36656
|
} finally {
|
|
36466
36657
|
await manager.disconnect(session.sessionId, true).catch(() => void 0);
|
|
@@ -37029,7 +37220,7 @@ var waitForBinding = async (clientId, timeoutMs) => {
|
|
|
37029
37220
|
if (!getQueueEntry(clientId)) {
|
|
37030
37221
|
break;
|
|
37031
37222
|
}
|
|
37032
|
-
await new Promise((
|
|
37223
|
+
await new Promise((resolve9) => setTimeout(resolve9, 250));
|
|
37033
37224
|
}
|
|
37034
37225
|
dequeueClient(clientId);
|
|
37035
37226
|
throw new Error("RELAY_WAIT_TIMEOUT: Timed out waiting for relay binding.");
|
|
@@ -37105,119 +37296,6 @@ var getBindingRenewConfig = () => ({
|
|
|
37105
37296
|
waitMaxMs: WAIT_MAX_MS
|
|
37106
37297
|
});
|
|
37107
37298
|
|
|
37108
|
-
// src/cli/utils/http.ts
|
|
37109
|
-
var DEFAULT_HTTP_TIMEOUT_MS = 5e3;
|
|
37110
|
-
function isAbortError(error) {
|
|
37111
|
-
if (!error || typeof error !== "object") return false;
|
|
37112
|
-
return "name" in error && error.name === "AbortError";
|
|
37113
|
-
}
|
|
37114
|
-
var resolveTimeoutMs = (timeoutMs = DEFAULT_HTTP_TIMEOUT_MS) => {
|
|
37115
|
-
return Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : DEFAULT_HTTP_TIMEOUT_MS;
|
|
37116
|
-
};
|
|
37117
|
-
var createTimeoutError = (timeoutMs) => {
|
|
37118
|
-
return new Error(`Request timed out after ${timeoutMs}ms`);
|
|
37119
|
-
};
|
|
37120
|
-
var createTimedSignal = (timeoutMs, upstreamSignal) => {
|
|
37121
|
-
const controller = new AbortController();
|
|
37122
|
-
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
37123
|
-
let removeAbortListener;
|
|
37124
|
-
if (upstreamSignal) {
|
|
37125
|
-
if (upstreamSignal.aborted) {
|
|
37126
|
-
controller.abort(upstreamSignal.reason);
|
|
37127
|
-
} else {
|
|
37128
|
-
const onAbort = () => controller.abort(upstreamSignal.reason);
|
|
37129
|
-
upstreamSignal.addEventListener("abort", onAbort, { once: true });
|
|
37130
|
-
removeAbortListener = () => upstreamSignal.removeEventListener("abort", onAbort);
|
|
37131
|
-
}
|
|
37132
|
-
}
|
|
37133
|
-
return {
|
|
37134
|
-
signal: controller.signal,
|
|
37135
|
-
dispose: () => {
|
|
37136
|
-
clearTimeout(timeoutId);
|
|
37137
|
-
removeAbortListener?.();
|
|
37138
|
-
}
|
|
37139
|
-
};
|
|
37140
|
-
};
|
|
37141
|
-
var cancelResponseBody = (response) => {
|
|
37142
|
-
try {
|
|
37143
|
-
void response.body?.cancel?.();
|
|
37144
|
-
} catch {
|
|
37145
|
-
}
|
|
37146
|
-
};
|
|
37147
|
-
var readResponseBodyWithTimeout = async (response, signal, timeoutMs, reader) => {
|
|
37148
|
-
let bodyCancelled = false;
|
|
37149
|
-
const cancelBody = () => {
|
|
37150
|
-
if (bodyCancelled) {
|
|
37151
|
-
return;
|
|
37152
|
-
}
|
|
37153
|
-
bodyCancelled = true;
|
|
37154
|
-
cancelResponseBody(response);
|
|
37155
|
-
};
|
|
37156
|
-
if (signal.aborted) {
|
|
37157
|
-
cancelBody();
|
|
37158
|
-
throw createTimeoutError(timeoutMs);
|
|
37159
|
-
}
|
|
37160
|
-
let removeAbortListener;
|
|
37161
|
-
const abortPromise = new Promise((_, reject) => {
|
|
37162
|
-
const onAbort = () => {
|
|
37163
|
-
cancelBody();
|
|
37164
|
-
reject(createTimeoutError(timeoutMs));
|
|
37165
|
-
};
|
|
37166
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
37167
|
-
removeAbortListener = () => signal.removeEventListener("abort", onAbort);
|
|
37168
|
-
});
|
|
37169
|
-
try {
|
|
37170
|
-
return await Promise.race([reader(), abortPromise]);
|
|
37171
|
-
} catch (error) {
|
|
37172
|
-
if (signal.aborted || isAbortError(error)) {
|
|
37173
|
-
cancelBody();
|
|
37174
|
-
throw createTimeoutError(timeoutMs);
|
|
37175
|
-
}
|
|
37176
|
-
throw error;
|
|
37177
|
-
} finally {
|
|
37178
|
-
removeAbortListener?.();
|
|
37179
|
-
}
|
|
37180
|
-
};
|
|
37181
|
-
async function fetchWithTimeout(input, init = {}, timeoutMs = DEFAULT_HTTP_TIMEOUT_MS) {
|
|
37182
|
-
const resolvedTimeout = resolveTimeoutMs(timeoutMs);
|
|
37183
|
-
const timedSignal = createTimedSignal(resolvedTimeout, init?.signal ?? void 0);
|
|
37184
|
-
try {
|
|
37185
|
-
return await fetch(input, { ...init, signal: timedSignal.signal });
|
|
37186
|
-
} catch (error) {
|
|
37187
|
-
if (isAbortError(error) || timedSignal.signal.aborted) {
|
|
37188
|
-
throw createTimeoutError(resolvedTimeout);
|
|
37189
|
-
}
|
|
37190
|
-
throw error;
|
|
37191
|
-
} finally {
|
|
37192
|
-
timedSignal.dispose();
|
|
37193
|
-
}
|
|
37194
|
-
}
|
|
37195
|
-
async function fetchWithTimeoutContext(input, init = {}, timeoutMs = DEFAULT_HTTP_TIMEOUT_MS) {
|
|
37196
|
-
const resolvedTimeout = resolveTimeoutMs(timeoutMs);
|
|
37197
|
-
const timedSignal = createTimedSignal(resolvedTimeout, init?.signal ?? void 0);
|
|
37198
|
-
try {
|
|
37199
|
-
const response = await fetch(input, { ...init, signal: timedSignal.signal });
|
|
37200
|
-
return {
|
|
37201
|
-
response,
|
|
37202
|
-
signal: timedSignal.signal,
|
|
37203
|
-
timeoutMs: resolvedTimeout,
|
|
37204
|
-
dispose: timedSignal.dispose
|
|
37205
|
-
};
|
|
37206
|
-
} catch (error) {
|
|
37207
|
-
timedSignal.dispose();
|
|
37208
|
-
if (isAbortError(error) || timedSignal.signal.aborted) {
|
|
37209
|
-
throw createTimeoutError(resolvedTimeout);
|
|
37210
|
-
}
|
|
37211
|
-
throw error;
|
|
37212
|
-
}
|
|
37213
|
-
}
|
|
37214
|
-
async function readResponseTextWithTimeout(response, signal, timeoutMs) {
|
|
37215
|
-
return await readResponseBodyWithTimeout(response, signal, timeoutMs, () => response.text());
|
|
37216
|
-
}
|
|
37217
|
-
async function readResponseJsonWithTimeout(response, signal, timeoutMs) {
|
|
37218
|
-
return await readResponseBodyWithTimeout(response, signal, timeoutMs, () => response.json());
|
|
37219
|
-
}
|
|
37220
|
-
|
|
37221
37299
|
// src/cli/daemon-commands.ts
|
|
37222
37300
|
var createDaemonWorkflowRuntime = (core, options) => resolveBundledProviderRuntime({
|
|
37223
37301
|
existingRuntime: core.providerRuntime,
|
|
@@ -37695,6 +37773,22 @@ async function handleDaemonCommand(core, request) {
|
|
|
37695
37773
|
requireString3(params2.sessionId, "sessionId"),
|
|
37696
37774
|
optionalString6(params2.targetId)
|
|
37697
37775
|
);
|
|
37776
|
+
case "export.clonePageHtml":
|
|
37777
|
+
await authorizeSessionCommand(core, params2, request.name, bindingId);
|
|
37778
|
+
if (typeof core.manager.clonePageHtmlWithOptions !== "function") {
|
|
37779
|
+
throw new Error("clonePageHtmlWithOptions unavailable in this execution lane.");
|
|
37780
|
+
}
|
|
37781
|
+
{
|
|
37782
|
+
const maxNodes = optionalPositiveInteger2(params2.maxNodes, "maxNodes");
|
|
37783
|
+
return core.manager.clonePageHtmlWithOptions(
|
|
37784
|
+
requireString3(params2.sessionId, "sessionId"),
|
|
37785
|
+
optionalString6(params2.targetId),
|
|
37786
|
+
{
|
|
37787
|
+
...typeof maxNodes === "number" ? { maxNodes } : {},
|
|
37788
|
+
...typeof params2.inlineStyles === "boolean" ? { inlineStyles: params2.inlineStyles } : {}
|
|
37789
|
+
}
|
|
37790
|
+
);
|
|
37791
|
+
}
|
|
37698
37792
|
case "export.cloneComponent":
|
|
37699
37793
|
await authorizeSessionCommand(core, params2, request.name, bindingId);
|
|
37700
37794
|
return core.manager.cloneComponent(
|
|
@@ -37984,8 +38078,8 @@ async function handleDaemonCommand(core, request) {
|
|
|
37984
38078
|
await core.manager.goto(session.sessionId, url, "load", captureTimeoutMs);
|
|
37985
38079
|
const screenshot = await Promise.race([
|
|
37986
38080
|
core.manager.screenshot(session.sessionId),
|
|
37987
|
-
new Promise((
|
|
37988
|
-
setTimeout(() =>
|
|
38081
|
+
new Promise((resolve9) => {
|
|
38082
|
+
setTimeout(() => resolve9(null), captureTimeoutMs);
|
|
37989
38083
|
})
|
|
37990
38084
|
]);
|
|
37991
38085
|
if (!screenshot || typeof screenshot.base64 !== "string" || screenshot.base64.length === 0) return null;
|
|
@@ -38623,6 +38717,15 @@ function requireFiniteNumber(value, label) {
|
|
|
38623
38717
|
}
|
|
38624
38718
|
throw new Error(`Invalid ${label}`);
|
|
38625
38719
|
}
|
|
38720
|
+
function optionalPositiveInteger2(value, label) {
|
|
38721
|
+
if (typeof value === "undefined") {
|
|
38722
|
+
return void 0;
|
|
38723
|
+
}
|
|
38724
|
+
if (typeof value === "number" && Number.isInteger(value) && value > 0) {
|
|
38725
|
+
return value;
|
|
38726
|
+
}
|
|
38727
|
+
throw new Error(`Invalid ${label}`);
|
|
38728
|
+
}
|
|
38626
38729
|
function requirePointerPoint(value, label) {
|
|
38627
38730
|
const point = requireRecord2(value, label);
|
|
38628
38731
|
return {
|
|
@@ -38769,7 +38872,7 @@ async function waitForRelayHandshake(relay, observedPort, timeoutMs) {
|
|
|
38769
38872
|
if (observedStatus?.extensionHandshakeComplete) {
|
|
38770
38873
|
return true;
|
|
38771
38874
|
}
|
|
38772
|
-
await new Promise((
|
|
38875
|
+
await new Promise((resolve9) => setTimeout(resolve9, delay3));
|
|
38773
38876
|
delay3 = Math.min(delay3 * 2, WAIT_MAX_DELAY_MS);
|
|
38774
38877
|
}
|
|
38775
38878
|
return false;
|
|
@@ -38928,6 +39031,11 @@ async function resolveMacroExpression(options, config, manager, browserFallbackP
|
|
|
38928
39031
|
|
|
38929
39032
|
// src/cli/daemon.ts
|
|
38930
39033
|
var DEFAULT_DAEMON_PORT2 = 8788;
|
|
39034
|
+
var DAEMON_STOP_DEBUG_ENV = "OPDEVBROWSER_DEBUG_DAEMON_STOP";
|
|
39035
|
+
var DAEMON_FINGERPRINT_FILE = "daemon-fingerprint.json";
|
|
39036
|
+
var DAEMON_STOP_REASON_HEADER = "x-opendevbrowser-stop-reason";
|
|
39037
|
+
var DAEMON_STOP_CLIENT_PID_HEADER = "x-opendevbrowser-stop-client-pid";
|
|
39038
|
+
var DAEMON_STOP_FINGERPRINT_HEADER = "x-opendevbrowser-stop-fingerprint";
|
|
38931
39039
|
var RECOVERABLE_PLAYWRIGHT_TRANSPORT_ERRORS = [
|
|
38932
39040
|
"Cannot find context with specified id",
|
|
38933
39041
|
"Detached while handling command."
|
|
@@ -38964,28 +39072,78 @@ function clearDaemonMetadata() {
|
|
|
38964
39072
|
} catch {
|
|
38965
39073
|
}
|
|
38966
39074
|
}
|
|
38967
|
-
function resolveCurrentDaemonEntrypointPath() {
|
|
38968
|
-
const rawEntry = process.argv[1];
|
|
39075
|
+
function resolveCurrentDaemonEntrypointPath(options = {}) {
|
|
39076
|
+
const rawEntry = options.argv1 ?? process.argv[1];
|
|
38969
39077
|
if (typeof rawEntry === "string" && rawEntry.trim().length > 0) {
|
|
38970
39078
|
return resolve7(rawEntry);
|
|
38971
39079
|
}
|
|
38972
|
-
|
|
39080
|
+
const moduleUrl = options.moduleUrl ?? import.meta.url;
|
|
39081
|
+
const cliEntrypoint = resolve7(fileURLToPath2(new URL("./index.js", moduleUrl)));
|
|
39082
|
+
const entryExists = options.entryExists ?? existsSync6;
|
|
39083
|
+
if (entryExists(cliEntrypoint)) {
|
|
39084
|
+
return cliEntrypoint;
|
|
39085
|
+
}
|
|
39086
|
+
return resolve7(fileURLToPath2(moduleUrl));
|
|
38973
39087
|
}
|
|
38974
|
-
function
|
|
39088
|
+
function hashFileContents(entryPath) {
|
|
38975
39089
|
try {
|
|
38976
39090
|
return createHash6("sha256").update(readFileSync5(entryPath)).digest("hex");
|
|
38977
39091
|
} catch {
|
|
38978
39092
|
return "missing";
|
|
38979
39093
|
}
|
|
38980
39094
|
}
|
|
38981
|
-
function
|
|
38982
|
-
|
|
38983
|
-
|
|
38984
|
-
|
|
39095
|
+
function resolveDaemonFingerprintDistRoot(modulePath) {
|
|
39096
|
+
let currentDir = dirname8(modulePath);
|
|
39097
|
+
while (true) {
|
|
39098
|
+
if (basename2(currentDir) === "dist") {
|
|
39099
|
+
return currentDir;
|
|
39100
|
+
}
|
|
39101
|
+
const parentDir = dirname8(currentDir);
|
|
39102
|
+
if (parentDir === currentDir) {
|
|
39103
|
+
break;
|
|
39104
|
+
}
|
|
39105
|
+
currentDir = parentDir;
|
|
39106
|
+
}
|
|
39107
|
+
return null;
|
|
39108
|
+
}
|
|
39109
|
+
function readDaemonFingerprintArtifact(modulePath) {
|
|
39110
|
+
const distRoot = resolveDaemonFingerprintDistRoot(modulePath);
|
|
39111
|
+
if (distRoot === null) {
|
|
39112
|
+
return null;
|
|
39113
|
+
}
|
|
39114
|
+
try {
|
|
39115
|
+
const content = readFileSync5(join16(distRoot, DAEMON_FINGERPRINT_FILE), "utf-8");
|
|
39116
|
+
const payload = JSON.parse(content);
|
|
39117
|
+
if (typeof payload.fingerprint === "string" && payload.fingerprint.trim().length > 0) {
|
|
39118
|
+
return payload.fingerprint.trim();
|
|
39119
|
+
}
|
|
39120
|
+
} catch {
|
|
39121
|
+
}
|
|
39122
|
+
return null;
|
|
39123
|
+
}
|
|
39124
|
+
function getCurrentDaemonFingerprint(options = {}) {
|
|
39125
|
+
const modulePath = resolve7(fileURLToPath2(options.moduleUrl ?? import.meta.url));
|
|
39126
|
+
const sharedFingerprint = readDaemonFingerprintArtifact(modulePath);
|
|
39127
|
+
const fingerprintParts = [
|
|
39128
|
+
DAEMON_FINGERPRINT_VERSION,
|
|
39129
|
+
sharedFingerprint ?? hashFileContents(modulePath)
|
|
39130
|
+
];
|
|
39131
|
+
return createHash6("sha256").update(fingerprintParts.join("\n")).digest("hex");
|
|
38985
39132
|
}
|
|
38986
39133
|
function isCurrentDaemonFingerprint(fingerprint) {
|
|
38987
39134
|
return typeof fingerprint === "string" && fingerprint === getCurrentDaemonFingerprint();
|
|
38988
39135
|
}
|
|
39136
|
+
function createDaemonStopHeaders(token, reason) {
|
|
39137
|
+
const headers = {
|
|
39138
|
+
Authorization: `Bearer ${token}`,
|
|
39139
|
+
[DAEMON_STOP_FINGERPRINT_HEADER]: getCurrentDaemonFingerprint(),
|
|
39140
|
+
[DAEMON_STOP_REASON_HEADER]: reason
|
|
39141
|
+
};
|
|
39142
|
+
if (process.env[DAEMON_STOP_DEBUG_ENV] === "1") {
|
|
39143
|
+
headers[DAEMON_STOP_CLIENT_PID_HEADER] = String(process.pid);
|
|
39144
|
+
}
|
|
39145
|
+
return headers;
|
|
39146
|
+
}
|
|
38989
39147
|
function resolveDaemonFingerprint(...candidates) {
|
|
38990
39148
|
for (const candidate of candidates) {
|
|
38991
39149
|
if (typeof candidate === "string" && candidate.trim().length > 0) {
|
|
@@ -39027,6 +39185,20 @@ function sendJson(response, status, payload) {
|
|
|
39027
39185
|
});
|
|
39028
39186
|
response.end(JSON.stringify(payload));
|
|
39029
39187
|
}
|
|
39188
|
+
function logDaemonStopDebug(message, details) {
|
|
39189
|
+
if (process.env[DAEMON_STOP_DEBUG_ENV] !== "1") {
|
|
39190
|
+
return;
|
|
39191
|
+
}
|
|
39192
|
+
const suffix = details ? ` ${JSON.stringify(details)}` : "";
|
|
39193
|
+
console.error(`[daemon-stop-debug] ${message}${suffix}`);
|
|
39194
|
+
}
|
|
39195
|
+
function readSingleHeader(request, name) {
|
|
39196
|
+
const value = request.headers[name];
|
|
39197
|
+
if (typeof value === "string") {
|
|
39198
|
+
return value;
|
|
39199
|
+
}
|
|
39200
|
+
return null;
|
|
39201
|
+
}
|
|
39030
39202
|
var isDaemonCommandRequest = (value) => {
|
|
39031
39203
|
if (typeof value.name !== "string") {
|
|
39032
39204
|
return false;
|
|
@@ -39078,8 +39250,20 @@ async function startDaemon(options = {}) {
|
|
|
39078
39250
|
return;
|
|
39079
39251
|
}
|
|
39080
39252
|
if (request.method === "POST" && url.pathname === "/stop") {
|
|
39253
|
+
const stopFingerprint = readSingleHeader(request, DAEMON_STOP_FINGERPRINT_HEADER);
|
|
39254
|
+
logDaemonStopDebug("http.stop", {
|
|
39255
|
+
remoteAddress: request.socket.remoteAddress ?? null,
|
|
39256
|
+
remotePort: request.socket.remotePort ?? null,
|
|
39257
|
+
reason: readSingleHeader(request, DAEMON_STOP_REASON_HEADER),
|
|
39258
|
+
clientPid: readSingleHeader(request, DAEMON_STOP_CLIENT_PID_HEADER),
|
|
39259
|
+
fingerprintMatches: stopFingerprint === fingerprint
|
|
39260
|
+
});
|
|
39261
|
+
if (stopFingerprint !== fingerprint) {
|
|
39262
|
+
sendJson(response, 409, { ok: false, error: "Stale daemon stop request." });
|
|
39263
|
+
return;
|
|
39264
|
+
}
|
|
39081
39265
|
sendJson(response, 200, { ok: true });
|
|
39082
|
-
await stop();
|
|
39266
|
+
await stop("http.stop");
|
|
39083
39267
|
return;
|
|
39084
39268
|
}
|
|
39085
39269
|
if (request.method === "POST" && url.pathname === "/command") {
|
|
@@ -39098,9 +39282,9 @@ async function startDaemon(options = {}) {
|
|
|
39098
39282
|
}
|
|
39099
39283
|
sendJson(response, 404, { error: "Not found" });
|
|
39100
39284
|
});
|
|
39101
|
-
await new Promise((
|
|
39285
|
+
await new Promise((resolve9, reject) => {
|
|
39102
39286
|
server.once("error", reject);
|
|
39103
|
-
server.listen(port, "127.0.0.1", () =>
|
|
39287
|
+
server.listen(port, "127.0.0.1", () => resolve9());
|
|
39104
39288
|
});
|
|
39105
39289
|
const state = {
|
|
39106
39290
|
port,
|
|
@@ -39133,7 +39317,7 @@ async function startDaemon(options = {}) {
|
|
|
39133
39317
|
return;
|
|
39134
39318
|
}
|
|
39135
39319
|
console.error(error);
|
|
39136
|
-
void stop().finally(() => {
|
|
39320
|
+
void stop("uncaughtException").finally(() => {
|
|
39137
39321
|
process.exitCode = 1;
|
|
39138
39322
|
});
|
|
39139
39323
|
};
|
|
@@ -39142,15 +39326,16 @@ async function startDaemon(options = {}) {
|
|
|
39142
39326
|
return;
|
|
39143
39327
|
}
|
|
39144
39328
|
console.error(reason);
|
|
39145
|
-
void stop().finally(() => {
|
|
39329
|
+
void stop("unhandledRejection").finally(() => {
|
|
39146
39330
|
process.exitCode = 1;
|
|
39147
39331
|
});
|
|
39148
39332
|
};
|
|
39149
|
-
const stop = async () => {
|
|
39333
|
+
const stop = async (reason = "unknown") => {
|
|
39150
39334
|
if (stopping) {
|
|
39151
39335
|
return;
|
|
39152
39336
|
}
|
|
39153
39337
|
stopping = true;
|
|
39338
|
+
logDaemonStopDebug("stop.begin", { reason });
|
|
39154
39339
|
clearDaemonMetadata();
|
|
39155
39340
|
clearBinding();
|
|
39156
39341
|
process.off("SIGINT", sigintHandler);
|
|
@@ -39158,16 +39343,17 @@ async function startDaemon(options = {}) {
|
|
|
39158
39343
|
process.off("uncaughtException", uncaughtExceptionHandler);
|
|
39159
39344
|
process.off("unhandledRejection", unhandledRejectionHandler);
|
|
39160
39345
|
core.cleanup();
|
|
39161
|
-
await new Promise((
|
|
39162
|
-
server.close(() =>
|
|
39346
|
+
await new Promise((resolve9) => {
|
|
39347
|
+
server.close(() => resolve9());
|
|
39163
39348
|
});
|
|
39349
|
+
logDaemonStopDebug("stop.complete", { reason });
|
|
39164
39350
|
};
|
|
39165
39351
|
const sigintHandler = () => {
|
|
39166
|
-
stop().catch(() => {
|
|
39352
|
+
void stop("SIGINT").catch(() => {
|
|
39167
39353
|
});
|
|
39168
39354
|
};
|
|
39169
39355
|
const sigtermHandler = () => {
|
|
39170
|
-
stop().catch(() => {
|
|
39356
|
+
void stop("SIGTERM").catch(() => {
|
|
39171
39357
|
});
|
|
39172
39358
|
};
|
|
39173
39359
|
process.on("SIGINT", sigintHandler);
|
|
@@ -39177,7 +39363,7 @@ async function startDaemon(options = {}) {
|
|
|
39177
39363
|
return { state, stop };
|
|
39178
39364
|
}
|
|
39179
39365
|
function readJson2(request) {
|
|
39180
|
-
return new Promise((
|
|
39366
|
+
return new Promise((resolve9, reject) => {
|
|
39181
39367
|
let data = "";
|
|
39182
39368
|
request.setEncoding("utf8");
|
|
39183
39369
|
request.on("data", (chunk) => {
|
|
@@ -39190,7 +39376,7 @@ function readJson2(request) {
|
|
|
39190
39376
|
reject(new Error("Invalid JSON body"));
|
|
39191
39377
|
return;
|
|
39192
39378
|
}
|
|
39193
|
-
|
|
39379
|
+
resolve9(parsed);
|
|
39194
39380
|
} catch (error) {
|
|
39195
39381
|
reject(error);
|
|
39196
39382
|
}
|
|
@@ -39241,12 +39427,20 @@ function resolveExitCode(result) {
|
|
|
39241
39427
|
return result.success ? EXIT_SUCCESS : EXIT_EXECUTION;
|
|
39242
39428
|
}
|
|
39243
39429
|
|
|
39430
|
+
// src/cli/daemon-status-policy.ts
|
|
39431
|
+
var DEFAULT_DAEMON_STATUS_FETCH_OPTIONS = {
|
|
39432
|
+
timeoutMs: 5e3,
|
|
39433
|
+
retryAttempts: 5,
|
|
39434
|
+
retryDelayMs: 250
|
|
39435
|
+
};
|
|
39436
|
+
|
|
39244
39437
|
// src/cli/daemon-status.ts
|
|
39438
|
+
var DEFAULT_DAEMON_STATUS_TIMEOUT_MS = DEFAULT_DAEMON_STATUS_FETCH_OPTIONS.timeoutMs;
|
|
39245
39439
|
var sleep2 = async (delayMs) => {
|
|
39246
39440
|
if (!(Number.isFinite(delayMs) && delayMs > 0)) {
|
|
39247
39441
|
return;
|
|
39248
39442
|
}
|
|
39249
|
-
await new Promise((
|
|
39443
|
+
await new Promise((resolve9) => setTimeout(resolve9, delayMs));
|
|
39250
39444
|
};
|
|
39251
39445
|
var resolveRetryAttempts = (retryAttempts) => {
|
|
39252
39446
|
return typeof retryAttempts === "number" && Number.isFinite(retryAttempts) && retryAttempts > 1 ? Math.floor(retryAttempts) : 1;
|
|
@@ -39254,17 +39448,66 @@ var resolveRetryAttempts = (retryAttempts) => {
|
|
|
39254
39448
|
var resolveRetryDelayMs = (retryDelayMs) => {
|
|
39255
39449
|
return typeof retryDelayMs === "number" && Number.isFinite(retryDelayMs) && retryDelayMs > 0 ? retryDelayMs : 0;
|
|
39256
39450
|
};
|
|
39451
|
+
var resolveStatusTimeoutMs = (timeoutMs) => {
|
|
39452
|
+
return typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : DEFAULT_DAEMON_STATUS_TIMEOUT_MS;
|
|
39453
|
+
};
|
|
39454
|
+
var withFingerprintCurrent = (status) => ({
|
|
39455
|
+
...status,
|
|
39456
|
+
fingerprintCurrent: isCurrentDaemonFingerprint(status.fingerprint)
|
|
39457
|
+
});
|
|
39458
|
+
var readRemainingBudgetMs = (deadlineMs) => {
|
|
39459
|
+
return Math.max(0, deadlineMs - Date.now());
|
|
39460
|
+
};
|
|
39461
|
+
var readSeedTimeoutMs = (remainingBudgetMs, remainingSeedCount) => {
|
|
39462
|
+
if (remainingSeedCount <= 1) {
|
|
39463
|
+
return remainingBudgetMs;
|
|
39464
|
+
}
|
|
39465
|
+
return Math.max(1, Math.floor(remainingBudgetMs / remainingSeedCount));
|
|
39466
|
+
};
|
|
39467
|
+
var resolveDaemonStatusSeeds = (metadata, config) => {
|
|
39468
|
+
const seeds = [];
|
|
39469
|
+
const seen = /* @__PURE__ */ new Set();
|
|
39470
|
+
const addSeed = (seed) => {
|
|
39471
|
+
if (!seed) {
|
|
39472
|
+
return;
|
|
39473
|
+
}
|
|
39474
|
+
const key = `${seed.port}:${seed.token}`;
|
|
39475
|
+
if (seen.has(key)) {
|
|
39476
|
+
return;
|
|
39477
|
+
}
|
|
39478
|
+
seen.add(key);
|
|
39479
|
+
seeds.push(seed);
|
|
39480
|
+
};
|
|
39481
|
+
addSeed(
|
|
39482
|
+
config.daemonPort > 0 && config.daemonToken ? {
|
|
39483
|
+
port: config.daemonPort,
|
|
39484
|
+
token: config.daemonToken,
|
|
39485
|
+
relayPort: config.relayPort
|
|
39486
|
+
} : null
|
|
39487
|
+
);
|
|
39488
|
+
addSeed(metadata);
|
|
39489
|
+
return seeds;
|
|
39490
|
+
};
|
|
39257
39491
|
async function fetchDaemonStatus(port, token, options = {}) {
|
|
39258
39492
|
const attempts = resolveRetryAttempts(options.retryAttempts);
|
|
39259
39493
|
const retryDelayMs = resolveRetryDelayMs(options.retryDelayMs);
|
|
39260
39494
|
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
39261
39495
|
try {
|
|
39262
|
-
const
|
|
39496
|
+
const timedResponse = await fetchWithTimeoutContext(`http://127.0.0.1:${port}/status`, {
|
|
39263
39497
|
method: "GET",
|
|
39264
39498
|
headers: { Authorization: `Bearer ${token}` }
|
|
39265
39499
|
}, options.timeoutMs);
|
|
39266
|
-
|
|
39267
|
-
|
|
39500
|
+
try {
|
|
39501
|
+
if (timedResponse.response.ok) {
|
|
39502
|
+
const status = await readResponseJsonWithTimeout(
|
|
39503
|
+
timedResponse.response,
|
|
39504
|
+
timedResponse.signal,
|
|
39505
|
+
timedResponse.timeoutMs
|
|
39506
|
+
);
|
|
39507
|
+
return withFingerprintCurrent(status);
|
|
39508
|
+
}
|
|
39509
|
+
} finally {
|
|
39510
|
+
timedResponse.dispose();
|
|
39268
39511
|
}
|
|
39269
39512
|
} catch {
|
|
39270
39513
|
}
|
|
@@ -39278,32 +39521,34 @@ async function fetchDaemonStatusFromMetadata(config, options = {}) {
|
|
|
39278
39521
|
const resolvedConfig = config ?? loadGlobalConfig();
|
|
39279
39522
|
const attempts = resolveRetryAttempts(options.retryAttempts);
|
|
39280
39523
|
const retryDelayMs = resolveRetryDelayMs(options.retryDelayMs);
|
|
39524
|
+
const deadlineMs = Date.now() + resolveStatusTimeoutMs(options.timeoutMs);
|
|
39281
39525
|
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
39282
39526
|
const metadata = readDaemonMetadata();
|
|
39283
|
-
|
|
39284
|
-
|
|
39285
|
-
|
|
39286
|
-
|
|
39287
|
-
|
|
39527
|
+
const seeds = resolveDaemonStatusSeeds(metadata, resolvedConfig);
|
|
39528
|
+
for (let seedIndex = 0; seedIndex < seeds.length; seedIndex += 1) {
|
|
39529
|
+
const seed = seeds[seedIndex];
|
|
39530
|
+
if (!seed) {
|
|
39531
|
+
continue;
|
|
39288
39532
|
}
|
|
39289
|
-
|
|
39290
|
-
|
|
39291
|
-
|
|
39292
|
-
|
|
39533
|
+
const remainingBudgetMs = readRemainingBudgetMs(deadlineMs);
|
|
39534
|
+
if (remainingBudgetMs <= 0) {
|
|
39535
|
+
return null;
|
|
39536
|
+
}
|
|
39537
|
+
const timeoutMs = readSeedTimeoutMs(remainingBudgetMs, seeds.length - seedIndex);
|
|
39538
|
+
const status = await fetchDaemonStatus(seed.port, seed.token, {
|
|
39539
|
+
timeoutMs
|
|
39293
39540
|
});
|
|
39294
39541
|
if (status?.ok) {
|
|
39295
|
-
persistDaemonStatusMetadata(
|
|
39296
|
-
port: resolvedConfig.daemonPort,
|
|
39297
|
-
token: resolvedConfig.daemonToken,
|
|
39298
|
-
pid: status.pid,
|
|
39299
|
-
relayPort: status.relay.port ?? resolvedConfig.relayPort,
|
|
39300
|
-
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
39301
|
-
}, status, resolvedConfig);
|
|
39542
|
+
persistDaemonStatusMetadata(seed, status, resolvedConfig);
|
|
39302
39543
|
return status;
|
|
39303
39544
|
}
|
|
39304
39545
|
}
|
|
39305
39546
|
if (attempt < attempts) {
|
|
39306
|
-
|
|
39547
|
+
const remainingBudgetMs = readRemainingBudgetMs(deadlineMs);
|
|
39548
|
+
if (remainingBudgetMs <= 0) {
|
|
39549
|
+
break;
|
|
39550
|
+
}
|
|
39551
|
+
await sleep2(Math.min(retryDelayMs, remainingBudgetMs));
|
|
39307
39552
|
}
|
|
39308
39553
|
}
|
|
39309
39554
|
return null;
|
|
@@ -39326,8 +39571,9 @@ function persistDaemonStatusMetadata(base, status, config) {
|
|
|
39326
39571
|
// src/cli/daemon-client.ts
|
|
39327
39572
|
import { spawn as spawn2 } from "child_process";
|
|
39328
39573
|
import { existsSync as existsSync7, readFileSync as readFileSync6 } from "fs";
|
|
39329
|
-
import { join as join17 } from "path";
|
|
39574
|
+
import { join as join17, resolve as resolve8 } from "path";
|
|
39330
39575
|
import { randomUUID as randomUUID23 } from "crypto";
|
|
39576
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
39331
39577
|
var CLIENT_ID_FILE = "client.json";
|
|
39332
39578
|
var DEFAULT_RENEW_AFTER_MS = 2e4;
|
|
39333
39579
|
var MIN_RENEW_AFTER_MS = 5e3;
|
|
@@ -39338,10 +39584,23 @@ var DAEMON_STATUS_RETRY_OPTIONS = {
|
|
|
39338
39584
|
retryAttempts: 5,
|
|
39339
39585
|
retryDelayMs: 250
|
|
39340
39586
|
};
|
|
39587
|
+
var DAEMON_CONFIG_PREFER_OPTIONS = {
|
|
39588
|
+
timeoutMs: 500,
|
|
39589
|
+
retryAttempts: 3,
|
|
39590
|
+
retryDelayMs: 250
|
|
39591
|
+
};
|
|
39341
39592
|
var DAEMON_RESTART_STATUS_TIMEOUT_MS = 5e3;
|
|
39593
|
+
var DAEMON_RECOVERY_READY_TIMEOUT_MS = 5e3;
|
|
39342
39594
|
var DAEMON_RESTART_READY_TIMEOUT_MS = 15e3;
|
|
39343
39595
|
var DAEMON_RESTART_POLL_DELAY_MS = 250;
|
|
39344
39596
|
var cachedClientState;
|
|
39597
|
+
var logDaemonStopDebug2 = (message, details) => {
|
|
39598
|
+
if (process.env[DAEMON_STOP_DEBUG_ENV] !== "1") {
|
|
39599
|
+
return;
|
|
39600
|
+
}
|
|
39601
|
+
const suffix = details ? ` ${JSON.stringify(details)}` : "";
|
|
39602
|
+
console.error(`[daemon-stop-debug] ${message}${suffix}`);
|
|
39603
|
+
};
|
|
39345
39604
|
var getClientStateFilePath = () => {
|
|
39346
39605
|
const cacheRoot = getCacheRoot();
|
|
39347
39606
|
return join17(cacheRoot, CLIENT_ID_FILE);
|
|
@@ -39429,7 +39688,7 @@ var isLeaseInvalidError = (error) => {
|
|
|
39429
39688
|
const message = error instanceof Error ? error.message : String(error ?? "");
|
|
39430
39689
|
return message.startsWith("RELAY_LEASE_INVALID");
|
|
39431
39690
|
};
|
|
39432
|
-
var
|
|
39691
|
+
var isTransportTimeoutError2 = (error) => {
|
|
39433
39692
|
const message = error instanceof Error ? error.message : String(error ?? "");
|
|
39434
39693
|
return message.startsWith("Request timed out after ");
|
|
39435
39694
|
};
|
|
@@ -39465,7 +39724,7 @@ var DaemonClient = class {
|
|
|
39465
39724
|
this.maybeTrackLease(name, params2, result);
|
|
39466
39725
|
return result;
|
|
39467
39726
|
}
|
|
39468
|
-
if (
|
|
39727
|
+
if (isBindingRequiredError(error)) {
|
|
39469
39728
|
if (this.binding) {
|
|
39470
39729
|
this.clearBinding();
|
|
39471
39730
|
}
|
|
@@ -39588,22 +39847,31 @@ var DaemonClient = class {
|
|
|
39588
39847
|
}
|
|
39589
39848
|
}
|
|
39590
39849
|
async callRaw(name, params2, timeoutMs) {
|
|
39591
|
-
const
|
|
39850
|
+
const budget = createTimeoutBudget(timeoutMs);
|
|
39851
|
+
const connection = await resolveDaemonConnection(budget, {
|
|
39852
|
+
preferConfiguredRecovery: requiresConfiguredRecovery(name)
|
|
39853
|
+
});
|
|
39592
39854
|
let timedResponse;
|
|
39593
39855
|
try {
|
|
39594
|
-
timedResponse = await openDaemonCommand(
|
|
39856
|
+
timedResponse = await openDaemonCommand(
|
|
39857
|
+
connection.port,
|
|
39858
|
+
connection.token,
|
|
39859
|
+
name,
|
|
39860
|
+
params2,
|
|
39861
|
+
readRemainingBudgetMs2(budget)
|
|
39862
|
+
);
|
|
39595
39863
|
} catch (error) {
|
|
39596
|
-
if (
|
|
39864
|
+
if (isTransportTimeoutError2(error)) {
|
|
39597
39865
|
throw error;
|
|
39598
39866
|
}
|
|
39599
|
-
timedResponse = await retryWithRefreshedConnection(name, params2,
|
|
39867
|
+
timedResponse = await retryWithRefreshedConnection(name, params2, budget);
|
|
39600
39868
|
}
|
|
39601
39869
|
try {
|
|
39602
39870
|
if (!timedResponse.response.ok) {
|
|
39603
39871
|
const message = await readDaemonErrorMessage(timedResponse);
|
|
39604
39872
|
if (message.includes("Unauthorized") || timedResponse.response.status === 401) {
|
|
39605
39873
|
timedResponse.dispose();
|
|
39606
|
-
timedResponse = await retryWithRefreshedConnection(name, params2,
|
|
39874
|
+
timedResponse = await retryWithRefreshedConnection(name, params2, budget);
|
|
39607
39875
|
if (!timedResponse.response.ok) {
|
|
39608
39876
|
throw new CliError(await readDaemonErrorMessage(timedResponse), EXIT_EXECUTION);
|
|
39609
39877
|
}
|
|
@@ -39628,6 +39896,37 @@ var DaemonClient = class {
|
|
|
39628
39896
|
var asPositiveNumber = (value) => {
|
|
39629
39897
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
39630
39898
|
};
|
|
39899
|
+
var createTransportTimeoutError = (timeoutMs) => {
|
|
39900
|
+
return new Error(`Request timed out after ${timeoutMs}ms`);
|
|
39901
|
+
};
|
|
39902
|
+
var createTimeoutBudget = (timeoutMs) => {
|
|
39903
|
+
const resolved = asPositiveNumber(timeoutMs);
|
|
39904
|
+
return resolved === void 0 ? null : { timeoutMs: resolved, deadlineMs: Date.now() + resolved };
|
|
39905
|
+
};
|
|
39906
|
+
var readRemainingBudgetMs2 = (budget) => {
|
|
39907
|
+
if (!budget) {
|
|
39908
|
+
return void 0;
|
|
39909
|
+
}
|
|
39910
|
+
const remainingMs = budget.deadlineMs - Date.now();
|
|
39911
|
+
if (remainingMs <= 0) {
|
|
39912
|
+
throw createTransportTimeoutError(budget.timeoutMs);
|
|
39913
|
+
}
|
|
39914
|
+
return remainingMs;
|
|
39915
|
+
};
|
|
39916
|
+
var capTimeoutToBudget = (timeoutMs, budget) => {
|
|
39917
|
+
const remainingMs = readRemainingBudgetMs2(budget);
|
|
39918
|
+
return remainingMs === void 0 ? timeoutMs : Math.max(1, Math.min(timeoutMs, remainingMs));
|
|
39919
|
+
};
|
|
39920
|
+
var resolveReadyDeadlineMs = (readyTimeoutMs, budget) => {
|
|
39921
|
+
const localDeadlineMs = Date.now() + readyTimeoutMs;
|
|
39922
|
+
return budget ? Math.min(localDeadlineMs, budget.deadlineMs) : localDeadlineMs;
|
|
39923
|
+
};
|
|
39924
|
+
var hasBudgetTimedOut = (budget, deadlineMs) => {
|
|
39925
|
+
if (!budget) {
|
|
39926
|
+
return false;
|
|
39927
|
+
}
|
|
39928
|
+
return deadlineMs >= budget.deadlineMs && Date.now() >= budget.deadlineMs;
|
|
39929
|
+
};
|
|
39631
39930
|
var deriveTransportTimeoutMs = (params2, explicitTimeoutMs) => {
|
|
39632
39931
|
const explicit = asPositiveNumber(explicitTimeoutMs);
|
|
39633
39932
|
if (explicit !== void 0) {
|
|
@@ -39649,11 +39948,98 @@ var cliClient = new DaemonClient({ autoRenew: false });
|
|
|
39649
39948
|
async function callDaemon(command, params2, options) {
|
|
39650
39949
|
return cliClient.call(command, params2 ?? {}, options);
|
|
39651
39950
|
}
|
|
39951
|
+
var TYPESCRIPT_ENTRY_RE = /\.[cm]?ts$/i;
|
|
39952
|
+
var RESTART_LOADER_ARG_FLAGS = /* @__PURE__ */ new Set(["--experimental-loader", "--import", "--loader", "--require", "-r"]);
|
|
39953
|
+
var RESTART_TYPESCRIPT_CONTEXT_ARG_FLAGS = /* @__PURE__ */ new Set(["--experimental-strip-types", "--experimental-transform-types"]);
|
|
39954
|
+
var RESTART_DEBUG_ARG_FLAGS = /* @__PURE__ */ new Set(["--inspect", "--inspect-brk", "--inspect-port", "--debug", "--debug-brk"]);
|
|
39955
|
+
var isInlineRestartArg = (arg, flags) => {
|
|
39956
|
+
for (const flag of flags) {
|
|
39957
|
+
if (arg.startsWith(`${flag}=`)) {
|
|
39958
|
+
return true;
|
|
39959
|
+
}
|
|
39960
|
+
}
|
|
39961
|
+
return false;
|
|
39962
|
+
};
|
|
39963
|
+
var isRestartLoaderArg = (arg) => {
|
|
39964
|
+
return RESTART_LOADER_ARG_FLAGS.has(arg) || isInlineRestartArg(arg, RESTART_LOADER_ARG_FLAGS);
|
|
39965
|
+
};
|
|
39966
|
+
var isRestartTypeScriptContextArg = (arg) => {
|
|
39967
|
+
return RESTART_TYPESCRIPT_CONTEXT_ARG_FLAGS.has(arg) || isInlineRestartArg(arg, RESTART_TYPESCRIPT_CONTEXT_ARG_FLAGS);
|
|
39968
|
+
};
|
|
39969
|
+
var isRestartDebugArg = (arg) => {
|
|
39970
|
+
return RESTART_DEBUG_ARG_FLAGS.has(arg) || isInlineRestartArg(arg, RESTART_DEBUG_ARG_FLAGS);
|
|
39971
|
+
};
|
|
39972
|
+
var resolveRestartSplitArgValue = (arg, value) => {
|
|
39973
|
+
if (arg.includes("=")) return null;
|
|
39974
|
+
if (typeof value !== "string") return null;
|
|
39975
|
+
return value.startsWith("-") ? null : value;
|
|
39976
|
+
};
|
|
39977
|
+
var resolveRestartExecArgv = (entryPath, execArgv) => {
|
|
39978
|
+
const preserved = [];
|
|
39979
|
+
let hasLoaderContext = false;
|
|
39980
|
+
for (let index = 0; index < execArgv.length; index += 1) {
|
|
39981
|
+
const arg = execArgv[index];
|
|
39982
|
+
if (!arg) {
|
|
39983
|
+
continue;
|
|
39984
|
+
}
|
|
39985
|
+
if (isRestartDebugArg(arg)) {
|
|
39986
|
+
const next = resolveRestartSplitArgValue(arg, execArgv[index + 1]);
|
|
39987
|
+
if (RESTART_DEBUG_ARG_FLAGS.has(arg) && next) {
|
|
39988
|
+
index += 1;
|
|
39989
|
+
}
|
|
39990
|
+
continue;
|
|
39991
|
+
}
|
|
39992
|
+
preserved.push(arg);
|
|
39993
|
+
if (isRestartLoaderArg(arg) || isRestartTypeScriptContextArg(arg)) {
|
|
39994
|
+
hasLoaderContext = true;
|
|
39995
|
+
}
|
|
39996
|
+
const value = resolveRestartSplitArgValue(arg, execArgv[index + 1]);
|
|
39997
|
+
if (!value) continue;
|
|
39998
|
+
preserved.push(value);
|
|
39999
|
+
index += 1;
|
|
40000
|
+
}
|
|
40001
|
+
return TYPESCRIPT_ENTRY_RE.test(entryPath) && !hasLoaderContext ? [] : preserved;
|
|
40002
|
+
};
|
|
40003
|
+
var fetchCurrentDaemonStatus = async (connection, options, budget = null) => {
|
|
40004
|
+
const attempts = typeof options.retryAttempts === "number" && Number.isFinite(options.retryAttempts) && options.retryAttempts > 1 ? Math.floor(options.retryAttempts) : 1;
|
|
40005
|
+
const retryDelayMs = typeof options.retryDelayMs === "number" && Number.isFinite(options.retryDelayMs) && options.retryDelayMs > 0 ? options.retryDelayMs : 0;
|
|
40006
|
+
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
40007
|
+
const status = await fetchDaemonStatus(connection.port, connection.token, {
|
|
40008
|
+
timeoutMs: capTimeoutToBudget(options.timeoutMs ?? DAEMON_RESTART_STATUS_TIMEOUT_MS, budget)
|
|
40009
|
+
});
|
|
40010
|
+
if (status?.ok && isCurrentDaemonFingerprint(status.fingerprint)) {
|
|
40011
|
+
return status;
|
|
40012
|
+
}
|
|
40013
|
+
if (attempt < attempts) {
|
|
40014
|
+
await sleep3(Math.min(retryDelayMs, readRemainingBudgetMs2(budget) ?? retryDelayMs));
|
|
40015
|
+
}
|
|
40016
|
+
}
|
|
40017
|
+
return null;
|
|
40018
|
+
};
|
|
40019
|
+
var fetchAnyDaemonStatus = async (connection, options, budget = null) => {
|
|
40020
|
+
const attempts = typeof options.retryAttempts === "number" && Number.isFinite(options.retryAttempts) && options.retryAttempts > 1 ? Math.floor(options.retryAttempts) : 1;
|
|
40021
|
+
const retryDelayMs = typeof options.retryDelayMs === "number" && Number.isFinite(options.retryDelayMs) && options.retryDelayMs > 0 ? options.retryDelayMs : 0;
|
|
40022
|
+
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
40023
|
+
const status = await fetchDaemonStatus(connection.port, connection.token, {
|
|
40024
|
+
timeoutMs: capTimeoutToBudget(options.timeoutMs ?? DAEMON_RESTART_STATUS_TIMEOUT_MS, budget)
|
|
40025
|
+
});
|
|
40026
|
+
if (status?.ok) {
|
|
40027
|
+
return status;
|
|
40028
|
+
}
|
|
40029
|
+
if (attempt < attempts) {
|
|
40030
|
+
await sleep3(Math.min(retryDelayMs, readRemainingBudgetMs2(budget) ?? retryDelayMs));
|
|
40031
|
+
}
|
|
40032
|
+
}
|
|
40033
|
+
return null;
|
|
40034
|
+
};
|
|
39652
40035
|
var sleep3 = async (delayMs) => {
|
|
39653
40036
|
if (!(Number.isFinite(delayMs) && delayMs > 0)) {
|
|
39654
40037
|
return;
|
|
39655
40038
|
}
|
|
39656
|
-
await new Promise((
|
|
40039
|
+
await new Promise((resolve9) => setTimeout(resolve9, delayMs));
|
|
40040
|
+
};
|
|
40041
|
+
var requiresConfiguredRecovery = (name) => {
|
|
40042
|
+
return name === "canvas.execute";
|
|
39657
40043
|
};
|
|
39658
40044
|
var getConfiguredDaemonConnection = () => {
|
|
39659
40045
|
const config = loadGlobalConfig();
|
|
@@ -39674,18 +40060,91 @@ var persistResolvedDaemonStatus = (connection, status) => {
|
|
|
39674
40060
|
fingerprint: status.fingerprint
|
|
39675
40061
|
}, status, config);
|
|
39676
40062
|
};
|
|
39677
|
-
var
|
|
40063
|
+
var persistCurrentConfiguredConnection = async (configuredConnection, status, staleMetadata) => {
|
|
40064
|
+
if (staleMetadata && !sameDaemonConnection(staleMetadata.connection, configuredConnection)) {
|
|
40065
|
+
void stopDaemonConnection(staleMetadata.connection, null, "persistCurrentConfiguredConnection.staleMetadata").catch(() => void 0);
|
|
40066
|
+
}
|
|
40067
|
+
persistResolvedDaemonStatus(configuredConnection, status);
|
|
40068
|
+
return configuredConnection;
|
|
40069
|
+
};
|
|
40070
|
+
var resolveConfiguredPreferenceOptions = (budget) => {
|
|
40071
|
+
if (!budget) {
|
|
40072
|
+
return DAEMON_CONFIG_PREFER_OPTIONS;
|
|
40073
|
+
}
|
|
40074
|
+
const remainingMs = readRemainingBudgetMs2(budget);
|
|
40075
|
+
if (remainingMs === void 0 || remainingMs <= 1) {
|
|
40076
|
+
return null;
|
|
40077
|
+
}
|
|
40078
|
+
const timeoutMs = Math.min(DAEMON_CONFIG_PREFER_OPTIONS.timeoutMs ?? remainingMs, remainingMs);
|
|
40079
|
+
const retryDelayMs = Math.max(0, DAEMON_CONFIG_PREFER_OPTIONS.retryDelayMs ?? 0);
|
|
40080
|
+
const maxAttempts = Math.max(1, DAEMON_CONFIG_PREFER_OPTIONS.retryAttempts ?? 1);
|
|
40081
|
+
let retryAttempts = 1;
|
|
40082
|
+
while (retryAttempts < maxAttempts) {
|
|
40083
|
+
const nextAttempts = retryAttempts + 1;
|
|
40084
|
+
const nextWorstCaseMs = nextAttempts * timeoutMs + (nextAttempts - 1) * retryDelayMs;
|
|
40085
|
+
if (nextWorstCaseMs > remainingMs) {
|
|
40086
|
+
break;
|
|
40087
|
+
}
|
|
40088
|
+
retryAttempts = nextAttempts;
|
|
40089
|
+
}
|
|
40090
|
+
return {
|
|
40091
|
+
timeoutMs,
|
|
40092
|
+
retryAttempts,
|
|
40093
|
+
retryDelayMs: retryAttempts > 1 ? retryDelayMs : 0
|
|
40094
|
+
};
|
|
40095
|
+
};
|
|
40096
|
+
var stopDaemonConnection = async (connection, budget = null, reason = "unknown") => {
|
|
40097
|
+
const stopTimeoutMs = capTimeoutToBudget(DAEMON_RESTART_STATUS_TIMEOUT_MS, budget);
|
|
40098
|
+
logDaemonStopDebug2("client.stop.request", { reason, port: connection.port });
|
|
39678
40099
|
try {
|
|
39679
|
-
await fetchWithTimeout(`http://127.0.0.1:${connection.port}/stop`, {
|
|
40100
|
+
const response = await fetchWithTimeout(`http://127.0.0.1:${connection.port}/stop`, {
|
|
39680
40101
|
method: "POST",
|
|
39681
|
-
headers:
|
|
39682
|
-
},
|
|
40102
|
+
headers: createDaemonStopHeaders(connection.token, reason)
|
|
40103
|
+
}, stopTimeoutMs);
|
|
40104
|
+
if (response.status === 409) {
|
|
40105
|
+
logDaemonStopDebug2("client.stop.fingerprintRejected", { reason, port: connection.port });
|
|
40106
|
+
return "fingerprint_rejected";
|
|
40107
|
+
}
|
|
40108
|
+
if (!response.ok) {
|
|
40109
|
+
logDaemonStopDebug2("client.stop.rejected", { reason, port: connection.port, status: response.status });
|
|
40110
|
+
return "unreachable";
|
|
40111
|
+
}
|
|
40112
|
+
logDaemonStopDebug2("client.stop.complete", { reason, port: connection.port });
|
|
40113
|
+
return "stopped";
|
|
39683
40114
|
} catch {
|
|
40115
|
+
logDaemonStopDebug2("client.stop.error", { reason, port: connection.port });
|
|
40116
|
+
return "unreachable";
|
|
40117
|
+
}
|
|
40118
|
+
};
|
|
40119
|
+
function resolveDaemonRestartCommand(options = {}) {
|
|
40120
|
+
const execPath = options.execPath ?? process.execPath;
|
|
40121
|
+
const execArgv = options.execArgv ?? process.execArgv;
|
|
40122
|
+
const moduleUrl = options.moduleUrl ?? import.meta.url;
|
|
40123
|
+
const argv1 = options.argv1 ?? process.argv[1];
|
|
40124
|
+
const entryPath = resolveCurrentDaemonEntrypointPath({
|
|
40125
|
+
argv1,
|
|
40126
|
+
moduleUrl,
|
|
40127
|
+
entryExists: options.entryExists ?? existsSync7
|
|
40128
|
+
});
|
|
40129
|
+
if (!(typeof argv1 === "string" && argv1.trim().length > 0)) {
|
|
40130
|
+
const modulePath = resolve8(fileURLToPath3(moduleUrl));
|
|
40131
|
+
if (entryPath === modulePath) {
|
|
40132
|
+
throw createDisconnectedError("Daemon restart requires a stable CLI entrypoint. Start with `opendevbrowser serve`.");
|
|
40133
|
+
}
|
|
39684
40134
|
}
|
|
39685
|
-
|
|
40135
|
+
const restartExecArgv = resolveRestartExecArgv(entryPath, execArgv);
|
|
40136
|
+
if (TYPESCRIPT_ENTRY_RE.test(entryPath) && restartExecArgv.length === 0) {
|
|
40137
|
+
throw createDisconnectedError("Daemon restart requires the original loader context. Start with `opendevbrowser serve`.");
|
|
40138
|
+
}
|
|
40139
|
+
return {
|
|
40140
|
+
command: execPath,
|
|
40141
|
+
args: [...restartExecArgv, entryPath]
|
|
40142
|
+
};
|
|
40143
|
+
}
|
|
39686
40144
|
var restartDaemonConnection = async (connection) => {
|
|
39687
|
-
const
|
|
39688
|
-
|
|
40145
|
+
const restart = resolveDaemonRestartCommand();
|
|
40146
|
+
const child = spawn2(restart.command, [
|
|
40147
|
+
...restart.args,
|
|
39689
40148
|
"serve",
|
|
39690
40149
|
"--port",
|
|
39691
40150
|
String(connection.port),
|
|
@@ -39699,11 +40158,18 @@ var restartDaemonConnection = async (connection) => {
|
|
|
39699
40158
|
});
|
|
39700
40159
|
child.unref();
|
|
39701
40160
|
};
|
|
39702
|
-
var waitForCurrentDaemonStatus = async (connection) => {
|
|
39703
|
-
const deadline =
|
|
40161
|
+
var waitForCurrentDaemonStatus = async (connection, readyTimeoutMs = DAEMON_RESTART_READY_TIMEOUT_MS, budget = null) => {
|
|
40162
|
+
const deadline = resolveReadyDeadlineMs(readyTimeoutMs, budget);
|
|
39704
40163
|
while (true) {
|
|
40164
|
+
const remainingMs = deadline - Date.now();
|
|
40165
|
+
if (remainingMs <= 0) {
|
|
40166
|
+
if (hasBudgetTimedOut(budget, deadline)) {
|
|
40167
|
+
throw createTransportTimeoutError(budget.timeoutMs);
|
|
40168
|
+
}
|
|
40169
|
+
return null;
|
|
40170
|
+
}
|
|
39705
40171
|
const status = await fetchDaemonStatus(connection.port, connection.token, {
|
|
39706
|
-
timeoutMs: DAEMON_RESTART_STATUS_TIMEOUT_MS
|
|
40172
|
+
timeoutMs: Math.min(DAEMON_RESTART_STATUS_TIMEOUT_MS, remainingMs)
|
|
39707
40173
|
});
|
|
39708
40174
|
if (status?.ok && isCurrentDaemonFingerprint(status.fingerprint)) {
|
|
39709
40175
|
return status;
|
|
@@ -39711,15 +40177,36 @@ var waitForCurrentDaemonStatus = async (connection) => {
|
|
|
39711
40177
|
if (Date.now() >= deadline) {
|
|
39712
40178
|
return null;
|
|
39713
40179
|
}
|
|
39714
|
-
await sleep3(DAEMON_RESTART_POLL_DELAY_MS);
|
|
40180
|
+
await sleep3(Math.min(DAEMON_RESTART_POLL_DELAY_MS, Math.max(0, deadline - Date.now())));
|
|
39715
40181
|
}
|
|
39716
40182
|
};
|
|
39717
|
-
var
|
|
39718
|
-
const
|
|
39719
|
-
|
|
39720
|
-
|
|
39721
|
-
|
|
39722
|
-
|
|
40183
|
+
var waitForDaemonShutdown = async (connection, readyTimeoutMs = DAEMON_RECOVERY_READY_TIMEOUT_MS, budget = null) => {
|
|
40184
|
+
const deadline = resolveReadyDeadlineMs(readyTimeoutMs, budget);
|
|
40185
|
+
while (true) {
|
|
40186
|
+
const remainingMs = deadline - Date.now();
|
|
40187
|
+
if (remainingMs <= 0) {
|
|
40188
|
+
if (hasBudgetTimedOut(budget, deadline)) {
|
|
40189
|
+
throw createTransportTimeoutError(budget.timeoutMs);
|
|
40190
|
+
}
|
|
40191
|
+
return null;
|
|
40192
|
+
}
|
|
40193
|
+
const status = await fetchDaemonStatus(connection.port, connection.token, {
|
|
40194
|
+
timeoutMs: Math.min(DAEMON_RESTART_STATUS_TIMEOUT_MS, remainingMs)
|
|
40195
|
+
});
|
|
40196
|
+
if (!status?.ok) {
|
|
40197
|
+
return "stopped";
|
|
40198
|
+
}
|
|
40199
|
+
if (isCurrentDaemonFingerprint(status.fingerprint)) {
|
|
40200
|
+
return status;
|
|
40201
|
+
}
|
|
40202
|
+
if (Date.now() >= deadline) {
|
|
40203
|
+
return null;
|
|
40204
|
+
}
|
|
40205
|
+
await sleep3(Math.min(DAEMON_RESTART_POLL_DELAY_MS, Math.max(0, deadline - Date.now())));
|
|
40206
|
+
}
|
|
40207
|
+
};
|
|
40208
|
+
var resolveMetadataConnection = async (metadataConnection, configuredConnection, budget = null) => {
|
|
40209
|
+
const status = await fetchAnyDaemonStatus(metadataConnection, DAEMON_STATUS_RETRY_OPTIONS, budget);
|
|
39723
40210
|
if (!status?.ok) {
|
|
39724
40211
|
return null;
|
|
39725
40212
|
}
|
|
@@ -39732,57 +40219,130 @@ var resolveMetadataConnection = async (metadataConnection, configuredConnection)
|
|
|
39732
40219
|
}
|
|
39733
40220
|
return { connection: metadataConnection, status };
|
|
39734
40221
|
};
|
|
39735
|
-
var resolveFreshDaemonConnection = async () => {
|
|
40222
|
+
var resolveFreshDaemonConnection = async (budget = null, options = {}) => {
|
|
39736
40223
|
const configuredConnection = getConfiguredDaemonConnection();
|
|
39737
40224
|
if (!configuredConnection) {
|
|
39738
40225
|
throw createDisconnectedError("Daemon not running. Start with `opendevbrowser serve`.");
|
|
39739
40226
|
}
|
|
39740
|
-
const configuredStatus = await
|
|
39741
|
-
|
|
39742
|
-
configuredConnection.token,
|
|
39743
|
-
DAEMON_STATUS_RETRY_OPTIONS
|
|
39744
|
-
);
|
|
39745
|
-
if (configuredStatus?.ok && isCurrentDaemonFingerprint(configuredStatus.fingerprint)) {
|
|
39746
|
-
persistResolvedDaemonStatus(configuredConnection, configuredStatus);
|
|
39747
|
-
return configuredConnection;
|
|
39748
|
-
}
|
|
40227
|
+
const configuredStatus = await fetchAnyDaemonStatus(configuredConnection, DAEMON_STATUS_RETRY_OPTIONS, budget);
|
|
40228
|
+
let currentConfiguredStatus = configuredStatus?.ok && isCurrentDaemonFingerprint(configuredStatus.fingerprint) ? configuredStatus : null;
|
|
39749
40229
|
const metadata = readDaemonMetadata();
|
|
39750
40230
|
const metadataConnection = metadata ? { port: metadata.port, token: metadata.token } : null;
|
|
39751
|
-
const staleMetadata = metadataConnection ? await resolveMetadataConnection(metadataConnection, configuredConnection) : null;
|
|
39752
|
-
if (
|
|
40231
|
+
const staleMetadata = metadataConnection ? await resolveMetadataConnection(metadataConnection, configuredConnection, budget) : null;
|
|
40232
|
+
if (currentConfiguredStatus?.ok) {
|
|
40233
|
+
return await persistCurrentConfiguredConnection(configuredConnection, currentConfiguredStatus, staleMetadata);
|
|
40234
|
+
}
|
|
40235
|
+
if (options.preferConfiguredRecovery && staleMetadata) {
|
|
40236
|
+
currentConfiguredStatus = await waitForCurrentDaemonStatus(
|
|
40237
|
+
configuredConnection,
|
|
40238
|
+
DAEMON_RECOVERY_READY_TIMEOUT_MS,
|
|
40239
|
+
budget
|
|
40240
|
+
);
|
|
40241
|
+
if (currentConfiguredStatus?.ok) {
|
|
40242
|
+
return await persistCurrentConfiguredConnection(configuredConnection, currentConfiguredStatus, staleMetadata);
|
|
40243
|
+
}
|
|
40244
|
+
if (!configuredStatus?.ok) {
|
|
40245
|
+
throw createDisconnectedError("Daemon not running. Start with `opendevbrowser serve`.");
|
|
40246
|
+
}
|
|
40247
|
+
}
|
|
40248
|
+
if (!options.preferConfiguredRecovery && staleMetadata?.status.ok && isCurrentDaemonFingerprint(staleMetadata.status.fingerprint)) {
|
|
40249
|
+
if (configuredStatus?.ok) {
|
|
40250
|
+
void stopDaemonConnection(configuredConnection, budget, "resolveFreshDaemonConnection.configuredCurrentMetadataPreferred").catch(() => void 0);
|
|
40251
|
+
}
|
|
39753
40252
|
return staleMetadata.connection;
|
|
39754
40253
|
}
|
|
40254
|
+
if (!configuredStatus?.ok && staleMetadata) {
|
|
40255
|
+
currentConfiguredStatus = await waitForCurrentDaemonStatus(
|
|
40256
|
+
configuredConnection,
|
|
40257
|
+
DAEMON_RECOVERY_READY_TIMEOUT_MS,
|
|
40258
|
+
budget
|
|
40259
|
+
);
|
|
40260
|
+
if (currentConfiguredStatus?.ok) {
|
|
40261
|
+
return await persistCurrentConfiguredConnection(configuredConnection, currentConfiguredStatus, staleMetadata);
|
|
40262
|
+
}
|
|
40263
|
+
throw createDisconnectedError("Daemon not running. Start with `opendevbrowser serve`.");
|
|
40264
|
+
}
|
|
39755
40265
|
const staleConnections = [];
|
|
39756
40266
|
if (configuredStatus?.ok) {
|
|
39757
|
-
staleConnections.push(configuredConnection);
|
|
39758
|
-
}
|
|
39759
|
-
if (staleMetadata && !sameDaemonConnection(staleMetadata.connection, configuredConnection)) {
|
|
39760
|
-
staleConnections.push(staleMetadata.connection);
|
|
40267
|
+
staleConnections.push({ connection: configuredConnection, status: configuredStatus });
|
|
39761
40268
|
}
|
|
39762
40269
|
if (staleConnections.length === 0) {
|
|
40270
|
+
const recoveringStatus = await waitForCurrentDaemonStatus(
|
|
40271
|
+
configuredConnection,
|
|
40272
|
+
DAEMON_RECOVERY_READY_TIMEOUT_MS,
|
|
40273
|
+
budget
|
|
40274
|
+
);
|
|
40275
|
+
if (recoveringStatus?.ok) {
|
|
40276
|
+
persistResolvedDaemonStatus(configuredConnection, recoveringStatus);
|
|
40277
|
+
return configuredConnection;
|
|
40278
|
+
}
|
|
39763
40279
|
throw createDisconnectedError("Daemon not running. Start with `opendevbrowser serve`.");
|
|
39764
40280
|
}
|
|
39765
40281
|
for (const staleConnection of staleConnections) {
|
|
39766
|
-
await stopDaemonConnection(
|
|
40282
|
+
const stopOutcome = await stopDaemonConnection(
|
|
40283
|
+
staleConnection.connection,
|
|
40284
|
+
budget,
|
|
40285
|
+
"resolveFreshDaemonConnection.staleConnections"
|
|
40286
|
+
);
|
|
40287
|
+
if (stopOutcome === "fingerprint_rejected") {
|
|
40288
|
+
throw createDisconnectedError(
|
|
40289
|
+
`Daemon on 127.0.0.1:${staleConnection.connection.port} pid=${staleConnection.status.pid} is protected by a different opendevbrowser build. Start with \`opendevbrowser serve\`.`
|
|
40290
|
+
);
|
|
40291
|
+
}
|
|
40292
|
+
}
|
|
40293
|
+
if (configuredStatus?.ok) {
|
|
40294
|
+
const shutdownOutcome = await waitForDaemonShutdown(configuredConnection, DAEMON_RECOVERY_READY_TIMEOUT_MS, budget);
|
|
40295
|
+
if (!shutdownOutcome) {
|
|
40296
|
+
throw createDisconnectedError("Daemon restart could not reclaim the configured port after fingerprint mismatch. Start with `opendevbrowser serve`.");
|
|
40297
|
+
}
|
|
40298
|
+
if (shutdownOutcome !== "stopped") {
|
|
40299
|
+
persistResolvedDaemonStatus(configuredConnection, shutdownOutcome);
|
|
40300
|
+
return configuredConnection;
|
|
40301
|
+
}
|
|
39767
40302
|
}
|
|
39768
40303
|
await restartDaemonConnection(configuredConnection);
|
|
39769
|
-
const refreshedStatus = await waitForCurrentDaemonStatus(configuredConnection);
|
|
40304
|
+
const refreshedStatus = await waitForCurrentDaemonStatus(configuredConnection, DAEMON_RESTART_READY_TIMEOUT_MS, budget);
|
|
39770
40305
|
if (!refreshedStatus?.ok) {
|
|
39771
40306
|
throw createDisconnectedError("Daemon restart failed after fingerprint mismatch. Start with `opendevbrowser serve`.");
|
|
39772
40307
|
}
|
|
39773
40308
|
persistResolvedDaemonStatus(configuredConnection, refreshedStatus);
|
|
39774
40309
|
return configuredConnection;
|
|
39775
40310
|
};
|
|
39776
|
-
var resolveDaemonConnection = async () => {
|
|
40311
|
+
var resolveDaemonConnection = async (budget = null, options = {}) => {
|
|
39777
40312
|
const metadata = readDaemonMetadata();
|
|
39778
40313
|
if (metadata && isCurrentDaemonFingerprint(metadata.fingerprint)) {
|
|
39779
|
-
|
|
40314
|
+
const metadataConnection = { port: metadata.port, token: metadata.token };
|
|
40315
|
+
const configuredConnection = getConfiguredDaemonConnection();
|
|
40316
|
+
if (!configuredConnection || sameDaemonConnection(metadataConnection, configuredConnection)) {
|
|
40317
|
+
return metadataConnection;
|
|
40318
|
+
}
|
|
40319
|
+
const configuredOptions = resolveConfiguredPreferenceOptions(budget);
|
|
40320
|
+
if (!configuredOptions) {
|
|
40321
|
+
if (options.preferConfiguredRecovery) {
|
|
40322
|
+
return await resolveFreshDaemonConnection(budget, options);
|
|
40323
|
+
}
|
|
40324
|
+
return metadataConnection;
|
|
40325
|
+
}
|
|
40326
|
+
const configuredStatus = await fetchCurrentDaemonStatus(configuredConnection, configuredOptions, budget);
|
|
40327
|
+
if (configuredStatus?.ok) {
|
|
40328
|
+
return await persistCurrentConfiguredConnection(
|
|
40329
|
+
configuredConnection,
|
|
40330
|
+
configuredStatus,
|
|
40331
|
+
{ connection: metadataConnection }
|
|
40332
|
+
);
|
|
40333
|
+
}
|
|
40334
|
+
if (options.preferConfiguredRecovery) {
|
|
40335
|
+
return await resolveFreshDaemonConnection(budget, options);
|
|
40336
|
+
}
|
|
40337
|
+
return metadataConnection;
|
|
39780
40338
|
}
|
|
39781
|
-
return await resolveFreshDaemonConnection();
|
|
40339
|
+
return await resolveFreshDaemonConnection(budget, options);
|
|
39782
40340
|
};
|
|
39783
|
-
var retryWithRefreshedConnection = async (name, params2,
|
|
39784
|
-
const connection = await resolveFreshDaemonConnection(
|
|
39785
|
-
|
|
40341
|
+
var retryWithRefreshedConnection = async (name, params2, budget) => {
|
|
40342
|
+
const connection = await resolveFreshDaemonConnection(budget, {
|
|
40343
|
+
preferConfiguredRecovery: requiresConfiguredRecovery(name)
|
|
40344
|
+
});
|
|
40345
|
+
return await openDaemonCommand(connection.port, connection.token, name, params2, readRemainingBudgetMs2(budget));
|
|
39786
40346
|
};
|
|
39787
40347
|
var openDaemonCommand = async (port, token, name, params2, timeoutMs) => {
|
|
39788
40348
|
return await fetchWithTimeoutContext(`http://127.0.0.1:${port}/command`, {
|
|
@@ -39967,6 +40527,15 @@ var buildAnnotateResult = async (payload) => {
|
|
|
39967
40527
|
};
|
|
39968
40528
|
};
|
|
39969
40529
|
|
|
40530
|
+
// src/cli/transport-timeouts.ts
|
|
40531
|
+
var DEFAULT_CLICK_TRANSPORT_TIMEOUT_MS = 6e4;
|
|
40532
|
+
var DEFAULT_DIALOG_TRANSPORT_TIMEOUT_MS = 3e4;
|
|
40533
|
+
var DEFAULT_TARGET_CREATION_TRANSPORT_TIMEOUT_MS = 3e4;
|
|
40534
|
+
var DEFAULT_SNAPSHOT_TRANSPORT_TIMEOUT_MS = 3e4;
|
|
40535
|
+
var DEFAULT_REVIEW_TRANSPORT_TIMEOUT_MS = 3e4;
|
|
40536
|
+
var DEFAULT_SCREENSHOT_TRANSPORT_TIMEOUT_MS = 3e4;
|
|
40537
|
+
var DEFAULT_WORKFLOW_TRANSPORT_TIMEOUT_MS = 12e4;
|
|
40538
|
+
|
|
39970
40539
|
// src/public-surface/generated-manifest.ts
|
|
39971
40540
|
var PUBLIC_SURFACE_MANIFEST = {
|
|
39972
40541
|
"schemaVersion": "2026-04-04",
|
|
@@ -40547,10 +41116,10 @@ var PUBLIC_SURFACE_MANIFEST = {
|
|
|
40547
41116
|
"--cookie-policy"
|
|
40548
41117
|
],
|
|
40549
41118
|
"examples": [
|
|
40550
|
-
'npx opendevbrowser inspiredesign run --brief "Extract a reusable dashboard design contract from live references" --url https://linear.app --
|
|
41119
|
+
'npx opendevbrowser inspiredesign run --brief "Extract a reusable dashboard design contract from live references" --url https://linear.app --include-prototype-guidance --output-dir /tmp/inspiredesign --output-format json'
|
|
40551
41120
|
],
|
|
40552
41121
|
"notes": [
|
|
40553
|
-
"
|
|
41122
|
+
"Any inspiredesign --url forces deep capture for DOM/layout evidence; without URLs, --capture-mode defaults to off.",
|
|
40554
41123
|
"Repeat --url for multiple references. There is no --urls alias."
|
|
40555
41124
|
],
|
|
40556
41125
|
"groupId": "provider_workflows",
|
|
@@ -42489,7 +43058,7 @@ var PUBLIC_SURFACE_MANIFEST = {
|
|
|
42489
43058
|
"name": "opendevbrowser_inspiredesign_run",
|
|
42490
43059
|
"description": "Run the inspiredesign workflow directly.",
|
|
42491
43060
|
"cliEquivalent": "inspiredesign",
|
|
42492
|
-
"example": 'npx opendevbrowser inspiredesign run --brief "Extract a reusable dashboard design contract from live references" --url https://linear.app --
|
|
43061
|
+
"example": 'npx opendevbrowser inspiredesign run --brief "Extract a reusable dashboard design contract from live references" --url https://linear.app --include-prototype-guidance --output-dir /tmp/inspiredesign --output-format json'
|
|
42493
43062
|
},
|
|
42494
43063
|
{
|
|
42495
43064
|
"name": "opendevbrowser_canvas",
|
|
@@ -42942,21 +43511,31 @@ export {
|
|
|
42942
43511
|
executeMacroWithRuntime,
|
|
42943
43512
|
fetchWithTimeout,
|
|
42944
43513
|
readDaemonMetadata,
|
|
42945
|
-
|
|
43514
|
+
isCurrentDaemonFingerprint,
|
|
43515
|
+
createDaemonStopHeaders,
|
|
42946
43516
|
startDaemon,
|
|
42947
43517
|
EXIT_USAGE,
|
|
42948
43518
|
EXIT_EXECUTION,
|
|
42949
43519
|
EXIT_DISCONNECTED,
|
|
42950
43520
|
createUsageError,
|
|
43521
|
+
createDisconnectedError,
|
|
42951
43522
|
toCliError,
|
|
42952
43523
|
formatErrorPayload,
|
|
42953
43524
|
resolveExitCode,
|
|
43525
|
+
DEFAULT_DAEMON_STATUS_FETCH_OPTIONS,
|
|
42954
43526
|
fetchDaemonStatus,
|
|
42955
43527
|
fetchDaemonStatusFromMetadata,
|
|
42956
43528
|
DaemonClient,
|
|
42957
43529
|
callDaemon,
|
|
42958
43530
|
onboarding_metadata_default,
|
|
42959
43531
|
buildAnnotateResult,
|
|
43532
|
+
DEFAULT_CLICK_TRANSPORT_TIMEOUT_MS,
|
|
43533
|
+
DEFAULT_DIALOG_TRANSPORT_TIMEOUT_MS,
|
|
43534
|
+
DEFAULT_TARGET_CREATION_TRANSPORT_TIMEOUT_MS,
|
|
43535
|
+
DEFAULT_SNAPSHOT_TRANSPORT_TIMEOUT_MS,
|
|
43536
|
+
DEFAULT_REVIEW_TRANSPORT_TIMEOUT_MS,
|
|
43537
|
+
DEFAULT_SCREENSHOT_TRANSPORT_TIMEOUT_MS,
|
|
43538
|
+
DEFAULT_WORKFLOW_TRANSPORT_TIMEOUT_MS,
|
|
42960
43539
|
VALID_FLAGS,
|
|
42961
43540
|
VALID_EQUALS_FLAGS,
|
|
42962
43541
|
CLI_COMMANDS,
|
|
@@ -42965,4 +43544,4 @@ export {
|
|
|
42965
43544
|
TOOL_SURFACE_ENTRIES
|
|
42966
43545
|
};
|
|
42967
43546
|
/* v8 ignore next -- @preserve */
|
|
42968
|
-
//# sourceMappingURL=chunk-
|
|
43547
|
+
//# sourceMappingURL=chunk-GTTYIAI7.js.map
|