@lynn123411/dsh-subagent-judge-dispatch 0.6.14 → 0.6.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/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,20 @@ 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",
225
+ "reason.catalog-unavailable": "could not verify rule models against the DSH catalog",
224
226
  "reason.unidentified-task": "the original task could not be identified",
225
227
  "reason.explicit-route": "the delegation already specified a model",
226
228
  "reason.recorded-route": "the subagent already selected or used a model",
@@ -248,17 +250,22 @@ var en = {
248
250
  "rows.hintDuplicateDescription": "Description repeats another row",
249
251
  "rows.hintNoModel": "Choose a model",
250
252
  "rows.hintNoEffort": "Choose a reasoning effort",
251
- "rows.hintModelNotAllowed": "Model is outside the host\u2019s allowed list",
253
+ "rows.hintModelUnavailable": "Model is missing from the DSH catalog",
252
254
  "rows.hintEffortUnavailable": "This model does not support the selected effort",
253
255
  "rows.modelPlaceholder": "Not chosen",
256
+ "rows.modelSearch": "Search models or providers",
257
+ "rows.modelSearchClear": "Clear search",
258
+ "rows.modelSearchEmpty": "No matching models",
259
+ "rows.catalogLoading": "Loading the DSH model catalog\u2026",
260
+ "rows.catalogUnavailable": "Could not load the DSH model catalog.",
261
+ "rows.catalogRetry": "Retry loading models",
262
+ "rows.catalogEmpty": "No models are listed in DSH. Add one in Models settings.",
254
263
  "rows.effortPlaceholder": "Not chosen",
255
264
  "rows.effortChoices": "Effort choices",
256
265
  "rows.effortDefault": "Model default",
257
266
  "rows.useDefaultEffort": "Use model default",
258
267
  "rows.incomplete": "Not used",
259
268
  "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
269
  "rows.importOpen": "Import",
263
270
  "rows.export": "Export",
264
271
  "rows.exported": "Copied the task-type list as JSON.",
@@ -299,6 +306,7 @@ var en = {
299
306
  "log.column.duration": "Duration",
300
307
  "log.column.details": "Details",
301
308
  "log.loading": "Loading the log\u2026",
309
+ "log.recovered": "The damaged log was saved as a backup. New entries are recorded in a new log.",
302
310
  "log.empty": "No entries yet.",
303
311
  "log.filterLabel": "Filter by result",
304
312
  "log.filterAll": "All",
@@ -366,10 +374,7 @@ var zh = {
366
374
  "ready.loading": "\u6B63\u5728\u8BFB\u53D6 DSH \u8BBE\u7F6E\u3002",
367
375
  "ready.address": "\u8BF7\u586B\u5199\u6709\u6548\u7684\u670D\u52A1\u5730\u5740\u3002",
368
376
  "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",
377
+ "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
378
  "ready.count": "{total} \u6761\u89C4\u5219\u4E2D\u6709 {used} \u6761\u53EF\u7528",
374
379
  "ready.readOnly": "\u6B64\u9875\u9762\u53EA\u80FD\u67E5\u770B\u914D\u7F6E\u3002",
375
380
  "transfer.judge": "\u5BFC\u5165\uFF0F\u5BFC\u51FA\u8FDE\u63A5\u8BBE\u7F6E",
@@ -435,14 +440,20 @@ var zh = {
435
440
  "judge.probing": "\u6B63\u5728\u8BD5\u2026",
436
441
  "judge.probeOk": "\u8FDE\u4E0A\u4E86\uFF0C\u7528\u4E86 {latency} \u6BEB\u79D2",
437
442
  "judge.probeFail": "\u7528\u4E0D\u4E86\uFF1A{reason}",
443
+ "judge.probeHttpStatus": "\uFF08HTTP {status}\uFF09",
438
444
  "reason.unconfigured": "\u7AEF\u70B9\u5730\u5740\u6216\u5224\u65AD\u6A21\u578B\u8FD8\u6CA1\u586B",
439
445
  "reason.unreachable": "\u8FDE\u4E0D\u4E0A\u8FD9\u4E2A\u5730\u5740",
446
+ "reason.authentication": "\u51ED\u636E\u6216\u6743\u9650\u6709\u95EE\u9898",
447
+ "reason.rate-limited": "\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41",
448
+ "reason.server-error": "\u5224\u65AD\u670D\u52A1\u51FA\u9519",
449
+ "reason.http-error": "\u5224\u65AD\u670D\u52A1\u62D2\u7EDD\u4E86\u8BF7\u6C42",
440
450
  "reason.timeout": "\u5224\u65AD\u6216\u8DEF\u7EBF\u6821\u9A8C\u8D85\u8FC7 5 \u79D2",
441
451
  "reason.unmatched": "\u7B54\u590D\u5BF9\u4E0D\u4E0A\u6E05\u5355",
442
452
  "reason.incomplete": "\u9009\u4E2D\u7684\u7C7B\u578B\u6CA1\u586B\u5168",
443
453
  "reason.unavailable-route": "\u9009\u4E2D\u7684\u6A21\u578B\u6216\u63A8\u7406\u7B49\u7EA7\u5F53\u524D\u4E0D\u53EF\u7528",
444
454
  "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",
455
+ "reason.no-authorized-route": "\u89C4\u5219\u4E2D\u6CA1\u6709\u6A21\u578B\u51FA\u73B0\u5728\u5F53\u524D DSH \u76EE\u5F55\u91CC",
456
+ "reason.catalog-unavailable": "\u672A\u80FD\u8BFB\u53D6 DSH \u6A21\u578B\u76EE\u5F55\u4EE5\u6838\u5BF9\u89C4\u5219",
446
457
  "reason.unidentified-task": "\u627E\u4E0D\u5230\u8FD9\u6B21\u6D3E\u51FA\u7684\u539F\u4EFB\u52A1",
447
458
  "reason.explicit-route": "\u6D3E\u4EFB\u52A1\u65F6\u5DF2\u6307\u5B9A\u6A21\u578B",
448
459
  "reason.recorded-route": "\u5B50\u4EE3\u7406\u5DF2\u9009\u62E9\u6216\u4F7F\u7528\u8FC7\u6A21\u578B",
@@ -470,17 +481,22 @@ var zh = {
470
481
  "rows.hintDuplicateDescription": "\u63CF\u8FF0\u548C\u522B\u7684\u884C\u91CD\u590D",
471
482
  "rows.hintNoModel": "\u672A\u9009\u6A21\u578B",
472
483
  "rows.hintNoEffort": "\u672A\u9009\u63A8\u7406\u5F3A\u5EA6",
473
- "rows.hintModelNotAllowed": "\u6A21\u578B\u4E0D\u5728\u5BBF\u4E3B\u5141\u8BB8\u6E05\u5355\u4E2D",
484
+ "rows.hintModelUnavailable": "DSH \u6A21\u578B\u76EE\u5F55\u4E2D\u6CA1\u6709\u8FD9\u4E2A\u6A21\u578B",
474
485
  "rows.hintEffortUnavailable": "\u8BE5\u6A21\u578B\u4E0D\u652F\u6301\u9009\u4E2D\u7684\u63A8\u7406\u5F3A\u5EA6",
475
486
  "rows.modelPlaceholder": "\u8FD8\u6CA1\u9009",
487
+ "rows.modelSearch": "\u641C\u7D22\u6A21\u578B\u6216\u4F9B\u5E94\u5546",
488
+ "rows.modelSearchClear": "\u6E05\u9664\u641C\u7D22",
489
+ "rows.modelSearchEmpty": "\u6CA1\u6709\u5339\u914D\u7684\u6A21\u578B",
490
+ "rows.catalogLoading": "\u6B63\u5728\u8BFB\u53D6 DSH \u6A21\u578B\u76EE\u5F55\u2026",
491
+ "rows.catalogUnavailable": "\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6 DSH \u6A21\u578B\u76EE\u5F55\u3002",
492
+ "rows.catalogRetry": "\u91CD\u65B0\u8BFB\u53D6\u6A21\u578B",
493
+ "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
494
  "rows.effortPlaceholder": "\u8FD8\u6CA1\u9009",
477
495
  "rows.effortChoices": "\u9009\u62E9\u63A8\u7406\u5F3A\u5EA6",
478
496
  "rows.effortDefault": "\u6A21\u578B\u9ED8\u8BA4",
479
497
  "rows.useDefaultEffort": "\u4F7F\u7528\u6A21\u578B\u9ED8\u8BA4\u5F3A\u5EA6",
480
498
  "rows.incomplete": "\u4E0D\u751F\u6548",
481
499
  "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
500
  "rows.importOpen": "\u5BFC\u5165",
485
501
  "rows.export": "\u5BFC\u51FA",
486
502
  "rows.exported": "\u5DF2\u7ECF\u628A\u4EFB\u52A1\u7C7B\u578B\u6E05\u5355\u6309 JSON \u590D\u5236\u8D70\u4E86\u3002",
@@ -521,6 +537,7 @@ var zh = {
521
537
  "log.column.duration": "\u8017\u65F6",
522
538
  "log.column.details": "\u8BE6\u60C5",
523
539
  "log.loading": "\u6B63\u5728\u8BFB\u53D6\u65E5\u5FD7\u2026",
540
+ "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
541
  "log.empty": "\u8FD8\u6CA1\u6709\u65E5\u5FD7\u3002",
525
542
  "log.filterLabel": "\u6309\u7ED3\u679C\u7B5B\u9009",
526
543
  "log.filterAll": "\u5168\u90E8",
@@ -624,6 +641,7 @@ function detailType(entry, t) {
624
641
  return t("log.detailMissing");
625
642
  }
626
643
  function LogDetails({ entry, t }) {
644
+ const taskText = entry.taskText?.replace(/^Timeline: tree=tree-[a-f0-9]+; tasks=[\w-]+(?:,[ \t]*[\w-]+)*\.(?:\s+|$)/, "");
627
645
  const phases = PHASES.flatMap((phase) => {
628
646
  const ms = entry.phaseTimingsMs?.[phase];
629
647
  return ms === void 0 ? [] : [{ phase, ms }];
@@ -667,11 +685,11 @@ function LogDetails({ entry, t }) {
667
685
  ] }),
668
686
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
669
687
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dt", { children: t("log.detailTask") }),
670
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dd", { className: "dsh-judge-log-saved-text", children: entry.taskText === void 0 ? t("log.detailMissing") : entry.taskText.trim() === "" ? t("log.detailBlankTask") : entry.taskText })
688
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dd", { className: "dsh-judge-log-saved-text", children: taskText === void 0 ? t("log.detailMissing") : taskText.trim() === "" ? t("log.detailBlankTask") : taskText })
671
689
  ] })
672
690
  ] }) });
