dsh-taskbridge 1.3.2 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -345,7 +345,17 @@ window.__ModuleLoader__.load({
345
345
  const whole = (value, fallback) => Number.isFinite(value) ? Math.trunc(value) : fallback;
346
346
  return {
347
347
  selfCheckSeconds: whole(block.selfCheckSeconds, MONITORING_DEFAULTS.selfCheckSeconds),
348
- attentionSeconds: whole(block.attentionSeconds, MONITORING_DEFAULTS.attentionSeconds)
348
+ attentionSeconds: whole(block.attentionSeconds, MONITORING_DEFAULTS.attentionSeconds),
349
+ repeatFailureThreshold: whole(block.repeatFailureThreshold, MONITORING_DEFAULTS.repeatFailureThreshold)
350
+ };
351
+ }
352
+ function monitoringDraftOf(source) {
353
+ const block = source?.monitoring;
354
+ if (block === null || typeof block !== "object" || Array.isArray(block)) return { ...MONITORING_DEFAULTS };
355
+ return {
356
+ selfCheckSeconds: block.selfCheckSeconds,
357
+ attentionSeconds: block.attentionSeconds,
358
+ repeatFailureThreshold: block.repeatFailureThreshold === void 0 ? MONITORING_DEFAULTS.repeatFailureThreshold : block.repeatFailureThreshold
349
359
  };
350
360
  }
351
361
  function secondsToMinutes(seconds) {
@@ -443,11 +453,15 @@ window.__ModuleLoader__.load({
443
453
  selfCheckSecondsMin: 30,
444
454
  selfCheckSecondsMax: 3600,
445
455
  attentionSecondsMin: 31,
446
- attentionSecondsMax: 7200
456
+ attentionSecondsMax: 7200,
457
+ // Repeated-failure reminder: a COUNT of consecutive identical failures, 0 = off.
458
+ repeatFailureThresholdMin: 0,
459
+ repeatFailureThresholdMax: 20
447
460
  });
448
461
  var MONITORING_DEFAULTS = Object.freeze({
449
462
  selfCheckSeconds: 300,
450
- attentionSeconds: 600
463
+ attentionSeconds: 600,
464
+ repeatFailureThreshold: 3
451
465
  });
452
466
  var SELF_CHECK_LABELS = Object.freeze({
453
467
  "executor-alive-silent": "执行器健在,这段时间没有新输出",
@@ -457,6 +471,15 @@ window.__ModuleLoader__.load({
457
471
  "waiting-for-permission": "正在等待本次调用授权决定",
458
472
  settled: "任务已经结束"
459
473
  });
474
+ function repeatFailureLine(activity) {
475
+ const block = activity?.repeatFailure;
476
+ if (block === null || block === void 0) return "未采集到";
477
+ const reported = Array.isArray(block.reported) ? block.reported : [];
478
+ if (reported.length === 0) {
479
+ return block.threshold === 0 ? "已关闭" : `尚未触发(连续 ${block.threshold} 次才提醒)`;
480
+ }
481
+ return reported.map((entry) => `${entry.toolName ?? "工具"} · ${entry.failureCode ?? "error"} 连续 ${entry.consecutive} 次`).join(";");
482
+ }
460
483
  var WAIT_REASON_LABELS = Object.freeze({
461
484
  heartbeat: "没有需要处理的事(内部心跳)",
462
485
  attention: "长时间没有任何新进展,需要你判断",
@@ -726,21 +749,7 @@ window.__ModuleLoader__.load({
726
749
  if (!Number.isInteger(parallelism) || parallelism < LIMITS.maxParallelismMin || parallelism > LIMITS.maxParallelismMax) {
727
750
  problems.push(`最大并发需为 ${LIMITS.maxParallelismMin}–${LIMITS.maxParallelismMax} 之间的整数`);
728
751
  }
729
- const monitoring = monitoringOf(draft);
730
- for (const [field, label] of [
731
- ["selfCheckSeconds", "程序自检间隔"],
732
- ["attentionSeconds", "提醒你的间隔"]
733
- ]) {
734
- const value = monitoring[field];
735
- const min = field === "selfCheckSeconds" ? LIMITS.selfCheckSecondsMin : LIMITS.attentionSecondsMin;
736
- const max = field === "selfCheckSeconds" ? LIMITS.selfCheckSecondsMax : LIMITS.attentionSecondsMax;
737
- if (!Number.isInteger(value) || value < min || value > max) {
738
- problems.push(`${label}需为 ${min}–${max} 秒之间的整数`);
739
- }
740
- }
741
- if (Number.isInteger(monitoring.selfCheckSeconds) && Number.isInteger(monitoring.attentionSeconds) && monitoring.attentionSeconds <= monitoring.selfCheckSeconds) {
742
- problems.push("提醒你的间隔必须大于程序自检间隔");
743
- }
752
+ problems.push(...precheckMonitoring(monitoringDraftOf(draft)));
744
753
  return problems;
745
754
  }
746
755
  function taskStateLabel(state) {
@@ -833,7 +842,8 @@ window.__ModuleLoader__.load({
833
842
  }
834
843
  function taskProgress(task) {
835
844
  const activity = taskActivity(task);
836
- const phase = taskPhaseLabel(task?.phase);
845
+ const outcome = taskOutcome(task);
846
+ const phase = outcome.label;
837
847
  if (activity === null) {
838
848
  return {
839
849
  available: false,
@@ -887,13 +897,23 @@ window.__ModuleLoader__.load({
887
897
  function isLiveTask(task) {
888
898
  return task?.state === "pending" || task?.state === "running";
889
899
  }
890
- function hasLiveTasks(tasks) {
891
- return Array.isArray(tasks) && tasks.some(isLiveTask);
900
+ function isTaskRecordChanging(task) {
901
+ if (isLiveTask(task)) return true;
902
+ if (task?.state === "awaiting-host-review") {
903
+ const persistence = task.reviewPersistence;
904
+ if (persistence !== null && typeof persistence === "object") return persistence.durable !== true;
905
+ return task.hostAcceptance === null || task.hostAcceptance === void 0;
906
+ }
907
+ return task?.reviewPersistence?.pending === true;
908
+ }
909
+ function hasChangingRecords(tasks) {
910
+ return Array.isArray(tasks) && tasks.some(isTaskRecordChanging);
892
911
  }
893
912
  function precheckMonitoring(monitoring) {
894
913
  const problems = [];
895
914
  const self = monitoring?.selfCheckSeconds;
896
915
  const attention = monitoring?.attentionSeconds;
916
+ const repeat = monitoring?.repeatFailureThreshold === void 0 ? MONITORING_DEFAULTS.repeatFailureThreshold : monitoring.repeatFailureThreshold;
897
917
  if (!Number.isInteger(self) || self < LIMITS.selfCheckSecondsMin || self > LIMITS.selfCheckSecondsMax) {
898
918
  problems.push(`程序自检间隔需为 ${LIMITS.selfCheckSecondsMin}–${LIMITS.selfCheckSecondsMax} 秒之间的整数`);
899
919
  }
@@ -903,14 +923,103 @@ window.__ModuleLoader__.load({
903
923
  if (Number.isInteger(self) && Number.isInteger(attention) && attention <= self) {
904
924
  problems.push("提醒你的间隔必须大于程序自检间隔");
905
925
  }
926
+ if (!Number.isInteger(repeat) || repeat < LIMITS.repeatFailureThresholdMin || repeat > LIMITS.repeatFailureThresholdMax) {
927
+ problems.push(`重复失败提醒次数需为 ${LIMITS.repeatFailureThresholdMin}–${LIMITS.repeatFailureThresholdMax} 之间的整数(0 表示关闭)`);
928
+ }
906
929
  return problems;
907
930
  }
908
931
  function taskOutcome(task) {
909
932
  const state = String(task?.state ?? "");
910
- const accepted = task?.hostAcceptance !== null && task?.hostAcceptance !== void 0;
911
- const executed = state === "awaiting-host-review" || accepted === true;
912
- const note = state === "awaiting-host-review" ? "执行已完成,等待宿主(Codex)审查;插件不会自行验收。" : accepted === true ? "宿主已记录验收结论。" : state === "failed" ? "执行失败;错误详情见下方证据。" : state === "cancelled" ? "任务已取消,未产生验收结论。" : "任务尚未产生结果。";
913
- return { label: taskStateLabel(state), executed, accepted, note };
933
+ const acceptance = task?.hostAcceptance;
934
+ const persistence = task?.reviewPersistence;
935
+ const decided = acceptance !== null && acceptance !== void 0 && (persistence === null || persistence === void 0 || persistence.durable !== false);
936
+ const accepted = decided && acceptance?.accepted === true;
937
+ const executed = state === "awaiting-host-review" || decided;
938
+ let label;
939
+ let tone;
940
+ let note;
941
+ let phaseLabel;
942
+ const saving = persistence?.pending === true;
943
+ const failedWrite = persistence?.state === "failed";
944
+ if (accepted) {
945
+ label = "审查通过";
946
+ tone = "on";
947
+ note = "宿主已记录验收结论:审查通过。";
948
+ phaseLabel = null;
949
+ } else if (decided) {
950
+ label = "需要修正";
951
+ tone = "warn";
952
+ note = "宿主已记录验收结论:需要修正(本任务的执行结果未被接受)。";
953
+ phaseLabel = null;
954
+ } else if (saving) {
955
+ label = persistence.state === "timed-out" ? "审查结论保存未确认" : "审查结论保存中";
956
+ tone = "warn";
957
+ note = persistence.state === "timed-out" ? "审查结论已发出但尚未确认写入;插件会继续读取同一任务直到确认,不要重新派工。" : "审查结论正在写入,确认保存后才会显示审查通过或需要修正。";
958
+ phaseLabel = null;
959
+ } else if (failedWrite) {
960
+ label = "审查结论保存失败";
961
+ tone = "warn";
962
+ note = "审查结论未能写入,未记录为已验收;可对同一任务重试。";
963
+ phaseLabel = null;
964
+ } else if (state === "awaiting-host-review") {
965
+ label = "等待宿主审查";
966
+ tone = "warn";
967
+ note = "执行已完成,等待宿主(Codex)审查;插件不会自行验收。";
968
+ phaseLabel = null;
969
+ } else if (state === "failed") {
970
+ label = taskStateLabel(state);
971
+ tone = "warn";
972
+ note = "执行失败;错误详情见下方证据。";
973
+ phaseLabel = null;
974
+ } else if (state === "cancelled") {
975
+ label = taskStateLabel(state);
976
+ tone = "off";
977
+ note = "任务已取消,未产生验收结论。";
978
+ phaseLabel = null;
979
+ } else {
980
+ label = taskStateLabel(state);
981
+ tone = state === "running" ? "on" : "off";
982
+ note = "任务尚未产生结果。";
983
+ phaseLabel = taskPhaseLabel(task?.phase);
984
+ }
985
+ return { label, tone, executed, accepted, decided, phaseLabel, note };
986
+ }
987
+ function hostReviewLine(task, formatTime2) {
988
+ const acceptance = task?.hostAcceptance;
989
+ if (acceptance === null || acceptance === void 0) return "未记录(插件不会自行验收)";
990
+ const label = acceptance.accepted === true ? "审查通过" : "需要修正";
991
+ const at = typeof acceptance.acceptedAt === "number" ? `(${formatTime2(acceptance.acceptedAt)})` : "";
992
+ const note = typeof acceptance.note === "string" && acceptance.note !== "" ? `:${boundedText(acceptance.note, 200)}` : "";
993
+ return `${label}${at}${note}`;
994
+ }
995
+ var REVIEW_NOTE_PREVIEW_CHARS = 200;
996
+ function reviewNotePreview(task) {
997
+ const acceptance = task?.hostAcceptance;
998
+ if (acceptance === null || acceptance === void 0) return null;
999
+ if (acceptance.noteOmitted === true && typeof acceptance.note !== "string") {
1000
+ const chars = Number.isFinite(acceptance.noteChars) ? acceptance.noteChars : 0;
1001
+ return { text: "", chars, truncated: chars > 0, omitted: true };
1002
+ }
1003
+ const note = typeof acceptance.note === "string" ? acceptance.note : "";
1004
+ const all = Array.from(note);
1005
+ return {
1006
+ text: all.slice(0, REVIEW_NOTE_PREVIEW_CHARS).join(""),
1007
+ chars: all.length,
1008
+ truncated: all.length > REVIEW_NOTE_PREVIEW_CHARS,
1009
+ omitted: false
1010
+ };
1011
+ }
1012
+ var RECORD_REFRESH_INTERVAL_MS = 5e3;
1013
+ function recordRefreshPlan(input = {}) {
1014
+ const all = [];
1015
+ if (Array.isArray(input.tasks)) all.push(...input.tasks);
1016
+ if (input.selectedTask !== null && input.selectedTask !== void 0) all.push(input.selectedTask);
1017
+ const changing = hasChangingRecords(all);
1018
+ const intervalMs = RECORD_REFRESH_INTERVAL_MS;
1019
+ if (input.visible === false) return { refresh: false, intervalMs, reason: "hidden" };
1020
+ if (changing !== true) return { refresh: false, intervalMs, reason: "settled" };
1021
+ if (input.loading === true) return { refresh: false, intervalMs, reason: "loading" };
1022
+ return { refresh: true, intervalMs, reason: "changing" };
914
1023
  }
915
1024
  function changedFiles(task) {
916
1025
  const candidates = [task?.diff?.files, task?.diff?.changedFiles, task?.changedFiles];
@@ -1633,22 +1742,26 @@ window.__ModuleLoader__.load({
1633
1742
  });
1634
1743
  },
1635
1744
  /**
1636
- * Replace only the two silence thresholds.
1745
+ * Replace the silence thresholds and the repeated-failure count.
1637
1746
  *
1638
1747
  * The narrow route exists so an operator adjusting a timer cannot rewrite a
1639
1748
  * provider list. On success the committed document is adopted for `settings` and
1640
1749
  * the draft's monitoring block, and OTHER unsaved draft edits are left alone —
1641
1750
  * a timer save must never discard a half-finished provider edit.
1642
- * @param {{ selfCheckSeconds: number, attentionSeconds: number }} monitoring - already-validated block.
1751
+ *
1752
+ * Order matters: the RAW block is validated first and only then normalized for the
1753
+ * wire. Validating the normalized block would accept a cleared field, because
1754
+ * `monitoringOf` replaces it with the documented default.
1755
+ * @param {{ selfCheckSeconds: number, attentionSeconds: number, repeatFailureThreshold: number }} monitoring - the block as the operator typed it.
1643
1756
  * @returns {Promise<{ ok: boolean, error?: unknown }>} outcome.
1644
1757
  */
1645
1758
  async saveMonitoring(monitoring) {
1646
- const normalized = monitoringOf({ monitoring });
1647
- const problems = precheckMonitoring(normalized);
1759
+ const problems = precheckMonitoring(monitoring);
1648
1760
  if (problems.length > 0) {
1649
1761
  notify("error", `未保存:${problems.join(";")}`);
1650
1762
  return { ok: false, problems };
1651
1763
  }
1764
+ const normalized = monitoringOf({ monitoring });
1652
1765
  return await track("monitoring", async () => {
1653
1766
  try {
1654
1767
  const body = await api.putMonitoring(normalized);
@@ -2550,14 +2663,22 @@ window.__ModuleLoader__.load({
2550
2663
  }
2551
2664
  function MonitoringCard({ store, snapshot }) {
2552
2665
  const draft = snapshot.draft;
2553
- const monitoring = monitoringOf(draft);
2666
+ const raw = monitoringDraftOf(draft);
2554
2667
  const saved = monitoringOf(snapshot.settings);
2555
2668
  const [saving, setSaving] = (0, import_react.useState)(false);
2556
- const problems = precheckMonitoring(monitoring);
2557
- const dirty = monitoring.selfCheckSeconds !== saved.selfCheckSeconds || monitoring.attentionSeconds !== saved.attentionSeconds;
2558
- const edit = (field, raw) => {
2669
+ const problems = precheckMonitoring(raw);
2670
+ const dirty = raw.selfCheckSeconds !== saved.selfCheckSeconds || raw.attentionSeconds !== saved.attentionSeconds || raw.repeatFailureThreshold !== saved.repeatFailureThreshold;
2671
+ const edit = (field, rawMinutes) => {
2559
2672
  store.editDraft((current) => {
2560
- current.monitoring = { ...monitoringOf(current), [field]: minutesToSeconds(raw) };
2673
+ current.monitoring = { ...monitoringDraftOf(current), [field]: minutesToSeconds(rawMinutes) };
2674
+ });
2675
+ };
2676
+ const editFailureCount = (value) => {
2677
+ store.editDraft((current) => {
2678
+ current.monitoring = {
2679
+ ...monitoringDraftOf(current),
2680
+ repeatFailureThreshold: value === "" ? "" : Number(value)
2681
+ };
2561
2682
  });
2562
2683
  };
2563
2684
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshdg-card", "data-dshdg-monitoring": "", children: [
@@ -2572,7 +2693,7 @@ window.__ModuleLoader__.load({
2572
2693
  {
2573
2694
  label: "程序自检间隔(分钟)",
2574
2695
  htmlFor: "dshdg-monitoring-selfcheck",
2575
- hint: `${LIMITS.selfCheckSecondsMin / 60}–${LIMITS.selfCheckSecondsMax / 60} 分钟;存成整秒(当前 ${monitoring.selfCheckSeconds} 秒)`,
2696
+ hint: `${LIMITS.selfCheckSecondsMin / 60}–${LIMITS.selfCheckSecondsMax / 60} 分钟;存成整秒(当前 ${raw.selfCheckSeconds === "" ? "未填" : `${raw.selfCheckSeconds} 秒`})`,
2576
2697
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2577
2698
  "input",
2578
2699
  {
@@ -2582,10 +2703,10 @@ window.__ModuleLoader__.load({
2582
2703
  min: LIMITS.selfCheckSecondsMin / 60,
2583
2704
  max: LIMITS.selfCheckSecondsMax / 60,
2584
2705
  step: 0.5,
2585
- value: String(Number.isFinite(secondsToMinutes(monitoring.selfCheckSeconds)) ? secondsToMinutes(monitoring.selfCheckSeconds) : ""),
2706
+ value: String(Number.isFinite(secondsToMinutes(raw.selfCheckSeconds)) ? secondsToMinutes(raw.selfCheckSeconds) : ""),
2586
2707
  onChange: (event) => {
2587
- const raw = event.target.value;
2588
- edit("selfCheckSeconds", raw === "" ? "" : raw);
2708
+ const value = event.target.value;
2709
+ edit("selfCheckSeconds", value === "" ? "" : value);
2589
2710
  }
2590
2711
  }
2591
2712
  )
@@ -2596,7 +2717,7 @@ window.__ModuleLoader__.load({
2596
2717
  {
2597
2718
  label: "提醒你的间隔(分钟)",
2598
2719
  htmlFor: "dshdg-monitoring-attention",
2599
- hint: `${LIMITS.attentionSecondsMin / 60}–${LIMITS.attentionSecondsMax / 60} 分钟,且必须大于自检间隔;存成整秒(当前 ${monitoring.attentionSeconds} 秒)`,
2720
+ hint: `${LIMITS.attentionSecondsMin / 60}–${LIMITS.attentionSecondsMax / 60} 分钟,且必须大于自检间隔;存成整秒(当前 ${raw.attentionSeconds === "" ? "未填" : `${raw.attentionSeconds} 秒`})`,
2600
2721
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2601
2722
  "input",
2602
2723
  {
@@ -2606,10 +2727,33 @@ window.__ModuleLoader__.load({
2606
2727
  min: LIMITS.attentionSecondsMin / 60,
2607
2728
  max: LIMITS.attentionSecondsMax / 60,
2608
2729
  step: 0.5,
2609
- value: String(Number.isFinite(secondsToMinutes(monitoring.attentionSeconds)) ? secondsToMinutes(monitoring.attentionSeconds) : ""),
2730
+ value: String(Number.isFinite(secondsToMinutes(raw.attentionSeconds)) ? secondsToMinutes(raw.attentionSeconds) : ""),
2731
+ onChange: (event) => {
2732
+ const value = event.target.value;
2733
+ edit("attentionSeconds", value === "" ? "" : value);
2734
+ }
2735
+ }
2736
+ )
2737
+ }
2738
+ ),
2739
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2740
+ Field,
2741
+ {
2742
+ label: "重复失败提醒(次)",
2743
+ htmlFor: "dshdg-monitoring-repeat",
2744
+ hint: `同一工具、同一操作、同一失败连续这么多次时提醒一次;${LIMITS.repeatFailureThresholdMin} 表示关闭(当前 ${raw.repeatFailureThreshold === "" ? "未填" : `${raw.repeatFailureThreshold} 次`})`,
2745
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2746
+ "input",
2747
+ {
2748
+ id: "dshdg-monitoring-repeat",
2749
+ type: "number",
2750
+ inputMode: "numeric",
2751
+ min: LIMITS.repeatFailureThresholdMin,
2752
+ max: LIMITS.repeatFailureThresholdMax,
2753
+ step: 1,
2754
+ value: String(raw.repeatFailureThreshold),
2610
2755
  onChange: (event) => {
2611
- const raw = event.target.value;
2612
- edit("attentionSeconds", raw === "" ? "" : raw);
2756
+ editFailureCount(event.target.value);
2613
2757
  }
2614
2758
  }
2615
2759
  )
@@ -2620,6 +2764,11 @@ window.__ModuleLoader__.load({
2620
2764
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ul", { className: "dshdg-hint", children: [
2621
2765
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: "「没有新进展」本身不等于失败:插件不会因为安静、也不会因为单个工具跑得久就判定任务失败。" }),
2622
2766
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: "只有确实没有进展、并且超过「提醒你的间隔」之后,才会把这件事报告给派工方。" }),
2767
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
2768
+ "重复失败提醒与上面两个间隔",
2769
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "互相独立" }),
2770
+ ":它数的是同一操作连续失败了几次,而不是安静了多久,所以正在忙碌地反复失败也会被提醒。它只提醒一次,不会自动取消任务、更换模型或改动超时。"
2771
+ ] }),
2623
2772
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
2624
2773
  "修改只影响",
2625
2774
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "之后新提交" }),
@@ -2636,7 +2785,7 @@ window.__ModuleLoader__.load({
2636
2785
  onClick: async () => {
2637
2786
  setSaving(true);
2638
2787
  try {
2639
- await store.saveMonitoring(monitoring);
2788
+ await store.saveMonitoring(monitoringDraftOf(draft));
2640
2789
  } finally {
2641
2790
  setSaving(false);
2642
2791
  }
@@ -2815,6 +2964,45 @@ window.__ModuleLoader__.load({
2815
2964
  ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshdg-faint", children: "关闭时不创建审查代理,也不发出任何审查请求。" })
2816
2965
  ] });
2817
2966
  }
2967
+ function ReviewNoteDetail({ task }) {
2968
+ const [open, setOpen] = (0, import_react.useState)(false);
2969
+ const [copyState, setCopyState] = (0, import_react.useState)(null);
2970
+ const preview = reviewNotePreview(task);
2971
+ if (preview === null) return "未记录(插件不会自行验收)";
2972
+ if (preview.omitted === true) {
2973
+ return `审查意见已保存(${preview.chars} 字符),当前读取结果省略正文;可在结果详情中按需读取全文。`;
2974
+ }
2975
+ if (preview.chars === 0) return "(无审查意见正文)";
2976
+ const full = typeof task?.hostAcceptance?.note === "string" ? task.hostAcceptance.note : "";
2977
+ const copy = () => {
2978
+ const clipboard = globalThis.navigator?.clipboard;
2979
+ if (typeof clipboard?.writeText !== "function") {
2980
+ setCopyState("复制失败:浏览器不支持写入剪贴板,请手动选择文本。");
2981
+ return;
2982
+ }
2983
+ void Promise.resolve().then(() => clipboard.writeText(full)).then(
2984
+ () => {
2985
+ setCopyState("已复制完整审查意见");
2986
+ },
2987
+ () => {
2988
+ setCopyState("复制失败:浏览器未允许写入剪贴板,请手动选择文本。");
2989
+ }
2990
+ );
2991
+ };
2992
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshdg-note", children: [
2993
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshdg-row", children: [
2994
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshdg-hint", children: [
2995
+ preview.chars,
2996
+ " 字符"
2997
+ ] }),
2998
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshdg-spacer" }),
2999
+ preview.chars > REVIEW_NOTE_PREVIEW_CHARS ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => setOpen(!open), children: open ? "收起" : "展开全文" }) : null,
3000
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: copy, children: "复制全文" })
3001
+ ] }),
3002
+ copyState === null ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshdg-hint", children: copyState }),
3003
+ open || preview.chars <= REVIEW_NOTE_PREVIEW_CHARS ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "dshdg-mono dshdg-note-full", children: full }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "dshdg-mono dshdg-note-preview", children: `${preview.text}…` })
3004
+ ] });
3005
+ }
2818
3006
  function TaskDetail({ store, task }) {
2819
3007
  const outcome = taskOutcome(task);
2820
3008
  const files = changedFiles(task);
@@ -2829,11 +3017,11 @@ window.__ModuleLoader__.load({
2829
3017
  const permission = permissionSummary(task);
2830
3018
  const pending = pendingPermission(task);
2831
3019
  const evidence = Array.isArray(task.permission?.evidence) ? task.permission.evidence : [];
2832
- const badgeTone = isAwaitingPermission(task) ? "warn" : task.state === "awaiting-host-review" ? "warn" : task.state === "failed" ? "warn" : "off";
3020
+ const badgeTone = isAwaitingPermission(task) ? "warn" : outcome.tone;
2833
3021
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshdg-item", children: [
2834
3022
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshdg-item-head", children: [
2835
3023
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: task.title || task.taskId }),
2836
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { tone: badgeTone, children: taskStateLabel(task.state) }),
3024
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { tone: badgeTone, children: outcome.label }),
2837
3025
  isAwaitingPermission(task) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { tone: "warn", children: PERMISSION_STATE_LABELS.pending }) : null,
2838
3026
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshdg-spacer" }),
2839
3027
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -2869,7 +3057,7 @@ window.__ModuleLoader__.load({
2869
3057
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "对话" }),
2870
3058
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: execution?.conversation === null || execution?.conversation === void 0 ? task.continueFromTaskId === null || task.continueFromTaskId === void 0 ? "(未放置对话)" : `(未放置对话;本任务声明续接 ${task.continueFromTaskId})` : execution.conversation.reused === true ? `续接 ${execution.conversation.continuedFromTaskId ?? "上一任务"} · 工作区 ${execution.conversation.workspaceId ?? "—"}` : `新开 · 工作区 ${execution.conversation.workspaceId ?? "—"}` }),
2871
3059
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "阶段" }),
2872
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: taskPhaseLabel(task.phase) }),
3060
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: outcome.decided || task.state === "awaiting-host-review" ? "执行已结束" : taskPhaseLabel(task.phase) }),
2873
3061
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "最近进展" }),
2874
3062
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: activity === null || activity.lastActivityAt === null ? "未采集到" : `${formatTime(activity.lastActivityAt)}(距上次进展 ${formatDuration(activity.idleForMs)})` }),
2875
3063
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "当前工具" }),
@@ -2878,6 +3066,8 @@ window.__ModuleLoader__.load({
2878
3066
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: activity === null || activity.selfCheck === null || activity.selfCheck.verdict === null ? activity === null ? "未采集到" : "尚未触发程序自检(安静时间还没到自检间隔)" : `${SELF_CHECK_LABELS[activity.selfCheck.verdict] ?? activity.selfCheck.verdict}` + (activity.selfCheck.checkedAt === null ? "" : `(${formatTime(activity.selfCheck.checkedAt)})`) }),
2879
3067
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "监控间隔" }),
2880
3068
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: activity === null || activity.selfCheckSeconds === null ? "未采集到" : `自检 ${formatDuration(activity.selfCheckSeconds * 1e3)} · 提醒 ${formatDuration((activity.attentionSeconds ?? 0) * 1e3)}` }),
3069
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "重复失败提醒" }),
3070
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: repeatFailureLine(activity) }),
2881
3071
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "创建" }),
2882
3072
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: formatTime(task.createdAt) }),
2883
3073
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "结束" }),
@@ -2890,7 +3080,9 @@ window.__ModuleLoader__.load({
2890
3080
  review?.verdict === null || review?.verdict === void 0 ? "" : ` · ${REVIEW_VERDICT_LABELS[review.verdict] ?? review.verdict}`
2891
3081
  ] }),
