refactor(session): fold the session family into packages/session/

git mv the 12 packages from session-persistence/, session-projection/,
session-title/, and telemetry/ into one session/ group per the
regrouping RFC; merge the four group READMEs into one bilingual
triplet; rewrite the group segment in tsconfig references (intra-group
references shorten to ../<pkg>), tsconfig.base.json paths/globs,
knip.json keys, vitest include, gate scripts, and authored doc/note
citations; regenerate module graph, doc graphs, catalogs, and the
lockfile importer keys. No npm names change.

Full unit suite: 8779 passed; the 18 reported failures reproduce as
env flakes (ambient-proxy IPv6 tunneling, watched-dir inotify
timeouts under parallel load) — each passes in isolation with
NO_PROXY set, matching their known pre-existing behavior on master.
This commit is contained in:
Tianyi Cui
2026-07-30 01:52:06 +08:00
parent 645fcf5713
commit 7e445c3a67
220 changed files with 258 additions and 286 deletions
@@ -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 packages/session-title/session-title-all-messages-llm/README.md
README.md: 25ec92432b5c2d18624f2f4d851552ee2b3bf5d0
README.zh.md: 947aa614741b2b0bd50e70f1d273a625a5624cc6
@@ -0,0 +1,28 @@
# @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.
## Model Experience
### All-messages title request
#### What the model sees
The title model receives the shared title instruction and a JSON array of all eligible human messages through the current revision, in log order with exact seqs. Seeded history is included.
#### Token effect
One auxiliary request may follow every new eligible prompt, bounded per request by `maxInputBytes` and `maxOutputTokens`; explicit refreshes may add calls. The main agent request gains zero tokens.
#### KV Cache effect
No main-request invalidation. Auxiliary input grows or changes after each prompt, so provider-specific cache reuse ends at the first changed JSON token.
## Known Limitations and Deferred Work
- Input overflow retains the prior title; this provider has no summarization-of-summaries or retention policy for very long sessions.
- It treats all eligible human messages equally and offers no weighting, filtering, or manual-title precedence.
@@ -0,0 +1,28 @@
# @deepseek-ai/dsh-session-title-all-messages-llm
[English](README.md) | 中文
可选的 `ctx.sessionTitle` 提供方,通过 `ctx.llm` 总结所有符合条件的用户消息。它注册 `all-user-messages` 节奏,并在每条新用户提示词后启动新 revision,同时使用预置历史与子会话提示词。较新的 revision 会中止并取代旧工作;即使提供方忽略取消,也无法提交陈旧输出。
该插件使用完整且必填的[共享大语言模型(LLM)配置](../session-title-llm/README.md#configuration)。同时省略 `provider` 与 `model` 时,会继承每个当前已记录主请求的确切路由;也可以同时设置二者,使标题生成使用独立路由。如果最终封装的聚合提示词超过 `maxInputBytes`,请求会失败而不是截断历史;自动使用时会发出警告并保留先前标题。
## 模型体验
### 全消息标题请求
#### 模型看到的内容
标题模型会收到共享标题指令,以及一个 JSON 数组,其中按日志顺序包含截至当前 revision 的所有符合条件用户消息和确切 seq。预置历史也包含在内。
#### Token 影响
每条符合条件的新提示词之后都可能发送一次辅助请求,每次请求受 `maxInputBytes` 和 `maxOutputTokens` 约束;显式刷新可能增加调用。主 agent(智能体)请求不会增加 token。
#### KV Cache 影响
不会使主请求的 KV Cache 失效。每条提示词后,辅助输入都会增长或变化,因此提供方专用缓存复用会在第一个变化的 JSON token 处结束。
## 已知限制与暂缓事项
- 输入溢出时保留先前标题;对于很长的会话,此提供方没有基于摘要继续生成摘要的机制或保留策略。
- 它平等对待所有符合条件的用户消息,不提供权重、过滤或手动标题优先级。
@@ -0,0 +1,41 @@
{
"name": "@deepseek-ai/dsh-session-title-all-messages-llm",
"description": "All-user-messages LLM provider plugin for DeepSeek Harness session titles",
"version": "0.0.1",
"private": true,
"type": "module",
"main": "lib/index.js",
"types": "lib/types/index.d.ts",
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"default": "./lib/index.js"
},
"./invariant": {
"types": "./lib/types/invariant.d.ts",
"default": "./lib/invariant.js"
},
"./package.json": "./package.json"
},
"files": ["lib/index.js", "lib/invariant.js", "lib/types/**/*.d.ts"],
"license": "BSD-3-Clause",
"peerDependencies": {
"@deepseek-ai/dsh-invariants": "^0.0.1",
"@deepseek-ai/dsh-llm": "^0.0.1",
"@deepseek-ai/dsh-session": "^0.0.1",
"@deepseek-ai/dsh-session-title": "^0.0.1",
"@deepseek-ai/dsh-session-title-llm": "^0.0.1",
"cordis": "^4.0.0-rc.7"
},
"dependencies": {
"schemastery": "^3.18.0"
},
"devDependencies": {
"@deepseek-ai/dsh-invariants": "workspace:^",
"@deepseek-ai/dsh-llm": "workspace:^",
"@deepseek-ai/dsh-session": "workspace:^",
"@deepseek-ai/dsh-session-title": "workspace:^",
"@deepseek-ai/dsh-session-title-llm": "workspace:^",
"cordis": "^4.0.0-rc.7"
}
}
@@ -0,0 +1,36 @@
/** All-human-messages model provider for `ctx.sessionTitle`. */
import type { Context } from 'cordis'
import z from 'schemastery'
import {
registerSessionTitleLlmProvider,
SessionTitleLlmConfigFields,
} from '@deepseek-ai/dsh-session-title-llm'
import type { SessionTitleLlmConfig } from '@deepseek-ai/dsh-session-title-llm'
export const name = 'session-title-all-messages-llm'
export const inject = ['sessionTitle', 'llm', 'sessions']
/** Required LLM policy; this plugin adds no defaults. */
export type Config = SessionTitleLlmConfig
/** Loader schema shared with the first-message provider. */
/* jscpd:ignore-start -- Loader requires each plugin to export its own statically walkable schema; the field validators remain shared. */
export const Config: z<Config> = z.object({
targetWords: SessionTitleLlmConfigFields.targetWords,
targetCjkCharacters: SessionTitleLlmConfigFields.targetCjkCharacters,
maxInputBytes: SessionTitleLlmConfigFields.maxInputBytes,
maxOutputTokens: SessionTitleLlmConfigFields.maxOutputTokens,
timeoutMs: SessionTitleLlmConfigFields.timeoutMs,
provider: SessionTitleLlmConfigFields.provider,
model: SessionTitleLlmConfigFields.model,
})
/* jscpd:ignore-end */
/**
* Register the all-user-messages model provider.
* @param ctx - context exposing session-title, LLM, and session services.
* @param config - required route, target, byte, token, and timeout policy.
*/
export function apply(ctx: Context, config: Config): void {
registerSessionTitleLlmProvider(ctx, config, name, 'all-user-messages', messages => messages)
}
@@ -0,0 +1,30 @@
/**
* Package-owned invariant companion for `@deepseek-ai/dsh-session-title-all-messages-llm`.
* @module @deepseek-ai/dsh-session-title-all-messages-llm/invariant
*/
/* jscpd:ignore-start */
import type { Context } from 'cordis'
import type { InvariantInstaller } from '@deepseek-ai/dsh-invariants'
const PACKAGE_NAME = '@deepseek-ai/dsh-session-title-all-messages-llm'
/** Cordis companion plugin name. */
export const name = 'session-title-all-messages-llm-invariant'
/** Service required before the companion can reserve package ownership. */
export const inject = ['invariants']
/**
* No runtime invariant: this thin provider delegates request and result validation to the shared
* title service and LLM helper and retains no independent mutable state.
*/
const install: InvariantInstaller = () => {}
/**
* Register this package's invariant companion.
* @param ctx - Cordis context carrying the invariant service.
* @returns the installed registration's disposer after setup succeeds.
*/
export const apply = (ctx: Context): Promise<() => void> =>
Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install))
/* jscpd:ignore-end */
@@ -0,0 +1,73 @@
import { Context } from 'cordis'
import { describe, expect, it } from 'vitest'
import LlmService, { createUserMessage, LlmAdapter } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions, StreamChunk } from '@deepseek-ai/dsh-llm'
import SessionStore, { Session, SessionId } from '@deepseek-ai/dsh-session'
import SessionTitleService from '@deepseek-ai/dsh-session-title'
import * as providerPlugin from '@deepseek-ai/dsh-session-title-all-messages-llm'
class RecordingAdapter extends LlmAdapter {
readonly requests: GenerateOptions[] = []
override async * stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
this.requests.push(options)
yield { type: 'text-delta', index: 0, text: 'All messages model title' }
yield { type: 'finish', reason: { kind: 'stop' } }
}
}
const TITLE_CONFIG = { fallbackMaxWords: 5, fallbackMaxBytes: 40, maxTitleBytes: 80 } as const
const LLM_CONFIG = {
targetWords: 5,
targetCjkCharacters: 10,
maxInputBytes: 1_000,
maxOutputTokens: 32,
timeoutMs: 1_000,
} as const
async function settle(): Promise<void> {
await new Promise(resolve => setTimeout(resolve, 0))
}
describe('all-messages LLM title provider', () => {
it('includes seeded history and the latest prompt while inheriting the logged request route', async () => {
const seeded = Session.create(SessionId('seed-source'))
seeded.append('turn/start', { turn: 1 })
const inherited = seeded.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'inherited prompt' }], source: { kind: 'user' },
}), { surfaceOp: 'append' })
seeded.append('session/title', {
title: 'Inherited fallback', messageSeqs: [inherited.seq], source: { kind: 'fallback' },
})
seeded.append('turn/end', { turn: 1, reason: { kind: 'completed' } })
const ctx = new Context()
await ctx.plugin(LlmService)
await ctx.plugin(SessionStore)
await ctx.plugin(SessionTitleService, TITLE_CONFIG)
const adapter = new RecordingAdapter()
ctx.llm.registerAdapter(['current-route'], adapter)
await ctx.plugin(providerPlugin, LLM_CONFIG)
const session = ctx.sessions.create(SessionId('all-plugin'), {
seed: seeded.events,
meta: { parentSession: seeded.id, seedLength: seeded.seq },
})
session.append('turn/start', { turn: 2 })
const latest = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'latest prompt' }], source: { kind: 'user' },
}), { surfaceOp: 'append' })
await settle()
session.append('request/header', {
header: { config: { provider: 'current-route', model: 'current-model' } }, reason: 'resume',
})
await settle()
expect(adapter.requests[0]).toMatchObject({ provider: 'current-route', model: 'current-model' })
const content = adapter.requests[0]?.messages[0]?.content[0]
expect(content?.type === 'text' && content.text).toContain('inherited prompt')
expect(content?.type === 'text' && content.text).toContain('latest prompt')
expect(ctx.sessionTitle.get(session)).toMatchObject({
messageSeqs: [inherited.seq, latest.seq],
})
})
})
@@ -0,0 +1,14 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": { "rootDir": "src", "outDir": "lib/types" },
"include": ["src"],
"references": [
{ "path": "../../../vendor/cosmokit" },
{ "path": "../../../vendor/cordis" },
{ "path": "../../../vendor/schemastery" },
{ "path": "../../support/invariants" },
{ "path": "../../llm/llm" },
{ "path": "../session-title" },
{ "path": "../session-title-llm" }
]
}