@deepseek-ai/dsh-error 0.0.0-stage → 0.2.2-rc.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 +21 -0
- package/README.i18n.yaml +34 -0
- package/README.md +75 -2
- package/README.zh.md +76 -0
- package/lib/index.js +23 -0
- package/lib/types/index.d.ts +17 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js.map +1 -0
- package/package.json +35 -3
- package/src/index.ts +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
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.
|
package/README.i18n.yaml
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
|
|
2
|
+
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
|
3
|
+
# After editing either side, bring the other along and re-record with:
|
|
4
|
+
# pnpm run verify-translation-pairing --write packages/util/error/README.md
|
|
5
|
+
/:
|
|
6
|
+
en: 765d60b0cc7f8cf1
|
|
7
|
+
zh: 66b731f7143ccc5c
|
|
8
|
+
/deepseek-ai-dsh-error:
|
|
9
|
+
en: 78fc89983568c13f
|
|
10
|
+
zh: 12bb37d45b49562b
|
|
11
|
+
/deepseek-ai-dsh-error/summary:
|
|
12
|
+
en: eefb4278f326243a
|
|
13
|
+
zh: 681e25fc7d65865e
|
|
14
|
+
/deepseek-ai-dsh-error/table-of-contents:
|
|
15
|
+
en: c992e0cd2e7042d6
|
|
16
|
+
zh: 2e8cd826664632d1
|
|
17
|
+
/deepseek-ai-dsh-error/use-this-package:
|
|
18
|
+
en: 1b8c9b68ec9b48fc
|
|
19
|
+
zh: 4b0b54d3330b288b
|
|
20
|
+
/deepseek-ai-dsh-error/understand-the-implementation:
|
|
21
|
+
en: 42b15ac6321706aa
|
|
22
|
+
zh: 4ed0861911abaf5d
|
|
23
|
+
/deepseek-ai-dsh-error/understand-the-implementation/source-map:
|
|
24
|
+
en: a2e80abfe169f97f
|
|
25
|
+
zh: eb37e22c32f66add
|
|
26
|
+
/deepseek-ai-dsh-error/understand-the-implementation/why-it-stays-dependency-free:
|
|
27
|
+
en: 79564181c4c59db6
|
|
28
|
+
zh: 845856fa121b3ff7
|
|
29
|
+
/deepseek-ai-dsh-error/further-exploration:
|
|
30
|
+
en: 530bc3a0690a4012
|
|
31
|
+
zh: 192682c5a8571dfe
|
|
32
|
+
/deepseek-ai-dsh-error/dev-note:
|
|
33
|
+
en: 5de1d6304e00c58f
|
|
34
|
+
zh: 0087361e6f535488
|
package/README.md
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
description: "Dependency-free HarnessError base class whose stable code lets tool results, retries, and replay route failures."
|
|
3
|
+
kind: "package-library"
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# @deepseek-ai/dsh-error
|
|
7
|
+
|
|
8
|
+
English | [中文](README.zh.md)
|
|
9
|
+
|
|
10
|
+
## Summary
|
|
11
|
+
|
|
12
|
+
`dsh-error` holds `HarnessError`, the base class for every expected Harness failure. A `HarnessError` carries a stable machine-routable `code` beside its human-readable `message` and optional `cause`, and its `name` is the constructing class name. The tool registry records `name` and `code` of a thrown `HarnessError` on `tool/result`, so retry policy, UI, replay, and analytics route on the code instead of parsing text. The package has no dependencies, so packages below `dsh-llm` in the dependency graph can extend the base too; `dsh-llm` re-exports the same class.
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Use this package](#use-this-package)
|
|
17
|
+
- [Understand the implementation](#understand-the-implementation)
|
|
18
|
+
- [Further Exploration](#further-exploration)
|
|
19
|
+
- [Dev Note](#dev-note)
|
|
20
|
+
|
|
21
|
+
-----
|
|
22
|
+
|
|
23
|
+
<a id="use-this-package"></a>
|
|
24
|
+
## Use this package
|
|
25
|
+
|
|
26
|
+
Extend `HarnessError` with one class per owning package or domain and give each failure a stable `UPPER_SNAKE_CASE` code:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { HarnessError } from '@deepseek-ai/dsh-error'
|
|
30
|
+
|
|
31
|
+
export class ArchiveError extends HarnessError {}
|
|
32
|
+
|
|
33
|
+
throw new ArchiveError('archive entry is missing', 'ARCHIVE_ENTRY_NOT_FOUND')
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Assign `this.name` a string literal in a subclass constructor when a bundler could rename the class, because `name` is persisted. Import the class from `@deepseek-ai/dsh-error` or from its `@deepseek-ai/dsh-llm` re-export; both name the same class, so `instanceof` checks agree. The [error class and code guide](../../../.agents/skills/dsh-error-handling/references/error-codes.md) defines class choice, naming, and code conventions.
|
|
37
|
+
|
|
38
|
+
-----
|
|
39
|
+
|
|
40
|
+
<a id="understand-the-implementation"></a>
|
|
41
|
+
## Understand the implementation
|
|
42
|
+
|
|
43
|
+
<details>
|
|
44
|
+
<summary>Implementation internals — click to expand</summary>
|
|
45
|
+
|
|
46
|
+
### Source map
|
|
47
|
+
|
|
48
|
+
| File | Role |
|
|
49
|
+
|---|---|
|
|
50
|
+
| [`src/index.ts`](src/index.ts) | The `HarnessError` base class |
|
|
51
|
+
|
|
52
|
+
### Why it stays dependency-free
|
|
53
|
+
|
|
54
|
+
`dsh-llm` depends on lower packages such as `dsh-attachment` and `dsh-typert-protocol`, so a base class defined there could not be extended below it without a dependency cycle. Keeping the class in a package without dependencies lets every package extend it; the [decision note](../../../.agents/notes/implemented/architecture/2026-11-05-harness-error-dependency-free-base.md) records the relocation.
|
|
55
|
+
|
|
56
|
+
</details>
|
|
57
|
+
|
|
58
|
+
-----
|
|
59
|
+
|
|
60
|
+
<a id="further-exploration"></a>
|
|
61
|
+
## Further Exploration
|
|
62
|
+
|
|
63
|
+
- [Tools subsystem](../../../docs/subsystems/tools.md) — how the registry records `ToolErrorInfo` from a thrown `HarnessError`.
|
|
64
|
+
- [Error-handling rules](../../../.agents/skills/dsh-error-handling/SKILL.md) — when code must throw a `HarnessError`.
|
|
65
|
+
|
|
66
|
+
-----
|
|
67
|
+
|
|
68
|
+
<a id="dev-note"></a>
|
|
69
|
+
## Dev Note
|
|
70
|
+
|
|
71
|
+
<details>
|
|
72
|
+
<summary>Working context for maintainers — click to expand</summary>
|
|
73
|
+
|
|
74
|
+
None.
|
|
75
|
+
|
|
76
|
+
</details>
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "无依赖的 HarnessError 基类,其稳定 code 让工具结果、重试与回放能够按失败类别路由。"
|
|
3
|
+
kind: "package-library"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @deepseek-ai/dsh-error
|
|
7
|
+
|
|
8
|
+
[English](README.md) | 中文
|
|
9
|
+
|
|
10
|
+
## 概述
|
|
11
|
+
|
|
12
|
+
`dsh-error` 存放 `HarnessError`,即所有预期 Harness 失败的基类。`HarnessError` 在人类可读的 `message` 与可选的 `cause` 之外,携带稳定、可供机器路由的 `code`,其 `name` 为构造它的类名。工具注册表会把抛出的 `HarnessError` 的 `name` 与 `code` 记录到 `tool/result` 上,使重试策略、UI、回放与数据分析按 code 路由,而不必解析文本。本包没有任何依赖,因此依赖图中位于 `dsh-llm` 之下的包也能继承该基类;`dsh-llm` 会重新导出同一个类。
|
|
13
|
+
|
|
14
|
+
## 目录
|
|
15
|
+
|
|
16
|
+
- [使用本包](#use-this-package)
|
|
17
|
+
- [理解实现](#understand-the-implementation)
|
|
18
|
+
- [进一步探索](#further-exploration)
|
|
19
|
+
- [开发备注](#dev-note)
|
|
20
|
+
|
|
21
|
+
-----
|
|
22
|
+
|
|
23
|
+
<a id="use-this-package"></a>
|
|
24
|
+
## 使用本包
|
|
25
|
+
|
|
26
|
+
每个所属包或领域继承出一个 `HarnessError` 子类,并为每种失败指定稳定的 `UPPER_SNAKE_CASE` code:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { HarnessError } from '@deepseek-ai/dsh-error'
|
|
30
|
+
|
|
31
|
+
export class ArchiveError extends HarnessError {}
|
|
32
|
+
|
|
33
|
+
throw new ArchiveError('archive entry is missing', 'ARCHIVE_ENTRY_NOT_FOUND')
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
打包工具可能重命名类时,在子类构造函数中把 `this.name` 赋为字符串字面量,因为 `name` 会被持久化。可以从 `@deepseek-ai/dsh-error` 导入该类,也可以使用 `@deepseek-ai/dsh-llm` 的重新导出;两者是同一个类,因此 `instanceof` 判断结果一致。[错误类与 code 指南](../../../.agents/skills/dsh-error-handling/references/error-codes.md)规定了类的选择、命名与 code 约定。
|
|
37
|
+
|
|
38
|
+
-----
|
|
39
|
+
|
|
40
|
+
<a id="understand-the-implementation"></a>
|
|
41
|
+
## 理解实现
|
|
42
|
+
|
|
43
|
+
<details>
|
|
44
|
+
<summary>实现细节——点击展开</summary>
|
|
45
|
+
|
|
46
|
+
### 源码地图
|
|
47
|
+
|
|
48
|
+
| 文件 | 职责 |
|
|
49
|
+
|---|---|
|
|
50
|
+
| [`src/index.ts`](src/index.ts) | `HarnessError` 基类 |
|
|
51
|
+
|
|
52
|
+
### 为什么保持无依赖
|
|
53
|
+
|
|
54
|
+
`dsh-llm` 依赖 `dsh-attachment`、`dsh-typert-protocol` 等更底层的包,定义在其中的基类无法被这些包继承,否则会形成依赖环。把该类放在没有依赖的包中,所有包都可以继承它;[决策记录](../../../.agents/notes/implemented/architecture/2026-11-05-harness-error-dependency-free-base.zh.md)记录了这次迁移。
|
|
55
|
+
|
|
56
|
+
</details>
|
|
57
|
+
|
|
58
|
+
-----
|
|
59
|
+
|
|
60
|
+
<a id="further-exploration"></a>
|
|
61
|
+
## 进一步探索
|
|
62
|
+
|
|
63
|
+
- [工具子系统](../../../docs/subsystems/tools.zh.md) — 注册表如何根据抛出的 `HarnessError` 记录 `ToolErrorInfo`。
|
|
64
|
+
- [错误处理规则](../../../.agents/skills/dsh-error-handling/SKILL.md) — 何时必须抛出 `HarnessError`。
|
|
65
|
+
|
|
66
|
+
-----
|
|
67
|
+
|
|
68
|
+
<a id="dev-note"></a>
|
|
69
|
+
## 开发备注
|
|
70
|
+
|
|
71
|
+
<details>
|
|
72
|
+
<summary>维护者的工作背景——点击展开</summary>
|
|
73
|
+
|
|
74
|
+
无。
|
|
75
|
+
|
|
76
|
+
</details>
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region lib/types/index.js
|
|
2
|
+
/**
|
|
3
|
+
* Harness error base with a stable machine-routable code and chained cause.
|
|
4
|
+
* Package errors extend it so tool results and replay can retain failure class.
|
|
5
|
+
* @module @deepseek-ai/dsh-error
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base class for all harness errors. Carries a `code` (stable, programmatic —
|
|
9
|
+
* e.g. `NO_ADAPTER`, `INVALID_ARGS`) distinct from the
|
|
10
|
+
* human-readable `message`, and supports `cause` chaining via the standard
|
|
11
|
+
* `ErrorOptions`. `name` defaults to the subclass constructor name.
|
|
12
|
+
*/
|
|
13
|
+
var HarnessError = class extends Error {
|
|
14
|
+
/** Stable machine-routable failure class (e.g. `RATE_LIMIT`); route on this, never by parsing `message`. */
|
|
15
|
+
code;
|
|
16
|
+
constructor(message, code, options) {
|
|
17
|
+
super(message, options);
|
|
18
|
+
this.code = code;
|
|
19
|
+
this.name = new.target.name;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { HarnessError };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness error base with a stable machine-routable code and chained cause.
|
|
3
|
+
* Package errors extend it so tool results and replay can retain failure class.
|
|
4
|
+
* @module @deepseek-ai/dsh-error
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Base class for all harness errors. Carries a `code` (stable, programmatic —
|
|
8
|
+
* e.g. `NO_ADAPTER`, `INVALID_ARGS`) distinct from the
|
|
9
|
+
* human-readable `message`, and supports `cause` chaining via the standard
|
|
10
|
+
* `ErrorOptions`. `name` defaults to the subclass constructor name.
|
|
11
|
+
*/
|
|
12
|
+
export declare class HarnessError extends Error {
|
|
13
|
+
/** Stable machine-routable failure class (e.g. `RATE_LIMIT`); route on this, never by parsing `message`. */
|
|
14
|
+
readonly code: string;
|
|
15
|
+
constructor(message: string, code: string, options?: ErrorOptions);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,4GAA4G;IAC5G,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;gBAET,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAKlE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,4GAA4G;IACnG,IAAI,CAAQ;IAErB,YAAY,OAAe,EAAE,IAAY,EAAE,OAAsB;QAC/D,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA;IAC7B,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-error",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "Dependency-free HarnessError base class with a stable machine-routable code for the DeepSeek Harness",
|
|
4
|
+
"version": "0.2.2-rc.2",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
|
|
11
|
+
"directory": "packages/util/error"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./src/*": "./src/*",
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"lib/index.js",
|
|
26
|
+
"lib/types/**/*.d.ts",
|
|
27
|
+
"lib/types/**/*.d.ts.map",
|
|
28
|
+
"lib/**/*.js.map",
|
|
29
|
+
"src"
|
|
30
|
+
],
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@deepseek-ai/cordis": "~4.1.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@deepseek-ai/cordis": "~4.1.0"
|
|
37
|
+
}
|
|
6
38
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness error base with a stable machine-routable code and chained cause.
|
|
3
|
+
* Package errors extend it so tool results and replay can retain failure class.
|
|
4
|
+
* @module @deepseek-ai/dsh-error
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Base class for all harness errors. Carries a `code` (stable, programmatic —
|
|
9
|
+
* e.g. `NO_ADAPTER`, `INVALID_ARGS`) distinct from the
|
|
10
|
+
* human-readable `message`, and supports `cause` chaining via the standard
|
|
11
|
+
* `ErrorOptions`. `name` defaults to the subclass constructor name.
|
|
12
|
+
*/
|
|
13
|
+
export class HarnessError extends Error {
|
|
14
|
+
/** Stable machine-routable failure class (e.g. `RATE_LIMIT`); route on this, never by parsing `message`. */
|
|
15
|
+
readonly code: string
|
|
16
|
+
|
|
17
|
+
constructor(message: string, code: string, options?: ErrorOptions) {
|
|
18
|
+
super(message, options)
|
|
19
|
+
this.code = code
|
|
20
|
+
this.name = new.target.name
|
|
21
|
+
}
|
|
22
|
+
}
|