@deepseek-ai/dsh-llm-replay 0.1.2-alpha.2 → 0.1.2-alpha.4
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 +7 -7
- package/lib/types/index.d.ts +4 -3
- package/package.json +10 -17
- package/lib/invariant.js +0 -23
- package/lib/types/invariant.d.ts +0 -16
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/test-support/llm-replay/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: c0643bf6823e96cf3663f8299d0f5645d7974011
|
|
6
|
+
README.zh.md: 1c2fe3393691b4988678497aa5948957f678c80b
|
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ Replay is built on one idea: the projected session log is the fixture. `deriveRe
|
|
|
102
102
|
| File | Role |
|
|
103
103
|
|---|---|
|
|
104
104
|
| [`src/index.ts`](src/index.ts) | Types, fixture derivation, override validation, placeholder resolution, session binding, `installLlmReplay`, and the plugin export |
|
|
105
|
-
|
|
|
105
|
+
| — | No runtime invariant companion is published; this test-only adapter consumes a fixed replay script; its stream grammar is checked by the LLM companion and fixture derivation tests. |
|
|
106
106
|
|
|
107
107
|
### Binding and stream flow
|
|
108
108
|
|
package/README.zh.md
CHANGED
|
@@ -102,7 +102,7 @@ fixture 是运行一次真实 agent 所产生的持久化会话日志(`<scenar
|
|
|
102
102
|
| 文件 | 职责 |
|
|
103
103
|
|---|---|
|
|
104
104
|
| [`src/index.ts`](src/index.ts) | 类型、fixture 派生、override 校验、占位符解析、会话绑定、`installLlmReplay` 与插件导出 |
|
|
105
|
-
|
|
|
105
|
+
| — | 不发布运行时不变式伴生入口;流语法由 LLM 伴生插件与派生测试检验。 |
|
|
106
106
|
|
|
107
107
|
### 绑定与流式流程
|
|
108
108
|
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { delimiter } from "node:path";
|
|
3
|
-
import { decodeSeqRanges, decodeStorageRecord } from "@deepseek-ai/dsh-session";
|
|
3
|
+
import { SessionLogOffset, decodeSeqRanges, decodeStorageRecord } from "@deepseek-ai/dsh-session";
|
|
4
4
|
import { LlmAdapter, LlmError, ReasoningEffortId, requestImageHandleText, resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
|
|
5
5
|
import { assertNever } from "@deepseek-ai/dsh-util-values";
|
|
6
6
|
//#region lib/types/index.js
|
|
@@ -29,7 +29,7 @@ const PACKED_CHUNK_ROW_TYPES = new Set([
|
|
|
29
29
|
*/
|
|
30
30
|
function parseSessionLog(text) {
|
|
31
31
|
const events = [];
|
|
32
|
-
let nextSeq = 0;
|
|
32
|
+
let nextSeq = SessionLogOffset(0);
|
|
33
33
|
let headerSkipped = false;
|
|
34
34
|
for (const [index, line] of text.split(/\r?\n/).entries()) {
|
|
35
35
|
if (line.trim().length === 0) continue;
|
|
@@ -60,7 +60,7 @@ function parseSessionLog(text) {
|
|
|
60
60
|
throw new Error(`session snapshot line ${index + 1}: ${detail}`, { cause: error });
|
|
61
61
|
}
|
|
62
62
|
events.push(...decoded);
|
|
63
|
-
nextSeq
|
|
63
|
+
nextSeq = SessionLogOffset(nextSeq + decoded.length);
|
|
64
64
|
}
|
|
65
65
|
return events;
|
|
66
66
|
}
|
|
@@ -68,7 +68,7 @@ function parseSessionLog(text) {
|
|
|
68
68
|
* Read replay identity, ordering, and fork-seed facts from the JSONL header.
|
|
69
69
|
*
|
|
70
70
|
* @param text - the raw `.jsonl` file contents (only the header line is read).
|
|
71
|
-
* @returns the header's `id`, `createdAt`, and
|
|
71
|
+
* @returns the header's `id`, `createdAt`, and inherited-event count, defaulted when absent.
|
|
72
72
|
*/
|
|
73
73
|
function parseSessionHeader(text) {
|
|
74
74
|
const firstLine = text.split("\n").find((line) => line.trim().length > 0) ?? "{}";
|
|
@@ -76,7 +76,7 @@ function parseSessionHeader(text) {
|
|
|
76
76
|
return {
|
|
77
77
|
id: typeof parsed.id === "string" ? parsed.id : "",
|
|
78
78
|
createdAt: typeof parsed.createdAt === "number" ? parsed.createdAt : 0,
|
|
79
|
-
|
|
79
|
+
inheritedEventCount: SessionLogOffset(typeof parsed.seedLength === "number" ? parsed.seedLength : 0)
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
@@ -369,7 +369,7 @@ function deriveScriptFromFile(file) {
|
|
|
369
369
|
}
|
|
370
370
|
/**
|
|
371
371
|
* Load the primary and child scripts in bind order. Child derivation begins at
|
|
372
|
-
*
|
|
372
|
+
* the v0 header's inherited-event cut so parent chunks are never replayed as child calls.
|
|
373
373
|
*
|
|
374
374
|
* @param config - the fixture paths: the primary log plus any recorded child logs.
|
|
375
375
|
* @returns the primary script first, then the child scripts in bind order.
|
|
@@ -391,7 +391,7 @@ function loadSessionScripts(config) {
|
|
|
391
391
|
if (!existsSync(childFile)) throw new Error(`llm-replay: child fixture not found: ${childFile} — re-record the scenario`);
|
|
392
392
|
const text = readFileSync(childFile, "utf8");
|
|
393
393
|
const header = parseSessionHeader(text);
|
|
394
|
-
const ownEvents = parseSessionLog(text).slice(header.
|
|
394
|
+
const ownEvents = parseSessionLog(text).slice(header.inheritedEventCount);
|
|
395
395
|
children.push({
|
|
396
396
|
recordedId: header.id,
|
|
397
397
|
createdAt: header.createdAt,
|
package/lib/types/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { Context } from '@deepseek-ai/cordis';
|
|
10
10
|
import { type SessionEvent } from '@deepseek-ai/dsh-session';
|
|
11
|
+
import type { SessionLogOffset as SessionLogOffsetType } from '@deepseek-ai/dsh-session';
|
|
11
12
|
import type { GenerateOptions, ModelModality, RetryPolicyConfig, StreamChunk } from '@deepseek-ai/dsh-llm';
|
|
12
13
|
/**
|
|
13
14
|
* One recorded model call. `throw` may replay prefix chunks before failing;
|
|
@@ -161,12 +162,12 @@ export declare function parseSessionLog(text: string): SessionEvent[];
|
|
|
161
162
|
* Read replay identity, ordering, and fork-seed facts from the JSONL header.
|
|
162
163
|
*
|
|
163
164
|
* @param text - the raw `.jsonl` file contents (only the header line is read).
|
|
164
|
-
* @returns the header's `id`, `createdAt`, and
|
|
165
|
+
* @returns the header's `id`, `createdAt`, and inherited-event count, defaulted when absent.
|
|
165
166
|
*/
|
|
166
167
|
export declare function parseSessionHeader(text: string): {
|
|
167
168
|
id: string;
|
|
168
169
|
createdAt: number;
|
|
169
|
-
|
|
170
|
+
inheritedEventCount: SessionLogOffsetType;
|
|
170
171
|
};
|
|
171
172
|
/**
|
|
172
173
|
* Reconstruct the per-`stream()` replay script from a recorded session log.
|
|
@@ -231,7 +232,7 @@ export declare function resolveScriptedEntry(entry: ReplayEntry, messages: Gener
|
|
|
231
232
|
export declare function loadReplayScript(config: ReplayConfig): ReplayEntry[];
|
|
232
233
|
/**
|
|
233
234
|
* Load the primary and child scripts in bind order. Child derivation begins at
|
|
234
|
-
*
|
|
235
|
+
* the v0 header's inherited-event cut so parent chunks are never replayed as child calls.
|
|
235
236
|
*
|
|
236
237
|
* @param config - the fixture paths: the primary log plus any recorded child logs.
|
|
237
238
|
* @returns the primary script first, then the child scripts in bind order.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-llm-replay",
|
|
3
3
|
"description": "Replay LLM plugin: short-circuits llm/stream with model chunks reconstructed from a recorded session JSONL (keyless snapshot tests)",
|
|
4
|
-
"version": "0.1.2-alpha.
|
|
4
|
+
"version": "0.1.2-alpha.4",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -18,26 +18,20 @@
|
|
|
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
|
"./src/*": "./src/*",
|
|
26
22
|
"./package.json": "./package.json"
|
|
27
23
|
},
|
|
28
24
|
"files": [
|
|
29
25
|
"lib/index.js",
|
|
30
|
-
"lib/invariant.js",
|
|
31
26
|
"lib/types/**/*.d.ts"
|
|
32
27
|
],
|
|
33
28
|
"license": "MIT",
|
|
34
29
|
"peerDependencies": {
|
|
35
|
-
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "^0.1.2-alpha.2",
|
|
36
30
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
37
|
-
"@deepseek-ai/dsh-
|
|
38
|
-
"@deepseek-ai/dsh-
|
|
39
|
-
"@deepseek-ai/dsh-
|
|
40
|
-
"@deepseek-ai/dsh-
|
|
31
|
+
"@deepseek-ai/dsh-compaction": "^0.1.2-alpha.4",
|
|
32
|
+
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.4",
|
|
33
|
+
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "^0.1.2-alpha.4",
|
|
34
|
+
"@deepseek-ai/dsh-session": "^0.1.2-alpha.4"
|
|
41
35
|
},
|
|
42
36
|
"peerDependenciesMeta": {
|
|
43
37
|
"@deepseek-ai/dsh-deepseek-llm-api-extensions": {
|
|
@@ -46,13 +40,12 @@
|
|
|
46
40
|
},
|
|
47
41
|
"devDependencies": {
|
|
48
42
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
49
|
-
"@deepseek-ai/dsh-compaction": "^0.1.2-alpha.
|
|
50
|
-
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "^0.1.2-alpha.
|
|
51
|
-
"@deepseek-ai/dsh-
|
|
52
|
-
"@deepseek-ai/dsh-
|
|
53
|
-
"@deepseek-ai/dsh-session": "^0.1.2-alpha.2"
|
|
43
|
+
"@deepseek-ai/dsh-compaction": "^0.1.2-alpha.4",
|
|
44
|
+
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "^0.1.2-alpha.4",
|
|
45
|
+
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.4",
|
|
46
|
+
"@deepseek-ai/dsh-session": "^0.1.2-alpha.4"
|
|
54
47
|
},
|
|
55
48
|
"dependencies": {
|
|
56
|
-
"@deepseek-ai/dsh-util-values": "^0.1.2-alpha.
|
|
49
|
+
"@deepseek-ai/dsh-util-values": "^0.1.2-alpha.4"
|
|
57
50
|
}
|
|
58
51
|
}
|
package/lib/invariant.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region lib/types/invariant.js
|
|
2
|
-
/**
|
|
3
|
-
* Package-owned invariant companion for `@deepseek-ai/dsh-llm-replay`.
|
|
4
|
-
* @module @deepseek-ai/dsh-llm-replay/invariant
|
|
5
|
-
*/
|
|
6
|
-
const PACKAGE_NAME = "@deepseek-ai/dsh-llm-replay";
|
|
7
|
-
/** Cordis companion plugin name. */
|
|
8
|
-
const name = "llm-replay-invariant";
|
|
9
|
-
/** Service required before the companion can reserve package ownership. */
|
|
10
|
-
const inject = ["invariants"];
|
|
11
|
-
/**
|
|
12
|
-
* No runtime invariant: this test-only adapter consumes a fixed replay script; its stream grammar
|
|
13
|
-
* is checked by the LLM companion and fixture derivation tests.
|
|
14
|
-
*/
|
|
15
|
-
const install = () => {};
|
|
16
|
-
/**
|
|
17
|
-
* Register this package's invariant companion.
|
|
18
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
19
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
20
|
-
*/
|
|
21
|
-
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
22
|
-
//#endregion
|
|
23
|
-
export { apply, inject, name };
|
package/lib/types/invariant.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package-owned invariant companion for `@deepseek-ai/dsh-llm-replay`.
|
|
3
|
-
* @module @deepseek-ai/dsh-llm-replay/invariant
|
|
4
|
-
*/
|
|
5
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
-
/** Cordis companion plugin name. */
|
|
7
|
-
export declare const name = "llm-replay-invariant";
|
|
8
|
-
/** Service required before the companion can reserve package ownership. */
|
|
9
|
-
export declare const inject: string[];
|
|
10
|
-
/**
|
|
11
|
-
* Register this package's invariant companion.
|
|
12
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
13
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
14
|
-
*/
|
|
15
|
-
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
16
|
-
//# sourceMappingURL=invariant.d.ts.map
|