@deepseek-ai/dsh-session-reference 0.0.1-rc.2 → 0.0.1-rc.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/README.i18n.yaml +2 -2
- package/README.md +3 -3
- package/README.zh.md +3 -3
- package/lib/index.js +5 -5
- package/lib/types/index.d.ts +3 -3
- package/package.json +17 -17
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/context/session-reference/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 1f7df17f512b109e0e29bebf3f7931516914c368
|
|
6
|
+
README.zh.md: 380f1c613621a8e1fd5b4ee27b70f40f4072197b
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
English | [中文](README.zh.md)
|
|
4
4
|
|
|
5
|
-
`ctx.
|
|
5
|
+
`ctx.sessionReferenceResolver` prepares bounded, read-only snapshots of other sessions as sourced model-facing context. It consumes `ctx.sessionQuery` and the backend-independent compact checkpoint marker; SQLite FTS is not required. Hosts that support cross-session mentions may opt into the service.
|
|
6
6
|
|
|
7
7
|
## Public API
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ English | [中文](README.zh.md)
|
|
|
12
12
|
|
|
13
13
|
## Snapshot semantics
|
|
14
14
|
|
|
15
|
-
Preparation calls `ctx.sessionQuery.readSurface()` once per distinct source and never rereads it after enqueue. It projects only direct-user `user/message`, assistant text, and `user/message` checkpoints carrying the canonical `dsh-
|
|
15
|
+
Preparation calls `ctx.sessionQuery.readSurface()` once per distinct source and never rereads it after enqueue. It projects only direct-user `user/message`, assistant text, and `user/message` checkpoints carrying the canonical `dsh-compaction` source marker from the folded current surface. For a source prompt that already contains baked prefix context, projection reads only its model-hidden display content, preventing recursive snapshot propagation. Shadowed pre-compaction events, tools, reasoning, context, plugin-generated user messages other than marked compact checkpoints, and unfinished assistant chunks are excluded. A compacted source therefore contributes its latest checkpoint plus retained later conversation, not restored shadowed text.
|
|
16
16
|
|
|
17
17
|
The context source is `{ kind: 'session-reference', version: 1, references }`; each reference records its source id and label, capture seq, compact presence, retained/omitted message counts, omitted UTF-8 bytes, and truncation state. When the agent is idle, the standard TUI installs a one-shot `agent/pre-step` wrapper that adds the snapshot only to an `enter` decision containing the claimed direct prompt. While the agent is running, it calls `inject()` immediately before `steer()`, placing both messages in the next-step inbox for the same later claim. The target log therefore records a sourced context `user/message` followed by the readable direct `user/message`. Later source mutation, compaction, or deletion cannot change target replay.
|
|
18
18
|
|
|
@@ -24,7 +24,7 @@ The context source is `{ kind: 'session-reference', version: 1, references }`; e
|
|
|
24
24
|
| `candidateLimit` | `50` | Default candidate count returned to a host. |
|
|
25
25
|
| `maxReferenceBytes` | `65536` | Maximum serialized JSON bytes for one reference object. |
|
|
26
26
|
|
|
27
|
-
Retention applies `maxReferenceBytes` independently to each source, keeps compact checkpoints and the newest message before dropping older non-checkpoint units, and uses `dsh-retention` head/tail truncation with an exact UTF-8 omission notice. If one source's fixed serialized fields cannot fit, preparation fails with `SESSION_REFERENCE_BUDGET_EXCEEDED` instead of returning a partial context.
|
|
27
|
+
Retention applies `maxReferenceBytes` independently to each source, keeps compact checkpoints and the newest message before dropping older non-checkpoint units, and uses `dsh-output-retention` head/tail truncation with an exact UTF-8 omission notice. If one source's fixed serialized fields cannot fit, preparation fails with `SESSION_REFERENCE_BUDGET_EXCEEDED` instead of returning a partial context.
|
|
28
28
|
|
|
29
29
|
## Model Experience
|
|
30
30
|
|
package/README.zh.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 中文
|
|
4
4
|
|
|
5
|
-
`ctx.
|
|
5
|
+
`ctx.sessionReferenceResolver` 会把其他会话准备为有界、只读快照,作为带来源信息、面向模型的上下文。它消费 `ctx.sessionQuery` 与后端无关的 compact 检查点标记;不需要 SQLite FTS。支持跨会话 mention 的宿主可以主动启用该服务。
|
|
6
6
|
|
|
7
7
|
## 公开 API
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
## 快照语义
|
|
14
14
|
|
|
15
|
-
准备阶段会对每个不同源调用一次 `ctx.sessionQuery.readSurface()`,入队后绝不重读。它仅投影折叠后当前表层中的用户直接发出的 `user/message`、assistant 文本,以及 `user/message` 检查点;这类检查点携带规范 `dsh-
|
|
15
|
+
准备阶段会对每个不同源调用一次 `ctx.sessionQuery.readSurface()`,入队后绝不重读。它仅投影折叠后当前表层中的用户直接发出的 `user/message`、assistant 文本,以及 `user/message` 检查点;这类检查点携带规范 `dsh-compaction` 源标记。对于已经包含固化前缀上下文的源提示词,投影只读取其对模型隐藏的显示内容,以防止快照递归传播。已遮蔽的压缩(compaction)前事件、工具、推理(reasoning)、上下文、除已标记 compact 检查点外的插件生成 user 消息,以及未完成的 assistant 分片均会被排除。因此,已压缩源只会提供最新检查点及其后保留的会话内容,不会还原已遮蔽的文本。
|
|
16
16
|
|
|
17
17
|
上下文源为 `{ kind: 'session-reference', version: 1, references }`;每条引用会记录其源 id 与 label、捕获 seq、是否存在 compact、已保留/已省略消息数、已省略 UTF-8 字节数与截断状态。agent 空闲时,标准 TUI 会安装一次性的 `agent/pre-step` 包装层,只把快照添加到包含已领取直接提示词的 `enter` 决策。agent 运行时,它会紧接着调用 `inject()` 和 `steer()`,把两条消息放入 next-step inbox,等待后续同一次领取。目标日志因此会先记录一条带来源信息的上下文 `user/message`,再记录可读的直接 `user/message`。后续源变更、压缩或删除都无法改变目标回放。
|
|
18
18
|
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
| `candidateLimit` | `50` | 返回给宿主的默认候选数量。 |
|
|
25
25
|
| `maxReferenceBytes` | `65536` | 一个引用对象的最大序列化 JSON 字节数。 |
|
|
26
26
|
|
|
27
|
-
保留会对每个源独立应用 `maxReferenceBytes`,保留 compact 检查点与最新消息,再丢弃较旧的非检查点单元,并使用 `dsh-retention` 头部/尾部截断和精确 UTF-8 省略通知。如果某个源的固定序列化字段本身就超出限额,准备会以 `SESSION_REFERENCE_BUDGET_EXCEEDED` 失败,而不返回部分上下文。
|
|
27
|
+
保留会对每个源独立应用 `maxReferenceBytes`,保留 compact 检查点与最新消息,再丢弃较旧的非检查点单元,并使用 `dsh-output-retention` 头部/尾部截断和精确 UTF-8 省略通知。如果某个源的固定序列化字段本身就超出限额,准备会以 `SESSION_REFERENCE_BUDGET_EXCEEDED` 失败,而不返回部分上下文。
|
|
28
28
|
|
|
29
29
|
## 模型体验
|
|
30
30
|
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Service } from "@deepseek-ai/cordis";
|
|
2
2
|
import z from "@deepseek-ai/schemastery";
|
|
3
3
|
import { assertNever, createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
4
|
-
import { isCompactCheckpointSource } from "@deepseek-ai/dsh-
|
|
5
|
-
import { TextRetainer } from "@deepseek-ai/dsh-retention";
|
|
4
|
+
import { isCompactCheckpointSource } from "@deepseek-ai/dsh-compaction";
|
|
5
|
+
import { TextRetainer } from "@deepseek-ai/dsh-output-retention";
|
|
6
6
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
7
7
|
//#region lib/types/config.js
|
|
8
8
|
/** Configuration and stable diagnostics for session references. */
|
|
@@ -276,7 +276,7 @@ user explicitly repeats them.
|
|
|
276
276
|
`;
|
|
277
277
|
const PROMPT_SUFFIX = "\n</referenced-sessions>";
|
|
278
278
|
/** Exact-read consumer that prepares immutable cross-session message context. */
|
|
279
|
-
var
|
|
279
|
+
var SessionReferenceResolver = class extends Service {
|
|
280
280
|
static inject = ["sessionQuery"];
|
|
281
281
|
static Config = z.object({
|
|
282
282
|
maxReferences: z.number().step(1).min(1).max(3).default(3),
|
|
@@ -285,7 +285,7 @@ var SessionReferenceService = class extends Service {
|
|
|
285
285
|
});
|
|
286
286
|
config;
|
|
287
287
|
constructor(ctx, config = {}) {
|
|
288
|
-
super(ctx, "
|
|
288
|
+
super(ctx, "sessionReferenceResolver");
|
|
289
289
|
this.config = {
|
|
290
290
|
maxReferences: config.maxReferences ?? 3,
|
|
291
291
|
candidateLimit: config.candidateLimit ?? 50,
|
|
@@ -438,4 +438,4 @@ function cancelled(signal) {
|
|
|
438
438
|
return new SessionReferenceError("session reference preparation was cancelled", "SESSION_REFERENCE_CANCELLED", { cause: signal.reason });
|
|
439
439
|
}
|
|
440
440
|
//#endregion
|
|
441
|
-
export { DEFAULT_CANDIDATE_LIMIT, DEFAULT_MAX_REFERENCE_BYTES, MAX_REFERENCES, SESSION_REFERENCE_SCHEME, SessionReferenceError,
|
|
441
|
+
export { DEFAULT_CANDIDATE_LIMIT, DEFAULT_MAX_REFERENCE_BYTES, MAX_REFERENCES, SESSION_REFERENCE_SCHEME, SessionReferenceError, SessionReferenceResolver, SessionReferenceResolver as default, decodeSessionReferenceUri, encodeSessionReferenceUri, formatSessionReferenceMention, parseSessionReferenceText };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -16,11 +16,11 @@ export { DEFAULT_CANDIDATE_LIMIT, DEFAULT_MAX_REFERENCE_BYTES, MAX_REFERENCES, S
|
|
|
16
16
|
export { SESSION_REFERENCE_SCHEME, decodeSessionReferenceUri, encodeSessionReferenceUri, formatSessionReferenceMention, parseSessionReferenceText, } from './uri.ts';
|
|
17
17
|
declare module '@deepseek-ai/cordis' {
|
|
18
18
|
interface Context {
|
|
19
|
-
|
|
19
|
+
sessionReferenceResolver: SessionReferenceResolver;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
/** Exact-read consumer that prepares immutable cross-session message context. */
|
|
23
|
-
export declare class
|
|
23
|
+
export declare class SessionReferenceResolver extends Service {
|
|
24
24
|
static inject: string[];
|
|
25
25
|
static Config: z<Config>;
|
|
26
26
|
private readonly config;
|
|
@@ -45,5 +45,5 @@ export declare class SessionReferenceService extends Service {
|
|
|
45
45
|
prepare(agent: Agent, content: ContentBlock[], references: SessionReferenceInput[], signal?: AbortSignal): Promise<PreparedReferencedMessage>;
|
|
46
46
|
private renderSources;
|
|
47
47
|
}
|
|
48
|
-
export default
|
|
48
|
+
export default SessionReferenceResolver;
|
|
49
49
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-session-reference",
|
|
3
|
-
"description": "Cross-session snapshot references and durable untrusted model context (ctx.
|
|
4
|
-
"version": "0.0.1-rc.
|
|
3
|
+
"description": "Cross-session snapshot references and durable untrusted model context (ctx.sessionReferenceResolver)",
|
|
4
|
+
"version": "0.0.1-rc.3",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "restricted"
|
|
7
7
|
},
|
|
@@ -35,23 +35,23 @@
|
|
|
35
35
|
"@deepseek-ai/schemastery": "^3.18.1-rc.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@deepseek-ai/dsh-
|
|
39
|
-
"@deepseek-ai/dsh-invariants": "^0.0.1-rc.
|
|
40
|
-
"@deepseek-ai/dsh-
|
|
41
|
-
"@deepseek-ai/dsh-
|
|
42
|
-
"@deepseek-ai/dsh-retention": "^0.0.1-rc.
|
|
43
|
-
"@deepseek-ai/dsh-session": "^0.0.1-rc.
|
|
44
|
-
"@deepseek-ai/dsh-session-query": "^0.0.1-rc.
|
|
38
|
+
"@deepseek-ai/dsh-compaction": "^0.0.1-rc.3",
|
|
39
|
+
"@deepseek-ai/dsh-invariants": "^0.0.1-rc.3",
|
|
40
|
+
"@deepseek-ai/dsh-agent": "^0.0.1-rc.3",
|
|
41
|
+
"@deepseek-ai/dsh-llm": "^0.0.1-rc.3",
|
|
42
|
+
"@deepseek-ai/dsh-output-retention": "^0.0.1-rc.3",
|
|
43
|
+
"@deepseek-ai/dsh-session": "^0.0.1-rc.3",
|
|
44
|
+
"@deepseek-ai/dsh-session-query": "^0.0.1-rc.3",
|
|
45
45
|
"@deepseek-ai/cordis": "^4.0.1-rc.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@deepseek-ai/dsh-
|
|
49
|
-
"@deepseek-ai/dsh-
|
|
50
|
-
"@deepseek-ai/dsh-llm": "^0.0.1-rc.
|
|
51
|
-
"@deepseek-ai/dsh-
|
|
52
|
-
"@deepseek-ai/dsh-
|
|
53
|
-
"@deepseek-ai/dsh-session
|
|
54
|
-
"@deepseek-ai/
|
|
55
|
-
"@deepseek-ai/
|
|
48
|
+
"@deepseek-ai/dsh-compaction": "^0.0.1-rc.3",
|
|
49
|
+
"@deepseek-ai/dsh-invariants": "^0.0.1-rc.3",
|
|
50
|
+
"@deepseek-ai/dsh-llm": "^0.0.1-rc.3",
|
|
51
|
+
"@deepseek-ai/dsh-output-retention": "^0.0.1-rc.3",
|
|
52
|
+
"@deepseek-ai/dsh-agent": "^0.0.1-rc.3",
|
|
53
|
+
"@deepseek-ai/dsh-session": "^0.0.1-rc.3",
|
|
54
|
+
"@deepseek-ai/dsh-session-query": "^0.0.1-rc.3",
|
|
55
|
+
"@deepseek-ai/cordis": "^4.0.1-rc.1"
|
|
56
56
|
}
|
|
57
57
|
}
|