@zoraxylia/dsh-codex-adapter 0.1.15 → 0.1.17
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/.claude-plugin/plugin.json +1 -1
- package/lib/client.js +253 -42
- package/lib/server.mjs +1 -1
- package/package.json +1 -1
- package/src/client/index.tsx +91 -18
- package/src/history.mjs +139 -0
- package/src/hub/index.mjs +35 -1
- package/src/server.mjs +1 -1
package/lib/client.js
CHANGED
|
@@ -515,6 +515,19 @@ const COPY = {
|
|
|
515
515
|
saved: "已保存",
|
|
516
516
|
jobs: "Worker 任务",
|
|
517
517
|
empty: "当前没有 worker 任务。",
|
|
518
|
+
history: "历史看板",
|
|
519
|
+
historyEmpty: "还没有历史记录。",
|
|
520
|
+
historyTotal: "总数",
|
|
521
|
+
historyDone: "成功",
|
|
522
|
+
historyFailed: "失败",
|
|
523
|
+
historyAvg: "平均耗时",
|
|
524
|
+
historyRefresh: "刷新",
|
|
525
|
+
historyTime: "时间",
|
|
526
|
+
historyTier: "档位",
|
|
527
|
+
historyModel: "模型",
|
|
528
|
+
historyStatus: "状态",
|
|
529
|
+
historyCost: "耗时",
|
|
530
|
+
historyTask: "任务",
|
|
518
531
|
statusRunning: "运行中",
|
|
519
532
|
statusStalled: "疑似卡住",
|
|
520
533
|
statusNeedsInput: "需输入",
|
|
@@ -687,6 +700,19 @@ const COPY = {
|
|
|
687
700
|
saved: "Saved",
|
|
688
701
|
jobs: "Worker jobs",
|
|
689
702
|
empty: "No worker jobs yet.",
|
|
703
|
+
history: "History",
|
|
704
|
+
historyEmpty: "No history yet.",
|
|
705
|
+
historyTotal: "Total",
|
|
706
|
+
historyDone: "Done",
|
|
707
|
+
historyFailed: "Failed",
|
|
708
|
+
historyAvg: "Avg duration",
|
|
709
|
+
historyRefresh: "Refresh",
|
|
710
|
+
historyTime: "Time",
|
|
711
|
+
historyTier: "Tier",
|
|
712
|
+
historyModel: "Model",
|
|
713
|
+
historyStatus: "Status",
|
|
714
|
+
historyCost: "Duration",
|
|
715
|
+
historyTask: "Task",
|
|
690
716
|
statusRunning: "running",
|
|
691
717
|
statusStalled: "stalled",
|
|
692
718
|
statusNeedsInput: "needs input",
|
|
@@ -1010,11 +1036,29 @@ function WorkersPanel({ ctx }) {
|
|
|
1010
1036
|
const [notice, setNotice] = (0, react.useState)("");
|
|
1011
1037
|
const [rowNote, setRowNote] = (0, react.useState)({});
|
|
1012
1038
|
const [busy, setBusy] = (0, react.useState)(false);
|
|
1039
|
+
const [historyRows, setHistoryRows] = (0, react.useState)([]);
|
|
1040
|
+
const [historyAgg, setHistoryAgg] = (0, react.useState)(null);
|
|
1013
1041
|
const [provForm, setProvForm] = (0, react.useState)(null);
|
|
1014
1042
|
const [modelAdd, setModelAdd] = (0, react.useState)(null);
|
|
1015
1043
|
const [testResult, setTestResult] = (0, react.useState)(null);
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1044
|
+
const TABS = [
|
|
1045
|
+
"integrations",
|
|
1046
|
+
"config",
|
|
1047
|
+
"history"
|
|
1048
|
+
];
|
|
1049
|
+
const [tab, setTab] = (0, react.useState)(() => {
|
|
1050
|
+
try {
|
|
1051
|
+
const saved = localStorage.getItem("dsh-adapter-tab");
|
|
1052
|
+
return TABS.includes(saved ?? "") ? saved : "config";
|
|
1053
|
+
} catch {
|
|
1054
|
+
return "config";
|
|
1055
|
+
}
|
|
1056
|
+
});
|
|
1057
|
+
(0, react.useEffect)(() => {
|
|
1058
|
+
try {
|
|
1059
|
+
localStorage.setItem("dsh-adapter-tab", tab);
|
|
1060
|
+
} catch {}
|
|
1061
|
+
}, [tab]);
|
|
1018
1062
|
/**
|
|
1019
1063
|
* The panel is served from disk on every load, but the hub's routes are
|
|
1020
1064
|
* registered at instance boot — after an upgrade the new UI can call a route
|
|
@@ -1234,6 +1278,17 @@ function WorkersPanel({ ctx }) {
|
|
|
1234
1278
|
}
|
|
1235
1279
|
}).catch(() => {});
|
|
1236
1280
|
}, [post, copy]);
|
|
1281
|
+
const loadHistory = (0, react.useCallback)(() => {
|
|
1282
|
+
get("/history?limit=100").then((r) => {
|
|
1283
|
+
if (r.ok) {
|
|
1284
|
+
setHistoryRows(r.records ?? []);
|
|
1285
|
+
setHistoryAgg(r.stats ?? null);
|
|
1286
|
+
}
|
|
1287
|
+
}).catch(() => {});
|
|
1288
|
+
}, [get]);
|
|
1289
|
+
(0, react.useEffect)(() => {
|
|
1290
|
+
loadHistory();
|
|
1291
|
+
}, [loadHistory]);
|
|
1237
1292
|
/** Selects & checkboxes: apply immediately. */
|
|
1238
1293
|
const field = (key, value) => {
|
|
1239
1294
|
setConfig((c) => ({
|
|
@@ -1548,38 +1603,6 @@ function WorkersPanel({ ctx }) {
|
|
|
1548
1603
|
]
|
|
1549
1604
|
});
|
|
1550
1605
|
/** Clickable section header that toggles its section's collapsed state. */
|
|
1551
|
-
const sectionHeader = (text, collapsed, toggle) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1552
|
-
role: "button",
|
|
1553
|
-
tabIndex: 0,
|
|
1554
|
-
"aria-expanded": !collapsed,
|
|
1555
|
-
title: collapsed ? copy.expand : copy.collapse,
|
|
1556
|
-
onClick: toggle,
|
|
1557
|
-
onKeyDown: (e) => {
|
|
1558
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
1559
|
-
e.preventDefault();
|
|
1560
|
-
toggle();
|
|
1561
|
-
}
|
|
1562
|
-
},
|
|
1563
|
-
style: {
|
|
1564
|
-
...S.section,
|
|
1565
|
-
display: "flex",
|
|
1566
|
-
alignItems: "center",
|
|
1567
|
-
gap: 6,
|
|
1568
|
-
cursor: "pointer",
|
|
1569
|
-
userSelect: "none"
|
|
1570
|
-
},
|
|
1571
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1572
|
-
"aria-hidden": "true",
|
|
1573
|
-
style: {
|
|
1574
|
-
fontSize: 11,
|
|
1575
|
-
width: 12,
|
|
1576
|
-
flexShrink: 0,
|
|
1577
|
-
textAlign: "center",
|
|
1578
|
-
opacity: .85
|
|
1579
|
-
},
|
|
1580
|
-
children: collapsed ? "▸" : "▾"
|
|
1581
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: text })]
|
|
1582
|
-
});
|
|
1583
1606
|
const rows = jobsLoaded ? displayJobs(jobs, ghosts) : [];
|
|
1584
1607
|
const groups = groupJobs(rows);
|
|
1585
1608
|
const locks = workspaceLocks(rows);
|
|
@@ -1789,8 +1812,35 @@ function WorkersPanel({ ctx }) {
|
|
|
1789
1812
|
style: { opacity: .75 },
|
|
1790
1813
|
children: copy.intro
|
|
1791
1814
|
}),
|
|
1792
|
-
|
|
1793
|
-
|
|
1815
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1816
|
+
style: {
|
|
1817
|
+
display: "flex",
|
|
1818
|
+
gap: 2,
|
|
1819
|
+
borderBottom: "1px solid rgba(128,128,128,0.2)",
|
|
1820
|
+
marginTop: 2
|
|
1821
|
+
},
|
|
1822
|
+
children: [
|
|
1823
|
+
["integrations", copy.integrations],
|
|
1824
|
+
["config", copy.globalConfig],
|
|
1825
|
+
["history", copy.history]
|
|
1826
|
+
].map(([key, label]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1827
|
+
type: "button",
|
|
1828
|
+
onClick: () => setTab(key),
|
|
1829
|
+
style: {
|
|
1830
|
+
padding: "6px 12px",
|
|
1831
|
+
fontSize: 12.5,
|
|
1832
|
+
border: "none",
|
|
1833
|
+
background: "transparent",
|
|
1834
|
+
cursor: "pointer",
|
|
1835
|
+
color: tab === key ? "inherit" : "rgba(128,128,128,0.85)",
|
|
1836
|
+
fontWeight: tab === key ? 600 : 400,
|
|
1837
|
+
borderBottom: tab === key ? "2px solid #4c8dff" : "2px solid transparent",
|
|
1838
|
+
marginBottom: -1
|
|
1839
|
+
},
|
|
1840
|
+
children: label
|
|
1841
|
+
}, key))
|
|
1842
|
+
}),
|
|
1843
|
+
tab === "integrations" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1794
1844
|
style: {
|
|
1795
1845
|
display: "flex",
|
|
1796
1846
|
flexDirection: "column",
|
|
@@ -1833,8 +1883,7 @@ function WorkersPanel({ ctx }) {
|
|
|
1833
1883
|
})
|
|
1834
1884
|
]
|
|
1835
1885
|
}),
|
|
1836
|
-
|
|
1837
|
-
!globalConfigCollapsed && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [config && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1886
|
+
tab === "config" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [config && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1838
1887
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1839
1888
|
style: S.group,
|
|
1840
1889
|
children: copy.groupDispatch
|
|
@@ -2487,11 +2536,173 @@ function WorkersPanel({ ctx }) {
|
|
|
2487
2536
|
},
|
|
2488
2537
|
children: notice
|
|
2489
2538
|
}),
|
|
2490
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
2539
|
+
tab === "history" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2540
|
+
style: {
|
|
2541
|
+
display: "flex",
|
|
2542
|
+
flexDirection: "column",
|
|
2543
|
+
gap: 8
|
|
2544
|
+
},
|
|
2545
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2546
|
+
style: {
|
|
2547
|
+
display: "flex",
|
|
2548
|
+
gap: 14,
|
|
2549
|
+
alignItems: "center",
|
|
2550
|
+
flexWrap: "wrap",
|
|
2551
|
+
fontSize: 12
|
|
2552
|
+
},
|
|
2553
|
+
children: [
|
|
2554
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
2555
|
+
copy.historyTotal,
|
|
2556
|
+
": ",
|
|
2557
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: historyAgg?.total ?? 0 })
|
|
2558
|
+
] }),
|
|
2559
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
2560
|
+
copy.historyDone,
|
|
2561
|
+
": ",
|
|
2562
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: historyAgg?.done ?? 0 })
|
|
2563
|
+
] }),
|
|
2564
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
2565
|
+
copy.historyFailed,
|
|
2566
|
+
": ",
|
|
2567
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: historyAgg?.failed ?? 0 })
|
|
2568
|
+
] }),
|
|
2569
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
2570
|
+
copy.historyAvg,
|
|
2571
|
+
": ",
|
|
2572
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [historyAgg?.avgSeconds ?? 0, "s"] })
|
|
2573
|
+
] }),
|
|
2574
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: { flex: 1 } }),
|
|
2575
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2576
|
+
type: "button",
|
|
2577
|
+
style: {
|
|
2578
|
+
...S.btn,
|
|
2579
|
+
padding: "2px 8px"
|
|
2580
|
+
},
|
|
2581
|
+
onClick: loadHistory,
|
|
2582
|
+
children: copy.historyRefresh
|
|
2583
|
+
})
|
|
2584
|
+
]
|
|
2585
|
+
}), historyRows.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2586
|
+
style: {
|
|
2587
|
+
opacity: .55,
|
|
2588
|
+
fontSize: 12
|
|
2589
|
+
},
|
|
2590
|
+
children: copy.historyEmpty
|
|
2591
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2592
|
+
style: { overflowX: "auto" },
|
|
2593
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
2594
|
+
style: {
|
|
2595
|
+
borderCollapse: "collapse",
|
|
2596
|
+
width: "100%",
|
|
2597
|
+
fontSize: 12
|
|
2598
|
+
},
|
|
2599
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", {
|
|
2600
|
+
style: {
|
|
2601
|
+
textAlign: "left",
|
|
2602
|
+
opacity: .6
|
|
2603
|
+
},
|
|
2604
|
+
children: [
|
|
2605
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
2606
|
+
style: {
|
|
2607
|
+
padding: "4px 6px",
|
|
2608
|
+
fontWeight: 500
|
|
2609
|
+
},
|
|
2610
|
+
children: copy.historyTime
|
|
2611
|
+
}),
|
|
2612
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
2613
|
+
style: {
|
|
2614
|
+
padding: "4px 6px",
|
|
2615
|
+
fontWeight: 500
|
|
2616
|
+
},
|
|
2617
|
+
children: copy.historyTier
|
|
2618
|
+
}),
|
|
2619
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
2620
|
+
style: {
|
|
2621
|
+
padding: "4px 6px",
|
|
2622
|
+
fontWeight: 500
|
|
2623
|
+
},
|
|
2624
|
+
children: copy.historyModel
|
|
2625
|
+
}),
|
|
2626
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
2627
|
+
style: {
|
|
2628
|
+
padding: "4px 6px",
|
|
2629
|
+
fontWeight: 500
|
|
2630
|
+
},
|
|
2631
|
+
children: copy.historyStatus
|
|
2632
|
+
}),
|
|
2633
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
2634
|
+
style: {
|
|
2635
|
+
padding: "4px 6px",
|
|
2636
|
+
fontWeight: 500
|
|
2637
|
+
},
|
|
2638
|
+
children: copy.historyCost
|
|
2639
|
+
}),
|
|
2640
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
2641
|
+
style: {
|
|
2642
|
+
padding: "4px 6px",
|
|
2643
|
+
fontWeight: 500
|
|
2644
|
+
},
|
|
2645
|
+
children: copy.historyTask
|
|
2646
|
+
})
|
|
2647
|
+
]
|
|
2648
|
+
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: historyRows.map((r) => {
|
|
2649
|
+
const start = Date.parse(r.startedAt ?? "");
|
|
2650
|
+
const end = Date.parse(r.endedAt ?? "");
|
|
2651
|
+
const secs = Number.isFinite(start) && Number.isFinite(end) && end >= start ? ((end - start) / 1e3).toFixed(1) + "s" : "—";
|
|
2652
|
+
const color = r.status === "failed" ? "#e5484d" : r.status === "done" ? "#3fb950" : void 0;
|
|
2653
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", {
|
|
2654
|
+
style: { borderTop: "1px solid rgba(128,128,128,0.14)" },
|
|
2655
|
+
children: [
|
|
2656
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2657
|
+
style: {
|
|
2658
|
+
padding: "4px 6px",
|
|
2659
|
+
whiteSpace: "nowrap"
|
|
2660
|
+
},
|
|
2661
|
+
children: r.endedAt ? new Date(r.endedAt).toLocaleString() : "—"
|
|
2662
|
+
}),
|
|
2663
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2664
|
+
style: { padding: "4px 6px" },
|
|
2665
|
+
children: r.tier ?? "—"
|
|
2666
|
+
}),
|
|
2667
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
|
|
2668
|
+
style: { padding: "4px 6px" },
|
|
2669
|
+
children: [r.model ?? "—", r.effort ? ` @${r.effort}` : ""]
|
|
2670
|
+
}),
|
|
2671
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2672
|
+
style: {
|
|
2673
|
+
padding: "4px 6px",
|
|
2674
|
+
color
|
|
2675
|
+
},
|
|
2676
|
+
children: r.status ?? "—"
|
|
2677
|
+
}),
|
|
2678
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2679
|
+
style: {
|
|
2680
|
+
padding: "4px 6px",
|
|
2681
|
+
whiteSpace: "nowrap"
|
|
2682
|
+
},
|
|
2683
|
+
children: secs
|
|
2684
|
+
}),
|
|
2685
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2686
|
+
style: {
|
|
2687
|
+
padding: "4px 6px",
|
|
2688
|
+
maxWidth: 360,
|
|
2689
|
+
overflow: "hidden",
|
|
2690
|
+
textOverflow: "ellipsis",
|
|
2691
|
+
whiteSpace: "nowrap"
|
|
2692
|
+
},
|
|
2693
|
+
title: r.task ?? "",
|
|
2694
|
+
children: r.task ?? "—"
|
|
2695
|
+
})
|
|
2696
|
+
]
|
|
2697
|
+
}, r.id);
|
|
2698
|
+
}) })]
|
|
2699
|
+
})
|
|
2700
|
+
})]
|
|
2701
|
+
}),
|
|
2702
|
+
tab === "history" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2491
2703
|
style: S.section,
|
|
2492
2704
|
children: copy.jobs
|
|
2493
|
-
}),
|
|
2494
|
-
!jobsLoaded || groups.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2705
|
+
}), !jobsLoaded || groups.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2495
2706
|
style: { opacity: .55 },
|
|
2496
2707
|
children: copy.empty
|
|
2497
2708
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -2538,7 +2749,7 @@ function WorkersPanel({ ctx }) {
|
|
|
2538
2749
|
}, workspaceKey(group.cwd))) })
|
|
2539
2750
|
]
|
|
2540
2751
|
})
|
|
2541
|
-
}),
|
|
2752
|
+
})] }),
|
|
2542
2753
|
hoverTask && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2543
2754
|
style: {
|
|
2544
2755
|
position: "fixed",
|
package/lib/server.mjs
CHANGED
|
@@ -15072,7 +15072,7 @@ function describeBindings(config = {}) {
|
|
|
15072
15072
|
}
|
|
15073
15073
|
|
|
15074
15074
|
// src/server.mjs
|
|
15075
|
-
var server = new McpServer({ name: "dsh-adapter", version: "0.1.
|
|
15075
|
+
var server = new McpServer({ name: "dsh-adapter", version: "0.1.17" });
|
|
15076
15076
|
var tierSchema = external_exports.enum(["flash", "pro"]).optional().describe("Worker model tier. flash = mechanical, well-scoped work (single-file edits, lookups, formatting); pro = multi-file changes, debugging, design judgment. Omit to use the session default. Ignored when worker= is set.");
|
|
15077
15077
|
var effortSchema = external_exports.enum(["off", "high", "max"]).optional().describe("Reasoning effort for the worker. Omit to use the session default. With worker= it only applies when passed explicitly and the profile supports it (agy maps to low/medium/high).");
|
|
15078
15078
|
var workerSchema = external_exports.string().optional().describe('Named CLI worker profile (e.g. "agy" or "grok"). Explicit opt-in only: set it when the user explicitly asks for that external coding CLI, never as a default. When set, dispatch bypasses tier/mode and runs the task through that CLI; the profile pins backend\xD7model\xD7effort. See dsh_worker_config output, worker_profiles field, for the available profiles.');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zoraxylia/dsh-codex-adapter",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/hub/index.mjs",
|
|
6
6
|
"description": "Dispatch tasks from Claude Code / Codex to DSH agents as native subagents with live progress; configure dispatch defaults, execution mode, and vision / image-generation access, installed into the host in one click.",
|
package/src/client/index.tsx
CHANGED
|
@@ -137,6 +137,9 @@ const COPY = {
|
|
|
137
137
|
cardCustomProv: { t: '自定义 Provider', d: '接入自己的 API 或本地命令;保存后会出现在上面的视觉 / 生图 provider 选择里。' },
|
|
138
138
|
modeDesc: { auto: 'auto · 优先 hub', hub: 'hub · 必须 hub', standalone: 'standalone · 独立进程' },
|
|
139
139
|
save: '保存', saved: '已保存', jobs: 'Worker 任务', empty: '当前没有 worker 任务。',
|
|
140
|
+
history: '历史看板', historyEmpty: '还没有历史记录。', historyTotal: '总数', historyDone: '成功', historyFailed: '失败',
|
|
141
|
+
historyAvg: '平均耗时', historyRefresh: '刷新', historyTime: '时间', historyTier: '档位', historyModel: '模型',
|
|
142
|
+
historyStatus: '状态', historyCost: '耗时', historyTask: '任务',
|
|
140
143
|
statusRunning: '运行中', statusStalled: '疑似卡住', statusNeedsInput: '需输入', statusDone: '完成', statusFailed: '失败', statusCancelled: '已取消', statusOrphaned: '失联',
|
|
141
144
|
statusTitle: (s: string) => `状态:${s}`,
|
|
142
145
|
orphanWriterGone: (origin: string) => `所属实例已消失:写入该状态的进程(${origin})已不存在,任务随它一起终止(最后状态 running)`,
|
|
@@ -233,6 +236,9 @@ const COPY = {
|
|
|
233
236
|
cardCustomProv: { t: 'Custom providers', d: 'Bring your own API or local command; saved providers appear in the vision / image-gen selects above.' },
|
|
234
237
|
modeDesc: { auto: 'auto · prefer hub', hub: 'hub · require hub', standalone: 'standalone' },
|
|
235
238
|
save: 'Save', saved: 'Saved', jobs: 'Worker jobs', empty: 'No worker jobs yet.',
|
|
239
|
+
history: 'History', historyEmpty: 'No history yet.', historyTotal: 'Total', historyDone: 'Done', historyFailed: 'Failed',
|
|
240
|
+
historyAvg: 'Avg duration', historyRefresh: 'Refresh', historyTime: 'Time', historyTier: 'Tier', historyModel: 'Model',
|
|
241
|
+
historyStatus: 'Status', historyCost: 'Duration', historyTask: 'Task',
|
|
236
242
|
statusRunning: 'running', statusStalled: 'stalled', statusNeedsInput: 'needs input', statusDone: 'done', statusFailed: 'failed', statusCancelled: 'cancelled', statusOrphaned: 'orphaned',
|
|
237
243
|
statusTitle: (s: string) => `status: ${s}`,
|
|
238
244
|
orphanWriterGone: (origin: string) => `Owning instance gone: the process that wrote this status (${origin}) no longer exists — the job died with it (last status: running)`,
|
|
@@ -416,6 +422,8 @@ function WorkersPanel({ ctx }: { ctx: any }) {
|
|
|
416
422
|
// Per-integration feedback, rendered next to the button that was pressed.
|
|
417
423
|
const [rowNote, setRowNote] = useState<Record<string, { kind: 'working' | 'ok' | 'error'; text: string }>>({});
|
|
418
424
|
const [busy, setBusy] = useState(false);
|
|
425
|
+
const [historyRows, setHistoryRows] = useState<any[]>([]);
|
|
426
|
+
const [historyAgg, setHistoryAgg] = useState<any>(null);
|
|
419
427
|
const [provForm, setProvForm] = useState<{
|
|
420
428
|
originalId?: string; name: string; type: 'api' | 'cli'; models: string;
|
|
421
429
|
base_url: string; api_key: string; imagegen_model: string;
|
|
@@ -423,8 +431,15 @@ function WorkersPanel({ ctx }: { ctx: any }) {
|
|
|
423
431
|
} | null>(null);
|
|
424
432
|
const [modelAdd, setModelAdd] = useState<string | null>(null);
|
|
425
433
|
const [testResult, setTestResult] = useState<{ key: string; ok?: boolean; steps?: any[]; error?: string; busy: boolean } | null>(null);
|
|
426
|
-
const [
|
|
427
|
-
|
|
434
|
+
const TABS = ['integrations', 'config', 'history'] as const;
|
|
435
|
+
type TabKey = (typeof TABS)[number];
|
|
436
|
+
const [tab, setTab] = useState<TabKey>(() => {
|
|
437
|
+
try {
|
|
438
|
+
const saved = localStorage.getItem('dsh-adapter-tab');
|
|
439
|
+
return (TABS as readonly string[]).includes(saved ?? '') ? (saved as TabKey) : 'config';
|
|
440
|
+
} catch { return 'config'; }
|
|
441
|
+
});
|
|
442
|
+
useEffect(() => { try { localStorage.setItem('dsh-adapter-tab', tab); } catch { /* private mode */ } }, [tab]);
|
|
428
443
|
// Deliberately no default dispatch-target select here: CLI backends stay
|
|
429
444
|
// opt-in per call via the worker argument (see the read-only workerOptIn
|
|
430
445
|
// card below). Re-adding a default would silently re-route every
|
|
@@ -569,6 +584,13 @@ function WorkersPanel({ ctx }: { ctx: any }) {
|
|
|
569
584
|
if (r.ok) { setConfig(r.config); setNotice(copy.saved); setTimeout(() => setNotice(''), 1500); }
|
|
570
585
|
}).catch(() => {});
|
|
571
586
|
}, [post, copy]);
|
|
587
|
+
const loadHistory = useCallback(() => {
|
|
588
|
+
void get('/history?limit=100').then((r) => {
|
|
589
|
+
if (r.ok) { setHistoryRows(r.records ?? []); setHistoryAgg(r.stats ?? null); }
|
|
590
|
+
}).catch(() => {});
|
|
591
|
+
}, [get]);
|
|
592
|
+
useEffect(() => { loadHistory(); }, [loadHistory]);
|
|
593
|
+
|
|
572
594
|
/** Selects & checkboxes: apply immediately. */
|
|
573
595
|
const field = (key: string, value: any) => {
|
|
574
596
|
setConfig((c: any) => ({ ...c, [key]: value }));
|
|
@@ -723,18 +745,6 @@ function WorkersPanel({ ctx }: { ctx: any }) {
|
|
|
723
745
|
);
|
|
724
746
|
|
|
725
747
|
/** Clickable section header that toggles its section's collapsed state. */
|
|
726
|
-
const sectionHeader = (text: string, collapsed: boolean, toggle: () => void) => (
|
|
727
|
-
<div
|
|
728
|
-
role="button" tabIndex={0} aria-expanded={!collapsed}
|
|
729
|
-
title={collapsed ? copy.expand : copy.collapse}
|
|
730
|
-
onClick={toggle}
|
|
731
|
-
onKeyDown={(e: any) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); toggle(); } }}
|
|
732
|
-
style={{ ...S.section, display: 'flex', alignItems: 'center', gap: 6, cursor: 'pointer', userSelect: 'none' as const }}
|
|
733
|
-
>
|
|
734
|
-
<span aria-hidden="true" style={{ fontSize: 11, width: 12, flexShrink: 0, textAlign: 'center' as const, opacity: 0.85 }}>{collapsed ? '▸' : '▾'}</span>
|
|
735
|
-
<span>{text}</span>
|
|
736
|
-
</div>
|
|
737
|
-
);
|
|
738
748
|
|
|
739
749
|
// --- jobs board (WPC10; workspace groups + lock badges: WPC13) ------------
|
|
740
750
|
const rows = jobsLoaded ? displayJobs(jobs, ghosts) : [];
|
|
@@ -808,8 +818,20 @@ function WorkersPanel({ ctx }: { ctx: any }) {
|
|
|
808
818
|
<div style={{ fontSize: 19, fontWeight: 600, marginBottom: -2 }}>{copy.title}</div>
|
|
809
819
|
<div style={{ opacity: 0.75 }}>{copy.intro}</div>
|
|
810
820
|
|
|
811
|
-
{
|
|
812
|
-
|
|
821
|
+
<div style={{ display: 'flex', gap: 2, borderBottom: '1px solid rgba(128,128,128,0.2)', marginTop: 2 }}>
|
|
822
|
+
{([['integrations', copy.integrations], ['config', copy.globalConfig], ['history', copy.history]] as const).map(([key, label]) => (
|
|
823
|
+
<button key={key} type="button" onClick={() => setTab(key)}
|
|
824
|
+
style={{
|
|
825
|
+
padding: '6px 12px', fontSize: 12.5, border: 'none', background: 'transparent', cursor: 'pointer',
|
|
826
|
+
color: tab === key ? 'inherit' : 'rgba(128,128,128,0.85)',
|
|
827
|
+
fontWeight: tab === key ? 600 : 400,
|
|
828
|
+
borderBottom: tab === key ? '2px solid #4c8dff' : '2px solid transparent',
|
|
829
|
+
marginBottom: -1,
|
|
830
|
+
}}>{label}</button>
|
|
831
|
+
))}
|
|
832
|
+
</div>
|
|
833
|
+
|
|
834
|
+
{tab === 'integrations' && (
|
|
813
835
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
|
814
836
|
{integrationRow('Claude Code', !!status?.claude?.installed,
|
|
815
837
|
status?.claude?.installed ? <span style={S.chip(!!status?.claude?.hud)}>{copy.hud}</span> : null,
|
|
@@ -833,8 +855,7 @@ function WorkersPanel({ ctx }: { ctx: any }) {
|
|
|
833
855
|
</div>
|
|
834
856
|
)}
|
|
835
857
|
|
|
836
|
-
{
|
|
837
|
-
{!globalConfigCollapsed && (<>
|
|
858
|
+
{tab === 'config' && (<>
|
|
838
859
|
{config && (<>
|
|
839
860
|
<div style={S.group}>{copy.groupDispatch}</div>
|
|
840
861
|
{block(copy.cardDispatch, (<>
|
|
@@ -1032,6 +1053,57 @@ function WorkersPanel({ ctx }: { ctx: any }) {
|
|
|
1032
1053
|
|
|
1033
1054
|
{notice !== '' && <div style={{ fontSize: 12, opacity: 0.8, whiteSpace: 'pre-wrap' }}>{notice}</div>}
|
|
1034
1055
|
|
|
1056
|
+
{tab === 'history' && (
|
|
1057
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
|
1058
|
+
<div style={{ display: 'flex', gap: 14, alignItems: 'center', flexWrap: 'wrap', fontSize: 12 }}>
|
|
1059
|
+
<span>{copy.historyTotal}: <b>{historyAgg?.total ?? 0}</b></span>
|
|
1060
|
+
<span>{copy.historyDone}: <b>{historyAgg?.done ?? 0}</b></span>
|
|
1061
|
+
<span>{copy.historyFailed}: <b>{historyAgg?.failed ?? 0}</b></span>
|
|
1062
|
+
<span>{copy.historyAvg}: <b>{historyAgg?.avgSeconds ?? 0}s</b></span>
|
|
1063
|
+
<span style={{ flex: 1 }} />
|
|
1064
|
+
<button type="button" style={{ ...S.btn, padding: '2px 8px' }} onClick={loadHistory}>{copy.historyRefresh}</button>
|
|
1065
|
+
</div>
|
|
1066
|
+
{historyRows.length === 0 ? (
|
|
1067
|
+
<div style={{ opacity: 0.55, fontSize: 12 }}>{copy.historyEmpty}</div>
|
|
1068
|
+
) : (
|
|
1069
|
+
<div style={{ overflowX: 'auto' }}>
|
|
1070
|
+
<table style={{ borderCollapse: 'collapse', width: '100%', fontSize: 12 }}>
|
|
1071
|
+
<thead>
|
|
1072
|
+
<tr style={{ textAlign: 'left', opacity: 0.6 }}>
|
|
1073
|
+
<th style={{ padding: '4px 6px', fontWeight: 500 }}>{copy.historyTime}</th>
|
|
1074
|
+
<th style={{ padding: '4px 6px', fontWeight: 500 }}>{copy.historyTier}</th>
|
|
1075
|
+
<th style={{ padding: '4px 6px', fontWeight: 500 }}>{copy.historyModel}</th>
|
|
1076
|
+
<th style={{ padding: '4px 6px', fontWeight: 500 }}>{copy.historyStatus}</th>
|
|
1077
|
+
<th style={{ padding: '4px 6px', fontWeight: 500 }}>{copy.historyCost}</th>
|
|
1078
|
+
<th style={{ padding: '4px 6px', fontWeight: 500 }}>{copy.historyTask}</th>
|
|
1079
|
+
</tr>
|
|
1080
|
+
</thead>
|
|
1081
|
+
<tbody>
|
|
1082
|
+
{historyRows.map((r) => {
|
|
1083
|
+
const start = Date.parse(r.startedAt ?? '');
|
|
1084
|
+
const end = Date.parse(r.endedAt ?? '');
|
|
1085
|
+
const secs = Number.isFinite(start) && Number.isFinite(end) && end >= start ? ((end - start) / 1000).toFixed(1) + 's' : '—';
|
|
1086
|
+
const color = r.status === 'failed' ? '#e5484d' : r.status === 'done' ? '#3fb950' : undefined;
|
|
1087
|
+
return (
|
|
1088
|
+
<tr key={r.id} style={{ borderTop: '1px solid rgba(128,128,128,0.14)' }}>
|
|
1089
|
+
<td style={{ padding: '4px 6px', whiteSpace: 'nowrap' }}>{r.endedAt ? new Date(r.endedAt).toLocaleString() : '—'}</td>
|
|
1090
|
+
<td style={{ padding: '4px 6px' }}>{r.tier ?? '—'}</td>
|
|
1091
|
+
<td style={{ padding: '4px 6px' }}>{r.model ?? '—'}{r.effort ? ` @${r.effort}` : ''}</td>
|
|
1092
|
+
<td style={{ padding: '4px 6px', color }}>{r.status ?? '—'}</td>
|
|
1093
|
+
<td style={{ padding: '4px 6px', whiteSpace: 'nowrap' }}>{secs}</td>
|
|
1094
|
+
<td style={{ padding: '4px 6px', maxWidth: 360, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}
|
|
1095
|
+
title={r.task ?? ''}>{r.task ?? '—'}</td>
|
|
1096
|
+
</tr>
|
|
1097
|
+
);
|
|
1098
|
+
})}
|
|
1099
|
+
</tbody>
|
|
1100
|
+
</table>
|
|
1101
|
+
</div>
|
|
1102
|
+
)}
|
|
1103
|
+
</div>
|
|
1104
|
+
)}
|
|
1105
|
+
|
|
1106
|
+
{tab === 'history' && (<>
|
|
1035
1107
|
<div style={S.section}>{copy.jobs}</div>
|
|
1036
1108
|
{!jobsLoaded || groups.length === 0 ? (
|
|
1037
1109
|
<div style={{ opacity: 0.55 }}>{copy.empty}</div>
|
|
@@ -1056,6 +1128,7 @@ function WorkersPanel({ ctx }: { ctx: any }) {
|
|
|
1056
1128
|
</table>
|
|
1057
1129
|
</div>
|
|
1058
1130
|
)}
|
|
1131
|
+
</>)}
|
|
1059
1132
|
{hoverTask && createPortal(
|
|
1060
1133
|
<div style={{
|
|
1061
1134
|
position: 'fixed', right: hoverTask.right, zIndex: 9999,
|
package/src/history.mjs
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Persistent worker-task history. The live board only knows the jobs of the
|
|
2
|
+
// current process (plus shards of other running processes); a finished job
|
|
3
|
+
// disappears on restart. Every terminal job is appended here once, so the
|
|
4
|
+
// settings page can show a durable history board with basic aggregates.
|
|
5
|
+
|
|
6
|
+
import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { homedir } from 'node:os';
|
|
9
|
+
|
|
10
|
+
const CONFIG_DIR = join(homedir(), '.config', 'dsh-adapter');
|
|
11
|
+
const FILE = join(CONFIG_DIR, 'history.jsonl');
|
|
12
|
+
const MAX_RECORDS = 2000;
|
|
13
|
+
const MAX_BYTES = 8 * 1024 * 1024;
|
|
14
|
+
|
|
15
|
+
const clip = (value, max) => {
|
|
16
|
+
if (typeof value !== 'string') return value ?? null;
|
|
17
|
+
return value.length > max ? value.slice(0, max) + '…' : value;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** The durable subset of a job, with long text clipped. */
|
|
21
|
+
export function historyRecord(job) {
|
|
22
|
+
return {
|
|
23
|
+
id: job.id,
|
|
24
|
+
sessionId: job.sessionId ?? null,
|
|
25
|
+
tier: job.tier ?? null,
|
|
26
|
+
provider: job.provider ?? null,
|
|
27
|
+
model: job.model ?? null,
|
|
28
|
+
effort: job.effort ?? null,
|
|
29
|
+
status: job.status ?? null,
|
|
30
|
+
source: job.source ?? null,
|
|
31
|
+
cwd: job.cwd ?? null,
|
|
32
|
+
mode: job.mode ?? null,
|
|
33
|
+
task: clip(job.task, 400),
|
|
34
|
+
result: clip(job.result, 1500),
|
|
35
|
+
error: clip(job.error, 400),
|
|
36
|
+
startedAt: job.startedAt ?? null,
|
|
37
|
+
endedAt: job.endedAt ?? null,
|
|
38
|
+
tokens: job.tokens ?? null,
|
|
39
|
+
toolCalls: job.toolCalls ?? null,
|
|
40
|
+
turn: job.turn ?? null,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function lines() {
|
|
45
|
+
if (!existsSync(FILE)) return [];
|
|
46
|
+
try { return readFileSync(FILE, 'utf8').split('\n').filter(Boolean); } catch { return []; }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Ids already persisted, so a restart does not duplicate a job. */
|
|
50
|
+
export function readHistoryIds() {
|
|
51
|
+
const ids = new Set();
|
|
52
|
+
for (const line of lines()) {
|
|
53
|
+
try { const rec = JSON.parse(line); if (rec?.id) ids.add(rec.id); } catch { /* skip */ }
|
|
54
|
+
}
|
|
55
|
+
return ids;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function pruneIfNeeded() {
|
|
59
|
+
try {
|
|
60
|
+
if (statSync(FILE).size <= MAX_BYTES) return;
|
|
61
|
+
} catch { return; }
|
|
62
|
+
const kept = lines().slice(-MAX_RECORDS);
|
|
63
|
+
writeFileSync(FILE, kept.join('\n') + (kept.length ? '\n' : ''));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function appendHistory(job) {
|
|
67
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
68
|
+
appendFileSync(FILE, JSON.stringify(historyRecord(job)) + '\n');
|
|
69
|
+
pruneIfNeeded();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Newest first, filtered and paged. */
|
|
73
|
+
export function readHistory({ limit = 100, offset = 0, tier, status, source } = {}) {
|
|
74
|
+
const records = [];
|
|
75
|
+
for (const line of lines()) {
|
|
76
|
+
let rec;
|
|
77
|
+
try { rec = JSON.parse(line); } catch { continue; }
|
|
78
|
+
if (!rec?.id) continue;
|
|
79
|
+
if (tier && rec.tier !== tier) continue;
|
|
80
|
+
if (status && rec.status !== status) continue;
|
|
81
|
+
if (source && rec.source !== source) continue;
|
|
82
|
+
records.push(rec);
|
|
83
|
+
}
|
|
84
|
+
records.reverse();
|
|
85
|
+
const page = records.slice(Math.max(0, offset), Math.max(0, offset) + Math.max(1, limit));
|
|
86
|
+
return { records: page, total: records.length };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Aggregates over the filtered set (all of it, not just the page). */
|
|
90
|
+
export function historyStats(filter = {}) {
|
|
91
|
+
const { records } = readHistory({ ...filter, limit: 100000, offset: 0 });
|
|
92
|
+
let done = 0;
|
|
93
|
+
let failed = 0;
|
|
94
|
+
let cancelled = 0;
|
|
95
|
+
let durationMs = 0;
|
|
96
|
+
let timed = 0;
|
|
97
|
+
const byTier = {};
|
|
98
|
+
for (const rec of records) {
|
|
99
|
+
if (rec.status === 'done') done += 1;
|
|
100
|
+
else if (rec.status === 'failed') failed += 1;
|
|
101
|
+
else if (rec.status === 'cancelled') cancelled += 1;
|
|
102
|
+
const start = Date.parse(rec.startedAt ?? '');
|
|
103
|
+
const end = Date.parse(rec.endedAt ?? '');
|
|
104
|
+
if (Number.isFinite(start) && Number.isFinite(end) && end >= start) { durationMs += end - start; timed += 1; }
|
|
105
|
+
const tier = rec.tier ?? 'unknown';
|
|
106
|
+
byTier[tier] = (byTier[tier] ?? 0) + 1;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
total: records.length,
|
|
110
|
+
done,
|
|
111
|
+
failed,
|
|
112
|
+
cancelled,
|
|
113
|
+
avgSeconds: timed === 0 ? 0 : Math.round(durationMs / timed / 1000),
|
|
114
|
+
byTier,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function historyPath() { return FILE; }
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* One-time import of jobs still sitting in the status shards, so a fresh
|
|
122
|
+
* history file is not empty just because the board predates this feature.
|
|
123
|
+
*/
|
|
124
|
+
export function backfillHistory() {
|
|
125
|
+
const dir = join(CONFIG_DIR, 'status.d');
|
|
126
|
+
let files = [];
|
|
127
|
+
try { files = readdirSync(dir).filter((f) => f.endsWith('.json')); } catch { return 0; }
|
|
128
|
+
const known = readHistoryIds();
|
|
129
|
+
let imported = 0;
|
|
130
|
+
for (const file of files) {
|
|
131
|
+
let parsed;
|
|
132
|
+
try { parsed = JSON.parse(readFileSync(join(dir, file), 'utf8')); } catch { continue; }
|
|
133
|
+
for (const job of parsed?.jobs ?? []) {
|
|
134
|
+
if (!job?.id || known.has(job.id) || !['done', 'failed', 'cancelled'].includes(job.status)) continue;
|
|
135
|
+
try { appendHistory(job); known.add(job.id); imported += 1; } catch { /* skip */ }
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return imported;
|
|
139
|
+
}
|
package/src/hub/index.mjs
CHANGED
|
@@ -10,6 +10,9 @@ import { isAbsoluteCwd, canonicalCwd } from '../paths.mjs';
|
|
|
10
10
|
import { createShardWriter, readMergedStatus } from '../status-shard.mjs';
|
|
11
11
|
import { procAlive, killWorkerProcess, parsePid, ProcKillRefused } from '../proc-kill.mjs';
|
|
12
12
|
import { installWorkerQuestionHandoff } from '../worker-question.mjs';
|
|
13
|
+
import { appendHistory, backfillHistory, historyStats, readHistory, readHistoryIds } from '../history.mjs';
|
|
14
|
+
|
|
15
|
+
const HISTORY_TERMINAL = new Set(['done', 'failed', 'cancelled']);
|
|
13
16
|
import { probeProvider } from '../provider-probe.mjs';
|
|
14
17
|
|
|
15
18
|
// No @deepseek-ai imports here on purpose: this plugin is loaded into the
|
|
@@ -121,7 +124,14 @@ export class WorkerRegistry {
|
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
publish() {
|
|
124
|
-
|
|
127
|
+
const jobs = [...this.jobs.values()];
|
|
128
|
+
this.shard.publish(jobs.map((j) => this.view(j)));
|
|
129
|
+
// Persist each terminal job exactly once; the live board forgets on restart.
|
|
130
|
+
this.recorded ??= readHistoryIds();
|
|
131
|
+
for (const job of jobs) {
|
|
132
|
+
if (!HISTORY_TERMINAL.has(job.status) || this.recorded.has(job.id)) continue;
|
|
133
|
+
try { appendHistory(job); this.recorded.add(job.id); } catch { /* history is best-effort */ }
|
|
134
|
+
}
|
|
125
135
|
}
|
|
126
136
|
|
|
127
137
|
/**
|
|
@@ -535,6 +545,7 @@ export async function apply(ctx) {
|
|
|
535
545
|
try {
|
|
536
546
|
const { readGlobalConfig } = await import('../install/install.mjs');
|
|
537
547
|
hub.getConfig = () => mergeAutoProviders(readGlobalConfig());
|
|
548
|
+
try { backfillHistory(); } catch { /* best effort */ }
|
|
538
549
|
hub.refreshAutoProviders = refreshAutoProviders;
|
|
539
550
|
void refreshAutoProviders();
|
|
540
551
|
} catch {}
|
|
@@ -904,6 +915,29 @@ export async function apply(ctx) {
|
|
|
904
915
|
},
|
|
905
916
|
}));
|
|
906
917
|
|
|
918
|
+
|
|
919
|
+
disposers.push(webServer.register({
|
|
920
|
+
kind: 'exact', path: `${ROUTE_BASE}/history`,
|
|
921
|
+
handler: async (req, res) => {
|
|
922
|
+
if (!isLoopbackRequest(req)) return sendJson(res, 403, { ok: false, error: 'loopback only' });
|
|
923
|
+
if (req.method !== 'GET') return sendJson(res, 405, { ok: false, error: 'GET only' });
|
|
924
|
+
try {
|
|
925
|
+
const url = new URL(req.url, 'http://localhost');
|
|
926
|
+
const filter = {
|
|
927
|
+
tier: url.searchParams.get('tier') || undefined,
|
|
928
|
+
status: url.searchParams.get('status') || undefined,
|
|
929
|
+
source: url.searchParams.get('source') || undefined,
|
|
930
|
+
};
|
|
931
|
+
const limit = Math.min(500, Math.max(1, Number(url.searchParams.get('limit')) || 100));
|
|
932
|
+
const offset = Math.max(0, Number(url.searchParams.get('offset')) || 0);
|
|
933
|
+
const { records, total } = readHistory({ ...filter, limit, offset });
|
|
934
|
+
return sendJson(res, 200, { ok: true, records, total, stats: historyStats(filter) });
|
|
935
|
+
} catch (err) {
|
|
936
|
+
return sendJson(res, 500, { ok: false, error: err?.message ?? String(err) });
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
}));
|
|
940
|
+
|
|
907
941
|
return () => { for (const d of disposers.reverse()) d(); };
|
|
908
942
|
});
|
|
909
943
|
|
package/src/server.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { acquireCwdLock, releaseCwdLockByJobId, updateCwdLockHolder, getCwdLocks
|
|
|
12
12
|
import { resolveWorkerCwd } from './paths.mjs';
|
|
13
13
|
import { detectOrchestrator } from './process-info.mjs';
|
|
14
14
|
|
|
15
|
-
const server = new McpServer({ name: 'dsh-adapter', version: '0.1.
|
|
15
|
+
const server = new McpServer({ name: 'dsh-adapter', version: '0.1.17' });
|
|
16
16
|
|
|
17
17
|
const tierSchema = z.enum(['flash', 'pro']).optional().describe('Worker model tier. flash = mechanical, well-scoped work (single-file edits, lookups, formatting); pro = multi-file changes, debugging, design judgment. Omit to use the session default. Ignored when worker= is set.');
|
|
18
18
|
const effortSchema = z.enum(['off', 'high', 'max']).optional().describe('Reasoning effort for the worker. Omit to use the session default. With worker= it only applies when passed explicitly and the profile supports it (agy maps to low/medium/high).');
|