@allternit/gizzi-code 1.0.0 → 1.0.1

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.
Files changed (158) hide show
  1. package/bin/gizzi +4 -0
  2. package/bin/gizzi-ink +5 -0
  3. package/package.json +137 -31
  4. package/src/Tool.ts +26 -0
  5. package/src/bootstrap/state.ts +165 -322
  6. package/src/commands.ts +209 -0
  7. package/src/context/QueuedMessageContext.tsx +63 -0
  8. package/src/context/fpsMetrics.tsx +30 -0
  9. package/src/context/mailbox.tsx +38 -0
  10. package/src/context/modalContext.tsx +58 -0
  11. package/src/context/notifications.tsx +240 -0
  12. package/src/context/overlayContext.tsx +151 -0
  13. package/src/context/promptOverlayContext.tsx +125 -0
  14. package/src/context/stats.tsx +220 -0
  15. package/src/context/voice.tsx +88 -0
  16. package/src/hooks/useCanUseTool.ts +11 -0
  17. package/src/hooks/useExitOnCtrlCD.ts +40 -187
  18. package/src/hooks/useExitOnCtrlCDWithKeybindings.ts +68 -0
  19. package/src/hooks/useKeybinding.ts +68 -209
  20. package/src/hooks/useTerminalSize.ts +31 -99
  21. package/src/hooks.ts +37 -0
  22. package/src/ink.ts +204 -0
  23. package/src/main.ts +7 -0
  24. package/src/types/command.ts +216 -0
  25. package/src/types/connectorText.ts +39 -0
  26. package/src/types/fileSuggestion.ts +15 -0
  27. package/src/types/generated/events_mono/claude_code/v1/claude_code_internal_event.ts +865 -0
  28. package/src/types/generated/events_mono/common/v1/auth.ts +100 -0
  29. package/src/types/generated/events_mono/growthbook/v1/growthbook_experiment_event.ts +223 -0
  30. package/src/types/generated/google/protobuf/timestamp.ts +187 -0
  31. package/src/types/hooks.ts +319 -0
  32. package/src/types/ids.ts +44 -0
  33. package/src/types/logs.ts +331 -0
  34. package/src/types/merged/index.ts +5 -0
  35. package/src/types/merged/message.ts +552 -0
  36. package/src/types/message.ts +927 -186
  37. package/src/types/messageQueueTypes.ts +21 -0
  38. package/src/types/notebook.ts +72 -0
  39. package/src/types/permissions.ts +447 -0
  40. package/src/types/plugin.ts +363 -0
  41. package/src/types/statusLine.ts +15 -0
  42. package/src/types/textInputTypes.ts +387 -0
  43. package/src/types/tools.ts +149 -0
  44. package/src/types/utils.ts +20 -0
  45. package/src/utils/advisor.ts +12 -0
  46. package/src/utils/api.ts +29 -0
  47. package/src/utils/array.ts +7 -0
  48. package/src/utils/attachments.ts +60 -0
  49. package/src/utils/auth.ts +3 -0
  50. package/src/utils/claudeInChrome/chromeNativeHost.ts +15 -0
  51. package/src/utils/claudeInChrome/common.ts +12 -0
  52. package/src/utils/claudeInChrome/mcpServer.ts +15 -0
  53. package/src/utils/computerUse/common.ts +19 -0
  54. package/src/utils/computerUse/mcpServer.ts +15 -0
  55. package/src/utils/config.ts +35 -0
  56. package/src/utils/context.ts +19 -0
  57. package/src/utils/cwd.ts +3 -0
  58. package/src/utils/debug.ts +3 -0
  59. package/src/utils/earlyInput.ts +7 -0
  60. package/src/utils/effort.ts +13 -0
  61. package/src/utils/embeddedTools.ts +12 -0
  62. package/src/utils/envUtils.ts +3 -0
  63. package/src/utils/errors.ts +3 -0
  64. package/src/utils/execFileNoThrow.ts +24 -0
  65. package/src/utils/feature-flags.ts +112 -0
  66. package/src/utils/file.ts +3 -0
  67. package/src/utils/fileHistory.ts +17 -0
  68. package/src/utils/fingerprint.ts +7 -0
  69. package/src/utils/format.ts +75 -305
  70. package/src/utils/frontmatterParser.ts +33 -0
  71. package/src/utils/fsOperations.ts +31 -0
  72. package/src/utils/fullscreen.ts +40 -350
  73. package/src/utils/git.ts +15 -0
  74. package/src/utils/imageResizer.ts +30 -0
  75. package/src/utils/lazySchema.ts +9 -0
  76. package/src/utils/log.ts +3 -0
  77. package/src/utils/markdownConfigLoader.ts +12 -0
  78. package/src/utils/messages.ts +13 -0
  79. package/src/utils/migration.ts +137 -0
  80. package/src/utils/model/providers.ts +15 -0
  81. package/src/utils/path.ts +3 -0
  82. package/src/utils/permissions/PermissionResult.ts +14 -0
  83. package/src/utils/permissions/autoModeState.ts +12 -0
  84. package/src/utils/permissions/filesystem.ts +12 -0
  85. package/src/utils/plugins/loadPluginOutputStyles.ts +12 -0
  86. package/src/utils/plugins/schemas.ts +25 -0
  87. package/src/utils/process.ts +16 -0
  88. package/src/utils/sandbox/sandbox-adapter.ts +19 -0
  89. package/src/utils/sessionStorage.ts +238 -472
  90. package/src/utils/settings/constants.ts +10 -0
  91. package/src/utils/settings/settings.ts +19 -0
  92. package/src/utils/settings/types.ts +18 -0
  93. package/src/utils/shell/shellToolUtils.ts +9 -0
  94. package/src/utils/sinks.ts +11 -0
  95. package/src/utils/sleep.ts +7 -0
  96. package/src/utils/sliceAnsi.ts +7 -0
  97. package/src/utils/slowOperations.ts +3 -0
  98. package/src/utils/startupProfiler.ts +11 -0
  99. package/src/utils/stringUtils.ts +106 -0
  100. package/src/utils/systemPromptType.ts +9 -0
  101. package/src/utils/teleport/api.ts +15 -0
  102. package/src/utils/textHighlighting.ts +16 -0
  103. package/src/utils/theme.ts +17 -0
  104. package/src/utils/thinking.ts +58 -0
  105. package/src/utils/tokens.ts +11 -0
  106. package/src/utils/toolResultStorage.ts +17 -0
  107. package/src/utils/worktreeModeEnabled.ts +7 -0
  108. package/WORKSPACE_INTEGRATION.md +0 -290
  109. package/chat-sessions/sessions-index.json +0 -98
  110. package/package.json.original +0 -31
  111. package/package.json.publish +0 -47
  112. package/src/bootstrap/state.d.ts +0 -169
  113. package/src/bootstrap/state.js +0 -261
  114. package/src/context/pack-builder.d.ts +0 -24
  115. package/src/context/pack-builder.js +0 -281
  116. package/src/hooks/useExitOnCtrlCD.d.ts +0 -86
  117. package/src/hooks/useExitOnCtrlCD.js +0 -130
  118. package/src/hooks/useKeybinding.d.ts +0 -89
  119. package/src/hooks/useKeybinding.js +0 -163
  120. package/src/hooks/useTerminalSize.d.ts +0 -41
  121. package/src/hooks/useTerminalSize.js +0 -90
  122. package/src/index.d.ts +0 -23
  123. package/src/index.js +0 -24
  124. package/src/runtime/brand/brand.d.ts +0 -488
  125. package/src/runtime/brand/brand.js +0 -464
  126. package/src/runtime/brand/brand.ts +0 -667
  127. package/src/runtime/services/tokenEstimation.d.ts +0 -187
  128. package/src/runtime/services/tokenEstimation.js +0 -423
  129. package/src/runtime/services/tokenEstimation.ts +0 -547
  130. package/src/runtime/tools/Tool.d.ts +0 -239
  131. package/src/runtime/tools/Tool.js +0 -285
  132. package/src/runtime/tools/Tool.ts +0 -524
  133. package/src/scheduler/TaskScheduler.d.ts +0 -98
  134. package/src/scheduler/TaskScheduler.js +0 -201
  135. package/src/scheduler/TaskScheduler.ts +0 -259
  136. package/src/state/AppStateStore.d.ts +0 -347
  137. package/src/state/AppStateStore.js +0 -439
  138. package/src/state/AppStateStore.ts +0 -658
  139. package/src/state/WorkspaceStateStore.d.ts +0 -43
  140. package/src/state/WorkspaceStateStore.js +0 -224
  141. package/src/state/WorkspaceStateStore.ts +0 -297
  142. package/src/types/message.d.ts +0 -190
  143. package/src/types/message.js +0 -77
  144. package/src/utils/format.d.ts +0 -126
  145. package/src/utils/format.js +0 -230
  146. package/src/utils/fullscreen.d.ts +0 -161
  147. package/src/utils/fullscreen.js +0 -277
  148. package/src/utils/sessionStorage.d.ts +0 -210
  149. package/src/utils/sessionStorage.js +0 -435
  150. package/src/watcher/WorkspaceWatcher.d.ts +0 -70
  151. package/src/watcher/WorkspaceWatcher.js +0 -191
  152. package/src/watcher/WorkspaceWatcher.ts +0 -251
  153. package/src/workspace/loader.d.ts +0 -30
  154. package/src/workspace/loader.js +0 -117
  155. package/src/workspace/types.d.ts +0 -91
  156. package/src/workspace/types.js +0 -7
  157. package/threads/thread_1775361175022.json +0 -9
  158. package/tsconfig.json +0 -14
