返回 DeepSeek-Reasonix
message.go
根目录 / internal / transcript / message.go
1 // Package transcript owns the display projection shared by local and remote sessions.
2 // Its records are never used to construct provider requests.
3 package transcript
4
5 import (
6 "reasonix/internal/event"
7 "reasonix/internal/eventwire"
8 "reasonix/internal/provider"
9 )
10
11 type Message struct {
12 RecordID string `json:"recordId,omitempty"`
13 AttemptID string `json:"attemptId,omitempty"`
14 SubmissionID string `json:"submissionId,omitempty"`
15 Source string `json:"source,omitempty"`
16 MessageID string `json:"messageId,omitempty"`
17 CompletionReceipt *eventwire.CompletionReceipt `json:"completionReceipt,omitempty"`
18 CompletionSummary *eventwire.CompletionSummary `json:"completionSummary,omitempty"`
19 TurnID string `json:"turnId,omitempty"`
20 Role string `json:"role"`
21 Content string `json:"content"`
22 Detail string `json:"detail,omitempty"`
23 Code string `json:"code,omitempty"`
24 SubmitText string `json:"submitText,omitempty"`
25 CheckpointTurn *int `json:"checkpointTurn,omitempty"`
26 HistoryTurn int `json:"historyTurn,omitempty"`
27 CreatedAt int64 `json:"createdAt,omitempty"`
28 Reasoning string `json:"reasoning,omitempty"`
29 MemoryCitations []provider.MemoryCitation `json:"memoryCitations,omitempty"`
30 WorkDurationMs int64 `json:"workDurationMs,omitempty"`
31 // TurnDurationMs and TurnUsage are display-only, per-turn facts used by the
32 // chat footer. They never participate in provider messages or prompt caches.
33 TurnDurationMs int64 `json:"turnDurationMs,omitempty"`
34 TurnUsage *TurnUsage `json:"turnUsage,omitempty"`
35 Level string `json:"level,omitempty"`
36 ToolCalls []ToolCall `json:"toolCalls,omitempty"`
37 ToolCallID string `json:"toolCallId,omitempty"`
38 ToolName string `json:"toolName,omitempty"`
39 ToolResultArchived bool `json:"toolResultArchived,omitempty"`
40 ToolResultError string `json:"toolResultError,omitempty"`
41 // Execution is local shell metadata restored onto ToolCards after history
42 // reload. Omitted when absent so older frontends ignore it safely.
43 Execution *provider.ToolExecution `json:"execution,omitempty"`
44 PresentedFiles []provider.PresentedFile `json:"presentedFiles,omitempty"`
45 Pending bool `json:"pending,omitempty"`
46 Trigger string `json:"trigger,omitempty"`
47 Messages int `json:"messages,omitempty"`
48 Summary string `json:"summary,omitempty"`
49 Archive string `json:"archive,omitempty"`
50 DecisionReceipt *provider.DecisionReceipt `json:"decisionReceipt,omitempty"`
51 Readiness *event.FinalReadiness `json:"readiness,omitempty"`
52 ReadPause *provider.ReadPause `json:"readPause,omitempty"`
53 ReadCompletion *provider.ReadCompletion `json:"readCompletion,omitempty"`
54 ProtocolRecovery *provider.ProtocolRecoveryAction `json:"protocolRecovery,omitempty"`
55 Diagnostic *provider.FailureDiagnostic `json:"diagnostic,omitempty"`
56 ServerSearch []provider.ServerSearchCall `json:"serverSearch,omitempty"`
57 // Attachments are display-only facts for admitted session images. They never
58 // participate in provider requests; the frontend loads bytes through a
59 // digest-only session read authorized from this session's content graph.
60 Attachments []Attachment `json:"attachments,omitempty"`
61 }
62
63 // Attachment is the history-card identity of one admitted image. Digest is the
64 // SHA-256 of the original bytes; clients must not supply size or index fields.
65 type Attachment struct {
66 Kind string `json:"kind,omitempty"`
67 Digest string `json:"digest,omitempty"`
68 Name string `json:"name,omitempty"`
69 MIME string `json:"mime,omitempty"`
70 Width int `json:"width,omitempty"`
71 Height int `json:"height,omitempty"`
72 Bytes int64 `json:"bytes,omitempty"`
73 }
74
75 // TurnUsage is the exact sum of the usage events emitted during one UI turn.
76 // CacheReadTokens is present whenever at least one usage event was observed;
77 // zero is therefore a reported value rather than an unknown value.
78 type TurnUsage struct {
79 UncachedInputTokens int `json:"uncachedInputTokens"`
80 OutputTokens int `json:"outputTokens"`
81 TotalTokens int `json:"totalTokens"`
82 CacheReadTokens *int `json:"cacheReadTokens,omitempty"`
83 ReasoningTokens *int `json:"reasoningTokens,omitempty"`
84 Routes []string `json:"routes,omitempty"`
85 }
86
87 type ToolCall struct {
88 Partial bool `json:"partial,omitempty"`
89 ArgChars int `json:"argChars,omitempty"`
90 Pending bool `json:"pending,omitempty"`
91 ParentID string `json:"parentId,omitempty"`
92 StartedAt int64 `json:"startedAt,omitempty"`
93 ID string `json:"id"`
94 Name string `json:"name"`
95 Arguments string `json:"arguments"`
96 ResolvedName string `json:"resolvedName,omitempty"`
97 CapabilityID string `json:"capabilityId,omitempty"`
98 ResolvedReadOnly *bool `json:"resolvedReadOnly,omitempty"`
99 Subject string `json:"subject,omitempty"`
100 Summary string `json:"summary,omitempty"`
101 Diff string `json:"diff,omitempty"`
102 Added int `json:"added,omitempty"`
103 Removed int `json:"removed,omitempty"`
104 ArgumentsArchived bool `json:"argumentsArchived,omitempty"`
105 }
106
106 lines GO