dsh-plugin-agentflow 0.0.0-stage → 0.2.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/README.md +88 -2
- package/cordis.patch.yml +195 -0
- package/index.js +448 -0
- package/lib/bridge.js +858 -0
- package/lib/client.js +4 -0
- package/package.json +42 -4
- package/runtime/boards.mjs +486 -0
- package/runtime/bridge.mjs +230 -0
- package/runtime/dsh-source.mjs +289 -0
- package/runtime/engine.mjs +352 -0
- package/runtime/index.html +3299 -0
- package/runtime/llm.mjs +252 -0
- package/runtime/mcp.mjs +823 -0
- package/runtime/preset-gen.mjs +1117 -0
- package/runtime/presets.mjs +399 -0
- package/runtime/run.mjs +76 -0
- package/runtime/server.mjs +1151 -0
- package/runtime/skills.mjs +131 -0
- package/runtime/store.mjs +103 -0
- package/runtime/verify.mjs +219 -0
- package/runtime/web/dist/assets/index-CkM6YPl4.js +348 -0
- package/runtime/web/dist/assets/index-DEZcpxgr.css +1 -0
- package/runtime/web/dist/index.html +13 -0
- package/scripts/build-client.mjs +36 -0
- package/scripts/sync-runtime.mjs +84 -0
package/README.md
CHANGED
|
@@ -1,3 +1,89 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-plugin-agentflow
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
把 AgentFlow(物料画布式 agent 编排器)接进 DeepSeek Harness 的桌面插件:
|
|
4
|
+
|
|
5
|
+
- 设置页 / 侧边栏嵌入画布界面(本地后端 `http://127.0.0.1:8791`)
|
|
6
|
+
- 模型工具 `agentflow_list` / `agentflow_run`:看画布、跑画布
|
|
7
|
+
- 引擎随插件分发(`runtime/`),装完即用,不需要单独安装 `~/.dsh/agent-flow`
|
|
8
|
+
- 模型调用走 DSH 内核的 llm bridge(插件在 DSH 进程里起),不再自带 provider 凭据
|
|
9
|
+
|
|
10
|
+
## 安装
|
|
11
|
+
|
|
12
|
+
DSH 桌面版 → **设置 → 插件 → 添加插件**,然后二选一:
|
|
13
|
+
|
|
14
|
+
- 输入 GitHub 仓库地址(例:`https://github.com/<owner>/dsh-plugin-agentflow`)
|
|
15
|
+
- 输入本地目录(克隆下来的插件目录)
|
|
16
|
+
|
|
17
|
+
DSH 会安装插件依赖并加载;侧边栏/设置页出现 AgentFlow 即成功,**不需要手动起服务、不需要构建前端**(仓库里已包含构建好的客户端与 `runtime/` 引擎)。
|
|
18
|
+
|
|
19
|
+
## 首次启动会发生什么
|
|
20
|
+
|
|
21
|
+
1. 插件用当前 DSH 的 Node 进程拉起 `runtime/server.mjs`(先探测 8791 端口,已在跑就不重复起;日志丢弃,不污染 DSH 终端)
|
|
22
|
+
2. 后端监听 `127.0.0.1:8791`,数据目录默认 `~/.dsh/agent-flow-data`
|
|
23
|
+
3. 若新数据目录不存在或为空,且旧目录 `~/.dsh/agent-flow/data` 里有 `board.json`,会自动把旧数据抄一份过来(只抄一次,旧文件保留不动)
|
|
24
|
+
4. 新环境没有画布时,后端会自动建一张默认画布,打开页面即可看到
|
|
25
|
+
|
|
26
|
+
## 数据目录
|
|
27
|
+
|
|
28
|
+
默认:`~/.dsh/agent-flow-data/`
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
boards.json # 画布索引
|
|
32
|
+
boards/<id>.json # 每张画布
|
|
33
|
+
config.json # 引擎配置(含密钥时权限 0600)
|
|
34
|
+
drafts/ # 画布草稿
|
|
35
|
+
data/dsh-bridge.json # DSH llm bridge 的发现文件(进程级 token)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
覆盖方式(优先级从高到低):
|
|
39
|
+
|
|
40
|
+
| 方式 | 例子 |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| 插件配置 `dataDir` | `{ "dataDir": "/path/to/data" }` |
|
|
43
|
+
| 环境变量 `AGENTFLOW_DATA_DIR` | 启动 DSH 前 export |
|
|
44
|
+
| 默认值 | `~/.dsh/agent-flow-data` |
|
|
45
|
+
|
|
46
|
+
数据目录别放进插件安装目录:升级/重装插件会覆盖安装目录。
|
|
47
|
+
|
|
48
|
+
## 依赖
|
|
49
|
+
|
|
50
|
+
- DSH 0.2.x(插件依赖 `@deepseek-ai/dsh-tools ^0.2.1-rc.2`、`@deepseek-ai/cordis ^4.0.5`)
|
|
51
|
+
- Node 22+(后端用到 `fetch`、`AbortSignal.timeout`、`fs.cp`)
|
|
52
|
+
- 模型通道:引擎通过 DSH 内置的 llm bridge 调模型,需要 DSH 正在运行且插件已加载。DSH 没起 / 插件未加载时,画布仍能打开和编辑;关掉 mock 后跑图会失败,错误含「DSH 内核未连接」
|
|
53
|
+
- 引擎默认是 mock 模式(返回假输出,不调用模型);在画布设置里关掉 mock 才会真正调模型
|
|
54
|
+
|
|
55
|
+
## 预设导出
|
|
56
|
+
|
|
57
|
+
画布可导出成 DSH 预设,写入 `~/.dsh/profiles/<profile>/`(默认 profile 为 `desktop`)。
|
|
58
|
+
|
|
59
|
+
- 换 profile:启动 DSH 前设置 `AGENTFLOW_PROFILE=<profile 名>`,后端子进程会继承
|
|
60
|
+
- profile 目录不存在时导出接口返回 400,并提示具体路径
|
|
61
|
+
|
|
62
|
+
## 开发
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm install
|
|
66
|
+
npm run sync # 把 ~/.dsh/agent-flow 的引擎快照进 runtime/(清空重建)
|
|
67
|
+
npm run check # node --check
|
|
68
|
+
npm test # bridge 自测
|
|
69
|
+
npm run build # 构建客户端 bundle(改了 src/client.tsx 才需要)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- `runtime/` 是 `npm run sync` 的生成物,不要手改;引擎更新后重新跑一次 sync
|
|
73
|
+
- 开发时想直接改引擎源码,不必每次 sync:配 `agentflowDir` 或设 `AGENTFLOW_DIR=~/.dsh/agent-flow`,插件会改用该目录的引擎(此时 bridge 发现文件也写在该目录的 `data/` 下)
|
|
74
|
+
- 同步源可用 `AGENTFLOW_SRC=/path/to/agent-flow npm run sync` 指定
|
|
75
|
+
|
|
76
|
+
插件配置项:
|
|
77
|
+
|
|
78
|
+
| 配置 | 说明 |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `agentflowDir` | 引擎目录(开发用),覆盖自带 `runtime/` |
|
|
81
|
+
| `agentflowPort` | 后端端口,默认 `8791`(界面目前固定连 8791,改端口需同步改客户端) |
|
|
82
|
+
| `dataDir` | 数据目录,默认 `~/.dsh/agent-flow-data` |
|
|
83
|
+
|
|
84
|
+
## 限制
|
|
85
|
+
|
|
86
|
+
- 只在 macOS 上验证过;Windows 未测试(路径、进程管理可能还需适配)
|
|
87
|
+
- 端口默认固定 `8791`;被别的实例占用时,探测到存活就复用,否则启动会失败(插件客户端的 iframe 也写死了 8791,改端口需要同时改客户端)
|
|
88
|
+
- 一个 DSH 进程只托管一个自建后端;插件卸载时会杀掉自己拉起的那个,外部已在跑的不管
|
|
89
|
+
- 引擎是插件版本快照:升级引擎需要重新 `npm run sync` 并发布新版本插件
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# dsh-plugin-agentflow 的 bundle patch:把 AgentFlow 的两个工具挂到 profile 上。
|
|
2
|
+
#
|
|
3
|
+
# 与其它 DSH 插件同样的形状 —— 用户的 profile patch 可以按 id 覆写这一行来改
|
|
4
|
+
# agentflowDir(画布数据所在目录),不必复制整个插件配置。
|
|
5
|
+
|
|
6
|
+
- insert:
|
|
7
|
+
- id: agentflow
|
|
8
|
+
name: 'dsh-plugin-agentflow'
|
|
9
|
+
|
|
10
|
+
# >>> AgentFlow 预设(自动生成,重新导出会整体替换这段)
|
|
11
|
+
# 本文件由 AgentFlow 自动生成,请勿手改 —— 重新生成会整体覆盖。
|
|
12
|
+
# 来源画布:《AgentFlow》(id: demo)
|
|
13
|
+
# 生成器:~/.dsh/agent-flow/preset-gen.mjs
|
|
14
|
+
# 注意:delegation 组里的 tool-subagent 是分层下发子 agent 的唯一途径,不要删。
|
|
15
|
+
|
|
16
|
+
- insert:
|
|
17
|
+
- id: preset-flow-agentflow
|
|
18
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
19
|
+
config:
|
|
20
|
+
id: flow-agentflow
|
|
21
|
+
name: 'AgentFlow'
|
|
22
|
+
description: '由 AgentFlow 画布《AgentFlow》生成:6 个节点 / 5 层'
|
|
23
|
+
order: 50
|
|
24
|
+
plugins:
|
|
25
|
+
- id: persona
|
|
26
|
+
name: '@deepseek-ai/dsh-persona'
|
|
27
|
+
config:
|
|
28
|
+
prefix: |-
|
|
29
|
+
你是一个按固定流程组织子 agent 的调度者。
|
|
30
|
+
|
|
31
|
+
【你是谁】
|
|
32
|
+
你是「AgentFlow」。
|
|
33
|
+
这个流程共 6 个节点、5 层:大纲 → 对白版 / 下游卡片 → 人物版 → 合并 → 下游卡片。
|
|
34
|
+
|
|
35
|
+
【第一步:对齐需求】
|
|
36
|
+
动手前必须先把需求问清楚,最多问 3 个问题、一次问完:
|
|
37
|
+
- 这次的题材(主题)是什么?
|
|
38
|
+
- 期望的篇幅大概多少?
|
|
39
|
+
- 主要人物有哪些已有设定?
|
|
40
|
+
信息够了就说「开始执行」,不要边问边跑。
|
|
41
|
+
|
|
42
|
+
【流程】
|
|
43
|
+
第 1 层(串行)
|
|
44
|
+
▸ 大纲 —— 根据给定的题材,写一个三幕剧的简要大纲,每幕两三句话用修仙类的。11
|
|
45
|
+
完成标准:三幕结构清晰,每幕有一个明确转折.
|
|
46
|
+
用模型:deepseek-flash
|
|
47
|
+
参考技能:caveman、grill-me
|
|
48
|
+
|
|
49
|
+
第 2 层(并行,两个同时下发)
|
|
50
|
+
▸ 对白版 —— 基于大纲,为关键场景写几句有张力的对白。
|
|
51
|
+
完成标准:对白有潜台词,不要直白解释情绪
|
|
52
|
+
用模型:deepseek-flash
|
|
53
|
+
|
|
54
|
+
▸ 下游卡片
|
|
55
|
+
完成标准:(未填写)
|
|
56
|
+
用模型:deepseek-flash
|
|
57
|
+
|
|
58
|
+
第 3 层(等第 2 层全部完成)
|
|
59
|
+
▸ 人物版 —— 基于大纲,塑造主要人物的动机与成长弧线。
|
|
60
|
+
完成标准:主角有明确欲望、阻碍与转变
|
|
61
|
+
用模型:deepseek-flash
|
|
62
|
+
|
|
63
|
+
第 4 层(等第 3 层全部完成)
|
|
64
|
+
▸ 合并 —— 把两份材料合并成一份完整的三幕剧梗概,约 300 字。
|
|
65
|
+
完成标准:读起来是一个连贯故事,不是拼接
|
|
66
|
+
用模型:deepseek-flash
|
|
67
|
+
|
|
68
|
+
第 5 层(独立节点,可单独下发)
|
|
69
|
+
▸ 下游卡片
|
|
70
|
+
完成标准:(未填写)
|
|
71
|
+
用模型:deepseek-flash
|
|
72
|
+
|
|
73
|
+
【怎么下发】
|
|
74
|
+
- 每个节点用一次 `subagent` 工具;prompt 里给全:任务 + 完成标准 + 上游产出
|
|
75
|
+
- 同一层的多个节点同时下发,不要一个个等
|
|
76
|
+
- 上游产出原样传给下游,不要自己改写或概括
|
|
77
|
+
- 子 agent 如果还有自己的子任务,把它的子任务一并写进它的 prompt,让它继续嵌套
|
|
78
|
+
|
|
79
|
+
【收尾】
|
|
80
|
+
全部跑完,把最终产出交给用户。中间有节点失败要说清楚是哪个、为什么,不要假装成功。
|
|
81
|
+
- id: agent-instructions
|
|
82
|
+
name: '@deepseek-ai/dsh-agent-instructions'
|
|
83
|
+
config:
|
|
84
|
+
maxBytes: 65536
|
|
85
|
+
- id: time-context
|
|
86
|
+
name: '@deepseek-ai/dsh-time-context'
|
|
87
|
+
- id: tool-bash
|
|
88
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
89
|
+
disabled: !!js process.platform === 'win32'
|
|
90
|
+
- id: tool-pwsh
|
|
91
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
92
|
+
disabled: !!js process.platform !== 'win32'
|
|
93
|
+
- id: tool-fs
|
|
94
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
95
|
+
- id: tool-fs-search
|
|
96
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
97
|
+
config:
|
|
98
|
+
sampleOverCapGlobResults: false
|
|
99
|
+
- id: tool-jobs
|
|
100
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
101
|
+
- id: tool-schedule
|
|
102
|
+
name: '@deepseek-ai/dsh-tool-schedule'
|
|
103
|
+
- id: skill-filesystem
|
|
104
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
105
|
+
- id: tool-skill
|
|
106
|
+
name: '@deepseek-ai/dsh-tool-skill'
|
|
107
|
+
- id: command-goal
|
|
108
|
+
name: '@deepseek-ai/dsh-command-goal'
|
|
109
|
+
- id: tool-goal
|
|
110
|
+
name: '@deepseek-ai/dsh-tool-goal'
|
|
111
|
+
- id: planning
|
|
112
|
+
name: cordis:group
|
|
113
|
+
group: true
|
|
114
|
+
isolate:
|
|
115
|
+
planMode: true
|
|
116
|
+
config:
|
|
117
|
+
- id: plan-mode
|
|
118
|
+
name: '@deepseek-ai/dsh-plan-mode'
|
|
119
|
+
config:
|
|
120
|
+
section: |
|
|
121
|
+
You are in plan mode. Stay in plan mode until the user approves your plan through exit_plan_mode or switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
|
122
|
+
|
|
123
|
+
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
|
124
|
+
|
|
125
|
+
The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
|
|
126
|
+
|
|
127
|
+
Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
|
|
128
|
+
|
|
129
|
+
Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
|
|
130
|
+
|
|
131
|
+
When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
|
|
132
|
+
- id: compaction
|
|
133
|
+
name: cordis:group
|
|
134
|
+
group: true
|
|
135
|
+
isolate:
|
|
136
|
+
compaction: true
|
|
137
|
+
toolResultPruner: true
|
|
138
|
+
config:
|
|
139
|
+
- id: compaction-basic
|
|
140
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
141
|
+
- id: command-compact
|
|
142
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
143
|
+
- id: tool-result-pruner
|
|
144
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
145
|
+
config:
|
|
146
|
+
thresholdChars: 8192
|
|
147
|
+
headChars: 4096
|
|
148
|
+
tailChars: 1024
|
|
149
|
+
- id: delegation
|
|
150
|
+
name: cordis:group
|
|
151
|
+
group: true
|
|
152
|
+
isolate:
|
|
153
|
+
workflowEngine: true
|
|
154
|
+
config:
|
|
155
|
+
- id: tool-subagent-control
|
|
156
|
+
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
157
|
+
- id: tool-subagent-list-agents
|
|
158
|
+
name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
|
|
159
|
+
- id: tool-subagent
|
|
160
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
161
|
+
config:
|
|
162
|
+
provider: spawn
|
|
163
|
+
toolName: subagent
|
|
164
|
+
modelSelectionSettings: true
|
|
165
|
+
- id: tool-subagent-fork
|
|
166
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
167
|
+
config:
|
|
168
|
+
provider: fork
|
|
169
|
+
toolName: subagent_fork
|
|
170
|
+
- id: workflow-ptc
|
|
171
|
+
name: '@deepseek-ai/dsh-workflow-ptc'
|
|
172
|
+
config:
|
|
173
|
+
provider: spawn
|
|
174
|
+
- id: tool-workflow
|
|
175
|
+
name: '@deepseek-ai/dsh-tool-workflow'
|
|
176
|
+
- id: tool-ask-user
|
|
177
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
178
|
+
- id: tool-todo
|
|
179
|
+
name: '@deepseek-ai/dsh-tool-todo'
|
|
180
|
+
config:
|
|
181
|
+
allowParallelInProgress: true
|
|
182
|
+
- id: tool-web
|
|
183
|
+
name: '@deepseek-ai/dsh-tool-web'
|
|
184
|
+
config:
|
|
185
|
+
fetch: false
|
|
186
|
+
searchTimeoutMs: 60000
|
|
187
|
+
- id: present
|
|
188
|
+
name: '@deepseek-ai/dsh-tool-present'
|
|
189
|
+
- id: tool-plugin-manager
|
|
190
|
+
name: '@deepseek-ai/dsh-plugin-manager/tools'
|
|
191
|
+
disabled: true
|
|
192
|
+
- id: tool-plugin-market
|
|
193
|
+
name: '@deepseek-ai/dsh-plugin-market/tools'
|
|
194
|
+
disabled: true
|
|
195
|
+
# <<< AgentFlow 预设结束
|