@karlorz/codexhost-cli-win32-x64 0.17.0-1 → 0.17.1-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-web.js +1 -1
- package/app/cpa-live-voice-hook.js +1 -1
- package/app/desktop-controller.mjs +910 -38
- package/app/host-runtime.mjs +911 -41
- package/app/plugins/antigravity/plugin.mjs +27 -7
- package/app/plugins/cursor-cli/plugin.mjs +19 -3
- package/app/plugins/kimi-code/plugin.mjs +50 -3
- package/app/plugins/pi/plugin.mjs +208 -88
- package/app/plugins/zcode/plugin.mjs +142 -9
- package/app/renderer-extension.js +1 -1
- 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
package/app/host-runtime.mjs
CHANGED
|
@@ -29312,9 +29312,10 @@ function isolateRendererPrewarmConsumption(manager, discardExternal) {
|
|
|
29312
29312
|
}
|
|
29313
29313
|
|
|
29314
29314
|
// packages/desktop-control/dist/renderer-draft-prewarm-runtime.js
|
|
29315
|
-
function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewarmedThreadManager, isCurrentManager, retainResponses = retainRendererHostResponses, isolateConsumption = isolateRendererPrewarmConsumption) {
|
|
29315
|
+
function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewarmedThreadManager, isCurrentManager, retainResponses = retainRendererHostResponses, isolateConsumption = isolateRendererPrewarmConsumption, sendControlRequest) {
|
|
29316
29316
|
let disposed = false;
|
|
29317
29317
|
const originalSend = bridge.sendRequest;
|
|
29318
|
+
const controlSend = (method, parameters) => sendControlRequest ? sendControlRequest(method, parameters) : originalSend.call(bridge, method, parameters);
|
|
29318
29319
|
const originalPrewarm = bridge.prewarmThreadStart;
|
|
29319
29320
|
const originalOnNotification = manager.onNotification;
|
|
29320
29321
|
const originalDispatchAppServerResponse = manager.dispatchAppServerResponse;
|
|
@@ -29400,7 +29401,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
|
|
|
29400
29401
|
bridge.onError(requestId2, error51);
|
|
29401
29402
|
bridgeRequests.clear();
|
|
29402
29403
|
if (isRemoteControlHost && terminate) {
|
|
29403
|
-
void Promise.resolve(
|
|
29404
|
+
void Promise.resolve(controlSend("process/kill", { processHandle: failedProcessHandle })).catch(() => void 0);
|
|
29404
29405
|
}
|
|
29405
29406
|
};
|
|
29406
29407
|
const resetFailedBridge = () => {
|
|
@@ -29563,7 +29564,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
|
|
|
29563
29564
|
];
|
|
29564
29565
|
const startedProcessHandle = bridgeProcessHandle;
|
|
29565
29566
|
try {
|
|
29566
|
-
const started =
|
|
29567
|
+
const started = controlSend("process/spawn", {
|
|
29567
29568
|
command,
|
|
29568
29569
|
processHandle: startedProcessHandle,
|
|
29569
29570
|
cwd: "C:\\",
|
|
@@ -29586,7 +29587,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
|
|
|
29586
29587
|
await startBridge();
|
|
29587
29588
|
if (bridgeState !== "ready")
|
|
29588
29589
|
throw transportError("is not ready");
|
|
29589
|
-
await
|
|
29590
|
+
await controlSend("process/writeStdin", {
|
|
29590
29591
|
processHandle: bridgeProcessHandle,
|
|
29591
29592
|
deltaBase64: utf8Base64(`${JSON.stringify(value2)}
|
|
29592
29593
|
`)
|
|
@@ -29872,7 +29873,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
|
|
|
29872
29873
|
globalThis.clearTimeout(bridgeReadyTimeout);
|
|
29873
29874
|
bridgeReadyTimeout = null;
|
|
29874
29875
|
if (isRemoteControlHost && (bridgeState === "starting" || bridgeState === "ready")) {
|
|
29875
|
-
void Promise.resolve(
|
|
29876
|
+
void Promise.resolve(controlSend("process/kill", { processHandle: bridgeProcessHandle })).catch(() => void 0);
|
|
29876
29877
|
}
|
|
29877
29878
|
bridgeState = "disposed";
|
|
29878
29879
|
const disposedError = transportError("was disposed");
|
|
@@ -29974,11 +29975,12 @@ function resolveRendererHostManager(discovery, hostId2, managerFrom = requestMan
|
|
|
29974
29975
|
}
|
|
29975
29976
|
|
|
29976
29977
|
// packages/desktop-control/dist/renderer-host-routing.js
|
|
29977
|
-
function installRendererHostRouting(root, target, discover, resolve, createPolicy) {
|
|
29978
|
+
function installRendererHostRouting(root, target, discover, resolve, createPolicy, readConnection, publishRouting = true) {
|
|
29978
29979
|
const existing = target.__codexhostHostRoutingV1;
|
|
29979
|
-
if (existing)
|
|
29980
|
+
if (publishRouting && existing)
|
|
29980
29981
|
return existing;
|
|
29981
|
-
|
|
29982
|
+
if (publishRouting)
|
|
29983
|
+
target.__codexhostDraftPrewarmPolicyV1?.dispose?.();
|
|
29982
29984
|
let disposed = false;
|
|
29983
29985
|
let lastDiscovery = null;
|
|
29984
29986
|
const routes = /* @__PURE__ */ new Map();
|
|
@@ -30006,23 +30008,36 @@ function installRendererHostRouting(root, target, discover, resolve, createPolic
|
|
|
30006
30008
|
routes.delete(hostId2);
|
|
30007
30009
|
entry?.route.policy.dispose();
|
|
30008
30010
|
};
|
|
30011
|
+
const connectionFor = (hostId2) => {
|
|
30012
|
+
if (!hostId2.startsWith("remote-control:"))
|
|
30013
|
+
return void 0;
|
|
30014
|
+
try {
|
|
30015
|
+
return readConnection?.(hostId2);
|
|
30016
|
+
} catch {
|
|
30017
|
+
return null;
|
|
30018
|
+
}
|
|
30019
|
+
};
|
|
30020
|
+
const sameConnection = (expected, current) => expected === void 0 ? current === void 0 : current?.owner === expected.owner && current.revision === expected.revision;
|
|
30009
30021
|
const routeFor = (hostId2, discovery) => {
|
|
30010
30022
|
const manager = lookup(hostId2, discovery);
|
|
30023
|
+
const connection = connectionFor(hostId2);
|
|
30011
30024
|
const previous = routes.get(hostId2);
|
|
30012
|
-
if (manager && previous?.route.manager === manager && previous.bridge === manager.requestClient && previous.prewarmed === manager.prewarmedThreadManager && previous.route.policy.owns(manager, manager.requestClient, hostId2, manager.prewarmedThreadManager, true)) {
|
|
30025
|
+
if (manager && previous?.route.manager === manager && previous.bridge === manager.requestClient && previous.prewarmed === manager.prewarmedThreadManager && sameConnection(previous.connection, connection) && previous.route.policy.owns(manager, manager.requestClient, hostId2, manager.prewarmedThreadManager, true)) {
|
|
30013
30026
|
return previous.route;
|
|
30014
30027
|
}
|
|
30015
30028
|
retire(hostId2);
|
|
30016
|
-
if (!manager)
|
|
30029
|
+
if (!manager || connection === null)
|
|
30017
30030
|
return null;
|
|
30018
30031
|
const bridge = manager.requestClient;
|
|
30019
30032
|
const prewarmed = manager.prewarmedThreadManager;
|
|
30020
|
-
const policy = createPolicy(manager, bridge, hostId2, target, prewarmed, () => lookup(hostId2) === manager && manager.requestClient === bridge && manager.prewarmedThreadManager === prewarmed);
|
|
30033
|
+
const policy = createPolicy(manager, bridge, hostId2, target, prewarmed, () => lookup(hostId2) === manager && sameConnection(connection, connectionFor(hostId2)) && manager.requestClient === bridge && manager.prewarmedThreadManager === prewarmed);
|
|
30021
30034
|
const route = { hostId: hostId2, manager, policy };
|
|
30022
|
-
routes.set(hostId2, { route, bridge, prewarmed });
|
|
30035
|
+
routes.set(hostId2, { route, bridge, prewarmed, connection });
|
|
30023
30036
|
return route;
|
|
30024
30037
|
};
|
|
30025
30038
|
const publish = (route) => {
|
|
30039
|
+
if (!publishRouting)
|
|
30040
|
+
return;
|
|
30026
30041
|
const policy = route?.policy;
|
|
30027
30042
|
if (target.__codexhostDraftPrewarmPolicyV1 === policy)
|
|
30028
30043
|
return;
|
|
@@ -30076,7 +30091,7 @@ function installRendererHostRouting(root, target, discover, resolve, createPolic
|
|
|
30076
30091
|
if (!composer) {
|
|
30077
30092
|
for (const [hostId3, entry] of routes) {
|
|
30078
30093
|
const manager = lookup(hostId3, discovery);
|
|
30079
|
-
if (manager !== entry.route.manager || manager.requestClient !== entry.bridge || manager.prewarmedThreadManager !== entry.prewarmed)
|
|
30094
|
+
if (manager !== entry.route.manager || manager.requestClient !== entry.bridge || manager.prewarmedThreadManager !== entry.prewarmed || !sameConnection(entry.connection, connectionFor(hostId3)))
|
|
30080
30095
|
retire(hostId3);
|
|
30081
30096
|
}
|
|
30082
30097
|
}
|
|
@@ -30099,7 +30114,11 @@ function installRendererHostRouting(root, target, discover, resolve, createPolic
|
|
|
30099
30114
|
}
|
|
30100
30115
|
}
|
|
30101
30116
|
};
|
|
30102
|
-
|
|
30117
|
+
if (publishRouting)
|
|
30118
|
+
Object.defineProperty(target, "__codexhostHostRoutingV1", {
|
|
30119
|
+
configurable: true,
|
|
30120
|
+
value: routing
|
|
30121
|
+
});
|
|
30103
30122
|
return routing;
|
|
30104
30123
|
}
|
|
30105
30124
|
|
|
@@ -30276,20 +30295,42 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
30276
30295
|
return existing;
|
|
30277
30296
|
}
|
|
30278
30297
|
let disposed = false;
|
|
30298
|
+
let nativeRouting = null;
|
|
30279
30299
|
let discovery = null;
|
|
30280
30300
|
const routes = /* @__PURE__ */ new Map();
|
|
30281
30301
|
const read = () => {
|
|
30282
30302
|
if (disposed)
|
|
30283
30303
|
return null;
|
|
30284
|
-
|
|
30304
|
+
try {
|
|
30285
30305
|
const store = dependencies2.findStore(root);
|
|
30286
30306
|
discovery = store ? dependencies2.findFamily(store) : null;
|
|
30307
|
+
} catch {
|
|
30308
|
+
discovery = null;
|
|
30287
30309
|
}
|
|
30288
30310
|
return discovery;
|
|
30289
30311
|
};
|
|
30290
30312
|
if (!read())
|
|
30291
30313
|
return null;
|
|
30292
30314
|
const queuePolicy = dependencies2.installQueuePolicy(root, target);
|
|
30315
|
+
const native = () => {
|
|
30316
|
+
if (disposed)
|
|
30317
|
+
return null;
|
|
30318
|
+
try {
|
|
30319
|
+
nativeRouting ??= dependencies2.nativeRouting?.() ?? null;
|
|
30320
|
+
} catch {
|
|
30321
|
+
}
|
|
30322
|
+
return nativeRouting;
|
|
30323
|
+
};
|
|
30324
|
+
const connectionFor = (hostId2) => {
|
|
30325
|
+
if (!hostId2.startsWith("remote-control:"))
|
|
30326
|
+
return void 0;
|
|
30327
|
+
try {
|
|
30328
|
+
return dependencies2.readConnection?.(hostId2);
|
|
30329
|
+
} catch {
|
|
30330
|
+
return null;
|
|
30331
|
+
}
|
|
30332
|
+
};
|
|
30333
|
+
const sameConnection = (previous, current) => previous === void 0 ? current === void 0 : current?.owner === previous.owner && current.revision === previous.revision;
|
|
30293
30334
|
const isRecord22 = (value2) => typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
30294
30335
|
const externalDrafts = /* @__PURE__ */ new Map();
|
|
30295
30336
|
const selectedModels = /* @__PURE__ */ new Map();
|
|
@@ -30375,16 +30416,25 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
30375
30416
|
const postMessage = function(message2, ...rest) {
|
|
30376
30417
|
let routed = message2;
|
|
30377
30418
|
try {
|
|
30378
|
-
routed = disposed ? message2 : routeCreationCall(message2);
|
|
30419
|
+
routed = disposed || routes.size === 0 ? message2 : routeCreationCall(message2);
|
|
30379
30420
|
} catch {
|
|
30380
30421
|
routed = message2;
|
|
30381
30422
|
}
|
|
30382
30423
|
return originalPostMessage.call(this, routed, ...rest);
|
|
30383
30424
|
};
|
|
30384
30425
|
port.postMessage = postMessage;
|
|
30385
|
-
const createRoute = (hostId2, rpc) => {
|
|
30426
|
+
const createRoute = (hostId2, rpc, connection) => {
|
|
30386
30427
|
let retired = false;
|
|
30387
|
-
const isCurrent = () =>
|
|
30428
|
+
const isCurrent = () => {
|
|
30429
|
+
if (retired || disposed || routes.get(hostId2)?.rpc !== rpc || !sameConnection(connection, connectionFor(hostId2)))
|
|
30430
|
+
return false;
|
|
30431
|
+
try {
|
|
30432
|
+
const current = read();
|
|
30433
|
+
return !!current && dependencies2.resolve(current, hostId2) === rpc;
|
|
30434
|
+
} catch {
|
|
30435
|
+
return false;
|
|
30436
|
+
}
|
|
30437
|
+
};
|
|
30388
30438
|
const manager = Object.freeze({
|
|
30389
30439
|
kind: "main-process-rpc",
|
|
30390
30440
|
getHostId: () => hostId2,
|
|
@@ -30472,17 +30522,25 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
30472
30522
|
routes.delete(hostId2);
|
|
30473
30523
|
entry?.route.policy.dispose();
|
|
30474
30524
|
};
|
|
30475
|
-
const routeFor = (hostId2) => {
|
|
30525
|
+
const routeFor = (hostId2, nativeRoute) => {
|
|
30526
|
+
if (disposed)
|
|
30527
|
+
return null;
|
|
30528
|
+
const connection = connectionFor(hostId2);
|
|
30529
|
+
const preferred = nativeRoute === void 0 ? native()?.forHost(hostId2) : nativeRoute;
|
|
30530
|
+
if (connection === null || preferred) {
|
|
30531
|
+
retire(hostId2);
|
|
30532
|
+
return connection === null ? null : preferred ?? null;
|
|
30533
|
+
}
|
|
30476
30534
|
const current = read();
|
|
30477
30535
|
const rpc = current ? dependencies2.resolve(current, hostId2) : null;
|
|
30478
30536
|
const previous = routes.get(hostId2);
|
|
30479
|
-
if (rpc && previous?.rpc === rpc)
|
|
30537
|
+
if (rpc && previous?.rpc === rpc && sameConnection(previous.connection, connection))
|
|
30480
30538
|
return previous.route;
|
|
30481
30539
|
retire(hostId2);
|
|
30482
30540
|
if (!rpc)
|
|
30483
30541
|
return null;
|
|
30484
|
-
const route = createRoute(hostId2, rpc);
|
|
30485
|
-
routes.set(hostId2, { route, rpc });
|
|
30542
|
+
const route = createRoute(hostId2, rpc, connection);
|
|
30543
|
+
routes.set(hostId2, { route, rpc, connection });
|
|
30486
30544
|
return route;
|
|
30487
30545
|
};
|
|
30488
30546
|
const publish = (route) => {
|
|
@@ -30498,14 +30556,24 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
30498
30556
|
}
|
|
30499
30557
|
};
|
|
30500
30558
|
const composerHostId = (composer) => {
|
|
30559
|
+
const nativeHostId = native()?.hostIdForComposer(composer);
|
|
30560
|
+
if (nativeHostId)
|
|
30561
|
+
return nativeHostId;
|
|
30501
30562
|
const hostIds = new Set(dependencies2.composerHostIds(composer).hostIds);
|
|
30502
30563
|
const hostId2 = hostIds.size === 1 ? hostIds.values().next().value : null;
|
|
30503
30564
|
return typeof hostId2 === "string" && hostId2 ? hostId2 : null;
|
|
30504
30565
|
};
|
|
30505
30566
|
const routing = {
|
|
30506
30567
|
knownHostIds() {
|
|
30568
|
+
if (disposed)
|
|
30569
|
+
return [];
|
|
30507
30570
|
const current = read();
|
|
30508
|
-
return
|
|
30571
|
+
return [
|
|
30572
|
+
.../* @__PURE__ */ new Set([
|
|
30573
|
+
...current ? dependencies2.hostIds(current) : [],
|
|
30574
|
+
...native()?.knownHostIds?.() ?? []
|
|
30575
|
+
])
|
|
30576
|
+
];
|
|
30509
30577
|
},
|
|
30510
30578
|
forHost(hostId2) {
|
|
30511
30579
|
return hostId2 && !disposed ? routeFor(hostId2) : null;
|
|
@@ -30523,12 +30591,14 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
30523
30591
|
if (disposed)
|
|
30524
30592
|
return null;
|
|
30525
30593
|
let hostId2;
|
|
30594
|
+
let preferred = null;
|
|
30526
30595
|
try {
|
|
30527
|
-
|
|
30596
|
+
preferred = native()?.forComposer(composer) ?? null;
|
|
30597
|
+
hostId2 = preferred?.hostId ?? composerHostId(composer);
|
|
30528
30598
|
} catch {
|
|
30529
30599
|
hostId2 = null;
|
|
30530
30600
|
}
|
|
30531
|
-
const route = hostId2 ? routeFor(hostId2) : null;
|
|
30601
|
+
const route = hostId2 ? routeFor(hostId2, preferred) : null;
|
|
30532
30602
|
if (!composer)
|
|
30533
30603
|
publish(route);
|
|
30534
30604
|
return route;
|
|
@@ -30537,6 +30607,8 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
30537
30607
|
if (disposed)
|
|
30538
30608
|
return;
|
|
30539
30609
|
disposed = true;
|
|
30610
|
+
nativeRouting?.dispose();
|
|
30611
|
+
nativeRouting = null;
|
|
30540
30612
|
for (const hostId2 of [...routes.keys()])
|
|
30541
30613
|
retire(hostId2);
|
|
30542
30614
|
discovery = null;
|
|
@@ -30555,6 +30627,34 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
30555
30627
|
return routing;
|
|
30556
30628
|
}
|
|
30557
30629
|
|
|
30630
|
+
// packages/desktop-control/dist/renderer-connection-generation.js
|
|
30631
|
+
function readRendererConnectionGeneration(store, hostId2) {
|
|
30632
|
+
if (!store)
|
|
30633
|
+
return void 0;
|
|
30634
|
+
const record6 = (value2) => value2 !== null && typeof value2 === "object";
|
|
30635
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
30636
|
+
for (const members of store.familyBindings.values()) {
|
|
30637
|
+
const value2 = members.get(hostId2)?.value;
|
|
30638
|
+
if (record6(value2) && record6(value2.state$) && record6(value2.revision$) && record6(value2.appServerVersion$) && typeof value2.state$.get === "function" && typeof value2.revision$.get === "function")
|
|
30639
|
+
candidates.add(value2);
|
|
30640
|
+
}
|
|
30641
|
+
if (!candidates.size)
|
|
30642
|
+
return void 0;
|
|
30643
|
+
if (candidates.size !== 1)
|
|
30644
|
+
return null;
|
|
30645
|
+
const owner = candidates.values().next().value;
|
|
30646
|
+
if (!owner)
|
|
30647
|
+
return null;
|
|
30648
|
+
const state = owner.state$;
|
|
30649
|
+
const revision = owner.revision$;
|
|
30650
|
+
try {
|
|
30651
|
+
const current = revision.get();
|
|
30652
|
+
return state.get() === "connected" && typeof current === "number" && Number.isSafeInteger(current) ? { owner, revision: current } : null;
|
|
30653
|
+
} catch {
|
|
30654
|
+
return null;
|
|
30655
|
+
}
|
|
30656
|
+
}
|
|
30657
|
+
|
|
30558
30658
|
// packages/desktop-control/dist/renderer-draft-prewarm-policy.js
|
|
30559
30659
|
var REQUEST_MANAGER_WAIT_TIMEOUT_MS = 6e4;
|
|
30560
30660
|
var REQUEST_MANAGER_POLL_INTERVAL_MS = 25;
|
|
@@ -30567,15 +30667,19 @@ function directRendererInstaller() {
|
|
|
30567
30667
|
const retainRendererHostResponses = ${retainRendererHostResponses.toString()};
|
|
30568
30668
|
const createDraftPrewarmPolicyBridge = ${createDraftPrewarmPolicyBridge.toString()};
|
|
30569
30669
|
const isolateRendererPrewarmConsumption = ${isolateRendererPrewarmConsumption.toString()};
|
|
30670
|
+
const findRendererAppScopeStore = ${findRendererAppScopeStore.toString()};
|
|
30671
|
+
const readRendererConnectionGeneration = ${readRendererConnectionGeneration.toString()};
|
|
30570
30672
|
const discover = (root) =>
|
|
30571
30673
|
discoverRendererHosts(root, committedReactAncestors, requestManagerFromHookState);
|
|
30572
|
-
const installNative = () => (${installRendererHostRouting.toString()})(
|
|
30674
|
+
const installNative = (publishRouting = true) => (${installRendererHostRouting.toString()})(
|
|
30573
30675
|
document, window, discover,
|
|
30574
30676
|
(discovery, hostId) => resolveRendererHostManager(discovery, hostId, requestManagerFromHookState),
|
|
30575
30677
|
(manager, bridge, hostId, target, prewarmed, isCurrent) => createDraftPrewarmPolicyBridge(
|
|
30576
30678
|
manager, bridge, hostId, target, prewarmed, isCurrent, retainRendererHostResponses,
|
|
30577
30679
|
isolateRendererPrewarmConsumption,
|
|
30578
30680
|
),
|
|
30681
|
+
(hostId) => readRendererConnectionGeneration(findRendererAppScopeStore(document), hostId),
|
|
30682
|
+
publishRouting,
|
|
30579
30683
|
);
|
|
30580
30684
|
const installRpc = () => typeof MessagePort !== 'function' ? null : (${installRendererHostRpcRouting.toString()})(document, window, {
|
|
30581
30685
|
findStore: ${findRendererAppScopeStore.toString()},
|
|
@@ -30594,20 +30698,21 @@ function directRendererInstaller() {
|
|
|
30594
30698
|
portPrototype: MessagePort.prototype,
|
|
30595
30699
|
}),
|
|
30596
30700
|
portPrototype: MessagePort.prototype,
|
|
30701
|
+
nativeRouting: () => {
|
|
30702
|
+
const native = discover(document);
|
|
30703
|
+
return native.managers.length || native.registries.length ? installNative(false) : null;
|
|
30704
|
+
},
|
|
30705
|
+
readConnection: (hostId) => readRendererConnectionGeneration(findRendererAppScopeStore(document), hostId),
|
|
30597
30706
|
});
|
|
30598
30707
|
const connected = (routing) => routing.forComposer() !== null ||
|
|
30599
30708
|
['local', ...(routing.knownHostIds?.() ?? [])].some((hostId) => routing.forHost(hostId) !== null);
|
|
30600
30709
|
let nativeReady = false;
|
|
30601
|
-
//
|
|
30602
|
-
//
|
|
30710
|
+
// Mixed layouts can expose native managers for only some Hosts. Keep one
|
|
30711
|
+
// router that selects a native owner or the current ready RPC peer per Host.
|
|
30603
30712
|
const routing = (() => {
|
|
30604
|
-
if (window.__codexhostHostRoutingV1)
|
|
30605
|
-
|
|
30606
|
-
|
|
30607
|
-
hostId => existing.forHost(hostId)?.manager.kind === 'main-process-rpc'
|
|
30608
|
-
)) installRpc();
|
|
30609
|
-
return existing;
|
|
30610
|
-
}
|
|
30713
|
+
if (window.__codexhostHostRoutingV1) return window.__codexhostHostRoutingV1;
|
|
30714
|
+
const rpc = installRpc();
|
|
30715
|
+
if (rpc) return rpc;
|
|
30611
30716
|
const native = discover(document);
|
|
30612
30717
|
if (native.managers.length || native.registries.length) {
|
|
30613
30718
|
const routing = installNative();
|
|
@@ -30617,8 +30722,6 @@ function directRendererInstaller() {
|
|
|
30617
30722
|
}
|
|
30618
30723
|
routing.dispose();
|
|
30619
30724
|
}
|
|
30620
|
-
const rpc = installRpc();
|
|
30621
|
-
if (rpc) return rpc;
|
|
30622
30725
|
throw new Error('Renderer Host request manager is unavailable');
|
|
30623
30726
|
})();
|
|
30624
30727
|
// Publish a default draft policy only when its Host is unambiguous. Host
|
|
@@ -30790,6 +30893,765 @@ async function installRendererLoadedModules(renderer) {
|
|
|
30790
30893
|
}
|
|
30791
30894
|
}
|
|
30792
30895
|
|
|
30896
|
+
// packages/desktop-control/dist/renderer-native-rpc-discovery.js
|
|
30897
|
+
function nativeManagerDependencies(factoryName, callers) {
|
|
30898
|
+
const identifier = "[$A-Z_a-z][$\\w]*";
|
|
30899
|
+
const escaped = factoryName.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
30900
|
+
const pattern = new RegExp(`${escaped}\\((${identifier}),(${identifier}),\\1\\.get\\((${identifier}),\\2\\),(${identifier})\\.bind\\(null,\\1\\),\\((${identifier}),(${identifier})\\)=>\\5\\((${identifier}),\\6\\)\\)`);
|
|
30901
|
+
const matches = callers.flatMap((source) => {
|
|
30902
|
+
const match = pattern.exec(source);
|
|
30903
|
+
return match?.[3] && match[4] && match[7] ? [
|
|
30904
|
+
{
|
|
30905
|
+
requestDefinition: match[3],
|
|
30906
|
+
isHostForConversation: match[4],
|
|
30907
|
+
imageDefinition: match[7]
|
|
30908
|
+
}
|
|
30909
|
+
] : [];
|
|
30910
|
+
});
|
|
30911
|
+
return matches.length === 1 ? matches[0] : void 0;
|
|
30912
|
+
}
|
|
30913
|
+
function nativeRpcRole(source) {
|
|
30914
|
+
if (["dispatchMessageFromView", "threadProjectAssignments", "queuedMessageCoordination"].every((part) => source.includes(part)))
|
|
30915
|
+
return "createManager";
|
|
30916
|
+
if (["collectAppStateSnapshot", "getReviewPaneSnapshotMetrics", "registerReplayAdmission"].every((part) => source.includes(part)))
|
|
30917
|
+
return "createController";
|
|
30918
|
+
if (["getWorkInProgress", "getCachedThreadSearchSnapshot", "registerReplayAdmission"].every((part) => source.includes(part)))
|
|
30919
|
+
return "RpcManager";
|
|
30920
|
+
if (["prewarmedThreadManager", "onNotification", "dispatchAppServerResponse"].every((part) => source.includes(part)))
|
|
30921
|
+
return "Manager";
|
|
30922
|
+
return void 0;
|
|
30923
|
+
}
|
|
30924
|
+
function nativeRpcObjectShape(value2) {
|
|
30925
|
+
if (value2 === null || typeof value2 !== "object")
|
|
30926
|
+
return { scope: false, services: false, controller: false };
|
|
30927
|
+
const candidate = value2;
|
|
30928
|
+
const own = (keys) => keys.every((key) => Object.hasOwn(candidate, key));
|
|
30929
|
+
const methods = (keys) => keys.every((key) => typeof candidate[key] === "function");
|
|
30930
|
+
return {
|
|
30931
|
+
scope: own(["node", "scope", "get", "set", "watch"]) && methods(["get", "set", "watch"]),
|
|
30932
|
+
services: own(["appServerManagers", "remoteConnections", "applicationMenu"]) && typeof candidate.appServerManagers?.subscribe === "function",
|
|
30933
|
+
controller: own(["forHost", "collectAppStateSnapshot", "getReviewPaneSnapshotMetrics", "dispose"]) && methods(["forHost", "collectAppStateSnapshot", "getReviewPaneSnapshotMetrics", "dispose"])
|
|
30934
|
+
};
|
|
30935
|
+
}
|
|
30936
|
+
async function withNativeRpcComponents(client, install) {
|
|
30937
|
+
const group = `codexhost-native-rpc-${crypto.randomUUID()}`;
|
|
30938
|
+
const command = async (method, params) => client.command(method, params);
|
|
30939
|
+
const evaluate = (expression) => command("Runtime.evaluate", { expression, awaitPromise: true, objectGroup: group });
|
|
30940
|
+
const properties = (objectId) => command("Runtime.getProperties", { objectId, ownProperties: true });
|
|
30941
|
+
const call = (objectId, functionDeclaration, args = []) => command("Runtime.callFunctionOn", {
|
|
30942
|
+
objectId,
|
|
30943
|
+
functionDeclaration,
|
|
30944
|
+
arguments: args,
|
|
30945
|
+
objectGroup: group,
|
|
30946
|
+
returnByValue: true
|
|
30947
|
+
});
|
|
30948
|
+
try {
|
|
30949
|
+
const initial = await evaluate(String.raw`(() => {
|
|
30950
|
+
const catalog = globalThis.__codexhostLoadedModulesV1;
|
|
30951
|
+
if (!catalog?.complete || catalog.documentUrl !== location.href) return null;
|
|
30952
|
+
const urls = catalog.urls.filter(url => /^app:\/\/-\/assets\/(?:renderer-app-server-managers|app-shared)-[^/]+\.js$/.test(url));
|
|
30953
|
+
return { document, urls };
|
|
30954
|
+
})()`);
|
|
30955
|
+
if (!initial.result.objectId)
|
|
30956
|
+
return false;
|
|
30957
|
+
const holder = initial.result.objectId;
|
|
30958
|
+
const catalog = await call(holder, "function(){return this.urls}");
|
|
30959
|
+
const urls = catalog.result.value;
|
|
30960
|
+
if (!Array.isArray(urls) || urls.length !== 2)
|
|
30961
|
+
return false;
|
|
30962
|
+
const managerUrl = urls.find((url2) => url2.includes("renderer-app-server-managers"));
|
|
30963
|
+
const sharedUrl = urls.find((url2) => url2.includes("app-shared"));
|
|
30964
|
+
if (!managerUrl || !sharedUrl)
|
|
30965
|
+
return false;
|
|
30966
|
+
const attach = async (name, objectId) => {
|
|
30967
|
+
const result = await call(holder, "function(name,value){if(this.document!==document)throw Error('Renderer Realm changed');this[name]=value;return true}", [{ value: name }, { objectId }]);
|
|
30968
|
+
if (result.exceptionDetails)
|
|
30969
|
+
throw new Error("Native RPC discovery lost its Renderer Realm");
|
|
30970
|
+
};
|
|
30971
|
+
const imported = await evaluate(`import(${JSON.stringify(managerUrl)})`);
|
|
30972
|
+
if (!imported.result.objectId)
|
|
30973
|
+
return false;
|
|
30974
|
+
const exports = (await properties(imported.result.objectId)).result.filter((entry) => entry.value?.type === "function");
|
|
30975
|
+
let bindings = [];
|
|
30976
|
+
for (const entry of exports.slice(0, 3)) {
|
|
30977
|
+
if (!entry.value?.objectId)
|
|
30978
|
+
continue;
|
|
30979
|
+
const scopes = (await properties(entry.value.objectId)).internalProperties?.find((entry2) => entry2.name === "[[Scopes]]")?.value?.objectId;
|
|
30980
|
+
if (!scopes)
|
|
30981
|
+
continue;
|
|
30982
|
+
const modules = (await properties(scopes)).result.filter((entry2) => entry2.value?.description?.startsWith("Module") && entry2.value.objectId);
|
|
30983
|
+
const moduleId = modules[0]?.value?.objectId;
|
|
30984
|
+
if (modules.length !== 1 || !moduleId)
|
|
30985
|
+
continue;
|
|
30986
|
+
bindings = (await properties(moduleId)).result;
|
|
30987
|
+
break;
|
|
30988
|
+
}
|
|
30989
|
+
const functions = bindings.filter((entry) => entry.value?.type === "function");
|
|
30990
|
+
const roles = /* @__PURE__ */ new Map();
|
|
30991
|
+
for (const entry of functions) {
|
|
30992
|
+
const role = nativeRpcRole(entry.value?.description ?? "");
|
|
30993
|
+
if (role)
|
|
30994
|
+
roles.set(role, [...roles.get(role) ?? [], entry]);
|
|
30995
|
+
}
|
|
30996
|
+
if (["createManager", "Manager", "RpcManager", "createController"].some((role) => roles.get(role)?.length !== 1))
|
|
30997
|
+
return false;
|
|
30998
|
+
const factory = roles.get("createManager")?.[0];
|
|
30999
|
+
if (!factory)
|
|
31000
|
+
return false;
|
|
31001
|
+
const dependencies2 = nativeManagerDependencies(factory.name, functions.map((entry) => entry.value?.description ?? ""));
|
|
31002
|
+
if (!dependencies2)
|
|
31003
|
+
return false;
|
|
31004
|
+
for (const [role, entries] of roles) {
|
|
31005
|
+
const id2 = entries[0]?.value?.objectId;
|
|
31006
|
+
if (!id2)
|
|
31007
|
+
return false;
|
|
31008
|
+
await attach(role, id2);
|
|
31009
|
+
}
|
|
31010
|
+
for (const [role, name] of Object.entries(dependencies2)) {
|
|
31011
|
+
const value2 = bindings.find((entry) => entry.name === name)?.value?.objectId;
|
|
31012
|
+
if (!value2)
|
|
31013
|
+
return false;
|
|
31014
|
+
await attach(role, value2);
|
|
31015
|
+
}
|
|
31016
|
+
const shared = await evaluate(`import(${JSON.stringify(sharedUrl)})`);
|
|
31017
|
+
if (!shared.result.objectId)
|
|
31018
|
+
return false;
|
|
31019
|
+
const sharedExports = (await properties(shared.result.objectId)).result;
|
|
31020
|
+
const sessions = sharedExports.filter((entry) => entry.value?.type === "function" && ["getRemoteMain", "getStats", "drain", "getMainImport"].every((word) => entry.value?.description?.includes(word)));
|
|
31021
|
+
const sessionId = sessions[0]?.value?.objectId;
|
|
31022
|
+
if (sessions.length !== 1 || !sessionId)
|
|
31023
|
+
return false;
|
|
31024
|
+
await attach("RpcSession", sessionId);
|
|
31025
|
+
const serviceMatches = await command("Runtime.callFunctionOn", {
|
|
31026
|
+
objectId: shared.result.objectId,
|
|
31027
|
+
functionDeclaration: `function(){return [...new Set(Object.values(this).filter(value => (${nativeRpcObjectShape.toString()})(value).services))]}`,
|
|
31028
|
+
objectGroup: group
|
|
31029
|
+
});
|
|
31030
|
+
if (!serviceMatches.result.objectId)
|
|
31031
|
+
return false;
|
|
31032
|
+
const services = (await properties(serviceMatches.result.objectId)).result.flatMap((entry) => entry.value?.type === "object" && entry.value.objectId ? [entry.value.objectId] : []);
|
|
31033
|
+
const serviceId = services[0];
|
|
31034
|
+
if (services.length !== 1 || !serviceId)
|
|
31035
|
+
return false;
|
|
31036
|
+
await attach("services", serviceId);
|
|
31037
|
+
const prototype = await evaluate("Object.getPrototypeOf(async function(){})");
|
|
31038
|
+
if (!prototype.result.objectId)
|
|
31039
|
+
return false;
|
|
31040
|
+
const objects = await command("Runtime.queryObjects", {
|
|
31041
|
+
prototypeObjectId: prototype.result.objectId,
|
|
31042
|
+
objectGroup: group
|
|
31043
|
+
});
|
|
31044
|
+
if (!objects.objects.objectId)
|
|
31045
|
+
return false;
|
|
31046
|
+
const filtered = await command("Runtime.callFunctionOn", {
|
|
31047
|
+
objectId: objects.objects.objectId,
|
|
31048
|
+
functionDeclaration: 'function(){return this.filter(fn=>fn.name==="collectAppStateSnapshot"&&String(fn).includes("collectSnapshot")).slice(0,9)}',
|
|
31049
|
+
objectGroup: group
|
|
31050
|
+
});
|
|
31051
|
+
if (!filtered.result.objectId)
|
|
31052
|
+
return false;
|
|
31053
|
+
const snapshots = (await properties(filtered.result.objectId)).result.filter((entry) => entry.value?.type === "function");
|
|
31054
|
+
if (snapshots.length > 8)
|
|
31055
|
+
return false;
|
|
31056
|
+
const owners = [];
|
|
31057
|
+
for (const snapshot2 of snapshots) {
|
|
31058
|
+
const fn = snapshot2.value?.objectId;
|
|
31059
|
+
if (!fn)
|
|
31060
|
+
continue;
|
|
31061
|
+
const scopes = (await properties(fn)).internalProperties?.find((entry) => entry.name === "[[Scopes]]")?.value?.objectId;
|
|
31062
|
+
if (!scopes)
|
|
31063
|
+
continue;
|
|
31064
|
+
for (const scope of (await properties(scopes)).result) {
|
|
31065
|
+
if (!scope.value?.description?.startsWith("Closure") || !scope.value.objectId)
|
|
31066
|
+
continue;
|
|
31067
|
+
const candidates = (await properties(scope.value.objectId)).result;
|
|
31068
|
+
const controllers = [], handles = [];
|
|
31069
|
+
for (const binding of candidates) {
|
|
31070
|
+
if (binding.value?.type !== "object" || !binding.value.objectId)
|
|
31071
|
+
continue;
|
|
31072
|
+
const id2 = binding.value.objectId;
|
|
31073
|
+
const response = await call(id2, `function(){return (${nativeRpcObjectShape.toString()})(this)}`);
|
|
31074
|
+
const shape = response.result.value;
|
|
31075
|
+
if (shape?.scope)
|
|
31076
|
+
handles.push(id2);
|
|
31077
|
+
if (shape?.controller && (await call(id2, "function(fn){return this.collectAppStateSnapshot===fn}", [
|
|
31078
|
+
{ objectId: fn }
|
|
31079
|
+
])).result.value === true)
|
|
31080
|
+
controllers.push(id2);
|
|
31081
|
+
}
|
|
31082
|
+
const controller = controllers[0], handle = handles[0];
|
|
31083
|
+
if (controllers.length === 1 && handles.length === 1 && controller && handle)
|
|
31084
|
+
owners.push({ controller, scope: handle });
|
|
31085
|
+
}
|
|
31086
|
+
}
|
|
31087
|
+
const owner = owners[0];
|
|
31088
|
+
if (owners.length !== 1 || !owner)
|
|
31089
|
+
return false;
|
|
31090
|
+
await attach("controller", owner.controller);
|
|
31091
|
+
await attach("scope", owner.scope);
|
|
31092
|
+
return await install(holder);
|
|
31093
|
+
} finally {
|
|
31094
|
+
await client.command("Runtime.releaseObjectGroup", { objectGroup: group }).catch(() => void 0);
|
|
31095
|
+
}
|
|
31096
|
+
}
|
|
31097
|
+
|
|
31098
|
+
// packages/desktop-control/dist/renderer-native-rpc-runtime.js
|
|
31099
|
+
function installNativeRpcRemoteControl(components, target, dependencies2) {
|
|
31100
|
+
if (target.__codexhostNativeRpcRemoteControlV1)
|
|
31101
|
+
return true;
|
|
31102
|
+
const routing = target.__codexhostHostRoutingV1;
|
|
31103
|
+
if (!routing)
|
|
31104
|
+
return false;
|
|
31105
|
+
const adapted = dependencies2.createService(components, (hostId2, upstream) => dependencies2.createManager(components, hostId2, upstream, target, dependencies2.createPolicy, dependencies2.createChannel, dependencies2.retainInteractions));
|
|
31106
|
+
const controller = components.controller;
|
|
31107
|
+
const originalHost = routing.forHost, originalComposer = routing.forComposer, originalDispose = routing.dispose;
|
|
31108
|
+
controller.dispose();
|
|
31109
|
+
let replacement;
|
|
31110
|
+
try {
|
|
31111
|
+
replacement = components.createController(components.scope, adapted.service);
|
|
31112
|
+
} catch (error51) {
|
|
31113
|
+
replacement = components.createController(components.scope, components.services.appServerManagers);
|
|
31114
|
+
throw error51;
|
|
31115
|
+
} finally {
|
|
31116
|
+
adapted.service[Symbol.dispose]();
|
|
31117
|
+
controller.forHost = (hostId2) => replacement.forHost(hostId2);
|
|
31118
|
+
controller.collectAppStateSnapshot = (hostId2, options) => replacement.collectAppStateSnapshot(hostId2, options);
|
|
31119
|
+
controller.getReviewPaneSnapshotMetrics = (hostId2) => replacement.getReviewPaneSnapshotMetrics(hostId2);
|
|
31120
|
+
controller.dispose = () => replacement.dispose();
|
|
31121
|
+
}
|
|
31122
|
+
const forHost = (hostId2) => {
|
|
31123
|
+
const route = adapted.route(hostId2);
|
|
31124
|
+
return route === void 0 ? originalHost.call(routing, hostId2) : route;
|
|
31125
|
+
};
|
|
31126
|
+
const forComposer = (composer) => {
|
|
31127
|
+
const hostId2 = routing.hostIdForComposer(composer);
|
|
31128
|
+
return hostId2 ? forHost(hostId2) : originalComposer.call(routing, composer);
|
|
31129
|
+
};
|
|
31130
|
+
routing.forHost = forHost;
|
|
31131
|
+
routing.forComposer = forComposer;
|
|
31132
|
+
const installation2 = {
|
|
31133
|
+
dispose() {
|
|
31134
|
+
if (target.__codexhostNativeRpcRemoteControlV1 !== installation2)
|
|
31135
|
+
return;
|
|
31136
|
+
delete target.__codexhostNativeRpcRemoteControlV1;
|
|
31137
|
+
replacement.dispose();
|
|
31138
|
+
replacement = components.createController(components.scope, components.services.appServerManagers);
|
|
31139
|
+
if (routing.forHost === forHost)
|
|
31140
|
+
routing.forHost = originalHost;
|
|
31141
|
+
if (routing.forComposer === forComposer)
|
|
31142
|
+
routing.forComposer = originalComposer;
|
|
31143
|
+
routing.dispose = originalDispose;
|
|
31144
|
+
}
|
|
31145
|
+
};
|
|
31146
|
+
routing.dispose = () => {
|
|
31147
|
+
installation2.dispose();
|
|
31148
|
+
originalDispose.call(routing);
|
|
31149
|
+
};
|
|
31150
|
+
target.__codexhostNativeRpcRemoteControlV1 = installation2;
|
|
31151
|
+
return true;
|
|
31152
|
+
}
|
|
31153
|
+
|
|
31154
|
+
// packages/desktop-control/dist/renderer-native-remote-manager.js
|
|
31155
|
+
function createNativeRemoteManager(components, hostId2, original, target, createPolicy, createChannel, retainInteractions) {
|
|
31156
|
+
const source = components.scope.get(components.requestDefinition, hostId2);
|
|
31157
|
+
const upstream = original.dup();
|
|
31158
|
+
let manager;
|
|
31159
|
+
let policy;
|
|
31160
|
+
let interactions;
|
|
31161
|
+
let disposed = false;
|
|
31162
|
+
const pending = /* @__PURE__ */ new Set();
|
|
31163
|
+
const send = (method, params, options) => {
|
|
31164
|
+
const request = upstream.sendRequest(method, params, options);
|
|
31165
|
+
const result = Promise.resolve(request).finally(() => {
|
|
31166
|
+
request[Symbol.dispose]();
|
|
31167
|
+
pending.delete(result);
|
|
31168
|
+
});
|
|
31169
|
+
pending.add(result);
|
|
31170
|
+
return result;
|
|
31171
|
+
};
|
|
31172
|
+
const record6 = (value2) => value2 !== null && typeof value2 === "object";
|
|
31173
|
+
const dispatch = (type, payload) => {
|
|
31174
|
+
if ((type === "mcp-request" || type === "thread-prewarm-start") && record6(payload) && record6(payload.request)) {
|
|
31175
|
+
const request = payload.request;
|
|
31176
|
+
const options = {};
|
|
31177
|
+
for (const key of ["priority", "timeoutMs", "source", "trace", "threadAccess"])
|
|
31178
|
+
if (payload[key] !== void 0)
|
|
31179
|
+
options[key] = payload[key];
|
|
31180
|
+
void send(String(request.method), request.params, options).then((result) => {
|
|
31181
|
+
if (!disposed)
|
|
31182
|
+
client.onResult(request.id, result);
|
|
31183
|
+
}, (error51) => {
|
|
31184
|
+
if (!disposed)
|
|
31185
|
+
client.onError(request.id, {
|
|
31186
|
+
code: record6(error51) ? error51.jsonRpcCode ?? error51.code ?? -32603 : -32603,
|
|
31187
|
+
message: error51 instanceof Error ? error51.message : String(error51)
|
|
31188
|
+
});
|
|
31189
|
+
});
|
|
31190
|
+
return;
|
|
31191
|
+
}
|
|
31192
|
+
return source.dispatchMessage(type, payload);
|
|
31193
|
+
};
|
|
31194
|
+
const Constructor = source.constructor;
|
|
31195
|
+
let client;
|
|
31196
|
+
try {
|
|
31197
|
+
client = new Constructor(hostId2, dispatch, false, (id2) => manager?.getConversation(id2)?.threadAccess);
|
|
31198
|
+
client.setAppServerVersion(source.getAppServerVersion());
|
|
31199
|
+
manager = components.createManager(components.scope, hostId2, client, components.isHostForConversation.bind(null, components.scope), (get, id2) => get(components.imageDefinition, id2), { dispatchMessageFromView: dispatch });
|
|
31200
|
+
manager.dispatchAppServerResponse = manager.sendAppServerResponse;
|
|
31201
|
+
const owned = manager;
|
|
31202
|
+
const ownedPolicy = createPolicy(owned, client, hostId2, target, owned.prewarmedThreadManager, () => !disposed, void 0, void 0, (method, params) => send(method, params, { priority: "critical" }));
|
|
31203
|
+
policy = ownedPolicy;
|
|
31204
|
+
owned.sendAppServerResponse = (...args) => owned.dispatchAppServerResponse(...args);
|
|
31205
|
+
const channel = createChannel(components, owned);
|
|
31206
|
+
const nativeInteractions = retainInteractions(upstream, owned, hostId2);
|
|
31207
|
+
interactions = nativeInteractions;
|
|
31208
|
+
const notify = (event) => {
|
|
31209
|
+
const { data, source: source2, origin } = event;
|
|
31210
|
+
if (disposed || source2 != null && source2 !== target || !record6(data) || data.hostId !== hostId2)
|
|
31211
|
+
return;
|
|
31212
|
+
const ownOrigin = record6(target.location) ? target.location.origin : void 0;
|
|
31213
|
+
if (source2 === target && ownOrigin && ownOrigin !== "null" && origin !== ownOrigin)
|
|
31214
|
+
return;
|
|
31215
|
+
if (data.type === "mcp-notification" && typeof data.method === "string" && !data.method.startsWith("process/"))
|
|
31216
|
+
owned.onNotification(data.method, data.params);
|
|
31217
|
+
if (data.type === "mcp-request")
|
|
31218
|
+
owned.onRequest(record6(data.request) ? data.request : data);
|
|
31219
|
+
};
|
|
31220
|
+
target.addEventListener?.("message", notify);
|
|
31221
|
+
return {
|
|
31222
|
+
route: { hostId: hostId2, manager: owned, policy: ownedPolicy },
|
|
31223
|
+
rpc: channel.rpc,
|
|
31224
|
+
ready: nativeInteractions.ready,
|
|
31225
|
+
dispose() {
|
|
31226
|
+
if (disposed)
|
|
31227
|
+
return;
|
|
31228
|
+
disposed = true;
|
|
31229
|
+
target.removeEventListener?.("message", notify);
|
|
31230
|
+
nativeInteractions.dispose();
|
|
31231
|
+
ownedPolicy.dispose();
|
|
31232
|
+
client.queuedRequests.length = 0;
|
|
31233
|
+
for (const id2 of [...client.requestPromises.keys()])
|
|
31234
|
+
client.onError(id2, new Error("Remote Control connection retired"));
|
|
31235
|
+
channel.dispose();
|
|
31236
|
+
components.Manager.dispose(owned);
|
|
31237
|
+
void Promise.allSettled([...pending]).then(() => upstream[Symbol.dispose]());
|
|
31238
|
+
}
|
|
31239
|
+
};
|
|
31240
|
+
} catch (error51) {
|
|
31241
|
+
interactions?.dispose();
|
|
31242
|
+
policy?.dispose();
|
|
31243
|
+
if (manager)
|
|
31244
|
+
components.Manager.dispose(manager);
|
|
31245
|
+
upstream[Symbol.dispose]();
|
|
31246
|
+
throw error51;
|
|
31247
|
+
}
|
|
31248
|
+
}
|
|
31249
|
+
|
|
31250
|
+
// packages/desktop-control/dist/renderer-native-rpc-channel.js
|
|
31251
|
+
function createNativeRpcChannel(components, manager) {
|
|
31252
|
+
const channel = new MessageChannel();
|
|
31253
|
+
const transports = [];
|
|
31254
|
+
const transport = (port) => {
|
|
31255
|
+
const values = [];
|
|
31256
|
+
const readers = [];
|
|
31257
|
+
let closed = false;
|
|
31258
|
+
let failure3;
|
|
31259
|
+
port.addEventListener("message", (event) => {
|
|
31260
|
+
const value2 = JSON.stringify(event.data);
|
|
31261
|
+
const reader = readers.shift();
|
|
31262
|
+
if (reader)
|
|
31263
|
+
reader.resolve(value2);
|
|
31264
|
+
else
|
|
31265
|
+
values.push(value2);
|
|
31266
|
+
});
|
|
31267
|
+
port.start();
|
|
31268
|
+
const result = {
|
|
31269
|
+
send(message2) {
|
|
31270
|
+
if (closed)
|
|
31271
|
+
throw failure3;
|
|
31272
|
+
port.postMessage(JSON.parse(message2));
|
|
31273
|
+
},
|
|
31274
|
+
receive() {
|
|
31275
|
+
if (closed)
|
|
31276
|
+
return Promise.reject(failure3);
|
|
31277
|
+
const value2 = values.shift();
|
|
31278
|
+
return value2 !== void 0 ? Promise.resolve(value2) : new Promise((resolve, reject) => readers.push({ resolve, reject }));
|
|
31279
|
+
},
|
|
31280
|
+
abort(error51) {
|
|
31281
|
+
if (closed)
|
|
31282
|
+
return;
|
|
31283
|
+
closed = true;
|
|
31284
|
+
failure3 = error51 ?? new Error("Remote Control RPC manager retired");
|
|
31285
|
+
values.length = 0;
|
|
31286
|
+
for (const reader of readers.splice(0))
|
|
31287
|
+
reader.reject(failure3);
|
|
31288
|
+
port.close();
|
|
31289
|
+
}
|
|
31290
|
+
};
|
|
31291
|
+
transports.push(result);
|
|
31292
|
+
return result;
|
|
31293
|
+
};
|
|
31294
|
+
try {
|
|
31295
|
+
new components.RpcSession(transport(channel.port1), new components.RpcManager(() => manager));
|
|
31296
|
+
const session = new components.RpcSession(transport(channel.port2));
|
|
31297
|
+
const rpc = session.getRemoteMain();
|
|
31298
|
+
return {
|
|
31299
|
+
rpc,
|
|
31300
|
+
dispose() {
|
|
31301
|
+
rpc[Symbol.dispose]();
|
|
31302
|
+
for (const transport2 of transports)
|
|
31303
|
+
transport2.abort();
|
|
31304
|
+
}
|
|
31305
|
+
};
|
|
31306
|
+
} catch (error51) {
|
|
31307
|
+
for (const transport2 of transports)
|
|
31308
|
+
transport2.abort(error51);
|
|
31309
|
+
channel.port1.close();
|
|
31310
|
+
channel.port2.close();
|
|
31311
|
+
throw error51;
|
|
31312
|
+
}
|
|
31313
|
+
}
|
|
31314
|
+
|
|
31315
|
+
// packages/desktop-control/dist/renderer-native-rpc-service.js
|
|
31316
|
+
function createNativeRpcService(components, createRemote) {
|
|
31317
|
+
const source = components.services.appServerManagers.dup();
|
|
31318
|
+
const routes = /* @__PURE__ */ new Map();
|
|
31319
|
+
const subscriptions = /* @__PURE__ */ new Set();
|
|
31320
|
+
let refs = 1;
|
|
31321
|
+
const record6 = (value2) => value2 !== null && typeof value2 === "object";
|
|
31322
|
+
const connectionSignals = (hostId2) => {
|
|
31323
|
+
let node = components.scope.node;
|
|
31324
|
+
const seen = /* @__PURE__ */ new Set();
|
|
31325
|
+
while (node.parent && !seen.has(node.parent) && seen.size < 100) {
|
|
31326
|
+
seen.add(node);
|
|
31327
|
+
node = node.parent;
|
|
31328
|
+
}
|
|
31329
|
+
const found = [];
|
|
31330
|
+
for (const members of node.familyBindings.values()) {
|
|
31331
|
+
const value2 = members.get(hostId2)?.value;
|
|
31332
|
+
if (record6(value2) && Object.hasOwn(value2, "state$") && Object.hasOwn(value2, "revision$") && Object.hasOwn(value2, "appServerVersion$"))
|
|
31333
|
+
found.push({ state$: value2.state$, revision$: value2.revision$ });
|
|
31334
|
+
}
|
|
31335
|
+
return found.length === 1 ? found[0] : void 0;
|
|
31336
|
+
};
|
|
31337
|
+
const service = {
|
|
31338
|
+
dup() {
|
|
31339
|
+
refs++;
|
|
31340
|
+
return service;
|
|
31341
|
+
},
|
|
31342
|
+
onRpcBroken(listener) {
|
|
31343
|
+
source.onRpcBroken(listener);
|
|
31344
|
+
},
|
|
31345
|
+
openAccount(hostId2) {
|
|
31346
|
+
return source.openAccount(hostId2);
|
|
31347
|
+
},
|
|
31348
|
+
subscribe(hostId2, listener) {
|
|
31349
|
+
if (!hostId2.startsWith("remote-control:"))
|
|
31350
|
+
return source.subscribe(hostId2, listener);
|
|
31351
|
+
let active = true;
|
|
31352
|
+
let generation = 0;
|
|
31353
|
+
let upstream;
|
|
31354
|
+
let platformRequest;
|
|
31355
|
+
let remote;
|
|
31356
|
+
let stopWatch;
|
|
31357
|
+
let previousRevision;
|
|
31358
|
+
let previousState;
|
|
31359
|
+
const retire = () => {
|
|
31360
|
+
generation++;
|
|
31361
|
+
platformRequest?.[Symbol.dispose]();
|
|
31362
|
+
platformRequest = void 0;
|
|
31363
|
+
remote?.dispose();
|
|
31364
|
+
remote = void 0;
|
|
31365
|
+
routes.set(hostId2, null);
|
|
31366
|
+
};
|
|
31367
|
+
const cleanup = () => {
|
|
31368
|
+
if (!active)
|
|
31369
|
+
return;
|
|
31370
|
+
active = false;
|
|
31371
|
+
stopWatch?.();
|
|
31372
|
+
retire();
|
|
31373
|
+
upstream?.[Symbol.dispose]();
|
|
31374
|
+
upstream = void 0;
|
|
31375
|
+
routes.delete(hostId2);
|
|
31376
|
+
subscriptions.delete(cleanup);
|
|
31377
|
+
};
|
|
31378
|
+
subscriptions.add(cleanup);
|
|
31379
|
+
const publish = async () => {
|
|
31380
|
+
const owner = upstream;
|
|
31381
|
+
const current = generation;
|
|
31382
|
+
if (!owner || !active)
|
|
31383
|
+
return;
|
|
31384
|
+
let request;
|
|
31385
|
+
try {
|
|
31386
|
+
request = owner.getCodexHome();
|
|
31387
|
+
platformRequest = request;
|
|
31388
|
+
const home = await request;
|
|
31389
|
+
if (!active || current !== generation || owner !== upstream)
|
|
31390
|
+
return;
|
|
31391
|
+
if (!/^(?:[A-Za-z]:[\\/]|\\\\)/u.test(home)) {
|
|
31392
|
+
routes.delete(hostId2);
|
|
31393
|
+
listener({ status: "ready", manager: owner });
|
|
31394
|
+
return;
|
|
31395
|
+
}
|
|
31396
|
+
const created = createRemote(hostId2, owner);
|
|
31397
|
+
remote = created;
|
|
31398
|
+
await created.ready;
|
|
31399
|
+
if (!active || current !== generation || owner !== upstream)
|
|
31400
|
+
return;
|
|
31401
|
+
routes.set(hostId2, created.route);
|
|
31402
|
+
listener({ status: "ready", manager: created.rpc });
|
|
31403
|
+
} catch {
|
|
31404
|
+
if (active && current === generation) {
|
|
31405
|
+
remote?.dispose();
|
|
31406
|
+
remote = void 0;
|
|
31407
|
+
routes.delete(hostId2);
|
|
31408
|
+
listener({ status: "ready", manager: owner });
|
|
31409
|
+
}
|
|
31410
|
+
} finally {
|
|
31411
|
+
if (platformRequest === request) {
|
|
31412
|
+
platformRequest = void 0;
|
|
31413
|
+
request?.[Symbol.dispose]();
|
|
31414
|
+
}
|
|
31415
|
+
}
|
|
31416
|
+
};
|
|
31417
|
+
const changed = (state) => {
|
|
31418
|
+
if (!active)
|
|
31419
|
+
return;
|
|
31420
|
+
stopWatch?.();
|
|
31421
|
+
stopWatch = void 0;
|
|
31422
|
+
retire();
|
|
31423
|
+
upstream?.[Symbol.dispose]();
|
|
31424
|
+
upstream = void 0;
|
|
31425
|
+
if (state.status !== "ready") {
|
|
31426
|
+
listener(state);
|
|
31427
|
+
return;
|
|
31428
|
+
}
|
|
31429
|
+
upstream = state.manager.dup();
|
|
31430
|
+
listener({ status: "connecting" });
|
|
31431
|
+
const signals = connectionSignals(hostId2);
|
|
31432
|
+
if (!signals) {
|
|
31433
|
+
void publish();
|
|
31434
|
+
return;
|
|
31435
|
+
}
|
|
31436
|
+
previousState = void 0;
|
|
31437
|
+
previousRevision = void 0;
|
|
31438
|
+
stopWatch = components.scope.watch(({ get }) => {
|
|
31439
|
+
const connection = get(signals.state$), revision = get(signals.revision$);
|
|
31440
|
+
if (connection === previousState && revision === previousRevision)
|
|
31441
|
+
return;
|
|
31442
|
+
previousState = connection;
|
|
31443
|
+
previousRevision = revision;
|
|
31444
|
+
retire();
|
|
31445
|
+
listener({ status: connection === "connected" ? "connecting" : "disconnected" });
|
|
31446
|
+
if (connection === "connected")
|
|
31447
|
+
void publish();
|
|
31448
|
+
});
|
|
31449
|
+
};
|
|
31450
|
+
const original = source.subscribe(hostId2, changed);
|
|
31451
|
+
const result = original.then((lease) => {
|
|
31452
|
+
if (!active)
|
|
31453
|
+
lease[Symbol.dispose]();
|
|
31454
|
+
return {
|
|
31455
|
+
onRpcBroken: (listener2) => lease.onRpcBroken(listener2),
|
|
31456
|
+
[Symbol.dispose]() {
|
|
31457
|
+
cleanup();
|
|
31458
|
+
lease[Symbol.dispose]();
|
|
31459
|
+
}
|
|
31460
|
+
};
|
|
31461
|
+
});
|
|
31462
|
+
Object.assign(result, {
|
|
31463
|
+
onRpcBroken: (listener2) => original.onRpcBroken(listener2),
|
|
31464
|
+
[Symbol.dispose]() {
|
|
31465
|
+
cleanup();
|
|
31466
|
+
original[Symbol.dispose]();
|
|
31467
|
+
}
|
|
31468
|
+
});
|
|
31469
|
+
return result;
|
|
31470
|
+
},
|
|
31471
|
+
[Symbol.dispose]() {
|
|
31472
|
+
if (--refs !== 0)
|
|
31473
|
+
return;
|
|
31474
|
+
for (const cleanup of [...subscriptions])
|
|
31475
|
+
cleanup();
|
|
31476
|
+
source[Symbol.dispose]();
|
|
31477
|
+
}
|
|
31478
|
+
};
|
|
31479
|
+
return { service, route: (hostId2) => routes.get(hostId2) };
|
|
31480
|
+
}
|
|
31481
|
+
|
|
31482
|
+
// packages/desktop-control/dist/renderer-native-rpc-interactions.js
|
|
31483
|
+
function retainNativeRpcInteractions(upstream, manager, hostId2) {
|
|
31484
|
+
let disposed = false;
|
|
31485
|
+
const retained = /* @__PURE__ */ new Set();
|
|
31486
|
+
const requests = /* @__PURE__ */ new Map();
|
|
31487
|
+
const reads = /* @__PURE__ */ new Map();
|
|
31488
|
+
const record6 = (value2) => value2 !== null && typeof value2 === "object";
|
|
31489
|
+
const read = (threadId2) => {
|
|
31490
|
+
const existing = reads.get(threadId2);
|
|
31491
|
+
if (existing) {
|
|
31492
|
+
existing.dirty = true;
|
|
31493
|
+
return existing.promise;
|
|
31494
|
+
}
|
|
31495
|
+
const entry = { promise: Promise.resolve(), dirty: false };
|
|
31496
|
+
reads.set(threadId2, entry);
|
|
31497
|
+
entry.promise = Promise.resolve().then(async () => {
|
|
31498
|
+
do {
|
|
31499
|
+
if (disposed)
|
|
31500
|
+
break;
|
|
31501
|
+
entry.dirty = false;
|
|
31502
|
+
const pending = upstream.getConversation(threadId2);
|
|
31503
|
+
retained.add(pending);
|
|
31504
|
+
try {
|
|
31505
|
+
const conversation = await pending;
|
|
31506
|
+
if (disposed || entry.dirty || !record6(conversation) || !Array.isArray(conversation.requests))
|
|
31507
|
+
continue;
|
|
31508
|
+
const previous = requests.get(threadId2) ?? /* @__PURE__ */ new Set();
|
|
31509
|
+
const next = /* @__PURE__ */ new Set();
|
|
31510
|
+
for (const request of conversation.requests) {
|
|
31511
|
+
if (!record6(request) || typeof request.method !== "string" || !record6(request.params) || (request.params.threadId ?? request.params.conversationId) !== threadId2 || typeof request.id !== "string" && typeof request.id !== "number")
|
|
31512
|
+
continue;
|
|
31513
|
+
next.add(request.id);
|
|
31514
|
+
if (!previous.has(request.id))
|
|
31515
|
+
manager.onRequest(request);
|
|
31516
|
+
}
|
|
31517
|
+
if (next.size)
|
|
31518
|
+
requests.set(threadId2, next);
|
|
31519
|
+
else
|
|
31520
|
+
requests.delete(threadId2);
|
|
31521
|
+
} finally {
|
|
31522
|
+
if (retained.delete(pending))
|
|
31523
|
+
pending[Symbol.dispose]();
|
|
31524
|
+
}
|
|
31525
|
+
} while (!disposed && entry.dirty);
|
|
31526
|
+
}).finally(() => {
|
|
31527
|
+
reads.delete(threadId2);
|
|
31528
|
+
});
|
|
31529
|
+
return entry.promise;
|
|
31530
|
+
};
|
|
31531
|
+
const event = (value2) => {
|
|
31532
|
+
if (disposed || !record6(value2) || typeof value2.conversationId !== "string")
|
|
31533
|
+
return;
|
|
31534
|
+
void read(value2.conversationId).catch(() => void 0);
|
|
31535
|
+
};
|
|
31536
|
+
const subscribe = (input) => {
|
|
31537
|
+
const pending = upstream.subscribe(input);
|
|
31538
|
+
retained.add(pending);
|
|
31539
|
+
return Promise.resolve(pending).then((lease) => {
|
|
31540
|
+
if (disposed)
|
|
31541
|
+
lease[Symbol.dispose]();
|
|
31542
|
+
else
|
|
31543
|
+
retained.add(lease);
|
|
31544
|
+
});
|
|
31545
|
+
};
|
|
31546
|
+
const subscriptions = [
|
|
31547
|
+
"approval-request",
|
|
31548
|
+
"user-input-request",
|
|
31549
|
+
"mcp-elicitation-request",
|
|
31550
|
+
"approval-resolved"
|
|
31551
|
+
].map((name) => subscribe({ type: "event", key: { hostId: hostId2 }, event: name, listener: event }));
|
|
31552
|
+
subscriptions.push(subscribe({
|
|
31553
|
+
type: "notification",
|
|
31554
|
+
key: { hostId: hostId2 },
|
|
31555
|
+
methods: ["serverRequest/resolved"],
|
|
31556
|
+
listener(value2) {
|
|
31557
|
+
if (record6(value2) && record6(value2.params) && typeof value2.params.threadId === "string")
|
|
31558
|
+
event({ conversationId: value2.params.threadId });
|
|
31559
|
+
}
|
|
31560
|
+
}));
|
|
31561
|
+
const ready = Promise.all(subscriptions).then(async () => {
|
|
31562
|
+
if (disposed)
|
|
31563
|
+
return;
|
|
31564
|
+
const pending = upstream.getWorkInProgress();
|
|
31565
|
+
retained.add(pending);
|
|
31566
|
+
try {
|
|
31567
|
+
const work = await pending;
|
|
31568
|
+
if (disposed)
|
|
31569
|
+
return;
|
|
31570
|
+
if (!Array.isArray(work))
|
|
31571
|
+
throw new Error("Native RPC interaction snapshot is unavailable");
|
|
31572
|
+
const threadIds = new Set(work.flatMap((item) => record6(item) && typeof item.conversationId === "string" ? [item.conversationId] : []));
|
|
31573
|
+
await Promise.all([...threadIds].map(read));
|
|
31574
|
+
} finally {
|
|
31575
|
+
if (retained.delete(pending))
|
|
31576
|
+
pending[Symbol.dispose]();
|
|
31577
|
+
}
|
|
31578
|
+
});
|
|
31579
|
+
return {
|
|
31580
|
+
ready,
|
|
31581
|
+
dispose() {
|
|
31582
|
+
if (disposed)
|
|
31583
|
+
return;
|
|
31584
|
+
disposed = true;
|
|
31585
|
+
for (const lease of retained)
|
|
31586
|
+
lease[Symbol.dispose]();
|
|
31587
|
+
retained.clear();
|
|
31588
|
+
requests.clear();
|
|
31589
|
+
}
|
|
31590
|
+
};
|
|
31591
|
+
}
|
|
31592
|
+
|
|
31593
|
+
// packages/desktop-control/dist/renderer-native-rpc-install.js
|
|
31594
|
+
async function installNativeRpcRemoteControlDirect(renderer) {
|
|
31595
|
+
let attempt;
|
|
31596
|
+
const probeId = crypto.randomUUID();
|
|
31597
|
+
try {
|
|
31598
|
+
attempt = await renderer.evaluate(`(() => {
|
|
31599
|
+
if (window.__codexhostNativeRpcRemoteControlV1) return null;
|
|
31600
|
+
const routing = window.__codexhostHostRoutingV1;
|
|
31601
|
+
const owner = routing?.forHost('local')?.manager;
|
|
31602
|
+
if (owner?.kind !== 'main-process-rpc') return null;
|
|
31603
|
+
const catalog = window.__codexhostLoadedModulesV1;
|
|
31604
|
+
if (!catalog?.complete) return null;
|
|
31605
|
+
const key = JSON.stringify([catalog.owner, catalog.urls.filter(url => /renderer-app-server-managers|app-shared/.test(url)).sort()]);
|
|
31606
|
+
const previous = window.__codexhostNativeRpcDiscoveryV1;
|
|
31607
|
+
const sameOwner = previous?.key === key && previous.owner === owner;
|
|
31608
|
+
if (sameOwner && (previous.state !== 'unavailable' || previous.attempts >= 3 || Date.now() < previous.nextRetryAt)) return null;
|
|
31609
|
+
const token = ${JSON.stringify(probeId)};
|
|
31610
|
+
window.__codexhostNativeRpcDiscoveryV1 = {
|
|
31611
|
+
key, owner, token, state: 'discovering', attempts: sameOwner ? previous.attempts + 1 : 1,
|
|
31612
|
+
};
|
|
31613
|
+
return token;
|
|
31614
|
+
})()`);
|
|
31615
|
+
} catch {
|
|
31616
|
+
return false;
|
|
31617
|
+
}
|
|
31618
|
+
if (attempt === null)
|
|
31619
|
+
return false;
|
|
31620
|
+
let installed = false;
|
|
31621
|
+
try {
|
|
31622
|
+
installed = await withNativeRpcComponents(renderer, async (objectId) => {
|
|
31623
|
+
const result = await renderer.command("Runtime.callFunctionOn", {
|
|
31624
|
+
objectId,
|
|
31625
|
+
functionDeclaration: `function() {
|
|
31626
|
+
if (this.document !== document) return false;
|
|
31627
|
+
const retainRendererHostResponses = ${retainRendererHostResponses.toString()};
|
|
31628
|
+
const isolateRendererPrewarmConsumption = ${isolateRendererPrewarmConsumption.toString()};
|
|
31629
|
+
return (${installNativeRpcRemoteControl.toString()})(this, window, {
|
|
31630
|
+
createPolicy: ${createDraftPrewarmPolicyBridge.toString()},
|
|
31631
|
+
createManager: ${createNativeRemoteManager.toString()},
|
|
31632
|
+
createChannel: ${createNativeRpcChannel.toString()},
|
|
31633
|
+
createService: ${createNativeRpcService.toString()},
|
|
31634
|
+
retainInteractions: ${retainNativeRpcInteractions.toString()},
|
|
31635
|
+
});
|
|
31636
|
+
}`,
|
|
31637
|
+
returnByValue: true
|
|
31638
|
+
});
|
|
31639
|
+
return !result.exceptionDetails && result.result?.value === true;
|
|
31640
|
+
});
|
|
31641
|
+
return installed;
|
|
31642
|
+
} catch {
|
|
31643
|
+
return false;
|
|
31644
|
+
} finally {
|
|
31645
|
+
await renderer.evaluate(`(() => {
|
|
31646
|
+
const status = window.__codexhostNativeRpcDiscoveryV1;
|
|
31647
|
+
if (status?.token === ${JSON.stringify(attempt)}) {
|
|
31648
|
+
status.state = ${JSON.stringify(installed ? "ready" : "unavailable")};
|
|
31649
|
+
status.nextRetryAt = Date.now() + 5000 * 2 ** (status.attempts - 1);
|
|
31650
|
+
}
|
|
31651
|
+
})()`).catch(() => void 0);
|
|
31652
|
+
}
|
|
31653
|
+
}
|
|
31654
|
+
|
|
30793
31655
|
// packages/desktop-control/dist/renderer-cdp-control-session.js
|
|
30794
31656
|
function isRecord9(value2) {
|
|
30795
31657
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
@@ -31112,7 +31974,11 @@ var InstalledRendererCdpControlSession = class {
|
|
|
31112
31974
|
var defaultOperations = {
|
|
31113
31975
|
listTargets: (endpoint, signal) => listCdpTargets(endpoint, fetch, signal),
|
|
31114
31976
|
connect: (webSocketDebuggerUrl) => CdpClient.connect(webSocketDebuggerUrl),
|
|
31115
|
-
installDraftPrewarmPolicy
|
|
31977
|
+
async installDraftPrewarmPolicy(renderer) {
|
|
31978
|
+
const status2 = await installRendererDraftPrewarmPolicyDirect(renderer);
|
|
31979
|
+
await installNativeRpcRemoteControlDirect(renderer);
|
|
31980
|
+
return status2;
|
|
31981
|
+
}
|
|
31116
31982
|
};
|
|
31117
31983
|
async function createRendererCdpControlSession(options) {
|
|
31118
31984
|
const enabledAgents = options.enabledAgents;
|
|
@@ -36640,12 +37506,13 @@ var ExternalThreadRuntime = class {
|
|
|
36640
37506
|
}
|
|
36641
37507
|
try {
|
|
36642
37508
|
const aligned = await this.#repository.alignSnapshot(thread.record, snapshot2.value);
|
|
37509
|
+
const turns = aligned.record.state === "creating" && !aligned.record.nativeSessionRef && snapshot2.value.turns.length === 0 ? thread.turns : aligned.turns;
|
|
36643
37510
|
thread.record = aligned.record;
|
|
36644
|
-
thread.turns =
|
|
37511
|
+
thread.turns = turns;
|
|
36645
37512
|
thread.historyHydrated = true;
|
|
36646
37513
|
thread.thread = externalThreadValue({
|
|
36647
37514
|
record: aligned.record,
|
|
36648
|
-
turns
|
|
37515
|
+
turns,
|
|
36649
37516
|
sessionId: thread.sessionId,
|
|
36650
37517
|
running: thread.running
|
|
36651
37518
|
});
|
|
@@ -44629,7 +45496,10 @@ var AppServerHost = class {
|
|
|
44629
45496
|
request,
|
|
44630
45497
|
location,
|
|
44631
45498
|
(hostThreadId) => this.#repository.setArchived(hostThreadId, archived),
|
|
44632
|
-
"External Thread archive state could not be persisted"
|
|
45499
|
+
"External Thread archive state could not be persisted",
|
|
45500
|
+
// A loaded Thread whose deferred native Session never arrived (its first Turn
|
|
45501
|
+
// failed first) is still on Desktop's list and must remain archivable.
|
|
45502
|
+
true
|
|
44633
45503
|
);
|
|
44634
45504
|
if (!updated) return;
|
|
44635
45505
|
await this.#writer.json(
|