@zoraxylia/dsh-codex-adapter 0.1.14 → 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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-adapter",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Dispatch subtasks to DeepSeek Harness (DSH) agents as native subagents with live progress",
5
5
  "author": {
6
6
  "name": "zx-yk"
package/lib/client.js CHANGED
@@ -404,6 +404,8 @@ const COPY = {
404
404
  title: "DSH Adapter",
405
405
  intro: "Claude Code / Codex 可以给 DSH agent 分派任务,在宿主里显示为原生子代理、进度可见。配置派发默认值、执行方式,以及接入视觉与生图能力,一键装进宿主。",
406
406
  integrations: "集成",
407
+ globalMcp: "Codex 全局 MCP(CLI 与桌面端都可直接调用)",
408
+ globalMcpHint: "关闭后只安装 ds-flash / ds-pro 子代理角色,不注册全局 MCP;桌面端将无法直接调用。",
407
409
  collapse: "折叠",
408
410
  expand: "展开",
409
411
  doneAt: (t) => `已更新 · ${t}`,
@@ -513,6 +515,19 @@ const COPY = {
513
515
  saved: "已保存",
514
516
  jobs: "Worker 任务",
515
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: "任务",
516
531
  statusRunning: "运行中",
517
532
  statusStalled: "疑似卡住",
518
533
  statusNeedsInput: "需输入",
@@ -574,6 +589,8 @@ const COPY = {
574
589
  title: "DSH Adapter",
575
590
  intro: "Claude Code / Codex can dispatch tasks to DSH agents and see them as native subagents in the host with live progress. Configure dispatch defaults, execution mode, and vision / image-generation access, then install into the host in one click.",
576
591
  integrations: "Integrations",
592
+ globalMcp: "Codex global MCP (callable from both CLI and the desktop client)",
593
+ globalMcpHint: "When off, only the ds-flash / ds-pro agent roles are installed; the desktop client cannot call the worker tools directly.",
577
594
  collapse: "Collapse",
578
595
  expand: "Expand",
579
596
  doneAt: (t) => `Updated · ${t}`,
@@ -683,6 +700,19 @@ const COPY = {
683
700
  saved: "Saved",
684
701
  jobs: "Worker jobs",
685
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",
686
716
  statusRunning: "running",
687
717
  statusStalled: "stalled",
688
718
  statusNeedsInput: "needs input",
@@ -1006,6 +1036,9 @@ function WorkersPanel({ ctx }) {
1006
1036
  const [notice, setNotice] = (0, react.useState)("");
1007
1037
  const [rowNote, setRowNote] = (0, react.useState)({});
1008
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);
1009
1042
  const [provForm, setProvForm] = (0, react.useState)(null);
1010
1043
  const [modelAdd, setModelAdd] = (0, react.useState)(null);
1011
1044
  const [testResult, setTestResult] = (0, react.useState)(null);
@@ -1230,6 +1263,17 @@ function WorkersPanel({ ctx }) {
1230
1263
  }
1231
1264
  }).catch(() => {});
1232
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]);
1233
1277
  /** Selects & checkboxes: apply immediately. */
1234
1278
  const field = (key, value) => {
1235
1279
  setConfig((c) => ({
@@ -1799,7 +1843,34 @@ function WorkersPanel({ ctx }) {
1799
1843
  }) : null, "claude", "claude-uninstall", copy.tips.claude),
1800
1844
  integrationRow("Codex", !!status?.codex?.installed, null, "codex", "codex-uninstall", copy.tips.codex),
1801
1845
  integrationRow("Antigravity", !!status?.agy?.installed, null, "agy", "agy-uninstall", copy.tips.agy),
1802
- integrationRow("Grok", !!status?.grok?.installed, null, "grok", "grok-uninstall", copy.tips.grok)
1846
+ integrationRow("Grok", !!status?.grok?.installed, null, "grok", "grok-uninstall", copy.tips.grok),
1847
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1848
+ style: {
1849
+ display: "flex",
1850
+ alignItems: "center",
1851
+ gap: 6,
1852
+ fontSize: 12,
1853
+ paddingLeft: 2,
1854
+ opacity: config ? 1 : .5
1855
+ },
1856
+ title: copy.globalMcpHint,
1857
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1858
+ type: "checkbox",
1859
+ checked: config?.codex_global_mcp !== false,
1860
+ disabled: busy || !config,
1861
+ onChange: (e) => {
1862
+ const on = e.target.checked;
1863
+ setConfig((c) => ({
1864
+ ...c,
1865
+ codex_global_mcp: on
1866
+ }));
1867
+ post("/config", { codex_global_mcp: on }).then((r) => {
1868
+ if (r.ok) setConfig(r.config);
1869
+ if (status?.codex?.installed) act("codex");
1870
+ });
1871
+ }
1872
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: copy.globalMcp })]
1873
+ })
1803
1874
  ]
