@codexhost/cli-linux-arm64 0.18.0-beta.4 → 0.18.0-beta.5
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 +93 -53
- package/app/console-web.js +159 -119
- package/app/desktop-controller.mjs +283 -113
- package/app/host-runtime.mjs +2129 -1529
- package/app/plugins/antigravity/plugin.mjs +787 -303
- package/app/plugins/claude-code/plugin.mjs +85 -45
- package/app/plugins/codebuddy/plugin.mjs +99 -59
- package/app/plugins/codex-usage/plugin.mjs +85 -45
- package/app/plugins/copilot/plugin.mjs +90 -50
- package/app/plugins/cursor-cli/plugin.mjs +113 -73
- package/app/plugins/deepseek-harness/plugin.mjs +116 -76
- package/app/plugins/devin/plugin.mjs +90 -50
- package/app/plugins/grok/plugin.mjs +96 -56
- package/app/plugins/hermes/plugin.mjs +77 -37
- package/app/plugins/kimi-code/plugin.mjs +94 -54
- package/app/plugins/kiro-cli/plugin.mjs +90 -50
- package/app/plugins/omp/plugin.mjs +81 -41
- package/app/plugins/opencode/plugin.mjs +78 -38
- package/app/plugins/pi/plugin.mjs +94 -54
- package/app/plugins/qoder/plugin.mjs +106 -66
- package/app/plugins/qoder-cn/plugin.mjs +106 -66
- package/app/plugins/qwen-code/plugin.mjs +101 -61
- package/app/plugins/workbuddy/plugin.mjs +99 -59
- package/app/plugins/zcode/plugin.mjs +82 -42
- package/app/renderer-extension.js +353 -295
- package/app/web/assets/{index-D1dOzBMI.js → index-C0aXz2jD.js} +63 -63
- package/app/web/codex-agent.png +0 -0
- package/app/web/codexhost-settings.js +154 -114
- package/app/web/index.html +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +61 -61
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +8 -8
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +12 -12
- package/app/web/plugins/deepseek-ai__dsh-client-ui-permission-presets/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +8 -8
- package/app/web/sw.js +1 -6
- package/app/web-modules/server.mjs +2079 -1201
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __export = (
|
|
2
|
+
var __export = (target2, all) => {
|
|
3
3
|
for (var name in all)
|
|
4
|
-
__defProp(
|
|
4
|
+
__defProp(target2, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// packages/desktop-control/src/production-controller.ts
|
|
@@ -29,7 +29,7 @@ async function openRendererLocalPage(execute, url2, targets) {
|
|
|
29
29
|
initiator: "codexhost_local_page"
|
|
30
30
|
});
|
|
31
31
|
const deadline = Date.now() + 5e3;
|
|
32
|
-
while (!(await targets()).some((
|
|
32
|
+
while (!(await targets()).some((target2) => target2.url === url2)) {
|
|
33
33
|
if (Date.now() >= deadline)
|
|
34
34
|
throw new Error("Codex in-app browser did not load the local page");
|
|
35
35
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
@@ -145,7 +145,7 @@ async function listCdpTargets(endpoint, fetchImpl = defaultFetch, signal) {
|
|
|
145
145
|
if (!response.ok) throw new Error(`CDP target discovery failed with HTTP ${response.status}`);
|
|
146
146
|
const value = await response.json();
|
|
147
147
|
if (!Array.isArray(value)) throw new Error("CDP target discovery did not return an array");
|
|
148
|
-
return value.map(parseTarget).filter((
|
|
148
|
+
return value.map(parseTarget).filter((target2) => target2 !== null);
|
|
149
149
|
}
|
|
150
150
|
var CdpClient = class _CdpClient {
|
|
151
151
|
#commandTimeoutMs;
|
|
@@ -313,6 +313,116 @@ var CdpClient = class _CdpClient {
|
|
|
313
313
|
}
|
|
314
314
|
};
|
|
315
315
|
|
|
316
|
+
// packages/desktop-control/src/renderer-remote-sessions.ts
|
|
317
|
+
async function rendererRemoteSession(target2, operation) {
|
|
318
|
+
const routing = target2.__codexhostHostRoutingV1;
|
|
319
|
+
if (!routing) throw new Error("Desktop remote session routing is unavailable");
|
|
320
|
+
const ids = [...new Set(routing.knownHostIds?.() ?? [])].filter(
|
|
321
|
+
(id) => /^remote-(?:ssh(?:-|:)|control:)/u.test(id)
|
|
322
|
+
);
|
|
323
|
+
const state = target2.__codexhostRemoteSessionsV1 ??= { managers: /* @__PURE__ */ new WeakMap() };
|
|
324
|
+
if (operation.kind === "hosts") {
|
|
325
|
+
const api = target2.__codexhostRendererBindingProbeV1;
|
|
326
|
+
if (!api?.remoteConnections)
|
|
327
|
+
return ids.map((hostId2) => ({ hostId: hostId2, online: !!routing.forHost(hostId2) }));
|
|
328
|
+
const configured = await api.remoteConnections({ action: "catalog" });
|
|
329
|
+
const connections = Array.isArray(configured) ? configured : [];
|
|
330
|
+
const attempts = state.reconnectAttempts ??= /* @__PURE__ */ new Set();
|
|
331
|
+
return Promise.all(
|
|
332
|
+
[.../* @__PURE__ */ new Set([...ids, ...connections.map((c) => c.hostId)])].map(async (hostId2) => {
|
|
333
|
+
const connection = connections.find((c) => c.hostId === hostId2);
|
|
334
|
+
let status = await api.remoteConnections({ action: "state", hostId: hostId2 }).catch(() => ({ state: "error" }));
|
|
335
|
+
if (connection?.autoConnect === false) attempts.delete(hostId2);
|
|
336
|
+
if (connection?.autoConnect && status.state === "disconnected" && !attempts.has(hostId2)) {
|
|
337
|
+
attempts.add(hostId2);
|
|
338
|
+
await api.remoteConnections({ action: "connect", hostId: hostId2, enabled: true }).catch(() => void 0);
|
|
339
|
+
status = await api.remoteConnections({ action: "state", hostId: hostId2 }).catch(() => ({ state: "error" }));
|
|
340
|
+
}
|
|
341
|
+
return {
|
|
342
|
+
hostId: hostId2,
|
|
343
|
+
displayName: connection?.displayName ?? (hostId2.startsWith("remote-control:") ? "Remote Control" : hostId2.replace(/^remote-ssh-(?:discovered|codex-managed):/u, "")),
|
|
344
|
+
state: status.state,
|
|
345
|
+
online: status.state === "connected" && !!routing.forHost(hostId2)
|
|
346
|
+
};
|
|
347
|
+
})
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
if (!ids.includes(operation.hostId))
|
|
351
|
+
throw new Error("Remote Host is offline or no longer known to Desktop");
|
|
352
|
+
const route = routing.forHost(operation.hostId);
|
|
353
|
+
const manager = route?.manager;
|
|
354
|
+
if (!route || !manager) throw new Error("Remote Host is offline");
|
|
355
|
+
let generation = state.managers.get(route);
|
|
356
|
+
if (!generation) {
|
|
357
|
+
generation = { epoch: crypto.randomUUID(), answered: /* @__PURE__ */ new Set() };
|
|
358
|
+
state.managers.set(route, generation);
|
|
359
|
+
}
|
|
360
|
+
if ("epoch" in operation && operation.epoch !== generation.epoch)
|
|
361
|
+
throw new Error("Remote connection changed; refresh before operating");
|
|
362
|
+
if (operation.kind === "list")
|
|
363
|
+
return manager.sendRequest("thread/list", {
|
|
364
|
+
cursor: operation.cursor,
|
|
365
|
+
archived: operation.archived,
|
|
366
|
+
limit: 100
|
|
367
|
+
});
|
|
368
|
+
const threadId = operation.threadId;
|
|
369
|
+
const pendingRequests = async () => {
|
|
370
|
+
const conversation = await manager.getConversation?.(threadId);
|
|
371
|
+
if (routing.forHost(operation.hostId) !== route)
|
|
372
|
+
throw new Error("Remote connection changed during interaction read");
|
|
373
|
+
return Array.isArray(conversation?.requests) ? conversation.requests : [];
|
|
374
|
+
};
|
|
375
|
+
if (operation.kind === "read") {
|
|
376
|
+
const result = await manager.sendRequest("thread/read", { threadId, includeTurns: true });
|
|
377
|
+
if (routing.forHost(operation.hostId) !== route)
|
|
378
|
+
throw new Error("Remote connection changed during read");
|
|
379
|
+
const requests = await pendingRequests();
|
|
380
|
+
return {
|
|
381
|
+
result,
|
|
382
|
+
epoch: generation.epoch,
|
|
383
|
+
interactionsAvailable: !!manager.getConversation && !!manager.replyWithCommandExecutionApprovalDecision && !!manager.replyWithFileChangeApprovalDecision,
|
|
384
|
+
requests: requests.filter(
|
|
385
|
+
(request) => (request.params.threadId ?? request.params.conversationId) === threadId && !generation.answered.has(JSON.stringify([threadId, request.id]))
|
|
386
|
+
)
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
if (operation.kind === "respond") {
|
|
390
|
+
const key = JSON.stringify([threadId, operation.requestId]);
|
|
391
|
+
const request = (await pendingRequests()).find(
|
|
392
|
+
(item) => item.id === operation.requestId && (item.params.threadId ?? item.params.conversationId) === threadId
|
|
393
|
+
);
|
|
394
|
+
if (!request || generation.answered.has(key) || !manager.replyWithCommandExecutionApprovalDecision || !manager.replyWithFileChangeApprovalDecision)
|
|
395
|
+
throw new Error("Native interaction is no longer pending");
|
|
396
|
+
if (!["item/commandExecution/requestApproval", "item/fileChange/requestApproval"].includes(
|
|
397
|
+
request.method
|
|
398
|
+
) || !["accept", "decline", "cancel"].includes(String(operation.result.decision)) || Object.keys(operation.result).some((key2) => key2 !== "decision"))
|
|
399
|
+
throw new Error("Unsupported native interaction response");
|
|
400
|
+
generation.answered.add(key);
|
|
401
|
+
const respond2 = request.method === "item/commandExecution/requestApproval" ? manager.replyWithCommandExecutionApprovalDecision : manager.replyWithFileChangeApprovalDecision;
|
|
402
|
+
await respond2.call(manager, threadId, request.id, String(operation.result.decision));
|
|
403
|
+
return { accepted: true };
|
|
404
|
+
}
|
|
405
|
+
switch (operation.kind) {
|
|
406
|
+
case "prompt":
|
|
407
|
+
await manager.sendRequest("thread/resume", { threadId });
|
|
408
|
+
if (routing.forHost(operation.hostId) !== route)
|
|
409
|
+
throw new Error("Remote connection changed during resume");
|
|
410
|
+
return manager.sendRequest("turn/start", {
|
|
411
|
+
threadId,
|
|
412
|
+
input: [{ type: "text", text: operation.text, text_elements: [] }],
|
|
413
|
+
...operation.requestId ? { clientUserMessageId: operation.requestId } : {}
|
|
414
|
+
});
|
|
415
|
+
case "interrupt":
|
|
416
|
+
return manager.sendRequest("turn/interrupt", { threadId, turnId: operation.turnId });
|
|
417
|
+
case "rename":
|
|
418
|
+
return manager.sendRequest("thread/name/set", { threadId, name: operation.name });
|
|
419
|
+
case "archive":
|
|
420
|
+
return manager.sendRequest(operation.archived ? "thread/archive" : "thread/unarchive", {
|
|
421
|
+
threadId
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
316
426
|
// node_modules/zod/v4/classic/external.js
|
|
317
427
|
var external_exports = {};
|
|
318
428
|
__export(external_exports, {
|
|
@@ -1060,8 +1170,8 @@ function defineLazy(object2, key, getter) {
|
|
|
1060
1170
|
function objectClone(obj) {
|
|
1061
1171
|
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
1062
1172
|
}
|
|
1063
|
-
function assignProp(
|
|
1064
|
-
Object.defineProperty(
|
|
1173
|
+
function assignProp(target2, prop, value) {
|
|
1174
|
+
Object.defineProperty(target2, prop, {
|
|
1065
1175
|
value,
|
|
1066
1176
|
writable: true,
|
|
1067
1177
|
enumerable: true,
|
|
@@ -1244,35 +1354,35 @@ function normalizeParams(_params) {
|
|
|
1244
1354
|
return params;
|
|
1245
1355
|
}
|
|
1246
1356
|
function createTransparentProxy(getter) {
|
|
1247
|
-
let
|
|
1357
|
+
let target2;
|
|
1248
1358
|
return new Proxy({}, {
|
|
1249
1359
|
get(_, prop, receiver) {
|
|
1250
|
-
|
|
1251
|
-
return Reflect.get(
|
|
1360
|
+
target2 ?? (target2 = getter());
|
|
1361
|
+
return Reflect.get(target2, prop, receiver);
|
|
1252
1362
|
},
|
|
1253
1363
|
set(_, prop, value, receiver) {
|
|
1254
|
-
|
|
1255
|
-
return Reflect.set(
|
|
1364
|
+
target2 ?? (target2 = getter());
|
|
1365
|
+
return Reflect.set(target2, prop, value, receiver);
|
|
1256
1366
|
},
|
|
1257
1367
|
has(_, prop) {
|
|
1258
|
-
|
|
1259
|
-
return Reflect.has(
|
|
1368
|
+
target2 ?? (target2 = getter());
|
|
1369
|
+
return Reflect.has(target2, prop);
|
|
1260
1370
|
},
|
|
1261
1371
|
deleteProperty(_, prop) {
|
|
1262
|
-
|
|
1263
|
-
return Reflect.deleteProperty(
|
|
1372
|
+
target2 ?? (target2 = getter());
|
|
1373
|
+
return Reflect.deleteProperty(target2, prop);
|
|
1264
1374
|
},
|
|
1265
1375
|
ownKeys(_) {
|
|
1266
|
-
|
|
1267
|
-
return Reflect.ownKeys(
|
|
1376
|
+
target2 ?? (target2 = getter());
|
|
1377
|
+
return Reflect.ownKeys(target2);
|
|
1268
1378
|
},
|
|
1269
1379
|
getOwnPropertyDescriptor(_, prop) {
|
|
1270
|
-
|
|
1271
|
-
return Reflect.getOwnPropertyDescriptor(
|
|
1380
|
+
target2 ?? (target2 = getter());
|
|
1381
|
+
return Reflect.getOwnPropertyDescriptor(target2, prop);
|
|
1272
1382
|
},
|
|
1273
1383
|
defineProperty(_, prop, descriptor) {
|
|
1274
|
-
|
|
1275
|
-
return Reflect.defineProperty(
|
|
1384
|
+
target2 ?? (target2 = getter());
|
|
1385
|
+
return Reflect.defineProperty(target2, prop, descriptor);
|
|
1276
1386
|
}
|
|
1277
1387
|
});
|
|
1278
1388
|
}
|
|
@@ -11724,15 +11834,15 @@ function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
|
|
|
11724
11834
|
|
|
11725
11835
|
// node_modules/zod/v4/core/to-json-schema.js
|
|
11726
11836
|
function initializeContext(params) {
|
|
11727
|
-
let
|
|
11728
|
-
if (
|
|
11729
|
-
|
|
11730
|
-
if (
|
|
11731
|
-
|
|
11837
|
+
let target2 = params?.target ?? "draft-2020-12";
|
|
11838
|
+
if (target2 === "draft-4")
|
|
11839
|
+
target2 = "draft-04";
|
|
11840
|
+
if (target2 === "draft-7")
|
|
11841
|
+
target2 = "draft-07";
|
|
11732
11842
|
return {
|
|
11733
11843
|
processors: params.processors ?? {},
|
|
11734
11844
|
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
11735
|
-
target,
|
|
11845
|
+
target: target2,
|
|
11736
11846
|
unrepresentable: params?.unrepresentable ?? "throw",
|
|
11737
11847
|
override: params?.override ?? (() => {
|
|
11738
11848
|
}),
|
|
@@ -12074,8 +12184,8 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
|
12074
12184
|
return finalize(ctx, schema);
|
|
12075
12185
|
};
|
|
12076
12186
|
var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
12077
|
-
const { libraryOptions, target } = params ?? {};
|
|
12078
|
-
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
12187
|
+
const { libraryOptions, target: target2 } = params ?? {};
|
|
12188
|
+
const ctx = initializeContext({ ...libraryOptions ?? {}, target: target2, io, processors });
|
|
12079
12189
|
process2(schema, ctx);
|
|
12080
12190
|
extractDefs(ctx, schema);
|
|
12081
12191
|
return finalize(ctx, schema);
|
|
@@ -13134,8 +13244,8 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
13134
13244
|
catch(params) {
|
|
13135
13245
|
return _catch2(this, params);
|
|
13136
13246
|
},
|
|
13137
|
-
pipe(
|
|
13138
|
-
return pipe(this,
|
|
13247
|
+
pipe(target2) {
|
|
13248
|
+
return pipe(this, target2);
|
|
13139
13249
|
},
|
|
13140
13250
|
readonly() {
|
|
13141
13251
|
return readonly(this);
|
|
@@ -15365,15 +15475,15 @@ var threadOwnershipListResultSchema = external_exports.object({
|
|
|
15365
15475
|
threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
|
|
15366
15476
|
}).strict().superRefine(({ threads }, context) => {
|
|
15367
15477
|
const seen = /* @__PURE__ */ new Set();
|
|
15368
|
-
for (const [index,
|
|
15369
|
-
if (seen.has(
|
|
15478
|
+
for (const [index, thread2] of threads.entries()) {
|
|
15479
|
+
if (seen.has(thread2.threadId)) {
|
|
15370
15480
|
context.addIssue({
|
|
15371
15481
|
code: "custom",
|
|
15372
15482
|
message: "Thread ownership-list results must be unique",
|
|
15373
15483
|
path: ["threads", index, "threadId"]
|
|
15374
15484
|
});
|
|
15375
15485
|
}
|
|
15376
|
-
seen.add(
|
|
15486
|
+
seen.add(thread2.threadId);
|
|
15377
15487
|
}
|
|
15378
15488
|
});
|
|
15379
15489
|
var threadSteeringInspectParamsSchema = external_exports.object({
|
|
@@ -16707,6 +16817,44 @@ var remoteSshSetupParamsSchema = external_exports.object({
|
|
|
16707
16817
|
}).strict();
|
|
16708
16818
|
var remoteSshSetupResultSchema = external_exports.object({ state: external_exports.enum(["installed", "not-installed"]) }).strict();
|
|
16709
16819
|
|
|
16820
|
+
// packages/shared-contracts/dist/remote-sessions.js
|
|
16821
|
+
var REMOTE_CONTROLLER_REQUEST_MAX_BYTES = 16 * 1024;
|
|
16822
|
+
var identity = external_exports.string().min(1).max(1024);
|
|
16823
|
+
var target = { hostId: identity.regex(/^remote-(?:ssh(?:-|:)|control:)/u) };
|
|
16824
|
+
var thread = { ...target, threadId: identity };
|
|
16825
|
+
var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
16826
|
+
external_exports.strictObject({ kind: external_exports.literal("hosts") }),
|
|
16827
|
+
external_exports.strictObject({
|
|
16828
|
+
kind: external_exports.literal("list"),
|
|
16829
|
+
...target,
|
|
16830
|
+
cursor: external_exports.string().nullable(),
|
|
16831
|
+
archived: external_exports.boolean()
|
|
16832
|
+
}),
|
|
16833
|
+
external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
|
|
16834
|
+
external_exports.strictObject({
|
|
16835
|
+
kind: external_exports.literal("prompt"),
|
|
16836
|
+
...thread,
|
|
16837
|
+
epoch: identity,
|
|
16838
|
+
text: external_exports.string().min(1).max(8e3),
|
|
16839
|
+
requestId: identity.optional()
|
|
16840
|
+
}),
|
|
16841
|
+
external_exports.strictObject({ kind: external_exports.literal("interrupt"), ...thread, epoch: identity, turnId: identity }),
|
|
16842
|
+
external_exports.strictObject({
|
|
16843
|
+
kind: external_exports.literal("rename"),
|
|
16844
|
+
...thread,
|
|
16845
|
+
epoch: identity,
|
|
16846
|
+
name: external_exports.string().min(1).max(512)
|
|
16847
|
+
}),
|
|
16848
|
+
external_exports.strictObject({ kind: external_exports.literal("archive"), ...thread, epoch: identity, archived: external_exports.boolean() }),
|
|
16849
|
+
external_exports.strictObject({
|
|
16850
|
+
kind: external_exports.literal("respond"),
|
|
16851
|
+
...thread,
|
|
16852
|
+
epoch: identity,
|
|
16853
|
+
requestId: external_exports.union([identity, external_exports.number().int()]),
|
|
16854
|
+
result: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
16855
|
+
})
|
|
16856
|
+
]);
|
|
16857
|
+
|
|
16710
16858
|
// packages/shared-contracts/dist/remote-connections.js
|
|
16711
16859
|
var hostId = external_exports.string().min(1).max(1024);
|
|
16712
16860
|
var codexSshConnectionSchema = external_exports.object({
|
|
@@ -16727,7 +16875,9 @@ var codexSshDraftSchema = external_exports.strictObject({
|
|
|
16727
16875
|
identity: external_exports.string().max(4096).nullable()
|
|
16728
16876
|
});
|
|
16729
16877
|
var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
|
|
16878
|
+
external_exports.strictObject({ action: external_exports.literal("session"), operation: remoteSessionOperationSchema }),
|
|
16730
16879
|
external_exports.strictObject({ action: external_exports.literal("list") }),
|
|
16880
|
+
external_exports.strictObject({ action: external_exports.literal("catalog") }),
|
|
16731
16881
|
external_exports.strictObject({
|
|
16732
16882
|
action: external_exports.literal("read-thread"),
|
|
16733
16883
|
hostId: hostId.refine((id) => id !== "local"),
|
|
@@ -16800,6 +16950,8 @@ var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT
|
|
|
16800
16950
|
var MAX_REPLY_BYTES = 1024 * 1024;
|
|
16801
16951
|
function remoteConnectionsExpression(input) {
|
|
16802
16952
|
const request = remoteConnectionsRequestSchema.parse(input);
|
|
16953
|
+
if (request.action === "session")
|
|
16954
|
+
return `(async () => { try { return {result:await (${rendererRemoteSession.toString()})(window,${JSON.stringify(request.operation)})}; } catch(error) {return {error:{code:-32090,message:String(error?.message ?? error)}};} })()`;
|
|
16803
16955
|
return `(async () => {
|
|
16804
16956
|
try {
|
|
16805
16957
|
const api = window.__codexhostRendererBindingProbeV1;
|
|
@@ -16870,7 +17022,7 @@ async function serveLocalPage(socket, url2, open) {
|
|
|
16870
17022
|
}
|
|
16871
17023
|
|
|
16872
17024
|
// packages/desktop-control/src/controller-attachment-server.ts
|
|
16873
|
-
var MAX_REQUEST_BYTES =
|
|
17025
|
+
var MAX_REQUEST_BYTES = REMOTE_CONTROLLER_REQUEST_MAX_BYTES;
|
|
16874
17026
|
function validPort(value) {
|
|
16875
17027
|
return Number.isInteger(value) && value >= 1 && value <= 65535;
|
|
16876
17028
|
}
|
|
@@ -16931,19 +17083,19 @@ async function startControllerAttachmentServer(options) {
|
|
|
16931
17083
|
return;
|
|
16932
17084
|
}
|
|
16933
17085
|
socket.setTimeout(
|
|
16934
|
-
input.action === "read-thread" ? REMOTE_THREAD_CONTROL_TIMEOUT_MS : 3e4,
|
|
17086
|
+
input.action === "read-thread" || input.action === "session" ? REMOTE_THREAD_CONTROL_TIMEOUT_MS : 3e4,
|
|
16935
17087
|
() => socket.destroy()
|
|
16936
17088
|
);
|
|
16937
17089
|
const operation = options.remoteConnections;
|
|
16938
17090
|
void Promise.resolve().then(() => operation(input)).then(
|
|
16939
17091
|
(reply) => {
|
|
16940
17092
|
const serialized = JSON.stringify(reply) + "\n";
|
|
16941
|
-
if (input.action === "read-thread" && Buffer.byteLength(serialized) > REMOTE_THREAD_REPLY_MAX_BYTES) {
|
|
17093
|
+
if ((input.action === "read-thread" || input.action === "session") && Buffer.byteLength(serialized) > REMOTE_THREAD_REPLY_MAX_BYTES) {
|
|
16942
17094
|
socket.end(
|
|
16943
17095
|
JSON.stringify({
|
|
16944
17096
|
error: {
|
|
16945
17097
|
code: -32094,
|
|
16946
|
-
message: "Thread snapshot exceeds the 16 MiB response limit; reduce the message page size. Oversized individual results are not supported."
|
|
17098
|
+
message: input.action === "session" ? "Remote Thread snapshot exceeds the 16 MiB response limit; open this Thread in Codex Desktop. Paged remote snapshots are not supported." : "Thread snapshot exceeds the 16 MiB response limit; reduce the message page size. Oversized individual results are not supported."
|
|
16947
17099
|
}
|
|
16948
17100
|
}) + "\n"
|
|
16949
17101
|
);
|
|
@@ -17114,9 +17266,9 @@ function committedReactAncestors(value) {
|
|
|
17114
17266
|
const MAX_VISITED_FIBERS = 2e5;
|
|
17115
17267
|
const fiber = (value2) => typeof value2 === "object" && value2 !== null ? value2 : null;
|
|
17116
17268
|
const exhausted = () => {
|
|
17117
|
-
const
|
|
17118
|
-
if (typeof
|
|
17119
|
-
|
|
17269
|
+
const target2 = globalThis;
|
|
17270
|
+
if (typeof target2.dispatchEvent === "function" && typeof CustomEvent === "function")
|
|
17271
|
+
target2.dispatchEvent(
|
|
17120
17272
|
new CustomEvent("codexhost:react-fiber-walk-limit", {
|
|
17121
17273
|
detail: { limit: MAX_VISITED_FIBERS }
|
|
17122
17274
|
})
|
|
@@ -17182,8 +17334,8 @@ function committedReactAncestors(value) {
|
|
|
17182
17334
|
}
|
|
17183
17335
|
|
|
17184
17336
|
// packages/desktop-control/src/renderer-host-response-ownership.ts
|
|
17185
|
-
function retainRendererHostResponses(client, hostId2,
|
|
17186
|
-
if (typeof client.addRequestLifecycleListener !== "function" || typeof
|
|
17337
|
+
function retainRendererHostResponses(client, hostId2, target2) {
|
|
17338
|
+
if (typeof client.addRequestLifecycleListener !== "function" || typeof target2.addEventListener !== "function" || typeof target2.removeEventListener !== "function")
|
|
17187
17339
|
return () => {
|
|
17188
17340
|
};
|
|
17189
17341
|
const isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -17192,14 +17344,14 @@ function retainRendererHostResponses(client, hostId2, target) {
|
|
|
17192
17344
|
let unsubscribe = () => {
|
|
17193
17345
|
};
|
|
17194
17346
|
const detach = () => {
|
|
17195
|
-
|
|
17347
|
+
target2.removeEventListener?.("message", receive);
|
|
17196
17348
|
unsubscribe();
|
|
17197
17349
|
};
|
|
17198
17350
|
const receive = (event) => {
|
|
17199
17351
|
const { source, origin, data } = event;
|
|
17200
|
-
if (source != null && source !==
|
|
17201
|
-
const ownOrigin =
|
|
17202
|
-
if (source ===
|
|
17352
|
+
if (source != null && source !== target2) return;
|
|
17353
|
+
const ownOrigin = target2.location?.origin;
|
|
17354
|
+
if (source === target2 && ownOrigin && ownOrigin !== "null" && origin !== ownOrigin) return;
|
|
17203
17355
|
if (!isRecord3(data) || data.type !== "mcp-response" || data.hostId !== hostId2) return;
|
|
17204
17356
|
const message = data.message;
|
|
17205
17357
|
if (!isRecord3(message)) return;
|
|
@@ -17213,7 +17365,7 @@ function retainRendererHostResponses(client, hostId2, target) {
|
|
|
17213
17365
|
else client.onResult(id, message.result, data.hostMetrics);
|
|
17214
17366
|
});
|
|
17215
17367
|
};
|
|
17216
|
-
|
|
17368
|
+
target2.addEventListener("message", receive);
|
|
17217
17369
|
unsubscribe = client.addRequestLifecycleListener((event) => {
|
|
17218
17370
|
if (!isRecord3(event) || event.hostId !== hostId2) return;
|
|
17219
17371
|
const id = event.id;
|
|
@@ -17323,7 +17475,7 @@ function isolateRendererPrewarmConsumption(manager, discardExternal) {
|
|
|
17323
17475
|
}
|
|
17324
17476
|
|
|
17325
17477
|
// packages/desktop-control/src/renderer-draft-prewarm-runtime.ts
|
|
17326
|
-
function createDraftPrewarmPolicyBridge(manager, bridge, hostId2,
|
|
17478
|
+
function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target2, prewarmedThreadManager, isCurrentManager, retainResponses = retainRendererHostResponses, isolateConsumption = isolateRendererPrewarmConsumption, sendControlRequest) {
|
|
17327
17479
|
let disposed = false;
|
|
17328
17480
|
const originalSend = bridge.sendRequest;
|
|
17329
17481
|
const controlSend = (method, parameters) => sendControlRequest ? sendControlRequest(method, parameters) : originalSend.call(bridge, method, parameters);
|
|
@@ -17347,7 +17499,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
|
|
|
17347
17499
|
};
|
|
17348
17500
|
const isRemoteControlHost = hostId2.startsWith("remote-control:");
|
|
17349
17501
|
const retireResponses = isRemoteControlHost ? () => {
|
|
17350
|
-
} : retainResponses(bridge, hostId2,
|
|
17502
|
+
} : retainResponses(bridge, hostId2, target2);
|
|
17351
17503
|
const knownExternalThreadIds = /* @__PURE__ */ new Set();
|
|
17352
17504
|
const knownOfficialThreadIds = /* @__PURE__ */ new Set();
|
|
17353
17505
|
const threadOwnershipResolutions = /* @__PURE__ */ new Map();
|
|
@@ -17439,7 +17591,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
|
|
|
17439
17591
|
const observeBridgeResult = (request, result) => {
|
|
17440
17592
|
if (!request || !isRecord3(result)) return;
|
|
17441
17593
|
if (request.method === "thread/list" && Array.isArray(result.data)) {
|
|
17442
|
-
for (const
|
|
17594
|
+
for (const thread2 of result.data) rememberExternalThread(thread2);
|
|
17443
17595
|
return;
|
|
17444
17596
|
}
|
|
17445
17597
|
if (request.method === "thread/start" || request.method === "thread/read" || request.method === "thread/resume") {
|
|
@@ -17736,14 +17888,14 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
|
|
|
17736
17888
|
if (!isRecord3(parameters) || parameters.ephemeral === true) return;
|
|
17737
17889
|
const cwd = parameters.cwd;
|
|
17738
17890
|
if (typeof cwd !== "string" || cwd.length === 0) return;
|
|
17739
|
-
const drafts = isRecord3(
|
|
17891
|
+
const drafts = isRecord3(target2.__codexhostDraftWorkspacesV1) ? target2.__codexhostDraftWorkspacesV1 : {};
|
|
17740
17892
|
drafts[hostId2] = cwd;
|
|
17741
|
-
Object.defineProperty(
|
|
17893
|
+
Object.defineProperty(target2, "__codexhostDraftWorkspacesV1", {
|
|
17742
17894
|
configurable: true,
|
|
17743
17895
|
value: drafts
|
|
17744
17896
|
});
|
|
17745
|
-
if (typeof
|
|
17746
|
-
|
|
17897
|
+
if (typeof target2.dispatchEvent === "function" && typeof CustomEvent === "function") {
|
|
17898
|
+
target2.dispatchEvent(
|
|
17747
17899
|
new CustomEvent("codexhost:draft-workspace", { detail: { hostId: hostId2, cwd } })
|
|
17748
17900
|
);
|
|
17749
17901
|
}
|
|
@@ -17790,8 +17942,8 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
|
|
|
17790
17942
|
}
|
|
17791
17943
|
handleOuterNotification(message.method, message.params);
|
|
17792
17944
|
};
|
|
17793
|
-
const observesWindowNotifications = isRemoteControlHost && typeof
|
|
17794
|
-
if (observesWindowNotifications)
|
|
17945
|
+
const observesWindowNotifications = isRemoteControlHost && typeof target2.addEventListener === "function" && typeof target2.removeEventListener === "function";
|
|
17946
|
+
if (observesWindowNotifications) target2.addEventListener?.("message", routedWindowMessage);
|
|
17795
17947
|
const routedOnNotification = (method, parameters) => {
|
|
17796
17948
|
if (!handleOuterNotification(method, parameters)) {
|
|
17797
17949
|
originalOnNotification.call(manager, method, parameters);
|
|
@@ -17858,7 +18010,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
|
|
|
17858
18010
|
bridge.prewarmThreadStart = originalPrewarm;
|
|
17859
18011
|
}
|
|
17860
18012
|
if (observesWindowNotifications) {
|
|
17861
|
-
|
|
18013
|
+
target2.removeEventListener?.("message", routedWindowMessage);
|
|
17862
18014
|
} else if (manager.onNotification === routedOnNotification) {
|
|
17863
18015
|
manager.onNotification = originalOnNotification;
|
|
17864
18016
|
}
|
|
@@ -17971,11 +18123,11 @@ function resolveRendererHostManager(discovery, hostId2, managerFrom = requestMan
|
|
|
17971
18123
|
}
|
|
17972
18124
|
|
|
17973
18125
|
// packages/desktop-control/src/renderer-host-routing.ts
|
|
17974
|
-
function installRendererHostRouting(root,
|
|
17975
|
-
const existing =
|
|
18126
|
+
function installRendererHostRouting(root, target2, discover, resolve, createPolicy, readConnection, publishRouting = true) {
|
|
18127
|
+
const existing = target2.__codexhostHostRoutingV1;
|
|
17976
18128
|
if (publishRouting && existing) return existing;
|
|
17977
18129
|
if (publishRouting)
|
|
17978
|
-
|
|
18130
|
+
target2.__codexhostDraftPrewarmPolicyV1?.dispose?.();
|
|
17979
18131
|
let disposed = false;
|
|
17980
18132
|
let lastDiscovery = null;
|
|
17981
18133
|
const routes = /* @__PURE__ */ new Map();
|
|
@@ -18032,7 +18184,7 @@ function installRendererHostRouting(root, target, discover, resolve, createPolic
|
|
|
18032
18184
|
manager,
|
|
18033
18185
|
bridge,
|
|
18034
18186
|
hostId2,
|
|
18035
|
-
|
|
18187
|
+
target2,
|
|
18036
18188
|
prewarmed,
|
|
18037
18189
|
() => lookup(hostId2) === manager && sameConnection(connection, connectionFor(hostId2)) && manager.requestClient === bridge && manager.prewarmedThreadManager === prewarmed
|
|
18038
18190
|
);
|
|
@@ -18043,13 +18195,13 @@ function installRendererHostRouting(root, target, discover, resolve, createPolic
|
|
|
18043
18195
|
const publish = (route) => {
|
|
18044
18196
|
if (!publishRouting) return;
|
|
18045
18197
|
const policy = route?.policy;
|
|
18046
|
-
if (
|
|
18047
|
-
Object.defineProperty(
|
|
18198
|
+
if (target2.__codexhostDraftPrewarmPolicyV1 === policy) return;
|
|
18199
|
+
Object.defineProperty(target2, "__codexhostDraftPrewarmPolicyV1", {
|
|
18048
18200
|
configurable: true,
|
|
18049
18201
|
value: policy
|
|
18050
18202
|
});
|
|
18051
|
-
if (typeof
|
|
18052
|
-
|
|
18203
|
+
if (typeof target2.dispatchEvent === "function" && typeof CustomEvent === "function") {
|
|
18204
|
+
target2.dispatchEvent(new CustomEvent("codexhost:draft-prewarm-policy-changed"));
|
|
18053
18205
|
}
|
|
18054
18206
|
};
|
|
18055
18207
|
const composerHostId = (discovery) => {
|
|
@@ -18110,14 +18262,14 @@ function installRendererHostRouting(root, target, discover, resolve, createPolic
|
|
|
18110
18262
|
disposed = true;
|
|
18111
18263
|
for (const hostId2 of routes.keys()) retire(hostId2);
|
|
18112
18264
|
lastDiscovery = null;
|
|
18113
|
-
if (
|
|
18114
|
-
delete
|
|
18265
|
+
if (target2.__codexhostHostRoutingV1 === routing) {
|
|
18266
|
+
delete target2.__codexhostHostRoutingV1;
|
|
18115
18267
|
publish(null);
|
|
18116
18268
|
}
|
|
18117
18269
|
}
|
|
18118
18270
|
};
|
|
18119
18271
|
if (publishRouting)
|
|
18120
|
-
Object.defineProperty(
|
|
18272
|
+
Object.defineProperty(target2, "__codexhostHostRoutingV1", {
|
|
18121
18273
|
configurable: true,
|
|
18122
18274
|
value: routing
|
|
18123
18275
|
});
|
|
@@ -18226,8 +18378,8 @@ function rendererHostRpcHostIds(discovery) {
|
|
|
18226
18378
|
}
|
|
18227
18379
|
|
|
18228
18380
|
// packages/desktop-control/src/renderer-host-rpc-routing.ts
|
|
18229
|
-
function installRendererHostRpcRouting(root,
|
|
18230
|
-
const existing =
|
|
18381
|
+
function installRendererHostRpcRouting(root, target2, dependencies) {
|
|
18382
|
+
const existing = target2.__codexhostHostRoutingV1;
|
|
18231
18383
|
if (existing) return existing;
|
|
18232
18384
|
let disposed = false;
|
|
18233
18385
|
let nativeRouting = null;
|
|
@@ -18282,15 +18434,15 @@ function installRendererHostRpcRouting(root, target, dependencies) {
|
|
|
18282
18434
|
};
|
|
18283
18435
|
const publishDraftWorkspace = (hostId2, cwd) => {
|
|
18284
18436
|
if (typeof cwd !== "string" || cwd.length === 0) return;
|
|
18285
|
-
const drafts = isRecord3(
|
|
18437
|
+
const drafts = isRecord3(target2.__codexhostDraftWorkspacesV1) ? target2.__codexhostDraftWorkspacesV1 : {};
|
|
18286
18438
|
if (drafts[hostId2] === cwd) return;
|
|
18287
18439
|
drafts[hostId2] = cwd;
|
|
18288
|
-
Object.defineProperty(
|
|
18440
|
+
Object.defineProperty(target2, "__codexhostDraftWorkspacesV1", {
|
|
18289
18441
|
configurable: true,
|
|
18290
18442
|
value: drafts
|
|
18291
18443
|
});
|
|
18292
|
-
if (typeof
|
|
18293
|
-
|
|
18444
|
+
if (typeof target2.dispatchEvent === "function" && typeof CustomEvent === "function") {
|
|
18445
|
+
target2.dispatchEvent(
|
|
18294
18446
|
new CustomEvent("codexhost:draft-workspace", { detail: { hostId: hostId2, cwd } })
|
|
18295
18447
|
);
|
|
18296
18448
|
}
|
|
@@ -18363,6 +18515,24 @@ function installRendererHostRpcRouting(root, target, dependencies) {
|
|
|
18363
18515
|
const manager = Object.freeze({
|
|
18364
18516
|
kind: "main-process-rpc",
|
|
18365
18517
|
getHostId: () => hostId2,
|
|
18518
|
+
...typeof rpc.getConversation === "function" ? {
|
|
18519
|
+
getConversation: async (threadId) => {
|
|
18520
|
+
if (!isCurrent()) throw new Error("Remote manager retired");
|
|
18521
|
+
return rpc.getConversation?.(threadId);
|
|
18522
|
+
}
|
|
18523
|
+
} : {},
|
|
18524
|
+
...typeof rpc.replyWithCommandExecutionApprovalDecision === "function" ? {
|
|
18525
|
+
replyWithCommandExecutionApprovalDecision: async (threadId, requestId, decision) => {
|
|
18526
|
+
if (!isCurrent()) throw new Error("Remote manager retired");
|
|
18527
|
+
return rpc.replyWithCommandExecutionApprovalDecision?.(threadId, requestId, decision);
|
|
18528
|
+
}
|
|
18529
|
+
} : {},
|
|
18530
|
+
...typeof rpc.replyWithFileChangeApprovalDecision === "function" ? {
|
|
18531
|
+
replyWithFileChangeApprovalDecision: async (threadId, requestId, decision) => {
|
|
18532
|
+
if (!isCurrent()) throw new Error("Remote manager retired");
|
|
18533
|
+
return rpc.replyWithFileChangeApprovalDecision?.(threadId, requestId, decision);
|
|
18534
|
+
}
|
|
18535
|
+
} : {},
|
|
18366
18536
|
sendRequest(method, params, options) {
|
|
18367
18537
|
if (!isCurrent())
|
|
18368
18538
|
return Promise.reject(new Error(`Renderer request manager is retired for ${hostId2}`));
|
|
@@ -18374,13 +18544,13 @@ function installRendererHostRpcRouting(root, target, dependencies) {
|
|
|
18374
18544
|
const accepted = new Set(typeof methods === "string" ? [methods] : methods);
|
|
18375
18545
|
const onMessage = (event) => {
|
|
18376
18546
|
const { source, data } = event;
|
|
18377
|
-
if (source != null && source !==
|
|
18547
|
+
if (source != null && source !== target2) return;
|
|
18378
18548
|
if (!isRecord3(data) || data.type !== "mcp-notification" || data.hostId !== hostId2 || typeof data.method !== "string" || !accepted.has(data.method) || !isCurrent())
|
|
18379
18549
|
return;
|
|
18380
18550
|
listener({ method: data.method, params: data.params });
|
|
18381
18551
|
};
|
|
18382
|
-
|
|
18383
|
-
return () =>
|
|
18552
|
+
target2.addEventListener?.("message", onMessage);
|
|
18553
|
+
return () => target2.removeEventListener?.("message", onMessage);
|
|
18384
18554
|
}
|
|
18385
18555
|
});
|
|
18386
18556
|
const clearDrafts = () => {
|
|
@@ -18453,13 +18623,13 @@ function installRendererHostRpcRouting(root, target, dependencies) {
|
|
|
18453
18623
|
};
|
|
18454
18624
|
const publish = (route) => {
|
|
18455
18625
|
const policy = route?.policy;
|
|
18456
|
-
if (
|
|
18457
|
-
Object.defineProperty(
|
|
18626
|
+
if (target2.__codexhostDraftPrewarmPolicyV1 === policy) return;
|
|
18627
|
+
Object.defineProperty(target2, "__codexhostDraftPrewarmPolicyV1", {
|
|
18458
18628
|
configurable: true,
|
|
18459
18629
|
value: policy
|
|
18460
18630
|
});
|
|
18461
|
-
if (typeof
|
|
18462
|
-
|
|
18631
|
+
if (typeof target2.dispatchEvent === "function" && typeof CustomEvent === "function") {
|
|
18632
|
+
target2.dispatchEvent(new CustomEvent("codexhost:draft-prewarm-policy-changed"));
|
|
18463
18633
|
}
|
|
18464
18634
|
};
|
|
18465
18635
|
const composerHostId = (owners, composer) => {
|
|
@@ -18524,13 +18694,13 @@ function installRendererHostRpcRouting(root, target, dependencies) {
|
|
|
18524
18694
|
externalDrafts.clear();
|
|
18525
18695
|
selectedModels.clear();
|
|
18526
18696
|
if (port.postMessage === postMessage) port.postMessage = originalPostMessage;
|
|
18527
|
-
if (
|
|
18528
|
-
delete
|
|
18697
|
+
if (target2.__codexhostHostRoutingV1 === routing) {
|
|
18698
|
+
delete target2.__codexhostHostRoutingV1;
|
|
18529
18699
|
publish(null);
|
|
18530
18700
|
}
|
|
18531
18701
|
}
|
|
18532
18702
|
};
|
|
18533
|
-
Object.defineProperty(
|
|
18703
|
+
Object.defineProperty(target2, "__codexhostHostRoutingV1", { configurable: true, value: routing });
|
|
18534
18704
|
return routing;
|
|
18535
18705
|
}
|
|
18536
18706
|
|
|
@@ -18990,9 +19160,9 @@ async function withNativeRpcComponents(client, install) {
|
|
|
18990
19160
|
}
|
|
18991
19161
|
|
|
18992
19162
|
// packages/desktop-control/src/renderer-native-rpc-runtime.ts
|
|
18993
|
-
function installNativeRpcRemoteControl(components,
|
|
18994
|
-
if (
|
|
18995
|
-
const routing =
|
|
19163
|
+
function installNativeRpcRemoteControl(components, target2, dependencies) {
|
|
19164
|
+
if (target2.__codexhostNativeRpcRemoteControlV1) return true;
|
|
19165
|
+
const routing = target2.__codexhostHostRoutingV1;
|
|
18996
19166
|
if (!routing) return false;
|
|
18997
19167
|
const adapted = dependencies.createService(
|
|
18998
19168
|
components,
|
|
@@ -19000,7 +19170,7 @@ function installNativeRpcRemoteControl(components, target, dependencies) {
|
|
|
19000
19170
|
components,
|
|
19001
19171
|
hostId2,
|
|
19002
19172
|
upstream,
|
|
19003
|
-
|
|
19173
|
+
target2,
|
|
19004
19174
|
dependencies.createPolicy,
|
|
19005
19175
|
dependencies.createChannel,
|
|
19006
19176
|
dependencies.retainInteractions
|
|
@@ -19037,8 +19207,8 @@ function installNativeRpcRemoteControl(components, target, dependencies) {
|
|
|
19037
19207
|
routing.forComposer = forComposer;
|
|
19038
19208
|
const installation = {
|
|
19039
19209
|
dispose() {
|
|
19040
|
-
if (
|
|
19041
|
-
delete
|
|
19210
|
+
if (target2.__codexhostNativeRpcRemoteControlV1 !== installation) return;
|
|
19211
|
+
delete target2.__codexhostNativeRpcRemoteControlV1;
|
|
19042
19212
|
replacement.dispose();
|
|
19043
19213
|
replacement = components.createController(
|
|
19044
19214
|
components.scope,
|
|
@@ -19053,12 +19223,12 @@ function installNativeRpcRemoteControl(components, target, dependencies) {
|
|
|
19053
19223
|
installation.dispose();
|
|
19054
19224
|
originalDispose.call(routing);
|
|
19055
19225
|
};
|
|
19056
|
-
|
|
19226
|
+
target2.__codexhostNativeRpcRemoteControlV1 = installation;
|
|
19057
19227
|
return true;
|
|
19058
19228
|
}
|
|
19059
19229
|
|
|
19060
19230
|
// packages/desktop-control/src/renderer-native-remote-manager.ts
|
|
19061
|
-
function createNativeRemoteManager(components, hostId2, original,
|
|
19231
|
+
function createNativeRemoteManager(components, hostId2, original, target2, createPolicy, createChannel, retainInteractions) {
|
|
19062
19232
|
const source = components.scope.get(components.requestDefinition, hostId2);
|
|
19063
19233
|
const upstream = original.dup();
|
|
19064
19234
|
let manager;
|
|
@@ -19122,7 +19292,7 @@ function createNativeRemoteManager(components, hostId2, original, target, create
|
|
|
19122
19292
|
owned,
|
|
19123
19293
|
client,
|
|
19124
19294
|
hostId2,
|
|
19125
|
-
|
|
19295
|
+
target2,
|
|
19126
19296
|
owned.prewarmedThreadManager,
|
|
19127
19297
|
() => !disposed,
|
|
19128
19298
|
void 0,
|
|
@@ -19136,15 +19306,15 @@ function createNativeRemoteManager(components, hostId2, original, target, create
|
|
|
19136
19306
|
interactions = nativeInteractions;
|
|
19137
19307
|
const notify = (event) => {
|
|
19138
19308
|
const { data, source: source2, origin } = event;
|
|
19139
|
-
if (disposed || source2 != null && source2 !==
|
|
19309
|
+
if (disposed || source2 != null && source2 !== target2 || !record4(data) || data.hostId !== hostId2)
|
|
19140
19310
|
return;
|
|
19141
|
-
const ownOrigin = record4(
|
|
19142
|
-
if (source2 ===
|
|
19311
|
+
const ownOrigin = record4(target2.location) ? target2.location.origin : void 0;
|
|
19312
|
+
if (source2 === target2 && ownOrigin && ownOrigin !== "null" && origin !== ownOrigin) return;
|
|
19143
19313
|
if (data.type === "mcp-notification" && typeof data.method === "string" && !data.method.startsWith("process/"))
|
|
19144
19314
|
owned.onNotification(data.method, data.params);
|
|
19145
19315
|
if (data.type === "mcp-request") owned.onRequest(record4(data.request) ? data.request : data);
|
|
19146
19316
|
};
|
|
19147
|
-
|
|
19317
|
+
target2.addEventListener?.("message", notify);
|
|
19148
19318
|
return {
|
|
19149
19319
|
route: { hostId: hostId2, manager: owned, policy: ownedPolicy },
|
|
19150
19320
|
rpc: channel.rpc,
|
|
@@ -19152,7 +19322,7 @@ function createNativeRemoteManager(components, hostId2, original, target, create
|
|
|
19152
19322
|
dispose() {
|
|
19153
19323
|
if (disposed) return;
|
|
19154
19324
|
disposed = true;
|
|
19155
|
-
|
|
19325
|
+
target2.removeEventListener?.("message", notify);
|
|
19156
19326
|
nativeInteractions.dispose();
|
|
19157
19327
|
ownedPolicy.dispose();
|
|
19158
19328
|
client.queuedRequests.length = 0;
|
|
@@ -19712,9 +19882,9 @@ function isPrimaryRendererUrl(value) {
|
|
|
19712
19882
|
}
|
|
19713
19883
|
function selectPrimaryRendererTarget(targets, preferredTargetId) {
|
|
19714
19884
|
const candidates = targets.filter(
|
|
19715
|
-
(
|
|
19885
|
+
(target2) => target2.type === "page" && isPrimaryRendererUrl(target2.url)
|
|
19716
19886
|
);
|
|
19717
|
-
return candidates.find((
|
|
19887
|
+
return candidates.find((target2) => target2.id === preferredTargetId) ?? candidates.at(0) ?? null;
|
|
19718
19888
|
}
|
|
19719
19889
|
var RendererAdapterReadinessError = class extends Error {
|
|
19720
19890
|
constructor(state, reason) {
|
|
@@ -19742,7 +19912,7 @@ async function waitForPrimaryTarget(endpoint, operations, timeoutMs, pollInterva
|
|
|
19742
19912
|
let lastError;
|
|
19743
19913
|
while (!discovery.aborted) {
|
|
19744
19914
|
try {
|
|
19745
|
-
const
|
|
19915
|
+
const target2 = selectPrimaryRendererTarget(
|
|
19746
19916
|
await awaitWithSignal(
|
|
19747
19917
|
operations.listTargets(endpoint, discovery),
|
|
19748
19918
|
discovery,
|
|
@@ -19750,7 +19920,7 @@ async function waitForPrimaryTarget(endpoint, operations, timeoutMs, pollInterva
|
|
|
19750
19920
|
),
|
|
19751
19921
|
preferredTargetId
|
|
19752
19922
|
);
|
|
19753
|
-
if (
|
|
19923
|
+
if (target2) return target2;
|
|
19754
19924
|
lastError = new Error("Renderer CDP has no primary app://-/index.html page target");
|
|
19755
19925
|
} catch (error51) {
|
|
19756
19926
|
lastError = error51;
|
|
@@ -19805,8 +19975,8 @@ async function waitForBinding(renderer, enabledAgents, timeoutMs, pollIntervalMs
|
|
|
19805
19975
|
const detail = lastError instanceof Error ? `: ${lastError.message}` : "";
|
|
19806
19976
|
throw new Error(`Production Renderer binding did not become ready${detail}`);
|
|
19807
19977
|
}
|
|
19808
|
-
async function installTarget(
|
|
19809
|
-
const renderer = await operations.connect(
|
|
19978
|
+
async function installTarget(target2, rendererSource, enabledAgents, timeoutMs, pollIntervalMs, operations) {
|
|
19979
|
+
const renderer = await operations.connect(target2.webSocketDebuggerUrl);
|
|
19810
19980
|
let disposeModules;
|
|
19811
19981
|
try {
|
|
19812
19982
|
disposeModules = await installRendererLoadedModules(renderer);
|
|
@@ -19815,7 +19985,7 @@ async function installTarget(target, rendererSource, enabledAgents, timeoutMs, p
|
|
|
19815
19985
|
await evaluateSource(renderer, rendererSource);
|
|
19816
19986
|
const draftPrewarmPolicy = await operations.installDraftPrewarmPolicy(renderer);
|
|
19817
19987
|
const binding = await waitForBinding(renderer, enabledAgents, timeoutMs, pollIntervalMs);
|
|
19818
|
-
return { renderer, snapshot: { target, draftPrewarmPolicy, binding }, disposeModules };
|
|
19988
|
+
return { renderer, snapshot: { target: target2, draftPrewarmPolicy, binding }, disposeModules };
|
|
19819
19989
|
} catch (error51) {
|
|
19820
19990
|
disposeModules?.();
|
|
19821
19991
|
renderer.close();
|
|
@@ -19849,16 +20019,16 @@ var InstalledRendererCdpControlSession = class {
|
|
|
19849
20019
|
}
|
|
19850
20020
|
async ensureInstalled() {
|
|
19851
20021
|
if (this.#closed) throw new Error("Renderer CDP Control Session is closed");
|
|
19852
|
-
const
|
|
20022
|
+
const target2 = await waitForPrimaryTarget(
|
|
19853
20023
|
this.rendererCdpEndpoint,
|
|
19854
20024
|
this.operations,
|
|
19855
20025
|
this.timeoutMs,
|
|
19856
20026
|
this.pollIntervalMs,
|
|
19857
20027
|
this.currentSnapshot.target.id
|
|
19858
20028
|
);
|
|
19859
|
-
if (
|
|
20029
|
+
if (target2.id !== this.currentSnapshot.target.id) {
|
|
19860
20030
|
const replacement = await installTarget(
|
|
19861
|
-
|
|
20031
|
+
target2,
|
|
19862
20032
|
this.rendererSource,
|
|
19863
20033
|
this.enabledAgents,
|
|
19864
20034
|
this.timeoutMs,
|
|
@@ -19882,11 +20052,11 @@ var InstalledRendererCdpControlSession = class {
|
|
|
19882
20052
|
this.timeoutMs,
|
|
19883
20053
|
this.pollIntervalMs
|
|
19884
20054
|
);
|
|
19885
|
-
this.currentSnapshot = { target, draftPrewarmPolicy, binding };
|
|
20055
|
+
this.currentSnapshot = { target: target2, draftPrewarmPolicy, binding };
|
|
19886
20056
|
return this.currentSnapshot;
|
|
19887
20057
|
} catch {
|
|
19888
20058
|
const replacement = await installTarget(
|
|
19889
|
-
|
|
20059
|
+
target2,
|
|
19890
20060
|
this.rendererSource,
|
|
19891
20061
|
this.enabledAgents,
|
|
19892
20062
|
this.timeoutMs,
|
|
@@ -19932,7 +20102,7 @@ async function createRendererCdpControlSession(options) {
|
|
|
19932
20102
|
const timeoutMs = options.timeoutMs ?? 3e4;
|
|
19933
20103
|
const pollIntervalMs = options.pollIntervalMs ?? 250;
|
|
19934
20104
|
const operations = options.operations ?? defaultOperations;
|
|
19935
|
-
const
|
|
20105
|
+
const target2 = await waitForPrimaryTarget(
|
|
19936
20106
|
options.rendererCdpEndpoint,
|
|
19937
20107
|
operations,
|
|
19938
20108
|
timeoutMs,
|
|
@@ -19941,7 +20111,7 @@ async function createRendererCdpControlSession(options) {
|
|
|
19941
20111
|
options.signal
|
|
19942
20112
|
);
|
|
19943
20113
|
const installed = await installTarget(
|
|
19944
|
-
|
|
20114
|
+
target2,
|
|
19945
20115
|
options.rendererSource,
|
|
19946
20116
|
enabledAgents,
|
|
19947
20117
|
timeoutMs,
|