2892
3082
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "宿主验收" }),
2893
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: task.hostAcceptance === null || task.hostAcceptance === void 0 ? "未记录(插件不会自行验收)" : "已由宿主记录" })
3083
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: hostReviewLine(task, formatTime) }),
3084
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "完整审查意见" }),
3085
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReviewNoteDetail, { task }, task.taskId) })
2894
3086
  ] }),
2895
3087
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: "改动文件" }),
2896
3088
  files === null ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshdg-faint", children: "宿主未回报可识别的文件摘要,请以下方原始 diff 为准。" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "dshdg-mono", children: files.map((file) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: file }, file)) }),
@@ -2936,37 +3128,55 @@ window.__ModuleLoader__.load({
2936
3128
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshdg-hint", children: "重试前请确认顶部的本机调用开关已开启,然后在 MCP 宿主重新提交任务。本界面不会直接提交任务。" })
2937
3129
  ] });
2938
3130
  }
2939
- function useTaskAutoRefresh({ store, snapshot, intervalMs = 5e3 }) {
2940
- const live = hasLiveTasks(snapshot.tasks) || snapshot.taskDetail !== null && isLiveTask(snapshot.taskDetail);
2941
- const liveRef = (0, import_react.useRef)(live);
2942
- liveRef.current = live;
3131
+ function useTaskAutoRefresh({ store, snapshot, intervalMs = RECORD_REFRESH_INTERVAL_MS }) {
3132
+ const plan = recordRefreshPlan({
3133
+ tasks: snapshot.tasks,
3134
+ selectedTask: snapshot.taskDetail,
3135
+ visible: globalThis.document?.hidden !== true,
3136
+ loading: snapshot.loading?.tasks === true
3137
+ });
3138
+ const changing = hasChangingRecords([
3139
+ ...Array.isArray(snapshot.tasks) ? snapshot.tasks : [],
3140
+ ...snapshot.taskDetail === null || snapshot.taskDetail === void 0 ? [] : [snapshot.taskDetail]
3141
+ ]);
3142
+ const changingRef = (0, import_react.useRef)(changing);
3143
+ changingRef.current = changing;
3144
+ const [refreshError, setRefreshError] = (0, import_react.useState)(null);
2943
3145
  (0, import_react.useEffect)(() => {
2944
- if (!live) return void 0;
3146
+ if (!changing) return void 0;
2945
3147
  let timer = null;
2946
3148
  let disposed = false;
3149
+ let inFlight = false;
2947
3150
  const schedule = () => {
2948
3151
  if (disposed) return;
2949
3152
  if (timer !== null) clearTimeout(timer);
2950
3153
  timer = setTimeout(tick, intervalMs);
2951
3154
  timer.unref?.();
2952
3155
  };
3156
+ const read = () => {
3157
+ if (inFlight) return;
3158
+ inFlight = true;
3159
+ setRefreshError(null);
3160
+ void store.refreshTasks("auto").then((result) => {
3161
+ if (result?.ok === false) setRefreshError(describeError(result.error));
3162
+ }).finally(() => {
3163
+ inFlight = false;
3164
+ schedule();
3165
+ });
3166
+ };
2953
3167
  const tick = () => {
2954
3168
  timer = null;
2955
3169
  if (disposed) return;
2956
3170
  if (globalThis.document?.hidden === true) return;
2957
- if (!liveRef.current) return;
2958
- void store.refreshTasks("auto").finally(() => {
2959
- schedule();
2960
- });
3171
+ if (!changingRef.current) return;
3172
+ read();
2961
3173
  };
2962
3174
  const onVisibility = () => {
2963
3175
  if (globalThis.document?.hidden === true) return;
2964
- if (!liveRef.current) return;
3176
+ if (!changingRef.current) return;
2965
3177
  if (timer !== null) clearTimeout(timer);
2966
3178
  timer = null;
2967
- void store.refreshTasks("auto").finally(() => {
2968
- schedule();
2969
- });
3179
+ read();
2970
3180
  };
2971
3181
  schedule();
2972
3182
  const doc = globalThis.document;
@@ -2977,29 +3187,56 @@ window.__ModuleLoader__.load({
2977
3187
  timer = null;
2978
3188
  doc?.removeEventListener?.("visibilitychange", onVisibility);
2979
3189
  };
2980
- }, [store, live, intervalMs]);
3190
+ }, [store, changing, intervalMs]);
3191
+ return { ...plan, refreshError };
3192
+ }
3193
+ function TaskListNote({ task, onOpen }) {
3194
+ const preview = reviewNotePreview(task);
3195
+ if (preview === null) return null;
3196
+ if (preview.omitted === true) {
3197
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "dshdg-hint", children: [
3198
+ `审查意见已保存(${preview.chars} 字符),此处省略正文。`,
3199
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshdg-link", onClick: onOpen, children: "查看完整审查意见" })
3200
+ ] });
3201
+ }
3202
+ if (preview.chars === 0) return null;
3203
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "dshdg-hint dshdg-note-preview", children: [
3204
+ `审查意见:${preview.text}${preview.truncated ? "…" : ""}(${preview.chars} 字符)`,
3205
+ preview.truncated ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshdg-link", onClick: onOpen, children: "查看完整审查意见" }) : null
3206
+ ] });
2981
3207
  }
