@zoraxylia/dsh-codex-adapter 0.1.15 → 0.1.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/.claude-plugin/plugin.json +1 -1
- package/lib/client.js +204 -0
- package/lib/server.mjs +1 -1
- package/package.json +1 -1
- package/src/client/index.tsx +67 -0
- 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,6 +1036,9 @@ 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);
|
|
1041
|
+
const [historyCollapsed, setHistoryCollapsed] = (0, react.useState)(true);
|
|
1013
1042
|
const [provForm, setProvForm] = (0, react.useState)(null);
|
|
1014
1043
|
const [modelAdd, setModelAdd] = (0, react.useState)(null);
|
|
1015
1044
|
const [testResult, setTestResult] = (0, react.useState)(null);
|
|
@@ -1234,6 +1263,17 @@ function WorkersPanel({ ctx }) {
|
|
|
1234
1263
|
}
|
|
1235
1264
|
}).catch(() => {});
|
|
1236
1265
|
}, [post, copy]);
|
|
1266
|
+
const loadHistory = (0, react.useCallback)(() => {
|
|
1267
|
+
get("/history?limit=100").then((r) => {
|
|
1268
|
+
if (r.ok) {
|
|
1269
|
+
setHistoryRows(r.records ?? []);
|
|
1270
|
+
setHistoryAgg(r.stats ?? null);
|
|
1271
|
+
}
|
|
1272
|
+
}).catch(() => {});
|
|
1273
|
+
}, [get]);
|
|
1274
|
+
(0, react.useEffect)(() => {
|
|
1275
|
+
loadHistory();
|
|
1276
|
+
}, [loadHistory]);
|
|
1237
1277
|
/** Selects & checkboxes: apply immediately. */
|
|
1238
1278
|
const field = (key, value) => {
|
|
1239
1279
|
setConfig((c) => ({
|
|
@@ -2487,6 +2527,170 @@ function WorkersPanel({ ctx }) {
|
|
|
2487
2527
|
},
|
|
2488
2528
|
children: notice
|
|
2489
2529
|
}),
|
|
2530
|
+
sectionHeader(copy.history, historyCollapsed, () => setHistoryCollapsed((v) => !v)),
|
|
2531
|
+
!historyCollapsed && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2532
|
+
style: {
|
|
2533
|
+
display: "flex",
|
|
2534
|
+
flexDirection: "column",
|
|
2535
|
+
gap: 8
|
|
2536
|
+
},
|
|
2537
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2538
|
+
style: {
|
|
2539
|
+
display: "flex",
|
|
2540
|
+
gap: 14,
|
|
2541
|
+
alignItems: "center",
|
|
2542
|
+
flexWrap: "wrap",
|
|
2543
|
+
fontSize: 12
|
|
2544
|
+
},
|
|
2545
|
+
children: [
|
|
2546
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
2547
|
+
copy.historyTotal,
|
|
2548
|
+
": ",
|
|
2549
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: historyAgg?.total ?? 0 })
|
|
2550
|
+
] }),
|
|
2551
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
2552
|
+
copy.historyDone,
|
|
2553
|
+
": ",
|
|
2554
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: historyAgg?.done ?? 0 })
|
|
2555
|
+
] }),
|
|
2556
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
2557
|
+
copy.historyFailed,
|
|
2558
|
+
": ",
|
|
2559
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: historyAgg?.failed ?? 0 })
|
|
2560
|
+
] }),
|
|
2561
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
2562
|
+
copy.historyAvg,
|
|
2563
|
+
": ",
|
|
2564
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [historyAgg?.avgSeconds ?? 0, "s"] })
|
|
2565
|
+
] }),
|
|
2566
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: { flex: 1 } }),
|
|
2567
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2568
|
+
type: "button",
|
|
2569
|
+
style: {
|
|
2570
|
+
...S.btn,
|
|
2571
|
+
padding: "2px 8px"
|
|
2572
|
+
},
|
|
2573
|
+
onClick: loadHistory,
|
|
2574
|
+
children: copy.historyRefresh
|
|
2575
|
+
})
|
|
2576
|
+
]
|
|
2577
|
+
}), historyRows.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2578
|
+
style: {
|
|
2579
|
+
opacity: .55,
|
|
2580
|
+
fontSize: 12
|
|
2581
|
+
},
|
|
2582
|
+
children: copy.historyEmpty
|
|
2583
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2584
|
+
style: { overflowX: "auto" },
|
|
2585
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
2586
|
+
style: {
|
|
2587
|
+
borderCollapse: "collapse",
|
|
2588
|
+
width: "100%",
|
|
2589
|
+
fontSize: 12
|
|
2590
|
+
},
|
|
2591
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", {
|
|
2592
|
+
style: {
|
|
2593
|
+
textAlign: "left",
|
|
2594
|
+
opacity: .6
|
|
2595
|
+
},
|
|
2596
|
+
children: [
|
|
2597
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
2598
|
+
style: {
|
|
2599
|
+
padding: "4px 6px",
|
|
2600
|
+
fontWeight: 500
|
|
2601
|
+
},
|
|
2602
|
+
children: copy.historyTime
|
|
2603
|
+
}),
|
|
2604
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
2605
|
+
style: {
|
|
2606
|
+
padding: "4px 6px",
|
|
2607
|
+
fontWeight: 500
|
|
2608
|
+
},
|
|
2609
|
+
children: copy.historyTier
|
|
2610
|
+
}),
|
|
2611
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
2612
|
+
style: {
|
|
2613
|
+
padding: "4px 6px",
|
|
2614
|
+
fontWeight: 500
|
|
2615
|
+
},
|
|
2616
|
+
children: copy.historyModel
|
|
2617
|
+
}),
|
|
2618
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
2619
|
+
style: {
|
|
2620
|
+
padding: "4px 6px",
|
|
2621
|
+
fontWeight: 500
|
|
2622
|
+
},
|
|
2623
|
+
children: copy.historyStatus
|
|
2624
|
+
}),
|
|
2625
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
2626
|
+
style: {
|
|
2627
|
+
padding: "4px 6px",
|
|
2628
|
+
fontWeight: 500
|
|
2629
|
+
},
|
|
2630
|
+
children: copy.historyCost
|
|
2631
|
+
}),
|
|
2632
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
2633
|
+
style: {
|
|
2634
|
+
padding: "4px 6px",
|
|
2635
|
+
fontWeight: 500
|
|
2636
|
+
},
|
|
2637
|
+
children: copy.historyTask
|
|
2638
|
+
})
|
|
2639
|
+
]
|
|
2640
|
+
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: historyRows.map((r) => {
|
|
2641
|
+
const start = Date.parse(r.startedAt ?? "");
|
|
2642
|
+
const end = Date.parse(r.endedAt ?? "");
|
|
2643
|
+
const secs = Number.isFinite(start) && Number.isFinite(end) && end >= start ? ((end - start) / 1e3).toFixed(1) + "s" : "—";
|
|
2644
|
+
const color = r.status === "failed" ? "#e5484d" : r.status === "done" ? "#3fb950" : void 0;
|
|
2645
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", {
|
|
2646
|
+
style: { borderTop: "1px solid rgba(128,128,128,0.14)" },
|
|
2647
|
+
children: [
|
|
2648
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2649
|
+
style: {
|
|
2650
|
+
padding: "4px 6px",
|
|
2651
|
+
whiteSpace: "nowrap"
|
|
2652
|
+
},
|
|
2653
|
+
children: r.endedAt ? new Date(r.endedAt).toLocaleString() : "—"
|
|
2654
|
+
}),
|
|
2655
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2656
|
+
style: { padding: "4px 6px" },
|
|
2657
|
+
children: r.tier ?? "—"
|
|
2658
|
+
}),
|
|
2659
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
|
|
2660
|
+
style: { padding: "4px 6px" },
|
|
2661
|
+
children: [r.model ?? "—", r.effort ? ` @${r.effort}` : ""]
|
|
2662
|
+
}),
|
|
2663
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2664
|
+
style: {
|
|
2665
|
+
padding: "4px 6px",
|
|
2666
|
+
color
|
|
2667
|
+
},
|
|
2668
|
+
children: r.status ?? "—"
|
|
2669
|
+
}),
|
|
2670
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2671
|
+
style: {
|
|
2672
|
+
padding: "4px 6px",
|
|
2673
|
+
whiteSpace: "nowrap"
|
|
2674
|
+
},
|
|
2675
|
+
children: secs
|
|
2676
|
+
}),
|
|
2677
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2678
|
+
style: {
|
|
2679
|
+
padding: "4px 6px",
|
|
2680
|
+
maxWidth: 360,
|
|
2681
|
+
overflow: "hidden",
|
|
2682
|
+
textOverflow: "ellipsis",
|
|
2683
|
+
whiteSpace: "nowrap"
|
|
2684
|
+
},
|
|
2685
|
+
title: r.task ?? "",
|
|
2686
|
+
children: r.task ?? "—"
|
|
2687
|
+
})
|
|
2688
|
+
]
|
|
2689
|
+
}, r.id);
|
|
2690
|
+
}) })]
|
|
2691
|
+
})
|
|
2692
|
+
})]
|
|
2693
|
+
}),
|
|
2490
2694
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2491
2695
|
style: S.section,
|
|
2492
2696
|
children: copy.jobs
|
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.16" });
|
|
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.16",
|
|
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,9 @@ 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);
|
|
427
|
+
const [historyCollapsed, setHistoryCollapsed] = useState(true);
|
|
419
428
|
const [provForm, setProvForm] = useState<{
|
|
420
429
|
originalId?: string; name: string; type: 'api' | 'cli'; models: string;
|
|
421
430
|
base_url: string; api_key: string; imagegen_model: string;
|
|
@@ -569,6 +578,13 @@ function WorkersPanel({ ctx }: { ctx: any }) {
|
|
|
569
578
|
if (r.ok) { setConfig(r.config); setNotice(copy.saved); setTimeout(() => setNotice(''), 1500); }
|
|
570
579
|
}).catch(() => {});
|
|
571
580
|
}, [post, copy]);
|
|
581
|
+
const loadHistory = useCallback(() => {
|
|
582
|
+
void get('/history?limit=100').then((r) => {
|
|
583
|
+
if (r.ok) { setHistoryRows(r.records ?? []); setHistoryAgg(r.stats ?? null); }
|
|
584
|
+
}).catch(() => {});
|
|
585
|
+
}, [get]);
|
|
586
|
+
useEffect(() => { loadHistory(); }, [loadHistory]);
|
|
587
|
+
|
|
572
588
|
/** Selects & checkboxes: apply immediately. */
|
|
573
589
|
const field = (key: string, value: any) => {
|
|
574
590
|
setConfig((c: any) => ({ ...c, [key]: value }));
|
|
@@ -1032,6 +1048,57 @@ function WorkersPanel({ ctx }: { ctx: any }) {
|
|
|
1032
1048
|
|
|
1033
1049
|
{notice !== '' && <div style={{ fontSize: 12, opacity: 0.8, whiteSpace: 'pre-wrap' }}>{notice}</div>}
|
|
1034
1050
|
|
|
1051
|
+
{sectionHeader(copy.history, historyCollapsed, () => setHistoryCollapsed((v) => !v))}
|
|
1052
|
+
{!historyCollapsed && (
|
|
1053
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
|
1054
|
+
<div style={{ display: 'flex', gap: 14, alignItems: 'center', flexWrap: 'wrap', fontSize: 12 }}>
|
|
1055
|
+
<span>{copy.historyTotal}: <b>{historyAgg?.total ?? 0}</b></span>
|
|
1056
|
+
<span>{copy.historyDone}: <b>{historyAgg?.done ?? 0}</b></span>
|
|
1057
|
+
<span>{copy.historyFailed}: <b>{historyAgg?.failed ?? 0}</b></span>
|
|
1058
|
+
<span>{copy.historyAvg}: <b>{historyAgg?.avgSeconds ?? 0}s</b></span>
|
|
1059
|
+
<span style={{ flex: 1 }} />
|
|
1060
|
+
<button type="button" style={{ ...S.btn, padding: '2px 8px' }} onClick={loadHistory}>{copy.historyRefresh}</button>
|
|
1061
|
+
</div>
|
|
1062
|
+
{historyRows.length === 0 ? (
|
|
1063
|
+
<div style={{ opacity: 0.55, fontSize: 12 }}>{copy.historyEmpty}</div>
|
|
1064
|
+
) : (
|
|
1065
|
+
<div style={{ overflowX: 'auto' }}>
|
|
1066
|
+
<table style={{ borderCollapse: 'collapse', width: '100%', fontSize: 12 }}>
|
|
1067
|
+
<thead>
|
|
1068
|
+
<tr style={{ textAlign: 'left', opacity: 0.6 }}>
|
|
1069
|
+
<th style={{ padding: '4px 6px', fontWeight: 500 }}>{copy.historyTime}</th>
|
|
1070
|
+
<th style={{ padding: '4px 6px', fontWeight: 500 }}>{copy.historyTier}</th>
|
|
1071
|
+
<th style={{ padding: '4px 6px', fontWeight: 500 }}>{copy.historyModel}</th>
|
|
1072
|
+
<th style={{ padding: '4px 6px', fontWeight: 500 }}>{copy.historyStatus}</th>
|
|
1073
|
+
<th style={{ padding: '4px 6px', fontWeight: 500 }}>{copy.historyCost}</th>
|
|
1074
|
+
<th style={{ padding: '4px 6px', fontWeight: 500 }}>{copy.historyTask}</th>
|
|
1075
|
+
</tr>
|
|
1076
|
+
</thead>
|
|
1077
|
+
<tbody>
|
|
1078
|
+
{historyRows.map((r) => {
|
|
1079
|
+
const start = Date.parse(r.startedAt ?? '');
|
|
1080
|
+
const end = Date.parse(r.endedAt ?? '');
|
|
1081
|
+
const secs = Number.isFinite(start) && Number.isFinite(end) && end >= start ? ((end - start) / 1000).toFixed(1) + 's' : '—';
|
|
1082
|
+
const color = r.status === 'failed' ? '#e5484d' : r.status === 'done' ? '#3fb950' : undefined;
|
|
1083
|
+
return (
|
|
1084
|
+
<tr key={r.id} style={{ borderTop: '1px solid rgba(128,128,128,0.14)' }}>
|
|
1085
|
+
<td style={{ padding: '4px 6px', whiteSpace: 'nowrap' }}>{r.endedAt ? new Date(r.endedAt).toLocaleString() : '—'}</td>
|
|
1086
|
+
<td style={{ padding: '4px 6px' }}>{r.tier ?? '—'}</td>
|
|
1087
|
+
<td style={{ padding: '4px 6px' }}>{r.model ?? '—'}{r.effort ? ` @${r.effort}` : ''}</td>
|
|
1088
|
+
<td style={{ padding: '4px 6px', color }}>{r.status ?? '—'}</td>
|
|
1089
|
+
<td style={{ padding: '4px 6px', whiteSpace: 'nowrap' }}>{secs}</td>
|
|
1090
|
+
<td style={{ padding: '4px 6px', maxWidth: 360, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}
|
|
1091
|
+
title={r.task ?? ''}>{r.task ?? '—'}</td>
|
|
1092
|
+
</tr>
|
|
1093
|
+
);
|
|
1094
|
+
})}
|
|
1095
|
+
</tbody>
|
|
1096
|
+
</table>
|
|
1097
|
+
</div>
|
|
1098
|
+
)}
|
|
1099
|
+
</div>
|
|
1100
|
+
)}
|
|
1101
|
+
|
|
1035
1102
|
<div style={S.section}>{copy.jobs}</div>
|
|
1036
1103
|
{!jobsLoaded || groups.length === 0 ? (
|
|
1037
1104
|
<div style={{ opacity: 0.55 }}>{copy.empty}</div>
|
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.16' });
|
|
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).');
|