@huanlin/dsh-plugin-sleep 0.1.3 → 0.1.4
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 +100 -100
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<a href="https://dshfind.com/zh/plugins/huanlinoto/dsh-plugin-sleep"><img src="https://dshfind.com/api/card/huanlinoto/dsh-plugin-sleep?lang=zh" alt="dsh-plugin-sleep card"></a>
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
# dsh-sleep
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/@huanlin/dsh-plugin-sleep)
|
|
8
|
-
|
|
9
|
-
DSH 插件:向模型暴露一个 `sleep` 工具,让模型按指定毫秒数暂停执行后再返回。适合等待时间相关条件成立(服务重启、debounce 窗口、retry backoff)且没有事件型工具可用的场景。
|
|
10
|
-
|
|
11
|
-
## 安装
|
|
12
|
-
|
|
13
|
-
```sh
|
|
14
|
-
# 从 npm 安装(推荐):
|
|
15
|
-
dsh plugin --profile web add @huanlin/dsh-plugin-sleep
|
|
16
|
-
|
|
17
|
-
# 从本地 checkout 开发安装:
|
|
18
|
-
dsh plugin --profile web add link:D:\Projects\deepseek-harness\dsh-sleep
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
预构建策略:`lib/` 入库,无 `prepare` 脚本,npm 安装开箱即用,无需 `allowBuilds`。
|
|
22
|
-
|
|
23
|
-
## 配置
|
|
24
|
-
|
|
25
|
-
在 DSH GUI 设置页或 `cordis.patch.yml` 中配置:
|
|
26
|
-
|
|
27
|
-
| 字段 | 类型 | 默认值 | 说明 |
|
|
28
|
-
|------|------|--------|------|
|
|
29
|
-
| `maxDurationMs` | number | `60000` | 单次 sleep 上限毫秒数。超过会被 clamp 到此值,并在返回中标 `clamped: true`。 |
|
|
30
|
-
| `defaultDurationMs` | number | `0` | 当模型省略 `duration_ms` 时的回退值。 |
|
|
31
|
-
|
|
32
|
-
## 工具
|
|
33
|
-
|
|
34
|
-
### `sleep`
|
|
35
|
-
|
|
36
|
-
暂停 N 毫秒后返回。
|
|
37
|
-
|
|
38
|
-
**参数:**
|
|
39
|
-
|
|
40
|
-
| 参数 | 类型 | 必填 | 说明 |
|
|
41
|
-
|------|------|------|------|
|
|
42
|
-
| `duration_ms` | integer | 是 | 暂停毫秒数,必须 ≥ 0。超过 `maxDurationMs` 会被 clamp。 |
|
|
43
|
-
| `reason` | string | 否 | 人类可读的暂停理由,会原样回显。 |
|
|
44
|
-
|
|
45
|
-
**返回(规范 JSON):**
|
|
46
|
-
|
|
47
|
-
```jsonc
|
|
48
|
-
{
|
|
49
|
-
"requested_ms": 1000, // 调用方原始请求值
|
|
50
|
-
"actual_ms": 1002, // 实际等待毫秒数
|
|
51
|
-
"cancelled": false, // 是否被 abort 信号中断
|
|
52
|
-
"clamped": false, // 是否因超过 maxDurationMs 被钳制
|
|
53
|
-
"reason": "..." // 可选回显
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
取消语义:如果 sleep 中途 `exec.signal` 被 abort,工具**不抛错**,而是立即返回 `cancelled: true`(取消属于业务非理想态,不属基础设施失败,参见 `plugin-development-guide.md` §3 C5)。
|
|
58
|
-
|
|
59
|
-
## 开发
|
|
60
|
-
|
|
61
|
-
```sh
|
|
62
|
-
pnpm install # 安装开发依赖(schemastery、typescript、vitest)
|
|
63
|
-
pnpm run typecheck # tsc --noEmit 类型检查
|
|
64
|
-
pnpm test # vitest run 单元测试
|
|
65
|
-
pnpm run build # tsc + tsdown → lib/
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## 检查
|
|
69
|
-
|
|
70
|
-
合规自检(参见 `plugin-development-guide.md` §10):
|
|
71
|
-
|
|
72
|
-
- [x] **零源码 patch**:未修改 DSH checkout 任何文件
|
|
73
|
-
- [x] B1: `package.json` 声明 `dsh.bundle.patch`
|
|
74
|
-
- [x] B2: 插件自带 `cordis.patch.yml`(insert 行 id/name/config 齐全)
|
|
75
|
-
- [x] B3: patch 行 `name` 用包名(Loader 从 profile node_modules 解析)
|
|
76
|
-
- [x] F1: `files` 含 `lib/` + `cordis.patch.yml`
|
|
77
|
-
- [x] F2: `peerDependencies` 含 cordis + `@deepseek-ai/dsh-tools`(不用 devDependencies 冒充)
|
|
78
|
-
- [x] F3: typecheck/test/build script 齐全
|
|
79
|
-
- [x] A4: Config 用 Schemastery schema
|
|
80
|
-
- [x] A6: 不导出 default
|
|
81
|
-
- [x] C4: 工具返回规范 JSON 值 + render 投影分离
|
|
82
|
-
- [x] C6: 尊重 `exec.signal` 取消在途工作
|
|
83
|
-
- [x] G: Unit 测试(`tests/tools.spec.ts`,35+ 用例)
|
|
84
|
-
|
|
85
|
-
## 目录结构
|
|
86
|
-
|
|
87
|
-
```
|
|
88
|
-
dsh-sleep/
|
|
89
|
-
├── src/
|
|
90
|
-
│ ├── index.ts # 入口:name、inject、Config(Schemastery)、apply
|
|
91
|
-
│ ├── tools.ts # sleep 工具定义 + 可取消等待逻辑 + render 投影
|
|
92
|
-
│ └── types.d.ts # @deepseek-ai/dsh-tools + cordis 的环境类型声明
|
|
93
|
-
├── tests/
|
|
94
|
-
│ └── tools.spec.ts # 单元测试(覆盖正常/取消/clamp/边界)
|
|
95
|
-
├── cordis.patch.yml # bundle 层:插入 dsh-sleep 插件行
|
|
96
|
-
├── package.json # dsh.bundle.patch 声明 + peerDeps
|
|
97
|
-
├── tsconfig.json # NodeNext、ES2022、strict
|
|
98
|
-
├── tsdown.config.ts # 单 entry(host-only,无 client bundle)
|
|
99
|
-
└── vitest.config.ts # vitest forks pool
|
|
100
|
-
```
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://dshfind.com/zh/plugins/huanlinoto/dsh-plugin-sleep"><img src="https://dshfind.com/api/card/huanlinoto/dsh-plugin-sleep?lang=zh" alt="dsh-plugin-sleep card"></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# dsh-sleep
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@huanlin/dsh-plugin-sleep)
|
|
8
|
+
|
|
9
|
+
DSH 插件:向模型暴露一个 `sleep` 工具,让模型按指定毫秒数暂停执行后再返回。适合等待时间相关条件成立(服务重启、debounce 窗口、retry backoff)且没有事件型工具可用的场景。
|
|
10
|
+
|
|
11
|
+
## 安装
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
# 从 npm 安装(推荐):
|
|
15
|
+
dsh plugin --profile web add @huanlin/dsh-plugin-sleep
|
|
16
|
+
|
|
17
|
+
# 从本地 checkout 开发安装:
|
|
18
|
+
dsh plugin --profile web add link:D:\Projects\deepseek-harness\dsh-sleep
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
预构建策略:`lib/` 入库,无 `prepare` 脚本,npm 安装开箱即用,无需 `allowBuilds`。
|
|
22
|
+
|
|
23
|
+
## 配置
|
|
24
|
+
|
|
25
|
+
在 DSH GUI 设置页或 `cordis.patch.yml` 中配置:
|
|
26
|
+
|
|
27
|
+
| 字段 | 类型 | 默认值 | 说明 |
|
|
28
|
+
|------|------|--------|------|
|
|
29
|
+
| `maxDurationMs` | number | `60000` | 单次 sleep 上限毫秒数。超过会被 clamp 到此值,并在返回中标 `clamped: true`。 |
|
|
30
|
+
| `defaultDurationMs` | number | `0` | 当模型省略 `duration_ms` 时的回退值。 |
|
|
31
|
+
|
|
32
|
+
## 工具
|
|
33
|
+
|
|
34
|
+
### `sleep`
|
|
35
|
+
|
|
36
|
+
暂停 N 毫秒后返回。
|
|
37
|
+
|
|
38
|
+
**参数:**
|
|
39
|
+
|
|
40
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
41
|
+
|------|------|------|------|
|
|
42
|
+
| `duration_ms` | integer | 是 | 暂停毫秒数,必须 ≥ 0。超过 `maxDurationMs` 会被 clamp。 |
|
|
43
|
+
| `reason` | string | 否 | 人类可读的暂停理由,会原样回显。 |
|
|
44
|
+
|
|
45
|
+
**返回(规范 JSON):**
|
|
46
|
+
|
|
47
|
+
```jsonc
|
|
48
|
+
{
|
|
49
|
+
"requested_ms": 1000, // 调用方原始请求值
|
|
50
|
+
"actual_ms": 1002, // 实际等待毫秒数
|
|
51
|
+
"cancelled": false, // 是否被 abort 信号中断
|
|
52
|
+
"clamped": false, // 是否因超过 maxDurationMs 被钳制
|
|
53
|
+
"reason": "..." // 可选回显
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
取消语义:如果 sleep 中途 `exec.signal` 被 abort,工具**不抛错**,而是立即返回 `cancelled: true`(取消属于业务非理想态,不属基础设施失败,参见 `plugin-development-guide.md` §3 C5)。
|
|
58
|
+
|
|
59
|
+
## 开发
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
pnpm install # 安装开发依赖(schemastery、typescript、vitest)
|
|
63
|
+
pnpm run typecheck # tsc --noEmit 类型检查
|
|
64
|
+
pnpm test # vitest run 单元测试
|
|
65
|
+
pnpm run build # tsc + tsdown → lib/
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 检查
|
|
69
|
+
|
|
70
|
+
合规自检(参见 `plugin-development-guide.md` §10):
|
|
71
|
+
|
|
72
|
+
- [x] **零源码 patch**:未修改 DSH checkout 任何文件
|
|
73
|
+
- [x] B1: `package.json` 声明 `dsh.bundle.patch`
|
|
74
|
+
- [x] B2: 插件自带 `cordis.patch.yml`(insert 行 id/name/config 齐全)
|
|
75
|
+
- [x] B3: patch 行 `name` 用包名(Loader 从 profile node_modules 解析)
|
|
76
|
+
- [x] F1: `files` 含 `lib/` + `cordis.patch.yml`
|
|
77
|
+
- [x] F2: `peerDependencies` 含 cordis + `@deepseek-ai/dsh-tools`(不用 devDependencies 冒充)
|
|
78
|
+
- [x] F3: typecheck/test/build script 齐全
|
|
79
|
+
- [x] A4: Config 用 Schemastery schema
|
|
80
|
+
- [x] A6: 不导出 default
|
|
81
|
+
- [x] C4: 工具返回规范 JSON 值 + render 投影分离
|
|
82
|
+
- [x] C6: 尊重 `exec.signal` 取消在途工作
|
|
83
|
+
- [x] G: Unit 测试(`tests/tools.spec.ts`,35+ 用例)
|
|
84
|
+
|
|
85
|
+
## 目录结构
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
dsh-sleep/
|
|
89
|
+
├── src/
|
|
90
|
+
│ ├── index.ts # 入口:name、inject、Config(Schemastery)、apply
|
|
91
|
+
│ ├── tools.ts # sleep 工具定义 + 可取消等待逻辑 + render 投影
|
|
92
|
+
│ └── types.d.ts # @deepseek-ai/dsh-tools + cordis 的环境类型声明
|
|
93
|
+
├── tests/
|
|
94
|
+
│ └── tools.spec.ts # 单元测试(覆盖正常/取消/clamp/边界)
|
|
95
|
+
├── cordis.patch.yml # bundle 层:插入 dsh-sleep 插件行
|
|
96
|
+
├── package.json # dsh.bundle.patch 声明 + peerDeps
|
|
97
|
+
├── tsconfig.json # NodeNext、ES2022、strict
|
|
98
|
+
├── tsdown.config.ts # 单 entry(host-only,无 client bundle)
|
|
99
|
+
└── vitest.config.ts # vitest forks pool
|
|
100
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huanlin/dsh-plugin-sleep",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
36
|
-
"@deepseek-ai/dsh-tools": "^0.1.
|
|
37
|
-
"@deepseek-ai/dsh-llm": "^0.1.
|
|
36
|
+
"@deepseek-ai/dsh-tools": "^0.1.5-rc.1",
|
|
37
|
+
"@deepseek-ai/dsh-llm": "^0.1.5-rc.1"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"@deepseek-ai/cordis": {
|
|
@@ -48,6 +48,8 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
+
"@deepseek-ai/cordis": "link:D:/Projects/deepseek-harness/dsh/vendor/cordis",
|
|
52
|
+
"@deepseek-ai/dsh-tools": "link:D:/Projects/deepseek-harness/dsh/packages/core/tools",
|
|
51
53
|
"@types/node": "^22.20.0",
|
|
52
54
|
"tsdown": "^0.22.2",
|
|
53
55
|
"typescript": "^5.9.0",
|