返回 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 OperationID string `json:"operationId,omitempty"`
51 OperationRevision uint64 `json:"operationRevision,omitempty"`
52 RuntimeEpoch string `json:"runtimeEpoch,omitempty"`
53 OperationKind string `json:"operationKind,omitempty"`
54 OperationStatus string `json:"operationStatus,omitempty"`
55 OperationActivity string `json:"operationActivity,omitempty"`
56 ErrorCode string `json:"errorCode,omitempty"`
57 Applied bool `json:"applied,omitempty"`
58 InputTokens int `json:"inputTokens,omitempty"`
59 ResultTokens int `json:"resultTokens,omitempty"`
60 DecisionReceipt *provider.DecisionReceipt `json:"decisionReceipt,omitempty"`
61 Readiness *event.FinalReadiness `json:"readiness,omitempty"`
62 ReadPause *provider.ReadPause `json:"readPause,omitempty"`
63 ReadCompletion *provider.ReadCompletion `json:"readCompletion,omitempty"`
64 ProtocolRecovery *provider.ProtocolRecoveryAction `json:"protocolRecovery,omitempty"`
65 Diagnostic *provider.FailureDiagnostic `json:"diagnostic,omitempty"`
66 ServerSearch []provider.ServerSearchCall `json:"serverSearch,omitempty"`
67 // Attachments are display-only facts for admitted session images. They never
68 // participate in provider requests; the frontend loads bytes through a
69 // digest-only session read authorized from this session's content graph.
70 Attachments []Attachment `json:"attachments,omitempty"`
71 }
72
73 // Attachment is the history-card identity of one admitted image. Digest is the
74 // SHA-256 of the original bytes; clients must not supply size or index fields.
75 type Attachment struct {
76 Kind string `json:"kind,omitempty"`
77 Digest string `json:"digest,omitempty"`
78 Name string `json:"name,omitempty"`
79 MIME string `json:"mime,omitempty"`
80 Width int `json:"width,omitempty"`
81 Height int `json:"height,omitempty"`
82 Bytes int64 `json:"bytes,omitempty"`
83 }
84
85 // TurnUsage is the exact sum of the usage events emitted during one UI turn.
86 // CacheReadTokens is present whenever at least one usage event was observed;
87 // zero is therefore a reported value rather than an unknown value.
88 type TurnUsage struct {
89 UncachedInputTokens int `json:"uncachedInputTokens"`
90 OutputTokens int `json:"outputTokens"`
91 TotalTokens int `json:"totalTokens"`
92 CacheReadTokens *int `json:"cacheReadTokens,omitempty"`
93 ReasoningTokens *int `json:"reasoningTokens,omitempty"`
94 Routes []string `json:"routes,omitempty"`
95 }
96
97 type ToolCall struct {
98 Partial bool `json:"partial,omitempty"`
99 ArgChars int `json:"argChars,omitempty"`
100 Pending bool `json:"pending,omitempty"`
101 ParentID string `json:"parentId,omitempty"`
102 StartedAt int64 `json:"startedAt,omitempty"`
103 ID string `json:"id"`
104 Name string `json:"name"`
105 Arguments string `json:"arguments"`
106 ResolvedName string `json:"resolvedName,omitempty"`
107 CapabilityID string `json:"capabilityId,omitempty"`
108 ResolvedReadOnly *bool `json:"resolvedReadOnly,omitempty"`
109 Subject string `json:"subject,omitempty"`
110 Summary string `json:"summary,omitempty"`
111 Diff string `json:"diff,omitempty"`
112 Added int `json:"added,omitempty"`
113 Removed int `json:"removed,omitempty"`
114 ArgumentsArchived bool `json:"argumentsArchived,omitempty"`
115 }
116
116 lines GO