返回 DeepSeek-Reasonix
transcriptProtocol.ts
根目录 / desktop / frontend / src / lib / transcriptProtocol.ts
1 import type { HistoryMessage, TurnEventReplayView, TurnStatus, WireEvent, WireCompletionSummary } from "./types";
2 import type { TranscriptIdentity, TranscriptSnapshotBoundary } from "./turnEventProjection";
3 import type { HistorySwitchPhases } from "./sessionDiagnostics";
4
5 export interface TranscriptContentRef {
6 snapshotId: string;
7 recordId: string;
8 path: string[];
9 bytes: number;
10 }
11
12 export interface TranscriptRecord {
13 id: string;
14 order: number;
15 message: HistoryMessage;
16 refs: TranscriptContentRef[];
17 }
18
19 export interface TranscriptSnapshot extends TranscriptSnapshotBoundary {
20 records: TranscriptRecord[];
21 activeRecords: TranscriptRecord[];
22 runtime: { turnId?: string; submissionId?: string; status?: TurnStatus; phase?: string; startedAt?: number; completionSummary?: WireCompletionSummary; pendingEvents: WireEvent[] };
23 activeAttempts: Array<{ id: string; messageId: string }>;
24 before: number;
25 hasOlder: boolean;
26 totalRecords: number;
27 totalTurns: number;
28 stale: boolean;
29 }
30
31 export interface TranscriptPageRequest {
32 snapshotId?: string;
33 before?: number;
34 records?: number;
35 bytes?: number;
36 }
37
38 /**
39 * One user turn of the complete conversation. `id` is the stable record
40 * identity shared with the body records; `order` is only this snapshot's
41 * pagination position and must never be used as cross-snapshot identity or as
42 * a React key.
43 */
44 export interface TranscriptOutlineEntry {
45 id: string;
46 messageId?: string;
47 turn: number;
48 order: number;
49 prompt: string;
50 answer?: string;
51 }
52
53 export interface TranscriptOutlinePage {
54 protocolVersion: number;
55 snapshotId: string;
56 entries: TranscriptOutlineEntry[];
57 nextOffset: number;
58 done: boolean;
59 total: number;
60 stale: boolean;
61 }
62
63 export interface TranscriptOutlineRequest { snapshotId: string; offset?: number; entries?: number; bytes?: number }
64
65 export interface TranscriptContentChunk { data: string; nextOffset: number; done: boolean; stale: boolean }
66 export interface TranscriptReplayRequest { identity: TranscriptIdentity; after: number }
67 export interface TranscriptReplay extends TranscriptSnapshotBoundary, TurnEventReplayView {}
68
69 export interface TranscriptProtocolBindings {
70 TranscriptFollowForTab(tabId: string, request: import("../generated/desktopContract.generated").FollowRequest): Promise<import("../generated/desktopContract.generated").TranscriptFollowResponse>;
71 RemoteTranscriptFollowForTab(tabId: string, request: import("../generated/desktopContract.generated").FollowRequest): Promise<import("../generated/desktopContract.generated").TranscriptFollowResponse>;
72 TranscriptSnapshotForTab?(tabId: string, request: TranscriptPageRequest): Promise<TranscriptSnapshot>;
73 TranscriptPageForTab?(tabId: string, request: TranscriptPageRequest): Promise<TranscriptSnapshot>;
74 TranscriptContentForTab?(tabId: string, request: TranscriptContentRef & { offset: number }): Promise<TranscriptContentChunk>;
75 /** Optional beside the body protocol: an absent method means no outline. */
76 TranscriptOutlineForTab?(tabId: string, request: TranscriptOutlineRequest): Promise<TranscriptOutlinePage>;
77 TranscriptReplayForTab?(tabId: string, request: TranscriptReplayRequest): Promise<TranscriptReplay>;
78 RemoteTranscriptSnapshotForTab?(tabId: string, request: TranscriptPageRequest): Promise<{ supported: boolean; snapshot?: TranscriptSnapshot }>;
79 RemoteTranscriptPageForTab?(tabId: string, request: TranscriptPageRequest): Promise<TranscriptSnapshot>;
80 RemoteTranscriptContentForTab?(tabId: string, request: TranscriptContentRef & { offset: number }): Promise<TranscriptContentChunk>;
81 RemoteTranscriptOutlineForTab?(tabId: string, request: TranscriptOutlineRequest): Promise<TranscriptOutlinePage>;
82 RemoteTranscriptReplayForTab?(tabId: string, request: TranscriptReplayRequest): Promise<TranscriptReplay>;
83 ResumeTranscriptSessionForTab?(tabID: string, path: string): Promise<HistorySwitchPhases | void>;
84 OpenChannelTranscriptSessionForTab?(tabID: string, path: string): Promise<HistorySwitchPhases | void>;
85 }
86
87 export interface TranscriptTurnMetadata {
88 samplingCount?: number;
89 toolCount?: number;
90 turnFinal?: boolean;
91 }
92
92 lines TYPESCRIPT