@@ -1,277 +1,1018 @@
1
1
  /**
2
- * @fileoverview Message types for gizzi-code integration
3
- * @module types/message
4
- *
5
- * Defines core message interfaces and types used across the application
6
- * for chat, notifications, and system communications.
2
+ * Gizzi Message Type System
3
+ * Complete implementation based on Claude's canonical architecture
7
4
  */
8
5
 
6
+ type UUID = string
7
+
8
+ // ============================================================================
9
+ // Base Types
10
+ // ============================================================================
11
+
12
+ export type MessageRole = 'user' | 'assistant' | 'system'
13
+
14
+ export type SystemMessageLevel =
15
+ | 'info'
16
+ | 'warning'
17
+ | 'error'
18
+ | 'success'
19
+ | 'suggestion'
20
+
21
+ type MessageUsage = {
22
+ input_tokens: number
23
+ output_tokens: number
24
+ }
25
+
26
+ type NestedMessage = {
27
+ id?: string
28
+ role?: MessageRole
29
+ content: string | MessageContent[] | ContentBlock[] | unknown[] | unknown
30
+ stop_reason?: string | null
31
+ usage?: MessageUsage
32
+ model?: string
33
+ type?: string
34
+ stop_sequence?: string
35
+ container?: unknown
36
+ context_management?: unknown
37
+ [key: string]: any
38
+ }
39
+
9
40
  /**
10
- * Represents the possible roles a message can have in a conversation
11
- * @typedef {'user' | 'assistant' | 'system'} MessageRole
41
+ * Type guard to check if content is an array of MessageContent
12
42
  */
13
- export type MessageRole = 'user' | 'assistant' | 'system';
43
+ export function isMessageContentArray(content: unknown): content is MessageContent[] {
44
+ return Array.isArray(content) && content.length > 0 && typeof content[0] === 'object' && content[0] !== null && 'type' in content[0]
45
+ }
14
46
 
15
47
  /**
16
- * Valid message role values for runtime validation
17
- * @constant {MessageRole[]}
48
+ * Type guard to check if content is an array of ContentBlock
18
49
  */
19
- export const MESSAGE_ROLES: readonly MessageRole[] = ['user', 'assistant', 'system'] as const;
50
+ export function isContentBlockArray(content: unknown): content is ContentBlock[] {
51
+ return Array.isArray(content) && content.length > 0 && typeof content[0] === 'object' && content[0] !== null && 'type' in content[0]
52
+ }
20
53
 
21
54
  /**
22
- * Supported MIME types for message attachments
23
- * @typedef {string} AttachmentMimeType
55
+ * Get the first content item from a NestedMessage safely
24
56
  */
