@deepseek-ai/dsh-spill-policy 0.1.7-alpha.1 → 0.1.7-alpha.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/README.i18n.yaml +2 -2
- package/README.md +22 -22
- package/README.zh.md +22 -22
- package/lib/index.js +216 -142
- package/lib/types/index.d.ts +14 -50
- package/lib/types/index.js +110 -167
- package/lib/types/notice.d.ts +2 -1
- package/lib/types/notice.js +10 -2
- package/lib/types/retention.d.ts +24 -0
- package/lib/types/retention.js +88 -0
- package/package.json +35 -22
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/spill/spill-policy/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: d9caa9b2eb00f05ee6df70b19646d555b14d77e0
|
|
6
|
+
README.zh.md: 4d2b6e8fe88535c762964e7af4666492f68c9943
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "
|
|
2
|
+
description: "Tool-result retention with a shared text/image token budget and readable recovery files."
|
|
3
3
|
kind: "package-reference"
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
|
|
|
9
9
|
|
|
10
10
|
## Summary
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Keep oversized text and image results within a shared estimated token budget. The model receives ordered head/tail content and a path to the complete result. Images remain in attachment storage; the result file records their readable paths. Omitting `maxInlineTokens` disables retention, and recovery failures leave the original content visible.
|
|
13
13
|
|
|
14
14
|
## Table of Contents
|
|
15
15
|
|
|
@@ -25,28 +25,28 @@ Mount this package when oversized plain-text tool results should stay out of mod
|
|
|
25
25
|
<a id="use-this-package"></a>
|
|
26
26
|
## Use this package
|
|
27
27
|
|
|
28
|
-
Mount the policy alongside a spill backend
|
|
28
|
+
Mount the policy alongside a spill backend. Text and images share the configured budget after post-execute policy accepts the result.
|
|
29
29
|
|
|
30
30
|
### Minimal configuration
|
|
31
31
|
|
|
32
|
-
Load
|
|
32
|
+
Load a spill backend and set `maxInlineTokens` in estimated tokens:
|
|
33
33
|
|
|
34
34
|
```yaml
|
|
35
35
|
- name: '@deepseek-ai/dsh-spill-local'
|
|
36
36
|
- name: '@deepseek-ai/dsh-spill-policy'
|
|
37
37
|
config:
|
|
38
|
-
|
|
38
|
+
maxInlineTokens: 12500
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
| Field | Default | Meaning |
|
|
42
42
|
|---|---|---|
|
|
43
|
-
| `
|
|
43
|
+
| `maxInlineTokens` | omitted | Estimated token cap for retained text, images, image descriptions, and notices; omission disables retention |
|
|
44
44
|
|
|
45
45
|
The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-spill-policy) is the exhaustive source for every accepted field. A negative or fractional cap fails plugin load rather than corrupting per-call behavior.
|
|
46
46
|
|
|
47
47
|
### What the model sees
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
Oversized results keep their original order. Each end receives half the budget remaining after omission notices; text may be split, while each image is retained or omitted whole. Images inside the omitted interval are omitted too. A successful replacement stays within the configured token estimate:
|
|
50
50
|
|
|
51
51
|
```text
|
|
52
52
|
<retained head/tail preview>
|
|
@@ -54,19 +54,19 @@ An oversized plain-text result is replaced by a preview plus a notice inside the
|
|
|
54
54
|
(Omitted N bytes. Full formatted result stored at: /…/session-…/…-web_fetch.txt. Use read with offset/limit, or grep this path to search within it.)
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
The notice also reports omitted image counts. A notice-only result is allowed when no preview fits; if the notice itself exceeds the cap, the original content stays visible. The full result file keeps all accepted text and an attachment path at each image position, so the model can use `read` and then `read_image`. Attachment bytes are not copied into this file. Local attachment objects persist independently of spill cleanup.
|
|
58
58
|
|
|
59
59
|
### Which results are affected
|
|
60
60
|
|
|
61
|
-
The policy
|
|
61
|
+
The policy accepts text/image sequences. Results within budget, `read`, blocked decisions, value replacements, and other block types pass through. Text-only nested results are bounded only in their log copies. Provider or tool limits applied before this policy cannot be recovered here.
|
|
62
62
|
|
|
63
63
|
### Best-effort failure behavior
|
|
64
64
|
|
|
65
|
-
A missing
|
|
65
|
+
A missing owner or spill backend, failed storage, missing route image pricing, or unavailable execution-world image path logs a warning and keeps the original content. The policy never substitutes an unreadable path for an image.
|
|
66
66
|
|
|
67
67
|
### The durable log copy
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
PTC programs receive complete canonical values. Image-bearing sub-results are bounded before forwarding to the model; when every image is omitted, the model still receives the retained text and recovery notice. The dispatch log uses the same retained content. Text-only sub-call logs, including `read`, are bounded asynchronously without delaying program values.
|
|
70
70
|
|
|
71
71
|
-----
|
|
72
72
|
|
|
@@ -80,16 +80,16 @@ This section explains the design decisions behind the policy; the observable beh
|
|
|
80
80
|
|
|
81
81
|
### Design philosophy
|
|
82
82
|
|
|
83
|
-
The
|
|
83
|
+
The pure retention function selects ordered content by cost; the plugin owns policy, recovery text, and storage calls. Text uses the existing token-meter estimate. Images use the active route's `imageRequestPricing`, including descriptor text. DeepSeek routes reuse the provider's image-dimension calculator. The budget is an estimate, not an exact tokenizer guarantee.
|
|
84
84
|
|
|
85
85
|
### The two arms
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
The prepended `tools/post-execute` listener delegates before bounding accepted content. `tools/ptc-dispatch-log` shares the same helper. MCP's `projectContent` installs real image blocks before these policies; later content replacement, value replacement, or blocking remains authoritative.
|
|
88
88
|
|
|
89
89
|
<a id="shared-notice-ownership"></a>
|
|
90
90
|
### Shared notice ownership
|
|
91
91
|
|
|
92
|
-
The browser-safe
|
|
92
|
+
The browser-safe `./notice` entry owns `formatSpillNotice(omitted, ref, images)` and `hasSpillNotice(text)`. It recognizes both historical byte-only notices and notices with whole-image counts without changing recorded text.
|
|
93
93
|
|
|
94
94
|
### Source map
|
|
95
95
|
|
|
@@ -97,12 +97,12 @@ The browser-safe `@deepseek-ai/dsh-spill-policy/notice` entry owns both `formatS
|
|
|
97
97
|
|---|---|
|
|
98
98
|
| [`src/index.ts`](src/index.ts) | Plugin entry: `Config` validation, the two waterfall listeners, the shared replacement helper |
|
|
99
99
|
| [`src/notice.ts`](src/notice.ts) | Browser-safe notice formatting and recognition, published as `./notice` |
|
|
100
|
-
| [`src/
|
|
100
|
+
| [`src/retention.ts`](src/retention.ts) | Pure ordered text/image head-tail retention |
|
|
101
101
|
| — | No runtime invariant companion is published; this package exposes no independent event sequence or mutable data relation beyond contracts enforced at its owning seam. |
|
|
102
102
|
|
|
103
103
|
### Failure modes
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
Recovery or pricing failures preserve the input and log the reason. Negative, fractional, or unsafe-integer budgets fail at plugin load. Results containing unsupported block types remain unchanged.
|
|
106
106
|
|
|
107
107
|
</details>
|
|
108
108
|
|
|
@@ -115,7 +115,7 @@ Read these pages when the package-level contract is not enough.
|
|
|
115
115
|
|
|
116
116
|
- [Spill storage service](../spill/README.md) — the `saveText` contract behind the policy's replacement.
|
|
117
117
|
- [dsh-spill-local](../spill-local/README.md) — the local backend that stores the spilled text.
|
|
118
|
-
- [
|
|
118
|
+
- [Token meter](../../llm/token-meter/README.md) — shared text estimates and route image accounting.
|
|
119
119
|
- [Tool output spill decision](../../../.agents/notes/implemented/architecture/2026-07-08-tool-output-spill-files.md) — the capability boundary and design rationale.
|
|
120
120
|
|
|
121
121
|
-----
|
|
@@ -123,15 +123,15 @@ Read these pages when the package-level contract is not enough.
|
|
|
123
123
|
<a id="model-experience"></a>
|
|
124
124
|
## Model Experience
|
|
125
125
|
|
|
126
|
-
### Oversized
|
|
126
|
+
### Oversized text and image results
|
|
127
127
|
|
|
128
128
|
#### What the model sees
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
The retained prefix and suffix keep image order, with `[...]` at the omitted interval. The final notice names omitted text bytes, optional whole-image counts, and the complete-result path. Reading that file reveals the omitted text and image addresses.
|
|
131
131
|
|
|
132
132
|
#### Token effect
|
|
133
133
|
|
|
134
|
-
A successful replacement
|
|
134
|
+
A successful replacement fits `maxInlineTokens` under the shared text estimate and active route's image calculator, including notices and image descriptor text. Provider-reported usage remains authoritative.
|
|
135
135
|
|
|
136
136
|
#### KV Cache effect
|
|
137
137
|
|
|
@@ -145,7 +145,7 @@ Append-only; newly visible content follows the reusable request prefix and does
|
|
|
145
145
|
These limits define when the policy cannot help. They are current package constraints.
|
|
146
146
|
|
|
147
147
|
- **Text recognition cannot authenticate output** — a tool can print the same notice text; `hasSpillNotice` identifies a text convention, not proof that the policy saved a result.
|
|
148
|
-
- **
|
|
148
|
+
- **Unavailable recovery or pricing** — images require a route calculator and execution-readable attachment paths; otherwise the original content stays visible. Unsupported blocks, blocked feedback, and `read` also pass through.
|
|
149
149
|
- **A notice that cannot fit disables replacement for that call** — a tiny cap or long locator leaves the oversized original inline after the backend has already saved an unreferenced spill.
|
|
150
150
|
|
|
151
151
|
<a id="dev-note"></a>
|
|
@@ -162,6 +162,6 @@ Per-tool opt-out or per-tool policy declarations remain deferred; the built-in `
|
|
|
162
162
|
|
|
163
163
|
#### Future: earlier spill
|
|
164
164
|
|
|
165
|
-
The policy only sees final
|
|
165
|
+
The policy only sees final accepted content. Earlier provider truncation and tool-owned output limits remain outside its scope.
|
|
166
166
|
|
|
167
167
|
</details>
|
package/README.zh.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "
|
|
2
|
+
description: "工具结果保留:文字和图片共享 token 预算,并通过完整结果文件恢复省略内容。"
|
|
3
3
|
kind: "package-reference"
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ kind: "package-reference"
|
|
|
9
9
|
|
|
10
10
|
## 概述
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
将过大的文字和图片结果限制在共享的估算 token 预算内。模型收到按原顺序保留的首尾内容,以及完整结果文件的路径。图片保存在附件存储中,结果文件记录其可读取路径。省略 `maxInlineTokens` 会禁用策略,无法保存可恢复内容时保留原结果。
|
|
13
13
|
|
|
14
14
|
## 目录
|
|
15
15
|
|
|
@@ -25,28 +25,28 @@ kind: "package-reference"
|
|
|
25
25
|
<a id="use-this-package"></a>
|
|
26
26
|
## 使用本包
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
将策略与 spill 后端一起挂载。执行后策略接受结果之后,文字和图片共享配置的预算。
|
|
29
29
|
|
|
30
30
|
### 最小配置
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
挂载 spill 后端,并以估算 token 数设置 `maxInlineTokens`:
|
|
33
33
|
|
|
34
34
|
```yaml
|
|
35
35
|
- name: '@deepseek-ai/dsh-spill-local'
|
|
36
36
|
- name: '@deepseek-ai/dsh-spill-policy'
|
|
37
37
|
config:
|
|
38
|
-
|
|
38
|
+
maxInlineTokens: 12500
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
| 字段 | 默认值 | 含义 |
|
|
42
42
|
|---|---|---|
|
|
43
|
-
| `
|
|
43
|
+
| `maxInlineTokens` | 省略 | 保留的文字、图片、图片说明和提示的估算 token 上限;省略时禁用策略 |
|
|
44
44
|
|
|
45
45
|
生成的[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-spill-policy)是每个受支持字段的穷尽式真源。负数或小数上限会让插件加载失败,而不是破坏每次调用的行为。
|
|
46
46
|
|
|
47
47
|
### 模型看到什么
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
过大的结果保持原始顺序。扣除省略提示后,两端各使用剩余预算的一半;文字可以切分,图片整张保留或省略。省略区间中的图片也会被省略。成功替换的内容不超过配置的 token 估算预算:
|
|
50
50
|
|
|
51
51
|
```text
|
|
52
52
|
<retained head/tail preview>
|
|
@@ -54,19 +54,19 @@ kind: "package-reference"
|
|
|
54
54
|
(Omitted N bytes. Full formatted result stored at: /…/session-…/…-web_fetch.txt. Use read with offset/limit, or grep this path to search within it.)
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
提示也会报告省略的图片数量。预算容不下预览时允许只返回提示;连提示也超出上限时保留原内容。完整结果文件保存全部已接受文字,并在每张图片的位置记录附件路径,模型可先用 `read` 读取,再用 `read_image` 查看。图片字节不复制到这个文件中。本地附件对象的持久保存独立于 spill 文件清理。
|
|
58
58
|
|
|
59
59
|
### 哪些结果会受影响
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
策略接受文字和图片序列。预算内结果、`read`、被阻止的决策、值替换以及其他内容块类型会原样通过。纯文本嵌套结果只限制日志副本。提供方或工具在此前应用的限制无法在这里恢复。
|
|
62
62
|
|
|
63
63
|
### 尽力而为的故障行为
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
缺少归属或 spill 后端、存储失败、缺少模型图片计量或图片路径无法在执行环境读取时,策略记录警告并保留原内容。策略不会用无法读取的路径替换图片。
|
|
66
66
|
|
|
67
67
|
### 持久日志副本
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
PTC 程序收到完整的规范值。含图片的子结果在转发给模型前设定上限;全部图片被省略时,模型仍会收到保留的文字和读取提示。分发日志使用相同的保留内容。纯文本子调用的日志,包括 `read`,异步设定上限,不延迟程序获取返回值。
|
|
70
70
|
|
|
71
71
|
-----
|
|
72
72
|
|
|
@@ -80,16 +80,16 @@ kind: "package-reference"
|
|
|
80
80
|
|
|
81
81
|
### 设计理念
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
纯保留函数按成本选择有序内容,插件负责策略、读取提示和存储调用。文字使用现有 token-meter 估算。图片使用当前模型的 `imageRequestPricing`,并计入说明文字。DeepSeek 模型复用提供方的图片尺寸计算器。预算是估算值,不保证与实际分词结果完全一致。
|
|
84
84
|
|
|
85
85
|
### 两条分支
|
|
86
86
|
|
|
87
|
-
`tools/post-execute`
|
|
87
|
+
以 prepend 注册的 `tools/post-execute` 监听器先委托,再限制已接受的内容。`tools/ptc-dispatch-log` 共用同一辅助函数。MCP 的 `projectContent` 在这些策略之前安装真实图片块;后续内容替换、值替换或阻止仍然生效。
|
|
88
88
|
|
|
89
89
|
<a id="shared-notice-ownership"></a>
|
|
90
90
|
### 共享通知的所有权
|
|
91
91
|
|
|
92
|
-
浏览器安全入口
|
|
92
|
+
浏览器安全入口 `./notice` 负责 `formatSpillNotice(omitted, ref, images)` 和 `hasSpillNotice(text)`。它识别历史的仅字节提示和包含整张图片数量的提示,不改写已有记录。
|
|
93
93
|
|
|
94
94
|
### 源码地图
|
|
95
95
|
|
|
@@ -97,12 +97,12 @@ kind: "package-reference"
|
|
|
97
97
|
|---|---|
|
|
98
98
|
| [`src/index.ts`](src/index.ts) | 插件入口:`Config` 校验、两个 waterfall 监听器、共享替换辅助函数 |
|
|
99
99
|
| [`src/notice.ts`](src/notice.ts) | 浏览器安全的通知格式化与识别,以 `./notice` 发布 |
|
|
100
|
-
| [`src/
|
|
100
|
+
| [`src/retention.ts`](src/retention.ts) | 有序图文首尾保留的纯函数 |
|
|
101
101
|
| — | 不发布运行时不变式伴生入口;除在所属 seam 处强制执行的约定外,本包不公开独立的事件序列或可变数据关系。 |
|
|
102
102
|
|
|
103
103
|
### 故障模式
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
无法恢复内容或计量失败时保留输入,并记录原因。负数、小数或非安全整数预算会使插件加载失败。包含不支持的内容块类型的结果保持原样。
|
|
106
106
|
|
|
107
107
|
</details>
|
|
108
108
|
|
|
@@ -115,7 +115,7 @@ kind: "package-reference"
|
|
|
115
115
|
|
|
116
116
|
- [spill 存储服务](../spill/README.zh.md)——策略替换背后的 `saveText` 约定。
|
|
117
117
|
- [dsh-spill-local](../spill-local/README.zh.md)——保存 spill 文本的本地后端。
|
|
118
|
-
- [
|
|
118
|
+
- [Token meter](../../llm/token-meter/README.zh.md) — 共享文字估算和模型图片计量。
|
|
119
119
|
- [工具输出 spill 决策](../../../.agents/notes/implemented/architecture/2026-07-08-tool-output-spill-files.zh.md)——能力边界与设计依据。
|
|
120
120
|
|
|
121
121
|
-----
|
|
@@ -123,15 +123,15 @@ kind: "package-reference"
|
|
|
123
123
|
<a id="model-experience"></a>
|
|
124
124
|
## 模型体验
|
|
125
125
|
|
|
126
|
-
###
|
|
126
|
+
### 过大的文字和图片结果
|
|
127
127
|
|
|
128
128
|
#### 模型看到什么
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
保留的前缀和后缀维持图片顺序,并在省略区间显示 `[...]`。末尾提示说明省略的文字字节数、整张图片数量及完整结果路径。读取该文件可以找到省略的文字和图片地址。
|
|
131
131
|
|
|
132
132
|
#### Token 影响
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
成功替换的结果在共享文字估算和当前模型图片计算器下不超过 `maxInlineTokens`,包括提示和图片说明文字。实际用量以提供方报告为准。
|
|
135
135
|
|
|
136
136
|
#### KV Cache 影响
|
|
137
137
|
|
|
@@ -145,7 +145,7 @@ kind: "package-reference"
|
|
|
145
145
|
这些限制说明策略在哪些情况下无法提供帮助。它们是当前的包约束。
|
|
146
146
|
|
|
147
147
|
- **文本识别无法认证输出来源**——工具也能打印相同的通知文本;`hasSpillNotice` 识别的是文本约定,不能证明策略保存过结果。
|
|
148
|
-
-
|
|
148
|
+
- **无法恢复或计量**:图片要求模型计算器和执行环境可读取的附件路径,否则保留原内容。不支持的内容块、被阻止的反馈和 `read` 也会原样通过。
|
|
149
149
|
- **通知无法容纳时会禁用该次调用的替换**——上限极小或定位信息很长时,后端已经保存了无引用的 spill,但过大的原始结果仍留在内联位置。
|
|
150
150
|
|
|
151
151
|
<a id="dev-note"></a>
|
|
@@ -162,6 +162,6 @@ kind: "package-reference"
|
|
|
162
162
|
|
|
163
163
|
#### 未来:更早的 spill
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
策略只处理最终已接受的内容。此前的提供方截断和工具自身的输出限制仍由各自负责。
|
|
166
166
|
|
|
167
167
|
</details>
|