@karlorz/codexhost-cli-win32-x64 0.16.1-0 → 0.16.1-2
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/cpa-live-voice-hook.js +64 -9
- package/app/desktop-controller.mjs +86 -2
- package/app/host-runtime.mjs +215 -66
- package/app/plugins/grok/plugin.mjs +117 -3
- package/app/renderer-extension.js +64 -9
- 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/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Run Pi and Claude Code as first-class external harnesses inside Codex Desktop.
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install -g @karlorz/codexhost-cli@0.16.1-
|
|
10
|
+
npm install -g @karlorz/codexhost-cli@0.16.1-2
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Do not install this package directly. npm selects it through the optional dependencies of `@karlorz/codexhost-cli`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schemaVersion":1,"version":"0.16.1-
|
|
1
|
+
{"schemaVersion":1,"version":"0.16.1-2","distribution":"npm","target":"windows-x64"}
|
|
@@ -16361,9 +16361,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16361
16361
|
const matchesMetadata = (profile) => (version2 === void 0 || profile.version === version2) && (platform === void 0 || profile.platform === platform);
|
|
16362
16362
|
if (present.length > 0) {
|
|
16363
16363
|
const profile = present.length === 1 ? present[0] : void 0;
|
|
16364
|
-
|
|
16365
|
-
|
|
16366
|
-
|
|
16364
|
+
if (!profile || !matchesMetadata(profile)) return void 0;
|
|
16365
|
+
const initialPresent = auditedAppInitialAssetPresent(names, profile.initial);
|
|
16366
|
+
const sharedPresent = auditedAppInitialAssetPresent(names, profile.shared);
|
|
16367
|
+
return sharedPresent && (initialPresent || version2 !== void 0 && platform !== void 0) ? profile : void 0;
|
|
16367
16368
|
}
|
|
16368
16369
|
if (version2 === void 0) return void 0;
|
|
16369
16370
|
const candidates = profiles.filter(matchesMetadata);
|
|
@@ -16391,10 +16392,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16391
16392
|
var RENDERER_NEW_THREAD_PREFERENCE_KEY = "codexhost.new-thread-preference.v1";
|
|
16392
16393
|
|
|
16393
16394
|
// src/renderer-client-owned-voice.ts
|
|
16394
|
-
var CLIENT_OWNED_VOICE_VERSION = "26.
|
|
16395
|
-
var CLIENT_OWNED_VOICE_INITIAL_ASSET = "app-initial-
|
|
16396
|
-
var CLIENT_OWNED_VOICE_SHARED_ASSET = "app-shared-
|
|
16397
|
-
var CLIENT_OWNED_VOICE_OVERLAY_ASSET = "avatar-overlay-native-page-
|
|
16395
|
+
var CLIENT_OWNED_VOICE_VERSION = "26.1027.30824";
|
|
16396
|
+
var CLIENT_OWNED_VOICE_INITIAL_ASSET = "app-initial-60f141238751.js";
|
|
16397
|
+
var CLIENT_OWNED_VOICE_SHARED_ASSET = "app-shared-7815d5a1a42a.js";
|
|
16398
|
+
var CLIENT_OWNED_VOICE_OVERLAY_ASSET = "avatar-overlay-native-page-d9d400e751cd.js";
|
|
16398
16399
|
var CLIENT_OWNED_VOICE_ASSETS = [
|
|
16399
16400
|
{
|
|
16400
16401
|
platform: "darwin",
|
|
@@ -16402,6 +16403,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16402
16403
|
initial: CLIENT_OWNED_VOICE_INITIAL_ASSET,
|
|
16403
16404
|
shared: CLIENT_OWNED_VOICE_SHARED_ASSET,
|
|
16404
16405
|
overlay: CLIENT_OWNED_VOICE_OVERLAY_ASSET,
|
|
16406
|
+
init: "Edr",
|
|
16407
|
+
fetch: "wdr",
|
|
16408
|
+
fetchFrom: "initial",
|
|
16409
|
+
bridge: "LRt",
|
|
16410
|
+
services: "Vct",
|
|
16411
|
+
responseError: "Adr",
|
|
16412
|
+
responseErrorFrom: "initial",
|
|
16413
|
+
capabilityInit: "Ner",
|
|
16414
|
+
capabilityFamily: "Mer",
|
|
16415
|
+
inferenceGateFamily: "Lfr"
|
|
16416
|
+
},
|
|
16417
|
+
{
|
|
16418
|
+
platform: "darwin",
|
|
16419
|
+
version: "26.1023.51421",
|
|
16420
|
+
initial: "app-initial-bc8256c3cccb.js",
|
|
16421
|
+
shared: "app-shared-e9f258fd3588.js",
|
|
16422
|
+
overlay: "avatar-overlay-native-page-af6c3662f64f.js",
|
|
16405
16423
|
init: "xir",
|
|
16406
16424
|
fetch: "yir",
|
|
16407
16425
|
fetchFrom: "initial",
|
|
@@ -16723,7 +16741,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16723
16741
|
if (!object2(bridgeClass) && typeof bridgeClass !== "function") throw new Error();
|
|
16724
16742
|
const client = Reflect.get(fetchClass, "getInstance").call(fetchClass);
|
|
16725
16743
|
const bridge = Reflect.get(bridgeClass, "getInstance").call(bridgeClass);
|
|
16726
|
-
const
|
|
16744
|
+
const errorModule = "responseErrorFrom" in assets && assets.responseErrorFrom === "initial" ? fetchModule : sharedModule;
|
|
16745
|
+
const responseError = typeof errorName === "string" && typeof errorModule[errorName] === "function" ? errorModule[errorName] : async (response) => {
|
|
16727
16746
|
throw Object.assign(new Error(await response.text()), { status: response.status });
|
|
16728
16747
|
};
|
|
16729
16748
|
if (typeof client?.fetch !== "function" || typeof bridge?.dispatchMessage !== "function" || typeof bridge?.subscribe !== "function")
|
|
@@ -17018,6 +17037,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17018
17037
|
function isRecord4(value) {
|
|
17019
17038
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
17020
17039
|
}
|
|
17040
|
+
function conversationIdFrom(request) {
|
|
17041
|
+
if (typeof request === "string" && request) return request;
|
|
17042
|
+
if (!isRecord4(request)) return null;
|
|
17043
|
+
if (typeof request.conversationId === "string" && request.conversationId)
|
|
17044
|
+
return request.conversationId;
|
|
17045
|
+
if (typeof request.threadId === "string" && request.threadId) return request.threadId;
|
|
17046
|
+
return null;
|
|
17047
|
+
}
|
|
17048
|
+
function isHostExternalConversation(conversation, threadId) {
|
|
17049
|
+
return isRecord4(conversation) && conversation.id === threadId && conversation.modelProvider === "codexhost";
|
|
17050
|
+
}
|
|
17021
17051
|
function isManager(value) {
|
|
17022
17052
|
return isRecord4(value) && ["sendRequest", "steerTurn", "startTurn", "getTurnCoordinator"].every(
|
|
17023
17053
|
(key) => typeof value[key] === "function"
|
|
@@ -17053,6 +17083,27 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17053
17083
|
if (!text) return params;
|
|
17054
17084
|
return { ...params, input: [{ type: "text", text, text_elements: [] }] };
|
|
17055
17085
|
}
|
|
17086
|
+
function installExternalQueueUi(manager) {
|
|
17087
|
+
const coordinator = manager.getTurnCoordinator();
|
|
17088
|
+
const options = isRecord4(coordinator) ? coordinator.options : null;
|
|
17089
|
+
if (!isRecord4(options) || typeof options.getMessageQueueMode !== "function") return null;
|
|
17090
|
+
const descriptor = Object.getOwnPropertyDescriptor(options, "getMessageQueueMode");
|
|
17091
|
+
if (!descriptor?.writable) return null;
|
|
17092
|
+
const original = options.getMessageQueueMode;
|
|
17093
|
+
const getMessageQueueMode = (...args) => {
|
|
17094
|
+
const threadId = conversationIdFrom(args[0]);
|
|
17095
|
+
if (threadId && typeof manager.getConversation === "function" && isHostExternalConversation(manager.getConversation(threadId), threadId)) {
|
|
17096
|
+
return Promise.resolve("queue");
|
|
17097
|
+
}
|
|
17098
|
+
return original.apply(options, args);
|
|
17099
|
+
};
|
|
17100
|
+
options.getMessageQueueMode = getMessageQueueMode;
|
|
17101
|
+
return () => {
|
|
17102
|
+
if (options.getMessageQueueMode === getMessageQueueMode) {
|
|
17103
|
+
Object.defineProperty(options, "getMessageQueueMode", descriptor);
|
|
17104
|
+
}
|
|
17105
|
+
};
|
|
17106
|
+
}
|
|
17056
17107
|
function submissionHost(manager) {
|
|
17057
17108
|
const coordinator = manager.getTurnCoordinator();
|
|
17058
17109
|
const options = isRecord4(coordinator) ? coordinator.options : null;
|
|
@@ -17126,6 +17177,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17126
17177
|
function installRendererExternalSteering(target, sendTurnStart, prepareTurnInput) {
|
|
17127
17178
|
if (!isManager(target)) return null;
|
|
17128
17179
|
const manager = target;
|
|
17180
|
+
const restoreQueueUi = installExternalQueueUi(manager);
|
|
17129
17181
|
const originalSteer = manager.steerTurn;
|
|
17130
17182
|
const originalSend = manager.sendRequest;
|
|
17131
17183
|
const routes = /* @__PURE__ */ new Map();
|
|
@@ -17136,7 +17188,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17136
17188
|
if ((method === "turn/start" || method === "turn/steer") && prepareTurnInput) {
|
|
17137
17189
|
params = prepareTurnInput(params);
|
|
17138
17190
|
}
|
|
17139
|
-
if (method === "turn/start"
|
|
17191
|
+
if (method === "turn/start" || method === "turn/steer") {
|
|
17192
|
+
params = restoreQueuedTurnStartText(manager, params);
|
|
17193
|
+
}
|
|
17140
17194
|
const messageId = isRecord4(params) ? params.clientUserMessageId : null;
|
|
17141
17195
|
const route = typeof messageId === "string" && isRecord4(params) ? routes.get(`${params.threadId}\0${messageId}`) : void 0;
|
|
17142
17196
|
if (method !== "turn/start" || !isRecord4(params) || !route || route.threadId !== params.threadId) {
|
|
@@ -17343,6 +17397,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17343
17397
|
});
|
|
17344
17398
|
return () => {
|
|
17345
17399
|
disposed = true;
|
|
17400
|
+
restoreQueueUi?.();
|
|
17346
17401
|
restoreMethod("steerTurn");
|
|
17347
17402
|
if (getStreamRole) restoreMethod("getStreamRole");
|
|
17348
17403
|
if (pending.size === 0) {
|
|
@@ -17891,11 +17891,82 @@ function rendererHostRpcHostIds(discovery) {
|
|
|
17891
17891
|
(hostId2) => typeof hostId2 === "string"
|
|
17892
17892
|
);
|
|
17893
17893
|
}
|
|
17894
|
+
function rendererHostRpcUsesExternalQueue(store, conversationId) {
|
|
17895
|
+
const providers = /* @__PURE__ */ new Map();
|
|
17896
|
+
for (const members of store.familyBindings.values()) {
|
|
17897
|
+
for (const member of members.values()) {
|
|
17898
|
+
const signal = member.value;
|
|
17899
|
+
if (signal === null || typeof signal !== "object" || !("get" in signal) || typeof signal.get !== "function")
|
|
17900
|
+
continue;
|
|
17901
|
+
let value;
|
|
17902
|
+
try {
|
|
17903
|
+
value = signal.get();
|
|
17904
|
+
} catch {
|
|
17905
|
+
continue;
|
|
17906
|
+
}
|
|
17907
|
+
if (value === null || typeof value !== "object" || !("conversationId" in value) || value.conversationId !== conversationId || !("hostId" in value) || typeof value.hostId !== "string" || !("modelProvider" in value) || typeof value.modelProvider !== "string")
|
|
17908
|
+
continue;
|
|
17909
|
+
const hostProviders = providers.get(value.hostId) ?? /* @__PURE__ */ new Set();
|
|
17910
|
+
hostProviders.add(value.modelProvider);
|
|
17911
|
+
providers.set(value.hostId, hostProviders);
|
|
17912
|
+
}
|
|
17913
|
+
}
|
|
17914
|
+
if (providers.size !== 1) return false;
|
|
17915
|
+
const values = providers.values().next().value;
|
|
17916
|
+
return values?.size === 1 && values.has("codexhost");
|
|
17917
|
+
}
|
|
17918
|
+
|
|
17919
|
+
// packages/desktop-control/src/renderer-external-queue-policy.ts
|
|
17920
|
+
function installRendererExternalQueuePolicy(root, target, dependencies) {
|
|
17921
|
+
if (target.__codexhostExternalQueuePolicyV1) return target.__codexhostExternalQueuePolicyV1;
|
|
17922
|
+
const store = dependencies.findStore(root);
|
|
17923
|
+
if (!store) return null;
|
|
17924
|
+
const record3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
17925
|
+
let disposed = false;
|
|
17926
|
+
const route = (message) => {
|
|
17927
|
+
if (!Array.isArray(message) || message.length !== 2 || message[0] !== "push") return message;
|
|
17928
|
+
const expression = message[1];
|
|
17929
|
+
if (!Array.isArray(expression) || expression.length !== 4 || expression[0] !== "pipeline")
|
|
17930
|
+
return message;
|
|
17931
|
+
const [, importId, path5, args] = expression;
|
|
17932
|
+
if (!Array.isArray(path5) || path5.length !== 1 || path5[0] !== "sendMessage" || !Array.isArray(args))
|
|
17933
|
+
return message;
|
|
17934
|
+
const input = args[0];
|
|
17935
|
+
if (!record3(input) || typeof input.conversationId !== "string" || !record3(input.message) || !dependencies.usesExternalQueue(store, input.conversationId))
|
|
17936
|
+
return message;
|
|
17937
|
+
return [
|
|
17938
|
+
"push",
|
|
17939
|
+
["pipeline", importId, path5, [{ ...input, queueModeOverride: "queue" }, ...args.slice(1)]]
|
|
17940
|
+
];
|
|
17941
|
+
};
|
|
17942
|
+
const port = dependencies.portPrototype;
|
|
17943
|
+
const original = port.postMessage;
|
|
17944
|
+
const postMessage = function(message, ...rest) {
|
|
17945
|
+
return original.call(this, disposed ? message : route(message), ...rest);
|
|
17946
|
+
};
|
|
17947
|
+
port.postMessage = postMessage;
|
|
17948
|
+
const policy = {
|
|
17949
|
+
dispose() {
|
|
17950
|
+
disposed = true;
|
|
17951
|
+
if (port.postMessage === postMessage) port.postMessage = original;
|
|
17952
|
+
if (target.__codexhostExternalQueuePolicyV1 === policy)
|
|
17953
|
+
delete target.__codexhostExternalQueuePolicyV1;
|
|
17954
|
+
}
|
|
17955
|
+
};
|
|
17956
|
+
Object.defineProperty(target, "__codexhostExternalQueuePolicyV1", {
|
|
17957
|
+
configurable: true,
|
|
17958
|
+
value: policy
|
|
17959
|
+
});
|
|
17960
|
+
return policy;
|
|
17961
|
+
}
|
|
17894
17962
|
|
|
17895
17963
|
// packages/desktop-control/src/renderer-host-rpc-routing.ts
|
|
17896
17964
|
function installRendererHostRpcRouting(root, target, dependencies) {
|
|
17897
17965
|
const existing = target.__codexhostHostRoutingV1;
|
|
17898
|
-
if (existing)
|
|
17966
|
+
if (existing) {
|
|
17967
|
+
dependencies.installQueuePolicy(root, target);
|
|
17968
|
+
return existing;
|
|
17969
|
+
}
|
|
17899
17970
|
let disposed = false;
|
|
17900
17971
|
let discovery = null;
|
|
17901
17972
|
const routes = /* @__PURE__ */ new Map();
|
|
@@ -17908,6 +17979,7 @@ function installRendererHostRpcRouting(root, target, dependencies) {
|
|
|
17908
17979
|
return discovery;
|
|
17909
17980
|
};
|
|
17910
17981
|
if (!read()) return null;
|
|
17982
|
+
const queuePolicy = dependencies.installQueuePolicy(root, target);
|
|
17911
17983
|
const isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17912
17984
|
const externalDrafts = /* @__PURE__ */ new Map();
|
|
17913
17985
|
const selectedModels = /* @__PURE__ */ new Map();
|
|
@@ -18130,6 +18202,7 @@ function installRendererHostRpcRouting(root, target, dependencies) {
|
|
|
18130
18202
|
externalDrafts.clear();
|
|
18131
18203
|
selectedModels.clear();
|
|
18132
18204
|
if (port.postMessage === postMessage) port.postMessage = originalPostMessage;
|
|
18205
|
+
queuePolicy?.dispose();
|
|
18133
18206
|
if (target.__codexhostHostRoutingV1 === routing) {
|
|
18134
18207
|
delete target.__codexhostHostRoutingV1;
|
|
18135
18208
|
publish(null);
|
|
@@ -18173,13 +18246,24 @@ function directRendererInstaller() {
|
|
|
18173
18246
|
: (composer ?? document);
|
|
18174
18247
|
return discover(source);
|
|
18175
18248
|
},
|
|
18249
|
+
installQueuePolicy: (root, target) => (${installRendererExternalQueuePolicy.toString()})(root, target, {
|
|
18250
|
+
findStore: ${findRendererAppScopeStore.toString()},
|
|
18251
|
+
usesExternalQueue: ${rendererHostRpcUsesExternalQueue.toString()},
|
|
18252
|
+
portPrototype: MessagePort.prototype,
|
|
18253
|
+
}),
|
|
18176
18254
|
portPrototype: MessagePort.prototype,
|
|
18177
18255
|
});
|
|
18178
18256
|
// Desktop 26.1027 moved AppServerManagers to the main process. Older builds
|
|
18179
18257
|
// expose native managers in Renderer hook state; the main-process mode only
|
|
18180
18258
|
// applies when none is visible and its per-Host RPC store is identified.
|
|
18181
18259
|
const routing = (() => {
|
|
18182
|
-
if (window.__codexhostHostRoutingV1)
|
|
18260
|
+
if (window.__codexhostHostRoutingV1) {
|
|
18261
|
+
const existing = window.__codexhostHostRoutingV1;
|
|
18262
|
+
if (['local', ...(existing.knownHostIds?.() ?? [])].some(
|
|
18263
|
+
hostId => existing.forHost(hostId)?.manager.kind === 'main-process-rpc'
|
|
18264
|
+
)) installRpc();
|
|
18265
|
+
return existing;
|
|
18266
|
+
}
|
|
18183
18267
|
const native = discover(document);
|
|
18184
18268
|
if (native.managers.length || native.registries.length) return installNative();
|
|
18185
18269
|
const rpc = installRpc();
|
package/app/host-runtime.mjs
CHANGED
|
@@ -29602,12 +29602,87 @@ function resolveRendererHostRpc(discovery, hostId2) {
|
|
|
29602
29602
|
function rendererHostRpcHostIds(discovery) {
|
|
29603
29603
|
return [...discovery.family.keys()].filter((hostId2) => typeof hostId2 === "string");
|
|
29604
29604
|
}
|
|
29605
|
+
function rendererHostRpcUsesExternalQueue(store, conversationId) {
|
|
29606
|
+
const providers = /* @__PURE__ */ new Map();
|
|
29607
|
+
for (const members of store.familyBindings.values()) {
|
|
29608
|
+
for (const member of members.values()) {
|
|
29609
|
+
const signal = member.value;
|
|
29610
|
+
if (signal === null || typeof signal !== "object" || !("get" in signal) || typeof signal.get !== "function")
|
|
29611
|
+
continue;
|
|
29612
|
+
let value2;
|
|
29613
|
+
try {
|
|
29614
|
+
value2 = signal.get();
|
|
29615
|
+
} catch {
|
|
29616
|
+
continue;
|
|
29617
|
+
}
|
|
29618
|
+
if (value2 === null || typeof value2 !== "object" || !("conversationId" in value2) || value2.conversationId !== conversationId || !("hostId" in value2) || typeof value2.hostId !== "string" || !("modelProvider" in value2) || typeof value2.modelProvider !== "string")
|
|
29619
|
+
continue;
|
|
29620
|
+
const hostProviders = providers.get(value2.hostId) ?? /* @__PURE__ */ new Set();
|
|
29621
|
+
hostProviders.add(value2.modelProvider);
|
|
29622
|
+
providers.set(value2.hostId, hostProviders);
|
|
29623
|
+
}
|
|
29624
|
+
}
|
|
29625
|
+
if (providers.size !== 1)
|
|
29626
|
+
return false;
|
|
29627
|
+
const values = providers.values().next().value;
|
|
29628
|
+
return values?.size === 1 && values.has("codexhost");
|
|
29629
|
+
}
|
|
29630
|
+
|
|
29631
|
+
// packages/desktop-control/dist/renderer-external-queue-policy.js
|
|
29632
|
+
function installRendererExternalQueuePolicy(root, target, dependencies2) {
|
|
29633
|
+
if (target.__codexhostExternalQueuePolicyV1)
|
|
29634
|
+
return target.__codexhostExternalQueuePolicyV1;
|
|
29635
|
+
const store = dependencies2.findStore(root);
|
|
29636
|
+
if (!store)
|
|
29637
|
+
return null;
|
|
29638
|
+
const record5 = (value2) => value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
|
|
29639
|
+
let disposed = false;
|
|
29640
|
+
const route = (message2) => {
|
|
29641
|
+
if (!Array.isArray(message2) || message2.length !== 2 || message2[0] !== "push")
|
|
29642
|
+
return message2;
|
|
29643
|
+
const expression = message2[1];
|
|
29644
|
+
if (!Array.isArray(expression) || expression.length !== 4 || expression[0] !== "pipeline")
|
|
29645
|
+
return message2;
|
|
29646
|
+
const [, importId, path47, args] = expression;
|
|
29647
|
+
if (!Array.isArray(path47) || path47.length !== 1 || path47[0] !== "sendMessage" || !Array.isArray(args))
|
|
29648
|
+
return message2;
|
|
29649
|
+
const input = args[0];
|
|
29650
|
+
if (!record5(input) || typeof input.conversationId !== "string" || !record5(input.message) || !dependencies2.usesExternalQueue(store, input.conversationId))
|
|
29651
|
+
return message2;
|
|
29652
|
+
return [
|
|
29653
|
+
"push",
|
|
29654
|
+
["pipeline", importId, path47, [{ ...input, queueModeOverride: "queue" }, ...args.slice(1)]]
|
|
29655
|
+
];
|
|
29656
|
+
};
|
|
29657
|
+
const port = dependencies2.portPrototype;
|
|
29658
|
+
const original = port.postMessage;
|
|
29659
|
+
const postMessage = function(message2, ...rest) {
|
|
29660
|
+
return original.call(this, disposed ? message2 : route(message2), ...rest);
|
|
29661
|
+
};
|
|
29662
|
+
port.postMessage = postMessage;
|
|
29663
|
+
const policy = {
|
|
29664
|
+
dispose() {
|
|
29665
|
+
disposed = true;
|
|
29666
|
+
if (port.postMessage === postMessage)
|
|
29667
|
+
port.postMessage = original;
|
|
29668
|
+
if (target.__codexhostExternalQueuePolicyV1 === policy)
|
|
29669
|
+
delete target.__codexhostExternalQueuePolicyV1;
|
|
29670
|
+
}
|
|
29671
|
+
};
|
|
29672
|
+
Object.defineProperty(target, "__codexhostExternalQueuePolicyV1", {
|
|
29673
|
+
configurable: true,
|
|
29674
|
+
value: policy
|
|
29675
|
+
});
|
|
29676
|
+
return policy;
|
|
29677
|
+
}
|
|
29605
29678
|
|
|
29606
29679
|
// packages/desktop-control/dist/renderer-host-rpc-routing.js
|
|
29607
29680
|
function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
29608
29681
|
const existing = target.__codexhostHostRoutingV1;
|
|
29609
|
-
if (existing)
|
|
29682
|
+
if (existing) {
|
|
29683
|
+
dependencies2.installQueuePolicy(root, target);
|
|
29610
29684
|
return existing;
|
|
29685
|
+
}
|
|
29611
29686
|
let disposed = false;
|
|
29612
29687
|
let discovery = null;
|
|
29613
29688
|
const routes = /* @__PURE__ */ new Map();
|
|
@@ -29622,6 +29697,7 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
29622
29697
|
};
|
|
29623
29698
|
if (!read())
|
|
29624
29699
|
return null;
|
|
29700
|
+
const queuePolicy = dependencies2.installQueuePolicy(root, target);
|
|
29625
29701
|
const isRecord22 = (value2) => typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
29626
29702
|
const externalDrafts = /* @__PURE__ */ new Map();
|
|
29627
29703
|
const selectedModels = /* @__PURE__ */ new Map();
|
|
@@ -29872,6 +29948,7 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
29872
29948
|
selectedModels.clear();
|
|
29873
29949
|
if (port.postMessage === postMessage)
|
|
29874
29950
|
port.postMessage = originalPostMessage;
|
|
29951
|
+
queuePolicy?.dispose();
|
|
29875
29952
|
if (target.__codexhostHostRoutingV1 === routing) {
|
|
29876
29953
|
delete target.__codexhostHostRoutingV1;
|
|
29877
29954
|
publish(null);
|
|
@@ -29915,13 +29992,24 @@ function directRendererInstaller() {
|
|
|
29915
29992
|
: (composer ?? document);
|
|
29916
29993
|
return discover(source);
|
|
29917
29994
|
},
|
|
29995
|
+
installQueuePolicy: (root, target) => (${installRendererExternalQueuePolicy.toString()})(root, target, {
|
|
29996
|
+
findStore: ${findRendererAppScopeStore.toString()},
|
|
29997
|
+
usesExternalQueue: ${rendererHostRpcUsesExternalQueue.toString()},
|
|
29998
|
+
portPrototype: MessagePort.prototype,
|
|
29999
|
+
}),
|
|
29918
30000
|
portPrototype: MessagePort.prototype,
|
|
29919
30001
|
});
|
|
29920
30002
|
// Desktop 26.1027 moved AppServerManagers to the main process. Older builds
|
|
29921
30003
|
// expose native managers in Renderer hook state; the main-process mode only
|
|
29922
30004
|
// applies when none is visible and its per-Host RPC store is identified.
|
|
29923
30005
|
const routing = (() => {
|
|
29924
|
-
if (window.__codexhostHostRoutingV1)
|
|
30006
|
+
if (window.__codexhostHostRoutingV1) {
|
|
30007
|
+
const existing = window.__codexhostHostRoutingV1;
|
|
30008
|
+
if (['local', ...(existing.knownHostIds?.() ?? [])].some(
|
|
30009
|
+
hostId => existing.forHost(hostId)?.manager.kind === 'main-process-rpc'
|
|
30010
|
+
)) installRpc();
|
|
30011
|
+
return existing;
|
|
30012
|
+
}
|
|
29925
30013
|
const native = discover(document);
|
|
29926
30014
|
if (native.managers.length || native.registries.length) return installNative();
|
|
29927
30015
|
const rpc = installRpc();
|
|
@@ -36083,6 +36171,10 @@ var ExternalThreadQueue = class {
|
|
|
36083
36171
|
has(threadId2) {
|
|
36084
36172
|
return (this.#queues.get(threadId2)?.length ?? 0) > 0;
|
|
36085
36173
|
}
|
|
36174
|
+
peek(threadId2) {
|
|
36175
|
+
const item = this.#queues.get(threadId2)?.[0];
|
|
36176
|
+
return item ? publicSubmission(item) : void 0;
|
|
36177
|
+
}
|
|
36086
36178
|
list(threadId2, params) {
|
|
36087
36179
|
const items = this.#queues.get(threadId2) ?? [];
|
|
36088
36180
|
const start = params.cursor == null ? 0 : Number(params.cursor);
|
|
@@ -36230,6 +36322,30 @@ async function resolveExternalCommand(commands, text, options2 = {}) {
|
|
|
36230
36322
|
};
|
|
36231
36323
|
}
|
|
36232
36324
|
|
|
36325
|
+
// packages/host-runtime/src/external-thread-follow-up-queue.ts
|
|
36326
|
+
function isRecord15(value2) {
|
|
36327
|
+
return value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
|
|
36328
|
+
}
|
|
36329
|
+
function queuedSubmissionText(input) {
|
|
36330
|
+
return input.filter(isRecord15).map((item) => item.text).filter((value2) => typeof value2 === "string" && value2.length > 0).join("\n");
|
|
36331
|
+
}
|
|
36332
|
+
function queuedSubmissionInput(input) {
|
|
36333
|
+
return input.map((entry) => {
|
|
36334
|
+
if (!isRecord15(entry) || typeof entry.text !== "string" || entry.text.length === 0) {
|
|
36335
|
+
return entry;
|
|
36336
|
+
}
|
|
36337
|
+
if (entry.type === "input_text") {
|
|
36338
|
+
return {
|
|
36339
|
+
type: "text",
|
|
36340
|
+
text: entry.text,
|
|
36341
|
+
text_elements: Array.isArray(entry.text_elements) ? entry.text_elements : []
|
|
36342
|
+
};
|
|
36343
|
+
}
|
|
36344
|
+
if (entry.type !== "text" || Array.isArray(entry.text_elements)) return entry;
|
|
36345
|
+
return { ...entry, text_elements: [] };
|
|
36346
|
+
});
|
|
36347
|
+
}
|
|
36348
|
+
|
|
36233
36349
|
// packages/host-runtime/src/external-turn-steering.ts
|
|
36234
36350
|
function isHarnessCommand(thread, text) {
|
|
36235
36351
|
return thread.session.commands !== void 0 && isExternalCommandCandidate(restoreHarnessCommandMentions(text));
|
|
@@ -36241,6 +36357,13 @@ function externalSteeringDelivery(thread, text) {
|
|
|
36241
36357
|
}
|
|
36242
36358
|
return thread.session.capabilities.steer === true ? "activeTurn" : "newTurn";
|
|
36243
36359
|
}
|
|
36360
|
+
async function sessionCanNativeSteer(thread) {
|
|
36361
|
+
if (thread.session.readCapabilities) {
|
|
36362
|
+
const capabilities = await thread.session.readCapabilities();
|
|
36363
|
+
return capabilities.steer === true;
|
|
36364
|
+
}
|
|
36365
|
+
return thread.session.capabilities.steer === true;
|
|
36366
|
+
}
|
|
36244
36367
|
var ExternalSteerError = class extends Error {
|
|
36245
36368
|
constructor(code, message2) {
|
|
36246
36369
|
super(message2);
|
|
@@ -36257,14 +36380,17 @@ function parseInput(params) {
|
|
|
36257
36380
|
if (typeof params.expectedTurnId !== "string" || !params.expectedTurnId.trim()) {
|
|
36258
36381
|
throw new ExternalSteerError(-32602, "External steering requires expectedTurnId");
|
|
36259
36382
|
}
|
|
36260
|
-
|
|
36261
|
-
|
|
36262
|
-
|
|
36383
|
+
const input = Array.isArray(params.input) ? queuedSubmissionInput(params.input) : [];
|
|
36384
|
+
const textItems = input.filter(
|
|
36385
|
+
(item) => item !== null && typeof item === "object" && !Array.isArray(item) && typeof item.text === "string" && (item.type === void 0 || item.type === "text" || item.type === "input_text")
|
|
36386
|
+
);
|
|
36387
|
+
if (input.length === 0 || textItems.length !== input.length) {
|
|
36263
36388
|
throw new ExternalSteerError(-32602, "External steering requires text input");
|
|
36264
36389
|
}
|
|
36265
|
-
const text =
|
|
36266
|
-
if (!text.trim())
|
|
36390
|
+
const text = queuedSubmissionText(textItems);
|
|
36391
|
+
if (!text.trim()) {
|
|
36267
36392
|
throw new ExternalSteerError(-32602, "External steering input must not be empty");
|
|
36393
|
+
}
|
|
36268
36394
|
const clientUserMessageId = params.clientUserMessageId;
|
|
36269
36395
|
if (clientUserMessageId != null && (typeof clientUserMessageId !== "string" || !clientUserMessageId.trim())) {
|
|
36270
36396
|
throw new ExternalSteerError(-32602, "External steering message identity is invalid");
|
|
@@ -36537,7 +36663,7 @@ import { createHash as createHash7 } from "node:crypto";
|
|
|
36537
36663
|
var CURSOR_PREFIX = "codexhost:thread-messages:v1:";
|
|
36538
36664
|
var DEFAULT_MESSAGE_LIMIT = 25;
|
|
36539
36665
|
var MAX_MESSAGE_LIMIT = 100;
|
|
36540
|
-
function
|
|
36666
|
+
function isRecord16(value2) {
|
|
36541
36667
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
36542
36668
|
}
|
|
36543
36669
|
function stringValue(value2) {
|
|
@@ -36546,12 +36672,12 @@ function stringValue(value2) {
|
|
|
36546
36672
|
function textFromUserItem(item) {
|
|
36547
36673
|
if (!Array.isArray(item.content)) return "";
|
|
36548
36674
|
return item.content.flatMap(
|
|
36549
|
-
(part) =>
|
|
36675
|
+
(part) => isRecord16(part) && part.type === "text" && typeof part.text === "string" ? [part.text] : []
|
|
36550
36676
|
).join("\n");
|
|
36551
36677
|
}
|
|
36552
36678
|
function threadStatus(value2, running) {
|
|
36553
36679
|
if (running) return "running";
|
|
36554
|
-
if (
|
|
36680
|
+
if (isRecord16(value2)) {
|
|
36555
36681
|
if (value2.type === "active") return "running";
|
|
36556
36682
|
}
|
|
36557
36683
|
return "completed";
|
|
@@ -36568,10 +36694,10 @@ function allVisibleMessages(turns) {
|
|
|
36568
36694
|
const turnId = stringValue(turn.id);
|
|
36569
36695
|
if (!turnId || !Array.isArray(turn.items)) continue;
|
|
36570
36696
|
const agentItems = turn.items.filter(
|
|
36571
|
-
(item) =>
|
|
36697
|
+
(item) => isRecord16(item) && item.type === "agentMessage"
|
|
36572
36698
|
);
|
|
36573
36699
|
for (const item of turn.items) {
|
|
36574
|
-
if (!
|
|
36700
|
+
if (!isRecord16(item)) continue;
|
|
36575
36701
|
const id2 = stringValue(item.id);
|
|
36576
36702
|
if (!id2) continue;
|
|
36577
36703
|
if (item.type === "userMessage") {
|
|
@@ -36646,7 +36772,7 @@ function projectDelegationThreadSnapshot(input) {
|
|
|
36646
36772
|
const progress = latestTurnMessages.filter((message2) => message2.phase !== "final" && message2.text.trim()).map(({ id: id2, turnId, text }) => ({ id: id2, turnId, text }));
|
|
36647
36773
|
const result = input.running ? { availability: "pending" } : final ? { availability: "available", text: final.text } : {
|
|
36648
36774
|
availability: "unavailable",
|
|
36649
|
-
...
|
|
36775
|
+
...isRecord16(latestTurn?.error) && typeof latestTurn.error.message === "string" ? { message: latestTurn.error.message } : {}
|
|
36650
36776
|
};
|
|
36651
36777
|
const offset = options2.view === "messages" ? decodeCursor(input.threadId, options2.cursor) : visible.length;
|
|
36652
36778
|
const page = options2.view === "messages" ? [] : void 0;
|
|
@@ -39606,11 +39732,11 @@ function spawnOfficialAppServerConnection(input) {
|
|
|
39606
39732
|
}
|
|
39607
39733
|
|
|
39608
39734
|
// packages/host-runtime/src/account/codex-account-control.ts
|
|
39609
|
-
function
|
|
39735
|
+
function isRecord17(value2) {
|
|
39610
39736
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
39611
39737
|
}
|
|
39612
39738
|
function currentCodexAccountFromOfficialRead(result) {
|
|
39613
|
-
if (!
|
|
39739
|
+
if (!isRecord17(result) || !isRecord17(result.account) || result.account.type !== "chatgpt") {
|
|
39614
39740
|
return null;
|
|
39615
39741
|
}
|
|
39616
39742
|
const email3 = external_exports.string().email().max(320).safeParse(result.account.email);
|
|
@@ -39646,7 +39772,7 @@ import { randomUUID as randomUUID18 } from "node:crypto";
|
|
|
39646
39772
|
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
39647
39773
|
var INTERNAL_REQUEST_PREFIX = "codexhost:official:";
|
|
39648
39774
|
var MAX_RETIRED_IDS = 1024;
|
|
39649
|
-
function
|
|
39775
|
+
function isRecord18(value2) {
|
|
39650
39776
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
39651
39777
|
}
|
|
39652
39778
|
var OfficialRequestBroker = class {
|
|
@@ -39689,7 +39815,7 @@ var OfficialRequestBroker = class {
|
|
|
39689
39815
|
});
|
|
39690
39816
|
}
|
|
39691
39817
|
handle(value2) {
|
|
39692
|
-
if (!
|
|
39818
|
+
if (!isRecord18(value2) || typeof value2.id !== "string") return false;
|
|
39693
39819
|
const pending = this.#pending.get(value2.id);
|
|
39694
39820
|
if (!pending) return this.#retired.has(value2.id);
|
|
39695
39821
|
clearTimeout(pending.timeout);
|
|
@@ -40467,11 +40593,11 @@ function createOwnedConnectionBackend(factory) {
|
|
|
40467
40593
|
}
|
|
40468
40594
|
|
|
40469
40595
|
// packages/host-runtime/src/route-observation.ts
|
|
40470
|
-
function
|
|
40596
|
+
function isRecord19(value2) {
|
|
40471
40597
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
40472
40598
|
}
|
|
40473
40599
|
function classifyThreadPurpose(request) {
|
|
40474
|
-
return
|
|
40600
|
+
return isRecord19(request.params) && request.params.ephemeral === true ? "ephemeral" : "conversation";
|
|
40475
40601
|
}
|
|
40476
40602
|
var RequestRouteObservationTracker = class {
|
|
40477
40603
|
#nextCreateOrdinal = 0;
|
|
@@ -40496,13 +40622,13 @@ var RequestRouteObservationTracker = class {
|
|
|
40496
40622
|
this.#createByThreadId.set(threadId2, tracked);
|
|
40497
40623
|
}
|
|
40498
40624
|
bindOfficialResponse(response) {
|
|
40499
|
-
if (!
|
|
40625
|
+
if (!isRecord19(response) || !("id" in response)) return;
|
|
40500
40626
|
const tracked = this.#pendingByRequestId.get(response.id);
|
|
40501
40627
|
if (!tracked) return;
|
|
40502
40628
|
this.#pendingByRequestId.delete(response.id);
|
|
40503
40629
|
const result = response.result;
|
|
40504
|
-
const thread =
|
|
40505
|
-
if (
|
|
40630
|
+
const thread = isRecord19(result) ? result.thread : null;
|
|
40631
|
+
if (isRecord19(thread) && typeof thread.id === "string") {
|
|
40506
40632
|
this.#createByThreadId.set(thread.id, tracked);
|
|
40507
40633
|
}
|
|
40508
40634
|
}
|
|
@@ -40720,11 +40846,11 @@ var OfficialThreadListError = class extends Error {
|
|
|
40720
40846
|
}
|
|
40721
40847
|
rpcError;
|
|
40722
40848
|
};
|
|
40723
|
-
function
|
|
40849
|
+
function isRecord20(value2) {
|
|
40724
40850
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
40725
40851
|
}
|
|
40726
40852
|
function officialThreadListPageFromResponse(response) {
|
|
40727
|
-
if (
|
|
40853
|
+
if (isRecord20(response.error)) {
|
|
40728
40854
|
if (!Number.isSafeInteger(response.error.code) || typeof response.error.message !== "string") {
|
|
40729
40855
|
throw new Error("Official thread/list error response is invalid");
|
|
40730
40856
|
}
|
|
@@ -41129,30 +41255,6 @@ function externalThreadEmptyOfficialResult(method) {
|
|
|
41129
41255
|
return EMPTY_RESULTS.get(method)?.();
|
|
41130
41256
|
}
|
|
41131
41257
|
|
|
41132
|
-
// packages/host-runtime/src/external-thread-follow-up-queue.ts
|
|
41133
|
-
function isRecord20(value2) {
|
|
41134
|
-
return value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
|
|
41135
|
-
}
|
|
41136
|
-
function queuedSubmissionText(input) {
|
|
41137
|
-
return input.filter(isRecord20).map((item) => item.text).filter((value2) => typeof value2 === "string" && value2.length > 0).join("\n");
|
|
41138
|
-
}
|
|
41139
|
-
function queuedSubmissionInput(input) {
|
|
41140
|
-
return input.map((entry) => {
|
|
41141
|
-
if (!isRecord20(entry) || typeof entry.text !== "string" || entry.text.length === 0) {
|
|
41142
|
-
return entry;
|
|
41143
|
-
}
|
|
41144
|
-
if (entry.type === "input_text") {
|
|
41145
|
-
return {
|
|
41146
|
-
type: "text",
|
|
41147
|
-
text: entry.text,
|
|
41148
|
-
text_elements: Array.isArray(entry.text_elements) ? entry.text_elements : []
|
|
41149
|
-
};
|
|
41150
|
-
}
|
|
41151
|
-
if (entry.type !== "text" || Array.isArray(entry.text_elements)) return entry;
|
|
41152
|
-
return { ...entry, text_elements: [] };
|
|
41153
|
-
});
|
|
41154
|
-
}
|
|
41155
|
-
|
|
41156
41258
|
// packages/host-runtime/src/observed-session-usage.ts
|
|
41157
41259
|
var ObservedSessionUsage = class {
|
|
41158
41260
|
constructor(providers, prices, diagnose) {
|
|
@@ -41494,6 +41596,7 @@ var AppServerHost = class {
|
|
|
41494
41596
|
#externalVoiceResults = new ExternalVoiceResults(
|
|
41495
41597
|
(threadId2, text) => this.#externalVoice.reportProgress(threadId2, text)
|
|
41496
41598
|
);
|
|
41599
|
+
#injectingQueuedFollowUp = /* @__PURE__ */ new Set();
|
|
41497
41600
|
#externalQueue = new ExternalThreadQueue({
|
|
41498
41601
|
notifyChanged: (threadId2) => this.#writer.json({ method: "thread/queue/changed", params: { threadId: threadId2 } })
|
|
41499
41602
|
});
|
|
@@ -45231,6 +45334,38 @@ var AppServerHost = class {
|
|
|
45231
45334
|
throw error51;
|
|
45232
45335
|
}
|
|
45233
45336
|
}
|
|
45337
|
+
/** Pending rows remain editable until a tool/model boundary hands them to native steering. */
|
|
45338
|
+
async #injectQueuedFollowUp(thread, turnId) {
|
|
45339
|
+
if (this.#injectingQueuedFollowUp.has(thread.id)) return;
|
|
45340
|
+
this.#injectingQueuedFollowUp.add(thread.id);
|
|
45341
|
+
try {
|
|
45342
|
+
while (thread.running && thread.activeTurnId === turnId && this.#externalQueue.has(thread.id) && !this.#externalSteering.hasPending(thread.id)) {
|
|
45343
|
+
if (!await sessionCanNativeSteer(thread)) return;
|
|
45344
|
+
if (!thread.running || thread.activeTurnId !== turnId) return;
|
|
45345
|
+
const peeked = this.#externalQueue.peek(thread.id);
|
|
45346
|
+
if (!peeked) return;
|
|
45347
|
+
const text = queuedSubmissionText(peeked.input);
|
|
45348
|
+
if (!text.trim() || thread.session.commands && isExternalCommandCandidate(text)) return;
|
|
45349
|
+
const taken = this.#externalQueue.take(thread.id, peeked.id);
|
|
45350
|
+
try {
|
|
45351
|
+
await this.#insertExternalInput(thread, {
|
|
45352
|
+
turnId,
|
|
45353
|
+
text,
|
|
45354
|
+
clientUserMessageId: taken.submission.clientUserMessageId
|
|
45355
|
+
});
|
|
45356
|
+
await this.#externalQueue.notifyChanged(thread.id);
|
|
45357
|
+
} catch (error51) {
|
|
45358
|
+
this.#externalQueue.restore(thread.id, taken);
|
|
45359
|
+
await this.#externalQueue.notifyChanged(thread.id);
|
|
45360
|
+
throw error51;
|
|
45361
|
+
}
|
|
45362
|
+
}
|
|
45363
|
+
} catch (error51) {
|
|
45364
|
+
this.#diagnose(error51);
|
|
45365
|
+
} finally {
|
|
45366
|
+
this.#injectingQueuedFollowUp.delete(thread.id);
|
|
45367
|
+
}
|
|
45368
|
+
}
|
|
45234
45369
|
/** Desktop leaves queued follow-ups to the app-server once a Turn completes normally. */
|
|
45235
45370
|
async #drainExternalQueue(thread) {
|
|
45236
45371
|
if (!this.#externalQueue.has(thread.id) || this.#externalThreadBusy(thread) || this.#pendingExternalCommandRequests.has(thread.id))
|
|
@@ -45277,26 +45412,37 @@ var AppServerHost = class {
|
|
|
45277
45412
|
}
|
|
45278
45413
|
}
|
|
45279
45414
|
/** Native same-Turn input; `insertNativeSteer` owns the delivery and its fallback signal. */
|
|
45415
|
+
async #projectQueuedSteer(thread, turnId, text, clientUserMessageId) {
|
|
45416
|
+
const item = {
|
|
45417
|
+
type: "userMessage",
|
|
45418
|
+
itemId: hostItemIdSchema.parse(randomUUID19()),
|
|
45419
|
+
input: [{ type: "text", text }]
|
|
45420
|
+
};
|
|
45421
|
+
const projection = this.#projectedTurn(thread, turnId);
|
|
45422
|
+
if (clientUserMessageId) {
|
|
45423
|
+
projection.projector.bindUserMessageClientId(item.itemId, clientUserMessageId);
|
|
45424
|
+
}
|
|
45425
|
+
await this.#projectHarnessOutput(thread, {
|
|
45426
|
+
kind: "event",
|
|
45427
|
+
event: { type: "item.started", turnId, item }
|
|
45428
|
+
});
|
|
45429
|
+
await this.#projectHarnessOutput(thread, {
|
|
45430
|
+
kind: "event",
|
|
45431
|
+
event: {
|
|
45432
|
+
type: "item.completed",
|
|
45433
|
+
turnId,
|
|
45434
|
+
snapshot: { item, outcome: { status: "succeeded" } }
|
|
45435
|
+
}
|
|
45436
|
+
});
|
|
45437
|
+
}
|
|
45280
45438
|
async #insertExternalInput(thread, input) {
|
|
45281
45439
|
await insertNativeSteer(thread, input, {
|
|
45282
|
-
project:
|
|
45283
|
-
|
|
45284
|
-
|
|
45285
|
-
|
|
45286
|
-
|
|
45287
|
-
|
|
45288
|
-
kind: "event",
|
|
45289
|
-
event: { type: "item.started", turnId, item }
|
|
45290
|
-
});
|
|
45291
|
-
await this.#projectHarnessOutput(thread, {
|
|
45292
|
-
kind: "event",
|
|
45293
|
-
event: {
|
|
45294
|
-
type: "item.completed",
|
|
45295
|
-
turnId,
|
|
45296
|
-
snapshot: { item, outcome: { status: "succeeded" } }
|
|
45297
|
-
}
|
|
45298
|
-
});
|
|
45299
|
-
},
|
|
45440
|
+
project: (turnId, item, clientUserMessageId) => this.#projectQueuedSteer(
|
|
45441
|
+
thread,
|
|
45442
|
+
turnId,
|
|
45443
|
+
item.input.map((part) => part.text).join("\n"),
|
|
45444
|
+
clientUserMessageId
|
|
45445
|
+
),
|
|
45300
45446
|
diagnose: (error51) => this.#diagnose(error51)
|
|
45301
45447
|
});
|
|
45302
45448
|
return {
|
|
@@ -45767,6 +45913,9 @@ var AppServerHost = class {
|
|
|
45767
45913
|
event,
|
|
45768
45914
|
event.type === "turn.completed" ? result.completedTurn : void 0
|
|
45769
45915
|
);
|
|
45916
|
+
if (event.type === "item.completed" && !ephemeralTurn && (event.snapshot.item.type === "commandExecution" || event.snapshot.item.type === "toolExecution" || event.snapshot.item.type === "agentMessage")) {
|
|
45917
|
+
await this.#injectQueuedFollowUp(thread, event.turnId);
|
|
45918
|
+
}
|
|
45770
45919
|
if (event.type === "turn.completed") {
|
|
45771
45920
|
await this.#setThreadStatus(
|
|
45772
45921
|
thread,
|
|
@@ -25064,6 +25064,28 @@ var GrokQuestions = class {
|
|
|
25064
25064
|
}
|
|
25065
25065
|
};
|
|
25066
25066
|
|
|
25067
|
+
// dist/grok-interject.js
|
|
25068
|
+
var GROK_INTERJECT_METHOD = "x.ai/interject";
|
|
25069
|
+
var GROK_INTERJECT_FALLBACK_METHOD = "_x.ai/interject";
|
|
25070
|
+
var GrokSteerMissedTurnError = class extends Error {
|
|
25071
|
+
constructor(message = "Grok steer missed the active Turn") {
|
|
25072
|
+
super(message);
|
|
25073
|
+
this.name = "GrokSteerMissedTurnError";
|
|
25074
|
+
}
|
|
25075
|
+
};
|
|
25076
|
+
function parseGrokInterjectResult(value) {
|
|
25077
|
+
if (value === void 0 || value === null)
|
|
25078
|
+
return { status: "queued" };
|
|
25079
|
+
if (typeof value !== "object" || Array.isArray(value))
|
|
25080
|
+
return null;
|
|
25081
|
+
const record2 = value;
|
|
25082
|
+
const nested = record2.status === void 0 && typeof record2.result === "object" && record2.result !== null ? record2.result : record2;
|
|
25083
|
+
const status2 = nested.status ?? nested.ok;
|
|
25084
|
+
if (status2 === void 0 || status2 === "queued" || status2 === true)
|
|
25085
|
+
return { status: "queued" };
|
|
25086
|
+
return null;
|
|
25087
|
+
}
|
|
25088
|
+
|
|
25067
25089
|
// dist/acp-transport.js
|
|
25068
25090
|
var GrokTransportError = class extends Error {
|
|
25069
25091
|
kind;
|
|
@@ -25729,6 +25751,49 @@ var GrokAcpTransport = class {
|
|
|
25729
25751
|
this.#activeCompact = null;
|
|
25730
25752
|
}
|
|
25731
25753
|
}
|
|
25754
|
+
async interject(text, interjectionId) {
|
|
25755
|
+
const connection = this.#connection;
|
|
25756
|
+
const sessionId = this.#sessionId;
|
|
25757
|
+
if (!connection || !sessionId || this.#closed || this.#closing) {
|
|
25758
|
+
throw new GrokTransportError("unavailable", "Grok ACP Session is unavailable");
|
|
25759
|
+
}
|
|
25760
|
+
if (!this.#activePrompt) {
|
|
25761
|
+
const deadline = Date.now() + 2e3;
|
|
25762
|
+
while (!this.#activePrompt && Date.now() < deadline)
|
|
25763
|
+
await delay3(25);
|
|
25764
|
+
}
|
|
25765
|
+
if (!this.#activePrompt)
|
|
25766
|
+
throw new GrokSteerMissedTurnError();
|
|
25767
|
+
const params = {
|
|
25768
|
+
sessionId,
|
|
25769
|
+
text,
|
|
25770
|
+
...interjectionId ? { interjectionId } : {}
|
|
25771
|
+
};
|
|
25772
|
+
let raw;
|
|
25773
|
+
try {
|
|
25774
|
+
raw = await connection.request(GROK_INTERJECT_METHOD, params);
|
|
25775
|
+
} catch (error53) {
|
|
25776
|
+
if (!isGrokMethodNotFound(error53)) {
|
|
25777
|
+
throw new GrokTransportError("unavailable", "Grok Native Interject failed", {
|
|
25778
|
+
cause: error53
|
|
25779
|
+
});
|
|
25780
|
+
}
|
|
25781
|
+
try {
|
|
25782
|
+
raw = await connection.request(GROK_INTERJECT_FALLBACK_METHOD, params);
|
|
25783
|
+
} catch (fallback) {
|
|
25784
|
+
if (isGrokMethodNotFound(fallback)) {
|
|
25785
|
+
throw new GrokTransportError("protocolError", `Grok ACP Method Not Found: ${GROK_INTERJECT_METHOD}`, { cause: fallback });
|
|
25786
|
+
}
|
|
25787
|
+
throw new GrokTransportError("unavailable", "Grok Native Interject failed", {
|
|
25788
|
+
cause: fallback
|
|
25789
|
+
});
|
|
25790
|
+
}
|
|
25791
|
+
}
|
|
25792
|
+
const parsed = parseGrokInterjectResult(raw);
|
|
25793
|
+
if (!parsed)
|
|
25794
|
+
throw new GrokSteerMissedTurnError();
|
|
25795
|
+
return parsed;
|
|
25796
|
+
}
|
|
25732
25797
|
async setModel(modelId, reasoningEffort, contextWindowTokens) {
|
|
25733
25798
|
const connection = this.#connection;
|
|
25734
25799
|
if (!connection || !this.#sessionId)
|
|
@@ -27066,6 +27131,7 @@ function terminalOutcome2(response, cancelled) {
|
|
|
27066
27131
|
var GrokHarnessSession = class {
|
|
27067
27132
|
harnessId = grokHarnessId;
|
|
27068
27133
|
capabilities;
|
|
27134
|
+
readCapabilities;
|
|
27069
27135
|
commands;
|
|
27070
27136
|
goals;
|
|
27071
27137
|
#backgroundQueue = Promise.resolve();
|
|
@@ -27110,11 +27176,22 @@ var GrokHarnessSession = class {
|
|
|
27110
27176
|
this.initialUsage = options.initialUsage ?? null;
|
|
27111
27177
|
this.#usage = this.initialUsage;
|
|
27112
27178
|
this.#initialCostUsd = this.initialUsage?.totalCostUsd ?? 0;
|
|
27113
|
-
this.capabilities =
|
|
27179
|
+
this.capabilities = ((session) => ({
|
|
27180
|
+
...capabilitiesForModels(modelState),
|
|
27181
|
+
...transport.goalControl && transport.observeBackground ? { autonomousTurns: { observe: true } } : {},
|
|
27182
|
+
get steer() {
|
|
27183
|
+
return session.#canSteerActiveTurn();
|
|
27184
|
+
}
|
|
27185
|
+
}))(this);
|
|
27114
27186
|
this.commands = {
|
|
27115
27187
|
list: async () => ({ ok: true, value: this.#liveCommandCatalog() }),
|
|
27116
27188
|
execute: (command) => this.#executeHarnessCommand(command)
|
|
27117
27189
|
};
|
|
27190
|
+
this.readCapabilities = async () => ({
|
|
27191
|
+
...this.capabilities,
|
|
27192
|
+
...capabilitiesForModels(this.#modelState),
|
|
27193
|
+
steer: this.#canSteerActiveTurn()
|
|
27194
|
+
});
|
|
27118
27195
|
this.#state = stateForGrokModel(modelState, { nativeRef: nativeRef(opened.sessionId) }, modelState.currentModel, modelState.currentThinkingOptionId, options.initialPermissionModeId);
|
|
27119
27196
|
this.initialState = this.#state;
|
|
27120
27197
|
this.#snapshot = {
|
|
@@ -27164,7 +27241,6 @@ var GrokHarnessSession = class {
|
|
|
27164
27241
|
return goalControl(prompt);
|
|
27165
27242
|
}, (goal) => this.#event({ type: "goal.changed", goal }), 3e4, () => transport.getHistory());
|
|
27166
27243
|
this.goals = goals;
|
|
27167
|
-
this.capabilities = { ...this.capabilities, autonomousTurns: { observe: true } };
|
|
27168
27244
|
transport.observeBackground({
|
|
27169
27245
|
onEvent: (event) => {
|
|
27170
27246
|
if (event.type === "goal.changed") {
|
|
@@ -27237,7 +27313,7 @@ var GrokHarnessSession = class {
|
|
|
27237
27313
|
if ("commandId" in command)
|
|
27238
27314
|
return this.#executeHarnessCommand(command);
|
|
27239
27315
|
if (command.type === "turn.steer")
|
|
27240
|
-
return
|
|
27316
|
+
return this.#steer(command);
|
|
27241
27317
|
if (command.type === "turn.cancel")
|
|
27242
27318
|
return this.#cancel(command);
|
|
27243
27319
|
if (command.type === "interaction.respond")
|
|
@@ -27295,6 +27371,44 @@ var GrokHarnessSession = class {
|
|
|
27295
27371
|
}));
|
|
27296
27372
|
return { ok: true, value: { turnId: command.turnId } };
|
|
27297
27373
|
}
|
|
27374
|
+
#canSteerActiveTurn() {
|
|
27375
|
+
const active = this.#active;
|
|
27376
|
+
return this.#phase === "open" && active != null && !active.cancellationRequested && !active.catalogCommand && !active.command.turnId.startsWith("grok-autonomous-") && typeof this.#transport.interject === "function";
|
|
27377
|
+
}
|
|
27378
|
+
async #steer(command) {
|
|
27379
|
+
const active = this.#active;
|
|
27380
|
+
if (!this.#canSteerActiveTurn() || !active || active.command.turnId !== command.turnId) {
|
|
27381
|
+
if (typeof this.#transport.interject !== "function")
|
|
27382
|
+
return unsupportedSteer("Grok");
|
|
27383
|
+
return { ok: false, error: invalidState("Grok steer target is not the active Turn") };
|
|
27384
|
+
}
|
|
27385
|
+
const text = command.input.map((input) => input.text).join("\n");
|
|
27386
|
+
if (text.length === 0) {
|
|
27387
|
+
return {
|
|
27388
|
+
ok: false,
|
|
27389
|
+
error: {
|
|
27390
|
+
code: "invalidRequest",
|
|
27391
|
+
message: "Grok steer text must not be empty",
|
|
27392
|
+
retryable: false
|
|
27393
|
+
}
|
|
27394
|
+
};
|
|
27395
|
+
}
|
|
27396
|
+
const interject = this.#transport.interject;
|
|
27397
|
+
if (!interject)
|
|
27398
|
+
return unsupportedSteer("Grok");
|
|
27399
|
+
try {
|
|
27400
|
+
await interject.call(this.#transport, text, this.#randomUUID());
|
|
27401
|
+
} catch (error53) {
|
|
27402
|
+
if (error53 instanceof GrokSteerMissedTurnError) {
|
|
27403
|
+
return { ok: false, error: invalidState("Grok steer missed the active Turn") };
|
|
27404
|
+
}
|
|
27405
|
+
if (error53 instanceof GrokTransportError && error53.kind === "protocolError" && /method not found/iu.test(error53.message)) {
|
|
27406
|
+
return unsupportedSteer("Grok");
|
|
27407
|
+
}
|
|
27408
|
+
return { ok: false, error: normalizeError(error53, "nativeFailure") };
|
|
27409
|
+
}
|
|
27410
|
+
return { ok: true, value: { accepted: true } };
|
|
27411
|
+
}
|
|
27298
27412
|
#newActive(command, catalogCommand = false) {
|
|
27299
27413
|
let resolveCompletion = () => void 0;
|
|
27300
27414
|
const completion = new Promise((resolve) => {
|
|
@@ -16515,9 +16515,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16515
16515
|
const matchesMetadata = (profile) => (version2 === void 0 || profile.version === version2) && (platform === void 0 || profile.platform === platform);
|
|
16516
16516
|
if (present.length > 0) {
|
|
16517
16517
|
const profile = present.length === 1 ? present[0] : void 0;
|
|
16518
|
-
|
|
16519
|
-
|
|
16520
|
-
|
|
16518
|
+
if (!profile || !matchesMetadata(profile)) return void 0;
|
|
16519
|
+
const initialPresent = auditedAppInitialAssetPresent(names, profile.initial);
|
|
16520
|
+
const sharedPresent = auditedAppInitialAssetPresent(names, profile.shared);
|
|
16521
|
+
return sharedPresent && (initialPresent || version2 !== void 0 && platform !== void 0) ? profile : void 0;
|
|
16521
16522
|
}
|
|
16522
16523
|
if (version2 === void 0) return void 0;
|
|
16523
16524
|
const candidates = profiles.filter(matchesMetadata);
|
|
@@ -18139,10 +18140,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18139
18140
|
}
|
|
18140
18141
|
|
|
18141
18142
|
// src/renderer-client-owned-voice.ts
|
|
18142
|
-
var CLIENT_OWNED_VOICE_VERSION = "26.
|
|
18143
|
-
var CLIENT_OWNED_VOICE_INITIAL_ASSET = "app-initial-
|
|
18144
|
-
var CLIENT_OWNED_VOICE_SHARED_ASSET = "app-shared-
|
|
18145
|
-
var CLIENT_OWNED_VOICE_OVERLAY_ASSET = "avatar-overlay-native-page-
|
|
18143
|
+
var CLIENT_OWNED_VOICE_VERSION = "26.1027.30824";
|
|
18144
|
+
var CLIENT_OWNED_VOICE_INITIAL_ASSET = "app-initial-60f141238751.js";
|
|
18145
|
+
var CLIENT_OWNED_VOICE_SHARED_ASSET = "app-shared-7815d5a1a42a.js";
|
|
18146
|
+
var CLIENT_OWNED_VOICE_OVERLAY_ASSET = "avatar-overlay-native-page-d9d400e751cd.js";
|
|
18146
18147
|
var CLIENT_OWNED_VOICE_ASSETS = [
|
|
18147
18148
|
{
|
|
18148
18149
|
platform: "darwin",
|
|
@@ -18150,6 +18151,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18150
18151
|
initial: CLIENT_OWNED_VOICE_INITIAL_ASSET,
|
|
18151
18152
|
shared: CLIENT_OWNED_VOICE_SHARED_ASSET,
|
|
18152
18153
|
overlay: CLIENT_OWNED_VOICE_OVERLAY_ASSET,
|
|
18154
|
+
init: "Edr",
|
|
18155
|
+
fetch: "wdr",
|
|
18156
|
+
fetchFrom: "initial",
|
|
18157
|
+
bridge: "LRt",
|
|
18158
|
+
services: "Vct",
|
|
18159
|
+
responseError: "Adr",
|
|
18160
|
+
responseErrorFrom: "initial",
|
|
18161
|
+
capabilityInit: "Ner",
|
|
18162
|
+
capabilityFamily: "Mer",
|
|
18163
|
+
inferenceGateFamily: "Lfr"
|
|
18164
|
+
},
|
|
18165
|
+
{
|
|
18166
|
+
platform: "darwin",
|
|
18167
|
+
version: "26.1023.51421",
|
|
18168
|
+
initial: "app-initial-bc8256c3cccb.js",
|
|
18169
|
+
shared: "app-shared-e9f258fd3588.js",
|
|
18170
|
+
overlay: "avatar-overlay-native-page-af6c3662f64f.js",
|
|
18153
18171
|
init: "xir",
|
|
18154
18172
|
fetch: "yir",
|
|
18155
18173
|
fetchFrom: "initial",
|
|
@@ -18471,7 +18489,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18471
18489
|
if (!object2(bridgeClass) && typeof bridgeClass !== "function") throw new Error();
|
|
18472
18490
|
const client = Reflect.get(fetchClass, "getInstance").call(fetchClass);
|
|
18473
18491
|
const bridge = Reflect.get(bridgeClass, "getInstance").call(bridgeClass);
|
|
18474
|
-
const
|
|
18492
|
+
const errorModule = "responseErrorFrom" in assets && assets.responseErrorFrom === "initial" ? fetchModule : sharedModule;
|
|
18493
|
+
const responseError = typeof errorName === "string" && typeof errorModule[errorName] === "function" ? errorModule[errorName] : async (response) => {
|
|
18475
18494
|
throw Object.assign(new Error(await response.text()), { status: response.status });
|
|
18476
18495
|
};
|
|
18477
18496
|
if (typeof client?.fetch !== "function" || typeof bridge?.dispatchMessage !== "function" || typeof bridge?.subscribe !== "function")
|
|
@@ -27716,6 +27735,17 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
27716
27735
|
function isRecord9(value) {
|
|
27717
27736
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
27718
27737
|
}
|
|
27738
|
+
function conversationIdFrom(request) {
|
|
27739
|
+
if (typeof request === "string" && request) return request;
|
|
27740
|
+
if (!isRecord9(request)) return null;
|
|
27741
|
+
if (typeof request.conversationId === "string" && request.conversationId)
|
|
27742
|
+
return request.conversationId;
|
|
27743
|
+
if (typeof request.threadId === "string" && request.threadId) return request.threadId;
|
|
27744
|
+
return null;
|
|
27745
|
+
}
|
|
27746
|
+
function isHostExternalConversation(conversation, threadId) {
|
|
27747
|
+
return isRecord9(conversation) && conversation.id === threadId && conversation.modelProvider === "codexhost";
|
|
27748
|
+
}
|
|
27719
27749
|
function isManager(value) {
|
|
27720
27750
|
return isRecord9(value) && ["sendRequest", "steerTurn", "startTurn", "getTurnCoordinator"].every(
|
|
27721
27751
|
(key) => typeof value[key] === "function"
|
|
@@ -27751,6 +27781,27 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
27751
27781
|
if (!text) return params;
|
|
27752
27782
|
return { ...params, input: [{ type: "text", text, text_elements: [] }] };
|
|
27753
27783
|
}
|
|
27784
|
+
function installExternalQueueUi(manager) {
|
|
27785
|
+
const coordinator = manager.getTurnCoordinator();
|
|
27786
|
+
const options = isRecord9(coordinator) ? coordinator.options : null;
|
|
27787
|
+
if (!isRecord9(options) || typeof options.getMessageQueueMode !== "function") return null;
|
|
27788
|
+
const descriptor = Object.getOwnPropertyDescriptor(options, "getMessageQueueMode");
|
|
27789
|
+
if (!descriptor?.writable) return null;
|
|
27790
|
+
const original = options.getMessageQueueMode;
|
|
27791
|
+
const getMessageQueueMode = (...args) => {
|
|
27792
|
+
const threadId = conversationIdFrom(args[0]);
|
|
27793
|
+
if (threadId && typeof manager.getConversation === "function" && isHostExternalConversation(manager.getConversation(threadId), threadId)) {
|
|
27794
|
+
return Promise.resolve("queue");
|
|
27795
|
+
}
|
|
27796
|
+
return original.apply(options, args);
|
|
27797
|
+
};
|
|
27798
|
+
options.getMessageQueueMode = getMessageQueueMode;
|
|
27799
|
+
return () => {
|
|
27800
|
+
if (options.getMessageQueueMode === getMessageQueueMode) {
|
|
27801
|
+
Object.defineProperty(options, "getMessageQueueMode", descriptor);
|
|
27802
|
+
}
|
|
27803
|
+
};
|
|
27804
|
+
}
|
|
27754
27805
|
function submissionHost(manager) {
|
|
27755
27806
|
const coordinator = manager.getTurnCoordinator();
|
|
27756
27807
|
const options = isRecord9(coordinator) ? coordinator.options : null;
|
|
@@ -27824,6 +27875,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
27824
27875
|
function installRendererExternalSteering(target, sendTurnStart, prepareTurnInput) {
|
|
27825
27876
|
if (!isManager(target)) return null;
|
|
27826
27877
|
const manager = target;
|
|
27878
|
+
const restoreQueueUi = installExternalQueueUi(manager);
|
|
27827
27879
|
const originalSteer = manager.steerTurn;
|
|
27828
27880
|
const originalSend = manager.sendRequest;
|
|
27829
27881
|
const routes = /* @__PURE__ */ new Map();
|
|
@@ -27834,7 +27886,9 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
27834
27886
|
if ((method === "turn/start" || method === "turn/steer") && prepareTurnInput) {
|
|
27835
27887
|
params = prepareTurnInput(params);
|
|
27836
27888
|
}
|
|
27837
|
-
if (method === "turn/start"
|
|
27889
|
+
if (method === "turn/start" || method === "turn/steer") {
|
|
27890
|
+
params = restoreQueuedTurnStartText(manager, params);
|
|
27891
|
+
}
|
|
27838
27892
|
const messageId = isRecord9(params) ? params.clientUserMessageId : null;
|
|
27839
27893
|
const route = typeof messageId === "string" && isRecord9(params) ? routes.get(`${params.threadId}\0${messageId}`) : void 0;
|
|
27840
27894
|
if (method !== "turn/start" || !isRecord9(params) || !route || route.threadId !== params.threadId) {
|
|
@@ -28041,6 +28095,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
28041
28095
|
});
|
|
28042
28096
|
return () => {
|
|
28043
28097
|
disposed = true;
|
|
28098
|
+
restoreQueueUi?.();
|
|
28044
28099
|
restoreMethod("steerTurn");
|
|
28045
28100
|
if (getStreamRole) restoreMethod("getStreamRole");
|
|
28046
28101
|
if (pending.size === 0) {
|
package/bin/codexhost.exe
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|