25
- export type AttachmentMimeType =
26
- | 'image/png'
27
- | 'image/jpeg'
28
- | 'image/gif'
29
- | 'image/webp'
30
- | 'image/svg+xml'
31
- | 'text/plain'
32
- | 'text/markdown'
33
- | 'text/html'
34
- | 'application/json'
35
- | 'application/pdf'
36
- | 'application/zip'
37
- | 'audio/mpeg'
38
- | 'audio/wav'
39
- | 'video/mp4'
40
- | 'video/webm'
41
- | string;
57
+ export function getFirstContentItem(content: string | MessageContent[] | ContentBlock[]): MessageContent | ContentBlock | undefined {
58
+ if (typeof content === 'string') {
59
+ return { type: 'text', text: content }
60
+ }
61
+ if (Array.isArray(content) && content.length > 0) {
62
+ return content[0] as MessageContent | ContentBlock
63
+ }
64
+ return undefined
65
+ }
66
+
67
+ export interface MessageOrigin {
68
+ type?: string
69
+ kind?: string
70
+ id?: string
71
+ server?: string
72
+ }
73
+
74
+ export interface MessageAttachment {
75
+ type?:
76
+ | 'file'
77
+ | 'image'
78
+ | 'code'
79
+ | 'companion_intro'
80
+ | 'compact_file_reference'
81
+ | 'pdf_reference'
82
+ | 'already_read_file'
83
+ | 'edited_text_file'
84
+ | 'edited_image_file'
85
+ | 'directory'
86
+ | 'selected_lines_in_ide'
87
+ | 'opened_file_in_ide'
88
+ | 'todo_reminder'
89
+ | 'task_reminder'
90
+ | 'nested_memory'
91
+ | 'relevant_memories'
92
+ | 'dynamic_skill'
93
+ | 'skill_listing'
94
+ | 'skill_discovery'
95
+ | 'queued_command'
96
+ | 'output_style'
97
+ | 'diagnostics'
98
+ | 'plan_mode'
99
+ | 'plan_mode_reentry'
100
+ | 'plan_mode_exit'
101
+ | 'auto_mode'
102
+ | 'auto_mode_exit'
103
+ | 'critical_system_reminder'
104
+ | 'plan_file_reference'
105
+ | 'mcp_resource'
106
+ | 'command_permissions'
107
+ | 'agent_mention'
108
+ | 'task_status'
109
+ | 'async_hook_response'
110
+ | 'token_usage'
111
+ | 'budget_usd'
112
+ | 'output_token_usage'
113
+ | 'structured_output'
114
+ | 'invoked_skills'
115
+ | 'verify_plan_reminder'
116
+ | 'max_turns_reached'
117
+ | 'current_session_memory'
118
+ | 'teammate_shutdown_batch'
119
+ | 'compaction_reminder'
120
+ | 'context_efficiency'
121
+ | 'date_change'
122
+ | 'ultrathink_effort'
123
+ | 'deferred_tools_delta'
124
+ | 'agent_listing_delta'
125
+ | 'mcp_instructions_delta'
126
+ | 'teammate_mailbox'
127
+ | 'team_context'
128
+ | 'bagel_console'
129
+ | string
130
+ name?: string
131
+ fileName?: string
132
+ content?: string
133
+ mimeType?: string
134
+ prompt?: string | Array<{type: string; text?: string}>
135
+ identity?: {
136
+ type: string
137
+ name: string
138
+ }
139
+ // Properties for specific attachment types
140
+ isMeta?: boolean
141
+ commandMode?: string
142
+ memories?: Array<{content: string}>
143
+ addedNames?: string[]
144
+ removedNames?: string[]
145
+ // Hook-related properties
146
+ hookEvent?: string
147
+ hookName?: string
148
+ toolUseID?: string
149
+ tool_use_id?: string
150
+ // Data payload for complex attachments
151
+ data?: unknown
152
+ parentToolUseID?: string
153
+ parent_tool_use_id?: string
154
+ }
155
+
156
+ export interface ToolUseResult {
157
+ toolUseId: string
158
+ content: string | unknown[]
159
+ isError?: boolean
160
+ }
161
+
162
+ export interface MessageContent {
163
+ type: 'text' | 'tool_use' | 'tool_result' | 'thinking' | 'image' | 'redacted_thinking' | 'server_tool_use' | 'advisor_tool_result' | string
164
+ text?: string
165
+ id?: string
166
+ name?: string
167
+ input?: unknown
168
+ content?: string | unknown[] | Array<{type: string; text?: string; source?: unknown}>
169
+ thinking?: string
170
+ signature?: string
171
+ toolUseId?: string
172
+ tool_use_id?: string // Snake case alias
173
+ is_error?: boolean
174
+ source?: {
175
+ type: 'base64' | 'url'
176
+ media_type: string
177
+ data: string
178
+ }
179
+ // Additional properties for extended content types
180
+ data?: string
181
+ partial_json?: string
182
+ index?: number
183
+ caller?: string | null
184
+ // Tool result content items
185
+ toolUse?: {
186
+ name: string
187
+ input: Record<string, unknown>
188
+ }
189
+ [key: string]: unknown
190
+ }
191
+
192
+ // Specific content block types for discriminated unions
193
+ export interface TextContentBlock {
194
+ type: 'text'
195
+ text: string
196
+ [key: string]: unknown
197
+ }
198
+
199
+ export interface ToolUseContentBlock {
200
+ type: 'tool_use'
201
+ id: string
202
+ name: string
203
+ input: Record<string, unknown> | unknown
204
+ // Additional properties for SDK compatibility
205
+ toolUseId?: string
206
+ tool_use_id?: string
207
+ [key: string]: unknown
208
+ }
209
+
210
+ export interface ToolResultContentBlock {
211
+ type: 'tool_result'
212
+ tool_use_id: string
213
+ content: string | Array<{type: string; text?: string; source?: unknown}>
214
+ is_error?: boolean
215
+ [key: string]: unknown
216
+ }
42
217
 
43
218
  /**
44
- * Attachment metadata and content structure
45
- * @interface Attachment
219
+ * Tool reference content block (beta feature).
220
+ * Used for dynamic tool loading - contains a reference to a tool by name
221
+ * that gets expanded into the full tool definition in the API.
46
222
  */
