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