@karlorz/codexhost-cli-win32-arm64 0.13.2-2 → 0.13.3-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-web.js +2 -4
- package/app/cpa-live-voice-hook.js +71 -0
- package/app/desktop-controller.mjs +5 -0
- package/app/host-runtime.mjs +1733 -487
- package/app/plugins/codebuddy/plugin.mjs +22 -1
- package/app/plugins/deepseek-harness/manifest.json +2 -2
- package/app/plugins/deepseek-harness/plugin.mjs +67 -7
- package/app/plugins/opencode/plugin.mjs +6 -2
- package/app/plugins/workbuddy/plugin.mjs +139 -2
- package/app/renderer-extension.js +333 -133
- 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
|
@@ -18979,7 +18979,7 @@ ${error51.stderrTail}`] : []
|
|
|
18979
18979
|
launchPathSaveError: "Could not save. Enter an existing absolute installation folder on this Host and check configuration permissions.",
|
|
18980
18980
|
connectionOfficialWebsite: "Visit official website",
|
|
18981
18981
|
connectionOpenHarnessWeb: "Open DeepSeek Harness Web",
|
|
18982
|
-
connectionDeepSeekTestedVersions: "Supported DSH versions: 0.1.7-rc.1, 0.1.7-rc.2, 0.2.0-rc.1 and 0.2.
|
|
18982
|
+
connectionDeepSeekTestedVersions: "Supported DSH versions: 0.1.7-rc.1, 0.1.7-rc.2, 0.2.0-rc.1, 0.2.0-rc.2, 0.2.1-rc.1 and 0.2.1-rc.2. Versions newer than 0.2.1-rc.2 can be tried, but compatibility may be limited; versions older than 0.1.7-rc.1 must be upgraded first.",
|
|
18983
18983
|
connectionInstall: "Install",
|
|
18984
18984
|
connectionInstallDescription: "This Harness was not detected.",
|
|
18985
18985
|
connectionInstallRunning: "Installing on the selected Host. You can leave this page; login or setup may still be required afterward.",
|
|
@@ -19262,7 +19262,7 @@ ${error51.stderrTail}`] : []
|
|
|
19262
19262
|
launchPathSaveError: "\u4FDD\u5B58\u5931\u8D25\u3002\u8BF7\u586B\u5199\u6B64 Host \u4E0A\u5B9E\u9645\u5B58\u5728\u7684\u5B89\u88C5\u76EE\u5F55\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u5E76\u786E\u8BA4\u914D\u7F6E\u76EE\u5F55\u53EF\u5199\u3002",
|
|
19263
19263
|
connectionOfficialWebsite: "\u8BBF\u95EE\u5B98\u7F51",
|
|
19264
19264
|
connectionOpenHarnessWeb: "\u6253\u5F00 DeepSeek Harness Web",
|
|
19265
|
-
connectionDeepSeekTestedVersions: "\u652F\u6301 DSH \u7248\u672C\uFF1A0.1.7-rc.1\u30010.1.7-rc.2\u30010.2.0-rc.1 \u548C 0.2.
|
|
19265
|
+
connectionDeepSeekTestedVersions: "\u652F\u6301 DSH \u7248\u672C\uFF1A0.1.7-rc.1\u30010.1.7-rc.2\u30010.2.0-rc.1\u30010.2.0-rc.2\u30010.2.1-rc.1 \u548C 0.2.1-rc.2\u3002\u9AD8\u4E8E 0.2.1-rc.2 \u7684\u7248\u672C\u53EF\u4EE5\u5C1D\u8BD5\u8FDE\u63A5\uFF0C\u4F46\u9002\u914D\u5EA6\u53EF\u80FD\u6709\u9650\uFF1B\u4F4E\u4E8E 0.1.7-rc.1 \u7684\u7248\u672C\u9700\u8981\u5148\u5347\u7EA7\u3002",
|
|
19266
19266
|
connectionInstall: "\u5B89\u88C5",
|
|
19267
19267
|
connectionInstallDescription: "\u5C1A\u672A\u68C0\u6D4B\u5230\u8BE5 Harness\u3002",
|
|
19268
19268
|
connectionInstallRunning: "\u6B63\u5728\u6240\u9009 Host \u4E0A\u5B89\u88C5\uFF0C\u79BB\u5F00\u9875\u9762\u4E0D\u4F1A\u4E2D\u65AD\u3002\u5B89\u88C5\u540E\u53EF\u80FD\u4ECD\u9700\u767B\u5F55\u6216\u914D\u7F6E\u3002",
|
|
@@ -20058,7 +20058,6 @@ ${error51.stderrTail}`] : []
|
|
|
20058
20058
|
// src/renderer-usage-control.ts
|
|
20059
20059
|
var ENGLISH_USAGE_MESSAGES = Object.freeze({
|
|
20060
20060
|
usage: "Usage",
|
|
20061
|
-
account: "Account",
|
|
20062
20061
|
context: "Context",
|
|
20063
20062
|
recordedCredits: "Recorded usage",
|
|
20064
20063
|
latestCacheHit: "Latest cache hit (CH)",
|
|
@@ -20084,7 +20083,6 @@ ${error51.stderrTail}`] : []
|
|
|
20084
20083
|
});
|
|
20085
20084
|
var CHINESE_USAGE_MESSAGES = Object.freeze({
|
|
20086
20085
|
usage: "\u7528\u91CF",
|
|
20087
|
-
account: "\u8D26\u53F7",
|
|
20088
20086
|
context: "\u4E0A\u4E0B\u6587",
|
|
20089
20087
|
recordedCredits: "\u5DF2\u8BB0\u5F55\u6D88\u8017",
|
|
20090
20088
|
latestCacheHit: "\u6700\u8FD1\u7F13\u5B58\u547D\u4E2D\uFF08CH\uFF09",
|
|
@@ -20196,10 +20194,10 @@ ${error51.stderrTail}`] : []
|
|
|
20196
20194
|
popover.style.color = "CanvasText";
|
|
20197
20195
|
popover.style.boxShadow = "light-dark(0 10px 24px rgba(15, 23, 42, 0.12), 0 20px 45px rgba(0, 0, 0, 0.42)), 0 2px 8px light-dark(rgba(15, 23, 42, 0.06), rgba(0, 0, 0, 0.28))";
|
|
20198
20196
|
}
|
|
20199
|
-
function addDetailRow(parent, label, value
|
|
20197
|
+
function addDetailRow(parent, label, value) {
|
|
20200
20198
|
const row = document.createElement("div");
|
|
20201
20199
|
row.style.display = "grid";
|
|
20202
|
-
row.style.gridTemplateColumns =
|
|
20200
|
+
row.style.gridTemplateColumns = "minmax(0, 1fr) auto";
|
|
20203
20201
|
row.style.gap = "20px";
|
|
20204
20202
|
row.style.padding = "4px 0";
|
|
20205
20203
|
const labelElement = document.createElement("span");
|
|
@@ -20209,10 +20207,6 @@ ${error51.stderrTail}`] : []
|
|
|
20209
20207
|
valueElement.textContent = value;
|
|
20210
20208
|
valueElement.style.fontVariantNumeric = "tabular-nums";
|
|
20211
20209
|
valueElement.style.textAlign = "right";
|
|
20212
|
-
if (wrap) {
|
|
20213
|
-
valueElement.style.overflowWrap = "anywhere";
|
|
20214
|
-
valueElement.title = value;
|
|
20215
|
-
}
|
|
20216
20210
|
row.append(labelElement, valueElement);
|
|
20217
20211
|
parent.append(row);
|
|
20218
20212
|
}
|
|
@@ -20263,14 +20257,13 @@ ${error51.stderrTail}`] : []
|
|
|
20263
20257
|
if (note) addNote(parent, note);
|
|
20264
20258
|
}
|
|
20265
20259
|
}
|
|
20266
|
-
function renderDetails(popover, usage, messages, locale
|
|
20260
|
+
function renderDetails(popover, usage, messages, locale) {
|
|
20267
20261
|
popover.replaceChildren();
|
|
20268
20262
|
const heading = document.createElement("div");
|
|
20269
20263
|
heading.textContent = messages.usage;
|
|
20270
20264
|
heading.style.fontWeight = "600";
|
|
20271
20265
|
heading.style.marginBottom = "6px";
|
|
20272
20266
|
popover.append(heading);
|
|
20273
|
-
if (accountName) addDetailRow(popover, messages.account, accountName, true);
|
|
20274
20267
|
if (usage?.contextUsagePercent !== void 0) {
|
|
20275
20268
|
addContextRow(
|
|
20276
20269
|
popover,
|
|
@@ -20502,7 +20495,7 @@ ${error51.stderrTail}`] : []
|
|
|
20502
20495
|
document.body.append(popover);
|
|
20503
20496
|
return control;
|
|
20504
20497
|
}
|
|
20505
|
-
function renderRendererUsageControl(control, usage, locale = control.locale
|
|
20498
|
+
function renderRendererUsageControl(control, usage, locale = control.locale) {
|
|
20506
20499
|
control.locale = locale;
|
|
20507
20500
|
const messages = rendererUsageMessages(locale);
|
|
20508
20501
|
control.popover.setAttribute("aria-label", messages.threadUsageDetails);
|
|
@@ -20511,7 +20504,7 @@ ${error51.stderrTail}`] : []
|
|
|
20511
20504
|
const totalCostUsd = usage?.totalCostUsd;
|
|
20512
20505
|
const hasContext = usage?.contextUsedTokens !== void 0 && usage.contextWindowTokens !== void 0;
|
|
20513
20506
|
const hasTokenUsage = usage?.totalTokens !== void 0 || usage?.inputTokens !== void 0 || usage?.cachedInputTokens !== void 0 || usage?.cacheWriteInputTokens !== void 0 || usage?.outputTokens !== void 0;
|
|
20514
|
-
const visible = rendererUsageHasDisplayData(usage)
|
|
20507
|
+
const visible = rendererUsageHasDisplayData(usage);
|
|
20515
20508
|
control.root.style.display = visible ? "inline-flex" : "none";
|
|
20516
20509
|
if (!visible) {
|
|
20517
20510
|
closePopover(control);
|
|
@@ -20545,7 +20538,7 @@ ${error51.stderrTail}`] : []
|
|
|
20545
20538
|
control.trigger.setAttribute("aria-label", accessibleSummary);
|
|
20546
20539
|
control.trigger.title = accessibleSummary;
|
|
20547
20540
|
control.label.textContent = compactSummary;
|
|
20548
|
-
renderDetails(control.popover, usage, messages, locale
|
|
20541
|
+
renderDetails(control.popover, usage, messages, locale);
|
|
20549
20542
|
return true;
|
|
20550
20543
|
}
|
|
20551
20544
|
|
|
@@ -22999,14 +22992,8 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
22999
22992
|
permissionModeVisible,
|
|
23000
22993
|
locale
|
|
23001
22994
|
);
|
|
23002
|
-
const selectedCodexAccount = state.agent === "codex" && !ownershipError ? currentCodexAccount : void 0;
|
|
23003
22995
|
if (control.usage) {
|
|
23004
|
-
renderRendererUsageControl(
|
|
23005
|
-
control.usage,
|
|
23006
|
-
usage,
|
|
23007
|
-
locale,
|
|
23008
|
-
selectedCodexAccount?.email ?? selectedCodexAccount?.label ?? null
|
|
23009
|
-
);
|
|
22996
|
+
renderRendererUsageControl(control.usage, usage, locale);
|
|
23010
22997
|
}
|
|
23011
22998
|
control.harnessCommands.setLocale(locale);
|
|
23012
22999
|
control.harnessCommands.root.hidden = state.agent === "codex";
|
|
@@ -23146,62 +23133,141 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
23146
23133
|
}
|
|
23147
23134
|
};
|
|
23148
23135
|
|
|
23136
|
+
// src/renderer-codex-usage-banner.ts
|
|
23137
|
+
var MAX_FIBERS = 2e4;
|
|
23138
|
+
function isRecord3(value) {
|
|
23139
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23140
|
+
}
|
|
23141
|
+
function isUsageBanner(props) {
|
|
23142
|
+
return isRecord3(props) && "banner" in props && "rateLimitStatus" in props && typeof props.sendBlocked === "boolean";
|
|
23143
|
+
}
|
|
23144
|
+
function isElement(value) {
|
|
23145
|
+
return isRecord3(value) && typeof value.setAttribute === "function" && isRecord3(value.style);
|
|
23146
|
+
}
|
|
23147
|
+
function hostElements(fiber, budget) {
|
|
23148
|
+
const result = [];
|
|
23149
|
+
const visit = (node) => {
|
|
23150
|
+
for (let current = node; isRecord3(current); current = current.sibling) {
|
|
23151
|
+
if (budget.remaining-- <= 0) return;
|
|
23152
|
+
const { stateNode } = current;
|
|
23153
|
+
if (isElement(stateNode)) result.push(stateNode);
|
|
23154
|
+
else visit(current.child);
|
|
23155
|
+
}
|
|
23156
|
+
};
|
|
23157
|
+
visit(fiber.child);
|
|
23158
|
+
return result;
|
|
23159
|
+
}
|
|
23160
|
+
function findCodexUsageBannerElements(owner) {
|
|
23161
|
+
if (!isRecord3(owner)) return [];
|
|
23162
|
+
const budget = { remaining: MAX_FIBERS };
|
|
23163
|
+
const found = [];
|
|
23164
|
+
const stack = [owner.child];
|
|
23165
|
+
while (stack.length > 0 && budget.remaining > 0) {
|
|
23166
|
+
const node = stack.pop();
|
|
23167
|
+
if (!isRecord3(node)) continue;
|
|
23168
|
+
budget.remaining -= 1;
|
|
23169
|
+
const fiber = node;
|
|
23170
|
+
stack.push(fiber.sibling);
|
|
23171
|
+
if (isUsageBanner(fiber.memoizedProps)) found.push(...hostElements(fiber, budget));
|
|
23172
|
+
else stack.push(fiber.child);
|
|
23173
|
+
}
|
|
23174
|
+
return budget.remaining > 0 ? found : [];
|
|
23175
|
+
}
|
|
23176
|
+
var HIDDEN_ATTRIBUTE = "data-codexhost-usage-banner-hidden";
|
|
23177
|
+
function createRendererCodexUsageBanner() {
|
|
23178
|
+
const hidden = /* @__PURE__ */ new Map();
|
|
23179
|
+
const show = (element) => {
|
|
23180
|
+
const previous = hidden.get(element);
|
|
23181
|
+
hidden.delete(element);
|
|
23182
|
+
if (!previous || element.getAttribute(HIDDEN_ATTRIBUTE) === null) return;
|
|
23183
|
+
element.removeAttribute(HIDDEN_ATTRIBUTE);
|
|
23184
|
+
if (previous.value) element.style.setProperty("display", previous.value, previous.priority);
|
|
23185
|
+
else element.style.removeProperty("display");
|
|
23186
|
+
};
|
|
23187
|
+
return {
|
|
23188
|
+
hide(owner) {
|
|
23189
|
+
const current = new Set(findCodexUsageBannerElements(owner));
|
|
23190
|
+
for (const element of [...hidden.keys()]) if (!current.has(element)) show(element);
|
|
23191
|
+
for (const element of current) {
|
|
23192
|
+
if (hidden.has(element)) continue;
|
|
23193
|
+
hidden.set(element, {
|
|
23194
|
+
value: element.style.getPropertyValue("display"),
|
|
23195
|
+
priority: element.style.getPropertyPriority("display")
|
|
23196
|
+
});
|
|
23197
|
+
element.setAttribute(HIDDEN_ATTRIBUTE, "");
|
|
23198
|
+
element.style.setProperty("display", "none", "important");
|
|
23199
|
+
}
|
|
23200
|
+
},
|
|
23201
|
+
restore() {
|
|
23202
|
+
for (const element of [...hidden.keys()]) show(element);
|
|
23203
|
+
}
|
|
23204
|
+
};
|
|
23205
|
+
}
|
|
23206
|
+
|
|
23149
23207
|
// src/renderer-codex-usage-gate.ts
|
|
23150
23208
|
var EDITOR_SELECTOR2 = '[contenteditable="true"][role="textbox"]';
|
|
23151
23209
|
var MAX_HOOKS = 4096;
|
|
23152
23210
|
var MAX_DOM_DEPTH = 12;
|
|
23153
23211
|
var RETRY_DELAY_MS = 1e3;
|
|
23154
|
-
function
|
|
23212
|
+
function isRecord4(value) {
|
|
23155
23213
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23156
23214
|
}
|
|
23157
23215
|
function hooksOf(fiber) {
|
|
23158
23216
|
const result = [];
|
|
23159
|
-
let hook =
|
|
23160
|
-
while (
|
|
23217
|
+
let hook = isRecord4(fiber) ? fiber.memoizedState : null;
|
|
23218
|
+
while (isRecord4(hook) && result.length < MAX_HOOKS) {
|
|
23161
23219
|
result.push(hook);
|
|
23162
23220
|
hook = hook.next;
|
|
23163
23221
|
}
|
|
23164
23222
|
return hook == null ? result : [];
|
|
23165
23223
|
}
|
|
23166
|
-
function submitOwners(composer) {
|
|
23224
|
+
function submitOwners(composer, projections) {
|
|
23167
23225
|
let element = composer.querySelector(EDITOR_SELECTOR2) ?? composer;
|
|
23168
23226
|
for (let depth = 0; element && depth < MAX_DOM_DEPTH; depth += 1) {
|
|
23169
23227
|
const key = Object.getOwnPropertyNames(element).find(
|
|
23170
23228
|
(name) => name.startsWith("__reactFiber$")
|
|
23171
23229
|
);
|
|
23172
23230
|
if (key) {
|
|
23173
|
-
const
|
|
23231
|
+
const ancestors = committedReactAncestors(
|
|
23174
23232
|
Object.getOwnPropertyDescriptor(element, key)?.value
|
|
23175
|
-
).filter(
|
|
23176
|
-
({ memoizedProps: props }) => isRecord3(props) && "onLocalSubmitStart" in props && typeof props.submitDisabled === "boolean"
|
|
23177
23233
|
);
|
|
23178
|
-
|
|
23179
|
-
|
|
23234
|
+
const scopes = [];
|
|
23235
|
+
ancestors.forEach(({ memoizedProps: props }, index) => {
|
|
23236
|
+
if (isRecord4(props) && "onLocalSubmitStart" in props && typeof props.submitDisabled === "boolean") {
|
|
23237
|
+
scopes.push({ owner: ancestors[index], fibers: ancestors.slice(0, index + 1) });
|
|
23238
|
+
}
|
|
23239
|
+
});
|
|
23240
|
+
const valid = scopes.filter((scope) => {
|
|
23241
|
+
const gates = gateSubscriptions(scope, projections);
|
|
23180
23242
|
return !gates.invalid && gates.reserve.length > 0;
|
|
23181
23243
|
});
|
|
23244
|
+
return valid.filter(
|
|
23245
|
+
(scope) => !valid.some((other) => other !== scope && scope.fibers.includes(other.owner))
|
|
23246
|
+
);
|
|
23182
23247
|
}
|
|
23183
23248
|
element = element.parentElement;
|
|
23184
23249
|
}
|
|
23185
23250
|
return [];
|
|
23186
23251
|
}
|
|
23187
|
-
function
|
|
23188
|
-
const
|
|
23189
|
-
return
|
|
23252
|
+
function findSubmitScope(composer, projections) {
|
|
23253
|
+
const scopes = submitOwners(composer, projections);
|
|
23254
|
+
return scopes.length === 1 ? scopes[0] ?? null : null;
|
|
23190
23255
|
}
|
|
23191
|
-
function subscriptionAt(hook) {
|
|
23256
|
+
function subscriptionAt(hook, fiber) {
|
|
23192
23257
|
const memo = hook.memoizedState;
|
|
23193
23258
|
if (!Array.isArray(memo) || !Array.isArray(memo[1])) return null;
|
|
23194
23259
|
const [subscriber, dependencies] = memo;
|
|
23195
23260
|
if (dependencies.length !== 2) return null;
|
|
23196
23261
|
const signal = dependencies[0];
|
|
23197
|
-
const adapted = dependencies[1] === void 0 &&
|
|
23262
|
+
const adapted = dependencies[1] === void 0 && isRecord4(signal) && typeof signal.get === "function" && typeof signal.subscribe === "function";
|
|
23198
23263
|
const [store, atom] = adapted ? [signal.store, signal.atom] : dependencies;
|
|
23199
23264
|
const instance = hook.next?.queue;
|
|
23200
23265
|
const effect = hook.next?.next?.memoizedState;
|
|
23201
|
-
if (!
|
|
23266
|
+
if (!isRecord4(subscriber) || typeof subscriber.getSnapshot !== "function" || typeof subscriber.subscribe !== "function" || !isRecord4(store) || typeof store.get !== "function" || typeof store.sub !== "function" || !isRecord4(atom) || typeof atom.read !== "function" || "write" in atom || !isRecord4(instance) || typeof instance.value !== "boolean" || typeof instance.getSnapshot !== "function" || !isRecord4(effect) || typeof effect.create !== "function" || !Array.isArray(effect.deps) || effect.deps[0] !== subscriber.subscribe) {
|
|
23202
23267
|
return null;
|
|
23203
23268
|
}
|
|
23204
23269
|
return {
|
|
23270
|
+
fiber,
|
|
23205
23271
|
subscriber,
|
|
23206
23272
|
store,
|
|
23207
23273
|
atom,
|
|
@@ -23239,10 +23305,10 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
23239
23305
|
visiting.delete(dependency);
|
|
23240
23306
|
}
|
|
23241
23307
|
}
|
|
23242
|
-
if (!
|
|
23308
|
+
if (!isRecord4(value)) return value;
|
|
23243
23309
|
if (typeof value.hardBlocked === "boolean") return trace(value, "reserve");
|
|
23244
23310
|
if ("authMethod" in value) return trace(value, "auth");
|
|
23245
|
-
if (
|
|
23311
|
+
if (isRecord4(value.data) && isRecord4(value.data.rate_limit)) {
|
|
23246
23312
|
return {
|
|
23247
23313
|
...value,
|
|
23248
23314
|
data: { ...value.data, rate_limit: trace(value.data.rate_limit, "limit") }
|
|
@@ -23258,12 +23324,13 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
23258
23324
|
}
|
|
23259
23325
|
const reserve = read.has("reserve.hardBlocked") && !read.has("reserve.active");
|
|
23260
23326
|
const account = read.has("auth.authMethod") && read.has("limit.allowed");
|
|
23261
|
-
if (account &&
|
|
23327
|
+
if (account && read.has("reserve.hardBlocked")) return "mixed";
|
|
23262
23328
|
if (reserve) return "reserve";
|
|
23263
23329
|
if (account) return "account";
|
|
23264
23330
|
return null;
|
|
23265
23331
|
}
|
|
23266
|
-
function snapshotsMatch({ subscriber, instance, store, atom },
|
|
23332
|
+
function snapshotsMatch({ subscriber, instance, store, atom }, projections) {
|
|
23333
|
+
const projected = projections?.get(instance);
|
|
23267
23334
|
try {
|
|
23268
23335
|
if (typeof subscriber.createRender === "function" && subscriber.createRender() != null) {
|
|
23269
23336
|
return false;
|
|
@@ -23276,35 +23343,40 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
23276
23343
|
return false;
|
|
23277
23344
|
}
|
|
23278
23345
|
}
|
|
23279
|
-
function gateSubscriptions(
|
|
23346
|
+
function gateSubscriptions(scope, projections) {
|
|
23280
23347
|
const found = {
|
|
23281
23348
|
account: [],
|
|
23282
23349
|
reserve: [],
|
|
23283
23350
|
invalid: false
|
|
23284
23351
|
};
|
|
23285
|
-
for (const
|
|
23286
|
-
const
|
|
23287
|
-
|
|
23288
|
-
|
|
23289
|
-
if (
|
|
23290
|
-
|
|
23291
|
-
|
|
23352
|
+
for (const fiber of scope.fibers) {
|
|
23353
|
+
for (const hook of hooksOf(fiber)) {
|
|
23354
|
+
const subscription = subscriptionAt(hook, fiber);
|
|
23355
|
+
const kind = subscription && gateKind(subscription);
|
|
23356
|
+
if (subscription && kind) {
|
|
23357
|
+
if (kind !== "mixed" && snapshotsMatch(subscription, projections)) {
|
|
23358
|
+
found[kind].push(subscription);
|
|
23359
|
+
} else found.invalid = true;
|
|
23360
|
+
}
|
|
23292
23361
|
}
|
|
23293
23362
|
}
|
|
23294
23363
|
return found;
|
|
23295
23364
|
}
|
|
23296
|
-
function discoverGates(
|
|
23297
|
-
const gates = gateSubscriptions(
|
|
23365
|
+
function discoverGates(scope, projections) {
|
|
23366
|
+
const gates = gateSubscriptions(scope, projections);
|
|
23298
23367
|
if (gates.invalid) return null;
|
|
23299
|
-
const found =
|
|
23368
|
+
const found = [];
|
|
23300
23369
|
for (const kind of ["account", "reserve"]) {
|
|
23301
|
-
const
|
|
23302
|
-
|
|
23303
|
-
|
|
23370
|
+
const fibers = /* @__PURE__ */ new Set();
|
|
23371
|
+
for (const subscription of gates[kind]) {
|
|
23372
|
+
if (fibers.has(subscription.fiber)) return null;
|
|
23373
|
+
fibers.add(subscription.fiber);
|
|
23374
|
+
found.push([kind, subscription]);
|
|
23375
|
+
}
|
|
23304
23376
|
}
|
|
23305
23377
|
return found;
|
|
23306
23378
|
}
|
|
23307
|
-
function project2({ subscriber, store, atom, instance, subscribeEffect }) {
|
|
23379
|
+
function project2(kind, { fiber, subscriber, store, atom, instance, subscribeEffect }) {
|
|
23308
23380
|
for (const [target, key] of [
|
|
23309
23381
|
[store, "sub"],
|
|
23310
23382
|
[subscriber, "getSnapshot"],
|
|
@@ -23335,6 +23407,8 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
23335
23407
|
instance.getSnapshot = allowed;
|
|
23336
23408
|
if (instance.value !== false) onChange();
|
|
23337
23409
|
return {
|
|
23410
|
+
kind,
|
|
23411
|
+
fiber,
|
|
23338
23412
|
subscriber,
|
|
23339
23413
|
instance,
|
|
23340
23414
|
restore() {
|
|
@@ -23344,13 +23418,11 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
23344
23418
|
}
|
|
23345
23419
|
};
|
|
23346
23420
|
}
|
|
23347
|
-
function isBound(
|
|
23348
|
-
|
|
23349
|
-
|
|
23350
|
-
|
|
23351
|
-
|
|
23352
|
-
return bound.every(
|
|
23353
|
-
({ subscriber, instance }) => hooks.some(
|
|
23421
|
+
function isBound(projections) {
|
|
23422
|
+
return [...projections].every(({ fiber, subscriber, instance }) => {
|
|
23423
|
+
const alternate = isRecord4(fiber.alternate) ? fiber.alternate : null;
|
|
23424
|
+
return [fiber, alternate].some(
|
|
23425
|
+
(candidate) => hooksOf(candidate).some(
|
|
23354
23426
|
(hook) => Array.isArray(hook.memoizedState) && hook.memoizedState[0] === subscriber && hook.next?.queue === instance
|
|
23355
23427
|
)
|
|
23356
23428
|
);
|
|
@@ -23361,7 +23433,9 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
23361
23433
|
const projections = /* @__PURE__ */ new Map();
|
|
23362
23434
|
let retryAt = 0;
|
|
23363
23435
|
let allowed = false;
|
|
23436
|
+
const banner = createRendererCodexUsageBanner();
|
|
23364
23437
|
const release = () => {
|
|
23438
|
+
banner.restore();
|
|
23365
23439
|
const previous = [...projections.values()];
|
|
23366
23440
|
owner = null;
|
|
23367
23441
|
projections.clear();
|
|
@@ -23373,26 +23447,33 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
23373
23447
|
}
|
|
23374
23448
|
};
|
|
23375
23449
|
const bind = () => {
|
|
23376
|
-
const current =
|
|
23450
|
+
const current = findSubmitScope(composer, projections);
|
|
23377
23451
|
const gates = current && discoverGates(current, projections);
|
|
23378
|
-
if (!current || !gates?.
|
|
23452
|
+
if (!current || !gates?.some(([kind]) => kind === "reserve")) {
|
|
23453
|
+
throw new Error("Codex usage gate is unavailable");
|
|
23454
|
+
}
|
|
23379
23455
|
owner = current;
|
|
23380
23456
|
for (const [kind, gate] of gates) {
|
|
23381
|
-
if (!projections.has(
|
|
23457
|
+
if (!projections.has(gate.instance)) projections.set(gate.instance, project2(kind, gate));
|
|
23382
23458
|
}
|
|
23383
23459
|
return "bypassed";
|
|
23384
23460
|
};
|
|
23385
23461
|
const apply = () => {
|
|
23462
|
+
const status = applyGate();
|
|
23463
|
+
if (status === "bypassed" && owner) banner.hide(owner.owner);
|
|
23464
|
+
else banner.restore();
|
|
23465
|
+
return status;
|
|
23466
|
+
};
|
|
23467
|
+
const applyGate = () => {
|
|
23386
23468
|
if (!allowed || !composer.isConnected) {
|
|
23387
23469
|
release();
|
|
23388
23470
|
retryAt = 0;
|
|
23389
23471
|
return "native";
|
|
23390
23472
|
}
|
|
23391
|
-
if (owner && !isBound(
|
|
23473
|
+
if (owner && !isBound(projections.values())) {
|
|
23392
23474
|
release();
|
|
23393
23475
|
retryAt = 0;
|
|
23394
23476
|
}
|
|
23395
|
-
if (owner && projections.size === 2) return "bypassed";
|
|
23396
23477
|
if (Date.now() < retryAt) return owner ? "bypassed" : "unsupported";
|
|
23397
23478
|
retryAt = Date.now() + RETRY_DELAY_MS;
|
|
23398
23479
|
try {
|
|
@@ -23517,13 +23598,13 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
23517
23598
|
}
|
|
23518
23599
|
|
|
23519
23600
|
// src/renderer-native-thread.ts
|
|
23520
|
-
function
|
|
23601
|
+
function isRecord5(value) {
|
|
23521
23602
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23522
23603
|
}
|
|
23523
23604
|
async function verifyNativeCodexThread(sendRequest, threadId) {
|
|
23524
23605
|
const native = await sendRequest("thread/read", { threadId, includeTurns: false });
|
|
23525
|
-
const thread =
|
|
23526
|
-
if (!
|
|
23606
|
+
const thread = isRecord5(native) ? native.thread : null;
|
|
23607
|
+
if (!isRecord5(thread) || thread.id !== threadId || typeof thread.modelProvider !== "string" || !thread.modelProvider || thread.modelProvider === "codexhost" || typeof thread.cliVersion !== "string" || !thread.cliVersion || thread.cliVersion === "codexhost") {
|
|
23527
23608
|
throw new Error("Native Thread response cannot establish Codex ownership");
|
|
23528
23609
|
}
|
|
23529
23610
|
}
|
|
@@ -23602,15 +23683,15 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
23602
23683
|
var CODEX_ACCOUNT_LIST_METHOD = "codexhost/account/list";
|
|
23603
23684
|
var CODEX_ACCOUNT_REFRESH_METHOD = "codexhost/account/refresh";
|
|
23604
23685
|
var CODEX_ACCOUNT_CHANGED_METHOD = "codexhost/account/changed";
|
|
23605
|
-
function
|
|
23686
|
+
function isRecord6(value) {
|
|
23606
23687
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23607
23688
|
}
|
|
23608
23689
|
function notifiedThreadId(notification) {
|
|
23609
|
-
if (!
|
|
23690
|
+
if (!isRecord6(notification) || !THREAD_USAGE_REFRESH_METHODS.includes(notification.method)) {
|
|
23610
23691
|
return null;
|
|
23611
23692
|
}
|
|
23612
23693
|
const params = notification.params;
|
|
23613
|
-
if (!
|
|
23694
|
+
if (!isRecord6(params)) return null;
|
|
23614
23695
|
const parsed = hostThreadIdSchema.safeParse(params.threadId);
|
|
23615
23696
|
return parsed.success ? parsed.data : null;
|
|
23616
23697
|
}
|
|
@@ -23928,7 +24009,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
23928
24009
|
throw new Error("Renderer Account notification callback is unavailable");
|
|
23929
24010
|
}
|
|
23930
24011
|
return notifications.addNotificationCallback(CODEX_ACCOUNT_CHANGED_METHOD, (notification) => {
|
|
23931
|
-
if (!
|
|
24012
|
+
if (!isRecord6(notification) || notification.method !== CODEX_ACCOUNT_CHANGED_METHOD) return;
|
|
23932
24013
|
const state = codexAccountChangedSchema.safeParse(notification.params);
|
|
23933
24014
|
if (state.success) listener(state.data);
|
|
23934
24015
|
});
|
|
@@ -23937,16 +24018,16 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
23937
24018
|
}
|
|
23938
24019
|
|
|
23939
24020
|
// src/renderer-external-queue.ts
|
|
23940
|
-
function
|
|
24021
|
+
function isRecord7(value) {
|
|
23941
24022
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
23942
24023
|
}
|
|
23943
24024
|
function installRendererExternalQueue(target) {
|
|
23944
|
-
if (!
|
|
24025
|
+
if (!isRecord7(target) || typeof target.getTurnCoordinator !== "function" || typeof target.getConversation !== "function") {
|
|
23945
24026
|
return null;
|
|
23946
24027
|
}
|
|
23947
24028
|
const coordinator = target.getTurnCoordinator();
|
|
23948
|
-
const queue =
|
|
23949
|
-
if (!
|
|
24029
|
+
const queue = isRecord7(coordinator) ? coordinator.serverQueue : null;
|
|
24030
|
+
if (!isRecord7(queue) || typeof queue.isEnabled !== "function") return null;
|
|
23950
24031
|
const descriptor = Object.getOwnPropertyDescriptor(queue, "isEnabled");
|
|
23951
24032
|
if (!descriptor?.writable) return null;
|
|
23952
24033
|
const original = queue.isEnabled;
|
|
@@ -23955,7 +24036,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
23955
24036
|
const threadId = args[0];
|
|
23956
24037
|
if (typeof threadId === "string") {
|
|
23957
24038
|
const conversation = getConversation.call(target, threadId);
|
|
23958
|
-
if (
|
|
24039
|
+
if (isRecord7(conversation) && conversation.id === threadId && // Reserved transport marker from externalThreadValue, retained by
|
|
23959
24040
|
// Desktop in both newly created and hydrated conversation metadata.
|
|
23960
24041
|
conversation.modelProvider === "codexhost") {
|
|
23961
24042
|
return false;
|
|
@@ -23971,19 +24052,19 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
23971
24052
|
|
|
23972
24053
|
// src/renderer-external-steering.ts
|
|
23973
24054
|
var THREAD_OWNERSHIP_LIST_METHOD2 = "codexhost/thread/ownership/list";
|
|
23974
|
-
function
|
|
24055
|
+
function isRecord8(value) {
|
|
23975
24056
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
23976
24057
|
}
|
|
23977
24058
|
function isManager(value) {
|
|
23978
|
-
return
|
|
24059
|
+
return isRecord8(value) && ["sendRequest", "steerTurn", "startTurn", "getTurnCoordinator"].every(
|
|
23979
24060
|
(key) => typeof value[key] === "function"
|
|
23980
24061
|
);
|
|
23981
24062
|
}
|
|
23982
24063
|
function submissionHost(manager) {
|
|
23983
24064
|
const coordinator = manager.getTurnCoordinator();
|
|
23984
|
-
const options =
|
|
23985
|
-
const host =
|
|
23986
|
-
if (!
|
|
24065
|
+
const options = isRecord8(coordinator) ? coordinator.options : null;
|
|
24066
|
+
const host = isRecord8(options) ? options.submissionHost : null;
|
|
24067
|
+
if (!isRecord8(host) || typeof host.getActiveTurnId !== "function" || typeof host.hasPendingTurnStart !== "function") {
|
|
23987
24068
|
throw new Error("Desktop turn submission binding is unavailable");
|
|
23988
24069
|
}
|
|
23989
24070
|
return {
|
|
@@ -24025,20 +24106,20 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24025
24106
|
var INTERRUPTED_QUEUE_REASON = "Interrupted before the steer was accepted.";
|
|
24026
24107
|
async function preserveQueuedFollowUps(manager, threadId) {
|
|
24027
24108
|
const coordinator = manager.getTurnCoordinator();
|
|
24028
|
-
if (!
|
|
24109
|
+
if (!isRecord8(coordinator) || typeof coordinator.loadMessages !== "function" || typeof coordinator.readMessages !== "function" || typeof coordinator.mutate !== "function") {
|
|
24029
24110
|
throw new Error("Desktop follow-up queue binding is unavailable");
|
|
24030
24111
|
}
|
|
24031
24112
|
await coordinator.loadMessages.call(coordinator, threadId);
|
|
24032
24113
|
const messages = coordinator.readMessages.call(coordinator, threadId);
|
|
24033
24114
|
if (!Array.isArray(messages)) throw new Error("Desktop follow-up queue is unavailable");
|
|
24034
24115
|
const alreadyPaused = new Set(
|
|
24035
|
-
messages.filter((message2) =>
|
|
24116
|
+
messages.filter((message2) => isRecord8(message2) && message2.pausedReason != null).map((message2) => message2.id)
|
|
24036
24117
|
);
|
|
24037
24118
|
return () => {
|
|
24038
24119
|
coordinator.mutate.call(coordinator, threadId, (current) => {
|
|
24039
24120
|
if (!Array.isArray(current)) return current;
|
|
24040
24121
|
return current.map((message2) => {
|
|
24041
|
-
if (!
|
|
24122
|
+
if (!isRecord8(message2) || alreadyPaused.has(message2.id) || message2.pausedReason !== INTERRUPTED_QUEUE_REASON)
|
|
24042
24123
|
return message2;
|
|
24043
24124
|
const resumed = { ...message2 };
|
|
24044
24125
|
delete resumed.pausedReason;
|
|
@@ -24059,9 +24140,9 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24059
24140
|
if ((method === "turn/start" || method === "turn/steer") && prepareTurnInput) {
|
|
24060
24141
|
params = prepareTurnInput(params);
|
|
24061
24142
|
}
|
|
24062
|
-
const messageId =
|
|
24063
|
-
const route = typeof messageId === "string" &&
|
|
24064
|
-
if (method !== "turn/start" || !
|
|
24143
|
+
const messageId = isRecord8(params) ? params.clientUserMessageId : null;
|
|
24144
|
+
const route = typeof messageId === "string" && isRecord8(params) ? routes.get(`${params.threadId}\0${messageId}`) : void 0;
|
|
24145
|
+
if (method !== "turn/start" || !isRecord8(params) || !route || route.threadId !== params.threadId) {
|
|
24065
24146
|
if (method === "turn/start" && sendTurnStart) {
|
|
24066
24147
|
return sendTurnStart(params, (input) => {
|
|
24067
24148
|
if (disposed) throw new Error("External submission binding was disposed");
|
|
@@ -24087,7 +24168,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24087
24168
|
options
|
|
24088
24169
|
)
|
|
24089
24170
|
).then((response) => {
|
|
24090
|
-
if (!
|
|
24171
|
+
if (!isRecord8(response) || typeof response.turnId !== "string" || !response.turnId) {
|
|
24091
24172
|
throw new Error("External steering returned no replacement Turn identity");
|
|
24092
24173
|
}
|
|
24093
24174
|
return {
|
|
@@ -24118,7 +24199,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24118
24199
|
] = args;
|
|
24119
24200
|
if (typeof threadId !== "string") return originalSteer.apply(manager, args);
|
|
24120
24201
|
const role = manager.getStreamRole?.(threadId);
|
|
24121
|
-
if (
|
|
24202
|
+
if (isRecord8(role) && role.role === "follower") return originalSteer.apply(manager, args);
|
|
24122
24203
|
let host = null;
|
|
24123
24204
|
let expectedTurnId;
|
|
24124
24205
|
try {
|
|
@@ -24147,15 +24228,15 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24147
24228
|
if (owner === "codex") return originalSteer.apply(manager, args);
|
|
24148
24229
|
if (!host) throw new Error("Desktop turn submission binding is unavailable");
|
|
24149
24230
|
const currentRole = manager.getStreamRole?.(threadId);
|
|
24150
|
-
if (
|
|
24231
|
+
if (isRecord8(currentRole) && currentRole.role === "follower")
|
|
24151
24232
|
return originalSteer.apply(manager, args);
|
|
24152
24233
|
if (!Array.isArray(input) || input.length === 0 || input.some(
|
|
24153
|
-
(item) => !
|
|
24154
|
-
) || !input.some((item) =>
|
|
24234
|
+
(item) => !isRecord8(item) || item.type !== "text" || typeof item.text !== "string"
|
|
24235
|
+
) || !input.some((item) => isRecord8(item) && typeof item.text === "string" && item.text.trim())) {
|
|
24155
24236
|
throw new Error("External steering requires non-empty text input");
|
|
24156
24237
|
}
|
|
24157
24238
|
if (toolOutput != null) throw new Error("External steering cannot replace a tool response");
|
|
24158
|
-
if (!
|
|
24239
|
+
if (!isRecord8(restoreMessage) || !isRecord8(restoreMessage.context)) {
|
|
24159
24240
|
throw new Error("Desktop steering message context is unavailable");
|
|
24160
24241
|
}
|
|
24161
24242
|
const messageId = typeof clientUserMessageId === "string" && clientUserMessageId ? clientUserMessageId : typeof restoreMessage.id === "string" && restoreMessage.id ? restoreMessage.id : crypto.randomUUID();
|
|
@@ -24203,7 +24284,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24203
24284
|
},
|
|
24204
24285
|
onMessageAdded
|
|
24205
24286
|
);
|
|
24206
|
-
if (!
|
|
24287
|
+
if (!isRecord8(response) || !isRecord8(response.turn) || typeof response.turn.id !== "string") {
|
|
24207
24288
|
throw new Error("Desktop returned no replacement Turn identity");
|
|
24208
24289
|
}
|
|
24209
24290
|
try {
|
|
@@ -24234,7 +24315,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24234
24315
|
}
|
|
24235
24316
|
|
|
24236
24317
|
// src/renderer-remote-attachments.ts
|
|
24237
|
-
function
|
|
24318
|
+
function isRecord9(value) {
|
|
24238
24319
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
24239
24320
|
}
|
|
24240
24321
|
var MAX_IMAGE_BYTES = 20 * 1024 * 1024;
|
|
@@ -24286,14 +24367,14 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24286
24367
|
function createRemoteAttachmentSender(target, hostId2, isCurrent) {
|
|
24287
24368
|
const prepared = /* @__PURE__ */ new WeakMap();
|
|
24288
24369
|
return (params, send) => {
|
|
24289
|
-
if (hostId2 === "local" || !
|
|
24370
|
+
if (hostId2 === "local" || !isRecord9(target) || !isRecord9(params) || typeof params.threadId !== "string" || !Array.isArray(params.input) || typeof target.getConversation !== "function")
|
|
24290
24371
|
return send(params);
|
|
24291
24372
|
const images = params.input.filter(
|
|
24292
|
-
(item) =>
|
|
24373
|
+
(item) => isRecord9(item) && (item.type === "image" || item.type === "localImage")
|
|
24293
24374
|
);
|
|
24294
24375
|
if (images.length === 0) return send(params);
|
|
24295
24376
|
const conversation = target.getConversation.call(target, params.threadId);
|
|
24296
|
-
if (!
|
|
24377
|
+
if (!isRecord9(conversation) || conversation.id !== params.threadId || conversation.modelProvider !== "codexhost")
|
|
24297
24378
|
return send(params);
|
|
24298
24379
|
const assertCurrent = () => {
|
|
24299
24380
|
if (!isCurrent()) throw new Error("Remote attachment connection is no longer available");
|
|
@@ -24306,7 +24387,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24306
24387
|
const cached2 = prepared.get(params);
|
|
24307
24388
|
if (cached2) return cached2.then(dispatch);
|
|
24308
24389
|
const input = params.input;
|
|
24309
|
-
const text = input.filter((item) =>
|
|
24390
|
+
const text = input.filter((item) => isRecord9(item) && item.type === "text").map((item) => isRecord9(item) && typeof item.text === "string" ? item.text : "").join("\n");
|
|
24310
24391
|
const existingPaths = nativeImagePaths(text);
|
|
24311
24392
|
const prepare = async () => {
|
|
24312
24393
|
if (existingPaths.length === images.length) return params;
|
|
@@ -24338,7 +24419,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24338
24419
|
contents: file2.contents,
|
|
24339
24420
|
label: `image-${index + 1}.${file2.extension}`
|
|
24340
24421
|
});
|
|
24341
|
-
if (!
|
|
24422
|
+
if (!isRecord9(saved) || !filePath(saved.path) || saved.fsPath !== saved.path) {
|
|
24342
24423
|
throw new Error("Desktop returned an invalid remote attachment path");
|
|
24343
24424
|
}
|
|
24344
24425
|
created.push(saved.path);
|
|
@@ -24445,11 +24526,11 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
24445
24526
|
}
|
|
24446
24527
|
|
|
24447
24528
|
// src/renderer-manual-compaction.ts
|
|
24448
|
-
function
|
|
24529
|
+
function isRecord10(value) {
|
|
24449
24530
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
24450
24531
|
}
|
|
24451
24532
|
function installRendererManualCompaction(target, hostId2, messages) {
|
|
24452
|
-
if (!messages || typeof messages.addEventListener !== "function" || typeof messages.removeEventListener !== "function" || !
|
|
24533
|
+
if (!messages || typeof messages.addEventListener !== "function" || typeof messages.removeEventListener !== "function" || !isRecord10(target) || typeof target.registerPendingManualContextCompaction !== "function" || typeof target.getConversation !== "function") {
|
|
24453
24534
|
return null;
|
|
24454
24535
|
}
|
|
24455
24536
|
const register = target.registerPendingManualContextCompaction;
|
|
@@ -24458,18 +24539,18 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
24458
24539
|
const listener = (event) => {
|
|
24459
24540
|
if (event.source != null && event.source !== messages) return;
|
|
24460
24541
|
const message2 = event.data;
|
|
24461
|
-
if (!
|
|
24542
|
+
if (!isRecord10(message2) || message2.type !== "mcp-notification" || message2.hostId !== hostId2 || message2.method !== THREAD_MANUAL_COMPACTION_STARTED_METHOD) {
|
|
24462
24543
|
return;
|
|
24463
24544
|
}
|
|
24464
24545
|
const params = threadManualCompactionStartedSchema.safeParse(message2.params);
|
|
24465
24546
|
if (!params.success) return;
|
|
24466
24547
|
const { threadId } = params.data;
|
|
24467
24548
|
const conversation = getConversation.call(target, threadId);
|
|
24468
|
-
if (!
|
|
24549
|
+
if (!isRecord10(conversation) || conversation.id !== threadId || conversation.modelProvider !== "codexhost") {
|
|
24469
24550
|
return;
|
|
24470
24551
|
}
|
|
24471
24552
|
const role = getStreamRole?.call(target, threadId);
|
|
24472
|
-
if (
|
|
24553
|
+
if (isRecord10(role) && role.role === "follower") return;
|
|
24473
24554
|
register.call(target, threadId);
|
|
24474
24555
|
};
|
|
24475
24556
|
messages.addEventListener("message", listener);
|
|
@@ -24684,7 +24765,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
24684
24765
|
var SIDEBAR_THREAD_HOST_ID_ATTRIBUTE = "data-app-action-sidebar-thread-host-id";
|
|
24685
24766
|
var SIDEBAR_AGENT_ICON_ATTRIBUTE = "data-codexhost-sidebar-agent-icon";
|
|
24686
24767
|
var OWNERSHIP_RETRY_DELAYS_MS = [100, 300, 800, 1500, 3e3];
|
|
24687
|
-
function
|
|
24768
|
+
function isRecord11(value) {
|
|
24688
24769
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24689
24770
|
}
|
|
24690
24771
|
function sidebarThreadAttributes(element) {
|
|
@@ -24711,19 +24792,19 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
24711
24792
|
const fiberName = fiberNames[0];
|
|
24712
24793
|
if (fiberNames.length !== 1 || !fiberName) return null;
|
|
24713
24794
|
const firstFiber2 = Object.getOwnPropertyDescriptor(element, fiberName)?.value;
|
|
24714
|
-
if (!
|
|
24795
|
+
if (!isRecord11(firstFiber2)) return null;
|
|
24715
24796
|
const candidates = /* @__PURE__ */ new Set();
|
|
24716
24797
|
let fiber = firstFiber2;
|
|
24717
24798
|
for (let depth = 0; fiber && depth < 12; depth += 1) {
|
|
24718
24799
|
const props = fiber.memoizedProps;
|
|
24719
|
-
if (
|
|
24800
|
+
if (isRecord11(props) && isRecord11(props.dataAttributes)) {
|
|
24720
24801
|
const dataAttributes = props.dataAttributes;
|
|
24721
24802
|
const threadId = hostThreadIdSchema.safeParse(props.conversationId);
|
|
24722
24803
|
if (threadId.success && dataAttributes[SIDEBAR_THREAD_ROW_ATTRIBUTE] === rowMarker && dataAttributes[SIDEBAR_THREAD_ID_ATTRIBUTE] === taskKey && dataAttributes[SIDEBAR_THREAD_HOST_ID_ATTRIBUTE] === hostId2) {
|
|
24723
24804
|
candidates.add(threadId.data);
|
|
24724
24805
|
}
|
|
24725
24806
|
}
|
|
24726
|
-
fiber =
|
|
24807
|
+
fiber = isRecord11(fiber.return) ? fiber.return : null;
|
|
24727
24808
|
}
|
|
24728
24809
|
return candidates.size === 1 ? candidates.values().next().value ?? null : null;
|
|
24729
24810
|
}
|
|
@@ -25133,7 +25214,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25133
25214
|
if (row) finish(row);
|
|
25134
25215
|
});
|
|
25135
25216
|
}
|
|
25136
|
-
function
|
|
25217
|
+
function isRecord12(value) {
|
|
25137
25218
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25138
25219
|
}
|
|
25139
25220
|
function firstFiber(element) {
|
|
@@ -25143,7 +25224,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25143
25224
|
const name = names[0];
|
|
25144
25225
|
if (names.length !== 1 || !name) return null;
|
|
25145
25226
|
const value = Object.getOwnPropertyDescriptor(element, name)?.value;
|
|
25146
|
-
return
|
|
25227
|
+
return isRecord12(value) ? value : null;
|
|
25147
25228
|
}
|
|
25148
25229
|
function directForkAncestors(first) {
|
|
25149
25230
|
const ancestors = [];
|
|
@@ -25153,7 +25234,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25153
25234
|
if (seen.has(fiber)) return [];
|
|
25154
25235
|
seen.add(fiber);
|
|
25155
25236
|
ancestors.push(fiber);
|
|
25156
|
-
fiber =
|
|
25237
|
+
fiber = isRecord12(fiber.return) ? fiber.return : null;
|
|
25157
25238
|
}
|
|
25158
25239
|
return ancestors;
|
|
25159
25240
|
}
|
|
@@ -25171,7 +25252,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25171
25252
|
let hasForkCallback = false;
|
|
25172
25253
|
for (const fiber of ancestors) {
|
|
25173
25254
|
const props = fiber.memoizedProps;
|
|
25174
|
-
if (!
|
|
25255
|
+
if (!isRecord12(props)) continue;
|
|
25175
25256
|
if (!hasForkCallback && typeof props.onFork !== "function" && ownsOtherCallback(fiber, props)) {
|
|
25176
25257
|
return null;
|
|
25177
25258
|
}
|
|
@@ -25203,7 +25284,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25203
25284
|
if (!threadId.success || !turnId.success) return null;
|
|
25204
25285
|
const fiber = firstFiber(button2);
|
|
25205
25286
|
const buttonProps = fiber?.memoizedProps;
|
|
25206
|
-
if (!fiber || !
|
|
25287
|
+
if (!fiber || !isRecord12(buttonProps) || !Object.hasOwn(buttonProps, "aria-busy")) return null;
|
|
25207
25288
|
return forkTargetFromAncestors(button2, threadId.data, turnId.data, directForkAncestors(fiber)) ?? forkTargetFromAncestors(button2, threadId.data, turnId.data, committedReactAncestors(fiber));
|
|
25208
25289
|
}
|
|
25209
25290
|
var BrowserRendererForkDom = class {
|
|
@@ -25293,7 +25374,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25293
25374
|
}
|
|
25294
25375
|
var DRAFT_PREWARM_POLICY_WAIT_TIMEOUT_MS = 1e4;
|
|
25295
25376
|
var DRAFT_PREWARM_POLICY_POLL_INTERVAL_MS = 25;
|
|
25296
|
-
function
|
|
25377
|
+
function isRecord13(value) {
|
|
25297
25378
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25298
25379
|
}
|
|
25299
25380
|
function decodeOpenCodeTransportModelId(value) {
|
|
@@ -25458,7 +25539,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25458
25539
|
let fiber = findComposerFiber(composer);
|
|
25459
25540
|
for (let depth = 0; fiber && depth < 120; depth += 1) {
|
|
25460
25541
|
const props = fiber.memoizedProps;
|
|
25461
|
-
if (
|
|
25542
|
+
if (isRecord13(props) && "conversationId" in props && props.conversationId != null) {
|
|
25462
25543
|
const candidate = hostThreadIdSchema.safeParse(props.conversationId);
|
|
25463
25544
|
if (!candidate.success || threadId !== void 0 && threadId !== candidate.data) {
|
|
25464
25545
|
return null;
|
|
@@ -25471,12 +25552,12 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25471
25552
|
return threadId;
|
|
25472
25553
|
}
|
|
25473
25554
|
function isLegacySevenSlotDraftWrapper(value) {
|
|
25474
|
-
if (!Array.isArray(value) || value.length !== 7 || value[3] !== value[5] || value[3] !== value[6] || !
|
|
25555
|
+
if (!Array.isArray(value) || value.length !== 7 || value[3] !== value[5] || value[3] !== value[6] || !isRecord13(value[3]) || typeof value[3].get !== "function" || typeof value[2] !== "string" && value[2] !== null) {
|
|
25475
25556
|
return false;
|
|
25476
25557
|
}
|
|
25477
25558
|
try {
|
|
25478
25559
|
const draft = value[3].get();
|
|
25479
|
-
return
|
|
25560
|
+
return isRecord13(draft) && "modelSettings" in draft && "isManuallyChanged" in draft;
|
|
25480
25561
|
} catch {
|
|
25481
25562
|
return false;
|
|
25482
25563
|
}
|
|
@@ -25510,8 +25591,8 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25510
25591
|
let fiber = findComposerFiber(composer);
|
|
25511
25592
|
for (let depth = 0; fiber && depth < 120; depth += 1) {
|
|
25512
25593
|
const updateQueue = fiber.updateQueue;
|
|
25513
|
-
const memoCache =
|
|
25514
|
-
const data =
|
|
25594
|
+
const memoCache = isRecord13(updateQueue) ? updateQueue.memoCache : null;
|
|
25595
|
+
const data = isRecord13(memoCache) && Array.isArray(memoCache.data) ? memoCache.data : [];
|
|
25515
25596
|
for (const value of data) {
|
|
25516
25597
|
const draftId = draftIdFromMemoValue(value);
|
|
25517
25598
|
if (draftId) draftIds.add(draftId);
|
|
@@ -25539,7 +25620,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25539
25620
|
return ["default", draftIds.values().next().value];
|
|
25540
25621
|
}
|
|
25541
25622
|
function isDraftPrewarmPolicyReady(value) {
|
|
25542
|
-
return
|
|
25623
|
+
return isRecord13(value) && value.state === "ready" && typeof value.hostId === "string" && value.hostId.length > 0 && typeof value.select === "function" && typeof value.clear === "function";
|
|
25543
25624
|
}
|
|
25544
25625
|
async function waitForRendererDraftPrewarmPolicy(target, composer) {
|
|
25545
25626
|
const deadline = Date.now() + DRAFT_PREWARM_POLICY_WAIT_TIMEOUT_MS;
|
|
@@ -25805,11 +25886,11 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25805
25886
|
return null;
|
|
25806
25887
|
}
|
|
25807
25888
|
}
|
|
25808
|
-
function
|
|
25889
|
+
function isRecord14(value) {
|
|
25809
25890
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25810
25891
|
}
|
|
25811
25892
|
function parseExternalConfiguration(value) {
|
|
25812
|
-
if (!
|
|
25893
|
+
if (!isRecord14(value)) return void 0;
|
|
25813
25894
|
const model2 = harnessModelRefSchema.safeParse(value.model);
|
|
25814
25895
|
if (!model2.success) return void 0;
|
|
25815
25896
|
const thinkingOptionId = harnessThinkingOptionIdSchema.safeParse(value.thinkingOptionId);
|
|
@@ -25826,10 +25907,10 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25826
25907
|
const raw = storage.getItem(RENDERER_NEW_THREAD_PREFERENCE_KEY);
|
|
25827
25908
|
if (!raw) return void 0;
|
|
25828
25909
|
const parsed = JSON.parse(raw);
|
|
25829
|
-
if (!
|
|
25910
|
+
if (!isRecord14(parsed) || parsed.version !== 1) return void 0;
|
|
25830
25911
|
if (parsed.lastAgent !== "codex" && !harnessPluginIdSchema.safeParse(parsed.lastAgent).success)
|
|
25831
25912
|
return void 0;
|
|
25832
|
-
const externalByAgent =
|
|
25913
|
+
const externalByAgent = isRecord14(parsed.externalByAgent) ? parsed.externalByAgent : {};
|
|
25833
25914
|
const parsedExternal = Object.fromEntries(
|
|
25834
25915
|
Object.keys(externalByAgent).filter((agent) => harnessPluginIdSchema.safeParse(agent).success).flatMap((agent) => {
|
|
25835
25916
|
const configuration = parseExternalConfiguration(externalByAgent[agent]);
|
|
@@ -25955,7 +26036,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25955
26036
|
var GET_LOCALE_OVERRIDE_URL = "vscode://codex/get-setting";
|
|
25956
26037
|
var GET_LOCALE_INFO_URL = "vscode://codex/locale-info";
|
|
25957
26038
|
var DEFAULT_LOCALE_REQUEST_TIMEOUT_MS = 750;
|
|
25958
|
-
function
|
|
26039
|
+
function isRecord15(value) {
|
|
25959
26040
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25960
26041
|
}
|
|
25961
26042
|
function canonicalLocale(value) {
|
|
@@ -25977,7 +26058,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25977
26058
|
return new DOMException("The operation was aborted", "AbortError");
|
|
25978
26059
|
}
|
|
25979
26060
|
function parseLocaleOverride(value) {
|
|
25980
|
-
if (!
|
|
26061
|
+
if (!isRecord15(value) || !("value" in value)) {
|
|
25981
26062
|
throw new Error("Codex locale override response is malformed");
|
|
25982
26063
|
}
|
|
25983
26064
|
if (value.value === null) return { value: null };
|
|
@@ -25992,7 +26073,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25992
26073
|
return locale;
|
|
25993
26074
|
}
|
|
25994
26075
|
function parseLocaleInfo(value) {
|
|
25995
|
-
if (!
|
|
26076
|
+
if (!isRecord15(value)) throw new Error("Codex locale info response is malformed");
|
|
25996
26077
|
return {
|
|
25997
26078
|
ideLocale: optionalLocale(value.ideLocale, "IDE locale"),
|
|
25998
26079
|
systemLocale: optionalLocale(value.systemLocale, "system locale")
|
|
@@ -26021,7 +26102,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
26021
26102
|
const onAbort = () => settle(() => reject(abortError2()));
|
|
26022
26103
|
const onMessage = (event) => {
|
|
26023
26104
|
const message3 = event.data;
|
|
26024
|
-
if (!
|
|
26105
|
+
if (!isRecord15(message3) || message3.type !== "fetch-response") return;
|
|
26025
26106
|
if (message3.requestId !== requestId) return;
|
|
26026
26107
|
if (message3.responseType !== "success" || typeof message3.status !== "number" || message3.status < 200 || message3.status >= 300 || typeof message3.bodyJsonString !== "string") {
|
|
26027
26108
|
settle(() => reject(new Error("Codex locale request failed")));
|
|
@@ -41673,8 +41754,127 @@ ${usage_default}`;
|
|
|
41673
41754
|
return binding;
|
|
41674
41755
|
}
|
|
41675
41756
|
|
|
41757
|
+
// src/renderer-external-voice-launch.ts
|
|
41758
|
+
var HOOK_GLOBAL = "__codexhostExternalVoiceLaunchV1";
|
|
41759
|
+
var SHARED_ASSET = "app-shared-8bd9d0399038.js";
|
|
41760
|
+
function isRecord16(value) {
|
|
41761
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41762
|
+
}
|
|
41763
|
+
function routeExternalVoiceLaunch(request, routing) {
|
|
41764
|
+
if (!routing || !isRecord16(request) || request.source !== "composer_button_new_thread")
|
|
41765
|
+
return request;
|
|
41766
|
+
const hostId2 = request.hostId ?? "local";
|
|
41767
|
+
if (typeof hostId2 !== "string" || !hostId2) return request;
|
|
41768
|
+
const route = routing.forComposer();
|
|
41769
|
+
if (!route || route.hostId !== hostId2 || routing.forHost(hostId2) !== route) return request;
|
|
41770
|
+
const model2 = route.policy.selectedModel();
|
|
41771
|
+
if (!model2?.startsWith("codexhost/")) return request;
|
|
41772
|
+
const mode = request.activeCollaborationMode;
|
|
41773
|
+
if (mode !== void 0 && mode !== null && !isRecord16(mode)) return request;
|
|
41774
|
+
const settings = isRecord16(mode) ? mode.settings : void 0;
|
|
41775
|
+
if (settings !== void 0 && settings !== null && !isRecord16(settings)) return request;
|
|
41776
|
+
return {
|
|
41777
|
+
...request,
|
|
41778
|
+
activeCollaborationMode: {
|
|
41779
|
+
...isRecord16(mode) ? mode : { mode: "default" },
|
|
41780
|
+
settings: {
|
|
41781
|
+
reasoning_effort: null,
|
|
41782
|
+
developer_instructions: null,
|
|
41783
|
+
...isRecord16(settings) ? settings : {},
|
|
41784
|
+
model: model2
|
|
41785
|
+
}
|
|
41786
|
+
}
|
|
41787
|
+
};
|
|
41788
|
+
}
|
|
41789
|
+
function installExternalVoiceLaunchHook(options = {}) {
|
|
41790
|
+
const target = options.target ?? globalThis;
|
|
41791
|
+
const existing = target[HOOK_GLOBAL];
|
|
41792
|
+
if (existing) return existing;
|
|
41793
|
+
const config2 = readCpaLiveVoiceHookConfig(target);
|
|
41794
|
+
if (!config2) return { status: "disabled", dispose() {
|
|
41795
|
+
} };
|
|
41796
|
+
if (config2.auditedDesktopVersion !== AUDITED_CPA_LIVE_VOICE_DESKTOP_VERSION || config2.auditedAppInitialAsset !== AUDITED_CPA_LIVE_VOICE_APP_INITIAL_ASSET || config2.desktopVersion !== void 0 && config2.desktopVersion !== config2.auditedDesktopVersion)
|
|
41797
|
+
return { status: "unsupported", dispose() {
|
|
41798
|
+
} };
|
|
41799
|
+
const importModule = options.importModule ?? ((url2) => import(url2));
|
|
41800
|
+
let disposed = false;
|
|
41801
|
+
let timer;
|
|
41802
|
+
let restore;
|
|
41803
|
+
let module;
|
|
41804
|
+
const started = Date.now();
|
|
41805
|
+
const handle = {
|
|
41806
|
+
status: "pending",
|
|
41807
|
+
dispose() {
|
|
41808
|
+
disposed = true;
|
|
41809
|
+
if (timer !== void 0) target.clearTimeout(timer);
|
|
41810
|
+
restore?.();
|
|
41811
|
+
if (target[HOOK_GLOBAL] === handle) Reflect.deleteProperty(target, HOOK_GLOBAL);
|
|
41812
|
+
}
|
|
41813
|
+
};
|
|
41814
|
+
target[HOOK_GLOBAL] = handle;
|
|
41815
|
+
const attempt = async () => {
|
|
41816
|
+
if (disposed) return;
|
|
41817
|
+
try {
|
|
41818
|
+
const names = target.performance?.getEntriesByType("resource").map((entry) => entry.name) ?? [];
|
|
41819
|
+
for (const element of target.document?.querySelectorAll("script[src], link[href]") ?? []) {
|
|
41820
|
+
const name = element.getAttribute("src") ?? element.getAttribute("href");
|
|
41821
|
+
if (name) names.push(name);
|
|
41822
|
+
}
|
|
41823
|
+
if (auditedAppInitialAssetPresent(names, AUDITED_CPA_LIVE_VOICE_APP_INITIAL_ASSET) && auditedAppInitialAssetPresent(names, SHARED_ASSET)) {
|
|
41824
|
+
module ??= await importModule(`app://-/assets/${SHARED_ASSET}`);
|
|
41825
|
+
if (disposed) return;
|
|
41826
|
+
const services = module?.fN;
|
|
41827
|
+
if (isRecord16(services)) {
|
|
41828
|
+
const original = services.realtimeVoiceRuntime;
|
|
41829
|
+
if (typeof original === "function" || isRecord16(original)) {
|
|
41830
|
+
const start = Reflect.get(original, "requestRealtimeStart");
|
|
41831
|
+
if (typeof start !== "function") {
|
|
41832
|
+
handle.status = "unsupported";
|
|
41833
|
+
return;
|
|
41834
|
+
}
|
|
41835
|
+
const launch = (...args) => {
|
|
41836
|
+
let request = args[0];
|
|
41837
|
+
try {
|
|
41838
|
+
request = routeExternalVoiceLaunch(request, target.__codexhostHostRoutingV1);
|
|
41839
|
+
} catch {
|
|
41840
|
+
}
|
|
41841
|
+
return Reflect.apply(start, original, [request, ...args.slice(1)]);
|
|
41842
|
+
};
|
|
41843
|
+
const wrapped = new Proxy(original, {
|
|
41844
|
+
get(service, key, receiver) {
|
|
41845
|
+
return key === "requestRealtimeStart" ? launch : Reflect.get(service, key, receiver);
|
|
41846
|
+
}
|
|
41847
|
+
});
|
|
41848
|
+
if (!Reflect.set(services, "realtimeVoiceRuntime", wrapped)) {
|
|
41849
|
+
handle.status = "unsupported";
|
|
41850
|
+
return;
|
|
41851
|
+
}
|
|
41852
|
+
restore = () => {
|
|
41853
|
+
if (services.realtimeVoiceRuntime === wrapped)
|
|
41854
|
+
services.realtimeVoiceRuntime = original;
|
|
41855
|
+
};
|
|
41856
|
+
handle.status = "active";
|
|
41857
|
+
return;
|
|
41858
|
+
}
|
|
41859
|
+
}
|
|
41860
|
+
}
|
|
41861
|
+
} catch {
|
|
41862
|
+
handle.status = "unsupported";
|
|
41863
|
+
return;
|
|
41864
|
+
}
|
|
41865
|
+
if (Date.now() - started >= 6e4) {
|
|
41866
|
+
handle.status = "unsupported";
|
|
41867
|
+
return;
|
|
41868
|
+
}
|
|
41869
|
+
timer = target.setTimeout(() => void attempt(), 250);
|
|
41870
|
+
};
|
|
41871
|
+
void attempt();
|
|
41872
|
+
return handle;
|
|
41873
|
+
}
|
|
41874
|
+
|
|
41676
41875
|
// src/production-entry.ts
|
|
41677
41876
|
installCpaLiveVoiceHook();
|
|
41877
|
+
installExternalVoiceLaunchHook();
|
|
41678
41878
|
var installBinding = () => {
|
|
41679
41879
|
installRendererBinding();
|
|
41680
41880
|
};
|