ralphflow-dsh 2.3.1 → 2.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.
Files changed (87) hide show
  1. package/README.md +48 -22
  2. package/graphs/codewiki/format.md +362 -0
  3. package/graphs/codewiki/graph.yaml +39 -0
  4. package/graphs/codewiki/nodes/assemble.md +24 -0
  5. package/graphs/codewiki/nodes/core-pages.md +17 -0
  6. package/graphs/codewiki/nodes/module-pages.md +18 -0
  7. package/graphs/codewiki/nodes/operations-pages.md +18 -0
  8. package/graphs/codewiki/nodes/survey.md +22 -0
  9. package/lib/asset-path.d.ts +59 -0
  10. package/lib/asset-path.js +181 -0
  11. package/lib/assets.d.ts +42 -0
  12. package/lib/assets.js +86 -0
  13. package/lib/client/phase.d.ts +29 -0
  14. package/lib/client/phase.js +86 -0
  15. package/lib/client/selection.d.ts +28 -0
  16. package/lib/client/selection.js +9 -0
  17. package/lib/client/status-source.d.ts +3 -1
  18. package/lib/client/status-source.js +3 -2
  19. package/lib/client/status.js +49 -13
  20. package/lib/client/viewer.d.ts +18 -0
  21. package/lib/client/viewer.js +540 -0
  22. package/lib/client.js +1159 -64
  23. package/lib/engine.d.ts +111 -47
  24. package/lib/engine.js +473 -320
  25. package/lib/facade.d.ts +175 -0
  26. package/lib/facade.js +553 -0
  27. package/lib/graph/agent-registry.d.ts +4 -0
  28. package/lib/graph/agent-registry.js +20 -0
  29. package/lib/graph/asset.d.ts +47 -0
  30. package/lib/graph/asset.js +276 -0
  31. package/lib/graph/assets.d.ts +47 -0
  32. package/lib/graph/assets.js +224 -0
  33. package/lib/graph/branches.d.ts +9 -0
  34. package/lib/graph/branches.js +13 -0
  35. package/lib/graph/check.d.ts +23 -0
  36. package/lib/graph/check.js +46 -0
  37. package/lib/graph/engine.d.ts +55 -0
  38. package/lib/graph/engine.js +2002 -0
  39. package/lib/graph/report.d.ts +9 -0
  40. package/lib/graph/report.js +117 -0
  41. package/lib/graph/state.d.ts +244 -0
  42. package/lib/graph/state.js +358 -0
  43. package/lib/graph/workspace.d.ts +68 -0
  44. package/lib/graph/workspace.js +262 -0
  45. package/lib/index.d.ts +11 -1
  46. package/lib/index.js +156 -49
  47. package/lib/owner.d.ts +34 -0
  48. package/lib/owner.js +49 -0
  49. package/lib/paths.d.ts +12 -0
  50. package/lib/paths.js +44 -0
  51. package/lib/pause.d.ts +12 -0
  52. package/lib/pause.js +19 -0
  53. package/lib/skills.d.ts +17 -30
  54. package/lib/skills.js +85 -21
  55. package/lib/status-contract.d.ts +114 -1
  56. package/lib/status-contract.js +106 -4
  57. package/lib/status-service.d.ts +5 -1
  58. package/lib/status-service.js +8 -1
  59. package/lib/tools.d.ts +14 -6
  60. package/lib/tools.js +88 -60
  61. package/lib/unfinished.d.ts +11 -0
  62. package/lib/unfinished.js +18 -0
  63. package/lib/verifier-preset.d.ts +40 -0
  64. package/lib/verifier-preset.js +126 -0
  65. package/lib/verify.d.ts +82 -13
  66. package/lib/verify.js +382 -95
  67. package/package.json +50 -38
  68. package/skills/ralphflow-create/SKILL.md +32 -0
  69. package/skills/ralphflow-create/graph-authoring.md +85 -0
  70. package/skills/ralphflow-create/matt/LICENSE +21 -0
  71. package/skills/ralphflow-create/matt/SHA256SUMS +6 -0
  72. package/skills/ralphflow-create/matt/SKILL-MECHANICS.md +22 -0
  73. package/skills/ralphflow-create/matt/SOURCE.md +12 -0
  74. package/skills/ralphflow-create/matt/grilling.md +30 -0
  75. package/skills/ralphflow-create/matt/to-spec.md +75 -0
  76. package/skills/ralphflow-create/matt/to-tickets.md +105 -0
  77. package/skills/ralphflow-create/matt/writing-for-agents.md +81 -0
  78. package/skills/ralphflow-create/ralphflow-authoring.md +31 -0
  79. package/skills/ralphflow-create/testing-workflow.md +60 -0
  80. package/{references → skills/ralphflow-create}/workflow-authoring.md +25 -5
  81. package/workflows/create-graph/steps/graph.md +17 -0
  82. package/workflows/create-graph/workflow.yaml +77 -0
  83. package/workflows/loop/workflow.yaml +23 -0
  84. package/lib/create.d.ts +0 -2
  85. package/lib/create.js +0 -17
  86. package/workflows/loop.yaml +0 -45
  87. /package/workflows/{spec.yaml → spec/workflow.yaml} +0 -0
