1+ import {
2+ rooCliOutputFormats ,
3+ type RooCliCost ,
4+ type RooCliEventType ,
5+ type RooCliFinalOutput ,
6+ type RooCliOutputFormat ,
7+ type RooCliQueueItem ,
8+ type RooCliStreamEvent ,
9+ type RooCliToolResult ,
10+ type RooCliToolUse ,
11+ } from "@roo-code/types"
12+
113/**
214 * JSON Event Types for Structured CLI Output
315 *
1426/**
1527 * Output format options for the CLI.
1628 */
17- export const OUTPUT_FORMATS = [ "text" , "json" , "stream-json" ] as const
29+ export const OUTPUT_FORMATS = rooCliOutputFormats
1830
19- export type OutputFormat = ( typeof OUTPUT_FORMATS ) [ number ]
31+ export type OutputFormat = RooCliOutputFormat
2032
2133export function isValidOutputFormat ( format : string ) : format is OutputFormat {
2234 return ( OUTPUT_FORMATS as readonly string [ ] ) . includes ( format )
@@ -25,66 +37,24 @@ export function isValidOutputFormat(format: string): format is OutputFormat {
2537/**
2638 * Event type discriminators for JSON output.
2739 */
28- export type JsonEventType =
29- | "system" // System messages (init, ready, shutdown)
30- | "control" // Transport/control protocol events
31- | "queue" // Message queue telemetry from extension state
32- | "assistant" // Assistant text messages
33- | "user" // User messages (echoed input)
34- | "tool_use" // Tool invocations (file ops, commands, browser, MCP)
35- | "tool_result" // Results from tool execution
36- | "thinking" // Reasoning/thinking content
37- | "error" // Errors
38- | "result" // Final task result
40+ export type JsonEventType = RooCliEventType
3941
40- export interface JsonEventQueueItem {
41- /** Queue item id generated by MessageQueueService */
42- id : string
43- /** Queued text prompt preview */
44- text ?: string
45- /** Number of attached images in the queued message */
46- imageCount ?: number
47- /** Queue insertion/update timestamp (ms epoch) */
48- timestamp ?: number
49- }
42+ export type JsonEventQueueItem = RooCliQueueItem
5043
5144/**
5245 * Tool use information for tool_use events.
5346 */
54- export interface JsonEventToolUse {
55- /** Tool name (e.g., "read_file", "write_to_file", "execute_command") */
56- name : string
57- /** Tool input parameters */
58- input ?: Record < string , unknown >
59- }
47+ export type JsonEventToolUse = RooCliToolUse
6048
6149/**
6250 * Tool result information for tool_result events.
6351 */
64- export interface JsonEventToolResult {
65- /** Tool name that produced this result */
66- name : string
67- /** Tool output (for successful execution) */
68- output ?: string
69- /** Error message (for failed execution) */
70- error ?: string
71- }
52+ export type JsonEventToolResult = RooCliToolResult
7253
7354/**
7455 * Cost and token usage information.
7556 */
76- export interface JsonEventCost {
77- /** Total cost in USD */
78- totalCost ?: number
79- /** Input tokens used */
80- inputTokens ?: number
81- /** Output tokens generated */
82- outputTokens ?: number
83- /** Cache write tokens */
84- cacheWrites ?: number
85- /** Cache read tokens */
86- cacheReads ?: number
87- }
57+ export type JsonEventCost = RooCliCost
8858
8959/**
9060 * Base JSON event structure.
@@ -94,7 +64,7 @@ export interface JsonEventCost {
9464 * - Each delta includes `id` for easy correlation
9565 * - Final message has `done: true`
9666 */
97- export interface JsonEvent {
67+ export type JsonEvent = RooCliStreamEvent & {
9868 /** Event type discriminator */
9969 type : JsonEventType
10070 /** Protocol schema version (included on system.init) */
@@ -137,7 +107,7 @@ export interface JsonEvent {
137107 * Final JSON output for "json" mode (single object at end).
138108 * Contains the result and accumulated messages.
139109 */
140- export interface JsonFinalOutput {
110+ export type JsonFinalOutput = RooCliFinalOutput & {
141111 /** Final result type */
142112 type : "result"
143113 /** Whether the task succeeded */
0 commit comments