@karlorz/codexhost-cli-win32-x64 0.17.0-1 → 0.17.3-0
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/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +15 -0
- package/app/console-web.js +16 -1
- package/app/cpa-live-voice-hook.js +51 -33
- package/app/desktop-controller.mjs +1182 -46
- package/app/host-runtime.mjs +1239 -59
- package/app/plugins/antigravity/plugin.mjs +42 -7
- package/app/plugins/claude-code/plugin.mjs +15 -0
- package/app/plugins/codebuddy/plugin.mjs +15 -0
- package/app/plugins/codex-usage/plugin.mjs +15 -0
- package/app/plugins/copilot/plugin.mjs +15 -0
- package/app/plugins/cursor-cli/plugin.mjs +34 -3
- package/app/plugins/deepseek-harness/plugin.mjs +15 -0
- package/app/plugins/devin/plugin.mjs +15 -0
- package/app/plugins/grok/plugin.mjs +383 -70
- package/app/plugins/hermes/plugin.mjs +15 -0
- package/app/plugins/kimi-code/plugin.mjs +65 -3
- package/app/plugins/kiro-cli/plugin.mjs +15 -0
- package/app/plugins/omp/plugin.mjs +15 -0
- package/app/plugins/opencode/plugin.mjs +15 -0
- package/app/plugins/pi/plugin.mjs +223 -88
- package/app/plugins/qoder/plugin.mjs +15 -0
- package/app/plugins/qoder-cn/plugin.mjs +15 -0
- package/app/plugins/qwen-code/plugin.mjs +15 -0
- package/app/plugins/workbuddy/plugin.mjs +15 -0
- package/app/plugins/zcode/plugin.mjs +157 -9
- package/app/renderer-extension.js +594 -251
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
|
@@ -15853,6 +15853,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
15853
15853
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15854
15854
|
text: external_exports.string().optional()
|
|
15855
15855
|
}).strict();
|
|
15856
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
15857
|
+
kind: external_exports.literal("application"),
|
|
15858
|
+
value: external_exports.string().transform((text, context) => {
|
|
15859
|
+
try {
|
|
15860
|
+
return JSON.parse(text);
|
|
15861
|
+
} catch {
|
|
15862
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15863
|
+
return external_exports.NEVER;
|
|
15864
|
+
}
|
|
15865
|
+
}).pipe(external_exports.object({
|
|
15866
|
+
expectedTurnId: hostTurnIdSchema,
|
|
15867
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
15868
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15869
|
+
}).strict())
|
|
15870
|
+
}).strict().transform((context) => context.value);
|
|
15856
15871
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15857
15872
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15858
15873
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -16856,6 +16871,79 @@ function cpaLiveVoiceHookBootstrap(environment = process.env, desktopVersion) {
|
|
|
16856
16871
|
`;
|
|
16857
16872
|
}
|
|
16858
16873
|
|
|
16874
|
+
// packages/desktop-control/src/browser-annotation-style-compat.ts
|
|
16875
|
+
var BROWSER_ANNOTATION_STYLE_COMPAT_SOURCE = String.raw`(() => {
|
|
16876
|
+
const key = '__codexhostBrowserAnnotationStylesV1';
|
|
16877
|
+
if (globalThis[key]?.refresh() === true) return;
|
|
16878
|
+
if (typeof CSSStyleSheet !== 'function' ||
|
|
16879
|
+
typeof CSSStyleSheet.prototype.replaceSync !== 'function') return;
|
|
16880
|
+
let root = null;
|
|
16881
|
+
let shadow = null;
|
|
16882
|
+
let stylesObserver = null;
|
|
16883
|
+
const copies = new Map();
|
|
16884
|
+
function removeCopies() {
|
|
16885
|
+
if (shadow) {
|
|
16886
|
+
const owned = new Set(Array.from(copies.values(), copy => copy.sheet));
|
|
16887
|
+
shadow.adoptedStyleSheets = shadow.adoptedStyleSheets.filter(sheet => !owned.has(sheet));
|
|
16888
|
+
}
|
|
16889
|
+
copies.clear();
|
|
16890
|
+
}
|
|
16891
|
+
function syncStyles() {
|
|
16892
|
+
if (!shadow) return;
|
|
16893
|
+
const present = new Set();
|
|
16894
|
+
for (const style of shadow.querySelectorAll('style')) {
|
|
16895
|
+
const text = style.textContent || '';
|
|
16896
|
+
// Only repair Codex's cursor stylesheet when CSP rejected its style element.
|
|
16897
|
+
if (style.sheet || !text.includes('.annotation-selection-cursor')) continue;
|
|
16898
|
+
present.add(style);
|
|
16899
|
+
const previous = copies.get(style);
|
|
16900
|
+
if (previous?.text === text && shadow.adoptedStyleSheets.includes(previous.sheet)) continue;
|
|
16901
|
+
try {
|
|
16902
|
+
const sheet = previous?.sheet ?? new CSSStyleSheet();
|
|
16903
|
+
sheet.replaceSync(text);
|
|
16904
|
+
if (!shadow.adoptedStyleSheets.includes(sheet)) {
|
|
16905
|
+
shadow.adoptedStyleSheets = [...shadow.adoptedStyleSheets, sheet];
|
|
16906
|
+
}
|
|
16907
|
+
copies.set(style, { sheet, text });
|
|
16908
|
+
} catch { /* Unsupported annotation styles leave native behavior intact. */ }
|
|
16909
|
+
}
|
|
16910
|
+
for (const [style, copy] of copies) {
|
|
16911
|
+
if (present.has(style)) continue;
|
|
16912
|
+
shadow.adoptedStyleSheets = shadow.adoptedStyleSheets.filter(sheet => sheet !== copy.sheet);
|
|
16913
|
+
copies.delete(style);
|
|
16914
|
+
}
|
|
16915
|
+
}
|
|
16916
|
+
function refresh() {
|
|
16917
|
+
const nextRoot = document.documentElement;
|
|
16918
|
+
if (root !== nextRoot) {
|
|
16919
|
+
rootObserver.disconnect();
|
|
16920
|
+
rootObserver.observe(document, { childList: true });
|
|
16921
|
+
root = nextRoot;
|
|
16922
|
+
if (root) rootObserver.observe(root, { childList: true });
|
|
16923
|
+
}
|
|
16924
|
+
const host = document.getElementById('codex-browser-sidebar-comments-root');
|
|
16925
|
+
const nextShadow = host?.parentElement === root ? host?.shadowRoot ?? null : null;
|
|
16926
|
+
if (nextShadow !== shadow) {
|
|
16927
|
+
stylesObserver?.disconnect();
|
|
16928
|
+
removeCopies();
|
|
16929
|
+
shadow = nextShadow;
|
|
16930
|
+
stylesObserver = null;
|
|
16931
|
+
if (shadow && 'adoptedStyleSheets' in shadow) {
|
|
16932
|
+
stylesObserver = new MutationObserver(syncStyles);
|
|
16933
|
+
stylesObserver.observe(shadow, { childList: true, subtree: true, characterData: true });
|
|
16934
|
+
} else {
|
|
16935
|
+
shadow = null;
|
|
16936
|
+
}
|
|
16937
|
+
}
|
|
16938
|
+
syncStyles();
|
|
16939
|
+
return true;
|
|
16940
|
+
}
|
|
16941
|
+
const rootObserver = new MutationObserver(refresh);
|
|
16942
|
+
rootObserver.observe(document, { childList: true });
|
|
16943
|
+
globalThis[key] = { refresh };
|
|
16944
|
+
refresh();
|
|
16945
|
+
})();`;
|
|
16946
|
+
|
|
16859
16947
|
// packages/desktop-control/src/renderer-react-ownership.ts
|
|
16860
16948
|
function committedReactAncestors(value) {
|
|
16861
16949
|
const MAX_VISITED_FIBERS = 2e5;
|
|
@@ -17070,9 +17158,10 @@ function isolateRendererPrewarmConsumption(manager, discardExternal) {
|
|
|
17070
17158
|
}
|
|
17071
17159
|
|
|
17072
17160
|
// packages/desktop-control/src/renderer-draft-prewarm-runtime.ts
|
|
17073
|
-
function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewarmedThreadManager, isCurrentManager, retainResponses = retainRendererHostResponses, isolateConsumption = isolateRendererPrewarmConsumption) {
|
|
17161
|
+
function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewarmedThreadManager, isCurrentManager, retainResponses = retainRendererHostResponses, isolateConsumption = isolateRendererPrewarmConsumption, sendControlRequest) {
|
|
17074
17162
|
let disposed = false;
|
|
17075
17163
|
const originalSend = bridge.sendRequest;
|
|
17164
|
+
const controlSend = (method, parameters) => sendControlRequest ? sendControlRequest(method, parameters) : originalSend.call(bridge, method, parameters);
|
|
17076
17165
|
const originalPrewarm = bridge.prewarmThreadStart;
|
|
17077
17166
|
const originalOnNotification = manager.onNotification;
|
|
17078
17167
|
const originalDispatchAppServerResponse = manager.dispatchAppServerResponse;
|
|
@@ -17156,7 +17245,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
|
|
|
17156
17245
|
bridgeRequests.clear();
|
|
17157
17246
|
if (isRemoteControlHost && terminate) {
|
|
17158
17247
|
void Promise.resolve(
|
|
17159
|
-
|
|
17248
|
+
controlSend("process/kill", { processHandle: failedProcessHandle })
|
|
17160
17249
|
).catch(() => void 0);
|
|
17161
17250
|
}
|
|
17162
17251
|
};
|
|
@@ -17319,7 +17408,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
|
|
|
17319
17408
|
];
|
|
17320
17409
|
const startedProcessHandle = bridgeProcessHandle;
|
|
17321
17410
|
try {
|
|
17322
|
-
const started =
|
|
17411
|
+
const started = controlSend("process/spawn", {
|
|
17323
17412
|
command,
|
|
17324
17413
|
processHandle: startedProcessHandle,
|
|
17325
17414
|
cwd: "C:\\",
|
|
@@ -17340,7 +17429,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
|
|
|
17340
17429
|
const operation = async () => {
|
|
17341
17430
|
await startBridge();
|
|
17342
17431
|
if (bridgeState !== "ready") throw transportError("is not ready");
|
|
17343
|
-
await
|
|
17432
|
+
await controlSend("process/writeStdin", {
|
|
17344
17433
|
processHandle: bridgeProcessHandle,
|
|
17345
17434
|
deltaBase64: utf8Base64(`${JSON.stringify(value)}
|
|
17346
17435
|
`)
|
|
@@ -17620,7 +17709,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
|
|
|
17620
17709
|
bridgeReadyTimeout = null;
|
|
17621
17710
|
if (isRemoteControlHost && (bridgeState === "starting" || bridgeState === "ready")) {
|
|
17622
17711
|
void Promise.resolve(
|
|
17623
|
-
|
|
17712
|
+
controlSend("process/kill", { processHandle: bridgeProcessHandle })
|
|
17624
17713
|
).catch(() => void 0);
|
|
17625
17714
|
}
|
|
17626
17715
|
bridgeState = "disposed";
|
|
@@ -17722,10 +17811,11 @@ function resolveRendererHostManager(discovery, hostId2, managerFrom = requestMan
|
|
|
17722
17811
|
}
|
|
17723
17812
|
|
|
17724
17813
|
// packages/desktop-control/src/renderer-host-routing.ts
|
|
17725
|
-
function installRendererHostRouting(root, target, discover, resolve, createPolicy) {
|
|
17814
|
+
function installRendererHostRouting(root, target, discover, resolve, createPolicy, readConnection, publishRouting = true) {
|
|
17726
17815
|
const existing = target.__codexhostHostRoutingV1;
|
|
17727
|
-
if (existing) return existing;
|
|
17728
|
-
|
|
17816
|
+
if (publishRouting && existing) return existing;
|
|
17817
|
+
if (publishRouting)
|
|
17818
|
+
target.__codexhostDraftPrewarmPolicyV1?.dispose?.();
|
|
17729
17819
|
let disposed = false;
|
|
17730
17820
|
let lastDiscovery = null;
|
|
17731
17821
|
const routes = /* @__PURE__ */ new Map();
|
|
@@ -17752,10 +17842,20 @@ function installRendererHostRouting(root, target, discover, resolve, createPolic
|
|
|
17752
17842
|
routes.delete(hostId2);
|
|
17753
17843
|
entry?.route.policy.dispose();
|
|
17754
17844
|
};
|
|
17845
|
+
const connectionFor = (hostId2) => {
|
|
17846
|
+
if (!hostId2.startsWith("remote-control:")) return void 0;
|
|
17847
|
+
try {
|
|
17848
|
+
return readConnection?.(hostId2);
|
|
17849
|
+
} catch {
|
|
17850
|
+
return null;
|
|
17851
|
+
}
|
|
17852
|
+
};
|
|
17853
|
+
const sameConnection = (expected, current) => expected === void 0 ? current === void 0 : current?.owner === expected.owner && current.revision === expected.revision;
|
|
17755
17854
|
const routeFor = (hostId2, discovery) => {
|
|
17756
17855
|
const manager = lookup(hostId2, discovery);
|
|
17856
|
+
const connection = connectionFor(hostId2);
|
|
17757
17857
|
const previous = routes.get(hostId2);
|
|
17758
|
-
if (manager && previous?.route.manager === manager && previous.bridge === manager.requestClient && previous.prewarmed === manager.prewarmedThreadManager && previous.route.policy.owns(
|
|
17858
|
+
if (manager && previous?.route.manager === manager && previous.bridge === manager.requestClient && previous.prewarmed === manager.prewarmedThreadManager && sameConnection(previous.connection, connection) && previous.route.policy.owns(
|
|
17759
17859
|
manager,
|
|
17760
17860
|
manager.requestClient,
|
|
17761
17861
|
hostId2,
|
|
@@ -17765,7 +17865,7 @@ function installRendererHostRouting(root, target, discover, resolve, createPolic
|
|
|
17765
17865
|
return previous.route;
|
|
17766
17866
|
}
|
|
17767
17867
|
retire(hostId2);
|
|
17768
|
-
if (!manager) return null;
|
|
17868
|
+
if (!manager || connection === null) return null;
|
|
17769
17869
|
const bridge = manager.requestClient;
|
|
17770
17870
|
const prewarmed = manager.prewarmedThreadManager;
|
|
17771
17871
|
const policy = createPolicy(
|
|
@@ -17774,13 +17874,14 @@ function installRendererHostRouting(root, target, discover, resolve, createPolic
|
|
|
17774
17874
|
hostId2,
|
|
17775
17875
|
target,
|
|
17776
17876
|
prewarmed,
|
|
17777
|
-
() => lookup(hostId2) === manager && manager.requestClient === bridge && manager.prewarmedThreadManager === prewarmed
|
|
17877
|
+
() => lookup(hostId2) === manager && sameConnection(connection, connectionFor(hostId2)) && manager.requestClient === bridge && manager.prewarmedThreadManager === prewarmed
|
|
17778
17878
|
);
|
|
17779
17879
|
const route = { hostId: hostId2, manager, policy };
|
|
17780
|
-
routes.set(hostId2, { route, bridge, prewarmed });
|
|
17880
|
+
routes.set(hostId2, { route, bridge, prewarmed, connection });
|
|
17781
17881
|
return route;
|
|
17782
17882
|
};
|
|
17783
17883
|
const publish = (route) => {
|
|
17884
|
+
if (!publishRouting) return;
|
|
17784
17885
|
const policy = route?.policy;
|
|
17785
17886
|
if (target.__codexhostDraftPrewarmPolicyV1 === policy) return;
|
|
17786
17887
|
Object.defineProperty(target, "__codexhostDraftPrewarmPolicyV1", {
|
|
@@ -17833,7 +17934,7 @@ function installRendererHostRouting(root, target, discover, resolve, createPolic
|
|
|
17833
17934
|
if (!composer) {
|
|
17834
17935
|
for (const [hostId3, entry] of routes) {
|
|
17835
17936
|
const manager = lookup(hostId3, discovery);
|
|
17836
|
-
if (manager !== entry.route.manager || manager.requestClient !== entry.bridge || manager.prewarmedThreadManager !== entry.prewarmed)
|
|
17937
|
+
if (manager !== entry.route.manager || manager.requestClient !== entry.bridge || manager.prewarmedThreadManager !== entry.prewarmed || !sameConnection(entry.connection, connectionFor(hostId3)))
|
|
17837
17938
|
retire(hostId3);
|
|
17838
17939
|
}
|
|
17839
17940
|
}
|
|
@@ -17853,7 +17954,11 @@ function installRendererHostRouting(root, target, discover, resolve, createPolic
|
|
|
17853
17954
|
}
|
|
17854
17955
|
}
|
|
17855
17956
|
};
|
|
17856
|
-
|
|
17957
|
+
if (publishRouting)
|
|
17958
|
+
Object.defineProperty(target, "__codexhostHostRoutingV1", {
|
|
17959
|
+
configurable: true,
|
|
17960
|
+
value: routing
|
|
17961
|
+
});
|
|
17857
17962
|
return routing;
|
|
17858
17963
|
}
|
|
17859
17964
|
|
|
@@ -17903,7 +18008,9 @@ function findRendererHostRpcFamily(store) {
|
|
|
17903
18008
|
if (!record3(definition) || definition.kind !== "signal-family") continue;
|
|
17904
18009
|
if (!record3(members) || typeof members.get !== "function") continue;
|
|
17905
18010
|
for (const [hostId2, member] of members) {
|
|
17906
|
-
if (typeof hostId2 !== "string" ||
|
|
18011
|
+
if (typeof hostId2 !== "string" || !/^(?:local$|durable$|remote[-:]|ssh:)/u.test(hostId2))
|
|
18012
|
+
continue;
|
|
18013
|
+
if (!record3(member)) continue;
|
|
17907
18014
|
const signal = member.value;
|
|
17908
18015
|
if (!record3(signal) || typeof signal.get !== "function") continue;
|
|
17909
18016
|
let value;
|
|
@@ -18018,18 +18125,41 @@ function installRendererHostRpcRouting(root, target, dependencies) {
|
|
|
18018
18125
|
return existing;
|
|
18019
18126
|
}
|
|
18020
18127
|
let disposed = false;
|
|
18128
|
+
let nativeRouting = null;
|
|
18021
18129
|
let discovery = null;
|
|
18022
18130
|
const routes = /* @__PURE__ */ new Map();
|
|
18023
18131
|
const read = () => {
|
|
18024
18132
|
if (disposed) return null;
|
|
18025
|
-
|
|
18133
|
+
try {
|
|
18026
18134
|
const store = dependencies.findStore(root);
|
|
18027
|
-
|
|
18135
|
+
const bound = store && discovery?.store === store ? [...store.familyBindings.values()].includes(discovery.family) : false;
|
|
18136
|
+
if (!bound) discovery = store ? dependencies.findFamily(store) : null;
|
|
18137
|
+
} catch {
|
|
18138
|
+
discovery = null;
|
|
18028
18139
|
}
|
|
18029
18140
|
return discovery;
|
|
18030
18141
|
};
|
|
18031
18142
|
if (!read()) return null;
|
|
18032
18143
|
const queuePolicy = dependencies.installQueuePolicy(root, target);
|
|
18144
|
+
const discoverComposer = (composer) => {
|
|
18145
|
+
const owners = dependencies.discoverComposer(composer);
|
|
18146
|
+
if (!nativeRouting && (owners.managers.length || owners.registries.length)) {
|
|
18147
|
+
try {
|
|
18148
|
+
nativeRouting = dependencies.installNativeRouting();
|
|
18149
|
+
} catch {
|
|
18150
|
+
}
|
|
18151
|
+
}
|
|
18152
|
+
return owners;
|
|
18153
|
+
};
|
|
18154
|
+
const connectionFor = (hostId2) => {
|
|
18155
|
+
if (!hostId2.startsWith("remote-control:")) return void 0;
|
|
18156
|
+
try {
|
|
18157
|
+
return dependencies.readConnection?.(hostId2);
|
|
18158
|
+
} catch {
|
|
18159
|
+
return null;
|
|
18160
|
+
}
|
|
18161
|
+
};
|
|
18162
|
+
const sameConnection = (previous, current) => previous === void 0 ? current === void 0 : current?.owner === previous.owner && current.revision === previous.revision;
|
|
18033
18163
|
const isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18034
18164
|
const externalDrafts = /* @__PURE__ */ new Map();
|
|
18035
18165
|
const selectedModels = /* @__PURE__ */ new Map();
|
|
@@ -18107,16 +18237,25 @@ function installRendererHostRpcRouting(root, target, dependencies) {
|
|
|
18107
18237
|
const postMessage = function(message, ...rest) {
|
|
18108
18238
|
let routed = message;
|
|
18109
18239
|
try {
|
|
18110
|
-
routed = disposed ? message : routeCreationCall(message);
|
|
18240
|
+
routed = disposed || routes.size === 0 ? message : routeCreationCall(message);
|
|
18111
18241
|
} catch {
|
|
18112
18242
|
routed = message;
|
|
18113
18243
|
}
|
|
18114
18244
|
return originalPostMessage.call(this, routed, ...rest);
|
|
18115
18245
|
};
|
|
18116
18246
|
port.postMessage = postMessage;
|
|
18117
|
-
const createRoute = (hostId2, rpc) => {
|
|
18247
|
+
const createRoute = (hostId2, rpc, connection) => {
|
|
18118
18248
|
let retired = false;
|
|
18119
|
-
const isCurrent = () =>
|
|
18249
|
+
const isCurrent = () => {
|
|
18250
|
+
if (retired || disposed || routes.get(hostId2)?.rpc !== rpc || !sameConnection(connection, connectionFor(hostId2)))
|
|
18251
|
+
return false;
|
|
18252
|
+
try {
|
|
18253
|
+
const current = read();
|
|
18254
|
+
return !!current && dependencies.resolve(current, hostId2) === rpc;
|
|
18255
|
+
} catch {
|
|
18256
|
+
return false;
|
|
18257
|
+
}
|
|
18258
|
+
};
|
|
18120
18259
|
const manager = Object.freeze({
|
|
18121
18260
|
kind: "main-process-rpc",
|
|
18122
18261
|
getHostId: () => hostId2,
|
|
@@ -18193,15 +18332,23 @@ function installRendererHostRpcRouting(root, target, dependencies) {
|
|
|
18193
18332
|
routes.delete(hostId2);
|
|
18194
18333
|
entry?.route.policy.dispose();
|
|
18195
18334
|
};
|
|
18196
|
-
const routeFor = (hostId2) => {
|
|
18335
|
+
const routeFor = (hostId2, nativeRoute) => {
|
|
18336
|
+
if (disposed) return null;
|
|
18337
|
+
const connection = connectionFor(hostId2);
|
|
18338
|
+
const preferred = nativeRoute === void 0 ? nativeRouting?.forHost(hostId2) : nativeRoute;
|
|
18339
|
+
if (connection === null || preferred) {
|
|
18340
|
+
retire(hostId2);
|
|
18341
|
+
return connection === null ? null : preferred ?? null;
|
|
18342
|
+
}
|
|
18197
18343
|
const current = read();
|
|
18198
18344
|
const rpc = current ? dependencies.resolve(current, hostId2) : null;
|
|
18199
18345
|
const previous = routes.get(hostId2);
|
|
18200
|
-
if (rpc && previous?.rpc === rpc
|
|
18346
|
+
if (rpc && previous?.rpc === rpc && sameConnection(previous.connection, connection))
|
|
18347
|
+
return previous.route;
|
|
18201
18348
|
retire(hostId2);
|
|
18202
18349
|
if (!rpc) return null;
|
|
18203
|
-
const route = createRoute(hostId2, rpc);
|
|
18204
|
-
routes.set(hostId2, { route, rpc });
|
|
18350
|
+
const route = createRoute(hostId2, rpc, connection);
|
|
18351
|
+
routes.set(hostId2, { route, rpc, connection });
|
|
18205
18352
|
return route;
|
|
18206
18353
|
};
|
|
18207
18354
|
const publish = (route) => {
|
|
@@ -18215,15 +18362,27 @@ function installRendererHostRpcRouting(root, target, dependencies) {
|
|
|
18215
18362
|
target.dispatchEvent(new CustomEvent("codexhost:draft-prewarm-policy-changed"));
|
|
18216
18363
|
}
|
|
18217
18364
|
};
|
|
18218
|
-
const composerHostId = (composer) => {
|
|
18219
|
-
const
|
|
18365
|
+
const composerHostId = (owners, composer) => {
|
|
18366
|
+
const nativeHostId = nativeRouting?.hostIdForComposer(composer);
|
|
18367
|
+
if (nativeHostId) return nativeHostId;
|
|
18368
|
+
const hostIds = new Set((owners ?? discoverComposer(composer)).hostIds);
|
|
18220
18369
|
const hostId2 = hostIds.size === 1 ? hostIds.values().next().value : null;
|
|
18221
18370
|
return typeof hostId2 === "string" && hostId2 ? hostId2 : null;
|
|
18222
18371
|
};
|
|
18223
18372
|
const routing = {
|
|
18224
18373
|
knownHostIds() {
|
|
18374
|
+
if (disposed) return [];
|
|
18375
|
+
try {
|
|
18376
|
+
if (!nativeRouting) discoverComposer();
|
|
18377
|
+
} catch {
|
|
18378
|
+
}
|
|
18225
18379
|
const current = read();
|
|
18226
|
-
return
|
|
18380
|
+
return [
|
|
18381
|
+
.../* @__PURE__ */ new Set([
|
|
18382
|
+
...current ? dependencies.hostIds(current) : [],
|
|
18383
|
+
...nativeRouting?.knownHostIds?.() ?? []
|
|
18384
|
+
])
|
|
18385
|
+
];
|
|
18227
18386
|
},
|
|
18228
18387
|
forHost(hostId2) {
|
|
18229
18388
|
return hostId2 && !disposed ? routeFor(hostId2) : null;
|
|
@@ -18231,7 +18390,7 @@ function installRendererHostRpcRouting(root, target, dependencies) {
|
|
|
18231
18390
|
hostIdForComposer(composer) {
|
|
18232
18391
|
if (disposed) return null;
|
|
18233
18392
|
try {
|
|
18234
|
-
return composerHostId(composer);
|
|
18393
|
+
return composerHostId(nativeRouting ? null : discoverComposer(composer), composer);
|
|
18235
18394
|
} catch {
|
|
18236
18395
|
return null;
|
|
18237
18396
|
}
|
|
@@ -18239,18 +18398,23 @@ function installRendererHostRpcRouting(root, target, dependencies) {
|
|
|
18239
18398
|
forComposer(composer) {
|
|
18240
18399
|
if (disposed) return null;
|
|
18241
18400
|
let hostId2;
|
|
18401
|
+
let preferred = null;
|
|
18242
18402
|
try {
|
|
18243
|
-
|
|
18403
|
+
const owners = nativeRouting ? null : discoverComposer(composer);
|
|
18404
|
+
preferred = nativeRouting?.forComposer(composer) ?? null;
|
|
18405
|
+
hostId2 = preferred?.hostId ?? composerHostId(owners, composer);
|
|
18244
18406
|
} catch {
|
|
18245
18407
|
hostId2 = null;
|
|
18246
18408
|
}
|
|
18247
|
-
const route = hostId2 ? routeFor(hostId2) : null;
|
|
18409
|
+
const route = hostId2 ? routeFor(hostId2, preferred) : null;
|
|
18248
18410
|
if (!composer) publish(route);
|
|
18249
18411
|
return route;
|
|
18250
18412
|
},
|
|
18251
18413
|
dispose() {
|
|
18252
18414
|
if (disposed) return;
|
|
18253
18415
|
disposed = true;
|
|
18416
|
+
nativeRouting?.dispose();
|
|
18417
|
+
nativeRouting = null;
|
|
18254
18418
|
for (const hostId2 of [...routes.keys()]) retire(hostId2);
|
|
18255
18419
|
discovery = null;
|
|
18256
18420
|
externalDrafts.clear();
|
|
@@ -18267,6 +18431,30 @@ function installRendererHostRpcRouting(root, target, dependencies) {
|
|
|
18267
18431
|
return routing;
|
|
18268
18432
|
}
|
|
18269
18433
|
|
|
18434
|
+
// packages/desktop-control/src/renderer-connection-generation.ts
|
|
18435
|
+
function readRendererConnectionGeneration(store, hostId2) {
|
|
18436
|
+
if (!store) return void 0;
|
|
18437
|
+
const record3 = (value) => value !== null && typeof value === "object";
|
|
18438
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
18439
|
+
for (const members of store.familyBindings.values()) {
|
|
18440
|
+
const value = members.get(hostId2)?.value;
|
|
18441
|
+
if (record3(value) && record3(value.state$) && record3(value.revision$) && record3(value.appServerVersion$) && typeof value.state$.get === "function" && typeof value.revision$.get === "function")
|
|
18442
|
+
candidates.add(value);
|
|
18443
|
+
}
|
|
18444
|
+
if (!candidates.size) return void 0;
|
|
18445
|
+
if (candidates.size !== 1) return null;
|
|
18446
|
+
const owner = candidates.values().next().value;
|
|
18447
|
+
if (!owner) return null;
|
|
18448
|
+
const state = owner.state$;
|
|
18449
|
+
const revision = owner.revision$;
|
|
18450
|
+
try {
|
|
18451
|
+
const current = revision.get();
|
|
18452
|
+
return state.get() === "connected" && typeof current === "number" && Number.isSafeInteger(current) ? { owner, revision: current } : null;
|
|
18453
|
+
} catch {
|
|
18454
|
+
return null;
|
|
18455
|
+
}
|
|
18456
|
+
}
|
|
18457
|
+
|
|
18270
18458
|
// packages/desktop-control/src/renderer-draft-prewarm-policy.ts
|
|
18271
18459
|
var REQUEST_MANAGER_WAIT_TIMEOUT_MS = 6e4;
|
|
18272
18460
|
var REQUEST_MANAGER_POLL_INTERVAL_MS = 25;
|
|
@@ -18279,22 +18467,26 @@ function directRendererInstaller() {
|
|
|
18279
18467
|
const retainRendererHostResponses = ${retainRendererHostResponses.toString()};
|
|
18280
18468
|
const createDraftPrewarmPolicyBridge = ${createDraftPrewarmPolicyBridge.toString()};
|
|
18281
18469
|
const isolateRendererPrewarmConsumption = ${isolateRendererPrewarmConsumption.toString()};
|
|
18470
|
+
const findRendererAppScopeStore = ${findRendererAppScopeStore.toString()};
|
|
18471
|
+
const readRendererConnectionGeneration = ${readRendererConnectionGeneration.toString()};
|
|
18282
18472
|
const discover = (root) =>
|
|
18283
18473
|
discoverRendererHosts(root, committedReactAncestors, requestManagerFromHookState);
|
|
18284
|
-
const installNative = () => (${installRendererHostRouting.toString()})(
|
|
18474
|
+
const installNative = (publishRouting = true) => (${installRendererHostRouting.toString()})(
|
|
18285
18475
|
document, window, discover,
|
|
18286
18476
|
(discovery, hostId) => resolveRendererHostManager(discovery, hostId, requestManagerFromHookState),
|
|
18287
18477
|
(manager, bridge, hostId, target, prewarmed, isCurrent) => createDraftPrewarmPolicyBridge(
|
|
18288
18478
|
manager, bridge, hostId, target, prewarmed, isCurrent, retainRendererHostResponses,
|
|
18289
18479
|
isolateRendererPrewarmConsumption,
|
|
18290
18480
|
),
|
|
18481
|
+
(hostId) => readRendererConnectionGeneration(findRendererAppScopeStore(document), hostId),
|
|
18482
|
+
publishRouting,
|
|
18291
18483
|
);
|
|
18292
18484
|
const installRpc = () => typeof MessagePort !== 'function' ? null : (${installRendererHostRpcRouting.toString()})(document, window, {
|
|
18293
18485
|
findStore: ${findRendererAppScopeStore.toString()},
|
|
18294
18486
|
findFamily: ${findRendererHostRpcFamily.toString()},
|
|
18295
18487
|
resolve: ${resolveRendererHostRpc.toString()},
|
|
18296
18488
|
hostIds: ${rendererHostRpcHostIds.toString()},
|
|
18297
|
-
|
|
18489
|
+
discoverComposer: (composer) => {
|
|
18298
18490
|
const source = composer?.matches?.('[data-codex-composer], [contenteditable="true"][role="textbox"]')
|
|
18299
18491
|
? { querySelectorAll: () => [composer] }
|
|
18300
18492
|
: (composer ?? document);
|
|
@@ -18306,20 +18498,18 @@ function directRendererInstaller() {
|
|
|
18306
18498
|
portPrototype: MessagePort.prototype,
|
|
18307
18499
|
}),
|
|
18308
18500
|
portPrototype: MessagePort.prototype,
|
|
18501
|
+
installNativeRouting: () => installNative(false),
|
|
18502
|
+
readConnection: (hostId) => readRendererConnectionGeneration(findRendererAppScopeStore(document), hostId),
|
|
18309
18503
|
});
|
|
18310
18504
|
const connected = (routing) => routing.forComposer() !== null ||
|
|
18311
18505
|
['local', ...(routing.knownHostIds?.() ?? [])].some((hostId) => routing.forHost(hostId) !== null);
|
|
18312
18506
|
let nativeReady = false;
|
|
18313
|
-
//
|
|
18314
|
-
//
|
|
18507
|
+
// Mixed layouts can expose native managers for only some Hosts. Keep one
|
|
18508
|
+
// router that selects a native owner or the current ready RPC peer per Host.
|
|
18315
18509
|
const routing = (() => {
|
|
18316
|
-
if (window.__codexhostHostRoutingV1)
|
|
18317
|
-
|
|
18318
|
-
|
|
18319
|
-
hostId => existing.forHost(hostId)?.manager.kind === 'main-process-rpc'
|
|
18320
|
-
)) installRpc();
|
|
18321
|
-
return existing;
|
|
18322
|
-
}
|
|
18510
|
+
if (window.__codexhostHostRoutingV1) return window.__codexhostHostRoutingV1;
|
|
18511
|
+
const rpc = installRpc();
|
|
18512
|
+
if (rpc) return rpc;
|
|
18323
18513
|
const native = discover(document);
|
|
18324
18514
|
if (native.managers.length || native.registries.length) {
|
|
18325
18515
|
const routing = installNative();
|
|
@@ -18329,8 +18519,6 @@ function directRendererInstaller() {
|
|
|
18329
18519
|
}
|
|
18330
18520
|
routing.dispose();
|
|
18331
18521
|
}
|
|
18332
|
-
const rpc = installRpc();
|
|
18333
|
-
if (rpc) return rpc;
|
|
18334
18522
|
throw new Error('Renderer Host request manager is unavailable');
|
|
18335
18523
|
})();
|
|
18336
18524
|
// Publish a default draft policy only when its Host is unambiguous. Host
|
|
@@ -18490,6 +18678,892 @@ async function installRendererLoadedModules(renderer) {
|
|
|
18490
18678
|
}
|
|
18491
18679
|
}
|
|
18492
18680
|
|
|
18681
|
+
// packages/desktop-control/src/renderer-native-rpc-discovery.ts
|
|
18682
|
+
function nativeManagerDependencies(factoryName, callers) {
|
|
18683
|
+
const identifier = "[$A-Z_a-z][$\\w]*";
|
|
18684
|
+
const escaped = factoryName.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
18685
|
+
const pattern = new RegExp(
|
|
18686
|
+
`${escaped}\\((${identifier}),(${identifier}),\\1\\.get\\((${identifier}),\\2\\),(${identifier})\\.bind\\(null,\\1\\),\\((${identifier}),(${identifier})\\)=>\\5\\((${identifier}),\\6\\)\\)`
|
|
18687
|
+
);
|
|
18688
|
+
const matches = callers.flatMap((source) => {
|
|
18689
|
+
const match = pattern.exec(source);
|
|
18690
|
+
return match?.[3] && match[4] && match[7] ? [
|
|
18691
|
+
{
|
|
18692
|
+
requestDefinition: match[3],
|
|
18693
|
+
isHostForConversation: match[4],
|
|
18694
|
+
imageDefinition: match[7]
|
|
18695
|
+
}
|
|
18696
|
+
] : [];
|
|
18697
|
+
});
|
|
18698
|
+
return matches.length === 1 ? matches[0] : void 0;
|
|
18699
|
+
}
|
|
18700
|
+
function nativeRpcRole(source) {
|
|
18701
|
+
if (["dispatchMessageFromView", "threadProjectAssignments", "queuedMessageCoordination"].every(
|
|
18702
|
+
(part) => source.includes(part)
|
|
18703
|
+
))
|
|
18704
|
+
return "createManager";
|
|
18705
|
+
if (["collectAppStateSnapshot", "getReviewPaneSnapshotMetrics", "registerReplayAdmission"].every(
|
|
18706
|
+
(part) => source.includes(part)
|
|
18707
|
+
))
|
|
18708
|
+
return "createController";
|
|
18709
|
+
if (["getWorkInProgress", "getCachedThreadSearchSnapshot", "registerReplayAdmission"].every(
|
|
18710
|
+
(part) => source.includes(part)
|
|
18711
|
+
))
|
|
18712
|
+
return "RpcManager";
|
|
18713
|
+
if (["prewarmedThreadManager", "onNotification", "dispatchAppServerResponse"].every(
|
|
18714
|
+
(part) => source.includes(part)
|
|
18715
|
+
))
|
|
18716
|
+
return "Manager";
|
|
18717
|
+
return void 0;
|
|
18718
|
+
}
|
|
18719
|
+
function nativeRpcObjectShape(value) {
|
|
18720
|
+
if (value === null || typeof value !== "object")
|
|
18721
|
+
return { scope: false, services: false, controller: false };
|
|
18722
|
+
const candidate = value;
|
|
18723
|
+
const own = (keys) => keys.every((key) => Object.hasOwn(candidate, key));
|
|
18724
|
+
const methods = (keys) => keys.every((key) => typeof candidate[key] === "function");
|
|
18725
|
+
return {
|
|
18726
|
+
scope: own(["node", "scope", "get", "set", "watch"]) && methods(["get", "set", "watch"]),
|
|
18727
|
+
services: own(["appServerManagers", "remoteConnections", "applicationMenu"]) && typeof candidate.appServerManagers?.subscribe === "function",
|
|
18728
|
+
controller: own(["forHost", "collectAppStateSnapshot", "getReviewPaneSnapshotMetrics", "dispose"]) && methods(["forHost", "collectAppStateSnapshot", "getReviewPaneSnapshotMetrics", "dispose"])
|
|
18729
|
+
};
|
|
18730
|
+
}
|
|
18731
|
+
async function withNativeRpcComponents(client, install) {
|
|
18732
|
+
const group = `codexhost-native-rpc-${crypto.randomUUID()}`;
|
|
18733
|
+
const command = async (method, params) => client.command(method, params);
|
|
18734
|
+
const evaluate = (expression) => command("Runtime.evaluate", { expression, awaitPromise: true, objectGroup: group });
|
|
18735
|
+
const properties = (objectId) => command("Runtime.getProperties", { objectId, ownProperties: true });
|
|
18736
|
+
const call = (objectId, functionDeclaration, args = []) => command("Runtime.callFunctionOn", {
|
|
18737
|
+
objectId,
|
|
18738
|
+
functionDeclaration,
|
|
18739
|
+
arguments: args,
|
|
18740
|
+
objectGroup: group,
|
|
18741
|
+
returnByValue: true
|
|
18742
|
+
});
|
|
18743
|
+
try {
|
|
18744
|
+
const initial = await evaluate(String.raw`(() => {
|
|
18745
|
+
const catalog = globalThis.__codexhostLoadedModulesV1;
|
|
18746
|
+
if (!catalog?.complete || catalog.documentUrl !== location.href) return null;
|
|
18747
|
+
const urls = catalog.urls.filter(url => /^app:\/\/-\/assets\/(?:renderer-app-server-managers|app-shared)-[^/]+\.js$/.test(url));
|
|
18748
|
+
return { document, urls };
|
|
18749
|
+
})()`);
|
|
18750
|
+
if (!initial.result.objectId) return false;
|
|
18751
|
+
const holder = initial.result.objectId;
|
|
18752
|
+
const catalog = await call(holder, "function(){return this.urls}");
|
|
18753
|
+
const urls = catalog.result.value;
|
|
18754
|
+
if (!Array.isArray(urls) || urls.length !== 2) return false;
|
|
18755
|
+
const managerUrl = urls.find((url2) => url2.includes("renderer-app-server-managers"));
|
|
18756
|
+
const sharedUrl = urls.find((url2) => url2.includes("app-shared"));
|
|
18757
|
+
if (!managerUrl || !sharedUrl) return false;
|
|
18758
|
+
const attach = async (name, objectId) => {
|
|
18759
|
+
const result = await call(
|
|
18760
|
+
holder,
|
|
18761
|
+
"function(name,value){if(this.document!==document)throw Error('Renderer Realm changed');this[name]=value;return true}",
|
|
18762
|
+
[{ value: name }, { objectId }]
|
|
18763
|
+
);
|
|
18764
|
+
if (result.exceptionDetails) throw new Error("Native RPC discovery lost its Renderer Realm");
|
|
18765
|
+
};
|
|
18766
|
+
const imported = await evaluate(`import(${JSON.stringify(managerUrl)})`);
|
|
18767
|
+
if (!imported.result.objectId) return false;
|
|
18768
|
+
const exports = (await properties(imported.result.objectId)).result.filter(
|
|
18769
|
+
(entry) => entry.value?.type === "function"
|
|
18770
|
+
);
|
|
18771
|
+
let bindings = [];
|
|
18772
|
+
for (const entry of exports.slice(0, 3)) {
|
|
18773
|
+
if (!entry.value?.objectId) continue;
|
|
18774
|
+
const scopes = (await properties(entry.value.objectId)).internalProperties?.find(
|
|
18775
|
+
(entry2) => entry2.name === "[[Scopes]]"
|
|
18776
|
+
)?.value?.objectId;
|
|
18777
|
+
if (!scopes) continue;
|
|
18778
|
+
const modules = (await properties(scopes)).result.filter(
|
|
18779
|
+
(entry2) => entry2.value?.description?.startsWith("Module") && entry2.value.objectId
|
|
18780
|
+
);
|
|
18781
|
+
const moduleId = modules[0]?.value?.objectId;
|
|
18782
|
+
if (modules.length !== 1 || !moduleId) continue;
|
|
18783
|
+
bindings = (await properties(moduleId)).result;
|
|
18784
|
+
break;
|
|
18785
|
+
}
|
|
18786
|
+
const functions = bindings.filter((entry) => entry.value?.type === "function");
|
|
18787
|
+
const roles = /* @__PURE__ */ new Map();
|
|
18788
|
+
for (const entry of functions) {
|
|
18789
|
+
const role = nativeRpcRole(entry.value?.description ?? "");
|
|
18790
|
+
if (role) roles.set(role, [...roles.get(role) ?? [], entry]);
|
|
18791
|
+
}
|
|
18792
|
+
if (["createManager", "Manager", "RpcManager", "createController"].some(
|
|
18793
|
+
(role) => roles.get(role)?.length !== 1
|
|
18794
|
+
))
|
|
18795
|
+
return false;
|
|
18796
|
+
const factory = roles.get("createManager")?.[0];
|
|
18797
|
+
if (!factory) return false;
|
|
18798
|
+
const dependencies = nativeManagerDependencies(
|
|
18799
|
+
factory.name,
|
|
18800
|
+
functions.map((entry) => entry.value?.description ?? "")
|
|
18801
|
+
);
|
|
18802
|
+
if (!dependencies) return false;
|
|
18803
|
+
for (const [role, entries] of roles) {
|
|
18804
|
+
const id = entries[0]?.value?.objectId;
|
|
18805
|
+
if (!id) return false;
|
|
18806
|
+
await attach(role, id);
|
|
18807
|
+
}
|
|
18808
|
+
for (const [role, name] of Object.entries(dependencies)) {
|
|
18809
|
+
const value = bindings.find((entry) => entry.name === name)?.value?.objectId;
|
|
18810
|
+
if (!value) return false;
|
|
18811
|
+
await attach(role, value);
|
|
18812
|
+
}
|
|
18813
|
+
const shared = await evaluate(`import(${JSON.stringify(sharedUrl)})`);
|
|
18814
|
+
if (!shared.result.objectId) return false;
|
|
18815
|
+
const sharedExports = (await properties(shared.result.objectId)).result;
|
|
18816
|
+
const sessions = sharedExports.filter(
|
|
18817
|
+
(entry) => entry.value?.type === "function" && ["getRemoteMain", "getStats", "drain", "getMainImport"].every(
|
|
18818
|
+
(word) => entry.value?.description?.includes(word)
|
|
18819
|
+
)
|
|
18820
|
+
);
|
|
18821
|
+
const sessionId = sessions[0]?.value?.objectId;
|
|
18822
|
+
if (sessions.length !== 1 || !sessionId) return false;
|
|
18823
|
+
await attach("RpcSession", sessionId);
|
|
18824
|
+
const serviceMatches = await command("Runtime.callFunctionOn", {
|
|
18825
|
+
objectId: shared.result.objectId,
|
|
18826
|
+
functionDeclaration: `function(){return [...new Set(Object.values(this).filter(value => (${nativeRpcObjectShape.toString()})(value).services))]}`,
|
|
18827
|
+
objectGroup: group
|
|
18828
|
+
});
|
|
18829
|
+
if (!serviceMatches.result.objectId) return false;
|
|
18830
|
+
const services = (await properties(serviceMatches.result.objectId)).result.flatMap(
|
|
18831
|
+
(entry) => entry.value?.type === "object" && entry.value.objectId ? [entry.value.objectId] : []
|
|
18832
|
+
);
|
|
18833
|
+
const serviceId = services[0];
|
|
18834
|
+
if (services.length !== 1 || !serviceId) return false;
|
|
18835
|
+
await attach("services", serviceId);
|
|
18836
|
+
const prototype = await evaluate("Object.getPrototypeOf(async function(){})");
|
|
18837
|
+
if (!prototype.result.objectId) return false;
|
|
18838
|
+
const objects = await command("Runtime.queryObjects", {
|
|
18839
|
+
prototypeObjectId: prototype.result.objectId,
|
|
18840
|
+
objectGroup: group
|
|
18841
|
+
});
|
|
18842
|
+
if (!objects.objects.objectId) return false;
|
|
18843
|
+
const filtered = await command("Runtime.callFunctionOn", {
|
|
18844
|
+
objectId: objects.objects.objectId,
|
|
18845
|
+
functionDeclaration: 'function(){return this.filter(fn=>fn.name==="collectAppStateSnapshot"&&String(fn).includes("collectSnapshot")).slice(0,9)}',
|
|
18846
|
+
objectGroup: group
|
|
18847
|
+
});
|
|
18848
|
+
if (!filtered.result.objectId) return false;
|
|
18849
|
+
const snapshots = (await properties(filtered.result.objectId)).result.filter(
|
|
18850
|
+
(entry) => entry.value?.type === "function"
|
|
18851
|
+
);
|
|
18852
|
+
if (snapshots.length > 8) return false;
|
|
18853
|
+
const owners = [];
|
|
18854
|
+
for (const snapshot of snapshots) {
|
|
18855
|
+
const fn = snapshot.value?.objectId;
|
|
18856
|
+
if (!fn) continue;
|
|
18857
|
+
const scopes = (await properties(fn)).internalProperties?.find(
|
|
18858
|
+
(entry) => entry.name === "[[Scopes]]"
|
|
18859
|
+
)?.value?.objectId;
|
|
18860
|
+
if (!scopes) continue;
|
|
18861
|
+
for (const scope of (await properties(scopes)).result) {
|
|
18862
|
+
if (!scope.value?.description?.startsWith("Closure") || !scope.value.objectId) continue;
|
|
18863
|
+
const candidates = (await properties(scope.value.objectId)).result;
|
|
18864
|
+
const controllers = [], handles = [];
|
|
18865
|
+
for (const binding of candidates) {
|
|
18866
|
+
if (binding.value?.type !== "object" || !binding.value.objectId) continue;
|
|
18867
|
+
const id = binding.value.objectId;
|
|
18868
|
+
const response = await call(
|
|
18869
|
+
id,
|
|
18870
|
+
`function(){return (${nativeRpcObjectShape.toString()})(this)}`
|
|
18871
|
+
);
|
|
18872
|
+
const shape = response.result.value;
|
|
18873
|
+
if (shape?.scope) handles.push(id);
|
|
18874
|
+
if (shape?.controller && (await call(id, "function(fn){return this.collectAppStateSnapshot===fn}", [
|
|
18875
|
+
{ objectId: fn }
|
|
18876
|
+
])).result.value === true)
|
|
18877
|
+
controllers.push(id);
|
|
18878
|
+
}
|
|
18879
|
+
const controller = controllers[0], handle = handles[0];
|
|
18880
|
+
if (controllers.length === 1 && handles.length === 1 && controller && handle)
|
|
18881
|
+
owners.push({ controller, scope: handle });
|
|
18882
|
+
}
|
|
18883
|
+
}
|
|
18884
|
+
const owner = owners[0];
|
|
18885
|
+
if (owners.length !== 1 || !owner) return false;
|
|
18886
|
+
await attach("controller", owner.controller);
|
|
18887
|
+
await attach("scope", owner.scope);
|
|
18888
|
+
return await install(holder);
|
|
18889
|
+
} finally {
|
|
18890
|
+
await client.command("Runtime.releaseObjectGroup", { objectGroup: group }).catch(() => void 0);
|
|
18891
|
+
}
|
|
18892
|
+
}
|
|
18893
|
+
|
|
18894
|
+
// packages/desktop-control/src/renderer-native-rpc-runtime.ts
|
|
18895
|
+
function installNativeRpcRemoteControl(components, target, dependencies) {
|
|
18896
|
+
if (target.__codexhostNativeRpcRemoteControlV1) return true;
|
|
18897
|
+
const routing = target.__codexhostHostRoutingV1;
|
|
18898
|
+
if (!routing) return false;
|
|
18899
|
+
const adapted = dependencies.createService(
|
|
18900
|
+
components,
|
|
18901
|
+
(hostId2, upstream) => dependencies.createManager(
|
|
18902
|
+
components,
|
|
18903
|
+
hostId2,
|
|
18904
|
+
upstream,
|
|
18905
|
+
target,
|
|
18906
|
+
dependencies.createPolicy,
|
|
18907
|
+
dependencies.createChannel,
|
|
18908
|
+
dependencies.retainInteractions
|
|
18909
|
+
)
|
|
18910
|
+
);
|
|
18911
|
+
const controller = components.controller;
|
|
18912
|
+
const originalHost = routing.forHost, originalComposer = routing.forComposer, originalDispose = routing.dispose;
|
|
18913
|
+
controller.dispose();
|
|
18914
|
+
let replacement;
|
|
18915
|
+
try {
|
|
18916
|
+
replacement = components.createController(components.scope, adapted.service);
|
|
18917
|
+
} catch (error51) {
|
|
18918
|
+
replacement = components.createController(
|
|
18919
|
+
components.scope,
|
|
18920
|
+
components.services.appServerManagers
|
|
18921
|
+
);
|
|
18922
|
+
throw error51;
|
|
18923
|
+
} finally {
|
|
18924
|
+
adapted.service[Symbol.dispose]();
|
|
18925
|
+
controller.forHost = (hostId2) => replacement.forHost(hostId2);
|
|
18926
|
+
controller.collectAppStateSnapshot = (hostId2, options) => replacement.collectAppStateSnapshot(hostId2, options);
|
|
18927
|
+
controller.getReviewPaneSnapshotMetrics = (hostId2) => replacement.getReviewPaneSnapshotMetrics(hostId2);
|
|
18928
|
+
controller.dispose = () => replacement.dispose();
|
|
18929
|
+
}
|
|
18930
|
+
const forHost = (hostId2) => {
|
|
18931
|
+
const route = adapted.route(hostId2);
|
|
18932
|
+
return route === void 0 ? originalHost.call(routing, hostId2) : route;
|
|
18933
|
+
};
|
|
18934
|
+
const forComposer = (composer) => {
|
|
18935
|
+
const hostId2 = routing.hostIdForComposer(composer);
|
|
18936
|
+
return hostId2 ? forHost(hostId2) : originalComposer.call(routing, composer);
|
|
18937
|
+
};
|
|
18938
|
+
routing.forHost = forHost;
|
|
18939
|
+
routing.forComposer = forComposer;
|
|
18940
|
+
const installation = {
|
|
18941
|
+
dispose() {
|
|
18942
|
+
if (target.__codexhostNativeRpcRemoteControlV1 !== installation) return;
|
|
18943
|
+
delete target.__codexhostNativeRpcRemoteControlV1;
|
|
18944
|
+
replacement.dispose();
|
|
18945
|
+
replacement = components.createController(
|
|
18946
|
+
components.scope,
|
|
18947
|
+
components.services.appServerManagers
|
|
18948
|
+
);
|
|
18949
|
+
if (routing.forHost === forHost) routing.forHost = originalHost;
|
|
18950
|
+
if (routing.forComposer === forComposer) routing.forComposer = originalComposer;
|
|
18951
|
+
routing.dispose = originalDispose;
|
|
18952
|
+
}
|
|
18953
|
+
};
|
|
18954
|
+
routing.dispose = () => {
|
|
18955
|
+
installation.dispose();
|
|
18956
|
+
originalDispose.call(routing);
|
|
18957
|
+
};
|
|
18958
|
+
target.__codexhostNativeRpcRemoteControlV1 = installation;
|
|
18959
|
+
return true;
|
|
18960
|
+
}
|
|
18961
|
+
|
|
18962
|
+
// packages/desktop-control/src/renderer-native-remote-manager.ts
|
|
18963
|
+
function createNativeRemoteManager(components, hostId2, original, target, createPolicy, createChannel, retainInteractions) {
|
|
18964
|
+
const source = components.scope.get(components.requestDefinition, hostId2);
|
|
18965
|
+
const upstream = original.dup();
|
|
18966
|
+
let manager;
|
|
18967
|
+
let policy;
|
|
18968
|
+
let interactions;
|
|
18969
|
+
let disposed = false;
|
|
18970
|
+
const pending = /* @__PURE__ */ new Set();
|
|
18971
|
+
const send = (method, params, options) => {
|
|
18972
|
+
const request = upstream.sendRequest(method, params, options);
|
|
18973
|
+
const result = Promise.resolve(request).finally(() => {
|
|
18974
|
+
request[Symbol.dispose]();
|
|
18975
|
+
pending.delete(result);
|
|
18976
|
+
});
|
|
18977
|
+
pending.add(result);
|
|
18978
|
+
return result;
|
|
18979
|
+
};
|
|
18980
|
+
const record3 = (value) => value !== null && typeof value === "object";
|
|
18981
|
+
const dispatch = (type, payload) => {
|
|
18982
|
+
if ((type === "mcp-request" || type === "thread-prewarm-start") && record3(payload) && record3(payload.request)) {
|
|
18983
|
+
const request = payload.request;
|
|
18984
|
+
const options = {};
|
|
18985
|
+
for (const key of ["priority", "timeoutMs", "source", "trace", "threadAccess"])
|
|
18986
|
+
if (payload[key] !== void 0) options[key] = payload[key];
|
|
18987
|
+
void send(String(request.method), request.params, options).then(
|
|
18988
|
+
(result) => {
|
|
18989
|
+
if (!disposed) client.onResult(request.id, result);
|
|
18990
|
+
},
|
|
18991
|
+
(error51) => {
|
|
18992
|
+
if (!disposed)
|
|
18993
|
+
client.onError(request.id, {
|
|
18994
|
+
code: record3(error51) ? error51.jsonRpcCode ?? error51.code ?? -32603 : -32603,
|
|
18995
|
+
message: error51 instanceof Error ? error51.message : String(error51)
|
|
18996
|
+
});
|
|
18997
|
+
}
|
|
18998
|
+
);
|
|
18999
|
+
return;
|
|
19000
|
+
}
|
|
19001
|
+
return source.dispatchMessage(type, payload);
|
|
19002
|
+
};
|
|
19003
|
+
const Constructor = source.constructor;
|
|
19004
|
+
let client;
|
|
19005
|
+
try {
|
|
19006
|
+
client = new Constructor(
|
|
19007
|
+
hostId2,
|
|
19008
|
+
dispatch,
|
|
19009
|
+
false,
|
|
19010
|
+
(id) => manager?.getConversation(id)?.threadAccess
|
|
19011
|
+
);
|
|
19012
|
+
client.setAppServerVersion(source.getAppServerVersion());
|
|
19013
|
+
manager = components.createManager(
|
|
19014
|
+
components.scope,
|
|
19015
|
+
hostId2,
|
|
19016
|
+
client,
|
|
19017
|
+
components.isHostForConversation.bind(null, components.scope),
|
|
19018
|
+
(get, id) => get(components.imageDefinition, id),
|
|
19019
|
+
{ dispatchMessageFromView: dispatch }
|
|
19020
|
+
);
|
|
19021
|
+
manager.dispatchAppServerResponse = manager.sendAppServerResponse;
|
|
19022
|
+
const owned = manager;
|
|
19023
|
+
const ownedPolicy = createPolicy(
|
|
19024
|
+
owned,
|
|
19025
|
+
client,
|
|
19026
|
+
hostId2,
|
|
19027
|
+
target,
|
|
19028
|
+
owned.prewarmedThreadManager,
|
|
19029
|
+
() => !disposed,
|
|
19030
|
+
void 0,
|
|
19031
|
+
void 0,
|
|
19032
|
+
(method, params) => send(method, params, { priority: "critical" })
|
|
19033
|
+
);
|
|
19034
|
+
policy = ownedPolicy;
|
|
19035
|
+
owned.sendAppServerResponse = (...args) => owned.dispatchAppServerResponse(...args);
|
|
19036
|
+
const channel = createChannel(components, owned);
|
|
19037
|
+
const nativeInteractions = retainInteractions(upstream, owned, hostId2);
|
|
19038
|
+
interactions = nativeInteractions;
|
|
19039
|
+
const notify = (event) => {
|
|
19040
|
+
const { data, source: source2, origin } = event;
|
|
19041
|
+
if (disposed || source2 != null && source2 !== target || !record3(data) || data.hostId !== hostId2)
|
|
19042
|
+
return;
|
|
19043
|
+
const ownOrigin = record3(target.location) ? target.location.origin : void 0;
|
|
19044
|
+
if (source2 === target && ownOrigin && ownOrigin !== "null" && origin !== ownOrigin) return;
|
|
19045
|
+
if (data.type === "mcp-notification" && typeof data.method === "string" && !data.method.startsWith("process/"))
|
|
19046
|
+
owned.onNotification(data.method, data.params);
|
|
19047
|
+
if (data.type === "mcp-request") owned.onRequest(record3(data.request) ? data.request : data);
|
|
19048
|
+
};
|
|
19049
|
+
target.addEventListener?.("message", notify);
|
|
19050
|
+
return {
|
|
19051
|
+
route: { hostId: hostId2, manager: owned, policy: ownedPolicy },
|
|
19052
|
+
rpc: channel.rpc,
|
|
19053
|
+
ready: nativeInteractions.ready,
|
|
19054
|
+
dispose() {
|
|
19055
|
+
if (disposed) return;
|
|
19056
|
+
disposed = true;
|
|
19057
|
+
target.removeEventListener?.("message", notify);
|
|
19058
|
+
nativeInteractions.dispose();
|
|
19059
|
+
ownedPolicy.dispose();
|
|
19060
|
+
client.queuedRequests.length = 0;
|
|
19061
|
+
for (const id of [...client.requestPromises.keys()])
|
|
19062
|
+
client.onError(id, new Error("Remote Control connection retired"));
|
|
19063
|
+
channel.dispose();
|
|
19064
|
+
components.Manager.dispose(owned);
|
|
19065
|
+
void Promise.allSettled([...pending]).then(() => upstream[Symbol.dispose]());
|
|
19066
|
+
}
|
|
19067
|
+
};
|
|
19068
|
+
} catch (error51) {
|
|
19069
|
+
interactions?.dispose();
|
|
19070
|
+
policy?.dispose();
|
|
19071
|
+
if (manager) components.Manager.dispose(manager);
|
|
19072
|
+
upstream[Symbol.dispose]();
|
|
19073
|
+
throw error51;
|
|
19074
|
+
}
|
|
19075
|
+
}
|
|
19076
|
+
|
|
19077
|
+
// packages/desktop-control/src/renderer-native-rpc-channel.ts
|
|
19078
|
+
function createNativeRpcChannel(components, manager) {
|
|
19079
|
+
const channel = new MessageChannel();
|
|
19080
|
+
const transports = [];
|
|
19081
|
+
const transport = (port) => {
|
|
19082
|
+
const values = [];
|
|
19083
|
+
const readers = [];
|
|
19084
|
+
let closed = false;
|
|
19085
|
+
let failure;
|
|
19086
|
+
port.addEventListener("message", (event) => {
|
|
19087
|
+
const value = JSON.stringify(event.data);
|
|
19088
|
+
const reader = readers.shift();
|
|
19089
|
+
if (reader) reader.resolve(value);
|
|
19090
|
+
else values.push(value);
|
|
19091
|
+
});
|
|
19092
|
+
port.start();
|
|
19093
|
+
const result = {
|
|
19094
|
+
send(message) {
|
|
19095
|
+
if (closed) throw failure;
|
|
19096
|
+
port.postMessage(JSON.parse(message));
|
|
19097
|
+
},
|
|
19098
|
+
receive() {
|
|
19099
|
+
if (closed) return Promise.reject(failure);
|
|
19100
|
+
const value = values.shift();
|
|
19101
|
+
return value !== void 0 ? Promise.resolve(value) : new Promise((resolve, reject) => readers.push({ resolve, reject }));
|
|
19102
|
+
},
|
|
19103
|
+
abort(error51) {
|
|
19104
|
+
if (closed) return;
|
|
19105
|
+
closed = true;
|
|
19106
|
+
failure = error51 ?? new Error("Remote Control RPC manager retired");
|
|
19107
|
+
values.length = 0;
|
|
19108
|
+
for (const reader of readers.splice(0)) reader.reject(failure);
|
|
19109
|
+
port.close();
|
|
19110
|
+
}
|
|
19111
|
+
};
|
|
19112
|
+
transports.push(result);
|
|
19113
|
+
return result;
|
|
19114
|
+
};
|
|
19115
|
+
try {
|
|
19116
|
+
new components.RpcSession(transport(channel.port1), new components.RpcManager(() => manager));
|
|
19117
|
+
const session = new components.RpcSession(transport(channel.port2));
|
|
19118
|
+
const rpc = session.getRemoteMain();
|
|
19119
|
+
return {
|
|
19120
|
+
rpc,
|
|
19121
|
+
dispose() {
|
|
19122
|
+
rpc[Symbol.dispose]();
|
|
19123
|
+
for (const transport2 of transports) transport2.abort();
|
|
19124
|
+
}
|
|
19125
|
+
};
|
|
19126
|
+
} catch (error51) {
|
|
19127
|
+
for (const transport2 of transports) transport2.abort(error51);
|
|
19128
|
+
channel.port1.close();
|
|
19129
|
+
channel.port2.close();
|
|
19130
|
+
throw error51;
|
|
19131
|
+
}
|
|
19132
|
+
}
|
|
19133
|
+
|
|
19134
|
+
// packages/desktop-control/src/renderer-native-rpc-service.ts
|
|
19135
|
+
function createNativeRpcService(components, createRemote) {
|
|
19136
|
+
const source = components.services.appServerManagers.dup();
|
|
19137
|
+
const routes = /* @__PURE__ */ new Map();
|
|
19138
|
+
const subscriptions = /* @__PURE__ */ new Set();
|
|
19139
|
+
let refs = 1;
|
|
19140
|
+
const record3 = (value) => value !== null && typeof value === "object";
|
|
19141
|
+
const connectionSignals = (hostId2) => {
|
|
19142
|
+
let node = components.scope.node;
|
|
19143
|
+
const seen = /* @__PURE__ */ new Set();
|
|
19144
|
+
while (node.parent && !seen.has(node.parent) && seen.size < 100) {
|
|
19145
|
+
seen.add(node);
|
|
19146
|
+
node = node.parent;
|
|
19147
|
+
}
|
|
19148
|
+
const found = [];
|
|
19149
|
+
for (const members of node.familyBindings.values()) {
|
|
19150
|
+
const value = members.get(hostId2)?.value;
|
|
19151
|
+
if (record3(value) && Object.hasOwn(value, "state$") && Object.hasOwn(value, "revision$") && Object.hasOwn(value, "appServerVersion$"))
|
|
19152
|
+
found.push({ state$: value.state$, revision$: value.revision$ });
|
|
19153
|
+
}
|
|
19154
|
+
return found.length === 1 ? found[0] : void 0;
|
|
19155
|
+
};
|
|
19156
|
+
const service = {
|
|
19157
|
+
dup() {
|
|
19158
|
+
refs++;
|
|
19159
|
+
return service;
|
|
19160
|
+
},
|
|
19161
|
+
onRpcBroken(listener) {
|
|
19162
|
+
source.onRpcBroken(listener);
|
|
19163
|
+
},
|
|
19164
|
+
openAccount(hostId2) {
|
|
19165
|
+
return source.openAccount(hostId2);
|
|
19166
|
+
},
|
|
19167
|
+
subscribe(hostId2, listener) {
|
|
19168
|
+
if (!hostId2.startsWith("remote-control:")) return source.subscribe(hostId2, listener);
|
|
19169
|
+
let active = true;
|
|
19170
|
+
let generation = 0;
|
|
19171
|
+
let upstream;
|
|
19172
|
+
let platformRequest;
|
|
19173
|
+
let remote;
|
|
19174
|
+
let stopWatch;
|
|
19175
|
+
let previousRevision;
|
|
19176
|
+
let previousState;
|
|
19177
|
+
const retire = () => {
|
|
19178
|
+
generation++;
|
|
19179
|
+
platformRequest?.[Symbol.dispose]();
|
|
19180
|
+
platformRequest = void 0;
|
|
19181
|
+
remote?.dispose();
|
|
19182
|
+
remote = void 0;
|
|
19183
|
+
routes.set(hostId2, null);
|
|
19184
|
+
};
|
|
19185
|
+
const cleanup = () => {
|
|
19186
|
+
if (!active) return;
|
|
19187
|
+
active = false;
|
|
19188
|
+
stopWatch?.();
|
|
19189
|
+
retire();
|
|
19190
|
+
upstream?.[Symbol.dispose]();
|
|
19191
|
+
upstream = void 0;
|
|
19192
|
+
routes.delete(hostId2);
|
|
19193
|
+
subscriptions.delete(cleanup);
|
|
19194
|
+
};
|
|
19195
|
+
subscriptions.add(cleanup);
|
|
19196
|
+
const publish = async () => {
|
|
19197
|
+
const owner = upstream;
|
|
19198
|
+
const current = generation;
|
|
19199
|
+
if (!owner || !active) return;
|
|
19200
|
+
let request;
|
|
19201
|
+
try {
|
|
19202
|
+
request = owner.getCodexHome();
|
|
19203
|
+
platformRequest = request;
|
|
19204
|
+
const home = await request;
|
|
19205
|
+
if (!active || current !== generation || owner !== upstream) return;
|
|
19206
|
+
if (!/^(?:[A-Za-z]:[\\/]|\\\\)/u.test(home)) {
|
|
19207
|
+
routes.delete(hostId2);
|
|
19208
|
+
listener({ status: "ready", manager: owner });
|
|
19209
|
+
return;
|
|
19210
|
+
}
|
|
19211
|
+
const created = createRemote(hostId2, owner);
|
|
19212
|
+
remote = created;
|
|
19213
|
+
await created.ready;
|
|
19214
|
+
if (!active || current !== generation || owner !== upstream) return;
|
|
19215
|
+
routes.set(hostId2, created.route);
|
|
19216
|
+
listener({ status: "ready", manager: created.rpc });
|
|
19217
|
+
} catch {
|
|
19218
|
+
if (active && current === generation) {
|
|
19219
|
+
remote?.dispose();
|
|
19220
|
+
remote = void 0;
|
|
19221
|
+
routes.delete(hostId2);
|
|
19222
|
+
listener({ status: "ready", manager: owner });
|
|
19223
|
+
}
|
|
19224
|
+
} finally {
|
|
19225
|
+
if (platformRequest === request) {
|
|
19226
|
+
platformRequest = void 0;
|
|
19227
|
+
request?.[Symbol.dispose]();
|
|
19228
|
+
}
|
|
19229
|
+
}
|
|
19230
|
+
};
|
|
19231
|
+
const changed = (state) => {
|
|
19232
|
+
if (!active) return;
|
|
19233
|
+
stopWatch?.();
|
|
19234
|
+
stopWatch = void 0;
|
|
19235
|
+
retire();
|
|
19236
|
+
upstream?.[Symbol.dispose]();
|
|
19237
|
+
upstream = void 0;
|
|
19238
|
+
if (state.status !== "ready") {
|
|
19239
|
+
listener(state);
|
|
19240
|
+
return;
|
|
19241
|
+
}
|
|
19242
|
+
upstream = state.manager.dup();
|
|
19243
|
+
listener({ status: "connecting" });
|
|
19244
|
+
const signals = connectionSignals(hostId2);
|
|
19245
|
+
if (!signals) {
|
|
19246
|
+
void publish();
|
|
19247
|
+
return;
|
|
19248
|
+
}
|
|
19249
|
+
previousState = void 0;
|
|
19250
|
+
previousRevision = void 0;
|
|
19251
|
+
stopWatch = components.scope.watch(({ get }) => {
|
|
19252
|
+
const connection = get(signals.state$), revision = get(signals.revision$);
|
|
19253
|
+
if (connection === previousState && revision === previousRevision) return;
|
|
19254
|
+
previousState = connection;
|
|
19255
|
+
previousRevision = revision;
|
|
19256
|
+
retire();
|
|
19257
|
+
listener({ status: connection === "connected" ? "connecting" : "disconnected" });
|
|
19258
|
+
if (connection === "connected") void publish();
|
|
19259
|
+
});
|
|
19260
|
+
};
|
|
19261
|
+
const original = source.subscribe(hostId2, changed);
|
|
19262
|
+
const result = original.then((lease) => {
|
|
19263
|
+
if (!active) lease[Symbol.dispose]();
|
|
19264
|
+
return {
|
|
19265
|
+
onRpcBroken: (listener2) => lease.onRpcBroken(listener2),
|
|
19266
|
+
[Symbol.dispose]() {
|
|
19267
|
+
cleanup();
|
|
19268
|
+
lease[Symbol.dispose]();
|
|
19269
|
+
}
|
|
19270
|
+
};
|
|
19271
|
+
});
|
|
19272
|
+
Object.assign(result, {
|
|
19273
|
+
onRpcBroken: (listener2) => original.onRpcBroken(listener2),
|
|
19274
|
+
[Symbol.dispose]() {
|
|
19275
|
+
cleanup();
|
|
19276
|
+
original[Symbol.dispose]();
|
|
19277
|
+
}
|
|
19278
|
+
});
|
|
19279
|
+
return result;
|
|
19280
|
+
},
|
|
19281
|
+
[Symbol.dispose]() {
|
|
19282
|
+
if (--refs !== 0) return;
|
|
19283
|
+
for (const cleanup of [...subscriptions]) cleanup();
|
|
19284
|
+
source[Symbol.dispose]();
|
|
19285
|
+
}
|
|
19286
|
+
};
|
|
19287
|
+
return { service, route: (hostId2) => routes.get(hostId2) };
|
|
19288
|
+
}
|
|
19289
|
+
|
|
19290
|
+
// packages/desktop-control/src/renderer-native-rpc-interactions.ts
|
|
19291
|
+
function retainNativeRpcInteractions(upstream, manager, hostId2) {
|
|
19292
|
+
let disposed = false;
|
|
19293
|
+
const retained = /* @__PURE__ */ new Set();
|
|
19294
|
+
const requests = /* @__PURE__ */ new Map();
|
|
19295
|
+
const reads = /* @__PURE__ */ new Map();
|
|
19296
|
+
const record3 = (value) => value !== null && typeof value === "object";
|
|
19297
|
+
const read = (threadId) => {
|
|
19298
|
+
const existing = reads.get(threadId);
|
|
19299
|
+
if (existing) {
|
|
19300
|
+
existing.dirty = true;
|
|
19301
|
+
return existing.promise;
|
|
19302
|
+
}
|
|
19303
|
+
const entry = { promise: Promise.resolve(), dirty: false };
|
|
19304
|
+
reads.set(threadId, entry);
|
|
19305
|
+
entry.promise = Promise.resolve().then(async () => {
|
|
19306
|
+
do {
|
|
19307
|
+
if (disposed) break;
|
|
19308
|
+
entry.dirty = false;
|
|
19309
|
+
const pending = upstream.getConversation(threadId);
|
|
19310
|
+
retained.add(pending);
|
|
19311
|
+
try {
|
|
19312
|
+
const conversation = await pending;
|
|
19313
|
+
if (disposed || entry.dirty || !record3(conversation) || !Array.isArray(conversation.requests))
|
|
19314
|
+
continue;
|
|
19315
|
+
const previous = requests.get(threadId) ?? /* @__PURE__ */ new Set();
|
|
19316
|
+
const next = /* @__PURE__ */ new Set();
|
|
19317
|
+
for (const request of conversation.requests) {
|
|
19318
|
+
if (!record3(request) || typeof request.method !== "string" || !record3(request.params) || (request.params.threadId ?? request.params.conversationId) !== threadId || typeof request.id !== "string" && typeof request.id !== "number")
|
|
19319
|
+
continue;
|
|
19320
|
+
next.add(request.id);
|
|
19321
|
+
if (!previous.has(request.id)) manager.onRequest(request);
|
|
19322
|
+
}
|
|
19323
|
+
if (next.size) requests.set(threadId, next);
|
|
19324
|
+
else requests.delete(threadId);
|
|
19325
|
+
} finally {
|
|
19326
|
+
if (retained.delete(pending)) pending[Symbol.dispose]();
|
|
19327
|
+
}
|
|
19328
|
+
} while (!disposed && entry.dirty);
|
|
19329
|
+
}).finally(() => {
|
|
19330
|
+
reads.delete(threadId);
|
|
19331
|
+
});
|
|
19332
|
+
return entry.promise;
|
|
19333
|
+
};
|
|
19334
|
+
const event = (value) => {
|
|
19335
|
+
if (disposed || !record3(value) || typeof value.conversationId !== "string") return;
|
|
19336
|
+
void read(value.conversationId).catch(() => void 0);
|
|
19337
|
+
};
|
|
19338
|
+
const subscribe = (input) => {
|
|
19339
|
+
const pending = upstream.subscribe(input);
|
|
19340
|
+
retained.add(pending);
|
|
19341
|
+
return Promise.resolve(pending).then((lease) => {
|
|
19342
|
+
if (disposed) lease[Symbol.dispose]();
|
|
19343
|
+
else retained.add(lease);
|
|
19344
|
+
});
|
|
19345
|
+
};
|
|
19346
|
+
const subscriptions = [
|
|
19347
|
+
"approval-request",
|
|
19348
|
+
"user-input-request",
|
|
19349
|
+
"mcp-elicitation-request",
|
|
19350
|
+
"approval-resolved"
|
|
19351
|
+
].map((name) => subscribe({ type: "event", key: { hostId: hostId2 }, event: name, listener: event }));
|
|
19352
|
+
subscriptions.push(
|
|
19353
|
+
subscribe({
|
|
19354
|
+
type: "notification",
|
|
19355
|
+
key: { hostId: hostId2 },
|
|
19356
|
+
methods: ["serverRequest/resolved"],
|
|
19357
|
+
listener(value) {
|
|
19358
|
+
if (record3(value) && record3(value.params) && typeof value.params.threadId === "string")
|
|
19359
|
+
event({ conversationId: value.params.threadId });
|
|
19360
|
+
}
|
|
19361
|
+
})
|
|
19362
|
+
);
|
|
19363
|
+
const ready = Promise.all(subscriptions).then(async () => {
|
|
19364
|
+
if (disposed) return;
|
|
19365
|
+
const pending = upstream.getWorkInProgress();
|
|
19366
|
+
retained.add(pending);
|
|
19367
|
+
try {
|
|
19368
|
+
const work = await pending;
|
|
19369
|
+
if (disposed) return;
|
|
19370
|
+
if (!Array.isArray(work)) throw new Error("Native RPC interaction snapshot is unavailable");
|
|
19371
|
+
const threadIds = new Set(
|
|
19372
|
+
work.flatMap(
|
|
19373
|
+
(item) => record3(item) && typeof item.conversationId === "string" ? [item.conversationId] : []
|
|
19374
|
+
)
|
|
19375
|
+
);
|
|
19376
|
+
await Promise.all([...threadIds].map(read));
|
|
19377
|
+
} finally {
|
|
19378
|
+
if (retained.delete(pending)) pending[Symbol.dispose]();
|
|
19379
|
+
}
|
|
19380
|
+
});
|
|
19381
|
+
return {
|
|
19382
|
+
ready,
|
|
19383
|
+
dispose() {
|
|
19384
|
+
if (disposed) return;
|
|
19385
|
+
disposed = true;
|
|
19386
|
+
for (const lease of retained) lease[Symbol.dispose]();
|
|
19387
|
+
retained.clear();
|
|
19388
|
+
requests.clear();
|
|
19389
|
+
}
|
|
19390
|
+
};
|
|
19391
|
+
}
|
|
19392
|
+
|
|
19393
|
+
// packages/desktop-control/src/renderer-native-rpc-install.ts
|
|
19394
|
+
async function installNativeRpcRemoteControlDirect(renderer) {
|
|
19395
|
+
let attempt;
|
|
19396
|
+
const probeId = crypto.randomUUID();
|
|
19397
|
+
try {
|
|
19398
|
+
attempt = await renderer.evaluate(`(() => {
|
|
19399
|
+
if (window.__codexhostNativeRpcRemoteControlV1) return null;
|
|
19400
|
+
const routing = window.__codexhostHostRoutingV1;
|
|
19401
|
+
const owner = routing?.forHost('local')?.manager;
|
|
19402
|
+
if (owner?.kind !== 'main-process-rpc') return null;
|
|
19403
|
+
const catalog = window.__codexhostLoadedModulesV1;
|
|
19404
|
+
if (!catalog?.complete) return null;
|
|
19405
|
+
const key = JSON.stringify([catalog.owner, catalog.urls.filter(url => /renderer-app-server-managers|app-shared/.test(url)).sort()]);
|
|
19406
|
+
const previous = window.__codexhostNativeRpcDiscoveryV1;
|
|
19407
|
+
const sameOwner = previous?.key === key && previous.owner === owner;
|
|
19408
|
+
if (sameOwner && (previous.state !== 'unavailable' || previous.attempts >= 3 || Date.now() < previous.nextRetryAt)) return null;
|
|
19409
|
+
const token = ${JSON.stringify(probeId)};
|
|
19410
|
+
window.__codexhostNativeRpcDiscoveryV1 = {
|
|
19411
|
+
key, owner, token, state: 'discovering', attempts: sameOwner ? previous.attempts + 1 : 1,
|
|
19412
|
+
};
|
|
19413
|
+
return token;
|
|
19414
|
+
})()`);
|
|
19415
|
+
} catch {
|
|
19416
|
+
return false;
|
|
19417
|
+
}
|
|
19418
|
+
if (attempt === null) return false;
|
|
19419
|
+
let installed = false;
|
|
19420
|
+
try {
|
|
19421
|
+
installed = await withNativeRpcComponents(renderer, async (objectId) => {
|
|
19422
|
+
const result = await renderer.command("Runtime.callFunctionOn", {
|
|
19423
|
+
objectId,
|
|
19424
|
+
functionDeclaration: `function() {
|
|
19425
|
+
if (this.document !== document) return false;
|
|
19426
|
+
const retainRendererHostResponses = ${retainRendererHostResponses.toString()};
|
|
19427
|
+
const isolateRendererPrewarmConsumption = ${isolateRendererPrewarmConsumption.toString()};
|
|
19428
|
+
return (${installNativeRpcRemoteControl.toString()})(this, window, {
|
|
19429
|
+
createPolicy: ${createDraftPrewarmPolicyBridge.toString()},
|
|
19430
|
+
createManager: ${createNativeRemoteManager.toString()},
|
|
19431
|
+
createChannel: ${createNativeRpcChannel.toString()},
|
|
19432
|
+
createService: ${createNativeRpcService.toString()},
|
|
19433
|
+
retainInteractions: ${retainNativeRpcInteractions.toString()},
|
|
19434
|
+
});
|
|
19435
|
+
}`,
|
|
19436
|
+
returnByValue: true
|
|
19437
|
+
});
|
|
19438
|
+
return !result.exceptionDetails && result.result?.value === true;
|
|
19439
|
+
});
|
|
19440
|
+
return installed;
|
|
19441
|
+
} catch {
|
|
19442
|
+
return false;
|
|
19443
|
+
} finally {
|
|
19444
|
+
await renderer.evaluate(
|
|
19445
|
+
`(() => {
|
|
19446
|
+
const status = window.__codexhostNativeRpcDiscoveryV1;
|
|
19447
|
+
if (status?.token === ${JSON.stringify(attempt)}) {
|
|
19448
|
+
status.state = ${JSON.stringify(installed ? "ready" : "unavailable")};
|
|
19449
|
+
status.nextRetryAt = Date.now() + 5000 * 2 ** (status.attempts - 1);
|
|
19450
|
+
}
|
|
19451
|
+
})()`
|
|
19452
|
+
).catch(() => void 0);
|
|
19453
|
+
}
|
|
19454
|
+
}
|
|
19455
|
+
|
|
19456
|
+
// packages/desktop-control/src/renderer-rpc-steering.ts
|
|
19457
|
+
var RETRY_BASE_MS = 5e3;
|
|
19458
|
+
var RETRY_MAX_MS = 3e5;
|
|
19459
|
+
var retries = /* @__PURE__ */ new WeakMap();
|
|
19460
|
+
async function installRendererRpcSteeringDirect(client, now = Date.now) {
|
|
19461
|
+
try {
|
|
19462
|
+
const needed = await client.evaluate(`(() => {
|
|
19463
|
+
const steering = window.__codexhostRpcSteeringV1;
|
|
19464
|
+
if (steering && steering.controller.forHost === steering.forHost) return false;
|
|
19465
|
+
steering?.release();
|
|
19466
|
+
const routing=window.__codexhostHostRoutingV1;
|
|
19467
|
+
return ['local', ...(routing?.knownHostIds?.() ?? [])].some(id => routing?.forHost(id)?.manager.kind === 'main-process-rpc');
|
|
19468
|
+
})()`);
|
|
19469
|
+
if (!needed) return false;
|
|
19470
|
+
const retry = retries.get(client);
|
|
19471
|
+
if (retry && now() < retry.nextAt) return false;
|
|
19472
|
+
try {
|
|
19473
|
+
await discoverAndInstall(client);
|
|
19474
|
+
retries.delete(client);
|
|
19475
|
+
return true;
|
|
19476
|
+
} catch (error51) {
|
|
19477
|
+
const attempts = (retry?.attempts ?? 0) + 1;
|
|
19478
|
+
const delay = Math.min(RETRY_BASE_MS * 2 ** (attempts - 1), RETRY_MAX_MS);
|
|
19479
|
+
retries.set(client, { attempts, nextAt: now() + delay });
|
|
19480
|
+
console.error(
|
|
19481
|
+
`codexhost native steering discovery failed (attempt ${attempts}):`,
|
|
19482
|
+
error51 instanceof Error ? error51.message : String(error51)
|
|
19483
|
+
);
|
|
19484
|
+
return false;
|
|
19485
|
+
}
|
|
19486
|
+
} catch {
|
|
19487
|
+
return false;
|
|
19488
|
+
}
|
|
19489
|
+
}
|
|
19490
|
+
async function discoverAndInstall(client) {
|
|
19491
|
+
const group = `codexhost-rpc-steering-${crypto.randomUUID()}`;
|
|
19492
|
+
const command = (method, params) => client.command(method, params);
|
|
19493
|
+
const properties = (objectId) => command("Runtime.getProperties", { objectId, ownProperties: true });
|
|
19494
|
+
const call = (objectId, functionDeclaration, args = []) => command("Runtime.callFunctionOn", {
|
|
19495
|
+
objectId,
|
|
19496
|
+
functionDeclaration,
|
|
19497
|
+
arguments: args,
|
|
19498
|
+
objectGroup: group,
|
|
19499
|
+
returnByValue: true
|
|
19500
|
+
});
|
|
19501
|
+
try {
|
|
19502
|
+
const proto = await command("Runtime.evaluate", {
|
|
19503
|
+
expression: "Object.getPrototypeOf(async function(){})",
|
|
19504
|
+
objectGroup: group
|
|
19505
|
+
});
|
|
19506
|
+
if (!proto.result.objectId) throw new Error("Native RPC steering discovery is unavailable");
|
|
19507
|
+
const objects = await command("Runtime.queryObjects", {
|
|
19508
|
+
prototypeObjectId: proto.result.objectId,
|
|
19509
|
+
objectGroup: group
|
|
19510
|
+
});
|
|
19511
|
+
if (!objects.objects.objectId) throw new Error("Native RPC steering discovery is unavailable");
|
|
19512
|
+
const filtered = await command("Runtime.callFunctionOn", {
|
|
19513
|
+
objectId: objects.objects.objectId,
|
|
19514
|
+
functionDeclaration: 'function(){return this.filter(fn=>fn.name==="collectAppStateSnapshot"&&String(fn).includes("collectSnapshot")).slice(0,9)}',
|
|
19515
|
+
objectGroup: group
|
|
19516
|
+
});
|
|
19517
|
+
if (!filtered.result.objectId) throw new Error("Native RPC Controller is unavailable");
|
|
19518
|
+
const snapshots = (await properties(filtered.result.objectId)).result.flatMap(
|
|
19519
|
+
(entry) => entry.value?.type === "function" && entry.value.objectId ? [entry.value.objectId] : []
|
|
19520
|
+
);
|
|
19521
|
+
if (snapshots.length > 8) throw new Error("Native RPC Controller is ambiguous");
|
|
19522
|
+
const controllers = [];
|
|
19523
|
+
for (const snapshot of snapshots) {
|
|
19524
|
+
const scopes = (await properties(snapshot)).internalProperties?.find(
|
|
19525
|
+
(entry) => entry.name === "[[Scopes]]"
|
|
19526
|
+
)?.value?.objectId;
|
|
19527
|
+
if (!scopes) continue;
|
|
19528
|
+
for (const scope of (await properties(scopes)).result) {
|
|
19529
|
+
if (!scope.value?.objectId || !scope.value.description?.startsWith("Closure")) continue;
|
|
19530
|
+
const bindings = (await properties(scope.value.objectId)).result;
|
|
19531
|
+
const owners = [];
|
|
19532
|
+
let rootScope;
|
|
19533
|
+
for (const binding of bindings) {
|
|
19534
|
+
if (binding.value?.type !== "object" || !binding.value.objectId) continue;
|
|
19535
|
+
const id = binding.value.objectId;
|
|
19536
|
+
const result2 = await call(
|
|
19537
|
+
id,
|
|
19538
|
+
`function(){return (${nativeRpcObjectShape.toString()})(this)}`
|
|
19539
|
+
);
|
|
19540
|
+
const shape = result2.result.value;
|
|
19541
|
+
if (shape?.scope) rootScope = id;
|
|
19542
|
+
if (shape?.controller && (await call(id, "function(fn){return this.collectAppStateSnapshot===fn}", [
|
|
19543
|
+
{ objectId: snapshot }
|
|
19544
|
+
])).result.value === true)
|
|
19545
|
+
owners.push(id);
|
|
19546
|
+
}
|
|
19547
|
+
if (owners.length !== 1 || !rootScope) continue;
|
|
19548
|
+
const root = await call(
|
|
19549
|
+
rootScope,
|
|
19550
|
+
`function(){let node=this.node;const seen=new Set();while(node?.parent&&!seen.has(node.parent)&&seen.size<100){seen.add(node);node=node.parent}return (${findRendererAppScopeStore.toString()})(document)===node}`
|
|
19551
|
+
);
|
|
19552
|
+
if (root.result.value === true) controllers.push(owners[0]);
|
|
19553
|
+
}
|
|
19554
|
+
}
|
|
19555
|
+
if (controllers.length !== 1) throw new Error("Native RPC Controller is missing or ambiguous");
|
|
19556
|
+
const result = await call(
|
|
19557
|
+
controllers[0],
|
|
19558
|
+
"function(){return window.__codexhostInstallRpcSteeringV1?.(this) === true}"
|
|
19559
|
+
);
|
|
19560
|
+
if (result.exceptionDetails || result.result.value !== true)
|
|
19561
|
+
throw new Error("Native RPC steering installation failed");
|
|
19562
|
+
} finally {
|
|
19563
|
+
await client.command("Runtime.releaseObjectGroup", { objectGroup: group }).catch(() => void 0);
|
|
19564
|
+
}
|
|
19565
|
+
}
|
|
19566
|
+
|
|
18493
19567
|
// packages/desktop-control/src/renderer-cdp-control-session.ts
|
|
18494
19568
|
function isRecord2(value) {
|
|
18495
19569
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -18697,6 +19771,45 @@ function isLocalThreadRenderer(target) {
|
|
|
18697
19771
|
const route = url2.searchParams.get("initialRoute");
|
|
18698
19772
|
return [...url2.searchParams.keys()].length === 1 && (route === "/local" || route?.startsWith("/local/") === true);
|
|
18699
19773
|
}
|
|
19774
|
+
function isBrowserPage(target) {
|
|
19775
|
+
if (target.type !== "page") return false;
|
|
19776
|
+
try {
|
|
19777
|
+
return ["http:", "https:"].includes(new URL(target.url).protocol);
|
|
19778
|
+
} catch {
|
|
19779
|
+
return false;
|
|
19780
|
+
}
|
|
19781
|
+
}
|
|
19782
|
+
async function installBrowserAnnotationStyles(target, browserClients, operations, signal) {
|
|
19783
|
+
const timeoutMessage = "Browser annotation style compatibility installation timed out";
|
|
19784
|
+
const run = (operation) => runWithCdpSignal(signal, timeoutMessage, operation);
|
|
19785
|
+
let renderer = browserClients.get(target.id);
|
|
19786
|
+
const registered = renderer !== void 0;
|
|
19787
|
+
renderer ??= await connectRendererTarget(target, operations, signal, timeoutMessage);
|
|
19788
|
+
const connected = renderer;
|
|
19789
|
+
try {
|
|
19790
|
+
if (!registered) {
|
|
19791
|
+
await run(() => connected.command("Page.enable"));
|
|
19792
|
+
await run(
|
|
19793
|
+
() => connected.command("Page.addScriptToEvaluateOnNewDocument", {
|
|
19794
|
+
source: BROWSER_ANNOTATION_STYLE_COMPAT_SOURCE
|
|
19795
|
+
})
|
|
19796
|
+
);
|
|
19797
|
+
browserClients.set(target.id, connected);
|
|
19798
|
+
}
|
|
19799
|
+
const installed = await run(
|
|
19800
|
+
() => connected.evaluate(
|
|
19801
|
+
"globalThis.__codexhostBrowserAnnotationStylesV1?.refresh() === true"
|
|
19802
|
+
)
|
|
19803
|
+
);
|
|
19804
|
+
if (installed !== true) {
|
|
19805
|
+
await run(() => evaluateSource(connected, BROWSER_ANNOTATION_STYLE_COMPAT_SOURCE));
|
|
19806
|
+
}
|
|
19807
|
+
} catch (error51) {
|
|
19808
|
+
browserClients.delete(target.id);
|
|
19809
|
+
connected.close();
|
|
19810
|
+
throw error51;
|
|
19811
|
+
}
|
|
19812
|
+
}
|
|
18700
19813
|
async function installLocalThreadRenderer(target, source, enabledAgents, operations, signal) {
|
|
18701
19814
|
const timeoutMessage = "Local chat Renderer installation timed out";
|
|
18702
19815
|
const run = (operation) => runWithCdpSignal(signal, timeoutMessage, operation);
|
|
@@ -18714,14 +19827,24 @@ async function installLocalThreadRenderer(target, source, enabledAgents, operati
|
|
|
18714
19827
|
renderer.close();
|
|
18715
19828
|
}
|
|
18716
19829
|
}
|
|
18717
|
-
async function installAuxiliaryRenderers(endpoint, rendererSource, enabledAgents, overlayHookSource, operations, signal) {
|
|
19830
|
+
async function installAuxiliaryRenderers(endpoint, rendererSource, enabledAgents, overlayHookSource, browserStyleClients, operations, signal) {
|
|
18718
19831
|
try {
|
|
18719
19832
|
const targets = await awaitWithSignal(
|
|
18720
19833
|
operations.listTargets(endpoint, signal),
|
|
18721
19834
|
signal,
|
|
18722
19835
|
"Auxiliary Renderer CDP target discovery timed out"
|
|
18723
19836
|
);
|
|
19837
|
+
const liveTargets = new Set(targets.map((target) => target.id));
|
|
19838
|
+
for (const [id, client] of browserStyleClients) {
|
|
19839
|
+
if (!liveTargets.has(id)) {
|
|
19840
|
+
client.close();
|
|
19841
|
+
browserStyleClients.delete(id);
|
|
19842
|
+
}
|
|
19843
|
+
}
|
|
18724
19844
|
await Promise.allSettled([
|
|
19845
|
+
...targets.filter(isBrowserPage).map(
|
|
19846
|
+
(target) => installBrowserAnnotationStyles(target, browserStyleClients, operations, signal)
|
|
19847
|
+
),
|
|
18725
19848
|
...overlayHookSource ? selectAvatarOverlayRendererTargets(targets).map(
|
|
18726
19849
|
(overlay) => installOverlayHook(overlay, overlayHookSource, operations, signal)
|
|
18727
19850
|
) : [],
|
|
@@ -18750,11 +19873,12 @@ async function installTarget(target, rendererSource, enabledAgents, timeoutMs, p
|
|
|
18750
19873
|
}
|
|
18751
19874
|
}
|
|
18752
19875
|
var InstalledRendererCdpControlSession = class {
|
|
18753
|
-
constructor(renderer, rendererCdpEndpoint2, rendererSource, overlayHookSource, enabledAgents, timeoutMs, pollIntervalMs, operations, currentSnapshot, disposeModules) {
|
|
19876
|
+
constructor(renderer, rendererCdpEndpoint2, rendererSource, overlayHookSource, browserStyleClients, enabledAgents, timeoutMs, pollIntervalMs, operations, currentSnapshot, disposeModules) {
|
|
18754
19877
|
this.renderer = renderer;
|
|
18755
19878
|
this.rendererCdpEndpoint = rendererCdpEndpoint2;
|
|
18756
19879
|
this.rendererSource = rendererSource;
|
|
18757
19880
|
this.overlayHookSource = overlayHookSource;
|
|
19881
|
+
this.browserStyleClients = browserStyleClients;
|
|
18758
19882
|
this.enabledAgents = enabledAgents;
|
|
18759
19883
|
this.timeoutMs = timeoutMs;
|
|
18760
19884
|
this.pollIntervalMs = pollIntervalMs;
|
|
@@ -18766,6 +19890,7 @@ var InstalledRendererCdpControlSession = class {
|
|
|
18766
19890
|
rendererCdpEndpoint;
|
|
18767
19891
|
rendererSource;
|
|
18768
19892
|
overlayHookSource;
|
|
19893
|
+
browserStyleClients;
|
|
18769
19894
|
enabledAgents;
|
|
18770
19895
|
timeoutMs;
|
|
18771
19896
|
pollIntervalMs;
|
|
@@ -18832,6 +19957,7 @@ var InstalledRendererCdpControlSession = class {
|
|
|
18832
19957
|
this.rendererSource,
|
|
18833
19958
|
this.enabledAgents,
|
|
18834
19959
|
this.overlayHookSource,
|
|
19960
|
+
this.browserStyleClients,
|
|
18835
19961
|
this.operations,
|
|
18836
19962
|
discoveryTimeoutSignal(this.timeoutMs)
|
|
18837
19963
|
);
|
|
@@ -18851,12 +19977,19 @@ var InstalledRendererCdpControlSession = class {
|
|
|
18851
19977
|
this.#closed = true;
|
|
18852
19978
|
this.disposeModules();
|
|
18853
19979
|
this.renderer.close();
|
|
19980
|
+
for (const client of this.browserStyleClients.values()) client.close();
|
|
19981
|
+
this.browserStyleClients.clear();
|
|
18854
19982
|
}
|
|
18855
19983
|
};
|
|
18856
19984
|
var defaultOperations = {
|
|
18857
19985
|
listTargets: (endpoint, signal) => listCdpTargets(endpoint, fetch, signal),
|
|
18858
19986
|
connect: (webSocketDebuggerUrl) => CdpClient.connect(webSocketDebuggerUrl),
|
|
18859
|
-
installDraftPrewarmPolicy
|
|
19987
|
+
async installDraftPrewarmPolicy(renderer) {
|
|
19988
|
+
const status = await installRendererDraftPrewarmPolicyDirect(renderer);
|
|
19989
|
+
await installNativeRpcRemoteControlDirect(renderer);
|
|
19990
|
+
await installRendererRpcSteeringDirect(renderer);
|
|
19991
|
+
return status;
|
|
19992
|
+
}
|
|
18860
19993
|
};
|
|
18861
19994
|
async function createRendererCdpControlSession(options) {
|
|
18862
19995
|
const enabledAgents = options.enabledAgents;
|
|
@@ -18879,11 +20012,13 @@ async function createRendererCdpControlSession(options) {
|
|
|
18879
20012
|
pollIntervalMs,
|
|
18880
20013
|
operations
|
|
18881
20014
|
);
|
|
20015
|
+
const browserStyleClients = /* @__PURE__ */ new Map();
|
|
18882
20016
|
await installAuxiliaryRenderers(
|
|
18883
20017
|
options.rendererCdpEndpoint,
|
|
18884
20018
|
options.rendererSource,
|
|
18885
20019
|
enabledAgents,
|
|
18886
20020
|
options.overlayHookSource,
|
|
20021
|
+
browserStyleClients,
|
|
18887
20022
|
operations,
|
|
18888
20023
|
discoveryTimeoutSignal(timeoutMs, options.signal)
|
|
18889
20024
|
);
|
|
@@ -18892,6 +20027,7 @@ async function createRendererCdpControlSession(options) {
|
|
|
18892
20027
|
options.rendererCdpEndpoint,
|
|
18893
20028
|
options.rendererSource,
|
|
18894
20029
|
options.overlayHookSource,
|
|
20030
|
+
browserStyleClients,
|
|
18895
20031
|
enabledAgents,
|
|
18896
20032
|
timeoutMs,
|
|
18897
20033
|
pollIntervalMs,
|