@lynn123411/dsh-subagent-judge-dispatch 0.6.8 → 0.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/docs/DETAIL.md +1 -1
- package/docs/DETAIL.zh.md +1 -1
- package/docs/preview.svg +13 -60
- package/docs/preview.zh.svg +13 -60
- package/lib/client.js +74 -13
- package/lib/client.js.map +2 -2
- package/lib/index.js +67 -9
- package/lib/index.js.map +3 -3
- package/package.json +20 -20
package/lib/client.js
CHANGED
|
@@ -142,6 +142,7 @@ var ALLOWED_MODELS_NAMESPACE = "subagent-model-selection-settings";
|
|
|
142
142
|
var LOG_ROUTE_PATH = "/api/dsh-subagent-judge-dispatch/log";
|
|
143
143
|
var PREVIEW_ROUTE_PATH = "/api/dsh-subagent-judge-dispatch/preview";
|
|
144
144
|
var PROBE_ROUTE_PATH = "/api/dsh-subagent-judge-dispatch/probe";
|
|
145
|
+
var SAMPLE_ROUTE_PATH = "/api/dsh-subagent-judge-dispatch/sample";
|
|
145
146
|
async function readJson(response) {
|
|
146
147
|
try {
|
|
147
148
|
return await response.json();
|
|
@@ -152,14 +153,11 @@ async function readJson(response) {
|
|
|
152
153
|
function createDispatchRemote() {
|
|
153
154
|
return {
|
|
154
155
|
async log() {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
} catch {
|
|
161
|
-
return [];
|
|
162
|
-
}
|
|
156
|
+
const response = await fetch(LOG_ROUTE_PATH);
|
|
157
|
+
if (!response.ok) throw new Error("Log request failed");
|
|
158
|
+
const body = await readJson(response);
|
|
159
|
+
if (body?.ok !== true || !Array.isArray(body.entries)) throw new Error("Invalid log response");
|
|
160
|
+
return body.entries;
|
|
163
161
|
},
|
|
164
162
|
async preview() {
|
|
165
163
|
try {
|
|
@@ -185,6 +183,15 @@ function createDispatchRemote() {
|
|
|
185
183
|
} catch {
|
|
186
184
|
return { ok: false, latencyMs: 0, reason: "unreachable" };
|
|
187
185
|
}
|
|
186
|
+
},
|
|
187
|
+
async sample(task) {
|
|
188
|
+
const response = await fetch(SAMPLE_ROUTE_PATH, {
|
|
189
|
+
method: "POST",
|
|
190
|
+
headers: { "content-type": "application/json" },
|
|
191
|
+
body: JSON.stringify({ task })
|
|
192
|
+
});
|
|
193
|
+
if (!response.ok) throw new Error("Sample request failed");
|
|
194
|
+
return await readJson(response) ?? { ok: false, reason: "unreachable" };
|
|
188
195
|
}
|
|
189
196
|
};
|
|
190
197
|
}
|
|
@@ -192,6 +199,7 @@ function readRow(value) {
|
|
|
192
199
|
const record = typeof value === "object" && value !== null ? value : {};
|
|
193
200
|
const text = (key) => typeof record[key] === "string" ? record[key] : "";
|
|
194
201
|
return {
|
|
202
|
+
...typeof record.stableId === "string" && record.stableId !== "" ? { stableId: record.stableId } : {},
|
|
195
203
|
description: text("description"),
|
|
196
204
|
provider: text("provider"),
|
|
197
205
|
model: text("model"),
|
|
@@ -629,7 +637,9 @@ var DispatchCardStore = class {
|
|
|
629
637
|
ops.push({ op: "set", path: ["logEnabled"], value: this.state.logEnabled });
|
|
630
638
|
}
|
|
631
639
|
} else if (JSON.stringify(this.state.rows) !== JSON.stringify(this.state.committed.rows)) {
|
|
632
|
-
|
|
640
|
+
const rows = this.state.rows.map((row) => readRow({ ...row, stableId: row.stableId || crypto.randomUUID() }));
|
|
641
|
+
this.state = { ...this.state, rows };
|
|
642
|
+
ops.push({ op: "set", path: ["rows"], value: rows });
|
|
633
643
|
}
|
|
634
644
|
const typedKey = section === "judge" ? this.state.key.text.trim() : "";
|
|
635
645
|
if (ops.length === 0 && typedKey === "") {
|
|
@@ -703,7 +713,11 @@ var DispatchCardStore = class {
|
|
|
703
713
|
}
|
|
704
714
|
/** Read the runtime log from the Host. */
|
|
705
715
|
async refreshLog() {
|
|
706
|
-
if (this.remote === null)
|
|
716
|
+
if (this.remote === null) {
|
|
717
|
+
this.state = { ...this.state, logLoaded: true, logFailed: true };
|
|
718
|
+
this.notify();
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
707
721
|
try {
|
|
708
722
|
const entries = await this.remote.log();
|
|
709
723
|
this.state = { ...this.state, log: entries, logLoaded: true, logFailed: false };
|
|
@@ -730,6 +744,13 @@ var DispatchCardStore = class {
|
|
|
730
744
|
return { ok: false, latencyMs: 0, reason: "unreachable" };
|
|
731
745
|
}
|
|
732
746
|
}
|
|
747
|
+
async sample(task) {
|
|
748
|
+
try {
|
|
749
|
+
return await this.remote?.sample?.(task) ?? { ok: false, reason: "unreachable" };
|
|
750
|
+
} catch {
|
|
751
|
+
return { ok: false, reason: "unreachable" };
|
|
752
|
+
}
|
|
753
|
+
}
|
|
733
754
|
/** The effort ids available for one row's currently selected model. */
|
|
734
755
|
effortsFor(row) {
|
|
735
756
|
return this.state.models.find(
|
|
@@ -852,6 +873,7 @@ var en = {
|
|
|
852
873
|
"log.colTime": "Time",
|
|
853
874
|
"log.colLatency": "Took",
|
|
854
875
|
"log.resultJudged": "Type {id}",
|
|
876
|
+
"log.resultHistorical": "Type {id} at the time",
|
|
855
877
|
"log.resultInherited": "No match",
|
|
856
878
|
"log.promptTitle": "Judgement request metrics",
|
|
857
879
|
"log.promptDesc": "Judge model, number of offered choices, and input length.",
|
|
@@ -863,6 +885,14 @@ var en = {
|
|
|
863
885
|
"log.analysisCopyFailed": "Could not copy to the clipboard.",
|
|
864
886
|
"log.refresh": "Refresh",
|
|
865
887
|
"log.loadFailed": "The log could not be read.",
|
|
888
|
+
"log.typeKey": "Type identifier: {key}; number at the time of judgement.",
|
|
889
|
+
"log.legacyType": "Historical number; the original type cannot be identified after edits.",
|
|
890
|
+
"sample.title": "Try a sample task",
|
|
891
|
+
"sample.desc": "Sending will transmit this text and the configured type list to the configured judgement service. Uses saved settings; does not dispatch a subagent or write a log.",
|
|
892
|
+
"sample.send": "Send sample for judgement",
|
|
893
|
+
"sample.running": "Judging\u2026",
|
|
894
|
+
"sample.valid": "Route validation passed.",
|
|
895
|
+
"sample.failed": "Judgement or route validation failed:",
|
|
866
896
|
"ms": "{value} ms"
|
|
867
897
|
};
|
|
868
898
|
var zh = {
|
|
@@ -964,6 +994,7 @@ var zh = {
|
|
|
964
994
|
"log.colTime": "\u65F6\u95F4",
|
|
965
995
|
"log.colLatency": "\u8017\u65F6",
|
|
966
996
|
"log.resultJudged": "\u7C7B\u578B {id}",
|
|
997
|
+
"log.resultHistorical": "\u5F53\u65F6\u7684\u7C7B\u578B {id}",
|
|
967
998
|
"log.resultInherited": "\u672A\u5224\u6210",
|
|
968
999
|
"log.promptTitle": "\u5224\u65AD\u8BF7\u6C42\u7EDF\u8BA1",
|
|
969
1000
|
"log.promptDesc": "\u5224\u65AD\u6A21\u578B\u3001\u53EF\u9009\u7C7B\u578B\u6570\u548C\u8F93\u5165\u957F\u5EA6\u3002",
|
|
@@ -975,6 +1006,14 @@ var zh = {
|
|
|
975
1006
|
"log.analysisCopyFailed": "\u590D\u5236\u5230\u526A\u8D34\u677F\u6CA1\u6210\u529F\u3002",
|
|
976
1007
|
"log.refresh": "\u5237\u65B0",
|
|
977
1008
|
"log.loadFailed": "\u65E5\u5FD7\u8BFB\u4E0D\u51FA\u6765\u3002",
|
|
1009
|
+
"log.typeKey": "\u7C7B\u578B\u6807\u8BC6\uFF1A{key}\uFF1B\u7F16\u53F7\u662F\u5224\u65AD\u65F6\u7684\u7F16\u53F7\u3002",
|
|
1010
|
+
"log.legacyType": "\u8FD9\u662F\u5F53\u65F6\u7684\u7F16\u53F7\uFF1B\u6E05\u5355\u4FEE\u6539\u540E\u65E0\u6CD5\u786E\u5B9A\u539F\u6765\u7684\u7C7B\u578B\u3002",
|
|
1011
|
+
"sample.title": "\u8BD5\u5224\u6837\u4F8B\u4EFB\u52A1",
|
|
1012
|
+
"sample.desc": "\u53D1\u9001\u540E\uFF0C\u8FD9\u6BB5\u6587\u5B57\u548C\u5DF2\u4FDD\u5B58\u7684\u7C7B\u578B\u6E05\u5355\u4F1A\u53D1\u7ED9\u914D\u7F6E\u7684\u5224\u65AD\u670D\u52A1\u3002\u4F7F\u7528\u5DF2\u4FDD\u5B58\u7684\u8BBE\u7F6E\uFF0C\u4E0D\u4F1A\u6D3E\u51FA\u5B50\u4EE3\u7406\u6216\u5199\u5165\u65E5\u5FD7\u3002",
|
|
1013
|
+
"sample.send": "\u53D1\u9001\u6837\u4F8B\u5E76\u8BD5\u5224",
|
|
1014
|
+
"sample.running": "\u6B63\u5728\u5224\u65AD\u2026",
|
|
1015
|
+
"sample.valid": "\u8DEF\u7EBF\u6821\u9A8C\u901A\u8FC7\u3002",
|
|
1016
|
+
"sample.failed": "\u5224\u65AD\u6216\u8DEF\u7EBF\u6821\u9A8C\u5931\u8D25\uFF1A",
|
|
978
1017
|
"ms": "{value} \u6BEB\u79D2"
|
|
979
1018
|
};
|
|
980
1019
|
function apply(ctx) {
|
|
@@ -1135,6 +1174,9 @@ function JudgeDispatchPanel(props) {
|
|
|
1135
1174
|
const [previewOpen, setPreviewOpen] = (0, import_react2.useState)(false);
|
|
1136
1175
|
const [probing, setProbing] = (0, import_react2.useState)(false);
|
|
1137
1176
|
const [probeResult, setProbeResult] = (0, import_react2.useState)(null);
|
|
1177
|
+
const [sampleTask, setSampleTask] = (0, import_react2.useState)("");
|
|
1178
|
+
const [sampling, setSampling] = (0, import_react2.useState)(false);
|
|
1179
|
+
const [sampleResult, setSampleResult] = (0, import_react2.useState)(null);
|
|
1138
1180
|
const [detail, setDetail] = (0, import_react2.useState)(null);
|
|
1139
1181
|
const [openMenu, setOpenMenu] = (0, import_react2.useState)(null);
|
|
1140
1182
|
const [importSection, setImportSection] = (0, import_react2.useState)(null);
|
|
@@ -1249,6 +1291,7 @@ function JudgeDispatchPanel(props) {
|
|
|
1249
1291
|
}
|
|
1250
1292
|
) }),
|
|
1251
1293
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("td", { children: [
|
|
1294
|
+
draft.stableId && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-judge-hint", children: t("log.typeKey").replace("{key}", draft.stableId) }),
|
|
1252
1295
|
rowHints(state.rows, index, t).map((hint) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-judge-off", children: hint }, hint)),
|
|
1253
1296
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1254
1297
|
"textarea",
|
|
@@ -1523,7 +1566,25 @@ function JudgeDispatchPanel(props) {
|
|
|
1523
1566
|
copyNote !== null && copyNote.section === "rows" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: copyNote.ok ? "dsh-judge-note-ok" : "dsh-judge-note-bad", role: "status", children: copyNote.text }),
|
|
1524
1567
|
failure("rows")
|
|
1525
1568
|
] }),
|
|
1526
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-footer", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", onClick: () => void openPreview(), children: t("preview.open") }) })
|
|
1569
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-footer", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", onClick: () => void openPreview(), children: t("preview.open") }) }),
|
|
1570
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-judge-section", children: [
|
|
1571
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-title", children: t("sample.title") }),
|
|
1572
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-desc", children: t("sample.desc") }),
|
|
1573
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("textarea", { "aria-label": t("sample.title"), value: sampleTask, maxLength: 1e4, onChange: (event) => setSampleTask(event.target.value) }),
|
|
1574
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", disabled: sampling || !sampleTask.trim() || state.writing !== "", onClick: () => void (async () => {
|
|
1575
|
+
setSampling(true);
|
|
1576
|
+
await dispatchCardStore.flush();
|
|
1577
|
+
const current = dispatchCardStore.getState();
|
|
1578
|
+
if (current.writeFailed || current.key.failed || current.endpointUrl !== current.committed.endpointUrl || current.judgeModel !== current.committed.judgeModel || JSON.stringify(current.rows) !== JSON.stringify(current.committed.rows)) setSampleResult({ ok: false, reason: "write" });
|
|
1579
|
+
else setSampleResult(await dispatchCardStore.sample(sampleTask));
|
|
1580
|
+
setSampling(false);
|
|
1581
|
+
})(), children: sampling ? t("sample.running") : t("sample.send") }),
|
|
1582
|
+
sampleResult && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { role: "status", children: [
|
|
1583
|
+
sampleResult.typeId != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: t("log.resultJudged").replace("{id}", String(sampleResult.typeId)) }),
|
|
1584
|
+
sampleResult.route && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: [sampleResult.route.provider, sampleResult.route.model, sampleResult.route.reasoningEffort].join(" \xB7 ") }),
|
|
1585
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: sampleResult.ok ? t("sample.valid") : `${t("sample.failed")} ${sampleResult.reason === "write" ? t("write.invalid") : reasonText(sampleResult.reason)}` })
|
|
1586
|
+
] })
|
|
1587
|
+
] })
|
|
1527
1588
|
] });
|
|
1528
1589
|
const log = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-panel", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-judge-section", children: [
|
|
1529
1590
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-judge-head", children: [
|
|
@@ -1536,7 +1597,7 @@ function JudgeDispatchPanel(props) {
|
|
|
1536
1597
|
logCopyResult !== null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: logCopyResult ? "dsh-judge-note-ok" : "dsh-judge-note-bad", role: "status", children: t(logCopyResult ? "log.analysisCopied" : "log.analysisCopyFailed") }),
|
|
1537
1598
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-desc", children: t("log.desc") }),
|
|
1538
1599
|
state.logFailed && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-note-bad", children: t("log.loadFailed") }),
|
|
1539
|
-
state.logLoaded && state.log.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-desc", children: t("log.empty") }),
|
|
1600
|
+
state.logLoaded && !state.logFailed && state.log.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-desc", children: t("log.empty") }),
|
|
1540
1601
|
state.log.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-judge-log", children: [
|
|
1541
1602
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-judge-log-row dsh-judge-log-head", children: [
|
|
1542
1603
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: t("log.colResult") }),
|
|
@@ -1548,7 +1609,7 @@ function JudgeDispatchPanel(props) {
|
|
|
1548
1609
|
const result = entry.typeId === null ? {
|
|
1549
1610
|
text: t("log.resultInherited"),
|
|
1550
1611
|
hint: entry.reason === void 0 ? "" : reasonText(entry.reason)
|
|
1551
|
-
} : { text: t("log.
|
|
1612
|
+
} : { text: t("log.resultHistorical").replace("{id}", String(entry.typeId)), hint: entry.typeKey ? t("log.typeKey").replace("{key}", entry.typeKey) : t("log.legacyType") };
|
|
1552
1613
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1553
1614
|
"button",
|
|
1554
1615
|
{
|