dsh-session-guard 4.4.2 → 4.4.3
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/CHANGELOG.md +9 -0
- package/CHANGELOG.pt.md +196 -196
- package/INSTALL.pt.md +120 -120
- package/README.pt.md +377 -377
- package/dsh.plugin.json +1 -1
- package/lib/client.js +397 -181
- package/lib/client.js.map +1 -1
- package/locale/de.json +6 -6
- package/locale/en.json +6 -6
- package/locale/es.json +6 -6
- package/locale/fr.json +6 -6
- package/locale/it.json +6 -6
- package/locale/ja.json +6 -6
- package/locale/ko.json +6 -6
- package/locale/pt.json +6 -6
- package/locale/ru.json +6 -6
- package/locale/zh.json +6 -6
- package/package.json +129 -129
- package/src/bridge.js +190 -190
- package/src/client/badge-text.ts +49 -49
- package/src/client/family-section.tsx +79 -79
- package/src/client/locales.ts +400 -400
- package/src/client/pause-button-text.ts +76 -76
- package/src/client/pause-button.tsx +129 -129
- package/src/client/scope-face.ts +20 -20
- package/src/client/settings-bridge.ts +202 -202
- package/src/client/settings-card.tsx +4 -0
- package/src/client/star-row-copy.ts +256 -0
- package/src/client/status-badge.tsx +76 -76
- package/src/client/styles.ts +30 -30
- package/src/deferrals.js +197 -197
- package/src/holiday-store.js +196 -196
- package/src/holidays.js +215 -215
- package/src/pause-gate.js +544 -544
- package/src/provider-directory.js +101 -101
- package/src/provider.js +139 -139
- package/src/retry.js +227 -227
- package/src/settings-bridge.js +141 -141
- package/src/settings.js +98 -98
- package/src/step-gate.js +411 -411
- package/src/targets.js +70 -70
- package/src/time.js +216 -216
- package/src/tool-call-id.js +48 -48
- package/src/wiring.js +308 -308
package/src/tool-call-id.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dsh-session-guard — `tool/result` 调用 id 的多形态读取(**零依赖**,可单测)。
|
|
3
|
-
*
|
|
4
|
-
* 形状代际(2026-09-27 v4 适配订正;engines.dsh ≥0.1.7-rc.1):
|
|
5
|
-
*
|
|
6
|
-
* - **v4 native(现行,必读)**:`event.data.message` 为一等 `role:'tool'` 消息,
|
|
7
|
-
* `toolCallId` 在 message 顶层(`ToolResultMessage`,0.1.7-rc.2 dsh-llm
|
|
8
|
-
* message.d.ts 实证)。v4 解码 native-only,`type:'tool-result'` 块被宿主
|
|
9
|
-
* `assertBlock` 硬拒——**本文件的第一读取顺位**。
|
|
10
|
-
* - v3 wrapper(历史兼容):`event.data.message.content[].toolCallId`
|
|
11
|
-
* (`tool-result` 块)。未迁移的 v3 日志读侧仍可见。
|
|
12
|
-
* - 遗留形态:`event.data.message.source.callId`(旧记录经持久化协调器迁移)。
|
|
13
|
-
*
|
|
14
|
-
* 读取顺序:native 顶层 `toolCallId` → 块上 `toolCallId` → `source.callId`。
|
|
15
|
-
* **不要改成单读**——只读一层会在其它代际的记录上丢 id(in-flight 工具无法落地
|
|
16
|
-
* / 暂停点判定失效)。
|
|
17
|
-
*
|
|
18
|
-
* 本文件刻意不导入任何 `@deepseek-ai/*` 包,因此可在没有 DSH 运行时依赖的
|
|
19
|
-
* 环境下直接单测(见 `tests/tool-call-id.test.mjs`)。
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 读一条 `tool/result` 记录(`event.data.message`)的调用 id。
|
|
24
|
-
* @param {unknown} message - `event.data.message`(可能缺失或非对象)
|
|
25
|
-
* @returns {string|undefined} 调用 id;各形态都缺时返回 undefined
|
|
26
|
-
*/
|
|
27
|
-
export function readToolResultCallId(message) {
|
|
28
|
-
if (message === null || typeof message !== 'object') return undefined
|
|
29
|
-
// v4 native:一等 tool-role 消息,id 在顶层。
|
|
30
|
-
if (typeof message.toolCallId === 'string') return message.toolCallId
|
|
31
|
-
const content = Array.isArray(message.content) ? message.content : []
|
|
32
|
-
for (const block of content) {
|
|
33
|
-
if (block?.type === 'tool-result' && typeof block.toolCallId === 'string') return block.toolCallId
|
|
34
|
-
}
|
|
35
|
-
const legacy = message.source?.callId
|
|
36
|
-
return typeof legacy === 'string' ? legacy : undefined
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 读一个 `user/message` 内容块(`tool-result` 形态)的调用 id。
|
|
41
|
-
* @param {unknown} block - 内容块
|
|
42
|
-
* @returns {string|undefined} 调用 id;非 `tool-result` 或 id 非字符串时 undefined
|
|
43
|
-
*/
|
|
44
|
-
export function readToolResultBlockId(block) {
|
|
45
|
-
if (block === null || typeof block !== 'object') return undefined
|
|
46
|
-
if (block.type !== 'tool-result') return undefined
|
|
47
|
-
return typeof block.toolCallId === 'string' ? block.toolCallId : undefined
|
|
48
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* dsh-session-guard — `tool/result` 调用 id 的多形态读取(**零依赖**,可单测)。
|
|
3
|
+
*
|
|
4
|
+
* 形状代际(2026-09-27 v4 适配订正;engines.dsh ≥0.1.7-rc.1):
|
|
5
|
+
*
|
|
6
|
+
* - **v4 native(现行,必读)**:`event.data.message` 为一等 `role:'tool'` 消息,
|
|
7
|
+
* `toolCallId` 在 message 顶层(`ToolResultMessage`,0.1.7-rc.2 dsh-llm
|
|
8
|
+
* message.d.ts 实证)。v4 解码 native-only,`type:'tool-result'` 块被宿主
|
|
9
|
+
* `assertBlock` 硬拒——**本文件的第一读取顺位**。
|
|
10
|
+
* - v3 wrapper(历史兼容):`event.data.message.content[].toolCallId`
|
|
11
|
+
* (`tool-result` 块)。未迁移的 v3 日志读侧仍可见。
|
|
12
|
+
* - 遗留形态:`event.data.message.source.callId`(旧记录经持久化协调器迁移)。
|
|
13
|
+
*
|
|
14
|
+
* 读取顺序:native 顶层 `toolCallId` → 块上 `toolCallId` → `source.callId`。
|
|
15
|
+
* **不要改成单读**——只读一层会在其它代际的记录上丢 id(in-flight 工具无法落地
|
|
16
|
+
* / 暂停点判定失效)。
|
|
17
|
+
*
|
|
18
|
+
* 本文件刻意不导入任何 `@deepseek-ai/*` 包,因此可在没有 DSH 运行时依赖的
|
|
19
|
+
* 环境下直接单测(见 `tests/tool-call-id.test.mjs`)。
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 读一条 `tool/result` 记录(`event.data.message`)的调用 id。
|
|
24
|
+
* @param {unknown} message - `event.data.message`(可能缺失或非对象)
|
|
25
|
+
* @returns {string|undefined} 调用 id;各形态都缺时返回 undefined
|
|
26
|
+
*/
|
|
27
|
+
export function readToolResultCallId(message) {
|
|
28
|
+
if (message === null || typeof message !== 'object') return undefined
|
|
29
|
+
// v4 native:一等 tool-role 消息,id 在顶层。
|
|
30
|
+
if (typeof message.toolCallId === 'string') return message.toolCallId
|
|
31
|
+
const content = Array.isArray(message.content) ? message.content : []
|
|
32
|
+
for (const block of content) {
|
|
33
|
+
if (block?.type === 'tool-result' && typeof block.toolCallId === 'string') return block.toolCallId
|
|
34
|
+
}
|
|
35
|
+
const legacy = message.source?.callId
|
|
36
|
+
return typeof legacy === 'string' ? legacy : undefined
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 读一个 `user/message` 内容块(`tool-result` 形态)的调用 id。
|
|
41
|
+
* @param {unknown} block - 内容块
|
|
42
|
+
* @returns {string|undefined} 调用 id;非 `tool-result` 或 id 非字符串时 undefined
|
|
43
|
+
*/
|
|
44
|
+
export function readToolResultBlockId(block) {
|
|
45
|
+
if (block === null || typeof block !== 'object') return undefined
|
|
46
|
+
if (block.type !== 'tool-result') return undefined
|
|
47
|
+
return typeof block.toolCallId === 'string' ? block.toolCallId : undefined
|
|
48
|
+
}
|