@deepseek-ai/dsh-session-log-deepseek 0.2.0-rc.2 → 0.2.1-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 +4 -1
- package/lib/types/index.js +4 -1
- package/package.json +19 -26
- package/lib/invariant.js +0 -52
- package/lib/types/invariant.d.ts +0 -13
- package/lib/types/invariant.js +0 -66
package/README.i18n.yaml
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
en: 1b899e63d8039643
|
|
19
19
|
zh: d489461bbb618b5d
|
|
20
20
|
/deepseek-ai-dsh-session-log-deepseek/request-field:
|
|
21
|
-
en:
|
|
22
|
-
zh:
|
|
21
|
+
en: 65795dc44af4b15e
|
|
22
|
+
zh: 849c7d57f16f66af
|
|
23
23
|
/deepseek-ai-dsh-session-log-deepseek/acceptance-and-retry:
|
|
24
24
|
en: 3688592c474b3e95
|
|
25
25
|
zh: 5e83afeb9aa9e9e3
|
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ The Web **Settings → General → Upload Session Log when using the official mo
|
|
|
39
39
|
|
|
40
40
|
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 longest contiguous run after the watermark that fits `maxBytes`. 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 system, user, and tool events may carry `sourceEventSeqs`. Assistant provider metadata stays in the embedded stream, and log-only events carry neither metadata field.
|
|
41
41
|
|
|
42
|
-
`maxBytes` bounds the complete serialized field in UTF-8 bytes, including the header and numeric envelope fields. A backlog above the limit drains across consecutive accepted requests, each continuing after the previous `throughSeq`. When the first pending event alone exceeds the limit, the request omits `dsh_session_log`, the plugin logs
|
|
42
|
+
`maxBytes` bounds the complete serialized field in UTF-8 bytes, including the header and numeric envelope fields. A backlog above the limit drains across consecutive accepted requests, each continuing after the previous `throughSeq`. When the first pending event alone exceeds the limit, the request omits `dsh_session_log`, the plugin logs one warning per blocking event, and the watermark stays before that event until `maxBytes` admits it. An event too large for the runtime to serialize at all is handled the same way, and no `maxBytes` value admits it.
|
|
43
43
|
|
|
44
44
|
<a id="acceptance-and-retry"></a>
|
|
45
45
|
## Acceptance and retry
|
package/README.zh.md
CHANGED
|
@@ -39,7 +39,7 @@ Web **设置 → 通用 → 在使用官方模型 API 时上传 Session Log**
|
|
|
39
39
|
|
|
40
40
|
对于携带存活 `sessionId` 的请求,插件会折叠该确切会话格式代的最大已接受水位,对 `Session.events` 取快照,并发送水位之后能放进 `maxBytes` 的最长连续事件段。进程内 fold 会让每条事件只被扫描一次并增量消费后续追加;重启与 HMR(热模块替换)会从持久日志重建它。版本 1 字段包含 `sessionFormatVersion`、原始会话 header(仅 seeded Session 携带 `seedLength`)、数值型 `afterSeq` 与 `throughSeq`,以及每个已转换为原始数值 envelope 字段的完整规范事件。只有记录的会话 id 与格式代均匹配请求来源时水位才生效,因此 fork 会话会忽略从父会话继承的水位。表层事件必须携带 `surfaceOp`,替换范围使用数值型 `startSeq` 与 `endSeq`;仅 system、user 与 tool 事件可以携带 `sourceEventSeqs`。assistant 的提供方元数据保留在内嵌流中,只出现在日志中的事件不携带这两个元数据字段。
|
|
41
41
|
|
|
42
|
-
`maxBytes` 按 UTF-8 字节限制完整的序列化字段,包括 header 与数值型 envelope 字段。超过上限的积压会分多次已接受的请求补传,每次都从上一次的 `throughSeq` 之后继续。第一条待发事件本身就超过上限时,请求会省略 `dsh_session_log
|
|
42
|
+
`maxBytes` 按 UTF-8 字节限制完整的序列化字段,包括 header 与数值型 envelope 字段。超过上限的积压会分多次已接受的请求补传,每次都从上一次的 `throughSeq` 之后继续。第一条待发事件本身就超过上限时,请求会省略 `dsh_session_log`,插件对每个阻塞事件只记录一次告警,水位停在该事件之前,直到 `maxBytes` 能容纳它。运行时根本无法序列化的超大事件也按同样方式处理,且任何 `maxBytes` 都无法容纳它。
|
|
43
43
|
|
|
44
44
|
<a id="acceptance-and-retry"></a>
|
|
45
45
|
## 接受与重试
|
package/lib/index.js
CHANGED
|
@@ -19,6 +19,8 @@ const Config = z.object({
|
|
|
19
19
|
maxBytes: z.number().step(1).min(1).default(8 * 1024 * 1024)
|
|
20
20
|
});
|
|
21
21
|
const acceptanceFolds = /* @__PURE__ */ new WeakMap();
|
|
22
|
+
/** Event each Session's upload was last reported blocked at; a block is logged once. */
|
|
23
|
+
const blockedWarnings = /* @__PURE__ */ new WeakMap();
|
|
22
24
|
/** Translate logical Session metadata to raw external request fields. */
|
|
23
25
|
function wireHeader(session) {
|
|
24
26
|
const header = session.header;
|
|
@@ -165,7 +167,8 @@ function apply(ctx, config) {
|
|
|
165
167
|
const last = events.length === 0 ? void 0 : pending[events.length - 1];
|
|
166
168
|
if (last === void 0) {
|
|
167
169
|
const first = pending[0];
|
|
168
|
-
if (first !== void 0) {
|
|
170
|
+
if (first !== void 0 && blockedWarnings.get(session) !== first.seq) {
|
|
171
|
+
blockedWarnings.set(session, first.seq);
|
|
169
172
|
const seq = String(first.seq);
|
|
170
173
|
ctx.logger.warn(Number.isFinite(candidateBytes) ? `session-log-deepseek: event ${seq} of session "${session.id}" needs a ${String(candidateBytes)}-byte dsh_session_log field, above maxBytes ${String(maxBytes)}; this session's upload stays at event ${seq} until maxBytes admits it` : `session-log-deepseek: event ${seq} of session "${session.id}" is too large to serialize into a dsh_session_log field; this session's upload stays at event ${seq}`);
|
|
171
174
|
}
|
package/lib/types/index.js
CHANGED
|
@@ -18,6 +18,8 @@ export const Config = z.object({
|
|
|
18
18
|
maxBytes: z.number().step(1).min(1).default(8 * 1024 * 1024),
|
|
19
19
|
});
|
|
20
20
|
const acceptanceFolds = new WeakMap();
|
|
21
|
+
/** Event each Session's upload was last reported blocked at; a block is logged once. */
|
|
22
|
+
const blockedWarnings = new WeakMap();
|
|
21
23
|
/** Translate logical Session metadata to raw external request fields. */
|
|
22
24
|
function wireHeader(session) {
|
|
23
25
|
const header = session.header;
|
|
@@ -177,7 +179,8 @@ export function apply(ctx, config) {
|
|
|
177
179
|
const last = events.length === 0 ? undefined : pending[events.length - 1];
|
|
178
180
|
if (last === undefined) {
|
|
179
181
|
const first = pending[0];
|
|
180
|
-
if (first !== undefined) {
|
|
182
|
+
if (first !== undefined && blockedWarnings.get(session) !== first.seq) {
|
|
183
|
+
blockedWarnings.set(session, first.seq);
|
|
181
184
|
const seq = String(first.seq);
|
|
182
185
|
ctx.logger.warn(Number.isFinite(candidateBytes)
|
|
183
186
|
? `session-log-deepseek: event ${seq} of session "${session.id}" needs a ${String(candidateBytes)}-byte`
|
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.2.
|
|
4
|
+
"version": "0.2.1-alpha.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -18,10 +18,6 @@
|
|
|
18
18
|
"types": "./lib/types/index.d.ts",
|
|
19
19
|
"default": "./lib/index.js"
|
|
20
20
|
},
|
|
21
|
-
"./invariant": {
|
|
22
|
-
"types": "./lib/types/invariant.d.ts",
|
|
23
|
-
"default": "./lib/invariant.js"
|
|
24
|
-
},
|
|
25
21
|
"./types": {
|
|
26
22
|
"types": "./lib/types/types.d.ts",
|
|
27
23
|
"default": "./lib/types/types.js"
|
|
@@ -31,35 +27,32 @@
|
|
|
31
27
|
},
|
|
32
28
|
"files": [
|
|
33
29
|
"lib/index.js",
|
|
34
|
-
"lib/invariant.js",
|
|
35
30
|
"lib/types/**/*.js",
|
|
36
31
|
"lib/types/**/*.d.ts"
|
|
37
32
|
],
|
|
38
33
|
"license": "MIT",
|
|
39
34
|
"dependencies": {
|
|
40
|
-
"@deepseek-ai/dsh-brand": "0.2.
|
|
41
|
-
"@deepseek-ai/dsh-util-values": "0.2.
|
|
42
|
-
"@deepseek-ai/schemastery": "~3.18.
|
|
35
|
+
"@deepseek-ai/dsh-brand": "0.2.1-alpha.2",
|
|
36
|
+
"@deepseek-ai/dsh-util-values": "0.2.1-alpha.2",
|
|
37
|
+
"@deepseek-ai/schemastery": "~3.18.5-alpha.1"
|
|
43
38
|
},
|
|
44
39
|
"peerDependencies": {
|
|
45
|
-
"@deepseek-ai/cordis": "~4.0.
|
|
46
|
-
"@deepseek-ai/dsh-
|
|
47
|
-
"@deepseek-ai/dsh-
|
|
48
|
-
"@deepseek-ai/dsh-invariants": "0.2.0-rc.2"
|
|
40
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1",
|
|
41
|
+
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.2.1-alpha.2",
|
|
42
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.2"
|
|
49
43
|
},
|
|
50
44
|
"devDependencies": {
|
|
51
|
-
"@deepseek-ai/cordis": "~4.0.
|
|
52
|
-
"@deepseek-ai/cordis-plugin-include": "~1.0.
|
|
53
|
-
"@deepseek-ai/cordis-plugin-loader": "~1.0.
|
|
54
|
-
"@deepseek-ai/dsh-command-feedback": "0.2.
|
|
55
|
-
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.2.
|
|
56
|
-
"@deepseek-ai/dsh-
|
|
57
|
-
"@deepseek-ai/dsh-llm": "0.2.
|
|
58
|
-
"@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.
|
|
59
|
-
"@deepseek-ai/dsh-llm-mock-server": "0.2.
|
|
60
|
-
"@deepseek-ai/dsh-message-feedback": "0.2.
|
|
61
|
-
"@deepseek-ai/dsh-
|
|
62
|
-
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.
|
|
63
|
-
"@deepseek-ai/dsh-session": "0.2.0-rc.2"
|
|
45
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1",
|
|
46
|
+
"@deepseek-ai/cordis-plugin-include": "~1.0.10-alpha.1",
|
|
47
|
+
"@deepseek-ai/cordis-plugin-loader": "~1.0.6-alpha.1",
|
|
48
|
+
"@deepseek-ai/dsh-command-feedback": "0.2.1-alpha.2",
|
|
49
|
+
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.2.1-alpha.2",
|
|
50
|
+
"@deepseek-ai/dsh-llm": "0.2.1-alpha.2",
|
|
51
|
+
"@deepseek-ai/dsh-llm-deepseek": "0.2.1-alpha.2",
|
|
52
|
+
"@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.1-alpha.2",
|
|
53
|
+
"@deepseek-ai/dsh-llm-mock-server": "0.2.1-alpha.2",
|
|
54
|
+
"@deepseek-ai/dsh-message-feedback": "0.2.1-alpha.2",
|
|
55
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.2",
|
|
56
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.1-alpha.2"
|
|
64
57
|
}
|
|
65
58
|
}
|
package/lib/invariant.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { SessionSeq } from "@deepseek-ai/dsh-session";
|
|
2
|
-
//#region lib/types/invariant.js
|
|
3
|
-
/** Package-owned invariants for DeepSeek session-log acceptance watermarks. */
|
|
4
|
-
const PACKAGE_NAME = "@deepseek-ai/dsh-session-log-deepseek";
|
|
5
|
-
/** Cordis companion plugin name. */
|
|
6
|
-
const name = "session-log-deepseek-invariant";
|
|
7
|
-
/** Service required before the companion can reserve package ownership. */
|
|
8
|
-
const inject = ["invariants"];
|
|
9
|
-
/** Validate one acceptance watermark against its containing event and session. */
|
|
10
|
-
function validateDeliveryAccepted(session, event, fail) {
|
|
11
|
-
const { sessionId, throughSeq } = event.data;
|
|
12
|
-
const acceptedFormatVersion = event.data.sessionFormatVersion ?? 0;
|
|
13
|
-
if (!Number.isSafeInteger(acceptedFormatVersion) || acceptedFormatVersion < 0 || Object.is(acceptedFormatVersion, -0)) fail(`session-log-deepseek/delivery-accepted sessionFormatVersion must be a non-negative safe integer, got ${String(acceptedFormatVersion)}`);
|
|
14
|
-
if (acceptedFormatVersion !== session.header.version) return;
|
|
15
|
-
const inherited = session.header.parentSession !== void 0 && !session.isOwnSeq(event.seq);
|
|
16
|
-
if (sessionId !== session.id && !inherited) fail("a non-inherited session-log-deepseek/delivery-accepted event must name its containing session");
|
|
17
|
-
let acceptedSeq;
|
|
18
|
-
try {
|
|
19
|
-
acceptedSeq = SessionSeq(throughSeq);
|
|
20
|
-
} catch {
|
|
21
|
-
fail(`session-log-deepseek/delivery-accepted throughSeq must identify an earlier event, got ${throughSeq} at seq ${event.seq}`);
|
|
22
|
-
}
|
|
23
|
-
if (acceptedSeq >= event.seq) fail(`session-log-deepseek/delivery-accepted throughSeq must identify an earlier event, got ${throughSeq} at seq ${event.seq}`);
|
|
24
|
-
}
|
|
25
|
-
/** Validate acceptance watermarks already present in one Session. */
|
|
26
|
-
function validateSession(session, fail) {
|
|
27
|
-
for (const event of session.snapshotEvents()) if (event.type === "session-log-deepseek/delivery-accepted") validateDeliveryAccepted(session, event, fail);
|
|
28
|
-
}
|
|
29
|
-
/** Validate one live session-event dispatch. */
|
|
30
|
-
function validateDispatched(args, fail) {
|
|
31
|
-
const [session, event] = args;
|
|
32
|
-
if (event.type === "session-log-deepseek/delivery-accepted") validateDeliveryAccepted(session, event, fail);
|
|
33
|
-
}
|
|
34
|
-
/** Install validation for restored, newly created, and newly appended watermarks. */
|
|
35
|
-
const install = Object.assign((ctx, fail) => {
|
|
36
|
-
const validateExisting = (session) => {
|
|
37
|
-
validateSession(session, fail);
|
|
38
|
-
};
|
|
39
|
-
ctx.sessions.list().forEach(validateExisting);
|
|
40
|
-
ctx.on("session/created", validateExisting, { global: true });
|
|
41
|
-
ctx.on("internal/dispatch", (_mode, eventName, args) => {
|
|
42
|
-
if (eventName === "session/event") validateDispatched(args, fail);
|
|
43
|
-
}, { global: true });
|
|
44
|
-
}, { inject: ["sessions"] });
|
|
45
|
-
/**
|
|
46
|
-
* Register this package's invariant companion.
|
|
47
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
48
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
49
|
-
*/
|
|
50
|
-
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
51
|
-
//#endregion
|
|
52
|
-
export { apply, inject, name };
|
package/lib/types/invariant.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** Package-owned invariants for DeepSeek session-log acceptance watermarks. */
|
|
2
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
-
/** Cordis companion plugin name. */
|
|
4
|
-
export declare const name = "session-log-deepseek-invariant";
|
|
5
|
-
/** Service required before the companion can reserve package ownership. */
|
|
6
|
-
export declare const inject: string[];
|
|
7
|
-
/**
|
|
8
|
-
* Register this package's invariant companion.
|
|
9
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
10
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
11
|
-
*/
|
|
12
|
-
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
13
|
-
//# sourceMappingURL=invariant.d.ts.map
|
package/lib/types/invariant.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/** Package-owned invariants for DeepSeek session-log acceptance watermarks. */
|
|
2
|
-
import { SessionSeq } from '@deepseek-ai/dsh-session';
|
|
3
|
-
const PACKAGE_NAME = '@deepseek-ai/dsh-session-log-deepseek';
|
|
4
|
-
/** Cordis companion plugin name. */
|
|
5
|
-
export const name = 'session-log-deepseek-invariant';
|
|
6
|
-
/** Service required before the companion can reserve package ownership. */
|
|
7
|
-
export const inject = ['invariants'];
|
|
8
|
-
/** Validate one acceptance watermark against its containing event and session. */
|
|
9
|
-
function validateDeliveryAccepted(session, event, fail) {
|
|
10
|
-
const { sessionId, throughSeq } = event.data;
|
|
11
|
-
const acceptedFormatVersion = event.data.sessionFormatVersion ?? 0;
|
|
12
|
-
if (!Number.isSafeInteger(acceptedFormatVersion)
|
|
13
|
-
|| acceptedFormatVersion < 0
|
|
14
|
-
|| Object.is(acceptedFormatVersion, -0)) {
|
|
15
|
-
fail('session-log-deepseek/delivery-accepted sessionFormatVersion must be a non-negative safe integer'
|
|
16
|
-
+ `, got ${String(acceptedFormatVersion)}`);
|
|
17
|
-
}
|
|
18
|
-
if (acceptedFormatVersion !== session.header.version)
|
|
19
|
-
return;
|
|
20
|
-
const inherited = session.header.parentSession !== undefined
|
|
21
|
-
&& !session.isOwnSeq(event.seq);
|
|
22
|
-
if (sessionId !== session.id && !inherited) {
|
|
23
|
-
fail('a non-inherited session-log-deepseek/delivery-accepted event must name its containing session');
|
|
24
|
-
}
|
|
25
|
-
let acceptedSeq;
|
|
26
|
-
try {
|
|
27
|
-
acceptedSeq = SessionSeq(throughSeq);
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
fail(`session-log-deepseek/delivery-accepted throughSeq must identify an earlier event, got ${throughSeq} at seq ${event.seq}`);
|
|
31
|
-
}
|
|
32
|
-
if (acceptedSeq >= event.seq) {
|
|
33
|
-
fail(`session-log-deepseek/delivery-accepted throughSeq must identify an earlier event, got ${throughSeq} at seq ${event.seq}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/** Validate acceptance watermarks already present in one Session. */
|
|
37
|
-
function validateSession(session, fail) {
|
|
38
|
-
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
|
|
39
|
-
for (const event of session.snapshotEvents()) {
|
|
40
|
-
if (event.type === 'session-log-deepseek/delivery-accepted')
|
|
41
|
-
validateDeliveryAccepted(session, event, fail);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/** Validate one live session-event dispatch. */
|
|
45
|
-
function validateDispatched(args, fail) {
|
|
46
|
-
const [session, event] = args;
|
|
47
|
-
if (event.type === 'session-log-deepseek/delivery-accepted')
|
|
48
|
-
validateDeliveryAccepted(session, event, fail);
|
|
49
|
-
}
|
|
50
|
-
/** Install validation for restored, newly created, and newly appended watermarks. */
|
|
51
|
-
const install = Object.assign((ctx, fail) => {
|
|
52
|
-
const validateExisting = (session) => { validateSession(session, fail); };
|
|
53
|
-
ctx.sessions.list().forEach(validateExisting);
|
|
54
|
-
ctx.on('session/created', validateExisting, { global: true });
|
|
55
|
-
ctx.on('internal/dispatch', (_mode, eventName, args) => {
|
|
56
|
-
if (eventName === 'session/event')
|
|
57
|
-
validateDispatched(args, fail);
|
|
58
|
-
}, { global: true });
|
|
59
|
-
}, { inject: ['sessions'] });
|
|
60
|
-
/**
|
|
61
|
-
* Register this package's invariant companion.
|
|
62
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
63
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
64
|
-
*/
|
|
65
|
-
export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
66
|
-
//# sourceMappingURL=invariant.js.map
|