dsh-opendesign-corouter 0.1.14 → 0.1.16
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 +8 -4
- package/lib/client-config-writes.d.ts +36 -0
- package/lib/client-context-quick.d.ts +35 -0
- package/lib/client.d.ts +39 -5
- package/lib/client.js +1151 -427
- package/lib/config.d.ts +9 -0
- package/lib/context-budget.d.ts +23 -0
- package/lib/device-auth.d.ts +1 -1
- package/lib/empty-turn.d.ts +0 -5
- package/lib/eot-recovery.d.ts +3 -2
- package/lib/generated/typert.host.js +29 -2
- package/lib/generated/typert.remote-client.js +29 -2
- package/lib/index.d.ts +2 -0
- package/lib/index.js +473 -38
- package/lib/index.js.map +4 -4
- package/lib/model-settings.d.ts +7 -4
- package/lib/remote.d.ts +6 -0
- package/lib/turn-monitor-status.d.ts +16 -0
- package/lib/turn-monitor.d.ts +99 -0
- package/package.json +3 -1
package/lib/client.js
CHANGED
|
@@ -38,7 +38,12 @@ __export(client_exports, {
|
|
|
38
38
|
Overview: () => Overview,
|
|
39
39
|
QuotaView: () => QuotaView,
|
|
40
40
|
SettingsPage: () => SettingsPage,
|
|
41
|
+
TurnMonitorView: () => TurnMonitorView,
|
|
41
42
|
apply: () => apply,
|
|
43
|
+
contextCapacityConflict: () => contextCapacityConflict,
|
|
44
|
+
contextTierAvailable: () => contextTierAvailable,
|
|
45
|
+
contextTierConflict: () => contextTierConflict,
|
|
46
|
+
contextTierWindow: () => contextTierWindow,
|
|
42
47
|
formatRefreshCountdown: () => formatRefreshCountdown,
|
|
43
48
|
formatRelativeDeadline: () => formatRelativeDeadline,
|
|
44
49
|
formatTime: () => formatTime,
|
|
@@ -56,12 +61,13 @@ __export(client_exports, {
|
|
|
56
61
|
protocolEndpoint: () => protocolEndpoint,
|
|
57
62
|
quotaAutoRefresh: () => quotaAutoRefresh,
|
|
58
63
|
quotaStatusView: () => quotaStatusView,
|
|
64
|
+
selectedContextTier: () => selectedContextTier,
|
|
59
65
|
sortModelsByEnabled: () => sortModelsByEnabled,
|
|
60
66
|
tabAfter: () => tabAfter,
|
|
61
67
|
writeModelSettings: () => writeModelSettings
|
|
62
68
|
});
|
|
63
69
|
module.exports = __toCommonJS(client_exports);
|
|
64
|
-
var
|
|
70
|
+
var React2 = __toESM(require("react"), 1);
|
|
65
71
|
|
|
66
72
|
// node_modules/zod/v4/classic/external.js
|
|
67
73
|
var external_exports = {};
|
|
@@ -19562,8 +19568,8 @@ function fromJSONSchema(schema, params) {
|
|
|
19562
19568
|
var RESOLVING = /* @__PURE__ */ Symbol("z.visit/resolving");
|
|
19563
19569
|
function visit(schema, fnOrHandlers) {
|
|
19564
19570
|
const fn = typeof fnOrHandlers === "function" ? fnOrHandlers : (node2, rewritten) => {
|
|
19565
|
-
const
|
|
19566
|
-
return
|
|
19571
|
+
const h3 = fnOrHandlers[node2._zod.def.type];
|
|
19572
|
+
return h3 ? h3(node2, rewritten) : node2;
|
|
19567
19573
|
};
|
|
19568
19574
|
const cache = /* @__PURE__ */ new Map();
|
|
19569
19575
|
function run(s) {
|
|
@@ -19976,12 +19982,27 @@ var API_PROTOCOL_OPTIONS = [
|
|
|
19976
19982
|
{ id: "messages", name: "Anthropic Messages", description: "\u4F7F\u7528 Messages \u8BF7\u6C42\u4E0E\u6D41\u5F0F\u54CD\u5E94\u3002" }
|
|
19977
19983
|
];
|
|
19978
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
|
+
|
|
19979
20000
|
// src/model-settings.ts
|
|
19980
20001
|
function parseModelSettingsMap(value) {
|
|
19981
20002
|
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
19982
20003
|
const keys = Object.keys(value);
|
|
19983
20004
|
if (keys.length > 512) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u6700\u591A\u5141\u8BB8 512 \u4E2A\u6A21\u578B");
|
|
19984
|
-
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"]);
|
|
19985
20006
|
const efforts = ["none", "minimal", "low", "medium", "high", "xhigh", "ultra", "max"];
|
|
19986
20007
|
const out = {};
|
|
19987
20008
|
for (const id of keys) {
|
|
@@ -20014,6 +20035,13 @@ function parseModelSettingsMap(value) {
|
|
|
20014
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`);
|
|
20015
20036
|
parsed[field] = item;
|
|
20016
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
|
+
}
|
|
20017
20045
|
if (settings.reasoningEffort !== void 0) {
|
|
20018
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");
|
|
20019
20047
|
parsed.reasoningEffort = settings.reasoningEffort;
|
|
@@ -20029,6 +20057,10 @@ var MIN_REQUEST_IMAGE_BYTES = 1024 * 1024;
|
|
|
20029
20057
|
var DEFAULT_MAX_REQUEST_IMAGE_BYTES = 20 * 1024 * 1024;
|
|
20030
20058
|
var MAX_REQUEST_IMAGE_BYTES = 100 * 1024 * 1024;
|
|
20031
20059
|
|
|
20060
|
+
// src/turn-monitor-status.ts
|
|
20061
|
+
var REVIEW_DECISIONS = ["continued", "completed", "waiting-user", "waiting-work", "blocked", "limited", "skipped", "unverified"];
|
|
20062
|
+
var REVIEW_REASONS = ["missing-outcome", "pending-action", "reported-complete", "needs-user", "work-running", "reported-blocked", "continuation-limit", "no-progress", "goal-owned", "service-unavailable", "cancelled", "truncated", "request-failed", "disabled", "superseded", "invalid-evidence", "tool-concluded"];
|
|
20063
|
+
|
|
20032
20064
|
// src/remote.ts
|
|
20033
20065
|
var MAX_REVISION = 256;
|
|
20034
20066
|
var MAX_JOB_ID = 128;
|
|
@@ -20210,6 +20242,7 @@ function parseStatusConfig(value) {
|
|
|
20210
20242
|
if (!ENV_REF.test(apiKeyEnv)) throw new Error("\u51ED\u636E\u5F15\u7528\u540D\u5FC5\u987B\u662F\u5408\u6CD5\u6807\u8BC6\u7B26");
|
|
20211
20243
|
return {
|
|
20212
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") },
|
|
20213
20246
|
useDesktopCredential: flag(value.useDesktopCredential, "\u684C\u9762\u767B\u5F55\u6001\u5F00\u5173"),
|
|
20214
20247
|
baseURL: text(value.baseURL, "\u63A8\u7406\u5730\u5740", MAX_BASE_URL),
|
|
20215
20248
|
apiKeyEnv,
|
|
@@ -20218,7 +20251,9 @@ function parseStatusConfig(value) {
|
|
|
20218
20251
|
...value.requestTimeoutMs === void 0 ? {} : { requestTimeoutMs: positiveInteger(value.requestTimeoutMs, "\u8BF7\u6C42\u8D85\u65F6", 36e5, 1e3) },
|
|
20219
20252
|
...value.streamIdleTimeoutMs === void 0 ? {} : { streamIdleTimeoutMs: positiveInteger(value.streamIdleTimeoutMs, "\u6D41\u7A7A\u95F2\u8D85\u65F6", 18e5, 1e3) },
|
|
20220
20253
|
...value.quotaRefreshSeconds === void 0 ? {} : { quotaRefreshSeconds: positiveInteger(value.quotaRefreshSeconds, "\u81EA\u52A8\u5237\u65B0\u95F4\u9694", 3600, 5) },
|
|
20221
|
-
...value.maxRequestImageBytes === void 0 ? {} : { maxRequestImageBytes: positiveInteger(value.maxRequestImageBytes, "\u8BF7\u6C42\u56FE\u7247\u9884\u7B97", MAX_REQUEST_IMAGE_BYTES, MIN_REQUEST_IMAGE_BYTES) }
|
|
20254
|
+
...value.maxRequestImageBytes === void 0 ? {} : { maxRequestImageBytes: positiveInteger(value.maxRequestImageBytes, "\u8BF7\u6C42\u56FE\u7247\u9884\u7B97", MAX_REQUEST_IMAGE_BYTES, MIN_REQUEST_IMAGE_BYTES) },
|
|
20255
|
+
...value.turnReviewMaxContinuations === void 0 ? {} : { turnReviewMaxContinuations: positiveInteger(value.turnReviewMaxContinuations, "\u6536\u5C3E\u7EED\u529E\u6B21\u6570", 10) },
|
|
20256
|
+
...value.turnReviewNoProgressLimit === void 0 ? {} : { turnReviewNoProgressLimit: positiveInteger(value.turnReviewNoProgressLimit, "\u65E0\u8FDB\u5C55\u6B21\u6570", 5) }
|
|
20222
20257
|
};
|
|
20223
20258
|
}
|
|
20224
20259
|
function parseStatus(value) {
|
|
@@ -20243,12 +20278,25 @@ function parseStatus(value) {
|
|
|
20243
20278
|
login: parseLoginState(value.login),
|
|
20244
20279
|
config: parseStatusConfig(value.config),
|
|
20245
20280
|
guardedTurns: count(value.guardedTurns, "\u5DF2\u62E6\u622A\u7A7A\u8F6E\u6570"),
|
|
20281
|
+
...value.turnMonitor === void 0 ? {} : { turnMonitor: parseTurnMonitor(value.turnMonitor) },
|
|
20246
20282
|
models: parsed,
|
|
20247
20283
|
...value.modelsSource === void 0 ? {} : { modelsSource: member(value.modelsSource, ["builtin", "openai"], "\u6A21\u578B\u76EE\u5F55\u6765\u6E90") },
|
|
20248
20284
|
...value.modelsUpdatedAt === void 0 ? {} : { modelsUpdatedAt: isoTime(value.modelsUpdatedAt, "\u6A21\u578B\u66F4\u65B0\u65F6\u95F4") },
|
|
20249
20285
|
...value.modelsError === void 0 ? {} : { modelsError: text(value.modelsError, "\u6A21\u578B\u66F4\u65B0\u63D0\u793A", MAX_MESSAGE) }
|
|
20250
20286
|
};
|
|
20251
20287
|
}
|
|
20288
|
+
function parseTurnMonitor(value) {
|
|
20289
|
+
if (!record2(value)) throw new Error("\u7ED3\u675F\u6838\u9A8C\u72B6\u6001\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
20290
|
+
const last = value.last;
|
|
20291
|
+
if (last !== void 0 && !record2(last)) throw new Error("\u6700\u8FD1\u7ED3\u675F\u6838\u9A8C\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
20292
|
+
return {
|
|
20293
|
+
available: flag(value.available, "\u6536\u5C3E\u6838\u9A8C\u662F\u5426\u53EF\u7528"),
|
|
20294
|
+
checks: count(value.checks, "\u6536\u5C3E\u6838\u9A8C\u6B21\u6570"),
|
|
20295
|
+
continuations: count(value.continuations, "\u4EFB\u52A1\u7EED\u529E\u6B21\u6570"),
|
|
20296
|
+
requestRetries: count(value.requestRetries, "\u8BF7\u6C42\u91CD\u8BD5\u6B21\u6570"),
|
|
20297
|
+
...record2(last) ? { last: { at: isoTime(last.at, "\u6536\u5C3E\u6838\u9A8C\u65F6\u95F4"), decision: member(last.decision, REVIEW_DECISIONS, "\u6536\u5C3E\u6838\u9A8C\u51B3\u5B9A"), reason: member(last.reason, REVIEW_REASONS, "\u6536\u5C3E\u6838\u9A8C\u539F\u56E0") } } : {}
|
|
20298
|
+
};
|
|
20299
|
+
}
|
|
20252
20300
|
function parseStartLoginRequest(value) {
|
|
20253
20301
|
if (!record2(value)) throw new Error("\u767B\u5F55\u8BF7\u6C42\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
20254
20302
|
return { expectedRevision: text(value.expectedRevision, "\u914D\u7F6E\u7248\u672C", MAX_REVISION) };
|
|
@@ -20332,8 +20380,446 @@ function claudeOutputError(model, protocol, maxTokens) {
|
|
|
20332
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;
|
|
20333
20381
|
}
|
|
20334
20382
|
|
|
20335
|
-
// 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);
|
|
20336
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;
|
|
20337
20823
|
var SETTINGS_NS = "llm-opendesign-corouter";
|
|
20338
20824
|
var OFFICIAL_SITE = "https://corouter.open-design.ai/zh/";
|
|
20339
20825
|
var TABS = [
|
|
@@ -20351,9 +20837,14 @@ var MAX_REQUEST_TIMEOUT_MS = 36e5;
|
|
|
20351
20837
|
var DEFAULT_STREAM_IDLE_TIMEOUT_MS = 3e5;
|
|
20352
20838
|
var MIN_STREAM_IDLE_TIMEOUT_MS = 1e3;
|
|
20353
20839
|
var MAX_STREAM_IDLE_TIMEOUT_MS = 18e5;
|
|
20840
|
+
var DEFAULT_TURN_REVIEW_MAX_CONTINUATIONS = 3;
|
|
20841
|
+
var MIN_TURN_REVIEW_MAX_CONTINUATIONS = 1;
|
|
20842
|
+
var MAX_TURN_REVIEW_MAX_CONTINUATIONS = 10;
|
|
20843
|
+
var DEFAULT_TURN_REVIEW_NO_PROGRESS_LIMIT = 2;
|
|
20844
|
+
var MIN_TURN_REVIEW_NO_PROGRESS_LIMIT = 1;
|
|
20845
|
+
var MAX_TURN_REVIEW_NO_PROGRESS_LIMIT = 5;
|
|
20354
20846
|
var RPC_TIMEOUT_MS = 3e4;
|
|
20355
20847
|
var MAX_OUTPUT_TOKENS = 1e7;
|
|
20356
|
-
var MAX_CONTEXT_WINDOW = 1e8;
|
|
20357
20848
|
var GENERIC_ERROR = "\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002";
|
|
20358
20849
|
var LOGIN_LABELS = {
|
|
20359
20850
|
idle: "\u5C1A\u672A\u5F00\u59CB\u72EC\u7ACB\u767B\u5F55",
|
|
@@ -20370,6 +20861,35 @@ var QUOTA_LABELS = {
|
|
|
20370
20861
|
"need-login": "\u9700\u8981\u767B\u5F55\u540E\u8BFB\u53D6\u989D\u5EA6",
|
|
20371
20862
|
error: "\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u989D\u5EA6"
|
|
20372
20863
|
};
|
|
20864
|
+
var REVIEW_DECISION_LABELS = {
|
|
20865
|
+
continued: "\u5DF2\u7EED\u529E",
|
|
20866
|
+
completed: "\u5DF2\u5B8C\u6210",
|
|
20867
|
+
"waiting-user": "\u7B49\u5F85\u7528\u6237",
|
|
20868
|
+
"waiting-work": "\u7B49\u5F85\u6267\u884C",
|
|
20869
|
+
blocked: "\u53D7\u963B",
|
|
20870
|
+
limited: "\u8FBE\u5230\u4E0A\u9650",
|
|
20871
|
+
skipped: "\u672A\u6838\u9A8C",
|
|
20872
|
+
unverified: "\u65E0\u6CD5\u786E\u8BA4"
|
|
20873
|
+
};
|
|
20874
|
+
var REVIEW_REASON_LABELS = {
|
|
20875
|
+
"missing-outcome": "\u5C1A\u672A\u62A5\u544A\u6536\u5C3E\u72B6\u6001",
|
|
20876
|
+
"pending-action": "\u5C1A\u6709\u5F85\u6267\u884C\u4E8B\u9879",
|
|
20877
|
+
"reported-complete": "\u5DF2\u62A5\u544A\u5B8C\u6210",
|
|
20878
|
+
"needs-user": "\u9700\u8981\u7528\u6237\u8865\u5145",
|
|
20879
|
+
"work-running": "\u4EFB\u52A1\u4ECD\u5728\u8FDB\u884C",
|
|
20880
|
+
"reported-blocked": "\u5DF2\u62A5\u544A\u963B\u585E",
|
|
20881
|
+
"continuation-limit": "\u8FBE\u5230\u7EED\u529E\u4E0A\u9650",
|
|
20882
|
+
"no-progress": "\u65E0\u8FDB\u5C55",
|
|
20883
|
+
"goal-owned": "\u7531\u73B0\u6709\u76EE\u6807\u72B6\u6001\u63A7\u5236",
|
|
20884
|
+
"service-unavailable": "\u670D\u52A1\u6682\u4E0D\u53EF\u7528",
|
|
20885
|
+
cancelled: "\u5DF2\u53D6\u6D88",
|
|
20886
|
+
truncated: "\u56DE\u7B54\u88AB\u622A\u65AD",
|
|
20887
|
+
"request-failed": "\u8BF7\u6C42\u5931\u8D25",
|
|
20888
|
+
disabled: "\u76D1\u63A7\u672A\u542F\u7528",
|
|
20889
|
+
superseded: "\u88AB\u65B0\u4EFB\u52A1\u53D6\u4EE3",
|
|
20890
|
+
"invalid-evidence": "\u8BC1\u636E\u4E0D\u53EF\u7528",
|
|
20891
|
+
"tool-concluded": "\u5DE5\u5177\u5DF2\u7ED3\u675F\u672C\u8F6E"
|
|
20892
|
+
};
|
|
20373
20893
|
function installStyles() {
|
|
20374
20894
|
const style = document.createElement("style");
|
|
20375
20895
|
style.dataset.opendesignCorouter = "";
|
|
@@ -20388,6 +20908,7 @@ function installStyles() {
|
|
|
20388
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))}
|
|
20389
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}
|
|
20390
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}
|
|
20391
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}
|
|
20392
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}
|
|
20393
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}
|
|
@@ -20396,6 +20917,7 @@ function installStyles() {
|
|
|
20396
20917
|
.odc-switch{display:flex;align-items:center;gap:12px;min-height:44px;padding:6px 2px;cursor:pointer}.odc-switch input{appearance:auto;width:20px;height:20px;flex:none;margin:0;cursor:inherit;accent-color:var(--dsw-alias-brand-primary,Highlight)}.odc-switch>span{display:grid;gap:4px;min-width:0}.odc-switch:has(input:disabled){cursor:not-allowed;opacity:.6}.odc-divider{height:1px;border:0;background:var(--dsw-alias-border-l4,transparent);margin:2px 0}.odc-link{color:var(--dsw-alias-brand-primary,inherit);text-underline-offset:3px}
|
|
20397
20918
|
.odc-readonly{display:grid;gap:10px;margin-top:14px;padding:10px 12px;border-radius:8px;background:var(--dsw-alias-bg-layer-2,transparent)}.odc-code{display:block;min-width:0;color:var(--dsw-alias-label-primary,inherit);font-family:ui-monospace,'Cascadia Mono',Consolas,monospace;font-size:11px;line-height:1.6;overflow-wrap:anywhere}
|
|
20398
20919
|
.odc-timing{padding:12px 0;border-top:1px solid var(--dsw-alias-border-l4,transparent)}.odc-timing .odc-metric{min-height:0}.odc-settings>.odc-notice{margin-bottom:14px}.odc-model-details>summary{min-height:32px;padding:6px 0}
|
|
20920
|
+
.odc-turn-monitor{display:grid;gap:0;margin:12px 0 0}.odc-turn-monitor>div:first-child{display:flex;align-items:baseline;justify-content:space-between;gap:12px;flex-wrap:wrap;padding:0 0 6px}.odc-turn-monitor>div:first-child dt{font-size:12px;font-weight:600}.odc-turn-monitor-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-turn-monitor-row dt{font-size:12px;font-weight:600;color:var(--dsw-alias-label-secondary,inherit);min-width:0}.odc-turn-monitor-row dd{margin:0;min-width:0;text-align:right}.odc-turn-monitor-row .odc-metric-value{font-size:13px;font-variant-numeric:tabular-nums}.odc-turn-monitor-last dd{display:grid;gap:3px;justify-items:end}.odc-turn-monitor-verdict{font-size:12px;font-weight:600;overflow-wrap:anywhere;text-align:right}.odc-turn-monitor-last time{font-size:11px;font-variant-numeric:tabular-nums}
|
|
20399
20921
|
.odc-field-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))}
|
|
20400
20922
|
.odc-model-groups{align-items:start}.odc-label,.odc-hint,.odc-meta,.odc-window dt,.odc-quota-footer dt,.odc-quota-footer dd,.odc-window-details>summary,.odc-model-details>summary,.odc-model-item code,.odc-model-meta,.odc-model-count,.odc-code{font-size:12px}.odc-field-compact .odc-input,.odc-button-small{font-size:12px}.odc-button-small{min-height:32px}.odc-chip{font-size:11px}
|
|
20401
20923
|
.odc-settings{--odc-accent:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6);max-width:720px;padding:16px;line-height:1.6}
|
|
@@ -20405,14 +20927,14 @@ function installStyles() {
|
|
|
20405
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}
|
|
20406
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}
|
|
20407
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}
|
|
20408
|
-
@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}}
|
|
20409
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}
|
|
20410
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)}
|
|
20411
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}
|
|
20412
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}}
|
|
20413
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}}
|
|
20414
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}}
|
|
20415
|
-
`;
|
|
20937
|
+
${QUICK_CONTEXT_CSS}`;
|
|
20416
20938
|
document.head.append(style);
|
|
20417
20939
|
return () => style.remove();
|
|
20418
20940
|
}
|
|
@@ -20476,8 +20998,8 @@ function createCaller(ctx) {
|
|
|
20476
20998
|
};
|
|
20477
20999
|
}
|
|
20478
21000
|
function useMounted() {
|
|
20479
|
-
const mounted =
|
|
20480
|
-
|
|
21001
|
+
const mounted = React2.useRef(true);
|
|
21002
|
+
React2.useEffect(() => {
|
|
20481
21003
|
mounted.current = true;
|
|
20482
21004
|
return () => {
|
|
20483
21005
|
mounted.current = false;
|
|
@@ -20486,7 +21008,7 @@ function useMounted() {
|
|
|
20486
21008
|
return mounted;
|
|
20487
21009
|
}
|
|
20488
21010
|
function useFormSnapshot(form) {
|
|
20489
|
-
return
|
|
21011
|
+
return React2.useSyncExternalStore(
|
|
20490
21012
|
(listener) => form.subscribe(listener),
|
|
20491
21013
|
() => form.getSnapshot(),
|
|
20492
21014
|
() => form.getSnapshot()
|
|
@@ -20494,7 +21016,7 @@ function useFormSnapshot(form) {
|
|
|
20494
21016
|
}
|
|
20495
21017
|
function NoticeView({ notice }) {
|
|
20496
21018
|
if (notice === null) return null;
|
|
20497
|
-
return
|
|
21019
|
+
return h2("p", {
|
|
20498
21020
|
className: "odc-notice",
|
|
20499
21021
|
"data-kind": notice.kind,
|
|
20500
21022
|
role: notice.kind === "error" ? "alert" : "status"
|
|
@@ -20523,8 +21045,8 @@ function formatRefreshCountdown(value, now) {
|
|
|
20523
21045
|
return formatRelativeDeadline(value, now, "\u5373\u5C06\u5237\u65B0");
|
|
20524
21046
|
}
|
|
20525
21047
|
function RelativeDeadline({ at, busy = false, dueText, titleLabel, futureSuffix = "" }) {
|
|
20526
|
-
const [now, setNow] =
|
|
20527
|
-
|
|
21048
|
+
const [now, setNow] = React2.useState(() => Date.now());
|
|
21049
|
+
React2.useEffect(() => {
|
|
20528
21050
|
if (at === void 0 || !Number.isFinite(Date.parse(at))) return;
|
|
20529
21051
|
const update = () => setNow(Date.now());
|
|
20530
21052
|
update();
|
|
@@ -20535,10 +21057,10 @@ function RelativeDeadline({ at, busy = false, dueText, titleLabel, futureSuffix
|
|
|
20535
21057
|
document.removeEventListener("visibilitychange", update);
|
|
20536
21058
|
};
|
|
20537
21059
|
}, [at]);
|
|
20538
|
-
if (busy) return
|
|
20539
|
-
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");
|
|
20540
21062
|
const relative = formatRelativeDeadline(at, now, dueText) + (Date.parse(at) > now ? futureSuffix : "");
|
|
20541
|
-
return
|
|
21063
|
+
return h2("time", { dateTime: at, title: `${titleLabel}\uFF1A${formatTime(at)}`, "aria-label": `${relative}\uFF0C${titleLabel}\uFF1A${formatTime(at)}` }, relative);
|
|
20542
21064
|
}
|
|
20543
21065
|
function formatTokens(value) {
|
|
20544
21066
|
if (value === void 0 || !Number.isFinite(value)) return "\u2014";
|
|
@@ -20556,12 +21078,12 @@ function formatWindowCredits(value) {
|
|
|
20556
21078
|
if (value >= 1e3) return `${(value / 1e3).toFixed(1)}K`;
|
|
20557
21079
|
return String(value);
|
|
20558
21080
|
}
|
|
20559
|
-
function windowTone(
|
|
20560
|
-
return
|
|
21081
|
+
function windowTone(window2) {
|
|
21082
|
+
return window2.percent >= 100 ? "critical" : window2.percent >= 71 ? "warn" : "good";
|
|
20561
21083
|
}
|
|
20562
|
-
function windowDue(
|
|
20563
|
-
if (
|
|
20564
|
-
const at = Date.parse(
|
|
21084
|
+
function windowDue(window2, now) {
|
|
21085
|
+
if (window2.resetsAt === void 0) return false;
|
|
21086
|
+
const at = Date.parse(window2.resetsAt);
|
|
20565
21087
|
return Number.isFinite(at) && at <= now;
|
|
20566
21088
|
}
|
|
20567
21089
|
function quotaStatusView(quota, now) {
|
|
@@ -20570,22 +21092,22 @@ function quotaStatusView(quota, now) {
|
|
|
20570
21092
|
if (quota.stale) return { title: "\u663E\u793A\u4E0A\u6B21\u6210\u529F\u8BFB\u6570", tone: "warn", icon: "?" };
|
|
20571
21093
|
if (quota.state === "partial") return { title: QUOTA_LABELS.partial, tone: "warn", icon: "?" };
|
|
20572
21094
|
if (quota.eligible === false) return { title: "\u672A\u5F00\u901A Design Plan", tone: "neutral", icon: "i" };
|
|
20573
|
-
const windows = quota.windows.filter((
|
|
21095
|
+
const windows = quota.windows.filter((window3) => Number.isFinite(window3.percent));
|
|
20574
21096
|
if (!windows.length) return { title: "\u6682\u65E0\u8D60\u9001\u7A97\u53E3\u6570\u636E", tone: "neutral", icon: "i" };
|
|
20575
|
-
if (windows.some((
|
|
20576
|
-
const
|
|
20577
|
-
const tone = windowTone(
|
|
20578
|
-
const title = tone === "critical" ? "\u8D60\u9001\u7A97\u53E3\u989D\u5EA6\u5DF2\u7528\u5C3D" :
|
|
20579
|
-
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 };
|
|
20580
21102
|
}
|
|
20581
21103
|
function nextWindowResetAt(windows, now) {
|
|
20582
21104
|
let earliest;
|
|
20583
21105
|
let earliestMs = Number.POSITIVE_INFINITY;
|
|
20584
|
-
for (const
|
|
20585
|
-
if (
|
|
20586
|
-
const ms = Date.parse(
|
|
21106
|
+
for (const window2 of windows) {
|
|
21107
|
+
if (window2.resetsAt === void 0) continue;
|
|
21108
|
+
const ms = Date.parse(window2.resetsAt);
|
|
20587
21109
|
if (!Number.isFinite(ms) || ms <= now || ms >= earliestMs) continue;
|
|
20588
|
-
earliest =
|
|
21110
|
+
earliest = window2.resetsAt;
|
|
20589
21111
|
earliestMs = ms;
|
|
20590
21112
|
}
|
|
20591
21113
|
return earliest;
|
|
@@ -20600,12 +21122,12 @@ var RESET_MODE_LABELS = {
|
|
|
20600
21122
|
anchored_recurring: "\u56FA\u5B9A\u5468\u671F"
|
|
20601
21123
|
};
|
|
20602
21124
|
function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds, busy = false }) {
|
|
20603
|
-
const [now, setNow] =
|
|
20604
|
-
|
|
21125
|
+
const [now, setNow] = React2.useState(() => Date.now());
|
|
21126
|
+
React2.useEffect(() => {
|
|
20605
21127
|
setNow(Date.now());
|
|
20606
21128
|
}, [quota?.windows]);
|
|
20607
|
-
|
|
20608
|
-
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);
|
|
20609
21131
|
const update = () => setNow(Date.now());
|
|
20610
21132
|
const timer = future.length ? setTimeout(update, Math.min(2147483647, Math.max(1, Math.min(...future) - now + 10))) : void 0;
|
|
20611
21133
|
document.addEventListener("visibilitychange", update);
|
|
@@ -20614,7 +21136,7 @@ function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds, busy = fa
|
|
|
20614
21136
|
document.removeEventListener("visibilitychange", update);
|
|
20615
21137
|
};
|
|
20616
21138
|
}, [quota?.windows, now]);
|
|
20617
|
-
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");
|
|
20618
21140
|
const metrics = [
|
|
20619
21141
|
{ label: "\u5957\u9910\u4F59\u989D", value: formatUsd(quota.balances.subscriptionUsd), hint: "\u8BA2\u9605\u5269\u4F59\u53EF\u7528\u91D1\u989D" },
|
|
20620
21142
|
{ label: "\u5145\u503C / \u8D60\u9001\u91D1\u989D", value: formatUsd(quota.balances.rechargeUsd), hint: "\u5145\u503C\u4E0E\u8D60\u9001\u7684\u53EF\u7528\u91D1\u989D" },
|
|
@@ -20623,17 +21145,17 @@ function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds, busy = fa
|
|
|
20623
21145
|
const timing = [
|
|
20624
21146
|
{
|
|
20625
21147
|
label: "\u8BA2\u9605\u8D26\u671F\u7ED3\u675F",
|
|
20626
|
-
value:
|
|
21148
|
+
value: h2(RelativeDeadline, { at: quota.subscriptionPeriodEnd, dueText: "\u5DF2\u5230\u7ED3\u675F\u65F6\u95F4", titleLabel: "\u8D26\u671F\u7ED3\u675F\u65F6\u95F4" }),
|
|
20627
21149
|
hint: `\u8D26\u671F\u5F00\u59CB\uFF1A${formatTime(quota.subscriptionPeriodStart)}`
|
|
20628
21150
|
},
|
|
20629
21151
|
{
|
|
20630
21152
|
label: "\u4E0B\u6B21\u989D\u5EA6\u6062\u590D",
|
|
20631
|
-
value:
|
|
21153
|
+
value: h2(RelativeDeadline, { at: nextWindowResetAt(quota.windows, Date.now()), dueText: "\u7B49\u5F85\u66F4\u65B0", titleLabel: "\u989D\u5EA6\u6062\u590D\u65F6\u95F4" }),
|
|
20632
21154
|
hint: "\u6700\u65E9\u6062\u590D\u7684\u8D60\u9001\u7A97\u53E3\uFF1B\u4E0D\u4EE3\u8868\u94B1\u5305\u5230\u8D26\u65F6\u95F4"
|
|
20633
21155
|
},
|
|
20634
21156
|
{
|
|
20635
21157
|
label: "\u4E0B\u6B21\u81EA\u52A8\u5237\u65B0",
|
|
20636
|
-
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" }),
|
|
20637
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`
|
|
20638
21160
|
}
|
|
20639
21161
|
];
|
|
@@ -20642,119 +21164,166 @@ function QuotaView({ quota, nextAutoRefreshAt, refreshIntervalSeconds, busy = fa
|
|
|
20642
21164
|
quota.eligible === void 0 ? void 0 : `\u5957\u9910\u8D44\u683C\uFF1A${quota.eligible ? "\u5DF2\u5F00\u901A" : "\u672A\u5F00\u901A"}`
|
|
20643
21165
|
].filter((value) => value !== void 0).join(" \xB7 ");
|
|
20644
21166
|
const quotaStatus = quotaStatusView(quota, now);
|
|
20645
|
-
return
|
|
20646
|
-
|
|
21167
|
+
return h2(
|
|
21168
|
+
React2.Fragment,
|
|
20647
21169
|
null,
|
|
20648
|
-
|
|
21170
|
+
h2(
|
|
20649
21171
|
"div",
|
|
20650
21172
|
{ className: "odc-quota-panel" },
|
|
20651
|
-
|
|
21173
|
+
h2(
|
|
20652
21174
|
"div",
|
|
20653
21175
|
{ className: "odc-card-head" },
|
|
20654
|
-
|
|
21176
|
+
h2(
|
|
20655
21177
|
"div",
|
|
20656
21178
|
null,
|
|
20657
|
-
|
|
20658
|
-
tierLine === "" ? null :
|
|
21179
|
+
h2("h3", null, "\u5957\u9910\u8D60\u9001\u7A97\u53E3"),
|
|
21180
|
+
tierLine === "" ? null : h2("p", { className: "odc-hint" }, tierLine)
|
|
20659
21181
|
),
|
|
20660
|
-
quota.stale ?
|
|
21182
|
+
quota.stale ? h2("span", { className: "odc-chip" }, "\u4E0A\u6B21\u6210\u529F\u8BFB\u6570") : null
|
|
20661
21183
|
),
|
|
20662
|
-
|
|
21184
|
+
h2(
|
|
20663
21185
|
"div",
|
|
20664
21186
|
{ className: "odc-quota-status", "data-state": quota.state, "data-tone": quotaStatus.tone },
|
|
20665
|
-
|
|
20666
|
-
|
|
21187
|
+
h2("span", { className: "odc-state-mark", "aria-hidden": true }, quotaStatus.icon),
|
|
21188
|
+
h2(
|
|
20667
21189
|
"div",
|
|
20668
21190
|
{ className: "odc-state-copy" },
|
|
20669
|
-
|
|
20670
|
-
quotaStatus.window === void 0 ? null :
|
|
21191
|
+
h2("strong", null, quotaStatus.title),
|
|
21192
|
+
quotaStatus.window === void 0 ? null : h2(
|
|
20671
21193
|
"span",
|
|
20672
21194
|
{ className: "odc-hint" },
|
|
20673
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)}%`,
|
|
20674
|
-
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" }))
|
|
20675
21197
|
)
|
|
20676
21198
|
)
|
|
20677
21199
|
),
|
|
20678
|
-
quota.windows.length === 0 ? quota.eligible === false ?
|
|
20679
|
-
|
|
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,
|
|
20680
21202
|
null,
|
|
20681
|
-
|
|
20682
|
-
|
|
20683
|
-
) : quota.windows.map((
|
|
20684
|
-
const label = windowLabel(
|
|
20685
|
-
const remainingPercent = Math.max(0, Math.min(100, 100 -
|
|
20686
|
-
const tone = quota.state === "ok" && !quota.stale && !windowDue(
|
|
20687
|
-
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(
|
|
20688
21210
|
"section",
|
|
20689
|
-
{ className: "odc-window", key: `${
|
|
20690
|
-
|
|
21211
|
+
{ className: "odc-window", key: `${window2.durationSeconds}-${index}`, "aria-label": label, "data-tone": tone },
|
|
21212
|
+
h2(
|
|
20691
21213
|
"div",
|
|
20692
21214
|
{ className: "odc-window-head" },
|
|
20693
|
-
|
|
20694
|
-
|
|
21215
|
+
h2("h4", null, label),
|
|
21216
|
+
h2(
|
|
20695
21217
|
"div",
|
|
20696
21218
|
{ className: "odc-window-remaining" },
|
|
20697
|
-
|
|
20698
|
-
|
|
21219
|
+
h2("strong", null, `${remainingPercent.toFixed(1)}%`),
|
|
21220
|
+
h2("span", { className: "odc-label" }, "\u5269\u4F59\u6BD4\u4F8B")
|
|
20699
21221
|
)
|
|
20700
21222
|
),
|
|
20701
|
-
|
|
20702
|
-
|
|
20703
|
-
|
|
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(
|
|
20704
21226
|
"div",
|
|
20705
21227
|
{ className: "odc-window-bottom" },
|
|
20706
|
-
|
|
21228
|
+
h2(
|
|
20707
21229
|
"div",
|
|
20708
21230
|
{ className: "odc-window-reset" },
|
|
20709
|
-
|
|
20710
|
-
|
|
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" })
|
|
20711
21233
|
),
|
|
20712
|
-
|
|
21234
|
+
h2(
|
|
20713
21235
|
"details",
|
|
20714
21236
|
{ className: "odc-window-details" },
|
|
20715
|
-
|
|
20716
|
-
|
|
21237
|
+
h2("summary", null, "\u7A97\u53E3\u8BE6\u60C5"),
|
|
21238
|
+
h2(
|
|
20717
21239
|
"dl",
|
|
20718
21240
|
null,
|
|
20719
|
-
|
|
20720
|
-
|
|
20721
|
-
|
|
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))
|
|
20722
21244
|
)
|
|
20723
21245
|
)
|
|
20724
21246
|
)
|
|
20725
21247
|
);
|
|
20726
21248
|
})
|
|
20727
21249
|
),
|
|
20728
|
-
|
|
21250
|
+
h2(
|
|
20729
21251
|
"section",
|
|
20730
21252
|
{ className: "odc-card", "aria-label": "\u94B1\u5305\u4F59\u989D" },
|
|
20731
|
-
|
|
20732
|
-
|
|
21253
|
+
h2("h3", null, "\u94B1\u5305\u4F59\u989D"),
|
|
21254
|
+
h2("dl", { className: "odc-balance-list" }, metrics.map((metric) => h2(
|
|
20733
21255
|
"div",
|
|
20734
21256
|
{ className: "odc-balance-row odc-metric", key: metric.label },
|
|
20735
|
-
|
|
20736
|
-
|
|
21257
|
+
h2("div", null, h2("dt", { title: metric.hint }, metric.label)),
|
|
21258
|
+
h2("dd", null, h2("strong", { className: "odc-metric-value" }, metric.value))
|
|
20737
21259
|
)))
|
|
20738
21260
|
),
|
|
20739
|
-
|
|
21261
|
+
h2("dl", { className: "odc-card odc-timing", "aria-label": "\u989D\u5EA6\u65F6\u95F4\u5B89\u6392" }, timing.map((metric) => h2(
|
|
20740
21262
|
"div",
|
|
20741
21263
|
{ className: "odc-timing-row odc-metric", key: metric.label },
|
|
20742
|
-
|
|
20743
|
-
|
|
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))
|
|
20744
21266
|
))),
|
|
20745
|
-
|
|
21267
|
+
h2(
|
|
20746
21268
|
"dl",
|
|
20747
21269
|
{ className: "odc-quota-footer", "aria-label": "\u989D\u5EA6\u6570\u636E\u6765\u6E90\u4E0E\u66F4\u65B0\u65F6\u95F4" },
|
|
20748
|
-
|
|
20749
|
-
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]))
|
|
20750
21272
|
),
|
|
20751
|
-
|
|
21273
|
+
h2(
|
|
20752
21274
|
"details",
|
|
20753
21275
|
{ className: "odc-model-details" },
|
|
20754
|
-
|
|
20755
|
-
|
|
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")
|
|
21278
|
+
),
|
|
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
|
|
21280
|
+
);
|
|
21281
|
+
}
|
|
21282
|
+
function TurnMonitorView({ turnMonitor, guardedTurns, enabled = true, reviewEnabled = true }) {
|
|
21283
|
+
const metrics = [
|
|
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) },
|
|
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) },
|
|
21286
|
+
{ label: "\u7ED3\u675F\u6838\u9A8C", hint: "\u4EFB\u52A1\u6536\u5C3E\u7684\u6709\u754C\u6838\u9A8C\u6B21\u6570\uFF0C\u4ECE\u63D2\u4EF6\u52A0\u8F7D\u8D77\u7D2F\u8BA1", value: turnMonitor === void 0 ? "\u2014" : String(turnMonitor.checks) },
|
|
21287
|
+
{ label: "\u4EFB\u52A1\u7EED\u529E", hint: "\u7ED3\u675F\u68C0\u67E5\u70B9\u8FFD\u52A0\u7684\u6838\u9A8C\u6216\u4EFB\u52A1\u6B65\u9AA4\u6B21\u6570\uFF0C\u4ECE\u63D2\u4EF6\u52A0\u8F7D\u8D77\u7D2F\u8BA1", value: turnMonitor === void 0 ? "\u2014" : String(turnMonitor.continuations) }
|
|
21288
|
+
];
|
|
21289
|
+
const last = turnMonitor?.last;
|
|
21290
|
+
const lastAt = last === void 0 || !Number.isFinite(Date.parse(last.at)) ? void 0 : last.at;
|
|
21291
|
+
const lastDecision = last === void 0 ? void 0 : REVIEW_DECISION_LABELS[last.decision];
|
|
21292
|
+
const lastReason = last === void 0 ? void 0 : REVIEW_REASON_LABELS[last.reason];
|
|
21293
|
+
return h2(
|
|
21294
|
+
"dl",
|
|
21295
|
+
{ className: "odc-card odc-turn-monitor", "aria-label": "\u5F02\u5E38\u7ED3\u675F\u76D1\u63A7" },
|
|
21296
|
+
h2(
|
|
21297
|
+
"div",
|
|
21298
|
+
null,
|
|
21299
|
+
h2("dt", null, "\u76D1\u63A7\u6307\u6807"),
|
|
21300
|
+
h2(
|
|
21301
|
+
"span",
|
|
21302
|
+
{ className: "odc-hint", role: "status" },
|
|
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"
|
|
21304
|
+
)
|
|
20756
21305
|
),
|
|
20757
|
-
|
|
21306
|
+
metrics.map((metric) => h2(
|
|
21307
|
+
"div",
|
|
21308
|
+
{ className: "odc-turn-monitor-row", key: metric.label },
|
|
21309
|
+
h2("dt", { title: metric.hint }, metric.label),
|
|
21310
|
+
h2("dd", null, h2("strong", { className: "odc-metric-value" }, metric.value))
|
|
21311
|
+
)),
|
|
21312
|
+
h2(
|
|
21313
|
+
"div",
|
|
21314
|
+
{ className: "odc-turn-monitor-row odc-turn-monitor-last", key: "last" },
|
|
21315
|
+
h2("dt", null, "\u6700\u8FD1\u51B3\u5B9A"),
|
|
21316
|
+
h2(
|
|
21317
|
+
"dd",
|
|
21318
|
+
null,
|
|
21319
|
+
lastDecision === void 0 || lastReason === void 0 || lastAt === void 0 ? h2("span", { className: "odc-hint" }, "\u2014") : h2(
|
|
21320
|
+
React2.Fragment,
|
|
21321
|
+
null,
|
|
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))
|
|
21324
|
+
)
|
|
21325
|
+
)
|
|
21326
|
+
)
|
|
20758
21327
|
);
|
|
20759
21328
|
}
|
|
20760
21329
|
function writeModelSettings(map2, id, next) {
|
|
@@ -20770,6 +21339,7 @@ function writeModelSettings(map2, id, next) {
|
|
|
20770
21339
|
if (next.topP !== void 0) entry.topP = next.topP;
|
|
20771
21340
|
if (next.maxTokens !== void 0) entry.maxTokens = next.maxTokens;
|
|
20772
21341
|
if (next.contextWindow !== void 0) entry.contextWindow = next.contextWindow;
|
|
21342
|
+
if (next.contextTier !== void 0) entry.contextTier = next.contextTier;
|
|
20773
21343
|
if (next.reasoningEffort !== void 0) entry.reasoningEffort = next.reasoningEffort;
|
|
20774
21344
|
if (Object.keys(entry).length === 0) delete out[id];
|
|
20775
21345
|
else out[id] = entry;
|
|
@@ -20829,42 +21399,67 @@ function quotaAutoRefresh(secondsRaw, nextRefreshAt, now, backingOff = false) {
|
|
|
20829
21399
|
return { delayMs, at: new Date(now + delayMs).toISOString(), intervalSeconds };
|
|
20830
21400
|
}
|
|
20831
21401
|
function Overview({ status, busy, onRefresh, nextAutoRefreshAt, refreshIntervalSeconds, onConnection }) {
|
|
20832
|
-
return
|
|
20833
|
-
|
|
21402
|
+
return h2(
|
|
21403
|
+
React2.Fragment,
|
|
20834
21404
|
null,
|
|
20835
|
-
status !== void 0 && (status.apiKeyConfigured === false || status.quota.state === "need-login") ?
|
|
21405
|
+
status !== void 0 && (status.apiKeyConfigured === false || status.quota.state === "need-login") ? h2(
|
|
20836
21406
|
"section",
|
|
20837
21407
|
{ className: "odc-card odc-row", "aria-label": "\u8FDE\u63A5\u5F85\u5B8C\u6210" },
|
|
20838
|
-
|
|
21408
|
+
h2(
|
|
20839
21409
|
"div",
|
|
20840
21410
|
null,
|
|
20841
|
-
|
|
20842
|
-
|
|
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")
|
|
20843
21413
|
),
|
|
20844
|
-
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")
|
|
20845
21415
|
) : null,
|
|
20846
|
-
|
|
21416
|
+
h2(
|
|
20847
21417
|
"div",
|
|
20848
21418
|
{ className: "odc-card-head" },
|
|
20849
|
-
|
|
20850
|
-
|
|
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")
|
|
20851
21421
|
),
|
|
20852
|
-
|
|
21422
|
+
h2(QuotaView, { quota: status?.quota, nextAutoRefreshAt, refreshIntervalSeconds, busy })
|
|
20853
21423
|
);
|
|
20854
21424
|
}
|
|
20855
21425
|
var NUMERIC_FIELDS = {
|
|
20856
21426
|
temperature: { label: "\u6E29\u5EA6", hint: "0\u20132\uFF1B\u7559\u7A7A\u7EE7\u627F\u9ED8\u8BA4\u3002", min: 0, max: 2 },
|
|
20857
21427
|
topP: { label: "Top P", hint: "0\u20131\uFF1B\u7559\u7A7A\u7EE7\u627F\u9ED8\u8BA4\u3002", min: 0, max: 1 },
|
|
20858
|
-
maxTokens: { label: "\u6700\u5927\u8F93\u51FA\uFF08tokens\uFF09", hint: "\u6B63\u6574\u6570\uFF1B\u7559\u7A7A\
|
|
20859
|
-
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 }
|
|
20860
21429
|
};
|
|
20861
|
-
var NUMERIC_ORDER = ["temperature", "topP", "maxTokens"
|
|
20862
|
-
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 }) {
|
|
20863
21458
|
const spec = NUMERIC_FIELDS[field];
|
|
20864
21459
|
const mounted = useMounted();
|
|
20865
|
-
const [draft, setDraft] =
|
|
20866
|
-
const [error62, setError] =
|
|
20867
|
-
|
|
21460
|
+
const [draft, setDraft] = React2.useState(void 0);
|
|
21461
|
+
const [error62, setError] = React2.useState(void 0);
|
|
21462
|
+
React2.useEffect(() => {
|
|
20868
21463
|
setDraft(void 0);
|
|
20869
21464
|
setError(void 0);
|
|
20870
21465
|
}, [value, resetToken]);
|
|
@@ -20893,11 +21488,11 @@ function OptionalNumberField({ id, field, value, disabled, restricted = false, i
|
|
|
20893
21488
|
setError(void 0);
|
|
20894
21489
|
} else setError("\u8BBE\u7F6E\u672A\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5\u3002");
|
|
20895
21490
|
};
|
|
20896
|
-
return
|
|
21491
|
+
return h2(
|
|
20897
21492
|
"div",
|
|
20898
21493
|
{ className: "odc-field odc-field-compact" },
|
|
20899
|
-
|
|
20900
|
-
|
|
21494
|
+
h2("label", { htmlFor: id }, spec.label),
|
|
21495
|
+
h2("input", {
|
|
20901
21496
|
id,
|
|
20902
21497
|
className: "odc-input",
|
|
20903
21498
|
type: "number",
|
|
@@ -20914,20 +21509,80 @@ function OptionalNumberField({ id, field, value, disabled, restricted = false, i
|
|
|
20914
21509
|
void commit();
|
|
20915
21510
|
}
|
|
20916
21511
|
}),
|
|
20917
|
-
|
|
20918
|
-
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",
|
|
20919
21514
|
id: `${id}-hint`,
|
|
20920
|
-
...error62 === void 0 ? {} : { role: "alert" }
|
|
20921
|
-
}, 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
|
+
)
|
|
20922
21577
|
);
|
|
20923
21578
|
}
|
|
20924
21579
|
function EffortField({ id, model, value, disabled, pending, disabledReason, onSave }) {
|
|
20925
21580
|
const mounted = useMounted();
|
|
20926
|
-
const [editing, setEditing] =
|
|
20927
|
-
const [draft, setDraft] =
|
|
20928
|
-
const [baseValue, setBaseValue] =
|
|
20929
|
-
const [saving, setSaving] =
|
|
20930
|
-
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);
|
|
20931
21586
|
const listed = model.reasoningEfforts ?? [];
|
|
20932
21587
|
const invalidDefault = value !== void 0 && !listed.includes(value);
|
|
20933
21588
|
const invalidDraft = editing && draft !== "" && !listed.includes(draft);
|
|
@@ -20967,7 +21622,7 @@ function EffortField({ id, model, value, disabled, pending, disabledReason, onSa
|
|
|
20967
21622
|
if (mounted.current) setSaving(false);
|
|
20968
21623
|
}
|
|
20969
21624
|
};
|
|
20970
|
-
return
|
|
21625
|
+
return h2(
|
|
20971
21626
|
"div",
|
|
20972
21627
|
{
|
|
20973
21628
|
className: "odc-field odc-field-compact odc-effort",
|
|
@@ -20978,11 +21633,11 @@ function EffortField({ id, model, value, disabled, pending, disabledReason, onSa
|
|
|
20978
21633
|
cancel();
|
|
20979
21634
|
}
|
|
20980
21635
|
},
|
|
20981
|
-
editing ?
|
|
20982
|
-
|
|
21636
|
+
editing ? h2(
|
|
21637
|
+
React2.Fragment,
|
|
20983
21638
|
null,
|
|
20984
|
-
|
|
20985
|
-
|
|
21639
|
+
h2("label", { htmlFor: id }, "\u9ED8\u8BA4\u601D\u8003\u6DF1\u5EA6"),
|
|
21640
|
+
h2("select", {
|
|
20986
21641
|
id,
|
|
20987
21642
|
className: "odc-input",
|
|
20988
21643
|
value: draft,
|
|
@@ -20994,25 +21649,25 @@ function EffortField({ id, model, value, disabled, pending, disabledReason, onSa
|
|
|
20994
21649
|
setError(void 0);
|
|
20995
21650
|
}
|
|
20996
21651
|
}, [
|
|
20997
|
-
|
|
20998
|
-
...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`))
|
|
20999
21654
|
]),
|
|
21000
|
-
|
|
21655
|
+
h2(
|
|
21001
21656
|
"div",
|
|
21002
21657
|
{ className: "odc-effort-actions" },
|
|
21003
|
-
|
|
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: () => {
|
|
21004
21659
|
void save();
|
|
21005
21660
|
} }, saving ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58"),
|
|
21006
|
-
|
|
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")
|
|
21007
21662
|
)
|
|
21008
|
-
) :
|
|
21009
|
-
|
|
21663
|
+
) : h2(
|
|
21664
|
+
React2.Fragment,
|
|
21010
21665
|
null,
|
|
21011
|
-
|
|
21666
|
+
h2(
|
|
21012
21667
|
"div",
|
|
21013
21668
|
{ className: "odc-effort-head" },
|
|
21014
|
-
|
|
21015
|
-
|
|
21669
|
+
h2("span", { className: "odc-effort-label" }, "\u9ED8\u8BA4\u601D\u8003\u6DF1\u5EA6"),
|
|
21670
|
+
h2("button", {
|
|
21016
21671
|
className: "odc-button odc-button-small",
|
|
21017
21672
|
type: "button",
|
|
21018
21673
|
disabled: busy || disabled || unavailable && value === void 0,
|
|
@@ -21026,13 +21681,13 @@ function EffortField({ id, model, value, disabled, pending, disabledReason, onSa
|
|
|
21026
21681
|
}
|
|
21027
21682
|
}, "\u7F16\u8F91")
|
|
21028
21683
|
),
|
|
21029
|
-
|
|
21684
|
+
h2("p", { className: "odc-effort-value" }, invalidDefault ? `${value}\uFF08\u5F53\u524D\u4E0D\u53EF\u7528\uFF09` : value ?? "\u7EE7\u627F\u9ED8\u8BA4")
|
|
21030
21685
|
),
|
|
21031
|
-
|
|
21686
|
+
h2("small", {
|
|
21032
21687
|
className: "odc-hint",
|
|
21033
21688
|
id: `${id}-hint`
|
|
21034
21689
|
}, hint),
|
|
21035
|
-
error62 === void 0 ? null :
|
|
21690
|
+
error62 === void 0 ? null : h2("small", { className: "odc-hint odc-field-error", id: `${id}-error`, role: "alert" }, error62)
|
|
21036
21691
|
);
|
|
21037
21692
|
}
|
|
21038
21693
|
var PRICE_SITE = "https://corouter.open-design.ai/zh/models/";
|
|
@@ -21044,24 +21699,29 @@ function priceAmount(amount2, currency) {
|
|
|
21044
21699
|
return currency === "USD" ? `$${amount2}` : `${amount2}\uFF08\u5E01\u79CD\u672A\u6807\u660E\uFF09`;
|
|
21045
21700
|
}
|
|
21046
21701
|
function PriceDetails({ tiers }) {
|
|
21047
|
-
return
|
|
21702
|
+
return h2("div", { className: "odc-price-details", "aria-label": "\u5B98\u7F51\u4EF7\u683C\u8BE6\u60C5" }, tiers.map((tier, index) => h2(
|
|
21048
21703
|
"section",
|
|
21049
21704
|
{ className: "odc-price-tier", key: `${index}-${tier.label}` },
|
|
21050
|
-
|
|
21051
|
-
|
|
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)))))
|
|
21052
21707
|
)));
|
|
21053
21708
|
}
|
|
21054
21709
|
function ModelRow({ model, settings, authoritative, writable, pending, disabledReason, protocol = "chat-completions", price, priceKnown = false, onCommit }) {
|
|
21055
|
-
const id =
|
|
21710
|
+
const id = React2.useId();
|
|
21056
21711
|
const mounted = useMounted();
|
|
21057
|
-
const [error62, setError] =
|
|
21058
|
-
const [resetToken, setResetToken] =
|
|
21712
|
+
const [error62, setError] = React2.useState(void 0);
|
|
21713
|
+
const [resetToken, setResetToken] = React2.useState(0);
|
|
21059
21714
|
const enabled = modelEnabled(model, settings, authoritative);
|
|
21060
21715
|
const imageInput = modelImageInput(model, settings);
|
|
21061
21716
|
const imageInputManual = settings.imageInput !== void 0;
|
|
21062
21717
|
const samplingRestricted = hasRestrictedClaudeSampling(model.id, protocol);
|
|
21063
21718
|
const samplingError = claudeSamplingError(model.id, protocol, settings.temperature, settings.topP);
|
|
21064
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);
|
|
21065
21725
|
const hasOverrides = Object.keys(settings).length > 0;
|
|
21066
21726
|
const commit = async (next) => {
|
|
21067
21727
|
const saved = await onCommit(next);
|
|
@@ -21073,23 +21733,35 @@ function ModelRow({ model, settings, authoritative, writable, pending, disabledR
|
|
|
21073
21733
|
if (value === void 0) delete next[key];
|
|
21074
21734
|
else next[key] = value;
|
|
21075
21735
|
if ((key === "temperature" || key === "topP") && value !== void 0) {
|
|
21076
|
-
const
|
|
21077
|
-
if (
|
|
21078
|
-
setError(
|
|
21736
|
+
const reason2 = claudeSamplingError(model.id, protocol, next.temperature, next.topP);
|
|
21737
|
+
if (reason2 !== void 0) {
|
|
21738
|
+
setError(reason2);
|
|
21079
21739
|
return false;
|
|
21080
21740
|
}
|
|
21081
21741
|
}
|
|
21082
21742
|
if (key === "maxTokens" && value !== void 0) {
|
|
21083
|
-
const
|
|
21084
|
-
if (
|
|
21085
|
-
setError(
|
|
21743
|
+
const reason2 = claudeOutputError(model.id, protocol, value);
|
|
21744
|
+
if (reason2 !== void 0) {
|
|
21745
|
+
setError(reason2);
|
|
21086
21746
|
return false;
|
|
21087
21747
|
}
|
|
21088
21748
|
}
|
|
21089
|
-
const
|
|
21090
|
-
|
|
21091
|
-
|
|
21092
|
-
|
|
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);
|
|
21093
21765
|
return false;
|
|
21094
21766
|
}
|
|
21095
21767
|
setError(void 0);
|
|
@@ -21109,20 +21781,22 @@ function ModelRow({ model, settings, authoritative, writable, pending, disabledR
|
|
|
21109
21781
|
};
|
|
21110
21782
|
const imageDisabledReason = pending ? " \xB7 \u6B63\u5728\u4FDD\u5B58" : !writable ? " \xB7 \u914D\u7F6E\u4E0D\u53EF\u5199" : "";
|
|
21111
21783
|
const facts = [
|
|
21112
|
-
`\
|
|
21113
|
-
`\
|
|
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)}`,
|
|
21114
21788
|
...model.reasoningEfforts === void 0 || model.reasoningEfforts.length === 0 ? [] : [`\u601D\u8003\u6863\u4F4D ${model.reasoningEfforts.join(" / ")}`]
|
|
21115
21789
|
].join(" \xB7 ");
|
|
21116
|
-
return
|
|
21790
|
+
return h2(
|
|
21117
21791
|
"li",
|
|
21118
21792
|
{ className: "odc-model-item" },
|
|
21119
|
-
|
|
21793
|
+
h2(
|
|
21120
21794
|
"div",
|
|
21121
21795
|
{ className: "odc-model-head" },
|
|
21122
|
-
|
|
21796
|
+
h2(
|
|
21123
21797
|
"label",
|
|
21124
21798
|
{ className: "odc-switch odc-model-switch" },
|
|
21125
|
-
|
|
21799
|
+
h2("input", {
|
|
21126
21800
|
type: "checkbox",
|
|
21127
21801
|
checked: enabled,
|
|
21128
21802
|
disabled: !writable || pending,
|
|
@@ -21130,25 +21804,25 @@ function ModelRow({ model, settings, authoritative, writable, pending, disabledR
|
|
|
21130
21804
|
void commit({ ...settings, enabled: event.target.checked });
|
|
21131
21805
|
}
|
|
21132
21806
|
}),
|
|
21133
|
-
|
|
21807
|
+
h2("span", null, h2("strong", null, model.name), h2("code", null, model.id))
|
|
21134
21808
|
),
|
|
21135
|
-
|
|
21809
|
+
h2(
|
|
21136
21810
|
"div",
|
|
21137
21811
|
{ className: "odc-actions" },
|
|
21138
|
-
enabled ? null :
|
|
21139
|
-
|
|
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: () => {
|
|
21140
21814
|
void reset();
|
|
21141
21815
|
} }, "\u91CD\u7F6E")
|
|
21142
21816
|
)
|
|
21143
21817
|
),
|
|
21144
|
-
price !== void 0 ?
|
|
21145
|
-
|
|
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(
|
|
21146
21820
|
"div",
|
|
21147
21821
|
{ className: "odc-model-image" },
|
|
21148
|
-
|
|
21822
|
+
h2(
|
|
21149
21823
|
"label",
|
|
21150
21824
|
{ className: "odc-image-toggle" },
|
|
21151
|
-
|
|
21825
|
+
h2("input", {
|
|
21152
21826
|
type: "checkbox",
|
|
21153
21827
|
checked: imageInput,
|
|
21154
21828
|
disabled: !writable || pending,
|
|
@@ -21159,10 +21833,10 @@ function ModelRow({ model, settings, authoritative, writable, pending, disabledR
|
|
|
21159
21833
|
void commit({ ...settings, imageInput: event.target.checked });
|
|
21160
21834
|
}
|
|
21161
21835
|
}),
|
|
21162
|
-
|
|
21836
|
+
h2("span", null, "\u56FE\u7247\u8F93\u5165")
|
|
21163
21837
|
),
|
|
21164
|
-
|
|
21165
|
-
imageInputManual ?
|
|
21838
|
+
h2("small", { className: "odc-image-state", id: `${id}-image-state` }, imageInputSource(model, settings) + imageDisabledReason),
|
|
21839
|
+
imageInputManual ? h2("button", {
|
|
21166
21840
|
className: "odc-image-reset",
|
|
21167
21841
|
type: "button",
|
|
21168
21842
|
disabled: !writable || pending,
|
|
@@ -21173,33 +21847,44 @@ function ModelRow({ model, settings, authoritative, writable, pending, disabledR
|
|
|
21173
21847
|
}
|
|
21174
21848
|
}, "\u6062\u590D\u81EA\u52A8") : null
|
|
21175
21849
|
),
|
|
21176
|
-
|
|
21850
|
+
h2(
|
|
21177
21851
|
"details",
|
|
21178
21852
|
{ className: "odc-model-details" },
|
|
21179
|
-
|
|
21180
|
-
|
|
21181
|
-
model.id === "claude-opus-5.5" && model.contextWindow === 1e6 ?
|
|
21182
|
-
model.id === "muse-wonder" && model.contextWindow === 1048576 ?
|
|
21183
|
-
samplingRestricted && model.id === "claude-opus-4.8" ?
|
|
21184
|
-
samplingRestricted && model.maxOutputTokens === void 0 && settings.maxTokens === void 0 ?
|
|
21185
|
-
price === void 0 ? null :
|
|
21186
|
-
|
|
21187
|
-
|
|
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(
|
|
21188
21862
|
"div",
|
|
21189
21863
|
{ className: "odc-model-editor" },
|
|
21190
|
-
|
|
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, {
|
|
21191
21875
|
key,
|
|
21192
21876
|
id: `${id}-${key}`,
|
|
21193
21877
|
field: key,
|
|
21194
21878
|
value: settings[key],
|
|
21195
21879
|
disabled: !writable || pending,
|
|
21196
21880
|
restricted: samplingRestricted && (key === "temperature" || key === "topP"),
|
|
21197
|
-
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,
|
|
21198
21883
|
maxOutputLimit: samplingRestricted && key === "maxTokens" ? CLAUDE_MESSAGES_MAX_OUTPUT : void 0,
|
|
21199
21884
|
resetToken,
|
|
21200
21885
|
onSave: (value) => saveField(key, value)
|
|
21201
21886
|
})),
|
|
21202
|
-
|
|
21887
|
+
h2(EffortField, {
|
|
21203
21888
|
id: `${id}-effort`,
|
|
21204
21889
|
model,
|
|
21205
21890
|
value: settings.reasoningEffort,
|
|
@@ -21216,29 +21901,29 @@ function ModelRow({ model, settings, authoritative, writable, pending, disabledR
|
|
|
21216
21901
|
})
|
|
21217
21902
|
)
|
|
21218
21903
|
),
|
|
21219
|
-
error62 !== void 0 ?
|
|
21904
|
+
error62 !== void 0 ? h2("p", { className: "odc-hint odc-field-error", role: "alert" }, error62) : null
|
|
21220
21905
|
);
|
|
21221
21906
|
}
|
|
21222
21907
|
function ModelGroup({ title, group, models, settingsMap, authoritative, writable, pending, disabledReason, protocol, onCommit, prices }) {
|
|
21223
|
-
const [query, setQuery] =
|
|
21224
|
-
const [expanded, setExpanded] =
|
|
21225
|
-
const id =
|
|
21908
|
+
const [query, setQuery] = React2.useState("");
|
|
21909
|
+
const [expanded, setExpanded] = React2.useState(false);
|
|
21910
|
+
const id = React2.useId();
|
|
21226
21911
|
const normalized = query.trim().toLocaleLowerCase();
|
|
21227
21912
|
const groupModels = sortModelsByEnabled(models.filter((model) => model.group === group), settingsMap, authoritative);
|
|
21228
21913
|
const filtered = groupModels.filter((model) => normalized === "" || `${model.name} ${model.id}`.toLocaleLowerCase().includes(normalized));
|
|
21229
21914
|
const visible = normalized !== "" || expanded ? filtered : filtered.slice(0, 6);
|
|
21230
21915
|
const enabledCount = groupModels.filter((model) => modelEnabled(model, settingsMap[model.id], authoritative)).length;
|
|
21231
|
-
return
|
|
21916
|
+
return h2(
|
|
21232
21917
|
"section",
|
|
21233
21918
|
{ className: "odc-card", "aria-labelledby": `${id}-title` },
|
|
21234
|
-
|
|
21919
|
+
h2(
|
|
21235
21920
|
"div",
|
|
21236
21921
|
{ className: "odc-card-head" },
|
|
21237
|
-
|
|
21238
|
-
|
|
21922
|
+
h2("h3", { id: `${id}-title` }, title),
|
|
21923
|
+
h2("span", { className: "odc-model-count" }, `${enabledCount} / ${groupModels.length} \u5DF2\u542F\u7528`)
|
|
21239
21924
|
),
|
|
21240
|
-
|
|
21241
|
-
|
|
21925
|
+
h2("label", { className: "odc-label", htmlFor: `${id}-search` }, `\u641C\u7D22${title}`),
|
|
21926
|
+
h2("input", {
|
|
21242
21927
|
id: `${id}-search`,
|
|
21243
21928
|
className: "odc-input",
|
|
21244
21929
|
type: "search",
|
|
@@ -21246,7 +21931,7 @@ function ModelGroup({ title, group, models, settingsMap, authoritative, writable
|
|
|
21246
21931
|
placeholder: "\u641C\u7D22\u5168\u90E8\u6A21\u578B\u7684\u540D\u79F0\u6216 ID",
|
|
21247
21932
|
onChange: (event) => setQuery(event.target.value)
|
|
21248
21933
|
}),
|
|
21249
|
-
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, {
|
|
21250
21935
|
key: model.id,
|
|
21251
21936
|
model,
|
|
21252
21937
|
settings: modelSettingsEntry(settingsMap, model.id),
|
|
@@ -21259,7 +21944,7 @@ function ModelGroup({ title, group, models, settingsMap, authoritative, writable
|
|
|
21259
21944
|
priceKnown: prices !== void 0 && (prices.state !== "error" || prices.stale),
|
|
21260
21945
|
onCommit: (next) => onCommit(model.id, next)
|
|
21261
21946
|
}))),
|
|
21262
|
-
normalized === "" && filtered.length > 6 ?
|
|
21947
|
+
normalized === "" && filtered.length > 6 ? h2("button", {
|
|
21263
21948
|
type: "button",
|
|
21264
21949
|
className: "odc-button",
|
|
21265
21950
|
style: { marginTop: 12 },
|
|
@@ -21276,16 +21961,16 @@ function Models({ status, formSnapshot, setFormField, pendingField, onRefreshMod
|
|
|
21276
21961
|
const writable = formSnapshot.status === "ready" && formSnapshot.value !== void 0 && formSnapshot.writable;
|
|
21277
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";
|
|
21278
21963
|
const pending = pendingField.includes("modelSettings");
|
|
21279
|
-
const latestSettings =
|
|
21280
|
-
|
|
21964
|
+
const latestSettings = React2.useRef(settingsMap);
|
|
21965
|
+
React2.useEffect(() => {
|
|
21281
21966
|
latestSettings.current = settingsMap;
|
|
21282
21967
|
}, [settingsMap]);
|
|
21283
|
-
const saving =
|
|
21968
|
+
const saving = React2.useRef(false);
|
|
21284
21969
|
const commit = async (id, next) => {
|
|
21285
|
-
if (!writable || saving.current) return false;
|
|
21970
|
+
if (!writable || pending || saving.current) return false;
|
|
21286
21971
|
saving.current = true;
|
|
21287
21972
|
try {
|
|
21288
|
-
return await setFormField("modelSettings", writeModelSettings(latestSettings.current, id, next));
|
|
21973
|
+
return await setFormField("modelSettings", writeModelSettings(latestSettings.current, id, next), latestSettings.current);
|
|
21289
21974
|
} finally {
|
|
21290
21975
|
saving.current = false;
|
|
21291
21976
|
}
|
|
@@ -21297,23 +21982,23 @@ function Models({ status, formSnapshot, setFormField, pendingField, onRefreshMod
|
|
|
21297
21982
|
const reasoningEfforts = modelReasoningEfforts(model, protocol);
|
|
21298
21983
|
return { ...model, ...reasoningEfforts === void 0 ? {} : { reasoningEfforts } };
|
|
21299
21984
|
});
|
|
21300
|
-
return
|
|
21301
|
-
|
|
21985
|
+
return h2(
|
|
21986
|
+
React2.Fragment,
|
|
21302
21987
|
null,
|
|
21303
|
-
|
|
21988
|
+
h2(
|
|
21304
21989
|
"div",
|
|
21305
21990
|
{ className: "odc-card-head" },
|
|
21306
|
-
|
|
21991
|
+
h2(
|
|
21307
21992
|
"div",
|
|
21308
21993
|
null,
|
|
21309
|
-
|
|
21310
|
-
|
|
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")
|
|
21311
21996
|
),
|
|
21312
|
-
|
|
21997
|
+
h2(
|
|
21313
21998
|
"div",
|
|
21314
21999
|
{ className: "odc-actions" },
|
|
21315
|
-
|
|
21316
|
-
|
|
22000
|
+
h2("span", { className: "odc-label", role: "status" }, `\u6765\u6E90\uFF1A${source}${updated}`),
|
|
22001
|
+
h2("button", {
|
|
21317
22002
|
className: "odc-button",
|
|
21318
22003
|
type: "button",
|
|
21319
22004
|
disabled: refreshingModels || status === void 0 || status.apiKeyConfigured === false,
|
|
@@ -21322,34 +22007,34 @@ function Models({ status, formSnapshot, setFormField, pendingField, onRefreshMod
|
|
|
21322
22007
|
}, refreshingModels ? "\u6B63\u5728\u5237\u65B0\u6A21\u578B\u2026" : "\u5237\u65B0\u6A21\u578B\u76EE\u5F55")
|
|
21323
22008
|
)
|
|
21324
22009
|
),
|
|
21325
|
-
status?.apiKeyConfigured === false ?
|
|
21326
|
-
status?.modelsError !== void 0 ?
|
|
21327
|
-
|
|
21328
|
-
|
|
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(
|
|
21329
22014
|
"section",
|
|
21330
22015
|
{ className: "odc-card", "aria-label": "\u5B98\u7F51\u6A21\u578B\u4EF7\u683C" },
|
|
21331
|
-
|
|
22016
|
+
h2(
|
|
21332
22017
|
"div",
|
|
21333
22018
|
{ className: "odc-pricing-head" },
|
|
21334
|
-
|
|
21335
|
-
|
|
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")
|
|
21336
22021
|
),
|
|
21337
|
-
|
|
21338
|
-
|
|
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"))
|
|
21339
22024
|
),
|
|
21340
|
-
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(
|
|
21341
22026
|
"div",
|
|
21342
22027
|
{ className: "odc-model-groups" },
|
|
21343
|
-
|
|
21344
|
-
|
|
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 })
|
|
21345
22030
|
)
|
|
21346
22031
|
);
|
|
21347
22032
|
}
|
|
21348
22033
|
function NumberField({ id, label, hint, value, min, max, integer: integer2, disabled, onCommit }) {
|
|
21349
22034
|
const mounted = useMounted();
|
|
21350
|
-
const [draft, setDraft] =
|
|
21351
|
-
const [error62, setError] =
|
|
21352
|
-
|
|
22035
|
+
const [draft, setDraft] = React2.useState(String(value));
|
|
22036
|
+
const [error62, setError] = React2.useState(void 0);
|
|
22037
|
+
React2.useEffect(() => {
|
|
21353
22038
|
setDraft(String(value));
|
|
21354
22039
|
setError(void 0);
|
|
21355
22040
|
}, [value]);
|
|
@@ -21369,11 +22054,11 @@ function NumberField({ id, label, hint, value, min, max, integer: integer2, disa
|
|
|
21369
22054
|
if (saved) setError(void 0);
|
|
21370
22055
|
else setError("\u8BBE\u7F6E\u672A\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5\u3002");
|
|
21371
22056
|
};
|
|
21372
|
-
return
|
|
22057
|
+
return h2(
|
|
21373
22058
|
"div",
|
|
21374
22059
|
{ className: "odc-field" },
|
|
21375
|
-
|
|
21376
|
-
|
|
22060
|
+
h2("label", { htmlFor: id }, label),
|
|
22061
|
+
h2("input", {
|
|
21377
22062
|
id,
|
|
21378
22063
|
className: "odc-input",
|
|
21379
22064
|
type: "number",
|
|
@@ -21390,7 +22075,7 @@ function NumberField({ id, label, hint, value, min, max, integer: integer2, disa
|
|
|
21390
22075
|
void commit();
|
|
21391
22076
|
}
|
|
21392
22077
|
}),
|
|
21393
|
-
|
|
22078
|
+
h2("small", {
|
|
21394
22079
|
className: error62 === void 0 ? "odc-hint" : "odc-hint odc-field-error",
|
|
21395
22080
|
id: `${id}-hint`,
|
|
21396
22081
|
...error62 === void 0 ? {} : { role: "alert" }
|
|
@@ -21398,10 +22083,10 @@ function NumberField({ id, label, hint, value, min, max, integer: integer2, disa
|
|
|
21398
22083
|
);
|
|
21399
22084
|
}
|
|
21400
22085
|
function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
21401
|
-
const [apiKeyEnv, setApiKeyEnv] =
|
|
21402
|
-
const [keyNotice, setKeyNotice] =
|
|
22086
|
+
const [apiKeyEnv, setApiKeyEnv] = React2.useState(status?.config.apiKeyEnv ?? "");
|
|
22087
|
+
const [keyNotice, setKeyNotice] = React2.useState(null);
|
|
21403
22088
|
const mounted = useMounted();
|
|
21404
|
-
|
|
22089
|
+
React2.useEffect(() => {
|
|
21405
22090
|
setApiKeyEnv(formSnapshot.value?.apiKeyEnv ?? status?.config.apiKeyEnv ?? "");
|
|
21406
22091
|
}, [formSnapshot.value?.apiKeyEnv, status?.config.apiKeyEnv]);
|
|
21407
22092
|
const writable = formSnapshot.status === "ready" && formSnapshot.value !== void 0 && formSnapshot.writable;
|
|
@@ -21412,6 +22097,10 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21412
22097
|
const streamIdleTimeout = formSnapshot.value?.streamIdleTimeoutMs ?? status?.config.streamIdleTimeoutMs ?? DEFAULT_STREAM_IDLE_TIMEOUT_MS;
|
|
21413
22098
|
const refreshSeconds = formSnapshot.value?.quotaRefreshSeconds ?? status?.config.quotaRefreshSeconds ?? DEFAULT_QUOTA_REFRESH_SECONDS;
|
|
21414
22099
|
const imageBudget = formSnapshot.value?.maxRequestImageBytes ?? status?.config.maxRequestImageBytes ?? DEFAULT_MAX_REQUEST_IMAGE_BYTES;
|
|
22100
|
+
const turnContinuations = formSnapshot.value?.turnReviewMaxContinuations ?? status?.config.turnReviewMaxContinuations ?? DEFAULT_TURN_REVIEW_MAX_CONTINUATIONS;
|
|
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;
|
|
21415
22104
|
const selected = API_PROTOCOL_OPTIONS.find((option) => option.id === protocol);
|
|
21416
22105
|
const saveKeyRef = async () => {
|
|
21417
22106
|
const value = apiKeyEnv.trim();
|
|
@@ -21427,34 +22116,66 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21427
22116
|
if (mounted.current) setKeyNotice({ kind: "error", text: GENERIC_ERROR });
|
|
21428
22117
|
}
|
|
21429
22118
|
};
|
|
21430
|
-
return
|
|
21431
|
-
|
|
22119
|
+
return h2(
|
|
22120
|
+
React2.Fragment,
|
|
21432
22121
|
null,
|
|
21433
|
-
|
|
22122
|
+
h2(
|
|
21434
22123
|
"section",
|
|
21435
22124
|
{ className: "odc-card" },
|
|
21436
|
-
|
|
21437
|
-
|
|
21438
|
-
|
|
21439
|
-
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,
|
|
21440
22129
|
disabled: !writable || pendingField.includes("emptyTurnGuard"),
|
|
21441
22130
|
label: "\u542F\u7528\u5F02\u5E38\u7ED3\u675F\u76D1\u63A7",
|
|
21442
|
-
hint: `\u5DF2\
|
|
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`,
|
|
21443
22132
|
onChange: (checked) => {
|
|
21444
22133
|
void setFormField("emptyTurnGuard", checked);
|
|
21445
22134
|
}
|
|
21446
|
-
}))
|
|
22135
|
+
})),
|
|
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, {
|
|
22147
|
+
id: "odc-turn-continuations",
|
|
22148
|
+
label: "\u6536\u5C3E\u6838\u9A8C\u6700\u5927\u7EED\u529E\u6B21\u6570",
|
|
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`,
|
|
22150
|
+
value: turnContinuations,
|
|
22151
|
+
min: MIN_TURN_REVIEW_MAX_CONTINUATIONS,
|
|
22152
|
+
max: MAX_TURN_REVIEW_MAX_CONTINUATIONS,
|
|
22153
|
+
integer: true,
|
|
22154
|
+
disabled: !writable || !guard || !review || pendingField.includes("turnReviewMaxContinuations"),
|
|
22155
|
+
onCommit: (value) => setFormField("turnReviewMaxContinuations", value)
|
|
22156
|
+
}),
|
|
22157
|
+
h2(NumberField, {
|
|
22158
|
+
id: "odc-turn-no-progress",
|
|
22159
|
+
label: "\u65E0\u8FDB\u5C55\u505C\u6B62\u4E0A\u9650",
|
|
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`,
|
|
22161
|
+
value: turnNoProgress,
|
|
22162
|
+
min: MIN_TURN_REVIEW_NO_PROGRESS_LIMIT,
|
|
22163
|
+
max: MAX_TURN_REVIEW_NO_PROGRESS_LIMIT,
|
|
22164
|
+
integer: true,
|
|
22165
|
+
disabled: !writable || !guard || !review || pendingField.includes("turnReviewNoProgressLimit"),
|
|
22166
|
+
onCommit: (value) => setFormField("turnReviewNoProgressLimit", value)
|
|
22167
|
+
})
|
|
21447
22168
|
),
|
|
21448
|
-
|
|
22169
|
+
h2(
|
|
21449
22170
|
"section",
|
|
21450
22171
|
{ className: "odc-card" },
|
|
21451
|
-
|
|
21452
|
-
|
|
21453
|
-
|
|
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(
|
|
21454
22175
|
"div",
|
|
21455
22176
|
{ className: "odc-field" },
|
|
21456
|
-
|
|
21457
|
-
|
|
22177
|
+
h2("label", { htmlFor: "odc-api-protocol" }, "API \u534F\u8BAE"),
|
|
22178
|
+
h2("select", {
|
|
21458
22179
|
id: "odc-api-protocol",
|
|
21459
22180
|
className: "odc-input",
|
|
21460
22181
|
value: protocol,
|
|
@@ -21462,37 +22183,37 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21462
22183
|
onChange: (event) => {
|
|
21463
22184
|
void setFormField("apiProtocol", event.target.value);
|
|
21464
22185
|
}
|
|
21465
|
-
}, API_PROTOCOL_OPTIONS.map((option) =>
|
|
21466
|
-
|
|
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")
|
|
21467
22188
|
),
|
|
21468
|
-
|
|
22189
|
+
h2(
|
|
21469
22190
|
"div",
|
|
21470
22191
|
{ className: "odc-readonly" },
|
|
21471
|
-
|
|
22192
|
+
h2(
|
|
21472
22193
|
"div",
|
|
21473
22194
|
null,
|
|
21474
|
-
|
|
21475
|
-
|
|
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)
|
|
21476
22197
|
),
|
|
21477
|
-
|
|
22198
|
+
h2(
|
|
21478
22199
|
"div",
|
|
21479
22200
|
null,
|
|
21480
|
-
|
|
21481
|
-
|
|
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))
|
|
21482
22203
|
),
|
|
21483
|
-
|
|
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")
|
|
21484
22205
|
)
|
|
21485
22206
|
),
|
|
21486
|
-
|
|
22207
|
+
h2(
|
|
21487
22208
|
"section",
|
|
21488
22209
|
{ className: "odc-card" },
|
|
21489
|
-
|
|
21490
|
-
|
|
21491
|
-
|
|
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(
|
|
21492
22213
|
"div",
|
|
21493
22214
|
{ className: "odc-field" },
|
|
21494
|
-
|
|
21495
|
-
|
|
22215
|
+
h2("label", { htmlFor: "odc-api-key-env" }, "API Key \u73AF\u5883\u53D8\u91CF / \u51ED\u636E\u5F15\u7528\u540D"),
|
|
22216
|
+
h2("input", {
|
|
21496
22217
|
id: "odc-api-key-env",
|
|
21497
22218
|
className: "odc-input",
|
|
21498
22219
|
type: "text",
|
|
@@ -21502,23 +22223,23 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21502
22223
|
spellCheck: false,
|
|
21503
22224
|
onChange: (event) => setApiKeyEnv(event.target.value)
|
|
21504
22225
|
}),
|
|
21505
|
-
|
|
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")
|
|
21506
22227
|
),
|
|
21507
|
-
|
|
22228
|
+
h2(
|
|
21508
22229
|
"div",
|
|
21509
22230
|
{ className: "odc-actions", style: { marginTop: 10 } },
|
|
21510
|
-
|
|
22231
|
+
h2("button", { className: "odc-button", type: "button", disabled: !writable || pendingField.includes("apiKeyEnv"), onClick: () => {
|
|
21511
22232
|
void saveKeyRef();
|
|
21512
22233
|
} }, "\u4FDD\u5B58\u5F15\u7528\u540D")
|
|
21513
22234
|
),
|
|
21514
|
-
|
|
22235
|
+
h2(NoticeView, { notice: keyNotice })
|
|
21515
22236
|
),
|
|
21516
|
-
|
|
22237
|
+
h2(
|
|
21517
22238
|
"section",
|
|
21518
22239
|
{ className: "odc-card" },
|
|
21519
|
-
|
|
21520
|
-
|
|
21521
|
-
|
|
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, {
|
|
21522
22243
|
id: "odc-image-budget",
|
|
21523
22244
|
label: "\u5355\u6B21\u8BF7\u6C42\u56FE\u7247\u9884\u7B97\uFF08MiB\uFF09",
|
|
21524
22245
|
hint: "1\u2013100 MiB\uFF1B\u7F51\u5173\u9650\u5236\u8F83\u4F4E\u65F6\u53EF\u8C03\u5C0F\u3002",
|
|
@@ -21530,12 +22251,12 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21530
22251
|
onCommit: (value) => setFormField("maxRequestImageBytes", Math.round(value * 1024 * 1024))
|
|
21531
22252
|
})
|
|
21532
22253
|
),
|
|
21533
|
-
|
|
22254
|
+
h2(
|
|
21534
22255
|
"section",
|
|
21535
22256
|
{ className: "odc-card" },
|
|
21536
|
-
|
|
21537
|
-
|
|
21538
|
-
|
|
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, {
|
|
21539
22260
|
id: "odc-request-timeout",
|
|
21540
22261
|
label: "\u8BF7\u6C42\u603B\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",
|
|
21541
22262
|
hint: "\u4ECE\u53D1\u51FA\u8BF7\u6C42\u5230\u54CD\u5E94\u7ED3\u675F\u7684\u4E0A\u9650\uFF0C1000\u20133600000\u3002",
|
|
@@ -21546,7 +22267,7 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21546
22267
|
disabled: !writable || pendingField.includes("requestTimeoutMs"),
|
|
21547
22268
|
onCommit: (value) => setFormField("requestTimeoutMs", value)
|
|
21548
22269
|
}),
|
|
21549
|
-
|
|
22270
|
+
h2(NumberField, {
|
|
21550
22271
|
id: "odc-stream-idle-timeout",
|
|
21551
22272
|
label: "\u6D41\u5F0F\u7A7A\u95F2\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",
|
|
21552
22273
|
hint: "\u6D41\u5F0F\u54CD\u5E94\u65E0\u65B0\u6570\u636E\u7684\u6700\u957F\u7B49\u5F85\uFF0C1000\u20131800000\u3002",
|
|
@@ -21557,7 +22278,7 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21557
22278
|
disabled: !writable || pendingField.includes("streamIdleTimeoutMs"),
|
|
21558
22279
|
onCommit: (value) => setFormField("streamIdleTimeoutMs", value)
|
|
21559
22280
|
}),
|
|
21560
|
-
|
|
22281
|
+
h2(NumberField, {
|
|
21561
22282
|
id: "odc-quota-refresh",
|
|
21562
22283
|
label: "\u989D\u5EA6\u81EA\u52A8\u5237\u65B0\u95F4\u9694\uFF08\u79D2\uFF09",
|
|
21563
22284
|
hint: `5\u20133600\uFF1B\u9ED8\u8BA4 ${DEFAULT_QUOTA_REFRESH_SECONDS} \u79D2\uFF0C\u9875\u9762\u5173\u95ED\u540E\u505C\u6B62\u3002`,
|
|
@@ -21572,12 +22293,12 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21572
22293
|
);
|
|
21573
22294
|
}
|
|
21574
22295
|
function Switch({ checked, disabled, label, ariaLabel, hint, onChange }) {
|
|
21575
|
-
const hintId =
|
|
21576
|
-
return
|
|
22296
|
+
const hintId = React2.useId();
|
|
22297
|
+
return h2(
|
|
21577
22298
|
"label",
|
|
21578
22299
|
{ className: "odc-switch" },
|
|
21579
|
-
|
|
21580
|
-
|
|
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))
|
|
21581
22302
|
);
|
|
21582
22303
|
}
|
|
21583
22304
|
function loginInFlight(state) {
|
|
@@ -21592,9 +22313,9 @@ var ACTIVATION_OPEN_LABELS = {
|
|
|
21592
22313
|
};
|
|
21593
22314
|
function LoginApproval({ login, onOpen, opening, notice }) {
|
|
21594
22315
|
const mounted = useMounted();
|
|
21595
|
-
const copyVersion =
|
|
21596
|
-
const [copyState, setCopyState] =
|
|
21597
|
-
|
|
22316
|
+
const copyVersion = React2.useRef(0);
|
|
22317
|
+
const [copyState, setCopyState] = React2.useState("idle");
|
|
22318
|
+
React2.useEffect(() => {
|
|
21598
22319
|
copyVersion.current += 1;
|
|
21599
22320
|
setCopyState("idle");
|
|
21600
22321
|
}, [login?.jobId, login?.state, login?.activationUrl]);
|
|
@@ -21612,15 +22333,15 @@ function LoginApproval({ login, onOpen, opening, notice }) {
|
|
|
21612
22333
|
if (mounted.current && version2 === copyVersion.current) setCopyState("manual");
|
|
21613
22334
|
}
|
|
21614
22335
|
};
|
|
21615
|
-
return
|
|
22336
|
+
return h2(
|
|
21616
22337
|
"div",
|
|
21617
22338
|
{ className: "odc-readonly", "aria-label": "\u8BBE\u5907\u6388\u6743" },
|
|
21618
|
-
|
|
21619
|
-
|
|
21620
|
-
|
|
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(
|
|
21621
22342
|
"div",
|
|
21622
22343
|
{ className: "odc-actions" },
|
|
21623
|
-
|
|
22344
|
+
h2("button", {
|
|
21624
22345
|
className: "odc-button odc-button-primary",
|
|
21625
22346
|
type: "button",
|
|
21626
22347
|
disabled: opening === true || onOpen === void 0,
|
|
@@ -21628,40 +22349,40 @@ function LoginApproval({ login, onOpen, opening, notice }) {
|
|
|
21628
22349
|
onOpen?.();
|
|
21629
22350
|
}
|
|
21630
22351
|
}, opening === true ? "\u6B63\u5728\u6253\u5F00\u2026" : "\u5728\u65B0\u7A97\u53E3\u6253\u5F00\u6388\u6743\u9875"),
|
|
21631
|
-
|
|
22352
|
+
h2("button", { className: "odc-button", type: "button", disabled: copyState === "copying", onClick: () => {
|
|
21632
22353
|
void copyLink();
|
|
21633
22354
|
} }, copyState === "copying" ? "\u6B63\u5728\u590D\u5236\u2026" : "\u590D\u5236\u6388\u6743\u94FE\u63A5"),
|
|
21634
|
-
|
|
22355
|
+
h2("a", { className: "odc-link", href: url2, target: "_blank", rel: "noreferrer noopener" }, "\u5B98\u65B9\u6388\u6743\u9875")
|
|
21635
22356
|
),
|
|
21636
|
-
copyState === "copied" ?
|
|
21637
|
-
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(
|
|
21638
22359
|
"label",
|
|
21639
22360
|
{ className: "odc-field" },
|
|
21640
|
-
|
|
21641
|
-
|
|
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() })
|
|
21642
22363
|
) : null,
|
|
21643
|
-
notice ?
|
|
21644
|
-
|
|
21645
|
-
|
|
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")
|
|
21646
22367
|
);
|
|
21647
22368
|
}
|
|
21648
22369
|
function Connection({ status, formSnapshot, setFormField, pendingField, caller, onLoginStatus, onStatus }) {
|
|
21649
22370
|
const mounted = useMounted();
|
|
21650
|
-
const actionVersion =
|
|
21651
|
-
const [busy, setBusy] =
|
|
21652
|
-
const [notice, setNotice] =
|
|
21653
|
-
const [apiKey, setApiKey] =
|
|
21654
|
-
const [keyBusy, setKeyBusy] =
|
|
21655
|
-
const [opening, setOpening] =
|
|
21656
|
-
const [activationNotice, setActivationNotice] =
|
|
21657
|
-
const activationJob =
|
|
21658
|
-
const activationToken =
|
|
21659
|
-
const autoOpenPending =
|
|
21660
|
-
|
|
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(() => () => {
|
|
21661
22382
|
actionVersion.current += 1;
|
|
21662
22383
|
}, []);
|
|
21663
22384
|
const login = status?.login;
|
|
21664
|
-
|
|
22385
|
+
React2.useEffect(() => {
|
|
21665
22386
|
const job = login?.jobId ?? null;
|
|
21666
22387
|
if (activationJob.current === job) return;
|
|
21667
22388
|
activationJob.current = job;
|
|
@@ -21746,7 +22467,7 @@ function Connection({ status, formSnapshot, setFormField, pendingField, caller,
|
|
|
21746
22467
|
if (mounted.current && activationToken.current === token) setOpening(false);
|
|
21747
22468
|
}
|
|
21748
22469
|
};
|
|
21749
|
-
|
|
22470
|
+
React2.useEffect(() => {
|
|
21750
22471
|
if (!autoOpenPending.current || busy || keyBusy || opening || status === void 0) return;
|
|
21751
22472
|
if (state === "waiting") {
|
|
21752
22473
|
autoOpenPending.current = false;
|
|
@@ -21757,18 +22478,18 @@ function Connection({ status, formSnapshot, setFormField, pendingField, caller,
|
|
|
21757
22478
|
}, [state, login?.jobId, busy, keyBusy, opening, status]);
|
|
21758
22479
|
const desktopChecked = formSnapshot.value?.useDesktopCredential ?? status?.config.useDesktopCredential ?? true;
|
|
21759
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";
|
|
21760
|
-
return
|
|
21761
|
-
|
|
22481
|
+
return h2(
|
|
22482
|
+
React2.Fragment,
|
|
21762
22483
|
null,
|
|
21763
|
-
|
|
22484
|
+
h2(
|
|
21764
22485
|
"section",
|
|
21765
22486
|
{ className: "odc-card" },
|
|
21766
|
-
|
|
21767
|
-
|
|
21768
|
-
|
|
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(
|
|
21769
22490
|
"div",
|
|
21770
22491
|
{ style: { marginTop: 14 } },
|
|
21771
|
-
|
|
22492
|
+
h2(Switch, {
|
|
21772
22493
|
checked: desktopChecked,
|
|
21773
22494
|
disabled: formSnapshot.status !== "ready" || formSnapshot.value === void 0 || !formSnapshot.writable || pendingField.includes("useDesktopCredential"),
|
|
21774
22495
|
label: "\u4F18\u5148\u4F7F\u7528\u684C\u9762\u767B\u5F55\u6001",
|
|
@@ -21778,46 +22499,46 @@ function Connection({ status, formSnapshot, setFormField, pendingField, caller,
|
|
|
21778
22499
|
}
|
|
21779
22500
|
})
|
|
21780
22501
|
),
|
|
21781
|
-
|
|
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]}`)
|
|
21782
22503
|
),
|
|
21783
|
-
|
|
22504
|
+
h2(
|
|
21784
22505
|
"section",
|
|
21785
22506
|
{ className: "odc-card" },
|
|
21786
|
-
|
|
21787
|
-
|
|
21788
|
-
|
|
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(
|
|
21789
22510
|
"div",
|
|
21790
22511
|
{ className: "odc-actions", style: { marginTop: 14 } },
|
|
21791
|
-
|
|
22512
|
+
h2("button", { className: "odc-button odc-button-primary", type: "button", disabled: status === void 0 || busy || keyBusy || inFlight, onClick: () => {
|
|
21792
22513
|
void startLogin();
|
|
21793
22514
|
} }, "\u5F00\u59CB\u8BBE\u5907\u6388\u6743"),
|
|
21794
|
-
inFlight ?
|
|
22515
|
+
inFlight ? h2("button", { className: "odc-button", type: "button", disabled: busy || keyBusy || login?.jobId == null, onClick: () => {
|
|
21795
22516
|
void cancelLogin();
|
|
21796
22517
|
} }, "\u53D6\u6D88\u767B\u5F55") : null,
|
|
21797
|
-
|
|
22518
|
+
h2("a", { className: "odc-link", href: OFFICIAL_SITE, target: "_blank", rel: "noreferrer noopener" }, "\u6253\u5F00 CoRouter \u5B98\u7F51")
|
|
21798
22519
|
),
|
|
21799
|
-
|
|
22520
|
+
h2(LoginApproval, { login, onOpen: () => {
|
|
21800
22521
|
void openActivation();
|
|
21801
22522
|
}, opening, notice: activationNotice }),
|
|
21802
|
-
|
|
21803
|
-
|
|
22523
|
+
h2("p", { className: "odc-meta", role: state === "error" ? "alert" : "status" }, login?.message ?? LOGIN_LABELS[state]),
|
|
22524
|
+
h2(NoticeView, { notice })
|
|
21804
22525
|
),
|
|
21805
|
-
|
|
22526
|
+
h2(
|
|
21806
22527
|
"section",
|
|
21807
22528
|
{ className: "odc-card" },
|
|
21808
|
-
|
|
21809
|
-
|
|
21810
|
-
|
|
21811
|
-
|
|
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(
|
|
21812
22533
|
"form",
|
|
21813
22534
|
{ onSubmit: (event) => {
|
|
21814
22535
|
void saveKey(event);
|
|
21815
22536
|
} },
|
|
21816
|
-
|
|
22537
|
+
h2(
|
|
21817
22538
|
"div",
|
|
21818
22539
|
{ className: "odc-field" },
|
|
21819
|
-
|
|
21820
|
-
|
|
22540
|
+
h2("label", { htmlFor: "odc-api-key" }, "\u65B0\u7684 API Key"),
|
|
22541
|
+
h2("input", {
|
|
21821
22542
|
id: "odc-api-key",
|
|
21822
22543
|
className: "odc-input",
|
|
21823
22544
|
type: "password",
|
|
@@ -21829,12 +22550,12 @@ function Connection({ status, formSnapshot, setFormField, pendingField, caller,
|
|
|
21829
22550
|
placeholder: "\u4EC5\u7528\u4E8E\u672C\u6B21\u4FDD\u5B58\uFF0C\u4E0D\u4F1A\u56DE\u586B",
|
|
21830
22551
|
onChange: (event) => setApiKey(event.target.value)
|
|
21831
22552
|
}),
|
|
21832
|
-
|
|
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")
|
|
21833
22554
|
),
|
|
21834
|
-
|
|
22555
|
+
h2(
|
|
21835
22556
|
"div",
|
|
21836
22557
|
{ className: "odc-actions", style: { marginTop: 12 } },
|
|
21837
|
-
|
|
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")
|
|
21838
22559
|
)
|
|
21839
22560
|
)
|
|
21840
22561
|
)
|
|
@@ -21850,50 +22571,58 @@ function tabAfter(current, key) {
|
|
|
21850
22571
|
}
|
|
21851
22572
|
function SettingsPage({ caller, form }) {
|
|
21852
22573
|
const mounted = useMounted();
|
|
21853
|
-
const [tab, setTab] =
|
|
21854
|
-
const [status, setStatus] =
|
|
21855
|
-
const [error62, setError] =
|
|
21856
|
-
const [loading, setLoading] =
|
|
21857
|
-
const [refreshing, setRefreshing] =
|
|
21858
|
-
const [refreshingModels, setRefreshingModels] =
|
|
21859
|
-
const [prices, setPrices] =
|
|
21860
|
-
const [refreshingPrices, setRefreshingPrices] =
|
|
21861
|
-
const pricesBusy =
|
|
21862
|
-
const pricesRequested =
|
|
21863
|
-
const [modelsNotice, setModelsNotice] =
|
|
21864
|
-
const
|
|
21865
|
-
const
|
|
21866
|
-
|
|
21867
|
-
|
|
21868
|
-
|
|
21869
|
-
|
|
21870
|
-
const
|
|
21871
|
-
const
|
|
21872
|
-
const
|
|
21873
|
-
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();
|
|
21874
22600
|
const acceptedFormSnapshot = useFormSnapshot(form);
|
|
21875
|
-
const
|
|
21876
|
-
const
|
|
21877
|
-
const
|
|
21878
|
-
const batchWriteFailed = React.useRef(false);
|
|
21879
|
-
const formSnapshot = React.useMemo(() => ({
|
|
22601
|
+
const batchWriteFailed = React2.useRef(false);
|
|
22602
|
+
const pageBatchActive = React2.useRef(false);
|
|
22603
|
+
const formSnapshot = React2.useMemo(() => ({
|
|
21880
22604
|
...acceptedFormSnapshot,
|
|
21881
|
-
value: acceptedFormSnapshot.value === void 0 ? void 0 : { ...acceptedFormSnapshot.value, ...pendingValues }
|
|
21882
|
-
}), [acceptedFormSnapshot,
|
|
21883
|
-
|
|
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) => {
|
|
21884
22613
|
statusVersion.current += 1;
|
|
21885
22614
|
loginVersion.current += 1;
|
|
21886
22615
|
setStatus((previous) => previous === void 0 ? previous : { ...previous, login });
|
|
21887
22616
|
setError(void 0);
|
|
21888
22617
|
}, []);
|
|
21889
|
-
const acceptStatus =
|
|
22618
|
+
const acceptStatus = React2.useCallback((next) => {
|
|
21890
22619
|
statusVersion.current += 1;
|
|
21891
22620
|
loginVersion.current += 1;
|
|
21892
22621
|
setStatus(next);
|
|
21893
22622
|
setModelsNotice(null);
|
|
21894
22623
|
setError(void 0);
|
|
21895
22624
|
}, []);
|
|
21896
|
-
const loadStatus =
|
|
22625
|
+
const loadStatus = React2.useCallback(async () => {
|
|
21897
22626
|
const version2 = ++statusVersion.current;
|
|
21898
22627
|
try {
|
|
21899
22628
|
const next = await caller("status");
|
|
@@ -21906,9 +22635,9 @@ function SettingsPage({ caller, form }) {
|
|
|
21906
22635
|
if (mounted.current && version2 === statusVersion.current) setLoading(false);
|
|
21907
22636
|
}
|
|
21908
22637
|
}, [caller, mounted]);
|
|
21909
|
-
const refreshBusy =
|
|
21910
|
-
const forcedRefreshPending =
|
|
21911
|
-
const refresh =
|
|
22638
|
+
const refreshBusy = React2.useRef(false);
|
|
22639
|
+
const forcedRefreshPending = React2.useRef(false);
|
|
22640
|
+
const refresh = React2.useCallback(async (force = false) => {
|
|
21912
22641
|
if (refreshBusy.current) {
|
|
21913
22642
|
if (force) forcedRefreshPending.current = true;
|
|
21914
22643
|
return;
|
|
@@ -21935,7 +22664,7 @@ function SettingsPage({ caller, form }) {
|
|
|
21935
22664
|
}
|
|
21936
22665
|
}
|
|
21937
22666
|
}, [caller, loadStatus, mounted]);
|
|
21938
|
-
|
|
22667
|
+
React2.useEffect(() => {
|
|
21939
22668
|
void loadStatus();
|
|
21940
22669
|
void refresh();
|
|
21941
22670
|
return () => {
|
|
@@ -21947,21 +22676,14 @@ function SettingsPage({ caller, form }) {
|
|
|
21947
22676
|
forcedRefreshPending.current = false;
|
|
21948
22677
|
};
|
|
21949
22678
|
}, [loadStatus, refresh]);
|
|
21950
|
-
const setFormField =
|
|
22679
|
+
const setFormField = React2.useCallback(async (field, value, baseValue) => {
|
|
21951
22680
|
const snapshot = form.getSnapshot();
|
|
21952
|
-
if (snapshot.status !== "ready" || snapshot.value === void 0 || !snapshot.writable ||
|
|
21953
|
-
if (
|
|
21954
|
-
|
|
21955
|
-
writeVersions.current.set(field, version2);
|
|
21956
|
-
setPendingField([...writeVersions.current.keys()]);
|
|
21957
|
-
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;
|
|
21958
22684
|
setFormNotice({ kind: "status", text: "\u6B63\u5728\u4FDD\u5B58\u8BBE\u7F6E\u2026" });
|
|
21959
22685
|
try {
|
|
21960
|
-
const
|
|
21961
|
-
writeTail.current = operation.then(() => {
|
|
21962
|
-
}, () => {
|
|
21963
|
-
});
|
|
21964
|
-
const accepted = await operation;
|
|
22686
|
+
const accepted = await writes.set(field, value, baseValue);
|
|
21965
22687
|
if (!accepted) batchWriteFailed.current = true;
|
|
21966
22688
|
if (accepted && mounted.current && (field === "useDesktopCredential" || field === "quotaRefreshSeconds")) void refresh(true);
|
|
21967
22689
|
return accepted;
|
|
@@ -21969,22 +22691,14 @@ function SettingsPage({ caller, form }) {
|
|
|
21969
22691
|
batchWriteFailed.current = true;
|
|
21970
22692
|
return false;
|
|
21971
22693
|
} finally {
|
|
21972
|
-
if (
|
|
21973
|
-
|
|
21974
|
-
|
|
21975
|
-
setPendingValues((previous) => {
|
|
21976
|
-
const next = { ...previous };
|
|
21977
|
-
delete next[field];
|
|
21978
|
-
return next;
|
|
21979
|
-
});
|
|
21980
|
-
setPendingField([...writeVersions.current.keys()]);
|
|
21981
|
-
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" });
|
|
21982
|
-
}
|
|
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" });
|
|
21983
22697
|
}
|
|
21984
22698
|
}
|
|
21985
|
-
}, [form, mounted, refresh]);
|
|
21986
|
-
const refreshModelsBusy =
|
|
21987
|
-
const refreshModels =
|
|
22699
|
+
}, [form, mounted, refresh, writes]);
|
|
22700
|
+
const refreshModelsBusy = React2.useRef(false);
|
|
22701
|
+
const refreshModels = React2.useCallback(async () => {
|
|
21988
22702
|
if (refreshModelsBusy.current) return;
|
|
21989
22703
|
refreshModelsBusy.current = true;
|
|
21990
22704
|
const version2 = ++modelsVersion.current;
|
|
@@ -22005,7 +22719,7 @@ function SettingsPage({ caller, form }) {
|
|
|
22005
22719
|
}
|
|
22006
22720
|
}
|
|
22007
22721
|
}, [caller, mounted]);
|
|
22008
|
-
const refreshPrices =
|
|
22722
|
+
const refreshPrices = React2.useCallback(async () => {
|
|
22009
22723
|
if (pricesBusy.current) return;
|
|
22010
22724
|
pricesBusy.current = true;
|
|
22011
22725
|
setRefreshingPrices(true);
|
|
@@ -22019,14 +22733,14 @@ function SettingsPage({ caller, form }) {
|
|
|
22019
22733
|
if (mounted.current) setRefreshingPrices(false);
|
|
22020
22734
|
}
|
|
22021
22735
|
}, [caller, mounted]);
|
|
22022
|
-
|
|
22736
|
+
React2.useEffect(() => {
|
|
22023
22737
|
if (tab !== "models" || pricesRequested.current) return;
|
|
22024
22738
|
pricesRequested.current = true;
|
|
22025
22739
|
void refreshPrices();
|
|
22026
22740
|
}, [tab, refreshPrices]);
|
|
22027
22741
|
const loginState = status?.login.state;
|
|
22028
22742
|
const loginActive = loginState !== void 0 && loginInFlight(loginState);
|
|
22029
|
-
|
|
22743
|
+
React2.useEffect(() => {
|
|
22030
22744
|
if (!loginActive) return;
|
|
22031
22745
|
let stopped = false;
|
|
22032
22746
|
const poll = async () => {
|
|
@@ -22049,7 +22763,7 @@ function SettingsPage({ caller, form }) {
|
|
|
22049
22763
|
loginVersion.current += 1;
|
|
22050
22764
|
};
|
|
22051
22765
|
}, [caller, loadStatus, loginActive, mounted, refresh]);
|
|
22052
|
-
|
|
22766
|
+
React2.useEffect(() => {
|
|
22053
22767
|
if (loginState !== "success") return;
|
|
22054
22768
|
void loadStatus();
|
|
22055
22769
|
void refresh(true);
|
|
@@ -22057,11 +22771,11 @@ function SettingsPage({ caller, form }) {
|
|
|
22057
22771
|
const configuredSeconds = formSnapshot.value?.quotaRefreshSeconds ?? status?.config.quotaRefreshSeconds;
|
|
22058
22772
|
const refreshIntervalSeconds = configuredSeconds === void 0 ? DEFAULT_QUOTA_REFRESH_SECONDS : normaliseQuotaRefreshSeconds(configuredSeconds);
|
|
22059
22773
|
const quotaNextRefreshAt = status?.quota.nextRefreshAt;
|
|
22060
|
-
const schedule =
|
|
22774
|
+
const schedule = React2.useMemo(
|
|
22061
22775
|
() => status?.quota.state === "need-login" || status?.quota.autoRefreshPaused ? void 0 : quotaAutoRefresh(refreshIntervalSeconds, quotaNextRefreshAt, Date.now(), Boolean(status?.quota.refreshFailures)),
|
|
22062
22776
|
[refreshIntervalSeconds, quotaNextRefreshAt, status?.quota.state, status?.quota.autoRefreshPaused, status?.quota.refreshFailures, scheduleTick]
|
|
22063
22777
|
);
|
|
22064
|
-
|
|
22778
|
+
React2.useEffect(() => {
|
|
22065
22779
|
if (schedule === void 0) return;
|
|
22066
22780
|
const timer = setTimeout(() => {
|
|
22067
22781
|
void refresh().finally(() => {
|
|
@@ -22076,7 +22790,7 @@ function SettingsPage({ caller, form }) {
|
|
|
22076
22790
|
};
|
|
22077
22791
|
let content;
|
|
22078
22792
|
if (tab === "overview") {
|
|
22079
|
-
content =
|
|
22793
|
+
content = h2(Overview, {
|
|
22080
22794
|
status,
|
|
22081
22795
|
busy: refreshing,
|
|
22082
22796
|
onRefresh: () => {
|
|
@@ -22087,7 +22801,7 @@ function SettingsPage({ caller, form }) {
|
|
|
22087
22801
|
refreshIntervalSeconds
|
|
22088
22802
|
});
|
|
22089
22803
|
} else if (tab === "models") {
|
|
22090
|
-
content =
|
|
22804
|
+
content = h2(Models, {
|
|
22091
22805
|
status,
|
|
22092
22806
|
formSnapshot,
|
|
22093
22807
|
setFormField,
|
|
@@ -22104,16 +22818,16 @@ function SettingsPage({ caller, form }) {
|
|
|
22104
22818
|
}
|
|
22105
22819
|
});
|
|
22106
22820
|
} else if (tab === "connection") {
|
|
22107
|
-
content =
|
|
22821
|
+
content = h2(Connection, { status, formSnapshot, setFormField, pendingField, caller, onLoginStatus: acceptLoginStatus, onStatus: acceptStatus });
|
|
22108
22822
|
} else {
|
|
22109
|
-
content =
|
|
22823
|
+
content = h2(Advanced, { status, formSnapshot, setFormField, pendingField });
|
|
22110
22824
|
}
|
|
22111
|
-
return
|
|
22825
|
+
return h2(
|
|
22112
22826
|
"div",
|
|
22113
22827
|
{ className: "odc-settings" },
|
|
22114
|
-
|
|
22115
|
-
|
|
22116
|
-
|
|
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", {
|
|
22117
22831
|
key: item.id,
|
|
22118
22832
|
ref: (node2) => {
|
|
22119
22833
|
tabRefs.current[index] = node2;
|
|
@@ -22134,17 +22848,17 @@ function SettingsPage({ caller, form }) {
|
|
|
22134
22848
|
tabRefs.current[TABS.findIndex((candidate) => candidate.id === next)]?.focus();
|
|
22135
22849
|
}
|
|
22136
22850
|
}, item.label))),
|
|
22137
|
-
acceptedFormSnapshot.status !== "ready" || acceptedFormSnapshot.value === void 0 ?
|
|
22138
|
-
|
|
22139
|
-
|
|
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", {
|
|
22140
22854
|
className: "odc-panel",
|
|
22141
22855
|
role: "tabpanel",
|
|
22142
22856
|
id: `${baseId}-panel`,
|
|
22143
22857
|
tabIndex: 0,
|
|
22144
22858
|
"aria-labelledby": `${baseId}-tab-${tab}`
|
|
22145
22859
|
}, content),
|
|
22146
|
-
loading ?
|
|
22147
|
-
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
|
|
22148
22862
|
);
|
|
22149
22863
|
}
|
|
22150
22864
|
var name = "dsh-opendesign-corouter";
|
|
@@ -22155,6 +22869,8 @@ function apply(ctx) {
|
|
|
22155
22869
|
const caller = createCaller(ctx);
|
|
22156
22870
|
ctx.inject(["configForms"], (scope) => {
|
|
22157
22871
|
const form = scope.configForms.get(SETTINGS_NS);
|
|
22872
|
+
const writes = configWritesFor(form);
|
|
22873
|
+
scope.effect(() => () => writes.dispose(), "opendesign-corouter: shared settings writes");
|
|
22158
22874
|
scope.effect(() => scope.slots.inject("settings.section", () => scope.slots.register({
|
|
22159
22875
|
name: "settings.section",
|
|
22160
22876
|
id: "opendesign-corouter",
|
|
@@ -22162,6 +22878,14 @@ function apply(ctx) {
|
|
|
22162
22878
|
label: () => "OpenDesign CoRouter",
|
|
22163
22879
|
inject: () => ({ caller, form })
|
|
22164
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
|
+
});
|
|
22165
22889
|
});
|
|
22166
22890
|
}
|
|
22167
22891
|
return module.exports;}});
|