@lynn123411/dsh-subagent-judge-dispatch 0.5.0 → 0.6.0

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
@@ -56,6 +56,29 @@ function setupPluginPage(slots, register) {
56
56
  return slots.inject(BUNDLE_CONFIG_SLOT, register);
57
57
  }
58
58
 
59
+ // src/client/settings/official-settings.ts
60
+ var SUBAGENT_ITEM_ID = "subagent";
61
+ var OPEN_BUDGET_MS = 1500;
62
+ var OPEN_POLL_MS = 50;
63
+ function createOfficialSettingsOpener(navigation) {
64
+ if (navigation === void 0 || typeof navigation.openList !== "function") return null;
65
+ return () => {
66
+ navigation.openList();
67
+ const deadline = Date.now() + OPEN_BUDGET_MS;
68
+ const press = () => {
69
+ const card = document.querySelector(
70
+ `[data-plugin-item="${SUBAGENT_ITEM_ID}"] button`
71
+ );
72
+ if (card !== null) {
73
+ card.click();
74
+ return;
75
+ }
76
+ if (Date.now() < deadline) setTimeout(press, OPEN_POLL_MS);
77
+ };
78
+ setTimeout(press, 0);
79
+ };
80
+ }
81
+
59
82
  // src/server/judge-prompt.ts