2982
3208
  function TasksPanel({ store, snapshot }) {
2983
3209
  const tasks = snapshot.tasks ?? [];
2984
3210
  const detail = snapshot.taskDetail;
2985
- useTaskAutoRefresh({ store, snapshot });
3211
+ const plan = useTaskAutoRefresh({ store, snapshot });
2986
3212
  const liveCount = tasks.filter(isLiveTask).length;
3213
+ const changing = hasChangingRecords([
3214
+ ...tasks,
3215
+ ...detail === null || detail === void 0 ? [] : [detail]
3216
+ ]);
2987
3217
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshdg-panel", children: [
2988
3218
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshdg-row", children: [
2989
3219
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshdg-muted", children: "这里只记录执行事实。执行完成不等于被接受:“等待宿主审查”要由宿主(例如 Codex)单独给出结论。" }),
2990
3220
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshdg-spacer" }),
2991
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshdg-hint", children: liveCount === 0 && !(detail !== null && isLiveTask(detail)) ? "当前没有运行中的任务,不会自动刷新。" : `有 ${liveCount} 个进行中的任务,页面可见时每 5 秒自动刷新一次(只读,不调用模型)。` }),
3221
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshdg-hint", children: changing !== true ? "当前没有会变化的记录,不会自动刷新。" : `${liveCount > 0 ? `有 ${liveCount} 个进行中的任务;` : ""}有记录可能变化(待审或结论保存中),页面可见时每 5 秒只读刷新一次(不调用模型)。` }),
2992
3222
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: snapshot.loading?.tasks === true, onClick: () => {
2993
3223
  void store.refreshTasks("manual");
2994
3224
  }, children: snapshot.loading?.tasks === true ? "读取中…" : "刷新" })
