dsh-auto-flow 0.1.0 → 0.1.2
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/LICENSE +1 -1
- package/README.md +37 -46
- package/cordis.patch.yml +3 -24
- package/lib/client.js +20569 -519
- package/lib/index.d.ts +185 -107
- package/lib/index.js +2915 -420
- package/lib/typert.host.js +623 -155
- package/lib/typert.remote-client.d.ts +25 -13
- package/lib/typert.remote-client.js +446 -96
- package/lib/types.d.ts +2 -106
- package/lib/types.js +7 -1
- package/package.json +39 -28
package/LICENSE
CHANGED
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,41 +1,40 @@
|
|
|
1
|
-
#
|
|
1
|
+
# DeepSeek Harness 插件
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
DeepSeek Harness 插件 Bundle(Host 半 + Client 半同包),一个**确定性工作流插件**:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- **@Remote 严格模式**(`AutoFlowService`)——Host 服务,浏览器经 `ctx.remote.autoFlow` 调用,双向 zod 校验 + 完整类型,契约由 `pnpm typert:gen` 生成(`lib/typert.*`,提交进 git)。
|
|
6
|
+
- **工作流编辑器**:React Flow 画布 + 节点系统,画布经 `loadFlow`/`saveFlow` 落 domain storage。
|
|
7
|
+
- 编排节点:表单(数据源)/ 运行脚本(playwright-ag)/ 人工审批(屏障)。
|
|
8
|
+
- 值传递节点:文本模板 / AI 模型 / 图片识别 / 执行命令 / HTTP 请求 / 条件分支 / 输出,
|
|
9
|
+
支持 `{{input.*}}`、`{{steps.<节点id>}}`、`{{current}}` 插值与 true/false 分支剪枝。
|
|
10
|
+
- **执行引擎**:按层级并发调度脚本节点(同层独立脚本并行),审批节点是串行人工屏障;脚本经 playwright-ag 运行,产物落 `<workspaceDir>/<runId>/<index>-<script>/`,人工在审批面板对产物做增删改查后放行/驳回。
|
|
11
|
+
- **可运行脚本目录**:脚本清单(展示名 / 描述 / 参数 / 产物装配规则)由 playwright-ag 脚本自描述、经 `listScripts` 下发;本插件对具体业务脚本零感知。
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
- **轻执行也走 @Remote**:`exec` 方法在宿主内经 `ctx.shell`(与 bash 工具同一执行器,绝不经过模型)执行命令行,返回结构化结果(`exitCode`/`signal`/`stdout`/`stderr` 等),**输出只回调用方 UI,不进会话日志、不动界面**;shell 是可选依赖,未组合 shell 提供方时 `exec` 报错、插件其余部分照常工作。
|
|
9
|
-
- **注意**:内置 `ctx.remote.commands.execute` 是**会话命令通道**——结果会生成 durable 命令节点进会话并驱动界面(斜杠命令语义),仅用于"就是要当命令用"的场景;模板不拿它演示机器执行,以免污染会话。
|
|
10
|
-
- **模型工具**:`plugin_auto_flow` 复用上面的服务。
|
|
11
|
-
- **持久化只进 domain storage**:问候落 domain storage(与 session 日志隔离);不追加自定义会话事件(harness 持久化读路径会拒绝未知事件类型,且 `Session.append` 无法标记 `ignorable`)。
|
|
13
|
+
> English TL;DR: A dsh plugin bundle implementing a deterministic workflow editor + engine — strict `@Remote` RPC, a React Flow canvas with a node system (form / script / approval), concurrent script execution with serial human-approval gates, and workspace artifact CRUD. Scripts run via the playwright-ag plugin.
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
## 能力清单
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
| 客户端 UI 槽位(slots) | `ui-goal`、`ui-message-feedback` | `conversation.input.dock` 等三槽位 |
|
|
26
|
-
| 多语言 locale | `ui-*` 的 `locales.ts` | `src/client/locales.ts` |
|
|
27
|
-
| 跨插件服务协作 | Cordis `Service` | `dsh-auto-flow-core` 的 `autoFlowFormatter` |
|
|
17
|
+
| 能力 | 位置 |
|
|
18
|
+
| ------------------------------ | -------------------------------------------------------------------------- |
|
|
19
|
+
| `@Remote` 严格模式 | `src/host/service.ts` 的 `loadFlow` / `saveFlow` / `runFlow` 等 |
|
|
20
|
+
| 执行引擎(并发 + 审批 + 取消) | `src/host/engine.ts` + `src/host/service.ts` 的 `cancelRun` |
|
|
21
|
+
| 环检测 | `src/workflow/pipeline.ts` 的 `detectCycle` |
|
|
22
|
+
| 脚本目录(playwright-ag) | `src/host/service.ts` 的 `listScripts` + `src/client/.../scriptCatalog.ts` |
|
|
23
|
+
| 插件 Config + 设置 UI | `src/host/config.ts`(workspaceDir)+ `features/settings` |
|
|
24
|
+
| 持久化(domain storage) | `src/host/domain.ts`(flows / runs) |
|
|
25
|
+
| 客户端 UI 槽位(slots) | `src/client/features/*`(`conversation.input.dock` 等) |
|
|
26
|
+
| 多语言 locale | `src/client/features/*/locales.ts` + `locales.ts` 聚合 |
|
|
28
27
|
|
|
29
28
|
## 开发
|
|
30
29
|
|
|
31
30
|
```sh
|
|
32
|
-
pnpm install #
|
|
31
|
+
pnpm install # 安装全部工作区依赖
|
|
33
32
|
pnpm typert:gen # 首次必跑:生成 @Remote 契约(lib/typert.*),之后改动签名时重跑
|
|
34
33
|
pnpm dev # 开发:tsdown --watch 双段(含首次构建)
|
|
35
34
|
pnpm typecheck # 三程序检查:Host + Client + 默认程序(tsconfig.json,均不 emit)
|
|
36
35
|
pnpm test # 单测:Host 半 + 浏览器半 jsdom(需先跑过 typert:gen)
|
|
37
36
|
pnpm build # 一次性构建产物(发布用)
|
|
38
|
-
pnpm check # 一键门禁:
|
|
37
|
+
pnpm check # 一键门禁:typecheck + test + build(发布前跑)
|
|
39
38
|
```
|
|
40
39
|
|
|
41
40
|
### 热更新边界
|
|
@@ -60,41 +59,35 @@ dsh plugin --profile web add "<workspace>/packages/dsh-auto-flow"
|
|
|
60
59
|
|
|
61
60
|
`@Remote` 走 Typert 严格模式。**改了方法签名、导出名或参数类型后**运行 `pnpm typert:gen`。
|
|
62
61
|
生成器按工作区原生布局登记 `packages/*`;唯一适配是 `scripts/patch-typert-generator.mjs`
|
|
63
|
-
|
|
64
|
-
识别为协议符号,第三方仓库以 npm 依赖安装时需要此扩展)。生成器升级后由脚本内两处
|
|
65
|
-
**锚点检查**拦截:协议归属锚点失配报 `cannot apply the single protocol-owner patch`,
|
|
66
|
-
helper 插入点失配报 `cannot locate analyzer helper insertion point`——两种情况都按
|
|
67
|
-
报错更新该脚本的对应锚点即可)。
|
|
62
|
+
的协议归属补丁(生成器升级后由脚本内锚点检查拦截失效并报错,按报错更新锚点即可)。
|
|
68
63
|
|
|
69
64
|
产物 `lib/typert.*` 随发布提交(日常不提交 `lib/`,发布时 `git add -f packages/*/lib`),
|
|
70
65
|
GitHub 安装免构建。
|
|
71
66
|
|
|
72
67
|
## 插件配置
|
|
73
68
|
|
|
74
|
-
`src/
|
|
69
|
+
`src/host/config.ts` 的 `Config` 是插件配置,可在 Profile 的 `cordis.patch.yml` 里按行覆盖:
|
|
75
70
|
|
|
76
71
|
```yaml
|
|
77
72
|
- id: dsh-auto-flow
|
|
78
73
|
config:
|
|
79
|
-
|
|
80
|
-
maxCommandBytes: 1024
|
|
74
|
+
workspaceDir: workflow-runs
|
|
81
75
|
```
|
|
82
76
|
|
|
83
77
|
## 对齐官方(验收线)
|
|
84
78
|
|
|
85
|
-
- **结构 / 命名 / 依赖分层**:Host 半 default-export `class X extends TypertRemoteService`,Client 半 `inject` / `apply`;`dsh.bundle.patch` + `dsh.client` 双声明同包;exports / files
|
|
79
|
+
- **结构 / 命名 / 依赖分层**:Host 半 default-export `class X extends TypertRemoteService`,Client 半 `inject` / `apply`;`dsh.bundle.patch` + `dsh.client` 双声明同包;exports / files 分层对齐官方插件。
|
|
86
80
|
- **两类 schema**:插件 `Config` 用 schemastery(`z`),持久化记录用 zod。
|
|
87
|
-
- **注册即 effect**:每个贡献走 `ctx.effect` / 注册表返回的 disposer;可选 seam 用 `ctx.inject([...], cb)`;可选服务(
|
|
88
|
-
- **持久化只进 domain storage
|
|
89
|
-
- **Typed Remote 失败**:`RemoteErrorDetailsMap` 声明 `autoFlow/command-too-long`。
|
|
81
|
+
- **注册即 effect**:每个贡献走 `ctx.effect` / 注册表返回的 disposer;可选 seam 用 `ctx.inject([...], cb)`;可选服务(playwright-ag / storageDomain)用 `ctx.get(...)`。
|
|
82
|
+
- **持久化只进 domain storage**:运行快照落 domain storage(与 session 日志隔离);不追加自定义会话事件。
|
|
90
83
|
|
|
91
84
|
## 发布
|
|
92
85
|
|
|
93
86
|
npm(每包独立版本)。**发布前两件事**:
|
|
94
87
|
|
|
95
|
-
1. **登录 npmjs**:`npm login --registry=https://registry.npmjs.org
|
|
96
|
-
2. **包名可用性**:无 scope 的通用名(`dsh
|
|
97
|
-
3.
|
|
88
|
+
1. **登录 npmjs**:`npm login --registry=https://registry.npmjs.org/`。
|
|
89
|
+
2. **包名可用性**:无 scope 的通用名(`dsh-*`)容易被占用/保留,建议用你有所有权的 scope(`publishConfig.access: public` 已配好)。
|
|
90
|
+
3. **补全发布元数据**:把 `package.json` 的 `repository` / `bugs` / `homepage` / `keywords` 换成你的真实仓库信息。
|
|
98
91
|
|
|
99
92
|
```sh
|
|
100
93
|
pnpm publish:npm # prepublishOnly 自动 typert:gen + test + build
|
|
@@ -110,20 +103,18 @@ git push --tags
|
|
|
110
103
|
|
|
111
104
|
## 安装(用户侧)
|
|
112
105
|
|
|
113
|
-
命令里的包名/git
|
|
106
|
+
命令里的包名/git 地址统一用**双引号**包住。
|
|
114
107
|
|
|
115
108
|
```sh
|
|
116
109
|
dsh plugin --profile web add "dsh-auto-flow" # npm
|
|
117
110
|
dsh plugin --profile web remove "dsh-auto-flow" # npm 卸载
|
|
118
111
|
dsh plugin --profile web add "github:you/<repo>#dsh-auto-flow@v0.1.0" # GitHub(monorepo 子包)
|
|
119
|
-
dsh plugin --profile web remove "dsh-auto-flow" # GitHub 卸载
|
|
120
112
|
dsh plugin --profile web add "../<workspace>/packages/dsh-auto-flow" # 本地目录
|
|
121
113
|
```
|
|
122
114
|
|
|
123
115
|
## 常见问题
|
|
124
116
|
|
|
125
|
-
- **为什么把 `lib/` 提交进 git?** dsh 经 GitHub
|
|
126
|
-
- **首次 `pnpm build` / `pnpm test` 报找不到 `<包名>/remote`?** 先运行 `pnpm typert:gen
|
|
127
|
-
-
|
|
128
|
-
-
|
|
129
|
-
- **`pnpm publish:npm` 报 `E404 PUT ... - Not found`?** 两件事:① `npm login --registry=https://registry.npmjs.org/`(未登录 npmjs;全局 registry 若在 npmmirror 会误导);② 包名对 npmjs 不可创建(无 scope 通用名被占用/保留)——改用你有所有权的 scope 名(`@你的scope/xxx`)。
|
|
117
|
+
- **为什么把 `lib/` 提交进 git?** dsh 经 GitHub 安装插件时不触发构建,提交产物让安装开箱即用。
|
|
118
|
+
- **首次 `pnpm build` / `pnpm test` 报找不到 `<包名>/remote`?** 先运行 `pnpm typert:gen`。
|
|
119
|
+
- **运行工作流报 `playwright-missing`?** 未安装 playwright-ag 插件;装 `plugin_playwright_ag` 后重试。
|
|
120
|
+
- **运行报 `cycle-detected`?** 画布里存在环,检查连线后重跑。
|
package/cordis.patch.yml
CHANGED
|
@@ -1,33 +1,12 @@
|
|
|
1
1
|
# dsh-auto-flow 的 Bundle 补丁层:向 Profile 组合插入一个插件行。
|
|
2
|
+
# dsh plugin add 安装后,Loader 按这里的行挂载 Host 半;浏览器半由 dsh.client 声明自动接入。
|
|
2
3
|
#
|
|
3
|
-
#
|
|
4
|
-
# 这里的行会被 Loader 挂载(`name` 指向本包,即 Host 半),
|
|
5
|
-
# 浏览器半由包里的 dsh.client 声明自动接入,无需在此声明。
|
|
6
|
-
#
|
|
7
|
-
# 覆盖本插件配置示例(对应 src/index.ts 的 Config,取消注释即可用):
|
|
8
|
-
#
|
|
4
|
+
# 覆盖本插件配置(对应 src/host/config.ts 的 Config):
|
|
9
5
|
# - insert:
|
|
10
6
|
# - id: dsh-auto-flow
|
|
11
7
|
# name: 'dsh-auto-flow'
|
|
12
8
|
# config:
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
# 覆写其它插件配置(跨插件协作):补丁可以按 id 覆写组合里其它插件的配置,
|
|
16
|
-
# 例如给 dsh 内置的视觉适配器声明一条 OpenAI 兼容路由(密钥走环境变量/ .env,
|
|
17
|
-
# 不要写进 patch):
|
|
18
|
-
#
|
|
19
|
-
# - id: llm-pi-ai
|
|
20
|
-
# config:
|
|
21
|
-
# providers:
|
|
22
|
-
# studio-vision:
|
|
23
|
-
# displayName: Studio Vision
|
|
24
|
-
# apiKeyEnv: YOUR_API_KEY
|
|
25
|
-
# api: openai-completions
|
|
26
|
-
# baseURL: https://your-gateway.example.com/v1
|
|
27
|
-
# defaultInput: [text, image]
|
|
28
|
-
# models:
|
|
29
|
-
# - id: your-vl-model
|
|
30
|
-
# input: [text, image]
|
|
9
|
+
# workspaceDir: workflow-runs
|
|
31
10
|
- insert:
|
|
32
11
|
- id: dsh-auto-flow
|
|
33
12
|
name: 'dsh-auto-flow'
|