@lynn123411/dsh-subagent-judge-dispatch 0.6.14 → 0.6.15

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/lib/client.js CHANGED
@@ -31,7 +31,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/client/index.ts
32
32
  var index_exports = {};
33
33
  __export(index_exports, {
34
- ALLOWED_MODELS_NAMESPACE: () => ALLOWED_MODELS_NAMESPACE,
35
34
  JudgeDispatchPanel: () => JudgeDispatchPanel,
36
35
  NS: () => NS,
37
36
  SETTINGS_NAMESPACE: () => SETTINGS_NAMESPACE,
@@ -144,10 +143,7 @@ var en = {
144
143
  "ready.loading": "Waiting for the settings from DSH.",
145
144
  "ready.address": "Enter a valid service address.",
146
145
  "ready.model": "Enter the judgement model.",
147
- "ready.authorization.unknown": "Could not confirm which models DSH allows for subagents.",
148
- "ready.authorization.disabled": "Enable model selection under Plugins \u2192 Subagent.",
149
- "ready.authorization.invalid": "Add valid allowed models under Plugins \u2192 Subagent.",
150
- "ready.rules": "Complete a task rule and choose an allowed model.",
146
+ "ready.rules": "Complete a task rule with an available model.",
151
147
  "ready.count": "{used} of {total} task rules ready",
152
148
  "ready.readOnly": "This page can only view settings.",
153
149
  "transfer.judge": "Connection import/export",
@@ -213,14 +209,19 @@ var en = {
213
209
  "judge.probing": "Testing\u2026",
214
210
  "judge.probeOk": "Connected in {latency} ms",
215
211
  "judge.probeFail": "Not usable: {reason}",
212
+ "judge.probeHttpStatus": " (HTTP {status})",
216
213
  "reason.unconfigured": "the endpoint address or model is not filled in",
217
214
  "reason.unreachable": "the endpoint could not be reached",
215
+ "reason.authentication": "the service rejected the credentials or access",
216
+ "reason.rate-limited": "the service is receiving too many requests",
217
+ "reason.server-error": "the service reported a server error",
218
+ "reason.http-error": "the service rejected the request",
218
219
  "reason.timeout": "it did not answer within 5 seconds",
219
220
  "reason.unmatched": "the answer named no listed type",
220
221
  "reason.incomplete": "the selected type is not filled in",
221
222
  "reason.unavailable-route": "the selected model or effort is unavailable",
222
223
  "reason.no-match": "no configured type applies",
223
- "reason.no-authorized-route": "none of the configured types has a model DSH currently allows",
224
+ "reason.no-authorized-route": "none of the configured types has a model in the current DSH catalog",
224
225
  "reason.unidentified-task": "the original task could not be identified",
225
226
  "reason.explicit-route": "the delegation already specified a model",
226
227
  "reason.recorded-route": "the subagent already selected or used a model",
@@ -248,17 +249,22 @@ var en = {
248
249
  "rows.hintDuplicateDescription": "Description repeats another row",
249
250
  "rows.hintNoModel": "Choose a model",
250
251
  "rows.hintNoEffort": "Choose a reasoning effort",
251
- "rows.hintModelNotAllowed": "Model is outside the host\u2019s allowed list",
252
+ "rows.hintModelUnavailable": "Model is missing from the DSH catalog",
252
253
  "rows.hintEffortUnavailable": "This model does not support the selected effort",
253
254
  "rows.modelPlaceholder": "Not chosen",
255
+ "rows.modelSearch": "Search models or providers",
256
+ "rows.modelSearchClear": "Clear search",
257
+ "rows.modelSearchEmpty": "No matching models",
258
+ "rows.catalogLoading": "Loading the DSH model catalog\u2026",
259
+ "rows.catalogUnavailable": "Could not load the DSH model catalog.",
260
+ "rows.catalogRetry": "Retry loading models",
261
+ "rows.catalogEmpty": "No models are listed in DSH. Add one in Models settings.",
254
262
  "rows.effortPlaceholder": "Not chosen",
255
263
  "rows.effortChoices": "Effort choices",
256
264
  "rows.effortDefault": "Model default",
257
265
  "rows.useDefaultEffort": "Use model default",
258
266
  "rows.incomplete": "Not used",
259
267
  "rows.descriptionPlaceholder": "What kind of job is this? Write as much as you like.",
260
- "rows.dependsOn": "Under Plugins \u2192 Official \u2192 Subagent, enable model selection and add allowed models. If it is off, the child keeps its original model.",
261
- "rows.allowedEmpty": "The official setting offers no model yet; fill it in and the options appear here.",
262
268
  "rows.importOpen": "Import",
263
269
  "rows.export": "Export",
264
270
  "rows.exported": "Copied the task-type list as JSON.",
@@ -299,6 +305,7 @@ var en = {
299
305
  "log.column.duration": "Duration",
300
306
  "log.column.details": "Details",
301
307
  "log.loading": "Loading the log\u2026",
308
+ "log.recovered": "The damaged log was saved as a backup. New entries are recorded in a new log.",
302
309
  "log.empty": "No entries yet.",
303
310
  "log.filterLabel": "Filter by result",
304
311
  "log.filterAll": "All",
@@ -366,10 +373,7 @@ var zh = {
366
373
  "ready.loading": "\u6B63\u5728\u8BFB\u53D6 DSH \u8BBE\u7F6E\u3002",
367
374
  "ready.address": "\u8BF7\u586B\u5199\u6709\u6548\u7684\u670D\u52A1\u5730\u5740\u3002",
368
375
  "ready.model": "\u8BF7\u586B\u5199\u5224\u65AD\u6A21\u578B\u3002",
369
- "ready.authorization.unknown": "\u8FD8\u65E0\u6CD5\u786E\u8BA4 DSH \u5141\u8BB8\u5B50\u4EE3\u7406\u4F7F\u7528\u54EA\u4E9B\u6A21\u578B\u3002",
370
- "ready.authorization.disabled": "\u8BF7\u5728\u300C\u63D2\u4EF6 \u2192 \u5B50\u667A\u80FD\u4F53\u300D\u4E2D\u5F00\u542F\u6A21\u578B\u9009\u62E9\u3002",
371
- "ready.authorization.invalid": "\u8BF7\u5728\u300C\u63D2\u4EF6 \u2192 \u5B50\u667A\u80FD\u4F53\u300D\u4E2D\u6DFB\u52A0\u6709\u6548\u7684\u5141\u8BB8\u6A21\u578B\u3002",
372
- "ready.rules": "\u8BF7\u586B\u597D\u81F3\u5C11\u4E00\u6761\u4EFB\u52A1\u89C4\u5219\uFF0C\u5E76\u4E3A\u5B83\u9009\u4E00\u4E2A\u5141\u8BB8\u4F7F\u7528\u7684\u6A21\u578B\u3002",
376
+ "ready.rules": "\u8BF7\u586B\u597D\u81F3\u5C11\u4E00\u6761\u4EFB\u52A1\u89C4\u5219\uFF0C\u5E76\u9009\u62E9\u4E00\u4E2A\u53EF\u7528\u7684\u6A21\u578B\u3002",
373
377
  "ready.count": "{total} \u6761\u89C4\u5219\u4E2D\u6709 {used} \u6761\u53EF\u7528",
374
378
  "ready.readOnly": "\u6B64\u9875\u9762\u53EA\u80FD\u67E5\u770B\u914D\u7F6E\u3002",
375
379
  "transfer.judge": "\u5BFC\u5165\uFF0F\u5BFC\u51FA\u8FDE\u63A5\u8BBE\u7F6E",
@@ -435,14 +439,19 @@ var zh = {
435
439
  "judge.probing": "\u6B63\u5728\u8BD5\u2026",
436
440
  "judge.probeOk": "\u8FDE\u4E0A\u4E86\uFF0C\u7528\u4E86 {latency} \u6BEB\u79D2",
437
441
  "judge.probeFail": "\u7528\u4E0D\u4E86\uFF1A{reason}",
442
+ "judge.probeHttpStatus": "\uFF08HTTP {status}\uFF09",
438
443
  "reason.unconfigured": "\u7AEF\u70B9\u5730\u5740\u6216\u5224\u65AD\u6A21\u578B\u8FD8\u6CA1\u586B",
439
444
  "reason.unreachable": "\u8FDE\u4E0D\u4E0A\u8FD9\u4E2A\u5730\u5740",
445
+ "reason.authentication": "\u51ED\u636E\u6216\u6743\u9650\u6709\u95EE\u9898",
446
+ "reason.rate-limited": "\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41",
447
+ "reason.server-error": "\u5224\u65AD\u670D\u52A1\u51FA\u9519",
448
+ "reason.http-error": "\u5224\u65AD\u670D\u52A1\u62D2\u7EDD\u4E86\u8BF7\u6C42",
440
449
  "reason.timeout": "\u5224\u65AD\u6216\u8DEF\u7EBF\u6821\u9A8C\u8D85\u8FC7 5 \u79D2",
441
450
  "reason.unmatched": "\u7B54\u590D\u5BF9\u4E0D\u4E0A\u6E05\u5355",
442
451
  "reason.incomplete": "\u9009\u4E2D\u7684\u7C7B\u578B\u6CA1\u586B\u5168",
443
452
  "reason.unavailable-route": "\u9009\u4E2D\u7684\u6A21\u578B\u6216\u63A8\u7406\u7B49\u7EA7\u5F53\u524D\u4E0D\u53EF\u7528",
444
453
  "reason.no-match": "\u6CA1\u6709\u9002\u7528\u7684\u4EFB\u52A1\u7C7B\u578B",
445
- "reason.no-authorized-route": "\u89C4\u5219\u91CC\u6CA1\u6709 DSH \u5F53\u524D\u5141\u8BB8\u4F7F\u7528\u7684\u6A21\u578B",
454
+ "reason.no-authorized-route": "\u89C4\u5219\u4E2D\u6CA1\u6709\u6A21\u578B\u51FA\u73B0\u5728\u5F53\u524D DSH \u76EE\u5F55\u91CC",
446
455
  "reason.unidentified-task": "\u627E\u4E0D\u5230\u8FD9\u6B21\u6D3E\u51FA\u7684\u539F\u4EFB\u52A1",
447
456
  "reason.explicit-route": "\u6D3E\u4EFB\u52A1\u65F6\u5DF2\u6307\u5B9A\u6A21\u578B",
448
457
  "reason.recorded-route": "\u5B50\u4EE3\u7406\u5DF2\u9009\u62E9\u6216\u4F7F\u7528\u8FC7\u6A21\u578B",
@@ -470,17 +479,22 @@ var zh = {
470
479
  "rows.hintDuplicateDescription": "\u63CF\u8FF0\u548C\u522B\u7684\u884C\u91CD\u590D",
471
480
  "rows.hintNoModel": "\u672A\u9009\u6A21\u578B",
472
481
  "rows.hintNoEffort": "\u672A\u9009\u63A8\u7406\u5F3A\u5EA6",
473
- "rows.hintModelNotAllowed": "\u6A21\u578B\u4E0D\u5728\u5BBF\u4E3B\u5141\u8BB8\u6E05\u5355\u4E2D",
482
+ "rows.hintModelUnavailable": "DSH \u6A21\u578B\u76EE\u5F55\u4E2D\u6CA1\u6709\u8FD9\u4E2A\u6A21\u578B",
474
483
  "rows.hintEffortUnavailable": "\u8BE5\u6A21\u578B\u4E0D\u652F\u6301\u9009\u4E2D\u7684\u63A8\u7406\u5F3A\u5EA6",
475
484
  "rows.modelPlaceholder": "\u8FD8\u6CA1\u9009",
485
+ "rows.modelSearch": "\u641C\u7D22\u6A21\u578B\u6216\u4F9B\u5E94\u5546",
486
+ "rows.modelSearchClear": "\u6E05\u9664\u641C\u7D22",
487
+ "rows.modelSearchEmpty": "\u6CA1\u6709\u5339\u914D\u7684\u6A21\u578B",
488
+ "rows.catalogLoading": "\u6B63\u5728\u8BFB\u53D6 DSH \u6A21\u578B\u76EE\u5F55\u2026",
489
+ "rows.catalogUnavailable": "\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6 DSH \u6A21\u578B\u76EE\u5F55\u3002",
490
+ "rows.catalogRetry": "\u91CD\u65B0\u8BFB\u53D6\u6A21\u578B",
491
+ "rows.catalogEmpty": "DSH \u6A21\u578B\u76EE\u5F55\u4E3A\u7A7A\u3002\u8BF7\u5728\u300C\u6A21\u578B\u300D\u8BBE\u7F6E\u4E2D\u6DFB\u52A0\u6A21\u578B\u3002",
476
492
  "rows.effortPlaceholder": "\u8FD8\u6CA1\u9009",
477
493
  "rows.effortChoices": "\u9009\u62E9\u63A8\u7406\u5F3A\u5EA6",
478
494
  "rows.effortDefault": "\u6A21\u578B\u9ED8\u8BA4",
479
495
  "rows.useDefaultEffort": "\u4F7F\u7528\u6A21\u578B\u9ED8\u8BA4\u5F3A\u5EA6",
480
496
  "rows.incomplete": "\u4E0D\u751F\u6548",
481
497
  "rows.descriptionPlaceholder": "\u8FD9\u662F\u54EA\u79CD\u6D3B\uFF1F\u5199\u591A\u5C11\u90FD\u884C\u3002",
482
- "rows.dependsOn": "\u8BF7\u5728\u300C\u63D2\u4EF6 \u2192 \u5B98\u65B9 \u2192 \u5B50\u667A\u80FD\u4F53\u300D\u4E2D\u5F00\u542F\u6A21\u578B\u9009\u62E9\u5E76\u6DFB\u52A0\u5141\u8BB8\u7684\u6A21\u578B\u3002\u5173\u95ED\u65F6\uFF0C\u5B50\u4EE3\u7406\u6CBF\u7528\u539F\u8DEF\u7EBF\u3002",
483
- "rows.allowedEmpty": "\u5B98\u65B9\u914D\u7F6E\u91CC\u8FD8\u6CA1\u6709\u53EF\u9009\u6A21\u578B\uFF0C\u586B\u4E0A\u4E4B\u540E\u8FD9\u91CC\u624D\u6709\u53EF\u9009\u9879\u3002",
484
498
  "rows.importOpen": "\u5BFC\u5165",
485
499
  "rows.export": "\u5BFC\u51FA",
486
500
  "rows.exported": "\u5DF2\u7ECF\u628A\u4EFB\u52A1\u7C7B\u578B\u6E05\u5355\u6309 JSON \u590D\u5236\u8D70\u4E86\u3002",
@@ -521,6 +535,7 @@ var zh = {
521
535
  "log.column.duration": "\u8017\u65F6",
522
536
  "log.column.details": "\u8BE6\u60C5",
523
537
  "log.loading": "\u6B63\u5728\u8BFB\u53D6\u65E5\u5FD7\u2026",
538
+ "log.recovered": "\u539F\u65E5\u5FD7\u5DF2\u635F\u574F\uFF0C\u5DF2\u4FDD\u7559\u5907\u4EFD\u3002\u65B0\u8BB0\u5F55\u4F1A\u5199\u5165\u65B0\u7684\u65E5\u5FD7\u3002",
524
539
  "log.empty": "\u8FD8\u6CA1\u6709\u65E5\u5FD7\u3002",
525
540
  "log.filterLabel": "\u6309\u7ED3\u679C\u7B5B\u9009",
526
541
  "log.filterAll": "\u5168\u90E8",
@@ -671,7 +686,7 @@ function LogDetails({ entry, t }) {
671
686
  ] })
672
687
  ] }) });
673
688
  }
674
- function LogPanel({ entries, loaded, failed, loading, onRefresh, t }) {
689
+ function LogPanel({ entries, loaded, failed, loading, recovered, onRefresh, t }) {
675
690
  const [filter, setFilter] = React.useState("all");
676
691
  const [detail, setDetail] = React.useState(null);
677
692
  const [copyResult, setCopyResult] = React.useState(null);
@@ -713,6 +728,7 @@ function LogPanel({ entries, loaded, failed, loading, onRefresh, t }) {
713
728
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: t("log.desc") }),
714
729
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { role: "status", className: "dsh-judge-log-copy-status", "data-result": copyResult ?? void 0, children: copyResult === "copied" ? t("log.analysisCopied") : copyResult === "failed" ? t("log.analysisCopyFailed") : "" })
715
730
  ] }),