@@ -1,16 +1,18 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useId, useRef, useState } from "react";
3
3
  import { StateDot, useDismissOnOutsidePointer } from "@deepseek-ai/dsh-client-ui-primitives";
4
+ import { registerViewerTab } from "./viewer.js";
4
5
  import { statusRemote } from "../status-contract.js";
5
6
  import { createStatusSource } from "./status-source.js";
6
7
  const labels = {
7
8
  executing: "待交卷", verifying: "独立验证中", gate: "等待你放行", paused: "已暂停",
8
- switching: "切换步骤中", done: "已完成", cancelled: "已取消", unavailable: "状态不可用",
9
+ switching: "切换步骤中", done: "已完成", cancelled: "已取消", failed: "失败", unavailable: "状态不可用",
9
10
  };
10
11
  const votes = { pending: "等待验证", running: "验证中", passed: "通过", failed: "未通过", infra: "验证者故障" };
12
+ const checks = { passed: "已通过", failed: "未通过", infra: "验证未跑成", pending: "待验证", skipped: "已跳过" };
11
13
  /** The only stages that need the user to act. The input-area prompt appears for these and only these. */
12
14
  const actionStages = new Set(["gate", "paused"]);
13
- const terminalStages = new Set(["done", "cancelled"]);
15
+ const terminalStages = new Set(["done", "cancelled", "failed"]);
14
16
  const whole = (s) => s;
15
17
  /**
16
18
  * Colors, radii, shadows, and typography use installed dsh theme tokens.
@@ -21,6 +23,7 @@ const css = `
21
23
  .ralphflow-status { position: relative; display: inline-flex; align-items: center; gap: 4px; max-width: min(320px, 38vw); min-height: 28px; padding: 3px 2px; border: 0; background: none; color: var(--dsw-alias-label-tertiary); font: inherit; font-size: var(--dsw-font-xxs-12-font-size); line-height: var(--dsw-font-xxs-12-line-height); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
22
24
  .ralphflow-status:hover, .ralphflow-status:focus-visible { color: var(--dsw-alias-label-secondary); }
23
25
  .ralphflow-status-dot { flex: none; }
26
+ .ralphflow-status > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
24
27
  .ralphflow-status-popover { position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, calc(100vw - 32px)); max-height: min(480px, 100vh - 140px); z-index: 100; box-sizing: border-box; display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 12px; overflow: auto; --dsw-elevation-stroke-color: var(--dsw-alias-border-l1); border: 0; border-radius: var(--dsw-radius-lg); background: var(--dsw-alias-bg-layer-2); box-shadow: var(--dsw-elevation-prominent); color: var(--dsw-alias-label-primary); font-size: var(--dsh-content-font-size-secondary); line-height: var(--dsw-font-xs-13-line-height); }
25
28
  .ralphflow-status-popover-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
26
29
  .ralphflow-status-popover-title { min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@@ -34,6 +37,7 @@ const css = `
34
37
  .ralphflow-status-steps li { overflow-wrap: anywhere; }
35
38
  .ralphflow-status-votes { margin: 4px 0; padding-left: 20px; }
36
39
  .ralphflow-status-votes li { overflow-wrap: anywhere; }
40
+ .ralphflow-status-vote-check { color: var(--dsw-alias-label-tertiary); }
37
41
  .ralphflow-status-recent { margin: 4px 0; padding-left: 20px; }
38
42
  .ralphflow-status-recent li { overflow-wrap: anywhere; }
39
43
  .ralphflow-status-report { margin: 0; overflow-wrap: anywhere; }
@@ -41,6 +45,9 @@ const css = `
41
45
  .ralphflow-status-action-dock { width: calc(100% - 2 * var(--dsh-composer-side-clearance) - 4 * var(--dsh-composer-dock-inset)); margin: 0 auto; }
42
46
  .ralphflow-status-action { box-sizing: border-box; width: 100%; max-width: calc(var(--dsh-composer-card-max-width) - 4 * var(--dsh-composer-dock-inset)); margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 4px 12px; border: 0; border-radius: var(--dsw-radius-md); background: var(--dsw-alias-bg-layer-2); box-shadow: var(--dsw-elevation-panel); color: var(--dsw-alias-label-primary); font-size: var(--dsh-content-font-size-secondary); line-height: var(--dsw-font-xs-13-line-height); min-height: 36px; --dsw-elevation-stroke-color: var(--dsw-alias-border-l1); }
43
47
  .ralphflow-status-action-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
48
+ .ralphflow-status-pause { flex: none; margin-left: auto; padding: 3px 10px; border: 1px solid var(--dsw-alias-border-l1); border-radius: var(--dsw-radius-sm); background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); font: inherit; cursor: pointer; }
49
+ .ralphflow-status-pause:hover:not(:disabled) { background: var(--dsw-alias-bg-module-platform); }
50
+ .ralphflow-status-pause:disabled { opacity: .6; cursor: default; }
44
51
  /* The timeline broadcast row keeps its record role; only its radius/font move to tokens. */
