@karlorz/codexhost-cli-darwin-x64 0.19.0-2 → 0.20.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +60 -11
- package/app/console-web.js +1280 -826
- package/app/cpa-live-voice-hook.js +24 -3
- package/app/desktop-controller.mjs +24 -3
- package/app/host-runtime.mjs +1586 -1189
- package/app/plugins/antigravity/plugin.mjs +8782 -4311
- package/app/plugins/claude-code/plugin.mjs +26 -3
- package/app/plugins/codebuddy/plugin.mjs +41 -5
- package/app/plugins/codex-usage/plugin.mjs +26 -3
- package/app/plugins/copilot/plugin.mjs +26 -3
- package/app/plugins/cursor-cli/plugin.mjs +26 -3
- package/app/plugins/deepseek-harness/plugin.mjs +26 -3
- package/app/plugins/devin/plugin.mjs +25 -3
- package/app/plugins/grok/plugin.mjs +26 -3
- package/app/plugins/hermes/plugin.mjs +25 -3
- package/app/plugins/kimi-code/plugin.mjs +26 -3
- package/app/plugins/kiro-cli/plugin.mjs +26 -3
- package/app/plugins/omp/plugin.mjs +43 -5
- package/app/plugins/opencode/plugin.mjs +26 -3
- package/app/plugins/pi/plugin.mjs +45 -6
- package/app/plugins/qoder/plugin.mjs +48 -4
- package/app/plugins/qoder-cn/plugin.mjs +48 -4
- package/app/plugins/qwen-code/plugin.mjs +26 -3
- package/app/plugins/workbuddy/plugin.mjs +45 -8
- package/app/plugins/zcode/plugin.mjs +26 -3
- package/app/renderer-extension.js +1698 -983
- package/app/web/assets/index-B5OfOGb8.js +201 -0
- package/app/web/assets/index-D6-hvggd.css +1 -0
- package/app/web/assets/langs/{graphql-B8vkg11W.js → graphql-ChAeyPkT.js} +1 -1
- package/app/web/assets/langs/{http-DmoDEjMt.js → http-BvreBIbD.js} +1 -1
- package/app/web/assets/langs/{php-DJ5ovfAM.js → php-D8omCIuJ.js} +1 -1
- package/app/web/assets/langs/{rst-U5-R5x3p.js → rst-Do7RLLCS.js} +1 -1
- package/app/web/assets/langs/{ruby-VKVsnS0H.js → ruby-rH_O_vse.js} +1 -1
- package/app/web/assets/langs/{svelte-C20lOv9V.js → svelte-xZy73wAj.js} +1 -1
- package/app/web/assets/langs/{vue-z6Y-lzP-.js → vue-C4DW8agZ.js} +1 -1
- package/app/web/assets/{vendor-dSL872WO.js → vendor-C9g2bw8s.js} +3 -3
- package/app/web/codexhost-settings.js +1285 -827
- package/app/web/index.html +4 -3
- package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +68 -68
- package/app/web/plugins/deepseek-ai__dsh-client-connection/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +3 -3
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +13 -13
- package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
- package/app/web-modules/server.mjs +135 -69
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-BCyiiDDL.js +0 -199
- package/app/web/assets/index-BNQIOOHE.css +0 -1
|
@@ -17676,13 +17676,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17676
17676
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
17677
17677
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
17678
17678
|
var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
|
|
17679
|
+
var usageOutputTimingSchema = external_exports.object({
|
|
17680
|
+
version: external_exports.literal(3).optional(),
|
|
17681
|
+
requestId: external_exports.string().min(1),
|
|
17682
|
+
turnId: external_exports.string().min(1).max(1024),
|
|
17683
|
+
outputTokens: nonNegativeSafeIntegerSchema,
|
|
17684
|
+
startedAtMs: nonNegativeSafeIntegerSchema,
|
|
17685
|
+
completedAtMs: nonNegativeSafeIntegerSchema
|
|
17686
|
+
}).strict().refine((value) => value.completedAtMs > value.startedAtMs);
|
|
17679
17687
|
var usageMeasurementSchema = external_exports.object({
|
|
17688
|
+
version: external_exports.union([external_exports.literal(2), external_exports.literal(3)]).optional(),
|
|
17680
17689
|
value: finiteNonNegativeNumberSchema,
|
|
17681
17690
|
turnId: external_exports.string().min(1).max(1024),
|
|
17682
17691
|
at: nonNegativeSafeIntegerSchema
|
|
17683
17692
|
}).strict();
|
|
17684
17693
|
var usageMeasurementsSchema = external_exports.object({
|
|
17685
|
-
|
|
17694
|
+
// Unversioned intervals can omit hidden thinking time; do not restore them into averages.
|
|
17695
|
+
outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 3)).optional(),
|
|
17696
|
+
// Retain independent TTFT facts when dropping incompatible speed measurements.
|
|
17697
|
+
outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 3).optional().catch(void 0),
|
|
17686
17698
|
timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
|
|
17687
17699
|
}).strict();
|
|
17688
17700
|
var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
|
|
@@ -17702,6 +17714,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17702
17714
|
cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
17703
17715
|
outputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
17704
17716
|
outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
|
|
17717
|
+
sessionOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
|
|
17705
17718
|
apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
|
|
17706
17719
|
reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
17707
17720
|
totalTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
@@ -18174,6 +18187,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18174
18187
|
})
|
|
18175
18188
|
});
|
|
18176
18189
|
|
|
18190
|
+
// ../shared-contracts/dist/thread-archive-confirm.js
|
|
18191
|
+
var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
|
|
18192
|
+
var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
|
|
18193
|
+
|
|
18177
18194
|
// ../shared-contracts/dist/client-channel.js
|
|
18178
18195
|
var CLIENT_CHANNEL_VERSION = 1;
|
|
18179
18196
|
var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
@@ -18313,7 +18330,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18313
18330
|
/** Current interruptible Host Turn, including command Turns omitted from client history. */
|
|
18314
18331
|
activeTurnId: external_exports.string().min(1).nullable().optional(),
|
|
18315
18332
|
/** Most recent explicit command in this Host process; not native conversation history. */
|
|
18316
|
-
command: external_exports.object({
|
|
18333
|
+
command: external_exports.object({
|
|
18334
|
+
name: external_exports.string().min(1),
|
|
18335
|
+
turn: clientTurnSchema,
|
|
18336
|
+
/** First ordinary Turn started after this command; its retained result is not a new event. */
|
|
18337
|
+
subsequentTurnId: external_exports.string().min(1).optional()
|
|
18338
|
+
}).optional(),
|
|
18317
18339
|
thread: external_exports.object({
|
|
18318
18340
|
id: external_exports.string().min(1),
|
|
18319
18341
|
cwd: external_exports.string(),
|
|
@@ -18564,7 +18586,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18564
18586
|
quotaUntil: external_exports.string().optional()
|
|
18565
18587
|
}).strict().optional()
|
|
18566
18588
|
}).strict();
|
|
18567
|
-
var webLocalAccessRequiredDetailsSchema = external_exports.object({ url: external_exports.string() }).strict();
|
|
18568
18589
|
|
|
18569
18590
|
// ../shared-contracts/dist/delegation-read.js
|
|
18570
18591
|
var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
|
|
@@ -18765,6 +18786,135 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18765
18786
|
...window2.localizations ? { localizations: window2.localizations } : {}
|
|
18766
18787
|
}, locale).label;
|
|
18767
18788
|
}
|
|
18789
|
+
function periodOrder(periodType) {
|
|
18790
|
+
if (periodType === "five_hour")
|
|
18791
|
+
return 0;
|
|
18792
|
+
if (periodType === "seven_day")
|
|
18793
|
+
return 1;
|
|
18794
|
+
if (periodType === "weekly")
|
|
18795
|
+
return 2;
|
|
18796
|
+
if (periodType === "monthly")
|
|
18797
|
+
return 3;
|
|
18798
|
+
return 4;
|
|
18799
|
+
}
|
|
18800
|
+
function groupAccountCreditsWindows(credits, locale, periodLabel, groupedPeriodLabel = periodLabel) {
|
|
18801
|
+
const entries = [
|
|
18802
|
+
{
|
|
18803
|
+
label: credits.label,
|
|
18804
|
+
periodType: credits.periodType,
|
|
18805
|
+
scope: credits.scope,
|
|
18806
|
+
localizations: credits.localizations,
|
|
18807
|
+
usedPercent: credits.usedPercent,
|
|
18808
|
+
used: credits.used,
|
|
18809
|
+
limit: credits.limit,
|
|
18810
|
+
unit: credits.unit,
|
|
18811
|
+
resetsAt: credits.resetsAt,
|
|
18812
|
+
isPrimary: true
|
|
18813
|
+
},
|
|
18814
|
+
...(credits.productUsage ?? []).map((item) => ({
|
|
18815
|
+
product: item.product,
|
|
18816
|
+
periodType: item.periodType,
|
|
18817
|
+
scope: item.scope,
|
|
18818
|
+
localizations: item.localizations,
|
|
18819
|
+
usedPercent: item.usagePercent,
|
|
18820
|
+
used: item.used,
|
|
18821
|
+
limit: item.limit,
|
|
18822
|
+
unit: item.unit,
|
|
18823
|
+
resetsAt: item.resetsAt,
|
|
18824
|
+
isPrimary: false
|
|
18825
|
+
}))
|
|
18826
|
+
];
|
|
18827
|
+
const scopeCounts = /* @__PURE__ */ new Map();
|
|
18828
|
+
for (const entry of entries) {
|
|
18829
|
+
if (entry.scope)
|
|
18830
|
+
scopeCounts.set(entry.scope.id, (scopeCounts.get(entry.scope.id) ?? 0) + 1);
|
|
18831
|
+
}
|
|
18832
|
+
const sections = /* @__PURE__ */ new Map();
|
|
18833
|
+
for (const entry of entries) {
|
|
18834
|
+
const groupedScope = entry.scope && (scopeCounts.get(entry.scope.id) ?? 0) >= 2 ? entry.scope : void 0;
|
|
18835
|
+
const key = groupedScope ? `scope:${groupedScope.id}` : "default";
|
|
18836
|
+
let section = sections.get(key);
|
|
18837
|
+
if (!section) {
|
|
18838
|
+
section = groupedScope ? {
|
|
18839
|
+
id: groupedScope.id,
|
|
18840
|
+
title: localizeHarnessPresentation(groupedScope, locale).label,
|
|
18841
|
+
windows: []
|
|
18842
|
+
} : { windows: [] };
|
|
18843
|
+
sections.set(key, section);
|
|
18844
|
+
}
|
|
18845
|
+
const inlineScope = !groupedScope && entry.scope && entry.periodType && entry.periodType !== "unknown" ? localizeHarnessPresentation(entry.scope, locale).label : void 0;
|
|
18846
|
+
const label = groupedScope && entry.periodType && entry.periodType !== "unknown" ? groupedPeriodLabel(entry.periodType) : inlineScope && entry.periodType && entry.periodType !== "unknown" ? periodLabel(entry.periodType) : accountCreditsWindowLabel(entry, locale, periodLabel);
|
|
18847
|
+
section.windows.push({
|
|
18848
|
+
order: groupedScope ? periodOrder(entry.periodType) : 0,
|
|
18849
|
+
window: {
|
|
18850
|
+
label,
|
|
18851
|
+
...inlineScope ? { scopeLabel: inlineScope } : {},
|
|
18852
|
+
usedPercent: entry.usedPercent,
|
|
18853
|
+
...entry.used === void 0 ? {} : { used: entry.used },
|
|
18854
|
+
...entry.limit === void 0 ? {} : { limit: entry.limit },
|
|
18855
|
+
...entry.unit === void 0 ? {} : { unit: entry.unit },
|
|
18856
|
+
...entry.resetsAt === void 0 ? {} : { resetsAt: entry.resetsAt },
|
|
18857
|
+
isPrimary: entry.isPrimary
|
|
18858
|
+
}
|
|
18859
|
+
});
|
|
18860
|
+
}
|
|
18861
|
+
return [...sections.values()].map(({ windows, ...section }) => ({
|
|
18862
|
+
...section,
|
|
18863
|
+
windows: (section.title !== void 0 ? [...windows].sort((left, right) => left.order - right.order) : windows).map((item) => item.window)
|
|
18864
|
+
}));
|
|
18865
|
+
}
|
|
18866
|
+
function countdownMinutes(value, nowMs) {
|
|
18867
|
+
const timestamp = typeof value === "number" ? value * 1e3 : Date.parse(value);
|
|
18868
|
+
if (!Number.isFinite(timestamp))
|
|
18869
|
+
return null;
|
|
18870
|
+
return Math.max(0, Math.ceil((timestamp - nowMs) / 6e4));
|
|
18871
|
+
}
|
|
18872
|
+
function isChineseLocale(locale) {
|
|
18873
|
+
return locale === "zh-CN" || locale.startsWith("zh-");
|
|
18874
|
+
}
|
|
18875
|
+
function compactDurationText(minutes) {
|
|
18876
|
+
if (minutes >= 1440) {
|
|
18877
|
+
const days = Math.floor(minutes / 1440);
|
|
18878
|
+
const hours2 = Math.floor(minutes % 1440 / 60);
|
|
18879
|
+
return hours2 > 0 ? `${days}d${hours2}h` : `${days}d`;
|
|
18880
|
+
}
|
|
18881
|
+
const hours = Math.floor(minutes / 60);
|
|
18882
|
+
const mins = minutes % 60;
|
|
18883
|
+
if (hours > 0)
|
|
18884
|
+
return mins > 0 ? `${hours}h${mins}m` : `${hours}h`;
|
|
18885
|
+
return `${mins}m`;
|
|
18886
|
+
}
|
|
18887
|
+
function formatAccountCreditsResetCountdown(value, locale, nowMs = Date.now()) {
|
|
18888
|
+
const minutes = countdownMinutes(value, nowMs);
|
|
18889
|
+
if (minutes === null)
|
|
18890
|
+
return null;
|
|
18891
|
+
const chinese = isChineseLocale(locale);
|
|
18892
|
+
if (minutes === 0)
|
|
18893
|
+
return chinese ? "\u5373\u5C06\u91CD\u7F6E" : "Resets soon";
|
|
18894
|
+
if (minutes >= 1440) {
|
|
18895
|
+
const days = Math.floor(minutes / 1440);
|
|
18896
|
+
const hours2 = Math.floor(minutes % 1440 / 60);
|
|
18897
|
+
if (chinese)
|
|
18898
|
+
return hours2 > 0 ? `${days} \u5929 ${hours2} \u5C0F\u65F6\u540E\u91CD\u7F6E` : `${days} \u5929\u540E\u91CD\u7F6E`;
|
|
18899
|
+
return hours2 > 0 ? `Resets in ${days}d ${hours2}h` : `Resets in ${days}d`;
|
|
18900
|
+
}
|
|
18901
|
+
const hours = Math.floor(minutes / 60);
|
|
18902
|
+
const mins = minutes % 60;
|
|
18903
|
+
if (hours > 0) {
|
|
18904
|
+
if (chinese)
|
|
18905
|
+
return mins > 0 ? `${hours} \u5C0F\u65F6 ${mins} \u5206\u540E\u91CD\u7F6E` : `${hours} \u5C0F\u65F6\u540E\u91CD\u7F6E`;
|
|
18906
|
+
return mins > 0 ? `Resets in ${hours}h ${mins}m` : `Resets in ${hours}h`;
|
|
18907
|
+
}
|
|
18908
|
+
return chinese ? `${mins} \u5206\u949F\u540E\u91CD\u7F6E` : `Resets in ${mins}m`;
|
|
18909
|
+
}
|
|
18910
|
+
function formatAccountCreditsCompactCountdown(value, locale, nowMs = Date.now()) {
|
|
18911
|
+
const minutes = countdownMinutes(value, nowMs);
|
|
18912
|
+
if (minutes === null)
|
|
18913
|
+
return null;
|
|
18914
|
+
if (minutes === 0)
|
|
18915
|
+
return isChineseLocale(locale) ? "\u5373\u5C06\u91CD\u7F6E" : "Resets soon";
|
|
18916
|
+
return compactDurationText(minutes);
|
|
18917
|
+
}
|
|
18768
18918
|
|
|
18769
18919
|
// ../shared-contracts/dist/model-price-overrides.js
|
|
18770
18920
|
var MODEL_PRICE_OVERRIDES_GET_METHOD = "codexhost/usage/model-prices/get";
|
|
@@ -24983,6 +25133,37 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
24983
25133
|
return fallback;
|
|
24984
25134
|
}
|
|
24985
25135
|
|
|
25136
|
+
// src/settings/harness-version-messages.ts
|
|
25137
|
+
var harnessVersionEnglish = Object.freeze({
|
|
25138
|
+
locale: "en",
|
|
25139
|
+
unknown: "Unknown",
|
|
25140
|
+
trackingBranch: "Tracking branch (new commits)",
|
|
25141
|
+
notes: Object.freeze({
|
|
25142
|
+
"original-installer": "Use the original installer, package manager, or launcher to update this installation."
|
|
25143
|
+
})
|
|
25144
|
+
});
|
|
25145
|
+
var harnessVersionChinese = Object.freeze({
|
|
25146
|
+
locale: "zh-CN",
|
|
25147
|
+
unknown: "\u672A\u77E5",
|
|
25148
|
+
trackingBranch: "\u8DDF\u8E2A\u5206\u652F\uFF08\u6709\u65B0\u63D0\u4EA4\uFF09",
|
|
25149
|
+
notes: Object.freeze({
|
|
25150
|
+
"original-installer": "\u8BF7\u4F7F\u7528\u539F\u5B89\u88C5\u7A0B\u5E8F\u3001\u5305\u7BA1\u7406\u5668\u6216\u542F\u52A8\u5668\u66F4\u65B0\u6B64\u5B89\u88C5\u3002"
|
|
25151
|
+
})
|
|
25152
|
+
});
|
|
25153
|
+
function harnessVersionLabel(state, messages) {
|
|
25154
|
+
if (!state) return "\u2014";
|
|
25155
|
+
if (state.latestVersionKind === "unknown" || state.latestVersion === "Unknown")
|
|
25156
|
+
return messages.unknown;
|
|
25157
|
+
if (state.latestVersionKind === "tracking-branch" || state.latestVersion === "Tracking branch (new commits)")
|
|
25158
|
+
return messages.trackingBranch;
|
|
25159
|
+
return state.latestVersion;
|
|
25160
|
+
}
|
|
25161
|
+
function harnessVersionNote(state, messages) {
|
|
25162
|
+
if (state?.notice) return localizeHarnessText(state.notice, messages.locale);
|
|
25163
|
+
const code = state?.messageCode;
|
|
25164
|
+
return code && Object.hasOwn(messages.notes, code) ? messages.notes[code] : void 0;
|
|
25165
|
+
}
|
|
25166
|
+
|
|
24986
25167
|
// ../../node_modules/lucide/dist/esm/icons/smartphone.mjs
|
|
24987
25168
|
var Smartphone = [
|
|
24988
25169
|
["rect", { width: "14", height: "20", x: "5", y: "2", rx: "2", ry: "2" }],
|
|
@@ -25481,509 +25662,474 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
25481
25662
|
return svg2;
|
|
25482
25663
|
}
|
|
25483
25664
|
|
|
25484
|
-
// src/settings/
|
|
25485
|
-
function
|
|
25486
|
-
|
|
25487
|
-
|
|
25488
|
-
|
|
25489
|
-
|
|
25490
|
-
|
|
25491
|
-
|
|
25492
|
-
|
|
25493
|
-
|
|
25494
|
-
|
|
25495
|
-
input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
|
|
25496
|
-
input.setAttribute("aria-label", messages.launchPathLabel);
|
|
25497
|
-
label.append(input);
|
|
25498
|
-
const help = document2.createElement("p");
|
|
25499
|
-
help.textContent = messages.locale === "zh-CN" ? "\u586B\u5199\u63D2\u4EF6\u5BF9\u5E94\u5E94\u7528\u7684\u5B89\u88C5\u76EE\u5F55\uFF1B\u6E05\u9664\u540E\u6062\u590D\u81EA\u52A8\u53D1\u73B0\u3002\u4FEE\u6539\u540E\u9700\u91CD\u542F codexhost\u3002" : "Choose the application's installation directory; clear it to restore automatic discovery. Restart codexhost after changing it.";
|
|
25500
|
-
const actions = document2.createElement("div");
|
|
25501
|
-
actions.className = "settings-harness-launch__actions";
|
|
25502
|
-
const save = document2.createElement("button");
|
|
25503
|
-
save.type = "button";
|
|
25504
|
-
save.className = "settings-command-button";
|
|
25505
|
-
save.textContent = messages.launchPathSave;
|
|
25506
|
-
const reset = document2.createElement("button");
|
|
25507
|
-
reset.type = "button";
|
|
25508
|
-
reset.className = "settings-command-button settings-command-button--secondary";
|
|
25509
|
-
reset.textContent = messages.launchPathReset;
|
|
25510
|
-
const status = document2.createElement("p");
|
|
25511
|
-
status.setAttribute("role", "status");
|
|
25512
|
-
status.setAttribute("aria-live", "polite");
|
|
25513
|
-
actions.append(save, reset);
|
|
25514
|
-
section.append(label, help, actions, status);
|
|
25515
|
-
let busy = true;
|
|
25516
|
-
let loaded = false;
|
|
25517
|
-
const controls = () => {
|
|
25518
|
-
input.disabled = busy || !loaded;
|
|
25519
|
-
save.disabled = busy || !loaded || !input.value.trim();
|
|
25520
|
-
reset.disabled = busy || !loaded;
|
|
25521
|
-
};
|
|
25522
|
-
const show = (value) => {
|
|
25523
|
-
input.value = value.path ?? "";
|
|
25524
|
-
status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
|
|
25525
|
-
};
|
|
25526
|
-
const persist = async (value) => {
|
|
25527
|
-
if (busy || !loaded) return;
|
|
25528
|
-
busy = true;
|
|
25529
|
-
controls();
|
|
25530
|
-
status.textContent = messages.launchPathSaving;
|
|
25531
|
-
try {
|
|
25532
|
-
show(await settings.set(value));
|
|
25533
|
-
} catch {
|
|
25534
|
-
status.textContent = messages.launchPathSaveError;
|
|
25535
|
-
} finally {
|
|
25536
|
-
busy = false;
|
|
25537
|
-
controls();
|
|
25538
|
-
}
|
|
25539
|
-
};
|
|
25540
|
-
input.addEventListener("input", controls);
|
|
25541
|
-
save.addEventListener("click", () => {
|
|
25542
|
-
if (input.value.trim()) void persist(input.value.trim());
|
|
25543
|
-
});
|
|
25544
|
-
reset.addEventListener("click", () => {
|
|
25545
|
-
void persist(null);
|
|
25546
|
-
});
|
|
25547
|
-
controls();
|
|
25548
|
-
status.textContent = messages.launchPathLoading;
|
|
25549
|
-
void settings.get().then((value) => {
|
|
25550
|
-
loaded = true;
|
|
25551
|
-
show(value);
|
|
25552
|
-
}).catch(() => {
|
|
25553
|
-
loaded = true;
|
|
25554
|
-
status.textContent = messages.launchPathLoadError;
|
|
25555
|
-
}).finally(() => {
|
|
25556
|
-
busy = false;
|
|
25557
|
-
controls();
|
|
25558
|
-
});
|
|
25559
|
-
return section;
|
|
25560
|
-
}
|
|
25561
|
-
|
|
25562
|
-
// src/settings/preference-ui.ts
|
|
25563
|
-
var nextPreferenceId = 0;
|
|
25564
|
-
function preferenceId(prefix) {
|
|
25565
|
-
nextPreferenceId += 1;
|
|
25566
|
-
return `codexhost-${prefix}-${nextPreferenceId}`;
|
|
25665
|
+
// src/settings/connection-row.ts
|
|
25666
|
+
function connectionStatusLabel(availability2, messages, hasError = false) {
|
|
25667
|
+
if (availability2 === "updating") return messages.connectionStatusUpdating;
|
|
25668
|
+
if (hasError && availability2 !== "notInstalled") return messages.connectionStatusError;
|
|
25669
|
+
if (availability2 === "ready") return messages.connectionStatusReady;
|
|
25670
|
+
if (availability2 === "checking") return messages.connectionStatusChecking;
|
|
25671
|
+
if (availability2 === "notInstalled") return messages.connectionStatusNotInstalled;
|
|
25672
|
+
if (availability2 === "unavailable" || availability2 === "error") {
|
|
25673
|
+
return availability2 === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
|
|
25674
|
+
}
|
|
25675
|
+
return availability2 === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
|
|
25567
25676
|
}
|
|
25568
|
-
function
|
|
25569
|
-
|
|
25570
|
-
|
|
25571
|
-
|
|
25572
|
-
|
|
25573
|
-
|
|
25574
|
-
|
|
25575
|
-
heading.className = "m-0 text-[13px] leading-5 font-semibold text-settings-text";
|
|
25576
|
-
heading.textContent = title;
|
|
25577
|
-
header.append(heading);
|
|
25578
|
-
const card = document2.createElement("div");
|
|
25579
|
-
card.className = "rounded-[10px] border border-settings-border bg-settings-panel";
|
|
25580
|
-
group.setAttribute("aria-labelledby", heading.id);
|
|
25581
|
-
group.append(header, card);
|
|
25582
|
-
return { group, header, card };
|
|
25677
|
+
function connectionStatusTone(availability2, hasError = false) {
|
|
25678
|
+
if (availability2 === "updating") return "checking";
|
|
25679
|
+
if (hasError && availability2 !== "notInstalled") return "failed";
|
|
25680
|
+
if (availability2 === "ready") return "ready";
|
|
25681
|
+
if (availability2 === "checking" || availability2 === "installing") return "checking";
|
|
25682
|
+
if (availability2 === "notInstalled") return "setup";
|
|
25683
|
+
return "failed";
|
|
25583
25684
|
}
|
|
25584
|
-
function
|
|
25585
|
-
const
|
|
25586
|
-
|
|
25587
|
-
|
|
25588
|
-
|
|
25589
|
-
|
|
25590
|
-
|
|
25591
|
-
|
|
25592
|
-
|
|
25593
|
-
|
|
25594
|
-
|
|
25595
|
-
|
|
25596
|
-
if (input.help) heading.append(createHelpTooltip(document2, input.help.label, input.help.lines));
|
|
25597
|
-
const description = document2.createElement("div");
|
|
25598
|
-
description.id = preferenceId("preference-description");
|
|
25599
|
-
description.className = "text-xs leading-[18px] text-settings-muted data-[invalid=true]:text-settings-danger";
|
|
25600
|
-
description.textContent = input.description;
|
|
25601
|
-
copy.append(heading, description);
|
|
25602
|
-
item.append(copy);
|
|
25603
|
-
return { item, description };
|
|
25685
|
+
function createConnectionIdentityIcon(document2, item, size) {
|
|
25686
|
+
const container = document2.createElement("span");
|
|
25687
|
+
container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
|
|
25688
|
+
container.setAttribute("aria-hidden", "true");
|
|
25689
|
+
if (item.agentSnapshot) {
|
|
25690
|
+
container.append(
|
|
25691
|
+
createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
|
|
25692
|
+
);
|
|
25693
|
+
} else {
|
|
25694
|
+
container.textContent = "CH";
|
|
25695
|
+
}
|
|
25696
|
+
return container;
|
|
25604
25697
|
}
|
|
25605
|
-
function
|
|
25606
|
-
|
|
25607
|
-
|
|
25608
|
-
|
|
25609
|
-
button2.type = "button";
|
|
25610
|
-
button2.className = "inline-flex size-4 cursor-help items-center justify-center rounded-full border-0 bg-transparent p-0 text-settings-subtle transition-colors hover:text-settings-text focus-visible:text-settings-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-settings-focus";
|
|
25611
|
-
button2.setAttribute("aria-label", label);
|
|
25612
|
-
button2.append(createRendererSettingsIcon("help", 14));
|
|
25613
|
-
const tooltip = document2.createElement("div");
|
|
25614
|
-
tooltip.id = preferenceId("preference-tooltip");
|
|
25615
|
-
tooltip.setAttribute("role", "tooltip");
|
|
25616
|
-
tooltip.className = "pointer-events-none invisible absolute top-full left-0 z-20 mt-2 w-80 rounded-lg border border-settings-border bg-settings-panel px-3 py-2.5 text-xs leading-[18px] font-normal text-settings-text opacity-0 shadow-[0_10px_30px_rgb(0_0_0/0.22)] transition-opacity duration-150 group-hover:visible group-hover:opacity-100 group-focus-within:visible group-focus-within:opacity-100";
|
|
25617
|
-
const list = document2.createElement("ul");
|
|
25618
|
-
list.className = "m-0 grid list-disc gap-1 pl-4 marker:text-settings-subtle";
|
|
25619
|
-
for (const line of lines) {
|
|
25620
|
-
const item = document2.createElement("li");
|
|
25621
|
-
item.textContent = line;
|
|
25622
|
-
list.append(item);
|
|
25698
|
+
function sameElementChildren(container, next) {
|
|
25699
|
+
if (container.children.length !== next.length) return false;
|
|
25700
|
+
for (let index = 0; index < next.length; index++) {
|
|
25701
|
+
if (container.children[index] !== next[index]) return false;
|
|
25623
25702
|
}
|
|
25624
|
-
|
|
25625
|
-
button2.setAttribute("aria-describedby", tooltip.id);
|
|
25626
|
-
button2.addEventListener("keydown", (event) => {
|
|
25627
|
-
if (event.key === "Escape") button2.blur();
|
|
25628
|
-
});
|
|
25629
|
-
wrapper.append(button2, tooltip);
|
|
25630
|
-
return wrapper;
|
|
25703
|
+
return true;
|
|
25631
25704
|
}
|
|
25632
|
-
function
|
|
25633
|
-
|
|
25634
|
-
|
|
25635
|
-
|
|
25636
|
-
|
|
25637
|
-
|
|
25638
|
-
|
|
25639
|
-
|
|
25705
|
+
function reconcileElementChildren(container, next) {
|
|
25706
|
+
if (sameElementChildren(container, next)) return;
|
|
25707
|
+
if (typeof container.insertBefore !== "function") {
|
|
25708
|
+
container.replaceChildren(...next);
|
|
25709
|
+
return;
|
|
25710
|
+
}
|
|
25711
|
+
const nextSet = new Set(next);
|
|
25712
|
+
for (const child of [...container.children]) {
|
|
25713
|
+
if (!nextSet.has(child)) child.remove();
|
|
25714
|
+
}
|
|
25715
|
+
for (let index = 0; index < next.length; index++) {
|
|
25716
|
+
const desired = next[index];
|
|
25717
|
+
if (!desired) continue;
|
|
25718
|
+
const current = container.children[index] ?? null;
|
|
25719
|
+
if (current !== desired) {
|
|
25720
|
+
container.insertBefore(desired, current);
|
|
25721
|
+
}
|
|
25722
|
+
}
|
|
25640
25723
|
}
|
|
25641
|
-
function
|
|
25642
|
-
|
|
25643
|
-
|
|
25644
|
-
|
|
25645
|
-
control.type = "number";
|
|
25646
|
-
control.id = input.id;
|
|
25647
|
-
control.min = String(input.min);
|
|
25648
|
-
control.max = String(input.max);
|
|
25649
|
-
control.step = "1";
|
|
25650
|
-
control.setAttribute("aria-describedby", input.describedBy);
|
|
25651
|
-
control.className = "w-14 border-0 bg-transparent p-0 text-right text-[13px] leading-5 text-settings-text tabular-nums outline-none";
|
|
25652
|
-
const unit = document2.createElement("span");
|
|
25653
|
-
unit.className = "text-xs text-settings-muted";
|
|
25654
|
-
unit.setAttribute("aria-hidden", "true");
|
|
25655
|
-
unit.textContent = input.unit;
|
|
25656
|
-
field2.append(control, unit);
|
|
25657
|
-
return { field: field2, control };
|
|
25724
|
+
function identityIconSignature(item) {
|
|
25725
|
+
if (!item.agentSnapshot) return "adapter";
|
|
25726
|
+
const plugin = item.agentSnapshot.plugin;
|
|
25727
|
+
return `${item.agentSnapshot.agent}:${String(plugin?.icon ?? "")}:${String(plugin?.iconStyle ?? "")}`;
|
|
25658
25728
|
}
|
|
25659
|
-
|
|
25660
|
-
|
|
25661
|
-
|
|
25662
|
-
|
|
25663
|
-
|
|
25664
|
-
|
|
25665
|
-
|
|
25666
|
-
|
|
25667
|
-
|
|
25668
|
-
|
|
25669
|
-
|
|
25670
|
-
|
|
25671
|
-
|
|
25672
|
-
|
|
25673
|
-
|
|
25674
|
-
|
|
25675
|
-
|
|
25676
|
-
|
|
25677
|
-
|
|
25678
|
-
|
|
25679
|
-
|
|
25680
|
-
|
|
25681
|
-
|
|
25682
|
-
);
|
|
25683
|
-
|
|
25684
|
-
|
|
25685
|
-
|
|
25686
|
-
|
|
25687
|
-
|
|
25688
|
-
|
|
25689
|
-
|
|
25690
|
-
|
|
25691
|
-
|
|
25692
|
-
|
|
25693
|
-
|
|
25694
|
-
|
|
25695
|
-
|
|
25696
|
-
|
|
25697
|
-
|
|
25698
|
-
|
|
25699
|
-
|
|
25700
|
-
|
|
25701
|
-
|
|
25702
|
-
|
|
25703
|
-
|
|
25704
|
-
|
|
25705
|
-
|
|
25706
|
-
|
|
25707
|
-
|
|
25708
|
-
|
|
25709
|
-
|
|
25710
|
-
|
|
25711
|
-
|
|
25712
|
-
|
|
25713
|
-
|
|
25714
|
-
|
|
25715
|
-
browserHeader.append(browserCopy, browserInput);
|
|
25716
|
-
const browserHelp = document2.createElement("p");
|
|
25717
|
-
browserHelp.className = "settings-grok-computer-use__help";
|
|
25718
|
-
browserHelp.id = "grok-browser-help";
|
|
25719
|
-
browserHelp.textContent = messages.grokBrowserHelp;
|
|
25720
|
-
const browserStatus = document2.createElement("p");
|
|
25721
|
-
browserStatus.className = "settings-grok-computer-use__status";
|
|
25722
|
-
browserStatus.id = "grok-browser-status";
|
|
25723
|
-
browserStatus.setAttribute("role", "status");
|
|
25724
|
-
browserStatus.setAttribute("aria-live", "polite");
|
|
25725
|
-
section.append(header, help, status, browserHeader, browserHelp, browserStatus);
|
|
25726
|
-
let busy = true;
|
|
25727
|
-
let loaded = false;
|
|
25728
|
-
let last;
|
|
25729
|
-
const show = (value) => {
|
|
25730
|
-
last = value;
|
|
25731
|
-
input.checked = value.enabled;
|
|
25732
|
-
input.disabled = busy || !loaded || !value.available && !value.enabled;
|
|
25733
|
-
const browserOn = value.browser === true;
|
|
25734
|
-
const browserFiles = value.browserFilesPresent === true;
|
|
25735
|
-
browserInput.checked = browserOn;
|
|
25736
|
-
browserInput.disabled = busy || !loaded || !browserFiles && !browserOn;
|
|
25737
|
-
if (!browserFiles) {
|
|
25738
|
-
browserStatus.dataset.state = "unavailable";
|
|
25739
|
-
browserStatus.textContent = value.browserUnavailableReason ?? messages.grokBrowserUnavailable;
|
|
25740
|
-
} else if (value.browserAvailable !== true) {
|
|
25741
|
-
browserStatus.dataset.state = browserOn ? "unavailable" : "off";
|
|
25742
|
-
browserStatus.textContent = browserOn ? value.browserUnavailableReason ?? messages.grokBrowserBlocked : messages.grokBrowserOff;
|
|
25743
|
-
} else {
|
|
25744
|
-
browserStatus.dataset.state = browserOn ? "on" : "off";
|
|
25745
|
-
browserStatus.textContent = browserOn ? messages.grokBrowserOn : messages.grokBrowserOff;
|
|
25746
|
-
}
|
|
25747
|
-
if (value.applyFailed) {
|
|
25748
|
-
status.dataset.state = "unavailable";
|
|
25749
|
-
status.textContent = value.applyError ?? messages.grokComputerUseApplyFailed;
|
|
25750
|
-
return;
|
|
25729
|
+
function createConnectionRowView(document2, messages, groupable) {
|
|
25730
|
+
const row = document2.createElement("div");
|
|
25731
|
+
row.className = "settings-connection-row";
|
|
25732
|
+
row.setAttribute("role", "row");
|
|
25733
|
+
const identity3 = document2.createElement("div");
|
|
25734
|
+
identity3.className = "settings-connection-row__identity";
|
|
25735
|
+
identity3.setAttribute("role", "cell");
|
|
25736
|
+
let handle = null;
|
|
25737
|
+
if (groupable) {
|
|
25738
|
+
handle = document2.createElement("span");
|
|
25739
|
+
handle.className = "settings-connection-row__handle";
|
|
25740
|
+
handle.setAttribute("aria-hidden", "true");
|
|
25741
|
+
handle.append(createRendererSettingsIcon("grip-vertical", 15));
|
|
25742
|
+
identity3.append(handle);
|
|
25743
|
+
}
|
|
25744
|
+
let iconElement = null;
|
|
25745
|
+
let renderedIconKey = null;
|
|
25746
|
+
const label = document2.createElement("strong");
|
|
25747
|
+
const status = document2.createElement("span");
|
|
25748
|
+
status.className = "settings-connection-row__status";
|
|
25749
|
+
status.setAttribute("role", "cell");
|
|
25750
|
+
const action = document2.createElement("div");
|
|
25751
|
+
action.className = "settings-connection-row__action";
|
|
25752
|
+
action.setAttribute("role", "cell");
|
|
25753
|
+
row.append(identity3, status, action);
|
|
25754
|
+
let currentItem = null;
|
|
25755
|
+
let currentSelect = () => void 0;
|
|
25756
|
+
let currentGroup = null;
|
|
25757
|
+
let installButton = null;
|
|
25758
|
+
let viewErrorButton = null;
|
|
25759
|
+
let versionAvailableBadge = null;
|
|
25760
|
+
let updateButton = null;
|
|
25761
|
+
let groupToggleButton = null;
|
|
25762
|
+
let groupToggleSection = null;
|
|
25763
|
+
row.addEventListener("click", (event) => {
|
|
25764
|
+
const target2 = event.target;
|
|
25765
|
+
if (target2?.closest?.("a")) return;
|
|
25766
|
+
currentSelect();
|
|
25767
|
+
});
|
|
25768
|
+
row.addEventListener("keydown", (event) => {
|
|
25769
|
+
if (event.target?.closest?.("button, a")) return;
|
|
25770
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
25771
|
+
event.preventDefault();
|
|
25772
|
+
currentSelect();
|
|
25773
|
+
});
|
|
25774
|
+
if (groupable) {
|
|
25775
|
+
row.addEventListener("dragstart", (event) => currentGroup?.onDragStart(event));
|
|
25776
|
+
row.addEventListener("dragover", (event) => currentGroup?.onDragOver(event));
|
|
25777
|
+
row.addEventListener("dragleave", (event) => currentGroup?.onDragLeave(event));
|
|
25778
|
+
row.addEventListener("drop", (event) => currentGroup?.onDrop(event));
|
|
25779
|
+
row.addEventListener("dragend", (event) => currentGroup?.onDragEnd(event));
|
|
25780
|
+
}
|
|
25781
|
+
const setSelected = (selected) => {
|
|
25782
|
+
const nextSelected = String(selected);
|
|
25783
|
+
if (row.dataset.connectionSelected !== nextSelected) {
|
|
25784
|
+
row.dataset.connectionSelected = nextSelected;
|
|
25751
25785
|
}
|
|
25752
|
-
|
|
25753
|
-
|
|
25754
|
-
|
|
25755
|
-
return;
|
|
25786
|
+
const nextTabIndex = selected ? 0 : -1;
|
|
25787
|
+
if (row.tabIndex !== nextTabIndex) {
|
|
25788
|
+
row.tabIndex = nextTabIndex;
|
|
25756
25789
|
}
|
|
25757
|
-
status.dataset.state = value.enabled ? "on" : "off";
|
|
25758
|
-
status.textContent = value.enabled ? messages.grokComputerUseOn : messages.grokComputerUseOff;
|
|
25759
25790
|
};
|
|
25760
|
-
|
|
25761
|
-
|
|
25762
|
-
|
|
25763
|
-
|
|
25764
|
-
|
|
25765
|
-
|
|
25766
|
-
|
|
25767
|
-
|
|
25768
|
-
|
|
25769
|
-
|
|
25770
|
-
|
|
25771
|
-
|
|
25772
|
-
|
|
25773
|
-
|
|
25774
|
-
|
|
25791
|
+
return {
|
|
25792
|
+
element: row,
|
|
25793
|
+
setSelected,
|
|
25794
|
+
update(item, selected, select, group) {
|
|
25795
|
+
currentItem = item;
|
|
25796
|
+
currentSelect = select;
|
|
25797
|
+
currentGroup = group;
|
|
25798
|
+
if (row.dataset.connectionItem !== item.key) {
|
|
25799
|
+
row.dataset.connectionItem = item.key;
|
|
25800
|
+
}
|
|
25801
|
+
setSelected(selected);
|
|
25802
|
+
const nextIconKey = identityIconSignature(item);
|
|
25803
|
+
if (renderedIconKey !== nextIconKey || !iconElement) {
|
|
25804
|
+
renderedIconKey = nextIconKey;
|
|
25805
|
+
iconElement = createConnectionIdentityIcon(document2, item, 19);
|
|
25806
|
+
reconcileElementChildren(
|
|
25807
|
+
identity3,
|
|
25808
|
+
handle ? [handle, iconElement, label] : [iconElement, label]
|
|
25809
|
+
);
|
|
25775
25810
|
}
|
|
25776
|
-
|
|
25777
|
-
|
|
25811
|
+
if (handle && group && handle.title !== group.dragHandleTitle) {
|
|
25812
|
+
handle.title = group.dragHandleTitle;
|
|
25813
|
+
}
|
|
25814
|
+
if (label.textContent !== item.name) {
|
|
25815
|
+
label.textContent = item.name;
|
|
25816
|
+
}
|
|
25817
|
+
const tone = connectionStatusTone(item.availability, item.error !== null);
|
|
25818
|
+
if (status.dataset.connectionTone !== tone) {
|
|
25819
|
+
status.dataset.connectionTone = tone;
|
|
25820
|
+
}
|
|
25821
|
+
const statusText = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
|
|
25822
|
+
if (status.textContent !== statusText) {
|
|
25823
|
+
status.textContent = statusText;
|
|
25824
|
+
}
|
|
25825
|
+
const nextActions = [];
|
|
25826
|
+
if (item.agentSnapshot?.availability === "notInstalled" && item.install) {
|
|
25827
|
+
if (!installButton) {
|
|
25828
|
+
const button2 = document2.createElement("button");
|
|
25829
|
+
button2.type = "button";
|
|
25830
|
+
button2.className = "settings-connection-install-link";
|
|
25831
|
+
button2.append(createRendererSettingsIcon("download", 17));
|
|
25832
|
+
button2.addEventListener("click", (event) => {
|
|
25833
|
+
event.stopPropagation();
|
|
25834
|
+
currentSelect();
|
|
25835
|
+
currentItem?.install?.();
|
|
25836
|
+
});
|
|
25837
|
+
installButton = button2;
|
|
25838
|
+
}
|
|
25839
|
+
installButton.disabled = item.availability === "installing" || item.availability === "checking";
|
|
25840
|
+
const installLabel = messages.connectionInstall;
|
|
25841
|
+
const ariaLabel = `${installLabel}: ${item.name}`;
|
|
25842
|
+
if (installButton.getAttribute("aria-label") !== ariaLabel) {
|
|
25843
|
+
installButton.setAttribute("aria-label", ariaLabel);
|
|
25844
|
+
}
|
|
25845
|
+
if (installButton.title !== installLabel) {
|
|
25846
|
+
installButton.title = installLabel;
|
|
25847
|
+
}
|
|
25848
|
+
nextActions.push(installButton);
|
|
25849
|
+
} else if (item.error) {
|
|
25850
|
+
if (!viewErrorButton) {
|
|
25851
|
+
const button2 = document2.createElement("button");
|
|
25852
|
+
button2.type = "button";
|
|
25853
|
+
button2.className = "settings-connection-view-error";
|
|
25854
|
+
button2.textContent = messages.connectionViewError;
|
|
25855
|
+
button2.addEventListener("click", (event) => {
|
|
25856
|
+
event.stopPropagation();
|
|
25857
|
+
currentSelect();
|
|
25858
|
+
});
|
|
25859
|
+
viewErrorButton = button2;
|
|
25860
|
+
}
|
|
25861
|
+
nextActions.push(viewErrorButton);
|
|
25862
|
+
}
|
|
25863
|
+
const version2 = item.version;
|
|
25864
|
+
if (version2?.state?.updateAvailable && !version2.updating) {
|
|
25865
|
+
if (!versionAvailableBadge) {
|
|
25866
|
+
const badge = document2.createElement("span");
|
|
25867
|
+
badge.className = "settings-connection-version-available";
|
|
25868
|
+
badge.textContent = messages.harnessVersionAvailable;
|
|
25869
|
+
versionAvailableBadge = badge;
|
|
25870
|
+
}
|
|
25871
|
+
const badgeTitle = `${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
|
|
25872
|
+
${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
|
|
25873
|
+
if (versionAvailableBadge.title !== badgeTitle) {
|
|
25874
|
+
versionAvailableBadge.title = badgeTitle;
|
|
25875
|
+
}
|
|
25876
|
+
nextActions.push(versionAvailableBadge);
|
|
25877
|
+
}
|
|
25878
|
+
if (version2?.state?.updateAvailable && version2.state.canUpdate) {
|
|
25879
|
+
if (!updateButton) {
|
|
25880
|
+
const button2 = document2.createElement("button");
|
|
25881
|
+
button2.type = "button";
|
|
25882
|
+
button2.className = "settings-connection-install-link";
|
|
25883
|
+
button2.dataset.connectionAction = "update";
|
|
25884
|
+
button2.append(createRendererSettingsIcon("download", 17));
|
|
25885
|
+
button2.addEventListener("click", (event) => {
|
|
25886
|
+
event.stopPropagation();
|
|
25887
|
+
if (button2.disabled) return;
|
|
25888
|
+
void currentItem?.version?.update();
|
|
25889
|
+
currentSelect();
|
|
25890
|
+
});
|
|
25891
|
+
updateButton = button2;
|
|
25892
|
+
}
|
|
25893
|
+
updateButton.disabled = version2.updating;
|
|
25894
|
+
if (updateButton.title !== messages.harnessVersionUpdate) {
|
|
25895
|
+
updateButton.title = messages.harnessVersionUpdate;
|
|
25896
|
+
}
|
|
25897
|
+
const updateAriaLabel = `${messages.harnessVersionUpdate}: ${item.name}`;
|
|
25898
|
+
if (updateButton.getAttribute("aria-label") !== updateAriaLabel) {
|
|
25899
|
+
updateButton.setAttribute("aria-label", updateAriaLabel);
|
|
25900
|
+
}
|
|
25901
|
+
nextActions.push(updateButton);
|
|
25902
|
+
}
|
|
25903
|
+
if (group) {
|
|
25904
|
+
if (!groupToggleButton) {
|
|
25905
|
+
const button2 = document2.createElement("button");
|
|
25906
|
+
button2.type = "button";
|
|
25907
|
+
button2.className = "settings-connection-row__group-toggle";
|
|
25908
|
+
button2.addEventListener("click", (event) => {
|
|
25909
|
+
event.stopPropagation();
|
|
25910
|
+
currentGroup?.toggleSection();
|
|
25911
|
+
});
|
|
25912
|
+
groupToggleButton = button2;
|
|
25913
|
+
}
|
|
25914
|
+
groupToggleButton.disabled = group.disabled;
|
|
25915
|
+
if (groupToggleButton.title !== group.moveLabel) {
|
|
25916
|
+
groupToggleButton.title = group.moveLabel;
|
|
25917
|
+
}
|
|
25918
|
+
if (groupToggleButton.getAttribute("aria-label") !== group.moveLabel) {
|
|
25919
|
+
groupToggleButton.setAttribute("aria-label", group.moveLabel);
|
|
25920
|
+
}
|
|
25921
|
+
if (groupToggleSection !== group.section) {
|
|
25922
|
+
groupToggleSection = group.section;
|
|
25923
|
+
groupToggleButton.replaceChildren(
|
|
25924
|
+
createRendererSettingsIcon(
|
|
25925
|
+
group.section === "main" ? "chevron-down" : "chevron-up",
|
|
25926
|
+
15
|
|
25927
|
+
)
|
|
25928
|
+
);
|
|
25929
|
+
}
|
|
25930
|
+
nextActions.push(groupToggleButton);
|
|
25931
|
+
}
|
|
25932
|
+
reconcileElementChildren(action, nextActions);
|
|
25933
|
+
if (group) {
|
|
25934
|
+
row.draggable = !group.disabled;
|
|
25935
|
+
if (row.dataset.connectionGroupSection !== group.section) {
|
|
25936
|
+
row.dataset.connectionGroupSection = group.section;
|
|
25937
|
+
}
|
|
25938
|
+
}
|
|
25939
|
+
}
|
|
25778
25940
|
};
|
|
25779
|
-
input.addEventListener("change", () => save({ enabled: input.checked }, status));
|
|
25780
|
-
browserInput.addEventListener(
|
|
25781
|
-
"change",
|
|
25782
|
-
() => save({ browser: browserInput.checked }, browserStatus)
|
|
25783
|
-
);
|
|
25784
|
-
status.textContent = messages.grokComputerUseLoading;
|
|
25785
|
-
browserStatus.textContent = messages.grokBrowserOff;
|
|
25786
|
-
void settings.get().then((value) => {
|
|
25787
|
-
loaded = true;
|
|
25788
|
-
busy = false;
|
|
25789
|
-
show(value);
|
|
25790
|
-
}).catch(() => {
|
|
25791
|
-
busy = false;
|
|
25792
|
-
status.textContent = messages.grokComputerUseLoadError;
|
|
25793
|
-
browserStatus.textContent = messages.grokComputerUseLoadError;
|
|
25794
|
-
});
|
|
25795
|
-
return section;
|
|
25796
25941
|
}
|
|
25797
25942
|
|
|
25798
|
-
// src/settings/
|
|
25799
|
-
|
|
25800
|
-
|
|
25943
|
+
// src/settings/connection-updates.ts
|
|
25944
|
+
var sharedBatchStores = /* @__PURE__ */ new WeakMap();
|
|
25945
|
+
function getBatchStore(diagnostics) {
|
|
25946
|
+
if (!diagnostics) {
|
|
25947
|
+
return { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
|
|
25948
|
+
}
|
|
25949
|
+
let store = sharedBatchStores.get(diagnostics);
|
|
25950
|
+
if (!store) {
|
|
25951
|
+
store = { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
|
|
25952
|
+
sharedBatchStores.set(diagnostics, store);
|
|
25953
|
+
}
|
|
25954
|
+
return store;
|
|
25801
25955
|
}
|
|
25802
|
-
function
|
|
25803
|
-
const
|
|
25804
|
-
const
|
|
25956
|
+
function createConnectionUpdates(document2, messages, signal, onChange, diagnostics = null) {
|
|
25957
|
+
const store = getBatchStore(diagnostics);
|
|
25958
|
+
const notify2 = () => {
|
|
25959
|
+
for (const listener of [...store.listeners]) listener();
|
|
25960
|
+
};
|
|
25961
|
+
if (!signal.aborted) {
|
|
25962
|
+
const listener = () => {
|
|
25963
|
+
if (!signal.aborted) onChange();
|
|
25964
|
+
};
|
|
25965
|
+
store.listeners.add(listener);
|
|
25966
|
+
signal.addEventListener(
|
|
25967
|
+
"abort",
|
|
25968
|
+
() => {
|
|
25969
|
+
store.listeners.delete(listener);
|
|
25970
|
+
},
|
|
25971
|
+
{ once: true }
|
|
25972
|
+
);
|
|
25973
|
+
}
|
|
25974
|
+
const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
|
|
25975
|
+
const start = async (hostId2, panels) => {
|
|
25976
|
+
if (signal.aborted || store.batches.get(hostId2)?.running) return;
|
|
25977
|
+
const targets = eligible(panels);
|
|
25978
|
+
if (!targets.length) return;
|
|
25979
|
+
const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
|
|
25980
|
+
store.batches.set(hostId2, batch);
|
|
25981
|
+
notify2();
|
|
25982
|
+
await Promise.all(
|
|
25983
|
+
targets.map(async (panel) => {
|
|
25984
|
+
try {
|
|
25985
|
+
if (await panel.update()) batch.succeeded++;
|
|
25986
|
+
else batch.failed++;
|
|
25987
|
+
} catch {
|
|
25988
|
+
batch.failed++;
|
|
25989
|
+
}
|
|
25990
|
+
notify2();
|
|
25991
|
+
})
|
|
25992
|
+
);
|
|
25993
|
+
batch.running = false;
|
|
25994
|
+
notify2();
|
|
25995
|
+
};
|
|
25805
25996
|
return {
|
|
25806
|
-
|
|
25807
|
-
|
|
25808
|
-
|
|
25809
|
-
|
|
25810
|
-
|
|
25997
|
+
createControls(hostId2, panels) {
|
|
25998
|
+
let currentHostId = hostId2;
|
|
25999
|
+
let currentPanels = panels;
|
|
26000
|
+
let renderedLabel = null;
|
|
26001
|
+
const button2 = document2.createElement("button");
|
|
26002
|
+
button2.type = "button";
|
|
26003
|
+
button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
|
|
26004
|
+
button2.dataset.connectionAction = "update-all";
|
|
26005
|
+
button2.title = messages.harnessUpdateAllDescription;
|
|
26006
|
+
button2.addEventListener("click", () => {
|
|
26007
|
+
if (!button2.disabled) void start(currentHostId, currentPanels);
|
|
26008
|
+
});
|
|
26009
|
+
const result = document2.createElement("p");
|
|
26010
|
+
result.className = "settings-connection-update-result";
|
|
26011
|
+
result.setAttribute("role", "status");
|
|
26012
|
+
const update = (nextHostId, nextPanels) => {
|
|
26013
|
+
currentHostId = nextHostId;
|
|
26014
|
+
currentPanels = nextPanels;
|
|
26015
|
+
const batch = store.batches.get(nextHostId);
|
|
26016
|
+
const count4 = eligible(nextPanels).length;
|
|
26017
|
+
button2.disabled = signal.aborted || Boolean(batch?.running) || !count4;
|
|
26018
|
+
const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count4 ? `${messages.harnessUpdateAll} (${count4})` : messages.harnessUpdateAll;
|
|
26019
|
+
if (renderedLabel !== label) {
|
|
26020
|
+
renderedLabel = label;
|
|
26021
|
+
button2.replaceChildren(createRendererSettingsIcon("download", 15), label);
|
|
26022
|
+
}
|
|
26023
|
+
const hidden = !batch || batch.running;
|
|
26024
|
+
result.hidden = hidden;
|
|
26025
|
+
const resultText = batch && !batch.running ? messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed)) : "";
|
|
26026
|
+
if (result.textContent !== resultText) {
|
|
26027
|
+
result.textContent = resultText;
|
|
26028
|
+
}
|
|
26029
|
+
};
|
|
26030
|
+
update(hostId2, panels);
|
|
26031
|
+
return { button: button2, result, update };
|
|
26032
|
+
}
|
|
25811
26033
|
};
|
|
25812
26034
|
}
|
|
25813
26035
|
|
|
25814
|
-
// src/settings/harness-
|
|
25815
|
-
function
|
|
25816
|
-
|
|
25817
|
-
const guide = harnessInstallationGuide(plugin, messages.locale);
|
|
25818
|
-
const panel = document2.createElement("div");
|
|
25819
|
-
panel.className = "settings-harness-installation";
|
|
25820
|
-
const paragraph = (text) => {
|
|
25821
|
-
const p = document2.createElement("p");
|
|
25822
|
-
p.textContent = text;
|
|
25823
|
-
panel.append(p);
|
|
25824
|
-
};
|
|
25825
|
-
if (hostId2 !== "local") {
|
|
25826
|
-
paragraph(zh ? "\u8BF7\u5728\u8FDC\u7A0B Host \u4E0A\u5B89\u88C5\u3002" : "Install on the remote Host.");
|
|
25827
|
-
}
|
|
25828
|
-
if (guide.before) paragraph(guide.before);
|
|
25829
|
-
const install = installation && guide.commands.length > 0 ? document2.createElement("button") : null;
|
|
25830
|
-
if (install && installation) {
|
|
25831
|
-
install.type = "button";
|
|
25832
|
-
install.className = "settings-command-button";
|
|
25833
|
-
install.dataset.connectionAction = "install";
|
|
25834
|
-
install.disabled = installation.status !== "idle";
|
|
25835
|
-
install.textContent = installation.status === "installing" ? messages.connectionStatusInstalling : installation.status === "checking" ? messages.connectionStatusChecking : zh ? "\u4E00\u952E\u5B89\u88C5" : "Install automatically";
|
|
25836
|
-
install.addEventListener("click", () => {
|
|
25837
|
-
if (install.disabled) return;
|
|
25838
|
-
install.disabled = true;
|
|
25839
|
-
install.textContent = messages.connectionStatusInstalling;
|
|
25840
|
-
installation.run();
|
|
25841
|
-
});
|
|
25842
|
-
if (guide.commands.length > 1) panel.append(install);
|
|
25843
|
-
}
|
|
25844
|
-
for (const { terminal, command } of guide.commands) {
|
|
25845
|
-
const block = document2.createElement("div");
|
|
25846
|
-
block.className = "settings-harness-installation-command";
|
|
25847
|
-
const label = document2.createElement("strong");
|
|
25848
|
-
label.textContent = terminal;
|
|
25849
|
-
const pre = document2.createElement("pre");
|
|
25850
|
-
const code = document2.createElement("code");
|
|
25851
|
-
code.textContent = command;
|
|
25852
|
-
pre.append(code);
|
|
25853
|
-
const button2 = document2.createElement("button");
|
|
25854
|
-
button2.type = "button";
|
|
25855
|
-
button2.className = "settings-command-button settings-command-button--secondary";
|
|
25856
|
-
button2.dataset.connectionAction = "copy-install";
|
|
25857
|
-
const copyLabel = zh ? "\u590D\u5236\u547D\u4EE4" : "Copy command";
|
|
25858
|
-
button2.setAttribute("aria-label", `${copyLabel}: ${terminal}`);
|
|
25859
|
-
button2.append(createRendererSettingsIcon("copy", 16), copyLabel);
|
|
25860
|
-
button2.addEventListener("click", () => copy(button2, command, copyLabel));
|
|
25861
|
-
const actions = document2.createElement("div");
|
|
25862
|
-
actions.className = "settings-harness-installation-actions";
|
|
25863
|
-
if (install && guide.commands.length === 1) actions.append(install);
|
|
25864
|
-
actions.append(button2);
|
|
25865
|
-
block.append(label, pre, actions);
|
|
25866
|
-
panel.append(block);
|
|
25867
|
-
}
|
|
25868
|
-
for (const download2 of guide.downloads ?? []) {
|
|
25869
|
-
const link = document2.createElement("a");
|
|
25870
|
-
link.className = "settings-command-button settings-command-button--secondary";
|
|
25871
|
-
link.href = download2.url;
|
|
25872
|
-
link.target = "_blank";
|
|
25873
|
-
link.rel = "noopener noreferrer";
|
|
25874
|
-
link.textContent = zh ? "\u4E0B\u8F7D" : "Download";
|
|
25875
|
-
link.setAttribute("aria-label", `${link.textContent} ${download2.label}`);
|
|
25876
|
-
panel.append(link);
|
|
25877
|
-
}
|
|
25878
|
-
if (guide.after) paragraph(guide.after);
|
|
25879
|
-
if (!plugin?.installation && guide.url) {
|
|
25880
|
-
const link = document2.createElement("a");
|
|
25881
|
-
link.href = guide.url;
|
|
25882
|
-
link.target = "_blank";
|
|
25883
|
-
link.rel = "noopener noreferrer";
|
|
25884
|
-
link.textContent = zh ? "\u5B89\u88C5\u8BF4\u660E" : "Installation instructions";
|
|
25885
|
-
panel.append(link);
|
|
25886
|
-
}
|
|
25887
|
-
return panel;
|
|
25888
|
-
}
|
|
25889
|
-
|
|
25890
|
-
// src/settings/harness-install-store.ts
|
|
25891
|
-
function errorMessage(error51) {
|
|
25892
|
-
return typeof error51 === "object" && error51 !== null && "message" in error51 && typeof error51.message === "string" ? error51.message.slice(0, 2048) : "Could not install the Harness. Check the official installation guide and retry.";
|
|
25893
|
-
}
|
|
25894
|
-
function unknownInstallOutcome(message2) {
|
|
25895
|
-
return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
|
|
26036
|
+
// src/settings/harness-version-panel.ts
|
|
26037
|
+
function isUnsupportedInstallationError(error51) {
|
|
26038
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
|
|
25896
26039
|
}
|
|
25897
|
-
|
|
25898
|
-
|
|
25899
|
-
|
|
26040
|
+
function createHarnessVersionSession(client, options) {
|
|
26041
|
+
let state;
|
|
26042
|
+
let statusKind = "checking";
|
|
26043
|
+
let checkPromise = null;
|
|
26044
|
+
let updatePromise = null;
|
|
25900
26045
|
const listeners = /* @__PURE__ */ new Set();
|
|
25901
|
-
const
|
|
25902
|
-
const notify2 = () =>
|
|
26046
|
+
const signal = options?.signal;
|
|
26047
|
+
const notify2 = (pageChange) => {
|
|
26048
|
+
if (signal?.aborted) return;
|
|
26049
|
+
for (const listener of [...listeners]) listener(pageChange);
|
|
26050
|
+
};
|
|
26051
|
+
const check2 = () => {
|
|
26052
|
+
if (signal?.aborted || updatePromise) return Promise.resolve();
|
|
26053
|
+
if (checkPromise) return checkPromise;
|
|
26054
|
+
statusKind = "checking";
|
|
26055
|
+
notify2(false);
|
|
26056
|
+
checkPromise = (async () => {
|
|
26057
|
+
try {
|
|
26058
|
+
const result = await client.run("check");
|
|
26059
|
+
if (signal?.aborted || updatePromise) return;
|
|
26060
|
+
state = result;
|
|
26061
|
+
statusKind = "idle";
|
|
26062
|
+
} catch (error51) {
|
|
26063
|
+
if (signal?.aborted || updatePromise) return;
|
|
26064
|
+
statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
|
|
26065
|
+
if (state) state = { ...state, canUpdate: false };
|
|
26066
|
+
} finally {
|
|
26067
|
+
checkPromise = null;
|
|
26068
|
+
if (!signal?.aborted && !updatePromise) {
|
|
26069
|
+
notify2(true);
|
|
26070
|
+
}
|
|
26071
|
+
}
|
|
26072
|
+
})();
|
|
26073
|
+
return checkPromise;
|
|
26074
|
+
};
|
|
26075
|
+
const update = () => {
|
|
26076
|
+
if (updatePromise) return updatePromise;
|
|
26077
|
+
updatePromise = (async () => {
|
|
26078
|
+
if (signal?.aborted) return false;
|
|
26079
|
+
if (checkPromise) await checkPromise;
|
|
26080
|
+
if (signal?.aborted || statusKind === "unsupported" || !state?.canUpdate || !state.updateAvailable) {
|
|
26081
|
+
return false;
|
|
26082
|
+
}
|
|
26083
|
+
statusKind = "updating";
|
|
26084
|
+
notify2(true);
|
|
26085
|
+
try {
|
|
26086
|
+
const result = await client.run("update");
|
|
26087
|
+
if (signal?.aborted) return false;
|
|
26088
|
+
state = result;
|
|
26089
|
+
statusKind = !result.canUpdate ? "updated" : result.updateAvailable ? "failed" : "updated";
|
|
26090
|
+
return result.canUpdate && !result.updateAvailable;
|
|
26091
|
+
} catch (error51) {
|
|
26092
|
+
if (signal?.aborted) return false;
|
|
26093
|
+
statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
|
|
26094
|
+
if (state) state = { ...state, canUpdate: false };
|
|
26095
|
+
return false;
|
|
26096
|
+
} finally {
|
|
26097
|
+
updatePromise = null;
|
|
26098
|
+
if (!signal?.aborted) {
|
|
26099
|
+
notify2(true);
|
|
26100
|
+
}
|
|
26101
|
+
}
|
|
26102
|
+
})();
|
|
26103
|
+
return updatePromise;
|
|
26104
|
+
};
|
|
25903
26105
|
return {
|
|
25904
|
-
get
|
|
25905
|
-
|
|
25906
|
-
for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
|
|
25907
|
-
notify2();
|
|
26106
|
+
get state() {
|
|
26107
|
+
return state;
|
|
25908
26108
|
},
|
|
26109
|
+
get statusKind() {
|
|
26110
|
+
return statusKind;
|
|
26111
|
+
},
|
|
26112
|
+
get updating() {
|
|
26113
|
+
return statusKind === "updating";
|
|
26114
|
+
},
|
|
26115
|
+
prepareMount() {
|
|
26116
|
+
if (updatePromise || checkPromise) return false;
|
|
26117
|
+
statusKind = "checking";
|
|
26118
|
+
return true;
|
|
26119
|
+
},
|
|
26120
|
+
check: check2,
|
|
26121
|
+
update,
|
|
25909
26122
|
subscribe(listener) {
|
|
25910
26123
|
listeners.add(listener);
|
|
25911
26124
|
return () => {
|
|
25912
26125
|
listeners.delete(listener);
|
|
25913
26126
|
};
|
|
25914
|
-
},
|
|
25915
|
-
async install(host, agent) {
|
|
25916
|
-
const id = key(host, agent);
|
|
25917
|
-
const previous = states2.get(id);
|
|
25918
|
-
if (!diagnostics.installation || previous && previous.status !== "error") return;
|
|
25919
|
-
states2.set(id, { status: "installing" });
|
|
25920
|
-
notify2();
|
|
25921
|
-
let failure;
|
|
25922
|
-
try {
|
|
25923
|
-
await diagnostics.installation(host, agent, "install");
|
|
25924
|
-
states2.set(id, { status: "checking" });
|
|
25925
|
-
notify2();
|
|
25926
|
-
} catch (error51) {
|
|
25927
|
-
failure = errorMessage(error51);
|
|
25928
|
-
}
|
|
25929
|
-
try {
|
|
25930
|
-
await diagnostics.refresh(host);
|
|
25931
|
-
const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
|
|
25932
|
-
if (refreshed?.availability === "ready") failure = void 0;
|
|
25933
|
-
else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
|
|
25934
|
-
failure = void 0;
|
|
25935
|
-
}
|
|
25936
|
-
} catch (error51) {
|
|
25937
|
-
failure ??= errorMessage(error51);
|
|
25938
|
-
}
|
|
25939
|
-
if (failure) states2.set(id, { status: "error", error: failure });
|
|
25940
|
-
else states2.delete(id);
|
|
25941
|
-
notify2();
|
|
25942
26127
|
}
|
|
25943
26128
|
};
|
|
25944
26129
|
}
|
|
25945
|
-
function
|
|
25946
|
-
|
|
25947
|
-
|
|
25948
|
-
store = createStore(diagnostics);
|
|
25949
|
-
stores.set(diagnostics, store);
|
|
25950
|
-
}
|
|
25951
|
-
return store;
|
|
25952
|
-
}
|
|
25953
|
-
|
|
25954
|
-
// src/settings/harness-version-messages.ts
|
|
25955
|
-
var harnessVersionEnglish = Object.freeze({
|
|
25956
|
-
locale: "en",
|
|
25957
|
-
unknown: "Unknown",
|
|
25958
|
-
trackingBranch: "Tracking branch (new commits)",
|
|
25959
|
-
notes: Object.freeze({
|
|
25960
|
-
"original-installer": "Use the original installer, package manager, or launcher to update this installation."
|
|
25961
|
-
})
|
|
25962
|
-
});
|
|
25963
|
-
var harnessVersionChinese = Object.freeze({
|
|
25964
|
-
locale: "zh-CN",
|
|
25965
|
-
unknown: "\u672A\u77E5",
|
|
25966
|
-
trackingBranch: "\u8DDF\u8E2A\u5206\u652F\uFF08\u6709\u65B0\u63D0\u4EA4\uFF09",
|
|
25967
|
-
notes: Object.freeze({
|
|
25968
|
-
"original-installer": "\u8BF7\u4F7F\u7528\u539F\u5B89\u88C5\u7A0B\u5E8F\u3001\u5305\u7BA1\u7406\u5668\u6216\u542F\u52A8\u5668\u66F4\u65B0\u6B64\u5B89\u88C5\u3002"
|
|
25969
|
-
})
|
|
25970
|
-
});
|
|
25971
|
-
function harnessVersionLabel(state, messages) {
|
|
25972
|
-
if (!state) return "\u2014";
|
|
25973
|
-
if (state.latestVersionKind === "unknown" || state.latestVersion === "Unknown")
|
|
25974
|
-
return messages.unknown;
|
|
25975
|
-
if (state.latestVersionKind === "tracking-branch" || state.latestVersion === "Tracking branch (new commits)")
|
|
25976
|
-
return messages.trackingBranch;
|
|
25977
|
-
return state.latestVersion;
|
|
25978
|
-
}
|
|
25979
|
-
function harnessVersionNote(state, messages) {
|
|
25980
|
-
if (state?.notice) return localizeHarnessText(state.notice, messages.locale);
|
|
25981
|
-
const code = state?.messageCode;
|
|
25982
|
-
return code && Object.hasOwn(messages.notes, code) ? messages.notes[code] : void 0;
|
|
25983
|
-
}
|
|
25984
|
-
|
|
25985
|
-
// src/settings/harness-version-panel.ts
|
|
25986
|
-
function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0) {
|
|
26130
|
+
function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0, sharedSession) {
|
|
26131
|
+
const session = sharedSession ?? createHarnessVersionSession(client, { signal });
|
|
26132
|
+
const shouldScheduleCheck = session.prepareMount();
|
|
25987
26133
|
const panel = document2.createElement("section");
|
|
25988
26134
|
panel.className = "settings-harness-version";
|
|
25989
26135
|
panel.dataset.harnessVersion = agent;
|
|
@@ -26007,15 +26153,14 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
26007
26153
|
note.textContent = messages.harnessVersionNote;
|
|
26008
26154
|
actions.append(update);
|
|
26009
26155
|
panel.append(heading, versions, status, actions, note);
|
|
26010
|
-
let state;
|
|
26011
|
-
let busy = false;
|
|
26012
|
-
let updating = false;
|
|
26013
|
-
let unsupported = false;
|
|
26014
|
-
let updatePromise = null;
|
|
26015
26156
|
const render = () => {
|
|
26157
|
+
const state = session.state;
|
|
26158
|
+
const statusKind = session.statusKind;
|
|
26159
|
+
const busy = statusKind === "checking" || statusKind === "updating";
|
|
26016
26160
|
heading.textContent = state?.versionKind === "application" ? messages.harnessVersionApplicationTitle : messages.harnessVersionTitle;
|
|
26017
26161
|
current.textContent = `${messages.harnessVersionCurrent}: ${state?.currentVersion ?? "\u2014"}`;
|
|
26018
26162
|
latest.textContent = `${messages.harnessVersionLatest}: ${harnessVersionLabel(state, messages.harnessVersion)}`;
|
|
26163
|
+
status.textContent = statusKind === "checking" ? messages.harnessVersionChecking : statusKind === "updating" ? messages.harnessVersionUpdating : statusKind === "unsupported" ? messages.harnessVersionUnsupported : statusKind === "failed" ? messages.harnessVersionFailed : statusKind === "updated" ? !state?.canUpdate ? messages.harnessVersionManual : messages.harnessVersionUpdated : state && !state.canUpdate ? messages.harnessVersionManual : "";
|
|
26019
26164
|
update.disabled = busy || signal.aborted || !state?.canUpdate || !state.updateAvailable;
|
|
26020
26165
|
const manualUrl = !state?.canUpdate && state?.updateAvailable ? state.manualUpdateUrl : void 0;
|
|
26021
26166
|
actions.replaceChildren(update);
|
|
@@ -26034,99 +26179,92 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
26034
26179
|
const detail = harnessVersionNote(state, messages.harnessVersion);
|
|
26035
26180
|
note.textContent = detail ? !state?.canUpdate ? detail : `${detail} ${messages.harnessVersionNote}` : messages.harnessVersionNote;
|
|
26036
26181
|
};
|
|
26037
|
-
|
|
26038
|
-
if (
|
|
26039
|
-
|
|
26040
|
-
|
|
26041
|
-
|
|
26042
|
-
onChange();
|
|
26043
|
-
status.textContent = action === "check" ? messages.harnessVersionChecking : messages.harnessVersionUpdating;
|
|
26182
|
+
update.addEventListener("click", () => {
|
|
26183
|
+
if (!signal.aborted) void session.update();
|
|
26184
|
+
});
|
|
26185
|
+
const unsubscribe = session.subscribe((pageChange) => {
|
|
26186
|
+
if (signal.aborted) return;
|
|
26044
26187
|
render();
|
|
26045
|
-
|
|
26046
|
-
|
|
26047
|
-
if (signal.aborted) return false;
|
|
26048
|
-
state = result;
|
|
26049
|
-
status.textContent = !result.canUpdate ? messages.harnessVersionManual : action === "update" ? result.updateAvailable ? messages.harnessVersionFailed : messages.harnessVersionUpdated : "";
|
|
26050
|
-
return result.canUpdate && !result.updateAvailable;
|
|
26051
|
-
} catch (error51) {
|
|
26052
|
-
if (signal.aborted) return false;
|
|
26053
|
-
unsupported = typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
|
|
26054
|
-
status.textContent = unsupported ? messages.harnessVersionUnsupported : messages.harnessVersionFailed;
|
|
26055
|
-
if (state) state = { ...state, canUpdate: false };
|
|
26056
|
-
return false;
|
|
26057
|
-
} finally {
|
|
26058
|
-
busy = false;
|
|
26059
|
-
updating = false;
|
|
26060
|
-
if (!signal.aborted) {
|
|
26061
|
-
render();
|
|
26062
|
-
onChange();
|
|
26063
|
-
}
|
|
26064
|
-
}
|
|
26065
|
-
};
|
|
26066
|
-
const updateVersion = () => {
|
|
26067
|
-
updatePromise ??= run("update").finally(() => {
|
|
26068
|
-
updatePromise = null;
|
|
26069
|
-
});
|
|
26070
|
-
return updatePromise;
|
|
26071
|
-
};
|
|
26072
|
-
update.addEventListener("click", () => void updateVersion());
|
|
26188
|
+
if (pageChange) onChange();
|
|
26189
|
+
});
|
|
26073
26190
|
const owner = document2.defaultView;
|
|
26074
26191
|
let checkFrame = null;
|
|
26075
26192
|
let checkTimer = null;
|
|
26076
26193
|
signal.addEventListener(
|
|
26077
26194
|
"abort",
|
|
26078
26195
|
() => {
|
|
26196
|
+
unsubscribe();
|
|
26079
26197
|
if (checkFrame !== null) owner?.cancelAnimationFrame(checkFrame);
|
|
26080
26198
|
if (checkTimer !== null) owner?.clearTimeout(checkTimer);
|
|
26081
26199
|
render();
|
|
26082
26200
|
},
|
|
26083
26201
|
{ once: true }
|
|
26084
26202
|
);
|
|
26085
|
-
status.textContent = messages.harnessVersionChecking;
|
|
26086
26203
|
render();
|
|
26087
|
-
if (!signal.aborted
|
|
26088
|
-
|
|
26089
|
-
checkFrame =
|
|
26090
|
-
|
|
26091
|
-
|
|
26092
|
-
checkTimer =
|
|
26093
|
-
|
|
26094
|
-
|
|
26095
|
-
|
|
26096
|
-
|
|
26097
|
-
|
|
26204
|
+
if (shouldScheduleCheck && !signal.aborted) {
|
|
26205
|
+
if (owner?.requestAnimationFrame) {
|
|
26206
|
+
checkFrame = owner.requestAnimationFrame(() => {
|
|
26207
|
+
checkFrame = null;
|
|
26208
|
+
if (signal.aborted) return;
|
|
26209
|
+
checkTimer = owner.setTimeout(() => {
|
|
26210
|
+
checkTimer = null;
|
|
26211
|
+
if (!signal.aborted) void session.check();
|
|
26212
|
+
}, 0);
|
|
26213
|
+
});
|
|
26214
|
+
} else {
|
|
26215
|
+
void session.check();
|
|
26216
|
+
}
|
|
26098
26217
|
}
|
|
26099
26218
|
return {
|
|
26100
26219
|
element: panel,
|
|
26101
26220
|
get state() {
|
|
26102
|
-
return state;
|
|
26221
|
+
return session.state;
|
|
26103
26222
|
},
|
|
26104
26223
|
get updating() {
|
|
26105
|
-
return updating;
|
|
26224
|
+
return session.updating;
|
|
26106
26225
|
},
|
|
26107
|
-
update:
|
|
26226
|
+
update: () => signal.aborted ? Promise.resolve(false) : session.update()
|
|
26108
26227
|
};
|
|
26109
26228
|
}
|
|
26110
26229
|
|
|
26111
26230
|
// src/settings/connection-versions.ts
|
|
26231
|
+
var sessionStores = /* @__PURE__ */ new WeakMap();
|
|
26232
|
+
function getSessionStore(diagnostics) {
|
|
26233
|
+
let store = sessionStores.get(diagnostics);
|
|
26234
|
+
if (!store) {
|
|
26235
|
+
store = /* @__PURE__ */ new Map();
|
|
26236
|
+
sessionStores.set(diagnostics, store);
|
|
26237
|
+
}
|
|
26238
|
+
return store;
|
|
26239
|
+
}
|
|
26112
26240
|
function createConnectionVersions(document2, messages, signal, diagnostics, onChange) {
|
|
26113
26241
|
const panels = /* @__PURE__ */ new Map();
|
|
26114
26242
|
const installation = diagnostics?.installation?.bind(diagnostics);
|
|
26243
|
+
const sessions = diagnostics ? getSessionStore(diagnostics) : null;
|
|
26244
|
+
const sessionKey = (hostId2, agent) => JSON.stringify([hostId2, agent]);
|
|
26115
26245
|
return {
|
|
26246
|
+
isUpdating(hostId2, agent) {
|
|
26247
|
+
return Boolean(sessions?.get(sessionKey(hostId2, agent))?.updating);
|
|
26248
|
+
},
|
|
26116
26249
|
get(hostId2, agent) {
|
|
26117
26250
|
if (!installation || signal.aborted) return void 0;
|
|
26118
|
-
const key =
|
|
26251
|
+
const key = sessionKey(hostId2, agent);
|
|
26119
26252
|
let panel = panels.get(key);
|
|
26120
26253
|
if (!panel) {
|
|
26254
|
+
const run = (action) => installation(hostId2, agent, action);
|
|
26255
|
+
let session = sessions?.get(key);
|
|
26256
|
+
if (!session) {
|
|
26257
|
+
session = createHarnessVersionSession({ run });
|
|
26258
|
+
sessions?.set(key, session);
|
|
26259
|
+
}
|
|
26121
26260
|
panel = createHarnessVersionPanel(
|
|
26122
26261
|
document2,
|
|
26123
26262
|
messages,
|
|
26124
26263
|
signal,
|
|
26125
26264
|
agent,
|
|
26126
|
-
{
|
|
26127
|
-
|
|
26128
|
-
|
|
26129
|
-
onChange
|
|
26265
|
+
{ run },
|
|
26266
|
+
onChange,
|
|
26267
|
+
session
|
|
26130
26268
|
);
|
|
26131
26269
|
panels.set(key, panel);
|
|
26132
26270
|
}
|
|
@@ -26135,79 +26273,478 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
|
|
|
26135
26273
|
};
|
|
26136
26274
|
}
|
|
26137
26275
|
|
|
26138
|
-
// src/settings/
|
|
26139
|
-
|
|
26140
|
-
|
|
26141
|
-
|
|
26142
|
-
|
|
26143
|
-
|
|
26144
|
-
|
|
26145
|
-
|
|
26146
|
-
|
|
26147
|
-
|
|
26148
|
-
|
|
26149
|
-
|
|
26150
|
-
|
|
26151
|
-
|
|
26152
|
-
|
|
26153
|
-
|
|
26154
|
-
|
|
26155
|
-
|
|
26156
|
-
|
|
26157
|
-
|
|
26158
|
-
|
|
26159
|
-
|
|
26160
|
-
|
|
26161
|
-
|
|
26276
|
+
// src/settings/preference-ui.ts
|
|
26277
|
+
var nextPreferenceId = 0;
|
|
26278
|
+
function preferenceId(prefix) {
|
|
26279
|
+
nextPreferenceId += 1;
|
|
26280
|
+
return `codexhost-${prefix}-${nextPreferenceId}`;
|
|
26281
|
+
}
|
|
26282
|
+
function createPreferenceGroup(document2, title) {
|
|
26283
|
+
const group = document2.createElement("section");
|
|
26284
|
+
group.className = "mt-7 first-of-type:mt-0";
|
|
26285
|
+
const header = document2.createElement("div");
|
|
26286
|
+
header.className = "mb-2 flex min-h-6 items-center gap-2 px-1";
|
|
26287
|
+
const heading = document2.createElement("h3");
|
|
26288
|
+
heading.id = preferenceId("preference-group");
|
|
26289
|
+
heading.className = "m-0 text-[13px] leading-5 font-semibold text-settings-text";
|
|
26290
|
+
heading.textContent = title;
|
|
26291
|
+
header.append(heading);
|
|
26292
|
+
const card = document2.createElement("div");
|
|
26293
|
+
card.className = "rounded-[10px] border border-settings-border bg-settings-panel";
|
|
26294
|
+
group.setAttribute("aria-labelledby", heading.id);
|
|
26295
|
+
group.append(header, card);
|
|
26296
|
+
return { group, header, card };
|
|
26297
|
+
}
|
|
26298
|
+
function createPreferenceItem(document2, input) {
|
|
26299
|
+
const item = document2.createElement("div");
|
|
26300
|
+
item.className = "flex min-h-[60px] items-center justify-between gap-6 border-t border-settings-divider px-4 py-3 first:border-t-0";
|
|
26301
|
+
const copy = document2.createElement("div");
|
|
26302
|
+
copy.className = "flex min-w-0 flex-col gap-0.5";
|
|
26303
|
+
const heading = document2.createElement("div");
|
|
26304
|
+
heading.className = "flex items-center gap-1.5";
|
|
26305
|
+
const title = document2.createElement("label");
|
|
26306
|
+
title.htmlFor = input.controlId;
|
|
26307
|
+
title.className = "cursor-pointer text-[13px] leading-5 font-medium text-settings-text";
|
|
26308
|
+
title.textContent = input.title;
|
|
26309
|
+
heading.append(title);
|
|
26310
|
+
if (input.help) heading.append(createHelpTooltip(document2, input.help.label, input.help.lines));
|
|
26311
|
+
const description = document2.createElement("div");
|
|
26312
|
+
description.id = preferenceId("preference-description");
|
|
26313
|
+
description.className = "text-xs leading-[18px] text-settings-muted data-[invalid=true]:text-settings-danger";
|
|
26314
|
+
description.textContent = input.description;
|
|
26315
|
+
copy.append(heading, description);
|
|
26316
|
+
item.append(copy);
|
|
26317
|
+
return { item, description };
|
|
26318
|
+
}
|
|
26319
|
+
function createHelpTooltip(document2, label, lines) {
|
|
26320
|
+
const wrapper = document2.createElement("span");
|
|
26321
|
+
wrapper.className = "group relative inline-flex";
|
|
26322
|
+
const button2 = document2.createElement("button");
|
|
26323
|
+
button2.type = "button";
|
|
26324
|
+
button2.className = "inline-flex size-4 cursor-help items-center justify-center rounded-full border-0 bg-transparent p-0 text-settings-subtle transition-colors hover:text-settings-text focus-visible:text-settings-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-settings-focus";
|
|
26325
|
+
button2.setAttribute("aria-label", label);
|
|
26326
|
+
button2.append(createRendererSettingsIcon("help", 14));
|
|
26327
|
+
const tooltip = document2.createElement("div");
|
|
26328
|
+
tooltip.id = preferenceId("preference-tooltip");
|
|
26329
|
+
tooltip.setAttribute("role", "tooltip");
|
|
26330
|
+
tooltip.className = "pointer-events-none invisible absolute top-full left-0 z-20 mt-2 w-80 rounded-lg border border-settings-border bg-settings-panel px-3 py-2.5 text-xs leading-[18px] font-normal text-settings-text opacity-0 shadow-[0_10px_30px_rgb(0_0_0/0.22)] transition-opacity duration-150 group-hover:visible group-hover:opacity-100 group-focus-within:visible group-focus-within:opacity-100";
|
|
26331
|
+
const list = document2.createElement("ul");
|
|
26332
|
+
list.className = "m-0 grid list-disc gap-1 pl-4 marker:text-settings-subtle";
|
|
26333
|
+
for (const line of lines) {
|
|
26334
|
+
const item = document2.createElement("li");
|
|
26335
|
+
item.textContent = line;
|
|
26336
|
+
list.append(item);
|
|
26337
|
+
}
|
|
26338
|
+
tooltip.append(list);
|
|
26339
|
+
button2.setAttribute("aria-describedby", tooltip.id);
|
|
26340
|
+
button2.addEventListener("keydown", (event) => {
|
|
26341
|
+
if (event.key === "Escape") button2.blur();
|
|
26342
|
+
});
|
|
26343
|
+
wrapper.append(button2, tooltip);
|
|
26344
|
+
return wrapper;
|
|
26345
|
+
}
|
|
26346
|
+
function createPreferenceSwitch(document2, id, describedBy) {
|
|
26347
|
+
const input = document2.createElement("input");
|
|
26348
|
+
input.type = "checkbox";
|
|
26349
|
+
input.id = id;
|
|
26350
|
+
input.setAttribute("role", "switch");
|
|
26351
|
+
input.setAttribute("aria-describedby", describedBy);
|
|
26352
|
+
input.className = "relative m-0 h-5 w-9 shrink-0 cursor-pointer appearance-none rounded-full bg-settings-surface-hover ring-1 ring-settings-border transition-colors ring-inset before:absolute before:top-0.5 before:left-0.5 before:size-4 before:rounded-full before:bg-white before:shadow-[0_1px_2px_rgb(0_0_0/0.3)] before:transition-transform checked:bg-settings-focus checked:ring-transparent checked:before:translate-x-4 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-settings-focus";
|
|
26353
|
+
return input;
|
|
26354
|
+
}
|
|
26355
|
+
function createNumberField(document2, input) {
|
|
26356
|
+
const field2 = document2.createElement("div");
|
|
26357
|
+
field2.className = "flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-settings-border bg-settings-surface px-2.5 transition-colors focus-within:border-settings-focus data-[invalid=true]:border-settings-danger";
|
|
26358
|
+
const control = document2.createElement("input");
|
|
26359
|
+
control.type = "number";
|
|
26360
|
+
control.id = input.id;
|
|
26361
|
+
control.min = String(input.min);
|
|
26362
|
+
control.max = String(input.max);
|
|
26363
|
+
control.step = "1";
|
|
26364
|
+
control.setAttribute("aria-describedby", input.describedBy);
|
|
26365
|
+
control.className = "w-14 border-0 bg-transparent p-0 text-right text-[13px] leading-5 text-settings-text tabular-nums outline-none";
|
|
26366
|
+
const unit = document2.createElement("span");
|
|
26367
|
+
unit.className = "text-xs text-settings-muted";
|
|
26368
|
+
unit.setAttribute("aria-hidden", "true");
|
|
26369
|
+
unit.textContent = input.unit;
|
|
26370
|
+
field2.append(control, unit);
|
|
26371
|
+
return { field: field2, control };
|
|
26372
|
+
}
|
|
26373
|
+
|
|
26374
|
+
// src/settings/grok-computer-use-controls.ts
|
|
26375
|
+
function createGrokComputerUseControls(document2, messages, settings) {
|
|
26376
|
+
const section = document2.createElement("section");
|
|
26377
|
+
section.className = "settings-grok-computer-use";
|
|
26378
|
+
section.dataset.grokComputerUse = "true";
|
|
26379
|
+
const header = document2.createElement("div");
|
|
26380
|
+
header.className = "settings-grok-computer-use__header";
|
|
26381
|
+
const copy = document2.createElement("div");
|
|
26382
|
+
copy.className = "settings-grok-computer-use__copy";
|
|
26383
|
+
const title = document2.createElement("h3");
|
|
26384
|
+
title.className = "settings-grok-computer-use__title";
|
|
26385
|
+
title.id = "grok-computer-use-title";
|
|
26386
|
+
title.textContent = messages.grokComputerUseTitle;
|
|
26387
|
+
const description = document2.createElement("p");
|
|
26388
|
+
description.className = "settings-grok-computer-use__description";
|
|
26389
|
+
description.id = "grok-computer-use-description";
|
|
26390
|
+
description.textContent = messages.grokComputerUseDescription;
|
|
26391
|
+
copy.append(title, description);
|
|
26392
|
+
const input = createPreferenceSwitch(
|
|
26393
|
+
document2,
|
|
26394
|
+
"grok-computer-use-enabled",
|
|
26395
|
+
"grok-computer-use-description grok-computer-use-help grok-computer-use-status"
|
|
26396
|
+
);
|
|
26397
|
+
input.setAttribute("aria-labelledby", title.id);
|
|
26398
|
+
input.setAttribute("aria-label", messages.grokComputerUseLabel);
|
|
26399
|
+
header.append(copy, input);
|
|
26400
|
+
const help = document2.createElement("p");
|
|
26401
|
+
help.className = "settings-grok-computer-use__help";
|
|
26402
|
+
help.id = "grok-computer-use-help";
|
|
26403
|
+
help.textContent = messages.grokComputerUseHelp;
|
|
26404
|
+
const status = document2.createElement("p");
|
|
26405
|
+
status.className = "settings-grok-computer-use__status";
|
|
26406
|
+
status.id = "grok-computer-use-status";
|
|
26407
|
+
status.setAttribute("role", "status");
|
|
26408
|
+
status.setAttribute("aria-live", "polite");
|
|
26409
|
+
const browserHeader = document2.createElement("div");
|
|
26410
|
+
browserHeader.className = "settings-grok-computer-use__header settings-grok-computer-use__browser";
|
|
26411
|
+
const browserCopy = document2.createElement("div");
|
|
26412
|
+
browserCopy.className = "settings-grok-computer-use__copy";
|
|
26413
|
+
const browserTitle = document2.createElement("h3");
|
|
26414
|
+
browserTitle.className = "settings-grok-computer-use__title";
|
|
26415
|
+
browserTitle.id = "grok-browser-title";
|
|
26416
|
+
browserTitle.textContent = messages.grokBrowserTitle;
|
|
26417
|
+
const browserDescription = document2.createElement("p");
|
|
26418
|
+
browserDescription.className = "settings-grok-computer-use__description";
|
|
26419
|
+
browserDescription.id = "grok-browser-description";
|
|
26420
|
+
browserDescription.textContent = messages.grokBrowserDescription;
|
|
26421
|
+
browserCopy.append(browserTitle, browserDescription);
|
|
26422
|
+
const browserInput = createPreferenceSwitch(
|
|
26423
|
+
document2,
|
|
26424
|
+
"grok-browser-enabled",
|
|
26425
|
+
"grok-browser-description grok-browser-help grok-browser-status"
|
|
26426
|
+
);
|
|
26427
|
+
browserInput.setAttribute("aria-labelledby", browserTitle.id);
|
|
26428
|
+
browserInput.setAttribute("aria-label", messages.grokBrowserLabel);
|
|
26429
|
+
browserHeader.append(browserCopy, browserInput);
|
|
26430
|
+
const browserHelp = document2.createElement("p");
|
|
26431
|
+
browserHelp.className = "settings-grok-computer-use__help";
|
|
26432
|
+
browserHelp.id = "grok-browser-help";
|
|
26433
|
+
browserHelp.textContent = messages.grokBrowserHelp;
|
|
26434
|
+
const browserStatus = document2.createElement("p");
|
|
26435
|
+
browserStatus.className = "settings-grok-computer-use__status";
|
|
26436
|
+
browserStatus.id = "grok-browser-status";
|
|
26437
|
+
browserStatus.setAttribute("role", "status");
|
|
26438
|
+
browserStatus.setAttribute("aria-live", "polite");
|
|
26439
|
+
section.append(header, help, status, browserHeader, browserHelp, browserStatus);
|
|
26440
|
+
let busy = true;
|
|
26441
|
+
let loaded = false;
|
|
26442
|
+
let last;
|
|
26443
|
+
const show = (value) => {
|
|
26444
|
+
last = value;
|
|
26445
|
+
input.checked = value.enabled;
|
|
26446
|
+
input.disabled = busy || !loaded || !value.available && !value.enabled;
|
|
26447
|
+
const browserOn = value.browser === true;
|
|
26448
|
+
const browserFiles = value.browserFilesPresent === true;
|
|
26449
|
+
browserInput.checked = browserOn;
|
|
26450
|
+
browserInput.disabled = busy || !loaded || !browserFiles && !browserOn;
|
|
26451
|
+
if (!browserFiles) {
|
|
26452
|
+
browserStatus.dataset.state = "unavailable";
|
|
26453
|
+
browserStatus.textContent = value.browserUnavailableReason ?? messages.grokBrowserUnavailable;
|
|
26454
|
+
} else if (value.browserAvailable !== true) {
|
|
26455
|
+
browserStatus.dataset.state = browserOn ? "unavailable" : "off";
|
|
26456
|
+
browserStatus.textContent = browserOn ? value.browserUnavailableReason ?? messages.grokBrowserBlocked : messages.grokBrowserOff;
|
|
26457
|
+
} else {
|
|
26458
|
+
browserStatus.dataset.state = browserOn ? "on" : "off";
|
|
26459
|
+
browserStatus.textContent = browserOn ? messages.grokBrowserOn : messages.grokBrowserOff;
|
|
26460
|
+
}
|
|
26461
|
+
if (value.applyFailed) {
|
|
26462
|
+
status.dataset.state = "unavailable";
|
|
26463
|
+
status.textContent = value.applyError ?? messages.grokComputerUseApplyFailed;
|
|
26464
|
+
return;
|
|
26465
|
+
}
|
|
26466
|
+
if (!value.available) {
|
|
26467
|
+
status.dataset.state = "unavailable";
|
|
26468
|
+
status.textContent = value.unavailableReason ?? messages.grokComputerUseUnavailable;
|
|
26469
|
+
return;
|
|
26470
|
+
}
|
|
26471
|
+
status.dataset.state = value.enabled ? "on" : "off";
|
|
26472
|
+
status.textContent = value.enabled ? messages.grokComputerUseOn : messages.grokComputerUseOff;
|
|
26473
|
+
};
|
|
26474
|
+
const save = (update, target2) => {
|
|
26475
|
+
if (busy || !loaded) return;
|
|
26476
|
+
busy = true;
|
|
26477
|
+
input.disabled = true;
|
|
26478
|
+
browserInput.disabled = true;
|
|
26479
|
+
target2.textContent = messages.grokComputerUseSaving;
|
|
26480
|
+
void settings.set(update).then((value) => {
|
|
26481
|
+
busy = false;
|
|
26482
|
+
show(value);
|
|
26483
|
+
}).catch(() => {
|
|
26484
|
+
busy = false;
|
|
26485
|
+
if (last) show(last);
|
|
26486
|
+
else {
|
|
26487
|
+
input.disabled = false;
|
|
26488
|
+
browserInput.disabled = false;
|
|
26489
|
+
}
|
|
26490
|
+
target2.textContent = messages.grokComputerUseSaveError;
|
|
26491
|
+
});
|
|
26492
|
+
};
|
|
26493
|
+
input.addEventListener("change", () => save({ enabled: input.checked }, status));
|
|
26494
|
+
browserInput.addEventListener(
|
|
26495
|
+
"change",
|
|
26496
|
+
() => save({ browser: browserInput.checked }, browserStatus)
|
|
26497
|
+
);
|
|
26498
|
+
status.textContent = messages.grokComputerUseLoading;
|
|
26499
|
+
browserStatus.textContent = messages.grokBrowserOff;
|
|
26500
|
+
void settings.get().then((value) => {
|
|
26501
|
+
loaded = true;
|
|
26502
|
+
busy = false;
|
|
26503
|
+
show(value);
|
|
26504
|
+
}).catch(() => {
|
|
26505
|
+
busy = false;
|
|
26506
|
+
status.textContent = messages.grokComputerUseLoadError;
|
|
26507
|
+
browserStatus.textContent = messages.grokComputerUseLoadError;
|
|
26508
|
+
});
|
|
26509
|
+
return section;
|
|
26510
|
+
}
|
|
26511
|
+
|
|
26512
|
+
// src/settings/harness-install-store.ts
|
|
26513
|
+
function errorMessage(error51) {
|
|
26514
|
+
return typeof error51 === "object" && error51 !== null && "message" in error51 && typeof error51.message === "string" ? error51.message.slice(0, 2048) : "Could not install the Harness. Check the official installation guide and retry.";
|
|
26515
|
+
}
|
|
26516
|
+
function unknownInstallOutcome(message2) {
|
|
26517
|
+
return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
|
|
26518
|
+
}
|
|
26519
|
+
var stores = /* @__PURE__ */ new WeakMap();
|
|
26520
|
+
function createStore(diagnostics) {
|
|
26521
|
+
const states2 = /* @__PURE__ */ new Map();
|
|
26522
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
26523
|
+
const key = (host, agent) => JSON.stringify([host, agent]);
|
|
26524
|
+
const notify2 = () => listeners.forEach((listener) => listener());
|
|
26525
|
+
return {
|
|
26526
|
+
get: (host, agent) => states2.get(key(host, agent)),
|
|
26527
|
+
clearErrors() {
|
|
26528
|
+
for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
|
|
26529
|
+
notify2();
|
|
26530
|
+
},
|
|
26531
|
+
subscribe(listener) {
|
|
26532
|
+
listeners.add(listener);
|
|
26533
|
+
return () => {
|
|
26534
|
+
listeners.delete(listener);
|
|
26535
|
+
};
|
|
26536
|
+
},
|
|
26537
|
+
async install(host, agent) {
|
|
26538
|
+
const id = key(host, agent);
|
|
26539
|
+
const previous = states2.get(id);
|
|
26540
|
+
if (!diagnostics.installation || previous && previous.status !== "error") return;
|
|
26541
|
+
states2.set(id, { status: "installing" });
|
|
26542
|
+
notify2();
|
|
26543
|
+
let failure;
|
|
26544
|
+
try {
|
|
26545
|
+
await diagnostics.installation(host, agent, "install");
|
|
26546
|
+
states2.set(id, { status: "checking" });
|
|
26547
|
+
notify2();
|
|
26548
|
+
} catch (error51) {
|
|
26549
|
+
failure = errorMessage(error51);
|
|
26550
|
+
}
|
|
26551
|
+
try {
|
|
26552
|
+
await diagnostics.refresh(host);
|
|
26553
|
+
const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
|
|
26554
|
+
if (refreshed?.availability === "ready") failure = void 0;
|
|
26555
|
+
else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
|
|
26556
|
+
failure = void 0;
|
|
26557
|
+
}
|
|
26558
|
+
} catch (error51) {
|
|
26559
|
+
failure ??= errorMessage(error51);
|
|
26560
|
+
}
|
|
26561
|
+
if (failure) states2.set(id, { status: "error", error: failure });
|
|
26562
|
+
else states2.delete(id);
|
|
26563
|
+
notify2();
|
|
26564
|
+
}
|
|
26565
|
+
};
|
|
26566
|
+
}
|
|
26567
|
+
function harnessInstallStore(diagnostics) {
|
|
26568
|
+
let store = stores.get(diagnostics);
|
|
26569
|
+
if (!store) {
|
|
26570
|
+
store = createStore(diagnostics);
|
|
26571
|
+
stores.set(diagnostics, store);
|
|
26572
|
+
}
|
|
26573
|
+
return store;
|
|
26574
|
+
}
|
|
26575
|
+
|
|
26576
|
+
// src/settings/harness-installation-guides.ts
|
|
26577
|
+
function harnessHasInstallCommands(plugin) {
|
|
26578
|
+
return (plugin?.installation?.commands.length ?? 0) > 0;
|
|
26579
|
+
}
|
|
26580
|
+
function harnessInstallationGuide(plugin, locale) {
|
|
26581
|
+
const guide = plugin?.installation;
|
|
26582
|
+
const text = (value) => value?.[locale] ?? value?.en;
|
|
26583
|
+
return {
|
|
26584
|
+
url: plugin?.links?.installation ?? plugin?.links?.documentation ?? plugin?.links?.website,
|
|
26585
|
+
commands: guide?.commands ?? [],
|
|
26586
|
+
downloads: guide?.downloads ?? [],
|
|
26587
|
+
before: text(guide?.before),
|
|
26588
|
+
after: text(guide?.after)
|
|
26589
|
+
};
|
|
26590
|
+
}
|
|
26591
|
+
|
|
26592
|
+
// src/settings/harness-installation-panel.ts
|
|
26593
|
+
function createHarnessInstallationPanel(document2, plugin, hostId2, messages, copy, installation) {
|
|
26594
|
+
const zh = messages.locale === "zh-CN";
|
|
26595
|
+
const guide = harnessInstallationGuide(plugin, messages.locale);
|
|
26596
|
+
const panel = document2.createElement("div");
|
|
26597
|
+
panel.className = "settings-harness-installation";
|
|
26598
|
+
const paragraph = (text) => {
|
|
26599
|
+
const p = document2.createElement("p");
|
|
26600
|
+
p.textContent = text;
|
|
26601
|
+
panel.append(p);
|
|
26602
|
+
};
|
|
26603
|
+
if (hostId2 !== "local") {
|
|
26604
|
+
paragraph(zh ? "\u8BF7\u5728\u8FDC\u7A0B Host \u4E0A\u5B89\u88C5\u3002" : "Install on the remote Host.");
|
|
26605
|
+
}
|
|
26606
|
+
if (guide.before) paragraph(guide.before);
|
|
26607
|
+
const install = installation && guide.commands.length > 0 ? document2.createElement("button") : null;
|
|
26608
|
+
if (install && installation) {
|
|
26609
|
+
install.type = "button";
|
|
26610
|
+
install.className = "settings-command-button";
|
|
26611
|
+
install.dataset.connectionAction = "install";
|
|
26612
|
+
install.disabled = installation.status !== "idle";
|
|
26613
|
+
install.textContent = installation.status === "installing" ? messages.connectionStatusInstalling : installation.status === "checking" ? messages.connectionStatusChecking : zh ? "\u4E00\u952E\u5B89\u88C5" : "Install automatically";
|
|
26614
|
+
install.addEventListener("click", () => {
|
|
26615
|
+
if (install.disabled) return;
|
|
26616
|
+
install.disabled = true;
|
|
26617
|
+
install.textContent = messages.connectionStatusInstalling;
|
|
26618
|
+
installation.run();
|
|
26619
|
+
});
|
|
26620
|
+
if (guide.commands.length > 1) panel.append(install);
|
|
26621
|
+
}
|
|
26622
|
+
for (const { terminal, command } of guide.commands) {
|
|
26623
|
+
const block = document2.createElement("div");
|
|
26624
|
+
block.className = "settings-harness-installation-command";
|
|
26625
|
+
const label = document2.createElement("strong");
|
|
26626
|
+
label.textContent = terminal;
|
|
26627
|
+
const pre = document2.createElement("pre");
|
|
26628
|
+
const code = document2.createElement("code");
|
|
26629
|
+
code.textContent = command;
|
|
26630
|
+
pre.append(code);
|
|
26631
|
+
const button2 = document2.createElement("button");
|
|
26632
|
+
button2.type = "button";
|
|
26633
|
+
button2.className = "settings-command-button settings-command-button--secondary";
|
|
26634
|
+
button2.dataset.connectionAction = "copy-install";
|
|
26635
|
+
const copyLabel = zh ? "\u590D\u5236\u547D\u4EE4" : "Copy command";
|
|
26636
|
+
button2.setAttribute("aria-label", `${copyLabel}: ${terminal}`);
|
|
26637
|
+
button2.append(createRendererSettingsIcon("copy", 16), copyLabel);
|
|
26638
|
+
button2.addEventListener("click", () => copy(button2, command, copyLabel));
|
|
26639
|
+
const actions = document2.createElement("div");
|
|
26640
|
+
actions.className = "settings-harness-installation-actions";
|
|
26641
|
+
if (install && guide.commands.length === 1) actions.append(install);
|
|
26642
|
+
actions.append(button2);
|
|
26643
|
+
block.append(label, pre, actions);
|
|
26644
|
+
panel.append(block);
|
|
26645
|
+
}
|
|
26646
|
+
for (const download2 of guide.downloads ?? []) {
|
|
26647
|
+
const link = document2.createElement("a");
|
|
26648
|
+
link.className = "settings-command-button settings-command-button--secondary";
|
|
26649
|
+
link.href = download2.url;
|
|
26650
|
+
link.target = "_blank";
|
|
26651
|
+
link.rel = "noopener noreferrer";
|
|
26652
|
+
link.textContent = zh ? "\u4E0B\u8F7D" : "Download";
|
|
26653
|
+
link.setAttribute("aria-label", `${link.textContent} ${download2.label}`);
|
|
26654
|
+
panel.append(link);
|
|
26655
|
+
}
|
|
26656
|
+
if (guide.after) paragraph(guide.after);
|
|
26657
|
+
if (!plugin?.installation && guide.url) {
|
|
26658
|
+
const link = document2.createElement("a");
|
|
26659
|
+
link.href = guide.url;
|
|
26660
|
+
link.target = "_blank";
|
|
26661
|
+
link.rel = "noopener noreferrer";
|
|
26662
|
+
link.textContent = zh ? "\u5B89\u88C5\u8BF4\u660E" : "Installation instructions";
|
|
26663
|
+
panel.append(link);
|
|
26664
|
+
}
|
|
26665
|
+
return panel;
|
|
26666
|
+
}
|
|
26667
|
+
|
|
26668
|
+
// src/settings/harness-launch-controls.ts
|
|
26669
|
+
function createHarnessLaunchControls(document2, messages, agent, settings) {
|
|
26670
|
+
const section = document2.createElement("section");
|
|
26671
|
+
section.className = "settings-harness-launch";
|
|
26672
|
+
section.dataset.harnessLaunch = agent;
|
|
26673
|
+
const label = document2.createElement("label");
|
|
26674
|
+
label.textContent = messages.launchPathLabel;
|
|
26675
|
+
const input = document2.createElement("input");
|
|
26676
|
+
input.type = "text";
|
|
26677
|
+
input.autocomplete = "off";
|
|
26678
|
+
input.spellcheck = false;
|
|
26679
|
+
input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
|
|
26680
|
+
input.setAttribute("aria-label", messages.launchPathLabel);
|
|
26681
|
+
label.append(input);
|
|
26682
|
+
const help = document2.createElement("p");
|
|
26683
|
+
help.textContent = messages.locale === "zh-CN" ? "\u586B\u5199\u63D2\u4EF6\u5BF9\u5E94\u5E94\u7528\u7684\u5B89\u88C5\u76EE\u5F55\uFF1B\u6E05\u9664\u540E\u6062\u590D\u81EA\u52A8\u53D1\u73B0\u3002\u4FEE\u6539\u540E\u9700\u91CD\u542F codexhost\u3002" : "Choose the application's installation directory; clear it to restore automatic discovery. Restart codexhost after changing it.";
|
|
26684
|
+
const actions = document2.createElement("div");
|
|
26685
|
+
actions.className = "settings-harness-launch__actions";
|
|
26686
|
+
const save = document2.createElement("button");
|
|
26687
|
+
save.type = "button";
|
|
26688
|
+
save.className = "settings-command-button";
|
|
26689
|
+
save.textContent = messages.launchPathSave;
|
|
26690
|
+
const reset = document2.createElement("button");
|
|
26691
|
+
reset.type = "button";
|
|
26692
|
+
reset.className = "settings-command-button settings-command-button--secondary";
|
|
26693
|
+
reset.textContent = messages.launchPathReset;
|
|
26694
|
+
const status = document2.createElement("p");
|
|
26695
|
+
status.setAttribute("role", "status");
|
|
26696
|
+
status.setAttribute("aria-live", "polite");
|
|
26697
|
+
actions.append(save, reset);
|
|
26698
|
+
section.append(label, help, actions, status);
|
|
26699
|
+
let busy = true;
|
|
26700
|
+
let loaded = false;
|
|
26701
|
+
const controls = () => {
|
|
26702
|
+
input.disabled = busy || !loaded;
|
|
26703
|
+
save.disabled = busy || !loaded || !input.value.trim();
|
|
26704
|
+
reset.disabled = busy || !loaded;
|
|
26705
|
+
};
|
|
26706
|
+
const show = (value) => {
|
|
26707
|
+
input.value = value.path ?? "";
|
|
26708
|
+
status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
|
|
26162
26709
|
};
|
|
26163
|
-
|
|
26164
|
-
|
|
26165
|
-
|
|
26166
|
-
|
|
26167
|
-
|
|
26168
|
-
|
|
26169
|
-
|
|
26170
|
-
|
|
26171
|
-
|
|
26172
|
-
|
|
26173
|
-
|
|
26174
|
-
|
|
26175
|
-
button2.addEventListener("click", () => {
|
|
26176
|
-
if (!button2.disabled) void start(hostId2, panels);
|
|
26177
|
-
});
|
|
26178
|
-
const result = document2.createElement("p");
|
|
26179
|
-
result.className = "settings-connection-update-result";
|
|
26180
|
-
result.setAttribute("role", "status");
|
|
26181
|
-
result.hidden = !batch || batch.running;
|
|
26182
|
-
if (batch && !batch.running) {
|
|
26183
|
-
result.textContent = messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed));
|
|
26184
|
-
}
|
|
26185
|
-
return { button: button2, result };
|
|
26710
|
+
const persist = async (value) => {
|
|
26711
|
+
if (busy || !loaded) return;
|
|
26712
|
+
busy = true;
|
|
26713
|
+
controls();
|
|
26714
|
+
status.textContent = messages.launchPathSaving;
|
|
26715
|
+
try {
|
|
26716
|
+
show(await settings.set(value));
|
|
26717
|
+
} catch {
|
|
26718
|
+
status.textContent = messages.launchPathSaveError;
|
|
26719
|
+
} finally {
|
|
26720
|
+
busy = false;
|
|
26721
|
+
controls();
|
|
26186
26722
|
}
|
|
26187
26723
|
};
|
|
26724
|
+
input.addEventListener("input", controls);
|
|
26725
|
+
save.addEventListener("click", () => {
|
|
26726
|
+
if (input.value.trim()) void persist(input.value.trim());
|
|
26727
|
+
});
|
|
26728
|
+
reset.addEventListener("click", () => {
|
|
26729
|
+
void persist(null);
|
|
26730
|
+
});
|
|
26731
|
+
controls();
|
|
26732
|
+
status.textContent = messages.launchPathLoading;
|
|
26733
|
+
void settings.get().then((value) => {
|
|
26734
|
+
loaded = true;
|
|
26735
|
+
show(value);
|
|
26736
|
+
}).catch(() => {
|
|
26737
|
+
loaded = true;
|
|
26738
|
+
status.textContent = messages.launchPathLoadError;
|
|
26739
|
+
}).finally(() => {
|
|
26740
|
+
busy = false;
|
|
26741
|
+
controls();
|
|
26742
|
+
});
|
|
26743
|
+
return section;
|
|
26188
26744
|
}
|
|
26189
26745
|
|
|
26190
26746
|
// src/settings/connections-page.ts
|
|
26191
26747
|
var CODEXHOST_GITHUB_ISSUES_NEW_URL = "https://github.com/karlorz/codex-host/issues/new";
|
|
26192
|
-
function connectionStatusLabel(availability2, messages, hasError = false) {
|
|
26193
|
-
if (availability2 === "updating") return messages.connectionStatusUpdating;
|
|
26194
|
-
if (hasError && availability2 !== "notInstalled") return messages.connectionStatusError;
|
|
26195
|
-
if (availability2 === "ready") return messages.connectionStatusReady;
|
|
26196
|
-
if (availability2 === "checking") return messages.connectionStatusChecking;
|
|
26197
|
-
if (availability2 === "notInstalled") return messages.connectionStatusNotInstalled;
|
|
26198
|
-
if (availability2 === "unavailable" || availability2 === "error") {
|
|
26199
|
-
return availability2 === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
|
|
26200
|
-
}
|
|
26201
|
-
return availability2 === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
|
|
26202
|
-
}
|
|
26203
|
-
function connectionStatusTone(availability2, hasError = false) {
|
|
26204
|
-
if (availability2 === "updating") return "checking";
|
|
26205
|
-
if (hasError && availability2 !== "notInstalled") return "failed";
|
|
26206
|
-
if (availability2 === "ready") return "ready";
|
|
26207
|
-
if (availability2 === "checking" || availability2 === "installing") return "checking";
|
|
26208
|
-
if (availability2 === "notInstalled") return "setup";
|
|
26209
|
-
return "failed";
|
|
26210
|
-
}
|
|
26211
26748
|
function diagnosticText(hostId2, item) {
|
|
26212
26749
|
const error51 = item.error;
|
|
26213
26750
|
return [
|
|
@@ -26303,148 +26840,21 @@ ${error51.stderrTail}`] : []
|
|
|
26303
26840
|
tabs.addEventListener("wheel", onWheel, { passive: false });
|
|
26304
26841
|
const ownerWindow = document2.defaultView;
|
|
26305
26842
|
ownerWindow?.addEventListener("resize", updateButtons);
|
|
26306
|
-
|
|
26307
|
-
|
|
26308
|
-
|
|
26309
|
-
|
|
26310
|
-
|
|
26311
|
-
|
|
26312
|
-
|
|
26313
|
-
|
|
26843
|
+
const refreshLayout = () => {
|
|
26844
|
+
ownerWindow?.setTimeout(updateButtons, 0);
|
|
26845
|
+
updateButtons();
|
|
26846
|
+
};
|
|
26847
|
+
refreshLayout();
|
|
26848
|
+
return {
|
|
26849
|
+
update: refreshLayout,
|
|
26850
|
+
dispose() {
|
|
26851
|
+
left.removeEventListener("click", onLeft);
|
|
26852
|
+
right.removeEventListener("click", onRight);
|
|
26853
|
+
tabs.removeEventListener("scroll", updateButtons);
|
|
26854
|
+
tabs.removeEventListener("wheel", onWheel);
|
|
26855
|
+
ownerWindow?.removeEventListener("resize", updateButtons);
|
|
26856
|
+
}
|
|
26314
26857
|
};
|
|
26315
|
-
}
|
|
26316
|
-
function createConnectionIdentityIcon(document2, item, size) {
|
|
26317
|
-
const container = document2.createElement("span");
|
|
26318
|
-
container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
|
|
26319
|
-
container.setAttribute("aria-hidden", "true");
|
|
26320
|
-
if (item.agentSnapshot) {
|
|
26321
|
-
container.append(
|
|
26322
|
-
createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
|
|
26323
|
-
);
|
|
26324
|
-
} else {
|
|
26325
|
-
container.textContent = "CH";
|
|
26326
|
-
}
|
|
26327
|
-
return container;
|
|
26328
|
-
}
|
|
26329
|
-
function createConnectionRow(document2, item, messages, selected, select, group = null) {
|
|
26330
|
-
const row = document2.createElement("div");
|
|
26331
|
-
row.className = "settings-connection-row";
|
|
26332
|
-
row.dataset.connectionItem = item.key;
|
|
26333
|
-
row.dataset.connectionSelected = String(selected);
|
|
26334
|
-
row.tabIndex = selected ? 0 : -1;
|
|
26335
|
-
row.setAttribute("role", "row");
|
|
26336
|
-
const identity3 = document2.createElement("div");
|
|
26337
|
-
identity3.className = "settings-connection-row__identity";
|
|
26338
|
-
identity3.setAttribute("role", "cell");
|
|
26339
|
-
if (group) {
|
|
26340
|
-
const handle = document2.createElement("span");
|
|
26341
|
-
handle.className = "settings-connection-row__handle";
|
|
26342
|
-
handle.setAttribute("aria-hidden", "true");
|
|
26343
|
-
handle.title = group.dragHandleTitle;
|
|
26344
|
-
handle.append(createRendererSettingsIcon("grip-vertical", 15));
|
|
26345
|
-
identity3.append(handle);
|
|
26346
|
-
}
|
|
26347
|
-
const label = document2.createElement("strong");
|
|
26348
|
-
label.textContent = item.name;
|
|
26349
|
-
identity3.append(createConnectionIdentityIcon(document2, item, 19), label);
|
|
26350
|
-
const status = document2.createElement("span");
|
|
26351
|
-
status.className = "settings-connection-row__status";
|
|
26352
|
-
status.dataset.connectionTone = connectionStatusTone(item.availability, item.error !== null);
|
|
26353
|
-
status.setAttribute("role", "cell");
|
|
26354
|
-
status.textContent = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
|
|
26355
|
-
const version2 = item.version;
|
|
26356
|
-
const action = document2.createElement("div");
|
|
26357
|
-
action.className = "settings-connection-row__action";
|
|
26358
|
-
action.setAttribute("role", "cell");
|
|
26359
|
-
if (item.agentSnapshot?.availability === "notInstalled" && item.install) {
|
|
26360
|
-
const install = document2.createElement("button");
|
|
26361
|
-
install.type = "button";
|
|
26362
|
-
install.className = "settings-connection-install-link";
|
|
26363
|
-
install.addEventListener("click", (event) => {
|
|
26364
|
-
event.stopPropagation();
|
|
26365
|
-
select();
|
|
26366
|
-
item.install?.();
|
|
26367
|
-
});
|
|
26368
|
-
install.disabled = item.availability === "installing" || item.availability === "checking";
|
|
26369
|
-
const installLabel = messages.connectionInstall;
|
|
26370
|
-
install.setAttribute("aria-label", `${installLabel}: ${item.name}`);
|
|
26371
|
-
install.title = installLabel;
|
|
26372
|
-
install.append(createRendererSettingsIcon("download", 17));
|
|
26373
|
-
action.append(install);
|
|
26374
|
-
} else if (item.error) {
|
|
26375
|
-
const viewError = document2.createElement("button");
|
|
26376
|
-
viewError.type = "button";
|
|
26377
|
-
viewError.className = "settings-connection-view-error";
|
|
26378
|
-
viewError.textContent = messages.connectionViewError;
|
|
26379
|
-
viewError.addEventListener("click", (event) => {
|
|
26380
|
-
event.stopPropagation();
|
|
26381
|
-
select();
|
|
26382
|
-
});
|
|
26383
|
-
action.append(viewError);
|
|
26384
|
-
}
|
|
26385
|
-
if (version2?.state?.updateAvailable && !version2.updating) {
|
|
26386
|
-
const available = document2.createElement("span");
|
|
26387
|
-
available.className = "settings-connection-version-available";
|
|
26388
|
-
available.textContent = messages.harnessVersionAvailable;
|
|
26389
|
-
available.title = `${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
|
|
26390
|
-
${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
|
|
26391
|
-
action.append(available);
|
|
26392
|
-
}
|
|
26393
|
-
if (version2?.state?.updateAvailable && version2.state.canUpdate) {
|
|
26394
|
-
const update = document2.createElement("button");
|
|
26395
|
-
update.type = "button";
|
|
26396
|
-
update.className = "settings-connection-install-link";
|
|
26397
|
-
update.dataset.connectionAction = "update";
|
|
26398
|
-
update.disabled = version2.updating;
|
|
26399
|
-
update.title = messages.harnessVersionUpdate;
|
|
26400
|
-
update.setAttribute("aria-label", `${messages.harnessVersionUpdate}: ${item.name}`);
|
|
26401
|
-
update.append(createRendererSettingsIcon("download", 17));
|
|
26402
|
-
update.addEventListener("click", (event) => {
|
|
26403
|
-
event.stopPropagation();
|
|
26404
|
-
if (update.disabled) return;
|
|
26405
|
-
void version2.update();
|
|
26406
|
-
select();
|
|
26407
|
-
});
|
|
26408
|
-
action.append(update);
|
|
26409
|
-
}
|
|
26410
|
-
if (group) {
|
|
26411
|
-
const toggle = document2.createElement("button");
|
|
26412
|
-
toggle.type = "button";
|
|
26413
|
-
toggle.disabled = group.disabled;
|
|
26414
|
-
toggle.className = "settings-connection-row__group-toggle";
|
|
26415
|
-
toggle.title = group.moveLabel;
|
|
26416
|
-
toggle.setAttribute("aria-label", group.moveLabel);
|
|
26417
|
-
toggle.append(
|
|
26418
|
-
createRendererSettingsIcon(group.section === "main" ? "chevron-down" : "chevron-up", 15)
|
|
26419
|
-
);
|
|
26420
|
-
toggle.addEventListener("click", (event) => {
|
|
26421
|
-
event.stopPropagation();
|
|
26422
|
-
group.toggleSection();
|
|
26423
|
-
});
|
|
26424
|
-
action.append(toggle);
|
|
26425
|
-
}
|
|
26426
|
-
row.addEventListener("click", (event) => {
|
|
26427
|
-
const target2 = event.target;
|
|
26428
|
-
if (target2?.closest?.("a")) return;
|
|
26429
|
-
select();
|
|
26430
|
-
});
|
|
26431
|
-
row.addEventListener("keydown", (event) => {
|
|
26432
|
-
if (event.target?.closest?.("button, a")) return;
|
|
26433
|
-
if (event.key !== "Enter" && event.key !== " ") return;
|
|
26434
|
-
event.preventDefault();
|
|
26435
|
-
select();
|
|
26436
|
-
});
|
|
26437
|
-
if (group) {
|
|
26438
|
-
row.draggable = !group.disabled;
|
|
26439
|
-
row.dataset.connectionGroupSection = group.section;
|
|
26440
|
-
row.addEventListener("dragstart", group.onDragStart);
|
|
26441
|
-
row.addEventListener("dragover", group.onDragOver);
|
|
26442
|
-
row.addEventListener("dragleave", group.onDragLeave);
|
|
26443
|
-
row.addEventListener("drop", group.onDrop);
|
|
26444
|
-
row.addEventListener("dragend", group.onDragEnd);
|
|
26445
|
-
}
|
|
26446
|
-
row.append(identity3, status, action);
|
|
26447
|
-
return row;
|
|
26448
26858
|
}
|
|
26449
26859
|
function createInspectorHeader(document2, item, messages) {
|
|
26450
26860
|
const header = document2.createElement("header");
|
|
@@ -26474,6 +26884,29 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
26474
26884
|
header.append(identity3, status);
|
|
26475
26885
|
return header;
|
|
26476
26886
|
}
|
|
26887
|
+
function inspectorRenderSignature(hostId2, item, messages, diagnostics) {
|
|
26888
|
+
const plugin = item.agentSnapshot?.plugin;
|
|
26889
|
+
const notice = plugin?.notice ? plugin.notice[messages.locale] ?? plugin.notice.en : "";
|
|
26890
|
+
const websiteUrl = plugin?.links?.website ?? plugin?.links?.documentation ?? "";
|
|
26891
|
+
const hasLaunchControls = hostId2 === "local" && Boolean(item.agentSnapshot?.agent) && Boolean(plugin?.launchCommand) && Boolean(diagnostics?.getLaunchSettings && diagnostics?.setLaunchSettings);
|
|
26892
|
+
return JSON.stringify([
|
|
26893
|
+
hostId2,
|
|
26894
|
+
item.key,
|
|
26895
|
+
item.name,
|
|
26896
|
+
item.availability,
|
|
26897
|
+
item.agentSnapshot?.availability ?? null,
|
|
26898
|
+
String(plugin?.icon ?? ""),
|
|
26899
|
+
String(plugin?.iconStyle ?? ""),
|
|
26900
|
+
websiteUrl,
|
|
26901
|
+
notice,
|
|
26902
|
+
item.installError ?? "",
|
|
26903
|
+
Boolean(item.install),
|
|
26904
|
+
plugin?.installation ?? null,
|
|
26905
|
+
Boolean(item.openWebUi),
|
|
26906
|
+
hasLaunchControls,
|
|
26907
|
+
item.error ? diagnosticText(hostId2, item) : ""
|
|
26908
|
+
]);
|
|
26909
|
+
}
|
|
26477
26910
|
function renderConnectionInspector(document2, inspector, item, hostId2, messages, diagnostics, existingLaunchControls, refresh) {
|
|
26478
26911
|
inspector.replaceChildren(createInspectorHeader(document2, item, messages));
|
|
26479
26912
|
const body = document2.createElement("div");
|
|
@@ -26649,11 +27082,10 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
26649
27082
|
function requestConnectionsPageFocus(agentKey) {
|
|
26650
27083
|
pendingFocusAgent = agentKey;
|
|
26651
27084
|
}
|
|
26652
|
-
function createGroupDivider(document2
|
|
27085
|
+
function createGroupDivider(document2) {
|
|
26653
27086
|
const divider = document2.createElement("div");
|
|
26654
27087
|
divider.className = "settings-connection-group-divider";
|
|
26655
27088
|
divider.setAttribute("role", "presentation");
|
|
26656
|
-
divider.textContent = `${messages.connectionGroupMoreLabel} (${count4})`;
|
|
26657
27089
|
return divider;
|
|
26658
27090
|
}
|
|
26659
27091
|
function createGroupMoreHint(document2, messages) {
|
|
@@ -26706,11 +27138,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
26706
27138
|
context2.content.append(header, syncMessage, content);
|
|
26707
27139
|
let pending2 = false;
|
|
26708
27140
|
let selectedHostId = null;
|
|
27141
|
+
let renderedHostId = null;
|
|
26709
27142
|
let selectedItemKey = null;
|
|
26710
27143
|
let launchControls = null;
|
|
27144
|
+
let renderedInspector = null;
|
|
26711
27145
|
const hostNames = /* @__PURE__ */ new Map();
|
|
27146
|
+
const knownNotInstalled = /* @__PURE__ */ new Map();
|
|
26712
27147
|
let latestSnapshot = null;
|
|
26713
|
-
let disposeHostScroller = () => void 0;
|
|
26714
27148
|
let disposed = false;
|
|
26715
27149
|
let renderQueued = false;
|
|
26716
27150
|
let renderFrame = null;
|
|
@@ -26744,7 +27178,99 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
26744
27178
|
scheduleRender
|
|
26745
27179
|
);
|
|
26746
27180
|
const installs = diagnostics ? harnessInstallStore(diagnostics) : null;
|
|
26747
|
-
const updates = createConnectionUpdates(
|
|
27181
|
+
const updates = createConnectionUpdates(
|
|
27182
|
+
document2,
|
|
27183
|
+
messages,
|
|
27184
|
+
context2.signal,
|
|
27185
|
+
scheduleRender,
|
|
27186
|
+
diagnostics
|
|
27187
|
+
);
|
|
27188
|
+
const panelId = "codexhost-settings-connection-host-panel";
|
|
27189
|
+
const empty = document2.createElement("div");
|
|
27190
|
+
empty.className = "settings-empty";
|
|
27191
|
+
empty.textContent = messages.connectionNoRuntime;
|
|
27192
|
+
const layout = document2.createElement("div");
|
|
27193
|
+
layout.className = "settings-connections-layout";
|
|
27194
|
+
const list = document2.createElement("section");
|
|
27195
|
+
list.className = "settings-connection-list";
|
|
27196
|
+
const hostStrip = document2.createElement("div");
|
|
27197
|
+
hostStrip.className = "settings-connection-host-strip";
|
|
27198
|
+
const scrollLeft = createHostScrollButton(document2, "left", messages);
|
|
27199
|
+
const tabs = document2.createElement("div");
|
|
27200
|
+
tabs.className = "settings-connection-host-tabs";
|
|
27201
|
+
tabs.setAttribute("role", "tablist");
|
|
27202
|
+
tabs.setAttribute("aria-label", messages.connectionHosts);
|
|
27203
|
+
const scrollRight = createHostScrollButton(document2, "right", messages);
|
|
27204
|
+
hostStrip.append(scrollLeft, tabs, scrollRight);
|
|
27205
|
+
const updateControls = updates.createControls("local", []);
|
|
27206
|
+
const hostHeader = document2.createElement("div");
|
|
27207
|
+
hostHeader.className = "settings-connection-host-header";
|
|
27208
|
+
hostHeader.append(hostStrip, updateControls.button);
|
|
27209
|
+
const tableHeader = document2.createElement("div");
|
|
27210
|
+
tableHeader.className = "settings-connection-table-header";
|
|
27211
|
+
tableHeader.setAttribute("role", "row");
|
|
27212
|
+
const componentHeading = document2.createElement("span");
|
|
27213
|
+
componentHeading.textContent = messages.connectionComponent;
|
|
27214
|
+
componentHeading.setAttribute("role", "columnheader");
|
|
27215
|
+
const statusHeading = document2.createElement("span");
|
|
27216
|
+
statusHeading.textContent = messages.connectionStatus;
|
|
27217
|
+
statusHeading.setAttribute("role", "columnheader");
|
|
27218
|
+
const actionHeading = document2.createElement("span");
|
|
27219
|
+
actionHeading.setAttribute("aria-hidden", "true");
|
|
27220
|
+
tableHeader.append(componentHeading, statusHeading, actionHeading);
|
|
27221
|
+
const rows = document2.createElement("div");
|
|
27222
|
+
rows.className = "settings-connection-rows";
|
|
27223
|
+
rows.id = panelId;
|
|
27224
|
+
rows.setAttribute("role", "rowgroup");
|
|
27225
|
+
list.append(hostHeader, updateControls.result, tableHeader, rows);
|
|
27226
|
+
const inspector = document2.createElement("aside");
|
|
27227
|
+
inspector.className = "settings-connection-inspector";
|
|
27228
|
+
inspector.setAttribute("aria-live", "polite");
|
|
27229
|
+
layout.append(list, inspector);
|
|
27230
|
+
const hostScroller = configureHostScroller(
|
|
27231
|
+
document2,
|
|
27232
|
+
hostStrip,
|
|
27233
|
+
tabs,
|
|
27234
|
+
scrollLeft,
|
|
27235
|
+
scrollRight
|
|
27236
|
+
);
|
|
27237
|
+
const hostTabElements = /* @__PURE__ */ new Map();
|
|
27238
|
+
const hostRowViews = /* @__PURE__ */ new Map();
|
|
27239
|
+
const groupDivider = createGroupDivider(document2);
|
|
27240
|
+
const moreHint = createGroupMoreHint(document2, messages);
|
|
27241
|
+
const moreZone = document2.createElement("div");
|
|
27242
|
+
moreZone.className = "settings-connection-group-more";
|
|
27243
|
+
moreZone.setAttribute("role", "presentation");
|
|
27244
|
+
const resetButton = createGroupResetButton(document2, messages, () => {
|
|
27245
|
+
groupPreference.resetToDefault();
|
|
27246
|
+
});
|
|
27247
|
+
let draggingAgent = null;
|
|
27248
|
+
let currentCatalog = [];
|
|
27249
|
+
let currentMainEntries = [];
|
|
27250
|
+
let currentMoreEntries = [];
|
|
27251
|
+
let currentHostRows = /* @__PURE__ */ new Map();
|
|
27252
|
+
const clearDropIndicators = () => {
|
|
27253
|
+
for (const view of currentHostRows.values()) {
|
|
27254
|
+
view.element.dataset.connectionDropIndicator = "";
|
|
27255
|
+
}
|
|
27256
|
+
moreZone.dataset.connectionDragOver = "false";
|
|
27257
|
+
};
|
|
27258
|
+
moreZone.addEventListener("dragover", (event) => {
|
|
27259
|
+
if (!draggingAgent) return;
|
|
27260
|
+
event.preventDefault();
|
|
27261
|
+
moreZone.dataset.connectionDragOver = "true";
|
|
27262
|
+
});
|
|
27263
|
+
moreZone.addEventListener("dragleave", () => {
|
|
27264
|
+
moreZone.dataset.connectionDragOver = "false";
|
|
27265
|
+
});
|
|
27266
|
+
moreZone.addEventListener("drop", (event) => {
|
|
27267
|
+
event.preventDefault();
|
|
27268
|
+
moreZone.dataset.connectionDragOver = "false";
|
|
27269
|
+
if (!draggingAgent) return;
|
|
27270
|
+
groupPreference.moveAgent(draggingAgent, "more", null, currentCatalog);
|
|
27271
|
+
draggingAgent = null;
|
|
27272
|
+
clearDropIndicators();
|
|
27273
|
+
});
|
|
26748
27274
|
const runRefresh = () => {
|
|
26749
27275
|
if (pending2 || !diagnostics) return;
|
|
26750
27276
|
pending2 = true;
|
|
@@ -26757,6 +27283,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
26757
27283
|
success() {
|
|
26758
27284
|
installs?.clearErrors();
|
|
26759
27285
|
pending2 = false;
|
|
27286
|
+
renderedInspector = null;
|
|
26760
27287
|
refresh.disabled = false;
|
|
26761
27288
|
refresh.replaceChildren(
|
|
26762
27289
|
createRendererSettingsIcon("diagnose", 16),
|
|
@@ -26766,6 +27293,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
26766
27293
|
},
|
|
26767
27294
|
failure(error51) {
|
|
26768
27295
|
pending2 = false;
|
|
27296
|
+
renderedInspector = null;
|
|
26769
27297
|
refresh.disabled = false;
|
|
26770
27298
|
refresh.replaceChildren(
|
|
26771
27299
|
createRendererSettingsIcon("diagnose", 16),
|
|
@@ -26791,97 +27319,111 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
26791
27319
|
}
|
|
26792
27320
|
});
|
|
26793
27321
|
};
|
|
27322
|
+
const syncSelectedInspector = (hostId2, item) => {
|
|
27323
|
+
const currentDiagnostics = getDiagnostics();
|
|
27324
|
+
const signature = inspectorRenderSignature(hostId2, item, messages, currentDiagnostics);
|
|
27325
|
+
const versionElement = item.version?.element ?? null;
|
|
27326
|
+
if (renderedInspector?.signature === signature && renderedInspector.versionElement === versionElement) {
|
|
27327
|
+
return;
|
|
27328
|
+
}
|
|
27329
|
+
const existing = launchControls?.hostId === hostId2 && launchControls.itemKey === item.key ? launchControls.element : null;
|
|
27330
|
+
const element = renderConnectionInspector(
|
|
27331
|
+
document2,
|
|
27332
|
+
inspector,
|
|
27333
|
+
item,
|
|
27334
|
+
hostId2,
|
|
27335
|
+
messages,
|
|
27336
|
+
currentDiagnostics,
|
|
27337
|
+
existing,
|
|
27338
|
+
runRefresh
|
|
27339
|
+
);
|
|
27340
|
+
launchControls = { hostId: hostId2, itemKey: item.key, element };
|
|
27341
|
+
if (versionElement) inspector.append(versionElement);
|
|
27342
|
+
renderedInspector = { signature, versionElement };
|
|
27343
|
+
};
|
|
26794
27344
|
const render = (snapshot) => {
|
|
26795
27345
|
const syncStatus = groupPreference.syncStatus();
|
|
26796
27346
|
const groupDisabled = syncStatus === "loading" || syncStatus === "saving";
|
|
26797
27347
|
syncMessage.hidden = syncStatus === "ready";
|
|
26798
27348
|
syncMessage.textContent = syncStatus === "error" ? messages.connectionGroupSyncFailed : syncStatus === "saving" ? messages.connectionGroupSaving : messages.connectionGroupLoading;
|
|
26799
27349
|
latestSnapshot = snapshot;
|
|
26800
|
-
disposeHostScroller();
|
|
26801
|
-
disposeHostScroller = () => void 0;
|
|
26802
27350
|
if (!snapshot) {
|
|
26803
|
-
|
|
26804
|
-
|
|
26805
|
-
empty
|
|
26806
|
-
content.replaceChildren(empty);
|
|
27351
|
+
renderedHostId = null;
|
|
27352
|
+
renderedInspector = null;
|
|
27353
|
+
reconcileElementChildren(content, [empty]);
|
|
26807
27354
|
return;
|
|
26808
27355
|
}
|
|
26809
27356
|
const selectedHost = (selectedHostId ? snapshot.hosts.find((host) => host.hostId === selectedHostId) : void 0) ?? snapshot.hosts.find((host) => host.active) ?? snapshot.hosts.find((host) => host.hostId === "local") ?? snapshot.hosts[0];
|
|
26810
27357
|
if (!selectedHost) return;
|
|
26811
27358
|
selectedHostId = selectedHost.hostId;
|
|
26812
|
-
const
|
|
26813
|
-
|
|
26814
|
-
|
|
26815
|
-
|
|
26816
|
-
|
|
26817
|
-
|
|
26818
|
-
|
|
26819
|
-
|
|
26820
|
-
|
|
26821
|
-
|
|
26822
|
-
|
|
26823
|
-
|
|
26824
|
-
|
|
26825
|
-
|
|
26826
|
-
|
|
26827
|
-
|
|
26828
|
-
|
|
26829
|
-
|
|
26830
|
-
|
|
26831
|
-
|
|
26832
|
-
|
|
26833
|
-
|
|
26834
|
-
|
|
27359
|
+
const layoutFirstMount = content.children[0] !== layout;
|
|
27360
|
+
reconcileElementChildren(content, [layout]);
|
|
27361
|
+
let tabsChanged = tabs.children.length !== snapshot.hosts.length;
|
|
27362
|
+
const nextTabs = snapshot.hosts.map((host) => {
|
|
27363
|
+
let tab = hostTabElements.get(host.hostId);
|
|
27364
|
+
if (!tab) {
|
|
27365
|
+
tab = document2.createElement("button");
|
|
27366
|
+
tab.type = "button";
|
|
27367
|
+
tab.className = "settings-connection-host-tab";
|
|
27368
|
+
tab.dataset.connectionHostTab = host.hostId;
|
|
27369
|
+
tab.setAttribute("role", "tab");
|
|
27370
|
+
tab.setAttribute("aria-controls", panelId);
|
|
27371
|
+
tab.addEventListener("click", () => {
|
|
27372
|
+
selectedHostId = host.hostId;
|
|
27373
|
+
render(latestSnapshot);
|
|
27374
|
+
});
|
|
27375
|
+
tab.addEventListener("keydown", (event) => {
|
|
27376
|
+
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
|
27377
|
+
event.preventDefault();
|
|
27378
|
+
const hosts = latestSnapshot?.hosts ?? [];
|
|
27379
|
+
const index = hosts.findIndex((candidate) => candidate.hostId === host.hostId);
|
|
27380
|
+
if (index < 0) return;
|
|
27381
|
+
const direction = event.key === "ArrowRight" ? 1 : -1;
|
|
27382
|
+
const next = hosts[(index + direction + hosts.length) % hosts.length];
|
|
27383
|
+
if (!next) return;
|
|
27384
|
+
selectedHostId = next.hostId;
|
|
27385
|
+
render(latestSnapshot);
|
|
27386
|
+
hostTabElements.get(next.hostId)?.focus();
|
|
27387
|
+
});
|
|
27388
|
+
hostTabElements.set(host.hostId, tab);
|
|
27389
|
+
tabsChanged = true;
|
|
27390
|
+
}
|
|
27391
|
+
const isSelected = host.hostId === selectedHost.hostId;
|
|
27392
|
+
const activeValue = String(host.active);
|
|
27393
|
+
if (tab.dataset.connectionHostActive !== activeValue) {
|
|
27394
|
+
tab.dataset.connectionHostActive = activeValue;
|
|
27395
|
+
}
|
|
27396
|
+
const selectedValue = String(isSelected);
|
|
27397
|
+
if (tab.getAttribute("aria-selected") !== selectedValue) {
|
|
27398
|
+
tab.setAttribute("aria-selected", selectedValue);
|
|
27399
|
+
}
|
|
27400
|
+
const nextTabIndex = isSelected ? 0 : -1;
|
|
27401
|
+
if (tab.tabIndex !== nextTabIndex) {
|
|
27402
|
+
tab.tabIndex = nextTabIndex;
|
|
27403
|
+
}
|
|
26835
27404
|
const hostName = hostNames.get(host.hostId) || connectionHostName(host.hostId, messages);
|
|
26836
|
-
tab.textContent
|
|
26837
|
-
|
|
26838
|
-
|
|
26839
|
-
|
|
26840
|
-
|
|
26841
|
-
|
|
26842
|
-
|
|
26843
|
-
|
|
26844
|
-
|
|
26845
|
-
const direction = event.key === "ArrowRight" ? 1 : -1;
|
|
26846
|
-
const next = snapshot.hosts[(index + direction + snapshot.hosts.length) % snapshot.hosts.length];
|
|
26847
|
-
if (!next) return;
|
|
26848
|
-
selectedHostId = next.hostId;
|
|
26849
|
-
render(latestSnapshot);
|
|
26850
|
-
const nextTab = [
|
|
26851
|
-
...content.querySelectorAll("[data-connection-host-tab]")
|
|
26852
|
-
].find((candidate) => candidate.dataset.connectionHostTab === next.hostId);
|
|
26853
|
-
nextTab?.focus();
|
|
26854
|
-
});
|
|
26855
|
-
tabs.append(tab);
|
|
27405
|
+
if (tab.textContent !== hostName) {
|
|
27406
|
+
tab.textContent = hostName;
|
|
27407
|
+
tabsChanged = true;
|
|
27408
|
+
}
|
|
27409
|
+
const tabTitle = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
|
|
27410
|
+
if (tab.title !== tabTitle) {
|
|
27411
|
+
tab.title = tabTitle;
|
|
27412
|
+
}
|
|
27413
|
+
return tab;
|
|
26856
27414
|
});
|
|
26857
|
-
|
|
26858
|
-
|
|
26859
|
-
|
|
26860
|
-
|
|
26861
|
-
const componentHeading = document2.createElement("span");
|
|
26862
|
-
componentHeading.textContent = messages.connectionComponent;
|
|
26863
|
-
componentHeading.setAttribute("role", "columnheader");
|
|
26864
|
-
const statusHeading = document2.createElement("span");
|
|
26865
|
-
statusHeading.textContent = messages.connectionStatus;
|
|
26866
|
-
statusHeading.setAttribute("role", "columnheader");
|
|
26867
|
-
const actionHeading = document2.createElement("span");
|
|
26868
|
-
actionHeading.setAttribute("aria-hidden", "true");
|
|
26869
|
-
tableHeader.append(componentHeading, statusHeading, actionHeading);
|
|
26870
|
-
const rows = document2.createElement("div");
|
|
26871
|
-
rows.className = "settings-connection-rows";
|
|
26872
|
-
rows.id = panelId;
|
|
26873
|
-
rows.dataset.connectionHost = selectedHost.hostId;
|
|
26874
|
-
rows.setAttribute("role", "rowgroup");
|
|
26875
|
-
const inspector = document2.createElement("aside");
|
|
26876
|
-
inspector.className = "settings-connection-inspector";
|
|
26877
|
-
inspector.setAttribute("aria-live", "polite");
|
|
27415
|
+
reconcileElementChildren(tabs, nextTabs);
|
|
27416
|
+
if (rows.dataset.connectionHost !== selectedHost.hostId) {
|
|
27417
|
+
rows.dataset.connectionHost = selectedHost.hostId;
|
|
27418
|
+
}
|
|
26878
27419
|
const items = connectionItems(snapshot, selectedHost, messages, diagnostics).map(
|
|
26879
27420
|
(item) => {
|
|
26880
27421
|
const agent = item.agentSnapshot?.agent;
|
|
26881
27422
|
if (!agent) return item;
|
|
26882
27423
|
const state = installs?.get(selectedHost.hostId, agent);
|
|
26883
27424
|
const availability2 = state?.status ?? item.availability;
|
|
26884
|
-
const
|
|
27425
|
+
const updating = versions.isUpdating(selectedHost.hostId, agent);
|
|
27426
|
+
const version2 = updating || item.agentSnapshot?.availability !== "notInstalled" && availability2 !== "installing" && availability2 !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
|
|
26885
27427
|
return {
|
|
26886
27428
|
...item,
|
|
26887
27429
|
...state ? { availability: state.status } : {},
|
|
@@ -26903,66 +27445,66 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
26903
27445
|
(item) => item.agentSnapshot?.availability === "notInstalled" || item.error !== null
|
|
26904
27446
|
)?.key ?? items[0]?.key ?? null;
|
|
26905
27447
|
}
|
|
26906
|
-
|
|
27448
|
+
let hostRows = hostRowViews.get(selectedHost.hostId);
|
|
27449
|
+
if (!hostRows) {
|
|
27450
|
+
hostRows = /* @__PURE__ */ new Map();
|
|
27451
|
+
hostRowViews.set(selectedHost.hostId, hostRows);
|
|
27452
|
+
}
|
|
27453
|
+
currentHostRows = hostRows;
|
|
26907
27454
|
const selectItem = (item) => {
|
|
26908
27455
|
selectedItemKey = item.key;
|
|
26909
|
-
for (const [key,
|
|
26910
|
-
|
|
26911
|
-
row.dataset.connectionSelected = String(selected);
|
|
26912
|
-
row.tabIndex = selected ? 0 : -1;
|
|
27456
|
+
for (const [key, view] of currentHostRows) {
|
|
27457
|
+
view.setSelected(key === item.key);
|
|
26913
27458
|
}
|
|
26914
|
-
|
|
26915
|
-
const element = renderConnectionInspector(
|
|
26916
|
-
document2,
|
|
26917
|
-
inspector,
|
|
26918
|
-
item,
|
|
26919
|
-
selectedHost.hostId,
|
|
26920
|
-
messages,
|
|
26921
|
-
getDiagnostics(),
|
|
26922
|
-
existing,
|
|
26923
|
-
runRefresh
|
|
26924
|
-
);
|
|
26925
|
-
launchControls = { hostId: selectedHost.hostId, itemKey: item.key, element };
|
|
26926
|
-
if (item.version) inspector.append(item.version.element);
|
|
27459
|
+
syncSelectedInspector(selectedHost.hostId, item);
|
|
26927
27460
|
};
|
|
26928
|
-
const
|
|
26929
|
-
|
|
26930
|
-
|
|
26931
|
-
document2,
|
|
27461
|
+
const ensureRowView = (key, groupable) => {
|
|
27462
|
+
let view = hostRows.get(key);
|
|
27463
|
+
if (!view) {
|
|
27464
|
+
view = createConnectionRowView(document2, messages, groupable);
|
|
27465
|
+
hostRows.set(key, view);
|
|
27466
|
+
}
|
|
27467
|
+
return view;
|
|
27468
|
+
};
|
|
27469
|
+
const activeKeys = /* @__PURE__ */ new Set();
|
|
27470
|
+
const nextRowChildren = [];
|
|
27471
|
+
const pinnedItems = items.filter((item) => item.agentSnapshot === void 0);
|
|
27472
|
+
for (const pinnedItem of pinnedItems) {
|
|
27473
|
+
activeKeys.add(pinnedItem.key);
|
|
27474
|
+
const view = ensureRowView(pinnedItem.key, false);
|
|
27475
|
+
view.update(
|
|
26932
27476
|
pinnedItem,
|
|
26933
|
-
messages,
|
|
26934
27477
|
pinnedItem.key === selectedItemKey,
|
|
26935
|
-
() => selectItem(pinnedItem)
|
|
27478
|
+
() => selectItem(pinnedItem),
|
|
27479
|
+
null
|
|
26936
27480
|
);
|
|
26937
|
-
|
|
26938
|
-
rows.append(row);
|
|
27481
|
+
nextRowChildren.push(view.element);
|
|
26939
27482
|
}
|
|
26940
27483
|
const groupableItems = items.filter(
|
|
26941
27484
|
(item) => item.agentSnapshot !== void 0
|
|
26942
27485
|
);
|
|
26943
27486
|
const agentByKey = new Map(groupableItems.map((item) => [item.key, item]));
|
|
26944
|
-
|
|
26945
|
-
const
|
|
26946
|
-
|
|
26947
|
-
|
|
26948
|
-
|
|
26949
|
-
|
|
26950
|
-
|
|
26951
|
-
|
|
26952
|
-
|
|
27487
|
+
currentCatalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
|
|
27488
|
+
const notInstalledAgents = /* @__PURE__ */ new Set();
|
|
27489
|
+
for (const item of groupableItems) {
|
|
27490
|
+
const agent = item.agentSnapshot.agent;
|
|
27491
|
+
const stateKey = `${selectedHost.hostId}:${agent}`;
|
|
27492
|
+
if (item.agentSnapshot.availability !== "checking") {
|
|
27493
|
+
knownNotInstalled.set(stateKey, item.agentSnapshot.availability === "notInstalled");
|
|
27494
|
+
}
|
|
27495
|
+
const isNotInstalled = item.agentSnapshot.availability === "checking" ? knownNotInstalled.get(stateKey) ?? false : item.agentSnapshot.availability === "notInstalled";
|
|
27496
|
+
if (isNotInstalled) notInstalledAgents.add(agent);
|
|
27497
|
+
}
|
|
27498
|
+
const preferenceOrder = groupPreference.list(notInstalledAgents, currentCatalog).filter((entry) => agentByKey.has(entry.agent));
|
|
27499
|
+
currentMainEntries = preferenceOrder.filter((entry) => entry.section === "main");
|
|
27500
|
+
currentMoreEntries = preferenceOrder.filter((entry) => entry.section === "more");
|
|
26953
27501
|
const nextInSection = (section, agent) => {
|
|
26954
|
-
const
|
|
26955
|
-
const index =
|
|
26956
|
-
return index >= 0 ?
|
|
26957
|
-
};
|
|
26958
|
-
let draggingAgent = null;
|
|
26959
|
-
let moreZone = null;
|
|
26960
|
-
const clearDropIndicators = () => {
|
|
26961
|
-
for (const row of rowElements.values()) row.dataset.connectionDropIndicator = "";
|
|
26962
|
-
if (moreZone) moreZone.dataset.connectionDragOver = "false";
|
|
27502
|
+
const sectionEntries = section === "main" ? currentMainEntries : currentMoreEntries;
|
|
27503
|
+
const index = sectionEntries.findIndex((entry) => entry.agent === agent);
|
|
27504
|
+
return index >= 0 ? sectionEntries[index + 1]?.agent ?? null : null;
|
|
26963
27505
|
};
|
|
26964
27506
|
const dropTargetSection = (agent, event) => {
|
|
26965
|
-
const row =
|
|
27507
|
+
const row = currentHostRows.get(agent)?.element;
|
|
26966
27508
|
const rect = row && typeof row.getBoundingClientRect === "function" ? row.getBoundingClientRect() : null;
|
|
26967
27509
|
const before = rect ? event.clientY - rect.top < rect.height / 2 : true;
|
|
26968
27510
|
const section = row?.dataset.connectionGroupSection ?? "main";
|
|
@@ -26974,7 +27516,12 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
26974
27516
|
moveLabel: section === "main" ? messages.connectionGroupMoveToMore : messages.connectionGroupMoveToMain,
|
|
26975
27517
|
dragHandleTitle: messages.connectionGroupDragHandle,
|
|
26976
27518
|
toggleSection() {
|
|
26977
|
-
groupPreference.moveAgent(
|
|
27519
|
+
groupPreference.moveAgent(
|
|
27520
|
+
agent,
|
|
27521
|
+
section === "main" ? "more" : "main",
|
|
27522
|
+
null,
|
|
27523
|
+
currentCatalog
|
|
27524
|
+
);
|
|
26978
27525
|
},
|
|
26979
27526
|
onDragStart(event) {
|
|
26980
27527
|
if (groupDisabled) {
|
|
@@ -26984,127 +27531,107 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
26984
27531
|
draggingAgent = agent;
|
|
26985
27532
|
event.dataTransfer?.setData("text/plain", agent);
|
|
26986
27533
|
if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
|
|
26987
|
-
const row =
|
|
27534
|
+
const row = currentHostRows.get(agent)?.element;
|
|
26988
27535
|
if (row) row.dataset.connectionDragging = "true";
|
|
26989
27536
|
},
|
|
26990
27537
|
onDragOver(event) {
|
|
26991
27538
|
if (!draggingAgent || draggingAgent === agent) return;
|
|
26992
27539
|
event.preventDefault();
|
|
26993
|
-
const row =
|
|
27540
|
+
const row = currentHostRows.get(agent)?.element;
|
|
26994
27541
|
if (!row) return;
|
|
26995
27542
|
const { before } = dropTargetSection(agent, event);
|
|
26996
27543
|
clearDropIndicators();
|
|
26997
27544
|
row.dataset.connectionDropIndicator = before ? "before" : "after";
|
|
26998
27545
|
},
|
|
26999
27546
|
onDragLeave() {
|
|
27000
|
-
const row =
|
|
27547
|
+
const row = currentHostRows.get(agent)?.element;
|
|
27001
27548
|
if (row) row.dataset.connectionDropIndicator = "";
|
|
27002
27549
|
},
|
|
27003
27550
|
onDrop(event) {
|
|
27004
27551
|
event.preventDefault();
|
|
27005
27552
|
if (!draggingAgent) return;
|
|
27006
27553
|
const { beforeAgent } = dropTargetSection(agent, event);
|
|
27007
|
-
groupPreference.moveAgent(draggingAgent, section, beforeAgent,
|
|
27554
|
+
groupPreference.moveAgent(draggingAgent, section, beforeAgent, currentCatalog);
|
|
27008
27555
|
draggingAgent = null;
|
|
27009
27556
|
clearDropIndicators();
|
|
27010
27557
|
},
|
|
27011
27558
|
onDragEnd() {
|
|
27012
27559
|
draggingAgent = null;
|
|
27013
|
-
const row =
|
|
27560
|
+
const row = currentHostRows.get(agent)?.element;
|
|
27014
27561
|
if (row) row.dataset.connectionDragging = "false";
|
|
27015
27562
|
clearDropIndicators();
|
|
27563
|
+
scheduleRender();
|
|
27016
27564
|
}
|
|
27017
27565
|
});
|
|
27018
|
-
const
|
|
27019
|
-
const item = agentByKey.get(agent);
|
|
27020
|
-
if (!item)
|
|
27021
|
-
|
|
27022
|
-
|
|
27566
|
+
for (const entry of currentMainEntries) {
|
|
27567
|
+
const item = agentByKey.get(entry.agent);
|
|
27568
|
+
if (!item) continue;
|
|
27569
|
+
activeKeys.add(item.key);
|
|
27570
|
+
const view = ensureRowView(item.key, true);
|
|
27571
|
+
view.update(
|
|
27023
27572
|
item,
|
|
27024
|
-
messages,
|
|
27025
27573
|
item.key === selectedItemKey,
|
|
27026
27574
|
() => selectItem(item),
|
|
27027
|
-
createGroupController(agent,
|
|
27575
|
+
createGroupController(entry.agent, "main")
|
|
27028
27576
|
);
|
|
27029
|
-
|
|
27030
|
-
|
|
27031
|
-
};
|
|
27032
|
-
for (const entry of mainEntries) appendGroupRow(entry.agent, "main");
|
|
27577
|
+
nextRowChildren.push(view.element);
|
|
27578
|
+
}
|
|
27033
27579
|
if (groupableItems.length > 0) {
|
|
27034
|
-
|
|
27035
|
-
|
|
27036
|
-
|
|
27037
|
-
|
|
27038
|
-
|
|
27039
|
-
|
|
27040
|
-
|
|
27041
|
-
|
|
27042
|
-
zone.dataset.connectionDragOver = "true";
|
|
27043
|
-
});
|
|
27044
|
-
zone.addEventListener("dragleave", () => {
|
|
27045
|
-
zone.dataset.connectionDragOver = "false";
|
|
27046
|
-
});
|
|
27047
|
-
zone.addEventListener("drop", (event) => {
|
|
27048
|
-
event.preventDefault();
|
|
27049
|
-
zone.dataset.connectionDragOver = "false";
|
|
27050
|
-
if (!draggingAgent) return;
|
|
27051
|
-
groupPreference.moveAgent(draggingAgent, "more", null, catalog);
|
|
27052
|
-
draggingAgent = null;
|
|
27053
|
-
clearDropIndicators();
|
|
27054
|
-
});
|
|
27055
|
-
if (moreEntries.length === 0) {
|
|
27056
|
-
zone.append(createGroupMoreHint(document2, messages));
|
|
27580
|
+
const dividerText = `${messages.connectionGroupMoreLabel} (${currentMoreEntries.length})`;
|
|
27581
|
+
if (groupDivider.textContent !== dividerText) {
|
|
27582
|
+
groupDivider.textContent = dividerText;
|
|
27583
|
+
}
|
|
27584
|
+
nextRowChildren.push(groupDivider);
|
|
27585
|
+
const nextMoreChildren = [];
|
|
27586
|
+
if (currentMoreEntries.length === 0) {
|
|
27587
|
+
nextMoreChildren.push(moreHint);
|
|
27057
27588
|
} else {
|
|
27058
|
-
for (const entry of
|
|
27589
|
+
for (const entry of currentMoreEntries) {
|
|
27059
27590
|
const item = agentByKey.get(entry.agent);
|
|
27060
27591
|
if (!item) continue;
|
|
27061
|
-
|
|
27062
|
-
|
|
27592
|
+
activeKeys.add(item.key);
|
|
27593
|
+
const view = ensureRowView(item.key, true);
|
|
27594
|
+
view.update(
|
|
27063
27595
|
item,
|
|
27064
|
-
messages,
|
|
27065
27596
|
item.key === selectedItemKey,
|
|
27066
27597
|
() => selectItem(item),
|
|
27067
27598
|
createGroupController(entry.agent, "more")
|
|
27068
27599
|
);
|
|
27069
|
-
|
|
27070
|
-
zone.append(row);
|
|
27600
|
+
nextMoreChildren.push(view.element);
|
|
27071
27601
|
}
|
|
27072
27602
|
}
|
|
27073
|
-
|
|
27074
|
-
|
|
27075
|
-
|
|
27076
|
-
|
|
27077
|
-
|
|
27078
|
-
|
|
27603
|
+
if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
|
|
27604
|
+
reconcileElementChildren(moreZone, nextMoreChildren);
|
|
27605
|
+
}
|
|
27606
|
+
nextRowChildren.push(moreZone);
|
|
27607
|
+
resetButton.disabled = groupDisabled;
|
|
27608
|
+
nextRowChildren.push(resetButton);
|
|
27609
|
+
}
|
|
27610
|
+
for (const key of hostRows.keys()) {
|
|
27611
|
+
if (!activeKeys.has(key)) hostRows.delete(key);
|
|
27612
|
+
}
|
|
27613
|
+
if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
|
|
27614
|
+
reconcileElementChildren(rows, nextRowChildren);
|
|
27079
27615
|
}
|
|
27080
27616
|
const selectedItem = items.find((item) => item.key === selectedItemKey) ?? items[0];
|
|
27081
27617
|
if (selectedItem) selectItem(selectedItem);
|
|
27082
|
-
|
|
27618
|
+
updateControls.update(
|
|
27083
27619
|
selectedHost.hostId,
|
|
27084
27620
|
items.flatMap((item) => item.version ? [item.version] : [])
|
|
27085
27621
|
);
|
|
27086
|
-
|
|
27087
|
-
|
|
27088
|
-
|
|
27089
|
-
|
|
27090
|
-
|
|
27091
|
-
|
|
27092
|
-
|
|
27093
|
-
|
|
27094
|
-
|
|
27095
|
-
|
|
27096
|
-
|
|
27097
|
-
|
|
27098
|
-
|
|
27099
|
-
const selectedTab = [...tabs.children].find(
|
|
27100
|
-
(child) => child.getAttribute("aria-selected") === "true"
|
|
27101
|
-
);
|
|
27102
|
-
if (selectedTab) {
|
|
27103
|
-
const left = selectedTab.offsetLeft;
|
|
27104
|
-
const right = left + selectedTab.offsetWidth;
|
|
27105
|
-
if (left < tabs.scrollLeft) tabs.scrollLeft = left;
|
|
27106
|
-
else if (right > tabs.scrollLeft + tabs.clientWidth) {
|
|
27107
|
-
tabs.scrollLeft = right - tabs.clientWidth;
|
|
27622
|
+
if (layoutFirstMount || tabsChanged) {
|
|
27623
|
+
hostScroller.update();
|
|
27624
|
+
}
|
|
27625
|
+
if (renderedHostId !== selectedHost.hostId) {
|
|
27626
|
+
renderedHostId = selectedHost.hostId;
|
|
27627
|
+
const selectedTab = hostTabElements.get(selectedHost.hostId);
|
|
27628
|
+
if (selectedTab) {
|
|
27629
|
+
const left = selectedTab.offsetLeft;
|
|
27630
|
+
const right = left + selectedTab.offsetWidth;
|
|
27631
|
+
if (left < tabs.scrollLeft) tabs.scrollLeft = left;
|
|
27632
|
+
else if (right > tabs.scrollLeft + tabs.clientWidth) {
|
|
27633
|
+
tabs.scrollLeft = right - tabs.clientWidth;
|
|
27634
|
+
}
|
|
27108
27635
|
}
|
|
27109
27636
|
}
|
|
27110
27637
|
};
|
|
@@ -27125,7 +27652,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
27125
27652
|
refresh.disabled = true;
|
|
27126
27653
|
return () => {
|
|
27127
27654
|
cancelRender();
|
|
27128
|
-
|
|
27655
|
+
hostScroller.dispose();
|
|
27129
27656
|
unsubscribeGroup();
|
|
27130
27657
|
};
|
|
27131
27658
|
}
|
|
@@ -27134,7 +27661,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
27134
27661
|
const unsubscribeInstalls = installs?.subscribe(scheduleRender);
|
|
27135
27662
|
return () => {
|
|
27136
27663
|
cancelRender();
|
|
27137
|
-
|
|
27664
|
+
hostScroller.dispose();
|
|
27138
27665
|
unsubscribeInstalls?.();
|
|
27139
27666
|
unsubscribe();
|
|
27140
27667
|
unsubscribeGroup();
|
|
@@ -28780,6 +29307,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
28780
29307
|
latestCacheHit: "Latest cache hit (CH)",
|
|
28781
29308
|
sessionCacheHit: "Average cache hit",
|
|
28782
29309
|
outputSpeed: "Output speed (TPS)",
|
|
29310
|
+
averageOutputSpeed: "Average output speed (TPS)",
|
|
28783
29311
|
apiOutputSpeed: "API average speed",
|
|
28784
29312
|
apiOutputSpeedDescription: "Output tokens / native API time, including first-token wait; not generation TPS.",
|
|
28785
29313
|
timeToFirstOutput: "Time to first token (TTFT)",
|
|
@@ -28805,6 +29333,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
28805
29333
|
latestCacheHit: "\u6700\u8FD1\u7F13\u5B58\u547D\u4E2D\uFF08CH\uFF09",
|
|
28806
29334
|
sessionCacheHit: "\u5E73\u5747\u7F13\u5B58\u547D\u4E2D",
|
|
28807
29335
|
outputSpeed: "\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
|
|
29336
|
+
averageOutputSpeed: "\u5E73\u5747\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
|
|
28808
29337
|
apiOutputSpeed: "API \u5E73\u5747\u901F\u5EA6",
|
|
28809
29338
|
apiOutputSpeedDescription: "\u8F93\u51FA Token \xF7 \u539F\u751F API \u8017\u65F6\uFF0C\u542B\u9996\u5B57\u7B49\u5F85\uFF1B\u4E0D\u662F\u751F\u6210 TPS\u3002",
|
|
28810
29339
|
timeToFirstOutput: "\u9996 token\uFF08TTFT\uFF09",
|
|
@@ -28902,7 +29431,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
28902
29431
|
return svg2;
|
|
28903
29432
|
}
|
|
28904
29433
|
function rendererUsageHasDisplayData(usage) {
|
|
28905
|
-
return usage?.cacheHitRatePercent !== void 0 || usage?.sessionCacheHitRatePercent !== void 0 || usage?.outputTokensPerSecond !== void 0 || usage?.apiOutputTokensPerSecond !== void 0 || usage?.timeToFirstOutputMs !== void 0 || usage?.totalCostUsd !== void 0 || usage?.totalCredits !== void 0 || usage?.contextUsagePercent !== void 0 || usage?.contextUsedTokens !== void 0 && usage.contextWindowTokens !== void 0 || usage?.totalTokens !== void 0 || usage?.inputTokens !== void 0 || usage?.cachedInputTokens !== void 0 || usage?.cacheWriteInputTokens !== void 0 || usage?.outputTokens !== void 0;
|
|
29434
|
+
return usage?.cacheHitRatePercent !== void 0 || usage?.sessionCacheHitRatePercent !== void 0 || usage?.sessionOutputTokensPerSecond !== void 0 || usage?.outputTokensPerSecond !== void 0 || usage?.apiOutputTokensPerSecond !== void 0 || usage?.timeToFirstOutputMs !== void 0 || usage?.totalCostUsd !== void 0 || usage?.totalCredits !== void 0 || usage?.contextUsagePercent !== void 0 || usage?.contextUsedTokens !== void 0 && usage.contextWindowTokens !== void 0 || usage?.totalTokens !== void 0 || usage?.inputTokens !== void 0 || usage?.cachedInputTokens !== void 0 || usage?.cacheWriteInputTokens !== void 0 || usage?.outputTokens !== void 0;
|
|
28906
29435
|
}
|
|
28907
29436
|
function applyRendererPopoverChrome(popover) {
|
|
28908
29437
|
popover.style.border = "1px solid light-dark(rgba(15, 23, 42, 0.10), color-mix(in srgb, CanvasText 16%, transparent))";
|
|
@@ -29015,6 +29544,12 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
29015
29544
|
formatRendererCacheHitRate(usage.sessionCacheHitRatePercent)
|
|
29016
29545
|
]);
|
|
29017
29546
|
}
|
|
29547
|
+
if (usage?.sessionOutputTokensPerSecond !== void 0) {
|
|
29548
|
+
session.push([
|
|
29549
|
+
messages.averageOutputSpeed,
|
|
29550
|
+
formatRendererTokenRate(usage.sessionOutputTokensPerSecond, locale)
|
|
29551
|
+
]);
|
|
29552
|
+
}
|
|
29018
29553
|
if (usage?.cacheHitRatePercent !== void 0) {
|
|
29019
29554
|
session.push([messages.latestCacheHit, formatRendererCacheHitRate(usage.cacheHitRatePercent)]);
|
|
29020
29555
|
}
|
|
@@ -30841,9 +31376,13 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
30841
31376
|
resets: "Resets",
|
|
30842
31377
|
details: "Account limit details",
|
|
30843
31378
|
weekly: "Weekly limit",
|
|
31379
|
+
weeklyShort: "Weekly",
|
|
30844
31380
|
monthly: "Monthly limit",
|
|
31381
|
+
monthlyShort: "Monthly",
|
|
30845
31382
|
fiveHour: "5-hour limit",
|
|
31383
|
+
fiveHourShort: "5-hour",
|
|
30846
31384
|
sevenDay: "7-day limit",
|
|
31385
|
+
sevenDayShort: "7-day",
|
|
30847
31386
|
account: "Account limit"
|
|
30848
31387
|
});
|
|
30849
31388
|
var CHINESE_CREDITS_MESSAGES = Object.freeze({
|
|
@@ -30851,9 +31390,13 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
30851
31390
|
resets: "\u91CD\u7F6E",
|
|
30852
31391
|
details: "\u8D26\u53F7\u989D\u5EA6\u8BE6\u60C5",
|
|
30853
31392
|
weekly: "\u5468\u989D\u5EA6",
|
|
31393
|
+
weeklyShort: "\u5468\u989D\u5EA6",
|
|
30854
31394
|
monthly: "\u6708\u989D\u5EA6",
|
|
31395
|
+
monthlyShort: "\u6708\u989D\u5EA6",
|
|
30855
31396
|
fiveHour: "5 \u5C0F\u65F6\u989D\u5EA6",
|
|
31397
|
+
fiveHourShort: "5 \u5C0F\u65F6",
|
|
30856
31398
|
sevenDay: "7 \u5929\u989D\u5EA6",
|
|
31399
|
+
sevenDayShort: "7 \u5929",
|
|
30857
31400
|
account: "\u8D26\u53F7\u989D\u5EA6"
|
|
30858
31401
|
});
|
|
30859
31402
|
function rendererCreditsMessages(locale) {
|
|
@@ -30885,6 +31428,14 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
30885
31428
|
if (periodType === "seven_day") return messages.sevenDay;
|
|
30886
31429
|
return messages.account;
|
|
30887
31430
|
}
|
|
31431
|
+
function compactPeriodLabel(periodType, locale) {
|
|
31432
|
+
const messages = rendererCreditsMessages(locale);
|
|
31433
|
+
if (periodType === "weekly") return messages.weeklyShort;
|
|
31434
|
+
if (periodType === "monthly") return messages.monthlyShort;
|
|
31435
|
+
if (periodType === "five_hour") return messages.fiveHourShort;
|
|
31436
|
+
if (periodType === "seven_day") return messages.sevenDayShort;
|
|
31437
|
+
return messages.account;
|
|
31438
|
+
}
|
|
30888
31439
|
function productLabel(product, locale = "en") {
|
|
30889
31440
|
return accountCreditsWindowLabel(product, locale, (period) => creditsPeriodLabel(period, locale));
|
|
30890
31441
|
}
|
|
@@ -30896,10 +31447,10 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
30896
31447
|
function remainingPercent(usedPercent) {
|
|
30897
31448
|
return Math.min(100, Math.max(0, 100 - usedPercent));
|
|
30898
31449
|
}
|
|
30899
|
-
function renderCreditsBar(usagePercent, color) {
|
|
31450
|
+
function renderCreditsBar(usagePercent, color, height = "6px") {
|
|
30900
31451
|
const track = document.createElement("div");
|
|
30901
31452
|
track.dataset.codexhostCreditsBar = "";
|
|
30902
|
-
track.style.height =
|
|
31453
|
+
track.style.height = height;
|
|
30903
31454
|
track.style.borderRadius = "9999px";
|
|
30904
31455
|
track.style.background = "color-mix(in srgb, currentColor 16%, transparent)";
|
|
30905
31456
|
track.style.overflow = "hidden";
|
|
@@ -30916,6 +31467,34 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
30916
31467
|
const formatted = formatRendererCreditsReset(resetsAt, /* @__PURE__ */ new Date(), locale);
|
|
30917
31468
|
return locale === "zh-CN" ? `${formatted} ${messages.resets}` : `${messages.resets} ${formatted}`;
|
|
30918
31469
|
}
|
|
31470
|
+
function renderResetLine(resetsAt, fontSize, locale, messages) {
|
|
31471
|
+
const exact = resetLabel(resetsAt, locale, messages);
|
|
31472
|
+
const reset = document.createElement("div");
|
|
31473
|
+
reset.dataset.codexhostResetAt = resetsAt;
|
|
31474
|
+
reset.dataset.codexhostResetLocale = locale;
|
|
31475
|
+
reset.textContent = formatAccountCreditsResetCountdown(resetsAt, locale) ?? exact;
|
|
31476
|
+
reset.title = exact;
|
|
31477
|
+
reset.style.fontSize = fontSize;
|
|
31478
|
+
reset.style.color = "color-mix(in srgb, currentColor 62%, transparent)";
|
|
31479
|
+
return reset;
|
|
31480
|
+
}
|
|
31481
|
+
function refreshResetLines(popover) {
|
|
31482
|
+
if (typeof popover.querySelectorAll !== "function") return;
|
|
31483
|
+
const nowMs = Date.now();
|
|
31484
|
+
for (const element of popover.querySelectorAll("[data-codexhost-reset-at]")) {
|
|
31485
|
+
const resetsAt = element.dataset.codexhostResetAt;
|
|
31486
|
+
if (!resetsAt) continue;
|
|
31487
|
+
const locale = element.dataset.codexhostResetLocale === "zh-CN" ? "zh-CN" : "en";
|
|
31488
|
+
const exact = resetLabel(resetsAt, locale, rendererCreditsMessages(locale));
|
|
31489
|
+
if (element.dataset.codexhostResetCompact === "1") {
|
|
31490
|
+
const compact = formatAccountCreditsCompactCountdown(resetsAt, locale, nowMs);
|
|
31491
|
+
element.textContent = `\xB7 ${compact ?? exact}`;
|
|
31492
|
+
} else {
|
|
31493
|
+
element.textContent = formatAccountCreditsResetCountdown(resetsAt, locale, nowMs) ?? exact;
|
|
31494
|
+
}
|
|
31495
|
+
element.title = exact;
|
|
31496
|
+
}
|
|
31497
|
+
}
|
|
30919
31498
|
function renderCreditsHeader(credits, locale, messages) {
|
|
30920
31499
|
const wrapper = document.createElement("div");
|
|
30921
31500
|
wrapper.style.marginBottom = "11px";
|
|
@@ -30932,11 +31511,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
30932
31511
|
label.style.fontWeight = "600";
|
|
30933
31512
|
left.append(label);
|
|
30934
31513
|
if (credits.resetsAt) {
|
|
30935
|
-
|
|
30936
|
-
reset.textContent = resetLabel(credits.resetsAt, locale, messages);
|
|
30937
|
-
reset.style.fontSize = "11px";
|
|
30938
|
-
reset.style.color = "color-mix(in srgb, currentColor 62%, transparent)";
|
|
30939
|
-
left.append(reset);
|
|
31514
|
+
left.append(renderResetLine(credits.resetsAt, "11px", locale, messages));
|
|
30940
31515
|
}
|
|
30941
31516
|
const color = toneColor(rendererCreditsTone(credits.usedPercent));
|
|
30942
31517
|
const remaining = remainingPercent(credits.usedPercent);
|
|
@@ -30965,7 +31540,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
30965
31540
|
const color = toneColor(rendererCreditsTone(usagePercent));
|
|
30966
31541
|
const remaining = remainingPercent(usagePercent);
|
|
30967
31542
|
const tile = document.createElement("div");
|
|
30968
|
-
tile.style.marginBottom = "
|
|
31543
|
+
tile.style.marginBottom = "9px";
|
|
30969
31544
|
const top = document.createElement("div");
|
|
30970
31545
|
top.style.display = "flex";
|
|
30971
31546
|
top.style.alignItems = "flex-start";
|
|
@@ -30978,40 +31553,137 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
30978
31553
|
name.style.fontSize = "12px";
|
|
30979
31554
|
left.append(name);
|
|
30980
31555
|
if (resetsAt) {
|
|
30981
|
-
|
|
30982
|
-
reset.textContent = resetLabel(resetsAt, locale, messages);
|
|
30983
|
-
reset.style.fontSize = "10.5px";
|
|
30984
|
-
reset.style.color = "color-mix(in srgb, currentColor 62%, transparent)";
|
|
30985
|
-
left.append(reset);
|
|
31556
|
+
left.append(renderResetLine(resetsAt, "10.5px", locale, messages));
|
|
30986
31557
|
}
|
|
30987
31558
|
const percent2 = document.createElement("span");
|
|
30988
31559
|
percent2.textContent = `${messages.remaining} ${formatRendererCreditsPercent(remaining)}`;
|
|
30989
31560
|
percent2.style.fontSize = "12px";
|
|
30990
31561
|
percent2.style.fontVariantNumeric = "tabular-nums";
|
|
31562
|
+
percent2.style.whiteSpace = "nowrap";
|
|
30991
31563
|
percent2.style.color = color;
|
|
30992
31564
|
top.append(left, percent2);
|
|
30993
31565
|
tile.append(top, renderCreditsBar(remaining, color));
|
|
30994
31566
|
return tile;
|
|
30995
31567
|
}
|
|
31568
|
+
function renderCompactCreditsRow(label, usagePercent, locale, messages, resetsAt, hero = false) {
|
|
31569
|
+
const color = toneColor(rendererCreditsTone(usagePercent));
|
|
31570
|
+
const remaining = remainingPercent(usagePercent);
|
|
31571
|
+
const row = document.createElement("div");
|
|
31572
|
+
row.style.marginBottom = "8px";
|
|
31573
|
+
const top = document.createElement("div");
|
|
31574
|
+
top.style.display = "flex";
|
|
31575
|
+
top.style.alignItems = "baseline";
|
|
31576
|
+
top.style.justifyContent = "space-between";
|
|
31577
|
+
top.style.gap = "8px";
|
|
31578
|
+
top.style.marginBottom = "4px";
|
|
31579
|
+
const left = document.createElement("span");
|
|
31580
|
+
left.style.display = "inline-flex";
|
|
31581
|
+
left.style.alignItems = "baseline";
|
|
31582
|
+
left.style.gap = "6px";
|
|
31583
|
+
left.style.minWidth = "0";
|
|
31584
|
+
const name = document.createElement("span");
|
|
31585
|
+
name.textContent = label;
|
|
31586
|
+
name.style.fontSize = "12px";
|
|
31587
|
+
name.style.color = "color-mix(in srgb, currentColor 82%, transparent)";
|
|
31588
|
+
left.append(name);
|
|
31589
|
+
if (resetsAt) {
|
|
31590
|
+
const exact = resetLabel(resetsAt, locale, messages);
|
|
31591
|
+
if (usagePercent > 0) {
|
|
31592
|
+
const countdown = document.createElement("span");
|
|
31593
|
+
countdown.dataset.codexhostResetAt = resetsAt;
|
|
31594
|
+
countdown.dataset.codexhostResetLocale = locale;
|
|
31595
|
+
countdown.dataset.codexhostResetCompact = "1";
|
|
31596
|
+
const compact = formatAccountCreditsCompactCountdown(resetsAt, locale);
|
|
31597
|
+
countdown.textContent = `\xB7 ${compact ?? exact}`;
|
|
31598
|
+
countdown.title = exact;
|
|
31599
|
+
countdown.style.fontSize = "11px";
|
|
31600
|
+
countdown.style.color = "color-mix(in srgb, currentColor 52%, transparent)";
|
|
31601
|
+
countdown.style.whiteSpace = "nowrap";
|
|
31602
|
+
left.append(countdown);
|
|
31603
|
+
} else {
|
|
31604
|
+
left.title = exact;
|
|
31605
|
+
}
|
|
31606
|
+
}
|
|
31607
|
+
const percent2 = document.createElement("span");
|
|
31608
|
+
percent2.textContent = formatRendererCreditsPercent(remaining);
|
|
31609
|
+
percent2.style.fontSize = hero ? "22px" : "13px";
|
|
31610
|
+
percent2.style.fontWeight = hero ? "700" : "600";
|
|
31611
|
+
if (hero) {
|
|
31612
|
+
percent2.style.lineHeight = "1";
|
|
31613
|
+
percent2.style.marginTop = "-6px";
|
|
31614
|
+
}
|
|
31615
|
+
percent2.style.fontVariantNumeric = "tabular-nums";
|
|
31616
|
+
percent2.style.whiteSpace = "nowrap";
|
|
31617
|
+
percent2.style.color = color;
|
|
31618
|
+
top.append(left, percent2);
|
|
31619
|
+
row.append(top, renderCreditsBar(remaining, color, "4px"));
|
|
31620
|
+
return row;
|
|
31621
|
+
}
|
|
30996
31622
|
function renderDetails2(popover, credits, locale) {
|
|
30997
31623
|
const messages = rendererCreditsMessages(locale);
|
|
30998
31624
|
const glowColor = toneColor(rendererCreditsTone(credits.usedPercent));
|
|
30999
31625
|
popover.style.backgroundImage = `radial-gradient(160px 100px at 18% -10%, color-mix(in srgb, ${glowColor} 20%, transparent), transparent 70%)`;
|
|
31000
31626
|
popover.setAttribute("aria-label", messages.details);
|
|
31001
31627
|
popover.replaceChildren();
|
|
31002
|
-
|
|
31003
|
-
|
|
31004
|
-
|
|
31005
|
-
|
|
31006
|
-
|
|
31007
|
-
locale,
|
|
31008
|
-
messages,
|
|
31009
|
-
product.resetsAt
|
|
31010
|
-
)
|
|
31628
|
+
const sections = groupAccountCreditsWindows(
|
|
31629
|
+
credits,
|
|
31630
|
+
locale,
|
|
31631
|
+
(period) => creditsPeriodLabel(period, locale),
|
|
31632
|
+
(period) => compactPeriodLabel(period, locale)
|
|
31011
31633
|
);
|
|
31012
|
-
const
|
|
31013
|
-
if (
|
|
31014
|
-
|
|
31634
|
+
const firstScopedIndex = sections.findIndex((section) => section.title !== void 0);
|
|
31635
|
+
if (firstScopedIndex === -1) {
|
|
31636
|
+
popover.append(renderCreditsHeader(credits, locale, messages));
|
|
31637
|
+
const tiles = (credits.productUsage ?? []).map(
|
|
31638
|
+
(product) => renderCreditsTile(
|
|
31639
|
+
productLabel(product, locale),
|
|
31640
|
+
product.usagePercent,
|
|
31641
|
+
locale,
|
|
31642
|
+
messages,
|
|
31643
|
+
product.resetsAt
|
|
31644
|
+
)
|
|
31645
|
+
);
|
|
31646
|
+
const lastTile = tiles.at(-1);
|
|
31647
|
+
if (lastTile) lastTile.style.marginBottom = "0";
|
|
31648
|
+
popover.append(...tiles);
|
|
31649
|
+
return;
|
|
31650
|
+
}
|
|
31651
|
+
sections.forEach((section, sectionIndex) => {
|
|
31652
|
+
const group = document.createElement("div");
|
|
31653
|
+
if (sectionIndex > 0) {
|
|
31654
|
+
group.style.marginTop = "11px";
|
|
31655
|
+
group.style.paddingTop = "10px";
|
|
31656
|
+
group.style.borderTop = "1px solid color-mix(in srgb, currentColor 12%, transparent)";
|
|
31657
|
+
}
|
|
31658
|
+
if (section.title) {
|
|
31659
|
+
const heading = document.createElement("div");
|
|
31660
|
+
heading.textContent = section.title;
|
|
31661
|
+
heading.style.marginBottom = "7px";
|
|
31662
|
+
heading.style.fontSize = "12px";
|
|
31663
|
+
heading.style.fontWeight = "600";
|
|
31664
|
+
group.append(heading);
|
|
31665
|
+
}
|
|
31666
|
+
const tiles = section.windows.map(
|
|
31667
|
+
(window2, windowIndex) => section.title ? renderCompactCreditsRow(
|
|
31668
|
+
window2.label,
|
|
31669
|
+
window2.usedPercent,
|
|
31670
|
+
locale,
|
|
31671
|
+
messages,
|
|
31672
|
+
window2.resetsAt,
|
|
31673
|
+
sectionIndex === firstScopedIndex && windowIndex === 0
|
|
31674
|
+
) : renderCreditsTile(
|
|
31675
|
+
window2.scopeLabel ? `${window2.scopeLabel} \xB7 ${window2.label}` : window2.label,
|
|
31676
|
+
window2.usedPercent,
|
|
31677
|
+
locale,
|
|
31678
|
+
messages,
|
|
31679
|
+
window2.resetsAt
|
|
31680
|
+
)
|
|
31681
|
+
);
|
|
31682
|
+
const lastTile = tiles.at(-1);
|
|
31683
|
+
if (lastTile) lastTile.style.marginBottom = "0";
|
|
31684
|
+
group.append(...tiles);
|
|
31685
|
+
popover.append(group);
|
|
31686
|
+
});
|
|
31015
31687
|
}
|
|
31016
31688
|
function popoverIsOpen2(popover) {
|
|
31017
31689
|
try {
|
|
@@ -31038,6 +31710,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
31038
31710
|
control.trigger.setAttribute("aria-expanded", "false");
|
|
31039
31711
|
}
|
|
31040
31712
|
function openPopover2(control) {
|
|
31713
|
+
refreshResetLines(control.popover);
|
|
31041
31714
|
positionPopover2(control);
|
|
31042
31715
|
control.popover.hidden = false;
|
|
31043
31716
|
if (typeof control.popover.showPopover === "function" && !popoverIsOpen2(control.popover)) {
|
|
@@ -43157,6 +43830,25 @@ ${detail}` : ""}`
|
|
|
43157
43830
|
node.textContent = label;
|
|
43158
43831
|
return node;
|
|
43159
43832
|
}
|
|
43833
|
+
function labeledField(document2, input) {
|
|
43834
|
+
const field2 = document2.createElement("div");
|
|
43835
|
+
field2.className = input.wide ? "settings-mcp-clients-field settings-mcp-clients-field--wide" : "settings-mcp-clients-field";
|
|
43836
|
+
const controlId = input.control.id || preferenceId("mcp-client");
|
|
43837
|
+
input.control.id = controlId;
|
|
43838
|
+
const label = document2.createElement("label");
|
|
43839
|
+
label.htmlFor = controlId;
|
|
43840
|
+
label.textContent = input.label;
|
|
43841
|
+
field2.append(label, input.control);
|
|
43842
|
+
if (input.hint) {
|
|
43843
|
+
const hint = document2.createElement("p");
|
|
43844
|
+
hint.className = "settings-mcp-clients-hint";
|
|
43845
|
+
hint.id = preferenceId("mcp-client-hint");
|
|
43846
|
+
hint.textContent = input.hint;
|
|
43847
|
+
input.control.setAttribute("aria-describedby", hint.id);
|
|
43848
|
+
field2.append(hint);
|
|
43849
|
+
}
|
|
43850
|
+
return field2;
|
|
43851
|
+
}
|
|
43160
43852
|
function createMcpClientsSettingsPage(messages, getClient) {
|
|
43161
43853
|
return Object.freeze({
|
|
43162
43854
|
id: "mcp-clients",
|
|
@@ -43194,10 +43886,12 @@ ${detail}` : ""}`
|
|
|
43194
43886
|
status.textContent = message2;
|
|
43195
43887
|
};
|
|
43196
43888
|
const form = document2.createElement("form");
|
|
43197
|
-
form.className = "settings-
|
|
43889
|
+
form.className = "settings-mcp-clients-form";
|
|
43890
|
+
form.setAttribute("aria-label", copy.add);
|
|
43198
43891
|
const nameInput = document2.createElement("input");
|
|
43199
43892
|
nameInput.type = "text";
|
|
43200
43893
|
nameInput.required = true;
|
|
43894
|
+
nameInput.autocomplete = "off";
|
|
43201
43895
|
nameInput.placeholder = copy.name;
|
|
43202
43896
|
nameInput.setAttribute("aria-label", copy.name);
|
|
43203
43897
|
const accessSelect = document2.createElement("select");
|
|
@@ -43208,7 +43902,6 @@ ${detail}` : ""}`
|
|
|
43208
43902
|
);
|
|
43209
43903
|
const workspaces = document2.createElement("textarea");
|
|
43210
43904
|
workspaces.rows = 3;
|
|
43211
|
-
workspaces.placeholder = copy.workspacesHint;
|
|
43212
43905
|
workspaces.setAttribute("aria-label", copy.workspaces);
|
|
43213
43906
|
const connectionSelect = document2.createElement("select");
|
|
43214
43907
|
connectionSelect.setAttribute("aria-label", copy.connection);
|
|
@@ -43225,25 +43918,46 @@ ${detail}` : ""}`
|
|
|
43225
43918
|
);
|
|
43226
43919
|
const directUrlInput = document2.createElement("input");
|
|
43227
43920
|
directUrlInput.type = "url";
|
|
43228
|
-
directUrlInput.placeholder = copy.directUrlHint;
|
|
43229
43921
|
directUrlInput.setAttribute("aria-label", copy.directUrl);
|
|
43230
43922
|
const oauthInput = document2.createElement("input");
|
|
43231
43923
|
oauthInput.type = "text";
|
|
43232
|
-
oauthInput.
|
|
43924
|
+
oauthInput.autocomplete = "off";
|
|
43233
43925
|
oauthInput.setAttribute("aria-label", copy.oauthClientId);
|
|
43234
43926
|
const add = document2.createElement("button");
|
|
43235
43927
|
add.type = "submit";
|
|
43236
43928
|
add.className = "settings-command-button";
|
|
43237
43929
|
add.textContent = copy.add;
|
|
43930
|
+
const workspacesField = labeledField(document2, {
|
|
43931
|
+
label: copy.workspaces,
|
|
43932
|
+
control: workspaces,
|
|
43933
|
+
hint: copy.workspacesHint,
|
|
43934
|
+
wide: true
|
|
43935
|
+
});
|
|
43936
|
+
const directUrlField = labeledField(document2, {
|
|
43937
|
+
label: copy.directUrl,
|
|
43938
|
+
control: directUrlInput,
|
|
43939
|
+
hint: copy.directUrlHint,
|
|
43940
|
+
wide: true
|
|
43941
|
+
});
|
|
43942
|
+
const actions = document2.createElement("div");
|
|
43943
|
+
actions.className = "settings-mcp-clients-actions";
|
|
43944
|
+
actions.append(add);
|
|
43945
|
+
const syncOptionalFields = () => {
|
|
43946
|
+
workspacesField.hidden = accessSelect.value !== "selected-workspaces";
|
|
43947
|
+
directUrlField.hidden = connectionSelect.value !== "direct";
|
|
43948
|
+
};
|
|
43949
|
+
accessSelect.addEventListener("change", syncOptionalFields);
|
|
43950
|
+
connectionSelect.addEventListener("change", syncOptionalFields);
|
|
43951
|
+
syncOptionalFields();
|
|
43238
43952
|
form.append(
|
|
43239
|
-
nameInput,
|
|
43240
|
-
accessSelect,
|
|
43241
|
-
|
|
43242
|
-
connectionSelect,
|
|
43243
|
-
grantSelect,
|
|
43244
|
-
|
|
43245
|
-
oauthInput,
|
|
43246
|
-
|
|
43953
|
+
labeledField(document2, { label: copy.name, control: nameInput }),
|
|
43954
|
+
labeledField(document2, { label: copy.access, control: accessSelect }),
|
|
43955
|
+
workspacesField,
|
|
43956
|
+
labeledField(document2, { label: copy.connection, control: connectionSelect }),
|
|
43957
|
+
labeledField(document2, { label: copy.grant, control: grantSelect }),
|
|
43958
|
+
directUrlField,
|
|
43959
|
+
labeledField(document2, { label: copy.oauthClientId, control: oauthInput }),
|
|
43960
|
+
actions
|
|
43247
43961
|
);
|
|
43248
43962
|
const tableWrap = document2.createElement("div");
|
|
43249
43963
|
tableWrap.className = "settings-enrollment-table-wrap";
|
|
@@ -43303,15 +44017,15 @@ ${detail}` : ""}`
|
|
|
43303
44017
|
grantCell.textContent = grantLabel(view.dispatchGrant, copy);
|
|
43304
44018
|
const urlCell = document2.createElement("td");
|
|
43305
44019
|
urlCell.textContent = view.mcpUrl ?? view.mcpUrlNote ?? "\u2014";
|
|
43306
|
-
const
|
|
43307
|
-
|
|
44020
|
+
const actions2 = document2.createElement("td");
|
|
44021
|
+
actions2.className = "settings-enrollment-actions";
|
|
43308
44022
|
if (view.mcpUrl) {
|
|
43309
44023
|
const copyButton = document2.createElement("button");
|
|
43310
44024
|
copyButton.type = "button";
|
|
43311
44025
|
copyButton.className = "settings-command-button settings-command-button--secondary";
|
|
43312
44026
|
copyButton.textContent = copy.copyUrl;
|
|
43313
44027
|
copyButton.addEventListener("click", () => void copyUrl(view.mcpUrl));
|
|
43314
|
-
|
|
44028
|
+
actions2.append(copyButton);
|
|
43315
44029
|
}
|
|
43316
44030
|
const full = document2.createElement("button");
|
|
43317
44031
|
full.type = "button";
|
|
@@ -43367,8 +44081,8 @@ ${detail}` : ""}`
|
|
|
43367
44081
|
}
|
|
43368
44082
|
);
|
|
43369
44083
|
});
|
|
43370
|
-
|
|
43371
|
-
row.append(nameCell, accessCell, connectionCell, grantCell, urlCell,
|
|
44084
|
+
actions2.append(full, revoke);
|
|
44085
|
+
row.append(nameCell, accessCell, connectionCell, grantCell, urlCell, actions2);
|
|
43372
44086
|
tbody.append(row);
|
|
43373
44087
|
}
|
|
43374
44088
|
};
|
|
@@ -45400,6 +46114,7 @@ ${detail}` : ""}`
|
|
|
45400
46114
|
.settings-connection-inspector {
|
|
45401
46115
|
position: sticky;
|
|
45402
46116
|
top: 18px;
|
|
46117
|
+
overflow-anchor: none;
|
|
45403
46118
|
}
|
|
45404
46119
|
|
|
45405
46120
|
.settings-connection-inspector__header {
|
|
@@ -47733,7 +48448,7 @@ ${detail}` : ""}`
|
|
|
47733
48448
|
`;
|
|
47734
48449
|
|
|
47735
48450
|
// src/settings/enrollment.css
|
|
47736
|
-
var enrollment_default = ".settings-enrollment-header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 24px;\n margin-bottom: 8px;\n}\n.settings-enrollment-copy {\n min-width: 0;\n flex: 1 1 auto;\n}\n.settings-enrollment-title {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n.settings-enrollment-header .settings-section-label {\n padding-bottom: 0;\n}\n.settings-enrollment-header .settings-page-description {\n margin: 5px 0 0;\n}\n.settings-enrollment-status {\n min-height: 1.2em;\n margin: 0 0 8px;\n color: light-dark(#676773, #a5a5af);\n font-size: 12px;\n}\n.settings-enrollment-status.is-error {\n color: light-dark(#8a3b32, #f0b4ae);\n}\n.settings-enrollment-table-wrap {\n border: 1px solid light-dark(#e2e2e8, #36363b);\n border-radius: 11px;\n overflow-x: auto;\n container-type: inline-size;\n}\n.settings-enrollment-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 12px;\n}\n.settings-enrollment-table th {\n padding: 12px 16px;\n color: light-dark(#676773, #a5a5af);\n background: light-dark(#f8f8fa, #202024);\n font-size: 11px;\n font-weight: 500;\n text-align: left;\n}\n.settings-enrollment-table th:last-child,\n.settings-enrollment-actions {\n text-align: right;\n}\n.settings-enrollment-table td {\n padding: 14px 16px;\n vertical-align: middle;\n border-top: 1px solid var(--settings-divider, light-dark(#ececf0, #2e2e33));\n}\n.settings-enrollment-executable,\n.settings-enrollment-allowlist {\n color: light-dark(#676773, #a5a5af);\n font-size: 11px;\n word-break: break-all;\n}\n.settings-enrollment-empty {\n color: light-dark(#676773, #a5a5af);\n text-align: center;\n}\n\n@container (max-width: 720px) {\n .settings-enrollment-table,\n .settings-enrollment-table tbody {\n display: block;\n }\n .settings-enrollment-table thead {\n display: none;\n }\n .settings-enrollment-row {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: 10px;\n padding: 16px;\n border-top: 1px solid var(--settings-divider, light-dark(#ececf0, #2e2e33));\n }\n .settings-enrollment-row:first-child {\n border-top: 0;\n }\n .settings-enrollment-table .settings-enrollment-row > td {\n display: block;\n padding: 0;\n border: 0;\n text-align: left;\n }\n .settings-enrollment-actions {\n text-align: left;\n }\n}\n";
|
|
48451
|
+
var enrollment_default = ".settings-enrollment-header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 24px;\n margin-bottom: 8px;\n}\n.settings-enrollment-copy {\n min-width: 0;\n flex: 1 1 auto;\n}\n.settings-enrollment-title {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n.settings-enrollment-header .settings-section-label {\n padding-bottom: 0;\n}\n.settings-enrollment-header .settings-page-description {\n margin: 5px 0 0;\n}\n.settings-enrollment-status {\n min-height: 1.2em;\n margin: 0 0 8px;\n color: light-dark(#676773, #a5a5af);\n font-size: 12px;\n}\n.settings-enrollment-status.is-error {\n color: light-dark(#8a3b32, #f0b4ae);\n}\n.settings-enrollment-table-wrap {\n border: 1px solid light-dark(#e2e2e8, #36363b);\n border-radius: 11px;\n overflow-x: auto;\n container-type: inline-size;\n}\n.settings-enrollment-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 12px;\n}\n.settings-enrollment-table th {\n padding: 12px 16px;\n color: light-dark(#676773, #a5a5af);\n background: light-dark(#f8f8fa, #202024);\n font-size: 11px;\n font-weight: 500;\n text-align: left;\n}\n.settings-enrollment-table th:last-child,\n.settings-enrollment-actions {\n text-align: right;\n}\n.settings-enrollment-table td {\n padding: 14px 16px;\n vertical-align: middle;\n border-top: 1px solid var(--settings-divider, light-dark(#ececf0, #2e2e33));\n}\n.settings-enrollment-executable,\n.settings-enrollment-allowlist {\n color: light-dark(#676773, #a5a5af);\n font-size: 11px;\n word-break: break-all;\n}\n.settings-enrollment-empty {\n color: light-dark(#676773, #a5a5af);\n text-align: center;\n}\n\n@container (max-width: 720px) {\n .settings-enrollment-table,\n .settings-enrollment-table tbody {\n display: block;\n }\n .settings-enrollment-table thead {\n display: none;\n }\n .settings-enrollment-row {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: 10px;\n padding: 16px;\n border-top: 1px solid var(--settings-divider, light-dark(#ececf0, #2e2e33));\n }\n .settings-enrollment-row:first-child {\n border-top: 0;\n }\n .settings-enrollment-table .settings-enrollment-row > td {\n display: block;\n padding: 0;\n border: 0;\n text-align: left;\n }\n .settings-enrollment-actions {\n text-align: left;\n }\n}\n\n.settings-mcp-clients-form {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 12px;\n margin: 0 0 16px;\n align-items: flex-end;\n}\n@media (max-width: 720px) {\n .settings-mcp-clients-form {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n.settings-mcp-clients-field {\n display: flex;\n flex-direction: column;\n gap: 6px;\n min-width: 0;\n}\n.settings-mcp-clients-field--wide {\n grid-column: 1 / -1;\n}\n.settings-mcp-clients-field > label {\n color: var(--settings-muted);\n font-size: 11px;\n font-weight: 500;\n}\n.settings-mcp-clients-field input,\n.settings-mcp-clients-field select,\n.settings-mcp-clients-field textarea {\n width: 100%;\n min-width: 0;\n min-height: 36px;\n padding: 6px 10px;\n color: var(--settings-text);\n background: var(--settings-bg);\n border: 1px solid var(--settings-border);\n border-radius: 6px;\n font: inherit;\n font-size: 13px;\n}\n.settings-mcp-clients-field textarea {\n min-height: 72px;\n resize: vertical;\n}\n.settings-mcp-clients-field input::placeholder,\n.settings-mcp-clients-field textarea::placeholder {\n color: var(--settings-muted);\n}\n.settings-mcp-clients-field input:focus-visible,\n.settings-mcp-clients-field select:focus-visible,\n.settings-mcp-clients-field textarea:focus-visible {\n outline: 2px solid var(--settings-focus);\n outline-offset: 2px;\n}\n.settings-mcp-clients-hint {\n margin: 0;\n color: var(--settings-muted);\n font-size: 11px;\n line-height: 16px;\n}\n.settings-mcp-clients-actions {\n display: flex;\n align-items: flex-end;\n justify-content: flex-start;\n}\n";
|
|
47737
48452
|
|
|
47738
48453
|
// src/console/components.css
|
|
47739
48454
|
var components_default = `/* Shared blocks */
|