731
+ recovered && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-judge-log-warning", role: "status", children: t("log.recovered") }),
716
732
  failed && !loading && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-judge-log-error", role: "alert", children: t(entries.length === 0 ? "log.loadFailed" : "log.refreshFailed") }),
717
733
  entries.length === 0 && !loaded && !failed && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-judge-log-message", role: "status", children: t("log.loading") }),
718
734
  entries.length === 0 && loaded && !failed && !loading && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-judge-log-message", role: "status", children: t("log.empty") }),
@@ -778,12 +794,13 @@ var LOG_PANEL_CSS = `
778
794
  .dsh-judge-log-toolbar { justify-content: space-between; gap: 8px 12px; }
779
795
  .dsh-judge-log-actions { gap: 6px; }
780
796
  .dsh-judge-log-filter[aria-pressed="true"] { color: var(--dsw-alias-label-primary); }
781
- .dsh-judge-log-caption, .dsh-judge-log-message, .dsh-judge-log-error {
797
+ .dsh-judge-log-caption, .dsh-judge-log-message, .dsh-judge-log-error, .dsh-judge-log-warning {
782
798
  margin: 10px 0 0;
783
799
  color: var(--dsw-alias-label-secondary);
784
800
  font: var(--dsw-font-xs-13);
785
801
  }
786
802
  .dsh-judge-log-error { color: var(--dsw-alias-state-error-primary); }
803
+ .dsh-judge-log-warning { color: var(--dsw-alias-state-warn-primary); }
787
804
  .dsh-judge-log-caption { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
788
805
  .dsh-judge-log-copy-status[data-result='copied'] { color: var(--dsw-alias-state-success-primary); }
789
806
  .dsh-judge-log-copy-status[data-result='failed'] { color: var(--dsw-alias-state-error-primary); }
@@ -881,7 +898,6 @@ var SAMPLE_ROUTE_PATH = `${BASE_PATH}/sample`;
881
898
  var KEY_STATUS_ROUTE_PATH = `${BASE_PATH}/key-status`;
882
899
 
883
900
  // src/client/settings/store.ts
884
- var ALLOWED_MODELS_NAMESPACE = "subagent-model-selection-settings";
885
901
  async function readJson(response) {
886
902
  try {
887
903
  return await response.json();
@@ -896,7 +912,7 @@ function createDispatchRemote() {
896
912
  if (!response.ok) throw new Error("Log request failed");
897
913
  const body = await readJson(response);
898
914
  if (body?.ok !== true || !Array.isArray(body.entries)) throw new Error("Invalid log response");
899
- return body.entries;
915
+ return { entries: body.entries, recovered: body.recovered === true };
900
916
  },
901
917
  async preview(task = "", label = "") {
902
918
  try {
@@ -921,7 +937,8 @@ function createDispatchRemote() {
921
937
  return {
922
938
  ok: body.ok === true,
923
939
  latencyMs: typeof body.latencyMs === "number" ? body.latencyMs : 0,
924
- ...typeof body.reason === "string" ? { reason: body.reason } : {}
940
+ ...typeof body.reason === "string" ? { reason: body.reason } : {},
941
+ ...Number.isInteger(body.httpStatus) && body.httpStatus >= 100 && body.httpStatus <= 599 ? { httpStatus: body.httpStatus } : {}
925
942
  };
926
943
  } catch {
927
944
  return { ok: false, latencyMs: 0, reason: "unreachable" };
@@ -1001,35 +1018,20 @@ function splitRouteKey(key) {
1001
1018
  if (at < 0) return { provider: "", model: "" };
1002
1019
  return { provider: key.slice(0, at), model: key.slice(at + 1) };
1003
1020
  }
1004
- function buildModelOptions(allowed, groups) {
1021
+ function buildModelOptions(groups) {
1005
1022
  const byRoute = /* @__PURE__ */ new Map();
1006
1023
  for (const group of groups) {
1007
1024
  for (const model of group.models) {
1008
1025
  byRoute.set(routeKey(group.id, model.id), {
1009
- label: model.name,
1026
+ provider: group.id,
1027
+ providerName: group.name || group.id,
1028
+ model: model.id,
1029
+ label: model.name || model.id,
1010
1030
  efforts: (model.reasoning?.efforts ?? []).map((effort) => effort.id)
1011
1031
  });
1012
1032
  }
1013
1033
  }
1014
- const options = [];
1015
- const seen = /* @__PURE__ */ new Set();
1016
- for (const entry of allowed) {
1017
- const provider = typeof entry?.provider === "string" ? entry.provider : "";
1018
- const model = typeof entry?.model === "string" ? entry.model : "";
1019
- if (provider === "" || model === "") continue;
1020
- const key = routeKey(provider, model);
1021
- if (seen.has(key)) continue;
1022
- seen.add(key);
1023
- const found = byRoute.get(key);
1024
- options.push({
1025
- provider,
1026
- model,
1027
- label: found?.label ?? model,
1028
- efforts: found?.efforts ?? [],
1029
- catalogued: found !== void 0
1030
- });
1031
- }
1032
- return options;
1034
+ return [...byRoute.values()];
1033
1035
  }
1034
1036
  function rowHints(rows, index, t) {
1035
1037
  const row = rows[index];
@@ -1140,8 +1142,7 @@ var DispatchCardStore = class {
1140
1142
  connectionRevision: 0,
1141
1143
  rows: [],
1142
1144
  models: [],
1143
- modelAuthorization: "unknown",
1144
- catalogRead: false,
1145
+ catalogStatus: "loading",
1145
1146
  committed: {
1146
1147
  enabled: DEFAULT_ENABLED,
1147
1148
  logEnabled: true,
@@ -1154,6 +1155,7 @@ var DispatchCardStore = class {
1154
1155
  writeErrors: {},
1155
1156
  key: emptyKey(),
1156
1157
  log: [],
1158
+ logRecovered: false,
1157
1159
  logLoaded: false,
1158
1160
  logFailed: false,
1159
1161
  logLoading: false
@@ -1162,7 +1164,6 @@ var DispatchCardStore = class {
1162
1164
  queue = Promise.resolve();
1163
1165
  pendingOps = [];
1164
1166
  form = null;
1165
- allowedForm = null;
1166
1167
  modelLoadRevision = 0;
1167
1168
  logLoadRevision = 0;
1168
1169
  session = null;
@@ -1171,20 +1172,20 @@ var DispatchCardStore = class {
1171
1172
  keyEndpoint = "";
1172
1173
  keyStatusRevision = 0;
1173
1174
  offForm = null;
1174
- offAllowed = null;
1175
1175
  translate = (key) => key;
1176
1176
  attach(options) {
1177
1177
  this.offForm?.();
1178
- this.offAllowed?.();
1179
1178
  this.form = options.form;
1180
- this.allowedForm = options.allowedForm;
1181
1179
  this.session = options.session;
1180
+ this.modelLoadRevision++;
1182
1181
  this.remote = options.remote;
1183
1182
  this.logLoadRevision++;
1184
1183
  this.credentials = options.credentials;
1185
1184
  this.translate = options.t;
1186
1185
  this.state = {
1187
1186
  ...this.state,
1187
+ models: [],
1188
+ catalogStatus: "loading",
1188
1189
  logLoading: false,
1189
1190
  key: { ...this.state.key, unavailable: options.credentials === null }
1190
1191
  };
@@ -1192,10 +1193,6 @@ var DispatchCardStore = class {
1192
1193
  this.offForm = this.form.subscribe(() => this.deriveCommitted());
1193
1194
  this.deriveCommitted();
1194
1195
  }
1195
- if (this.allowedForm !== null) {
1196
- this.offAllowed = this.allowedForm.subscribe(() => void this.loadModels());
1197
- }
1198
- void this.loadModels();
1199
1196
  void this.refreshKeyStatus();
1200
1197
  }
1201
1198
  getState() {
@@ -1209,28 +1206,15 @@ var DispatchCardStore = class {
1209
1206
  }
1210
1207
  async loadModels() {
1211
1208
  const revision = ++this.modelLoadRevision;
1212
- const snapshot = this.allowedForm?.getSnapshot();
1213
- const allowedValue = snapshot?.value;
1214
- const allowed = Array.isArray(allowedValue?.allowedModels) ? allowedValue.allowedModels : [];
1215
- const options = buildModelOptions(allowed, []);
1216
- const modelAuthorization = snapshot?.status !== "ready" || allowedValue === void 0 ? "unknown" : allowedValue.enabled !== true ? "disabled" : options.length === 0 || options.length !== allowed.length ? "invalid" : "enabled";
1217
- this.state = { ...this.state, models: options, catalogRead: false, modelAuthorization };
1218
- this.notify();
1219
- let groups = [];
1220
- let catalogRead = false;
1221
- if (this.allowedForm !== null && this.session !== null) {
1222
- try {
1223
- const response = await this.session.modelCatalog();
1224
- if (response.ok) {
1225
- groups = response.value.groups;
1226
- catalogRead = true;
1227
- }
1228
- } catch {
1229
- }
1209
+ this.stage({ catalogStatus: "loading", models: [] });
1210
+ let groups;
1211
+ try {
1212
+ const response = await this.session?.modelCatalog();
1213
+ if (response?.ok) groups = response.value.groups;
1214
+ } catch {
1230
1215
  }
1231
1216
  if (revision !== this.modelLoadRevision) return;
1232
- this.state = { ...this.state, models: buildModelOptions(allowed, groups), catalogRead };
1233
- this.notify();
1217
+ this.stage(groups === void 0 ? { catalogStatus: "unavailable" } : { catalogStatus: "ready", models: buildModelOptions(groups) });
1234
1218
  }
1235
1219
  async refreshKeyStatus() {
1236
1220
  const revision = ++this.keyStatusRevision;
@@ -1306,27 +1290,25 @@ var DispatchCardStore = class {
1306
1290
  this.keyEndpoint = this.state.endpointUrl;
1307
1291
  this.stage({ key: { ...this.state.key, text, failed: false, error: "" } });
1308
1292
  }
1309
- cell(index, key, value) {
1310
- if (key === "effort") {
1311
- this.chooseEffort(index, value);
1312
- return;
1313
- }
1314
- const rows = this.state.rows.map((row, at) => at === index ? { ...row, [key]: value } : row);
1315
- this.stage({ rows: key === "model" ? this.reconcileEffort(rows, index) : rows });
1293
+ describeRow(index, description) {
1294
+ const rows = this.state.rows.map((row, at) => at === index ? { ...row, description } : row);
1295
+ this.stage({ rows });
1296
+ }
1297
+ chooseModel(index, provider, model) {
1298
+ const option = this.state.models.find((candidate) => candidate.provider === provider && candidate.model === model);
1299
+ if (option === void 0) return;
1300
+ const rows = this.state.rows.map((row, at) => at === index ? {
1301
+ ...row,
1302
+ provider,
1303
+ model,
1304
+ effort: option.efforts.includes(row.effort) ? row.effort : ""
1305
+ } : row);
1306
+ this.stage({ rows });
1316
1307
  }
1317
1308
  chooseEffort(index, effort) {
1318
1309
  const rows = this.state.rows.map((row, at) => at === index ? readRow({ ...row, effort: effort ?? "", useDefaultEffort: effort === void 0 }) : row);
1319
1310
  this.stage({ rows });
1320
1311
  }
1321
- reconcileEffort(rows, index) {
1322
- const row = rows[index];
1323
- if (row === void 0) return rows;
1324
- const efforts = this.effortsFor(row);
1325
- if (efforts !== void 0 && row.effort !== "" && !efforts.includes(row.effort)) {
1326
- return rows.map((candidate, at) => at === index ? { ...candidate, effort: "" } : candidate);
1327
- }
1328
- return rows;
1329
- }
1330
1312
  addRow() {
1331
1313
  this.stage({ rows: [...this.state.rows, { description: "", provider: "", model: "", effort: "", enabled: true }] });
1332
1314
  void this.commit("rows");
@@ -1481,9 +1463,9 @@ var DispatchCardStore = class {
1481
1463
  this.state = { ...this.state, logLoading: true };
1482
1464
  this.notify();
1483
1465
  try {
1484
- const entries = await remote.log();
1466
+ const { entries, recovered } = await remote.log();
1485
1467
  if (revision !== this.logLoadRevision) return;
1486
- this.state = { ...this.state, log: entries, logLoaded: true, logFailed: false, logLoading: false };
1468
+ this.state = { ...this.state, log: entries, logRecovered: recovered, logLoaded: true, logFailed: false, logLoading: false };
1487
1469
  } catch {
1488
1470
  if (revision !== this.logLoadRevision) return;
1489
1471
  this.state = { ...this.state, logLoaded: true, logFailed: true, logLoading: false };
@@ -1512,12 +1494,6 @@ var DispatchCardStore = class {
1512
1494
  return { ok: false, reason: "unreachable" };
1513
1495
  }
1514
1496
  }
1515
- effortsFor(row) {
1516
- const option = this.state.models.find(
1517
- (candidate) => candidate.provider === row.provider && candidate.model === row.model
1518
- );
1519
- return option?.catalogued === true ? option.efforts : void 0;
1520
- }
1521
1497
  rowUsable(row) {
1522
1498
  return isOfferedRow(row);
1523
1499
  }
@@ -1598,6 +1574,33 @@ var RULES_LIST_CSS = `
1598
1574
  .dsh-judge-rule-effort-input > span { flex: 1; min-width: 0; }