47
- export interface Attachment {
48
- /** Unique identifier for the attachment */
49
- readonly id: string;
223
+ export interface ToolReferenceContentBlock {
224
+ type: 'tool_reference'
225
+ tool_name: string
226
+ }
227
+
228
+ export interface ThinkingContentBlock {
229
+ type: 'thinking'
230
+ thinking: string
231
+ signature?: string
232
+ [key: string]: unknown
233
+ }
50
234
 
51
- /** Original filename */
52
- readonly name: string;
235
+ export interface RedactedThinkingContentBlock {
236
+ type: 'redacted_thinking'
237
+ data: string
238
+ [key: string]: unknown
239
+ }
53
240
 
54
- /** MIME type of the attachment */
55
- readonly mimeType: AttachmentMimeType;
241
+ export interface ImageContentBlock {
242
+ type: 'image'
243
+ source: {
244
+ type: 'base64' | 'url'
245
+ media_type: string
246
+ data: string
247
+ }
248
+ [key: string]: unknown
249
+ }
56
250
 
57
- /** File size in bytes */
58
- readonly size: number;
251
+ export type ContentBlock = TextContentBlock | ToolUseContentBlock | ToolResultContentBlock | ThinkingContentBlock | RedactedThinkingContentBlock | ImageContentBlock
59
252
 
60
- /** Data URL or storage reference for the attachment content */
61
- readonly url: string;
253
+ export interface CompactMetadata {
254
+ messageCount: number
255
+ direction?: 'up' | 'down'
256
+ /** Tool names discovered before compaction, preserved across compact boundaries */
257
+ preCompactDiscoveredTools?: string[]
258
+ [key: string]: unknown
259
+ }
62
260
 
63
- /** Optional preview/thumbnail URL for image/video attachments */
64
- readonly previewUrl?: string;
261
+ export interface McpMeta {
262
+ serverName?: string
263
+ _meta?: Record<string, unknown>
264
+ structuredContent?: Record<string, unknown>
265
+ [key: string]: unknown
266
+ }
65
267
 
66
- /** Optional caption or description */
67
- readonly caption?: string;
268
+ export interface ToolUseSummary {
269
+ toolUseId: string
270
+ name: string
271
+ status: 'pending' | 'running' | 'completed' | 'error'
272
+ result?: string
273
+ }
68
274
 
69
- /** Timestamp when the attachment was created */
70
- readonly createdAt: Date;
275
+ // ============================================================================
276
+ // Base Message Interface
277
+ // ============================================================================
71
278
 
72
- /** Optional metadata for specific attachment types */
73
- readonly metadata?: Readonly<Record<string, unknown>>;
279
+ export interface Message {
280
+ // Core properties
281
+ type: MessageRole | 'progress' | 'system' | 'tombstone' | 'attachment' | 'grouped_tool_use' | 'collapsed_read_search' | 'stream_event'
282
+ role?: MessageRole
283
+ uuid: UUID | string
284
+ id?: string // Alternative ID property
285
+ content?: string | MessageContent[] | ContentBlock[] | unknown[]
286
+
287
+ // Stream event properties
288
+ event?: {
289
+ type: 'message_start' | 'message_delta' | 'message_stop' | 'content_block_start' | 'content_block_delta' | 'content_block_stop'
290
+ message?: {
291
+ usage?: MessageUsage
292
+ }
293
+ delta?: {
294
+ stop_reason?: string | null
295
+ }
296
+ usage?: MessageUsage
297
+ }
298
+
299
+ // Message state
300
+ stop_reason?: string | null
301
+ model?: string
302
+ usage?: MessageUsage
303
+
304
+ // Session context
305
+ session_id?: string
306
+ parent_tool_use_id?: string | null
307
+ parentToolUseID?: string | null
308
+ isCompactSummary?: boolean
309
+
310
+ // Nested message (for compact summaries)
311
+ message?: NestedMessage
312
+
313
+ // UI/Display properties
314
+ isVirtual?: boolean
315
+ isMeta?: boolean
316
+ isVisibleInTranscriptOnly?: boolean
317
+ isApiErrorMessage?: boolean
318
+ subtype?:
319
+ | 'user'
320
+ | 'assistant'
321
+ | 'system'
322
+ | 'attachment'
323
+ | 'compact_boundary'
324
+ | 'tool_summary'
325
+ | 'thinking'
326
+ | 'memory_saved'
327
+ | 'stop_hook'
328
+ | 'api_error'
329
+ | 'informational'
330
+ | 'bridge_status'
331
+ | 'local_command'
332
+ | 'api_metrics'
333
+ | 'stop_hook_summary'
334
+ | 'turn_duration'
335
+ | 'microcompact_boundary'
336
+ | 'agents_killed'
337
+ | 'away_summary'
338
+ | 'hook_result'
339
+ | 'hook_progress'
340
+ | 'hook_response'
341
+ | 'hook_started'
342
+ | 'success'
343
+ | 'file_snapshot'
344
+ | 'permission_retry'
345
+ | 'scheduled_task_fire'
346
+ | string
347
+
348
+ // Origin and context
349
+ origin?: MessageOrigin
350
+
351
+ // Tool and attachment data
352
+ toolUseResult?: ToolUseResult
353
+ toolUseID?: string
354
+ toolUseSummary?: ToolUseSummary
355
+ attachment?: MessageAttachment
356
+ client?: unknown
357
+ source?: unknown
358
+ data?: {
359
+ toolUseId?: string
360
+ content?: unknown
361
+ type?: string
362
+ [key: string]: unknown
363
+ }
364
+
365
+ // Metadata
366
+ timestamp?: string | number
367
+ requestId?: string
368
+ error?: Error | string
369
+ apiError?: unknown
370
+ errorDetails?: string
371
+ advisorModel?: string
372
+ mcpMeta?: McpMeta
373
+ imagePasteIds?: Array<string | number>
374
+ compactMetadata?: CompactMetadata
375
+ messageCount?: number
376
+ permissionMode?: string
377
+ level?: SystemMessageLevel
378
+ preventContinuation?: boolean
379
+ commands?: string[]
380
+ url?: string
381
+ upgradeNudge?: string
382
+ hookCount?: number
383
+ hookInfos?: StopHookInfo[]
384
+ hookErrors?: string[]
385
+ stopReason?: string
386
+ hasOutput?: boolean
387
+ hookLabel?: string
388
+ totalDurationMs?: number
389
+ durationMs?: number
390
+ budgetTokens?: number
391
+ budgetLimit?: number
392
+ budgetNudges?: number
393
+ writtenPaths?: string[]
394
+ microcompactMetadata?: {
395
+ trigger: 'auto'
396
+ preTokens: number
397
+ tokensSaved: number
398
+ compactedToolIds: string[]
399
+ clearedAttachmentUUIDs: string[]
400
+ }
401
+ ttftMs?: number
402
+ otps?: number
403
+ isP50?: boolean
404
+ hookDurationMs?: number
405
+ turnDurationMs?: number
406
+ toolDurationMs?: number
407
+ classifierDurationMs?: number
408
+ toolCount?: number
409
+ classifierCount?: number
410
+ configWriteCount?: number
411
+ cause?: Error
412
+ retryInMs?: number
413
+ retryAttempt?: number
414
+ maxRetries?: number
415
+
416
+ // Agent/workspace
417
+ agentDefinitions?: unknown[]
418
+
419
+ // Additional properties for various message types
420
+ text?: string
421
+ name?: string
422
+ command?: string
423
+ tool_use_id?: string
424
+ output?: string
425
+ stdout?: string
426
+ result?: unknown
427
+ status?: 'connected' | 'disconnected' | 'reconnecting'
428
+ taskName?: string
429
+ scheduledTime?: number
430
+
431
+ // For collapsed read search groups
432
+ messages?: Message[]
433
+ summary?: string
434
+
435
+ // For progress messages
436
+ toolUseId?: string
437
+
438
+ // For permission/system messages
439
+ toolName?: string
440
+
441
+ // Array-like properties (for filter, length, etc.)
442
+ length?: number
443
+ filter?: unknown
444
+
445
+ // Catch-all for any other properties used in the codebase
446
+ [key: string]: any
74
447
  }
75
448
 
449
+ // ============================================================================
450
+ // Role-Specific Message Types
451
+ // ============================================================================
452
+
453
+ export interface UserMessage extends Message {
454
+ type: 'user'
455
+ role?: 'user'
456
+ message: NestedMessage & {
457
+ role: 'user'
458
+ content: string | MessageContent[] | ContentBlock[]
459
+ }
460
+ }
461
+
462
+ export interface AssistantMessage extends Message {
463
+ type: 'assistant'
464
+ role?: 'assistant'
465
+ message: NestedMessage & {
466
+ role: 'assistant'
467
+ content: string | MessageContent[] | ContentBlock[]
468
+ }
469
+ }
470
+
471
+ export interface SystemMessage extends Message {
472
+ type: 'system'
473
+ role?: 'system'
474
+ content?: string
475
+ level?: SystemMessageLevel
476
+ }
477
+
478
+ // ============================================================================
479
+ // UI/Display Message Types
480
+ // ============================================================================
481
+
76
482
  /**
77
- * Message status indicators
78
- * @typedef {'pending' | 'sent' | 'delivered' | 'read' | 'error'} MessageStatus
483
+ * RenderableMessage - Messages that can be rendered in the UI
484
+ * Includes display properties for the TUI
79
485
  */
80
- export type MessageStatus = 'pending' | 'sent' | 'delivered' | 'read' | 'error';
486
+ export interface RenderableMessage extends Message {
487
+ isRenderable: true
488
+ renderOptions?: {
489
+ collapsible?: boolean
490
+ highlight?: boolean
491
+ }
492
+ messages?: Message[]
493
+ // Properties for collapsed_read_search type
494
+ relevantMemories?: Array<{content: string}>
495
+ }
81
496
 
82
497
  /**
83
- * Core message structure for all communications
84
- * @interface Message
498
+ * AttachmentMessage - Messages containing file attachments
85
499
  */
86
- export interface Message {
87
- /** Unique message identifier */
88
- readonly id: string;
89
-
90
- /** Message role identifying the sender type */
91
- readonly role: MessageRole;
92
-
93
- /** Message content - can be text or structured data */
94
- readonly content: string;
500
+ export interface AttachmentMessage<T = MessageAttachment> extends Message {
501
+ type: 'attachment'
502
+ subtype: 'attachment'
503
+ attachment: T
504
+ fileName?: string
505
+ mimeType?: string
506
+ }
95
507
 
96
- /** Optional timestamp when the message was created */
97
- readonly timestamp?: Date;
508
+ // ============================================================================
509
+ // System Message Subtypes
510
+ // ============================================================================
98
511
 
99
- /** Optional array of file attachments */
100
- readonly attachments?: readonly Attachment[];
512
+ /**
513
+ * SystemCompactBoundaryMessage - Marks snip boundaries in conversation
514
+ */
515
+ export interface SystemCompactBoundaryMessage extends SystemMessage {
516
+ subtype: 'compact_boundary'
517
+ compactMetadata: CompactMetadata
518
+ messageCount: number
519
+ direction?: 'up' | 'down'
520
+ }
101
521
 
102
- /** Current status of the message delivery */
103
- readonly status?: MessageStatus;
522
+ /**
523
+ * SystemAPIErrorMessage - API error messages
524
+ */
525
+ export interface SystemAPIErrorMessage extends SystemMessage {
526
+ subtype: 'api_error'
527
+ error: string | Error
528
+ cause?: Error
529
+ retryInMs?: number
530
+ retryAttempt?: number
531
+ maxRetries?: number
532
+ isApiErrorMessage?: true
533
+ }
104
534
 
105
- /** Optional metadata for extended message properties */
106
- readonly metadata?: Readonly<Record<string, unknown>>;
535
+ /**
536
+ * SystemMemorySavedMessage - Memory persistence notifications
537
+ */
538
+ export interface SystemMemorySavedMessage extends SystemMessage {
539
+ subtype: 'memory_saved'
540
+ }
107
541
 
108
- /** Optional ID of the message this is replying to */
109
- readonly replyTo?: string;
542
+ /**
543
+ * SystemStopHookSummaryMessage - Hook execution summaries
544
+ */
545
+ export interface SystemStopHookSummaryMessage extends SystemMessage {
546
+ subtype: 'stop_hook_summary'
547
+ hookCount: number
548
+ hookInfos: StopHookInfo[]
549
+ hookErrors: string[]
550
+ preventedContinuation: boolean
551
+ stopReason?: string
552
+ hasOutput: boolean
553
+ hookLabel?: string
554
+ totalDurationMs?: number
555
+ }
110
556
 
111
- /** Optional edit history for tracking modifications */
112
- readonly edits?: ReadonlyArray<{
113
- readonly content: string;
114
- readonly timestamp: Date;
115
- }>;
557
+ /**
558
+ * SystemThinkingMessage - Assistant thinking/reasoning display
559
+ */
560
+ export interface SystemThinkingMessage extends SystemMessage {
561
+ subtype: 'thinking'
562
+ thinking: string
563
+ signature?: string
116
564
  }
117
565
 
118
566
  /**
119
- * System-specific message with additional metadata
120
- * @interface SystemMessage
121
- * @extends Message
567
+ * SystemTurnDurationMessage - Turn timing information
122
568
  */
123
- export interface SystemMessage extends Message {
124
- readonly role: 'system';
569
+ export interface SystemTurnDurationMessage extends SystemMessage {
570
+ subtype: 'turn_duration'
571
+ durationMs: number
572
+ budgetTokens?: number
573
+ budgetLimit?: number
574
+ budgetNudges?: number
575
+ messageCount?: number
576
+ }
125
577
 
126
- /** System message type categorization */
127
- readonly systemType: 'notification' | 'error' | 'warning' | 'info' | 'command';
578
+ /**
579
+ * SystemBridgeStatusMessage - Bridge connection status
580
+ */
581
+ export interface SystemBridgeStatusMessage extends SystemMessage {
582
+ subtype: 'bridge_status'
583
+ url: string
584
+ upgradeNudge?: string
585
+ }
128
586
 
129
- /** Optional action button or link */
130
- readonly action?: {
131
- readonly label: string;
132
- readonly handler: string;
133
- readonly payload?: unknown;
134
- };
587
+ /**
588
+ * SystemInformationalMessage - General system information
589
+ */
590
+ export interface SystemInformationalMessage extends SystemMessage {
591
+ subtype: 'informational'
592
+ content: string
135
593
  }
136
594
 
137
595
  /**
138
- * User message with optional context
139
- * @interface UserMessage
140
- * @extends Message
596
+ * SystemAgentsKilledMessage - Notification when agents are killed
141
597
  */
142
- export interface UserMessage extends Message {
143
- readonly role: 'user';
598
+ export interface SystemAgentsKilledMessage extends SystemMessage {
599
+ subtype: 'agents_killed'
600
+ }
144
601
 
145
- /** Optional session or conversation context */
146
- readonly context?: Readonly<Record<string, unknown>>;
602
+ /**
603
+ * SystemAwaySummaryMessage - Summary generated while away
604
+ */
605
+ export interface SystemAwaySummaryMessage extends SystemMessage {
606
+ subtype: 'away_summary'
607
+ content: string
147
608
  }
148
609
 
149
610
  /**
150
- * Assistant/AI response message with optional thinking/reasoning
151
- * @interface AssistantMessage
152
- * @extends Message
611
+ * SystemLocalCommandMessage - Local command execution message
153
612
  */
154
- export interface AssistantMessage extends Message {
155
- readonly role: 'assistant';
613
+ export interface SystemLocalCommandMessage extends SystemMessage {
614
+ subtype: 'local_command'
615
+ content: string
616
+ }
156
617
 
157
- /** Optional thinking/reasoning process for the response */
158
- readonly reasoning?: string;
618
+ export interface SystemApiMetricsMessage extends SystemMessage {
619
+ subtype: 'api_metrics'
620
+ ttftMs: number
621
+ otps: number
622
+ isP50?: boolean
623
+ hookDurationMs?: number
624
+ turnDurationMs?: number
625
+ toolDurationMs?: number
626
+ classifierDurationMs?: number
627
+ toolCount?: number
628
+ hookCount?: number
629
+ classifierCount?: number
630
+ configWriteCount?: number
631
+ }
159
632
 
160
- /** Token usage statistics for the response */
161
- readonly tokenUsage?: {
162
- readonly prompt: number;
163
- readonly completion: number;
164
- readonly total: number;
165
- };
633
+ export interface SystemMicrocompactBoundaryMessage extends SystemMessage {
634
+ subtype: 'microcompact_boundary'
635
+ content: string
636
+ microcompactMetadata: {
637
+ trigger: 'auto'
638
+ preTokens: number
639
+ tokensSaved: number
640
+ compactedToolIds: string[]
641
+ clearedAttachmentUUIDs: string[]
642
+ }
643
+ }
166
644
 
167
- /** Model identifier that generated the response */
168
- readonly model?: string;
645
+ /**
646
+ * SystemPermissionRetryMessage - Permission retry request
647
+ */
648
+ export interface SystemPermissionRetryMessage extends SystemMessage {
649
+ subtype: 'permission_retry'
650
+ commands: string[]
169
651
  }
170
652
 
171
653
  /**
172
- * Union type for all message variants
173
- * @typedef {UserMessage | AssistantMessage | SystemMessage} TypedMessage
654
+ * SystemScheduledTaskFireMessage - Scheduled task execution notification
174
655
  */
175
- export type TypedMessage = UserMessage | AssistantMessage | SystemMessage;
656
+ export interface SystemScheduledTaskFireMessage extends SystemMessage {
657
+ subtype: 'scheduled_task_fire'
658
+ content: string
659
+ }
660
+
661
+ // ============================================================================
662
+ // Tool-Related Message Types
663
+ // ============================================================================
176
664
 
177
665
  /**
178
- * Message thread/conversation structure
179
- * @interface MessageThread
666
+ * ToolUseSummaryMessage - Summary of tool execution
180
667
  */
181
- export interface MessageThread {
182
- /** Unique thread identifier */
183
- readonly id: string;
668
+ export interface ToolUseSummaryMessage extends Message {
669
+ subtype: 'tool_summary'
670
+ toolUseSummary: ToolUseSummary
671
+ }
184
672
 
185
- /** Thread title or subject */
186
- readonly title?: string;
673
+ /**
674
+ * GroupedToolUseMessage - Grouped tool use results
675
+ */
676
+ export interface GroupedToolUseMessage extends Message {
677
+ type: 'grouped_tool_use'
678
+ toolUses: ToolUseResult[]
679
+ messages: Message[]
680
+ toolName: string
681
+ displayMessage: Message
682
+ }
187
683
 
188
- /** Array of messages in the thread */
189
- readonly messages: readonly TypedMessage[];
684
+ /**
685
+ * HookResultMessage - Hook execution results
686
+ */
687
+ export interface HookResultMessage extends Message {
688
+ subtype: 'hook_result'
689
+ hookName: string
690
+ result: unknown
691
+ }
190
692
 
191
- /** Thread creation timestamp */
192
- readonly createdAt: Date;
693
+ // ============================================================================
694
+ // Special Message Types
695
+ // ============================================================================
193
696
 
194
- /** Last activity timestamp */
195
- readonly updatedAt: Date;
697
+ /**
698
+ * ProgressMessage - Streaming progress updates
699
+ */
700
+ export interface ProgressMessage<T = unknown> {
701
+ type: 'progress'
702
+ toolUseID?: string
703
+ parentToolUseID?: string
704
+ uuid?: string
705
+ timestamp?: string
706
+ data?: {
707
+ type?: string
708
+ } & T
709
+ [key: string]: unknown
710
+ // Progress messages may contain nested message data for streaming
711
+ message?: {
712
+ content: MessageContent[] | ContentBlock[]
713
+ role?: MessageRole
714
+ id?: string
715
+ type?: string
716
+ }
717
+ }
196
718
 
197
- /** Optional metadata for the thread */
198
- readonly metadata?: Readonly<Record<string, unknown>>;
719
+ /**
720
+ * CollapsedReadSearchGroup - Collapsed search results
721
+ */
722
+ export interface CollapsedReadSearchGroup {
723
+ type: 'collapsed_read_search'
724
+ messages: Message[]
725
+ summary: string
726
+ toolName?: string
727
+ displayMessage: Message
728
+ uuid: UUID | string
729
+ timestamp?: string | number
730
+ // Count properties for collapsed search/read operations
731
+ searchCount?: number
732
+ readCount?: number
733
+ listCount?: number
734
+ replCount?: number
735
+ memorySearchCount?: number
736
+ memoryReadCount?: number
737
+ memoryWriteCount?: number
738
+ teamMemorySearchCount?: number
739
+ teamMemoryReadCount?: number
740
+ teamMemoryWriteCount?: number
741
+ readFilePaths?: string[]
742
+ searchArgs?: string[]
743
+ latestDisplayHint?: string
744
+ mcpCallCount?: number
745
+ mcpServerNames?: string[]
746
+ bashCount?: number
747
+ gitOpBashCount?: number
748
+ commits?: Array<{sha: string; kind: string}>
749
+ pushes?: Array<{branch: string}>
750
+ branches?: Array<{ref: string; action: string}>
751
+ prs?: Array<{number: number; url?: string; action?: string}>
752
+ hookTotalMs?: number
753
+ hookCount?: number
754
+ hookInfos?: StopHookInfo[]
755
+ relevantMemories?: Array<{path: string; content: string; mtimeMs: number}>
199
756
  }
200
757
 
201
758
  /**
202
- * Type guard to check if a message is from a user
203
- * @param {Message} message - The message to check
204
- * @returns {boolean} True if the message is from a user
759
+ * TombstoneMessage - Deleted message placeholder
205
760
  */
206
- export function isUserMessage(message: Message): message is UserMessage {
207
- return message.role === 'user';
761
+ export interface TombstoneMessage extends Message {
762
+ type: 'tombstone'
763
+ originalUuid: string
764
+ deletedAt: number
208
765
  }
209
766
 
210
767
  /**
211
- * Type guard to check if a message is from the assistant
212
- * @param {Message} message - The message to check
213
- * @returns {boolean} True if the message is from the assistant
768
+ * QueueOperationMessage - Async operation queue
214
769
  */
215
- export function isAssistantMessage(message: Message): message is AssistantMessage {
216
- return message.role === 'assistant';
770
+ export interface QueueOperationMessage extends Message {
771
+ operation: 'enqueue' | 'dequeue'
772
+ queueName: string
217
773
  }
218
774
 
775
+ // ============================================================================
776
+ // Stream Event Types
777
+ // ============================================================================
778
+
219
779
  /**
220
- * Type guard to check if a message is a system message
221
- * @param {Message} message - The message to check
222
- * @returns {boolean} True if the message is a system message
780
+ * StreamEvent - Events emitted during message streaming
223
781
  */
224
- export function isSystemMessage(message: Message): message is SystemMessage {
225
- return message.role === 'system';
782
+ export interface StreamEvent {
783
+ type: 'content' | 'error' | 'done' | 'tool_use' | 'tool_result'
784
+ content?: string
785
+ delta?: string
786
+ toolUse?: unknown
787
+ error?: Error
226
788
  }
227
789
 
228
790
  /**
229
- * Type guard to check if a value is a valid MessageRole
230
- * @param {unknown} value - The value to check
231
- * @returns {boolean} True if the value is a valid MessageRole
791
+ * RequestStartEvent - Emitted when a request starts
232
792
  */
233
- export function isMessageRole(value: unknown): value is MessageRole {
234
- return typeof value === 'string' && MESSAGE_ROLES.includes(value as MessageRole);
793
+ export interface RequestStartEvent {
794
+ type: 'request_start'
795
+ requestId: string
796
+ timestamp: number
235
797
  }
236
798
 
799
+ // ============================================================================
800
+ // Compact Direction Type
801
+ // ============================================================================
802
+
803
+ /**
804
+ * PartialCompactDirection - Direction for partial compaction
805
+ */
806
+ export type PartialCompactDirection = 'up' | 'down' | 'both' | 'from' | 'up_to'
807
+
808
+ // ============================================================================
809
+ // Stop Hook Info
810
+ // ============================================================================
811
+
237
812
  /**
238
- * Creates a new message with proper defaults
239
- * @param {Object} params - Message creation parameters
240
- * @returns {Message} A new message object
813
+ * StopHookInfo - Information about a stop hook execution
241
814
  */
242
- export function createMessage(params: {
243
- role: MessageRole;
244
- content: string;
245
- attachments?: Attachment[];
246
- metadata?: Record<string, unknown>;
247
- replyTo?: string;
248
- }): Message {
249
- return {
250
- id: generateMessageId(),
251
- role: params.role,
252
- content: params.content,
253
- timestamp: new Date(),
254
- status: 'pending',
255
- ...(params.attachments && { attachments: params.attachments }),
256
- ...(params.metadata && { metadata: params.metadata }),
257
- ...(params.replyTo && { replyTo: params.replyTo }),
258
- };
815
+ export interface StopHookInfo {
816
+ name: string
817
+ duration: number
818
+ result?: unknown
819
+ command?: string
820
+ durationMs?: number
821
+ [key: string]: unknown
822
+ }
823
+
824
+ // ============================================================================
825
+ // Normalized Types (for internal processing)
826
+ // ============================================================================
827
+
828
+ export type NormalizedMessage = UserMessage | AssistantMessage | SystemMessage
829
+
830
+ export interface NormalizedUserMessage extends UserMessage {
831
+ normalized: true
832
+ originalContent?: string
259
833
  }
260
834
 
835
+ // Normalized assistant message for SDK processing
836
+ export interface NormalizedAssistantMessage extends AssistantMessage {
837
+ normalized: true
838
+ content: string | MessageContent[]
839
+ role: 'assistant'
840
+ }
841
+
842
+ // ============================================================================
843
+ // SDK Types
844
+ // ============================================================================
845
+
261
846
  /**
262
- * Generates a unique message ID
263
- * @returns {string} A unique identifier
847
+ * SDKPartialAssistantMessage - Streaming assistant message chunks
264
848
  */
265
- function generateMessageId(): string {
266
- return `msg_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
849
+ export interface SDKPartialAssistantMessage {
850
+ type: 'assistant' | 'stream_event'
851
+ event: 'content_block_delta' | 'content_block_start' | 'content_block_stop' | 'message_delta' | 'message_start' | 'message_stop'
852
+ uuid: string
853
+ session_id: string
854
+ parent_tool_use_id: string | null
855
+ [key: string]: unknown
856
+ content?: string
857
+ delta?: {
858
+ type: string
859
+ text?: string
860
+ partial_json?: string
861
+ }
862
+ index?: number
863
+ message?: {
864
+ id?: string
865
+ role: 'assistant'
866
+ content: MessageContent[]
867
+ stop_reason?: string | null
868
+ model?: string
869
+ usage?: {
870
+ input_tokens: number
871
+ output_tokens: number
872
+ }
873
+ }
874
+ usage?: {
875
+ input_tokens: number
876
+ output_tokens: number
877
+ }
878
+ stop_reason?: string | null
879
+ }
880
+
881
+ // ============================================================================
882
+ // Utility Types
883
+ // ============================================================================
884
+
885
+ export type AnyMessage =
886
+ | Message
887
+ | UserMessage
888
+ | AssistantMessage
889
+ | SystemMessage
890
+ | RenderableMessage
891
+ | AttachmentMessage
892
+ | SystemCompactBoundaryMessage
893
+ | SystemAPIErrorMessage
894
+ | ToolUseSummaryMessage
895
+ | ProgressMessage
896
+ | TombstoneMessage
897
+
898
+ export type MessageSubtype = Extract<Message['subtype'], string>
899
+
900
+ // Type guards
901
+ export function isAttachmentMessage(msg: Message): msg is AttachmentMessage {
902
+ return msg.subtype === 'attachment'
903
+ }
904
+
905
+ export function isSystemCompactBoundaryMessage(msg: Message): msg is SystemCompactBoundaryMessage {
906
+ return msg.subtype === 'compact_boundary'
907
+ }
908
+
909
+ export function isSystemAPIErrorMessage(msg: Message): msg is SystemAPIErrorMessage {
910
+ return msg.isApiErrorMessage === true || msg.subtype === 'api_error'
911
+ }
912
+
913
+ export function isToolUseSummaryMessage(msg: Message): msg is ToolUseSummaryMessage {
914
+ return msg.subtype === 'tool_summary'
915
+ }
916
+
917
+ // Content type guards
918
+ export function isTextContentBlock(content: MessageContent): content is TextContentBlock {
919
+ return content.type === 'text'
920
+ }
921
+
922
+ export function isToolUseContentBlock(content: MessageContent): content is ToolUseContentBlock {
923
+ return content.type === 'tool_use'
924
+ }
925
+
926
+ export function isToolResultContentBlock(content: MessageContent): content is ToolResultContentBlock {
927
+ return content.type === 'tool_result'
928
+ }
929
+
930
+ // Helper type for nested message with array content
931
+ export type NestedMessageWithArrayContent = {
932
+ id?: string
933
+ role?: MessageRole
934
+ type?: string
935
+ content: MessageContent[] | ContentBlock[]
936
+ stop_reason?: string | null
937
+ usage?: {
938
+ input_tokens: number
939
+ output_tokens: number
940
+ }
941
+ }
942
+
943
+ // Type guard for nested message with array content
944
+ export function hasArrayContent(message: { content?: string | MessageContent[] | ContentBlock[] }): message is { content: MessageContent[] | ContentBlock[] } {
945
+ return Array.isArray(message.content)
946
+ }
947
+
948
+ // Helper to get the first content block from a message's content
949
+ export function getFirstContentBlock(message: { content?: string | MessageContent[] | ContentBlock[] }): MessageContent | ContentBlock | undefined {
950
+ if (Array.isArray(message.content) && message.content.length > 0) {
951
+ return message.content[0] as MessageContent | ContentBlock
952
+ }
953
+ return undefined
954
+ }
955
+
956
+ // Type guard for tool use content blocks
957
+ export function isToolUseBlock(content: MessageContent | ContentBlock): content is ToolUseContentBlock {
958
+ return content.type === 'tool_use'
959
+ }
960
+
961
+ // Type guard for text content blocks
962
+ export function isTextBlock(content: MessageContent | ContentBlock): content is TextContentBlock {
963
+ return content.type === 'text'
964
+ }
965
+
966
+ // Type guard for tool result content blocks
967
+ export function isToolResultBlock(content: MessageContent | ContentBlock): content is ToolResultContentBlock {
968
+ return content.type === 'tool_result'
969
+ }
970
+
971
+ // Type guard for thinking content blocks
972
+ export function isThinkingBlock(content: MessageContent | ContentBlock): content is ThinkingContentBlock {
973
+ return content.type === 'thinking'
267
974
  }
268
975
 
269
- // Default export for convenient importing
270
- export default {
271
- MESSAGE_ROLES,
272
- isUserMessage,
273
- isAssistantMessage,
274
- isSystemMessage,
275
- isMessageRole,
276
- createMessage,
277
- };
976
+ // Type guard for redacted thinking content blocks
977
+ export function isRedactedThinkingBlock(content: MessageContent | ContentBlock): content is RedactedThinkingContentBlock {
978
+ return content.type === 'redacted_thinking'
979
+ }
980
+
981
+ // ============================================================================
982
+ // Helper Types for Array Content
983
+ // ============================================================================
984
+
985
+ // Message where nested message content is guaranteed to be an array
986
+ export interface MessageWithArrayContent extends Message {
987
+ message: {
988
+ id?: string
989
+ role?: MessageRole
990
+ content: MessageContent[] | ContentBlock[]
991
+ stop_reason?: string | null
992
+ usage?: {
993
+ input_tokens: number
994
+ output_tokens: number
995
+ }
996
+ }
997
+ }
998
+
999
+ // ============================================================================
1000
+ // Collapsible Message Type
1001
+ // ============================================================================
1002
+
1003
+ export interface CollapsibleMessage extends Message {
1004
+ collapsible: true
1005
+ collapsed: boolean
1006
+ summary?: string
1007
+ children?: Message[]
1008
+ }
1009
+
1010
+ // ============================================================================
1011
+ // File Snapshot Message Type
1012
+ // ============================================================================
1013
+
1014
+ export interface SystemFileSnapshotMessage extends SystemMessage {
1015
+ subtype: 'file_snapshot'
1016
+ files: string[]
1017
+ timestamp: number
1018
+ }