dsh-taskflow 0.0.0-stage → 0.1.0

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/client.js ADDED
@@ -0,0 +1,312 @@
1
+ /*! Third-party UI attribution
2
+ MIT License
3
+ Copyright (c) 2026 DeepSeek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+ */
23
+ // Generated by npm run build.
24
+ window.__ModuleLoader__.load({ id: "dsh-taskflow", factory: function(require) { var module = {exports:{}}; var exports = module.exports;
25
+ var __create = Object.create;
26
+ var __defProp = Object.defineProperty;
27
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
28
+ var __getOwnPropNames = Object.getOwnPropertyNames;
29
+ var __getProtoOf = Object.getPrototypeOf;
30
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
31
+ var __export = (target, all) => {
32
+ for (var name in all)
33
+ __defProp(target, name, { get: all[name], enumerable: true });
34
+ };
35
+ var __copyProps = (to, from, except, desc) => {
36
+ if (from && typeof from === "object" || typeof from === "function") {
37
+ for (let key of __getOwnPropNames(from))
38
+ if (!__hasOwnProp.call(to, key) && key !== except)
39
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
40
+ }
41
+ return to;
42
+ };
43
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
44
+ // If the importer is in node compatibility mode or this is not an ESM
45
+ // file that has been converted to a CommonJS file using a Babel-
46
+ // compatible transform (i.e. "__esModule" has not been set), then set
47
+ // "default" to the CommonJS "module.exports" for node compatibility.
48
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
49
+ mod
50
+ ));
51
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
52
+
53
+ // src/client/index.jsx
54
+ var index_exports = {};
55
+ __export(index_exports, {
56
+ apply: () => apply,
57
+ createApi: () => createApi,
58
+ inject: () => inject
59
+ });
60
+ module.exports = __toCommonJS(index_exports);
61
+ var import_react6 = __toESM(require("react"), 1);
62
+ var import_react_dom2 = require("react-dom");
63
+
64
+ // src/client/components/task-panel.jsx
65
+ var import_react3 = __toESM(require("react"), 1);
66
+
67
+ // src/client/model.mjs
68
+ var STATUS = { pending: "待执行", queued: "排队中", running: "执行中", awaiting_children: "等待下级", paused: "已暂停", blocked: "受阻", failed: "失败", completed: "已完成", cancelled: "已取消" };
69
+ var TOOL_NAMES = { browser: "浏览器", editor: "编辑器", terminal: "终端", plugin: "插件", orchestration: "编排" };
70
+ function visibleTree(plan, { filter = "all", scope = "global", sessionId } = {}) {
71
+ if (!plan) return [];
72
+ const all = Object.values(plan.tasks), kept = /* @__PURE__ */ new Set();
73
+ const matches = (t) => (filter === "all" || (filter === "active" ? !["completed", "cancelled"].includes(t.status) : t.status === filter)) && (scope === "global" || t.executionSessionId === sessionId || (t.parentId ? plan.tasks[t.parentId].executionSessionId : plan.rootSessionId) === sessionId);
74
+ for (const t of all.filter(matches)) {
75
+ for (let x = t; x; x = plan.tasks[x.parentId]) {
76
+ if (kept.has(x.id)) break;
77
+ kept.add(x.id);
78
+ }
79
+ }
80
+ const walk = (parentId) => all.filter((t) => t.parentId === parentId && kept.has(t.id)).map((t) => ({ ...t, children: walk(t.id) }));
81
+ return walk(null);
82
+ }
83
+ function progress(plan) {
84
+ const roots = Object.values(plan?.tasks ?? {}).filter((t) => t.parentId === null && t.status !== "cancelled");
85
+ const done = roots.filter((t) => t.status === "completed").length;
86
+ return { done, total: roots.length, percent: roots.length ? Math.round(done / roots.length * 100) : 0 };
87
+ }
88
+
89
+ // src/client/generated/icons.jsx
90
+ var import_react = __toESM(require("react"), 1);
91
+ var paths = { layers: "m12 3 9 5-9 5-9-5 9-5zm-9 9 9 5 9-5M3 16l9 5 9-5", chat: "M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6A8.4 8.4 0 0 1 12.5 3h.5a8.5 8.5 0 0 1 8 8v.5z", check: "m5 12 4 4L19 6", chevron: "m9 5 7 7-7 7", arrow: "M5 12h14m-6-6 6 6-6 6", back: "M19 12H5m6-6-6 6 6 6", plus: "M12 5v14M5 12h14", search: "m21 21-4.3-4.3M19 10.5a8.5 8.5 0 1 1-17 0 8.5 8.5 0 0 1 17 0", browser: "M3 8h18M5 4h14a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m1 2h.01M9 6h.01", code: "m8 6-6 6 6 6m8-12 6 6-6 6m-3-15-2 18", terminal: "m4 5 6 6-6 6m9 1h7", plugin: "M8 3v4H4v5h4v4h4v5h5v-5h4v-5h-4V7h-4V3H8z", settings: "M9 3h6l1 4 4 1 1 6-4 2-1 4H9l-1-4-4-1-1-6 4-2 2-4zm7 9a4 4 0 1 1-8 0 4 4 0 0 1 8 0", file: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zm0 0v6h6M8 13h8m-8 4h6", branch: "M6 3v12a3 3 0 0 0 3 3h9M6 8h8a4 4 0 0 0 4-4m-9 14a3 3 0 1 1-6 0 3 3 0 0 1 6 0m12-15a3 3 0 1 1-6 0 3 3 0 0 1 6 0", clock: "M12 7v5l3 2m6-2a9 9 0 1 1-18 0 9 9 0 0 1 18 0", download: "M12 3v12m-5-5 5 5 5-5M4 16v4h16v-4", send: "m22 2-7 20-4-9-9-4 20-7zM22 2 11 13", close: "m6 6 12 12M6 18 18 6", upload: "M12 16V3M7 8l5-5 5 5M4 16v5h16v-5", refresh: "M20 7V3l-4 4a8 8 0 1 0 4 8M20 3h-5", lock: "M6 11h12v10H6zm3 0V7a3 3 0 0 1 6 0v4", expand: "M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5", eye: "M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12zm13 0a3 3 0 1 1-6 0 3 3 0 0 1 6 0", book: "M12 5s-4-3-9-2v16c5-1 9 2 9 2s4-3 9-2V3c-5-1-9 2-9 2zm0 0v16", info: "M12 11v6m0-10h.01m9 5a9 9 0 1 1-18 0 9 9 0 0 1 18 0", dots: "M5 12h.01M12 12h.01M19 12h.01" };
92
+ paths.folder = "M3 7V5h6l2 2h10v13H3V7z";
93
+ paths.panel = "M3 4h18v16H3zm7 0v16";
94
+ paths.edit = "m16 3 5 5-12 12-6 1 1-6L16 3zm-3 3 5 5";
95
+ paths.moon = "M20 15a9 9 0 0 1-11-11 9 9 0 1 0 11 11";
96
+ function Icon({ name, ...props }) {
97
+ return /* @__PURE__ */ import_react.default.createElement("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", ...props }, /* @__PURE__ */ import_react.default.createElement("path", { d: paths[name] || paths.file }));
98
+ }
99
+
100
+ // src/client/components/task-dialog.jsx
101
+ var import_react2 = __toESM(require("react"), 1);
102
+ var import_react_dom = require("react-dom");
103
+ function TaskDialog({ title, subtitle, children, actions, onClose, closeLabel = "关闭任务详情" }) {
104
+ const ref = (0, import_react2.useRef)(null);
105
+ (0, import_react2.useEffect)(() => {
106
+ const d = ref.current;
107
+ if (typeof d.showModal === "function") d.showModal();
108
+ else d.setAttribute("open", "");
109
+ return () => {
110
+ if (d.open && typeof d.close === "function") d.close();
111
+ };
112
+ }, []);
113
+ return (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react2.default.createElement("dialog", { ref, className: "tf-dialog", "aria-label": title, onCancel: (e) => {
114
+ e.preventDefault();
115
+ onClose();
116
+ }, onClick: (e) => {
117
+ if (e.target === ref.current) {
118
+ const r = ref.current.getBoundingClientRect();
119
+ if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom) onClose();
120
+ }
121
+ } }, /* @__PURE__ */ import_react2.default.createElement("header", { className: "dialog-head" }, /* @__PURE__ */ import_react2.default.createElement("div", null, /* @__PURE__ */ import_react2.default.createElement("small", null, subtitle), /* @__PURE__ */ import_react2.default.createElement("h2", null, title)), /* @__PURE__ */ import_react2.default.createElement("button", { className: "iconbtn", "aria-label": closeLabel, onClick: onClose }, /* @__PURE__ */ import_react2.default.createElement(Icon, { name: "close" }))), /* @__PURE__ */ import_react2.default.createElement("div", { className: "dialog-body" }, children), actions && /* @__PURE__ */ import_react2.default.createElement("footer", { className: "dialog-actions" }, actions)), document.body);
122
+ }
123
+
124
+ // src/client/components/task-panel.jsx
125
+ function TaskPanel({ view, sessionId, action, navigate, augment, onError }) {
126
+ const [filter, setFilter] = (0, import_react3.useState)("all"), [scope, setScope] = (0, import_react3.useState)("global"), [collapsed, setCollapsed] = (0, import_react3.useState)(/* @__PURE__ */ new Set()), [detail, setDetail] = (0, import_react3.useState)(null), [busy, setBusy] = (0, import_react3.useState)(false), [error, setError] = (0, import_react3.useState)("");
127
+ (0, import_react3.useEffect)(() => {
128
+ setDetail(null);
129
+ setError("");
130
+ }, [sessionId]);
131
+ const p = view.plan, pr = progress(p);
132
+ const perform = async (type, data) => {
133
+ if (busy) return;
134
+ setBusy(true);
135
+ setError("");
136
+ try {
137
+ await action(type, data);
138
+ } catch (e) {
139
+ setError(e.message);
140
+ onError?.(e);
141
+ } finally {
142
+ setBusy(false);
143
+ }
144
+ };
145
+ const prompt = (value) => {
146
+ augment(value);
147
+ setDetail(null);
148
+ };
149
+ const row = (t) => /* @__PURE__ */ import_react3.default.createElement("div", { className: "task-node", key: t.id }, /* @__PURE__ */ import_react3.default.createElement("div", { className: `tf-row task-row ${t.status} ${view.currentTaskId === t.id ? "focused" : ""}`, "data-task-id": t.id, "data-status": t.status }, /* @__PURE__ */ import_react3.default.createElement("div", { className: "task-line" }, /* @__PURE__ */ import_react3.default.createElement("span", { className: `task-box ${t.status}`, "aria-label": STATUS[t.status] }, t.status === "completed" ? /* @__PURE__ */ import_react3.default.createElement(Icon, { name: "check" }) : t.status === "cancelled" ? "−" : null), /* @__PURE__ */ import_react3.default.createElement("div", { className: "task-copy" }, /* @__PURE__ */ import_react3.default.createElement("button", { className: "tf-task task-title", onClick: () => {
150
+ const target = t.executionSessionId || (t.parentId ? p.tasks[t.parentId].executionSessionId : p.rootSessionId);
151
+ if (target && target !== sessionId) navigate(target);
152
+ else void perform("focus", { taskId: t.id });
153
+ } }, t.title), /* @__PURE__ */ import_react3.default.createElement("div", { className: "task-meta" }, /* @__PURE__ */ import_react3.default.createElement("code", null, t.id), /* @__PURE__ */ import_react3.default.createElement("span", null, "· ", t.mode === "delegate" && t.executionSessionId ? "独立会话" : t.mode === "delegate" ? "按需委派" : "当前会话"), t.version > 1 && /* @__PURE__ */ import_react3.default.createElement("span", null, "v", t.version), t.children.length > 0 && /* @__PURE__ */ import_react3.default.createElement("button", { className: "tf-fold", "aria-label": `${collapsed.has(t.id) ? "展开" : "折叠"} ${t.title}`, onClick: () => setCollapsed((old) => {
154
+ const n = new Set(old);
155
+ n.has(t.id) ? n.delete(t.id) : n.add(t.id);
156
+ return n;
157
+ }) }, /* @__PURE__ */ import_react3.default.createElement(Icon, { name: "chevron", style: { transform: collapsed.has(t.id) ? "" : "rotate(90deg)" } })))), /* @__PURE__ */ import_react3.default.createElement("button", { className: "iconbtn", "aria-label": `查看 ${t.id} 详情`, onClick: () => setDetail(t.id) }, /* @__PURE__ */ import_react3.default.createElement(Icon, { name: "dots" }))), !["completed", "cancelled"].includes(t.status) && /* @__PURE__ */ import_react3.default.createElement("div", { className: "task-status" }, /* @__PURE__ */ import_react3.default.createElement("span", { className: `pill ${t.status === "running" ? "blue" : ""}` }, /* @__PURE__ */ import_react3.default.createElement("i", { className: `dot ${t.status}` }), STATUS[t.status]), ["pending", "paused", "blocked", "failed"].includes(t.status) && /* @__PURE__ */ import_react3.default.createElement("button", { className: "btn small outline", onClick: () => prompt(`继续执行 ${t.id},按当前要求完成任务。`) }, t.status === "pending" ? "开始" : "继续"))), !collapsed.has(t.id) && t.children.length > 0 && /* @__PURE__ */ import_react3.default.createElement("div", { className: "child-tasks" }, t.children.map(row)));
158
+ const selected = p?.tasks[detail];
159
+ return /* @__PURE__ */ import_react3.default.createElement("section", { className: "tf-panel", "aria-label": "任务导航" }, /* @__PURE__ */ import_react3.default.createElement("header", { className: "plan-tabs" }, /* @__PURE__ */ import_react3.default.createElement("span", { className: "tab" }, /* @__PURE__ */ import_react3.default.createElement(Icon, { name: "check" }), "任务导航"), /* @__PURE__ */ import_react3.default.createElement("span", { className: "pill", style: { fontSize: 10 } }, "持久计划"), /* @__PURE__ */ import_react3.default.createElement("button", { className: "iconbtn", "aria-label": "查看任务动态", onClick: () => setDetail("activity") }, /* @__PURE__ */ import_react3.default.createElement(Icon, { name: "dots" }))), view.loading ? /* @__PURE__ */ import_react3.default.createElement("p", { className: "empty" }, "正在加载任务…") : !p ? /* @__PURE__ */ import_react3.default.createElement("div", { className: "empty" }, /* @__PURE__ */ import_react3.default.createElement(Icon, { name: "check" }), /* @__PURE__ */ import_react3.default.createElement("p", null, "暂无任务计划"), /* @__PURE__ */ import_react3.default.createElement("p", null, "在会话中描述目标,模型将根据任务复杂度规划待办。")) : /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement("div", { className: "plan-heading" }, /* @__PURE__ */ import_react3.default.createElement("h2", null, p.title), /* @__PURE__ */ import_react3.default.createElement("div", { className: "progress-label" }, /* @__PURE__ */ import_react3.default.createElement("strong", null, pr.done, " / ", pr.total, " 项已完成"), /* @__PURE__ */ import_react3.default.createElement("span", null, "v", p.version, " · ", pr.percent, "%")), /* @__PURE__ */ import_react3.default.createElement("div", { className: "progress-track", role: "progressbar", "aria-label": "根任务完成进度", "aria-valuenow": pr.percent, "aria-valuemin": 0, "aria-valuemax": 100 }, /* @__PURE__ */ import_react3.default.createElement("span", { style: { width: `${pr.percent}%` } }))), /* @__PURE__ */ import_react3.default.createElement("div", { className: "plan-controls" }, /* @__PURE__ */ import_react3.default.createElement("div", { className: "segments" }, [["global", "全局计划"], ["local", "当前会话"]].map(([id, title]) => /* @__PURE__ */ import_react3.default.createElement("button", { key: id, className: scope === id ? "selected" : "", "aria-pressed": scope === id, onClick: () => setScope(id) }, title))), /* @__PURE__ */ import_react3.default.createElement("select", { "aria-label": "任务筛选", value: filter, onChange: (e) => setFilter(e.target.value) }, /* @__PURE__ */ import_react3.default.createElement("option", { value: "all" }, "全部事项"), /* @__PURE__ */ import_react3.default.createElement("option", { value: "active" }, "未完成"), /* @__PURE__ */ import_react3.default.createElement("option", { value: "completed" }, "已完成"), /* @__PURE__ */ import_react3.default.createElement("option", { value: "cancelled" }, "已取消"))), /* @__PURE__ */ import_react3.default.createElement("div", { className: "task-list" }, visibleTree(p, { filter, scope, sessionId }).map(row)), /* @__PURE__ */ import_react3.default.createElement("footer", { className: "plan-bottom" }, /* @__PURE__ */ import_react3.default.createElement("button", { className: "btn outline", onClick: () => augment(view.currentTaskId ? `在 ${view.currentTaskId} 下新增一个` : "新增一个待办事项:") }, /* @__PURE__ */ import_react3.default.createElement(Icon, { name: "plus" }), view.currentTaskId ? "在当前任务下增补" : "在主任务下增补"), /* @__PURE__ */ import_react3.default.createElement("p", null, "稳定 ID · 跨轮保留 · 刷新恢复"))), (error || view.error) && /* @__PURE__ */ import_react3.default.createElement("p", { role: "alert", className: "tf-error" }, error || view.error), selected && /* @__PURE__ */ import_react3.default.createElement(TaskDialog, { title: selected.title, subtitle: `${selected.id} · 任务详情`, onClose: () => setDetail(null), actions: /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, ["pending", "paused", "blocked", "failed"].includes(selected.status) && /* @__PURE__ */ import_react3.default.createElement("button", { className: "btn small primary", onClick: () => prompt(`继续执行 ${selected.id},按当前要求完成任务。`) }, "在会话中继续"), selected.status !== "cancelled" && /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement("button", { className: "btn small outline", onClick: () => prompt(`在 ${selected.id} 下新增一个`) }, "增补下级事项"), /* @__PURE__ */ import_react3.default.createElement("button", { className: "btn small outline", onClick: () => prompt(`修改 ${selected.id} 的要求为:`) }, "修改要求")), !["cancelled", "completed"].includes(selected.status) && /* @__PURE__ */ import_react3.default.createElement("button", { className: "btn small danger", disabled: busy, onClick: () => void perform("cancel", { taskId: selected.id, version: selected.version }) }, "取消任务"), /* @__PURE__ */ import_react3.default.createElement("button", { className: "btn small", disabled: busy, onClick: () => void perform("reorder", { taskId: selected.id, direction: -1, expectedVersion: p.version }) }, "上移"), /* @__PURE__ */ import_react3.default.createElement("button", { className: "btn small", disabled: busy, onClick: () => void perform("reorder", { taskId: selected.id, direction: 1, expectedVersion: p.version }) }, "下移")) }, /* @__PURE__ */ import_react3.default.createElement("dl", { className: "detail-kv" }, /* @__PURE__ */ import_react3.default.createElement("dt", null, "状态"), /* @__PURE__ */ import_react3.default.createElement("dd", null, /* @__PURE__ */ import_react3.default.createElement("span", { className: "pill" }, STATUS[selected.status], " · v", selected.version)), /* @__PURE__ */ import_react3.default.createElement("dt", null, "执行方式"), /* @__PURE__ */ import_react3.default.createElement("dd", null, selected.mode === "delegate" ? "独立子会话" : "当前会话"), /* @__PURE__ */ import_react3.default.createElement("dt", null, "父级事项"), /* @__PURE__ */ import_react3.default.createElement("dd", null, selected.parentId || "主任务"), /* @__PURE__ */ import_react3.default.createElement("dt", null, "任务要求"), /* @__PURE__ */ import_react3.default.createElement("dd", null, selected.instructions || selected.title), /* @__PURE__ */ import_react3.default.createElement("dt", null, "完成标准"), /* @__PURE__ */ import_react3.default.createElement("dd", null, selected.criteria || "按当前任务要求完成")), selected.report && /* @__PURE__ */ import_react3.default.createElement("div", { className: "notice" }, /* @__PURE__ */ import_react3.default.createElement("strong", null, selected.report.version === selected.version ? "执行结果" : `历史结果 v${selected.report.version}(当前要求已变化)`), /* @__PURE__ */ import_react3.default.createElement("p", null, selected.report.summary)), error && /* @__PURE__ */ import_react3.default.createElement("p", { className: "tf-error", role: "alert" }, error)), detail === "activity" && p && /* @__PURE__ */ import_react3.default.createElement(TaskDialog, { title: "任务动态", subtitle: `持久计划 · v${p.version}`, closeLabel: "关闭任务动态", onClose: () => setDetail(null) }, [...p.events].reverse().map((e) => /* @__PURE__ */ import_react3.default.createElement("article", { className: "history", key: e.id }, /* @__PURE__ */ import_react3.default.createElement("time", null, e.at.replace("T", " ").slice(0, 19), " · ", e.taskId), e.detail))));
160
+ }
161
+
162
+ // src/client/components/tool-panel.jsx
163
+ var import_react4 = __toESM(require("react"), 1);
164
+ function ToolPanel({ tool, onClose, renderer }) {
165
+ const [reload, setReload] = (0, import_react4.useState)(0);
166
+ if (!tool?.open) return null;
167
+ return /* @__PURE__ */ import_react4.default.createElement("aside", { className: "tf-tool", "aria-label": `${TOOL_NAMES[tool.kind]}工具视图` }, /* @__PURE__ */ import_react4.default.createElement("header", { className: "tool-header" }, /* @__PURE__ */ import_react4.default.createElement(Icon, { name: tool.kind === "editor" ? "code" : tool.kind }), /* @__PURE__ */ import_react4.default.createElement("span", null, TOOL_NAMES[tool.kind]), /* @__PURE__ */ import_react4.default.createElement("span", { className: "binding" }, tool.taskId || tool.title), /* @__PURE__ */ import_react4.default.createElement("button", { className: "iconbtn", "aria-label": "收起工具视图", onClick: onClose }, /* @__PURE__ */ import_react4.default.createElement(Icon, { name: "close" }))), /* @__PURE__ */ import_react4.default.createElement("div", { className: "tool-context" }, /* @__PURE__ */ import_react4.default.createElement(Icon, { name: "branch" }), "模型调用触发展开 · 仅当前工具"), /* @__PURE__ */ import_react4.default.createElement("div", { className: "tool-content" }, renderer ? renderer(tool) : tool.kind === "browser" && tool.url ? /* @__PURE__ */ import_react4.default.createElement("div", { className: "browser-window" }, /* @__PURE__ */ import_react4.default.createElement("div", { className: "browser-toolbar" }, /* @__PURE__ */ import_react4.default.createElement("button", { className: "iconbtn", "aria-label": "刷新网页预览", onClick: () => setReload((r) => r + 1) }, /* @__PURE__ */ import_react4.default.createElement(Icon, { name: "refresh" })), /* @__PURE__ */ import_react4.default.createElement("div", { className: "address" }, /* @__PURE__ */ import_react4.default.createElement(Icon, { name: "lock" }), /* @__PURE__ */ import_react4.default.createElement("input", { readOnly: true, "aria-label": "工具页面地址", value: tool.url })), /* @__PURE__ */ import_react4.default.createElement("a", { className: "iconbtn", href: tool.url, target: "_blank", rel: "noopener noreferrer", "aria-label": "在新标签页打开" }, /* @__PURE__ */ import_react4.default.createElement(Icon, { name: "expand" }))), /* @__PURE__ */ import_react4.default.createElement("iframe", { key: reload, title: "网页预览", src: tool.url, sandbox: "allow-scripts allow-forms", referrerPolicy: "no-referrer" })) : tool.kind === "terminal" ? /* @__PURE__ */ import_react4.default.createElement("pre", { className: "terminal" }, tool.content) : /* @__PURE__ */ import_react4.default.createElement("div", { className: "code-window" }, /* @__PURE__ */ import_react4.default.createElement("div", { className: "file-tab" }, tool.title), /* @__PURE__ */ import_react4.default.createElement("pre", null, tool.content))), /* @__PURE__ */ import_react4.default.createElement("footer", { className: "tool-footer" }, "工具视图与当前会话绑定 · 收起后回到完整对话"));
168
+ }
169
+
170
+ // src/client/hooks/use-taskflow.mjs
171
+ var import_react5 = require("react");
172
+ function useTaskflow(api, sessionId) {
173
+ const [state, setState] = (0, import_react5.useState)({ plan: null, loading: true });
174
+ const latest = (0, import_react5.useRef)(0);
175
+ (0, import_react5.useEffect)(() => {
176
+ let alive = true;
177
+ const generation = ++latest.current;
178
+ setState({ plan: null, loading: true });
179
+ let inFlight = false;
180
+ const load = async () => {
181
+ if (inFlight) return;
182
+ inFlight = true;
183
+ try {
184
+ const value = await api.view(sessionId);
185
+ if (alive && latest.current === generation) setState({ ...value, loading: false });
186
+ } catch (e) {
187
+ if (alive) setState((s) => ({ ...s, loading: false, error: e.message }));
188
+ } finally {
189
+ inFlight = false;
190
+ }
191
+ };
192
+ void load();
193
+ const timer = setInterval(load, 1200);
194
+ return () => {
195
+ alive = false;
196
+ clearInterval(timer);
197
+ };
198
+ }, [api, sessionId]);
199
+ return state;
200
+ }
201
+
202
+ // src/client/styles.css
203
+ var styles_default = "/* Host-only adaptations. Component declarations are synced from the PRD. */\n.tf-panel,.tf-tool,.tf-dialog{--ink:var(--dsw-alias-label-primary,#262626);--secondary:var(--dsw-alias-label-secondary,#666);--muted:var(--dsw-alias-label-tertiary,#999);--line:var(--dsw-alias-border-l2,#eee);--surface:var(--dsw-alias-bg-base,#fff);--hover:var(--dsw-alias-interactive-bg-hover,#f5f5f5);--blue:var(--dsw-alias-state-business-primary,#4d6bfe);--hairline:1px;box-sizing:border-box;color:var(--ink);font:14px var(--dsw-font-family,system-ui,sans-serif);-webkit-font-smoothing:antialiased}\n.tf-panel *,.tf-tool *,.tf-dialog *{box-sizing:border-box}:where(.tf-panel,.tf-tool,.tf-dialog) button{font-family:inherit;color:inherit;cursor:pointer;border:0;background:none}:where(.tf-panel,.tf-tool,.tf-dialog) button:hover{background:var(--hover)}.tf-panel button:disabled,.tf-dialog button:disabled{opacity:.4;cursor:default}.tf-panel button:focus-visible,.tf-tool button:focus-visible,.tf-dialog button:focus-visible{outline:2px solid var(--blue);outline-offset:2px}.tf-panel svg,.tf-tool svg,.tf-dialog svg,.tf-entry svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;vertical-align:middle;flex-shrink:0}\n.tf-panel.tf-panel{height:100%;border:0;overflow:hidden}.tf-panel .tf-task{text-align:left;padding:0;display:block;width:100%;overflow-wrap:anywhere;border-radius:0}.tf-panel .tf-task:hover{background:none}.tf-fold{padding:0;display:inline-grid;place-items:center}.tf-panel .tf-fold svg{width:11px;height:11px}.tf-error{font-size:12px;color:#d33;overflow-wrap:anywhere;padding:8px 16px}.tf-dialog dd{white-space:pre-wrap}.tf-tool.tf-tool{height:100%;width:100%;max-width:none;min-width:0}.tf-tool iframe{display:block;border:0;width:100%;height:430px;background:white}.tf-tool .tool-header>span:first-of-type{white-space:nowrap}.tf-tool .tool-header .iconbtn{margin-left:0}\n.tf-tool-layout{display:grid!important;grid-template-columns:clamp(300px,48%,650px) minmax(0,1fr)!important;grid-template-rows:auto minmax(0,1fr)!important}.tf-tool-layout>[data-conversation-content]{grid-column:2;grid-row:2;min-width:0}.tf-tool-layout>:not([data-conversation-content]):not(.tf-tool-mount){grid-column:1/-1}.tf-tool-mount{grid-column:1;grid-row:2;min-height:0;min-width:0}.tf-tool-layout.tf-tool-body{grid-template-rows:minmax(0,1fr)!important}.tf-tool-body>[data-conversation-content],.tf-tool-body>.tf-tool-mount{grid-row:1!important}.tf-entry{font:inherit;background:none;border:0;border-radius:8px;padding:5px 8px;color:inherit;cursor:pointer;display:inline-flex;align-items:center;gap:4px}.tf-entry svg{width:14px;height:14px}.tf-mobile-view{display:none}\n@media(max-width:1250px){.tf-tool-layout{grid-template-columns:minmax(245px,50%) minmax(0,1fr)!important}.tf-tool-layout .messages{padding:23px 16px}.tf-tool-layout .composer{padding:12px 14px 7px}.tf-tool-layout .suggestions{display:none}.tf-tool-layout .composer-controls .model{display:none}}\n@media(max-width:1080px){.tf-tool-layout{grid-template-columns:minmax(0,1fr)!important}.tf-tool-layout>.tf-tool-mount{grid-row:2;grid-column:1;display:none}.tf-tool-layout>[data-conversation-content]{grid-row:2;grid-column:1}.tf-tool-layout.tf-tool-show-tool>.tf-tool-mount{display:block}.tf-tool-layout.tf-tool-show-tool>[data-conversation-content]{display:none}.tf-mobile-view{display:flex;gap:2px}.tf-mobile-view button{font:inherit;font-size:11px;border:0;padding:4px 6px;border-radius:6px;background:transparent;color:inherit;white-space:nowrap;cursor:pointer}.tf-mobile-view button[aria-pressed=true]{background:var(--dsw-alias-interactive-bg-hover,#f4f5f7)}}\n\n\n@media(max-width:790px){.tf-tool-layout .tf-tool .tool-content{padding:18px 14px}}\n";
204
+
205
+ // src/client/generated/prototype.css
206
+ var prototype_default = '/* Generated from docs/prototype/dsh-taskflow-prd.html.\n * Original DeepSeek UI styles: MIT; see licenses/DeepSeek-MIT.txt.\n * Run npm run build to resync. */\n:where(.tf-panel,.tf-tool,.tf-dialog) .iconbtn{display:inline-grid;place-items:center;width:28px;height:28px;border-radius:8px;color:var(--secondary);padding:0;flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .iconbtn svg{width:16px;height:16px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:36px;border:0;border-radius:12px;padding:0 14px;background:transparent;color:var(--ink);font-size:14px;line-height:22px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.small{min-height:28px;height:auto;padding:4px 10px;border-radius:8px;font-size:12px;line-height:18px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.outline{box-shadow:inset 0 0 0 var(--hairline) var(--dsw-alias-border-l3)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.primary{background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.primary:hover{background:var(--dsw-alias-button-primary-hover)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.blue{color:var(--blue);background:var(--dsw-specific-bubble)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.danger{color:var(--dsw-alias-state-danger-primary,#ec1313)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn svg{width:16px;height:16px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .subtle{color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .pill{display:inline-flex;align-items:center;gap:5px;background:var(--hover);color:var(--secondary);font-size:11px;line-height:18px;padding:2px 7px;border-radius:6px;white-space:nowrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .pill.blue{color:var(--blue);background:var(--dsw-specific-bubble)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .pill.success{color:var(--dsw-alias-state-success-primary,#168349);background:var(--dsw-static-green-500-a08)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dot{width:6px;height:6px;border-radius:50%;background:var(--muted);display:inline-block;flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dot.running{background:var(--blue)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dot.completed{background:var(--dsw-static-green-500)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dot.awaiting_children{background:var(--dsw-static-amber-500)}\n.tf-tool{display:flex;flex-direction:column;flex:0 0 48%;max-width:650px;min-width:300px;min-height:0;border-right:1px solid var(--dsw-alias-border-l3);background:var(--surface);order:-1}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-header{height:38px;flex-shrink:0;display:flex;align-items:center;gap:7px;padding:0 10px;font-size:12px;border-bottom:1px solid var(--line)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-header svg{width:15px;height:15px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-header .binding{font-size:11px;color:var(--muted);margin-left:auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-context{height:38px;flex-shrink:0;display:flex;align-items:center;gap:6px;padding:0 12px;font-size:11px;color:var(--muted);border-bottom:1px solid var(--line)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-content{flex:1;min-height:0;overflow:auto;padding:20px 16px;background:var(--dsw-specific-sidebar-fill);scrollbar-width:thin}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-footer{padding:8px 12px;font-size:10px;color:var(--muted);border-top:1px solid var(--line);line-height:1.7}\n:where(.tf-panel,.tf-tool,.tf-dialog) .browser-window{border:1px solid var(--line);border-radius:12px;overflow:hidden;background:var(--surface)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .browser-toolbar{height:42px;display:flex;align-items:center;gap:5px;border-bottom:1px solid var(--line);padding:0 8px;background:var(--dsw-specific-sidebar-fill)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .browser-toolbar .iconbtn{width:22px;height:25px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .browser-toolbar .iconbtn svg{width:13px;height:13px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .address{border:1px solid var(--line);border-radius:8px;background:var(--surface);height:26px;display:flex;align-items:center;gap:5px;flex:1;min-width:0;padding:0 8px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .address svg{width:11px;height:11px;color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .address input{font-size:10px;background:none;border:0;outline:0;min-width:0;width:100%;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .code-window{border:1px solid var(--line);border-radius:8px;overflow:hidden;background:var(--surface)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .file-tab{background:var(--dsw-specific-sidebar-fill);padding:11px 12px;font-size:11px;border-bottom:1px solid var(--line)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .code-window pre{font:12px/2 Consolas,var(--dsw-font-family);white-space:pre-wrap;margin:0;padding:18px 14px;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .terminal{background:var(--dsw-static-neutral-bluish-950);color:var(--dsw-static-neutral-bluish-100);padding:18px 15px;border-radius:8px;min-height:250px;font:11px/2 Consolas,var(--dsw-font-family);white-space:pre-wrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plugin-card{border:1px solid var(--line);border-radius:12px;background:var(--surface);padding:18px;margin-bottom:15px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plugin-card h3{font-size:15px;margin:12px 0;font-weight:500}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plugin-card p{font-size:12px;line-height:1.9;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-caption{font-size:10px;line-height:1.8;color:var(--muted);margin:12px 0}\n.tf-panel{grid-column:3;grid-row:2;display:flex;flex-direction:column;min-width:0;min-height:0;background:var(--surface);border-left:1px solid var(--dsw-alias-border-l3)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-tabs{display:flex;align-items:center;gap:7px;min-height:38px;height:38px;padding:0 10px;border-bottom:1px solid var(--line);font-size:12px;flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-tabs .tab{display:flex;align-items:center;gap:5px;border-bottom:2px solid var(--ink);height:38px;padding:0 6px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-tabs .tab svg{width:14px;height:14px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-tabs .iconbtn{margin-left:auto}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading{padding:16px 18px 14px;flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading h2{font-size:15px;font-weight:500;line-height:1.5;margin:0 0 8px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading p{font-size:12px;color:var(--muted);margin:0;line-height:1.8}\n:where(.tf-panel,.tf-tool,.tf-dialog) .progress-label{display:flex;align-items:center;justify-content:space-between;font-size:11px;color:var(--muted);margin-top:12px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .progress-label strong{font-weight:400;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .progress-track{height:3px;background:var(--hover);border-radius:3px;overflow:hidden;margin-top:9px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .progress-track span{background:var(--blue);height:100%;display:block;transition:width .2s}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-controls{padding:0 16px 12px;display:flex;align-items:center;gap:7px;border-bottom:1px solid var(--line);flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .segments{display:flex;flex:1;padding:3px;border-radius:8px;background:var(--hover)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .segments button{flex:1;padding:4px 5px;border-radius:6px;color:var(--muted);font-size:11px;white-space:nowrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .segments button.selected{background:var(--surface);color:var(--ink);box-shadow:0 1px 3px #00000008}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-controls select{font-size:11px;width:72px;padding:6px 2px;border:0;background:transparent;color:var(--secondary);border-radius:6px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-list{overflow:auto;flex:1;min-height:0;padding:10px 10px 16px;scrollbar-width:thin}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row{margin:2px 0;border-radius:8px;padding:11px 8px;cursor:pointer;border:1px solid transparent}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row:hover{background:var(--hover)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.focused{background:var(--dsw-specific-bubble);border-color:var(--dsw-static-deepseek-100)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.cancelled{opacity:.55}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.context-only{background:transparent}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.context-only .task-title{color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-line{display:flex;gap:8px;align-items:flex-start}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box{width:15px;height:15px;display:grid;place-items:center;border:1px solid var(--dsw-alias-border-l4);border-radius:4px;flex-shrink:0;margin-top:3px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box svg{width:11px;height:11px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box.completed{background:var(--blue);border-color:var(--blue);color:var(--dsw-static-neutral-00)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box.running{border-color:var(--blue)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box.running:before{content:"";width:5px;height:5px;border-radius:50%;background:var(--blue)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-copy{flex:1;min-width:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-title{font-size:13px;line-height:1.7;font-weight:400}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.completed .task-title{color:var(--muted);text-decoration:line-through;text-decoration-color:var(--dsw-alias-border-l4)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-meta{font-size:10px;color:var(--muted);display:flex;align-items:center;gap:5px;margin-top:4px;flex-wrap:wrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-meta code{font:10px Consolas,var(--dsw-font-family)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row .iconbtn{height:22px;width:20px;margin-right:-3px;color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row .iconbtn svg{width:14px;height:14px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-status{display:flex;align-items:center;gap:7px;margin:8px 0 0 23px;font-size:11px;color:var(--muted);flex-wrap:wrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-status .pill{font-size:10px;padding:1px 5px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-status .btn{font-size:10px;min-height:23px;padding:2px 7px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .child-tasks{border-left:1px solid var(--line);margin-left:15px;padding-left:5px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-bottom{padding:12px 16px;border-top:1px solid var(--line);flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-bottom .btn{width:100%;font-size:12px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-bottom p{text-align:center;font-size:10px;color:var(--muted);margin:9px 0 0;line-height:1.8}\n:where(.tf-panel,.tf-tool,.tf-dialog) .empty{padding:35px 18px;color:var(--muted);font-size:13px;line-height:1.9;text-align:center}\n:where(.tf-panel,.tf-tool,.tf-dialog) .empty svg{width:24px;height:24px;margin-bottom:10px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .saved:before{content:"";width:5px;height:5px;border-radius:50%;background:var(--dsw-static-green-500);display:inline-block;vertical-align:2px;margin-right:5px}\n.tf-dialog{width:min(590px,calc(100vw - 28px));max-height:88dvh;padding:0;border:1px solid var(--line);border-radius:20px;background:var(--surface);color:var(--ink);box-shadow:0 10px 45px #00000020}\n.tf-dialog::backdrop{background:#00000040;backdrop-filter:blur(2px)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-head{padding:21px 24px 17px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line);gap:12px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-head h2{font-size:17px;line-height:1.6;font-weight:500;margin:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-head small{display:block;font-size:10px;color:var(--muted);margin-bottom:5px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-body{padding:7px 24px 20px;max-height:calc(88dvh - 145px);overflow:auto;scrollbar-width:thin}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-actions{border-top:1px solid var(--line);display:flex;justify-content:flex-end;align-items:center;flex-wrap:wrap;gap:7px;padding:13px 24px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .notice{background:var(--hover);border-radius:12px;padding:12px 14px;margin:15px 0;font-size:12px;line-height:1.9;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .notice.blue{background:var(--dsw-specific-bubble);color:var(--blue)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .notice.warn{background:var(--dsw-static-amber-100);color:#9a6c25}\nbody[data-ds-dark-theme] :where(.tf-panel,.tf-tool,.tf-dialog) .notice.warn{background:var(--dsw-static-amber-900);color:var(--dsw-static-amber-400)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .field{display:block;color:var(--secondary);font-size:12px;margin:17px 0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .field input,:where(.tf-panel,.tf-tool,.tf-dialog) .field textarea,:where(.tf-panel,.tf-tool,.tf-dialog) .field select{display:block;width:100%;border:1px solid var(--dsw-alias-border-l3);border-radius:8px;background:var(--surface);color:var(--ink);font-size:13px;line-height:1.8;padding:8px 10px;margin-top:7px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .field textarea{resize:vertical;min-height:85px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .field small{display:block;color:var(--muted);font-size:11px;line-height:1.8;margin-top:6px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .detail-kv{display:grid;grid-template-columns:86px 1fr;gap:12px;font-size:12px;line-height:1.9;margin:21px 0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .detail-kv dt{color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .detail-kv dd{margin:0;overflow-wrap:anywhere}\n:where(.tf-panel,.tf-tool,.tf-dialog) .history{padding:12px 0;border-top:1px solid var(--line);font-size:12px;line-height:1.9}\n:where(.tf-panel,.tf-tool,.tf-dialog) .history time{display:block;font-size:10px;color:var(--muted);margin-bottom:4px}\n@media(min-width:1700px){.tf-tool{flex-basis:49%}\n}\n@media(max-width:1250px){:where(.tf-panel,.tf-tool,.tf-dialog) .tool-content{padding:14px 10px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-title{font-size:12px}\n}\n@media(max-width:1080px){:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading{padding:15px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-controls{padding:0 12px 12px}\n}\n@media(max-width:790px){.tf-tool{min-width:0;max-width:none;flex:1}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-header .binding{font-size:10px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading{padding:20px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-controls{padding:0 18px 14px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-list{padding:0 16px 16px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-title{font-size:13px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-meta{font-size:11px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row{padding:12px 10px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-bottom{padding:12px 20px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-head{padding:18px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-body{padding:5px 18px 20px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-actions{padding:12px 18px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-actions .btn{font-size:12px;padding:0 10px}\n}\n';
207
+
208
+ // src/client/index.jsx
209
+ var inject = ["slots", "sessions", "connection"];
210
+ function createApi(connection) {
211
+ const call = async (method, data) => {
212
+ const result = await connection.rpc.call("/api", method, data);
213
+ if (!result.ok) throw new Error(result.error.message);
214
+ return result.value;
215
+ };
216
+ return { view: (sessionId) => call("taskflow/view", { sessionId }), action: (sessionId, action, data) => call("taskflow/action", { sessionId, action, ...data }) };
217
+ }
218
+ function apply(ctx) {
219
+ const api = createApi(ctx.connection), renderers = /* @__PURE__ */ new Map();
220
+ ctx.provide("taskflowViews", { register(kind, component) {
221
+ renderers.set(kind, component);
222
+ return () => {
223
+ if (renderers.get(kind) === component) renderers.delete(kind);
224
+ };
225
+ } });
226
+ ctx.effect(() => {
227
+ const style = document.createElement("style");
228
+ style.dataset.dshTaskflow = "";
229
+ style.textContent = styles_default + "\n" + prototype_default;
230
+ document.head.append(style);
231
+ return () => style.remove();
232
+ });
233
+ ctx.inject(["sidebarRightTabs", "sidebarRight", "uiWorkspace"], (scope) => {
234
+ scope.effect(() => scope.sidebarRightTabs.register({ id: "dsh-taskflow", kind: "taskflow", priority: "extension", keepMounted: true, title: () => "任务导航", guide: [{ id: "taskflow", order: 0, title: () => "任务导航", description: () => "持久层级待办" }] }));
235
+ const register = (slot, options, Component) => scope.effect(() => scope.slots.inject(slot, () => scope.slots.register({ name: slot, ...options }, Component)));
236
+ const augment = (props, value) => {
237
+ const binding = ctx.sessions.binding(props.sessionId);
238
+ const input = binding && ctx.conversation?.input?.for(binding.ctx);
239
+ if (input) {
240
+ input.setDraft(value);
241
+ input.focus();
242
+ } else props.inputActions?.setDraft(value);
243
+ };
244
+ function Panel(props) {
245
+ const view = useTaskflow(api, props.sessionId);
246
+ return /* @__PURE__ */ import_react6.default.createElement(TaskPanel, { view, sessionId: props.sessionId, action: (type, data) => api.action(props.sessionId, type, data), navigate: (id) => scope.uiWorkspace.openSession(id), augment: (value) => augment(props, value) });
247
+ }
248
+ register("sidebar.right.pane.tab", { key: "dsh-taskflow" }, Panel);
249
+ function SessionEntry(props) {
250
+ const view = useTaskflow(api, props.sessionId), [mount, setMount] = (0, import_react6.useState)(null), [showTool, setShowTool] = (0, import_react6.useState)(true), autoOpened = (0, import_react6.useRef)(false);
251
+ (0, import_react6.useEffect)(() => {
252
+ if (mount) mount.parentElement?.classList.toggle("tf-tool-show-tool", showTool);
253
+ }, [mount, showTool]);
254
+ (0, import_react6.useEffect)(() => {
255
+ if (view.tool?.open) setShowTool(true);
256
+ }, [view.tool?.open, props.sessionId]);
257
+ (0, import_react6.useEffect)(() => {
258
+ if (view.plan && !autoOpened.current) {
259
+ try {
260
+ scope.sidebarRight.openTab("taskflow");
261
+ autoOpened.current = true;
262
+ } catch {
263
+ }
264
+ }
265
+ }, [view.plan?.id, props.sessionId]);
266
+ (0, import_react6.useEffect)(() => {
267
+ autoOpened.current = false;
268
+ }, [props.sessionId]);
269
+ (0, import_react6.useEffect)(() => {
270
+ if (!view.tool?.open) {
271
+ setMount(null);
272
+ return;
273
+ }
274
+ let cleanup = () => {
275
+ };
276
+ const attach = () => {
277
+ const body = [...document.querySelectorAll("[data-conversation-content]")].find((e) => e.dataset.conversationSession === props.sessionId && e.dataset.contentPhase !== "hero");
278
+ if (!body) return false;
279
+ const parent = body.parentElement;
280
+ const node = document.createElement("div");
281
+ node.className = "tf-tool-mount";
282
+ const bodyOnly = parent.classList.contains("workbody");
283
+ parent.append(node);
284
+ parent.classList.add("tf-tool-layout");
285
+ if (bodyOnly) parent.classList.add("tf-tool-body");
286
+ setMount(node);
287
+ cleanup = () => {
288
+ parent.classList.remove("tf-tool-layout", "tf-tool-show-tool", "tf-tool-body");
289
+ node.remove();
290
+ };
291
+ return true;
292
+ };
293
+ let observer;
294
+ if (!attach()) {
295
+ observer = new MutationObserver(() => {
296
+ if (attach()) observer.disconnect();
297
+ });
298
+ observer.observe(document.body, { childList: true, subtree: true });
299
+ }
300
+ return () => {
301
+ observer?.disconnect();
302
+ cleanup();
303
+ setMount(null);
304
+ };
305
+ }, [view.tool?.open, props.sessionId]);
306
+ const Renderer = renderers.get(view.tool?.kind);
307
+ return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, /* @__PURE__ */ import_react6.default.createElement("button", { className: "tf-entry", onClick: () => scope.sidebarRight.openTab("taskflow") }, /* @__PURE__ */ import_react6.default.createElement(Icon, { name: "check" }), "任务导航"), view.tool?.open && /* @__PURE__ */ import_react6.default.createElement("span", { className: "tf-mobile-view" }, /* @__PURE__ */ import_react6.default.createElement("button", { "aria-pressed": !showTool, onClick: () => setShowTool(false) }, "看对话"), /* @__PURE__ */ import_react6.default.createElement("button", { "aria-pressed": showTool, onClick: () => setShowTool(true) }, "看工具")), mount && (0, import_react_dom2.createPortal)(/* @__PURE__ */ import_react6.default.createElement(ToolPanel, { tool: view.tool, onClose: () => void api.action(props.sessionId, "close-view", {}), renderer: Renderer ? (tool) => /* @__PURE__ */ import_react6.default.createElement(Renderer, { tool, sessionId: props.sessionId }) : null }), mount));
308
+ }
309
+ register("conversation.session.header.utilities", { id: "taskflow", order: -5 }, SessionEntry);
310
+ });
311
+ }
312
+ return module.exports; }});
@@ -0,0 +1,8 @@
1
+ - insert:
2
+ - id: taskflow
3
+ name: dsh-taskflow
4
+ config:
5
+ maxDepth: 2
6
+ maxConcurrent: 2
7
+ maxTasks: 200
8
+ autoPlan: true
package/docs/DETAIL.md ADDED
@@ -0,0 +1,51 @@
1
+ # Taskflow
2
+
3
+ A DeepSeek Harness plugin (0.1.0) for persistent task trees, selective nested
4
+ sessions and direct-parent completion notifications.
5
+
6
+ ## Requirements
7
+
8
+ DSH **>=0.2.1-rc.3 <1.0.0-0**, Node.js **>=24.9.0**, and enabled host services for tools,
9
+ agents, sessions, systemPrompt and subagents, with a `spawn` provider.
10
+ The client requires the conversation, workspace and right-sidebar services.
11
+ Full `engines.dsh` declaration: `>=0.2.1-rc.3 <1.0.0-0 || >=0.2.2-0 <1.0.0-0 || >=0.2.3-0 <1.0.0-0 || >=0.3.0-0 <1.0.0-0`.
12
+ The declared range is separate from the versions exercised in the acceptance record.
13
+
14
+ ## Workflow
15
+
16
+ Describe a goal in the main session. The model creates a task plan independently
17
+ of `todo_write`. Simple tasks stay in their owner session; independent complex
18
+ tasks can spawn a child session and, within configured limits, grandchildren.
19
+ A valid completion immediately checks the task and notifies only its direct
20
+ parent. No review or parent approval step is added.
21
+
22
+ Later messages update the same ledger rather than replacing it. Additions attach
23
+ to the current task unless the main session explicitly names a parent ID or
24
+ unique full title. Editing requirements increments the version; stale execution
25
+ results are rejected. Adding children to a completed task reopens its ancestors
26
+ and retains the old report.
27
+
28
+ The right panel displays the hierarchy. Use the detail menu to add or edit a task;
29
+ these actions prefill the conversation and take effect after sending. Cancellation
30
+ and sibling reordering are direct interface actions.
31
+
32
+ ## Data and tools
33
+
34
+ The ledger defaults to `${DSH_HOME}/taskflow` or `~/.dsh/taskflow`. One active writer
35
+ is allowed per directory. Back up the directory while the host is stopped, and
36
+ also back up native DSH sessions for a complete migration. Interrupted work pauses
37
+ on recovery; it is not automatically rerun.
38
+
39
+ Tools remain host-owned. Taskflow displays actual URLs or text to the left of the
40
+ conversation on demand. The default browser surface is a restricted iframe, not
41
+ a browser automation engine. Embedded pages may fail due to CSP, authentication
42
+ or cross-origin restrictions. Other plugins may register dedicated renderers.
43
+
44
+ ## Validation status
45
+
46
+ Core, client and real DSH AgentLoop integration are tested using a deterministic
47
+ model adapter. Screenshots are from the labelled local acceptance shell. Full
48
+ profile installation, production model planning and third-party tool integration
49
+ still require acceptance. See the repository's acceptance record for details.
50
+
51
+ Original code: Apache-2.0. Imported UI portions: MIT; see NOTICE and licenses/.
@@ -0,0 +1,36 @@
1
+ # 智能任务编排
2
+
3
+ 面向 DeepSeek Harness 的智能任务编排插件(0.1.0),提供持久层级任务计划、按需子会话与完成通知。
4
+
5
+ ## 环境要求
6
+
7
+ Node.js ≥24.9.0。宿主须启用 tools、agents、sessions、systemPrompt、subagents,并注册 `spawn` 子会话提供者;客户端需要会话、工作区和右侧栏服务。宿主兼容声明:`>=0.2.1-rc.3 <1.0.0-0 || >=0.2.2-0 <1.0.0-0 || >=0.2.3-0 <1.0.0-0 || >=0.3.0-0 <1.0.0-0`。声明范围与已运行测试的版本分别记录,具体见仓库验收记录。
8
+
9
+ ## 使用方式
10
+
11
+ 在主会话说明目标,模型根据复杂度创建独立于 `todo_write` 的任务计划。简单事项在负责会话内完成,复杂且独立的事项可创建子会话,在配置上限内继续生成孙子会话。有效结果立即完成事项并通知直接父会话,无父级审批环节。
12
+
13
+ 后续消息只做增量变更,不覆盖原计划。新增事项默认挂到当前任务;主会话可明确指定父任务 ID 或唯一完整名称。修改要求后版本递增,旧执行结果失效。向已完成任务增补下级时会重新打开祖先并保留历史报告。
14
+
15
+ 右侧直接显示层级清单。详情菜单支持增补、修改和继续,点击后会预填会话,发送后由模型执行;取消和同级排序可直接操作。
16
+
17
+ 示例:
18
+
19
+ ```text
20
+ 先规划知识库导入任务,复杂部分按需委派。
21
+ 在 T-005 下新增一个移动端检查。
22
+ 修改 T-003 的要求,增加 PDF 支持。
23
+ 继续执行 T-003。
24
+ ```
25
+
26
+ ## 数据与工具
27
+
28
+ 账本默认位于 `${DSH_HOME}/taskflow`,未设置环境变量时为 `~/.dsh/taskflow`。同一目录只允许一个活跃写入者。停止宿主后备份整个目录,完整迁移还需备份原生 DSH 会话。中断任务恢复为暂停,需从负责会话继续。
29
+
30
+ 浏览器、命令和编辑操作仍由宿主工具执行。Taskflow 按需在会话左侧显示实际 URL 或文本;默认网页是受限 iframe,不是浏览器自动化引擎,网站的 CSP、认证或跨域限制可能阻止显示。其他插件可注册专用渲染器。
31
+
32
+ ## 验证范围
33
+
34
+ 已使用固定响应模型验证领域规则、客户端和真实 DSH AgentLoop 集成。截图来自明确标注的本地验收外壳;完整 profile 安装、真实模型规划及第三方工具仍需验收。宿主升级前应重新检查兼容性。
35
+
36
+ 原创代码 Apache-2.0,复用界面部分 MIT,完整归属见 NOTICE 与 licenses/。
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export { name, inject, Config, apply } from './src/server/index.mjs';
@@ -0,0 +1,20 @@
1
+ MIT License
2
+ Copyright (c) 2026 DeepSeek
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
@@ -0,0 +1,94 @@
1
+ Bundled Montserrat font: SIL Open Font License
2
+ Copyright 2024 The Montserrat.Git Project Authors (https://github.com/JulietaUla/Montserrat.git)
3
+
4
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
5
+ This license is copied below, and is also available with a FAQ at:
6
+ https://openfontlicense.org
7
+
8
+
9
+ —————————————————————————————-
10
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
11
+ —————————————————————————————-
12
+
13
+ PREAMBLE
14
+ The goals of the Open Font License (OFL) are to stimulate worldwide
15
+ development of collaborative font projects, to support the font creation
16
+ efforts of academic and linguistic communities, and to provide a free and
17
+ open framework in which fonts may be shared and improved in partnership
18
+ with others.
19
+
20
+ The OFL allows the licensed fonts to be used, studied, modified and
21
+ redistributed freely as long as they are not sold by themselves. The
22
+ fonts, including any derivative works, can be bundled, embedded,
23
+ redistributed and/or sold with any software provided that any reserved
24
+ names are not used by derivative works. The fonts and derivatives,
25
+ however, cannot be released under any other type of license. The
26
+ requirement for fonts to remain under this license does not apply
27
+ to any document created using the fonts or their derivatives.
28
+
29
+ DEFINITIONS
30
+ "Font Software" refers to the set of files released by the Copyright
31
+ Holder(s) under this license and clearly marked as such. This may
32
+ include source files, build scripts and documentation.
33
+
34
+ "Reserved Font Name" refers to any names specified as such after the
35
+ copyright statement(s).
36
+
37
+ "Original Version" refers to the collection of Font Software components as
38
+ distributed by the Copyright Holder(s).
39
+
40
+ "Modified Version" refers to any derivative made by adding to, deleting,
41
+ or substituting — in part or in whole — any of the components of the
42
+ Original Version, by changing formats or by porting the Font Software to a
43
+ new environment.
44
+
45
+ "Author" refers to any designer, engineer, programmer, technical
46
+ writer or other person who contributed to the Font Software.
47
+
48
+ PERMISSION & CONDITIONS
49
+ Permission is hereby granted, free of charge, to any person obtaining
50
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
51
+ redistribute, and sell modified and unmodified copies of the Font
52
+ Software, subject to the following conditions:
53
+
54
+ 1) Neither the Font Software nor any of its individual components,
55
+ in Original or Modified Versions, may be sold by itself.
56
+
57
+ 2) Original or Modified Versions of the Font Software may be bundled,
58
+ redistributed and/or sold with any software, provided that each copy
59
+ contains the above copyright notice and this license. These can be
60
+ included either as stand-alone text files, human-readable headers or
61
+ in the appropriate machine-readable metadata fields within text or
62
+ binary files as long as those fields can be easily viewed by the user.
63
+
64
+ 3) No Modified Version of the Font Software may use the Reserved Font
65
+ Name(s) unless explicit written permission is granted by the corresponding
66
+ Copyright Holder. This restriction only applies to the primary font name as
67
+ presented to the users.
68
+
69
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
70
+ Software shall not be used to promote, endorse or advertise any
71
+ Modified Version, except to acknowledge the contribution(s) of the
72
+ Copyright Holder(s) and the Author(s) or with their explicit written
73
+ permission.
74
+
75
+ 5) The Font Software, modified or unmodified, in part or in whole,
76
+ must be distributed entirely under this license, and must not be
77
+ distributed under any other license. The requirement for fonts to
78
+ remain under this license does not apply to any document created
79
+ using the Font Software.
80
+
81
+ TERMINATION
82
+ This license becomes null and void if any of the above conditions are
83
+ not met.
84
+
85
+ DISCLAIMER
86
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
87
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
88
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
89
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
90
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
91
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
92
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
93
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
94
+ OTHER DEALINGS IN THE FONT SOFTWARE.
package/locale/en.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "meta": {
3
+ "title": "Taskflow",
4
+ "description": "Persistent task trees, selective nested sessions and direct-parent completion notifications.",
5
+ "detail": "docs/DETAIL.md"
6
+ }
7
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "meta": {
3
+ "title": "智能任务编排",
4
+ "description": "持久层级计划、按需递归子会话与直接父任务完成通知。",
5
+ "detail": "docs/DETAIL.zh-CN.md"
6
+ }
7
+ }