@deepseek-ai/dsh-session 0.1.0-rc.7 → 0.1.1-rc.1
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 +1 -1
- package/README.zh.md +10 -10
- package/lib/index.js +4 -0
- package/lib/types/known-event-types.js +4 -0
- package/lib/types/types.d.ts +6 -1
- package/package.json +12 -12
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/core/session/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: c62668167f4e0dfda822c7b82add3b4d8eb3d635
|
|
6
|
+
README.zh.md: 0b8eb6e1bc106509a86ed51ae2f37f2ad471c7a1
|
package/README.md
CHANGED
|
@@ -98,7 +98,7 @@ Every `SessionEvent` carries three optional top-level fields (structural metadat
|
|
|
98
98
|
|
|
99
99
|
#### What the model sees
|
|
100
100
|
|
|
101
|
-
The model receives the complete messages from `user/message`, `assistant/message`, and `tool/result` surface entries verbatim. Their identities, roles, sources, and content blocks are the same values established at creation; projections do not mint identities. A prompt envelope changes only human presentation; its prefix context and request delimiter are already present in the event content. Tool calls live inside assistant messages. Chunks, boundaries, usage, hook records, todo records, and other log-only events add no message.
|
|
101
|
+
The model receives the complete messages from `user/message`, `assistant/message`, and `tool/result` surface entries verbatim. Their identities, roles, sources, and content blocks are the same values established at creation; projections do not mint identities. Direct prompts and injected context remain separate `user/message` events whose sources preserve their provenance. A prompt envelope changes only human presentation; its prefix context and request delimiter are already present in the event content. Tool calls live inside assistant messages. Chunks, boundaries, usage, hook records, todo records, and other log-only events add no message.
|
|
102
102
|
|
|
103
103
|
#### Token effect
|
|
104
104
|
|
package/README.zh.md
CHANGED
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
- `enter(session)` 执行冲突检查,在不通知的情况下发布,并返回一个绑定到该条目的幂等脱离函数。允许并发准备相同 id,但只有一个条目能够成功进入;陈旧的脱离函数无法移除其替代项。
|
|
27
27
|
- `announce(session)` 发出唯一一次创建边,并拒绝重复或重入通知。该次分发期间请求的脱离操作会延后,之后再发出成对的释放边;未通知的条目不会发出任何生命周期边。
|
|
28
28
|
|
|
29
|
-
`dsh-agent-loop` 使用这一拆分,以保证循环的最终刷新先于会话脱离;详见[所有权 Agent Note](../../../.agents/notes/implemented/architecture/2026-06-18-agent-lifecycle-and-ownership-contracts.md)。
|
|
29
|
+
`dsh-agent-loop` 使用这一拆分,以保证循环的最终刷新先于会话脱离;详见[所有权 Agent Note](../../../.agents/notes/implemented/architecture/2026-06-18-agent-lifecycle-and-ownership-contracts.zh.md)。
|
|
30
30
|
|
|
31
31
|
### 实时服务事件
|
|
32
32
|
|
|
33
|
-
会话存储会将已通知的创建与释放配对,在提交后发布追加通知并逐个监听器收容失败,同时提供受等待的持久性检查点。确切签名和作用域行为见 [session.md](../../../docs/subsystems/session.md#cordis-surface) 的生成区块;载荷见[持久化目录](../../../docs/persistence-catalog.md)。
|
|
33
|
+
会话存储会将已通知的创建与释放配对,在提交后发布追加通知并逐个监听器收容失败,同时提供受等待的持久性检查点。确切签名和作用域行为见 [session.md](../../../docs/subsystems/session.zh.md#cordis-surface) 的生成区块;载荷见[持久化目录](../../../docs/persistence-catalog.zh.md)。
|
|
34
34
|
|
|
35
35
|
### 类:`Session`
|
|
36
36
|
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
|
|
57
57
|
### Surface 类型
|
|
58
58
|
|
|
59
|
-
此包拥有有序 surface 投影、替换校验、回放,以及区分追加来源事件与替换事件的类型守卫。[surface 类型目录](../../../docs/subsystems/session.md#surface-types)拥有精确形状与字段语义。面向人的 transcript(文本记录)必须投影追加来源事件,而不是 `session.surface`,因为已落地的替换会遮蔽读者已经看到的历史;面向模型的消费方继续读取 `session.surface`。
|
|
59
|
+
此包拥有有序 surface 投影、替换校验、回放,以及区分追加来源事件与替换事件的类型守卫。[surface 类型目录](../../../docs/subsystems/session.zh.md#surface-types)拥有精确形状与字段语义。面向人的 transcript(文本记录)必须投影追加来源事件,而不是 `session.surface`,因为已落地的替换会遮蔽读者已经看到的历史;面向模型的消费方继续读取 `session.surface`。
|
|
60
60
|
|
|
61
61
|
### 请求头重建(`request-header.ts`)
|
|
62
62
|
|
|
63
|
-
`request/header` 记录非历史请求封装的完整规范快照,其原因为 `initial`、`resume` 或 `change`。其可选 `adapterDefaults` 映射会标记由精确模型解析填入的生效 `reasoningEffort` 或 `maxTokens` 值,使下一次请求提议能够将它们与显式对话设置区分开。`foldRequestHeader()` 选择最新快照;旧版增量事件和已移除的 `fallback` 原因会被拒绝。详见[可重建请求 Agent Note](../../../.agents/notes/implemented/architecture/2026-07-05-reconstructable-requests.md)。
|
|
63
|
+
`request/header` 记录非历史请求封装的完整规范快照,其原因为 `initial`、`resume` 或 `change`。其可选 `adapterDefaults` 映射会标记由精确模型解析填入的生效 `reasoningEffort` 或 `maxTokens` 值,使下一次请求提议能够将它们与显式对话设置区分开。`foldRequestHeader()` 选择最新快照;旧版增量事件和已移除的 `fallback` 原因会被拒绝。详见[可重建请求 Agent Note](../../../.agents/notes/implemented/architecture/2026-07-05-reconstructable-requests.zh.md)。
|
|
64
64
|
|
|
65
65
|
`user/message` 会直接存储完整的 `UserMessage`,其中包括收件箱路由或进入步骤前创建的标识。无论它是直接人类提示词、合成注入,还是已进入的 Goal Round,都会原样呈现其 `content`;带类型的 `source` 是区分三者的唯一通道,并携带各领域专有的持久事实。`assistant/message` 和 `tool/result` 也会存储完整的消息值。轮次执行仍由 `turn/start` 与 `turn/end` 包围;`agent.inject()` 会把输入排队,直到后续某次 pre-step 领取它,并在 enter 决策中返回它。
|
|
66
66
|
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
|
|
69
69
|
### 会话事件词汇(`types.ts`)
|
|
70
70
|
|
|
71
|
-
生成的[持久化日志事件目录](../../../docs/persistence-catalog.md)逐成员列举仅追加日志的事件类型、载荷、surface 标记与声明位置。Token 记账读取每个步骤的 `assistant/chunk { type: 'usage' }` 记录;如果没有用量分片,则将 `assistant/message.usage` 作为已提交步骤的后备。失败的模型请求尝试没有 assistant 消息。每条 `assistant/message` 都会记录提供方、模型和可选回放状态。
|
|
71
|
+
生成的[持久化日志事件目录](../../../docs/persistence-catalog.zh.md)逐成员列举仅追加日志的事件类型、载荷、surface 标记与声明位置。Token 记账读取每个步骤的 `assistant/chunk { type: 'usage' }` 记录;如果没有用量分片,则将 `assistant/message.usage` 作为已提交步骤的后备。失败的模型请求尝试没有 assistant 消息。每条 `assistant/message` 都会记录提供方、模型和可选回放状态。
|
|
72
72
|
|
|
73
73
|
`SessionEventMap` 可通过合并扩展:插件使用声明合并添加自身类型(压缩 seam 的 `compaction/*`、有界恢复的非 surface `llm/retry`、钩子桥接层的 `hook/*`);合并成员会出现在同一目录中。插件拥有其合并事件的关系不变量,包括是否允许纯日志事件出现在轮次之间。需要持久性的生产方通过 `Session` 追加,再等待 `ctx.sessions.flush(session)`,无需虚构一个执行轮次。
|
|
74
74
|
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
|
|
81
81
|
- `sourceEventSeqs?: number[]`:被引用为来源的较早事件 seq(例如 `assistant/message` 引用的 `assistant/chunk` seq,或压缩替换条目引用的已遮蔽条目)。对于 `assistant/message`,存在的 `[]` 表示已知提供方流为空;省略则表示旧版或外部事件没有记录源流。其他 surface 事件若有此字段,则要求非空列表。
|
|
82
82
|
- `surfaceOp?: SurfaceOp`:事件进入 surface 的方式。非 surface 事件(边界、分片、用量、错误)不含该字段。
|
|
83
|
-
- `ignorable?: true`:标记读取器在不认识事件类型时可以安全跳过该事件;缺失表示必需,不认识的事件类型会使会话重建被拒绝([机制](../../../.agents/notes/implemented/architecture/2026-08-10-session-log-version-mechanism.md))。
|
|
83
|
+
- `ignorable?: true`:标记读取器在不认识事件类型时可以安全跳过该事件;缺失表示必需,不认识的事件类型会使会话重建被拒绝([机制](../../../.agents/notes/implemented/architecture/2026-08-10-session-log-version-mechanism.zh.md))。
|
|
84
84
|
|
|
85
85
|
### 元数据类型(`types.ts`)
|
|
86
86
|
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
|
|
91
91
|
- 持久化插件:订阅 `session/event`(延后写入),并在 `session/flush`(受等待)及 fiber dispose(资源释放)时排空。持久后端读取日志并重新加载到实时会话;这类后端会把元数据约定(`SessionHeader`、`session.header`)与日志一同存储。
|
|
92
92
|
- 回放/fork:`create(id, { seed })` 校验并冻结连续的当前格式日志,再重建 surface;请求头必须包含提供方/模型,assistant 消息必须包含提供方/模型溯源信息。持久化层在构造该当前格式 seed 前负责读取兼容性处理。`fork(source, boundary?, childSessionId?)` 选择已完成轮次前缀并记录谱系。
|
|
93
|
-
- 压缩:`dsh-compaction-basic` 为摘要检查点追加一个替换用 `user/message`,而 `dsh-compaction-tool-result-pruner` 追加仅修改内容的 `tool/result` 替换。工具配对边界策略及其缓存归 [`dsh-compaction` seam](../../compaction/compaction/README.md) 所有;此包拥有有序 surface 成员关系、替换校验与 `replaceGeneration`。
|
|
93
|
+
- 压缩:`dsh-compaction-basic` 为摘要检查点追加一个替换用 `user/message`,而 `dsh-compaction-tool-result-pruner` 追加仅修改内容的 `tool/result` 替换。工具配对边界策略及其缓存归 [`dsh-compaction` seam](../../compaction/compaction/README.zh.md) 所有;此包拥有有序 surface 成员关系、替换校验与 `replaceGeneration`。
|
|
94
94
|
|
|
95
95
|
## 模型体验
|
|
96
96
|
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
|
|
99
99
|
#### 模型看到的内容
|
|
100
100
|
|
|
101
|
-
模型会原样接收 `user/message`、`assistant/message` 和 `tool/result` surface
|
|
101
|
+
模型会原样接收 `user/message`、`assistant/message` 和 `tool/result` surface 条目中的完整消息。其标识、角色、来源和内容块都与创建时确定的值相同;投影不会生成标识。直接提示词与注入上下文仍是彼此独立的 `user/message` 事件,各事件的来源会保留其出处。提示词封装只改变面向人的呈现;其前缀上下文和请求分隔符已经位于事件内容中。工具调用包含在 assistant 消息内。分片、边界、用量、钩子记录、todo 记录以及其他仅日志事件不会添加消息。
|
|
102
102
|
|
|
103
103
|
#### Token 影响
|
|
104
104
|
|
|
@@ -139,6 +139,6 @@
|
|
|
139
139
|
## 已知限制与暂缓事项
|
|
140
140
|
|
|
141
141
|
- **会话分支/树结构**(pi 风格条目树):除非需要超越基于边界的 `fork()` 能力,否则暂缓。
|
|
142
|
-
- **`fork()` 仅在实时会话的稳定边界处切分**:所选前缀结束时不得有开放轮次,且源会话必须位于存储中;[fork API](../../../.agents/notes/implemented/feature/2026-06-30-session-store-fork-api.md) 不支持对已持久化但未加载的会话进行 fork。
|
|
143
|
-
- **`SESSION_FORMAT_VERSION` 固定为 `0`**:预发布阶段不承诺广泛兼容性;`Session` 只接受当前 seed 形状,后端拒绝其他任何版本并说明方向(更新的版本提示"由更新的 harness 写入,请升级";更旧的版本说明尚无升级路径)。不认识的事件类型同样被拒绝,除非信封带 `ignorable` 标记;版本机制见 [session-log 版本机制 Agent Note](../../../.agents/notes/implemented/architecture/2026-08-10-session-log-version-mechanism.md)。范围受限的存储导入升级应由持久化边界负责([政策](../../../AGENTS.md)、[消息标识机制引入前的消息恢复](../../../.agents/notes/implemented/bug-fix/2026-07-28-load-pre-identity-session-messages.md))。
|
|
142
|
+
- **`fork()` 仅在实时会话的稳定边界处切分**:所选前缀结束时不得有开放轮次,且源会话必须位于存储中;[fork API](../../../.agents/notes/implemented/feature/2026-06-30-session-store-fork-api.zh.md) 不支持对已持久化但未加载的会话进行 fork。
|
|
143
|
+
- **`SESSION_FORMAT_VERSION` 固定为 `0`**:预发布阶段不承诺广泛兼容性;`Session` 只接受当前 seed 形状,后端拒绝其他任何版本并说明方向(更新的版本提示"由更新的 harness 写入,请升级";更旧的版本说明尚无升级路径)。不认识的事件类型同样被拒绝,除非信封带 `ignorable` 标记;版本机制见 [session-log 版本机制 Agent Note](../../../.agents/notes/implemented/architecture/2026-08-10-session-log-version-mechanism.zh.md)。范围受限的存储导入升级应由持久化边界负责([政策](../../../AGENTS.md)、[消息标识机制引入前的消息恢复](../../../.agents/notes/implemented/bug-fix/2026-07-28-load-pre-identity-session-messages.zh.md))。
|
|
144
144
|
- **`TurnEndReasonMap` 不含 ACP(Agent Client Protocol)命名的 `refusal`/`max_turn_requests` 变体**:受生产方约束;只有当适配器或循环首次产生这些变体时才加入。
|
package/lib/index.js
CHANGED
|
@@ -1083,6 +1083,10 @@ const KNOWN_SESSION_EVENT_TYPES = new Set([
|
|
|
1083
1083
|
"step/end",
|
|
1084
1084
|
"step/start",
|
|
1085
1085
|
"subagent/descriptor",
|
|
1086
|
+
"team/member",
|
|
1087
|
+
"team/message/delivered",
|
|
1088
|
+
"team/message/queued",
|
|
1089
|
+
"team/task",
|
|
1086
1090
|
"todo/write",
|
|
1087
1091
|
"tool-workflow/agent-end",
|
|
1088
1092
|
"tool-workflow/agent-start",
|
|
@@ -47,6 +47,10 @@ export const KNOWN_SESSION_EVENT_TYPES = new Set([
|
|
|
47
47
|
'step/end',
|
|
48
48
|
'step/start',
|
|
49
49
|
'subagent/descriptor',
|
|
50
|
+
'team/member',
|
|
51
|
+
'team/message/delivered',
|
|
52
|
+
'team/message/queued',
|
|
53
|
+
'team/task',
|
|
50
54
|
'todo/write',
|
|
51
55
|
'tool-workflow/agent-end',
|
|
52
56
|
'tool-workflow/agent-start',
|
package/lib/types/types.d.ts
CHANGED
|
@@ -270,13 +270,18 @@ export interface SessionEventMap {
|
|
|
270
270
|
* Assembled assistant message for one step (derived history uses this).
|
|
271
271
|
* Carries the step's `usage` when the adapter reported token accounting, so
|
|
272
272
|
* the model output and its accounting travel together (there is no separate
|
|
273
|
-
* usage record). `usage` is absent when the adapter reported none.
|
|
273
|
+
* usage record). `usage` is absent when the adapter reported none. A turn
|
|
274
|
+
* cancelled mid-stream finalizes its delivered text/reasoning prefix as this
|
|
275
|
+
* event with `interrupted: true`; undispatched tool calls are absent. The
|
|
276
|
+
* marker distinguishes that prefix without re-deriving interruption from turn
|
|
277
|
+
* boundaries. An aborted turn with no such event streamed no visible content.
|
|
274
278
|
*/
|
|
275
279
|
'assistant/message': {
|
|
276
280
|
turn: number;
|
|
277
281
|
step: number;
|
|
278
282
|
message: AssistantMessage;
|
|
279
283
|
usage?: TokenUsage;
|
|
284
|
+
interrupted?: true;
|
|
280
285
|
};
|
|
281
286
|
/**
|
|
282
287
|
* The model requested one tool invocation: `name` with the raw `arguments`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-session",
|
|
3
3
|
"description": "Event-sourced session store for the DeepSeek Harness",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1-rc.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -41,20 +41,20 @@
|
|
|
41
41
|
],
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@deepseek-ai/dsh-
|
|
45
|
-
"@deepseek-ai/dsh-
|
|
46
|
-
"@deepseek-ai/dsh-
|
|
47
|
-
"@deepseek-ai/dsh-scope": "^0.1.
|
|
48
|
-
"@deepseek-ai/dsh-typert-protocol": "^0.1.
|
|
44
|
+
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.1",
|
|
45
|
+
"@deepseek-ai/dsh-llm": "^0.1.1-rc.1",
|
|
46
|
+
"@deepseek-ai/dsh-brand": "^0.1.1-rc.1",
|
|
47
|
+
"@deepseek-ai/dsh-scope": "^0.1.1-rc.1",
|
|
48
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.1.1-rc.1",
|
|
49
49
|
"@deepseek-ai/cordis": "^4.0.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@deepseek-ai/dsh-
|
|
53
|
-
"@deepseek-ai/dsh-
|
|
54
|
-
"@deepseek-ai/dsh-
|
|
55
|
-
"@deepseek-ai/dsh-
|
|
56
|
-
"@deepseek-ai/dsh-
|
|
57
|
-
"@deepseek-ai/dsh-typert-registry": "^0.1.
|
|
52
|
+
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.1",
|
|
53
|
+
"@deepseek-ai/dsh-llm": "^0.1.1-rc.1",
|
|
54
|
+
"@deepseek-ai/dsh-scope": "^0.1.1-rc.1",
|
|
55
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.1.1-rc.1",
|
|
56
|
+
"@deepseek-ai/dsh-brand": "^0.1.1-rc.1",
|
|
57
|
+
"@deepseek-ai/dsh-typert-registry": "^0.1.1-rc.1",
|
|
58
58
|
"@deepseek-ai/cordis": "^4.0.1"
|
|
59
59
|
}
|
|
60
60
|
}
|