1599
1575
  @media (pointer: coarse) { .dsh-judge-rule-editor { font: var(--dsw-font-m-16); } }
1600
1576
  `;
1577
+ var CLEAR_MODEL_SEARCH = "clear-model-search";
1578
+ function providerLabel(option, models) {
1579
+ const duplicate = models.some((item) => item.provider !== option.provider && item.providerName === option.providerName);
1580
+ return duplicate ? `${option.providerName} (${option.provider})` : option.providerName;
1581
+ }
1582
+ function modelLabel(option, models) {
1583
+ const duplicate = models.some((item) => item.provider === option.provider && item.model !== option.model && item.label === option.label);
1584
+ return duplicate ? `${option.label} (${option.model})` : option.label;
1585
+ }
1586
+ function modelMenuItems(models, query) {
1587
+ const words = query.trim().toLowerCase().split(/\s+/);
1588
+ const groups = /* @__PURE__ */ new Map();
1589
+ for (const option of models) {
1590
+ const searchable = [option.label, option.model, option.providerName, option.provider].join(" ").toLowerCase();
1591
+ if (!words.every((word) => searchable.includes(word))) continue;
1592
+ const group = groups.get(option.provider) ?? [];
1593
+ group.push(option);
1594
+ groups.set(option.provider, group);
1595
+ }
1596
+ return Array.from(groups, ([provider, options]) => [
1597
+ { type: "label", id: `provider:${provider}`, text: providerLabel(options[0], models) },
1598
+ ...options.map((option) => ({
1599
+ id: routeKey(provider, option.model),
1600
+ label: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { title: `${option.provider}/${option.model}`, children: modelLabel(option, models) })
1601
+ }))
1602
+ ]).flat();
1603
+ }
1601
1604
  function readRuleModel(state, row) {
1602
1605
  const provider = row.provider.trim();
1603
1606
  const model = row.model.trim();
@@ -1605,10 +1608,10 @@ function readRuleModel(state, row) {
1605
1608
  const modelChosen = provider !== "" && model !== "";
1606
1609
  const effortChosen = row.useDefaultEffort === true || effort !== "";
1607
1610
  const option = state.models.find((item) => item.provider === provider && item.model === model);
1608
- const efforts = option?.catalogued === true ? option.efforts : void 0;
1611
+ const efforts = option?.efforts;
1609
1612
  let problem;
1610
- if (modelChosen && state.modelAuthorization === "enabled" && option === void 0) {
1611
- problem = "model-not-allowed";
1613
+ if (modelChosen && state.catalogStatus === "ready" && option === void 0) {
1614
+ problem = "model-unavailable";
1612
1615
  } else if (row.useDefaultEffort !== true && effort !== "" && efforts !== void 0 && !efforts.includes(effort)) {
1613
1616
  problem = "effort-not-supported";
1614
1617
  }
@@ -1623,16 +1626,17 @@ function commitRows() {
1623
1626
  function RuleRow({ draft, index, number, state, t, onMove }) {
1624
1627
  const [editingDescription, setEditingDescription] = (0, import_react2.useState)(false);
1625
1628
  const [openMenu, setOpenMenu] = (0, import_react2.useState)(null);
1629
+ const [modelQuery, setModelQuery] = (0, import_react2.useState)("");
1626
1630
  const editorId = (0, import_react2.useId)();
1627
1631
  const editor = (0, import_react2.useRef)(null);
1628
1632
  const description = draft.description.trim();
1629
1633
  const { provider, model, effort, modelChosen, effortChosen, option, efforts, problem } = readRuleModel(state, draft);
1630
- const modelText = model === "" ? t("rows.modelPlaceholder") : [option?.label || model, provider].filter(Boolean).join(" \xB7 ");
1634
+ const modelText = model === "" ? t("rows.modelPlaceholder") : option === void 0 ? [model, provider].filter(Boolean).join(" \xB7 ") : [modelLabel(option, state.models), providerLabel(option, state.models)].join(" \xB7 ");
1631
1635
  const effortText = draft.useDefaultEffort === true ? t("rows.effortDefault") : draft.effort;
1632
1636
  const hints = rowHints(state.rows, index, (key) => key === "rows.hintDuplicateDescription" ? t(key) : "").filter(Boolean);
1633
1637
  if (!modelChosen) hints.push(t("rows.hintNoModel"));
1634
1638
  if (!effortChosen) hints.push(t("rows.hintNoEffort"));
1635
- if (problem === "model-not-allowed") hints.push(t("rows.hintModelNotAllowed"));
1639
+ if (problem === "model-unavailable") hints.push(t("rows.hintModelUnavailable"));
1636
1640
  if (problem === "effort-not-supported") hints.push(t("rows.hintEffortUnavailable"));
1637
1641
  (0, import_react2.useLayoutEffect)(() => {
1638
1642
  if (editingDescription) editor.current?.focus();
@@ -1724,7 +1728,7 @@ function RuleRow({ draft, index, number, state, t, onMove }) {
1724
1728
  value: draft.description,
1725
1729
  placeholder: t("rows.descriptionPlaceholder"),
1726
1730
  "aria-label": `${t("rows.colDescription")} ${position}`,
1727
- onChange: (event) => dispatchCardStore.cell(index, "description", event.target.value),
1731
+ onChange: (event) => dispatchCardStore.describeRow(index, event.target.value),
1728
1732
  onBlur: commitRows
1729
1733
  }
1730
1734
  ),
@@ -1748,24 +1752,39 @@ function RuleRow({ draft, index, number, state, t, onMove }) {
1748
1752
  "aria-label": `${t("rows.colModel")} ${position} \xB7 ${modelText}`,
1749
1753
  "aria-haspopup": "menu",
1750
1754
  "aria-expanded": modelMenuOpen,
1751
- onClick: () => setOpenMenu(modelMenuOpen ? null : "model"),
1755
+ onClick: () => {
1756
+ setModelQuery("");
1757
+ setOpenMenu(modelMenuOpen ? null : "model");
1758
+ },
1752
1759
  children: [
1753
1760
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-judge-rule-choice-value", children: modelText }),
1754
1761
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "aria-hidden": "true", children: "\u25BE" })
1755
1762
  ]
1756
1763
  }
1757
1764
  ),
1758
- items: state.models.map(({ provider: provider2, model: model2 }) => ({ id: routeKey(provider2, model2), label: `${provider2}/${model2}` })),
1765
+ items: modelMenuOpen ? modelMenuItems(state.models, modelQuery) : [],
1766
+ footer: modelQuery === "" ? void 0 : [{ id: CLEAR_MODEL_SEARCH, label: t("rows.modelSearchClear") }],
1759
1767
  selectedId: modelChosen ? routeKey(provider, model) : void 0,
1760
1768
  onSelect: (id) => {
1769
+ if (id === CLEAR_MODEL_SEARCH) {
1770
+ setModelQuery("");
1771
+ return;
1772
+ }
1761
1773
  const picked = splitRouteKey(id);
1762
- dispatchCardStore.cell(index, "provider", picked.provider);
1763
- dispatchCardStore.cell(index, "model", picked.model);
1774
+ dispatchCardStore.chooseModel(index, picked.provider, picked.model);
1764
1775
  closeMenu();
1765
1776
  commitRows();
1766
1777
  },
1767
1778
  onClose: closeMenu,
1768
- autoFocus: true,
1779
+ search: {
1780
+ label: t("rows.modelSearch"),
1781
+ emptyMessage: t("rows.modelSearchEmpty"),
1782
+ value: modelQuery,
1783
+ onChange: setModelQuery,
1784
+ skipAutoFocusOnTouch: true
1785
+ },
1786
+ maxVisibleRows: 8,
1787
+ minWidthFromAnchor: true,
1769
1788
  portal: true
1770
1789
  }
1771
1790
  )
@@ -2032,6 +2051,9 @@ function JudgeDispatchPanel(props) {
2032
2051
  (0, import_react3.useEffect)(() => () => {
2033
2052
  void dispatchCardStore.flush();
2034
2053
  }, []);
2054
+ (0, import_react3.useEffect)(() => {
2055
+ void dispatchCardStore.loadModels();
2056
+ }, []);
2035
2057
  (0, import_react3.useEffect)(() => {
2036
2058
  if (tab === "log") void dispatchCardStore.refreshLog();
2037
2059
  }, [tab]);
@@ -2040,16 +2062,15 @@ function JudgeDispatchPanel(props) {
2040
2062
  const savedOrigin = judgeOrigin(state.committed.endpointUrl);
2041
2063
  const keyConfigured = origin === savedOrigin && state.key.configured;
2042
2064
  const destination = (site) => site === void 0 ? t("sample.destinationMissing") : t("sample.destination").replace("{origin}", site);
2043
- const usableCount = state.modelAuthorization === "enabled" ? state.committed.rows.filter((row) => dispatchCardStore.rowUsable(row) && ruleModelProblem(state, row) === void 0).length : 0;
2065
+ const usableCount = state.catalogStatus === "ready" ? state.committed.rows.filter((row) => dispatchCardStore.rowUsable(row) && ruleModelProblem(state, row) === void 0).length : 0;
2044
2066
  const issues = [];
2045
2067
  if (!state.available) issues.push(t("ready.loading"));
2046
2068
  else {
2047
2069
  if (!savedOrigin) issues.push(t("ready.address"));
2048
2070
  if (!state.committed.judgeModel.trim()) issues.push(t("ready.model"));
2049
- if (state.modelAuthorization !== "enabled") issues.push(t(`ready.authorization.${state.modelAuthorization}`));
2050
- else if (usableCount === 0) issues.push(t("ready.rules"));
2071
+ if (state.catalogStatus === "ready" && usableCount === 0) issues.push(t("ready.rules"));
2051
2072
  }
2052
- const setupReady = issues.length === 0;
2073
+ const setupReady = issues.length === 0 && state.catalogStatus === "ready";
2053
2074
  const count = t("ready.count").replace("{used}", String(usableCount)).replace("{total}", String(state.committed.rows.length));
2054
2075
  const probeStale = probe !== null && (connectionDirty(state) || probe.revision !== state.connectionRevision);
2055
2076
  const result = sampleResult?.input === sample && sampleResult.revision === state.connectionRevision && sameRows(sampleResult.rows, state.committed.rows) ? sampleResult.result : void 0;
@@ -2154,7 +2175,7 @@ function JudgeDispatchPanel(props) {
2154
2175
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "dsh-judge-section", "aria-label": t("ready.label"), children: [
2155
2176
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsh-judge-status", "data-ready": setupReady && state.committed.enabled, children: [
2156
2177
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: t(!setupReady ? "ready.needsSetup" : state.committed.enabled ? "ready.ready" : "ready.off") }),
2157
- state.modelAuthorization !== "unknown" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-judge-desc", children: count })
2178
+ state.available && state.catalogStatus === "ready" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-judge-desc", children: count })
2158
2179
  ] }),
2159
2180
  issues.map((issue) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsh-judge-desc", children: issue }, issue)),
2160
2181
  state.available && !state.writable && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsh-judge-desc", children: t("ready.readOnly") })
@@ -2247,6 +2268,7 @@ function JudgeDispatchPanel(props) {
2247
2268
  ),
2248
2269
  !probing && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { role: "status", className: probe === null || probeStale ? "dsh-judge-desc" : probe.result.ok ? "dsh-judge-note-ok" : "dsh-judge-note-bad", children: [
2249
2270
  probe === null ? t("judge.notTested") : probeStale ? t("judge.testStale") : probe.result.ok ? t("judge.probeOk").replace("{latency}", String(probe.result.latencyMs)) : t("judge.probeFail").replace("{reason}", reasonText(probe.result.reason)),
2271
+ probe && !probeStale && !probe.result.ok && probe.result.httpStatus !== void 0 && t("judge.probeHttpStatus").replace("{status}", String(probe.result.httpStatus)),
2250
2272
  probe && !probeStale && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
2251
2273
  " \xB7 ",
2252
2274
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("time", { dateTime: new Date(probe.at).toISOString(), children: new Date(probe.at).toLocaleTimeString() })
@@ -2264,6 +2286,18 @@ function JudgeDispatchPanel(props) {
2264
2286
  transfer("rows")
2265
2287
  ] })
2266
2288
  ] }),
2289
+ state.catalogStatus !== "ready" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsh-judge-feedback", children: [
2290
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-judge-desc", role: "status", children: t(state.catalogStatus === "loading" ? "rows.catalogLoading" : "rows.catalogUnavailable") }),
2291
+ state.catalogStatus === "unavailable" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2292
+ import_dsh_client_ui_primitives4.Button,
2293
+ {
2294
+ size: "sm",
2295
+ variant: "outline",
2296
+ onClick: () => void dispatchCardStore.loadModels(),
2297
+ children: t("rows.catalogRetry")
2298
+ }
2299
+ )
2300
+ ] }) : state.models.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsh-judge-desc", children: t("rows.catalogEmpty") }),
2267
2301
  state.rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsh-judge-desc", children: t("rows.empty") }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RulesList, { state, t }),
2268
2302
  copied("rows"),
2269
2303
  saveFeedback(state, "rows", t)
@@ -2349,6 +2383,7 @@ function JudgeDispatchPanel(props) {
2349
2383
  LogPanel,
2350
2384
  {
2351
2385
  entries: state.log,
2386
+ recovered: state.logRecovered,
2352
2387
  loading: state.logLoading,
2353
2388
  loaded: state.logLoaded,
2354
2389
  failed: state.logFailed,
@@ -2462,7 +2497,6 @@ function setupSettingsUi(ctx) {
2462
2497
  try {
2463
2498
  dispatchCardStore.attach({
2464
2499
  form: ctx.configForms.get(SETTINGS_NAMESPACE),
2465
- allowedForm: ctx.configForms.get(ALLOWED_MODELS_NAMESPACE),
2466
2500
  session: ctx.remote?.session ?? null,
2467
2501
  remote: createDispatchRemote(),
2468
2502
  credentials: ctx.remote?.credentials ?? null,