@mingozhou/dsh-replay 0.3.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/LICENSE +21 -0
- package/README.md +164 -0
- package/README.zh.md +164 -0
- package/cordis.patch.yml +6 -0
- package/lib/client.js +2478 -0
- package/lib/core.js +720 -0
- package/lib/index.js +111 -0
- package/lib/types/demo/main.d.ts +1 -0
- package/lib/types/demo/samples.d.ts +21 -0
- package/lib/types/src/client/api.d.ts +43 -0
- package/lib/types/src/client/components/AuditView.d.ts +8 -0
- package/lib/types/src/client/components/CompareView.d.ts +9 -0
- package/lib/types/src/client/components/ForkTreeView.d.ts +7 -0
- package/lib/types/src/client/components/ItemDetail.d.ts +6 -0
- package/lib/types/src/client/components/OverviewView.d.ts +8 -0
- package/lib/types/src/client/components/ReplayApp.d.ts +12 -0
- package/lib/types/src/client/components/ReplayModal.d.ts +8 -0
- package/lib/types/src/client/components/SessionPicker.d.ts +6 -0
- package/lib/types/src/client/components/TimelineView.d.ts +6 -0
- package/lib/types/src/client/export.d.ts +13 -0
- package/lib/types/src/client/i18n.d.ts +24 -0
- package/lib/types/src/client/index.d.ts +12 -0
- package/lib/types/src/client/mascot-image.d.ts +1 -0
- package/lib/types/src/client/mascot.d.ts +17 -0
- package/lib/types/src/client/viewer-entry.d.ts +1 -0
- package/lib/types/src/core/audit.d.ts +39 -0
- package/lib/types/src/core/compare.d.ts +31 -0
- package/lib/types/src/core/cost.d.ts +30 -0
- package/lib/types/src/core/decode.d.ts +25 -0
- package/lib/types/src/core/forktree.d.ts +33 -0
- package/lib/types/src/core/index.d.ts +7 -0
- package/lib/types/src/core/timeline.d.ts +96 -0
- package/lib/types/src/core/types.d.ts +88 -0
- package/lib/types/src/index.d.ts +20 -0
- package/lib/viewer.js +812 -0
- package/package.json +107 -0
- package/scripts/build.mjs +131 -0
- package/src/client/api.ts +119 -0
- package/src/client/components/AuditView.tsx +57 -0
- package/src/client/components/CompareView.tsx +186 -0
- package/src/client/components/ForkTreeView.tsx +123 -0
- package/src/client/components/ItemDetail.tsx +117 -0
- package/src/client/components/OverviewView.tsx +258 -0
- package/src/client/components/ReplayApp.tsx +205 -0
- package/src/client/components/ReplayModal.tsx +53 -0
- package/src/client/components/SessionPicker.tsx +60 -0
- package/src/client/components/TimelineView.tsx +296 -0
- package/src/client/export.ts +43 -0
- package/src/client/i18n.ts +360 -0
- package/src/client/index.ts +146 -0
- package/src/client/mascot-image.ts +1 -0
- package/src/client/mascot.tsx +192 -0
- package/src/client/styles.css +719 -0
- package/src/client/viewer-entry.tsx +66 -0
- package/src/core/audit.ts +227 -0
- package/src/core/compare.ts +0 -0
- package/src/core/cost.ts +61 -0
- package/src/core/decode.ts +125 -0
- package/src/core/forktree.ts +104 -0
- package/src/core/index.ts +7 -0
- package/src/core/timeline.ts +396 -0
- package/src/core/types.ts +90 -0
- package/src/index.ts +157 -0
- package/tsconfig.json +18 -0
- package/types.d.ts +15 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural types for the DeepSeek Harness session log (format version 0).
|
|
3
|
+
*
|
|
4
|
+
* These are intentionally *structural* copies of the shapes in
|
|
5
|
+
* `@deepseek-ai/dsh-session` — the core analysis layer has zero runtime
|
|
6
|
+
* dependencies on harness packages so it can run in the browser, in tests,
|
|
7
|
+
* and inside the host plugin alike. Field names track the upstream
|
|
8
|
+
* vocabulary exactly; unknown event types are preserved untyped.
|
|
9
|
+
*/
|
|
10
|
+
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
11
|
+
[key: string]: JsonValue;
|
|
12
|
+
};
|
|
13
|
+
/** Session header — line 1 of a JSONL log / `sessions` row in SQLite. */
|
|
14
|
+
export interface SessionHeader {
|
|
15
|
+
version?: number;
|
|
16
|
+
id: string;
|
|
17
|
+
createdAt: number;
|
|
18
|
+
cwd?: string;
|
|
19
|
+
parentSession?: string;
|
|
20
|
+
seedLength?: number;
|
|
21
|
+
origin?: 'subagent';
|
|
22
|
+
delegationDepth?: number;
|
|
23
|
+
agentPreset?: string;
|
|
24
|
+
}
|
|
25
|
+
/** The event envelope. `seq` is contiguous and monotonic from 0. */
|
|
26
|
+
export interface SessionEvent {
|
|
27
|
+
type: string;
|
|
28
|
+
seq: number;
|
|
29
|
+
time: number;
|
|
30
|
+
data: JsonValue;
|
|
31
|
+
ignorable?: true;
|
|
32
|
+
sourceEventSeqs?: number[];
|
|
33
|
+
surfaceOp?: 'append' | {
|
|
34
|
+
op: 'replace';
|
|
35
|
+
start: number;
|
|
36
|
+
end: number;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Disjoint token counts. Billed input = input + cacheRead + cacheWrite. */
|
|
40
|
+
export interface TokenUsage {
|
|
41
|
+
inputTokens: number;
|
|
42
|
+
outputTokens: number;
|
|
43
|
+
cacheReadTokens?: number;
|
|
44
|
+
cacheWriteTokens?: number;
|
|
45
|
+
reasoningTokens?: number;
|
|
46
|
+
}
|
|
47
|
+
/** Packed chunk rows — the one wire shape that is not a SessionEvent. */
|
|
48
|
+
export interface ChunkRowBase {
|
|
49
|
+
type: 'text-chunks' | 'reasoning-chunks' | 'tool-call-chunks';
|
|
50
|
+
seq0: number;
|
|
51
|
+
time0: number;
|
|
52
|
+
data: {
|
|
53
|
+
turn: number;
|
|
54
|
+
step: number;
|
|
55
|
+
index: number;
|
|
56
|
+
dt: number[];
|
|
57
|
+
texts?: string[];
|
|
58
|
+
id?: string;
|
|
59
|
+
name?: string;
|
|
60
|
+
args?: string[];
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export type StorageRecord = SessionEvent | ChunkRowBase;
|
|
64
|
+
export interface ContentBlock {
|
|
65
|
+
type: string;
|
|
66
|
+
text?: string;
|
|
67
|
+
[key: string]: JsonValue | undefined;
|
|
68
|
+
}
|
|
69
|
+
export interface MessageLike {
|
|
70
|
+
id?: string;
|
|
71
|
+
role?: string;
|
|
72
|
+
content?: ContentBlock[];
|
|
73
|
+
source?: {
|
|
74
|
+
kind?: string;
|
|
75
|
+
[key: string]: JsonValue | undefined;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** A parsed session: header + fully decoded, seq-ordered events. */
|
|
79
|
+
export interface ParsedSession {
|
|
80
|
+
header: SessionHeader;
|
|
81
|
+
events: SessionEvent[];
|
|
82
|
+
/** Lines (or rows) that failed to decode — kept for diagnostics, never dropped silently. */
|
|
83
|
+
malformed: {
|
|
84
|
+
line: number;
|
|
85
|
+
raw: string;
|
|
86
|
+
error: string;
|
|
87
|
+
}[];
|
|
88
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-replay — host half.
|
|
3
|
+
*
|
|
4
|
+
* Registers a small read-only HTTP API on the harness web server that the
|
|
5
|
+
* browser half (and nothing else) consumes:
|
|
6
|
+
*
|
|
7
|
+
* GET /replay/api/sessions → { sessions: [{ header, title }] }
|
|
8
|
+
* GET /replay/api/session/<id> → { header, events }
|
|
9
|
+
*
|
|
10
|
+
* Reads go through `ctx.sessionQuery` (live-preferred corpus), so an open
|
|
11
|
+
* session replays with its in-memory state, not a stale disk artifact.
|
|
12
|
+
*/
|
|
13
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
14
|
+
export declare const name = "dsh-replay";
|
|
15
|
+
export declare const inject: string[];
|
|
16
|
+
export interface Config {
|
|
17
|
+
/** URL prefix for the replay API (exact-prefix route). */
|
|
18
|
+
routePrefix?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function apply(ctx: Context, config?: Config): void;
|