@deepseek-ai/dsh-session-log-deepseek 0.1.3-alpha.2 → 0.1.5-alpha.2
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 +1 -1
- package/lib/index.js +40 -12
- package/lib/types/index.js +32 -13
- package/lib/types/types.d.ts +32 -10
- package/package.json +15 -15
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/session/session-log-deepseek/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 38a5ec64cee32c25b11e5b7c0b55b7302f66952a
|
|
6
|
+
README.zh.md: 598345ebfbc24d4786aa9e7361d947b41b5d79d0
|
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ Shipped profiles mount the plugin so an overlay can enable it, but the default c
|
|
|
34
34
|
<a id="request-field"></a>
|
|
35
35
|
## Request field
|
|
36
36
|
|
|
37
|
-
For a request carrying a live `sessionId`, the plugin folds the greatest accepted watermark for that exact Session format generation, snapshots `Session.events`, and sends the contiguous suffix after the watermark. A process-local fold scans each event once and consumes later appends incrementally; restart and HMR rebuild it from the durable log. The version-1 field contains `sessionFormatVersion`, a raw session header (`seedLength` is present only for a seeded Session), numeric `afterSeq` and `throughSeq`, and every complete canonical event translated to raw-number envelope fields. Forked sessions ignore inherited parent watermarks because both the recorded Session id and format generation must match the request source.
|
|
37
|
+
For a request carrying a live `sessionId`, the plugin folds the greatest accepted watermark for that exact Session format generation, snapshots `Session.events`, and sends the contiguous suffix after the watermark. A process-local fold scans each event once and consumes later appends incrementally; restart and HMR rebuild it from the durable log. The version-1 field contains `sessionFormatVersion`, a raw session header (`seedLength` is present only for a seeded Session), numeric `afterSeq` and `throughSeq`, and every complete canonical event translated to raw-number envelope fields. Forked sessions ignore inherited parent watermarks because both the recorded Session id and format generation must match the request source. Surface events require `surfaceOp`, with numeric `startSeq` and `endSeq` for replacements; only user and tool events may carry `sourceEventSeqs`. Assistant provenance stays in the embedded stream, and log-only events carry neither metadata field.
|
|
38
38
|
|
|
39
39
|
<a id="acceptance-and-retry"></a>
|
|
40
40
|
## Acceptance and retry
|
package/README.zh.md
CHANGED
|
@@ -34,7 +34,7 @@ kind: "package-reference"
|
|
|
34
34
|
<a id="request-field"></a>
|
|
35
35
|
## 请求字段
|
|
36
36
|
|
|
37
|
-
对于携带存活 `sessionId` 的请求,插件会折叠该确切会话格式代的最大已接受水位,对 `Session.events` 取快照,并发送水位之后的连续后缀。进程内 fold 会让每条事件只被扫描一次并增量消费后续追加;重启与 HMR 会从持久日志重建它。版本 1 字段包含 `sessionFormatVersion`、原始会话 header(仅 seeded Session 携带 `seedLength`)、数值型 `afterSeq` 与 `throughSeq`,以及把完整权威事件翻译为原始数值 envelope 字段后的数组元素。只有记录的会话 id 与格式代均匹配请求来源时水位才生效,因此 fork 会话会忽略从父会话继承的水位。
|
|
37
|
+
对于携带存活 `sessionId` 的请求,插件会折叠该确切会话格式代的最大已接受水位,对 `Session.events` 取快照,并发送水位之后的连续后缀。进程内 fold 会让每条事件只被扫描一次并增量消费后续追加;重启与 HMR 会从持久日志重建它。版本 1 字段包含 `sessionFormatVersion`、原始会话 header(仅 seeded Session 携带 `seedLength`)、数值型 `afterSeq` 与 `throughSeq`,以及把完整权威事件翻译为原始数值 envelope 字段后的数组元素。只有记录的会话 id 与格式代均匹配请求来源时水位才生效,因此 fork 会话会忽略从父会话继承的水位。 表层事件必须携带 `surfaceOp`,替换范围使用数值型 `startSeq` 与 `endSeq`;仅 user 与 tool 事件可以携带 `sourceEventSeqs`。assistant 的来源保留在内嵌流中,仅日志事件不携带这两个元数据字段。
|
|
38
38
|
|
|
39
39
|
<a id="acceptance-and-retry"></a>
|
|
40
40
|
## 接受与重试
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
2
|
import { brandString } from "@deepseek-ai/dsh-brand";
|
|
3
|
-
import { SessionLogOffset, SessionSeq
|
|
3
|
+
import { KNOWN_SESSION_EVENT_TYPES, SessionLogOffset, SessionSeq } from "@deepseek-ai/dsh-session";
|
|
4
4
|
//#region lib/types/index.js
|
|
5
5
|
/**
|
|
6
6
|
* Incremental session-log contribution for official DeepSeek LLM API requests.
|
|
@@ -32,20 +32,48 @@ function wireHeader(session) {
|
|
|
32
32
|
}
|
|
33
33
|
/** Translate compile-time sequence brands to raw numeric request fields. */
|
|
34
34
|
function wireEvent(event) {
|
|
35
|
-
const
|
|
36
|
-
const surfaceOp = surfaceEvent?.surfaceOp;
|
|
37
|
-
return {
|
|
38
|
-
type: event.type,
|
|
35
|
+
const common = {
|
|
39
36
|
seq: Number(event.seq),
|
|
40
37
|
time: event.time,
|
|
41
38
|
data: event.data,
|
|
42
|
-
...event.ignorable === void 0 ? {} : { ignorable: event.ignorable }
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
...event.ignorable === void 0 ? {} : { ignorable: event.ignorable }
|
|
40
|
+
};
|
|
41
|
+
switch (event.type) {
|
|
42
|
+
case "system/message":
|
|
43
|
+
case "user/message":
|
|
44
|
+
case "tool/result": return {
|
|
45
|
+
...common,
|
|
46
|
+
type: event.type,
|
|
47
|
+
surfaceOp: wireSurfaceOp(event.surfaceOp),
|
|
48
|
+
...event.sourceEventSeqs === void 0 ? {} : { sourceEventSeqs: event.sourceEventSeqs.map(Number) }
|
|
49
|
+
};
|
|
50
|
+
case "assistant/message": return {
|
|
51
|
+
...common,
|
|
52
|
+
type: event.type,
|
|
53
|
+
surfaceOp: wireSurfaceOp(event.surfaceOp)
|
|
54
|
+
};
|
|
55
|
+
default:
|
|
56
|
+
if (!KNOWN_SESSION_EVENT_TYPES.has(event.type) && event.ignorable === true) {
|
|
57
|
+
const opaque = event;
|
|
58
|
+
return {
|
|
59
|
+
...common,
|
|
60
|
+
type: event.type,
|
|
61
|
+
ignorable: true,
|
|
62
|
+
...opaque.surfaceOp === void 0 ? {} : { surfaceOp: opaque.surfaceOp },
|
|
63
|
+
...opaque.sourceEventSeqs === void 0 ? {} : { sourceEventSeqs: opaque.sourceEventSeqs }
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
...common,
|
|
68
|
+
type: event.type
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function wireSurfaceOp(op) {
|
|
73
|
+
return op === "append" ? op : {
|
|
74
|
+
op: "replace",
|
|
75
|
+
startSeq: Number(op.startSeq),
|
|
76
|
+
endSeq: Number(op.endSeq)
|
|
49
77
|
};
|
|
50
78
|
}
|
|
51
79
|
/**
|
package/lib/types/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import z from '@deepseek-ai/schemastery';
|
|
8
8
|
import { brandString } from '@deepseek-ai/dsh-brand';
|
|
9
|
-
import {
|
|
9
|
+
import { KNOWN_SESSION_EVENT_TYPES, SessionLogOffset, SessionSeq } from '@deepseek-ai/dsh-session';
|
|
10
10
|
/** Cordis plugin name. */
|
|
11
11
|
export const name = 'session-log-deepseek';
|
|
12
12
|
/** Services required to resolve sessions and contribute the provider request field. */
|
|
@@ -33,23 +33,42 @@ function wireHeader(session) {
|
|
|
33
33
|
}
|
|
34
34
|
/** Translate compile-time sequence brands to raw numeric request fields. */
|
|
35
35
|
function wireEvent(event) {
|
|
36
|
-
const
|
|
37
|
-
const surfaceOp = surfaceEvent?.surfaceOp;
|
|
38
|
-
return {
|
|
39
|
-
type: event.type,
|
|
36
|
+
const common = {
|
|
40
37
|
seq: Number(event.seq),
|
|
41
38
|
time: event.time,
|
|
42
39
|
data: event.data,
|
|
43
40
|
...event.ignorable === undefined ? {} : { ignorable: event.ignorable },
|
|
44
|
-
...surfaceEvent?.sourceEventSeqs === undefined
|
|
45
|
-
? {}
|
|
46
|
-
: { sourceEventSeqs: surfaceEvent.sourceEventSeqs.map(Number) },
|
|
47
|
-
...surfaceOp === undefined
|
|
48
|
-
? {}
|
|
49
|
-
: surfaceOp === 'append'
|
|
50
|
-
? { surfaceOp }
|
|
51
|
-
: { surfaceOp: { op: 'replace', start: Number(surfaceOp.start), end: Number(surfaceOp.end) } },
|
|
52
41
|
};
|
|
42
|
+
switch (event.type) {
|
|
43
|
+
case 'system/message':
|
|
44
|
+
case 'user/message':
|
|
45
|
+
case 'tool/result':
|
|
46
|
+
return {
|
|
47
|
+
...common,
|
|
48
|
+
type: event.type,
|
|
49
|
+
surfaceOp: wireSurfaceOp(event.surfaceOp),
|
|
50
|
+
...event.sourceEventSeqs === undefined ? {} : { sourceEventSeqs: event.sourceEventSeqs.map(Number) },
|
|
51
|
+
};
|
|
52
|
+
case 'assistant/message':
|
|
53
|
+
return { ...common, type: event.type, surfaceOp: wireSurfaceOp(event.surfaceOp) };
|
|
54
|
+
default: {
|
|
55
|
+
// Restored unknown ignorable records are opaque, not current surface events.
|
|
56
|
+
if (!KNOWN_SESSION_EVENT_TYPES.has(event.type) && event.ignorable === true) {
|
|
57
|
+
const opaque = event;
|
|
58
|
+
return {
|
|
59
|
+
...common, type: event.type, ignorable: true,
|
|
60
|
+
...opaque.surfaceOp === undefined ? {} : { surfaceOp: opaque.surfaceOp },
|
|
61
|
+
...opaque.sourceEventSeqs === undefined ? {} : { sourceEventSeqs: opaque.sourceEventSeqs },
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return { ...common, type: event.type };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function wireSurfaceOp(op) {
|
|
69
|
+
return op === 'append'
|
|
70
|
+
? op
|
|
71
|
+
: { op: 'replace', startSeq: Number(op.startSeq), endSeq: Number(op.endSeq) };
|
|
53
72
|
}
|
|
54
73
|
/**
|
|
55
74
|
* Highest confirmed sequence for this exact Session format generation.
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Wire types for lossless incremental DeepSeek session-log upload. */
|
|
2
|
-
import type { SessionEvent } from '@deepseek-ai/dsh-session';
|
|
2
|
+
import type { SessionEvent, SurfaceEventType } from '@deepseek-ai/dsh-session';
|
|
3
3
|
import type { JsonValue } from '@deepseek-ai/dsh-util-values';
|
|
4
4
|
/** Session header fields serialized as raw JSON primitives on the external request wire. */
|
|
5
5
|
export interface DeepSeekSessionLogWireHeader {
|
|
@@ -17,19 +17,41 @@ export interface DeepSeekSessionLogWireHeader {
|
|
|
17
17
|
/** Raw-number surface mutation serialized on the external request wire. */
|
|
18
18
|
export type DeepSeekSessionLogWireSurfaceOp = 'append' | {
|
|
19
19
|
readonly op: 'replace';
|
|
20
|
-
readonly
|
|
21
|
-
readonly
|
|
20
|
+
readonly startSeq: number;
|
|
21
|
+
readonly endSeq: number;
|
|
22
22
|
};
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
/**
|
|
24
|
+
* One canonical event translated to raw JSON primitives for upload. Surface
|
|
25
|
+
* events require an operation; system, user, and tool events may cite sources.
|
|
26
|
+
* Assistant provenance is embedded in its data; log-only events carry neither field.
|
|
27
|
+
*/
|
|
28
|
+
export type DeepSeekSessionLogWireEvent = {
|
|
29
|
+
[K in SessionEvent['type']]: {
|
|
30
|
+
readonly type: K;
|
|
31
|
+
readonly seq: number;
|
|
32
|
+
readonly time: number;
|
|
33
|
+
readonly data: JsonValue;
|
|
34
|
+
readonly ignorable?: true;
|
|
35
|
+
} & (K extends SurfaceEventType ? {
|
|
36
|
+
readonly surfaceOp: DeepSeekSessionLogWireSurfaceOp;
|
|
37
|
+
} & (K extends 'assistant/message' ? {
|
|
38
|
+
readonly sourceEventSeqs?: never;
|
|
39
|
+
} : {
|
|
40
|
+
readonly sourceEventSeqs?: readonly number[];
|
|
41
|
+
}) : {
|
|
42
|
+
readonly surfaceOp?: never;
|
|
43
|
+
readonly sourceEventSeqs?: never;
|
|
44
|
+
});
|
|
45
|
+
}[SessionEvent['type']] | {
|
|
46
|
+
/** Unrecognized ignorable records retain opaque metadata without surface semantics. */
|
|
47
|
+
readonly type: string;
|
|
26
48
|
readonly seq: number;
|
|
27
49
|
readonly time: number;
|
|
28
50
|
readonly data: JsonValue;
|
|
29
|
-
readonly ignorable
|
|
30
|
-
readonly
|
|
31
|
-
readonly
|
|
32
|
-
}
|
|
51
|
+
readonly ignorable: true;
|
|
52
|
+
readonly surfaceOp?: JsonValue;
|
|
53
|
+
readonly sourceEventSeqs?: JsonValue;
|
|
54
|
+
};
|
|
33
55
|
/** Versioned incremental session-log field carried by an official DeepSeek request. */
|
|
34
56
|
export interface DeepSeekSessionLogExtension {
|
|
35
57
|
readonly version: 1;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-session-log-deepseek",
|
|
3
3
|
"description": "Incremental lossless session-log request extension for the official DeepSeek LLM API",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5-alpha.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -37,28 +37,28 @@
|
|
|
37
37
|
],
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@deepseek-ai/dsh-brand": "^0.1.
|
|
41
|
-
"@deepseek-ai/dsh-util-values": "^0.1.
|
|
40
|
+
"@deepseek-ai/dsh-brand": "^0.1.5-alpha.2",
|
|
41
|
+
"@deepseek-ai/dsh-util-values": "^0.1.5-alpha.2",
|
|
42
42
|
"@deepseek-ai/schemastery": "^3.18.2"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
46
|
-
"@deepseek-ai/dsh-
|
|
47
|
-
"@deepseek-ai/dsh-
|
|
48
|
-
"@deepseek-ai/dsh-session": "^0.1.
|
|
46
|
+
"@deepseek-ai/dsh-invariants": "^0.1.5-alpha.2",
|
|
47
|
+
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "^0.1.5-alpha.2",
|
|
48
|
+
"@deepseek-ai/dsh-session": "^0.1.5-alpha.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
52
52
|
"@deepseek-ai/cordis-plugin-include": "^1.0.7",
|
|
53
53
|
"@deepseek-ai/cordis-plugin-loader": "^1.0.3",
|
|
54
|
-
"@deepseek-ai/dsh-command-feedback": "^0.1.
|
|
55
|
-
"@deepseek-ai/dsh-
|
|
56
|
-
"@deepseek-ai/dsh-
|
|
57
|
-
"@deepseek-ai/dsh-llm
|
|
58
|
-
"@deepseek-ai/dsh-llm-deepseek": "^0.1.
|
|
59
|
-
"@deepseek-ai/dsh-
|
|
60
|
-
"@deepseek-ai/dsh-
|
|
61
|
-
"@deepseek-ai/dsh-session
|
|
62
|
-
"@deepseek-ai/dsh-
|
|
54
|
+
"@deepseek-ai/dsh-command-feedback": "^0.1.5-alpha.2",
|
|
55
|
+
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "^0.1.5-alpha.2",
|
|
56
|
+
"@deepseek-ai/dsh-invariants": "^0.1.5-alpha.2",
|
|
57
|
+
"@deepseek-ai/dsh-llm": "^0.1.5-alpha.2",
|
|
58
|
+
"@deepseek-ai/dsh-llm-deepseek": "^0.1.5-alpha.2",
|
|
59
|
+
"@deepseek-ai/dsh-llm-mock-server": "^0.1.5-alpha.2",
|
|
60
|
+
"@deepseek-ai/dsh-message-feedback": "^0.1.5-alpha.2",
|
|
61
|
+
"@deepseek-ai/dsh-session": "^0.1.5-alpha.2",
|
|
62
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "^0.1.5-alpha.2"
|
|
63
63
|
}
|
|
64
64
|
}
|