2995
3225
  ] }),
3226
+ plan.refreshError !== null && plan.refreshError !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "dshdg-warn", children: [
3227
+ "自动刷新失败(",
3228
+ String(plan.refreshError),
3229
+ "),下面仍是上次读取的内容;可点“刷新”重试。"
3230
+ ] }) : null,
2996
3231
  tasks.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshdg-faint", children: "还没有任务记录。" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshdg-list", children: tasks.map((task) => {
2997
3232
  const progress = taskProgress(task);
3233
+ const outcome = taskOutcome(task);
3234
+ const phase = outcome.phaseLabel;
2998
3235
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshdg-item", children: [
2999
3236
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshdg-item-head", children: [
3000
3237
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: task.title || task.taskId }),
3001
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { tone: isAwaitingPermission(task) ? "warn" : task.state === "awaiting-host-review" ? "warn" : task.state === "failed" ? "warn" : "off", children: taskStateLabel(task.state) }),
3002
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { tone: progress.tone, children: taskPhaseLabel(task.phase) }),
3238
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { tone: isAwaitingPermission(task) ? "warn" : outcome.tone, children: outcome.label }),
3239
+ phase === null ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { tone: progress.tone, children: phase }),
3003
3240
  isAwaitingPermission(task) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { tone: "warn", children: PERMISSION_STATE_LABELS.pending }) : null,