60
83
  function isSelectableRow(row) {
61
84
  return row.provider.trim() !== "" && row.model.trim() !== "" && row.effort.trim() !== "";
@@ -65,8 +88,6 @@ function isSelectableRow(row) {
65
88
  var JUDGE_API_KEY_REF = "SUBAGENT_JUDGE_API_KEY";
66
89
 
67
90
  // src/client/settings/store.ts
68
- var DEFAULT_ENDPOINT_URL = "http://127.0.0.1:3425/v1/systemone";
69
- var DEFAULT_JUDGE_MODEL = "future-jev/jev-latest";
70
91
  var SETTINGS_NAMESPACE = "dsh-subagent-judge-dispatch";
71
92
  var ALLOWED_MODELS_NAMESPACE = "subagent-model-selection-settings";
72
93
  var LOG_ROUTE_PATH = "/api/dsh-subagent-judge-dispatch/log";
@@ -232,11 +253,42 @@ function parseRowsJson(text) {
232
253
  if (rows.length === 0) return { ok: false, error: "empty" };
233
254
  return { ok: true, rows };
234
255
  }
256
+ function exportJudgeJson(state) {
257
+ return JSON.stringify(
258
+ {
259
+ endpointUrl: state.endpointUrl,
260
+ judgeModel: state.judgeModel
261
+ },
262
+ null,
263
+ 2
264
+ );
265
+ }
266
+ function parseJudgeJson(text) {
267
+ let parsed;
268
+ try {
269
+ parsed = JSON.parse(text);
270
+ } catch {
271
+ return { ok: false, error: "json" };
272
+ }
273
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
274
+ return { ok: false, error: "shape" };
275
+ }
276
+ const record = parsed;
277
+ const wrongType = ["endpointUrl", "judgeModel"].some((key) => record[key] !== void 0 && typeof record[key] !== "string");
278
+ if (wrongType) return { ok: false, error: "shape" };
279
+ const value = {
280
+ endpointUrl: typeof record.endpointUrl === "string" ? record.endpointUrl : "",
281
+ judgeModel: typeof record.judgeModel === "string" ? record.judgeModel : ""
282
+ };
283
+ if (value.endpointUrl.trim() === "" && value.judgeModel.trim() === "") {
284
+ return { ok: false, error: "empty" };
285
+ }
286
+ return { ok: true, value };
287
+ }
235
288
  function emptyKey() {
236
289
  return {
237
290
  text: "",
238
291
  configured: false,
239
- writable: false,
240
292
  unavailable: false,
241
293
  writing: false,
242
294
  failed: false,
@@ -249,16 +301,16 @@ var DispatchCardStore = class {
249
301
  writable: false,
250
302
  enabled: true,
251
303
  logEnabled: true,
252
- endpointUrl: DEFAULT_ENDPOINT_URL,
253
- judgeModel: DEFAULT_JUDGE_MODEL,
304
+ endpointUrl: "",
305
+ judgeModel: "",
254
306
  rows: [],
255
307
  models: [],
256
308
  catalogRead: false,
257
309
  committed: {
258
310
  enabled: true,
259
311
  logEnabled: true,
260
- endpointUrl: DEFAULT_ENDPOINT_URL,
261
- judgeModel: DEFAULT_JUDGE_MODEL,
312
+ endpointUrl: "",
313
+ judgeModel: "",
262
314
  rows: []
263
315
  },
264
316
  writing: "",
@@ -279,6 +331,7 @@ var DispatchCardStore = class {
279
331
  credentials = null;
280
332
  offForm = null;
281
333
  offAllowed = null;
334
+ officialSettingsOpener = null;
282
335
  translate = (key) => key;
283
336
  /** Bind the Host services; re-binding detaches the previous subscriptions. */
284
337
  attach(options) {
@@ -289,6 +342,7 @@ var DispatchCardStore = class {
289
342
  this.session = options.session;
290
343
  this.remote = options.remote;
291
344
  this.credentials = options.credentials;
345
+ this.officialSettingsOpener = options.officialSettingsOpener;
292
346
  this.translate = options.t;
293
347
  this.state = {
294
348
  ...this.state,
@@ -341,11 +395,7 @@ var DispatchCardStore = class {
341
395
  const info = response.value[JUDGE_API_KEY_REF];
342
396
  this.state = {
343
397
  ...this.state,
344
- key: {
345
- ...this.state.key,
346
- configured: info?.configured === true,
347
- writable: info?.writable === true
348
- }
398
+ key: { ...this.state.key, configured: info?.configured === true }
349
399
  };
350
400
  this.notify();
351
401
  } catch {
@@ -368,8 +418,8 @@ var DispatchCardStore = class {
368
418
  const committed = {
369
419
  enabled: typeof value.enabled === "boolean" ? value.enabled : true,
370
420
  logEnabled: typeof value.logEnabled === "boolean" ? value.logEnabled : true,
371
- endpointUrl: typeof value.endpointUrl === "string" ? value.endpointUrl : DEFAULT_ENDPOINT_URL,
372
- judgeModel: typeof value.judgeModel === "string" ? value.judgeModel : DEFAULT_JUDGE_MODEL,
421
+ endpointUrl: typeof value.endpointUrl === "string" ? value.endpointUrl : "",
422
+ judgeModel: typeof value.judgeModel === "string" ? value.judgeModel : "",
373
423
  rows
374
424
  };
375
425
  const staged = (current, previously) => current !== previously;
@@ -449,6 +499,22 @@ var DispatchCardStore = class {
449
499
  this.stage({ rows: rows.map((row) => ({ ...row })) });
450
500
  void this.commit("rows");
451
501
  }
502
+ /**
503
+ * Replace the judgement service's connection settings with an imported set and
504
+ * write them.
505
+ *
506
+ * The import dialog's own button is the confirmation, so the settings it
507
+ * produces are written at once rather than left as a draft.
508
+ *
509
+ * @param draft - the settings read from the pasted JSON.
510
+ */
511
+ replaceJudgeConfig(draft) {
512
+ this.stage({
513
+ endpointUrl: draft.endpointUrl,
514
+ judgeModel: draft.judgeModel
515
+ });
516
+ void this.commit("judge");
517
+ }
452
518
  /** Delete one row and write the rest; the remaining rows renumber themselves. */
453
519
  removeRow(index) {
454
520
  this.stage({ rows: this.state.rows.filter((_row, at) => at !== index) });
@@ -575,51 +641,13 @@ var DispatchCardStore = class {
575
641
  return { ok: false, error: message };
576
642
  }
577
643
  }
578
- /**
579
- * Remove the stored judgement key.
580
- *
581
- * A separate control rather than "save an empty field": the shared
582
- * configuration form's own rule is that a blank draft writes nothing, so an
583
- * emptied input cannot mean removal without contradicting it.
584
- *
585
- * @returns settlement after the credentials read-back.
586
- */
587
- async clearKey() {
588
- const credentials = this.credentials;
589
- if (credentials === null) return;
590
- this.state = { ...this.state, key: { ...this.state.key, writing: true, failed: false, error: "" } };
591
- this.notify();
592
- try {
593
- const response = await credentials.unset(JUDGE_API_KEY_REF);
594
- if (!response.ok) {
595
- this.state = {
596
- ...this.state,
597
- key: {
598
- ...this.state.key,
599
- writing: false,
600
- failed: true,
601
- error: response.error.message || this.translate("key.clearFailed")
602
- }
603
- };
604
- } else {
605
- this.state = {
606
- ...this.state,
607
- key: { ...this.state.key, writing: false, text: "", failed: false, error: "", configured: false }
608
- };
609
- await this.refreshKeyStatus();
610
- }
611
- } catch (error) {
612
- this.state = {
613
- ...this.state,
614
- key: {
615
- ...this.state.key,
616
- writing: false,
617
- failed: true,
618
- error: error instanceof Error && error.message !== "" ? error.message : this.translate("key.clearFailed")
619
- }
620
- };
621
- }
622
- this.notify();
644
+ /** Whether this page can open the official setting the type list depends on. */
645
+ canOpenOfficialSettings() {
646
+ return this.officialSettingsOpener !== null;
647
+ }
648
+ /** Open the official setting the type list depends on. */
649
+ openOfficialSettings() {
650
+ this.officialSettingsOpener?.();
623
651
  }
624
652
  /** Read the runtime log from the Host. */
625
653
  async refreshLog() {
@@ -683,7 +711,7 @@ var en = {
683
711
  "judge.title": "Judgement service",
684
712
  "judge.desc": "The task type is decided by this endpoint. It receives the delegation label, the task text and the type list, and answers with one type number.",
685
713
  "judge.endpoint": "Endpoint address",
686
- "judge.endpointDesc": "The full address, including the protocol path. One System One example is prefilled.",
714
+ "judge.endpointDesc": "The judge model's base URL. /v1/systemone or /systemone is appended automatically.",
687
715
  "judge.model": "Judgement model",
688
716
  "judge.modelDesc": "The model id this endpoint interprets.",
689
717
  "judge.key": "Key",
@@ -692,12 +720,23 @@ var en = {
692
720
  "judge.keyPlaceholderSet": "A key is stored; type a new one to replace it",
693
721
  "judge.keySet": "Key stored",
694
722
  "judge.keyUnset": "No key",
695
- "judge.keyClear": "Remove the key",
696
723
  "judge.keyFailed": "The key was not stored: {error}",
697
724
  "key.unavailable": "The credentials service is unavailable on this page.",
698
725
  "judge.keyUnavailable": "This page has no credentials channel, so a key cannot be stored from here.",
699
726
  "key.writeFailed": "The key was not accepted.",
700
- "key.clearFailed": "The key was not removed.",
727
+ "judge.importOpen": "Import",
728
+ "judge.export": "Export",
729
+ "judge.exported": "Copied the judgement service settings as JSON.",
730
+ "judge.exportFailed": "Could not copy to the clipboard.",
731
+ "judge.importTitle": "Import the judgement service settings",
732
+ "judge.importDesc": "Paste the JSON here. It replaces the address and the model, and is written at once.",
733
+ "judge.importPlaceholder": '{\n "endpointUrl": "...",\n "judgeModel": "..."\n}',
734
+ "judge.importApply": "Replace and write",
735
+ "judge.importCancel": "Cancel",
736
+ "judge.importClose": "Close",
737
+ "judge.importBadJson": "This is not valid JSON.",
738
+ "judge.importBadShape": "This is not a judgement service setting: endpointUrl and judgeModel must be text.",
739
+ "judge.importEmpty": "This setting names neither an address nor a model.",
701
740
  "judge.probe": "Test the connection",
702
741
  "judge.probing": "Testing\u2026",
703
742
  "judge.probeOk": "Connected in {latency} ms",
@@ -710,7 +749,6 @@ var en = {
710
749
  "reason.other": "other",
711
750
  "reason.unknown": "unknown reason",
712
751
  "rows.title": "Task types",
713
- "rows.desc": "One row per task type: the number it answers with, the description it reads, the model it runs on, and the effort. Numbers are assigned for you, always 1, 2, 3\u2026",
714
752
  "rows.empty": "No task type yet. Add one below.",
715
753
  "rows.colId": "No.",
716
754
  "rows.colType": "Task type",
@@ -725,7 +763,9 @@ var en = {
725
763
  "rows.effortPlaceholder": "Not chosen",
726
764
  "rows.incomplete": "Not used",
727
765
  "rows.descriptionPlaceholder": "What kind of job is this? Write as much as you like.",
728
- "rows.allowedEmpty": 'The host setting "models subagents may choose" is empty, so there is nothing to pick. Fill it in on the Subagent settings page first.',
766
+ "rows.dependsOn": 'Depends on the official setting "Allow agents to choose models for Subagents".',
767
+ "rows.dependsOnOpen": "Open",
768
+ "rows.allowedEmpty": "The official setting offers no model yet; fill it in and the options appear here.",
729
769
  "rows.importOpen": "Import",
730
770
  "rows.export": "Export",
731
771
  "rows.exported": "Copied the task-type list as JSON.",
@@ -778,7 +818,7 @@ var zh = {
778
818
  "judge.title": "\u5224\u65AD\u670D\u52A1",
779
819
  "judge.desc": "\u4EFB\u52A1\u7C7B\u578B\u7531\u8FD9\u4E2A\u5730\u5740\u51B3\u5B9A\uFF1A\u5B83\u6536\u5230\u6D3E\u5DE5\u6807\u7B7E\u3001\u4EFB\u52A1\u6B63\u6587\u548C\u7C7B\u578B\u6E05\u5355\uFF0C\u56DE\u7B54\u4E00\u4E2A\u7C7B\u578B\u7F16\u53F7\u3002",
780
820
  "judge.endpoint": "\u7AEF\u70B9\u5730\u5740",
781
- "judge.endpointDesc": "\u5B8C\u6574\u5730\u5740\uFF0C\u8981\u5E26\u534F\u8BAE\u8DEF\u5F84\u3002\u5DF2\u7ECF\u9884\u586B\u4E00\u4E2A System One \u7684\u4F8B\u5B50\u3002",
821
+ "judge.endpointDesc": "\u5224\u65AD\u6A21\u578B\u7684BaseURL\u3002\u4F1A\u81EA\u52A8\u8865/v1/systemone\u6216/systemone",
782
822
  "judge.model": "\u5224\u65AD\u6A21\u578B",
783
823
  "judge.modelDesc": "\u8FD9\u4E2A\u5730\u5740\u6240\u4F7F\u7528\u7684\u6A21\u578B\u540D\u3002",
784
824
  "judge.key": "\u5BC6\u94A5",
@@ -787,12 +827,23 @@ var zh = {
787
827
  "judge.keyPlaceholderSet": "\u5DF2\u7ECF\u5B58\u4E86\u5BC6\u94A5\uFF0C\u8981\u6362\u5C31\u586B\u4E00\u4E2A\u65B0\u7684",
788
828
  "judge.keySet": "\u5DF2\u5B58\u5BC6\u94A5",
789
829
  "judge.keyUnset": "\u8FD8\u6CA1\u6709\u5BC6\u94A5",
790
- "judge.keyClear": "\u5220\u6389\u5BC6\u94A5",
791
830
  "judge.keyFailed": "\u5BC6\u94A5\u6CA1\u5B58\u4E0A\uFF1A{error}",
792
831
  "key.unavailable": "\u8FD9\u4E2A\u9875\u9762\u4E0A\u7528\u4E0D\u4E86\u51ED\u636E\u670D\u52A1\u3002",
793
832
  "judge.keyUnavailable": "\u8FD9\u4E2A\u9875\u9762\u4E0A\u6CA1\u6709\u51ED\u636E\u901A\u9053\uFF0C\u5728\u8FD9\u91CC\u5B58\u4E0D\u4E86\u5BC6\u94A5\u3002",
794
833
  "key.writeFailed": "\u5BC6\u94A5\u6CA1\u88AB\u63A5\u53D7\u3002",
795
- "key.clearFailed": "\u5BC6\u94A5\u6CA1\u5220\u6389\u3002",
834
+ "judge.importOpen": "\u5BFC\u5165",
835
+ "judge.export": "\u5BFC\u51FA",
836
+ "judge.exported": "\u5DF2\u7ECF\u628A\u5224\u65AD\u670D\u52A1\u8BBE\u7F6E\u6309 JSON \u590D\u5236\u8D70\u4E86\u3002",
837
+ "judge.exportFailed": "\u590D\u5236\u5230\u526A\u8D34\u677F\u6CA1\u6210\u529F\u3002",
838
+ "judge.importTitle": "\u5BFC\u5165\u5224\u65AD\u670D\u52A1\u8BBE\u7F6E",
839
+ "judge.importDesc": "\u628A JSON \u7C98\u8D34\u5230\u8FD9\u91CC\u3002\u5B83\u4F1A\u66FF\u6362\u5730\u5740\u4E0E\u5224\u65AD\u6A21\u578B\uFF0C\u5E76\u7ACB\u5373\u5199\u5165\u3002",
840
+ "judge.importPlaceholder": '{\n "endpointUrl": "\u2026\u2026",\n "judgeModel": "\u2026\u2026"\n}',
841
+ "judge.importApply": "\u66FF\u6362\u5E76\u5199\u5165",
842
+ "judge.importCancel": "\u53D6\u6D88",
843
+ "judge.importClose": "\u5173\u95ED",
844
+ "judge.importBadJson": "\u8FD9\u4E0D\u662F\u5408\u6CD5\u7684 JSON\u3002",
845
+ "judge.importBadShape": "\u8FD9\u4E0D\u662F\u4E00\u4EFD\u5224\u65AD\u670D\u52A1\u8BBE\u7F6E\uFF1AendpointUrl \u4E0E judgeModel \u8981\u662F\u6587\u5B57\u3002",
846
+ "judge.importEmpty": "\u8FD9\u4EFD\u8BBE\u7F6E\u91CC\u65E2\u6CA1\u6709\u5730\u5740\u4E5F\u6CA1\u6709\u6A21\u578B\u3002",
796
847
  "judge.probe": "\u8BD5\u4E00\u4E0B\u901A\u4E0D\u901A",
797
848
  "judge.probing": "\u6B63\u5728\u8BD5\u2026",
798
849
  "judge.probeOk": "\u8FDE\u4E0A\u4E86\uFF0C\u7528\u4E86 {latency} \u6BEB\u79D2",
@@ -805,7 +856,6 @@ var zh = {
805
856
  "reason.other": "\u5176\u4ED6",
806
857
  "reason.unknown": "\u539F\u56E0\u4E0D\u660E",
807
858
  "rows.title": "\u4EFB\u52A1\u7C7B\u578B",
808
- "rows.desc": "\u4E00\u884C\u4E00\u4E2A\u4EFB\u52A1\u7C7B\u578B\uFF1A\u5B83\u56DE\u7B54\u7684\u7F16\u53F7\u3001\u5B83\u8BFB\u7684\u63CF\u8FF0\u3001\u8BE5\u7528\u7684\u6A21\u578B\u4E0E\u5F3A\u5EA6\u3002\u7F16\u53F7\u7531\u63D2\u4EF6\u81EA\u52A8\u6392\uFF0C\u6C38\u8FDC\u4ECE 1 \u5F80\u540E\u8FDE\u7740\u3002",
809
859
  "rows.empty": "\u8FD8\u6CA1\u6709\u4EFB\u52A1\u7C7B\u578B\u3002\u5728\u4E0B\u9762\u52A0\u4E00\u884C\u3002",
810
860
  "rows.colId": "\u7F16\u53F7",
811
861
  "rows.colType": "\u4EFB\u52A1\u7C7B\u578B",
@@ -820,7 +870,9 @@ var zh = {
820
870
  "rows.effortPlaceholder": "\u8FD8\u6CA1\u9009",
821
871
  "rows.incomplete": "\u4E0D\u751F\u6548",
822
872
  "rows.descriptionPlaceholder": "\u8FD9\u662F\u54EA\u79CD\u6D3B\uFF1F\u5199\u591A\u5C11\u90FD\u884C\u3002",
823
- "rows.allowedEmpty": "\u5BBF\u4E3B\u90A3\u4EFD\u300C\u5B50\u4EE3\u7406\u53EF\u9009\u7528\u54EA\u4E9B\u6A21\u578B\u300D\u8FD8\u662F\u7A7A\u7684\uFF0C\u6CA1\u6709\u53EF\u4EE5\u9009\u7684\u4E1C\u897F\u3002\u5148\u5230\u5B50\u4EE3\u7406\u8BBE\u7F6E\u9875\u628A\u5B83\u586B\u4E0A\u3002",
873
+ "rows.dependsOn": "\u4F9D\u8D56\u5B98\u65B9\u914D\u7F6E\u300C\u5141\u8BB8 Agent \u4E3A\u5B50\u667A\u80FD\u4F53\u9009\u62E9\u6A21\u578B\u300D\u3002",
874
+ "rows.dependsOnOpen": "\u53BB\u8BBE\u7F6E",
875
+ "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",
824
876
  "rows.importOpen": "\u5BFC\u5165",
825
877
  "rows.export": "\u5BFC\u51FA",
826
878
  "rows.exported": "\u5DF2\u7ECF\u628A\u4EFB\u52A1\u7C7B\u578B\u6E05\u5355\u6309 JSON \u590D\u5236\u8D70\u4E86\u3002",
@@ -870,9 +922,16 @@ function apply(ctx) {
870
922
  // src/client/settings/ui.tsx
871
923
  var import_jsx_runtime = require("react/jsx-runtime");
872
924
  var IMPORT_ERROR_KEYS = {
873
- json: "rows.importBadJson",
874
- shape: "rows.importBadShape",
875
- empty: "rows.importEmpty"
925
+ rows: {
926
+ json: "rows.importBadJson",
927
+ shape: "rows.importBadShape",
928
+ empty: "rows.importEmpty"
929
+ },
930
+ judge: {
931
+ json: "judge.importBadJson",
932
+ shape: "judge.importBadShape",
933
+ empty: "judge.importEmpty"
934
+ }
876
935
  };
877
936
  var CREDENTIALS_PATH = "~/.dsh/.credentials.yaml";
878
937
  function withSamples(text, samples) {
@@ -916,6 +975,12 @@ var CARD_CSS = `
916
975
  .dsh-judge-off { display: block; color: var(--dsw-alias-state-warn-label); font: var(--dsw-font-xxxs-11); }
917
976
  /* \u6807\u9898\u884C\u53F3\u7AEF\u7684\u4E00\u7EC4\u52A8\u4F5C\uFF1A\u8BD5\u901A\u3001\u5BFC\u5165\u3001\u5BFC\u51FA\u3001\u52A0\u4E00\u884C\u90FD\u6392\u5728\u8FD9\u91CC\u3002 */
918
977
  .dsh-judge-actions-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
978
+ /* \u4EFB\u52A1\u7C7B\u578B\u90A3\u4E00\u8282\u9876\u90E8\u7684\u4E00\u884C\uFF1A\u4F9D\u8D56\u54EA\u4EFD\u5B98\u65B9\u914D\u7F6E\uFF0C\u4EE5\u53CA\u53BB\u90A3\u91CC\u7684\u5165\u53E3\u3002 */
979
+ .dsh-judge-dependency { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px; }
980
+ .dsh-judge-dependency .dsh-judge-desc { max-width: none; }
981
+ /* \u5165\u53E3\u6309\u94FE\u63A5\u7684\u6837\u5B50\u8D70\uFF1A\u6CA1\u6709\u6309\u94AE\u7684\u76D2\u5B50\u548C\u5E95\u8272\uFF0C\u53EA\u5728\u60AC\u505C\u65F6\u52A0\u4E0B\u5212\u7EBF\u3002 */
982
+ .dsh-judge-link { height: auto; padding: 0 2px; color: var(--dsw-alias-link); font: var(--dsw-font-xxs-12); }
983
+ .dsh-judge-link:hover { color: var(--dsw-alias-link); background: none; text-decoration: underline; }
919
984
  /* \u5361\u7247\u6700\u4E0B\u9762\u7684\u51FA\u53E3\uFF1A\u53EA\u6709\u9884\u89C8\u8FD9\u4E00\u4EF6\u8DE8\u8282\u7684\u52A8\u4F5C\uFF0C\u9760\u53F3\u4E0E\u4E24\u8282\u7684\u53F3\u8FB9\u7F18\u5BF9\u9F50\u3002 */
920
985
  .dsh-judge-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
921
986
  .dsh-judge-hint { color: var(--dsw-alias-label-tertiary); font: var(--dsw-font-xxs-12); }
@@ -979,7 +1044,8 @@ function JudgeDispatchPanel(props) {
979
1044
  const [probeResult, setProbeResult] = (0, import_react.useState)(null);
980
1045
  const [detail, setDetail] = (0, import_react.useState)(null);
981
1046
  const [openMenu, setOpenMenu] = (0, import_react.useState)(null);
982
- const [importText, setImportText] = (0, import_react.useState)(null);
1047
+ const [importSection, setImportSection] = (0, import_react.useState)(null);
1048
+ const [importText, setImportText] = (0, import_react.useState)("");
983
1049
  const [importError, setImportError] = (0, import_react.useState)("");
984
1050
  const [copyNote, setCopyNote] = (0, import_react.useState)(null);
985
1051
  (0, import_react.useEffect)(() => {
@@ -1007,22 +1073,40 @@ function JudgeDispatchPanel(props) {
1007
1073
  };
1008
1074
  const exportRows = async () => {
1009
1075
  const copied = await (0, import_dsh_client_ui_primitives.writeClipboard)(exportRowsJson(state.rows));
1010
- setCopyNote({ ok: copied, text: t(copied ? "rows.exported" : "rows.exportFailed") });
1076
+ setCopyNote({ ok: copied, text: t(copied ? "rows.exported" : "rows.exportFailed"), section: "rows" });
1077
+ };
1078
+ const exportJudge = async () => {
1079
+ const copied = await (0, import_dsh_client_ui_primitives.writeClipboard)(exportJudgeJson(state));
1080
+ setCopyNote({ ok: copied, text: t(copied ? "judge.exported" : "judge.exportFailed"), section: "judge" });
1011
1081
  };
1012
- const openImport = () => {
1082
+ const openImport = (section) => {
1083
+ setImportSection(section);
1013
1084
  setImportText("");
1014
1085
  setImportError("");
1015
1086
  setCopyNote(null);
1016
1087
  };
1088
+ const closeImport = () => {
1089
+ setImportSection(null);
1090
+ setImportText("");
1091
+ setImportError("");
1092
+ };
1017
1093
  const applyImport = () => {
1018
- const result = parseRowsJson(importText ?? "");
1019
- if (!result.ok) {
1020
- setImportError(t(IMPORT_ERROR_KEYS[result.error]));
1021
- return;
1094
+ if (importSection === "judge") {
1095
+ const result = parseJudgeJson(importText);
1096
+ if (!result.ok) {
1097
+ setImportError(t(IMPORT_ERROR_KEYS.judge[result.error]));
1098
+ return;
1099
+ }
1100
+ dispatchCardStore.replaceJudgeConfig(result.value);
1101
+ } else {
1102
+ const result = parseRowsJson(importText);
1103
+ if (!result.ok) {
1104
+ setImportError(t(IMPORT_ERROR_KEYS.rows[result.error]));
1105
+ return;
1106
+ }
1107
+ dispatchCardStore.replaceRows(result.rows);
1022
1108
  }
1023
- dispatchCardStore.replaceRows(result.rows);
1024
- setImportText(null);
1025
- setImportError("");
1109
+ closeImport();
1026
1110
  };
1027
1111
  const commitJudge = () => void dispatchCardStore.commit("judge");
1028
1112
  const commitRows = () => void dispatchCardStore.commit("rows");
@@ -1148,16 +1232,20 @@ function JudgeDispatchPanel(props) {
1148
1232
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-judge-section", children: [
1149
1233
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-judge-head", children: [
1150
1234
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-judge-title", children: t("judge.title") }),
1151
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1152
- import_dsh_client_ui_primitives.Button,
1153
- {
1154
- variant: "outline",
1155
- size: "sm",
1156
- disabled: probing || state.writing !== "",
1157
- onClick: () => void runProbe(),
1158
- children: probing ? t("judge.probing") : t("judge.probe")
1159
- }
1160
- )
1235
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-judge-actions-group", children: [
1236
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "outline", size: "sm", onClick: () => openImport("judge"), children: t("judge.importOpen") }),
1237
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "outline", size: "sm", onClick: () => void exportJudge(), children: t("judge.export") }),
1238
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1239
+ import_dsh_client_ui_primitives.Button,
1240
+ {
1241
+ variant: "outline",
1242
+ size: "sm",
1243
+ disabled: probing || state.writing !== "",
1244
+ onClick: () => void runProbe(),
1245
+ children: probing ? t("judge.probing") : t("judge.probe")
1246
+ }
1247
+ )
1248
+ ] })
1161
1249
  ] }),
1162
1250
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-judge-desc", children: t("judge.desc") }),
1163
1251
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-judge-row", children: [
@@ -1201,7 +1289,7 @@ function JudgeDispatchPanel(props) {
1201
1289
  type: "text",
1202
1290
  className: "dsh-judge-field",
1203
1291
  value: state.endpointUrl,
1204
- placeholder: "http://127.0.0.1:3425/v1/systemone",
1292
+ placeholder: "http://127.0.0.1:3425",
1205
1293
  "aria-label": t("judge.endpoint"),
1206
1294
  disabled: !state.writable,
1207
1295
  onChange: (event) => dispatchCardStore.field("endpointUrl", event.target.value),
@@ -1255,34 +1343,37 @@ function JudgeDispatchPanel(props) {
1255
1343
  ),
1256
1344
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-judge-key-line", children: [
1257
1345
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: state.key.configured ? "success" : "warning", children: t(state.key.configured ? "judge.keySet" : "judge.keyUnset") }),
1258
- state.key.configured && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1259
- import_dsh_client_ui_primitives.Button,
1260
- {
1261
- variant: "outline",
1262
- size: "sm",
1263
- disabled: state.key.writing || !state.key.writable,
1264
- onClick: () => void dispatchCardStore.clearKey(),
1265
- children: t("judge.keyClear")
1266
- }
1267
- ),
1268
1346
  state.key.unavailable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-judge-hint", children: t("judge.keyUnavailable") }),
1269
1347
  state.key.failed && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-judge-note-bad", role: "alert", children: t("judge.keyFailed").replace("{error}", state.key.error || t("write.invalid")) })
1270
1348
  ] })
1271
1349
  ] })
1272
1350
  ] }),
1273
1351
  probeResult !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: probeResult.ok ? "dsh-judge-note-ok" : "dsh-judge-note-bad", children: probeResult.ok ? t("judge.probeOk").replace("{latency}", String(probeResult.latencyMs)) : t("judge.probeFail").replace("{reason}", reasonText(probeResult.reason)) }),
1352
+ copyNote !== null && copyNote.section === "judge" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: copyNote.ok ? "dsh-judge-note-ok" : "dsh-judge-note-bad", role: "status", children: copyNote.text }),
1274
1353
  failure("judge")
1275
1354
  ] }),
1276
1355
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-judge-section", children: [
1277
1356
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-judge-head", children: [
1278
1357
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-judge-title", children: t("rows.title") }),
1279
1358
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-judge-actions-group", children: [
1280
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "outline", size: "sm", onClick: openImport, children: t("rows.importOpen") }),
1359
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "outline", size: "sm", onClick: () => openImport("rows"), children: t("rows.importOpen") }),
1281
1360
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "outline", size: "sm", onClick: () => void exportRows(), children: t("rows.export") }),
1282
1361
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "outline", size: "sm", onClick: () => dispatchCardStore.addRow(), children: t("rows.add") })
1283
1362
  ] })
1284
1363
  ] }),
1285
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-judge-desc", children: t("rows.desc") }),
1364
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-judge-dependency", children: [
1365
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-judge-desc", children: t("rows.dependsOn") }),
1366
+ dispatchCardStore.canOpenOfficialSettings() && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1367
+ import_dsh_client_ui_primitives.Button,
1368
+ {
1369
+ variant: "ghost",
1370
+ size: "sm",
1371
+ className: "dsh-judge-link",
1372
+ onClick: () => dispatchCardStore.openOfficialSettings(),
1373
+ children: t("rows.dependsOnOpen")
1374
+ }
1375
+ )
1376
+ ] }),
1286
1377
  state.models.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-judge-off", children: t("rows.allowedEmpty") }),
1287
1378
  state.rows.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-judge-desc", children: t("rows.empty") }),
1288
1379
  state.rows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { className: "dsh-judge-table", children: [
@@ -1295,7 +1386,7 @@ function JudgeDispatchPanel(props) {
1295
1386
  ] }) }),
1296
1387
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: state.rows.map((draft, index) => row(draft, index)) })
1297
1388
  ] }),
1298
- copyNote !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: copyNote.ok ? "dsh-judge-note-ok" : "dsh-judge-note-bad", role: "status", children: copyNote.text }),
1389
+ copyNote !== null && copyNote.section === "rows" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: copyNote.ok ? "dsh-judge-note-ok" : "dsh-judge-note-bad", role: "status", children: copyNote.text }),
1299
1390
  failure("rows")
1300
1391
  ] }),
1301
1392
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-judge-footer", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "outline", size: "sm", onClick: () => void openPreview(), children: t("preview.open") }) })
@@ -1376,24 +1467,24 @@ function JudgeDispatchPanel(props) {
1376
1467
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1377
1468
  import_dsh_client_ui_primitives.Modal,
1378
1469
  {
1379
- open: importText !== null,
1380
- onClose: () => setImportText(null),
1381
- title: t("rows.importTitle"),
1382
- closeLabel: t("rows.importClose"),
1383
- description: t("rows.importDesc"),
1470
+ open: importSection !== null,
1471
+ onClose: closeImport,
1472
+ title: t(importSection === "judge" ? "judge.importTitle" : "rows.importTitle"),
1473
+ closeLabel: t(importSection === "judge" ? "judge.importClose" : "rows.importClose"),
1474
+ description: t(importSection === "judge" ? "judge.importDesc" : "rows.importDesc"),
1384
1475
  className: "dsh-judge-modal",
1385
1476
  footer: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1386
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "outline", size: "sm", onClick: () => setImportText(null), children: t("rows.importCancel") }),
1387
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "primary", size: "sm", onClick: applyImport, children: t("rows.importApply") })
1477
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "outline", size: "sm", onClick: closeImport, children: t(importSection === "judge" ? "judge.importCancel" : "rows.importCancel") }),
1478
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "primary", size: "sm", onClick: applyImport, children: t(importSection === "judge" ? "judge.importApply" : "rows.importApply") })
1388
1479
  ] }),
1389
1480
  children: [
1390
1481
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1391
1482
  "textarea",
1392
1483
  {
1393
1484
  className: "dsh-judge-paste",
1394
- value: importText ?? "",
1395
- "aria-label": t("rows.importTitle"),
1396
- placeholder: t("rows.importPlaceholder"),
1485
+ value: importText,
1486
+ "aria-label": t(importSection === "judge" ? "judge.importTitle" : "rows.importTitle"),
1487
+ placeholder: t(importSection === "judge" ? "judge.importPlaceholder" : "rows.importPlaceholder"),
1397
1488
  spellCheck: false,
1398
1489
  "data-modal-autofocus": true,
1399
1490
  onChange: (event) => {
@@ -1440,6 +1531,11 @@ function setupSettingsUi(ctx) {
1440
1531
  remote: createDispatchRemote(),
1441
1532
  // The judgement key is written here; its value never rides a response.
1442
1533
  credentials: ctx.remote?.credentials ?? null,
1534
+ // The type list's options come from the host's own official setting; this
1535
+ // is the one jump to it the page can make.
1536
+ officialSettingsOpener: createOfficialSettingsOpener(
1537
+ ctx.get?.("pluginNavigation")
1538
+ ),
1443
1539
  t
1444
1540
  });
1445
1541
  } catch (error) {