@karlorz/codexhost-cli-win32-x64 0.18.0-0 → 0.18.0-1
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 +258 -57
- package/app/console-web.js +1813 -137
- package/app/cpa-live-voice-hook.js +1879 -426
- package/app/desktop-controller.mjs +1783 -192
- package/app/host-runtime.mjs +2595 -1088
- package/app/overlay-voice-bootstrap.js +1616 -0
- package/app/plugins/antigravity/plugin.mjs +257 -56
- package/app/plugins/claude-code/plugin.mjs +257 -56
- package/app/plugins/codebuddy/plugin.mjs +257 -56
- package/app/plugins/codex-usage/plugin.mjs +257 -56
- package/app/plugins/copilot/plugin.mjs +257 -56
- package/app/plugins/cursor-cli/plugin.mjs +257 -56
- package/app/plugins/deepseek-harness/plugin.mjs +257 -56
- package/app/plugins/devin/plugin.mjs +257 -56
- package/app/plugins/grok/plugin.mjs +257 -56
- package/app/plugins/hermes/plugin.mjs +257 -56
- package/app/plugins/kimi-code/plugin.mjs +257 -56
- package/app/plugins/kiro-cli/plugin.mjs +257 -56
- package/app/plugins/omp/plugin.mjs +257 -56
- package/app/plugins/opencode/plugin.mjs +257 -56
- package/app/plugins/pi/plugin.mjs +257 -56
- package/app/plugins/qoder/plugin.mjs +257 -56
- package/app/plugins/qoder-cn/plugin.mjs +257 -56
- package/app/plugins/qwen-code/plugin.mjs +257 -56
- package/app/plugins/workbuddy/plugin.mjs +257 -56
- package/app/plugins/zcode/plugin.mjs +257 -56
- package/app/renderer-extension.js +22195 -19283
- package/app/voice-profile-pins.json +25 -0
- package/app/voice-qualification.json +4 -0
- package/app/web/assets/index-py6Ho-Dy.js +199 -0
- package/app/web/codexhost-settings.js +1762 -129
- package/app/web/index.html +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +63 -63
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +79 -79
- package/app/web-modules/server.mjs +956 -180
- 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/web/assets/index-Bs17Kuah.js +0 -199
|
@@ -2510,7 +2510,7 @@ var require_extension = __commonJS({
|
|
|
2510
2510
|
var require_websocket = __commonJS({
|
|
2511
2511
|
"packages/web-server/node_modules/ws/lib/websocket.js"(exports, module) {
|
|
2512
2512
|
"use strict";
|
|
2513
|
-
var EventEmitter2 = __require("events"), https = __require("https"), http = __require("http"), net = __require("net"), tls = __require("tls"), { randomBytes: randomBytes5, createHash:
|
|
2513
|
+
var EventEmitter2 = __require("events"), https = __require("https"), http = __require("http"), net = __require("net"), tls = __require("tls"), { randomBytes: randomBytes5, createHash: createHash12 } = __require("crypto"), { Duplex, Readable: Readable3 } = __require("stream"), { URL: URL2 } = __require("url"), PerMessageDeflate3 = require_permessage_deflate(), Receiver3 = require_receiver(), Sender3 = require_sender(), { isBlob } = require_validation(), {
|
|
2514
2514
|
BINARY_TYPES,
|
|
2515
2515
|
CLOSE_TIMEOUT,
|
|
2516
2516
|
EMPTY_BUFFER,
|
|
@@ -2972,7 +2972,7 @@ var require_websocket = __commonJS({
|
|
|
2972
2972
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
2973
2973
|
return;
|
|
2974
2974
|
}
|
|
2975
|
-
let digest2 =
|
|
2975
|
+
let digest2 = createHash12("sha1").update(key + GUID).digest("base64");
|
|
2976
2976
|
if (res.headers["sec-websocket-accept"] !== digest2) {
|
|
2977
2977
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
2978
2978
|
return;
|
|
@@ -3210,7 +3210,7 @@ var require_subprotocol = __commonJS({
|
|
|
3210
3210
|
var require_websocket_server = __commonJS({
|
|
3211
3211
|
"packages/web-server/node_modules/ws/lib/websocket-server.js"(exports, module) {
|
|
3212
3212
|
"use strict";
|
|
3213
|
-
var EventEmitter2 = __require("events"), http = __require("http"), { Duplex } = __require("stream"), { createHash:
|
|
3213
|
+
var EventEmitter2 = __require("events"), http = __require("http"), { Duplex } = __require("stream"), { createHash: createHash12 } = __require("crypto"), extension3 = require_extension(), PerMessageDeflate3 = require_permessage_deflate(), subprotocol3 = require_subprotocol(), WebSocket4 = require_websocket(), { CLOSE_TIMEOUT, GUID, kWebSocket } = require_constants(), keyRegex = /^[+/0-9A-Za-z]{22}==$/, RUNNING = 0, CLOSING = 1, CLOSED = 2, WebSocketServer3 = class extends EventEmitter2 {
|
|
3214
3214
|
/**
|
|
3215
3215
|
* Create a `WebSocketServer` instance.
|
|
3216
3216
|
*
|
|
@@ -3457,7 +3457,7 @@ var require_websocket_server = __commonJS({
|
|
|
3457
3457
|
"HTTP/1.1 101 Switching Protocols",
|
|
3458
3458
|
"Upgrade: websocket",
|
|
3459
3459
|
"Connection: Upgrade",
|
|
3460
|
-
`Sec-WebSocket-Accept: ${
|
|
3460
|
+
`Sec-WebSocket-Accept: ${createHash12("sha1").update(key + GUID).digest("base64")}`
|
|
3461
3461
|
], ws = new this.options.WebSocket(null, void 0, this.options);
|
|
3462
3462
|
if (protocols.size) {
|
|
3463
3463
|
let protocol = this.options.handleProtocols ? this.options.handleProtocols(protocols, req) : protocols.values().next().value;
|
|
@@ -5165,7 +5165,7 @@ var require_extension2 = __commonJS({
|
|
|
5165
5165
|
var require_websocket2 = __commonJS({
|
|
5166
5166
|
"node_modules/ws/lib/websocket.js"(exports, module) {
|
|
5167
5167
|
"use strict";
|
|
5168
|
-
var EventEmitter2 = __require("events"), https = __require("https"), http = __require("http"), net = __require("net"), tls = __require("tls"), { randomBytes: randomBytes5, createHash:
|
|
5168
|
+
var EventEmitter2 = __require("events"), https = __require("https"), http = __require("http"), net = __require("net"), tls = __require("tls"), { randomBytes: randomBytes5, createHash: createHash12 } = __require("crypto"), { Duplex, Readable: Readable3 } = __require("stream"), { URL: URL2 } = __require("url"), PerMessageDeflate3 = require_permessage_deflate2(), Receiver3 = require_receiver2(), Sender3 = require_sender2(), { isBlob } = require_validation2(), {
|
|
5169
5169
|
BINARY_TYPES,
|
|
5170
5170
|
CLOSE_TIMEOUT,
|
|
5171
5171
|
EMPTY_BUFFER,
|
|
@@ -5627,7 +5627,7 @@ var require_websocket2 = __commonJS({
|
|
|
5627
5627
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
5628
5628
|
return;
|
|
5629
5629
|
}
|
|
5630
|
-
let digest2 =
|
|
5630
|
+
let digest2 = createHash12("sha1").update(key + GUID).digest("base64");
|
|
5631
5631
|
if (res.headers["sec-websocket-accept"] !== digest2) {
|
|
5632
5632
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
5633
5633
|
return;
|
|
@@ -5865,7 +5865,7 @@ var require_subprotocol2 = __commonJS({
|
|
|
5865
5865
|
var require_websocket_server2 = __commonJS({
|
|
5866
5866
|
"node_modules/ws/lib/websocket-server.js"(exports, module) {
|
|
5867
5867
|
"use strict";
|
|
5868
|
-
var EventEmitter2 = __require("events"), http = __require("http"), { Duplex } = __require("stream"), { createHash:
|
|
5868
|
+
var EventEmitter2 = __require("events"), http = __require("http"), { Duplex } = __require("stream"), { createHash: createHash12 } = __require("crypto"), extension3 = require_extension2(), PerMessageDeflate3 = require_permessage_deflate2(), subprotocol3 = require_subprotocol2(), WebSocket4 = require_websocket2(), { CLOSE_TIMEOUT, GUID, kWebSocket } = require_constants2(), keyRegex = /^[+/0-9A-Za-z]{22}==$/, RUNNING = 0, CLOSING = 1, CLOSED = 2, WebSocketServer3 = class extends EventEmitter2 {
|
|
5869
5869
|
/**
|
|
5870
5870
|
* Create a `WebSocketServer` instance.
|
|
5871
5871
|
*
|
|
@@ -6112,7 +6112,7 @@ var require_websocket_server2 = __commonJS({
|
|
|
6112
6112
|
"HTTP/1.1 101 Switching Protocols",
|
|
6113
6113
|
"Upgrade: websocket",
|
|
6114
6114
|
"Connection: Upgrade",
|
|
6115
|
-
`Sec-WebSocket-Accept: ${
|
|
6115
|
+
`Sec-WebSocket-Accept: ${createHash12("sha1").update(key + GUID).digest("base64")}`
|
|
6116
6116
|
], ws = new this.options.WebSocket(null, void 0, this.options);
|
|
6117
6117
|
if (protocols.size) {
|
|
6118
6118
|
let protocol = this.options.handleProtocols ? this.options.handleProtocols(protocols, req) : protocols.values().next().value;
|
|
@@ -38146,7 +38146,7 @@ var require_auto = __commonJS({
|
|
|
38146
38146
|
// node_modules/acme-client/src/client.js
|
|
38147
38147
|
var require_client = __commonJS({
|
|
38148
38148
|
"node_modules/acme-client/src/client.js"(exports, module) {
|
|
38149
|
-
var { createHash:
|
|
38149
|
+
var { createHash: createHash12 } = __require("crypto"), { getPemBodyAsB64u } = require_crypto(), { log } = require_logger(), HttpClient = require_http(), AcmeApi = require_api(), verify = require_verify(), util2 = require_util(), auto = require_auto(), validStates = ["ready", "valid"], pendingStates = ["pending", "processing"], invalidStates = ["invalid"], defaultOpts = {
|
|
38150
38150
|
directoryUrl: void 0,
|
|
38151
38151
|
accountKey: void 0,
|
|
38152
38152
|
accountUrl: null,
|
|
@@ -38402,11 +38402,11 @@ var require_client = __commonJS({
|
|
|
38402
38402
|
* ```
|
|
38403
38403
|
*/
|
|
38404
38404
|
async getChallengeKeyAuthorization(challenge) {
|
|
38405
|
-
let jwk = this.http.getJwk(), thumbprint =
|
|
38405
|
+
let jwk = this.http.getJwk(), thumbprint = createHash12("sha256").update(JSON.stringify(jwk)).digest("base64url"), result = `${challenge.token}.${thumbprint}`;
|
|
38406
38406
|
if (challenge.type === "http-01")
|
|
38407
38407
|
return result;
|
|
38408
38408
|
if (challenge.type === "dns-01")
|
|
38409
|
-
return
|
|
38409
|
+
return createHash12("sha256").update(result).digest("base64url");
|
|
38410
38410
|
if (challenge.type === "tls-alpn-01")
|
|
38411
38411
|
return result;
|
|
38412
38412
|
throw new Error(`Unable to produce key authorization, unknown challenge type: ${challenge.type}`);
|
|
@@ -67829,15 +67829,24 @@ var harnessGoalStatusSchema = external_exports.enum([
|
|
|
67829
67829
|
origin: goalOriginSchema
|
|
67830
67830
|
});
|
|
67831
67831
|
|
|
67832
|
-
// packages/shared-contracts/dist/realtime-call.js
|
|
67833
|
-
var REALTIME_CALL_FORWARDED_HEADERS = [
|
|
67832
|
+
// packages/shared-contracts/dist/realtime-call-core.js
|
|
67833
|
+
var REALTIME_CALL_METHOD = "codexhost/realtime/call", REALTIME_CALL_FORWARDED_HEADERS = [
|
|
67834
67834
|
"openai-alpha",
|
|
67835
67835
|
"thread-id",
|
|
67836
67836
|
"session-id",
|
|
67837
67837
|
"originator",
|
|
67838
67838
|
"x-codex-turn-metadata"
|
|
67839
67839
|
], FORWARDED_HEADERS = new Set(REALTIME_CALL_FORWARDED_HEADERS);
|
|
67840
|
-
var REALTIME_CALL_ID_PATTERN = /^
|
|
67840
|
+
var REALTIME_CALL_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/u;
|
|
67841
|
+
function isRealtimeCallId(value) {
|
|
67842
|
+
return typeof value == "string" && REALTIME_CALL_ID_PATTERN.test(value);
|
|
67843
|
+
}
|
|
67844
|
+
function realtimeCallIdFromLocation(location) {
|
|
67845
|
+
let path8 = location.split(/[?#]/u)[0] ?? "";
|
|
67846
|
+
return /^[A-Za-z0-9_-]{1,128}$/u.test(path8) ? path8 : /\/(?:calls|live)\/([A-Za-z0-9_-]{1,128})$/u.exec(path8)?.[1];
|
|
67847
|
+
}
|
|
67848
|
+
|
|
67849
|
+
// packages/shared-contracts/dist/realtime-call.js
|
|
67841
67850
|
var requestId = external_exports.string().min(1).max(128), realtimeCallParamsSchema = external_exports.discriminatedUnion("operation", [
|
|
67842
67851
|
external_exports.object({
|
|
67843
67852
|
operation: external_exports.literal("create"),
|
|
@@ -67882,12 +67891,7 @@ var enrollmentAllowlistEntrySchema = external_exports.strictObject({
|
|
|
67882
67891
|
// packages/shared-contracts/dist/enrolled-mcp-relay.js
|
|
67883
67892
|
var RELAY_LINK_PROTOCOL_VERSION = 1;
|
|
67884
67893
|
var RELAY_PUBLIC_ORIGIN = "https://codexhost.karldigi.dev", RELAY_PUBLIC_RESOURCE = `${RELAY_PUBLIC_ORIGIN}/mcp`, RELAY_WAIT_TIMEOUT_MAX_MS = 25e3;
|
|
67885
|
-
var RELAY_MAX_BODY_BYTES = 2 * 1024 * 1024
|
|
67886
|
-
"/v1/enroll/status",
|
|
67887
|
-
"/v1/thread/read",
|
|
67888
|
-
"/v1/thread/wait",
|
|
67889
|
-
"/v1/thread/send"
|
|
67890
|
-
];
|
|
67894
|
+
var RELAY_MAX_BODY_BYTES = 2 * 1024 * 1024;
|
|
67891
67895
|
var relayLinkHelloSchema = external_exports.strictObject({
|
|
67892
67896
|
v: external_exports.literal(RELAY_LINK_PROTOCOL_VERSION),
|
|
67893
67897
|
secret: external_exports.string().min(1).max(4096)
|
|
@@ -67897,8 +67901,11 @@ var relayLinkHelloSchema = external_exports.strictObject({
|
|
|
67897
67901
|
}), relayLinkRequestSchema = external_exports.strictObject({
|
|
67898
67902
|
requestId: external_exports.string().min(1).max(128),
|
|
67899
67903
|
deadlineMs: external_exports.number().int().positive(),
|
|
67900
|
-
route: external_exports.
|
|
67901
|
-
body: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
67904
|
+
route: external_exports.string().min(1).max(128),
|
|
67905
|
+
body: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
67906
|
+
operationalClient: external_exports.string().min(1).max(64).optional(),
|
|
67907
|
+
oauthClientId: external_exports.string().min(1).max(128).optional(),
|
|
67908
|
+
dispatchGrant: external_exports.enum(["legacy-four", "full-dispatch"]).optional()
|
|
67902
67909
|
}), relayLinkErrorSchema = external_exports.strictObject({
|
|
67903
67910
|
code: external_exports.string().min(1).max(64),
|
|
67904
67911
|
message: external_exports.string().max(2048),
|
|
@@ -67935,6 +67942,187 @@ var relayLinkHelloSchema = external_exports.strictObject({
|
|
|
67935
67942
|
runtime: external_exports.enum(["reachable", "unreachable"])
|
|
67936
67943
|
});
|
|
67937
67944
|
|
|
67945
|
+
// packages/shared-contracts/dist/external-clients.js
|
|
67946
|
+
var EXTERNAL_CLIENT_NAME_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/u, externalClientNameSchema = external_exports.string().trim().min(1).max(64).regex(EXTERNAL_CLIENT_NAME_PATTERN), externalClientAccessSchema = external_exports.enum(["all-threads", "selected-workspaces"]), externalClientConnectionModeSchema = external_exports.enum(["public-relay", "local", "direct"]), externalClientDispatchGrantSchema = external_exports.enum(["legacy-four", "full-dispatch"]);
|
|
67947
|
+
var workspacePathSchema = external_exports.string().trim().min(1).max(4096), directUrlSchema = external_exports.string().trim().max(2048);
|
|
67948
|
+
var externalClientPublicViewSchema = external_exports.strictObject({
|
|
67949
|
+
name: externalClientNameSchema,
|
|
67950
|
+
createdAt: external_exports.string().min(1).max(64),
|
|
67951
|
+
access: externalClientAccessSchema,
|
|
67952
|
+
workspaces: external_exports.array(workspacePathSchema).max(64),
|
|
67953
|
+
connectionMode: externalClientConnectionModeSchema,
|
|
67954
|
+
dispatchGrant: externalClientDispatchGrantSchema,
|
|
67955
|
+
oauthClientId: external_exports.string().trim().min(1).max(128).optional(),
|
|
67956
|
+
directUrl: directUrlSchema.optional(),
|
|
67957
|
+
mcpUrl: external_exports.string().min(1).max(2048).optional(),
|
|
67958
|
+
mcpUrlNote: external_exports.string().min(1).max(512).optional()
|
|
67959
|
+
}), externalClientListParamsSchema = external_exports.strictObject({}), externalClientListResultSchema = external_exports.strictObject({
|
|
67960
|
+
clients: external_exports.array(externalClientPublicViewSchema).max(256)
|
|
67961
|
+
}), externalClientWriteFieldsSchema = external_exports.strictObject({
|
|
67962
|
+
access: externalClientAccessSchema.optional(),
|
|
67963
|
+
workspaces: external_exports.array(workspacePathSchema).max(64).optional(),
|
|
67964
|
+
connectionMode: externalClientConnectionModeSchema.optional(),
|
|
67965
|
+
dispatchGrant: externalClientDispatchGrantSchema.optional(),
|
|
67966
|
+
oauthClientId: external_exports.string().trim().min(1).max(128).optional(),
|
|
67967
|
+
directUrl: directUrlSchema.optional()
|
|
67968
|
+
}), externalClientCreateParamsSchema = externalClientWriteFieldsSchema.extend({
|
|
67969
|
+
name: externalClientNameSchema
|
|
67970
|
+
}), externalClientCreateResultSchema = externalClientPublicViewSchema.extend({
|
|
67971
|
+
token: external_exports.string().min(1).max(256).optional()
|
|
67972
|
+
}), externalClientUpdateParamsSchema = externalClientWriteFieldsSchema.extend({
|
|
67973
|
+
name: externalClientNameSchema,
|
|
67974
|
+
clearOauthClientId: external_exports.literal(!0).optional()
|
|
67975
|
+
}), externalClientRevokeParamsSchema = external_exports.strictObject({
|
|
67976
|
+
name: externalClientNameSchema
|
|
67977
|
+
}), externalClientRevokeResultSchema = external_exports.strictObject({
|
|
67978
|
+
name: externalClientNameSchema,
|
|
67979
|
+
revoked: external_exports.literal(!0)
|
|
67980
|
+
}), stringProp = (description) => ({ type: "string", description }), integerProp = (description) => ({
|
|
67981
|
+
type: "integer",
|
|
67982
|
+
minimum: 0,
|
|
67983
|
+
description
|
|
67984
|
+
}), threadProp = stringProp("Thread id or codex://threads/<id> link"), EXTERNAL_MCP_TOOL_DESCRIPTORS = [
|
|
67985
|
+
{
|
|
67986
|
+
name: "harness_list",
|
|
67987
|
+
description: "List the Harnesses this codexhost can delegate to.",
|
|
67988
|
+
inputSchema: { type: "object", properties: {} }
|
|
67989
|
+
},
|
|
67990
|
+
{
|
|
67991
|
+
name: "harness_inspect",
|
|
67992
|
+
description: "Read a Harness's Models, Thinking options and defaults; use the returned ids when delegating.",
|
|
67993
|
+
inputSchema: {
|
|
67994
|
+
type: "object",
|
|
67995
|
+
properties: {
|
|
67996
|
+
harnessId: stringProp("Harness id from harness_list"),
|
|
67997
|
+
cwd: stringProp("Absolute workspace path"),
|
|
67998
|
+
refresh: { type: "boolean" }
|
|
67999
|
+
},
|
|
68000
|
+
required: ["harnessId"]
|
|
68001
|
+
}
|
|
68002
|
+
},
|
|
68003
|
+
{
|
|
68004
|
+
name: "delegate_start",
|
|
68005
|
+
description: "Start a task in a new Thread and return at once. Without parentThread the work belongs to this client and cwd is required. watch=true records an event for this client when the Thread stops (read it with events_poll or the SSE stream).",
|
|
68006
|
+
inputSchema: {
|
|
68007
|
+
type: "object",
|
|
68008
|
+
properties: {
|
|
68009
|
+
harnessId: stringProp("Harness id from harness_list"),
|
|
68010
|
+
task: stringProp("The full task text"),
|
|
68011
|
+
taskName: stringProp("Short display name"),
|
|
68012
|
+
cwd: stringProp("Absolute workspace path"),
|
|
68013
|
+
model: stringProp("Model id from harness_inspect"),
|
|
68014
|
+
thinking: stringProp("Thinking option id from harness_inspect"),
|
|
68015
|
+
parentThread: stringProp("Optional parent Thread"),
|
|
68016
|
+
requestId: stringProp("Reuse to retry idempotently"),
|
|
68017
|
+
refs: {
|
|
68018
|
+
type: "array",
|
|
68019
|
+
items: { type: "string" },
|
|
68020
|
+
description: "Absolute URIs of where the work came from"
|
|
68021
|
+
},
|
|
68022
|
+
watch: { type: "boolean", description: "Record an event when the Thread stops" },
|
|
68023
|
+
watchTimeoutMs: integerProp("How long to watch; default 29 minutes")
|
|
68024
|
+
},
|
|
68025
|
+
required: ["harnessId", "task"]
|
|
68026
|
+
}
|
|
68027
|
+
},
|
|
68028
|
+
{
|
|
68029
|
+
name: "thread_read",
|
|
68030
|
+
description: "Read a Thread's status and latest result, or page its visible messages (view=messages). Never changes the Thread.",
|
|
68031
|
+
inputSchema: {
|
|
68032
|
+
type: "object",
|
|
68033
|
+
properties: {
|
|
68034
|
+
thread: threadProp,
|
|
68035
|
+
view: { type: "string", enum: ["result", "messages"] },
|
|
68036
|
+
cursor: stringProp("Message cursor"),
|
|
68037
|
+
limit: integerProp("Messages per page, at most 100")
|
|
68038
|
+
},
|
|
68039
|
+
required: ["thread"]
|
|
68040
|
+
}
|
|
68041
|
+
},
|
|
68042
|
+
{
|
|
68043
|
+
name: "thread_wait",
|
|
68044
|
+
description: "Wait up to timeoutMs (at most 60000) for a Thread to stop, then return the same snapshot as thread_read plus timedOut.",
|
|
68045
|
+
inputSchema: {
|
|
68046
|
+
type: "object",
|
|
68047
|
+
properties: {
|
|
68048
|
+
thread: threadProp,
|
|
68049
|
+
timeoutMs: integerProp("At most 60000; default 30000"),
|
|
68050
|
+
view: { type: "string", enum: ["result", "messages"] }
|
|
68051
|
+
},
|
|
68052
|
+
required: ["thread"]
|
|
68053
|
+
}
|
|
68054
|
+
},
|
|
68055
|
+
{
|
|
68056
|
+
name: "thread_list",
|
|
68057
|
+
description: "List Threads: by workspace (cwd), by parent Thread, by the client that started them, or by reference.",
|
|
68058
|
+
inputSchema: {
|
|
68059
|
+
type: "object",
|
|
68060
|
+
properties: {
|
|
68061
|
+
cwd: stringProp("Absolute workspace path"),
|
|
68062
|
+
parent: stringProp("Parent Thread"),
|
|
68063
|
+
client: stringProp("Client name"),
|
|
68064
|
+
ref: stringProp("Reference URI"),
|
|
68065
|
+
limit: integerProp("At most 100; default 25"),
|
|
68066
|
+
cursor: stringProp("Cursor from a previous page"),
|
|
68067
|
+
sort: {
|
|
68068
|
+
type: "string",
|
|
68069
|
+
enum: [
|
|
68070
|
+
"created-asc",
|
|
68071
|
+
"created-desc",
|
|
68072
|
+
"updated-asc",
|
|
68073
|
+
"updated-desc",
|
|
68074
|
+
"recency-asc",
|
|
68075
|
+
"recency-desc"
|
|
68076
|
+
]
|
|
68077
|
+
}
|
|
68078
|
+
}
|
|
68079
|
+
}
|
|
68080
|
+
},
|
|
68081
|
+
{
|
|
68082
|
+
name: "thread_send",
|
|
68083
|
+
description: "Start a new Turn in an idle Thread. THREAD_BUSY means its current Turn is still running; messages are not queued.",
|
|
68084
|
+
inputSchema: {
|
|
68085
|
+
type: "object",
|
|
68086
|
+
properties: { thread: threadProp, message: stringProp("Message text") },
|
|
68087
|
+
required: ["thread", "message"]
|
|
68088
|
+
}
|
|
68089
|
+
},
|
|
68090
|
+
{
|
|
68091
|
+
name: "thread_cancel",
|
|
68092
|
+
description: "Cancel a Thread's active Turn, keeping the Thread and its history.",
|
|
68093
|
+
inputSchema: { type: "object", properties: { thread: threadProp }, required: ["thread"] }
|
|
68094
|
+
},
|
|
68095
|
+
{
|
|
68096
|
+
name: "thread_watch",
|
|
68097
|
+
description: "Record one event for this client when the Thread stops or the watch expires.",
|
|
68098
|
+
inputSchema: {
|
|
68099
|
+
type: "object",
|
|
68100
|
+
properties: { thread: threadProp, timeoutMs: integerProp("Default 29 minutes") },
|
|
68101
|
+
required: ["thread"]
|
|
68102
|
+
}
|
|
68103
|
+
},
|
|
68104
|
+
{
|
|
68105
|
+
name: "thread_watches",
|
|
68106
|
+
description: "List watches that have not been delivered yet.",
|
|
68107
|
+
inputSchema: { type: "object", properties: {} }
|
|
68108
|
+
},
|
|
68109
|
+
{
|
|
68110
|
+
name: "events_poll",
|
|
68111
|
+
description: "Read this client's events after a cursor (0 for all retained). Waits up to timeoutMs (at most 60000) for the first one. Pass the returned cursor back next time. CURSOR_EXPIRED: reconcile with thread_list client=<this client>.",
|
|
68112
|
+
inputSchema: {
|
|
68113
|
+
type: "object",
|
|
68114
|
+
properties: {
|
|
68115
|
+
after: integerProp("Cursor; 0 for all retained"),
|
|
68116
|
+
timeoutMs: integerProp("At most 60000; default 0"),
|
|
68117
|
+
limit: integerProp("At most 100")
|
|
68118
|
+
}
|
|
68119
|
+
}
|
|
68120
|
+
}
|
|
68121
|
+
];
|
|
68122
|
+
|
|
68123
|
+
// packages/shared-contracts/dist/external-mcp-map.js
|
|
68124
|
+
var DEFAULT_WATCH_MS = 29 * 6e4;
|
|
68125
|
+
|
|
67938
68126
|
// packages/shared-contracts/dist/grok-computer-use.js
|
|
67939
68127
|
var grokComputerUseGetSchema = external_exports.object({}).strict(), grokComputerUseSetSchema = external_exports.object({
|
|
67940
68128
|
enabled: external_exports.boolean().optional(),
|
|
@@ -68388,6 +68576,48 @@ var threadSteeringContextSchema = external_exports.object({
|
|
|
68388
68576
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
68389
68577
|
}).strict();
|
|
68390
68578
|
|
|
68579
|
+
// packages/shared-contracts/dist/voice-settings.js
|
|
68580
|
+
var VOICE_SETTINGS_METHOD = "codexhost/voice/settings", VOICE_GATEWAY_STATUS_METHOD = "codexhost/voice/gateway-status", voiceRoutesSchema = external_exports.strictObject({
|
|
68581
|
+
chatExperience: external_exports.enum(["chatgpt", "codex"]),
|
|
68582
|
+
chatConnection: external_exports.enum(["desktop", "gateway"]),
|
|
68583
|
+
workConnection: external_exports.enum(["desktop", "gateway"])
|
|
68584
|
+
}), DEFAULT_VOICE_ROUTES = Object.freeze({
|
|
68585
|
+
chatExperience: "chatgpt",
|
|
68586
|
+
chatConnection: "desktop",
|
|
68587
|
+
workConnection: "gateway"
|
|
68588
|
+
}), voiceSettingsSchema = voiceRoutesSchema.extend({ inject: external_exports.boolean() }), voiceSettingsRequestSchema = external_exports.discriminatedUnion("operation", [
|
|
68589
|
+
external_exports.strictObject({
|
|
68590
|
+
operation: external_exports.literal("get"),
|
|
68591
|
+
runtime: external_exports.strictObject({
|
|
68592
|
+
id: external_exports.string().uuid(),
|
|
68593
|
+
revision: external_exports.string().max(64),
|
|
68594
|
+
activeCall: external_exports.boolean()
|
|
68595
|
+
}).optional()
|
|
68596
|
+
}),
|
|
68597
|
+
external_exports.strictObject({ operation: external_exports.literal("migrate"), routes: voiceRoutesSchema }),
|
|
68598
|
+
external_exports.strictObject({
|
|
68599
|
+
operation: external_exports.literal("set"),
|
|
68600
|
+
settings: voiceSettingsSchema,
|
|
68601
|
+
revision: external_exports.string().max(64)
|
|
68602
|
+
}),
|
|
68603
|
+
external_exports.strictObject({ operation: external_exports.literal("restart"), confirm: external_exports.literal(!0) })
|
|
68604
|
+
]), voiceSettingsStateSchema = external_exports.strictObject({
|
|
68605
|
+
settings: voiceSettingsSchema,
|
|
68606
|
+
initialized: external_exports.boolean(),
|
|
68607
|
+
revision: external_exports.string(),
|
|
68608
|
+
activeInject: external_exports.boolean().nullable(),
|
|
68609
|
+
envOverride: external_exports.enum(["0", "1"]).nullable(),
|
|
68610
|
+
activeEnvOverride: external_exports.enum(["0", "1"]).nullable(),
|
|
68611
|
+
routesActive: external_exports.boolean().nullable(),
|
|
68612
|
+
activeCall: external_exports.boolean().nullable(),
|
|
68613
|
+
gatewayReady: external_exports.boolean().nullable(),
|
|
68614
|
+
restartAvailable: external_exports.boolean(),
|
|
68615
|
+
restart: external_exports.strictObject({
|
|
68616
|
+
phase: external_exports.enum(["idle", "restarting", "succeeded", "failed"]),
|
|
68617
|
+
error: external_exports.string().nullable()
|
|
68618
|
+
})
|
|
68619
|
+
});
|
|
68620
|
+
|
|
68391
68621
|
// packages/shared-contracts/dist/client-channel.js
|
|
68392
68622
|
var CLIENT_CHANNEL_VERSION = 1, CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
68393
68623
|
var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict(), clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict(), clientProjectlessWorkspaceSchema = external_exports.object({
|
|
@@ -69102,6 +69332,10 @@ var consoleOpenParamsSchema = external_exports.strictObject({}), consoleOpenResu
|
|
|
69102
69332
|
"codexhost/voice/gateway-status",
|
|
69103
69333
|
"codexhost/enrollment/list",
|
|
69104
69334
|
"codexhost/enrollment/revoke",
|
|
69335
|
+
"codexhost/external-clients/list",
|
|
69336
|
+
"codexhost/external-clients/create",
|
|
69337
|
+
"codexhost/external-clients/update",
|
|
69338
|
+
"codexhost/external-clients/revoke",
|
|
69105
69339
|
"codexhost/console/remote-connections",
|
|
69106
69340
|
"codexhost/runtime/status",
|
|
69107
69341
|
"codexhost/remote/ssh-setup",
|
|
@@ -69714,48 +69948,6 @@ var webUiExtensionIdSchema = external_exports.string().max(214).regex(/^(?:@[a-z
|
|
|
69714
69948
|
registry: webUiExtensionRegistrySchema.optional()
|
|
69715
69949
|
}).strict(), webUiExtensionEnabledSchema = external_exports.object({ id: webUiExtensionIdSchema, enabled: external_exports.boolean() }).strict(), webUiExtensionRemoveSchema = external_exports.object({ id: webUiExtensionIdSchema }).strict();
|
|
69716
69950
|
|
|
69717
|
-
// packages/shared-contracts/dist/voice-settings.js
|
|
69718
|
-
var voiceRoutesSchema = external_exports.strictObject({
|
|
69719
|
-
chatExperience: external_exports.enum(["chatgpt", "codex"]),
|
|
69720
|
-
chatConnection: external_exports.enum(["desktop", "gateway"]),
|
|
69721
|
-
workConnection: external_exports.enum(["desktop", "gateway"])
|
|
69722
|
-
}), DEFAULT_VOICE_ROUTES = Object.freeze({
|
|
69723
|
-
chatExperience: "chatgpt",
|
|
69724
|
-
chatConnection: "desktop",
|
|
69725
|
-
workConnection: "gateway"
|
|
69726
|
-
}), voiceSettingsSchema = voiceRoutesSchema.extend({ inject: external_exports.boolean() }), voiceSettingsRequestSchema = external_exports.discriminatedUnion("operation", [
|
|
69727
|
-
external_exports.strictObject({
|
|
69728
|
-
operation: external_exports.literal("get"),
|
|
69729
|
-
runtime: external_exports.strictObject({
|
|
69730
|
-
id: external_exports.string().uuid(),
|
|
69731
|
-
revision: external_exports.string().max(64),
|
|
69732
|
-
activeCall: external_exports.boolean()
|
|
69733
|
-
}).optional()
|
|
69734
|
-
}),
|
|
69735
|
-
external_exports.strictObject({ operation: external_exports.literal("migrate"), routes: voiceRoutesSchema }),
|
|
69736
|
-
external_exports.strictObject({
|
|
69737
|
-
operation: external_exports.literal("set"),
|
|
69738
|
-
settings: voiceSettingsSchema,
|
|
69739
|
-
revision: external_exports.string().max(64)
|
|
69740
|
-
}),
|
|
69741
|
-
external_exports.strictObject({ operation: external_exports.literal("restart"), confirm: external_exports.literal(!0) })
|
|
69742
|
-
]), voiceSettingsStateSchema = external_exports.strictObject({
|
|
69743
|
-
settings: voiceSettingsSchema,
|
|
69744
|
-
initialized: external_exports.boolean(),
|
|
69745
|
-
revision: external_exports.string(),
|
|
69746
|
-
activeInject: external_exports.boolean().nullable(),
|
|
69747
|
-
envOverride: external_exports.enum(["0", "1"]).nullable(),
|
|
69748
|
-
activeEnvOverride: external_exports.enum(["0", "1"]).nullable(),
|
|
69749
|
-
routesActive: external_exports.boolean().nullable(),
|
|
69750
|
-
activeCall: external_exports.boolean().nullable(),
|
|
69751
|
-
gatewayReady: external_exports.boolean().nullable(),
|
|
69752
|
-
restartAvailable: external_exports.boolean(),
|
|
69753
|
-
restart: external_exports.strictObject({
|
|
69754
|
-
phase: external_exports.enum(["idle", "restarting", "succeeded", "failed"]),
|
|
69755
|
-
error: external_exports.string().nullable()
|
|
69756
|
-
})
|
|
69757
|
-
});
|
|
69758
|
-
|
|
69759
69951
|
// packages/shared-contracts/dist/background-activity.js
|
|
69760
69952
|
var backgroundActivitySchema = external_exports.strictObject({
|
|
69761
69953
|
id: external_exports.string().min(1),
|
|
@@ -79226,6 +79418,407 @@ import { isAbsolute as isAbsolute8, join as join12 } from "node:path";
|
|
|
79226
79418
|
import { readdir as readdir3, open as open2 } from "node:fs/promises";
|
|
79227
79419
|
import { constants as constants5 } from "node:fs";
|
|
79228
79420
|
import path6 from "node:path";
|
|
79421
|
+
|
|
79422
|
+
// packages/desktop-control/dist/renderer-app-url.js
|
|
79423
|
+
function parseCodexAppUrl(value) {
|
|
79424
|
+
try {
|
|
79425
|
+
let url2 = new URL(value);
|
|
79426
|
+
return url2.protocol === "app:" && url2.hostname === "-" ? url2 : null;
|
|
79427
|
+
} catch {
|
|
79428
|
+
return null;
|
|
79429
|
+
}
|
|
79430
|
+
}
|
|
79431
|
+
function isPrimaryRendererUrl(value) {
|
|
79432
|
+
let url2 = parseCodexAppUrl(value);
|
|
79433
|
+
return url2 !== null && url2.pathname === "/index.html" && url2.search === "" && url2.hash === "";
|
|
79434
|
+
}
|
|
79435
|
+
function isAvatarOverlayRendererUrl(value) {
|
|
79436
|
+
let url2 = parseCodexAppUrl(value);
|
|
79437
|
+
return url2 ? url2.pathname === "/avatar-overlay.html" ? !0 : url2.pathname === "/index.html" && url2.searchParams.get("initialRoute") === "/avatar-overlay" : !1;
|
|
79438
|
+
}
|
|
79439
|
+
function isEligibleVoiceHostUrl(value) {
|
|
79440
|
+
return isPrimaryRendererUrl(value) || isAvatarOverlayRendererUrl(value);
|
|
79441
|
+
}
|
|
79442
|
+
function rendererVoiceHostDocumentGuardExpression() {
|
|
79443
|
+
return `(function(){try{
|
|
79444
|
+
if (window.top !== window) return false;
|
|
79445
|
+
var url = new URL(location.href);
|
|
79446
|
+
if (url.protocol !== "app:" || url.hostname !== "-") return false;
|
|
79447
|
+
if (url.pathname === "/avatar-overlay.html") return true;
|
|
79448
|
+
if (url.pathname !== "/index.html") return false;
|
|
79449
|
+
if (url.search === "" && url.hash === "") return true;
|
|
79450
|
+
return url.searchParams.get("initialRoute") === "/avatar-overlay";
|
|
79451
|
+
}catch(e){return false;}})()`;
|
|
79452
|
+
}
|
|
79453
|
+
|
|
79454
|
+
// packages/desktop-control/dist/renderer-voice-host-binding.js
|
|
79455
|
+
var RENDERER_VOICE_HOST_BINDING_NAME = "__codexhostVoiceHostBindingV1", RENDERER_VOICE_HOST_CAPABILITY_GLOBAL = "__codexhostVoiceHostV1", RENDERER_VOICE_HOST_DELIVER_GLOBAL = "__codexhostVoiceHostDeliverV1", RENDERER_VOICE_HOST_PENDING_GLOBAL = "__codexhostVoiceHostPendingV1", RENDERER_VOICE_HOST_MAX_PAYLOAD_BYTES = 256 * 1024, RENDERER_VOICE_HOST_SETTINGS_TIMEOUT_MS = 1e4, RENDERER_VOICE_HOST_GATEWAY_TIMEOUT_MS = 2e3, RENDERER_VOICE_HOST_REALTIME_TIMEOUT_MS = 3e4, RENDERER_VOICE_HOST_METHODS = [
|
|
79456
|
+
VOICE_SETTINGS_METHOD,
|
|
79457
|
+
VOICE_GATEWAY_STATUS_METHOD,
|
|
79458
|
+
REALTIME_CALL_METHOD
|
|
79459
|
+
], ALLOWED_METHODS = new Set(RENDERER_VOICE_HOST_METHODS), STALE_CONTEXT = /uniqueContextId not found|Cannot find context with specified id|Execution context was destroyed|Cannot find default execution context/i, UNAVAILABLE = "Local Host connection is unavailable", UNKNOWN_OUTCOME = "Host request outcome is unknown. Do not retry automatically.", RENDERER_VOICE_HOST_CLEANUP_UNCONFIRMED = "Original Host owner is unreachable; cleanup is unconfirmed. Do not retry automatically.";
|
|
79460
|
+
function isRecord3(value) {
|
|
79461
|
+
return typeof value == "object" && value !== null && !Array.isArray(value);
|
|
79462
|
+
}
|
|
79463
|
+
function allowlistedStage(value) {
|
|
79464
|
+
return value === "config" || value === "request" || value === "transport" || value === "identity" || value === "cancel" ? value : void 0;
|
|
79465
|
+
}
|
|
79466
|
+
function isCreateOperation(method2, params) {
|
|
79467
|
+
return method2 === REALTIME_CALL_METHOD && params.operation === "create";
|
|
79468
|
+
}
|
|
79469
|
+
function cleanupUnconfirmedError(error51) {
|
|
79470
|
+
if (error51 instanceof Error && error51.message === RENDERER_VOICE_HOST_CLEANUP_UNCONFIRMED && allowlistedStage(Reflect.get(error51, "stage")) === "cancel")
|
|
79471
|
+
return error51;
|
|
79472
|
+
}
|
|
79473
|
+
function rendererVoiceHostCapabilitySource(owner, generation) {
|
|
79474
|
+
let guard = rendererVoiceHostDocumentGuardExpression();
|
|
79475
|
+
return `(() => {
|
|
79476
|
+
if (!${guard}) return true;
|
|
79477
|
+
const binding = ${JSON.stringify(RENDERER_VOICE_HOST_BINDING_NAME)};
|
|
79478
|
+
const cap = ${JSON.stringify(RENDERER_VOICE_HOST_CAPABILITY_GLOBAL)};
|
|
79479
|
+
const deliver = ${JSON.stringify(RENDERER_VOICE_HOST_DELIVER_GLOBAL)};
|
|
79480
|
+
const pendingKey = ${JSON.stringify(RENDERER_VOICE_HOST_PENDING_GLOBAL)};
|
|
79481
|
+
const allowed = ${JSON.stringify([...RENDERER_VOICE_HOST_METHODS])};
|
|
79482
|
+
const maxBytes = ${RENDERER_VOICE_HOST_MAX_PAYLOAD_BYTES};
|
|
79483
|
+
const ownerId = ${JSON.stringify(owner)};
|
|
79484
|
+
const generation = ${generation};
|
|
79485
|
+
const settingsTimeout = ${RENDERER_VOICE_HOST_SETTINGS_TIMEOUT_MS};
|
|
79486
|
+
const gatewayTimeout = ${RENDERER_VOICE_HOST_GATEWAY_TIMEOUT_MS};
|
|
79487
|
+
const realtimeTimeout = ${RENDERER_VOICE_HOST_REALTIME_TIMEOUT_MS};
|
|
79488
|
+
const pending = globalThis[pendingKey] instanceof Map ? globalThis[pendingKey] : new Map();
|
|
79489
|
+
globalThis[pendingKey] = pending;
|
|
79490
|
+
const unavailable = () => Promise.reject(new Error(${JSON.stringify(UNAVAILABLE)}));
|
|
79491
|
+
const settleWait = (wait, message) => {
|
|
79492
|
+
try { clearTimeout(wait.timer); } catch (e) {}
|
|
79493
|
+
try { wait.reject(new Error(message)); } catch (e) {}
|
|
79494
|
+
};
|
|
79495
|
+
const settleAll = (message) => {
|
|
79496
|
+
for (const [id, wait] of [...pending.entries()]) {
|
|
79497
|
+
pending.delete(id);
|
|
79498
|
+
settleWait(wait, message);
|
|
79499
|
+
}
|
|
79500
|
+
};
|
|
79501
|
+
const previous = globalThis[cap];
|
|
79502
|
+
if (previous && previous.generation !== generation) settleAll(${JSON.stringify(UNAVAILABLE)});
|
|
79503
|
+
globalThis[deliver] = (message) => {
|
|
79504
|
+
if (!message || typeof message !== "object" || typeof message.id !== "string") return;
|
|
79505
|
+
const wait = pending.get(message.id);
|
|
79506
|
+
if (!wait) return;
|
|
79507
|
+
pending.delete(message.id);
|
|
79508
|
+
try { clearTimeout(wait.timer); } catch (e) {}
|
|
79509
|
+
if (message.ok) {
|
|
79510
|
+
wait.resolve(message.result);
|
|
79511
|
+
return;
|
|
79512
|
+
}
|
|
79513
|
+
const error = new Error(
|
|
79514
|
+
typeof message.error === "string" && message.error.length > 0 && message.error.length <= 500
|
|
79515
|
+
? message.error
|
|
79516
|
+
: "Host request failed",
|
|
79517
|
+
);
|
|
79518
|
+
if (typeof message.stage === "string") error.stage = message.stage;
|
|
79519
|
+
wait.reject(error);
|
|
79520
|
+
};
|
|
79521
|
+
Object.defineProperty(globalThis, cap, {
|
|
79522
|
+
configurable: true,
|
|
79523
|
+
value: Object.freeze({
|
|
79524
|
+
owner: ownerId,
|
|
79525
|
+
generation,
|
|
79526
|
+
request(method, params) {
|
|
79527
|
+
try {
|
|
79528
|
+
if (!${guard}) return unavailable();
|
|
79529
|
+
if (typeof method !== "string" || !allowed.includes(method)) return unavailable();
|
|
79530
|
+
const body = params !== null && typeof params === "object" && !Array.isArray(params) ? params : {};
|
|
79531
|
+
const id = crypto.randomUUID();
|
|
79532
|
+
const payload = JSON.stringify({ v: 1, id, owner: ownerId, generation, method, params: body });
|
|
79533
|
+
if (payload.length > maxBytes) return Promise.reject(new Error("Voice request is too large"));
|
|
79534
|
+
const timeoutMs =
|
|
79535
|
+
method === ${JSON.stringify(VOICE_GATEWAY_STATUS_METHOD)}
|
|
79536
|
+
? gatewayTimeout
|
|
79537
|
+
: method === ${JSON.stringify(REALTIME_CALL_METHOD)}
|
|
79538
|
+
? realtimeTimeout
|
|
79539
|
+
: settingsTimeout;
|
|
79540
|
+
return new Promise((resolve, reject) => {
|
|
79541
|
+
const timer = setTimeout(() => {
|
|
79542
|
+
if (!pending.has(id)) return;
|
|
79543
|
+
pending.delete(id);
|
|
79544
|
+
try {
|
|
79545
|
+
globalThis[binding](JSON.stringify({
|
|
79546
|
+
v: 1,
|
|
79547
|
+
id,
|
|
79548
|
+
owner: ownerId,
|
|
79549
|
+
generation,
|
|
79550
|
+
abandon: true,
|
|
79551
|
+
method,
|
|
79552
|
+
params: body,
|
|
79553
|
+
}));
|
|
79554
|
+
} catch (e) {}
|
|
79555
|
+
reject(new Error(${JSON.stringify(UNAVAILABLE)}));
|
|
79556
|
+
}, timeoutMs);
|
|
79557
|
+
pending.set(id, { resolve, reject, timer, generation });
|
|
79558
|
+
try {
|
|
79559
|
+
globalThis[binding](payload);
|
|
79560
|
+
} catch {
|
|
79561
|
+
pending.delete(id);
|
|
79562
|
+
try { clearTimeout(timer); } catch (e) {}
|
|
79563
|
+
reject(new Error(${JSON.stringify(UNAVAILABLE)}));
|
|
79564
|
+
}
|
|
79565
|
+
});
|
|
79566
|
+
} catch {
|
|
79567
|
+
return unavailable();
|
|
79568
|
+
}
|
|
79569
|
+
},
|
|
79570
|
+
}),
|
|
79571
|
+
});
|
|
79572
|
+
return true;
|
|
79573
|
+
})()`;
|
|
79574
|
+
}
|
|
79575
|
+
function evaluateResultValue(response) {
|
|
79576
|
+
if (!(!isRecord3(response) || isRecord3(response.exceptionDetails)))
|
|
79577
|
+
return isRecord3(response.result) ? response.result.value : void 0;
|
|
79578
|
+
}
|
|
79579
|
+
function callIdFromCreateResult(result) {
|
|
79580
|
+
if (!isRecord3(result) || !isRecord3(result.headers))
|
|
79581
|
+
return;
|
|
79582
|
+
let location = result.headers.location;
|
|
79583
|
+
if (typeof location != "string")
|
|
79584
|
+
return;
|
|
79585
|
+
let callId = realtimeCallIdFromLocation(location);
|
|
79586
|
+
return isRealtimeCallId(callId) ? callId : void 0;
|
|
79587
|
+
}
|
|
79588
|
+
async function cleanupAbandonedCreate(execution, params, result) {
|
|
79589
|
+
let unconfirmed, note = (error51) => {
|
|
79590
|
+
unconfirmed ??= cleanupUnconfirmedError(error51);
|
|
79591
|
+
}, requestId2 = typeof params.requestId == "string" ? params.requestId : void 0;
|
|
79592
|
+
requestId2 && await execution.request(REALTIME_CALL_METHOD, { operation: "cancel", requestId: requestId2 }).catch(note);
|
|
79593
|
+
let callId = callIdFromCreateResult(result);
|
|
79594
|
+
return callId && await execution.request(REALTIME_CALL_METHOD, { operation: "hangup", callId }).catch(note), unconfirmed;
|
|
79595
|
+
}
|
|
79596
|
+
function captureExecution(host) {
|
|
79597
|
+
return host.bindExecution?.() ?? {
|
|
79598
|
+
generation: host.generation,
|
|
79599
|
+
request: (method2, params) => host.request(method2, params)
|
|
79600
|
+
};
|
|
79601
|
+
}
|
|
79602
|
+
async function readContextDocument(renderer, executionContextId) {
|
|
79603
|
+
try {
|
|
79604
|
+
let response = await renderer.command("Runtime.evaluate", {
|
|
79605
|
+
expression: "(function(){try{return {href:String(location.href),top:window.top===window};}catch(e){return {href:'',top:false};}})()",
|
|
79606
|
+
contextId: executionContextId,
|
|
79607
|
+
returnByValue: !0
|
|
79608
|
+
}), value = evaluateResultValue(response);
|
|
79609
|
+
return !isRecord3(value) || typeof value.href != "string" || typeof value.top != "boolean" ? void 0 : { href: value.href, top: value.top };
|
|
79610
|
+
} catch (error51) {
|
|
79611
|
+
return error51 instanceof Error && STALE_CONTEXT.test(error51.message), void 0;
|
|
79612
|
+
}
|
|
79613
|
+
}
|
|
79614
|
+
async function deliver(renderer, executionContextId, message2) {
|
|
79615
|
+
let encoded = JSON.stringify(message2), payload = encoded.length > RENDERER_VOICE_HOST_MAX_PAYLOAD_BYTES ? JSON.stringify({
|
|
79616
|
+
id: message2.id,
|
|
79617
|
+
ok: !1,
|
|
79618
|
+
error: "Host request failed"
|
|
79619
|
+
}) : encoded;
|
|
79620
|
+
await renderer.command("Runtime.evaluate", {
|
|
79621
|
+
expression: `typeof globalThis[${JSON.stringify(RENDERER_VOICE_HOST_DELIVER_GLOBAL)}]==='function'&&globalThis[${JSON.stringify(RENDERER_VOICE_HOST_DELIVER_GLOBAL)}](${payload})`,
|
|
79622
|
+
contextId: executionContextId,
|
|
79623
|
+
returnByValue: !0
|
|
79624
|
+
}).catch(() => {
|
|
79625
|
+
});
|
|
79626
|
+
}
|
|
79627
|
+
async function registerFutureScript(renderer, source, previousId) {
|
|
79628
|
+
previousId && await renderer.command("Page.removeScriptToEvaluateOnNewDocument", { identifier: previousId }).catch(() => {
|
|
79629
|
+
});
|
|
79630
|
+
let added = await renderer.command("Page.addScriptToEvaluateOnNewDocument", { source });
|
|
79631
|
+
return isRecord3(added) && typeof added.identifier == "string" ? added.identifier : void 0;
|
|
79632
|
+
}
|
|
79633
|
+
async function removeFutureScript(renderer, identifier) {
|
|
79634
|
+
identifier && await renderer.command("Page.removeScriptToEvaluateOnNewDocument", { identifier }).catch(() => {
|
|
79635
|
+
});
|
|
79636
|
+
}
|
|
79637
|
+
async function installRendererVoiceHostBinding(renderer, host, options) {
|
|
79638
|
+
let disposed = !1, scriptId, publishing = Promise.resolve(), inflight = /* @__PURE__ */ new Set(), works = /* @__PURE__ */ new Map(), abandonedIds = /* @__PURE__ */ new Set(), contexts = /* @__PURE__ */ new Map(), rememberContext = (params) => {
|
|
79639
|
+
if (!isRecord3(params) || !isRecord3(params.context))
|
|
79640
|
+
return;
|
|
79641
|
+
let context = params.context;
|
|
79642
|
+
if (typeof context.id != "number" || typeof context.uniqueId != "string")
|
|
79643
|
+
return;
|
|
79644
|
+
let aux = isRecord3(context.auxData) ? context.auxData : void 0;
|
|
79645
|
+
contexts.set(context.id, {
|
|
79646
|
+
uniqueId: context.uniqueId,
|
|
79647
|
+
isDefault: aux?.isDefault === !0
|
|
79648
|
+
});
|
|
79649
|
+
}, observeCleanupUnconfirmed = async (contextId, pageId, unconfirmed) => {
|
|
79650
|
+
!unconfirmed || disposed || await deliver(renderer, contextId, {
|
|
79651
|
+
id: pageId,
|
|
79652
|
+
ok: !1,
|
|
79653
|
+
error: unconfirmed.message,
|
|
79654
|
+
stage: "cancel"
|
|
79655
|
+
});
|
|
79656
|
+
}, abandonWork = (item) => {
|
|
79657
|
+
item.abandoned || (item.abandoned = !0, item.create && cleanupAbandonedCreate(item.execution, { requestId: item.create.requestId, operation: "create" }, item.create.result).then((unconfirmed) => observeCleanupUnconfirmed(item.contextId, item.pageId, unconfirmed)));
|
|
79658
|
+
}, abandonMatching = (contextId, uniqueId) => {
|
|
79659
|
+
for (let item of works.values())
|
|
79660
|
+
(contextId !== void 0 && item.contextId === contextId || uniqueId !== void 0 && item.uniqueId === uniqueId) && abandonWork(item);
|
|
79661
|
+
}, forgetContext = (params) => {
|
|
79662
|
+
if (!isRecord3(params))
|
|
79663
|
+
return;
|
|
79664
|
+
let contextId, uniqueId;
|
|
79665
|
+
if (typeof params.executionContextId == "number" && (contextId = params.executionContextId, uniqueId = contexts.get(contextId)?.uniqueId, contexts.delete(contextId)), typeof params.executionContextUniqueId == "string") {
|
|
79666
|
+
uniqueId = params.executionContextUniqueId;
|
|
79667
|
+
for (let [id, record5] of contexts)
|
|
79668
|
+
record5.uniqueId === uniqueId && (contextId = id, contexts.delete(id));
|
|
79669
|
+
}
|
|
79670
|
+
abandonMatching(contextId, uniqueId);
|
|
79671
|
+
}, unsubscribeCreated = renderer.on("Runtime.executionContextCreated", rememberContext), unsubscribeDestroyed = renderer.on("Runtime.executionContextDestroyed", forgetContext), unsubscribeCleared = renderer.on("Runtime.executionContextsCleared", () => {
|
|
79672
|
+
contexts.clear();
|
|
79673
|
+
for (let item of works.values())
|
|
79674
|
+
abandonWork(item);
|
|
79675
|
+
}), contextIsVerified = async (executionContextId, uniqueId) => {
|
|
79676
|
+
let tracked = contexts.get(executionContextId);
|
|
79677
|
+
if (!tracked?.isDefault || tracked.uniqueId !== uniqueId)
|
|
79678
|
+
return !1;
|
|
79679
|
+
let document2 = await readContextDocument(renderer, executionContextId), still = contexts.get(executionContextId);
|
|
79680
|
+
return still?.uniqueId !== uniqueId || !still.isDefault || !document2?.top ? !1 : isEligibleVoiceHostUrl(document2.href);
|
|
79681
|
+
}, publishGeneration = async () => {
|
|
79682
|
+
if (disposed)
|
|
79683
|
+
return;
|
|
79684
|
+
let startedGeneration = host.generation, source = rendererVoiceHostCapabilitySource(host.owner, startedGeneration), addedId = await registerFutureScript(renderer, source, scriptId);
|
|
79685
|
+
if (disposed || host.generation !== startedGeneration) {
|
|
79686
|
+
await removeFutureScript(renderer, addedId);
|
|
79687
|
+
return;
|
|
79688
|
+
}
|
|
79689
|
+
scriptId = addedId, await renderer.evaluate(source);
|
|
79690
|
+
}, enqueuePublish = () => {
|
|
79691
|
+
publishing = publishing.catch(() => {
|
|
79692
|
+
}).then(() => publishGeneration()).catch(() => {
|
|
79693
|
+
});
|
|
79694
|
+
}, cancelInflightCreates = () => {
|
|
79695
|
+
for (let item of works.values())
|
|
79696
|
+
!item.create || item.abandoned || item.execution.request(REALTIME_CALL_METHOD, { operation: "cancel", requestId: item.create.requestId }).catch((error51) => observeCleanupUnconfirmed(item.contextId, item.pageId, cleanupUnconfirmedError(error51)));
|
|
79697
|
+
};
|
|
79698
|
+
options?.enableRuntime !== !1 && await renderer.command("Runtime.enable"), await renderer.command("Page.enable"), await renderer.command("Runtime.addBinding", { name: RENDERER_VOICE_HOST_BINDING_NAME }), await publishGeneration();
|
|
79699
|
+
let refresh = () => {
|
|
79700
|
+
disposed || (cancelInflightCreates(), enqueuePublish());
|
|
79701
|
+
}, unsubscribeGeneration = host.onGenerationChange?.(refresh), unsubscribe = renderer.on("Runtime.bindingCalled", (params) => {
|
|
79702
|
+
if (disposed || !isRecord3(params) || params.name !== RENDERER_VOICE_HOST_BINDING_NAME || typeof params.executionContextId != "number" || typeof params.payload != "string" || params.payload.length > RENDERER_VOICE_HOST_MAX_PAYLOAD_BYTES)
|
|
79703
|
+
return;
|
|
79704
|
+
let contextId = params.executionContextId, payloadText = params.payload, startedGeneration = host.generation, work = (async () => {
|
|
79705
|
+
let parsed;
|
|
79706
|
+
try {
|
|
79707
|
+
parsed = JSON.parse(payloadText);
|
|
79708
|
+
} catch {
|
|
79709
|
+
return;
|
|
79710
|
+
}
|
|
79711
|
+
if (!isRecord3(parsed) || parsed.v !== 1 || typeof parsed.id != "string" || parsed.id.length === 0 || parsed.id.length > 128 || parsed.owner !== host.owner)
|
|
79712
|
+
return;
|
|
79713
|
+
let requestId2 = parsed.id;
|
|
79714
|
+
if (parsed.abandon === !0) {
|
|
79715
|
+
let existing = works.get(requestId2);
|
|
79716
|
+
existing ? abandonWork(existing) : abandonedIds.add(requestId2);
|
|
79717
|
+
return;
|
|
79718
|
+
}
|
|
79719
|
+
if (parsed.generation !== startedGeneration || parsed.generation !== host.generation || typeof parsed.method != "string" || !isRecord3(parsed.params)) {
|
|
79720
|
+
await deliver(renderer, contextId, { id: requestId2, ok: !1, error: UNAVAILABLE });
|
|
79721
|
+
return;
|
|
79722
|
+
}
|
|
79723
|
+
let tracked = contexts.get(contextId);
|
|
79724
|
+
if (!tracked?.isDefault)
|
|
79725
|
+
return;
|
|
79726
|
+
let uniqueId = tracked.uniqueId, execution = captureExecution(host), item = {
|
|
79727
|
+
pageId: requestId2,
|
|
79728
|
+
contextId,
|
|
79729
|
+
uniqueId,
|
|
79730
|
+
generation: startedGeneration,
|
|
79731
|
+
execution,
|
|
79732
|
+
abandoned: abandonedIds.has(requestId2),
|
|
79733
|
+
...isCreateOperation(parsed.method, parsed.params) && typeof parsed.params.requestId == "string" ? { create: { requestId: parsed.params.requestId } } : {}
|
|
79734
|
+
};
|
|
79735
|
+
works.set(requestId2, item), abandonedIds.delete(requestId2);
|
|
79736
|
+
try {
|
|
79737
|
+
if (item.abandoned) {
|
|
79738
|
+
item.create && await observeCleanupUnconfirmed(contextId, requestId2, await cleanupAbandonedCreate(item.execution, { requestId: item.create.requestId, operation: "create" }, item.create.result));
|
|
79739
|
+
return;
|
|
79740
|
+
}
|
|
79741
|
+
let method2 = parsed.method, requestParams = parsed.params, verified = await contextIsVerified(contextId, uniqueId), still = contexts.get(contextId);
|
|
79742
|
+
if (disposed || item.abandoned || host.generation !== startedGeneration || still?.uniqueId !== uniqueId) {
|
|
79743
|
+
item.create && await observeCleanupUnconfirmed(contextId, requestId2, await cleanupAbandonedCreate(item.execution, requestParams, item.create.result));
|
|
79744
|
+
return;
|
|
79745
|
+
}
|
|
79746
|
+
if (!verified) {
|
|
79747
|
+
still?.isDefault && await deliver(renderer, contextId, { id: requestId2, ok: !1, error: UNAVAILABLE });
|
|
79748
|
+
return;
|
|
79749
|
+
}
|
|
79750
|
+
if (!ALLOWED_METHODS.has(method2)) {
|
|
79751
|
+
await deliver(renderer, contextId, { id: requestId2, ok: !1, error: UNAVAILABLE });
|
|
79752
|
+
return;
|
|
79753
|
+
}
|
|
79754
|
+
try {
|
|
79755
|
+
let result = await item.execution.request(method2, requestParams);
|
|
79756
|
+
item.create && (item.create.result = result);
|
|
79757
|
+
let after = contexts.get(contextId);
|
|
79758
|
+
if (disposed || item.abandoned || host.generation !== startedGeneration || after?.uniqueId !== uniqueId) {
|
|
79759
|
+
item.create && await observeCleanupUnconfirmed(contextId, requestId2, await cleanupAbandonedCreate(item.execution, requestParams, result));
|
|
79760
|
+
return;
|
|
79761
|
+
}
|
|
79762
|
+
await deliver(renderer, contextId, { id: requestId2, ok: !0, result });
|
|
79763
|
+
} catch (error51) {
|
|
79764
|
+
let unconfirmed = cleanupUnconfirmedError(error51);
|
|
79765
|
+
if (unconfirmed && !disposed) {
|
|
79766
|
+
await deliver(renderer, contextId, {
|
|
79767
|
+
id: requestId2,
|
|
79768
|
+
ok: !1,
|
|
79769
|
+
error: unconfirmed.message,
|
|
79770
|
+
stage: "cancel"
|
|
79771
|
+
});
|
|
79772
|
+
return;
|
|
79773
|
+
}
|
|
79774
|
+
if (disposed || item.abandoned || host.generation !== startedGeneration)
|
|
79775
|
+
return;
|
|
79776
|
+
let stage = error51 instanceof Error ? allowlistedStage(Reflect.get(error51, "stage")) : void 0;
|
|
79777
|
+
await deliver(renderer, contextId, {
|
|
79778
|
+
id: requestId2,
|
|
79779
|
+
ok: !1,
|
|
79780
|
+
error: error51 instanceof Error && error51.message.length > 0 && error51.message.length <= 500 && !/bearer|token|authorization|sdp/i.test(error51.message) ? error51.message : "Host request failed",
|
|
79781
|
+
...stage ? { stage } : {}
|
|
79782
|
+
});
|
|
79783
|
+
}
|
|
79784
|
+
} finally {
|
|
79785
|
+
works.delete(requestId2);
|
|
79786
|
+
}
|
|
79787
|
+
})();
|
|
79788
|
+
inflight.add(work), work.finally(() => inflight.delete(work));
|
|
79789
|
+
});
|
|
79790
|
+
return () => {
|
|
79791
|
+
if (disposed)
|
|
79792
|
+
return;
|
|
79793
|
+
disposed = !0, unsubscribeGeneration?.(), unsubscribe(), unsubscribeCreated(), unsubscribeDestroyed(), unsubscribeCleared(), cancelInflightCreates();
|
|
79794
|
+
let outstanding = [...inflight], leftover = [...works.values()];
|
|
79795
|
+
Promise.allSettled(outstanding).then(async () => {
|
|
79796
|
+
for (let item of leftover)
|
|
79797
|
+
item.create && await observeCleanupUnconfirmed(item.contextId, item.pageId, await cleanupAbandonedCreate(item.execution, { requestId: item.create.requestId, operation: "create" }, item.create.result));
|
|
79798
|
+
}), removeFutureScript(renderer, scriptId), renderer.command("Runtime.removeBinding", { name: RENDERER_VOICE_HOST_BINDING_NAME }).catch(() => {
|
|
79799
|
+
}), renderer.evaluate(`(() => {
|
|
79800
|
+
const pending = globalThis[${JSON.stringify(RENDERER_VOICE_HOST_PENDING_GLOBAL)}];
|
|
79801
|
+
if (pending && typeof pending.forEach === "function") {
|
|
79802
|
+
for (const [id, wait] of [...pending.entries()]) {
|
|
79803
|
+
pending.delete(id);
|
|
79804
|
+
try { clearTimeout(wait.timer); } catch (e) {}
|
|
79805
|
+
try { wait.reject(new Error(${JSON.stringify(UNKNOWN_OUTCOME)})); } catch (e) {}
|
|
79806
|
+
}
|
|
79807
|
+
}
|
|
79808
|
+
delete globalThis[${JSON.stringify(RENDERER_VOICE_HOST_CAPABILITY_GLOBAL)}];
|
|
79809
|
+
delete globalThis[${JSON.stringify(RENDERER_VOICE_HOST_DELIVER_GLOBAL)}];
|
|
79810
|
+
delete globalThis[${JSON.stringify(RENDERER_VOICE_HOST_PENDING_GLOBAL)}];
|
|
79811
|
+
return true;
|
|
79812
|
+
})()`).catch(() => {
|
|
79813
|
+
});
|
|
79814
|
+
};
|
|
79815
|
+
}
|
|
79816
|
+
|
|
79817
|
+
// packages/desktop-control/dist/host-client-channel.js
|
|
79818
|
+
var VOICE_SETTINGS_TIMEOUT_MS = 1e4, VOICE_GATEWAY_STATUS_TIMEOUT_MS = 2e3, REALTIME_CALL_TIMEOUT_MS = 3e4, VOICE_GATEWAY_STAGES = /* @__PURE__ */ new Set(["config", "request", "transport", "identity", "cancel"]);
|
|
79819
|
+
function voiceGatewayStage(value) {
|
|
79820
|
+
return typeof value == "string" && VOICE_GATEWAY_STAGES.has(value) ? value : void 0;
|
|
79821
|
+
}
|
|
79229
79822
|
async function discoverHostClientChannel(directory2) {
|
|
79230
79823
|
let candidates = [];
|
|
79231
79824
|
for (let name2 of await readdir3(directory2).catch(() => []))
|
|
@@ -79340,16 +79933,23 @@ var HostClientChannel = class {
|
|
|
79340
79933
|
}, 1e3), this.retry.unref());
|
|
79341
79934
|
}
|
|
79342
79935
|
}
|
|
79343
|
-
|
|
79344
|
-
|
|
79936
|
+
bindVoiceExecution() {
|
|
79937
|
+
let generation = this.generation, port = this.descriptor.port, token = this.descriptor.token;
|
|
79938
|
+
return {
|
|
79939
|
+
generation,
|
|
79940
|
+
request: (method2, params) => this.post("/v1/rpc", { method: method2, params }, method2 === VOICE_GATEWAY_STATUS_METHOD ? VOICE_GATEWAY_STATUS_TIMEOUT_MS : method2 === REALTIME_CALL_METHOD ? REALTIME_CALL_TIMEOUT_MS : VOICE_SETTINGS_TIMEOUT_MS, { port, token })
|
|
79941
|
+
};
|
|
79942
|
+
}
|
|
79943
|
+
async post(route, body, timeoutMs = 12e4, bound) {
|
|
79944
|
+
if (!bound && (this.stopped || !this.online))
|
|
79345
79945
|
throw new Error("CH is disconnected; reconnect before submitting an operation");
|
|
79346
|
-
let generation = this.generation, response, value;
|
|
79946
|
+
let generation = this.generation, port = bound?.port ?? this.descriptor.port, token = bound?.token ?? this.descriptor.token, response, value;
|
|
79347
79947
|
try {
|
|
79348
|
-
response = await fetch(`http://127.0.0.1:${
|
|
79948
|
+
response = await fetch(`http://127.0.0.1:${port}${route}`, {
|
|
79349
79949
|
redirect: "error",
|
|
79350
79950
|
method: "POST",
|
|
79351
79951
|
headers: {
|
|
79352
|
-
authorization: `Bearer ${
|
|
79952
|
+
authorization: `Bearer ${token}`,
|
|
79353
79953
|
"content-type": "application/json"
|
|
79354
79954
|
},
|
|
79355
79955
|
body: JSON.stringify(body),
|
|
@@ -79359,17 +79959,23 @@ var HostClientChannel = class {
|
|
|
79359
79959
|
if (!parsed || typeof parsed != "object" || Array.isArray(parsed))
|
|
79360
79960
|
throw new Error("Invalid Host reply");
|
|
79361
79961
|
value = parsed;
|
|
79362
|
-
} catch {
|
|
79363
|
-
throw Object.assign(new Error(
|
|
79962
|
+
} catch (error51) {
|
|
79963
|
+
throw bound ? Object.assign(new Error(RENDERER_VOICE_HOST_CLEANUP_UNCONFIRMED), {
|
|
79964
|
+
code: -32093,
|
|
79965
|
+
stage: "cancel"
|
|
79966
|
+
}) : error51 && typeof error51 == "object" && "stage" in error51 ? error51 : Object.assign(new Error("CH connection lost; operation outcome may be unknown. Do not retry automatically."), { code: -32093 });
|
|
79364
79967
|
}
|
|
79365
|
-
if (generation !== this.generation || !this.online || this.stopped)
|
|
79968
|
+
if (!bound && (generation !== this.generation || !this.online || this.stopped))
|
|
79366
79969
|
throw Object.assign(new Error("Obsolete Host reply; resynchronize after reconnecting"), {
|
|
79367
79970
|
code: -32094
|
|
79368
79971
|
});
|
|
79369
|
-
if (value.error || !response.ok)
|
|
79370
|
-
|
|
79371
|
-
|
|
79972
|
+
if (value.error || !response.ok) {
|
|
79973
|
+
let error51 = value.error, data2 = error51 && typeof error51 == "object" && "data" in error51 ? error51.data : void 0, stage = data2 && typeof data2 == "object" && data2 !== null && "stage" in data2 ? voiceGatewayStage(data2.stage) : void 0;
|
|
79974
|
+
throw Object.assign(new Error(error51?.message ?? "Host request failed"), {
|
|
79975
|
+
code: error51?.code ?? -32603,
|
|
79976
|
+
...stage ? { stage } : {}
|
|
79372
79977
|
});
|
|
79978
|
+
}
|
|
79373
79979
|
if (!Object.hasOwn(value, "result"))
|
|
79374
79980
|
throw new Error("Invalid Host reply; operation outcome may be unknown");
|
|
79375
79981
|
return value.result;
|
|
@@ -79377,9 +79983,21 @@ var HostClientChannel = class {
|
|
|
79377
79983
|
request(method2, params) {
|
|
79378
79984
|
return this.post("/v1/rpc", { method: method2, params }, harnessInstallationRequestTimeoutMs(method2, params) ?? 12e4);
|
|
79379
79985
|
}
|
|
79986
|
+
requestVoiceSettings(params) {
|
|
79987
|
+
return this.post("/v1/rpc", { method: VOICE_SETTINGS_METHOD, params }, VOICE_SETTINGS_TIMEOUT_MS);
|
|
79988
|
+
}
|
|
79989
|
+
requestVoiceGatewayStatus() {
|
|
79990
|
+
return this.post("/v1/rpc", { method: VOICE_GATEWAY_STATUS_METHOD, params: {} }, VOICE_GATEWAY_STATUS_TIMEOUT_MS);
|
|
79991
|
+
}
|
|
79992
|
+
requestRealtimeCall(params) {
|
|
79993
|
+
return this.post("/v1/rpc", { method: REALTIME_CALL_METHOD, params }, REALTIME_CALL_TIMEOUT_MS);
|
|
79994
|
+
}
|
|
79380
79995
|
get epoch() {
|
|
79381
79996
|
return this.descriptor.epoch;
|
|
79382
79997
|
}
|
|
79998
|
+
get channelGeneration() {
|
|
79999
|
+
return this.generation;
|
|
80000
|
+
}
|
|
79383
80001
|
/** Options are opt-in; an older Host ignores them and returns full Turns. */
|
|
79384
80002
|
async snapshot(threadId, options = {}) {
|
|
79385
80003
|
let generation = this.generation, snapshot = clientThreadSnapshotSchema.parse(await this.post("/v1/snapshot", { ...options, threadId }));
|
|
@@ -79484,9 +80102,9 @@ var CdpConnectionClosedError = class extends Error {
|
|
|
79484
80102
|
};
|
|
79485
80103
|
function cdpExceptionMessage(details, fallback) {
|
|
79486
80104
|
let exception2 = details.exception;
|
|
79487
|
-
return
|
|
80105
|
+
return isRecord4(exception2) && typeof exception2.description == "string" && exception2.description ? exception2.description : typeof details.text == "string" && details.text ? details.text : fallback;
|
|
79488
80106
|
}
|
|
79489
|
-
function
|
|
80107
|
+
function isRecord4(value) {
|
|
79490
80108
|
return typeof value == "object" && value !== null && !Array.isArray(value);
|
|
79491
80109
|
}
|
|
79492
80110
|
function loopbackUrl(value, protocols) {
|
|
@@ -79501,7 +80119,7 @@ function optionalText(value) {
|
|
|
79501
80119
|
return typeof value == "string" && value.length > 0 ? value : null;
|
|
79502
80120
|
}
|
|
79503
80121
|
function parseTarget(value) {
|
|
79504
|
-
if (!
|
|
80122
|
+
if (!isRecord4(value))
|
|
79505
80123
|
throw new Error("CDP target must be an object");
|
|
79506
80124
|
let id = optionalText(value.id), type2 = optionalText(value.type), url2 = optionalText(value.url), webSocketDebuggerUrl = optionalText(value.webSocketDebuggerUrl);
|
|
79507
80125
|
return webSocketDebuggerUrl && loopbackUrl(webSocketDebuggerUrl, ["ws:", "wss:"]), !id || !type2 || !url2 || !webSocketDebuggerUrl ? null : {
|
|
@@ -79528,10 +80146,10 @@ function messageText(value) {
|
|
|
79528
80146
|
throw new Error("CDP WebSocket returned a non-text message");
|
|
79529
80147
|
}
|
|
79530
80148
|
function parseResponse(value) {
|
|
79531
|
-
if (!
|
|
80149
|
+
if (!isRecord4(value) || typeof value.id != "number")
|
|
79532
80150
|
return null;
|
|
79533
80151
|
let response = { id: value.id };
|
|
79534
|
-
return "result" in value && (response.result = value.result),
|
|
80152
|
+
return "result" in value && (response.result = value.result), isRecord4(value.error) && (response.error = {
|
|
79535
80153
|
...typeof value.error.code == "number" ? { code: value.error.code } : {},
|
|
79536
80154
|
...typeof value.error.message == "string" ? { message: value.error.message } : {}
|
|
79537
80155
|
}), response;
|
|
@@ -79589,7 +80207,7 @@ var CdpClient = class _CdpClient {
|
|
|
79589
80207
|
let id = this.#nextId++;
|
|
79590
80208
|
return new Promise((resolve20, reject) => {
|
|
79591
80209
|
let timeout = setTimeout(() => {
|
|
79592
|
-
this.#
|
|
80210
|
+
this.#disconnect(new CdpConnectionClosedError(`CDP command '${method2}' timed out`));
|
|
79593
80211
|
}, this.#commandTimeoutMs);
|
|
79594
80212
|
this.#pending.set(id, { resolve: resolve20, reject, timeout });
|
|
79595
80213
|
try {
|
|
@@ -79605,19 +80223,19 @@ var CdpClient = class _CdpClient {
|
|
|
79605
80223
|
awaitPromise: !0,
|
|
79606
80224
|
returnByValue: !0
|
|
79607
80225
|
});
|
|
79608
|
-
if (!
|
|
80226
|
+
if (!isRecord4(response))
|
|
79609
80227
|
throw new Error("Runtime.evaluate returned an invalid result");
|
|
79610
80228
|
try {
|
|
79611
|
-
if (
|
|
80229
|
+
if (isRecord4(response.exceptionDetails))
|
|
79612
80230
|
throw new Error(cdpExceptionMessage(response.exceptionDetails, "Renderer evaluation failed"));
|
|
79613
|
-
if (!
|
|
80231
|
+
if (!isRecord4(response.result) || !("value" in response.result))
|
|
79614
80232
|
throw new Error("Runtime.evaluate did not return a value");
|
|
79615
80233
|
return response.result.value;
|
|
79616
80234
|
} finally {
|
|
79617
80235
|
let objects = [
|
|
79618
80236
|
response.result,
|
|
79619
|
-
|
|
79620
|
-
], ids = new Set(objects.flatMap((object4) =>
|
|
80237
|
+
isRecord4(response.exceptionDetails) ? response.exceptionDetails.exception : void 0
|
|
80238
|
+
], ids = new Set(objects.flatMap((object4) => isRecord4(object4) && typeof object4.objectId == "string" ? [object4.objectId] : []));
|
|
79621
80239
|
await Promise.all([...ids].map((objectId) => this.command("Runtime.releaseObject", { objectId }).catch(() => {
|
|
79622
80240
|
})));
|
|
79623
80241
|
}
|
|
@@ -79632,7 +80250,7 @@ var CdpClient = class _CdpClient {
|
|
|
79632
80250
|
try {
|
|
79633
80251
|
let value = JSON.parse(messageText(event.data)), response = parseResponse(value);
|
|
79634
80252
|
if (!response) {
|
|
79635
|
-
if (!
|
|
80253
|
+
if (!isRecord4(value) || typeof value.method != "string")
|
|
79636
80254
|
return;
|
|
79637
80255
|
let sessionId = typeof value.sessionId == "string" ? value.sessionId : void 0;
|
|
79638
80256
|
for (let listener of this.#listeners.get(value.method) ?? [])
|
|
@@ -79833,7 +80451,7 @@ function retainRendererHostResponses(client, hostId2, target2) {
|
|
|
79833
80451
|
if (typeof client.addRequestLifecycleListener != "function" || typeof target2.addEventListener != "function" || typeof target2.removeEventListener != "function")
|
|
79834
80452
|
return () => {
|
|
79835
80453
|
};
|
|
79836
|
-
let
|
|
80454
|
+
let isRecord7 = (value) => typeof value == "object" && value !== null && !Array.isArray(value), pending = /* @__PURE__ */ new Set(), retired = !1, unsubscribe = () => {
|
|
79837
80455
|
}, detach = () => {
|
|
79838
80456
|
target2.removeEventListener?.("message", receive), unsubscribe();
|
|
79839
80457
|
}, receive = (event) => {
|
|
@@ -79841,21 +80459,21 @@ function retainRendererHostResponses(client, hostId2, target2) {
|
|
|
79841
80459
|
if (source != null && source !== target2)
|
|
79842
80460
|
return;
|
|
79843
80461
|
let ownOrigin = target2.location?.origin;
|
|
79844
|
-
if (source === target2 && ownOrigin && ownOrigin !== "null" && origin !== ownOrigin || !
|
|
80462
|
+
if (source === target2 && ownOrigin && ownOrigin !== "null" && origin !== ownOrigin || !isRecord7(data2) || data2.type !== "mcp-response" || data2.hostId !== hostId2)
|
|
79845
80463
|
return;
|
|
79846
80464
|
let message2 = data2.message;
|
|
79847
|
-
if (!
|
|
80465
|
+
if (!isRecord7(message2))
|
|
79848
80466
|
return;
|
|
79849
80467
|
let id = message2.id;
|
|
79850
80468
|
if (typeof id != "string" && typeof id != "number" || !pending.has(id))
|
|
79851
80469
|
return;
|
|
79852
|
-
let hasError =
|
|
80470
|
+
let hasError = isRecord7(message2.error);
|
|
79853
80471
|
!hasError && !Object.prototype.hasOwnProperty.call(message2, "result") || queueMicrotask(() => {
|
|
79854
80472
|
pending.has(id) && (hasError ? client.onError(id, message2.error, data2.hostMetrics) : client.onResult(id, message2.result, data2.hostMetrics));
|
|
79855
80473
|
});
|
|
79856
80474
|
};
|
|
79857
80475
|
return target2.addEventListener("message", receive), unsubscribe = client.addRequestLifecycleListener((event) => {
|
|
79858
|
-
if (!
|
|
80476
|
+
if (!isRecord7(event) || event.hostId !== hostId2)
|
|
79859
80477
|
return;
|
|
79860
80478
|
let id = event.id;
|
|
79861
80479
|
typeof id != "string" && typeof id != "number" || (!retired && event.type === "started" && typeof event.method == "string" && event.method.startsWith("codexhost/") ? pending.add(id) : (event.type === "completed" || event.type === "failed") && (pending.delete(id), retired && pending.size === 0 && detach()));
|
|
@@ -79940,9 +80558,9 @@ function isolateRendererPrewarmConsumption(manager, discardExternal) {
|
|
|
79940
80558
|
|
|
79941
80559
|
// packages/desktop-control/dist/renderer-draft-prewarm-runtime.js
|
|
79942
80560
|
function createDraftPrewarmPolicyBridge(manager, bridge2, hostId2, target2, prewarmedThreadManager, isCurrentManager, retainResponses = retainRendererHostResponses, isolateConsumption = isolateRendererPrewarmConsumption, sendControlRequest) {
|
|
79943
|
-
let disposed = !1, originalSend = bridge2.sendRequest, controlSend = (method2, parameters) => sendControlRequest ? sendControlRequest(method2, parameters) : originalSend.call(bridge2, method2, parameters), originalPrewarm = bridge2.prewarmThreadStart, originalOnNotification = manager.onNotification, originalDispatchAppServerResponse = manager.dispatchAppServerResponse, selectedModel = null, prewarmGeneration = 0, externalPrewarms = /* @__PURE__ */ new Set(),
|
|
80561
|
+
let disposed = !1, originalSend = bridge2.sendRequest, controlSend = (method2, parameters) => sendControlRequest ? sendControlRequest(method2, parameters) : originalSend.call(bridge2, method2, parameters), originalPrewarm = bridge2.prewarmThreadStart, originalOnNotification = manager.onNotification, originalDispatchAppServerResponse = manager.dispatchAppServerResponse, selectedModel = null, prewarmGeneration = 0, externalPrewarms = /* @__PURE__ */ new Set(), isRecord7 = (value) => typeof value == "object" && value !== null && !Array.isArray(value), isUnsupportedPosixBridgeSpawn = (value) => {
|
|
79944
80562
|
let marker = "AbsolutePathBuf deserialized without a base path";
|
|
79945
|
-
return typeof value == "string" ? value.startsWith("Invalid request:") && value.includes(marker) :
|
|
80563
|
+
return typeof value == "string" ? value.startsWith("Invalid request:") && value.includes(marker) : isRecord7(value) ? typeof value.message == "string" && value.message.includes(marker) && (value.code === -32600 || value.message.startsWith("Invalid request:")) ? !0 : value.cause !== value && isUnsupportedPosixBridgeSpawn(value.cause) : !1;
|
|
79946
80564
|
}, isRemoteControlHost = hostId2.startsWith("remote-control:"), retireResponses = isRemoteControlHost ? () => {
|
|
79947
80565
|
} : retainResponses(bridge2, hostId2, target2), knownExternalThreadIds = /* @__PURE__ */ new Set(), knownOfficialThreadIds = /* @__PURE__ */ new Set(), threadOwnershipResolutions = /* @__PURE__ */ new Map(), createBridgeProcessHandle = () => `codexhost-${typeof crypto?.randomUUID == "function" ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`}`, bridgeProcessHandle = createBridgeProcessHandle(), bridgeReadyMethod = "codexhost/remote-control-bridge/ready", bridgeRequests = /* @__PURE__ */ new Map(), bridgeServerRequestIdPrefix = "codexhost/remote-control-bridge/server-request/", bridgeServerRequests = /* @__PURE__ */ new Map(), nextBridgeServerRequestOrdinal = 1, outputDecoders = {
|
|
79948
80566
|
stdout: new TextDecoder(),
|
|
@@ -79976,9 +80594,9 @@ function createDraftPrewarmPolicyBridge(manager, bridge2, hostId2, target2, prew
|
|
|
79976
80594
|
}, resetFailedBridge = () => {
|
|
79977
80595
|
bridgeState === "failed" && (bridgeProcessHandle = createBridgeProcessHandle(), outputDecoders = { stdout: new TextDecoder(), stderr: new TextDecoder() }, outputBuffers.stdout = "", outputBuffers.stderr = "", bridgeReadyPromise = null, bridgeReadyResolve = null, bridgeReadyReject = null, bridgeInitialization = null, writeTail = Promise.resolve(), bridgeServerRequests.clear(), nextBridgeServerRequestOrdinal = 1, bridgeState = "idle");
|
|
79978
80596
|
}, rememberExternalThread = (value) => {
|
|
79979
|
-
!
|
|
80597
|
+
!isRecord7(value) || typeof value.id != "string" || (value.modelProvider === "codexhost" || value.cliVersion === "codexhost") && (knownExternalThreadIds.add(value.id), knownOfficialThreadIds.delete(value.id));
|
|
79980
80598
|
}, observeBridgeResult = (request2, result) => {
|
|
79981
|
-
if (!(!request2 || !
|
|
80599
|
+
if (!(!request2 || !isRecord7(result))) {
|
|
79982
80600
|
if (request2.method === "thread/list" && Array.isArray(result.data)) {
|
|
79983
80601
|
for (let thread2 of result.data)
|
|
79984
80602
|
rememberExternalThread(thread2);
|
|
@@ -79988,23 +80606,23 @@ function createDraftPrewarmPolicyBridge(manager, bridge2, hostId2, target2, prew
|
|
|
79988
80606
|
rememberExternalThread(result.thread);
|
|
79989
80607
|
return;
|
|
79990
80608
|
}
|
|
79991
|
-
if (request2.method === "codexhost/thread/inspect" &&
|
|
80609
|
+
if (request2.method === "codexhost/thread/inspect" && isRecord7(request2.parameters) && typeof request2.parameters.threadId == "string") {
|
|
79992
80610
|
result.owner === "external" ? (knownExternalThreadIds.add(request2.parameters.threadId), knownOfficialThreadIds.delete(request2.parameters.threadId)) : result.owner === "codex" && (knownOfficialThreadIds.add(request2.parameters.threadId), knownExternalThreadIds.delete(request2.parameters.threadId));
|
|
79993
80611
|
return;
|
|
79994
80612
|
}
|
|
79995
|
-
request2.method === "thread/delete" &&
|
|
80613
|
+
request2.method === "thread/delete" && isRecord7(request2.parameters) && typeof request2.parameters.threadId == "string" && (knownExternalThreadIds.delete(request2.parameters.threadId), knownOfficialThreadIds.delete(request2.parameters.threadId));
|
|
79996
80614
|
}
|
|
79997
80615
|
}, handleBridgeFrame = (value) => {
|
|
79998
|
-
if (!
|
|
80616
|
+
if (!isRecord7(value)) {
|
|
79999
80617
|
failBridge("received a non-object app-server frame");
|
|
80000
80618
|
return;
|
|
80001
80619
|
}
|
|
80002
80620
|
if (value.method === bridgeReadyMethod && value.id === void 0) {
|
|
80003
|
-
|
|
80621
|
+
isRecord7(value.params) && value.params.protocolVersion === 1 ? (bridgeState = "ready", bridgeReadyTimeout !== null && globalThis.clearTimeout(bridgeReadyTimeout), bridgeReadyTimeout = null, bridgeReadyResolve?.(), bridgeReadyResolve = null, bridgeReadyReject = null) : failBridge("reported an unsupported protocol version");
|
|
80004
80622
|
return;
|
|
80005
80623
|
}
|
|
80006
80624
|
if (typeof value.method == "string" && value.id === void 0) {
|
|
80007
|
-
value.method === "thread/started" &&
|
|
80625
|
+
value.method === "thread/started" && isRecord7(value.params) && rememberExternalThread(value.params.thread), originalOnNotification.call(manager, value.method, value.params);
|
|
80008
80626
|
return;
|
|
80009
80627
|
}
|
|
80010
80628
|
if (typeof value.method == "string" && value.id !== void 0) {
|
|
@@ -80043,11 +80661,11 @@ function createDraftPrewarmPolicyBridge(manager, bridge2, hostId2, target2, prew
|
|
|
80043
80661
|
}
|
|
80044
80662
|
}
|
|
80045
80663
|
}, handleOuterNotification = (method2, parameters) => {
|
|
80046
|
-
if (method2 === "process/exited" &&
|
|
80664
|
+
if (method2 === "process/exited" && isRecord7(parameters) && parameters.processHandle === bridgeProcessHandle) {
|
|
80047
80665
|
let exitCode = typeof parameters.exitCode == "number" ? parameters.exitCode : "unknown", stderr = typeof parameters.stderr == "string" ? parameters.stderr.trim() : "";
|
|
80048
80666
|
return failBridge(`process exited unexpectedly with code ${exitCode}${stderr ? `: ${stderr}` : ""}`, !1), !0;
|
|
80049
80667
|
}
|
|
80050
|
-
return method2 !== "process/outputDelta" || !
|
|
80668
|
+
return method2 !== "process/outputDelta" || !isRecord7(parameters) || parameters.processHandle !== bridgeProcessHandle || parameters.stream !== "stdout" && parameters.stream !== "stderr" || typeof parameters.deltaBase64 != "string" ? !1 : parameters.capReached === !0 ? (failBridge(`${parameters.stream} was truncated`), !0) : (consumeBridgeOutput(parameters.stream, parameters.deltaBase64), !0);
|
|
80051
80669
|
}, startBridge = () => {
|
|
80052
80670
|
if (!isRemoteControlHost)
|
|
80053
80671
|
return Promise.resolve();
|
|
@@ -80119,7 +80737,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge2, hostId2, target2, prew
|
|
|
80119
80737
|
});
|
|
80120
80738
|
});
|
|
80121
80739
|
}, initializeBridge = () => (resetFailedBridge(), bridgeInitialization || (bridgeInitialization = startBridge().then(() => initializeBridgeProtocol()).then(() => writeBridgeFrame({ method: "initialized", params: {} })), bridgeInitialization)), threadIdFromParameters = (parameters) => {
|
|
80122
|
-
if (!
|
|
80740
|
+
if (!isRecord7(parameters))
|
|
80123
80741
|
return null;
|
|
80124
80742
|
let value = parameters.threadId ?? parameters.conversationId;
|
|
80125
80743
|
return typeof value == "string" ? value : null;
|
|
@@ -80134,8 +80752,8 @@ function createDraftPrewarmPolicyBridge(manager, bridge2, hostId2, target2, prew
|
|
|
80134
80752
|
let resolution = initializeBridge().then(() => enqueueBridgeRequest("codexhost/thread/ownership/list", {
|
|
80135
80753
|
threadIds: [threadId]
|
|
80136
80754
|
})).then((value) => {
|
|
80137
|
-
let ownerships =
|
|
80138
|
-
if (!ownerships || !
|
|
80755
|
+
let ownerships = isRecord7(value) && Array.isArray(value.threads) ? value.threads : null, ownership = ownerships?.[0];
|
|
80756
|
+
if (!ownerships || !isRecord7(ownership) || ownerships.length !== 1 || ownership.threadId !== threadId || ownership.owner !== "external" && ownership.owner !== "codex")
|
|
80139
80757
|
throw transportError("Thread ownership lookup returned an invalid result");
|
|
80140
80758
|
return ownership.owner === "external" ? (knownExternalThreadIds.add(threadId), knownOfficialThreadIds.delete(threadId), "external") : (knownOfficialThreadIds.add(threadId), knownExternalThreadIds.delete(threadId), "codex");
|
|
80141
80759
|
});
|
|
@@ -80155,7 +80773,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge2, hostId2, target2, prew
|
|
|
80155
80773
|
if (method2.startsWith("codexhost/") || method2 === "thread/list")
|
|
80156
80774
|
return !0;
|
|
80157
80775
|
if (method2 === "thread/start")
|
|
80158
|
-
return
|
|
80776
|
+
return isRecord7(parameters) && typeof parameters.model == "string" && parameters.model.startsWith("codexhost/");
|
|
80159
80777
|
let threadId = threadIdFromParameters(parameters);
|
|
80160
80778
|
return threadId && knownExternalThreadIds.has(threadId) ? !0 : threadId && knownOfficialThreadIds.has(threadId) ? !1 : selectedModel !== null && (method2.startsWith("thread/") || method2.startsWith("turn/") || method2.startsWith("review/"));
|
|
80161
80779
|
}, routedSend = (method2, parameters, options) => {
|
|
@@ -80170,12 +80788,12 @@ function createDraftPrewarmPolicyBridge(manager, bridge2, hostId2, target2, prew
|
|
|
80170
80788
|
throw error51;
|
|
80171
80789
|
}) : shouldUseBridge(method2, parameters) ? sendBridged() : sendDirect();
|
|
80172
80790
|
}, publishDraftWorkspace = (parameters) => {
|
|
80173
|
-
if (!
|
|
80791
|
+
if (!isRecord7(parameters) || parameters.ephemeral === !0)
|
|
80174
80792
|
return;
|
|
80175
80793
|
let cwd = parameters.cwd;
|
|
80176
80794
|
if (typeof cwd != "string" || cwd.length === 0)
|
|
80177
80795
|
return;
|
|
80178
|
-
let drafts =
|
|
80796
|
+
let drafts = isRecord7(target2.__codexhostDraftWorkspacesV1) ? target2.__codexhostDraftWorkspacesV1 : {};
|
|
80179
80797
|
drafts[hostId2] = cwd, Object.defineProperty(target2, "__codexhostDraftWorkspacesV1", {
|
|
80180
80798
|
configurable: !0,
|
|
80181
80799
|
value: drafts
|
|
@@ -80191,11 +80809,11 @@ function createDraftPrewarmPolicyBridge(manager, bridge2, hostId2, target2, prew
|
|
|
80191
80809
|
for (let threadId of externalPrewarms)
|
|
80192
80810
|
discardExternalPrewarm(threadId);
|
|
80193
80811
|
}, restoreConsumption = isolateConsumption(manager, discardExternalPrewarm), routedPrewarm = (parameters, options) => {
|
|
80194
|
-
let external =
|
|
80812
|
+
let external = isRecord7(parameters) && parameters.ephemeral !== !0 && typeof parameters.model == "string" && parameters.model.startsWith("codexhost/"), routedParameters = external ? { ...parameters, codexhostPrewarm: !0 } : parameters, generation = prewarmGeneration;
|
|
80195
80813
|
publishDraftWorkspace(routedParameters);
|
|
80196
80814
|
let pending = shouldUseBridge("thread/start", routedParameters) ? routedSend("thread/start", routedParameters, options) : options === void 0 ? originalPrewarm.call(bridge2, routedParameters) : originalPrewarm.call(bridge2, routedParameters, options);
|
|
80197
|
-
return
|
|
80198
|
-
let threadId = external &&
|
|
80815
|
+
return isRecord7(parameters) && parameters.ephemeral === !0 || typeof pending != "object" && typeof pending != "function" || pending === null || typeof Reflect.get(pending, "then") != "function" ? pending : Promise.resolve(pending).then((result) => {
|
|
80816
|
+
let threadId = external && isRecord7(result) && isRecord7(result.thread) && typeof result.thread.id == "string" ? result.thread.id : null;
|
|
80199
80817
|
if (disposed || generation !== prewarmGeneration)
|
|
80200
80818
|
throw threadId && discardExternalPrewarm(threadId), new Error("Renderer draft prewarm was invalidated by a configuration change");
|
|
80201
80819
|
return threadId && externalPrewarms.add(threadId), publishDraftWorkspace(routedParameters), result;
|
|
@@ -80204,7 +80822,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge2, hostId2, target2, prew
|
|
|
80204
80822
|
bridge2.sendRequest = routedSend, bridge2.prewarmThreadStart = routedPrewarm;
|
|
80205
80823
|
let routedWindowMessage = (event) => {
|
|
80206
80824
|
let message2 = event.data;
|
|
80207
|
-
!
|
|
80825
|
+
!isRecord7(message2) || message2.type !== "mcp-notification" || message2.hostId !== hostId2 || typeof message2.method != "string" || handleOuterNotification(message2.method, message2.params);
|
|
80208
80826
|
}, observesWindowNotifications = isRemoteControlHost && typeof target2.addEventListener == "function" && typeof target2.removeEventListener == "function";
|
|
80209
80827
|
observesWindowNotifications && target2.addEventListener?.("message", routedWindowMessage);
|
|
80210
80828
|
let routedOnNotification = (method2, parameters) => {
|
|
@@ -80612,13 +81230,13 @@ function installRendererHostRpcRouting(root, target2, dependencies) {
|
|
|
80612
81230
|
} catch {
|
|
80613
81231
|
return null;
|
|
80614
81232
|
}
|
|
80615
|
-
}, sameConnection = (previous, current) => previous === void 0 ? current === void 0 : current?.owner === previous.owner && current.revision === previous.revision,
|
|
81233
|
+
}, sameConnection = (previous, current) => previous === void 0 ? current === void 0 : current?.owner === previous.owner && current.revision === previous.revision, isRecord7 = (value) => typeof value == "object" && value !== null && !Array.isArray(value), externalDrafts = /* @__PURE__ */ new Map(), selectedModels = /* @__PURE__ */ new Map(), prewarmCarrier = (carrier) => {
|
|
80616
81234
|
let prefix = "codexhost/plugin-v1@";
|
|
80617
81235
|
if (!carrier.startsWith(prefix))
|
|
80618
81236
|
return null;
|
|
80619
81237
|
try {
|
|
80620
81238
|
let json3 = carrier.slice(prefix.length).replace(/[a-f0-9]{2}/gu, (byte) => String.fromCharCode(Number.parseInt(byte, 16))), route = JSON.parse(json3);
|
|
80621
|
-
if (!
|
|
81239
|
+
if (!isRecord7(route))
|
|
80622
81240
|
return null;
|
|
80623
81241
|
let payload = [...JSON.stringify({ ...route, prewarm: !0 })].map((character) => character.charCodeAt(0).toString(16).padStart(2, "0")).join("");
|
|
80624
81242
|
return `${prefix}${payload}`;
|
|
@@ -80628,7 +81246,7 @@ function installRendererHostRpcRouting(root, target2, dependencies) {
|
|
|
80628
81246
|
}, publishDraftWorkspace = (hostId2, cwd) => {
|
|
80629
81247
|
if (typeof cwd != "string" || cwd.length === 0)
|
|
80630
81248
|
return;
|
|
80631
|
-
let drafts =
|
|
81249
|
+
let drafts = isRecord7(target2.__codexhostDraftWorkspacesV1) ? target2.__codexhostDraftWorkspacesV1 : {};
|
|
80632
81250
|
drafts[hostId2] !== cwd && (drafts[hostId2] = cwd, Object.defineProperty(target2, "__codexhostDraftWorkspacesV1", {
|
|
80633
81251
|
configurable: !0,
|
|
80634
81252
|
value: drafts
|
|
@@ -80643,14 +81261,14 @@ function installRendererHostRpcRouting(root, target2, dependencies) {
|
|
|
80643
81261
|
if (!Array.isArray(path8) || path8.length !== 1 || !Array.isArray(args))
|
|
80644
81262
|
return message2;
|
|
80645
81263
|
let [input, options] = args;
|
|
80646
|
-
if (!
|
|
81264
|
+
if (!isRecord7(input) || !isRecord7(input.collaborationMode))
|
|
80647
81265
|
return message2;
|
|
80648
81266
|
let settings2 = input.collaborationMode.settings;
|
|
80649
|
-
if (!
|
|
81267
|
+
if (!isRecord7(settings2))
|
|
80650
81268
|
return message2;
|
|
80651
81269
|
let nativeModel = typeof settings2.model == "string" ? settings2.model : null, model2 = null;
|
|
80652
81270
|
if (path8[0] === "startConversation") {
|
|
80653
|
-
let draftId =
|
|
81271
|
+
let draftId = isRecord7(options) ? options.clientThreadId : null;
|
|
80654
81272
|
model2 = typeof draftId == "string" ? externalDrafts.get(draftId)?.model ?? null : null;
|
|
80655
81273
|
} else if (path8[0] === "prewarmConversation") {
|
|
80656
81274
|
input.ephemeral !== !0 && publishDraftWorkspace("local", input.cwd);
|
|
@@ -80724,7 +81342,7 @@ function installRendererHostRpcRouting(root, target2, dependencies) {
|
|
|
80724
81342
|
addNotificationCallback(methods2, listener) {
|
|
80725
81343
|
let accepted = new Set(typeof methods2 == "string" ? [methods2] : methods2), onMessage = (event) => {
|
|
80726
81344
|
let { source, data: data2 } = event;
|
|
80727
|
-
source != null && source !== target2 || !
|
|
81345
|
+
source != null && source !== target2 || !isRecord7(data2) || data2.type !== "mcp-notification" || data2.hostId !== hostId2 || typeof data2.method != "string" || !accepted.has(data2.method) || !isCurrent() || listener({ method: data2.method, params: data2.params });
|
|
80728
81346
|
};
|
|
80729
81347
|
return target2.addEventListener?.("message", onMessage), () => target2.removeEventListener?.("message", onMessage);
|
|
80730
81348
|
}
|
|
@@ -80968,6 +81586,9 @@ function installRendererDraftPrewarmPolicyDirect(renderer) {
|
|
|
80968
81586
|
// packages/desktop-control/dist/renderer-control-session.js
|
|
80969
81587
|
var startupTraceStartedAt = Date.now();
|
|
80970
81588
|
|
|
81589
|
+
// packages/desktop-control/dist/renderer-cdp-control-session.js
|
|
81590
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
81591
|
+
|
|
80971
81592
|
// packages/desktop-control/dist/cpa-live-voice-hook.js
|
|
80972
81593
|
var CPA_LIVE_VOICE_HOOK_GLOBAL = "__codexhostCpaLiveVoiceHookV1";
|
|
80973
81594
|
|
|
@@ -81684,7 +82305,7 @@ async function installRendererRpcSteeringDirect(client, now = Date.now) {
|
|
|
81684
82305
|
try {
|
|
81685
82306
|
if (!await client.evaluate(`(() => {
|
|
81686
82307
|
const steering = window.__codexhostRpcSteeringV1;
|
|
81687
|
-
if (steering && steering.controller.forHost === steering.forHost) return false;
|
|
82308
|
+
if (steering && (steering.owns?.() ?? steering.controller.forHost === steering.forHost)) return false;
|
|
81688
82309
|
steering?.release();
|
|
81689
82310
|
const routing=window.__codexhostHostRoutingV1;
|
|
81690
82311
|
return ['local', ...(routing?.knownHostIds?.() ?? [])].some(id => routing?.forHost(id)?.manager.kind === 'main-process-rpc');
|
|
@@ -81767,7 +82388,7 @@ async function discoverAndInstall(client) {
|
|
|
81767
82388
|
}
|
|
81768
82389
|
|
|
81769
82390
|
// packages/desktop-control/dist/renderer-cdp-control-session.js
|
|
81770
|
-
function
|
|
82391
|
+
function isRecord5(value) {
|
|
81771
82392
|
return typeof value == "object" && value !== null && !Array.isArray(value);
|
|
81772
82393
|
}
|
|
81773
82394
|
function sleep2(milliseconds) {
|
|
@@ -81809,22 +82430,6 @@ function sameAgents(actual, expected) {
|
|
|
81809
82430
|
let expectedSet = new Set(expected);
|
|
81810
82431
|
return actual.length === expected.length && actual.every((agent) => expectedSet.has(agent));
|
|
81811
82432
|
}
|
|
81812
|
-
function parseCodexAppUrl(value) {
|
|
81813
|
-
try {
|
|
81814
|
-
let url2 = new URL(value);
|
|
81815
|
-
return url2.protocol === "app:" && url2.hostname === "-" ? url2 : null;
|
|
81816
|
-
} catch {
|
|
81817
|
-
return null;
|
|
81818
|
-
}
|
|
81819
|
-
}
|
|
81820
|
-
function isPrimaryRendererUrl(value) {
|
|
81821
|
-
let url2 = parseCodexAppUrl(value);
|
|
81822
|
-
return url2 !== null && url2.pathname === "/index.html" && url2.search === "" && url2.hash === "";
|
|
81823
|
-
}
|
|
81824
|
-
function isAvatarOverlayRendererUrl(value) {
|
|
81825
|
-
let url2 = parseCodexAppUrl(value);
|
|
81826
|
-
return url2 ? url2.pathname === "/avatar-overlay.html" ? !0 : url2.pathname === "/index.html" && url2.searchParams.get("initialRoute") === "/avatar-overlay" : !1;
|
|
81827
|
-
}
|
|
81828
82433
|
function selectPrimaryRendererTarget(targets, preferredTargetId) {
|
|
81829
82434
|
let candidates = targets.filter((target2) => target2.type === "page" && isPrimaryRendererUrl(target2.url));
|
|
81830
82435
|
return candidates.find((target2) => target2.id === preferredTargetId) ?? candidates.at(0) ?? null;
|
|
@@ -81840,7 +82445,7 @@ var RendererAdapterReadinessError = class extends Error {
|
|
|
81840
82445
|
}
|
|
81841
82446
|
};
|
|
81842
82447
|
function validateBindingStatus(value, expectedAgents) {
|
|
81843
|
-
if (!
|
|
82448
|
+
if (!isRecord5(value) || value.version !== 2 || !Array.isArray(value.enabledAgents) || value.enabledAgents.some((agent) => typeof agent != "string") || !sameAgents(value.enabledAgents, expectedAgents) || !isRecord5(value.adapter))
|
|
81844
82449
|
throw new Error("Production Renderer binding returned an invalid status");
|
|
81845
82450
|
if (value.adapter.state !== "ready" || typeof value.adapter.reason != "string") {
|
|
81846
82451
|
let state = typeof value.adapter.state == "string" ? value.adapter.state : "invalid", reason = typeof value.adapter.reason == "string" ? value.adapter.reason : "unknown";
|
|
@@ -81872,14 +82477,20 @@ async function waitForPrimaryTarget(endpoint, operations, timeoutMs, pollInterva
|
|
|
81872
82477
|
let detail = lastError instanceof Error ? `: ${lastError.message}` : "";
|
|
81873
82478
|
throw new Error(`Primary Codex Renderer CDP target did not become ready${detail}`);
|
|
81874
82479
|
}
|
|
82480
|
+
async function bindRendererVoiceHost(renderer, voiceHost, disposals, options) {
|
|
82481
|
+
voiceHost && (disposals.get(renderer)?.(), disposals.set(renderer, await installRendererVoiceHostBinding(renderer, voiceHost, options)));
|
|
82482
|
+
}
|
|
82483
|
+
function unbindRendererVoiceHost(renderer, disposals) {
|
|
82484
|
+
disposals.get(renderer)?.(), disposals.delete(renderer);
|
|
82485
|
+
}
|
|
81875
82486
|
async function evaluateSource(renderer, source) {
|
|
81876
82487
|
let response = await renderer.command("Runtime.evaluate", {
|
|
81877
82488
|
expression: source,
|
|
81878
82489
|
awaitPromise: !0
|
|
81879
82490
|
});
|
|
81880
|
-
if (!
|
|
82491
|
+
if (!isRecord5(response))
|
|
81881
82492
|
throw new Error("Renderer source evaluation returned an invalid result");
|
|
81882
|
-
if (
|
|
82493
|
+
if (isRecord5(response.exceptionDetails))
|
|
81883
82494
|
throw new Error(cdpExceptionMessage(response.exceptionDetails, "Renderer source evaluation failed"));
|
|
81884
82495
|
}
|
|
81885
82496
|
async function readBinding(renderer) {
|
|
@@ -81903,21 +82514,173 @@ async function waitForBinding(renderer, enabledAgents, timeoutMs, pollIntervalMs
|
|
|
81903
82514
|
let detail = lastError instanceof Error ? `: ${lastError.message}` : "";
|
|
81904
82515
|
throw new Error(`Production Renderer binding did not become ready${detail}`);
|
|
81905
82516
|
}
|
|
81906
|
-
|
|
81907
|
-
|
|
81908
|
-
|
|
81909
|
-
|
|
81910
|
-
|
|
81911
|
-
|
|
82517
|
+
var overlayInstallState = /* @__PURE__ */ new WeakMap(), OVERLAY_HOOK_SNAPSHOT_EXPRESSION = `(() => { /*__codexhostOverlayHookSnapshot*/
|
|
82518
|
+
const cpa = globalThis.${CPA_LIVE_VOICE_HOOK_GLOBAL};
|
|
82519
|
+
const native = globalThis.__codexhostNativeChatVoiceV1;
|
|
82520
|
+
const labels =
|
|
82521
|
+
typeof document !== "undefined" && document.querySelectorAll
|
|
82522
|
+
? [...document.querySelectorAll("button")].map((button) =>
|
|
82523
|
+
(button.getAttribute("aria-label") || "").toLowerCase(),
|
|
82524
|
+
)
|
|
82525
|
+
: [];
|
|
82526
|
+
let call = "unknown";
|
|
82527
|
+
if (native && native.activeCall === true) call = "active";
|
|
82528
|
+
else if (labels.some((label) => label === "end voice" || label === "end voice chat"))
|
|
82529
|
+
call = "active";
|
|
82530
|
+
else if (native && native.activeCall === false) call = "idle";
|
|
82531
|
+
else if (labels.some((label) => label.includes("start voice"))) call = "idle";
|
|
82532
|
+
const isolated =
|
|
82533
|
+
cpa && typeof cpa === "object" && "isolatedQualification" in cpa
|
|
82534
|
+
? cpa.isolatedQualification
|
|
82535
|
+
: undefined;
|
|
82536
|
+
return {
|
|
82537
|
+
enabled: Boolean(cpa && typeof cpa === "object" && cpa.enabled === true),
|
|
82538
|
+
revision: typeof cpa?.implementationRevision === "string" ? cpa.implementationRevision : null,
|
|
82539
|
+
isolatedPath:
|
|
82540
|
+
isolated && typeof isolated === "object" && typeof isolated.path === "string"
|
|
82541
|
+
? isolated.path
|
|
82542
|
+
: null,
|
|
82543
|
+
isolatedPaths: (() => {
|
|
82544
|
+
if (!isolated || typeof isolated !== "object") return null;
|
|
82545
|
+
const listed = Array.isArray(isolated.paths)
|
|
82546
|
+
? isolated.paths
|
|
82547
|
+
: typeof isolated.path === "string"
|
|
82548
|
+
? [isolated.path]
|
|
82549
|
+
: [];
|
|
82550
|
+
const unique = ["chat", "work-codex", "work-grok"].filter((path) => listed.includes(path));
|
|
82551
|
+
return unique.length ? unique : null;
|
|
82552
|
+
})(),
|
|
82553
|
+
isolatedRun:
|
|
82554
|
+
isolated && typeof isolated === "object" && typeof isolated.run === "string"
|
|
82555
|
+
? isolated.run
|
|
82556
|
+
: null,
|
|
82557
|
+
isolatedExpiresAt:
|
|
82558
|
+
isolated && typeof isolated === "object" && typeof isolated.expiresAt === "string"
|
|
82559
|
+
? isolated.expiresAt
|
|
82560
|
+
: null,
|
|
82561
|
+
isolatedPlatform:
|
|
82562
|
+
isolated && typeof isolated === "object" && typeof isolated.desktopPlatform === "string"
|
|
82563
|
+
? isolated.desktopPlatform
|
|
82564
|
+
: null,
|
|
82565
|
+
appPath: typeof cpa?.desktopAppPath === "string" ? cpa.desktopAppPath : null,
|
|
82566
|
+
call,
|
|
82567
|
+
};
|
|
82568
|
+
})()`;
|
|
82569
|
+
function overlaySourceDigest(source) {
|
|
82570
|
+
return createHash8("sha256").update(source).digest("hex");
|
|
82571
|
+
}
|
|
82572
|
+
function emptyOverlaySnapshot(enabled, call = "unknown") {
|
|
82573
|
+
return {
|
|
82574
|
+
enabled,
|
|
82575
|
+
revision: null,
|
|
82576
|
+
isolatedPath: null,
|
|
82577
|
+
isolatedPaths: null,
|
|
82578
|
+
isolatedRun: null,
|
|
82579
|
+
isolatedExpiresAt: null,
|
|
82580
|
+
isolatedPlatform: null,
|
|
82581
|
+
appPath: null,
|
|
82582
|
+
call
|
|
82583
|
+
};
|
|
81912
82584
|
}
|
|
81913
|
-
|
|
81914
|
-
let
|
|
82585
|
+
function overlayIdentityFromSource(source) {
|
|
82586
|
+
let needle = `globalThis.${CPA_LIVE_VOICE_HOOK_GLOBAL} = Object.freeze(`, start = source.indexOf(needle);
|
|
82587
|
+
if (start < 0)
|
|
82588
|
+
return;
|
|
82589
|
+
let json3 = source.slice(start + needle.length), end = json3.indexOf(");");
|
|
82590
|
+
if (!(end < 0))
|
|
82591
|
+
try {
|
|
82592
|
+
let parsed = JSON.parse(json3.slice(0, end));
|
|
82593
|
+
if (!isRecord5(parsed))
|
|
82594
|
+
return;
|
|
82595
|
+
let isolated = parsed.isolatedQualification;
|
|
82596
|
+
return {
|
|
82597
|
+
enabled: parsed.enabled === !0,
|
|
82598
|
+
revision: typeof parsed.implementationRevision == "string" ? parsed.implementationRevision : null,
|
|
82599
|
+
isolatedPath: isRecord5(isolated) && typeof isolated.path == "string" ? isolated.path : null,
|
|
82600
|
+
isolatedPaths: (() => {
|
|
82601
|
+
if (!isRecord5(isolated))
|
|
82602
|
+
return null;
|
|
82603
|
+
let listed = Array.isArray(isolated.paths) ? isolated.paths : typeof isolated.path == "string" ? [isolated.path] : [], unique = ["chat", "work-codex", "work-grok"].filter((path8) => listed.includes(path8));
|
|
82604
|
+
return unique.length ? unique : null;
|
|
82605
|
+
})(),
|
|
82606
|
+
isolatedRun: isRecord5(isolated) && typeof isolated.run == "string" ? isolated.run : null,
|
|
82607
|
+
isolatedExpiresAt: isRecord5(isolated) && typeof isolated.expiresAt == "string" ? isolated.expiresAt : null,
|
|
82608
|
+
isolatedPlatform: isRecord5(isolated) && typeof isolated.desktopPlatform == "string" ? isolated.desktopPlatform : null,
|
|
82609
|
+
appPath: typeof parsed.desktopAppPath == "string" ? parsed.desktopAppPath : null,
|
|
82610
|
+
call: "idle"
|
|
82611
|
+
};
|
|
82612
|
+
} catch {
|
|
82613
|
+
return;
|
|
82614
|
+
}
|
|
82615
|
+
}
|
|
82616
|
+
function overlayIsolatedPaths(snapshot) {
|
|
82617
|
+
return snapshot.isolatedPaths && snapshot.isolatedPaths.length > 0 ? snapshot.isolatedPaths : snapshot.isolatedPath ? [snapshot.isolatedPath] : null;
|
|
82618
|
+
}
|
|
82619
|
+
function overlayIdentitiesMatch(live, desired) {
|
|
82620
|
+
return live.enabled === !0 && live.revision === desired.revision && live.isolatedPath === desired.isolatedPath && JSON.stringify(overlayIsolatedPaths(live)) === JSON.stringify(overlayIsolatedPaths(desired)) && live.isolatedRun === desired.isolatedRun && live.isolatedExpiresAt === desired.isolatedExpiresAt && live.isolatedPlatform === desired.isolatedPlatform && live.appPath === desired.appPath;
|
|
82621
|
+
}
|
|
82622
|
+
function readOverlayHookSnapshot(value) {
|
|
82623
|
+
if (value === !0)
|
|
82624
|
+
return emptyOverlaySnapshot(!0);
|
|
82625
|
+
if (value === !1 || value == null)
|
|
82626
|
+
return emptyOverlaySnapshot(!1);
|
|
82627
|
+
if (!isRecord5(value) || typeof value.enabled != "boolean")
|
|
82628
|
+
return;
|
|
82629
|
+
let call = value.call === "active" || value.call === "idle" ? value.call : "unknown";
|
|
82630
|
+
return {
|
|
82631
|
+
enabled: value.enabled,
|
|
82632
|
+
revision: typeof value.revision == "string" ? value.revision : null,
|
|
82633
|
+
isolatedPath: typeof value.isolatedPath == "string" ? value.isolatedPath : null,
|
|
82634
|
+
isolatedPaths: Array.isArray(value.isolatedPaths) ? value.isolatedPaths.filter((path8) => typeof path8 == "string") : typeof value.isolatedPath == "string" ? [value.isolatedPath] : null,
|
|
82635
|
+
isolatedRun: typeof value.isolatedRun == "string" ? value.isolatedRun : null,
|
|
82636
|
+
isolatedExpiresAt: typeof value.isolatedExpiresAt == "string" ? value.isolatedExpiresAt : null,
|
|
82637
|
+
isolatedPlatform: typeof value.isolatedPlatform == "string" ? value.isolatedPlatform : null,
|
|
82638
|
+
appPath: typeof value.appPath == "string" ? value.appPath : null,
|
|
82639
|
+
call
|
|
82640
|
+
};
|
|
82641
|
+
}
|
|
82642
|
+
async function installOverlayHook(target2, overlayHookSource, overlayClients, operations, signal, overlayVoiceBootstrapSource, voiceHost, voiceHostDisposals) {
|
|
82643
|
+
let timeoutMessage = "Overlay hook installation timed out", currentDocumentSource = overlayVoiceBootstrapSource ?? overlayHookSource, desiredDigest = overlaySourceDigest(currentDocumentSource), desiredIdentity = overlayIdentityFromSource(currentDocumentSource), run2 = (operation) => runWithCdpSignal(signal, timeoutMessage, operation), renderer = overlayClients.get(target2.id), registered = renderer !== void 0;
|
|
82644
|
+
renderer ??= await connectRendererTarget(target2, operations, signal, timeoutMessage);
|
|
82645
|
+
let connected = renderer;
|
|
81915
82646
|
try {
|
|
81916
|
-
|
|
82647
|
+
registered ? voiceHost && voiceHostDisposals && !voiceHostDisposals.has(connected) && await run2(() => bindRendererVoiceHost(connected, voiceHost, voiceHostDisposals, { enableRuntime: !1 })) : (voiceHost && voiceHostDisposals && !voiceHostDisposals.has(connected) && await run2(() => bindRendererVoiceHost(connected, voiceHost, voiceHostDisposals, { enableRuntime: !1 })), await run2(() => connected.command("Runtime.enable")), await run2(() => connected.command("Page.enable")), overlayClients.set(target2.id, connected));
|
|
82648
|
+
let inspected = !0, snapshot = readOverlayHookSnapshot(await run2(async () => {
|
|
82649
|
+
try {
|
|
82650
|
+
return await connected.evaluate(OVERLAY_HOOK_SNAPSHOT_EXPRESSION);
|
|
82651
|
+
} catch {
|
|
82652
|
+
inspected = !1;
|
|
82653
|
+
return;
|
|
82654
|
+
}
|
|
82655
|
+
})), applied = overlayInstallState.get(connected), identityMatches = inspected && desiredIdentity !== void 0 && snapshot !== void 0 && overlayIdentitiesMatch(snapshot, desiredIdentity), digestMatches = applied?.currentDigest === desiredDigest, currentMatches = inspected && snapshot?.enabled === !0 && identityMatches && digestMatches, callKnownIdle = inspected && snapshot?.call === "idle";
|
|
82656
|
+
if (!registered || applied?.futureDigest !== desiredDigest) {
|
|
82657
|
+
if (applied?.scriptId)
|
|
82658
|
+
try {
|
|
82659
|
+
await run2(() => connected.command("Page.removeScriptToEvaluateOnNewDocument", {
|
|
82660
|
+
identifier: applied.scriptId
|
|
82661
|
+
}));
|
|
82662
|
+
} catch {
|
|
82663
|
+
}
|
|
82664
|
+
let added = await run2(() => connected.command("Page.addScriptToEvaluateOnNewDocument", {
|
|
82665
|
+
source: currentDocumentSource
|
|
82666
|
+
})), addedId = isRecord5(added) && typeof added.identifier == "string" ? added.identifier : void 0;
|
|
82667
|
+
overlayInstallState.set(connected, {
|
|
82668
|
+
futureDigest: desiredDigest,
|
|
82669
|
+
...applied?.currentDigest ? { currentDigest: applied.currentDigest } : {},
|
|
82670
|
+
...addedId ? { scriptId: addedId } : {}
|
|
82671
|
+
});
|
|
82672
|
+
}
|
|
82673
|
+
if (currentMatches || !callKnownIdle)
|
|
81917
82674
|
return;
|
|
81918
|
-
await run2(() =>
|
|
81919
|
-
|
|
81920
|
-
|
|
82675
|
+
await run2(() => evaluateSource(connected, currentDocumentSource));
|
|
82676
|
+
let evaluated = overlayInstallState.get(connected);
|
|
82677
|
+
overlayInstallState.set(connected, {
|
|
82678
|
+
futureDigest: desiredDigest,
|
|
82679
|
+
currentDigest: desiredDigest,
|
|
82680
|
+
...evaluated?.scriptId ? { scriptId: evaluated.scriptId } : {}
|
|
82681
|
+
});
|
|
82682
|
+
} catch (error51) {
|
|
82683
|
+
throw overlayClients.delete(target2.id), voiceHostDisposals && unbindRendererVoiceHost(connected, voiceHostDisposals), connected.close(), error51;
|
|
81921
82684
|
}
|
|
81922
82685
|
}
|
|
81923
82686
|
function isLocalThreadRenderer(target2) {
|
|
@@ -81958,27 +82721,30 @@ async function installLocalThreadRenderer(target2, source, enabledAgents, operat
|
|
|
81958
82721
|
renderer.close();
|
|
81959
82722
|
}
|
|
81960
82723
|
}
|
|
81961
|
-
async function installAuxiliaryRenderers(endpoint, rendererSource, enabledAgents, overlayHookSource, browserStyleClients, operations, signal) {
|
|
82724
|
+
async function installAuxiliaryRenderers(endpoint, rendererSource, enabledAgents, overlayHookSource, overlayVoiceBootstrapSource, browserStyleClients, overlayClients, operations, signal, voiceHost, voiceHostDisposals) {
|
|
81962
82725
|
try {
|
|
81963
82726
|
let targets = await awaitWithSignal(operations.listTargets(endpoint, signal), signal, "Auxiliary Renderer CDP target discovery timed out"), liveTargets = new Set(targets.map((target2) => target2.id));
|
|
81964
|
-
for (let [
|
|
81965
|
-
|
|
82727
|
+
for (let clients of [browserStyleClients, overlayClients])
|
|
82728
|
+
for (let [id, client] of clients)
|
|
82729
|
+
liveTargets.has(id) || (voiceHostDisposals && unbindRendererVoiceHost(client, voiceHostDisposals), client.close(), clients.delete(id));
|
|
81966
82730
|
await Promise.allSettled([
|
|
81967
82731
|
...targets.filter(isBrowserPage).map((target2) => installBrowserAnnotationStyles(target2, browserStyleClients, operations, signal)),
|
|
81968
|
-
...overlayHookSource ? selectAvatarOverlayRendererTargets(targets).map((overlay) => installOverlayHook(overlay, overlayHookSource, operations, signal)) : [],
|
|
82732
|
+
...overlayHookSource ? selectAvatarOverlayRendererTargets(targets).map((overlay) => installOverlayHook(overlay, overlayHookSource, overlayClients, operations, signal, overlayVoiceBootstrapSource, voiceHost, voiceHostDisposals)) : [],
|
|
81969
82733
|
...targets.filter(isLocalThreadRenderer).map((target2) => installLocalThreadRenderer(target2, rendererSource, enabledAgents, operations, signal))
|
|
81970
82734
|
]);
|
|
81971
82735
|
} catch {
|
|
81972
82736
|
}
|
|
81973
82737
|
}
|
|
81974
|
-
async function installTarget(target2, rendererSource, enabledAgents, timeoutMs, pollIntervalMs, operations) {
|
|
82738
|
+
async function installTarget(target2, rendererSource, enabledAgents, timeoutMs, pollIntervalMs, operations, voiceHost, voiceHostDisposals) {
|
|
81975
82739
|
let renderer = await operations.connect(target2.webSocketDebuggerUrl), disposeModules;
|
|
81976
82740
|
try {
|
|
81977
|
-
|
|
82741
|
+
voiceHost && voiceHostDisposals && await bindRendererVoiceHost(renderer, voiceHost, voiceHostDisposals, {
|
|
82742
|
+
enableRuntime: !1
|
|
82743
|
+
}), disposeModules = await installRendererLoadedModules(renderer), await renderer.command("Page.enable"), await renderer.command("Page.addScriptToEvaluateOnNewDocument", { source: rendererSource }), await evaluateSource(renderer, rendererSource);
|
|
81978
82744
|
let draftPrewarmPolicy = await operations.installDraftPrewarmPolicy(renderer), binding = await waitForBinding(renderer, enabledAgents, timeoutMs, pollIntervalMs);
|
|
81979
82745
|
return { renderer, snapshot: { target: target2, draftPrewarmPolicy, binding }, disposeModules };
|
|
81980
82746
|
} catch (error51) {
|
|
81981
|
-
throw disposeModules?.(), renderer.close(), error51;
|
|
82747
|
+
throw disposeModules?.(), voiceHostDisposals && unbindRendererVoiceHost(renderer, voiceHostDisposals), renderer.close(), error51;
|
|
81982
82748
|
}
|
|
81983
82749
|
}
|
|
81984
82750
|
var InstalledRendererCdpControlSession = class {
|
|
@@ -81986,16 +82752,20 @@ var InstalledRendererCdpControlSession = class {
|
|
|
81986
82752
|
rendererCdpEndpoint;
|
|
81987
82753
|
rendererSource;
|
|
81988
82754
|
overlayHookSource;
|
|
82755
|
+
overlayVoiceBootstrapSource;
|
|
81989
82756
|
browserStyleClients;
|
|
82757
|
+
overlayClients;
|
|
81990
82758
|
enabledAgents;
|
|
81991
82759
|
timeoutMs;
|
|
81992
82760
|
pollIntervalMs;
|
|
81993
82761
|
operations;
|
|
81994
82762
|
currentSnapshot;
|
|
81995
82763
|
disposeModules;
|
|
82764
|
+
voiceHost;
|
|
82765
|
+
voiceHostDisposals;
|
|
81996
82766
|
#closed = !1;
|
|
81997
|
-
constructor(renderer, rendererCdpEndpoint, rendererSource, overlayHookSource, browserStyleClients, enabledAgents, timeoutMs, pollIntervalMs, operations, currentSnapshot, disposeModules) {
|
|
81998
|
-
this.renderer = renderer, this.rendererCdpEndpoint = rendererCdpEndpoint, this.rendererSource = rendererSource, this.overlayHookSource = overlayHookSource, this.browserStyleClients = browserStyleClients, this.enabledAgents = enabledAgents, this.timeoutMs = timeoutMs, this.pollIntervalMs = pollIntervalMs, this.operations = operations, this.currentSnapshot = currentSnapshot, this.disposeModules = disposeModules;
|
|
82767
|
+
constructor(renderer, rendererCdpEndpoint, rendererSource, overlayHookSource, overlayVoiceBootstrapSource, browserStyleClients, overlayClients, enabledAgents, timeoutMs, pollIntervalMs, operations, currentSnapshot, disposeModules, voiceHost, voiceHostDisposals) {
|
|
82768
|
+
this.renderer = renderer, this.rendererCdpEndpoint = rendererCdpEndpoint, this.rendererSource = rendererSource, this.overlayHookSource = overlayHookSource, this.overlayVoiceBootstrapSource = overlayVoiceBootstrapSource, this.browserStyleClients = browserStyleClients, this.overlayClients = overlayClients, this.enabledAgents = enabledAgents, this.timeoutMs = timeoutMs, this.pollIntervalMs = pollIntervalMs, this.operations = operations, this.currentSnapshot = currentSnapshot, this.disposeModules = disposeModules, this.voiceHost = voiceHost, this.voiceHostDisposals = voiceHostDisposals;
|
|
81999
82769
|
}
|
|
82000
82770
|
get snapshot() {
|
|
82001
82771
|
return this.currentSnapshot;
|
|
@@ -82005,18 +82775,18 @@ var InstalledRendererCdpControlSession = class {
|
|
|
82005
82775
|
throw new Error("Renderer CDP Control Session is closed");
|
|
82006
82776
|
let target2 = await waitForPrimaryTarget(this.rendererCdpEndpoint, this.operations, this.timeoutMs, this.pollIntervalMs, this.currentSnapshot.target.id);
|
|
82007
82777
|
if (target2.id !== this.currentSnapshot.target.id) {
|
|
82008
|
-
let replacement = await installTarget(target2, this.rendererSource, this.enabledAgents, this.timeoutMs, this.pollIntervalMs, this.operations);
|
|
82009
|
-
this.disposeModules(), this.renderer.close(), this.renderer = replacement.renderer, this.disposeModules = replacement.disposeModules, this.currentSnapshot = replacement.snapshot;
|
|
82778
|
+
let replacement = await installTarget(target2, this.rendererSource, this.enabledAgents, this.timeoutMs, this.pollIntervalMs, this.operations, this.voiceHost, this.voiceHostDisposals);
|
|
82779
|
+
this.disposeModules(), unbindRendererVoiceHost(this.renderer, this.voiceHostDisposals), this.renderer.close(), this.renderer = replacement.renderer, this.disposeModules = replacement.disposeModules, this.currentSnapshot = replacement.snapshot;
|
|
82010
82780
|
} else
|
|
82011
82781
|
try {
|
|
82012
82782
|
await readBinding(this.renderer) === null && await evaluateSource(this.renderer, this.rendererSource);
|
|
82013
82783
|
let draftPrewarmPolicy = await this.operations.installDraftPrewarmPolicy(this.renderer), binding = await waitForBinding(this.renderer, this.enabledAgents, this.timeoutMs, this.pollIntervalMs);
|
|
82014
82784
|
this.currentSnapshot = { target: target2, draftPrewarmPolicy, binding };
|
|
82015
82785
|
} catch {
|
|
82016
|
-
let replacement = await installTarget(target2, this.rendererSource, this.enabledAgents, this.timeoutMs, this.pollIntervalMs, this.operations);
|
|
82017
|
-
this.disposeModules(), this.renderer.close(), this.renderer = replacement.renderer, this.disposeModules = replacement.disposeModules, this.currentSnapshot = replacement.snapshot;
|
|
82786
|
+
let replacement = await installTarget(target2, this.rendererSource, this.enabledAgents, this.timeoutMs, this.pollIntervalMs, this.operations, this.voiceHost, this.voiceHostDisposals);
|
|
82787
|
+
this.disposeModules(), unbindRendererVoiceHost(this.renderer, this.voiceHostDisposals), this.renderer.close(), this.renderer = replacement.renderer, this.disposeModules = replacement.disposeModules, this.currentSnapshot = replacement.snapshot;
|
|
82018
82788
|
}
|
|
82019
|
-
return await installAuxiliaryRenderers(this.rendererCdpEndpoint, this.rendererSource, this.enabledAgents, this.overlayHookSource, this.browserStyleClients, this.operations, discoveryTimeoutSignal(this.timeoutMs)), this.currentSnapshot;
|
|
82789
|
+
return await installAuxiliaryRenderers(this.rendererCdpEndpoint, this.rendererSource, this.enabledAgents, this.overlayHookSource, this.overlayVoiceBootstrapSource, this.browserStyleClients, this.overlayClients, this.operations, discoveryTimeoutSignal(this.timeoutMs), this.voiceHost, this.voiceHostDisposals), this.currentSnapshot;
|
|
82020
82790
|
}
|
|
82021
82791
|
async activateDesktop() {
|
|
82022
82792
|
if (this.#closed)
|
|
@@ -82028,10 +82798,16 @@ var InstalledRendererCdpControlSession = class {
|
|
|
82028
82798
|
}
|
|
82029
82799
|
close() {
|
|
82030
82800
|
if (!this.#closed) {
|
|
82031
|
-
this.#closed = !0, this.disposeModules(), this.renderer.close();
|
|
82801
|
+
this.#closed = !0, this.disposeModules(), unbindRendererVoiceHost(this.renderer, this.voiceHostDisposals), this.renderer.close();
|
|
82032
82802
|
for (let client of this.browserStyleClients.values())
|
|
82033
82803
|
client.close();
|
|
82034
82804
|
this.browserStyleClients.clear();
|
|
82805
|
+
for (let client of this.overlayClients.values())
|
|
82806
|
+
unbindRendererVoiceHost(client, this.voiceHostDisposals), client.close();
|
|
82807
|
+
this.overlayClients.clear();
|
|
82808
|
+
for (let dispose of this.voiceHostDisposals.values())
|
|
82809
|
+
dispose();
|
|
82810
|
+
this.voiceHostDisposals.clear();
|
|
82035
82811
|
}
|
|
82036
82812
|
}
|
|
82037
82813
|
}, defaultOperations = {
|
|
@@ -82043,8 +82819,8 @@ var InstalledRendererCdpControlSession = class {
|
|
|
82043
82819
|
}
|
|
82044
82820
|
};
|
|
82045
82821
|
async function createRendererCdpControlSession(options) {
|
|
82046
|
-
let enabledAgents = options.enabledAgents, timeoutMs = options.timeoutMs ?? 3e4, pollIntervalMs = options.pollIntervalMs ?? 250, operations = options.operations ?? defaultOperations, target2 = await waitForPrimaryTarget(options.rendererCdpEndpoint, operations, timeoutMs, pollIntervalMs, void 0, options.signal), installed = await installTarget(target2, options.rendererSource, enabledAgents, timeoutMs, pollIntervalMs, operations), browserStyleClients = /* @__PURE__ */ new Map();
|
|
82047
|
-
return await installAuxiliaryRenderers(options.rendererCdpEndpoint, options.rendererSource, enabledAgents, options.overlayHookSource, browserStyleClients, operations, discoveryTimeoutSignal(timeoutMs, options.signal)), new InstalledRendererCdpControlSession(installed.renderer, options.rendererCdpEndpoint, options.rendererSource, options.overlayHookSource, browserStyleClients, enabledAgents, timeoutMs, pollIntervalMs, operations, installed.snapshot, installed.disposeModules);
|
|
82822
|
+
let enabledAgents = options.enabledAgents, timeoutMs = options.timeoutMs ?? 3e4, pollIntervalMs = options.pollIntervalMs ?? 250, operations = options.operations ?? defaultOperations, target2 = await waitForPrimaryTarget(options.rendererCdpEndpoint, operations, timeoutMs, pollIntervalMs, void 0, options.signal), voiceHostDisposals = /* @__PURE__ */ new Map(), installed = await installTarget(target2, options.rendererSource, enabledAgents, timeoutMs, pollIntervalMs, operations, options.voiceHost, voiceHostDisposals), browserStyleClients = /* @__PURE__ */ new Map(), overlayClients = /* @__PURE__ */ new Map();
|
|
82823
|
+
return await installAuxiliaryRenderers(options.rendererCdpEndpoint, options.rendererSource, enabledAgents, options.overlayHookSource, options.overlayVoiceBootstrapSource, browserStyleClients, overlayClients, operations, discoveryTimeoutSignal(timeoutMs, options.signal), options.voiceHost, voiceHostDisposals), new InstalledRendererCdpControlSession(installed.renderer, options.rendererCdpEndpoint, options.rendererSource, options.overlayHookSource, options.overlayVoiceBootstrapSource, browserStyleClients, overlayClients, enabledAgents, timeoutMs, pollIntervalMs, operations, installed.snapshot, installed.disposeModules, options.voiceHost, voiceHostDisposals);
|
|
82048
82824
|
}
|
|
82049
82825
|
function installRendererCdpControlSession(options) {
|
|
82050
82826
|
return createRendererCdpControlSession(options);
|
|
@@ -91184,7 +91960,7 @@ async function readPdf(path8, limit, signal) {
|
|
|
91184
91960
|
}
|
|
91185
91961
|
|
|
91186
91962
|
// apps/web-ui/packages/document/office-to-pdf/src/queue.ts
|
|
91187
|
-
import { createHash as
|
|
91963
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
91188
91964
|
var ConversionQueue = class {
|
|
91189
91965
|
/**
|
|
91190
91966
|
* @param config - validated queue, source, reader, and completed-result limits.
|
|
@@ -91329,7 +92105,7 @@ var ConversionQueue = class {
|
|
|
91329
92105
|
"input-too-large",
|
|
91330
92106
|
"The source exceeds its reserved read capacity."
|
|
91331
92107
|
);
|
|
91332
|
-
let digest2 =
|
|
92108
|
+
let digest2 = createHash9("sha256").update(job.request.extension).update("\0").update(input.bytes).digest("hex"), key = OfficeToPdfKey(`${this.generation}:${digest2}`), cached3 = this.ready.get(key);
|
|
91333
92109
|
if (cached3 !== void 0) {
|
|
91334
92110
|
this.ready.delete(key), this.ready.set(key, cached3), this.finish(job, cached3);
|
|
91335
92111
|
return;
|
|
@@ -95856,7 +96632,7 @@ import {
|
|
|
95856
96632
|
} from "node:fs";
|
|
95857
96633
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
95858
96634
|
import { basename as basename9, dirname as dirname13, isAbsolute as isAbsolute15, join as join22 } from "node:path";
|
|
95859
|
-
function
|
|
96635
|
+
function isRecord6(value) {
|
|
95860
96636
|
return value !== null && typeof value == "object" && !Array.isArray(value);
|
|
95861
96637
|
}
|
|
95862
96638
|
function hasExactKeys(value, required2, optional2 = []) {
|
|
@@ -95864,7 +96640,7 @@ function hasExactKeys(value, required2, optional2 = []) {
|
|
|
95864
96640
|
return required2.every((key) => Object.hasOwn(value, key)) && Object.keys(value).every((key) => allowed.has(key));
|
|
95865
96641
|
}
|
|
95866
96642
|
function isSerializedRunnerError(value) {
|
|
95867
|
-
return !
|
|
96643
|
+
return !isRecord6(value) || !hasExactKeys(value, ["name", "message"], ["code", "syscall", "path"]) ? !1 : typeof value.name == "string" && typeof value.message == "string" && (value.code === void 0 || typeof value.code == "string") && (value.syscall === void 0 || typeof value.syscall == "string") && (value.path === void 0 || typeof value.path == "string");
|
|
95868
96644
|
}
|
|
95869
96645
|
function parseErrorResult(value) {
|
|
95870
96646
|
if (!hasExactKeys(value, ["type", "error"]) || !isSerializedRunnerError(value.error))
|
|
@@ -95888,11 +96664,11 @@ function createLinuxLaunchFiles(request2) {
|
|
|
95888
96664
|
function readLinuxStartupError(path8) {
|
|
95889
96665
|
if (!existsSync10(path8)) return;
|
|
95890
96666
|
let value = JSON.parse(readFileSync11(path8, "utf8"));
|
|
95891
|
-
if (!
|
|
96667
|
+
if (!isRecord6(value)) throw new Error("subprocess runner emitted an invalid startup error");
|
|
95892
96668
|
return parseErrorResult(value);
|
|
95893
96669
|
}
|
|
95894
96670
|
function parseWindowsRunnerResult(value) {
|
|
95895
|
-
if (!
|
|
96671
|
+
if (!isRecord6(value) || typeof value.type != "string")
|
|
95896
96672
|
throw new Error("subprocess runner emitted an invalid Windows result");
|
|
95897
96673
|
if (value.type === "error") return parseErrorResult(value);
|
|
95898
96674
|
if (value.type === "target-exit") {
|
|
@@ -98224,7 +99000,7 @@ var DshWebServices = class _DshWebServices {
|
|
|
98224
99000
|
|
|
98225
99001
|
// packages/web-server/src/office-engine.ts
|
|
98226
99002
|
import { execFile as execFile7 } from "node:child_process";
|
|
98227
|
-
import { createHash as
|
|
99003
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
98228
99004
|
import { existsSync as existsSync12 } from "node:fs";
|
|
98229
99005
|
import { mkdir as mkdir5, readdir as readdir7, rename as rename4, rm as rm6, writeFile as writeFile4 } from "node:fs/promises";
|
|
98230
99006
|
import Module from "node:module";
|
|
@@ -98249,7 +99025,7 @@ function createOfficeEngine(dataRoot2, artifacts) {
|
|
|
98249
99025
|
let response = await fetch(engine.url);
|
|
98250
99026
|
if (!response.ok) throw new Error(`Office engine download failed: HTTP ${response.status}`);
|
|
98251
99027
|
let bytes = Buffer.from(await response.arrayBuffer());
|
|
98252
|
-
if (`sha512-${
|
|
99028
|
+
if (`sha512-${createHash10("sha512").update(bytes).digest("base64")}` !== engine.integrity)
|
|
98253
99029
|
throw new Error("Office engine SHA-512 verification failed");
|
|
98254
99030
|
let archive = join24(temporary, "engine.tgz");
|
|
98255
99031
|
await writeFile4(archive, bytes), await extract("tar", ["-xzf", "engine.tgz"], { cwd: temporary });
|
|
@@ -99721,7 +100497,7 @@ function defaultWebDataDirectory(hostDataDirectory) {
|
|
|
99721
100497
|
}
|
|
99722
100498
|
|
|
99723
100499
|
// packages/web-server/src/packaged-host.ts
|
|
99724
|
-
import { createHash as
|
|
100500
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
99725
100501
|
import { cp, mkdir as mkdir7, mkdtemp as mkdtemp3, readFile as readFile6, readdir as readdir8, rename as rename5, rm as rm8, stat as stat8 } from "node:fs/promises";
|
|
99726
100502
|
import { join as join30 } from "node:path";
|
|
99727
100503
|
async function hashDirectory(root, hash3, relative11 = "") {
|
|
@@ -99741,7 +100517,7 @@ async function snapshotPackagedHost(distribution, data2) {
|
|
|
99741
100517
|
recursive: !0,
|
|
99742
100518
|
dereference: !0
|
|
99743
100519
|
});
|
|
99744
|
-
let hash3 =
|
|
100520
|
+
let hash3 = createHash11("sha256");
|
|
99745
100521
|
await hashDirectory(staging, hash3);
|
|
99746
100522
|
let destination = join30(builds, hash3.digest("hex"));
|
|
99747
100523
|
try {
|