@liberseek/boft-cli-win32-arm64 0.6.3 → 0.6.4
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/host-runtime.mjs +22 -4
- package/app/plugins/grok/plugin.mjs +914 -85
- package/app/renderer-extension.js +644 -8
- 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
|
@@ -23538,6 +23538,640 @@ ${error51.stderrTail}`] : []
|
|
|
23538
23538
|
return () => style.remove();
|
|
23539
23539
|
}
|
|
23540
23540
|
|
|
23541
|
+
// src/renderer-subagent-thread-model.ts
|
|
23542
|
+
function isRecord7(value) {
|
|
23543
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23544
|
+
}
|
|
23545
|
+
function nonBlank(value) {
|
|
23546
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
23547
|
+
}
|
|
23548
|
+
function threadFromReadResult(value, expectedThreadId) {
|
|
23549
|
+
if (!isRecord7(value)) return null;
|
|
23550
|
+
const directThread = isRecord7(value.thread) ? value.thread : null;
|
|
23551
|
+
const nestedThread = isRecord7(value.result) && isRecord7(value.result.thread) ? value.result.thread : null;
|
|
23552
|
+
const thread = directThread ?? nestedThread;
|
|
23553
|
+
if (!thread) return null;
|
|
23554
|
+
if (expectedThreadId && (!nonBlank(thread.id) || thread.id.trim() !== expectedThreadId)) {
|
|
23555
|
+
return null;
|
|
23556
|
+
}
|
|
23557
|
+
return thread;
|
|
23558
|
+
}
|
|
23559
|
+
function rendererThreadRequestTarget() {
|
|
23560
|
+
if (typeof window === "undefined") return null;
|
|
23561
|
+
const policy = window.__codexhostDraftPrewarmPolicyV1;
|
|
23562
|
+
if (typeof policy?.requestTarget !== "function") return null;
|
|
23563
|
+
try {
|
|
23564
|
+
const target = policy.requestTarget();
|
|
23565
|
+
return isRecord7(target) && typeof target.sendRequest === "function" ? target : null;
|
|
23566
|
+
} catch {
|
|
23567
|
+
return null;
|
|
23568
|
+
}
|
|
23569
|
+
}
|
|
23570
|
+
function isParentComposerModelLabel(model) {
|
|
23571
|
+
const head = model.includes(" \xB7 ") ? model.split(" \xB7 ")[0]?.trim() ?? "" : model;
|
|
23572
|
+
if (!head) return false;
|
|
23573
|
+
if (/^(grok|gpt|o\d|claude|codex)/i.test(head)) return false;
|
|
23574
|
+
return model.includes(" \xB7 ");
|
|
23575
|
+
}
|
|
23576
|
+
function usableThreadModel(value) {
|
|
23577
|
+
if (!nonBlank(value) || isParentComposerModelLabel(value)) return void 0;
|
|
23578
|
+
return value.trim();
|
|
23579
|
+
}
|
|
23580
|
+
function subagentThreadModelFromReadResult(value, expectedThreadId) {
|
|
23581
|
+
const thread = threadFromReadResult(value, expectedThreadId);
|
|
23582
|
+
if (!thread) return null;
|
|
23583
|
+
const model = usableThreadModel(thread.model) ?? usableThreadModel(thread.latestModel) ?? usableThreadModel(thread.resolvedModelLabel);
|
|
23584
|
+
const reasoningEffort = usableThreadModel(thread.reasoningEffort) ?? usableThreadModel(thread.latestReasoningEffort);
|
|
23585
|
+
if (!model && !reasoningEffort) return null;
|
|
23586
|
+
return {
|
|
23587
|
+
...model ? { model } : {},
|
|
23588
|
+
...reasoningEffort ? { reasoningEffort } : {}
|
|
23589
|
+
};
|
|
23590
|
+
}
|
|
23591
|
+
async function readSubagentThreadModelFromTarget(target, threadId) {
|
|
23592
|
+
const result = await target.sendRequest("thread/read", {
|
|
23593
|
+
threadId,
|
|
23594
|
+
includeTurns: false
|
|
23595
|
+
});
|
|
23596
|
+
return subagentThreadModelFromReadResult(result, threadId);
|
|
23597
|
+
}
|
|
23598
|
+
async function readRendererSubagentThreadModel(threadId) {
|
|
23599
|
+
const target = rendererThreadRequestTarget();
|
|
23600
|
+
if (!target) return null;
|
|
23601
|
+
return readSubagentThreadModelFromTarget(target, threadId);
|
|
23602
|
+
}
|
|
23603
|
+
function subagentStatusFromReadResult(value, expectedThreadId) {
|
|
23604
|
+
const thread = threadFromReadResult(value, expectedThreadId);
|
|
23605
|
+
if (!thread) return null;
|
|
23606
|
+
const threadStatus = isRecord7(thread.status) && nonBlank(thread.status.type) ? thread.status.type : void 0;
|
|
23607
|
+
if (threadStatus === "systemError") return "failed";
|
|
23608
|
+
const turns = Array.isArray(thread.turns) ? thread.turns : [];
|
|
23609
|
+
const lastTurn = [...turns].reverse().find(isRecord7);
|
|
23610
|
+
const turnStatus = lastTurn && nonBlank(lastTurn.status) ? lastTurn.status : void 0;
|
|
23611
|
+
if (turnStatus === "completed") return "completed";
|
|
23612
|
+
if (turnStatus === "failed") return "failed";
|
|
23613
|
+
if (turnStatus === "interrupted" || turnStatus === "cancelled") return "interrupted";
|
|
23614
|
+
if (turnStatus === "inProgress" || turnStatus === "running") return "running";
|
|
23615
|
+
if (turnStatus === "pending" || turnStatus === "queued") return "waiting";
|
|
23616
|
+
if (threadStatus === "active") return "running";
|
|
23617
|
+
return null;
|
|
23618
|
+
}
|
|
23619
|
+
async function readRendererSubagentStatus(threadId) {
|
|
23620
|
+
const target = rendererThreadRequestTarget();
|
|
23621
|
+
if (!target) return null;
|
|
23622
|
+
const result = await target.sendRequest("thread/read", {
|
|
23623
|
+
threadId,
|
|
23624
|
+
includeTurns: true
|
|
23625
|
+
});
|
|
23626
|
+
return subagentStatusFromReadResult(result, threadId);
|
|
23627
|
+
}
|
|
23628
|
+
function createSubagentThreadModelResolver(options) {
|
|
23629
|
+
const models = /* @__PURE__ */ new Map();
|
|
23630
|
+
const pending = /* @__PURE__ */ new Set();
|
|
23631
|
+
const attempts = /* @__PURE__ */ new Map();
|
|
23632
|
+
const retryTimers = /* @__PURE__ */ new Map();
|
|
23633
|
+
const maxAttempts = options.maxAttempts ?? 3;
|
|
23634
|
+
const retryDelayMs = options.retryDelayMs ?? 1e3;
|
|
23635
|
+
let disposed = false;
|
|
23636
|
+
const ensure = (threadId) => {
|
|
23637
|
+
if (disposed || !threadId || models.has(threadId) || pending.has(threadId)) return;
|
|
23638
|
+
const attempt = (attempts.get(threadId) ?? 0) + 1;
|
|
23639
|
+
if (attempt > maxAttempts) return;
|
|
23640
|
+
attempts.set(threadId, attempt);
|
|
23641
|
+
pending.add(threadId);
|
|
23642
|
+
void options.read(threadId).then(
|
|
23643
|
+
(snapshot) => {
|
|
23644
|
+
if (disposed) return;
|
|
23645
|
+
if (snapshot) {
|
|
23646
|
+
models.set(threadId, snapshot);
|
|
23647
|
+
attempts.delete(threadId);
|
|
23648
|
+
options.onUpdate();
|
|
23649
|
+
return;
|
|
23650
|
+
}
|
|
23651
|
+
if (attempt >= maxAttempts || retryTimers.has(threadId)) return;
|
|
23652
|
+
retryTimers.set(
|
|
23653
|
+
threadId,
|
|
23654
|
+
setTimeout(() => {
|
|
23655
|
+
retryTimers.delete(threadId);
|
|
23656
|
+
ensure(threadId);
|
|
23657
|
+
}, retryDelayMs)
|
|
23658
|
+
);
|
|
23659
|
+
},
|
|
23660
|
+
() => {
|
|
23661
|
+
if (disposed || attempt >= maxAttempts || retryTimers.has(threadId)) return;
|
|
23662
|
+
retryTimers.set(
|
|
23663
|
+
threadId,
|
|
23664
|
+
setTimeout(() => {
|
|
23665
|
+
retryTimers.delete(threadId);
|
|
23666
|
+
ensure(threadId);
|
|
23667
|
+
}, retryDelayMs)
|
|
23668
|
+
);
|
|
23669
|
+
}
|
|
23670
|
+
).finally(() => {
|
|
23671
|
+
pending.delete(threadId);
|
|
23672
|
+
});
|
|
23673
|
+
};
|
|
23674
|
+
return {
|
|
23675
|
+
get(threadId) {
|
|
23676
|
+
return models.get(threadId);
|
|
23677
|
+
},
|
|
23678
|
+
ensure,
|
|
23679
|
+
refresh() {
|
|
23680
|
+
if (disposed) return;
|
|
23681
|
+
for (const threadId of [...attempts.keys()]) {
|
|
23682
|
+
if (pending.has(threadId) || retryTimers.has(threadId)) continue;
|
|
23683
|
+
attempts.delete(threadId);
|
|
23684
|
+
ensure(threadId);
|
|
23685
|
+
}
|
|
23686
|
+
},
|
|
23687
|
+
dispose() {
|
|
23688
|
+
if (disposed) return;
|
|
23689
|
+
disposed = true;
|
|
23690
|
+
for (const timer of retryTimers.values()) clearTimeout(timer);
|
|
23691
|
+
retryTimers.clear();
|
|
23692
|
+
pending.clear();
|
|
23693
|
+
attempts.clear();
|
|
23694
|
+
models.clear();
|
|
23695
|
+
}
|
|
23696
|
+
};
|
|
23697
|
+
}
|
|
23698
|
+
function createSubagentThreadStatusResolver(options) {
|
|
23699
|
+
const statuses = /* @__PURE__ */ new Map();
|
|
23700
|
+
const pending = /* @__PURE__ */ new Set();
|
|
23701
|
+
const attempts = /* @__PURE__ */ new Map();
|
|
23702
|
+
const maxAttempts = options.maxAttempts ?? 3;
|
|
23703
|
+
let disposed = false;
|
|
23704
|
+
const ensure = (threadId) => {
|
|
23705
|
+
const current = statuses.get(threadId);
|
|
23706
|
+
if (disposed || !threadId || pending.has(threadId) || current === "completed" || current === "failed" || current === "interrupted") {
|
|
23707
|
+
return;
|
|
23708
|
+
}
|
|
23709
|
+
const attempt = (attempts.get(threadId) ?? 0) + 1;
|
|
23710
|
+
if (attempt > maxAttempts) return;
|
|
23711
|
+
attempts.set(threadId, attempt);
|
|
23712
|
+
pending.add(threadId);
|
|
23713
|
+
void options.read(threadId).then((status) => {
|
|
23714
|
+
if (disposed || !status) return;
|
|
23715
|
+
statuses.set(threadId, status);
|
|
23716
|
+
if (status === "completed" || status === "failed" || status === "interrupted") {
|
|
23717
|
+
attempts.delete(threadId);
|
|
23718
|
+
}
|
|
23719
|
+
options.onUpdate();
|
|
23720
|
+
}).catch(() => {
|
|
23721
|
+
}).finally(() => {
|
|
23722
|
+
pending.delete(threadId);
|
|
23723
|
+
});
|
|
23724
|
+
};
|
|
23725
|
+
return {
|
|
23726
|
+
get(threadId) {
|
|
23727
|
+
return statuses.get(threadId);
|
|
23728
|
+
},
|
|
23729
|
+
ensure,
|
|
23730
|
+
refresh() {
|
|
23731
|
+
if (disposed) return;
|
|
23732
|
+
for (const threadId of /* @__PURE__ */ new Set([...statuses.keys(), ...attempts.keys()])) {
|
|
23733
|
+
const status = statuses.get(threadId);
|
|
23734
|
+
if (status === "completed" || status === "failed" || status === "interrupted") continue;
|
|
23735
|
+
attempts.delete(threadId);
|
|
23736
|
+
ensure(threadId);
|
|
23737
|
+
}
|
|
23738
|
+
},
|
|
23739
|
+
dispose() {
|
|
23740
|
+
disposed = true;
|
|
23741
|
+
statuses.clear();
|
|
23742
|
+
attempts.clear();
|
|
23743
|
+
pending.clear();
|
|
23744
|
+
}
|
|
23745
|
+
};
|
|
23746
|
+
}
|
|
23747
|
+
|
|
23748
|
+
// src/renderer-subagent-row-meta.ts
|
|
23749
|
+
var SUBAGENT_ROW_META_ATTRIBUTE = "data-codexhost-subagent-meta";
|
|
23750
|
+
var SUBAGENT_ROW_COPY_ATTRIBUTE = "data-codexhost-subagent-copy";
|
|
23751
|
+
var SUBAGENT_ITEM_BUTTON_SELECTOR = 'button[data-slot="thread-summary-panel-item-button"]';
|
|
23752
|
+
var SUBAGENT_ITEM_LABEL_SELECTOR = '[data-slot="thread-summary-panel-item-label"]';
|
|
23753
|
+
function isRecord8(value) {
|
|
23754
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23755
|
+
}
|
|
23756
|
+
function nonBlank2(value) {
|
|
23757
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
23758
|
+
}
|
|
23759
|
+
function isDomElement(value) {
|
|
23760
|
+
return typeof Element !== "undefined" && value instanceof Element;
|
|
23761
|
+
}
|
|
23762
|
+
function isHtmlElement(value) {
|
|
23763
|
+
return typeof HTMLElement !== "undefined" && value instanceof HTMLElement;
|
|
23764
|
+
}
|
|
23765
|
+
function isParentComposerModelLabel2(model) {
|
|
23766
|
+
const trimmed = model?.trim();
|
|
23767
|
+
if (!trimmed) return false;
|
|
23768
|
+
const head = trimmed.includes(" \xB7 ") ? trimmed.split(" \xB7 ")[0]?.trim() ?? "" : trimmed;
|
|
23769
|
+
if (!head) return false;
|
|
23770
|
+
if (/^(grok|gpt|o\d|claude|codex)/i.test(head)) return false;
|
|
23771
|
+
return trimmed.includes(" \xB7 ");
|
|
23772
|
+
}
|
|
23773
|
+
function usableModel(value) {
|
|
23774
|
+
if (!nonBlank2(value) || isParentComposerModelLabel2(value)) return void 0;
|
|
23775
|
+
return value.trim();
|
|
23776
|
+
}
|
|
23777
|
+
function prettySubagentStatus(status) {
|
|
23778
|
+
switch (status) {
|
|
23779
|
+
case "active":
|
|
23780
|
+
case "running":
|
|
23781
|
+
case "working":
|
|
23782
|
+
return "\u8FDB\u884C\u4E2D";
|
|
23783
|
+
case "waiting":
|
|
23784
|
+
case "pending":
|
|
23785
|
+
case "pendingInit":
|
|
23786
|
+
return "\u7B49\u5F85\u4E2D";
|
|
23787
|
+
case "done":
|
|
23788
|
+
case "completed":
|
|
23789
|
+
return "\u5DF2\u5B8C\u6210";
|
|
23790
|
+
case "failed":
|
|
23791
|
+
case "errored":
|
|
23792
|
+
return "\u5931\u8D25";
|
|
23793
|
+
case "interrupted":
|
|
23794
|
+
return "\u5DF2\u4E2D\u65AD";
|
|
23795
|
+
default:
|
|
23796
|
+
return void 0;
|
|
23797
|
+
}
|
|
23798
|
+
}
|
|
23799
|
+
function prettySubagentEffort(value) {
|
|
23800
|
+
const trimmed = value?.trim();
|
|
23801
|
+
if (!trimmed) return void 0;
|
|
23802
|
+
const lower = trimmed.toLowerCase();
|
|
23803
|
+
if (lower === "xhigh") return "xHigh";
|
|
23804
|
+
if (lower === "ultra") return "\u8D85\u9AD8";
|
|
23805
|
+
return trimmed.charAt(0).toUpperCase() + trimmed.slice(1);
|
|
23806
|
+
}
|
|
23807
|
+
function prettySubagentModel(model) {
|
|
23808
|
+
const trimmed = model.trim();
|
|
23809
|
+
if (!trimmed || isParentComposerModelLabel2(trimmed)) return "";
|
|
23810
|
+
if (trimmed.includes(" \xB7 ")) return trimmed;
|
|
23811
|
+
const slash = trimmed.lastIndexOf("/");
|
|
23812
|
+
const id = slash >= 0 ? trimmed.slice(slash + 1) : trimmed;
|
|
23813
|
+
if (id.toLowerCase().startsWith("grok")) {
|
|
23814
|
+
return id.replace(/^grok[-_]?/iu, "Grok ").replace(/\s+/gu, " ").trim();
|
|
23815
|
+
}
|
|
23816
|
+
if (!id.trimStart().toLowerCase().startsWith("gpt")) return trimmed;
|
|
23817
|
+
const joiner = /^gpt-\d/iu.test(id.trimStart()) ? " " : "-";
|
|
23818
|
+
return id.split(/(\s+)/u).map((part) => {
|
|
23819
|
+
if (part.trim().length === 0) return part;
|
|
23820
|
+
return part.split("-").map((token, index) => {
|
|
23821
|
+
if (token.toLowerCase() === "gpt") return "GPT";
|
|
23822
|
+
if (token.toLowerCase() === "oai") return "OAI";
|
|
23823
|
+
if (index > 0 && token.length > 0) {
|
|
23824
|
+
return `${token[0]?.toUpperCase() ?? ""}${token.slice(1)}`;
|
|
23825
|
+
}
|
|
23826
|
+
return token;
|
|
23827
|
+
}).join(joiner).replace(/^GPT (?=\d)/u, "GPT-");
|
|
23828
|
+
}).join("");
|
|
23829
|
+
}
|
|
23830
|
+
function includesEffort(label, effort) {
|
|
23831
|
+
return new RegExp(`(?:^|\xB7\\s*)${effort.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}$`, "iu").test(
|
|
23832
|
+
label
|
|
23833
|
+
);
|
|
23834
|
+
}
|
|
23835
|
+
function formatSubagentRowMeta(row) {
|
|
23836
|
+
const raw = usableModel(row.spawnModel) ?? usableModel(row.model) ?? "";
|
|
23837
|
+
const model = raw ? prettySubagentModel(raw) : "";
|
|
23838
|
+
const effort = prettySubagentEffort(row.reasoningEffort);
|
|
23839
|
+
const modelLine = model && effort && !includesEffort(model, effort) ? `${model} \xB7 ${effort}` : model || effort;
|
|
23840
|
+
const parts = [prettySubagentStatus(row.status), modelLine].filter(
|
|
23841
|
+
(value) => typeof value === "string" && value.length > 0
|
|
23842
|
+
);
|
|
23843
|
+
return parts.length > 0 ? parts.join(" \xB7 ") : void 0;
|
|
23844
|
+
}
|
|
23845
|
+
function contribute(target, source, allowUnscopedModel = false) {
|
|
23846
|
+
const sourceId = nonBlank2(source.conversationId) ? source.conversationId.trim() : Array.isArray(source.receiverThreadIds) && nonBlank2(source.receiverThreadIds[0]) ? source.receiverThreadIds[0].trim() : void 0;
|
|
23847
|
+
if (target.conversationId && sourceId && sourceId !== target.conversationId) return;
|
|
23848
|
+
if (nonBlank2(source.displayName) && !target.displayName) {
|
|
23849
|
+
target.displayName = source.displayName.trim();
|
|
23850
|
+
}
|
|
23851
|
+
if (sourceId && !target.conversationId) target.conversationId = sourceId;
|
|
23852
|
+
const childModelSource = allowUnscopedModel || source.type === "collabAgentToolCall" || target.conversationId && nonBlank2(source.id) && source.id.trim() === target.conversationId;
|
|
23853
|
+
if (childModelSource) {
|
|
23854
|
+
const spawn = usableModel(source.spawnModel);
|
|
23855
|
+
const model = usableModel(source.model) ?? usableModel(source.modelLabel) ?? usableModel(source.latestModel);
|
|
23856
|
+
if (spawn && !target.spawnModel) target.spawnModel = spawn;
|
|
23857
|
+
if (model && !usableModel(target.model)) target.model = model;
|
|
23858
|
+
if (nonBlank2(source.reasoningEffort) && !target.reasoningEffort) {
|
|
23859
|
+
target.reasoningEffort = source.reasoningEffort.trim();
|
|
23860
|
+
}
|
|
23861
|
+
if (nonBlank2(source.latestReasoningEffort) && !target.reasoningEffort) {
|
|
23862
|
+
target.reasoningEffort = source.latestReasoningEffort.trim();
|
|
23863
|
+
}
|
|
23864
|
+
}
|
|
23865
|
+
if (nonBlank2(source.agentRole) && !target.agentRole) {
|
|
23866
|
+
target.agentRole = source.agentRole.trim();
|
|
23867
|
+
}
|
|
23868
|
+
if (nonBlank2(source.status) && !target.status) {
|
|
23869
|
+
target.status = source.status.trim();
|
|
23870
|
+
}
|
|
23871
|
+
if (isRecord8(source.agentState) && nonBlank2(source.agentState.status) && !target.status) {
|
|
23872
|
+
target.status = source.agentState.status.trim();
|
|
23873
|
+
}
|
|
23874
|
+
if (isRecord8(source.agentsStates) && target.conversationId) {
|
|
23875
|
+
const state = source.agentsStates[target.conversationId];
|
|
23876
|
+
if (isRecord8(state) && nonBlank2(state.status) && !target.status) {
|
|
23877
|
+
target.status = state.status.trim();
|
|
23878
|
+
}
|
|
23879
|
+
}
|
|
23880
|
+
}
|
|
23881
|
+
function collabMatches(item, conversationId) {
|
|
23882
|
+
if (item.type !== "collabAgentToolCall" || item.tool !== "spawnAgent") return false;
|
|
23883
|
+
if (!conversationId) return true;
|
|
23884
|
+
if (Array.isArray(item.receiverThreadIds) && item.receiverThreadIds.includes(conversationId)) {
|
|
23885
|
+
return true;
|
|
23886
|
+
}
|
|
23887
|
+
return isRecord8(item.agentsStates) && conversationId in item.agentsStates;
|
|
23888
|
+
}
|
|
23889
|
+
function harvestFromValue(value, target) {
|
|
23890
|
+
if (!isRecord8(value)) return;
|
|
23891
|
+
contribute(target, value);
|
|
23892
|
+
const nested = [
|
|
23893
|
+
isRecord8(value.row) ? value.row : null,
|
|
23894
|
+
isRecord8(value.backgroundAgent) ? value.backgroundAgent : null,
|
|
23895
|
+
isRecord8(value.item) ? value.item : null,
|
|
23896
|
+
isRecord8(value.item) && isRecord8(value.item.backgroundAgent) ? value.item.backgroundAgent : null,
|
|
23897
|
+
isRecord8(value.thread) && (!target.conversationId || nonBlank2(value.thread.id) && value.thread.id.trim() === target.conversationId) ? value.thread : null,
|
|
23898
|
+
isRecord8(value.childConversation) ? value.childConversation : null
|
|
23899
|
+
];
|
|
23900
|
+
for (const source of nested) {
|
|
23901
|
+
if (source) contribute(target, source);
|
|
23902
|
+
}
|
|
23903
|
+
if (!target.conversationId) return;
|
|
23904
|
+
const items = Array.isArray(value.items) ? value.items : Array.isArray(value.turns) ? value.turns.flatMap(
|
|
23905
|
+
(turn) => isRecord8(turn) && Array.isArray(turn.items) ? turn.items : []
|
|
23906
|
+
) : [];
|
|
23907
|
+
for (const item of items) {
|
|
23908
|
+
if (!isRecord8(item)) continue;
|
|
23909
|
+
if (collabMatches(item, target.conversationId)) contribute(target, item, true);
|
|
23910
|
+
}
|
|
23911
|
+
}
|
|
23912
|
+
function finalizeRow(target) {
|
|
23913
|
+
if (!nonBlank2(target.displayName)) return null;
|
|
23914
|
+
if (!nonBlank2(target.conversationId) && !nonBlank2(target.spawnModel) && !nonBlank2(target.model) && !nonBlank2(target.status)) {
|
|
23915
|
+
return null;
|
|
23916
|
+
}
|
|
23917
|
+
const spawnModel = usableModel(target.spawnModel);
|
|
23918
|
+
const model = usableModel(target.model);
|
|
23919
|
+
return {
|
|
23920
|
+
displayName: target.displayName.trim(),
|
|
23921
|
+
...spawnModel ? { spawnModel } : {},
|
|
23922
|
+
...model ? { model } : {},
|
|
23923
|
+
...nonBlank2(target.reasoningEffort) ? { reasoningEffort: target.reasoningEffort.trim() } : {},
|
|
23924
|
+
...nonBlank2(target.agentRole) ? { agentRole: target.agentRole.trim() } : {},
|
|
23925
|
+
...nonBlank2(target.status) ? { status: target.status.trim() } : {},
|
|
23926
|
+
...nonBlank2(target.conversationId) ? { conversationId: target.conversationId.trim() } : {}
|
|
23927
|
+
};
|
|
23928
|
+
}
|
|
23929
|
+
function withResolvedThreadModel(row, thread) {
|
|
23930
|
+
const spawn = usableModel(row.spawnModel);
|
|
23931
|
+
const model = spawn ?? usableModel(row.model) ?? usableModel(thread.model);
|
|
23932
|
+
const reasoningEffort = row.reasoningEffort ?? (nonBlank2(thread.reasoningEffort) ? thread.reasoningEffort.trim() : void 0);
|
|
23933
|
+
return {
|
|
23934
|
+
displayName: row.displayName,
|
|
23935
|
+
...row.conversationId ? { conversationId: row.conversationId } : {},
|
|
23936
|
+
...row.status ? { status: row.status } : {},
|
|
23937
|
+
...row.agentRole ? { agentRole: row.agentRole } : {},
|
|
23938
|
+
...spawn ? { spawnModel: spawn } : {},
|
|
23939
|
+
...model ? { model } : {},
|
|
23940
|
+
...reasoningEffort ? { reasoningEffort } : {}
|
|
23941
|
+
};
|
|
23942
|
+
}
|
|
23943
|
+
function withResolvedThreadStatus(row, status) {
|
|
23944
|
+
return { ...row, status };
|
|
23945
|
+
}
|
|
23946
|
+
function resolveSubagentRow(row, modelResolver, statusResolver) {
|
|
23947
|
+
if (!row.conversationId) return row;
|
|
23948
|
+
const resolvedStatus = statusResolver?.get(row.conversationId);
|
|
23949
|
+
let enriched = resolvedStatus ? withResolvedThreadStatus(row, resolvedStatus) : row;
|
|
23950
|
+
const visibleStatus = prettySubagentStatus(enriched.status);
|
|
23951
|
+
if (!visibleStatus || visibleStatus === "\u8FDB\u884C\u4E2D" || visibleStatus === "\u7B49\u5F85\u4E2D") {
|
|
23952
|
+
statusResolver?.ensure(row.conversationId);
|
|
23953
|
+
}
|
|
23954
|
+
const resolvedModel = modelResolver?.get(row.conversationId);
|
|
23955
|
+
if (resolvedModel) enriched = withResolvedThreadModel(enriched, resolvedModel);
|
|
23956
|
+
const currentModel = usableModel(enriched.spawnModel) ?? usableModel(enriched.model);
|
|
23957
|
+
const modelIncludesEffort = Boolean(currentModel?.includes(" \xB7 "));
|
|
23958
|
+
if (!currentModel || !enriched.reasoningEffort && !modelIncludesEffort) {
|
|
23959
|
+
modelResolver?.ensure(row.conversationId);
|
|
23960
|
+
}
|
|
23961
|
+
return enriched;
|
|
23962
|
+
}
|
|
23963
|
+
function subagentRowMetaFromProps(value) {
|
|
23964
|
+
const target = {};
|
|
23965
|
+
harvestFromValue(value, target);
|
|
23966
|
+
return finalizeRow(target);
|
|
23967
|
+
}
|
|
23968
|
+
function fiberFromElement(element) {
|
|
23969
|
+
const names = Object.getOwnPropertyNames(element).filter(
|
|
23970
|
+
(name2) => name2.startsWith("__reactFiber$")
|
|
23971
|
+
);
|
|
23972
|
+
const name = names[0];
|
|
23973
|
+
if (!name) return null;
|
|
23974
|
+
const fiber = Object.getOwnPropertyDescriptor(element, name)?.value ?? element[name];
|
|
23975
|
+
return isRecord8(fiber) ? fiber : null;
|
|
23976
|
+
}
|
|
23977
|
+
function metaFromFiberProps(fiber) {
|
|
23978
|
+
if (!fiber) return null;
|
|
23979
|
+
return subagentRowMetaFromProps(fiber.memoizedProps) ?? subagentRowMetaFromProps(fiber.pendingProps);
|
|
23980
|
+
}
|
|
23981
|
+
function mergeRow(base, next) {
|
|
23982
|
+
if (!base) return next;
|
|
23983
|
+
if (!next) return base;
|
|
23984
|
+
if (base.conversationId && next.conversationId && base.conversationId !== next.conversationId) {
|
|
23985
|
+
return base;
|
|
23986
|
+
}
|
|
23987
|
+
const spawnModel = usableModel(base.spawnModel) ?? usableModel(next.spawnModel);
|
|
23988
|
+
const model = usableModel(base.model) ?? usableModel(next.model);
|
|
23989
|
+
const reasoningEffort = base.reasoningEffort ?? next.reasoningEffort;
|
|
23990
|
+
const agentRole = base.agentRole ?? next.agentRole;
|
|
23991
|
+
const status = base.status ?? next.status;
|
|
23992
|
+
const conversationId = base.conversationId ?? next.conversationId;
|
|
23993
|
+
return {
|
|
23994
|
+
displayName: base.displayName || next.displayName,
|
|
23995
|
+
...spawnModel ? { spawnModel } : {},
|
|
23996
|
+
...model ? { model } : {},
|
|
23997
|
+
...reasoningEffort ? { reasoningEffort } : {},
|
|
23998
|
+
...agentRole ? { agentRole } : {},
|
|
23999
|
+
...status ? { status } : {},
|
|
24000
|
+
...conversationId ? { conversationId } : {}
|
|
24001
|
+
};
|
|
24002
|
+
}
|
|
24003
|
+
function metaFromDescendants(start) {
|
|
24004
|
+
if (!start || !isRecord8(start.child)) return null;
|
|
24005
|
+
const stack = [start.child];
|
|
24006
|
+
const seen = /* @__PURE__ */ new Set();
|
|
24007
|
+
let found = null;
|
|
24008
|
+
let steps = 0;
|
|
24009
|
+
while (stack.length > 0 && steps < 40) {
|
|
24010
|
+
const fiber = stack.pop();
|
|
24011
|
+
if (!fiber || seen.has(fiber)) continue;
|
|
24012
|
+
seen.add(fiber);
|
|
24013
|
+
steps += 1;
|
|
24014
|
+
found = mergeRow(found, metaFromFiberProps(fiber));
|
|
24015
|
+
if (isRecord8(fiber.child)) stack.push(fiber.child);
|
|
24016
|
+
if (isRecord8(fiber.sibling)) stack.push(fiber.sibling);
|
|
24017
|
+
}
|
|
24018
|
+
return found;
|
|
24019
|
+
}
|
|
24020
|
+
function subagentRowMetaFromElement(element) {
|
|
24021
|
+
let fiber = fiberFromElement(element);
|
|
24022
|
+
let found = metaFromDescendants(fiber);
|
|
24023
|
+
for (let depth = 0; fiber && depth < 12; depth += 1) {
|
|
24024
|
+
found = mergeRow(found, metaFromFiberProps(fiber));
|
|
24025
|
+
fiber = isRecord8(fiber.return) ? fiber.return : null;
|
|
24026
|
+
}
|
|
24027
|
+
return found;
|
|
24028
|
+
}
|
|
24029
|
+
function findNameNode(element) {
|
|
24030
|
+
const label = element.querySelector(SUBAGENT_ITEM_LABEL_SELECTOR);
|
|
24031
|
+
return label ?? element;
|
|
24032
|
+
}
|
|
24033
|
+
function createMetaNode(ownerDocument) {
|
|
24034
|
+
const meta3 = ownerDocument.createElement("span");
|
|
24035
|
+
meta3.setAttribute(SUBAGENT_ROW_META_ATTRIBUTE, "true");
|
|
24036
|
+
meta3.style.display = "block";
|
|
24037
|
+
meta3.style.maxWidth = "100%";
|
|
24038
|
+
meta3.style.fontSize = "11px";
|
|
24039
|
+
meta3.style.lineHeight = "1.35";
|
|
24040
|
+
meta3.style.color = "var(--text-tertiary, #8a8a8a)";
|
|
24041
|
+
meta3.style.whiteSpace = "normal";
|
|
24042
|
+
return meta3;
|
|
24043
|
+
}
|
|
24044
|
+
function ensureColumnCopy(nameNode) {
|
|
24045
|
+
const parent = nameNode.parentElement;
|
|
24046
|
+
if (parent?.getAttribute(SUBAGENT_ROW_COPY_ATTRIBUTE) === "true") {
|
|
24047
|
+
const existing = parent.querySelector(`[${SUBAGENT_ROW_META_ATTRIBUTE}]`);
|
|
24048
|
+
if (existing) return { copy: parent, meta: existing };
|
|
24049
|
+
const meta4 = createMetaNode(nameNode.ownerDocument);
|
|
24050
|
+
parent.append(meta4);
|
|
24051
|
+
return { copy: parent, meta: meta4 };
|
|
24052
|
+
}
|
|
24053
|
+
const copy = nameNode.ownerDocument.createElement("span");
|
|
24054
|
+
copy.setAttribute(SUBAGENT_ROW_COPY_ATTRIBUTE, "true");
|
|
24055
|
+
copy.style.display = "flex";
|
|
24056
|
+
copy.style.flexDirection = "column";
|
|
24057
|
+
copy.style.alignItems = "flex-start";
|
|
24058
|
+
copy.style.justifyContent = "center";
|
|
24059
|
+
copy.style.minWidth = "0";
|
|
24060
|
+
copy.style.flex = "1";
|
|
24061
|
+
copy.style.overflow = "hidden";
|
|
24062
|
+
nameNode.style.maxWidth = "100%";
|
|
24063
|
+
nameNode.style.minWidth = "0";
|
|
24064
|
+
nameNode.replaceWith(copy);
|
|
24065
|
+
copy.append(nameNode);
|
|
24066
|
+
const meta3 = createMetaNode(nameNode.ownerDocument);
|
|
24067
|
+
copy.append(meta3);
|
|
24068
|
+
return { copy, meta: meta3 };
|
|
24069
|
+
}
|
|
24070
|
+
function decorateSubagentRow(element, resolver, statusResolver) {
|
|
24071
|
+
const label = element.querySelector(SUBAGENT_ITEM_LABEL_SELECTOR);
|
|
24072
|
+
const harvested = subagentRowMetaFromElement(element) ?? (label ? subagentRowMetaFromElement(label) : null);
|
|
24073
|
+
if (!harvested) return false;
|
|
24074
|
+
const row = resolveSubagentRow(harvested, resolver, statusResolver);
|
|
24075
|
+
const text = formatSubagentRowMeta(row);
|
|
24076
|
+
const nameNode = findNameNode(element);
|
|
24077
|
+
if (!nameNode || !text) {
|
|
24078
|
+
element.querySelector(`[${SUBAGENT_ROW_META_ATTRIBUTE}]`)?.remove();
|
|
24079
|
+
return false;
|
|
24080
|
+
}
|
|
24081
|
+
const { meta: meta3 } = ensureColumnCopy(nameNode);
|
|
24082
|
+
if (meta3.textContent !== text) meta3.textContent = text;
|
|
24083
|
+
return true;
|
|
24084
|
+
}
|
|
24085
|
+
function decorateSubagentRows(root, resolver, statusResolver) {
|
|
24086
|
+
if (typeof root.querySelectorAll !== "function") return 0;
|
|
24087
|
+
const buttons = root.querySelectorAll(SUBAGENT_ITEM_BUTTON_SELECTOR);
|
|
24088
|
+
let decorated = 0;
|
|
24089
|
+
for (const element of buttons) {
|
|
24090
|
+
if (!isHtmlElement(element)) continue;
|
|
24091
|
+
if (decorateSubagentRow(element, resolver, statusResolver)) decorated += 1;
|
|
24092
|
+
}
|
|
24093
|
+
return decorated;
|
|
24094
|
+
}
|
|
24095
|
+
function isOwnMetaMutation(mutations) {
|
|
24096
|
+
return mutations.every((mutation) => {
|
|
24097
|
+
const nodes = [...mutation.addedNodes, ...mutation.removedNodes, mutation.target];
|
|
24098
|
+
return nodes.every((node) => {
|
|
24099
|
+
if (!isDomElement(node)) return mutation.type === "characterData";
|
|
24100
|
+
return node.getAttribute?.(SUBAGENT_ROW_META_ATTRIBUTE) === "true" || node.getAttribute?.(SUBAGENT_ROW_COPY_ATTRIBUTE) === "true" || Boolean(node.closest?.(`[${SUBAGENT_ROW_META_ATTRIBUTE}]`)) || Boolean(node.closest?.(`[${SUBAGENT_ROW_COPY_ATTRIBUTE}]`));
|
|
24101
|
+
});
|
|
24102
|
+
});
|
|
24103
|
+
}
|
|
24104
|
+
function installRendererSubagentRowMeta(root) {
|
|
24105
|
+
const owner = root ?? (typeof document !== "undefined" && typeof Element !== "undefined" ? document : void 0);
|
|
24106
|
+
if (!owner || typeof MutationObserver === "undefined" || typeof Element === "undefined" || typeof document === "undefined") {
|
|
24107
|
+
return { refresh() {
|
|
24108
|
+
}, dispose() {
|
|
24109
|
+
} };
|
|
24110
|
+
}
|
|
24111
|
+
let disposed = false;
|
|
24112
|
+
let scanScheduled = false;
|
|
24113
|
+
let mutating = false;
|
|
24114
|
+
let debounce;
|
|
24115
|
+
const scan = () => {
|
|
24116
|
+
scanScheduled = false;
|
|
24117
|
+
if (disposed) return;
|
|
24118
|
+
mutating = true;
|
|
24119
|
+
try {
|
|
24120
|
+
decorateSubagentRows(owner, resolver, statusResolver);
|
|
24121
|
+
} finally {
|
|
24122
|
+
mutating = false;
|
|
24123
|
+
}
|
|
24124
|
+
};
|
|
24125
|
+
const schedule = () => {
|
|
24126
|
+
if (disposed || mutating || scanScheduled) return;
|
|
24127
|
+
scanScheduled = true;
|
|
24128
|
+
if (debounce !== void 0) clearTimeout(debounce);
|
|
24129
|
+
debounce = setTimeout(() => {
|
|
24130
|
+
debounce = void 0;
|
|
24131
|
+
scan();
|
|
24132
|
+
}, 250);
|
|
24133
|
+
};
|
|
24134
|
+
const resolver = createSubagentThreadModelResolver({
|
|
24135
|
+
read: readRendererSubagentThreadModel,
|
|
24136
|
+
onUpdate: schedule
|
|
24137
|
+
});
|
|
24138
|
+
const statusResolver = createSubagentThreadStatusResolver({
|
|
24139
|
+
read: readRendererSubagentStatus,
|
|
24140
|
+
onUpdate: schedule
|
|
24141
|
+
});
|
|
24142
|
+
const observer = new MutationObserver((mutations) => {
|
|
24143
|
+
if (mutating || isOwnMetaMutation(mutations)) return;
|
|
24144
|
+
schedule();
|
|
24145
|
+
});
|
|
24146
|
+
observer.observe(owner, { childList: true, subtree: true });
|
|
24147
|
+
schedule();
|
|
24148
|
+
return {
|
|
24149
|
+
refresh() {
|
|
24150
|
+
resolver.refresh();
|
|
24151
|
+
statusResolver.refresh();
|
|
24152
|
+
schedule();
|
|
24153
|
+
},
|
|
24154
|
+
dispose() {
|
|
24155
|
+
if (disposed) return;
|
|
24156
|
+
disposed = true;
|
|
24157
|
+
if (debounce !== void 0) clearTimeout(debounce);
|
|
24158
|
+
observer.disconnect();
|
|
24159
|
+
resolver.dispose();
|
|
24160
|
+
statusResolver.dispose();
|
|
24161
|
+
if (isDomElement(owner) || typeof Document !== "undefined" && owner instanceof Document) {
|
|
24162
|
+
for (const copy of owner.querySelectorAll(`[${SUBAGENT_ROW_COPY_ATTRIBUTE}]`)) {
|
|
24163
|
+
const label = copy.querySelector(SUBAGENT_ITEM_LABEL_SELECTOR);
|
|
24164
|
+
if (label && copy.parentElement) copy.replaceWith(label);
|
|
24165
|
+
else copy.remove();
|
|
24166
|
+
}
|
|
24167
|
+
for (const meta3 of owner.querySelectorAll(`[${SUBAGENT_ROW_META_ATTRIBUTE}]`)) {
|
|
24168
|
+
meta3.remove();
|
|
24169
|
+
}
|
|
24170
|
+
}
|
|
24171
|
+
}
|
|
24172
|
+
};
|
|
24173
|
+
}
|
|
24174
|
+
|
|
23541
24175
|
// src/renderer-permission-mode-preference.ts
|
|
23542
24176
|
var CLAUDE_PERMISSION_MODE_PREFERENCE_KEY = "codexhost.claude-code.permission-mode.v1";
|
|
23543
24177
|
function rendererStorage() {
|
|
@@ -23575,11 +24209,11 @@ ${error51.stderrTail}`] : []
|
|
|
23575
24209
|
return null;
|
|
23576
24210
|
}
|
|
23577
24211
|
}
|
|
23578
|
-
function
|
|
24212
|
+
function isRecord9(value) {
|
|
23579
24213
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23580
24214
|
}
|
|
23581
24215
|
function parseExternalConfiguration(value) {
|
|
23582
|
-
if (!
|
|
24216
|
+
if (!isRecord9(value)) return void 0;
|
|
23583
24217
|
const model = harnessModelRefSchema.safeParse(value.model);
|
|
23584
24218
|
if (!model.success) return void 0;
|
|
23585
24219
|
const thinkingOptionId = harnessThinkingOptionIdSchema.safeParse(value.thinkingOptionId);
|
|
@@ -23596,9 +24230,9 @@ ${error51.stderrTail}`] : []
|
|
|
23596
24230
|
const raw = storage.getItem(RENDERER_NEW_THREAD_PREFERENCE_KEY);
|
|
23597
24231
|
if (!raw) return void 0;
|
|
23598
24232
|
const parsed = JSON.parse(raw);
|
|
23599
|
-
if (!
|
|
24233
|
+
if (!isRecord9(parsed) || parsed.version !== 1) return void 0;
|
|
23600
24234
|
if (!KNOWN_RENDERER_AGENTS.some((agent) => agent === parsed.lastAgent)) return void 0;
|
|
23601
|
-
const externalByAgent =
|
|
24235
|
+
const externalByAgent = isRecord9(parsed.externalByAgent) ? parsed.externalByAgent : {};
|
|
23602
24236
|
const parsedExternal = Object.fromEntries(
|
|
23603
24237
|
KNOWN_RENDERER_AGENTS.filter(
|
|
23604
24238
|
(agent) => agent !== "codex"
|
|
@@ -23674,7 +24308,7 @@ ${error51.stderrTail}`] : []
|
|
|
23674
24308
|
var GET_LOCALE_OVERRIDE_URL = "vscode://codex/get-setting";
|
|
23675
24309
|
var GET_LOCALE_INFO_URL = "vscode://codex/locale-info";
|
|
23676
24310
|
var DEFAULT_LOCALE_REQUEST_TIMEOUT_MS = 750;
|
|
23677
|
-
function
|
|
24311
|
+
function isRecord10(value) {
|
|
23678
24312
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23679
24313
|
}
|
|
23680
24314
|
function canonicalLocale(value) {
|
|
@@ -23696,7 +24330,7 @@ ${error51.stderrTail}`] : []
|
|
|
23696
24330
|
return new DOMException("The operation was aborted", "AbortError");
|
|
23697
24331
|
}
|
|
23698
24332
|
function parseLocaleOverride(value) {
|
|
23699
|
-
if (!
|
|
24333
|
+
if (!isRecord10(value) || !("value" in value)) {
|
|
23700
24334
|
throw new Error("Codex locale override response is malformed");
|
|
23701
24335
|
}
|
|
23702
24336
|
if (value.value === null) return { value: null };
|
|
@@ -23711,7 +24345,7 @@ ${error51.stderrTail}`] : []
|
|
|
23711
24345
|
return locale;
|
|
23712
24346
|
}
|
|
23713
24347
|
function parseLocaleInfo(value) {
|
|
23714
|
-
if (!
|
|
24348
|
+
if (!isRecord10(value)) throw new Error("Codex locale info response is malformed");
|
|
23715
24349
|
return {
|
|
23716
24350
|
ideLocale: optionalLocale(value.ideLocale, "IDE locale"),
|
|
23717
24351
|
systemLocale: optionalLocale(value.systemLocale, "system locale")
|
|
@@ -23740,7 +24374,7 @@ ${error51.stderrTail}`] : []
|
|
|
23740
24374
|
const onAbort = () => settle(() => reject(abortError2()));
|
|
23741
24375
|
const onMessage = (event) => {
|
|
23742
24376
|
const message2 = event.data;
|
|
23743
|
-
if (!
|
|
24377
|
+
if (!isRecord10(message2) || message2.type !== "fetch-response") return;
|
|
23744
24378
|
if (message2.requestId !== requestId) return;
|
|
23745
24379
|
if (message2.responseType !== "success" || typeof message2.status !== "number" || message2.status < 200 || message2.status >= 300 || typeof message2.bodyJsonString !== "string") {
|
|
23746
24380
|
settle(() => reject(new Error("Codex locale request failed")));
|
|
@@ -27393,6 +28027,7 @@ ${accounts_default}`;
|
|
|
27393
28027
|
const existing = window.__codexhostRendererBindingProbeV1;
|
|
27394
28028
|
if (existing) return existing;
|
|
27395
28029
|
const disposeApprovalStyle = installRendererApprovalStyle(document);
|
|
28030
|
+
const subagentRowMeta = installRendererSubagentRowMeta();
|
|
27396
28031
|
const enabledAgents = [...new Set(options.enabledAgents ?? DEFAULT_RENDERER_AGENTS)];
|
|
27397
28032
|
const enabledAgentSet = new Set(enabledAgents);
|
|
27398
28033
|
const controller = new DraftAgentController({
|
|
@@ -29227,6 +29862,7 @@ ${accounts_default}`;
|
|
|
29227
29862
|
if (disposed) return;
|
|
29228
29863
|
disposed = true;
|
|
29229
29864
|
disposeApprovalStyle();
|
|
29865
|
+
subagentRowMeta.dispose();
|
|
29230
29866
|
usageNotificationDispose?.();
|
|
29231
29867
|
usageNotificationDispose = null;
|
|
29232
29868
|
adapterDispose?.();
|