673
691
  }
674
- function LogPanel({ entries, loaded, failed, loading, onRefresh, t }) {
692
+ function LogPanel({ entries, loaded, failed, loading, recovered, onRefresh, t }) {
675
693
  const [filter, setFilter] = React.useState("all");
676
694
  const [detail, setDetail] = React.useState(null);
677
695
  const [copyResult, setCopyResult] = React.useState(null);
@@ -713,6 +731,7 @@ function LogPanel({ entries, loaded, failed, loading, onRefresh, t }) {
713
731
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: t("log.desc") }),
714
732
  /* @__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
733
  ] }),
734
+ recovered && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-judge-log-warning", role: "status", children: t("log.recovered") }),
716
735
  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
736
  entries.length === 0 && !loaded && !failed && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-judge-log-message", role: "status", children: t("log.loading") }),
718
737
  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 +797,13 @@ var LOG_PANEL_CSS = `
778
797
  .dsh-judge-log-toolbar { justify-content: space-between; gap: 8px 12px; }
779
798
  .dsh-judge-log-actions { gap: 6px; }
780
799
  .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 {
800
+ .dsh-judge-log-caption, .dsh-judge-log-message, .dsh-judge-log-error, .dsh-judge-log-warning {
782
801
  margin: 10px 0 0;
783
802
  color: var(--dsw-alias-label-secondary);
784
803
  font: var(--dsw-font-xs-13);
785
804
  }
786
805
  .dsh-judge-log-error { color: var(--dsw-alias-state-error-primary); }
806
+ .dsh-judge-log-warning { color: var(--dsw-alias-state-warn-primary); }
787
807
  .dsh-judge-log-caption { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
788
808
  .dsh-judge-log-copy-status[data-result='copied'] { color: var(--dsw-alias-state-success-primary); }
789
809
  .dsh-judge-log-copy-status[data-result='failed'] { color: var(--dsw-alias-state-error-primary); }
@@ -881,7 +901,6 @@ var SAMPLE_ROUTE_PATH = `${BASE_PATH}/sample`;
881
901
  var KEY_STATUS_ROUTE_PATH = `${BASE_PATH}/key-status`;
882
902
 
883
903
  // src/client/settings/store.ts
884
- var ALLOWED_MODELS_NAMESPACE = "subagent-model-selection-settings";
885
904
  async function readJson(response) {
886
905
  try {
887
906
  return await response.json();
@@ -896,7 +915,7 @@ function createDispatchRemote() {
896
915
  if (!response.ok) throw new Error("Log request failed");
897
916
  const body = await readJson(response);
898
917
  if (body?.ok !== true || !Array.isArray(body.entries)) throw new Error("Invalid log response");
899
- return body.entries;
918
+ return { entries: body.entries, recovered: body.recovered === true };
900
919
  },
901
920
  async preview(task = "", label = "") {
902
921
  try {
@@ -921,7 +940,8 @@ function createDispatchRemote() {
921
940
  return {
922
941
  ok: body.ok === true,
923
942
  latencyMs: typeof body.latencyMs === "number" ? body.latencyMs : 0,
924
- ...typeof body.reason === "string" ? { reason: body.reason } : {}
943
+ ...typeof body.reason === "string" ? { reason: body.reason } : {},
944
+ ...Number.isInteger(body.httpStatus) && body.httpStatus >= 100 && body.httpStatus <= 599 ? { httpStatus: body.httpStatus } : {}
925
945
  };
926
946
  } catch {
927
947
  return { ok: false, latencyMs: 0, reason: "unreachable" };
@@ -1001,35 +1021,20 @@ function splitRouteKey(key) {
1001
1021
  if (at < 0) return { provider: "", model: "" };
1002
1022
  return { provider: key.slice(0, at), model: key.slice(at + 1) };
1003
1023
  }
1004
- function buildModelOptions(allowed, groups) {
1024
+ function buildModelOptions(groups) {
1005
1025
  const byRoute = /* @__PURE__ */ new Map();
1006
1026
  for (const group of groups) {
1007
1027
  for (const model of group.models) {
1008
1028
  byRoute.set(routeKey(group.id, model.id), {
1009
- label: model.name,
1029
+ provider: group.id,
1030
+ providerName: group.name || group.id,
1031
+ model: model.id,
1032
+ label: model.name || model.id,
1010
1033
  efforts: (model.reasoning?.efforts ?? []).map((effort) => effort.id)
1011
1034
  });
1012
1035
  }
1013
1036
  }
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;
1037
+ return [...byRoute.values()];
1033
1038
  }
