dsh-opendesign-corouter 0.1.15 → 0.1.17
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 +7 -3
- package/lib/client-config-writes.d.ts +36 -0
- package/lib/client-context-quick.d.ts +35 -0
- package/lib/client.d.ts +29 -6
- package/lib/client.js +1042 -446
- package/lib/config.d.ts +7 -0
- package/lib/context-budget.d.ts +23 -0
- package/lib/device-auth.d.ts +1 -1
- package/lib/generated/typert.host.js +9 -1
- package/lib/generated/typert.remote-client.js +9 -1
- package/lib/index.d.ts +12 -0
- package/lib/index.js +168 -16
- package/lib/index.js.map +4 -4
- package/lib/model-catalog-snapshot.d.ts +22 -0
- package/lib/model-settings.d.ts +7 -4
- package/lib/remote.d.ts +2 -0
- package/package.json +3 -1
package/lib/client.js
CHANGED
|
@@ -40,6 +40,10 @@ __export(client_exports, {
|
|
|
40
40
|
SettingsPage: () => SettingsPage,
|
|
41
41
|
TurnMonitorView: () => TurnMonitorView,
|
|
42
42
|
apply: () => apply,
|
|
43
|
+
contextCapacityConflict: () => contextCapacityConflict,
|
|
44
|
+
contextTierAvailable: () => contextTierAvailable,
|
|
45
|
+
contextTierConflict: () => contextTierConflict,
|
|
46
|
+
contextTierWindow: () => contextTierWindow,
|
|
43
47
|
formatRefreshCountdown: () => formatRefreshCountdown,
|
|
44
48
|
formatRelativeDeadline: () => formatRelativeDeadline,
|
|
45
49
|
formatTime: () => formatTime,
|
|
@@ -57,12 +61,13 @@ __export(client_exports, {
|
|
|
57
61
|
protocolEndpoint: () => protocolEndpoint,
|
|
58
62
|
quotaAutoRefresh: () => quotaAutoRefresh,
|
|
59
63
|
quotaStatusView: () => quotaStatusView,
|
|
64
|
+
selectedContextTier: () => selectedContextTier,
|
|
60
65
|
sortModelsByEnabled: () => sortModelsByEnabled,
|
|
61
66
|
tabAfter: () => tabAfter,
|
|
62
67
|
writeModelSettings: () => writeModelSettings
|
|
63
68
|
});
|
|
64
69
|
module.exports = __toCommonJS(client_exports);
|
|
65
|
-
var
|
|
70
|
+
var React2 = __toESM(require("react"), 1);
|
|
66
71
|
|
|
67
72
|
// node_modules/zod/v4/classic/external.js
|
|
68
73
|
var external_exports = {};
|
|
@@ -19563,8 +19568,8 @@ function fromJSONSchema(schema, params) {
|
|
|
19563
19568
|
var RESOLVING = /* @__PURE__ */ Symbol("z.visit/resolving");
|
|
19564
19569
|
function visit(schema, fnOrHandlers) {
|
|
19565
19570
|
const fn = typeof fnOrHandlers === "function" ? fnOrHandlers : (node2, rewritten) => {
|
|
19566
|
-
const
|
|
19567
|
-
return
|
|
19571
|
+
const h3 = fnOrHandlers[node2._zod.def.type];
|
|
19572
|
+
return h3 ? h3(node2, rewritten) : node2;
|
|
19568
19573
|
};
|
|
19569
19574
|
const cache = /* @__PURE__ */ new Map();
|
|
19570
19575
|
function run(s) {
|
|
@@ -19977,12 +19982,27 @@ var API_PROTOCOL_OPTIONS = [
|
|
|
19977
19982
|
{ id: "messages", name: "Anthropic Messages", description: "\u4F7F\u7528 Messages \u8BF7\u6C42\u4E0E\u6D41\u5F0F\u54CD\u5E94\u3002" }
|
|
19978
19983
|
];
|
|
19979
19984
|
|
|
19985
|
+
// src/context-budget.ts
|
|
19986
|
+
var CONTEXT_WINDOW_PRESETS = [
|
|
19987
|
+
{ id: "default", label: "\u9ED8\u8BA4", tokens: 272e3 },
|
|
19988
|
+
{ id: "extended", label: "\u6269\u5C55", tokens: 5e5 },
|
|
19989
|
+
{ id: "maximum", label: "\u6700\u5927", tokens: 872e3 }
|
|
19990
|
+
];
|
|
19991
|
+
function contextWindowPreset(legacyOverride, tier) {
|
|
19992
|
+
return tier ?? (legacyOverride === void 0 ? "default" : void 0);
|
|
19993
|
+
}
|
|
19994
|
+
function effectiveContextWindow(reference, override, tier) {
|
|
19995
|
+
if (tier === void 0 && override !== void 0) return override;
|
|
19996
|
+
const requested = (CONTEXT_WINDOW_PRESETS.find((preset) => preset.id === (tier ?? "default")) ?? CONTEXT_WINDOW_PRESETS[0]).tokens;
|
|
19997
|
+
return reference === void 0 ? requested : Math.min(requested, reference);
|
|
19998
|
+
}
|
|
19999
|
+
|
|
19980
20000
|
// src/model-settings.ts
|
|
19981
20001
|
function parseModelSettingsMap(value) {
|
|
19982
20002
|
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
19983
20003
|
const keys = Object.keys(value);
|
|
19984
20004
|
if (keys.length > 512) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u6700\u591A\u5141\u8BB8 512 \u4E2A\u6A21\u578B");
|
|
19985
|
-
const fields = /* @__PURE__ */ new Set(["enabled", "imageInput", "temperature", "topP", "maxTokens", "contextWindow", "reasoningEffort"]);
|
|
20005
|
+
const fields = /* @__PURE__ */ new Set(["enabled", "imageInput", "temperature", "topP", "maxTokens", "contextWindow", "contextTier", "reasoningEffort"]);
|
|
19986
20006
|
const efforts = ["none", "minimal", "low", "medium", "high", "xhigh", "ultra", "max"];
|
|
19987
20007
|
const out = {};
|
|
19988
20008
|
for (const id of keys) {
|
|
@@ -20015,6 +20035,13 @@ function parseModelSettingsMap(value) {
|
|
|
20015
20035
|
if (typeof item !== "number" || !Number.isSafeInteger(item) || item < 1 || item > max) throw new Error(`\u6A21\u578B\u8BBE\u7F6E\u7684 ${field} \u5FC5\u987B\u662F 1 \u5230 ${max} \u4E4B\u95F4\u7684\u6574\u6570`);
|
|
20016
20036
|
parsed[field] = item;
|
|
20017
20037
|
}
|
|
20038
|
+
if (settings.contextTier !== void 0) {
|
|
20039
|
+
if (settings.contextTier !== "default" && settings.contextTier !== "extended" && settings.contextTier !== "maximum") throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 contextTier \u4E0D\u5728\u5141\u8BB8\u7684\u53D6\u503C\u5185");
|
|
20040
|
+
if (parsed.contextWindow !== void 0) throw new Error("\u4E0A\u4E0B\u6587\u6863\u4F4D\u4E0E\u65E7\u81EA\u5B9A\u4E49\u7A97\u53E3\u4E0D\u80FD\u540C\u65F6\u8BBE\u7F6E");
|
|
20041
|
+
parsed.contextTier = settings.contextTier;
|
|
20042
|
+
const window2 = parsed.contextTier === "default" ? 272e3 : parsed.contextTier === "extended" ? 5e5 : 872e3;
|
|
20043
|
+
if (parsed.maxTokens !== void 0 && parsed.maxTokens >= window2) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 maxTokens \u5FC5\u987B\u5C0F\u4E8E\u6863\u4F4D\u603B\u7A97\u53E3");
|
|
20044
|
+
}
|
|
20018
20045
|
if (settings.reasoningEffort !== void 0) {
|
|
20019
20046
|
if (typeof settings.reasoningEffort !== "string" || !efforts.includes(settings.reasoningEffort)) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 reasoningEffort \u4E0D\u5728\u5141\u8BB8\u7684\u53D6\u503C\u5185");
|
|
20020
20047
|
parsed.reasoningEffort = settings.reasoningEffort;
|
|
@@ -20215,6 +20242,7 @@ function parseStatusConfig(value) {
|
|
|
20215
20242
|
if (!ENV_REF.test(apiKeyEnv)) throw new Error("\u51ED\u636E\u5F15\u7528\u540D\u5FC5\u987B\u662F\u5408\u6CD5\u6807\u8BC6\u7B26");
|
|
20216
20243
|
return {
|
|
20217
20244
|
emptyTurnGuard: flag(value.emptyTurnGuard, "\u7A7A\u8F6E\u4FDD\u62A4\u5F00\u5173"),
|
|
20245
|
+
...value.turnCompletionReview === void 0 ? {} : { turnCompletionReview: flag(value.turnCompletionReview, "\u7ED3\u675F\u56DE\u5408\u6838\u9A8C\u5F00\u5173") },
|
|
20218
20246
|
useDesktopCredential: flag(value.useDesktopCredential, "\u684C\u9762\u767B\u5F55\u6001\u5F00\u5173"),
|
|
20219
20247
|
baseURL: text(value.baseURL, "\u63A8\u7406\u5730\u5740", MAX_BASE_URL),
|
|
20220
20248
|
apiKeyEnv,
|
|
@@ -20352,8 +20380,446 @@ function claudeOutputError(model, protocol, maxTokens) {
|
|
|
20352
20380
|
return hasRestrictedClaudeSampling(model, protocol) && maxTokens !== void 0 && maxTokens > CLAUDE_MESSAGES_MAX_OUTPUT ? "\u6B64 Claude \u6A21\u578B\u7684 Messages \u6700\u5927\u8F93\u51FA\u4E3A 128000\uFF0C\u8BF7\u51CF\u5C0F\u8F93\u51FA\u4E0A\u9650\u3002" : void 0;
|
|
20353
20381
|
}
|
|
20354
20382
|
|
|
20355
|
-
// src/client.ts
|
|
20383
|
+
// src/client-config-writes.ts
|
|
20384
|
+
var COORDINATORS = /* @__PURE__ */ new WeakMap();
|
|
20385
|
+
function configWritesFor(form) {
|
|
20386
|
+
const existing = COORDINATORS.get(form);
|
|
20387
|
+
if (existing) return existing;
|
|
20388
|
+
const created = new ConfigWritesImpl(form);
|
|
20389
|
+
COORDINATORS.set(form, created);
|
|
20390
|
+
return created;
|
|
20391
|
+
}
|
|
20392
|
+
var ConfigWritesImpl = class {
|
|
20393
|
+
form;
|
|
20394
|
+
listeners = /* @__PURE__ */ new Set();
|
|
20395
|
+
/** Fields with a queued or running write, in call order. */
|
|
20396
|
+
inflight = /* @__PURE__ */ new Map();
|
|
20397
|
+
/** Values of the writes in flight, projected for the UI until the write is done. */
|
|
20398
|
+
overlay = /* @__PURE__ */ new Map();
|
|
20399
|
+
queue = [];
|
|
20400
|
+
running = false;
|
|
20401
|
+
disposed = false;
|
|
20402
|
+
snapshot = { pendingFields: [], pendingValues: {} };
|
|
20403
|
+
constructor(form) {
|
|
20404
|
+
this.form = form;
|
|
20405
|
+
}
|
|
20406
|
+
getSnapshot() {
|
|
20407
|
+
return this.snapshot;
|
|
20408
|
+
}
|
|
20409
|
+
subscribe(listener) {
|
|
20410
|
+
if (this.disposed) return () => {
|
|
20411
|
+
};
|
|
20412
|
+
this.listeners.add(listener);
|
|
20413
|
+
return () => {
|
|
20414
|
+
this.listeners.delete(listener);
|
|
20415
|
+
};
|
|
20416
|
+
}
|
|
20417
|
+
async set(field, value, baseValue) {
|
|
20418
|
+
if (this.disposed) return false;
|
|
20419
|
+
const current = this.form.getSnapshot();
|
|
20420
|
+
if (!writableSnapshot(current)) return false;
|
|
20421
|
+
if (this.inflight.has(field)) return false;
|
|
20422
|
+
const baseline = baseValue !== void 0 ? baseValue : readField(current.value, field);
|
|
20423
|
+
const task = { field, value, baseline, resolve: () => {
|
|
20424
|
+
} };
|
|
20425
|
+
const accepted = new Promise((resolve) => {
|
|
20426
|
+
task.resolve = resolve;
|
|
20427
|
+
});
|
|
20428
|
+
this.inflight.set(field, task);
|
|
20429
|
+
this.overlay.set(field, value);
|
|
20430
|
+
this.publish();
|
|
20431
|
+
this.queue.push(task);
|
|
20432
|
+
this.drain();
|
|
20433
|
+
return accepted;
|
|
20434
|
+
}
|
|
20435
|
+
dispose() {
|
|
20436
|
+
if (this.disposed) return;
|
|
20437
|
+
this.disposed = true;
|
|
20438
|
+
const queued = this.queue.splice(0, this.queue.length);
|
|
20439
|
+
for (const task of queued) {
|
|
20440
|
+
this.inflight.delete(task.field);
|
|
20441
|
+
this.overlay.delete(task.field);
|
|
20442
|
+
task.resolve(false);
|
|
20443
|
+
}
|
|
20444
|
+
this.listeners.clear();
|
|
20445
|
+
this.inflight.clear();
|
|
20446
|
+
this.overlay.clear();
|
|
20447
|
+
this.snapshot = { pendingFields: [], pendingValues: {} };
|
|
20448
|
+
COORDINATORS.delete(this.form);
|
|
20449
|
+
}
|
|
20450
|
+
drain() {
|
|
20451
|
+
if (this.running) return;
|
|
20452
|
+
this.running = true;
|
|
20453
|
+
void this.runQueue();
|
|
20454
|
+
}
|
|
20455
|
+
async runQueue() {
|
|
20456
|
+
try {
|
|
20457
|
+
while (!this.disposed) {
|
|
20458
|
+
const task = this.queue.shift();
|
|
20459
|
+
if (!task) break;
|
|
20460
|
+
const accepted = await this.execute(task);
|
|
20461
|
+
this.finish(task, accepted);
|
|
20462
|
+
}
|
|
20463
|
+
} finally {
|
|
20464
|
+
this.running = false;
|
|
20465
|
+
if (!this.disposed && this.queue.length > 0) this.drain();
|
|
20466
|
+
}
|
|
20467
|
+
}
|
|
20468
|
+
async execute(task) {
|
|
20469
|
+
if (this.disposed) return false;
|
|
20470
|
+
const current = this.form.getSnapshot();
|
|
20471
|
+
if (!writableSnapshot(current)) return false;
|
|
20472
|
+
let payload = task.value;
|
|
20473
|
+
if (task.field === "modelSettings") {
|
|
20474
|
+
const rebased = rebaseModelSettings(task.baseline, task.value, readField(current.value, "modelSettings"));
|
|
20475
|
+
payload = rebased;
|
|
20476
|
+
if (!this.disposed) {
|
|
20477
|
+
this.overlay.set(task.field, rebased);
|
|
20478
|
+
this.publish();
|
|
20479
|
+
}
|
|
20480
|
+
}
|
|
20481
|
+
try {
|
|
20482
|
+
const accepted = await this.form.set(task.field, payload);
|
|
20483
|
+
return accepted === true;
|
|
20484
|
+
} catch {
|
|
20485
|
+
return false;
|
|
20486
|
+
}
|
|
20487
|
+
}
|
|
20488
|
+
finish(task, accepted) {
|
|
20489
|
+
this.inflight.delete(task.field);
|
|
20490
|
+
this.overlay.delete(task.field);
|
|
20491
|
+
if (!this.disposed) this.publish();
|
|
20492
|
+
task.resolve(accepted);
|
|
20493
|
+
}
|
|
20494
|
+
publish() {
|
|
20495
|
+
this.snapshot = {
|
|
20496
|
+
pendingFields: [...this.inflight.keys()],
|
|
20497
|
+
pendingValues: buildValues(this.overlay)
|
|
20498
|
+
};
|
|
20499
|
+
for (const listener of [...this.listeners]) listener();
|
|
20500
|
+
}
|
|
20501
|
+
};
|
|
20502
|
+
function writableSnapshot(snapshot) {
|
|
20503
|
+
return snapshot.status === "ready" && snapshot.value !== void 0 && snapshot.writable;
|
|
20504
|
+
}
|
|
20505
|
+
function readField(values, field) {
|
|
20506
|
+
if (!values) return void 0;
|
|
20507
|
+
return values[field];
|
|
20508
|
+
}
|
|
20509
|
+
function buildValues(overlay) {
|
|
20510
|
+
return Object.fromEntries(overlay);
|
|
20511
|
+
}
|
|
20512
|
+
function toSettingsMap(value) {
|
|
20513
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
|
|
20514
|
+
const out = {};
|
|
20515
|
+
for (const [id, entry] of Object.entries(value)) {
|
|
20516
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) continue;
|
|
20517
|
+
const fields = {};
|
|
20518
|
+
for (const [key, field] of Object.entries(entry)) fields[key] = field;
|
|
20519
|
+
out[id] = fields;
|
|
20520
|
+
}
|
|
20521
|
+
return out;
|
|
20522
|
+
}
|
|
20523
|
+
function diffModelSettings(base, next) {
|
|
20524
|
+
const changes = [];
|
|
20525
|
+
const ids = /* @__PURE__ */ new Set([...Object.keys(base), ...Object.keys(next)]);
|
|
20526
|
+
for (const id of ids) {
|
|
20527
|
+
const baseEntry = base[id] ?? {};
|
|
20528
|
+
const nextEntry = next[id] ?? {};
|
|
20529
|
+
const fields = /* @__PURE__ */ new Set([...Object.keys(baseEntry), ...Object.keys(nextEntry)]);
|
|
20530
|
+
for (const field of fields) {
|
|
20531
|
+
const had = Object.prototype.hasOwnProperty.call(baseEntry, field);
|
|
20532
|
+
const has = Object.prototype.hasOwnProperty.call(nextEntry, field);
|
|
20533
|
+
if (had && has) {
|
|
20534
|
+
if (sameValue(baseEntry[field], nextEntry[field])) continue;
|
|
20535
|
+
changes.push({ id, field, value: nextEntry[field], remove: false });
|
|
20536
|
+
} else if (had) {
|
|
20537
|
+
changes.push({ id, field, value: void 0, remove: true });
|
|
20538
|
+
} else {
|
|
20539
|
+
changes.push({ id, field, value: nextEntry[field], remove: false });
|
|
20540
|
+
}
|
|
20541
|
+
}
|
|
20542
|
+
}
|
|
20543
|
+
return changes;
|
|
20544
|
+
}
|
|
20545
|
+
function applyModelSettings(latest, changes) {
|
|
20546
|
+
const out = {};
|
|
20547
|
+
for (const [id, entry] of Object.entries(latest)) out[id] = { ...entry };
|
|
20548
|
+
for (const change of changes) {
|
|
20549
|
+
const entry = out[change.id] ?? {};
|
|
20550
|
+
if (change.remove || change.value === void 0) delete entry[change.field];
|
|
20551
|
+
else entry[change.field] = change.value;
|
|
20552
|
+
out[change.id] = entry;
|
|
20553
|
+
}
|
|
20554
|
+
for (const id of Object.keys(out)) {
|
|
20555
|
+
if (Object.keys(out[id] ?? {}).length === 0) delete out[id];
|
|
20556
|
+
}
|
|
20557
|
+
return out;
|
|
20558
|
+
}
|
|
20559
|
+
function rebaseModelSettings(baseline, desired, latest) {
|
|
20560
|
+
const changes = diffModelSettings(toSettingsMap(baseline), toSettingsMap(desired));
|
|
20561
|
+
return applyModelSettings(toSettingsMap(latest), changes);
|
|
20562
|
+
}
|
|
20563
|
+
function sameValue(left, right) {
|
|
20564
|
+
if (Object.is(left, right)) return true;
|
|
20565
|
+
if (left === null || right === null) return false;
|
|
20566
|
+
if (typeof left !== "object" || typeof right !== "object") return false;
|
|
20567
|
+
if (Array.isArray(left) !== Array.isArray(right)) return false;
|
|
20568
|
+
if (Array.isArray(left) && Array.isArray(right)) {
|
|
20569
|
+
if (left.length !== right.length) return false;
|
|
20570
|
+
return left.every((item, index) => sameValue(item, right[index]));
|
|
20571
|
+
}
|
|
20572
|
+
const leftEntries = Object.entries(left);
|
|
20573
|
+
const rightEntries = Object.entries(right);
|
|
20574
|
+
if (leftEntries.length !== rightEntries.length) return false;
|
|
20575
|
+
for (const [key, value] of leftEntries) {
|
|
20576
|
+
if (!Object.prototype.hasOwnProperty.call(right, key)) return false;
|
|
20577
|
+
if (!sameValue(value, right[key])) return false;
|
|
20578
|
+
}
|
|
20579
|
+
return true;
|
|
20580
|
+
}
|
|
20581
|
+
|
|
20582
|
+
// src/client-context-quick.ts
|
|
20583
|
+
var React = __toESM(require("react"), 1);
|
|
20356
20584
|
var h = React.createElement;
|
|
20585
|
+
var EMPTY_GROUPS = [];
|
|
20586
|
+
function isCoRouterProvider(provider) {
|
|
20587
|
+
return provider === "opendesign-corouter-plan" || provider === "opendesign-corouter-paid";
|
|
20588
|
+
}
|
|
20589
|
+
function quickWindowLabel(tokens) {
|
|
20590
|
+
return tokens % 1e3 === 0 ? `${tokens / 1e3}K` : tokens.toLocaleString("en-US");
|
|
20591
|
+
}
|
|
20592
|
+
var QUICK_CONTEXT_CSS = `
|
|
20593
|
+
.odc-quick{display:inline-flex;color:var(--dsw-alias-label-primary,CanvasText);font:12px/1.5 system-ui,sans-serif}
|
|
20594
|
+
.odc-quick-trigger{display:inline-flex;align-items:center;gap:4px;min-height:30px;padding:3px 7px;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary,CanvasText);font:inherit;font-variant-numeric:tabular-nums;cursor:pointer}
|
|
20595
|
+
.odc-quick-trigger:hover,.odc-quick-trigger[aria-expanded=true]{background:var(--dsw-alias-bg-layer-2,Canvas);color:var(--dsw-alias-label-primary,CanvasText)}
|
|
20596
|
+
/* Off-viewport until the first position() call: a popover that paints at the static
|
|
20597
|
+
position would sit at the top-left corner and swallow outside clicks. */
|
|
20598
|
+
.odc-quick-panel{position:fixed;inset:auto;left:-9999px;top:-9999px;margin:0;box-sizing:border-box;width:min(320px,calc(100vw - 24px));max-height:calc(100dvh - 24px);overflow:auto;padding:14px;border:1px solid var(--dsw-alias-border-l3,CanvasText);border-radius:10px;background:var(--dsw-alias-bg-layer-1,Canvas);color:var(--dsw-alias-label-primary,CanvasText);box-shadow:var(--dsw-shadow-lv2,0 4px 20px #0002);font:12px/1.6 system-ui,sans-serif;color-scheme:light}
|
|
20599
|
+
body[data-ds-dark-theme] .odc-quick-panel{color-scheme:dark}
|
|
20600
|
+
.odc-quick-panel:popover-open{display:grid;grid-template-columns:minmax(0,1fr);gap:8px}.odc-quick-panel h3,.odc-quick-panel p{margin:0;min-width:0}.odc-quick-panel h3{font-size:14px}.odc-quick-panel small{font-size:12px;min-width:0;overflow-wrap:anywhere;color:var(--dsw-alias-label-secondary,CanvasText)}
|
|
20601
|
+
.odc-quick-options{display:grid;gap:6px;margin:0;padding:0;border:0;min-width:0}.odc-quick-options legend{margin-bottom:4px}.odc-quick-option{display:flex;align-items:center;gap:8px;min-height:38px;min-width:0;padding:6px 8px;border:1px solid var(--dsw-alias-border-l3,CanvasText);border-radius:7px;cursor:pointer}.odc-quick-option:has(input:checked){border-color:var(--dsw-alias-brand-primary,Highlight)}.odc-quick-option:has(input:disabled){cursor:not-allowed;opacity:.65}.odc-quick-option input{accent-color:var(--dsw-alias-brand-primary,Highlight);flex:none}.odc-quick-option span{display:grid;min-width:0;overflow-wrap:anywhere}
|
|
20602
|
+
.odc-quick-error{color:var(--dsw-alias-state-error-primary,CanvasText);color:color-mix(in srgb,var(--dsw-alias-state-error-primary,CanvasText) 85%,var(--dsw-alias-label-primary,CanvasText))}.odc-quick :focus-visible{outline:2px solid var(--dsw-alias-brand-primary,Highlight);outline-offset:2px}
|
|
20603
|
+
@media(forced-colors:active){.odc-quick-trigger,.odc-quick-option,.odc-quick-panel{border-color:ButtonText}.odc-quick-option:has(input:checked){border-color:Highlight}.odc-quick-option input{forced-color-adjust:auto}}
|
|
20604
|
+
`;
|
|
20605
|
+
function ContextQuickSwitch({ directory, form, caller }) {
|
|
20606
|
+
const snapshot = React.useSyncExternalStore(
|
|
20607
|
+
React.useCallback((listener) => directory.subscribe(listener), [directory]),
|
|
20608
|
+
React.useCallback(() => directory.getSnapshot(), [directory]),
|
|
20609
|
+
React.useCallback(() => directory.getSnapshot(), [directory])
|
|
20610
|
+
);
|
|
20611
|
+
const current = snapshot.current;
|
|
20612
|
+
if (current === null || !isCoRouterProvider(current.provider)) return null;
|
|
20613
|
+
return h(ContextQuickControl, {
|
|
20614
|
+
key: `${current.provider}/${current.model}`,
|
|
20615
|
+
provider: current.provider,
|
|
20616
|
+
modelId: current.model,
|
|
20617
|
+
selecting: snapshot.pending !== null || snapshot.status === "selecting",
|
|
20618
|
+
directoryUnavailable: snapshot.status !== "ready",
|
|
20619
|
+
catalog: snapshot.groups.length === 0 ? EMPTY_GROUPS : snapshot.groups,
|
|
20620
|
+
form,
|
|
20621
|
+
caller
|
|
20622
|
+
});
|
|
20623
|
+
}
|
|
20624
|
+
function ContextQuickControl({ provider, modelId, selecting, directoryUnavailable, catalog, form, caller }) {
|
|
20625
|
+
const writes = React.useMemo(() => configWritesFor(form), [form]);
|
|
20626
|
+
const writeState = React.useSyncExternalStore(
|
|
20627
|
+
React.useCallback((listener) => writes.subscribe(listener), [writes]),
|
|
20628
|
+
React.useCallback(() => writes.getSnapshot(), [writes]),
|
|
20629
|
+
React.useCallback(() => writes.getSnapshot(), [writes])
|
|
20630
|
+
);
|
|
20631
|
+
const formState = React.useSyncExternalStore(
|
|
20632
|
+
React.useCallback((listener) => form.subscribe(listener), [form]),
|
|
20633
|
+
React.useCallback(() => form.getSnapshot(), [form]),
|
|
20634
|
+
React.useCallback(() => form.getSnapshot(), [form])
|
|
20635
|
+
);
|
|
20636
|
+
const [status, setStatus] = React.useState();
|
|
20637
|
+
const [loading, setLoading] = React.useState(true);
|
|
20638
|
+
const [loadError, setLoadError] = React.useState(false);
|
|
20639
|
+
const [error62, setError] = React.useState();
|
|
20640
|
+
const [notice, setNotice] = React.useState();
|
|
20641
|
+
const [open2, setOpen] = React.useState(false);
|
|
20642
|
+
const popup = React.useRef(null);
|
|
20643
|
+
const button = React.useRef(null);
|
|
20644
|
+
const alive = React.useRef(true);
|
|
20645
|
+
const generation = React.useRef(0);
|
|
20646
|
+
const popupId = React.useId();
|
|
20647
|
+
React.useEffect(() => {
|
|
20648
|
+
alive.current = true;
|
|
20649
|
+
return () => {
|
|
20650
|
+
alive.current = false;
|
|
20651
|
+
generation.current++;
|
|
20652
|
+
};
|
|
20653
|
+
}, []);
|
|
20654
|
+
const loadStatus = React.useCallback(async () => {
|
|
20655
|
+
const version2 = ++generation.current;
|
|
20656
|
+
setLoading(true);
|
|
20657
|
+
setLoadError(false);
|
|
20658
|
+
try {
|
|
20659
|
+
const next = await caller("status");
|
|
20660
|
+
if (alive.current && version2 === generation.current) setStatus(next);
|
|
20661
|
+
} catch {
|
|
20662
|
+
if (alive.current && version2 === generation.current) setLoadError(true);
|
|
20663
|
+
} finally {
|
|
20664
|
+
if (alive.current && version2 === generation.current) setLoading(false);
|
|
20665
|
+
}
|
|
20666
|
+
}, [caller]);
|
|
20667
|
+
React.useEffect(() => {
|
|
20668
|
+
void loadStatus();
|
|
20669
|
+
}, [loadStatus, catalog]);
|
|
20670
|
+
const position = React.useCallback(() => {
|
|
20671
|
+
const panel = popup.current, anchor2 = button.current;
|
|
20672
|
+
if (!panel || !anchor2 || !panel.matches(":popover-open")) return;
|
|
20673
|
+
const rect = anchor2.getBoundingClientRect();
|
|
20674
|
+
const width = panel.offsetWidth, height = panel.offsetHeight;
|
|
20675
|
+
panel.style.left = `${Math.max(12, Math.min(rect.right - width, window.innerWidth - width - 12))}px`;
|
|
20676
|
+
panel.style.top = `${Math.max(12, Math.min(rect.top - height - 8 >= 12 ? rect.top - height - 8 : rect.bottom + 8, window.innerHeight - height - 12))}px`;
|
|
20677
|
+
}, []);
|
|
20678
|
+
React.useEffect(() => {
|
|
20679
|
+
const panel = popup.current;
|
|
20680
|
+
if (!panel) return;
|
|
20681
|
+
button.current?.setAttribute("popovertarget", popupId);
|
|
20682
|
+
button.current?.setAttribute("popovertargetaction", "toggle");
|
|
20683
|
+
const toggle = () => {
|
|
20684
|
+
const shown = panel.matches(":popover-open");
|
|
20685
|
+
setOpen(shown);
|
|
20686
|
+
if (shown) {
|
|
20687
|
+
position();
|
|
20688
|
+
panel.querySelector("input:checked:not(:disabled),input:not(:disabled)")?.focus();
|
|
20689
|
+
}
|
|
20690
|
+
};
|
|
20691
|
+
panel.addEventListener("toggle", toggle);
|
|
20692
|
+
return () => {
|
|
20693
|
+
panel.removeEventListener("toggle", toggle);
|
|
20694
|
+
};
|
|
20695
|
+
}, [position, popupId]);
|
|
20696
|
+
React.useEffect(() => {
|
|
20697
|
+
if (!open2) return;
|
|
20698
|
+
const escape = (event) => {
|
|
20699
|
+
if (event.key !== "Escape") return;
|
|
20700
|
+
event.preventDefault();
|
|
20701
|
+
event.stopPropagation();
|
|
20702
|
+
popup.current?.hidePopover();
|
|
20703
|
+
button.current?.focus();
|
|
20704
|
+
};
|
|
20705
|
+
document.addEventListener("keydown", escape, true);
|
|
20706
|
+
window.addEventListener("resize", position);
|
|
20707
|
+
window.addEventListener("scroll", position, true);
|
|
20708
|
+
return () => {
|
|
20709
|
+
document.removeEventListener("keydown", escape, true);
|
|
20710
|
+
window.removeEventListener("resize", position);
|
|
20711
|
+
window.removeEventListener("scroll", position, true);
|
|
20712
|
+
};
|
|
20713
|
+
}, [open2, position]);
|
|
20714
|
+
const values = { ...formState.value ?? status?.config, ...writeState.pendingValues };
|
|
20715
|
+
const settingsMap = values.modelSettings ?? {};
|
|
20716
|
+
const settings = settingsMap[modelId] ?? {};
|
|
20717
|
+
const row = status?.models.find((model) => model.id === modelId && model.group === (provider === "opendesign-corouter-plan" ? "plan" : "paid"));
|
|
20718
|
+
const tier = contextWindowPreset(settings.contextWindow, settings.contextTier);
|
|
20719
|
+
const windowSize = effectiveContextWindow(row?.contextWindow, settings.contextWindow, settings.contextTier);
|
|
20720
|
+
const pending = writeState.pendingFields.includes("modelSettings");
|
|
20721
|
+
const reason = selecting ? "\u6B63\u5728\u5207\u6362\u6A21\u578B\uFF0C\u8BF7\u7A0D\u5019\u3002" : directoryUnavailable ? "\u4F1A\u8BDD\u6A21\u578B\u76EE\u5F55\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002" : formState.status === "unavailable" ? "\u6A21\u578B\u8BBE\u7F6E\u6682\u4E0D\u53EF\u7528\u3002" : formState.status !== "ready" || formState.value === void 0 ? "\u6B63\u5728\u8F7D\u5165\u6A21\u578B\u8BBE\u7F6E\u3002" : !formState.writable ? "\u5F53\u524D\u8BBE\u7F6E\u4E3A\u53EA\u8BFB\u3002" : pending ? "\u6B63\u5728\u4FDD\u5B58\u6A21\u578B\u8BBE\u7F6E\u2026" : loading ? "\u6B63\u5728\u8BFB\u53D6\u6A21\u578B\u53C2\u8003\u5BB9\u91CF\u2026" : loadError ? "\u6A21\u578B\u4FE1\u606F\u8BFB\u53D6\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002" : row === void 0 ? "\u5F53\u524D\u6A21\u578B\u4E0D\u5728 CoRouter \u76EE\u5F55\u4E2D\u3002" : void 0;
|
|
20722
|
+
React.useEffect(() => {
|
|
20723
|
+
if (open2) position();
|
|
20724
|
+
}, [open2, status, loading, error62, notice, reason, position]);
|
|
20725
|
+
React.useEffect(() => {
|
|
20726
|
+
if (open2 && reason === void 0 && document.activeElement === button.current) {
|
|
20727
|
+
popup.current?.querySelector("input:checked:not(:disabled),input:not(:disabled)")?.focus();
|
|
20728
|
+
}
|
|
20729
|
+
}, [open2, reason]);
|
|
20730
|
+
const wasPending = React.useRef(false);
|
|
20731
|
+
React.useEffect(() => {
|
|
20732
|
+
if (wasPending.current && !pending && open2) popup.current?.querySelector("input:checked:not(:disabled)")?.focus();
|
|
20733
|
+
wasPending.current = pending;
|
|
20734
|
+
}, [pending, open2]);
|
|
20735
|
+
const choose = async (nextTier) => {
|
|
20736
|
+
if (reason !== void 0 || row === void 0) return;
|
|
20737
|
+
const candidate = { ...settings };
|
|
20738
|
+
delete candidate.contextWindow;
|
|
20739
|
+
if (nextTier === "default") delete candidate.contextTier;
|
|
20740
|
+
else candidate.contextTier = nextTier;
|
|
20741
|
+
const capacity = effectiveContextWindow(row.contextWindow, void 0, nextTier);
|
|
20742
|
+
if (candidate.maxTokens !== void 0 && candidate.maxTokens >= capacity) {
|
|
20743
|
+
setError(`\u6700\u5927\u8F93\u51FA ${candidate.maxTokens.toLocaleString("en-US")} \u4E0D\u5C0F\u4E8E\u6240\u9009\u603B\u7A97\u53E3 ${capacity.toLocaleString("en-US")}\uFF1B\u8BF7\u5148\u5728\u8BBE\u7F6E\u9875\u6E05\u7A7A\u6216\u51CF\u5C0F\u6700\u5927\u8F93\u51FA\u3002`);
|
|
20744
|
+
return;
|
|
20745
|
+
}
|
|
20746
|
+
setError(void 0);
|
|
20747
|
+
setNotice(void 0);
|
|
20748
|
+
const nextMap = { ...settingsMap, [modelId]: candidate };
|
|
20749
|
+
if (Object.keys(candidate).length === 0) delete nextMap[modelId];
|
|
20750
|
+
const saved = await writes.set("modelSettings", nextMap, settingsMap);
|
|
20751
|
+
if (!alive.current) return;
|
|
20752
|
+
if (saved) setNotice("\u4E0A\u4E0B\u6587\u6863\u4F4D\u5DF2\u4FDD\u5B58\u3002");
|
|
20753
|
+
else setError("\u8BBE\u7F6E\u672A\u4FDD\u5B58\uFF0C\u5DF2\u6062\u590D\u539F\u503C\uFF0C\u8BF7\u91CD\u8BD5\u3002");
|
|
20754
|
+
};
|
|
20755
|
+
const show = () => {
|
|
20756
|
+
const panel = popup.current;
|
|
20757
|
+
if (!panel) return;
|
|
20758
|
+
if (panel.matches(":popover-open")) {
|
|
20759
|
+
panel.hidePopover();
|
|
20760
|
+
return;
|
|
20761
|
+
}
|
|
20762
|
+
panel.showPopover();
|
|
20763
|
+
position();
|
|
20764
|
+
if (!loading) void loadStatus();
|
|
20765
|
+
};
|
|
20766
|
+
const label = row === void 0 ? "\u4E0A\u4E0B\u6587\u2026" : `${tier === void 0 ? "\u81EA\u5B9A\u4E49 " : ""}${quickWindowLabel(windowSize)}`;
|
|
20767
|
+
return h(
|
|
20768
|
+
"div",
|
|
20769
|
+
{ className: "odc-quick" },
|
|
20770
|
+
h("button", {
|
|
20771
|
+
ref: button,
|
|
20772
|
+
className: "odc-quick-trigger",
|
|
20773
|
+
type: "button",
|
|
20774
|
+
"aria-label": `CoRouter \u4E0A\u4E0B\u6587\uFF1A${label}`,
|
|
20775
|
+
"aria-haspopup": "dialog",
|
|
20776
|
+
"aria-expanded": open2,
|
|
20777
|
+
"aria-controls": popupId,
|
|
20778
|
+
title: `\u4E0A\u4E0B\u6587\u603B\u7A97\u53E3\uFF08\u542B\u8F93\u51FA\u9884\u7559\uFF09\u3002\u4FEE\u6539 ${modelId} \u7684\u9ED8\u8BA4\u503C\uFF0C\u5176\u4ED6\u4F1A\u8BDD\u540C\u6B65\u3002`,
|
|
20779
|
+
onClick: () => {
|
|
20780
|
+
if (!popup.current?.matches(":popover-open") && !loading) void loadStatus();
|
|
20781
|
+
},
|
|
20782
|
+
onKeyDown: (event) => {
|
|
20783
|
+
if (event.key !== "ArrowDown") return;
|
|
20784
|
+
event.preventDefault();
|
|
20785
|
+
if (!popup.current?.matches(":popover-open")) show();
|
|
20786
|
+
else popup.current.querySelector("input:checked:not(:disabled),input:not(:disabled)")?.focus();
|
|
20787
|
+
}
|
|
20788
|
+
}, label, h("span", { "aria-hidden": true }, " \u25BE")),
|
|
20789
|
+
h(
|
|
20790
|
+
"div",
|
|
20791
|
+
{ id: popupId, ref: popup, popover: "auto", className: "odc-quick-panel", role: "dialog", "aria-labelledby": `${popupId}-title` },
|
|
20792
|
+
h("h3", { id: `${popupId}-title` }, "\u4E0A\u4E0B\u6587\u7A97\u53E3"),
|
|
20793
|
+
h("small", null, modelId),
|
|
20794
|
+
h("p", null, "\u4FEE\u6539\u6B64\u6A21\u578B\u7684\u9ED8\u8BA4\u503C\uFF0C\u5176\u4ED6\u4F1A\u8BDD\u540C\u6B65\u3002"),
|
|
20795
|
+
h(
|
|
20796
|
+
"fieldset",
|
|
20797
|
+
{ className: "odc-quick-options", "aria-describedby": `${popupId}-reason` },
|
|
20798
|
+
h("legend", null, "\u4E0A\u4E0B\u6587\u6863\u4F4D"),
|
|
20799
|
+
CONTEXT_WINDOW_PRESETS.map((preset) => {
|
|
20800
|
+
const available = preset.id === "default" || row?.contextWindow === void 0 || preset.tokens <= row.contextWindow;
|
|
20801
|
+
return h(
|
|
20802
|
+
"label",
|
|
20803
|
+
{ className: "odc-quick-option", key: preset.id },
|
|
20804
|
+
h("input", { type: "radio", name: popupId, checked: tier === preset.id, disabled: reason !== void 0 || !available, "aria-describedby": `${popupId}-reason`, onChange: () => {
|
|
20805
|
+
void choose(preset.id);
|
|
20806
|
+
} }),
|
|
20807
|
+
h("span", null, `${preset.label} ${quickWindowLabel(preset.tokens)}`, !available ? h("small", null, `\u8D85\u8FC7\u53C2\u8003\u5BB9\u91CF ${row?.contextWindow?.toLocaleString("en-US")}`) : null)
|
|
20808
|
+
);
|
|
20809
|
+
})
|
|
20810
|
+
),
|
|
20811
|
+
h("p", { id: `${popupId}-reason`, role: "status" }, reason ?? `\u5F53\u524D\u603B\u7A97\u53E3 ${windowSize.toLocaleString("en-US")} tokens\uFF08\u542B\u8F93\u51FA\u9884\u7559\uFF09\u3002${tier === void 0 ? "\u65E7\u81EA\u5B9A\u4E49\u503C\u6309\u539F\u503C\u4FDD\u7559\uFF0C\u9009\u62E9\u6863\u4F4D\u53EF\u66FF\u6362\u3002" : ""}`),
|
|
20812
|
+
loadError ? h("button", { type: "button", className: "odc-button", onClick: () => {
|
|
20813
|
+
void loadStatus();
|
|
20814
|
+
} }, "\u91CD\u8BD5\u8BFB\u53D6\u6A21\u578B\u4FE1\u606F") : null,
|
|
20815
|
+
error62 === void 0 ? null : h("p", { className: "odc-quick-error", role: "alert" }, error62),
|
|
20816
|
+
notice === void 0 ? null : h("p", { role: "status" }, notice)
|
|
20817
|
+
)
|
|
20818
|
+
);
|
|
20819
|
+
}
|
|
20820
|
+
|
|
20821
|
+
// src/client.ts
|
|
20822
|
+
var h2 = React2.createElement;
|
|
20357
20823
|
var SETTINGS_NS = "llm-opendesign-corouter";
|
|
20358
20824
|
var OFFICIAL_SITE = "https://corouter.open-design.ai/zh/";
|
|
20359
20825
|
var TABS = [
|
|
@@ -20379,7 +20845,6 @@ var MIN_TURN_REVIEW_NO_PROGRESS_LIMIT = 1;
|
|
|
20379
20845
|
var MAX_TURN_REVIEW_NO_PROGRESS_LIMIT = 5;
|
|
20380
20846
|
var RPC_TIMEOUT_MS = 3e4;
|
|
20381
20847
|
var MAX_OUTPUT_TOKENS = 1e7;
|
|
20382
|
-
var MAX_CONTEXT_WINDOW = 1e8;
|
|
20383
20848
|
var GENERIC_ERROR = "\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002";
|
|
20384
20849
|
var LOGIN_LABELS = {
|
|
20385
20850
|
idle: "\u5C1A\u672A\u5F00\u59CB\u72EC\u7ACB\u767B\u5F55",
|
|
@@ -20443,6 +20908,7 @@ function installStyles() {
|
|
|
20443
20908
|
.odc-notice{padding:9px 11px;border-radius:8px;background:var(--dsw-alias-bg-layer-2,transparent);font-size:12px;line-height:1.6}.odc-notice[data-kind=error]{color:var(--dsw-alias-state-error-primary,inherit);color:color-mix(in srgb,var(--dsw-alias-state-error-primary,CanvasText) 85%,var(--dsw-alias-label-primary,CanvasText))}
|
|
20444
20909
|
.odc-model-groups{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:12px}.odc-model-list{display:grid;gap:6px;margin:10px 0 0;padding:0;list-style:none}.odc-model-item{padding:9px 10px;border-radius:8px;background:var(--dsw-alias-bg-layer-2,transparent);min-width:0}.odc-model-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;flex-wrap:wrap}.odc-model-switch{min-width:0;flex:1 1 190px}.odc-model-item strong,.odc-model-item code{display:block;overflow-wrap:anywhere}.odc-model-item strong{font-size:12px;font-weight:600}.odc-model-item code{margin-top:2px;color:var(--dsw-alias-label-secondary,inherit);font-size:11px}.odc-model-meta{margin-top:6px!important;color:var(--dsw-alias-label-secondary,inherit);font-size:11px;overflow-wrap:anywhere}.odc-model-count{color:var(--dsw-alias-label-secondary,inherit);font-size:11px;font-weight:400}.odc-chip{display:inline-flex;align-items:center;padding:1px 7px;border:1px solid var(--dsw-alias-border-l3,transparent);border-radius:999px;color:var(--dsw-alias-label-secondary,inherit);font-size:10px;line-height:1.6}
|
|
20445
20910
|
.odc-model-details{margin-top:8px}.odc-model-details>summary{cursor:pointer;color:var(--dsw-alias-label-secondary,inherit);font-size:11px;line-height:1.7}.odc-model-editor{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:2px 10px;margin-top:8px}
|
|
20911
|
+
.odc-context{grid-column:1/-1;min-width:0;margin:0 0 4px;padding:10px 12px;border:1px solid var(--dsw-alias-border-l4,transparent);border-radius:10px}.odc-context-legend{padding:0 6px;font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary,inherit)}.odc-context-options{display:grid;gap:6px;margin-top:2px}.odc-context-option{display:flex;align-items:flex-start;gap:8px;min-width:0;min-height:32px;padding:6px 8px;border:1px solid var(--dsw-alias-border-l3,transparent);border-radius:8px;cursor:pointer}.odc-context-option:hover:not(:has(input:disabled)){border-color:color-mix(in srgb,var(--odc-accent) 55%,transparent)}.odc-context-option:has(input:checked){border-color:color-mix(in srgb,var(--odc-accent) 65%,transparent);background:color-mix(in srgb,var(--odc-accent) 8%,transparent)}.odc-context-option:has(input:disabled){cursor:not-allowed;opacity:.6}.odc-context-option input{appearance:auto;width:16px;height:16px;flex:none;margin:2px 0 0;cursor:inherit;accent-color:var(--dsw-alias-brand-primary,Highlight)}.odc-context-copy{display:grid;gap:1px;min-width:0}.odc-context-copy strong{font-size:12px;font-weight:600}.odc-context-legacy{margin-top:6px!important;color:var(--dsw-alias-label-secondary,inherit);font-size:12px}
|
|
20446
20912
|
.odc-model-image{display:flex;align-items:center;gap:2px 8px;flex-wrap:wrap;margin-top:3px;min-width:0}.odc-image-toggle{display:inline-flex;align-items:center;gap:6px;flex:none;min-height:28px;padding:2px 2px 2px 0;color:var(--dsw-alias-label-primary,inherit);font-size:12px;font-weight:550;cursor:pointer}.odc-image-toggle input{appearance:auto;width:16px;height:16px;flex:none;margin:0;cursor:inherit;accent-color:var(--dsw-alias-brand-primary,Highlight)}.odc-image-toggle:has(input:disabled){cursor:not-allowed;opacity:.6}.odc-image-state{min-width:0;color:var(--dsw-alias-label-secondary,inherit);font-size:12px;line-height:1.5;overflow-wrap:anywhere}.odc-image-reset{min-height:28px;padding:2px 7px;border:1px solid var(--dsw-alias-border-l3,CanvasText);border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary,inherit);font:inherit;font-size:12px;cursor:pointer}.odc-image-reset:hover:not(:disabled){border-color:var(--dsw-alias-brand-primary,Highlight);color:var(--dsw-alias-label-primary,inherit)}.odc-image-reset:disabled{opacity:.55;cursor:not-allowed}
|
|
20447
20913
|
.odc-field{display:grid;gap:6px;margin-top:14px}.odc-field-compact{margin-top:8px}.odc-field label,.odc-switch-text{font-size:12px;font-weight:550}.odc-input{width:100%;min-width:0;min-height:34px;padding:7px 9px;border:1px solid var(--dsw-alias-border-l3,transparent);border-radius:8px;background:var(--dsw-alias-bg-layer-2,transparent);color:var(--dsw-alias-label-primary,inherit);font:inherit;font-size:12px}.odc-field-compact .odc-input{min-height:30px;padding:5px 8px;font-size:11px}.odc-input::placeholder{color:var(--dsw-alias-label-secondary,inherit);opacity:1}.odc-input:disabled{opacity:.55}
|
|
20448
20914
|
.odc-effort{min-width:0}.odc-effort-head{display:flex;align-items:center;justify-content:space-between;gap:6px 10px;flex-wrap:wrap}.odc-effort-label{font-size:12px;font-weight:550}.odc-effort-value{min-width:0;margin:0;font-size:12px;overflow-wrap:anywhere}.odc-effort-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
|
|
@@ -20461,14 +20927,14 @@ function installStyles() {
|
|
|
20461
20927
|
.odc-quota-panel{display:grid;gap:8px;min-width:0}.odc-quota-panel>.odc-card-head{margin:0}.odc-quota-status{--odc-state:var(--odc-accent);display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid color-mix(in srgb,var(--odc-state) 28%,transparent);border-radius:10px;background:color-mix(in srgb,var(--odc-state) 10%,transparent);font-size:13px;font-weight:600}.odc-quota-status[data-tone=good]{--odc-state:var(--dsw-alias-state-success-primary,Highlight)}.odc-quota-status[data-tone=warn]{--odc-state:var(--dsw-alias-state-warn-primary,Highlight)}.odc-quota-status[data-tone=critical]{--odc-state:var(--dsw-alias-state-error-primary,Highlight)}.odc-state-mark{display:grid;place-items:center;width:28px;height:28px;border:1px solid color-mix(in srgb,var(--odc-state) 65%,transparent);border-radius:8px;flex:none;font-size:15px;font-weight:700}.odc-state-copy{display:grid;gap:1px;min-width:0}.odc-state-copy .odc-hint{font-weight:400}
|
|
20462
20928
|
.odc-window{--odc-window-color:var(--dsw-alias-label-secondary,CanvasText);gap:5px;margin:0;padding:10px 12px;border:0;border-radius:8px;background:color-mix(in srgb,var(--dsw-alias-label-primary,CanvasText) 5%,transparent)}.odc-window[data-tone=good]{--odc-window-color:color-mix(in srgb,var(--dsw-alias-state-success-primary,Highlight) 70%,var(--dsw-alias-label-primary,CanvasText))}.odc-window[data-tone=warn]{--odc-window-color:color-mix(in srgb,var(--dsw-alias-state-warn-primary,Highlight) 70%,var(--dsw-alias-label-primary,CanvasText))}.odc-window[data-tone=critical]{--odc-window-color:var(--dsw-alias-state-error-primary,Highlight)}.odc-window-remaining strong{font-size:18px}.odc-window progress{appearance:none;height:7px;border:0;border-radius:999px;overflow:hidden;background:color-mix(in srgb,var(--dsw-alias-label-primary,CanvasText) 18%,transparent);accent-color:var(--odc-window-color)}.odc-window progress::-webkit-progress-bar{background:color-mix(in srgb,var(--dsw-alias-label-primary,CanvasText) 18%,transparent);border-radius:999px}.odc-window progress::-webkit-progress-value{background:var(--odc-window-color);border-radius:999px}
|
|
20463
20929
|
.odc-window-usage{display:block;margin:0;color:var(--dsw-alias-label-secondary,inherit);font-size:12px;overflow-wrap:anywhere}.odc-window-bottom{display:flex;align-items:baseline;justify-content:space-between;gap:4px 12px;flex-wrap:wrap}.odc-window-reset{display:flex;align-items:baseline;justify-content:flex-start;flex-wrap:wrap;gap:4px 6px;padding:0;border:0}.odc-window-details>summary{min-height:28px;padding:4px 0}.odc-window-details[open]{flex-basis:100%}.odc-window-details dl>div{display:flex;justify-content:space-between;gap:12px}
|
|
20464
|
-
@media(forced-colors:active){.odc-window progress{appearance:auto;accent-color:Highlight;forced-color-adjust:auto}.odc-window progress::-webkit-progress-value{background:Highlight}.odc-image-toggle input{forced-color-adjust:auto}.odc-image-reset{border-color:ButtonText;background:ButtonFace;color:ButtonText}}
|
|
20930
|
+
@media(forced-colors:active){.odc-window progress{appearance:auto;accent-color:Highlight;forced-color-adjust:auto}.odc-window progress::-webkit-progress-value{background:Highlight}.odc-image-toggle input{forced-color-adjust:auto}.odc-image-reset{border-color:ButtonText;background:ButtonFace;color:ButtonText}.odc-context-option input{forced-color-adjust:auto}.odc-context-option{border-color:ButtonText}.odc-context-option:has(input:checked){border-color:Highlight}}
|
|
20465
20931
|
.odc-balance-list,.odc-timing{display:grid;gap:0;margin:0}.odc-balance-row,.odc-timing-row{display:flex;justify-content:space-between;align-items:baseline;gap:12px;min-width:0;min-height:0;padding:6px 0;border-top:1px solid var(--dsw-alias-border-l4,transparent)}.odc-balance-row:first-child,.odc-timing-row:first-child{border-top:0}.odc-balance-row>div,.odc-timing-row>div{min-width:0}.odc-balance-row dt,.odc-timing-row dt{font-size:12px;font-weight:600}.odc-balance-row dd,.odc-timing-row dd{margin:0;min-width:0;text-align:right}.odc-balance-row .odc-metric-value{font-size:13px}.odc-timing-row .odc-metric-text{font-size:13px;white-space:nowrap}.odc-timing-row .odc-hint{display:block}.odc-timing{padding:4px 14px}
|
|
20466
20932
|
.odc-model-item{background:transparent;border:1px solid var(--dsw-alias-border-l4,transparent)}.odc-model-item:has(details[open]){border-color:color-mix(in srgb,var(--odc-accent) 55%,transparent);background:color-mix(in srgb,var(--odc-accent) 5%,transparent)}
|
|
20467
20933
|
.odc-price-summary{margin:5px 0 0!important;font-size:12px;color:var(--dsw-alias-label-secondary,inherit);overflow-wrap:anywhere}.odc-pricing-head{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap}.odc-price-tier{padding:8px 0;border-top:1px solid var(--dsw-alias-border-l4,transparent)}.odc-price-tier dl{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px 12px;margin:6px 0 0}.odc-price-tier dl>div{display:flex;justify-content:space-between;gap:8px}.odc-price-tier dt{color:var(--dsw-alias-label-secondary,inherit)}.odc-price-tier dd{margin:0;font-variant-numeric:tabular-nums}
|
|
20468
20934
|
.odc-settings :focus-visible{outline:2px solid var(--dsw-alias-brand-primary,Highlight);outline-offset:3px}@media(max-width:680px){.odc-quota-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.odc-model-groups{grid-template-columns:1fr}.odc-model-editor{grid-template-columns:1fr}}@media(max-width:380px){.odc-quota-grid{grid-template-columns:1fr}.odc-card{padding:12px}}
|
|
20469
20935
|
@container(max-width:680px){.odc-quota-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.odc-model-groups,.odc-model-editor{grid-template-columns:1fr}}@container(max-width:380px){.odc-quota-grid{grid-template-columns:1fr}.odc-card{padding:12px}}
|
|
20470
20936
|
@container(max-width:480px){.odc-timing-row{align-items:flex-start}.odc-timing-row>div{flex:1 1 0}.odc-timing-row dd{flex:0 0 auto;max-width:50%;overflow-wrap:anywhere}.odc-timing-row .odc-metric-text{white-space:normal}}
|
|
20471
|
-
`;
|
|
20937
|
+
${QUICK_CONTEXT_CSS}`;
|
|
20472
20938
|
document.head.append(style);
|
|
20473
20939
|
return () => style.remove();
|
|
20474
20940
|
}
|
|
@@ -20532,8 +20998,8 @@ function createCaller(ctx) {
|
|
|
20532
20998
|
};
|
|
20533
20999
|
}
|
|
20534
21000
|
function useMounted() {
|
|
20535
|
-
const mounted =
|
|
20536
|
-
|
|
21001
|
+
const mounted = React2.useRef(true);
|
|
21002
|
+
React2.useEffect(() => {
|
|
20537
21003
|
mounted.current = true;
|
|
20538
21004
|
return () => {
|
|
20539
21005
|
mounted.current = false;
|
|
@@ -20542,7 +21008,7 @@ function useMounted() {
|
|
|
20542
21008
|
return mounted;
|
|
20543
21009
|
}
|
|
20544
21010
|
function useFormSnapshot(form) {
|
|
20545
|
-
return
|
|
21011
|
+
return React2.useSyncExternalStore(
|
|
20546
21012
|
(listener) => form.subscribe(listener),
|
|
20547
21013
|
() => form.getSnapshot(),
|
|
20548
21014
|
() => form.getSnapshot()
|
|
@@ -20550,7 +21016,7 @@ function useFormSnapshot(form) {
|
|
|
20550
21016
|
}
|
|
20551
21017
|
function NoticeView({ notice }) {
|
|
20552
21018
|
if (notice === null) return null;
|
|
20553
|
-
return
|
|
21019
|
+
return h2("p", {
|
|
20554
21020
|
className: "odc-notice",
|
|
20555
21021
|
"data-kind": notice.kind,
|
|
20556
21022
|
role: notice.kind === "error" ? "alert" : "status"
|
|
@@ -20579,8 +21045,8 @@ function formatRefreshCountdown(value, now) {
|
|
|
20579
21045
|
return formatRelativeDeadline(value, now, "\u5373\u5C06\u5237\u65B0");
|
|
20580
21046
|
}
|
|
20581
21047
|
function RelativeDeadline({ at, busy = false, dueText, titleLabel, futureSuffix = "" }) {
|
|
20582
|
-
const [now, setNow] =
|
|
20583
|
-
|
|
21048
|
+
const [now, setNow] = React2.useState(() => Date.now());
|
|
21049
|
+
React2.useEffect(() => {
|
|
20584
21050
|
if (at === void 0 || !Number.isFinite(Date.parse(at))) return;
|
|
20585
21051
|
const update = () => setNow(Date.now());
|
|
20586
21052
|
update();
|
|
@@ -20591,10 +21057,10 @@ function RelativeDeadline({ at, busy = false, dueText, titleLabel, futureSuffix
|
|
|
20591
21057
|
document.removeEventListener("visibilitychange", update);
|
|
20592
21058
|
};
|
|
20593
21059
|
}, [at]);
|
|
20594
|
-
if (busy) return
|
|
20595
|
-
if (at === void 0 || !Number.isFinite(Date.parse(at))) return
|
|
21060
|
+
if (busy) return h2("span", null, "\u5237\u65B0\u4E2D\u2026");
|
|
21061
|
+
if (at === void 0 || !Number.isFinite(Date.parse(at))) return h2("span", null, "\u2014");
|
|
20596
21062
|
const relative = formatRelativeDeadline(at, now, dueText) + (Date.parse(at) > now ? futureSuffix : "");
|
|
20597
|
-
return
|
|
21063
|
+
return h2("time", { dateTime: at, title: `${titleLabel}\uFF1A${formatTime(at)}`, "aria-label": `${relative}\uFF0C${titleLabel}\uFF1A${formatTime(at)}` }, relative);
|
|
20598
21064
|
}
|
|
20599
21065
|
function formatTokens(value) {
|
|
20600
21066
|
if (value === void 0 || !Number.isFinite(value)) return "\u2014";
|
|
@@ -20612,12 +21078,12 @@ function formatWindowCredits(value) {
|
|
|
20612
21078
|
if (value >= 1e3) return `${(value / 1e3).toFixed(1)}K`;
|
|
20613
21079
|
return String(value);
|
|
20614
21080
|
}
|
|
20615
|
-
function windowTone(
|
|
20616
|
-
return
|
|
21081
|
+
function windowTone(window2) {
|
|
21082
|
+
return window2.percent >= 100 ? "critical" : window2.percent >= 71 ? "warn" : "good";
|
|
20617
21083
|
}
|
|
20618
|
-
function windowDue(
|
|
20619
|
-
if (
|
|
20620
|
-
const at = Date.parse(
|
|
21084
|
+
function windowDue(window2, now) {
|
|
21085
|
+
if (window2.resetsAt === void 0) return false;
|
|
21086
|
+
const at = Date.parse(window2.resetsAt);
|
|
20621
21087
|
return Number.isFinite(at) && at <= now;
|
|
20622
21088
|
}
|
|
20623
21089
|
function quotaStatusView(quota, now) {
|
|
@@ -20626,22 +21092,22 @@ function quotaStatusView(quota, now) {
|
|
|
20626
21092
|
if (quota.stale) return { title: "\u663E\u793A\u4E0A\u6B21\u6210\u529F\u8BFB\u6570", tone: "warn", icon: "?" };
|
|
20627
21093
|
if (quota.state === "partial") return { title: QUOTA_LABELS.partial, tone: "warn", icon: "?" };
|
|
20628
21094
|
if (quota.eligible === false) return { title: "\u672A\u5F00\u901A Design Plan", tone: "neutral", icon: "i" };
|
|
20629
|
-
const windows = quota.windows.filter((
|
|
21095
|
+
const windows = quota.windows.filter((window3) => Number.isFinite(window3.percent));
|
|
20630
21096
|
if (!windows.length) return { title: "\u6682\u65E0\u8D60\u9001\u7A97\u53E3\u6570\u636E", tone: "neutral", icon: "i" };
|
|
20631
|
-
if (windows.some((
|
|
20632
|
-
const
|
|
20633
|
-
const tone = windowTone(
|
|
20634
|
-
const title = tone === "critical" ? "\u8D60\u9001\u7A97\u53E3\u989D\u5EA6\u5DF2\u7528\u5C3D" :
|
|
20635
|
-
return { title, tone, icon: tone === "good" ? "\u2713" : tone === "warn" ? "!" : "\xD7", window };
|
|
21097
|
+
if (windows.some((window3) => windowDue(window3, now))) return { title: "\u7B49\u5F85\u66F4\u65B0\u7A97\u53E3\u989D\u5EA6", tone: "neutral", icon: "\u2026" };
|
|
21098
|
+
const window2 = windows.reduce((worst, next) => next.percent > worst.percent ? next : worst);
|
|
21099
|
+
const tone = windowTone(window2);
|
|
21100
|
+
const title = tone === "critical" ? "\u8D60\u9001\u7A97\u53E3\u989D\u5EA6\u5DF2\u7528\u5C3D" : window2.percent >= 91 ? "\u8D60\u9001\u7A97\u53E3\u989D\u5EA6\u5373\u5C06\u7528\u5C3D" : tone === "warn" ? "\u8D60\u9001\u7A97\u53E3\u989D\u5EA6\u504F\u5C11" : "\u8D60\u9001\u7A97\u53E3\u989D\u5EA6\u5145\u8DB3";
|
|
21101
|
+
return { title, tone, icon: tone === "good" ? "\u2713" : tone === "warn" ? "!" : "\xD7", window: window2 };
|
|
20636
21102
|
}
|
|
20637
21103
|
function nextWindowResetAt(windows, now) {
|
|
20638
21104
|
let earliest;
|
|
20639
21105
|
let earliestMs = Number.POSITIVE_INFINITY;
|
|
20640
|
-
for (const
|
|
20641
|
-
if (
|
|
20642
|
-
const ms = Date.parse(
|
|
21106
|
+
for (const window2 of windows) {
|
|
21107
|
+
if (window2.resetsAt === void 0) continue;
|
|
21108
|
+
const ms = Date.parse(window2.resetsAt);
|
|
20643
21109
|
if (!Number.isFinite(ms) || ms <= now || ms >= earliestMs) continue;
|
|
20644
|
-
earliest =
|
|
21110
|
+
earliest = window2.resetsAt;
|
|
20645
21111
|
earliestMs = ms;
|
|
20646
21112
|
}
|
|
20647
21113
|
return earliest;
|
|
@@ -20656,12 +21122,12 @@ var RESET_MODE_LABELS = {
|
|
|
20656
21122
|
anchored_recurring: "\u56FA\u5B9A\u5468\u671F"
|
|
20657
21123
|
};
|
|
20658
21124
|
function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds, busy = false }) {
|
|
20659
|
-
const [now, setNow] =
|
|
20660
|
-
|
|
21125
|
+
const [now, setNow] = React2.useState(() => Date.now());
|
|
21126
|
+
React2.useEffect(() => {
|
|
20661
21127
|
setNow(Date.now());
|
|
20662
21128
|
}, [quota?.windows]);
|
|
20663
|
-
|
|
20664
|
-
const future = (quota?.windows ?? []).map((
|
|
21129
|
+
React2.useEffect(() => {
|
|
21130
|
+
const future = (quota?.windows ?? []).map((window2) => Date.parse(window2.resetsAt ?? "")).filter((at) => Number.isFinite(at) && at > now);
|
|
20665
21131
|
const update = () => setNow(Date.now());
|
|
20666
21132
|
const timer = future.length ? setTimeout(update, Math.min(2147483647, Math.max(1, Math.min(...future) - now + 10))) : void 0;
|
|
20667
21133
|
document.addEventListener("visibilitychange", update);
|
|
@@ -20670,7 +21136,7 @@ function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds, busy = fa
|
|
|
20670
21136
|
document.removeEventListener("visibilitychange", update);
|
|
20671
21137
|
};
|
|
20672
21138
|
}, [quota?.windows, now]);
|
|
20673
|
-
if (quota === void 0) return
|
|
21139
|
+
if (quota === void 0) return h2("p", { className: "odc-hint", role: "status" }, "\u6B63\u5728\u8BFB\u53D6\u989D\u5EA6\u2026");
|
|
20674
21140
|
const metrics = [
|
|
20675
21141
|
{ label: "\u5957\u9910\u4F59\u989D", value: formatUsd(quota.balances.subscriptionUsd), hint: "\u8BA2\u9605\u5269\u4F59\u53EF\u7528\u91D1\u989D" },
|
|
20676
21142
|
{ label: "\u5145\u503C / \u8D60\u9001\u91D1\u989D", value: formatUsd(quota.balances.rechargeUsd), hint: "\u5145\u503C\u4E0E\u8D60\u9001\u7684\u53EF\u7528\u91D1\u989D" },
|
|
@@ -20679,17 +21145,17 @@ function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds, busy = fa
|
|
|
20679
21145
|
const timing = [
|
|
20680
21146
|
{
|
|
20681
21147
|
label: "\u8BA2\u9605\u8D26\u671F\u7ED3\u675F",
|
|
20682
|
-
value:
|
|
21148
|
+
value: h2(RelativeDeadline, { at: quota.subscriptionPeriodEnd, dueText: "\u5DF2\u5230\u7ED3\u675F\u65F6\u95F4", titleLabel: "\u8D26\u671F\u7ED3\u675F\u65F6\u95F4" }),
|
|
20683
21149
|
hint: `\u8D26\u671F\u5F00\u59CB\uFF1A${formatTime(quota.subscriptionPeriodStart)}`
|
|
20684
21150
|
},
|
|
20685
21151
|
{
|
|
20686
21152
|
label: "\u4E0B\u6B21\u989D\u5EA6\u6062\u590D",
|
|
20687
|
-
value:
|
|
21153
|
+
value: h2(RelativeDeadline, { at: nextWindowResetAt(quota.windows, Date.now()), dueText: "\u7B49\u5F85\u66F4\u65B0", titleLabel: "\u989D\u5EA6\u6062\u590D\u65F6\u95F4" }),
|
|
20688
21154
|
hint: "\u6700\u65E9\u6062\u590D\u7684\u8D60\u9001\u7A97\u53E3\uFF1B\u4E0D\u4EE3\u8868\u94B1\u5305\u5230\u8D26\u65F6\u95F4"
|
|
20689
21155
|
},
|
|
20690
21156
|
{
|
|
20691
21157
|
label: "\u4E0B\u6B21\u81EA\u52A8\u5237\u65B0",
|
|
20692
|
-
value:
|
|
21158
|
+
value: h2(RelativeDeadline, { at: quota.state === "need-login" || quota.autoRefreshPaused ? void 0 : nextAutoRefreshAt, busy: busy && quota.state !== "need-login" && !quota.autoRefreshPaused, dueText: "\u5373\u5C06\u5237\u65B0", titleLabel: "\u8BA1\u5212\u5237\u65B0\u65F6\u95F4" }),
|
|
20693
21159
|
hint: quota.state === "need-login" ? "\u767B\u5F55\u540E\u81EA\u52A8\u5237\u65B0" : quota.autoRefreshPaused ? "\u8FDE\u7EED\u5931\u8D25\uFF0C\u81EA\u52A8\u91CD\u8BD5\u5DF2\u6682\u505C\uFF1B\u70B9\u51FB\u5237\u65B0\u989D\u5EA6\u91CD\u8BD5" : refreshIntervalSeconds === void 0 ? "\u672A\u542F\u7528\u81EA\u52A8\u5237\u65B0" : quota.refreshFailures ? `\u5237\u65B0\u5931\u8D25 ${quota.refreshFailures} \u6B21\uFF0C\u6B63\u5728\u5EF6\u8FDF\u91CD\u8BD5` : `\u6BCF ${refreshIntervalSeconds} \u79D2\u81EA\u52A8\u5237\u65B0`
|
|
20694
21160
|
}
|
|
20695
21161
|
];
|
|
@@ -20698,122 +21164,122 @@ function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds, busy = fa
|
|
|
20698
21164
|
quota.eligible === void 0 ? void 0 : `\u5957\u9910\u8D44\u683C\uFF1A${quota.eligible ? "\u5DF2\u5F00\u901A" : "\u672A\u5F00\u901A"}`
|
|
20699
21165
|
].filter((value) => value !== void 0).join(" \xB7 ");
|
|
20700
21166
|
const quotaStatus = quotaStatusView(quota, now);
|
|
20701
|
-
return
|
|
20702
|
-
|
|
21167
|
+
return h2(
|
|
21168
|
+
React2.Fragment,
|
|
20703
21169
|
null,
|
|
20704
|
-
|
|
21170
|
+
h2(
|
|
20705
21171
|
"div",
|
|
20706
21172
|
{ className: "odc-quota-panel" },
|
|
20707
|
-
|
|
21173
|
+
h2(
|
|
20708
21174
|
"div",
|
|
20709
21175
|
{ className: "odc-card-head" },
|
|
20710
|
-
|
|
21176
|
+
h2(
|
|
20711
21177
|
"div",
|
|
20712
21178
|
null,
|
|
20713
|
-
|
|
20714
|
-
tierLine === "" ? null :
|
|
21179
|
+
h2("h3", null, "\u5957\u9910\u8D60\u9001\u7A97\u53E3"),
|
|
21180
|
+
tierLine === "" ? null : h2("p", { className: "odc-hint" }, tierLine)
|
|
20715
21181
|
),
|
|
20716
|
-
quota.stale ?
|
|
21182
|
+
quota.stale ? h2("span", { className: "odc-chip" }, "\u4E0A\u6B21\u6210\u529F\u8BFB\u6570") : null
|
|
20717
21183
|
),
|
|
20718
|
-
|
|
21184
|
+
h2(
|
|
20719
21185
|
"div",
|
|
20720
21186
|
{ className: "odc-quota-status", "data-state": quota.state, "data-tone": quotaStatus.tone },
|
|
20721
|
-
|
|
20722
|
-
|
|
21187
|
+
h2("span", { className: "odc-state-mark", "aria-hidden": true }, quotaStatus.icon),
|
|
21188
|
+
h2(
|
|
20723
21189
|
"div",
|
|
20724
21190
|
{ className: "odc-state-copy" },
|
|
20725
|
-
|
|
20726
|
-
quotaStatus.window === void 0 ? null :
|
|
21191
|
+
h2("strong", null, quotaStatus.title),
|
|
21192
|
+
quotaStatus.window === void 0 ? null : h2(
|
|
20727
21193
|
"span",
|
|
20728
21194
|
{ className: "odc-hint" },
|
|
20729
21195
|
`${windowLabel(quotaStatus.window.durationSeconds).replace("\u8D60\u9001\u7A97\u53E3", "")} \xB7 \u5269\u4F59 ${Math.max(0, Math.min(100, 100 - quotaStatus.window.percent)).toFixed(1)}%`,
|
|
20730
|
-
quotaStatus.window.resetsAt === void 0 ? null :
|
|
21196
|
+
quotaStatus.window.resetsAt === void 0 ? null : h2(React2.Fragment, null, " \xB7 ", h2(RelativeDeadline, { at: quotaStatus.window.resetsAt, dueText: "\u7B49\u5F85\u66F4\u65B0", titleLabel: "\u9884\u8BA1\u6062\u590D\u65F6\u95F4", futureSuffix: "\u6062\u590D" }))
|
|
20731
21197
|
)
|
|
20732
21198
|
)
|
|
20733
21199
|
),
|
|
20734
|
-
quota.windows.length === 0 ? quota.eligible === false ?
|
|
20735
|
-
|
|
21200
|
+
quota.windows.length === 0 ? quota.eligible === false ? h2("p", { className: "odc-hint", role: "status" }, "\u5F53\u524D\u8D26\u53F7\u672A\u5F00\u901A Design Plan\uFF0C\u6CA1\u6709\u8D60\u9001\u989D\u5EA6\u7A97\u53E3\u3002") : h2(
|
|
21201
|
+
React2.Fragment,
|
|
20736
21202
|
null,
|
|
20737
|
-
|
|
20738
|
-
|
|
20739
|
-
) : quota.windows.map((
|
|
20740
|
-
const label = windowLabel(
|
|
20741
|
-
const remainingPercent = Math.max(0, Math.min(100, 100 -
|
|
20742
|
-
const tone = quota.state === "ok" && !quota.stale && !windowDue(
|
|
20743
|
-
return
|
|
21203
|
+
h2("p", { className: "odc-metric-value" }, "\u2014"),
|
|
21204
|
+
h2("p", { className: "odc-hint" }, "\u6682\u65F6\u65E0\u6CD5\u83B7\u53D6\u989D\u5EA6\u7A97\u53E3\u3002")
|
|
21205
|
+
) : quota.windows.map((window2, index) => {
|
|
21206
|
+
const label = windowLabel(window2.durationSeconds);
|
|
21207
|
+
const remainingPercent = Math.max(0, Math.min(100, 100 - window2.percent));
|
|
21208
|
+
const tone = quota.state === "ok" && !quota.stale && !windowDue(window2, now) ? windowTone(window2) : "neutral";
|
|
21209
|
+
return h2(
|
|
20744
21210
|
"section",
|
|
20745
|
-
{ className: "odc-window", key: `${
|
|
20746
|
-
|
|
21211
|
+
{ className: "odc-window", key: `${window2.durationSeconds}-${index}`, "aria-label": label, "data-tone": tone },
|
|
21212
|
+
h2(
|
|
20747
21213
|
"div",
|
|
20748
21214
|
{ className: "odc-window-head" },
|
|
20749
|
-
|
|
20750
|
-
|
|
21215
|
+
h2("h4", null, label),
|
|
21216
|
+
h2(
|
|
20751
21217
|
"div",
|
|
20752
21218
|
{ className: "odc-window-remaining" },
|
|
20753
|
-
|
|
20754
|
-
|
|
21219
|
+
h2("strong", null, `${remainingPercent.toFixed(1)}%`),
|
|
21220
|
+
h2("span", { className: "odc-label" }, "\u5269\u4F59\u6BD4\u4F8B")
|
|
20755
21221
|
)
|
|
20756
21222
|
),
|
|
20757
|
-
|
|
20758
|
-
|
|
20759
|
-
|
|
21223
|
+
h2("progress", { max: 100, value: remainingPercent, "aria-label": `${label}\u5269\u4F59\u989D\u5EA6` }),
|
|
21224
|
+
h2("p", { className: "odc-window-usage", title: `\u5DF2\u7528 ${window2.used} / \u603B\u8BA1 ${window2.limit} \u79EF\u5206`, "aria-label": `\u7A97\u53E3\u79EF\u5206\uFF1A\u5DF2\u7528 ${window2.used}\uFF0C\u603B\u8BA1 ${window2.limit}` }, `\u5DF2\u7528 ${formatWindowCredits(window2.used)} / \u603B\u8BA1 ${formatWindowCredits(window2.limit)} \u79EF\u5206`),
|
|
21225
|
+
h2(
|
|
20760
21226
|
"div",
|
|
20761
21227
|
{ className: "odc-window-bottom" },
|
|
20762
|
-
|
|
21228
|
+
h2(
|
|
20763
21229
|
"div",
|
|
20764
21230
|
{ className: "odc-window-reset" },
|
|
20765
|
-
|
|
20766
|
-
|
|
21231
|
+
h2("span", { className: "odc-label" }, "\u4E0B\u6B21\u6062\u590D"),
|
|
21232
|
+
h2(RelativeDeadline, { at: window2.resetsAt, dueText: "\u5DF2\u5230\u6062\u590D\u65F6\u95F4\uFF0C\u7B49\u5F85\u66F4\u65B0", titleLabel: "\u9884\u8BA1\u6062\u590D\u65F6\u95F4" })
|
|
20767
21233
|
),
|
|
20768
|
-
|
|
21234
|
+
h2(
|
|
20769
21235
|
"details",
|
|
20770
21236
|
{ className: "odc-window-details" },
|
|
20771
|
-
|
|
20772
|
-
|
|
21237
|
+
h2("summary", null, "\u7A97\u53E3\u8BE6\u60C5"),
|
|
21238
|
+
h2(
|
|
20773
21239
|
"dl",
|
|
20774
21240
|
null,
|
|
20775
|
-
|
|
20776
|
-
|
|
20777
|
-
|
|
21241
|
+
h2("div", null, h2("dt", null, "\u63A5\u53E3\u5269\u4F59\u79EF\u5206"), h2("dd", null, window2.remaining === void 0 ? "\u2014" : window2.remaining)),
|
|
21242
|
+
window2.windowStart === void 0 ? null : h2("div", null, h2("dt", null, "\u7A97\u53E3\u5F00\u59CB"), h2("dd", null, h2("time", { dateTime: window2.windowStart }, formatTime(window2.windowStart)))),
|
|
21243
|
+
window2.resetMode === void 0 ? null : h2("div", null, h2("dt", null, "\u91CD\u7F6E\u65B9\u5F0F"), h2("dd", null, RESET_MODE_LABELS[window2.resetMode] ?? window2.resetMode))
|
|
20778
21244
|
)
|
|
20779
21245
|
)
|
|
20780
21246
|
)
|
|
20781
21247
|
);
|
|
20782
21248
|
})
|
|
20783
21249
|
),
|
|
20784
|
-
|
|
21250
|
+
h2(
|
|
20785
21251
|
"section",
|
|
20786
21252
|
{ className: "odc-card", "aria-label": "\u94B1\u5305\u4F59\u989D" },
|
|
20787
|
-
|
|
20788
|
-
|
|
21253
|
+
h2("h3", null, "\u94B1\u5305\u4F59\u989D"),
|
|
21254
|
+
h2("dl", { className: "odc-balance-list" }, metrics.map((metric) => h2(
|
|
20789
21255
|
"div",
|
|
20790
21256
|
{ className: "odc-balance-row odc-metric", key: metric.label },
|
|
20791
|
-
|
|
20792
|
-
|
|
21257
|
+
h2("div", null, h2("dt", { title: metric.hint }, metric.label)),
|
|
21258
|
+
h2("dd", null, h2("strong", { className: "odc-metric-value" }, metric.value))
|
|
20793
21259
|
)))
|
|
20794
21260
|
),
|
|
20795
|
-
|
|
21261
|
+
h2("dl", { className: "odc-card odc-timing", "aria-label": "\u989D\u5EA6\u65F6\u95F4\u5B89\u6392" }, timing.map((metric) => h2(
|
|
20796
21262
|
"div",
|
|
20797
21263
|
{ className: "odc-timing-row odc-metric", key: metric.label },
|
|
20798
|
-
|
|
20799
|
-
|
|
21264
|
+
h2("div", null, h2("dt", null, metric.label), h2("span", { className: "odc-hint" }, metric.hint)),
|
|
21265
|
+
h2("dd", null, h2("strong", { className: "odc-metric-value odc-metric-text" }, metric.value))
|
|
20800
21266
|
))),
|
|
20801
|
-
|
|
21267
|
+
h2(
|
|
20802
21268
|
"dl",
|
|
20803
21269
|
{ className: "odc-quota-footer", "aria-label": "\u989D\u5EA6\u6570\u636E\u6765\u6E90\u4E0E\u66F4\u65B0\u65F6\u95F4" },
|
|
20804
|
-
|
|
20805
|
-
quota.source === void 0 ? null :
|
|
21270
|
+
h2("div", null, h2("dt", null, "\u6700\u8FD1\u66F4\u65B0"), h2("dd", null, h2("time", { dateTime: quota.updatedAt }, formatTime(quota.updatedAt)))),
|
|
21271
|
+
quota.source === void 0 ? null : h2("div", null, h2("dt", null, "\u6570\u636E\u6765\u6E90"), h2("dd", null, SOURCE_LABELS[quota.source]))
|
|
20806
21272
|
),
|
|
20807
|
-
|
|
21273
|
+
h2(
|
|
20808
21274
|
"details",
|
|
20809
21275
|
{ className: "odc-model-details" },
|
|
20810
|
-
|
|
20811
|
-
|
|
21276
|
+
h2("summary", null, "\u5982\u4F55\u7406\u89E3\u8FD9\u4E9B\u989D\u5EA6\uFF1F"),
|
|
21277
|
+
h2("p", { className: "odc-hint" }, "\u8D60\u9001\u7A97\u53E3\u663E\u793A\u5468\u671F\u5185\u7684\u4F7F\u7528\u91CF\u3002\u5957\u9910\u4F59\u989D\u548C\u5145\u503C / \u8D60\u9001\u91D1\u989D\u662F\u94B1\u5305\u7684\u4E0D\u540C\u5206\u6C60\uFF0C\u603B\u989D\u5EA6\u662F\u94B1\u5305\u5408\u8BA1\u3002\u2014 \u8868\u793A\u6682\u65E0\u6570\u636E\u3002")
|
|
20812
21278
|
),
|
|
20813
|
-
quota.note !== void 0 ?
|
|
21279
|
+
quota.note !== void 0 ? h2("p", { className: "odc-notice", "data-kind": quota.state === "error" ? "error" : "status", role: quota.state === "error" ? "alert" : "status" }, quota.note) : null
|
|
20814
21280
|
);
|
|
20815
21281
|
}
|
|
20816
|
-
function TurnMonitorView({ turnMonitor, guardedTurns, enabled = true }) {
|
|
21282
|
+
function TurnMonitorView({ turnMonitor, guardedTurns, enabled = true, reviewEnabled = true }) {
|
|
20817
21283
|
const metrics = [
|
|
20818
21284
|
{ label: "\u7A7A\u54CD\u5E94\uFF0F\u6B8B\u7559\u62E6\u622A", hint: "\u7A7A\u56DE\u7B54\u6216\u534F\u8BAE\u6807\u8BB0\u6B8B\u7559\u7684\u62E6\u622A\u6B21\u6570\uFF0C\u4ECE\u63D2\u4EF6\u52A0\u8F7D\u8D77\u7D2F\u8BA1", value: guardedTurns === void 0 ? "\u2014" : String(guardedTurns) },
|
|
20819
21285
|
{ label: "\u8BF7\u6C42\u91CD\u8BD5", hint: "\u672C\u63D2\u4EF6\u7A7A\u54CD\u5E94\u9519\u8BEF\u6062\u590D\u4E2D\u5DF2\u5F00\u59CB\u7684\u91CD\u8BD5\u6B21\u6570\uFF0C\u4ECE\u63D2\u4EF6\u52A0\u8F7D\u8D77\u7D2F\u8BA1", value: turnMonitor === void 0 ? "\u2014" : String(turnMonitor.requestRetries) },
|
|
@@ -20824,37 +21290,37 @@ function TurnMonitorView({ turnMonitor, guardedTurns, enabled = true }) {
|
|
|
20824
21290
|
const lastAt = last === void 0 || !Number.isFinite(Date.parse(last.at)) ? void 0 : last.at;
|
|
20825
21291
|
const lastDecision = last === void 0 ? void 0 : REVIEW_DECISION_LABELS[last.decision];
|
|
20826
21292
|
const lastReason = last === void 0 ? void 0 : REVIEW_REASON_LABELS[last.reason];
|
|
20827
|
-
return
|
|
21293
|
+
return h2(
|
|
20828
21294
|
"dl",
|
|
20829
21295
|
{ className: "odc-card odc-turn-monitor", "aria-label": "\u5F02\u5E38\u7ED3\u675F\u76D1\u63A7" },
|
|
20830
|
-
|
|
21296
|
+
h2(
|
|
20831
21297
|
"div",
|
|
20832
21298
|
null,
|
|
20833
|
-
|
|
20834
|
-
|
|
21299
|
+
h2("dt", null, "\u76D1\u63A7\u6307\u6807"),
|
|
21300
|
+
h2(
|
|
20835
21301
|
"span",
|
|
20836
21302
|
{ className: "odc-hint", role: "status" },
|
|
20837
|
-
!enabled ? "\u76D1\u63A7\u5DF2\u5173\u95ED\uFF1B\u4EE5\u4E0B\u4E3A\u672C\u6B21\u52A0\u8F7D\u7684\u7D2F\u8BA1\u8BB0\u5F55\u3002" : turnMonitor === void 0 ? guardedTurns === void 0 ? "\u6682\u65E0\u76D1\u63A7\u6570\u636E" : "\u4EC5\u534F\u8BAE\u62E6\u622A\u8BA1\u6570\u53EF\u7528" : turnMonitor.available ? `\u6536\u5C3E\u6838\u9A8C\u53EF\u7528\uFF0C\u5DF2\u6838\u9A8C ${turnMonitor.checks} \u6B21\u3002` : "\u4EC5\u534F\u8BAE\u4FDD\u62A4\u53EF\u7528\uFF1B\u6536\u5C3E\u6838\u9A8C\u672A\u542F\u7528\u3002"
|
|
21303
|
+
!enabled ? "\u76D1\u63A7\u5DF2\u5173\u95ED\uFF1B\u4EE5\u4E0B\u4E3A\u672C\u6B21\u52A0\u8F7D\u7684\u7D2F\u8BA1\u8BB0\u5F55\u3002" : turnMonitor === void 0 ? guardedTurns === void 0 ? "\u6682\u65E0\u76D1\u63A7\u6570\u636E" : "\u4EC5\u534F\u8BAE\u62E6\u622A\u8BA1\u6570\u53EF\u7528" : turnMonitor.available && reviewEnabled ? `\u6536\u5C3E\u6838\u9A8C\u53EF\u7528\uFF0C\u5DF2\u6838\u9A8C ${turnMonitor.checks} \u6B21\u3002` : "\u4EC5\u534F\u8BAE\u4FDD\u62A4\u53EF\u7528\uFF1B\u6536\u5C3E\u6838\u9A8C\u672A\u542F\u7528\u3002"
|
|
20838
21304
|
)
|
|
20839
21305
|
),
|
|
20840
|
-
metrics.map((metric) =>
|
|
21306
|
+
metrics.map((metric) => h2(
|
|
20841
21307
|
"div",
|
|
20842
21308
|
{ className: "odc-turn-monitor-row", key: metric.label },
|
|
20843
|
-
|
|
20844
|
-
|
|
21309
|
+
h2("dt", { title: metric.hint }, metric.label),
|
|
21310
|
+
h2("dd", null, h2("strong", { className: "odc-metric-value" }, metric.value))
|
|
20845
21311
|
)),
|
|
20846
|
-
|
|
21312
|
+
h2(
|
|
20847
21313
|
"div",
|
|
20848
21314
|
{ className: "odc-turn-monitor-row odc-turn-monitor-last", key: "last" },
|
|
20849
|
-
|
|
20850
|
-
|
|
21315
|
+
h2("dt", null, "\u6700\u8FD1\u51B3\u5B9A"),
|
|
21316
|
+
h2(
|
|
20851
21317
|
"dd",
|
|
20852
21318
|
null,
|
|
20853
|
-
lastDecision === void 0 || lastReason === void 0 || lastAt === void 0 ?
|
|
20854
|
-
|
|
21319
|
+
lastDecision === void 0 || lastReason === void 0 || lastAt === void 0 ? h2("span", { className: "odc-hint" }, "\u2014") : h2(
|
|
21320
|
+
React2.Fragment,
|
|
20855
21321
|
null,
|
|
20856
|
-
|
|
20857
|
-
|
|
21322
|
+
h2("span", { className: "odc-turn-monitor-verdict" }, `${lastDecision} \xB7 ${lastReason}`),
|
|
21323
|
+
h2("time", { className: "odc-hint", dateTime: lastAt, title: `\u6700\u8FD1\u51B3\u5B9A\u65F6\u95F4\uFF1A${formatTime(lastAt)}`, "aria-label": `\u6700\u8FD1\u51B3\u5B9A\uFF1A${lastDecision}\uFF0C\u539F\u56E0\uFF1A${lastReason}\uFF0C\u65F6\u95F4\uFF1A${formatTime(lastAt)}` }, formatTime(lastAt))
|
|
20858
21324
|
)
|
|
20859
21325
|
)
|
|
20860
21326
|
)
|
|
@@ -20873,6 +21339,7 @@ function writeModelSettings(map2, id, next) {
|
|
|
20873
21339
|
if (next.topP !== void 0) entry.topP = next.topP;
|
|
20874
21340
|
if (next.maxTokens !== void 0) entry.maxTokens = next.maxTokens;
|
|
20875
21341
|
if (next.contextWindow !== void 0) entry.contextWindow = next.contextWindow;
|
|
21342
|
+
if (next.contextTier !== void 0) entry.contextTier = next.contextTier;
|
|
20876
21343
|
if (next.reasoningEffort !== void 0) entry.reasoningEffort = next.reasoningEffort;
|
|
20877
21344
|
if (Object.keys(entry).length === 0) delete out[id];
|
|
20878
21345
|
else out[id] = entry;
|
|
@@ -20932,42 +21399,67 @@ function quotaAutoRefresh(secondsRaw, nextRefreshAt, now, backingOff = false) {
|
|
|
20932
21399
|
return { delayMs, at: new Date(now + delayMs).toISOString(), intervalSeconds };
|
|
20933
21400
|
}
|
|
20934
21401
|
function Overview({ status, busy, onRefresh, nextAutoRefreshAt, refreshIntervalSeconds, onConnection }) {
|
|
20935
|
-
return
|
|
20936
|
-
|
|
21402
|
+
return h2(
|
|
21403
|
+
React2.Fragment,
|
|
20937
21404
|
null,
|
|
20938
|
-
status !== void 0 && (status.apiKeyConfigured === false || status.quota.state === "need-login") ?
|
|
21405
|
+
status !== void 0 && (status.apiKeyConfigured === false || status.quota.state === "need-login") ? h2(
|
|
20939
21406
|
"section",
|
|
20940
21407
|
{ className: "odc-card odc-row", "aria-label": "\u8FDE\u63A5\u5F85\u5B8C\u6210" },
|
|
20941
|
-
|
|
21408
|
+
h2(
|
|
20942
21409
|
"div",
|
|
20943
21410
|
null,
|
|
20944
|
-
|
|
20945
|
-
|
|
21411
|
+
h2("h3", null, "\u5148\u5B8C\u6210\u8FDE\u63A5"),
|
|
21412
|
+
h2("p", { className: "odc-hint" }, status.apiKeyConfigured === false ? "\u5C1A\u65E0\u5F53\u524D\u7F51\u5173\u7684\u63A8\u7406\u51ED\u636E\uFF1B\u53EF\u5B8C\u6210\u8BBE\u5907\u6388\u6743\u6216\u5355\u72EC\u914D\u7F6E API Key\u3002" : "API Key \u5DF2\u914D\u7F6E\uFF1B\u767B\u5F55\u540E\u5373\u53EF\u67E5\u770B\u8D26\u53F7\u989D\u5EA6\u3002")
|
|
20946
21413
|
),
|
|
20947
|
-
onConnection === void 0 ? null :
|
|
21414
|
+
onConnection === void 0 ? null : h2("button", { type: "button", className: "odc-button odc-button-primary", onClick: onConnection }, "\u524D\u5F80\u8FDE\u63A5\u4E0E\u767B\u5F55")
|
|
20948
21415
|
) : null,
|
|
20949
|
-
|
|
21416
|
+
h2(
|
|
20950
21417
|
"div",
|
|
20951
21418
|
{ className: "odc-card-head" },
|
|
20952
|
-
|
|
20953
|
-
|
|
21419
|
+
h2("div", null, h2("h3", null, "\u989D\u5EA6\u6982\u89C8"), h2("p", { className: "odc-hint" }, "\u67E5\u770B\u5957\u9910\u7528\u91CF\u3001\u8BA2\u9605\u4F59\u989D\u548C\u5145\u503C\u4F59\u989D\u3002")),
|
|
21420
|
+
h2("button", { className: "odc-button", type: "button", disabled: busy, onClick: onRefresh }, busy ? "\u5237\u65B0\u4E2D\u2026" : "\u5237\u65B0\u989D\u5EA6")
|
|
20954
21421
|
),
|
|
20955
|
-
|
|
21422
|
+
h2(QuotaView, { quota: status?.quota, nextAutoRefreshAt, refreshIntervalSeconds, busy })
|
|
20956
21423
|
);
|
|
20957
21424
|
}
|
|
20958
21425
|
var NUMERIC_FIELDS = {
|
|
20959
21426
|
temperature: { label: "\u6E29\u5EA6", hint: "0\u20132\uFF1B\u7559\u7A7A\u7EE7\u627F\u9ED8\u8BA4\u3002", min: 0, max: 2 },
|
|
20960
21427
|
topP: { label: "Top P", hint: "0\u20131\uFF1B\u7559\u7A7A\u7EE7\u627F\u9ED8\u8BA4\u3002", min: 0, max: 1 },
|
|
20961
|
-
maxTokens: { label: "\u6700\u5927\u8F93\u51FA\uFF08tokens\uFF09", hint: "\u6B63\u6574\u6570\uFF1B\u7559\u7A7A\
|
|
20962
|
-
contextWindow: { label: "\u4E0A\u4E0B\u6587\u9884\u7B97\uFF08tokens\uFF09", hint: "\u6B63\u6574\u6570\uFF1B\u7559\u7A7A\u7EE7\u627F\u76EE\u5F55\u9ED8\u8BA4\u3002", min: 1, max: MAX_CONTEXT_WINDOW, integer: true }
|
|
21428
|
+
maxTokens: { label: "\u6700\u5927\u8F93\u51FA\uFF08tokens\uFF09", hint: "\u6B63\u6574\u6570\uFF1B\u7559\u7A7A\u6309\u6A21\u578B\u4E0E\u5F53\u524D\u603B\u7A97\u53E3\u81EA\u52A8\u9884\u7559\u3002", min: 1, max: MAX_OUTPUT_TOKENS, integer: true }
|
|
20963
21429
|
};
|
|
20964
|
-
var NUMERIC_ORDER = ["temperature", "topP", "maxTokens"
|
|
20965
|
-
function
|
|
21430
|
+
var NUMERIC_ORDER = ["temperature", "topP", "maxTokens"];
|
|
21431
|
+
function selectedContextTier(settings) {
|
|
21432
|
+
return contextWindowPreset(settings.contextWindow, settings.contextTier);
|
|
21433
|
+
}
|
|
21434
|
+
function contextTierAvailable(tier, reference) {
|
|
21435
|
+
if (tier === "default") return true;
|
|
21436
|
+
const preset = CONTEXT_WINDOW_PRESETS.find((item) => item.id === tier);
|
|
21437
|
+
if (preset === void 0) return false;
|
|
21438
|
+
return reference === void 0 || preset.tokens <= reference;
|
|
21439
|
+
}
|
|
21440
|
+
function contextTierWindow(tier, reference) {
|
|
21441
|
+
return effectiveContextWindow(reference, void 0, tier);
|
|
21442
|
+
}
|
|
21443
|
+
function contextCapacityConflict(reference, next) {
|
|
21444
|
+
const output2 = next.maxTokens;
|
|
21445
|
+
if (output2 === void 0) return void 0;
|
|
21446
|
+
const window2 = effectiveContextWindow(reference, next.contextWindow, next.contextTier);
|
|
21447
|
+
if (output2 < window2) return void 0;
|
|
21448
|
+
return `\u6700\u5927\u8F93\u51FA ${formatTokens(output2)} \u4E0D\u5C0F\u4E8E\u5F53\u524D\u603B\u7A97\u53E3 ${formatTokens(window2)}\uFF08\u542B\u8F93\u51FA\u9884\u7559\uFF09\uFF1B\u53EF\u6E05\u7A7A\u6216\u51CF\u5C0F\u6700\u5927\u8F93\u51FA\uFF0C\u6216\u6539\u9009\u66F4\u5927\u7684\u4E0A\u4E0B\u6587\u6863\u4F4D\u3002`;
|
|
21449
|
+
}
|
|
21450
|
+
function contextTierConflict(reference, tier, output2) {
|
|
21451
|
+
if (output2 === void 0) return void 0;
|
|
21452
|
+
const window2 = contextTierWindow(tier, reference);
|
|
21453
|
+
if (output2 < window2) return void 0;
|
|
21454
|
+
const preset = CONTEXT_WINDOW_PRESETS.find((item) => item.id === tier);
|
|
21455
|
+
return `\u65E0\u6CD5\u5207\u6362\u5230\u300C${preset?.label ?? tier}\u300D\u6863\uFF1A\u6700\u5927\u8F93\u51FA ${formatTokens(output2)} \u4E0D\u5C0F\u4E8E\u8BE5\u6863\u4F4D\u7684\u603B\u7A97\u53E3 ${formatTokens(window2)}\uFF08\u542B\u8F93\u51FA\u9884\u7559\uFF09\uFF1B\u8BF7\u5148\u6E05\u7A7A\u6216\u51CF\u5C0F\u6700\u5927\u8F93\u51FA\uFF0C\u5F53\u524D\u6863\u4F4D\u4FDD\u6301\u4E0D\u53D8\u3002`;
|
|
21456
|
+
}
|
|
21457
|
+
function OptionalNumberField({ id, field, value, disabled, restricted = false, invalid = false, conflict, maxOutputLimit, resetToken, onSave }) {
|
|
20966
21458
|
const spec = NUMERIC_FIELDS[field];
|
|
20967
21459
|
const mounted = useMounted();
|
|
20968
|
-
const [draft, setDraft] =
|
|
20969
|
-
const [error62, setError] =
|
|
20970
|
-
|
|
21460
|
+
const [draft, setDraft] = React2.useState(void 0);
|
|
21461
|
+
const [error62, setError] = React2.useState(void 0);
|
|
21462
|
+
React2.useEffect(() => {
|
|
20971
21463
|
setDraft(void 0);
|
|
20972
21464
|
setError(void 0);
|
|
20973
21465
|
}, [value, resetToken]);
|
|
@@ -20996,11 +21488,11 @@ function OptionalNumberField({ id, field, value, disabled, restricted = false, i
|
|
|
20996
21488
|
setError(void 0);
|
|
20997
21489
|
} else setError("\u8BBE\u7F6E\u672A\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5\u3002");
|
|
20998
21490
|
};
|
|
20999
|
-
return
|
|
21491
|
+
return h2(
|
|
21000
21492
|
"div",
|
|
21001
21493
|
{ className: "odc-field odc-field-compact" },
|
|
21002
|
-
|
|
21003
|
-
|
|
21494
|
+
h2("label", { htmlFor: id }, spec.label),
|
|
21495
|
+
h2("input", {
|
|
21004
21496
|
id,
|
|
21005
21497
|
className: "odc-input",
|
|
21006
21498
|
type: "number",
|
|
@@ -21017,20 +21509,80 @@ function OptionalNumberField({ id, field, value, disabled, restricted = false, i
|
|
|
21017
21509
|
void commit();
|
|
21018
21510
|
}
|
|
21019
21511
|
}),
|
|
21020
|
-
|
|
21021
|
-
className: error62 === void 0 ? "odc-hint" : "odc-hint odc-field-error",
|
|
21512
|
+
h2("small", {
|
|
21513
|
+
className: error62 === void 0 && conflict === void 0 ? "odc-hint" : "odc-hint odc-field-error",
|
|
21022
21514
|
id: `${id}-hint`,
|
|
21023
|
-
...error62 === void 0 ? {} : { role: "alert" }
|
|
21024
|
-
}, error62 ?? (restricted ? field === "temperature" ? "Messages \u4EC5\u63A5\u53D7 1\uFF1B\u5EFA\u8BAE\u7559\u7A7A\uFF0C\u4E14\u52FF\u540C\u65F6\u8BBE\u7F6E Top P\u3002" : "Messages \u4EC5\u63A5\u53D7 0.99\uFF1B\u5EFA\u8BAE\u7559\u7A7A\uFF0C\u4E14\u52FF\u540C\u65F6\u8BBE\u7F6E\u6E29\u5EA6\u3002" : maxOutputLimit !== void 0 ? `Messages \u6700\u5927\u8F93\u51FA ${maxOutputLimit}\uFF1B\u7559\u7A7A\u7EE7\u627F\u9ED8\u8BA4\u3002` : spec.hint))
|
|
21515
|
+
...error62 === void 0 && conflict === void 0 ? {} : { role: "alert" }
|
|
21516
|
+
}, error62 ?? conflict ?? (restricted ? field === "temperature" ? "Messages \u4EC5\u63A5\u53D7 1\uFF1B\u5EFA\u8BAE\u7559\u7A7A\uFF0C\u4E14\u52FF\u540C\u65F6\u8BBE\u7F6E Top P\u3002" : "Messages \u4EC5\u63A5\u53D7 0.99\uFF1B\u5EFA\u8BAE\u7559\u7A7A\uFF0C\u4E14\u52FF\u540C\u65F6\u8BBE\u7F6E\u6E29\u5EA6\u3002" : maxOutputLimit !== void 0 ? `Messages \u6700\u5927\u8F93\u51FA ${maxOutputLimit}\uFF1B\u7559\u7A7A\u7EE7\u627F\u9ED8\u8BA4\u3002` : spec.hint))
|
|
21517
|
+
);
|
|
21518
|
+
}
|
|
21519
|
+
function ContextWindowField({ id, reference, settings, disabled, reason, onSelect }) {
|
|
21520
|
+
const tier = selectedContextTier(settings);
|
|
21521
|
+
const legacy = settings.contextTier === void 0 && settings.contextWindow !== void 0;
|
|
21522
|
+
const both = settings.contextTier !== void 0 && settings.contextWindow !== void 0;
|
|
21523
|
+
const current = effectiveContextWindow(reference, settings.contextWindow, settings.contextTier);
|
|
21524
|
+
const requested = legacy ? void 0 : CONTEXT_WINDOW_PRESETS.find((preset) => preset.id === (tier ?? "default"))?.tokens;
|
|
21525
|
+
const clamped = requested !== void 0 && reference !== void 0 && current < requested;
|
|
21526
|
+
const note = legacy ? "\uFF1B\u65E7\u81EA\u5B9A\u4E49\u7A97\u53E3\u6309\u539F\u503C\u7EE7\u7EED\u751F\u6548" : clamped ? `\uFF1B\u53C2\u8003\u5BB9\u91CF ${formatTokens(reference ?? 0)}\uFF0C\u6240\u9009\u6863\u4F4D\u5DF2\u6309\u53C2\u8003\u5BB9\u91CF\u9650\u5E45` : "";
|
|
21527
|
+
const reasonId = `${id}-reason`;
|
|
21528
|
+
return h2(
|
|
21529
|
+
"fieldset",
|
|
21530
|
+
{ className: "odc-context", "aria-describedby": reason === void 0 ? void 0 : reasonId },
|
|
21531
|
+
h2("legend", { className: "odc-context-legend" }, "\u4E0A\u4E0B\u6587\u7A97\u53E3\uFF08\u8F93\u5165 + \u8F93\u51FA\u5408\u8BA1\uFF09"),
|
|
21532
|
+
h2(
|
|
21533
|
+
"div",
|
|
21534
|
+
{ className: "odc-context-options" },
|
|
21535
|
+
CONTEXT_WINDOW_PRESETS.map((preset) => {
|
|
21536
|
+
const available = contextTierAvailable(preset.id, reference);
|
|
21537
|
+
const inputId = `${id}-${preset.id}`;
|
|
21538
|
+
const hintId = `${inputId}-hint`;
|
|
21539
|
+
return h2(
|
|
21540
|
+
"label",
|
|
21541
|
+
{
|
|
21542
|
+
className: "odc-context-option",
|
|
21543
|
+
key: preset.id,
|
|
21544
|
+
htmlFor: inputId,
|
|
21545
|
+
"data-preset": preset.id,
|
|
21546
|
+
"data-available": available ? "true" : "false"
|
|
21547
|
+
},
|
|
21548
|
+
h2("input", {
|
|
21549
|
+
id: inputId,
|
|
21550
|
+
type: "radio",
|
|
21551
|
+
name: id,
|
|
21552
|
+
value: preset.id,
|
|
21553
|
+
checked: preset.id === tier,
|
|
21554
|
+
disabled: disabled || !available,
|
|
21555
|
+
"aria-describedby": reason === void 0 ? hintId : `${hintId} ${reasonId}`,
|
|
21556
|
+
onChange: () => {
|
|
21557
|
+
onSelect(preset.id);
|
|
21558
|
+
}
|
|
21559
|
+
}),
|
|
21560
|
+
h2(
|
|
21561
|
+
"span",
|
|
21562
|
+
{ className: "odc-context-copy" },
|
|
21563
|
+
h2("strong", null, preset.label),
|
|
21564
|
+
h2("small", { className: "odc-hint", id: hintId }, available ? `${formatTokens(preset.tokens)} tokens` : `${formatTokens(preset.tokens)} tokens \xB7 \u8D85\u8FC7\u53C2\u8003\u5BB9\u91CF ${formatTokens(reference ?? 0)}`)
|
|
21565
|
+
)
|
|
21566
|
+
);
|
|
21567
|
+
})
|
|
21568
|
+
),
|
|
21569
|
+
reason === void 0 ? null : h2("small", { className: "odc-hint", id: reasonId }, reason),
|
|
21570
|
+
legacy ? h2("p", { className: "odc-context-legacy", role: "status" }, `\u65E7\u81EA\u5B9A\u4E49 ${formatTokens(settings.contextWindow ?? 0)}\uFF0C\u9009\u62E9\u6863\u4F4D\u66FF\u6362`) : null,
|
|
21571
|
+
both ? h2("p", { className: "odc-context-legacy", role: "status" }, `\u65E7\u81EA\u5B9A\u4E49 ${formatTokens(settings.contextWindow ?? 0)} \u4E0E\u6240\u9009\u6863\u4F4D\u540C\u65F6\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6863\u4F4D\u4EE5\u53EA\u4FDD\u7559\u5176\u4E00\u3002`) : null,
|
|
21572
|
+
h2(
|
|
21573
|
+
"small",
|
|
21574
|
+
{ className: "odc-hint" },
|
|
21575
|
+
`\u5F53\u524D\u603B\u7A97\u53E3 ${formatTokens(current)} tokens\uFF08\u542B\u8F93\u51FA\u9884\u7559\uFF09${note}\u3002`
|
|
21576
|
+
)
|
|
21025
21577
|
);
|
|
21026
21578
|
}
|
|
21027
21579
|
function EffortField({ id, model, value, disabled, pending, disabledReason, onSave }) {
|
|
21028
21580
|
const mounted = useMounted();
|
|
21029
|
-
const [editing, setEditing] =
|
|
21030
|
-
const [draft, setDraft] =
|
|
21031
|
-
const [baseValue, setBaseValue] =
|
|
21032
|
-
const [saving, setSaving] =
|
|
21033
|
-
const [error62, setError] =
|
|
21581
|
+
const [editing, setEditing] = React2.useState(false);
|
|
21582
|
+
const [draft, setDraft] = React2.useState(value ?? "");
|
|
21583
|
+
const [baseValue, setBaseValue] = React2.useState(value);
|
|
21584
|
+
const [saving, setSaving] = React2.useState(false);
|
|
21585
|
+
const [error62, setError] = React2.useState(void 0);
|
|
21034
21586
|
const listed = model.reasoningEfforts ?? [];
|
|
21035
21587
|
const invalidDefault = value !== void 0 && !listed.includes(value);
|
|
21036
21588
|
const invalidDraft = editing && draft !== "" && !listed.includes(draft);
|
|
@@ -21070,7 +21622,7 @@ function EffortField({ id, model, value, disabled, pending, disabledReason, onSa
|
|
|
21070
21622
|
if (mounted.current) setSaving(false);
|
|
21071
21623
|
}
|
|
21072
21624
|
};
|
|
21073
|
-
return
|
|
21625
|
+
return h2(
|
|
21074
21626
|
"div",
|
|
21075
21627
|
{
|
|
21076
21628
|
className: "odc-field odc-field-compact odc-effort",
|
|
@@ -21081,11 +21633,11 @@ function EffortField({ id, model, value, disabled, pending, disabledReason, onSa
|
|
|
21081
21633
|
cancel();
|
|
21082
21634
|
}
|
|
21083
21635
|
},
|
|
21084
|
-
editing ?
|
|
21085
|
-
|
|
21636
|
+
editing ? h2(
|
|
21637
|
+
React2.Fragment,
|
|
21086
21638
|
null,
|
|
21087
|
-
|
|
21088
|
-
|
|
21639
|
+
h2("label", { htmlFor: id }, "\u9ED8\u8BA4\u601D\u8003\u6DF1\u5EA6"),
|
|
21640
|
+
h2("select", {
|
|
21089
21641
|
id,
|
|
21090
21642
|
className: "odc-input",
|
|
21091
21643
|
value: draft,
|
|
@@ -21097,25 +21649,25 @@ function EffortField({ id, model, value, disabled, pending, disabledReason, onSa
|
|
|
21097
21649
|
setError(void 0);
|
|
21098
21650
|
}
|
|
21099
21651
|
}, [
|
|
21100
|
-
|
|
21101
|
-
...options.map((effort) =>
|
|
21652
|
+
h2("option", { key: "", value: "" }, "\u7EE7\u627F\u9ED8\u8BA4"),
|
|
21653
|
+
...options.map((effort) => h2("option", { key: effort, value: effort, disabled: !listed.includes(effort) }, listed.includes(effort) ? effort : `${effort}\uFF08\u5F53\u524D\u4E0D\u53EF\u7528\uFF09`))
|
|
21102
21654
|
]),
|
|
21103
|
-
|
|
21655
|
+
h2(
|
|
21104
21656
|
"div",
|
|
21105
21657
|
{ className: "odc-effort-actions" },
|
|
21106
|
-
|
|
21658
|
+
h2("button", { className: "odc-button odc-button-small odc-button-primary", type: "button", disabled: busy || disabled || invalidDraft, "aria-label": "\u4FDD\u5B58\u9ED8\u8BA4\u601D\u8003\u6DF1\u5EA6", onClick: () => {
|
|
21107
21659
|
void save();
|
|
21108
21660
|
} }, saving ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58"),
|
|
21109
|
-
|
|
21661
|
+
h2("button", { className: "odc-button odc-button-small", type: "button", disabled: saving, "aria-label": "\u53D6\u6D88\u7F16\u8F91\u9ED8\u8BA4\u601D\u8003\u6DF1\u5EA6", onClick: cancel }, "\u53D6\u6D88")
|
|
21110
21662
|
)
|
|
21111
|
-
) :
|
|
21112
|
-
|
|
21663
|
+
) : h2(
|
|
21664
|
+
React2.Fragment,
|
|
21113
21665
|
null,
|
|
21114
|
-
|
|
21666
|
+
h2(
|
|
21115
21667
|
"div",
|
|
21116
21668
|
{ className: "odc-effort-head" },
|
|
21117
|
-
|
|
21118
|
-
|
|
21669
|
+
h2("span", { className: "odc-effort-label" }, "\u9ED8\u8BA4\u601D\u8003\u6DF1\u5EA6"),
|
|
21670
|
+
h2("button", {
|
|
21119
21671
|
className: "odc-button odc-button-small",
|
|
21120
21672
|
type: "button",
|
|
21121
21673
|
disabled: busy || disabled || unavailable && value === void 0,
|
|
@@ -21129,13 +21681,13 @@ function EffortField({ id, model, value, disabled, pending, disabledReason, onSa
|
|
|
21129
21681
|
}
|
|
21130
21682
|
}, "\u7F16\u8F91")
|
|
21131
21683
|
),
|
|
21132
|
-
|
|
21684
|
+
h2("p", { className: "odc-effort-value" }, invalidDefault ? `${value}\uFF08\u5F53\u524D\u4E0D\u53EF\u7528\uFF09` : value ?? "\u7EE7\u627F\u9ED8\u8BA4")
|
|
21133
21685
|
),
|
|
21134
|
-
|
|
21686
|
+
h2("small", {
|
|
21135
21687
|
className: "odc-hint",
|
|
21136
21688
|
id: `${id}-hint`
|
|
21137
21689
|
}, hint),
|
|
21138
|
-
error62 === void 0 ? null :
|
|
21690
|
+
error62 === void 0 ? null : h2("small", { className: "odc-hint odc-field-error", id: `${id}-error`, role: "alert" }, error62)
|
|
21139
21691
|
);
|
|
21140
21692
|
}
|
|
21141
21693
|
var PRICE_SITE = "https://corouter.open-design.ai/zh/models/";
|
|
@@ -21147,24 +21699,29 @@ function priceAmount(amount2, currency) {
|
|
|
21147
21699
|
return currency === "USD" ? `$${amount2}` : `${amount2}\uFF08\u5E01\u79CD\u672A\u6807\u660E\uFF09`;
|
|
21148
21700
|
}
|
|
21149
21701
|
function PriceDetails({ tiers }) {
|
|
21150
|
-
return
|
|
21702
|
+
return h2("div", { className: "odc-price-details", "aria-label": "\u5B98\u7F51\u4EF7\u683C\u8BE6\u60C5" }, tiers.map((tier, index) => h2(
|
|
21151
21703
|
"section",
|
|
21152
21704
|
{ className: "odc-price-tier", key: `${index}-${tier.label}` },
|
|
21153
|
-
|
|
21154
|
-
|
|
21705
|
+
h2("strong", null, `${tier.label} \xB7 ${priceUnit(tier)}`),
|
|
21706
|
+
h2("dl", null, [["\u8F93\u5165", tier.input], ["\u8F93\u51FA", tier.output], ["\u7F13\u5B58\u8BFB\u53D6", tier.cacheRead], ["\u7F13\u5B58\u5199\u5165", tier.cacheWrite]].map(([label, value]) => h2("div", { key: label }, h2("dt", null, label), h2("dd", null, priceAmount(value, tier.currency)))))
|
|
21155
21707
|
)));
|
|
21156
21708
|
}
|
|
21157
21709
|
function ModelRow({ model, settings, authoritative, writable, pending, disabledReason, protocol = "chat-completions", price, priceKnown = false, onCommit }) {
|
|
21158
|
-
const id =
|
|
21710
|
+
const id = React2.useId();
|
|
21159
21711
|
const mounted = useMounted();
|
|
21160
|
-
const [error62, setError] =
|
|
21161
|
-
const [resetToken, setResetToken] =
|
|
21712
|
+
const [error62, setError] = React2.useState(void 0);
|
|
21713
|
+
const [resetToken, setResetToken] = React2.useState(0);
|
|
21162
21714
|
const enabled = modelEnabled(model, settings, authoritative);
|
|
21163
21715
|
const imageInput = modelImageInput(model, settings);
|
|
21164
21716
|
const imageInputManual = settings.imageInput !== void 0;
|
|
21165
21717
|
const samplingRestricted = hasRestrictedClaudeSampling(model.id, protocol);
|
|
21166
21718
|
const samplingError = claudeSamplingError(model.id, protocol, settings.temperature, settings.topP);
|
|
21167
21719
|
const outputError = claudeOutputError(model.id, protocol, settings.maxTokens);
|
|
21720
|
+
const effectiveWindow = effectiveContextWindow(model.contextWindow, settings.contextWindow, settings.contextTier);
|
|
21721
|
+
const outputCap = model.maxOutputTokens ?? (protocol === "messages" ? 4096 : void 0);
|
|
21722
|
+
const reserveCandidate = outputCap === void 0 ? void 0 : Math.min(outputCap, Math.floor(effectiveWindow / 4));
|
|
21723
|
+
const autoReserve = reserveCandidate !== void 0 && claudeOutputError(model.id, protocol, reserveCandidate) === void 0 ? reserveCandidate : void 0;
|
|
21724
|
+
const outputConflict = contextCapacityConflict(model.contextWindow, settings);
|
|
21168
21725
|
const hasOverrides = Object.keys(settings).length > 0;
|
|
21169
21726
|
const commit = async (next) => {
|
|
21170
21727
|
const saved = await onCommit(next);
|
|
@@ -21176,23 +21733,35 @@ function ModelRow({ model, settings, authoritative, writable, pending, disabledR
|
|
|
21176
21733
|
if (value === void 0) delete next[key];
|
|
21177
21734
|
else next[key] = value;
|
|
21178
21735
|
if ((key === "temperature" || key === "topP") && value !== void 0) {
|
|
21179
|
-
const
|
|
21180
|
-
if (
|
|
21181
|
-
setError(
|
|
21736
|
+
const reason2 = claudeSamplingError(model.id, protocol, next.temperature, next.topP);
|
|
21737
|
+
if (reason2 !== void 0) {
|
|
21738
|
+
setError(reason2);
|
|
21182
21739
|
return false;
|
|
21183
21740
|
}
|
|
21184
21741
|
}
|
|
21185
21742
|
if (key === "maxTokens" && value !== void 0) {
|
|
21186
|
-
const
|
|
21187
|
-
if (
|
|
21188
|
-
setError(
|
|
21743
|
+
const reason2 = claudeOutputError(model.id, protocol, value);
|
|
21744
|
+
if (reason2 !== void 0) {
|
|
21745
|
+
setError(reason2);
|
|
21189
21746
|
return false;
|
|
21190
21747
|
}
|
|
21191
21748
|
}
|
|
21192
|
-
const
|
|
21193
|
-
|
|
21194
|
-
|
|
21195
|
-
|
|
21749
|
+
const reason = contextCapacityConflict(model.contextWindow, next);
|
|
21750
|
+
if (reason !== void 0) {
|
|
21751
|
+
setError(reason);
|
|
21752
|
+
return false;
|
|
21753
|
+
}
|
|
21754
|
+
setError(void 0);
|
|
21755
|
+
return commit(next);
|
|
21756
|
+
};
|
|
21757
|
+
const selectContextTier = async (tier) => {
|
|
21758
|
+
const next = { ...settings };
|
|
21759
|
+
delete next.contextWindow;
|
|
21760
|
+
if (tier === "default") delete next.contextTier;
|
|
21761
|
+
else next.contextTier = tier;
|
|
21762
|
+
const reason = contextTierConflict(model.contextWindow, tier, next.maxTokens);
|
|
21763
|
+
if (reason !== void 0) {
|
|
21764
|
+
setError(reason);
|
|
21196
21765
|
return false;
|
|
21197
21766
|
}
|
|
21198
21767
|
setError(void 0);
|
|
@@ -21212,20 +21781,22 @@ function ModelRow({ model, settings, authoritative, writable, pending, disabledR
|
|
|
21212
21781
|
};
|
|
21213
21782
|
const imageDisabledReason = pending ? " \xB7 \u6B63\u5728\u4FDD\u5B58" : !writable ? " \xB7 \u914D\u7F6E\u4E0D\u53EF\u5199" : "";
|
|
21214
21783
|
const facts = [
|
|
21215
|
-
`\
|
|
21216
|
-
`\
|
|
21784
|
+
`\u53C2\u8003\u5BB9\u91CF ${formatTokens(model.contextWindow)}`,
|
|
21785
|
+
`\u5F53\u524D\u603B\u7A97\u53E3 ${formatTokens(effectiveWindow)}\uFF08\u542B\u8F93\u51FA\u9884\u7559\uFF09`,
|
|
21786
|
+
`\u8F93\u51FA\u80FD\u529B\u53C2\u8003 ${formatTokens(model.maxOutputTokens)}`,
|
|
21787
|
+
`\u81EA\u52A8\u8F93\u51FA\u9884\u7559 ${formatTokens(autoReserve)}`,
|
|
21217
21788
|
...model.reasoningEfforts === void 0 || model.reasoningEfforts.length === 0 ? [] : [`\u601D\u8003\u6863\u4F4D ${model.reasoningEfforts.join(" / ")}`]
|
|
21218
21789
|
].join(" \xB7 ");
|
|
21219
|
-
return
|
|
21790
|
+
return h2(
|
|
21220
21791
|
"li",
|
|
21221
21792
|
{ className: "odc-model-item" },
|
|
21222
|
-
|
|
21793
|
+
h2(
|
|
21223
21794
|
"div",
|
|
21224
21795
|
{ className: "odc-model-head" },
|
|
21225
|
-
|
|
21796
|
+
h2(
|
|
21226
21797
|
"label",
|
|
21227
21798
|
{ className: "odc-switch odc-model-switch" },
|
|
21228
|
-
|
|
21799
|
+
h2("input", {
|
|
21229
21800
|
type: "checkbox",
|
|
21230
21801
|
checked: enabled,
|
|
21231
21802
|
disabled: !writable || pending,
|
|
@@ -21233,25 +21804,25 @@ function ModelRow({ model, settings, authoritative, writable, pending, disabledR
|
|
|
21233
21804
|
void commit({ ...settings, enabled: event.target.checked });
|
|
21234
21805
|
}
|
|
21235
21806
|
}),
|
|
21236
|
-
|
|
21807
|
+
h2("span", null, h2("strong", null, model.name), h2("code", null, model.id))
|
|
21237
21808
|
),
|
|
21238
|
-
|
|
21809
|
+
h2(
|
|
21239
21810
|
"div",
|
|
21240
21811
|
{ className: "odc-actions" },
|
|
21241
|
-
enabled ? null :
|
|
21242
|
-
|
|
21812
|
+
enabled ? null : h2("span", { className: "odc-chip" }, "\u5DF2\u7981\u7528"),
|
|
21813
|
+
h2("button", { className: "odc-button odc-button-small", type: "button", disabled: !writable || pending || !hasOverrides, onClick: () => {
|
|
21243
21814
|
void reset();
|
|
21244
21815
|
} }, "\u91CD\u7F6E")
|
|
21245
21816
|
)
|
|
21246
21817
|
),
|
|
21247
|
-
price !== void 0 ?
|
|
21248
|
-
|
|
21818
|
+
price !== void 0 ? h2("p", { className: "odc-price-summary" }, `\u5B98\u7F51\u53C2\u8003 \xB7 ${price.tiers[0].label} \xB7 \u8F93\u5165 ${priceAmount(price.tiers[0].input, price.tiers[0].currency)} / \u8F93\u51FA ${priceAmount(price.tiers[0].output, price.tiers[0].currency)} \xB7 ${priceUnit(price.tiers[0])}${price.tiers.length > 1 ? ` \xB7 \u5171 ${price.tiers.length} \u6863` : ""}`) : priceKnown ? h2("p", { className: "odc-price-summary" }, "\u5B98\u7F51\u6682\u672A\u5217\u51FA\u6B64\u6A21\u578B\u4EF7\u683C") : null,
|
|
21819
|
+
h2(
|
|
21249
21820
|
"div",
|
|
21250
21821
|
{ className: "odc-model-image" },
|
|
21251
|
-
|
|
21822
|
+
h2(
|
|
21252
21823
|
"label",
|
|
21253
21824
|
{ className: "odc-image-toggle" },
|
|
21254
|
-
|
|
21825
|
+
h2("input", {
|
|
21255
21826
|
type: "checkbox",
|
|
21256
21827
|
checked: imageInput,
|
|
21257
21828
|
disabled: !writable || pending,
|
|
@@ -21262,10 +21833,10 @@ function ModelRow({ model, settings, authoritative, writable, pending, disabledR
|
|
|
21262
21833
|
void commit({ ...settings, imageInput: event.target.checked });
|
|
21263
21834
|
}
|
|
21264
21835
|
}),
|
|
21265
|
-
|
|
21836
|
+
h2("span", null, "\u56FE\u7247\u8F93\u5165")
|
|
21266
21837
|
),
|
|
21267
|
-
|
|
21268
|
-
imageInputManual ?
|
|
21838
|
+
h2("small", { className: "odc-image-state", id: `${id}-image-state` }, imageInputSource(model, settings) + imageDisabledReason),
|
|
21839
|
+
imageInputManual ? h2("button", {
|
|
21269
21840
|
className: "odc-image-reset",
|
|
21270
21841
|
type: "button",
|
|
21271
21842
|
disabled: !writable || pending,
|
|
@@ -21276,33 +21847,44 @@ function ModelRow({ model, settings, authoritative, writable, pending, disabledR
|
|
|
21276
21847
|
}
|
|
21277
21848
|
}, "\u6062\u590D\u81EA\u52A8") : null
|
|
21278
21849
|
),
|
|
21279
|
-
|
|
21850
|
+
h2(
|
|
21280
21851
|
"details",
|
|
21281
21852
|
{ className: "odc-model-details" },
|
|
21282
|
-
|
|
21283
|
-
|
|
21284
|
-
model.id === "claude-opus-5.5" && model.contextWindow === 1e6 ?
|
|
21285
|
-
model.id === "muse-wonder" && model.contextWindow === 1048576 ?
|
|
21286
|
-
samplingRestricted && model.id === "claude-opus-4.8" ?
|
|
21287
|
-
samplingRestricted && model.maxOutputTokens === void 0 && settings.maxTokens === void 0 ?
|
|
21288
|
-
price === void 0 ? null :
|
|
21289
|
-
|
|
21290
|
-
|
|
21853
|
+
h2("summary", { "aria-label": `${model.name} \u53C2\u6570\u8BBE\u7F6E${price === void 0 ? "" : "\u4E0E\u4EF7\u683C"}` }, `${price === void 0 ? "\u53C2\u6570\u8BBE\u7F6E" : "\u53C2\u6570\u4E0E\u4EF7\u683C"} \xB7 ${hasOverrides ? "\u5DF2\u81EA\u5B9A\u4E49" : "\u4F7F\u7528\u9ED8\u8BA4\u503C"}`),
|
|
21854
|
+
h2("p", { className: "odc-model-meta" }, facts),
|
|
21855
|
+
model.id === "claude-opus-5.5" && model.contextWindow === 1e6 ? h2("p", { className: "odc-hint" }, "\u4E0A\u4E0B\u6587 1,000,000 \u4E3A\u5382\u5546\u53C2\u8003\uFF0C\u7F51\u5173\u5B9E\u9645\u5BB9\u91CF\u672A\u9A8C\u8BC1\uFF1B\u6863\u4F4D\u603B\u7A97\u53E3\u4E0D\u4F1A\u8D85\u8FC7\u8BE5\u53C2\u8003\u5BB9\u91CF\u3002") : null,
|
|
21856
|
+
model.id === "muse-wonder" && model.contextWindow === 1048576 ? h2("p", { className: "odc-hint" }, "\u4E0A\u4E0B\u6587 1,048,576 \u4E3A\u6682\u5B9A\u53C2\u8003\uFF0C\u7F51\u5173\u578B\u53F7\u6620\u5C04\u53CA\u5B9E\u9645\u5BB9\u91CF\u672A\u9A8C\u8BC1\uFF1B\u6863\u4F4D\u603B\u7A97\u53E3\u4E0D\u4F1A\u8D85\u8FC7\u8BE5\u53C2\u8003\u5BB9\u91CF\u3002") : null,
|
|
21857
|
+
samplingRestricted && model.id === "claude-opus-4.8" ? h2("p", { className: "odc-hint" }, "\u5382\u5546\u9ED8\u8BA4\u5173\u95ED\u601D\u8003\uFF0C\u9009\u62E9\u601D\u8003\u6DF1\u5EA6\u53EF\u542F\u7528\u81EA\u9002\u5E94\u601D\u8003\uFF1B\u7F51\u5173\u5B9E\u9645\u884C\u4E3A\u53EF\u80FD\u4E0D\u540C\u3002") : null,
|
|
21858
|
+
samplingRestricted && model.maxOutputTokens === void 0 && settings.maxTokens === void 0 ? h2("p", { className: "odc-hint" }, "Messages \u9ED8\u8BA4\u6700\u5927\u8F93\u51FA 4096\uFF1B\u8F83\u9AD8\u601D\u8003\u6DF1\u5EA6\u53EF\u80FD\u9700\u8981\u589E\u5927\u3002") : null,
|
|
21859
|
+
price === void 0 ? null : h2(PriceDetails, { tiers: price.tiers }),
|
|
21860
|
+
h2("p", { className: "odc-hint" }, "\u6570\u503C\u79BB\u5F00\u8F93\u5165\u6846\u540E\u4FDD\u5B58\uFF0C\u7559\u7A7A\u7EE7\u627F\u9ED8\u8BA4\uFF1B\u4E0A\u4E0B\u6587\u7A97\u53E3\u4E3A\u4E09\u6863\u4E92\u65A5\u9009\u62E9\u3002"),
|
|
21861
|
+
h2(
|
|
21291
21862
|
"div",
|
|
21292
21863
|
{ className: "odc-model-editor" },
|
|
21293
|
-
|
|
21864
|
+
h2(ContextWindowField, {
|
|
21865
|
+
id: `${id}-context`,
|
|
21866
|
+
reference: model.contextWindow,
|
|
21867
|
+
settings,
|
|
21868
|
+
disabled: !writable || pending,
|
|
21869
|
+
reason: pending ? "\u6B63\u5728\u4FDD\u5B58\u6A21\u578B\u8BBE\u7F6E\uFF0C\u5B8C\u6210\u540E\u53EF\u7EE7\u7EED\u9009\u62E9\u6863\u4F4D\u3002" : !writable ? disabledReason ?? "\u914D\u7F6E\u4E0D\u53EF\u5199" : void 0,
|
|
21870
|
+
onSelect: (tier) => {
|
|
21871
|
+
void selectContextTier(tier);
|
|
21872
|
+
}
|
|
21873
|
+
}),
|
|
21874
|
+
NUMERIC_ORDER.map((key) => h2(OptionalNumberField, {
|
|
21294
21875
|
key,
|
|
21295
21876
|
id: `${id}-${key}`,
|
|
21296
21877
|
field: key,
|
|
21297
21878
|
value: settings[key],
|
|
21298
21879
|
disabled: !writable || pending,
|
|
21299
21880
|
restricted: samplingRestricted && (key === "temperature" || key === "topP"),
|
|
21300
|
-
invalid: samplingError !== void 0 && settings[key] !== void 0 && (key === "temperature" || key === "topP") || key === "maxTokens" && outputError !== void 0,
|
|
21881
|
+
invalid: samplingError !== void 0 && settings[key] !== void 0 && (key === "temperature" || key === "topP") || key === "maxTokens" && (outputError !== void 0 || outputConflict !== void 0),
|
|
21882
|
+
conflict: key === "maxTokens" ? outputConflict : void 0,
|
|
21301
21883
|
maxOutputLimit: samplingRestricted && key === "maxTokens" ? CLAUDE_MESSAGES_MAX_OUTPUT : void 0,
|
|
21302
21884
|
resetToken,
|
|
21303
21885
|
onSave: (value) => saveField(key, value)
|
|
21304
21886
|
})),
|
|
21305
|
-
|
|
21887
|
+
h2(EffortField, {
|
|
21306
21888
|
id: `${id}-effort`,
|
|
21307
21889
|
model,
|
|
21308
21890
|
value: settings.reasoningEffort,
|
|
@@ -21319,29 +21901,29 @@ function ModelRow({ model, settings, authoritative, writable, pending, disabledR
|
|
|
21319
21901
|
})
|
|
21320
21902
|
)
|
|
21321
21903
|
),
|
|
21322
|
-
error62 !== void 0 ?
|
|
21904
|
+
error62 !== void 0 ? h2("p", { className: "odc-hint odc-field-error", role: "alert" }, error62) : null
|
|
21323
21905
|
);
|
|
21324
21906
|
}
|
|
21325
21907
|
function ModelGroup({ title, group, models, settingsMap, authoritative, writable, pending, disabledReason, protocol, onCommit, prices }) {
|
|
21326
|
-
const [query, setQuery] =
|
|
21327
|
-
const [expanded, setExpanded] =
|
|
21328
|
-
const id =
|
|
21908
|
+
const [query, setQuery] = React2.useState("");
|
|
21909
|
+
const [expanded, setExpanded] = React2.useState(false);
|
|
21910
|
+
const id = React2.useId();
|
|
21329
21911
|
const normalized = query.trim().toLocaleLowerCase();
|
|
21330
21912
|
const groupModels = sortModelsByEnabled(models.filter((model) => model.group === group), settingsMap, authoritative);
|
|
21331
21913
|
const filtered = groupModels.filter((model) => normalized === "" || `${model.name} ${model.id}`.toLocaleLowerCase().includes(normalized));
|
|
21332
21914
|
const visible = normalized !== "" || expanded ? filtered : filtered.slice(0, 6);
|
|
21333
21915
|
const enabledCount = groupModels.filter((model) => modelEnabled(model, settingsMap[model.id], authoritative)).length;
|
|
21334
|
-
return
|
|
21916
|
+
return h2(
|
|
21335
21917
|
"section",
|
|
21336
21918
|
{ className: "odc-card", "aria-labelledby": `${id}-title` },
|
|
21337
|
-
|
|
21919
|
+
h2(
|
|
21338
21920
|
"div",
|
|
21339
21921
|
{ className: "odc-card-head" },
|
|
21340
|
-
|
|
21341
|
-
|
|
21922
|
+
h2("h3", { id: `${id}-title` }, title),
|
|
21923
|
+
h2("span", { className: "odc-model-count" }, `${enabledCount} / ${groupModels.length} \u5DF2\u542F\u7528`)
|
|
21342
21924
|
),
|
|
21343
|
-
|
|
21344
|
-
|
|
21925
|
+
h2("label", { className: "odc-label", htmlFor: `${id}-search` }, `\u641C\u7D22${title}`),
|
|
21926
|
+
h2("input", {
|
|
21345
21927
|
id: `${id}-search`,
|
|
21346
21928
|
className: "odc-input",
|
|
21347
21929
|
type: "search",
|
|
@@ -21349,7 +21931,7 @@ function ModelGroup({ title, group, models, settingsMap, authoritative, writable
|
|
|
21349
21931
|
placeholder: "\u641C\u7D22\u5168\u90E8\u6A21\u578B\u7684\u540D\u79F0\u6216 ID",
|
|
21350
21932
|
onChange: (event) => setQuery(event.target.value)
|
|
21351
21933
|
}),
|
|
21352
|
-
filtered.length === 0 ?
|
|
21934
|
+
filtered.length === 0 ? h2("p", { className: "odc-hint", role: "status" }, "\u6CA1\u6709\u5339\u914D\u7684\u6A21\u578B\u3002") : h2("ul", { id: `${id}-list`, className: "odc-model-list" }, visible.map((model) => h2(ModelRow, {
|
|
21353
21935
|
key: model.id,
|
|
21354
21936
|
model,
|
|
21355
21937
|
settings: modelSettingsEntry(settingsMap, model.id),
|
|
@@ -21362,7 +21944,7 @@ function ModelGroup({ title, group, models, settingsMap, authoritative, writable
|
|
|
21362
21944
|
priceKnown: prices !== void 0 && (prices.state !== "error" || prices.stale),
|
|
21363
21945
|
onCommit: (next) => onCommit(model.id, next)
|
|
21364
21946
|
}))),
|
|
21365
|
-
normalized === "" && filtered.length > 6 ?
|
|
21947
|
+
normalized === "" && filtered.length > 6 ? h2("button", {
|
|
21366
21948
|
type: "button",
|
|
21367
21949
|
className: "odc-button",
|
|
21368
21950
|
style: { marginTop: 12 },
|
|
@@ -21379,16 +21961,16 @@ function Models({ status, formSnapshot, setFormField, pendingField, onRefreshMod
|
|
|
21379
21961
|
const writable = formSnapshot.status === "ready" && formSnapshot.value !== void 0 && formSnapshot.writable;
|
|
21380
21962
|
const disabledReason = formSnapshot.status === "loading" ? "\u6B63\u5728\u8F7D\u5165\u914D\u7F6E" : formSnapshot.status === "unavailable" ? "\u914D\u7F6E\u6682\u4E0D\u53EF\u7528" : !formSnapshot.writable ? "\u5F53\u524D\u8BBE\u7F6E\u4E3A\u53EA\u8BFB" : "\u914D\u7F6E\u4E0D\u53EF\u5199";
|
|
21381
21963
|
const pending = pendingField.includes("modelSettings");
|
|
21382
|
-
const latestSettings =
|
|
21383
|
-
|
|
21964
|
+
const latestSettings = React2.useRef(settingsMap);
|
|
21965
|
+
React2.useEffect(() => {
|
|
21384
21966
|
latestSettings.current = settingsMap;
|
|
21385
21967
|
}, [settingsMap]);
|
|
21386
|
-
const saving =
|
|
21968
|
+
const saving = React2.useRef(false);
|
|
21387
21969
|
const commit = async (id, next) => {
|
|
21388
|
-
if (!writable || saving.current) return false;
|
|
21970
|
+
if (!writable || pending || saving.current) return false;
|
|
21389
21971
|
saving.current = true;
|
|
21390
21972
|
try {
|
|
21391
|
-
return await setFormField("modelSettings", writeModelSettings(latestSettings.current, id, next));
|
|
21973
|
+
return await setFormField("modelSettings", writeModelSettings(latestSettings.current, id, next), latestSettings.current);
|
|
21392
21974
|
} finally {
|
|
21393
21975
|
saving.current = false;
|
|
21394
21976
|
}
|
|
@@ -21400,23 +21982,23 @@ function Models({ status, formSnapshot, setFormField, pendingField, onRefreshMod
|
|
|
21400
21982
|
const reasoningEfforts = modelReasoningEfforts(model, protocol);
|
|
21401
21983
|
return { ...model, ...reasoningEfforts === void 0 ? {} : { reasoningEfforts } };
|
|
21402
21984
|
});
|
|
21403
|
-
return
|
|
21404
|
-
|
|
21985
|
+
return h2(
|
|
21986
|
+
React2.Fragment,
|
|
21405
21987
|
null,
|
|
21406
|
-
|
|
21988
|
+
h2(
|
|
21407
21989
|
"div",
|
|
21408
21990
|
{ className: "odc-card-head" },
|
|
21409
|
-
|
|
21991
|
+
h2(
|
|
21410
21992
|
"div",
|
|
21411
21993
|
null,
|
|
21412
|
-
|
|
21413
|
-
|
|
21994
|
+
h2("h3", null, "\u53EF\u7528\u6A21\u578B"),
|
|
21995
|
+
h2("p", { className: "odc-hint" }, "\u6309\u5206\u7EC4\u641C\u7D22\u6A21\u578B\uFF0C\u8BBE\u7F6E\u542F\u7528\u72B6\u6001\u4E0E\u9ED8\u8BA4\u53C2\u6570\u3002\u4E0A\u4E0B\u6587\u4E3A\u53C2\u8003\u9884\u7B97\uFF1B\u5237\u65B0\u540E\u4F1A\u91C7\u7528\u7F51\u5173\u62A5\u544A\u7684\u8F83\u5C0F\u7A97\u53E3\uFF0C\u5B9E\u9645\u9650\u5236\u53EF\u80FD\u4E0D\u540C\uFF0C\u53EF\u5728\u6A21\u578B\u8BBE\u7F6E\u4E2D\u9009\u62E9\u603B\u7A97\u53E3\u6863\u4F4D\u3002")
|
|
21414
21996
|
),
|
|
21415
|
-
|
|
21997
|
+
h2(
|
|
21416
21998
|
"div",
|
|
21417
21999
|
{ className: "odc-actions" },
|
|
21418
|
-
|
|
21419
|
-
|
|
22000
|
+
h2("span", { className: "odc-label", role: "status" }, `\u6765\u6E90\uFF1A${source}${updated}`),
|
|
22001
|
+
h2("button", {
|
|
21420
22002
|
className: "odc-button",
|
|
21421
22003
|
type: "button",
|
|
21422
22004
|
disabled: refreshingModels || status === void 0 || status.apiKeyConfigured === false,
|
|
@@ -21425,34 +22007,34 @@ function Models({ status, formSnapshot, setFormField, pendingField, onRefreshMod
|
|
|
21425
22007
|
}, refreshingModels ? "\u6B63\u5728\u5237\u65B0\u6A21\u578B\u2026" : "\u5237\u65B0\u6A21\u578B\u76EE\u5F55")
|
|
21426
22008
|
)
|
|
21427
22009
|
),
|
|
21428
|
-
status?.apiKeyConfigured === false ?
|
|
21429
|
-
status?.modelsError !== void 0 ?
|
|
21430
|
-
|
|
21431
|
-
|
|
22010
|
+
status?.apiKeyConfigured === false ? h2("p", { className: "odc-hint" }, "\u5237\u65B0\u6A21\u578B\u9700\u8981\u53EF\u7528\u7684 API Key\uFF1B\u4FDD\u5B58 Key \u540E\u91CD\u8BD5\u3002") : null,
|
|
22011
|
+
status?.modelsError !== void 0 ? h2("p", { className: "odc-notice", "data-kind": "error", role: "alert" }, status.modelsError) : null,
|
|
22012
|
+
h2(NoticeView, { notice }),
|
|
22013
|
+
h2(
|
|
21432
22014
|
"section",
|
|
21433
22015
|
{ className: "odc-card", "aria-label": "\u5B98\u7F51\u6A21\u578B\u4EF7\u683C" },
|
|
21434
|
-
|
|
22016
|
+
h2(
|
|
21435
22017
|
"div",
|
|
21436
22018
|
{ className: "odc-pricing-head" },
|
|
21437
|
-
|
|
21438
|
-
|
|
22019
|
+
h2("h3", null, "\u5B98\u7F51\u53C2\u8003\u4EF7\u683C"),
|
|
22020
|
+
h2("button", { className: "odc-button", type: "button", disabled: refreshingPrices || onRefreshPrices === void 0, onClick: onRefreshPrices }, refreshingPrices ? "\u6B63\u5728\u66F4\u65B0\u4EF7\u683C\u2026" : "\u66F4\u65B0\u4EF7\u683C")
|
|
21439
22021
|
),
|
|
21440
|
-
|
|
21441
|
-
|
|
22022
|
+
h2("p", { className: "odc-hint", role: "status" }, refreshingPrices ? "\u6B63\u5728\u8BFB\u53D6\u5B98\u7F51\u4EF7\u683C\u2026" : prices === void 0 ? "\u7B49\u5F85\u8BFB\u53D6\u5B98\u7F51\u4EF7\u683C\u3002" : prices.state === "error" ? prices.stale ? `\u8BFB\u53D6\u5931\u8D25\uFF0C\u663E\u793A\u4E0A\u6B21\u4EF7\u683C\uFF08${formatTime(prices.fetchedAt)}\uFF09\u3002` : "\u5B98\u7F51\u4EF7\u683C\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002" : `\u5DF2\u66F4\u65B0\uFF1A${formatTime(prices.fetchedAt)}${prices.state === "partial" ? "\uFF1B\u90E8\u5206\u4EF7\u683C\u672A\u80FD\u8BFB\u53D6" : ""}`),
|
|
22023
|
+
h2("p", { className: "odc-hint" }, "\u5B98\u7F51\u5206\u6863\u4EF7\u683C\u4EC5\u4F9B\u53C2\u8003\uFF1B\u5B9E\u9645\u8D39\u7528\u4EE5\u8D26\u6237\u8D26\u5355\u4E3A\u51C6\u3002", " ", h2("a", { className: "odc-link", href: PRICE_SITE, target: "_blank", rel: "noreferrer noopener" }, "\u67E5\u770B\u5B98\u7F51\u4EF7\u683C"))
|
|
21442
22024
|
),
|
|
21443
|
-
models.length === 0 ?
|
|
22025
|
+
models.length === 0 ? h2("p", { className: "odc-hint", role: "status" }, "\u6682\u65E0\u53EF\u7528\u6A21\u578B\uFF1B\u53EF\u5237\u65B0\u6A21\u578B\u5217\u8868\u540E\u91CD\u8BD5\u3002") : h2(
|
|
21444
22026
|
"div",
|
|
21445
22027
|
{ className: "odc-model-groups" },
|
|
21446
|
-
|
|
21447
|
-
|
|
22028
|
+
h2(ModelGroup, { title: "\u5957\u9910\u8D60\u9001\u6A21\u578B", group: "plan", models, settingsMap, authoritative, writable, pending, disabledReason, protocol, onCommit: commit, prices }),
|
|
22029
|
+
h2(ModelGroup, { title: "\u4ED8\u8D39\u6A21\u578B", group: "paid", models, settingsMap, authoritative, writable, pending, disabledReason, protocol, onCommit: commit, prices })
|
|
21448
22030
|
)
|
|
21449
22031
|
);
|
|
21450
22032
|
}
|
|
21451
22033
|
function NumberField({ id, label, hint, value, min, max, integer: integer2, disabled, onCommit }) {
|
|
21452
22034
|
const mounted = useMounted();
|
|
21453
|
-
const [draft, setDraft] =
|
|
21454
|
-
const [error62, setError] =
|
|
21455
|
-
|
|
22035
|
+
const [draft, setDraft] = React2.useState(String(value));
|
|
22036
|
+
const [error62, setError] = React2.useState(void 0);
|
|
22037
|
+
React2.useEffect(() => {
|
|
21456
22038
|
setDraft(String(value));
|
|
21457
22039
|
setError(void 0);
|
|
21458
22040
|
}, [value]);
|
|
@@ -21472,11 +22054,11 @@ function NumberField({ id, label, hint, value, min, max, integer: integer2, disa
|
|
|
21472
22054
|
if (saved) setError(void 0);
|
|
21473
22055
|
else setError("\u8BBE\u7F6E\u672A\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5\u3002");
|
|
21474
22056
|
};
|
|
21475
|
-
return
|
|
22057
|
+
return h2(
|
|
21476
22058
|
"div",
|
|
21477
22059
|
{ className: "odc-field" },
|
|
21478
|
-
|
|
21479
|
-
|
|
22060
|
+
h2("label", { htmlFor: id }, label),
|
|
22061
|
+
h2("input", {
|
|
21480
22062
|
id,
|
|
21481
22063
|
className: "odc-input",
|
|
21482
22064
|
type: "number",
|
|
@@ -21493,7 +22075,7 @@ function NumberField({ id, label, hint, value, min, max, integer: integer2, disa
|
|
|
21493
22075
|
void commit();
|
|
21494
22076
|
}
|
|
21495
22077
|
}),
|
|
21496
|
-
|
|
22078
|
+
h2("small", {
|
|
21497
22079
|
className: error62 === void 0 ? "odc-hint" : "odc-hint odc-field-error",
|
|
21498
22080
|
id: `${id}-hint`,
|
|
21499
22081
|
...error62 === void 0 ? {} : { role: "alert" }
|
|
@@ -21501,10 +22083,10 @@ function NumberField({ id, label, hint, value, min, max, integer: integer2, disa
|
|
|
21501
22083
|
);
|
|
21502
22084
|
}
|
|
21503
22085
|
function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
21504
|
-
const [apiKeyEnv, setApiKeyEnv] =
|
|
21505
|
-
const [keyNotice, setKeyNotice] =
|
|
22086
|
+
const [apiKeyEnv, setApiKeyEnv] = React2.useState(status?.config.apiKeyEnv ?? "");
|
|
22087
|
+
const [keyNotice, setKeyNotice] = React2.useState(null);
|
|
21506
22088
|
const mounted = useMounted();
|
|
21507
|
-
|
|
22089
|
+
React2.useEffect(() => {
|
|
21508
22090
|
setApiKeyEnv(formSnapshot.value?.apiKeyEnv ?? status?.config.apiKeyEnv ?? "");
|
|
21509
22091
|
}, [formSnapshot.value?.apiKeyEnv, status?.config.apiKeyEnv]);
|
|
21510
22092
|
const writable = formSnapshot.status === "ready" && formSnapshot.value !== void 0 && formSnapshot.writable;
|
|
@@ -21517,6 +22099,8 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21517
22099
|
const imageBudget = formSnapshot.value?.maxRequestImageBytes ?? status?.config.maxRequestImageBytes ?? DEFAULT_MAX_REQUEST_IMAGE_BYTES;
|
|
21518
22100
|
const turnContinuations = formSnapshot.value?.turnReviewMaxContinuations ?? status?.config.turnReviewMaxContinuations ?? DEFAULT_TURN_REVIEW_MAX_CONTINUATIONS;
|
|
21519
22101
|
const turnNoProgress = formSnapshot.value?.turnReviewNoProgressLimit ?? status?.config.turnReviewNoProgressLimit ?? DEFAULT_TURN_REVIEW_NO_PROGRESS_LIMIT;
|
|
22102
|
+
const guard = formSnapshot.value?.emptyTurnGuard ?? status?.config.emptyTurnGuard ?? true;
|
|
22103
|
+
const review = formSnapshot.value?.turnCompletionReview ?? status?.config.turnCompletionReview ?? false;
|
|
21520
22104
|
const selected = API_PROTOCOL_OPTIONS.find((option) => option.id === protocol);
|
|
21521
22105
|
const saveKeyRef = async () => {
|
|
21522
22106
|
const value = apiKeyEnv.trim();
|
|
@@ -21532,25 +22116,34 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21532
22116
|
if (mounted.current) setKeyNotice({ kind: "error", text: GENERIC_ERROR });
|
|
21533
22117
|
}
|
|
21534
22118
|
};
|
|
21535
|
-
return
|
|
21536
|
-
|
|
22119
|
+
return h2(
|
|
22120
|
+
React2.Fragment,
|
|
21537
22121
|
null,
|
|
21538
|
-
|
|
22122
|
+
h2(
|
|
21539
22123
|
"section",
|
|
21540
22124
|
{ className: "odc-card" },
|
|
21541
|
-
|
|
21542
|
-
|
|
21543
|
-
|
|
21544
|
-
checked:
|
|
22125
|
+
h2("h3", null, "\u5F02\u5E38\u7ED3\u675F\u76D1\u63A7"),
|
|
22126
|
+
h2("p", { className: "odc-hint" }, "\u68C0\u6D4B DeepSeek V4.1 Flash \u5DE5\u5177\u5BF9\u8BDD\u4E2D\u7684\u7A7A\u56DE\u7B54\u3001\u534F\u8BAE\u6807\u8BB0\u6B8B\u7559\u6216\u8BF4\u660E\u4E0B\u4E00\u6B65\u540E\u672A\u6267\u884C\u7684\u63D0\u524D\u7ED3\u675F\u3002"),
|
|
22127
|
+
h2("div", { style: { marginTop: 14 } }, h2(Switch, {
|
|
22128
|
+
checked: guard,
|
|
21545
22129
|
disabled: !writable || pendingField.includes("emptyTurnGuard"),
|
|
21546
22130
|
label: "\u542F\u7528\u5F02\u5E38\u7ED3\u675F\u76D1\u63A7",
|
|
21547
|
-
hint: `\u5DF2\u7D2F\u8BA1 ${status?.guardedTurns ?? "\u2014"} \u6B21\u7A7A\u54CD\u5E94\u6216\u6B8B\u7559\u62E6\u622A\u3002\u534F\u8BAE\u7A7A\u54CD\u5E94\u6062\u590D\u6301\u7EED\u5230\u6210\u529F\u6216\u53D6\u6D88\
|
|
22131
|
+
hint: `\u5DF2\u7D2F\u8BA1 ${status?.guardedTurns ?? "\u2014"} \u6B21\u7A7A\u54CD\u5E94\u6216\u6B8B\u7559\u62E6\u622A\u3002\u534F\u8BAE\u7A7A\u54CD\u5E94\u6062\u590D\u6301\u7EED\u5230\u6210\u529F\u6216\u53D6\u6D88\u3002`,
|
|
21548
22132
|
onChange: (checked) => {
|
|
21549
22133
|
void setFormField("emptyTurnGuard", checked);
|
|
21550
22134
|
}
|
|
21551
22135
|
})),
|
|
21552
|
-
|
|
21553
|
-
|
|
22136
|
+
h2("div", { style: { marginTop: 14 } }, h2(Switch, {
|
|
22137
|
+
checked: review,
|
|
22138
|
+
disabled: !writable || !guard || pendingField.includes("turnCompletionReview"),
|
|
22139
|
+
label: "\u542F\u7528\u7ED3\u675F\u56DE\u5408\u6838\u9A8C",
|
|
22140
|
+
hint: !guard ? "\u9700\u8981\u5148\u5F00\u542F\u5F02\u5E38\u7ED3\u675F\u76D1\u63A7\uFF0C\u7ED3\u675F\u56DE\u5408\u6838\u9A8C\u624D\u4F1A\u5DE5\u4F5C\u3002" : "\u56DE\u590D\u7ED3\u675F\u540E\u8981\u6C42\u6A21\u578B\u8C03\u7528\u6536\u5C3E\u5DE5\u5177\u62A5\u544A\u5B8C\u6210\u3001\u7B49\u5F85\u7528\u6237\u3001\u7B49\u5F85\u540E\u53F0\u5DE5\u4F5C\u6216\u963B\u585E\u72B6\u6001\uFF1B\u5173\u95ED\u65F6\u56DE\u590D\u7ED3\u675F\u5373\u7ED3\u675F\u56DE\u5408\u3002\u6536\u5C3E\u6838\u9A8C\u6709\u754C\uFF0C\u53EF\u80FD\u989D\u5916\u6D88\u8017\u989D\u5EA6\u3002",
|
|
22141
|
+
onChange: (checked) => {
|
|
22142
|
+
void setFormField("turnCompletionReview", checked);
|
|
22143
|
+
}
|
|
22144
|
+
})),
|
|
22145
|
+
h2(TurnMonitorView, { turnMonitor: status?.turnMonitor, guardedTurns: status?.guardedTurns, enabled: guard, reviewEnabled: guard && review }),
|
|
22146
|
+
h2(NumberField, {
|
|
21554
22147
|
id: "odc-turn-continuations",
|
|
21555
22148
|
label: "\u6536\u5C3E\u6838\u9A8C\u6700\u5927\u7EED\u529E\u6B21\u6570",
|
|
21556
22149
|
hint: `\u6838\u9A8C\u672A\u5B8C\u6210\u65F6\u6700\u591A\u81EA\u52A8\u7EED\u529E\u7684\u6B21\u6570\uFF0C${MIN_TURN_REVIEW_MAX_CONTINUATIONS}\u2013${MAX_TURN_REVIEW_MAX_CONTINUATIONS}\uFF1B\u9ED8\u8BA4 ${DEFAULT_TURN_REVIEW_MAX_CONTINUATIONS} \u6B21\u3002`,
|
|
@@ -21558,10 +22151,10 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21558
22151
|
min: MIN_TURN_REVIEW_MAX_CONTINUATIONS,
|
|
21559
22152
|
max: MAX_TURN_REVIEW_MAX_CONTINUATIONS,
|
|
21560
22153
|
integer: true,
|
|
21561
|
-
disabled: !writable || pendingField.includes("turnReviewMaxContinuations"),
|
|
22154
|
+
disabled: !writable || !guard || !review || pendingField.includes("turnReviewMaxContinuations"),
|
|
21562
22155
|
onCommit: (value) => setFormField("turnReviewMaxContinuations", value)
|
|
21563
22156
|
}),
|
|
21564
|
-
|
|
22157
|
+
h2(NumberField, {
|
|
21565
22158
|
id: "odc-turn-no-progress",
|
|
21566
22159
|
label: "\u65E0\u8FDB\u5C55\u505C\u6B62\u4E0A\u9650",
|
|
21567
22160
|
hint: `\u8FDE\u7EED\u65E0\u8FDB\u5C55\u7684\u6838\u9A8C\u8FBE\u5230\u8BE5\u6B21\u6570\u5373\u505C\u6B62\u7EED\u529E\uFF0C${MIN_TURN_REVIEW_NO_PROGRESS_LIMIT}\u2013${MAX_TURN_REVIEW_NO_PROGRESS_LIMIT}\uFF1B\u9ED8\u8BA4 ${DEFAULT_TURN_REVIEW_NO_PROGRESS_LIMIT} \u6B21\u3002`,
|
|
@@ -21569,20 +22162,20 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21569
22162
|
min: MIN_TURN_REVIEW_NO_PROGRESS_LIMIT,
|
|
21570
22163
|
max: MAX_TURN_REVIEW_NO_PROGRESS_LIMIT,
|
|
21571
22164
|
integer: true,
|
|
21572
|
-
disabled: !writable || pendingField.includes("turnReviewNoProgressLimit"),
|
|
22165
|
+
disabled: !writable || !guard || !review || pendingField.includes("turnReviewNoProgressLimit"),
|
|
21573
22166
|
onCommit: (value) => setFormField("turnReviewNoProgressLimit", value)
|
|
21574
22167
|
})
|
|
21575
22168
|
),
|
|
21576
|
-
|
|
22169
|
+
h2(
|
|
21577
22170
|
"section",
|
|
21578
22171
|
{ className: "odc-card" },
|
|
21579
|
-
|
|
21580
|
-
|
|
21581
|
-
|
|
22172
|
+
h2("h3", null, "\u63A8\u7406\u534F\u8BAE"),
|
|
22173
|
+
h2("p", { className: "odc-hint" }, "\u9009\u62E9\u5F53\u524D\u7F51\u5173\u652F\u6301\u7684\u63A8\u7406\u534F\u8BAE\u3002\u6A21\u578B\u76EE\u5F55\u59CB\u7EC8\u4ECE\u8BE5\u7F51\u5173\u8BFB\u53D6\u3002"),
|
|
22174
|
+
h2(
|
|
21582
22175
|
"div",
|
|
21583
22176
|
{ className: "odc-field" },
|
|
21584
|
-
|
|
21585
|
-
|
|
22177
|
+
h2("label", { htmlFor: "odc-api-protocol" }, "API \u534F\u8BAE"),
|
|
22178
|
+
h2("select", {
|
|
21586
22179
|
id: "odc-api-protocol",
|
|
21587
22180
|
className: "odc-input",
|
|
21588
22181
|
value: protocol,
|
|
@@ -21590,37 +22183,37 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21590
22183
|
onChange: (event) => {
|
|
21591
22184
|
void setFormField("apiProtocol", event.target.value);
|
|
21592
22185
|
}
|
|
21593
|
-
}, API_PROTOCOL_OPTIONS.map((option) =>
|
|
21594
|
-
|
|
22186
|
+
}, API_PROTOCOL_OPTIONS.map((option) => h2("option", { key: option.id, value: option.id }, option.name))),
|
|
22187
|
+
h2("small", { className: "odc-hint" }, selected?.description ?? "\u9009\u62E9\u4E0E\u7F51\u5173\u517C\u5BB9\u7684\u63A8\u7406\u534F\u8BAE\u3002")
|
|
21595
22188
|
),
|
|
21596
|
-
|
|
22189
|
+
h2(
|
|
21597
22190
|
"div",
|
|
21598
22191
|
{ className: "odc-readonly" },
|
|
21599
|
-
|
|
22192
|
+
h2(
|
|
21600
22193
|
"div",
|
|
21601
22194
|
null,
|
|
21602
|
-
|
|
21603
|
-
|
|
22195
|
+
h2("span", { className: "odc-label" }, "\u5F53\u524D\u7F51\u5173\u5730\u5740\uFF08\u53EA\u8BFB\uFF09"),
|
|
22196
|
+
h2("code", { className: "odc-code" }, baseURL === "" ? "\u2014" : baseURL)
|
|
21604
22197
|
),
|
|
21605
|
-
|
|
22198
|
+
h2(
|
|
21606
22199
|
"div",
|
|
21607
22200
|
null,
|
|
21608
|
-
|
|
21609
|
-
|
|
22201
|
+
h2("span", { className: "odc-label" }, "\u5F53\u524D\u63A8\u7406\u8DEF\u5F84\uFF08\u53EA\u8BFB\uFF09"),
|
|
22202
|
+
h2("code", { className: "odc-code" }, protocolEndpoint(baseURL, protocol))
|
|
21610
22203
|
),
|
|
21611
|
-
|
|
22204
|
+
h2("small", { className: "odc-hint" }, "\u5730\u5740\u7531\u63D2\u4EF6\u914D\u7F6E\u63D0\u4F9B\uFF0C\u65E0\u9700\u5728\u6B64\u586B\u5199\uFF1B\u5207\u6362\u534F\u8BAE\u53EA\u6539\u53D8\u8BF7\u6C42\u8DEF\u5F84\u4E0E\u62A5\u6587\u683C\u5F0F\u3002")
|
|
21612
22205
|
)
|
|
21613
22206
|
),
|
|
21614
|
-
|
|
22207
|
+
h2(
|
|
21615
22208
|
"section",
|
|
21616
22209
|
{ className: "odc-card" },
|
|
21617
|
-
|
|
21618
|
-
|
|
21619
|
-
|
|
22210
|
+
h2("h3", null, "\u51ED\u636E\u4E0E\u7F51\u5173"),
|
|
22211
|
+
h2("p", { className: "odc-hint" }, "\u8FD9\u91CC\u53EA\u4FDD\u5B58\u51ED\u636E\u5F15\u7528\u540D\u79F0\uFF0C\u4E0D\u586B\u5199 Key \u672C\u8EAB\uFF1B\u7F51\u5173\u5730\u5740\u7531\u63D2\u4EF6\u914D\u7F6E\u6258\u7BA1\u3002"),
|
|
22212
|
+
h2(
|
|
21620
22213
|
"div",
|
|
21621
22214
|
{ className: "odc-field" },
|
|
21622
|
-
|
|
21623
|
-
|
|
22215
|
+
h2("label", { htmlFor: "odc-api-key-env" }, "API Key \u73AF\u5883\u53D8\u91CF / \u51ED\u636E\u5F15\u7528\u540D"),
|
|
22216
|
+
h2("input", {
|
|
21624
22217
|
id: "odc-api-key-env",
|
|
21625
22218
|
className: "odc-input",
|
|
21626
22219
|
type: "text",
|
|
@@ -21630,23 +22223,23 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21630
22223
|
spellCheck: false,
|
|
21631
22224
|
onChange: (event) => setApiKeyEnv(event.target.value)
|
|
21632
22225
|
}),
|
|
21633
|
-
|
|
22226
|
+
h2("small", { className: "odc-hint" }, "\u5F15\u7528\u540D\u5BF9\u5E94\u7684\u51ED\u636E\u4ECD\u4F18\u5148\u4E8E\u672C\u63D2\u4EF6\u4FDD\u5B58\u7684 Key\u3002")
|
|
21634
22227
|
),
|
|
21635
|
-
|
|
22228
|
+
h2(
|
|
21636
22229
|
"div",
|
|
21637
22230
|
{ className: "odc-actions", style: { marginTop: 10 } },
|
|
21638
|
-
|
|
22231
|
+
h2("button", { className: "odc-button", type: "button", disabled: !writable || pendingField.includes("apiKeyEnv"), onClick: () => {
|
|
21639
22232
|
void saveKeyRef();
|
|
21640
22233
|
} }, "\u4FDD\u5B58\u5F15\u7528\u540D")
|
|
21641
22234
|
),
|
|
21642
|
-
|
|
22235
|
+
h2(NoticeView, { notice: keyNotice })
|
|
21643
22236
|
),
|
|
21644
|
-
|
|
22237
|
+
h2(
|
|
21645
22238
|
"section",
|
|
21646
22239
|
{ className: "odc-card" },
|
|
21647
|
-
|
|
21648
|
-
|
|
21649
|
-
|
|
22240
|
+
h2("h3", null, "\u56FE\u7247\u8BF7\u6C42\u9884\u7B97"),
|
|
22241
|
+
h2("p", { className: "odc-hint" }, "\u5386\u53F2\u56FE\u7247\u8D85\u51FA\u9884\u7B97\u65F6\uFF0C\u7531\u5BBF\u4E3B\u5C06\u6700\u65E7\u56FE\u7247\u66FF\u6362\u4E3A\u5360\u4F4D\u7B26\u5E76\u91CD\u8BD5\uFF1B\u539F\u9644\u4EF6\u4FDD\u7559\u3002\u6458\u8981\u8BF7\u6C42\u4E5F\u4F7F\u7528\u6B64\u9884\u7B97\u3002"),
|
|
22242
|
+
h2(NumberField, {
|
|
21650
22243
|
id: "odc-image-budget",
|
|
21651
22244
|
label: "\u5355\u6B21\u8BF7\u6C42\u56FE\u7247\u9884\u7B97\uFF08MiB\uFF09",
|
|
21652
22245
|
hint: "1\u2013100 MiB\uFF1B\u7F51\u5173\u9650\u5236\u8F83\u4F4E\u65F6\u53EF\u8C03\u5C0F\u3002",
|
|
@@ -21658,12 +22251,12 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21658
22251
|
onCommit: (value) => setFormField("maxRequestImageBytes", Math.round(value * 1024 * 1024))
|
|
21659
22252
|
})
|
|
21660
22253
|
),
|
|
21661
|
-
|
|
22254
|
+
h2(
|
|
21662
22255
|
"section",
|
|
21663
22256
|
{ className: "odc-card" },
|
|
21664
|
-
|
|
21665
|
-
|
|
21666
|
-
|
|
22257
|
+
h2("h3", null, "\u8BF7\u6C42\u65F6\u9650\u4E0E\u81EA\u52A8\u5237\u65B0"),
|
|
22258
|
+
h2("p", { className: "odc-hint" }, "\u8F93\u5165\u6709\u6548\u8303\u56F4\u5185\u7684\u6574\u6570\uFF0C\u79BB\u5F00\u8F93\u5165\u6846\u540E\u4FDD\u5B58\u3002"),
|
|
22259
|
+
h2(NumberField, {
|
|
21667
22260
|
id: "odc-request-timeout",
|
|
21668
22261
|
label: "\u8BF7\u6C42\u603B\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",
|
|
21669
22262
|
hint: "\u4ECE\u53D1\u51FA\u8BF7\u6C42\u5230\u54CD\u5E94\u7ED3\u675F\u7684\u4E0A\u9650\uFF0C1000\u20133600000\u3002",
|
|
@@ -21674,7 +22267,7 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21674
22267
|
disabled: !writable || pendingField.includes("requestTimeoutMs"),
|
|
21675
22268
|
onCommit: (value) => setFormField("requestTimeoutMs", value)
|
|
21676
22269
|
}),
|
|
21677
|
-
|
|
22270
|
+
h2(NumberField, {
|
|
21678
22271
|
id: "odc-stream-idle-timeout",
|
|
21679
22272
|
label: "\u6D41\u5F0F\u7A7A\u95F2\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",
|
|
21680
22273
|
hint: "\u6D41\u5F0F\u54CD\u5E94\u65E0\u65B0\u6570\u636E\u7684\u6700\u957F\u7B49\u5F85\uFF0C1000\u20131800000\u3002",
|
|
@@ -21685,7 +22278,7 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21685
22278
|
disabled: !writable || pendingField.includes("streamIdleTimeoutMs"),
|
|
21686
22279
|
onCommit: (value) => setFormField("streamIdleTimeoutMs", value)
|
|
21687
22280
|
}),
|
|
21688
|
-
|
|
22281
|
+
h2(NumberField, {
|
|
21689
22282
|
id: "odc-quota-refresh",
|
|
21690
22283
|
label: "\u989D\u5EA6\u81EA\u52A8\u5237\u65B0\u95F4\u9694\uFF08\u79D2\uFF09",
|
|
21691
22284
|
hint: `5\u20133600\uFF1B\u9ED8\u8BA4 ${DEFAULT_QUOTA_REFRESH_SECONDS} \u79D2\uFF0C\u9875\u9762\u5173\u95ED\u540E\u505C\u6B62\u3002`,
|
|
@@ -21700,12 +22293,12 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21700
22293
|
);
|
|
21701
22294
|
}
|
|
21702
22295
|
function Switch({ checked, disabled, label, ariaLabel, hint, onChange }) {
|
|
21703
|
-
const hintId =
|
|
21704
|
-
return
|
|
22296
|
+
const hintId = React2.useId();
|
|
22297
|
+
return h2(
|
|
21705
22298
|
"label",
|
|
21706
22299
|
{ className: "odc-switch" },
|
|
21707
|
-
|
|
21708
|
-
|
|
22300
|
+
h2("input", { type: "checkbox", checked, disabled, "aria-label": ariaLabel, "aria-describedby": hintId, onChange: (event) => onChange(event.target.checked) }),
|
|
22301
|
+
h2("span", null, h2("span", { className: "odc-switch-text" }, label), h2("small", { className: "odc-hint", id: hintId }, hint))
|
|
21709
22302
|
);
|
|
21710
22303
|
}
|
|
21711
22304
|
function loginInFlight(state) {
|
|
@@ -21720,9 +22313,9 @@ var ACTIVATION_OPEN_LABELS = {
|
|
|
21720
22313
|
};
|
|
21721
22314
|
function LoginApproval({ login, onOpen, opening, notice }) {
|
|
21722
22315
|
const mounted = useMounted();
|
|
21723
|
-
const copyVersion =
|
|
21724
|
-
const [copyState, setCopyState] =
|
|
21725
|
-
|
|
22316
|
+
const copyVersion = React2.useRef(0);
|
|
22317
|
+
const [copyState, setCopyState] = React2.useState("idle");
|
|
22318
|
+
React2.useEffect(() => {
|
|
21726
22319
|
copyVersion.current += 1;
|
|
21727
22320
|
setCopyState("idle");
|
|
21728
22321
|
}, [login?.jobId, login?.state, login?.activationUrl]);
|
|
@@ -21740,15 +22333,15 @@ function LoginApproval({ login, onOpen, opening, notice }) {
|
|
|
21740
22333
|
if (mounted.current && version2 === copyVersion.current) setCopyState("manual");
|
|
21741
22334
|
}
|
|
21742
22335
|
};
|
|
21743
|
-
return
|
|
22336
|
+
return h2(
|
|
21744
22337
|
"div",
|
|
21745
22338
|
{ className: "odc-readonly", "aria-label": "\u8BBE\u5907\u6388\u6743" },
|
|
21746
|
-
|
|
21747
|
-
|
|
21748
|
-
|
|
22339
|
+
h2("span", { className: "odc-label" }, "\u6838\u5BF9\u6388\u6743\u7801"),
|
|
22340
|
+
h2("code", { className: "odc-metric-value", "aria-label": "\u8BBE\u5907\u6388\u6743\u7801" }, login.userCode),
|
|
22341
|
+
h2(
|
|
21749
22342
|
"div",
|
|
21750
22343
|
{ className: "odc-actions" },
|
|
21751
|
-
|
|
22344
|
+
h2("button", {
|
|
21752
22345
|
className: "odc-button odc-button-primary",
|
|
21753
22346
|
type: "button",
|
|
21754
22347
|
disabled: opening === true || onOpen === void 0,
|
|
@@ -21756,40 +22349,40 @@ function LoginApproval({ login, onOpen, opening, notice }) {
|
|
|
21756
22349
|
onOpen?.();
|
|
21757
22350
|
}
|
|
21758
22351
|
}, opening === true ? "\u6B63\u5728\u6253\u5F00\u2026" : "\u5728\u65B0\u7A97\u53E3\u6253\u5F00\u6388\u6743\u9875"),
|
|
21759
|
-
|
|
22352
|
+
h2("button", { className: "odc-button", type: "button", disabled: copyState === "copying", onClick: () => {
|
|
21760
22353
|
void copyLink();
|
|
21761
22354
|
} }, copyState === "copying" ? "\u6B63\u5728\u590D\u5236\u2026" : "\u590D\u5236\u6388\u6743\u94FE\u63A5"),
|
|
21762
|
-
|
|
22355
|
+
h2("a", { className: "odc-link", href: url2, target: "_blank", rel: "noreferrer noopener" }, "\u5B98\u65B9\u6388\u6743\u9875")
|
|
21763
22356
|
),
|
|
21764
|
-
copyState === "copied" ?
|
|
21765
|
-
copyState === "manual" ?
|
|
22357
|
+
copyState === "copied" ? h2("p", { className: "odc-hint", role: "status" }, "\u94FE\u63A5\u5DF2\u590D\u5236\uFF0C\u53EF\u5728\u5E38\u7528\u6D4F\u89C8\u5668\u4E2D\u7C98\u8D34\u6253\u5F00\u3002") : null,
|
|
22358
|
+
copyState === "manual" ? h2(
|
|
21766
22359
|
"label",
|
|
21767
22360
|
{ className: "odc-field" },
|
|
21768
|
-
|
|
21769
|
-
|
|
22361
|
+
h2("span", null, "\u8BF7\u9009\u62E9\u5E76\u590D\u5236\u6388\u6743\u94FE\u63A5"),
|
|
22362
|
+
h2("input", { className: "odc-input", type: "text", readOnly: true, value: url2, onFocus: (event) => event.target.select() })
|
|
21770
22363
|
) : null,
|
|
21771
|
-
notice ?
|
|
21772
|
-
|
|
21773
|
-
|
|
22364
|
+
notice ? h2(NoticeView, { notice }) : null,
|
|
22365
|
+
h2("p", { className: "odc-hint" }, `\u6388\u6743\u7801\u6709\u6548\u81F3 ${formatTime(login.expiresAt)}\u3002\u5728\u6388\u6743\u7A97\u53E3\u786E\u8BA4\u540E\uFF0C\u8FD4\u56DE\u6B64\u9875\u67E5\u770B\u7ED3\u679C\u3002`),
|
|
22366
|
+
h2("p", { className: "odc-hint" }, "\u4E34\u65F6 Chrome \u7A97\u53E3\u9700\u8981\u5355\u72EC\u767B\u5F55\uFF1B\u4E5F\u53EF\u590D\u5236\u94FE\u63A5\u5230\u5DF2\u767B\u5F55\u7684\u5E38\u7528\u6D4F\u89C8\u5668\u3002\u4EC5\u786E\u8BA4\u4F60\u672C\u4EBA\u53D1\u8D77\u7684\u6388\u6743\u3002")
|
|
21774
22367
|
);
|
|
21775
22368
|
}
|
|
21776
22369
|
function Connection({ status, formSnapshot, setFormField, pendingField, caller, onLoginStatus, onStatus }) {
|
|
21777
22370
|
const mounted = useMounted();
|
|
21778
|
-
const actionVersion =
|
|
21779
|
-
const [busy, setBusy] =
|
|
21780
|
-
const [notice, setNotice] =
|
|
21781
|
-
const [apiKey, setApiKey] =
|
|
21782
|
-
const [keyBusy, setKeyBusy] =
|
|
21783
|
-
const [opening, setOpening] =
|
|
21784
|
-
const [activationNotice, setActivationNotice] =
|
|
21785
|
-
const activationJob =
|
|
21786
|
-
const activationToken =
|
|
21787
|
-
const autoOpenPending =
|
|
21788
|
-
|
|
22371
|
+
const actionVersion = React2.useRef(0);
|
|
22372
|
+
const [busy, setBusy] = React2.useState(false);
|
|
22373
|
+
const [notice, setNotice] = React2.useState(null);
|
|
22374
|
+
const [apiKey, setApiKey] = React2.useState("");
|
|
22375
|
+
const [keyBusy, setKeyBusy] = React2.useState(false);
|
|
22376
|
+
const [opening, setOpening] = React2.useState(false);
|
|
22377
|
+
const [activationNotice, setActivationNotice] = React2.useState(null);
|
|
22378
|
+
const activationJob = React2.useRef(null);
|
|
22379
|
+
const activationToken = React2.useRef(0);
|
|
22380
|
+
const autoOpenPending = React2.useRef(false);
|
|
22381
|
+
React2.useEffect(() => () => {
|
|
21789
22382
|
actionVersion.current += 1;
|
|
21790
22383
|
}, []);
|
|
21791
22384
|
const login = status?.login;
|
|
21792
|
-
|
|
22385
|
+
React2.useEffect(() => {
|
|
21793
22386
|
const job = login?.jobId ?? null;
|
|
21794
22387
|
if (activationJob.current === job) return;
|
|
21795
22388
|
activationJob.current = job;
|
|
@@ -21874,7 +22467,7 @@ function Connection({ status, formSnapshot, setFormField, pendingField, caller,
|
|
|
21874
22467
|
if (mounted.current && activationToken.current === token) setOpening(false);
|
|
21875
22468
|
}
|
|
21876
22469
|
};
|
|
21877
|
-
|
|
22470
|
+
React2.useEffect(() => {
|
|
21878
22471
|
if (!autoOpenPending.current || busy || keyBusy || opening || status === void 0) return;
|
|
21879
22472
|
if (state === "waiting") {
|
|
21880
22473
|
autoOpenPending.current = false;
|
|
@@ -21885,18 +22478,18 @@ function Connection({ status, formSnapshot, setFormField, pendingField, caller,
|
|
|
21885
22478
|
}, [state, login?.jobId, busy, keyBusy, opening, status]);
|
|
21886
22479
|
const desktopChecked = formSnapshot.value?.useDesktopCredential ?? status?.config.useDesktopCredential ?? true;
|
|
21887
22480
|
const keySource = status?.apiKeySource === "reference" ? `\u73AF\u5883\u6216\u51ED\u636E\u5F15\u7528\uFF08${status.config.apiKeyEnv}\uFF09` : status?.apiKeySource === "stored" ? "\u5DF2\u4FDD\u5B58\u7684 API Key" : status?.apiKeySource === "device" ? "\u8BBE\u5907\u6388\u6743" : status?.apiKeyConfigured ? "\u5C1A\u672A\u786E\u8BA4" : "\u672A\u914D\u7F6E";
|
|
21888
|
-
return
|
|
21889
|
-
|
|
22481
|
+
return h2(
|
|
22482
|
+
React2.Fragment,
|
|
21890
22483
|
null,
|
|
21891
|
-
|
|
22484
|
+
h2(
|
|
21892
22485
|
"section",
|
|
21893
22486
|
{ className: "odc-card" },
|
|
21894
|
-
|
|
21895
|
-
|
|
21896
|
-
|
|
22487
|
+
h2("h3", null, "\u8FDE\u63A5\u65B9\u5F0F"),
|
|
22488
|
+
h2("p", { className: "odc-hint" }, "\u4F18\u5148\u590D\u7528 OpenDesign \u684C\u9762\u7AEF\u5DF2\u6709\u767B\u5F55\u6001\uFF0C\u65E0\u9700\u590D\u5236\u684C\u9762\u51ED\u636E\u3002\u5173\u95ED\u540E\u4F7F\u7528\u72EC\u7ACB\u767B\u5F55\u6216\u73AF\u5883\u51ED\u636E\u3002"),
|
|
22489
|
+
h2(
|
|
21897
22490
|
"div",
|
|
21898
22491
|
{ style: { marginTop: 14 } },
|
|
21899
|
-
|
|
22492
|
+
h2(Switch, {
|
|
21900
22493
|
checked: desktopChecked,
|
|
21901
22494
|
disabled: formSnapshot.status !== "ready" || formSnapshot.value === void 0 || !formSnapshot.writable || pendingField.includes("useDesktopCredential"),
|
|
21902
22495
|
label: "\u4F18\u5148\u4F7F\u7528\u684C\u9762\u767B\u5F55\u6001",
|
|
@@ -21906,46 +22499,46 @@ function Connection({ status, formSnapshot, setFormField, pendingField, caller,
|
|
|
21906
22499
|
}
|
|
21907
22500
|
})
|
|
21908
22501
|
),
|
|
21909
|
-
|
|
22502
|
+
h2("p", { className: "odc-meta" }, `\u5F53\u524D\u4F1A\u8BDD\u6765\u6E90\uFF1A${status?.sessionSource === void 0 ? "\u2014" : { desktop: "\u684C\u9762\u767B\u5F55\u6001", login: "\u72EC\u7ACB\u767B\u5F55", environment: "\u73AF\u5883\u51ED\u636E" }[status.sessionSource]}`)
|
|
21910
22503
|
),
|
|
21911
|
-
|
|
22504
|
+
h2(
|
|
21912
22505
|
"section",
|
|
21913
22506
|
{ className: "odc-card" },
|
|
21914
|
-
|
|
21915
|
-
|
|
21916
|
-
|
|
22507
|
+
h2("h3", null, "\u8BBE\u5907\u6388\u6743\u767B\u5F55"),
|
|
22508
|
+
h2("p", { className: "odc-hint" }, "\u7533\u8BF7\u6388\u6743\u7801\u540E\uFF0C\u7531\u63D2\u4EF6\u542F\u52A8\u4E34\u65F6\u7A97\u53E3\u663E\u793A\u5B98\u65B9\u6388\u6743\u9875\uFF0C\u4E5F\u53EF\u590D\u5236\u94FE\u63A5\u5230\u4F60\u81EA\u5DF1\u7684\u5E38\u7528\u6D4F\u89C8\u5668\u3002\u786E\u8BA4\u540E\u81EA\u52A8\u4FDD\u5B58\u8BBE\u5907\u4EE4\u724C\uFF0C\u7528\u4E8E\u67E5\u8BE2\u989D\u5EA6\u53CA\u5B98\u65B9\u7F51\u5173\u63A8\u7406\u3002"),
|
|
22509
|
+
h2(
|
|
21917
22510
|
"div",
|
|
21918
22511
|
{ className: "odc-actions", style: { marginTop: 14 } },
|
|
21919
|
-
|
|
22512
|
+
h2("button", { className: "odc-button odc-button-primary", type: "button", disabled: status === void 0 || busy || keyBusy || inFlight, onClick: () => {
|
|
21920
22513
|
void startLogin();
|
|
21921
22514
|
} }, "\u5F00\u59CB\u8BBE\u5907\u6388\u6743"),
|
|
21922
|
-
inFlight ?
|
|
22515
|
+
inFlight ? h2("button", { className: "odc-button", type: "button", disabled: busy || keyBusy || login?.jobId == null, onClick: () => {
|
|
21923
22516
|
void cancelLogin();
|
|
21924
22517
|
} }, "\u53D6\u6D88\u767B\u5F55") : null,
|
|
21925
|
-
|
|
22518
|
+
h2("a", { className: "odc-link", href: OFFICIAL_SITE, target: "_blank", rel: "noreferrer noopener" }, "\u6253\u5F00 CoRouter \u5B98\u7F51")
|
|
21926
22519
|
),
|
|
21927
|
-
|
|
22520
|
+
h2(LoginApproval, { login, onOpen: () => {
|
|
21928
22521
|
void openActivation();
|
|
21929
22522
|
}, opening, notice: activationNotice }),
|
|
21930
|
-
|
|
21931
|
-
|
|
22523
|
+
h2("p", { className: "odc-meta", role: state === "error" ? "alert" : "status" }, login?.message ?? LOGIN_LABELS[state]),
|
|
22524
|
+
h2(NoticeView, { notice })
|
|
21932
22525
|
),
|
|
21933
|
-
|
|
22526
|
+
h2(
|
|
21934
22527
|
"section",
|
|
21935
22528
|
{ className: "odc-card" },
|
|
21936
|
-
|
|
21937
|
-
|
|
21938
|
-
|
|
21939
|
-
|
|
22529
|
+
h2("h3", null, "API Key"),
|
|
22530
|
+
h2("p", { className: "odc-meta", "aria-label": "\u5F53\u524D\u751F\u6548\u7684\u63A8\u7406\u51ED\u636E\u6765\u6E90" }, `\u5F53\u524D\u751F\u6548\u6765\u6E90\uFF1A${keySource}`),
|
|
22531
|
+
h2("p", { className: "odc-hint" }, status?.apiKeyConfigured === true ? "\u5F53\u524D\u7F51\u5173\u5DF2\u914D\u7F6E\u63A8\u7406\u51ED\u636E\u3002\u53EF\u5728\u6B64\u4FDD\u5B58\u63D2\u4EF6\u4E13\u7528\u7684 API Key\u3002" : "\u5F53\u524D\u7F51\u5173\u5C1A\u65E0\u63A8\u7406\u51ED\u636E\u3002\u53EF\u5B8C\u6210\u8BBE\u5907\u6388\u6743\u4EE5\u4F7F\u7528\u5B98\u65B9\u7F51\u5173\uFF0C\u6216\u4E3A\u5F53\u524D\u7F51\u5173\u5355\u72EC\u4FDD\u5B58 API Key\u3002"),
|
|
22532
|
+
h2(
|
|
21940
22533
|
"form",
|
|
21941
22534
|
{ onSubmit: (event) => {
|
|
21942
22535
|
void saveKey(event);
|
|
21943
22536
|
} },
|
|
21944
|
-
|
|
22537
|
+
h2(
|
|
21945
22538
|
"div",
|
|
21946
22539
|
{ className: "odc-field" },
|
|
21947
|
-
|
|
21948
|
-
|
|
22540
|
+
h2("label", { htmlFor: "odc-api-key" }, "\u65B0\u7684 API Key"),
|
|
22541
|
+
h2("input", {
|
|
21949
22542
|
id: "odc-api-key",
|
|
21950
22543
|
className: "odc-input",
|
|
21951
22544
|
type: "password",
|
|
@@ -21957,12 +22550,12 @@ function Connection({ status, formSnapshot, setFormField, pendingField, caller,
|
|
|
21957
22550
|
placeholder: "\u4EC5\u7528\u4E8E\u672C\u6B21\u4FDD\u5B58\uFF0C\u4E0D\u4F1A\u56DE\u586B",
|
|
21958
22551
|
onChange: (event) => setApiKey(event.target.value)
|
|
21959
22552
|
}),
|
|
21960
|
-
|
|
22553
|
+
h2("small", { className: "odc-hint" }, "Key \u4FDD\u5B58\u540E\u6E05\u7A7A\uFF0C\u4E0D\u5199\u5165\u7F51\u9875\u5B58\u50A8\u3002\u989D\u5EA6\u5C5E\u4E8E\u5F53\u524D\u767B\u5F55\u8D26\u53F7\uFF0C\u672A\u9A8C\u8BC1\u4E0E\u6B64 Key \u7684\u5DE5\u4F5C\u7A7A\u95F4\u4E00\u81F4\u3002")
|
|
21961
22554
|
),
|
|
21962
|
-
|
|
22555
|
+
h2(
|
|
21963
22556
|
"div",
|
|
21964
22557
|
{ className: "odc-actions", style: { marginTop: 12 } },
|
|
21965
|
-
|
|
22558
|
+
h2("button", { className: "odc-button", type: "submit", disabled: status === void 0 || busy || inFlight || keyBusy || apiKey.trim() === "" }, keyBusy ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58 API Key")
|
|
21966
22559
|
)
|
|
21967
22560
|
)
|
|
21968
22561
|
)
|
|
@@ -21978,50 +22571,58 @@ function tabAfter(current, key) {
|
|
|
21978
22571
|
}
|
|
21979
22572
|
function SettingsPage({ caller, form }) {
|
|
21980
22573
|
const mounted = useMounted();
|
|
21981
|
-
const [tab, setTab] =
|
|
21982
|
-
const [status, setStatus] =
|
|
21983
|
-
const [error62, setError] =
|
|
21984
|
-
const [loading, setLoading] =
|
|
21985
|
-
const [refreshing, setRefreshing] =
|
|
21986
|
-
const [refreshingModels, setRefreshingModels] =
|
|
21987
|
-
const [prices, setPrices] =
|
|
21988
|
-
const [refreshingPrices, setRefreshingPrices] =
|
|
21989
|
-
const pricesBusy =
|
|
21990
|
-
const pricesRequested =
|
|
21991
|
-
const [modelsNotice, setModelsNotice] =
|
|
21992
|
-
const
|
|
21993
|
-
const
|
|
21994
|
-
|
|
21995
|
-
|
|
21996
|
-
|
|
21997
|
-
|
|
21998
|
-
const
|
|
21999
|
-
const
|
|
22000
|
-
const
|
|
22001
|
-
const
|
|
22574
|
+
const [tab, setTab] = React2.useState("overview");
|
|
22575
|
+
const [status, setStatus] = React2.useState();
|
|
22576
|
+
const [error62, setError] = React2.useState();
|
|
22577
|
+
const [loading, setLoading] = React2.useState(true);
|
|
22578
|
+
const [refreshing, setRefreshing] = React2.useState(false);
|
|
22579
|
+
const [refreshingModels, setRefreshingModels] = React2.useState(false);
|
|
22580
|
+
const [prices, setPrices] = React2.useState();
|
|
22581
|
+
const [refreshingPrices, setRefreshingPrices] = React2.useState(false);
|
|
22582
|
+
const pricesBusy = React2.useRef(false);
|
|
22583
|
+
const pricesRequested = React2.useRef(false);
|
|
22584
|
+
const [modelsNotice, setModelsNotice] = React2.useState(null);
|
|
22585
|
+
const writes = React2.useMemo(() => configWritesFor(form), [form]);
|
|
22586
|
+
const writeState = React2.useSyncExternalStore(
|
|
22587
|
+
React2.useCallback((listener) => writes.subscribe(listener), [writes]),
|
|
22588
|
+
React2.useCallback(() => writes.getSnapshot(), [writes]),
|
|
22589
|
+
React2.useCallback(() => writes.getSnapshot(), [writes])
|
|
22590
|
+
);
|
|
22591
|
+
const pendingField = writeState.pendingFields;
|
|
22592
|
+
const [formNotice, setFormNotice] = React2.useState(null);
|
|
22593
|
+
const [scheduleTick, setScheduleTick] = React2.useState(0);
|
|
22594
|
+
const statusVersion = React2.useRef(0);
|
|
22595
|
+
const quotaVersion = React2.useRef(0);
|
|
22596
|
+
const loginVersion = React2.useRef(0);
|
|
22597
|
+
const modelsVersion = React2.useRef(0);
|
|
22598
|
+
const tabRefs = React2.useRef([]);
|
|
22599
|
+
const baseId = React2.useId();
|
|
22002
22600
|
const acceptedFormSnapshot = useFormSnapshot(form);
|
|
22003
|
-
const
|
|
22004
|
-
const
|
|
22005
|
-
const
|
|
22006
|
-
const batchWriteFailed = React.useRef(false);
|
|
22007
|
-
const formSnapshot = React.useMemo(() => ({
|
|
22601
|
+
const batchWriteFailed = React2.useRef(false);
|
|
22602
|
+
const pageBatchActive = React2.useRef(false);
|
|
22603
|
+
const formSnapshot = React2.useMemo(() => ({
|
|
22008
22604
|
...acceptedFormSnapshot,
|
|
22009
|
-
value: acceptedFormSnapshot.value === void 0 ? void 0 : { ...acceptedFormSnapshot.value, ...pendingValues }
|
|
22010
|
-
}), [acceptedFormSnapshot,
|
|
22011
|
-
|
|
22605
|
+
value: acceptedFormSnapshot.value === void 0 ? void 0 : { ...acceptedFormSnapshot.value, ...writeState.pendingValues }
|
|
22606
|
+
}), [acceptedFormSnapshot, writeState]);
|
|
22607
|
+
React2.useEffect(() => {
|
|
22608
|
+
if (pendingField.length !== 0 || !pageBatchActive.current) return;
|
|
22609
|
+
pageBatchActive.current = false;
|
|
22610
|
+
setFormNotice(batchWriteFailed.current ? { kind: "error", text: "\u8BBE\u7F6E\u672A\u4FDD\u5B58\uFF0C\u5DF2\u6062\u590D\u539F\u503C\uFF0C\u8BF7\u91CD\u8BD5\u3002" } : { kind: "status", text: "\u8BBE\u7F6E\u5DF2\u4FDD\u5B58\u3002" });
|
|
22611
|
+
}, [pendingField]);
|
|
22612
|
+
const acceptLoginStatus = React2.useCallback((login) => {
|
|
22012
22613
|
statusVersion.current += 1;
|
|
22013
22614
|
loginVersion.current += 1;
|
|
22014
22615
|
setStatus((previous) => previous === void 0 ? previous : { ...previous, login });
|
|
22015
22616
|
setError(void 0);
|
|
22016
22617
|
}, []);
|
|
22017
|
-
const acceptStatus =
|
|
22618
|
+
const acceptStatus = React2.useCallback((next) => {
|
|
22018
22619
|
statusVersion.current += 1;
|
|
22019
22620
|
loginVersion.current += 1;
|
|
22020
22621
|
setStatus(next);
|
|
22021
22622
|
setModelsNotice(null);
|
|
22022
22623
|
setError(void 0);
|
|
22023
22624
|
}, []);
|
|
22024
|
-
const loadStatus =
|
|
22625
|
+
const loadStatus = React2.useCallback(async () => {
|
|
22025
22626
|
const version2 = ++statusVersion.current;
|
|
22026
22627
|
try {
|
|
22027
22628
|
const next = await caller("status");
|
|
@@ -22034,9 +22635,9 @@ function SettingsPage({ caller, form }) {
|
|
|
22034
22635
|
if (mounted.current && version2 === statusVersion.current) setLoading(false);
|
|
22035
22636
|
}
|
|
22036
22637
|
}, [caller, mounted]);
|
|
22037
|
-
const refreshBusy =
|
|
22038
|
-
const forcedRefreshPending =
|
|
22039
|
-
const refresh =
|
|
22638
|
+
const refreshBusy = React2.useRef(false);
|
|
22639
|
+
const forcedRefreshPending = React2.useRef(false);
|
|
22640
|
+
const refresh = React2.useCallback(async (force = false) => {
|
|
22040
22641
|
if (refreshBusy.current) {
|
|
22041
22642
|
if (force) forcedRefreshPending.current = true;
|
|
22042
22643
|
return;
|
|
@@ -22063,7 +22664,7 @@ function SettingsPage({ caller, form }) {
|
|
|
22063
22664
|
}
|
|
22064
22665
|
}
|
|
22065
22666
|
}, [caller, loadStatus, mounted]);
|
|
22066
|
-
|
|
22667
|
+
React2.useEffect(() => {
|
|
22067
22668
|
void loadStatus();
|
|
22068
22669
|
void refresh();
|
|
22069
22670
|
return () => {
|
|
@@ -22075,21 +22676,14 @@ function SettingsPage({ caller, form }) {
|
|
|
22075
22676
|
forcedRefreshPending.current = false;
|
|
22076
22677
|
};
|
|
22077
22678
|
}, [loadStatus, refresh]);
|
|
22078
|
-
const setFormField =
|
|
22679
|
+
const setFormField = React2.useCallback(async (field, value, baseValue) => {
|
|
22079
22680
|
const snapshot = form.getSnapshot();
|
|
22080
|
-
if (snapshot.status !== "ready" || snapshot.value === void 0 || !snapshot.writable ||
|
|
22081
|
-
if (
|
|
22082
|
-
|
|
22083
|
-
writeVersions.current.set(field, version2);
|
|
22084
|
-
setPendingField([...writeVersions.current.keys()]);
|
|
22085
|
-
setPendingValues((previous) => ({ ...previous, [field]: value }));
|
|
22681
|
+
if (snapshot.status !== "ready" || snapshot.value === void 0 || !snapshot.writable || writes.getSnapshot().pendingFields.includes(field)) return false;
|
|
22682
|
+
if (writes.getSnapshot().pendingFields.length === 0) batchWriteFailed.current = false;
|
|
22683
|
+
pageBatchActive.current = true;
|
|
22086
22684
|
setFormNotice({ kind: "status", text: "\u6B63\u5728\u4FDD\u5B58\u8BBE\u7F6E\u2026" });
|
|
22087
22685
|
try {
|
|
22088
|
-
const
|
|
22089
|
-
writeTail.current = operation.then(() => {
|
|
22090
|
-
}, () => {
|
|
22091
|
-
});
|
|
22092
|
-
const accepted = await operation;
|
|
22686
|
+
const accepted = await writes.set(field, value, baseValue);
|
|
22093
22687
|
if (!accepted) batchWriteFailed.current = true;
|
|
22094
22688
|
if (accepted && mounted.current && (field === "useDesktopCredential" || field === "quotaRefreshSeconds")) void refresh(true);
|
|
22095
22689
|
return accepted;
|
|
@@ -22097,22 +22691,14 @@ function SettingsPage({ caller, form }) {
|
|
|
22097
22691
|
batchWriteFailed.current = true;
|
|
22098
22692
|
return false;
|
|
22099
22693
|
} finally {
|
|
22100
|
-
if (
|
|
22101
|
-
|
|
22102
|
-
|
|
22103
|
-
setPendingValues((previous) => {
|
|
22104
|
-
const next = { ...previous };
|
|
22105
|
-
delete next[field];
|
|
22106
|
-
return next;
|
|
22107
|
-
});
|
|
22108
|
-
setPendingField([...writeVersions.current.keys()]);
|
|
22109
|
-
if (writeVersions.current.size === 0) setFormNotice(batchWriteFailed.current ? { kind: "error", text: "\u8BBE\u7F6E\u672A\u4FDD\u5B58\uFF0C\u5DF2\u6062\u590D\u539F\u503C\uFF0C\u8BF7\u91CD\u8BD5\u3002" } : { kind: "status", text: "\u8BBE\u7F6E\u5DF2\u4FDD\u5B58\u3002" });
|
|
22110
|
-
}
|
|
22694
|
+
if (mounted.current && writes.getSnapshot().pendingFields.length === 0) {
|
|
22695
|
+
pageBatchActive.current = false;
|
|
22696
|
+
setFormNotice(batchWriteFailed.current ? { kind: "error", text: "\u8BBE\u7F6E\u672A\u4FDD\u5B58\uFF0C\u5DF2\u6062\u590D\u539F\u503C\uFF0C\u8BF7\u91CD\u8BD5\u3002" } : { kind: "status", text: "\u8BBE\u7F6E\u5DF2\u4FDD\u5B58\u3002" });
|
|
22111
22697
|
}
|
|
22112
22698
|
}
|
|
22113
|
-
}, [form, mounted, refresh]);
|
|
22114
|
-
const refreshModelsBusy =
|
|
22115
|
-
const refreshModels =
|
|
22699
|
+
}, [form, mounted, refresh, writes]);
|
|
22700
|
+
const refreshModelsBusy = React2.useRef(false);
|
|
22701
|
+
const refreshModels = React2.useCallback(async () => {
|
|
22116
22702
|
if (refreshModelsBusy.current) return;
|
|
22117
22703
|
refreshModelsBusy.current = true;
|
|
22118
22704
|
const version2 = ++modelsVersion.current;
|
|
@@ -22133,7 +22719,7 @@ function SettingsPage({ caller, form }) {
|
|
|
22133
22719
|
}
|
|
22134
22720
|
}
|
|
22135
22721
|
}, [caller, mounted]);
|
|
22136
|
-
const refreshPrices =
|
|
22722
|
+
const refreshPrices = React2.useCallback(async () => {
|
|
22137
22723
|
if (pricesBusy.current) return;
|
|
22138
22724
|
pricesBusy.current = true;
|
|
22139
22725
|
setRefreshingPrices(true);
|
|
@@ -22147,14 +22733,14 @@ function SettingsPage({ caller, form }) {
|
|
|
22147
22733
|
if (mounted.current) setRefreshingPrices(false);
|
|
22148
22734
|
}
|
|
22149
22735
|
}, [caller, mounted]);
|
|
22150
|
-
|
|
22736
|
+
React2.useEffect(() => {
|
|
22151
22737
|
if (tab !== "models" || pricesRequested.current) return;
|
|
22152
22738
|
pricesRequested.current = true;
|
|
22153
22739
|
void refreshPrices();
|
|
22154
22740
|
}, [tab, refreshPrices]);
|
|
22155
22741
|
const loginState = status?.login.state;
|
|
22156
22742
|
const loginActive = loginState !== void 0 && loginInFlight(loginState);
|
|
22157
|
-
|
|
22743
|
+
React2.useEffect(() => {
|
|
22158
22744
|
if (!loginActive) return;
|
|
22159
22745
|
let stopped = false;
|
|
22160
22746
|
const poll = async () => {
|
|
@@ -22177,7 +22763,7 @@ function SettingsPage({ caller, form }) {
|
|
|
22177
22763
|
loginVersion.current += 1;
|
|
22178
22764
|
};
|
|
22179
22765
|
}, [caller, loadStatus, loginActive, mounted, refresh]);
|
|
22180
|
-
|
|
22766
|
+
React2.useEffect(() => {
|
|
22181
22767
|
if (loginState !== "success") return;
|
|
22182
22768
|
void loadStatus();
|
|
22183
22769
|
void refresh(true);
|
|
@@ -22185,11 +22771,11 @@ function SettingsPage({ caller, form }) {
|
|
|
22185
22771
|
const configuredSeconds = formSnapshot.value?.quotaRefreshSeconds ?? status?.config.quotaRefreshSeconds;
|
|
22186
22772
|
const refreshIntervalSeconds = configuredSeconds === void 0 ? DEFAULT_QUOTA_REFRESH_SECONDS : normaliseQuotaRefreshSeconds(configuredSeconds);
|
|
22187
22773
|
const quotaNextRefreshAt = status?.quota.nextRefreshAt;
|
|
22188
|
-
const schedule =
|
|
22774
|
+
const schedule = React2.useMemo(
|
|
22189
22775
|
() => status?.quota.state === "need-login" || status?.quota.autoRefreshPaused ? void 0 : quotaAutoRefresh(refreshIntervalSeconds, quotaNextRefreshAt, Date.now(), Boolean(status?.quota.refreshFailures)),
|
|
22190
22776
|
[refreshIntervalSeconds, quotaNextRefreshAt, status?.quota.state, status?.quota.autoRefreshPaused, status?.quota.refreshFailures, scheduleTick]
|
|
22191
22777
|
);
|
|
22192
|
-
|
|
22778
|
+
React2.useEffect(() => {
|
|
22193
22779
|
if (schedule === void 0) return;
|
|
22194
22780
|
const timer = setTimeout(() => {
|
|
22195
22781
|
void refresh().finally(() => {
|
|
@@ -22204,7 +22790,7 @@ function SettingsPage({ caller, form }) {
|
|
|
22204
22790
|
};
|
|
22205
22791
|
let content;
|
|
22206
22792
|
if (tab === "overview") {
|
|
22207
|
-
content =
|
|
22793
|
+
content = h2(Overview, {
|
|
22208
22794
|
status,
|
|
22209
22795
|
busy: refreshing,
|
|
22210
22796
|
onRefresh: () => {
|
|
@@ -22215,7 +22801,7 @@ function SettingsPage({ caller, form }) {
|
|
|
22215
22801
|
refreshIntervalSeconds
|
|
22216
22802
|
});
|
|
22217
22803
|
} else if (tab === "models") {
|
|
22218
|
-
content =
|
|
22804
|
+
content = h2(Models, {
|
|
22219
22805
|
status,
|
|
22220
22806
|
formSnapshot,
|
|
22221
22807
|
setFormField,
|
|
@@ -22232,16 +22818,16 @@ function SettingsPage({ caller, form }) {
|
|
|
22232
22818
|
}
|
|
22233
22819
|
});
|
|
22234
22820
|
} else if (tab === "connection") {
|
|
22235
|
-
content =
|
|
22821
|
+
content = h2(Connection, { status, formSnapshot, setFormField, pendingField, caller, onLoginStatus: acceptLoginStatus, onStatus: acceptStatus });
|
|
22236
22822
|
} else {
|
|
22237
|
-
content =
|
|
22823
|
+
content = h2(Advanced, { status, formSnapshot, setFormField, pendingField });
|
|
22238
22824
|
}
|
|
22239
|
-
return
|
|
22825
|
+
return h2(
|
|
22240
22826
|
"div",
|
|
22241
22827
|
{ className: "odc-settings" },
|
|
22242
|
-
|
|
22243
|
-
|
|
22244
|
-
|
|
22828
|
+
h2("h2", null, "OpenDesign CoRouter"),
|
|
22829
|
+
h2("p", { className: "odc-intro" }, "\u67E5\u770B\u989D\u5EA6\uFF0C\u7BA1\u7406\u6A21\u578B\u3001\u8FDE\u63A5\u4E0E\u8BF7\u6C42\u8BBE\u7F6E\u3002"),
|
|
22830
|
+
h2("div", { className: "odc-tabs", role: "tablist", "aria-label": "CoRouter \u8BBE\u7F6E\u5206\u7C7B" }, TABS.map((item, index) => h2("button", {
|
|
22245
22831
|
key: item.id,
|
|
22246
22832
|
ref: (node2) => {
|
|
22247
22833
|
tabRefs.current[index] = node2;
|
|
@@ -22262,17 +22848,17 @@ function SettingsPage({ caller, form }) {
|
|
|
22262
22848
|
tabRefs.current[TABS.findIndex((candidate) => candidate.id === next)]?.focus();
|
|
22263
22849
|
}
|
|
22264
22850
|
}, item.label))),
|
|
22265
|
-
acceptedFormSnapshot.status !== "ready" || acceptedFormSnapshot.value === void 0 ?
|
|
22266
|
-
|
|
22267
|
-
|
|
22851
|
+
acceptedFormSnapshot.status !== "ready" || acceptedFormSnapshot.value === void 0 ? h2(NoticeView, { notice: { kind: "status", text: acceptedFormSnapshot.status === "unavailable" ? "\u914D\u7F6E\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u68C0\u67E5\u63D2\u4EF6\u662F\u5426\u5DF2\u542F\u7528\u3002" : "\u6B63\u5728\u8F7D\u5165\u914D\u7F6E\uFF0C\u5B8C\u6210\u540E\u5373\u53EF\u4FEE\u6539\u3002" } }) : !acceptedFormSnapshot.writable ? h2(NoticeView, { notice: { kind: "status", text: "\u5F53\u524D\u8BBE\u7F6E\u4E3A\u53EA\u8BFB\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u4FEE\u6539\u3002" } }) : null,
|
|
22852
|
+
h2(NoticeView, { notice: pendingField.length > 0 ? { kind: "status", text: "\u6B63\u5728\u4FDD\u5B58\u8BBE\u7F6E\u2026" } : formNotice }),
|
|
22853
|
+
h2("div", {
|
|
22268
22854
|
className: "odc-panel",
|
|
22269
22855
|
role: "tabpanel",
|
|
22270
22856
|
id: `${baseId}-panel`,
|
|
22271
22857
|
tabIndex: 0,
|
|
22272
22858
|
"aria-labelledby": `${baseId}-tab-${tab}`
|
|
22273
22859
|
}, content),
|
|
22274
|
-
loading ?
|
|
22275
|
-
error62 !== void 0 ?
|
|
22860
|
+
loading ? h2("p", { className: "odc-meta", role: "status" }, "\u6B63\u5728\u8FDE\u63A5\u670D\u52A1\u2026") : null,
|
|
22861
|
+
error62 !== void 0 ? h2(NoticeView, { notice: { kind: "error", text: error62 } }) : null
|
|
22276
22862
|
);
|
|
22277
22863
|
}
|
|
22278
22864
|
var name = "dsh-opendesign-corouter";
|
|
@@ -22283,6 +22869,8 @@ function apply(ctx) {
|
|
|
22283
22869
|
const caller = createCaller(ctx);
|
|
22284
22870
|
ctx.inject(["configForms"], (scope) => {
|
|
22285
22871
|
const form = scope.configForms.get(SETTINGS_NS);
|
|
22872
|
+
const writes = configWritesFor(form);
|
|
22873
|
+
scope.effect(() => () => writes.dispose(), "opendesign-corouter: shared settings writes");
|
|
22286
22874
|
scope.effect(() => scope.slots.inject("settings.section", () => scope.slots.register({
|
|
22287
22875
|
name: "settings.section",
|
|
22288
22876
|
id: "opendesign-corouter",
|
|
@@ -22290,6 +22878,14 @@ function apply(ctx) {
|
|
|
22290
22878
|
label: () => "OpenDesign CoRouter",
|
|
22291
22879
|
inject: () => ({ caller, form })
|
|
22292
22880
|
}, SettingsPage)), "opendesign-corouter: settings section");
|
|
22881
|
+
scope.inject(["modelDirectories"], (modelScope) => {
|
|
22882
|
+
modelScope.effect(() => modelScope.slots.inject("conversation.input.right", () => modelScope.slots.register({
|
|
22883
|
+
name: "conversation.input.right",
|
|
22884
|
+
id: "opendesign-corouter-context",
|
|
22885
|
+
order: 9,
|
|
22886
|
+
inject: (sessionId) => ({ directory: modelScope.modelDirectories.directoryFor(sessionId).store, form, caller })
|
|
22887
|
+
}, ContextQuickSwitch)), "opendesign-corouter: session context switch");
|
|
22888
|
+
});
|
|
22293
22889
|
});
|
|
22294
22890
|
}
|
|
22295
22891
|
return module.exports;}});
|