3004
3241
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshdg-mono dshdg-faint", children: [
3005
3242
  task.config?.worker?.model ?? task.effective?.worker?.model ?? "—",
@@ -3033,6 +3270,9 @@ window.__ModuleLoader__.load({
3033
3270
  )
3034
3271
  ] }),
3035
3272
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshdg-hint", children: progress.headline }),
3273
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TaskListNote, { task, onOpen: () => {
3274
+ void store.openTask(task.taskId);
3275
+ } }),
3036
3276
  isAwaitingPermission(task) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshdg-hint", children: permissionSummary(task).note }) : null
3037
3277
  ] }, task.taskId);
3038
3278
  }) }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-taskbridge",
3
- "version": "1.3.2",
3
+ "version": "1.4.1",
4
4
  "description": "让 Claude Code 或 Codex 指挥 DSH 完成任务;在 DSH 插件中配置 API、执行模型、思考强度、权限审批与集中审查。",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -73,7 +73,10 @@
73
73
  "docs/taskdispatch-upgrade.md",
74
74
  "docs/claude-code.md",
75
75
  "docs/plugin-market.md",
76
- "docs/taskbridge-upgrade.md"
76
+ "docs/taskbridge-upgrade.md",
77
+ "docs/releases/1.4.0.zh.md",
78
+ "docs/releases/1.4.0-token-benchmark.zh.md",
79
+ "docs/releases/1.4.1.zh.md"
77
80
  ],
78
81
  "dsh": {
79
82
  "manifestVersion": 1,
@@ -123,7 +126,8 @@
123
126
  "codex-agent": "node bin/dsh-delegate-codex-agent.js",
124
127
  "control": "node bin/dsh-delegate-control.js",
125
128
  "pack:dry": "npm pack --dry-run",
126
- "build:market": "node scripts/build-plugin-market.mjs"
129
+ "build:market": "node scripts/build-plugin-market.mjs",
130
+ "verify:silent-wait": "node scripts/verify-silent-wait.mjs --duration-seconds 1200"
127
131
  },
128
132
  "keywords": [
129
133
  "dsh",