45
52
  .ralphflow-notice { margin: 8px 0; padding: 8px 12px; border-radius: var(--dsw-radius-sm); background: var(--dsw-alias-bg-module-platform); color: inherit; font-size: var(--dsh-content-font-size-secondary); line-height: 1.6; overflow-wrap: anywhere; }
46
53
  .ralphflow-notice > summary { cursor: pointer; }
@@ -58,7 +65,7 @@ export function injectStatusCss() {
58
65
  injectStatusCss();
59
66
  function StatusDot({ stage }) {
60
67
  const state = stage === "done" ? "done" : stage === "gate" || stage === "paused" ? "warning"
61
- : stage === "unavailable" ? "error" : stage === "cancelled" ? "idle" : "ongoing";
68
+ : stage === "unavailable" || stage === "failed" ? "error" : stage === "cancelled" ? "idle" : "ongoing";
62
69
  return _jsx(StateDot, { state: state, className: "ralphflow-status-dot" });
63
70
  }
64
71
  /** The single persistent location: bare text + dot, no container, dsh jobs-trigger style. */
@@ -76,7 +83,9 @@ function WorkflowStatusControl({ useWorkflowStatus }) {
76
83
  return _jsxs("div", { ref: root, style: { position: "relative" }, onKeyDown: (e) => { if (e.key === "Escape") {
77
84
  setOpened(false);
78
85
  trigger.current?.focus();
79
- } }, children: [_jsxs("button", { ref: trigger, type: "button", className: "ralphflow-status", "data-ralphflow-status": status.id, "data-stage": status.stage, "data-connection": connection, "aria-expanded": opened, "aria-controls": opened ? id : undefined, "aria-label": "\u67E5\u770B\u5DE5\u4F5C\u6D41\u72B6\u6001", onClick: () => setOpened((v) => !v), title: `${status.workflow} · ${status.step} · ${label}`, children: [_jsx(StatusDot, { stage: status.stage }), _jsxs("span", { children: [terminal ? `${label} · 报告` : `${status.step} · ${status.stage === "paused" ? `失败 ${status.failures} 次` : `第 ${status.failures + 1} 轮`} · ${label}`, connection === "live" ? "" : " · 同步中"] })] }), opened ? _jsx(WorkflowStatusPopover, { id: id, useWorkflowStatus: useWorkflowStatus }) : null] });
86
+ } }, children: [_jsxs("button", { ref: trigger, type: "button", className: "ralphflow-status", "data-ralphflow-status": status.id, "data-stage": status.stage, "data-connection": connection, "aria-expanded": opened, "aria-controls": opened ? id : undefined, "aria-label": "\u67E5\u770B\u5DE5\u4F5C\u6D41\u72B6\u6001", onClick: () => setOpened((v) => !v), title: `${status.workflow} · ${status.kind === "graph" ? (status.graph?.current?.name ?? status.graph?.phase ?? "Graph") : status.step} · ${label}`, children: [_jsx(StatusDot, { stage: status.stage }), _jsxs("span", { children: [status.kind === "graph"
87
+ ? `${status.graph?.phase ?? label}${status.graph?.counts ? ` · ${status.graph.counts.completed}/${status.graph.counts.total}` : ""}${connection === "live" ? "" : " · 同步中"}`
88
+ : terminal ? `${label} · 报告` : `${status.step} · ${status.stage === "paused" ? `返工 ${status.failures} 次` : `第 ${status.failures + 1} 轮`} · ${label}`, connection === "live" ? "" : " · 同步中"] })] }), opened ? _jsx(WorkflowStatusPopover, { id: id, useWorkflowStatus: useWorkflowStatus }) : null] });
80
89
  }