1804
1875
  }),
1805
1876
  sectionHeader(copy.globalConfig, globalConfigCollapsed, toggleGlobalConfig),
@@ -2456,6 +2527,170 @@ function WorkersPanel({ ctx }) {
2456
2527
  },
2457
2528
  children: notice
2458
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
+ }),
2459
2694
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2460
2695
  style: S.section,
2461
2696
  children: copy.jobs
package/lib/server.mjs CHANGED
@@ -14402,6 +14402,9 @@ var GLOBAL_CONFIG_DEFAULTS = {
14402
14402
  // auto = orchestrator picks the tier; flash-only / pro-only clamp every
14403
14403
  // dispatch to one tier at the tool layer regardless of what was requested.
14404
14404
  tier_policy: "auto",
14405
+ // Register the MCP server globally in ~/.codex/config.toml so the Codex
14406
+ // desktop client (which has no subagent spawn UI) can call the worker tools.
14407
+ codex_global_mcp: true,
14405
14408
  // When a blocking flash run fails, retry the same task once on pro.
14406
14409
  escalate_on_failure: false,
14407
14410
  // Multimodal bridge: which subscription CLI lends the text-only DS model
@@ -15069,7 +15072,7 @@ function describeBindings(config = {}) {
15069
15072
  }
15070
15073
 
15071
15074
  // src/server.mjs
15072
- var server = new McpServer({ name: "dsh-adapter", version: "0.1.14" });
15075
+ var server = new McpServer({ name: "dsh-adapter", version: "0.1.16" });
15073
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.");
15074
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).");
15075
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.14",
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.",
@@ -88,6 +88,8 @@ const COPY = {
88
88
  title: 'DSH Adapter',
89
89
  intro: 'Claude Code / Codex 可以给 DSH agent 分派任务,在宿主里显示为原生子代理、进度可见。配置派发默认值、执行方式,以及接入视觉与生图能力,一键装进宿主。',
90
90
  integrations: '集成',
91
+ globalMcp: 'Codex 全局 MCP(CLI 与桌面端都可直接调用)',
92
+ globalMcpHint: '关闭后只安装 ds-flash / ds-pro 子代理角色,不注册全局 MCP;桌面端将无法直接调用。',
91
93
  collapse: '折叠', expand: '展开',
92
94
  doneAt: (t: string) => `已更新 · ${t}`,
93
95
  installed: '已安装', notInstalled: '未安装', hud: 'HUD 段',
@@ -135,6 +137,9 @@ const COPY = {
135
137
  cardCustomProv: { t: '自定义 Provider', d: '接入自己的 API 或本地命令;保存后会出现在上面的视觉 / 生图 provider 选择里。' },
136
138
  modeDesc: { auto: 'auto · 优先 hub', hub: 'hub · 必须 hub', standalone: 'standalone · 独立进程' },
137
139
  save: '保存', saved: '已保存', jobs: 'Worker 任务', empty: '当前没有 worker 任务。',
140
+ history: '历史看板', historyEmpty: '还没有历史记录。', historyTotal: '总数', historyDone: '成功', historyFailed: '失败',
141
+ historyAvg: '平均耗时', historyRefresh: '刷新', historyTime: '时间', historyTier: '档位', historyModel: '模型',
142
+ historyStatus: '状态', historyCost: '耗时', historyTask: '任务',
138
143
  statusRunning: '运行中', statusStalled: '疑似卡住', statusNeedsInput: '需输入', statusDone: '完成', statusFailed: '失败', statusCancelled: '已取消', statusOrphaned: '失联',
139
144
  statusTitle: (s: string) => `状态:${s}`,
140
145
  orphanWriterGone: (origin: string) => `所属实例已消失:写入该状态的进程(${origin})已不存在,任务随它一起终止(最后状态 running)`,
@@ -182,6 +187,8 @@ const COPY = {
182
187
  title: 'DSH Adapter',
183
188
  intro: 'Claude Code / Codex can dispatch tasks to DSH agents and see them as native subagents in the host with live progress. Configure dispatch defaults, execution mode, and vision / image-generation access, then install into the host in one click.',
184
189
  integrations: 'Integrations',
190
+ globalMcp: 'Codex global MCP (callable from both CLI and the desktop client)',
191
+ globalMcpHint: 'When off, only the ds-flash / ds-pro agent roles are installed; the desktop client cannot call the worker tools directly.',
185
192
  collapse: 'Collapse', expand: 'Expand',
186
193
  doneAt: (t: string) => `Updated · ${t}`,
187
194
  installed: 'installed', notInstalled: 'not installed', hud: 'HUD segment',
@@ -229,6 +236,9 @@ const COPY = {
229
236
  cardCustomProv: { t: 'Custom providers', d: 'Bring your own API or local command; saved providers appear in the vision / image-gen selects above.' },
230
237
  modeDesc: { auto: 'auto · prefer hub', hub: 'hub · require hub', standalone: 'standalone' },
231
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',
232
242
  statusRunning: 'running', statusStalled: 'stalled', statusNeedsInput: 'needs input', statusDone: 'done', statusFailed: 'failed', statusCancelled: 'cancelled', statusOrphaned: 'orphaned',
233
243
  statusTitle: (s: string) => `status: ${s}`,
234
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)`,
@@ -412,6 +422,9 @@ function WorkersPanel({ ctx }: { ctx: any }) {
412
422
  // Per-integration feedback, rendered next to the button that was pressed.
413
423
  const [rowNote, setRowNote] = useState<Record<string, { kind: 'working' | 'ok' | 'error'; text: string }>>({});
414
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);
415
428
  const [provForm, setProvForm] = useState<{
416
429
  originalId?: string; name: string; type: 'api' | 'cli'; models: string;
417
430
  base_url: string; api_key: string; imagegen_model: string;
@@ -565,6 +578,13 @@ function WorkersPanel({ ctx }: { ctx: any }) {
565
578
  if (r.ok) { setConfig(r.config); setNotice(copy.saved); setTimeout(() => setNotice(''), 1500); }
566
579
  }).catch(() => {});
567
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
+
568
588
  /** Selects & checkboxes: apply immediately. */
569
589
  const field = (key: string, value: any) => {
570
590
  setConfig((c: any) => ({ ...c, [key]: value }));
@@ -813,6 +833,19 @@ function WorkersPanel({ ctx }: { ctx: any }) {
813
833
  {integrationRow('Codex', !!status?.codex?.installed, null, 'codex', 'codex-uninstall', (copy as any).tips.codex)}
814
834
  {integrationRow('Antigravity', !!status?.agy?.installed, null, 'agy', 'agy-uninstall', (copy as any).tips.agy)}
815
835
  {integrationRow('Grok', !!status?.grok?.installed, null, 'grok', 'grok-uninstall', (copy as any).tips.grok)}
836
+ <label style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 12, paddingLeft: 2, opacity: config ? 1 : 0.5 }}
837
+ title={copy.globalMcpHint}>
838
+ <input type="checkbox" checked={config?.codex_global_mcp !== false} disabled={busy || !config}
839
+ onChange={(e) => {
840
+ const on = e.target.checked;
841
+ setConfig((c: any) => ({ ...c, codex_global_mcp: on }));
842
+ void post('/config', { codex_global_mcp: on }).then((r) => {
843
+ if (r.ok) setConfig(r.config);
844
+ if (status?.codex?.installed) void act('codex');
845
+ });
846
+ }} />
847
+ <span>{copy.globalMcp}</span>
848
+ </label>
816
849
  </div>
817
850
  )}
818
851
 
@@ -1015,6 +1048,57 @@ function WorkersPanel({ ctx }: { ctx: any }) {
1015
1048
 
1016
1049
  {notice !== '' && <div style={{ fontSize: 12, opacity: 0.8, whiteSpace: 'pre-wrap' }}>{notice}</div>}
1017
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
+
1018
1102
  <div style={S.section}>{copy.jobs}</div>
1019
1103
  {!jobsLoaded || groups.length === 0 ? (
1020
1104
  <div style={{ opacity: 0.55 }}>{copy.empty}</div>
@@ -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
- this.shard.publish([...this.jobs.values()].map((j) => this.view(j)));
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 {}
@@ -890,7 +901,7 @@ export async function apply(ctx) {
890
901
  actions: [...base.actions, ...hud.actions.map((a) => `hud: ${a}`)],
891
902
  });
892
903
  }
893
- if (target === 'codex') return sendJson(res, 200, installCodex({}));
904
+ if (target === 'codex') return sendJson(res, 200, installCodex({ globalMcp: hub.getConfig().codex_global_mcp !== false }));
894
905
  if (target === 'agy') return sendJson(res, 200, installAgy({}));
895
906
  if (target === 'grok') return sendJson(res, 200, installGrok({}));
896
907
  if (target === 'claude-uninstall') return sendJson(res, 200, await uninstallClaudeCode({}));
@@ -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
 
@@ -83,6 +83,9 @@ export const GLOBAL_CONFIG_DEFAULTS = {
83
83
  // auto = orchestrator picks the tier; flash-only / pro-only clamp every
84
84
  // dispatch to one tier at the tool layer regardless of what was requested.
85
85
  tier_policy: 'auto',
86
+ // Register the MCP server globally in ~/.codex/config.toml so the Codex
87
+ // desktop client (which has no subagent spawn UI) can call the worker tools.
88
+ codex_global_mcp: true,
86
89
  // When a blocking flash run fails, retry the same task once on pro.
87
90
  escalate_on_failure: false,
88
91
  // Multimodal bridge: which subscription CLI lends the text-only DS model
@@ -390,7 +393,7 @@ function removeCodexMcp(text) {
390
393
  return [...lines.slice(0, start), ...lines.slice(end)].join('\n');
391
394
  }
392
395
 
393
- export function installCodex({ home = homedir(), scope } = {}) {
396
+ export function installCodex({ home = homedir(), scope, globalMcp = true } = {}) {
394
397
  const actions = [];
395
398
  const agentsDir = scope === 'project' ? join(process.cwd(), '.codex', 'agents') : join(home, '.codex', 'agents');
396
399
  mkdirSync(agentsDir, { recursive: true });
@@ -417,6 +420,17 @@ export function installCodex({ home = homedir(), scope } = {}) {
417
420
  const configFile = join(process.env.CODEX_HOME || join(home, '.codex'), 'config.toml');
418
421
  mkdirSync(dirname(configFile), { recursive: true });
419
422
  const before = existsSync(configFile) ? readFileSync(configFile, 'utf8') : '';
423
+ if (!globalMcp) {
424
+ if (before.includes('[mcp_servers.dsh-adapter]')) {
425
+ const bak = backup(configFile);
426
+ if (bak) actions.push(`backup: ${bak}`);
427
+ writeFileSync(configFile, removeCodexMcp(before));
428
+ actions.push('mcp: global registration disabled — entry removed');
429
+ } else {
430
+ actions.push('mcp: global registration disabled');
431
+ }
432
+ return { ok: true, actions };
433
+ }
420
434
  const bak = backup(configFile);
421
435
  if (bak) actions.push(`backup: ${bak}`);
422
436
  const launcher = resolveNodeLauncher();
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.14' });
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).');