@karlorz/codexhost-cli-win32-x64 0.17.1-0 → 0.17.4-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +15 -0
- package/app/console-web.js +15 -0
- package/app/cpa-live-voice-hook.js +62 -39
- package/app/desktop-controller.mjs +308 -27
- package/app/host-runtime.mjs +359 -42
- package/app/plugins/antigravity/plugin.mjs +15 -0
- package/app/plugins/claude-code/plugin.mjs +15 -0
- package/app/plugins/codebuddy/plugin.mjs +15 -0
- package/app/plugins/codex-usage/plugin.mjs +15 -0
- package/app/plugins/copilot/plugin.mjs +15 -0
- package/app/plugins/cursor-cli/plugin.mjs +43 -5
- package/app/plugins/deepseek-harness/plugin.mjs +15 -0
- package/app/plugins/devin/plugin.mjs +15 -0
- package/app/plugins/grok/plugin.mjs +424 -75
- package/app/plugins/hermes/plugin.mjs +15 -0
- package/app/plugins/kimi-code/plugin.mjs +15 -0
- package/app/plugins/kiro-cli/plugin.mjs +15 -0
- package/app/plugins/omp/plugin.mjs +15 -0
- package/app/plugins/opencode/plugin.mjs +15 -0
- package/app/plugins/pi/plugin.mjs +15 -0
- package/app/plugins/qoder/plugin.mjs +15 -0
- package/app/plugins/qoder-cn/plugin.mjs +15 -0
- package/app/plugins/qwen-code/plugin.mjs +15 -0
- package/app/plugins/workbuddy/plugin.mjs +15 -0
- package/app/plugins/zcode/plugin.mjs +15 -0
- package/app/renderer-extension.js +702 -282
- 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
|
@@ -21099,6 +21099,22 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
21099
21099
|
text: external_exports.string().optional()
|
|
21100
21100
|
}).strict();
|
|
21101
21101
|
var THREAD_STEER_DELIVERY_PARAM = "codexhostSteerDelivery";
|
|
21102
|
+
var THREAD_STEERING_CONTEXT_PARAM = "codexhost_external_steering";
|
|
21103
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
21104
|
+
kind: external_exports.literal("application"),
|
|
21105
|
+
value: external_exports.string().transform((text, context) => {
|
|
21106
|
+
try {
|
|
21107
|
+
return JSON.parse(text);
|
|
21108
|
+
} catch {
|
|
21109
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
21110
|
+
return external_exports.NEVER;
|
|
21111
|
+
}
|
|
21112
|
+
}).pipe(external_exports.object({
|
|
21113
|
+
expectedTurnId: hostTurnIdSchema,
|
|
21114
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
21115
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
21116
|
+
}).strict())
|
|
21117
|
+
}).strict().transform((context) => context.value);
|
|
21102
21118
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
21103
21119
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
21104
21120
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -28724,6 +28740,12 @@ function createLocalPageOpener(environment) {
|
|
|
28724
28740
|
}
|
|
28725
28741
|
|
|
28726
28742
|
// packages/desktop-control/dist/cdp-client.js
|
|
28743
|
+
var CdpConnectionClosedError = class extends Error {
|
|
28744
|
+
constructor(message2) {
|
|
28745
|
+
super(message2);
|
|
28746
|
+
this.name = "CdpConnectionClosedError";
|
|
28747
|
+
}
|
|
28748
|
+
};
|
|
28727
28749
|
function cdpExceptionMessage(details, fallback) {
|
|
28728
28750
|
const exception = details.exception;
|
|
28729
28751
|
if (isRecord8(exception) && typeof exception.description === "string" && exception.description) {
|
|
@@ -28818,8 +28840,8 @@ var CdpClient = class _CdpClient {
|
|
|
28818
28840
|
this.#socket = socket;
|
|
28819
28841
|
this.#commandTimeoutMs = commandTimeoutMs;
|
|
28820
28842
|
socket.addEventListener("message", (event) => this.#onMessage(event));
|
|
28821
|
-
socket.addEventListener("error", () => this.#
|
|
28822
|
-
socket.addEventListener("close", () => this.#
|
|
28843
|
+
socket.addEventListener("error", () => this.#disconnect(new CdpConnectionClosedError("CDP WebSocket failed")));
|
|
28844
|
+
socket.addEventListener("close", () => this.#disconnect(new CdpConnectionClosedError("CDP WebSocket closed")));
|
|
28823
28845
|
}
|
|
28824
28846
|
static async connect(url2, options = {}) {
|
|
28825
28847
|
loopbackUrl(url2, ["ws:", "wss:"]);
|
|
@@ -28870,7 +28892,7 @@ var CdpClient = class _CdpClient {
|
|
|
28870
28892
|
}
|
|
28871
28893
|
#send(method, params, sessionId) {
|
|
28872
28894
|
if (this.#closed)
|
|
28873
|
-
return Promise.reject(new
|
|
28895
|
+
return Promise.reject(new CdpConnectionClosedError("CDP client is closed"));
|
|
28874
28896
|
const id2 = this.#nextId++;
|
|
28875
28897
|
return new Promise((resolve, reject) => {
|
|
28876
28898
|
const timeout = setTimeout(() => {
|
|
@@ -28913,10 +28935,13 @@ var CdpClient = class _CdpClient {
|
|
|
28913
28935
|
}
|
|
28914
28936
|
}
|
|
28915
28937
|
close() {
|
|
28938
|
+
this.#disconnect(new CdpConnectionClosedError("CDP client closed"));
|
|
28939
|
+
}
|
|
28940
|
+
#disconnect(error51) {
|
|
28916
28941
|
if (this.#closed)
|
|
28917
28942
|
return;
|
|
28918
28943
|
this.#closed = true;
|
|
28919
|
-
this.#fail(
|
|
28944
|
+
this.#fail(error51);
|
|
28920
28945
|
this.#listeners.clear();
|
|
28921
28946
|
this.#socket.close();
|
|
28922
28947
|
}
|
|
@@ -30173,7 +30198,9 @@ function findRendererHostRpcFamily(store) {
|
|
|
30173
30198
|
if (!record6(members) || typeof members.get !== "function")
|
|
30174
30199
|
continue;
|
|
30175
30200
|
for (const [hostId2, member] of members) {
|
|
30176
|
-
if (typeof hostId2 !== "string" ||
|
|
30201
|
+
if (typeof hostId2 !== "string" || !/^(?:local$|durable$|remote[-:]|ssh:)/u.test(hostId2))
|
|
30202
|
+
continue;
|
|
30203
|
+
if (!record6(member))
|
|
30177
30204
|
continue;
|
|
30178
30205
|
const signal = member.value;
|
|
30179
30206
|
if (!record6(signal) || typeof signal.get !== "function")
|
|
@@ -30303,7 +30330,9 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
30303
30330
|
return null;
|
|
30304
30331
|
try {
|
|
30305
30332
|
const store = dependencies2.findStore(root);
|
|
30306
|
-
|
|
30333
|
+
const bound = store && discovery?.store === store ? [...store.familyBindings.values()].includes(discovery.family) : false;
|
|
30334
|
+
if (!bound)
|
|
30335
|
+
discovery = store ? dependencies2.findFamily(store) : null;
|
|
30307
30336
|
} catch {
|
|
30308
30337
|
discovery = null;
|
|
30309
30338
|
}
|
|
@@ -30312,14 +30341,15 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
30312
30341
|
if (!read())
|
|
30313
30342
|
return null;
|
|
30314
30343
|
const queuePolicy = dependencies2.installQueuePolicy(root, target);
|
|
30315
|
-
const
|
|
30316
|
-
|
|
30317
|
-
|
|
30318
|
-
|
|
30319
|
-
|
|
30320
|
-
|
|
30344
|
+
const discoverComposer = (composer) => {
|
|
30345
|
+
const owners = dependencies2.discoverComposer(composer);
|
|
30346
|
+
if (!nativeRouting && (owners.managers.length || owners.registries.length)) {
|
|
30347
|
+
try {
|
|
30348
|
+
nativeRouting = dependencies2.installNativeRouting();
|
|
30349
|
+
} catch {
|
|
30350
|
+
}
|
|
30321
30351
|
}
|
|
30322
|
-
return
|
|
30352
|
+
return owners;
|
|
30323
30353
|
};
|
|
30324
30354
|
const connectionFor = (hostId2) => {
|
|
30325
30355
|
if (!hostId2.startsWith("remote-control:"))
|
|
@@ -30526,7 +30556,7 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
30526
30556
|
if (disposed)
|
|
30527
30557
|
return null;
|
|
30528
30558
|
const connection = connectionFor(hostId2);
|
|
30529
|
-
const preferred = nativeRoute === void 0 ?
|
|
30559
|
+
const preferred = nativeRoute === void 0 ? nativeRouting?.forHost(hostId2) : nativeRoute;
|
|
30530
30560
|
if (connection === null || preferred) {
|
|
30531
30561
|
retire(hostId2);
|
|
30532
30562
|
return connection === null ? null : preferred ?? null;
|
|
@@ -30555,11 +30585,11 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
30555
30585
|
target.dispatchEvent(new CustomEvent("codexhost:draft-prewarm-policy-changed"));
|
|
30556
30586
|
}
|
|
30557
30587
|
};
|
|
30558
|
-
const composerHostId = (composer) => {
|
|
30559
|
-
const nativeHostId =
|
|
30588
|
+
const composerHostId = (owners, composer) => {
|
|
30589
|
+
const nativeHostId = nativeRouting?.hostIdForComposer(composer);
|
|
30560
30590
|
if (nativeHostId)
|
|
30561
30591
|
return nativeHostId;
|
|
30562
|
-
const hostIds = new Set(
|
|
30592
|
+
const hostIds = new Set((owners ?? discoverComposer(composer)).hostIds);
|
|
30563
30593
|
const hostId2 = hostIds.size === 1 ? hostIds.values().next().value : null;
|
|
30564
30594
|
return typeof hostId2 === "string" && hostId2 ? hostId2 : null;
|
|
30565
30595
|
};
|
|
@@ -30567,11 +30597,16 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
30567
30597
|
knownHostIds() {
|
|
30568
30598
|
if (disposed)
|
|
30569
30599
|
return [];
|
|
30600
|
+
try {
|
|
30601
|
+
if (!nativeRouting)
|
|
30602
|
+
discoverComposer();
|
|
30603
|
+
} catch {
|
|
30604
|
+
}
|
|
30570
30605
|
const current = read();
|
|
30571
30606
|
return [
|
|
30572
30607
|
.../* @__PURE__ */ new Set([
|
|
30573
30608
|
...current ? dependencies2.hostIds(current) : [],
|
|
30574
|
-
...
|
|
30609
|
+
...nativeRouting?.knownHostIds?.() ?? []
|
|
30575
30610
|
])
|
|
30576
30611
|
];
|
|
30577
30612
|
},
|
|
@@ -30582,7 +30617,7 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
30582
30617
|
if (disposed)
|
|
30583
30618
|
return null;
|
|
30584
30619
|
try {
|
|
30585
|
-
return composerHostId(composer);
|
|
30620
|
+
return composerHostId(nativeRouting ? null : discoverComposer(composer), composer);
|
|
30586
30621
|
} catch {
|
|
30587
30622
|
return null;
|
|
30588
30623
|
}
|
|
@@ -30593,8 +30628,9 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
30593
30628
|
let hostId2;
|
|
30594
30629
|
let preferred = null;
|
|
30595
30630
|
try {
|
|
30596
|
-
|
|
30597
|
-
|
|
30631
|
+
const owners = nativeRouting ? null : discoverComposer(composer);
|
|
30632
|
+
preferred = nativeRouting?.forComposer(composer) ?? null;
|
|
30633
|
+
hostId2 = preferred?.hostId ?? composerHostId(owners, composer);
|
|
30598
30634
|
} catch {
|
|
30599
30635
|
hostId2 = null;
|
|
30600
30636
|
}
|
|
@@ -30686,7 +30722,7 @@ function directRendererInstaller() {
|
|
|
30686
30722
|
findFamily: ${findRendererHostRpcFamily.toString()},
|
|
30687
30723
|
resolve: ${resolveRendererHostRpc.toString()},
|
|
30688
30724
|
hostIds: ${rendererHostRpcHostIds.toString()},
|
|
30689
|
-
|
|
30725
|
+
discoverComposer: (composer) => {
|
|
30690
30726
|
const source = composer?.matches?.('[data-codex-composer], [contenteditable="true"][role="textbox"]')
|
|
30691
30727
|
? { querySelectorAll: () => [composer] }
|
|
30692
30728
|
: (composer ?? document);
|
|
@@ -30698,10 +30734,7 @@ function directRendererInstaller() {
|
|
|
30698
30734
|
portPrototype: MessagePort.prototype,
|
|
30699
30735
|
}),
|
|
30700
30736
|
portPrototype: MessagePort.prototype,
|
|
30701
|
-
|
|
30702
|
-
const native = discover(document);
|
|
30703
|
-
return native.managers.length || native.registries.length ? installNative(false) : null;
|
|
30704
|
-
},
|
|
30737
|
+
installNativeRouting: () => installNative(false),
|
|
30705
30738
|
readConnection: (hostId) => readRendererConnectionGeneration(findRendererAppScopeStore(document), hostId),
|
|
30706
30739
|
});
|
|
30707
30740
|
const connected = (routing) => routing.forComposer() !== null ||
|
|
@@ -30758,6 +30791,79 @@ var startupTraceStartedAt = Date.now();
|
|
|
30758
30791
|
// packages/desktop-control/dist/cpa-live-voice-hook.js
|
|
30759
30792
|
var CPA_LIVE_VOICE_HOOK_GLOBAL = "__codexhostCpaLiveVoiceHookV1";
|
|
30760
30793
|
|
|
30794
|
+
// packages/desktop-control/dist/browser-annotation-style-compat.js
|
|
30795
|
+
var BROWSER_ANNOTATION_STYLE_COMPAT_SOURCE = String.raw`(() => {
|
|
30796
|
+
const key = '__codexhostBrowserAnnotationStylesV1';
|
|
30797
|
+
if (globalThis[key]?.refresh() === true) return;
|
|
30798
|
+
if (typeof CSSStyleSheet !== 'function' ||
|
|
30799
|
+
typeof CSSStyleSheet.prototype.replaceSync !== 'function') return;
|
|
30800
|
+
let root = null;
|
|
30801
|
+
let shadow = null;
|
|
30802
|
+
let stylesObserver = null;
|
|
30803
|
+
const copies = new Map();
|
|
30804
|
+
function removeCopies() {
|
|
30805
|
+
if (shadow) {
|
|
30806
|
+
const owned = new Set(Array.from(copies.values(), copy => copy.sheet));
|
|
30807
|
+
shadow.adoptedStyleSheets = shadow.adoptedStyleSheets.filter(sheet => !owned.has(sheet));
|
|
30808
|
+
}
|
|
30809
|
+
copies.clear();
|
|
30810
|
+
}
|
|
30811
|
+
function syncStyles() {
|
|
30812
|
+
if (!shadow) return;
|
|
30813
|
+
const present = new Set();
|
|
30814
|
+
for (const style of shadow.querySelectorAll('style')) {
|
|
30815
|
+
const text = style.textContent || '';
|
|
30816
|
+
// Only repair Codex's cursor stylesheet when CSP rejected its style element.
|
|
30817
|
+
if (style.sheet || !text.includes('.annotation-selection-cursor')) continue;
|
|
30818
|
+
present.add(style);
|
|
30819
|
+
const previous = copies.get(style);
|
|
30820
|
+
if (previous?.text === text && shadow.adoptedStyleSheets.includes(previous.sheet)) continue;
|
|
30821
|
+
try {
|
|
30822
|
+
const sheet = previous?.sheet ?? new CSSStyleSheet();
|
|
30823
|
+
sheet.replaceSync(text);
|
|
30824
|
+
if (!shadow.adoptedStyleSheets.includes(sheet)) {
|
|
30825
|
+
shadow.adoptedStyleSheets = [...shadow.adoptedStyleSheets, sheet];
|
|
30826
|
+
}
|
|
30827
|
+
copies.set(style, { sheet, text });
|
|
30828
|
+
} catch { /* Unsupported annotation styles leave native behavior intact. */ }
|
|
30829
|
+
}
|
|
30830
|
+
for (const [style, copy] of copies) {
|
|
30831
|
+
if (present.has(style)) continue;
|
|
30832
|
+
shadow.adoptedStyleSheets = shadow.adoptedStyleSheets.filter(sheet => sheet !== copy.sheet);
|
|
30833
|
+
copies.delete(style);
|
|
30834
|
+
}
|
|
30835
|
+
}
|
|
30836
|
+
function refresh() {
|
|
30837
|
+
const nextRoot = document.documentElement;
|
|
30838
|
+
if (root !== nextRoot) {
|
|
30839
|
+
rootObserver.disconnect();
|
|
30840
|
+
rootObserver.observe(document, { childList: true });
|
|
30841
|
+
root = nextRoot;
|
|
30842
|
+
if (root) rootObserver.observe(root, { childList: true });
|
|
30843
|
+
}
|
|
30844
|
+
const host = document.getElementById('codex-browser-sidebar-comments-root');
|
|
30845
|
+
const nextShadow = host?.parentElement === root ? host?.shadowRoot ?? null : null;
|
|
30846
|
+
if (nextShadow !== shadow) {
|
|
30847
|
+
stylesObserver?.disconnect();
|
|
30848
|
+
removeCopies();
|
|
30849
|
+
shadow = nextShadow;
|
|
30850
|
+
stylesObserver = null;
|
|
30851
|
+
if (shadow && 'adoptedStyleSheets' in shadow) {
|
|
30852
|
+
stylesObserver = new MutationObserver(syncStyles);
|
|
30853
|
+
stylesObserver.observe(shadow, { childList: true, subtree: true, characterData: true });
|
|
30854
|
+
} else {
|
|
30855
|
+
shadow = null;
|
|
30856
|
+
}
|
|
30857
|
+
}
|
|
30858
|
+
syncStyles();
|
|
30859
|
+
return true;
|
|
30860
|
+
}
|
|
30861
|
+
const rootObserver = new MutationObserver(refresh);
|
|
30862
|
+
rootObserver.observe(document, { childList: true });
|
|
30863
|
+
globalThis[key] = { refresh };
|
|
30864
|
+
refresh();
|
|
30865
|
+
})();`;
|
|
30866
|
+
|
|
30761
30867
|
// packages/desktop-control/dist/renderer-loaded-modules.js
|
|
30762
30868
|
var record3 = (value2) => typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
30763
30869
|
var MAX_MODULES = 4096;
|
|
@@ -31652,6 +31758,114 @@ async function installNativeRpcRemoteControlDirect(renderer) {
|
|
|
31652
31758
|
}
|
|
31653
31759
|
}
|
|
31654
31760
|
|
|
31761
|
+
// packages/desktop-control/dist/renderer-rpc-steering.js
|
|
31762
|
+
var RETRY_BASE_MS = 5e3;
|
|
31763
|
+
var RETRY_MAX_MS = 3e5;
|
|
31764
|
+
var retries = /* @__PURE__ */ new WeakMap();
|
|
31765
|
+
async function installRendererRpcSteeringDirect(client, now = Date.now) {
|
|
31766
|
+
try {
|
|
31767
|
+
const needed = await client.evaluate(`(() => {
|
|
31768
|
+
const steering = window.__codexhostRpcSteeringV1;
|
|
31769
|
+
if (steering && steering.controller.forHost === steering.forHost) return false;
|
|
31770
|
+
steering?.release();
|
|
31771
|
+
const routing=window.__codexhostHostRoutingV1;
|
|
31772
|
+
return ['local', ...(routing?.knownHostIds?.() ?? [])].some(id => routing?.forHost(id)?.manager.kind === 'main-process-rpc');
|
|
31773
|
+
})()`);
|
|
31774
|
+
if (!needed)
|
|
31775
|
+
return false;
|
|
31776
|
+
const retry = retries.get(client);
|
|
31777
|
+
if (retry && now() < retry.nextAt)
|
|
31778
|
+
return false;
|
|
31779
|
+
try {
|
|
31780
|
+
await discoverAndInstall(client);
|
|
31781
|
+
retries.delete(client);
|
|
31782
|
+
return true;
|
|
31783
|
+
} catch (error51) {
|
|
31784
|
+
const attempts = (retry?.attempts ?? 0) + 1;
|
|
31785
|
+
const delay8 = Math.min(RETRY_BASE_MS * 2 ** (attempts - 1), RETRY_MAX_MS);
|
|
31786
|
+
retries.set(client, { attempts, nextAt: now() + delay8 });
|
|
31787
|
+
console.error(`codexhost native steering discovery failed (attempt ${attempts}):`, error51 instanceof Error ? error51.message : String(error51));
|
|
31788
|
+
return false;
|
|
31789
|
+
}
|
|
31790
|
+
} catch {
|
|
31791
|
+
return false;
|
|
31792
|
+
}
|
|
31793
|
+
}
|
|
31794
|
+
async function discoverAndInstall(client) {
|
|
31795
|
+
const group = `codexhost-rpc-steering-${crypto.randomUUID()}`;
|
|
31796
|
+
const command = (method, params) => client.command(method, params);
|
|
31797
|
+
const properties = (objectId) => command("Runtime.getProperties", { objectId, ownProperties: true });
|
|
31798
|
+
const call = (objectId, functionDeclaration, args = []) => command("Runtime.callFunctionOn", {
|
|
31799
|
+
objectId,
|
|
31800
|
+
functionDeclaration,
|
|
31801
|
+
arguments: args,
|
|
31802
|
+
objectGroup: group,
|
|
31803
|
+
returnByValue: true
|
|
31804
|
+
});
|
|
31805
|
+
try {
|
|
31806
|
+
const proto = await command("Runtime.evaluate", {
|
|
31807
|
+
expression: "Object.getPrototypeOf(async function(){})",
|
|
31808
|
+
objectGroup: group
|
|
31809
|
+
});
|
|
31810
|
+
if (!proto.result.objectId)
|
|
31811
|
+
throw new Error("Native RPC steering discovery is unavailable");
|
|
31812
|
+
const objects = await command("Runtime.queryObjects", {
|
|
31813
|
+
prototypeObjectId: proto.result.objectId,
|
|
31814
|
+
objectGroup: group
|
|
31815
|
+
});
|
|
31816
|
+
if (!objects.objects.objectId)
|
|
31817
|
+
throw new Error("Native RPC steering discovery is unavailable");
|
|
31818
|
+
const filtered = await command("Runtime.callFunctionOn", {
|
|
31819
|
+
objectId: objects.objects.objectId,
|
|
31820
|
+
functionDeclaration: 'function(){return this.filter(fn=>fn.name==="collectAppStateSnapshot"&&String(fn).includes("collectSnapshot")).slice(0,9)}',
|
|
31821
|
+
objectGroup: group
|
|
31822
|
+
});
|
|
31823
|
+
if (!filtered.result.objectId)
|
|
31824
|
+
throw new Error("Native RPC Controller is unavailable");
|
|
31825
|
+
const snapshots = (await properties(filtered.result.objectId)).result.flatMap((entry) => entry.value?.type === "function" && entry.value.objectId ? [entry.value.objectId] : []);
|
|
31826
|
+
if (snapshots.length > 8)
|
|
31827
|
+
throw new Error("Native RPC Controller is ambiguous");
|
|
31828
|
+
const controllers = [];
|
|
31829
|
+
for (const snapshot2 of snapshots) {
|
|
31830
|
+
const scopes = (await properties(snapshot2)).internalProperties?.find((entry) => entry.name === "[[Scopes]]")?.value?.objectId;
|
|
31831
|
+
if (!scopes)
|
|
31832
|
+
continue;
|
|
31833
|
+
for (const scope of (await properties(scopes)).result) {
|
|
31834
|
+
if (!scope.value?.objectId || !scope.value.description?.startsWith("Closure"))
|
|
31835
|
+
continue;
|
|
31836
|
+
const bindings = (await properties(scope.value.objectId)).result;
|
|
31837
|
+
const owners = [];
|
|
31838
|
+
let rootScope;
|
|
31839
|
+
for (const binding of bindings) {
|
|
31840
|
+
if (binding.value?.type !== "object" || !binding.value.objectId)
|
|
31841
|
+
continue;
|
|
31842
|
+
const id2 = binding.value.objectId;
|
|
31843
|
+
const result2 = await call(id2, `function(){return (${nativeRpcObjectShape.toString()})(this)}`);
|
|
31844
|
+
const shape = result2.result.value;
|
|
31845
|
+
if (shape?.scope)
|
|
31846
|
+
rootScope = id2;
|
|
31847
|
+
if (shape?.controller && (await call(id2, "function(fn){return this.collectAppStateSnapshot===fn}", [
|
|
31848
|
+
{ objectId: snapshot2 }
|
|
31849
|
+
])).result.value === true)
|
|
31850
|
+
owners.push(id2);
|
|
31851
|
+
}
|
|
31852
|
+
if (owners.length !== 1 || !rootScope)
|
|
31853
|
+
continue;
|
|
31854
|
+
const root = await call(rootScope, `function(){let node=this.node;const seen=new Set();while(node?.parent&&!seen.has(node.parent)&&seen.size<100){seen.add(node);node=node.parent}return (${findRendererAppScopeStore.toString()})(document)===node}`);
|
|
31855
|
+
if (root.result.value === true)
|
|
31856
|
+
controllers.push(owners[0]);
|
|
31857
|
+
}
|
|
31858
|
+
}
|
|
31859
|
+
if (controllers.length !== 1)
|
|
31860
|
+
throw new Error("Native RPC Controller is missing or ambiguous");
|
|
31861
|
+
const result = await call(controllers[0], "function(){return window.__codexhostInstallRpcSteeringV1?.(this) === true}");
|
|
31862
|
+
if (result.exceptionDetails || result.result.value !== true)
|
|
31863
|
+
throw new Error("Native RPC steering installation failed");
|
|
31864
|
+
} finally {
|
|
31865
|
+
await client.command("Runtime.releaseObjectGroup", { objectGroup: group }).catch(() => void 0);
|
|
31866
|
+
}
|
|
31867
|
+
}
|
|
31868
|
+
|
|
31655
31869
|
// packages/desktop-control/dist/renderer-cdp-control-session.js
|
|
31656
31870
|
function isRecord9(value2) {
|
|
31657
31871
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
@@ -31808,6 +32022,8 @@ async function waitForBinding(renderer, enabledAgents, timeoutMs, pollIntervalMs
|
|
|
31808
32022
|
} catch (error51) {
|
|
31809
32023
|
signal?.throwIfAborted();
|
|
31810
32024
|
lastError = error51;
|
|
32025
|
+
if (error51 instanceof CdpConnectionClosedError)
|
|
32026
|
+
throw error51;
|
|
31811
32027
|
if (error51 instanceof RendererAdapterReadinessError && error51.state !== "installing") {
|
|
31812
32028
|
throw error51;
|
|
31813
32029
|
}
|
|
@@ -31850,6 +32066,40 @@ function isLocalThreadRenderer(target) {
|
|
|
31850
32066
|
const route = url2.searchParams.get("initialRoute");
|
|
31851
32067
|
return [...url2.searchParams.keys()].length === 1 && (route === "/local" || route?.startsWith("/local/") === true);
|
|
31852
32068
|
}
|
|
32069
|
+
function isBrowserPage(target) {
|
|
32070
|
+
if (target.type !== "page")
|
|
32071
|
+
return false;
|
|
32072
|
+
try {
|
|
32073
|
+
return ["http:", "https:"].includes(new URL(target.url).protocol);
|
|
32074
|
+
} catch {
|
|
32075
|
+
return false;
|
|
32076
|
+
}
|
|
32077
|
+
}
|
|
32078
|
+
async function installBrowserAnnotationStyles(target, browserClients, operations, signal) {
|
|
32079
|
+
const timeoutMessage = "Browser annotation style compatibility installation timed out";
|
|
32080
|
+
const run = (operation) => runWithCdpSignal(signal, timeoutMessage, operation);
|
|
32081
|
+
let renderer = browserClients.get(target.id);
|
|
32082
|
+
const registered = renderer !== void 0;
|
|
32083
|
+
renderer ??= await connectRendererTarget(target, operations, signal, timeoutMessage);
|
|
32084
|
+
const connected = renderer;
|
|
32085
|
+
try {
|
|
32086
|
+
if (!registered) {
|
|
32087
|
+
await run(() => connected.command("Page.enable"));
|
|
32088
|
+
await run(() => connected.command("Page.addScriptToEvaluateOnNewDocument", {
|
|
32089
|
+
source: BROWSER_ANNOTATION_STYLE_COMPAT_SOURCE
|
|
32090
|
+
}));
|
|
32091
|
+
browserClients.set(target.id, connected);
|
|
32092
|
+
}
|
|
32093
|
+
const installed = await run(() => connected.evaluate("globalThis.__codexhostBrowserAnnotationStylesV1?.refresh() === true"));
|
|
32094
|
+
if (installed !== true) {
|
|
32095
|
+
await run(() => evaluateSource(connected, BROWSER_ANNOTATION_STYLE_COMPAT_SOURCE));
|
|
32096
|
+
}
|
|
32097
|
+
} catch (error51) {
|
|
32098
|
+
browserClients.delete(target.id);
|
|
32099
|
+
connected.close();
|
|
32100
|
+
throw error51;
|
|
32101
|
+
}
|
|
32102
|
+
}
|
|
31853
32103
|
async function installLocalThreadRenderer(target, source, enabledAgents, operations, signal) {
|
|
31854
32104
|
const timeoutMessage = "Local chat Renderer installation timed out";
|
|
31855
32105
|
const run = (operation) => runWithCdpSignal(signal, timeoutMessage, operation);
|
|
@@ -31867,10 +32117,18 @@ async function installLocalThreadRenderer(target, source, enabledAgents, operati
|
|
|
31867
32117
|
renderer.close();
|
|
31868
32118
|
}
|
|
31869
32119
|
}
|
|
31870
|
-
async function installAuxiliaryRenderers(endpoint, rendererSource, enabledAgents, overlayHookSource, operations, signal) {
|
|
32120
|
+
async function installAuxiliaryRenderers(endpoint, rendererSource, enabledAgents, overlayHookSource, browserStyleClients, operations, signal) {
|
|
31871
32121
|
try {
|
|
31872
32122
|
const targets = await awaitWithSignal(operations.listTargets(endpoint, signal), signal, "Auxiliary Renderer CDP target discovery timed out");
|
|
32123
|
+
const liveTargets = new Set(targets.map((target) => target.id));
|
|
32124
|
+
for (const [id2, client] of browserStyleClients) {
|
|
32125
|
+
if (!liveTargets.has(id2)) {
|
|
32126
|
+
client.close();
|
|
32127
|
+
browserStyleClients.delete(id2);
|
|
32128
|
+
}
|
|
32129
|
+
}
|
|
31873
32130
|
await Promise.allSettled([
|
|
32131
|
+
...targets.filter(isBrowserPage).map((target) => installBrowserAnnotationStyles(target, browserStyleClients, operations, signal)),
|
|
31874
32132
|
...overlayHookSource ? selectAvatarOverlayRendererTargets(targets).map((overlay) => installOverlayHook(overlay, overlayHookSource, operations, signal)) : [],
|
|
31875
32133
|
...targets.filter(isLocalThreadRenderer).map((target) => installLocalThreadRenderer(target, rendererSource, enabledAgents, operations, signal))
|
|
31876
32134
|
]);
|
|
@@ -31899,6 +32157,7 @@ var InstalledRendererCdpControlSession = class {
|
|
|
31899
32157
|
rendererCdpEndpoint;
|
|
31900
32158
|
rendererSource;
|
|
31901
32159
|
overlayHookSource;
|
|
32160
|
+
browserStyleClients;
|
|
31902
32161
|
enabledAgents;
|
|
31903
32162
|
timeoutMs;
|
|
31904
32163
|
pollIntervalMs;
|
|
@@ -31906,11 +32165,12 @@ var InstalledRendererCdpControlSession = class {
|
|
|
31906
32165
|
currentSnapshot;
|
|
31907
32166
|
disposeModules;
|
|
31908
32167
|
#closed = false;
|
|
31909
|
-
constructor(renderer, rendererCdpEndpoint, rendererSource, overlayHookSource, enabledAgents, timeoutMs, pollIntervalMs, operations, currentSnapshot, disposeModules) {
|
|
32168
|
+
constructor(renderer, rendererCdpEndpoint, rendererSource, overlayHookSource, browserStyleClients, enabledAgents, timeoutMs, pollIntervalMs, operations, currentSnapshot, disposeModules) {
|
|
31910
32169
|
this.renderer = renderer;
|
|
31911
32170
|
this.rendererCdpEndpoint = rendererCdpEndpoint;
|
|
31912
32171
|
this.rendererSource = rendererSource;
|
|
31913
32172
|
this.overlayHookSource = overlayHookSource;
|
|
32173
|
+
this.browserStyleClients = browserStyleClients;
|
|
31914
32174
|
this.enabledAgents = enabledAgents;
|
|
31915
32175
|
this.timeoutMs = timeoutMs;
|
|
31916
32176
|
this.pollIntervalMs = pollIntervalMs;
|
|
@@ -31949,7 +32209,7 @@ var InstalledRendererCdpControlSession = class {
|
|
|
31949
32209
|
this.currentSnapshot = replacement.snapshot;
|
|
31950
32210
|
}
|
|
31951
32211
|
}
|
|
31952
|
-
await installAuxiliaryRenderers(this.rendererCdpEndpoint, this.rendererSource, this.enabledAgents, this.overlayHookSource, this.operations, discoveryTimeoutSignal(this.timeoutMs));
|
|
32212
|
+
await installAuxiliaryRenderers(this.rendererCdpEndpoint, this.rendererSource, this.enabledAgents, this.overlayHookSource, this.browserStyleClients, this.operations, discoveryTimeoutSignal(this.timeoutMs));
|
|
31953
32213
|
return this.currentSnapshot;
|
|
31954
32214
|
}
|
|
31955
32215
|
async activateDesktop() {
|
|
@@ -31969,6 +32229,9 @@ var InstalledRendererCdpControlSession = class {
|
|
|
31969
32229
|
this.#closed = true;
|
|
31970
32230
|
this.disposeModules();
|
|
31971
32231
|
this.renderer.close();
|
|
32232
|
+
for (const client of this.browserStyleClients.values())
|
|
32233
|
+
client.close();
|
|
32234
|
+
this.browserStyleClients.clear();
|
|
31972
32235
|
}
|
|
31973
32236
|
};
|
|
31974
32237
|
var defaultOperations = {
|
|
@@ -31977,6 +32240,7 @@ var defaultOperations = {
|
|
|
31977
32240
|
async installDraftPrewarmPolicy(renderer) {
|
|
31978
32241
|
const status2 = await installRendererDraftPrewarmPolicyDirect(renderer);
|
|
31979
32242
|
await installNativeRpcRemoteControlDirect(renderer);
|
|
32243
|
+
await installRendererRpcSteeringDirect(renderer);
|
|
31980
32244
|
return status2;
|
|
31981
32245
|
}
|
|
31982
32246
|
};
|
|
@@ -31987,8 +32251,9 @@ async function createRendererCdpControlSession(options) {
|
|
|
31987
32251
|
const operations = options.operations ?? defaultOperations;
|
|
31988
32252
|
const target = await waitForPrimaryTarget(options.rendererCdpEndpoint, operations, timeoutMs, pollIntervalMs, void 0, options.signal);
|
|
31989
32253
|
const installed = await installTarget(target, options.rendererSource, enabledAgents, timeoutMs, pollIntervalMs, operations);
|
|
31990
|
-
|
|
31991
|
-
|
|
32254
|
+
const browserStyleClients = /* @__PURE__ */ new Map();
|
|
32255
|
+
await installAuxiliaryRenderers(options.rendererCdpEndpoint, options.rendererSource, enabledAgents, options.overlayHookSource, browserStyleClients, operations, discoveryTimeoutSignal(timeoutMs, options.signal));
|
|
32256
|
+
return new InstalledRendererCdpControlSession(installed.renderer, options.rendererCdpEndpoint, options.rendererSource, options.overlayHookSource, browserStyleClients, enabledAgents, timeoutMs, pollIntervalMs, operations, installed.snapshot, installed.disposeModules);
|
|
31992
32257
|
}
|
|
31993
32258
|
function installRendererCdpControlSession(options) {
|
|
31994
32259
|
return createRendererCdpControlSession(options);
|
|
@@ -34806,7 +35071,6 @@ var NativeAccountObserver = class {
|
|
|
34806
35071
|
this.#initialized = true;
|
|
34807
35072
|
this.#lastGeneration = nativeGeneration ?? -1;
|
|
34808
35073
|
this.#scheduleAccountUpdate();
|
|
34809
|
-
if (nativeGeneration !== void 0) this.observe({ method: "account/updated" });
|
|
34810
35074
|
}
|
|
34811
35075
|
/** Called after forwarding the native frame. Identity read failure cannot alter its outcome. */
|
|
34812
35076
|
observe(value2) {
|
|
@@ -37804,6 +38068,7 @@ var publicSubmission = ({
|
|
|
37804
38068
|
var DEFAULT_PAGE_SIZE3 = 50;
|
|
37805
38069
|
var ExternalThreadQueue = class {
|
|
37806
38070
|
#queues = /* @__PURE__ */ new Map();
|
|
38071
|
+
#acceptedSteers = /* @__PURE__ */ new Map();
|
|
37807
38072
|
#notifyChanged;
|
|
37808
38073
|
#createId;
|
|
37809
38074
|
constructor(options) {
|
|
@@ -37849,7 +38114,7 @@ var ExternalThreadQueue = class {
|
|
|
37849
38114
|
async delete(threadId2, id2) {
|
|
37850
38115
|
const items = this.#queues.get(threadId2);
|
|
37851
38116
|
const index = items?.findIndex((item) => item.id === id2) ?? -1;
|
|
37852
|
-
if (!items || index === -1) return
|
|
38117
|
+
if (!items || index === -1) return this.#acceptedSteers.get(id2) === threadId2;
|
|
37853
38118
|
items.splice(index, 1);
|
|
37854
38119
|
this.#prune(threadId2);
|
|
37855
38120
|
await this.#notifyChanged(threadId2);
|
|
@@ -37882,6 +38147,26 @@ var ExternalThreadQueue = class {
|
|
|
37882
38147
|
index
|
|
37883
38148
|
};
|
|
37884
38149
|
}
|
|
38150
|
+
/** Reserve the exact queued input before steering can finish a replacement Turn.
|
|
38151
|
+
* Otherwise automatic queue advancement can deliver that input a second time. */
|
|
38152
|
+
takeSteered(threadId2, clientUserMessageId, input) {
|
|
38153
|
+
if (typeof clientUserMessageId !== "string") return;
|
|
38154
|
+
const matches = (this.#queues.get(threadId2) ?? []).filter(
|
|
38155
|
+
(item2) => item2.clientUserMessageId === clientUserMessageId
|
|
38156
|
+
);
|
|
38157
|
+
if (matches.length === 0) return;
|
|
38158
|
+
const item = matches[0];
|
|
38159
|
+
if (matches.length !== 1 || externalTurnInputText(item.input) !== externalTurnInputText(input))
|
|
38160
|
+
throw new ExternalQueueError(-32602, "Queued steering input changed before delivery");
|
|
38161
|
+
return this.take(threadId2, item.id);
|
|
38162
|
+
}
|
|
38163
|
+
async acceptSteered(threadId2, taken) {
|
|
38164
|
+
this.#acceptedSteers.set(taken.submission.id, threadId2);
|
|
38165
|
+
while (this.#acceptedSteers.size > 128) {
|
|
38166
|
+
this.#acceptedSteers.delete(this.#acceptedSteers.keys().next().value);
|
|
38167
|
+
}
|
|
38168
|
+
await this.#notifyChanged(threadId2);
|
|
38169
|
+
}
|
|
37885
38170
|
restore(threadId2, taken) {
|
|
37886
38171
|
const items = this.#items(threadId2);
|
|
37887
38172
|
if (items.some((item) => item.id === taken.submission.id)) return;
|
|
@@ -37895,6 +38180,9 @@ var ExternalThreadQueue = class {
|
|
|
37895
38180
|
}
|
|
37896
38181
|
forget(threadId2) {
|
|
37897
38182
|
this.#queues.delete(threadId2);
|
|
38183
|
+
for (const [id2, owner] of this.#acceptedSteers) {
|
|
38184
|
+
if (owner === threadId2) this.#acceptedSteers.delete(id2);
|
|
38185
|
+
}
|
|
37898
38186
|
}
|
|
37899
38187
|
#items(threadId2) {
|
|
37900
38188
|
let items = this.#queues.get(threadId2);
|
|
@@ -46089,7 +46377,7 @@ var AppServerHost = class {
|
|
|
46089
46377
|
...arguments_2 ? { arguments: arguments_2 } : {}
|
|
46090
46378
|
});
|
|
46091
46379
|
if (!result.ok) throw new ExternalCommandError(-32073, result.error.message);
|
|
46092
|
-
return { turnId
|
|
46380
|
+
return { turnId, turn: projection.projector.pendingTurn(), gate };
|
|
46093
46381
|
} catch (error51) {
|
|
46094
46382
|
restoreExecutionHost();
|
|
46095
46383
|
thread.running = false;
|
|
@@ -46917,6 +47205,11 @@ var AppServerHost = class {
|
|
|
46917
47205
|
);
|
|
46918
47206
|
}
|
|
46919
47207
|
async #startExternalTurn(request, thread) {
|
|
47208
|
+
const context = routingParams(request).additionalContext;
|
|
47209
|
+
if (isRecord21(context) && Object.hasOwn(context, THREAD_STEERING_CONTEXT_PARAM)) {
|
|
47210
|
+
await this.#steerExternalTurn(request, thread, true);
|
|
47211
|
+
return;
|
|
47212
|
+
}
|
|
46920
47213
|
if (this.#externalThreadBusy(thread) || this.#pendingExternalCommandRequests.has(thread.id)) {
|
|
46921
47214
|
await this.#writer.json(
|
|
46922
47215
|
rpcError(request, -32072, "External Thread already has an active Turn")
|
|
@@ -47135,34 +47428,61 @@ var AppServerHost = class {
|
|
|
47135
47428
|
this.#diagnose(error51);
|
|
47136
47429
|
}
|
|
47137
47430
|
}
|
|
47138
|
-
async #steerExternalTurn(request, thread) {
|
|
47431
|
+
async #steerExternalTurn(request, thread, asStart = false) {
|
|
47432
|
+
let queued;
|
|
47433
|
+
let accepted = false;
|
|
47139
47434
|
try {
|
|
47435
|
+
let params = requestObject(request);
|
|
47436
|
+
const context = params.additionalContext;
|
|
47437
|
+
if (isRecord21(context) && Object.hasOwn(context, THREAD_STEERING_CONTEXT_PARAM)) {
|
|
47438
|
+
const marker = threadSteeringContextSchema.safeParse(
|
|
47439
|
+
context[THREAD_STEERING_CONTEXT_PARAM]
|
|
47440
|
+
);
|
|
47441
|
+
if (!marker.success || marker.data.clientUserMessageId !== params.clientUserMessageId || asStart && marker.data.delivery !== "newTurn")
|
|
47442
|
+
throw new ExternalSteerError(-32602, "Invalid native steering preparation context");
|
|
47443
|
+
if (!asStart && params.expectedTurnId !== marker.data.expectedTurnId)
|
|
47444
|
+
throw new ExternalSteerError(-32074, "Native steering target changed before submission");
|
|
47445
|
+
params = {
|
|
47446
|
+
...params,
|
|
47447
|
+
expectedTurnId: marker.data.expectedTurnId,
|
|
47448
|
+
[THREAD_STEER_DELIVERY_PARAM]: marker.data.delivery
|
|
47449
|
+
};
|
|
47450
|
+
}
|
|
47451
|
+
queued = this.#externalQueue.takeSteered(thread.id, params.clientUserMessageId, params.input);
|
|
47140
47452
|
const started = await this.#externalSteering.run(
|
|
47141
47453
|
thread,
|
|
47142
|
-
|
|
47454
|
+
params,
|
|
47143
47455
|
(text, assertActive) => this.#beginExternalInputTurn(
|
|
47144
47456
|
thread,
|
|
47145
47457
|
text,
|
|
47146
47458
|
assertActive,
|
|
47147
47459
|
typeof requestObject(request).clientUserMessageId === "string" ? requestObject(request).clientUserMessageId : void 0,
|
|
47148
|
-
requestObject(request)[THREAD_REFERENCE_SOURCE_HOST_PARAM]
|
|
47460
|
+
queued ? queued.sourceHostId : requestObject(request)[THREAD_REFERENCE_SOURCE_HOST_PARAM]
|
|
47149
47461
|
),
|
|
47150
47462
|
(input) => this.#insertExternalInput(thread, input)
|
|
47151
47463
|
);
|
|
47464
|
+
accepted = true;
|
|
47465
|
+
if (queued) {
|
|
47466
|
+
await this.#externalQueue.acceptSteered(thread.id, queued).catch((error51) => this.#diagnose(error51));
|
|
47467
|
+
}
|
|
47152
47468
|
try {
|
|
47153
47469
|
await this.#writer.json(
|
|
47154
47470
|
rpcEnvelope(request, {
|
|
47155
|
-
result: { turnId: started.turnId, delivery: started.delivery }
|
|
47471
|
+
result: asStart ? { turn: this.#projectedTurn(thread, started.turnId).projector.pendingTurn() } : { turnId: started.turnId, delivery: started.delivery }
|
|
47156
47472
|
})
|
|
47157
47473
|
);
|
|
47158
47474
|
} finally {
|
|
47159
47475
|
started.gate.resolve();
|
|
47160
47476
|
}
|
|
47161
47477
|
} catch (error51) {
|
|
47478
|
+
if (queued && !accepted) {
|
|
47479
|
+
this.#externalQueue.restore(thread.id, queued);
|
|
47480
|
+
await this.#externalQueue.notifyChanged(thread.id).catch((failure3) => this.#diagnose(failure3));
|
|
47481
|
+
}
|
|
47162
47482
|
await this.#writer.json(
|
|
47163
47483
|
rpcError(
|
|
47164
47484
|
request,
|
|
47165
|
-
error51 instanceof ExternalSteerError || error51 instanceof ExternalCommandError ? error51.code : -32074,
|
|
47485
|
+
error51 instanceof ExternalSteerError || error51 instanceof ExternalCommandError || error51 instanceof ExternalQueueError ? error51.code : -32074,
|
|
47166
47486
|
errorMessage4(error51)
|
|
47167
47487
|
)
|
|
47168
47488
|
);
|
|
@@ -49631,9 +49951,6 @@ async function prepareLocalCodex(input) {
|
|
|
49631
49951
|
current = currentCodexAccountFromOfficialRead(response.result);
|
|
49632
49952
|
return snapshot2();
|
|
49633
49953
|
});
|
|
49634
|
-
void accounts.refresh?.()?.catch(() => {
|
|
49635
|
-
input.diagnosticOutput.write("codexhost: Codex Account identity could not be read\n");
|
|
49636
|
-
});
|
|
49637
49954
|
return {
|
|
49638
49955
|
officialRuntimeScope: scope,
|
|
49639
49956
|
accountControl: accounts,
|