81
90
  function WorkflowStatusPopover({ id, useWorkflowStatus }) {
82
91
  const { status, connection, error } = useWorkflowStatus(whole);
@@ -86,15 +95,36 @@ function WorkflowStatusPopover({ id, useWorkflowStatus }) {
86
95
  const returned = status.votes.filter((v) => v.status === "passed" || v.status === "failed" || v.status === "infra").length;
87
96
  // The internal failure budget is noise until it is nearly spent; only then surface n/m.
88
97
  const nearLimit = status.maxFailures > 0 && status.failures > 0 && status.failures >= status.maxFailures * 0.8;
89
- return _jsxs("div", { id: id, className: "ralphflow-status-popover", "data-ralphflow-status-popover": true, role: "status", children: [_jsxs("div", { className: "ralphflow-status-popover-head", children: [_jsxs("span", { className: "ralphflow-status-popover-title", children: ["Ralph Flow \u00B7 ", status.workflow] }), _jsxs("span", { className: "ralphflow-status-popover-stage", children: [labels[status.stage], connection === "live" ? "" : " · 同步中"] })] }), error ? _jsxs("div", { className: "ralphflow-status-banner", "data-kind": "error", role: "status", children: ["Ralph Flow \u00B7 ", error] }) : null, connection !== "live" && !error ? _jsx("div", { className: "ralphflow-status-banner", role: "status", children: "\u6B63\u5728\u91CD\u65B0\u540C\u6B65\uFF0C\u663E\u793A\u6700\u540E\u72B6\u6001\u3002" }) : null, !terminal && nearLimit ? _jsxs("div", { className: "ralphflow-status-banner", role: "status", children: ["\u672C\u6B65\u5931\u8D25\u63A5\u8FD1\u4E0A\u9650 \u00B7 ", status.failures, "/", status.maxFailures] }) : null, !terminal && status.hint ? _jsx("div", { className: "ralphflow-status-hint", children: status.hint }) : null, !terminal ? _jsx("p", { className: "ralphflow-status-task", children: status.task }) : null, !terminal ? _jsxs("div", { className: "ralphflow-status-label", children: ["\u672C\u6B65\u5931\u8D25 ", status.failures, " \u6B21"] }) : null, !terminal && status.steps.length ? _jsxs("div", { children: [_jsx("div", { className: "ralphflow-status-label", children: "\u6B65\u9AA4" }), _jsx("ol", { className: "ralphflow-status-steps", "aria-label": "\u5DE5\u4F5C\u6D41\u6B65\u9AA4", children: status.steps.map((step) => _jsxs("li", { "aria-current": step.current ? "step" : undefined, children: [step.current ? "→ " : "", _jsx("strong", { children: step.id }), " \u00B7 ", step.description, step.failures ? ` · 失败 ${step.failures} 次` : ""] }, step.id)) })] }) : null, !terminal && status.votes.length ? _jsxs("div", { children: [_jsxs("div", { className: "ralphflow-status-label", children: ["\u672C\u8F6E\u9A8C\u8BC1 \u00B7 ", returned, "/", status.votes.length, " \u5DF2\u8FD4\u56DE"] }), _jsx("ul", { className: "ralphflow-status-votes", "aria-label": `本轮验证 · ${returned}/${status.votes.length} 已返回`, children: status.votes.map((vote) => _jsxs("li", { children: ["\u9A8C\u8BC1\u8005 ", vote.index, "/", status.votes.length, " \u00B7 ", votes[vote.status], vote.reason ? _jsx("div", { children: vote.reason }) : null] }, vote.index)) })] }) : null, !terminal && status.recent.length ? _jsxs("details", { children: [_jsx("summary", { className: "ralphflow-status-label", children: "\u6700\u8FD1\u8F68\u8FF9" }), _jsx("ul", { className: "ralphflow-status-recent", children: status.recent.map((event, index) => _jsxs("li", { children: [event.step, " \u00B7 ", event.event, event.detail ? `:${event.detail}` : ""] }, index)) })] }) : null, status.report ? _jsxs("p", { className: "ralphflow-status-report", children: ["\u62A5\u544A\uFF1A", _jsx("code", { children: status.report })] }) : null] });
98
+ return _jsxs("div", { id: id, className: "ralphflow-status-popover", "data-ralphflow-status-popover": true, role: "status", children: [_jsxs("div", { className: "ralphflow-status-popover-head", children: [_jsxs("span", { className: "ralphflow-status-popover-title", children: ["Ralph Flow \u00B7 ", status.workflow] }), _jsxs("span", { className: "ralphflow-status-popover-stage", children: [labels[status.stage], connection === "live" ? "" : " · 同步中"] })] }), error ? _jsxs("div", { className: "ralphflow-status-banner", "data-kind": "error", role: "status", children: ["Ralph Flow \u00B7 ", error] }) : null, connection !== "live" && !error ? _jsx("div", { className: "ralphflow-status-banner", role: "status", children: "\u6B63\u5728\u91CD\u65B0\u540C\u6B65\uFF0C\u663E\u793A\u6700\u540E\u72B6\u6001\u3002" }) : null, !terminal && nearLimit ? _jsxs("div", { className: "ralphflow-status-banner", role: "status", children: ["\u672C\u6B65\u8FD4\u5DE5\u63A5\u8FD1\u4E0A\u9650 \u00B7 ", status.failures, "/", status.maxFailures] }) : null, !terminal && status.hint ? _jsx("div", { className: "ralphflow-status-hint", children: status.hint }) : null, !terminal ? _jsx("p", { className: "ralphflow-status-task", children: status.task }) : null, status.kind === "graph" && status.graph ? _jsxs("div", { children: [_jsxs("div", { className: "ralphflow-status-label", children: ["\u8282\u70B9 \u00B7 ", status.graph.counts.completed, "/", status.graph.counts.total, " \u5DF2\u5B8C\u6210", status.graph.counts.running ? ` · ${status.graph.counts.running} 在飞` : ""] }), _jsx("ol", { className: "ralphflow-status-steps", "aria-label": "Graph \u8282\u70B9", children: status.graph.nodes.map((node) => _jsxs("li", { "aria-current": node.current ? "step" : undefined, children: [node.current ? "→ " : "", _jsx("strong", { children: node.id }), " \u00B7 ", node.name, " \u00B7 ", node.label, node.check.mode !== "disabled" ? ` · CHECK ${checks[node.check.status] ?? node.check.status}` : "", node.check.reworks ? ` · 返工 ${node.check.reworks} 次` : ""] }, node.id)) }), status.graph.integration ? _jsxs("div", { className: "ralphflow-status-label", children: ["\u96C6\u6210\u5206\u652F ", status.graph.integration.branch, " \u00B7 \u5DF2\u63A5\u7EB3 ", status.graph.integration.accepted] }) : null, _jsxs("div", { className: "ralphflow-status-label", children: ["\u4EA4\u4ED8 \u00B7 \u5DF2\u4EA4\u4ED8 ", status.graph.delivery.delivered, " \u00B7 \u672A\u63A5\u7EB3 ", status.graph.delivery.unaccepted, " \u00B7 \u672A\u9A8C\u8BC1 ", status.graph.delivery.unverified, " \u00B7 \u672A\u5B8C\u6210 ", status.graph.delivery.unfinished] })] }) : null, status.kind !== "graph" && !terminal ? _jsxs("div", { className: "ralphflow-status-label", children: ["\u672C\u6B65\u8FD4\u5DE5 ", status.failures, " \u6B21"] }) : null, status.kind !== "graph" && !terminal && status.steps.length ? _jsxs("div", { children: [_jsx("div", { className: "ralphflow-status-label", children: "\u6B65\u9AA4" }), _jsx("ol", { className: "ralphflow-status-steps", "aria-label": "\u5DE5\u4F5C\u6D41\u6B65\u9AA4", children: status.steps.map((step) => _jsxs("li", { "aria-current": step.current ? "step" : undefined, children: [step.current ? "→ " : "", _jsx("strong", { children: step.id }), " \u00B7 ", step.description, step.failures ? ` · 失败 ${step.failures} 次` : ""] }, step.id)) })] }) : null, status.kind !== "graph" && !terminal && status.votes.length ? _jsxs("div", { children: [_jsxs("div", { className: "ralphflow-status-label", children: ["\u672C\u8F6E\u9A8C\u8BC1 \u00B7 ", returned, "/", status.votes.length, " \u5DF2\u8FD4\u56DE"] }), _jsx("ul", { className: "ralphflow-status-votes", "aria-label": `本轮验证 · ${returned}/${status.votes.length} 已返回`, children: status.votes.map((vote) => _jsxs("li", { children: ["\u9A8C\u8BC1\u8005 ", vote.index, "/", status.votes.length, " \u00B7 ", votes[vote.status], vote.check ? _jsxs("div", { className: "ralphflow-status-vote-check", children: ["\u68C0\u67E5\u4F9D\u636E\uFF1A", vote.check] }) : null, vote.reason ? _jsx("div", { children: vote.reason }) : null] }, vote.index)) })] }) : null, !terminal && status.recent.length ? _jsxs("details", { children: [_jsx("summary", { className: "ralphflow-status-label", children: "\u6700\u8FD1\u8F68\u8FF9" }), _jsx("ul", { className: "ralphflow-status-recent", children: status.recent.map((event, index) => _jsxs("li", { children: [event.step, " \u00B7 ", event.event, event.detail ? `:${event.detail}` : ""] }, index)) })] }) : null, status.report ? _jsxs("p", { className: "ralphflow-status-report", children: ["\u62A5\u544A\uFF1A", _jsx("code", { children: status.report })] }) : null] });
90
99
  }
91
- /** Input-area prompt: present only while the user must act, and it removes itself once handled. */
92
- function WorkflowStatusAction({ useWorkflowStatus }) {
100
+ /** Input-area prompt: present while the user must act, or while a Graph node is in flight. */
101
+ function WorkflowStatusAction({ useWorkflowStatus, pause }) {
93
102
  const { status } = useWorkflowStatus(whole);
94
- if (!status || !actionStages.has(status.stage))
103
+ const [pending, setPending] = useState(false);
104
+ const [error, setError] = useState(null);
105
+ if (!status)
106
+ return null;
107
+ const graph = status.kind === "graph" ? status.graph : undefined;
108
+ const running = graph?.status === "running" ? graph.nodes.filter((node) => node.status === "running") : [];
109
+ const backgroundRunning = running.filter((node) => node.execution === "background").length;
110
+ const mainRunning = running.some((node) => node.execution === "main");
111
+ // Graph 的常态是后台节点;主会话没有在飞回合,宿主的停止键是灰的。这里给一个
112
+ // 不依赖主回合的暂停入口,走 status remote 直接落 paused(user_stop)。主节点在飞时
113
+ // 宿主停止键本身可用,不重复给按钮。
114
+ if (backgroundRunning > 0 && !mainRunning && !actionStages.has(status.stage)) {
115
+ return _jsx("div", { className: "ralphflow-status-action-dock", children: _jsxs("div", { className: "ralphflow-status-action", "data-ralphflow-status-pause": status.id, children: [_jsx(StatusDot, { stage: status.stage }), _jsxs("span", { className: "ralphflow-status-action-text", children: ["Graph \u6267\u884C\u4E2D \u00B7 ", backgroundRunning, " \u4E2A\u8282\u70B9\u5728\u98DE", error ? ` · ${error}` : ""] }), _jsx("button", { type: "button", className: "ralphflow-status-pause", disabled: pending, onClick: () => {
116
+ setPending(true);
117
+ setError(null);
118
+ void pause().then((result) => { if (!result.ok)
119
+ setError(result.text); }, (cause) => { setError(cause instanceof Error ? cause.message : String(cause)); }).finally(() => setPending(false));
120
+ }, children: pending ? "暂停中…" : "暂停" })] }) });
121
+ }
122
+ if (!actionStages.has(status.stage))
95
123
  return null;
96
- const reason = status.stage === "gate" ? "等待你放行" : status.maxFailures > 0 && status.failures >= status.maxFailures ? "失败已到上限" : "已暂停";
97
- return _jsx("div", { className: "ralphflow-status-action-dock", children: _jsxs("div", { className: "ralphflow-status-action", "data-ralphflow-status-action": status.id, "data-stage": status.stage, role: "status", children: [_jsx(StatusDot, { stage: status.stage }), _jsxs("span", { className: "ralphflow-status-action-text", children: [reason, " \u00B7 \u8F93\u5165 ", _jsx("code", { children: "/ralphflow-continue" }), " \u7EE7\u7EED"] })] }) });
124
+ const reason = status.stage === "gate" ? "等待你放行" : status.maxFailures > 0 && status.failures >= status.maxFailures ? "返工已到上限" : "已暂停";
125
+ return _jsx("div", { className: "ralphflow-status-action-dock", children: _jsxs("div", { className: "ralphflow-status-action", "data-ralphflow-status-action": status.id, "data-stage": status.stage, role: "status", children: [_jsx(StatusDot, { stage: status.stage }), _jsxs("span", { className: "ralphflow-status-action-text", children: [reason, " \u00B7 ", status.kind === "graph" && status.stage === "gate"
126
+ ? "直接回复你的决定(“批准此版本”或要改什么)"
127
+ : _jsxs(_Fragment, { children: ["\u8F93\u5165 ", _jsx("code", { children: "/ralphflow-continue" }), " \u7EE7\u7EED"] })] })] }) });
98
128
  }
99
129
  /** Additive entries, with a single reference-counted observable for each bound Session. */
100
130
  export async function registerWorkflowStatus(ctx) {
@@ -103,14 +133,18 @@ export async function registerWorkflowStatus(ctx) {
103
133
  }
104
134
  function registerUi(ctx) {
105
135
  const sources = new Map();
106
- const sourceOf = (sessionId) => {
136
+ const sourceFor = (sessionId) => {
107
137
  let source = sources.get(sessionId);
108
138
  if (!source) {
109
139
  source = createStatusSource(ctx, sessionId);
110
140
  sources.set(sessionId, source);
111
141
  }
112
- return { hooks: { workflowStatus: source } };
142
+ return source;
113
143
  };
144
+ const sourceOf = (sessionId) => ({
145
+ hooks: { workflowStatus: sourceFor(sessionId) },
146
+ pause: () => sourceFor(sessionId).pause(),
147
+ });
114
148
  ctx.effect(() => () => { for (const source of sources.values())
115
149
  source.dispose(); sources.clear(); });
116
150
  ctx.slots.inject("conversation.input.dock", () => ctx.slots.register({
@@ -119,4 +153,6 @@ function registerUi(ctx) {
119
153
  ctx.slots.inject("conversation.session.header.actions", () => ctx.slots.register({
120
154
  name: "conversation.session.header.actions", id: "ralphflow-status", order: 15, inject: sourceOf,
121
155
  }, WorkflowStatusControl));
156
+ // 只读查看器:同一个 status source,不新开轮询、不复制下一动作逻辑。
157
+ registerViewerTab(ctx, sourceFor);
122
158
  }
@@ -0,0 +1,18 @@
1
+ import type { Context } from "@deepseek-ai/cordis";
2
+ import type { ClientStatus } from "./status-source.js";
3
+ export declare const VIEWER_TAB_ID = "ralphflow-viewer";
4
+ export declare const VIEWER_KIND = "ralphflow-viewer";
5
+ type Source = {
6
+ getSnapshot(): ClientStatus;
7
+ subscribe(listener: () => void): () => void;
8
+ dispose(): void;
9
+ };
10
+ type Props = {
11
+ sessionId: string;
12
+ source: Source;
13
+ };
14
+ export declare function injectViewerCss(): void;
15
+ export declare function ViewerPage(props: Props): import("react").JSX.Element;
16
+ /** 注册只读 tab:类型 + 右侧栏 seat;数据走调用方给的共享 status source。 */
17
+ export declare function registerViewerTab(ctx: Context, sourceOf: (sessionId: string) => Source): void;
18
+ export {};