Merge remote-tracking branch 'origin/master' into xtr/agent-loop-message-machine

# Conflicts:
#	packages/context/workspace-context/README.md
#	packages/llm/llm-retry/README.md
#	packages/session-persistence/session-checkpoint-policy/README.md
#	scripts/type-equiv.manifest.json
This commit is contained in:
_Kerman
2026-07-26 16:45:27 +08:00
699 changed files with 15263 additions and 1394 deletions

View File

@@ -0,0 +1,6 @@
# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write
README.md: 64bca8153e566e1590776af511662a873198106e
README.zh.md: b6779f3e798d695a3c22634bb298f2a7681edbfb

View File

@@ -1,5 +1,7 @@
# session-title/ — log-backed session-title capability family
English | [中文](README.zh.md)
Durable session-title state, one optional asynchronous provider seam, and two opt-in model-backed implementations. The built-in first-message fallback is part of the service, so every composition can title a session without an auxiliary model call.
| Package | Role | ctx key |

View File

@@ -0,0 +1,14 @@
# session-title/:日志支持的会话标题能力家族
[English](README.md) | 中文
持久会话标题状态、一个可选异步提供方 seam以及两个可选启用的模型后端实现。内置首消息回退属于服务本身因此任何组合都能在不调用辅助模型的情况下为会话生成标题。
| 包 | 职责 | ctx 键 |
|---|---|---|
| [`session-title/`](session-title/README.md) | 日志折叠、确定性回退、提供方注册表与刷新 API | `ctx.sessionTitle` |
| [`session-title-llm/`](session-title-llm/README.md) | 共享路由、请求日志记录、提示词、超时、流与验证辅助模块 | 无 |
| [`session-title-first-message-llm/`](session-title-first-message-llm/README.md) | 使用第一条符合条件的用户消息的可选提供方 | 注册到 `ctx.sessionTitle` |
| [`session-title-all-messages-llm/`](session-title-all-messages-llm/README.md) | 使用所有符合条件的用户消息的可选提供方 | 注册到 `ctx.sessionTitle` |
同一时间只能注册一个提供方。共享 demo 主干会挂载回退服务,但默认组合不包含两个模型提供方,因此部署会显式选择辅助成本和重新生成标题的节奏。

View File

@@ -0,0 +1,6 @@
# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write
README.md: 25ec92432b5c2d18624f2f4d851552ee2b3bf5d0
README.zh.md: 685046a2a4d0859e6eca86cfba67690b8271afaf

View File