1034
1039
  function rowHints(rows, index, t) {
1035
1040
  const row = rows[index];
@@ -1140,8 +1145,7 @@ var DispatchCardStore = class {
1140
1145
  connectionRevision: 0,
1141
1146
  rows: [],
1142
1147
  models: [],
1143
- modelAuthorization: "unknown",
1144
- catalogRead: false,
1148
+ catalogStatus: "loading",
1145
1149
  committed: {
1146
1150
  enabled: DEFAULT_ENABLED,
1147
1151
  logEnabled: true,
@@ -1154,6 +1158,7 @@ var DispatchCardStore = class {
1154
1158
  writeErrors: {},
1155
1159
  key: emptyKey(),
1156
1160
  log: [],
1161
+ logRecovered: false,
1157
1162
  logLoaded: false,
1158
1163
  logFailed: false,
1159
1164
  logLoading: false
@@ -1162,7 +1167,6 @@ var DispatchCardStore = class {
1162
1167
  queue = Promise.resolve();
1163
1168
  pendingOps = [];
1164
1169
  form = null;
1165
- allowedForm = null;
1166
1170
  modelLoadRevision = 0;
1167
1171
  logLoadRevision = 0;
1168
1172
  session = null;
@@ -1171,20 +1175,20 @@ var DispatchCardStore = class {
1171
1175
  keyEndpoint = "";
1172
1176
  keyStatusRevision = 0;
1173
1177
  offForm = null;
1174
- offAllowed = null;
1175
1178
  translate = (key) => key;
1176
1179
  attach(options) {
1177
1180
  this.offForm?.();
1178
- this.offAllowed?.();
1179
1181
  this.form = options.form;
1180
- this.allowedForm = options.allowedForm;
1181
1182
  this.session = options.session;
1183
+ this.modelLoadRevision++;
1182
1184
  this.remote = options.remote;
1183
1185
  this.logLoadRevision++;
1184
1186
  this.credentials = options.credentials;
1185
1187
  this.translate = options.t;
1186
1188
  this.state = {
1187
1189
  ...this.state,
1190
+ models: [],
1191
+ catalogStatus: "loading",
1188
1192
  logLoading: false,
1189
1193
  key: { ...this.state.key, unavailable: options.credentials === null }
1190
1194
  };
@@ -1192,10 +1196,6 @@ var DispatchCardStore = class {
1192
1196
  this.offForm = this.form.subscribe(() => this.deriveCommitted());
1193
1197
  this.deriveCommitted();
1194
1198
  }
1195
- if (this.allowedForm !== null) {
1196
- this.offAllowed = this.allowedForm.subscribe(() => void this.loadModels());
1197
- }
1198
- void this.loadModels();
1199
1199
  void this.refreshKeyStatus();
1200
1200
  }
1201
1201
  getState() {
@@ -1209,28 +1209,15 @@ var DispatchCardStore = class {
1209
1209
  }
1210
1210
  async loadModels() {
1211
1211
  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
- }
1212
+ this.stage({ catalogStatus: "loading", models: [] });
1213
+ let groups;
1214
+ try {
1215
+ const response = await this.session?.modelCatalog();
1216
+ if (response?.ok) groups = response.value.groups;
1217
+ } catch {
1230
1218
  }
1231
1219
  if (revision !== this.modelLoadRevision) return;
1232
- this.state = { ...this.state, models: buildModelOptions(allowed, groups), catalogRead };
1233
- this.notify();
1220
+ this.stage(groups === void 0 ? { catalogStatus: "unavailable" } : { catalogStatus: "ready", models: buildModelOptions(groups) });
1234
1221
  }
1235
1222
  async refreshKeyStatus() {
1236
1223
  const revision = ++this.keyStatusRevision;
@@ -1306,27 +1293,25 @@ var DispatchCardStore = class {
1306
1293
  this.keyEndpoint = this.state.endpointUrl;
1307
1294
  this.stage({ key: { ...this.state.key, text, failed: false, error: "" } });
1308
1295
  }
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 });
1296
+ describeRow(index, description) {
1297
+ const rows = this.state.rows.map((row, at) => at === index ? { ...row, description } : row);
1298
+ this.stage({ rows });
1299
+ }
1300
+ chooseModel(index, provider, model) {
1301
+ const option = this.state.models.find((candidate) => candidate.provider === provider && candidate.model === model);
1302
+ if (option === void 0) return;
1303
+ const rows = this.state.rows.map((row, at) => at === index ? {
1304
+ ...row,
1305
+ provider,
1306
+ model,
1307
+ effort: option.efforts.includes(row.effort) ? row.effort : ""
1308
+ } : row);
1309
+ this.stage({ rows });
1316
1310
  }
1317
1311
  chooseEffort(index, effort) {
1318
1312
  const rows = this.state.rows.map((row, at) => at === index ? readRow({ ...row, effort: effort ?? "", useDefaultEffort: effort === void 0 }) : row);
1319
1313
  this.stage({ rows });
1320
1314
  }
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
1315
  addRow() {
1331
1316
  this.stage({ rows: [...this.state.rows, { description: "", provider: "", model: "", effort: "", enabled: true }] });
1332
1317
  void this.commit("rows");
@@ -1481,9 +1466,9 @@ var DispatchCardStore = class {
1481
1466
  this.state = { ...this.state, logLoading: true };
1482
1467
  this.notify();
1483
1468
  try {
1484
- const entries = await remote.log();
1469
+ const { entries, recovered } = await remote.log();
1485
1470
  if (revision !== this.logLoadRevision) return;
1486
- this.state = { ...this.state, log: entries, logLoaded: true, logFailed: false, logLoading: false };
1471
+ this.state = { ...this.state, log: entries, logRecovered: recovered, logLoaded: true, logFailed: false, logLoading: false };
1487
1472
  } catch {
1488
1473
  if (revision !== this.logLoadRevision) return;
1489
1474
  this.state = { ...this.state, logLoaded: true, logFailed: true, logLoading: false };
@@ -1512,12 +1497,6 @@ var DispatchCardStore = class {
1512
1497
  return { ok: false, reason: "unreachable" };
1513
1498
  }
1514
1499
  }
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
1500
  rowUsable(row) {
1522
1501
  return isOfferedRow(row);
1523
1502
  }
@@ -1598,6 +1577,33 @@ var RULES_LIST_CSS = `
1598
1577
  .dsh-judge-rule-effort-input > span { flex: 1; min-width: 0; }
1599
1578
  @media (pointer: coarse) { .dsh-judge-rule-editor { font: var(--dsw-font-m-16); } }
1600
1579
  `;
1580
+ var CLEAR_MODEL_SEARCH = "clear-model-search";
1581
+ function providerLabel(option, models) {
1582
+ const duplicate = models.some((item) => item.provider !== option.provider && item.providerName === option.providerName);
1583
+ return duplicate ? `${option.providerName} (${option.provider})` : option.providerName;
1584
+ }
1585
+ function modelLabel(option, models) {
1586
+ const duplicate = models.some((item) => item.provider === option.provider && item.model !== option.model && item.label === option.label);
1587
+ return duplicate ? `${option.label} (${option.model})` : option.label;
1588
+ }
1589
+ function modelMenuItems(models, query) {
1590
+ const words = query.trim().toLowerCase().split(/\s+/);
1591
+ const groups = /* @__PURE__ */ new Map();
1592
+ for (const option of models) {
1593
+ const searchable = [option.label, option.model, option.providerName, option.provider].join(" ").toLowerCase();
1594
+ if (!words.every((word) => searchable.includes(word))) continue;
1595
+ const group = groups.get(option.provider) ?? [];
1596
+ group.push(option);
1597
+ groups.set(option.provider, group);
1598
+ }
1599
+ return Array.from(groups, ([provider, options]) => [
1600
+ { type: "label", id: `provider:${provider}`, text: providerLabel(options[0], models) },
1601
+ ...options.map((option) => ({
1602
+ id: routeKey(provider, option.model),
1603
+ label: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { title: `${option.provider}/${option.model}`, children: modelLabel(option, models) })
1604
+ }))
1605
+ ]).flat();
1606
+ }
1601
1607
  function readRuleModel(state, row) {
1602
1608
  const provider = row.provider.trim();
1603
1609
  const model = row.model.trim();
@@ -1605,10 +1611,10 @@ function readRuleModel(state, row) {
1605
1611
  const modelChosen = provider !== "" && model !== "";
1606
1612
  const effortChosen = row.useDefaultEffort === true || effort !== "";
1607
1613
  const option = state.models.find((item) => item.provider === provider && item.model === model);
1608
- const efforts = option?.catalogued === true ? option.efforts : void 0;
1614
+ const efforts = option?.efforts;
1609
1615
  let problem;
1610
- if (modelChosen && state.modelAuthorization === "enabled" && option === void 0) {
1611
- problem = "model-not-allowed";
1616
+ if (modelChosen && state.catalogStatus === "ready" && option === void 0) {
1617
+ problem = "model-unavailable";
1612
1618
  } else if (row.useDefaultEffort !== true && effort !== "" && efforts !== void 0 && !efforts.includes(effort)) {
1613
1619
  problem = "effort-not-supported";
1614
1620
  }
@@ -1623,16 +1629,17 @@ function commitRows() {
1623
1629
  function RuleRow({ draft, index, number, state, t, onMove }) {
1624
1630
  const [editingDescription, setEditingDescription] = (0, import_react2.useState)(false);
1625
1631
  const [openMenu, setOpenMenu] = (0, import_react2.useState)(null);
1632
+ const [modelQuery, setModelQuery] = (0, import_react2.useState)("");
1626
1633
  const editorId = (0, import_react2.useId)();
1627
1634
  const editor = (0, import_react2.useRef)(null);
1628
1635
  const description = draft.description.trim();
1629
1636
  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 ");
1637
+ 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
1638
  const effortText = draft.useDefaultEffort === true ? t("rows.effortDefault") : draft.effort;
1632
1639
  const hints = rowHints(state.rows, index, (key) => key === "rows.hintDuplicateDescription" ? t(key) : "").filter(Boolean);
1633
1640
  if (!modelChosen) hints.push(t("rows.hintNoModel"));
1634
1641
  if (!effortChosen) hints.push(t("rows.hintNoEffort"));
1635
- if (problem === "model-not-allowed") hints.push(t("rows.hintModelNotAllowed"));
1642
+ if (problem === "model-unavailable") hints.push(t("rows.hintModelUnavailable"));
1636
1643
  if (problem === "effort-not-supported") hints.push(t("rows.hintEffortUnavailable"));
1637
1644
  (0, import_react2.useLayoutEffect)(() => {
1638
1645
  if (editingDescription) editor.current?.focus();
@@ -1724,7 +1731,7 @@ function RuleRow({ draft, index, number, state, t, onMove }) {
1724
1731
  value: draft.description,
1725
1732
  placeholder: t("rows.descriptionPlaceholder"),
1726
1733
  "aria-label": `${t("rows.colDescription")} ${position}`,
1727
- onChange: (event) => dispatchCardStore.cell(index, "description", event.target.value),
1734
+ onChange: (event) => dispatchCardStore.describeRow(index, event.target.value),
1728
1735
  onBlur: commitRows
1729
1736
  }
1730
1737
  ),
@@ -1748,24 +1755,39 @@ function RuleRow({ draft, index, number, state, t, onMove }) {
1748
1755
  "aria-label": `${t("rows.colModel")} ${position} \xB7 ${modelText}`,
1749
1756
  "aria-haspopup": "menu",
1750
1757
  "aria-expanded": modelMenuOpen,
1751
- onClick: () => setOpenMenu(modelMenuOpen ? null : "model"),
1758
+ onClick: () => {
1759
+ setModelQuery("");
1760
+ setOpenMenu(modelMenuOpen ? null : "model");
1761
+ },
1752
1762
  children: [
1753
1763
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-judge-rule-choice-value", children: modelText }),
1754
1764
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "aria-hidden": "true", children: "\u25BE" })
1755
1765
  ]
1756
1766
  }
1757
1767
  ),
1758
- items: state.models.map(({ provider: provider2, model: model2 }) => ({ id: routeKey(provider2, model2), label: `${provider2}/${model2}` })),
1768
+ items: modelMenuOpen ? modelMenuItems(state.models, modelQuery) : [],
1769
+ footer: modelQuery === "" ? void 0 : [{ id: CLEAR_MODEL_SEARCH, label: t("rows.modelSearchClear") }],
1759
1770
  selectedId: modelChosen ? routeKey(provider, model) : void 0,
1760
1771
  onSelect: (id) => {
1772
+ if (id === CLEAR_MODEL_SEARCH) {
1773
+ setModelQuery("");
1774
+ return;
1775
+ }
1761
1776
  const picked = splitRouteKey(id);
1762
- dispatchCardStore.cell(index, "provider", picked.provider);
1763
- dispatchCardStore.cell(index, "model", picked.model);
1777
+ dispatchCardStore.chooseModel(index, picked.provider, picked.model);
1764
1778
  closeMenu();
1765
1779
  commitRows();
1766
1780
  },
1767
1781
  onClose: closeMenu,
1768
- autoFocus: true,
1782
+ search: {
1783
+ label: t("rows.modelSearch"),
1784
+ emptyMessage: t("rows.modelSearchEmpty"),
1785
+ value: modelQuery,
1786
+ onChange: setModelQuery,
1787
+ skipAutoFocusOnTouch: true
1788
+ },
1789
+ maxVisibleRows: 8,
1790
+ minWidthFromAnchor: true,
1769
1791
  portal: true
1770
1792
  }
1771
1793
  )
@@ -2032,6 +2054,9 @@ function JudgeDispatchPanel(props) {
2032
2054
  (0, import_react3.useEffect)(() => () => {
2033
2055
  void dispatchCardStore.flush();
2034
2056
  }, []);
2057
+ (0, import_react3.useEffect)(() => {
2058
+ void dispatchCardStore.loadModels();
2059
+ }, []);
2035
2060
  (0, import_react3.useEffect)(() => {
2036
2061
  if (tab === "log") void dispatchCardStore.refreshLog();
2037
2062
  }, [tab]);
@@ -2040,16 +2065,15 @@ function JudgeDispatchPanel(props) {
2040
2065
  const savedOrigin = judgeOrigin(state.committed.endpointUrl);
2041
2066
  const keyConfigured = origin === savedOrigin && state.key.configured;
2042
2067
  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;
2068
+ const usableCount = state.catalogStatus === "ready" ? state.committed.rows.filter((row) => dispatchCardStore.rowUsable(row) && ruleModelProblem(state, row) === void 0).length : 0;
2044
2069
  const issues = [];
2045
2070
  if (!state.available) issues.push(t("ready.loading"));
2046
2071
  else {
2047
2072
  if (!savedOrigin) issues.push(t("ready.address"));
2048
2073
  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"));
2074
+ if (state.catalogStatus === "ready" && usableCount === 0) issues.push(t("ready.rules"));
2051
2075
  }
2052
- const setupReady = issues.length === 0;
2076
+ const setupReady = issues.length === 0 && state.catalogStatus === "ready";
2053
2077
  const count = t("ready.count").replace("{used}", String(usableCount)).replace("{total}", String(state.committed.rows.length));
2054
2078
  const probeStale = probe !== null && (connectionDirty(state) || probe.revision !== state.connectionRevision);
2055
2079
  const result = sampleResult?.input === sample && sampleResult.revision === state.connectionRevision && sameRows(sampleResult.rows, state.committed.rows) ? sampleResult.result : void 0;
@@ -2154,7 +2178,7 @@ function JudgeDispatchPanel(props) {
2154
2178
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "dsh-judge-section", "aria-label": t("ready.label"), children: [
2155
2179
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsh-judge-status", "data-ready": setupReady && state.committed.enabled, children: [
2156
2180
  /* @__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 })
2181
+ state.available && state.catalogStatus === "ready" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-judge-desc", children: count })
2158
2182
  ] }),
2159
2183
  issues.map((issue) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsh-judge-desc", children: issue }, issue)),
2160
2184
  state.available && !state.writable && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsh-judge-desc", children: t("ready.readOnly") })
@@ -2247,6 +2271,7 @@ function JudgeDispatchPanel(props) {
2247
2271
  ),
2248
2272
  !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
2273
  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)),
2274
+ probe && !probeStale && !probe.result.ok && probe.result.httpStatus !== void 0 && t("judge.probeHttpStatus").replace("{status}", String(probe.result.httpStatus)),
2250
2275
  probe && !probeStale && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
2251
2276
  " \xB7 ",
2252
2277
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("time", { dateTime: new Date(probe.at).toISOString(), children: new Date(probe.at).toLocaleTimeString() })
@@ -2264,6 +2289,18 @@ function JudgeDispatchPanel(props) {
2264
2289
  transfer("rows")
2265
2290
  ] })
2266
2291
  ] }),
2292
+ state.catalogStatus !== "ready" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsh-judge-feedback", children: [
2293
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-judge-desc", role: "status", children: t(state.catalogStatus === "loading" ? "rows.catalogLoading" : "rows.catalogUnavailable") }),
2294
+ state.catalogStatus === "unavailable" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2295
+ import_dsh_client_ui_primitives4.Button,
2296
+ {
2297
+ size: "sm",
2298
+ variant: "outline",
2299
+ onClick: () => void dispatchCardStore.loadModels(),
2300
+ children: t("rows.catalogRetry")
2301
+ }
2302
+ )
2303
+ ] }) : state.models.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsh-judge-desc", children: t("rows.catalogEmpty") }),
2267
2304
  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
2305
  copied("rows"),
2269
2306
  saveFeedback(state, "rows", t)
@@ -2349,6 +2386,7 @@ function JudgeDispatchPanel(props) {
2349
2386
  LogPanel,
2350
2387
  {
2351
2388
  entries: state.log,
2389
+ recovered: state.logRecovered,
2352
2390
  loading: state.logLoading,
2353
2391
  loaded: state.logLoaded,
2354
2392
  failed: state.logFailed,
@@ -2462,7 +2500,6 @@ function setupSettingsUi(ctx) {
2462
2500
  try {
2463
2501
  dispatchCardStore.attach({
2464
2502
  form: ctx.configForms.get(SETTINGS_NAMESPACE),
2465
- allowedForm: ctx.configForms.get(ALLOWED_MODELS_NAMESPACE),
2466
2503
  session: ctx.remote?.session ?? null,
2467
2504
  remote: createDispatchRemote(),
2468
2505
  credentials: ctx.remote?.credentials ?? null,