@@ -1,5 +1,7 @@
# @deepseek-ai/dsh-session-title-all-messages-llm
English | [中文](README.zh.md)
Optional `ctx.sessionTitle` provider that summarizes every eligible human message through `ctx.llm`. It registers the `all-user-messages` cadence and starts a new revision after each new human prompt, using seeded history as well as child-session prompts. A newer revision aborts and supersedes older work; even a provider that ignores cancellation cannot commit stale output.
The plugin uses the complete required [shared LLM configuration](../session-title-llm/README.md#configuration). Omit both `provider` and `model` to inherit the exact route from each current logged main request, or set both to route title generation independently. If the final framed aggregate prompt exceeds `maxInputBytes`, the request fails instead of truncating history; automatic use warns and keeps the prior title.

View File

@@ -0,0 +1,28 @@
# @deepseek-ai/dsh-session-title-all-messages-llm
[English](README.md) | 中文
可选的 `ctx.sessionTitle` 提供方,通过 `ctx.llm` 总结所有符合条件的用户消息。它注册 `all-user-messages` 节奏,并在每条新用户提示词后启动新 revision同时使用 seed 历史与子会话提示词。较新的 revision 会中止并取代旧工作;即使提供方忽略取消,也无法提交陈旧输出。
该插件使用完整且必填的[共享 LLM 配置](../session-title-llm/README.md#configuration)。同时省略 `provider``model` 时,会继承每个当前已记录主请求的确切路由;也可以同时设置二者,使标题生成使用独立路由。如果最终封装的聚合提示词超过 `maxInputBytes`,请求会失败而不是截断历史;自动使用时会发出警告并保留先前标题。
## 模型体验
### 全消息标题请求
#### 模型看到的内容
标题模型会收到共享标题指令,以及一个 JSON 数组,其中按日志顺序包含截至当前 revision 的所有符合条件用户消息和确切 seq。Seed 历史也包含在内。
#### Token 影响
每条符合条件的新提示词之后都可能发送一项辅助请求,每次请求受 `maxInputBytes``maxOutputTokens` 约束;显式刷新可能增加调用。主 agent 请求不会增加 token。
#### KV Cache 影响
不会使主请求失效。每条提示词后,辅助输入都会增长或变化,因此提供方专用缓存复用会在第一个变化的 JSON token 处结束。
## 已知限制与暂缓工作
- 输入溢出时保留先前标题;对于很长的会话,此提供方没有摘要再摘要机制或保留策略。
- 它平等对待所有符合条件的用户消息,不提供权重、过滤或手动标题优先级。

View File

@@ -0,0 +1,6 @@
# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write
README.md: c24d4de1fa945d11b5a868cad88a94ed14ad3891
README.zh.md: a3adc5366c841ed6aa08220209ed372db1fc8666

View File

@@ -1,5 +1,7 @@
# @deepseek-ai/dsh-session-title-first-message-llm
English | [中文](README.zh.md)
Optional `ctx.sessionTitle` provider that summarizes the first eligible human message through `ctx.llm`. It registers the `first-message` cadence, runs automatically only when a fresh non-fork session first creates its fallback, and attributes the result to that message's exact seq. An automatic failure retains the fallback and is retried only through `ctx.sessionTitle.refresh()`.
The plugin uses the complete required [shared LLM configuration](../session-title-llm/README.md#configuration). Omit both `provider` and `model` to inherit the exact route from the current logged main request, or set both to route title generation independently.

View File

@@ -0,0 +1,28 @@
# @deepseek-ai/dsh-session-title-first-message-llm
[English](README.md) | 中文
可选的 `ctx.sessionTitle` 提供方,通过 `ctx.llm` 总结第一条符合条件的用户消息。它注册 `first-message` 节奏,只在全新非 fork 会话首次创建回退时自动运行,并将结果归因于该消息的确切 seq。自动失败会保留回退之后只能通过 `ctx.sessionTitle.refresh()` 重试。
该插件使用完整且必填的[共享 LLM 配置](../session-title-llm/README.md#configuration)。同时省略 `provider``model` 时,会继承当前已记录主请求的确切路由;也可以同时设置二者,使标题生成使用独立路由。
## 模型体验
### 首消息标题请求
#### 模型看到的内容
标题模型会收到共享标题指令,以及一个只包含第一条符合条件用户消息的 JSON 数组。后续提示词与继承的 fork 历史不会触发另一项自动调用。
#### Token 影响
全新会话最多自动发出一项辅助请求,并受 `maxInputBytes``maxOutputTokens` 约束;显式刷新可能发出额外调用。主 agent 请求不会增加 token。
#### KV Cache 影响
不会使主请求失效。辅助请求使用已配置或已记录路由,其缓存行为由提供方决定。
## 已知限制与暂缓工作
- 对于长期会话,第一条消息可能不再具有代表性;如果后续提示词应触发重新生成标题,请使用全消息提供方。
- Fork 会保留继承的标题,绝不会自动运行此提供方,即使 seed 中的首消息来自父会话。

View File

@@ -0,0 +1,6 @@
# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write
README.md: 5d004b634e6242a8a558182e6c953e4c43b25e1f
README.zh.md: 36567d950e612561d8af804eca64ac6f9f3cd788

View File

@@ -1,5 +1,7 @@
# @deepseek-ai/dsh-session-title-llm
English | [中文](README.zh.md)
Shared implementation policy for model-backed session-title providers. It resolves the auxiliary route, frames exact selected human messages as JSON, records the exact dispatchable request, applies a language-aware title instruction, enforces input and output budgets, composes timeout and caller cancellation, assembles the stream, and returns normalized text with exact source seqs and model provenance.
This package is a library, not a Cordis plugin. The provider plugins call `registerSessionTitleLlmProvider()` with their cadence and message selector; it validates shared config and delegates each revision to `generateSessionTitleWithLlm()`, so registration, route, prompt, cancellation, and validation behavior cannot drift between them.

View File

@@ -0,0 +1,47 @@
# @deepseek-ai/dsh-session-title-llm
[English](README.md) | 中文
模型后端会话标题提供方的共享实现策略。它解析辅助路由,将精确选中的用户消息封装为 JSON记录可分发的确切请求应用语言感知的标题指令强制执行输入和输出预算组合超时与调用方取消组装流并返回带有确切来源 seq 和模型 provenance 的规范化文本。
此包是普通库,不是 Cordis 插件。提供方插件调用 `registerSessionTitleLlmProvider()`,传入各自节奏与消息选择器;该函数验证共享配置,并将每个 revision 委派给 `generateSessionTitleWithLlm()`,使两者的注册、路由、提示词、取消与验证行为不会漂移。
## 路由与失败契约
`provider``model` 覆盖项都是可选的,但必须同时作为非空字符串提供。如果没有这一对取值,辅助模块会使用当前会话已记录 `request/header` 中捕获的确切提供方/模型路由;因此,在任何路由出现前显式刷新时必须提供覆盖项。辅助模块在记录或分发前,以 `maxInputBytes` 测量最终 JSON 封装的用户提示词,包括 seq 字段、包装层与 JSON 转义,而不是将其截断。消费流期间和流完成后都会重新检查超时与调用方取消,因此即使 interceptor 或适配器忽略 abort也不能接受迟到的成功结果。格式错误或空输出、工具调用和非 stop 结束原因同样会 reject会话标题服务决定该 reject 属于自动警告还是显式调用方失败。
路由与输入验证完成后,辅助模块会在模型分发前追加仅写入日志的 `session/title-llm-request` 事件。它包含标题提供方 id、确切来源 seq、路由、系统提示词、消息列表以及该调用使用的输出 token 上限。追加操作共享标题能力的逐会话结算队列,因此取代当前请求的新请求不会与更早回退、请求记录或已接受标题的 flush 冲突。分发的 envelope 会深度冻结,携带 `purpose: 'session-title'`,且有意不包含 dsh-agent-loop 的进程本地请求身份。Interceptor 会与记录保持一致,而循环专用重建观察者不会把它与对话 header 比较。DeepSeek 适配器会将该 purpose 映射为关闭 thinking使少量输出预算全部用于可见标题文本其他适配器负责自身 purpose 专用行为。后续模型失败会保留请求记录;从未成为可分发请求的验证失败不会创建记录。该事件始终位于派生模型历史之外。
## 配置
除成对的路由覆盖项外,每个字段都必填;库不提供默认值。
| 键 | 契约 |
|---|---|
| `targetWords` | 非 CJK 标题的正整数目标词数。 |
| `targetCjkCharacters` | 中文、日文或韩文标题的正整数目标字符数。 |
| `maxInputBytes` | 最终 JSON 封装用户提示词的正整数 UTF-8 字节上限。 |
| `maxOutputTokens` | 辅助生成的正整数 token 上限。 |
| `timeoutMs` | 运行时定时器限制内的端到端正数 deadline。 |
| `provider`, `model` | 可选显式路由;二者同时提供或同时省略。 |
## 模型体验
### 辅助标题请求
#### 模型看到的内容
标题模型会收到固定系统指令,要求以输入语言返回一个简洁且无装饰的标题,其中包含所配置的词数与 CJK 字符数目标。它唯一的用户消息包含一个 JSON 数组,其中是精确选中的用户消息及其 seq。
#### Token 影响
辅助请求根据所选输入大小和 `maxOutputTokens` 消耗 token。它与主 agent 请求相互独立,不会向 agent 历史增加标题文本或封装内容。DeepSeek 标题调用会关闭 thinking主对话保留自身配置的 thinking 模式。
#### KV Cache 影响
不会使主请求失效。辅助缓存复用由提供方决定;固定指令可复用,而 JSON 消息数组会随每个 revision 变化。
## 已知限制与暂缓工作
- 辅助模块只接受文本输出,并拒绝工具调用;不公开结构化输出适配器或提供方专用提示词变体。
- 它对整个封装用户提示词强制执行字节上限,不会剪裁单条消息或应用保留策略。

View File

@@ -0,0 +1,6 @@
# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write
README.md: 2be6f37ce37f525dd567772144e925886ad51b42
README.zh.md: 7f55b7bba912bf4611f5a058a0390d67b8860b24

View File

@@ -1,5 +1,7 @@
# @deepseek-ai/dsh-session-title
English | [中文](README.zh.md)
Log-backed session titles with an immediate deterministic fallback and one optional asynchronous provider. Every accepted revision is a log-only `session/title` event; `foldSessionTitle()` and `ctx.sessionTitle.get()` select the latest event and return its event seq and timestamp.
Only text blocks from human `user/message` events are eligible. The first eligible prompt schedules a fallback from its first words within the configured UTF-8 byte limit. Whitespace is normalized, terminal control sequences are removed, and truncation never splits a code point. Empty and non-text prompts wait for later eligible input.

View File

@@ -0,0 +1,54 @@
# @deepseek-ai/dsh-session-title
[English](README.md) | 中文
由日志支持的会话标题,提供即时确定性回退与一个可选异步提供方。每个已接受 revision 都是仅写入日志的 `session/title` 事件;`foldSessionTitle()``ctx.sessionTitle.get()` 会选择最新事件,并返回其事件 seq 和时间戳。
只有用户 `user/message` 事件中的文本块符合条件。第一条符合条件的提示词会安排回退,从其开头若干词生成标题,并受所配置 UTF-8 字节上限约束。系统会规范化空白、移除终端控制序列,且截断绝不会切断 code point。空提示词和非文本提示词会等待后续符合条件的输入。
## 服务:`SessionTitleService`ctx 键:`sessionTitle`
- `get(session)` 从活跃或回放日志折叠最新已接受标题。
- `refresh(session, signal?)` 在需要时物化回退,然后显式运行已注册提供方,处理当前符合条件的消息。提供方错误与调用方取消会 reject取消不会回滚已经进入持久化流程的回退追加。
- `register(provider)` 安装唯一可选提供方,并返回可等待的 Cordis effect disposer。第二次注册会立即抛出资源释放会中止待处理和活跃调用等待其结算之后才允许注册另一个提供方。
自动工作绝不会延迟主 agent 响应。只有当带标记、由循环构建的请求,其确切路由与当前已记录的 `request/header` 匹配时,提供方才会启动;即使 header 未变而无需新快照,也适用此规则。延迟完成会加入开放轮次,或使用已经 flush 的零步骤 `session-title` 轮次,并通过 `ctx.sessions.appendOutOfBand()` 追加。自动失败会发出警告并保留最新标题。新的全消息 revision、提供方资源释放、会话资源释放和显式刷新都会中止旧工作陈旧完成值无法追加。并发显式刷新会在等待回退持久化前预留顺序重叠的自动显式回退请求共享一个会话本地进行中追加。服务与随附模型提供方记录使用 `appendSessionTitleOutOfBand()`,共享逐会话结算队列,因此替换请求记录会等待更早标题写入,但无需串行等待被取代的模型调用本身。服务 teardown 会取消排队工作,并在卸载完成前排空忽略取消的调用。
Fork 会原样继承 seed 中的标题事件。首消息节奏不会自动为子会话重新生成标题;全消息节奏可以在子会话收到后续用户提示词后追加新 revision。
## 配置
所有上限都是必填项;该库不提供默认值。
| 键 | 契约 |
|---|---|
| `fallbackMaxWords` | 确定性回退中以空白分隔的最大正整数词数。 |
| `fallbackMaxBytes` | 回退允许的最大正整数 UTF-8 字节数;不得超过 `maxTitleBytes`。 |
| `maxTitleBytes` | 接受任何来源标题的最大正整数 UTF-8 字节数。 |
## 提供方契约
提供方会提供品牌化稳定 id、自动模式`first-message``all-user-messages`)和 `generate(request)`。请求携带活跃会话、截至一个固定 revision 的所有符合条件消息、可用时当前已记录的主请求路由,以及取消信号。结果包含非空标题、该请求中唯一且有序的来源消息 seq以及可选模型 provenance。服务会在结果持久化前进行规范化和验证。
参见[会话标题数据结构](../../../docs/core-data-structures/session-title.md)与[已实现决策](../../../.agents/notes/implemented/feature/2026-07-21-log-backed-session-titles.md)。
## 模型体验
### 会话标题状态
#### 模型看到的内容
无。`session/title` 只写入日志,绝不会进入会话接口、`deriveMessages()`、系统提示词、工具 schema 或请求前缀。
#### Token 影响
回退与已接受的提供方 revision 不会向主 agent 请求增加 token。可选提供方的独立辅助请求由对应提供方包记录。
#### KV Cache 影响
不影响主请求;标题事件不会改变重建内容或缓存键。
## 已知限制与暂缓工作
- 手动重命名、删除标题、生成标题与用户标题的优先级、搜索和列表索引都不属于此服务。
- 提供方注册表有意最多接受一个实现,因此部署若要组合相互竞争的标题策略,必须编写一个自行负责优先级的提供方。