-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathapi.ts
More file actions
178 lines (174 loc) · 6.45 KB
/
Copy pathapi.ts
File metadata and controls
178 lines (174 loc) · 6.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import type { EventEmitter } from "events"
import type { Socket } from "net"
import type { RooCodeEvents } from "./events.js"
import type { RooCodeSettings } from "./global-settings.js"
import type { HistoryItem } from "./history.js"
import type { ProviderSettingsEntry, ProviderSettings } from "./provider-settings.js"
import type { IpcMessage, IpcServerEvents } from "./ipc.js"
export type RooCodeAPIEvents = RooCodeEvents
export interface RooCodeAPI extends EventEmitter<RooCodeAPIEvents> {
/**
* Starts a new task with an optional initial message and images.
* @param task Optional initial task message.
* @param images Optional array of image data URIs (e.g., "data:image/webp;base64,...").
* @returns The ID of the new task.
*/
startNewTask({
configuration,
text,
images,
newTab,
}: {
configuration?: RooCodeSettings
text?: string
images?: string[]
newTab?: boolean
}): Promise<string>
/**
* Resumes a task with the given ID.
* @param taskId The ID of the task to resume.
* @throws Error if the task is not found in the task history.
*/
resumeTask(taskId: string): Promise<void>
/**
* Checks if a task with the given ID is in the task history.
* @param taskId The ID of the task to check.
* @returns True if the task is in the task history, false otherwise.
*/
isTaskInHistory(taskId: string): Promise<boolean>
/**
* Returns the HistoryItem for a task by ID. Intended for use in tests only.
* @param taskId The ID of the task.
* @returns The HistoryItem, or undefined if not found.
*/
getTaskHistoryItem(taskId: string): Promise<HistoryItem | undefined>
/**
* Returns the persisted API conversation history length for a task. Intended for use in tests only.
* @param taskId The ID of the task.
* @returns The number of persisted API conversation history entries, or 0 if unavailable.
*/
getTaskApiConversationHistoryLength(taskId: string): Promise<number>
/**
* Returns the current task stack.
* @returns An array of task IDs.
*/
getCurrentTaskStack(): string[]
/**
* Clears the current task.
*/
clearCurrentTask(lastMessage?: string): Promise<void>
/**
* Cancels the current task.
*/
cancelCurrentTask(): Promise<void>
/**
* Severs the delegated parent-child link for an interrupted (cancelled, not running)
* subtask, so the parent stops waiting on it and returns to "active". No-op (returns
* false) unless the child is interrupted and its parent is still delegated to it.
* @param childTaskId The ID of the child (subtask) to abandon.
* @returns True if the link was severed, false if there was nothing to abandon.
*/
abandonSubtask(childTaskId: string): Promise<boolean>
/**
* Sends a message to the current task.
* @param message Optional message to send.
* @param images Optional array of image data URIs (e.g., "data:image/webp;base64,...").
*/
sendMessage(message?: string, images?: string[]): Promise<void>
/**
* Simulates pressing the primary button in the chat interface.
*/
pressPrimaryButton(): Promise<void>
/**
* Simulates pressing the secondary button in the chat interface.
*/
pressSecondaryButton(): Promise<void>
/**
* Programmatically approves the current pending ask on the active task.
* Equivalent to the user clicking "Yes" for tool/command approvals, or
* confirming a completion result. No-ops if no task is active.
*/
approveCurrentAsk(): Promise<void>
/**
* Returns true if the API is ready to use.
*/
isReady(): boolean
/**
* Returns the current configuration.
* @returns The current configuration.
*/
getConfiguration(): RooCodeSettings
/**
* Sets the configuration for the current task.
* @param values An object containing key-value pairs to set.
*/
setConfiguration(values: RooCodeSettings): Promise<void>
/**
* Returns a list of all configured profile names
* @returns Array of profile names
*/
getProfiles(): string[]
/**
* Returns the profile entry for a given name
* @param name The name of the profile
* @returns The profile entry, or undefined if the profile does not exist
*/
getProfileEntry(name: string): ProviderSettingsEntry | undefined
/**
* Creates a new API configuration profile
* @param name The name of the profile
* @param profile The profile to create; defaults to an empty object
* @param activate Whether to activate the profile after creation; defaults to true
* @returns The ID of the created profile
* @throws Error if the profile already exists
*/
createProfile(name: string, profile?: ProviderSettings, activate?: boolean): Promise<string>
/**
* Updates an existing API configuration profile
* @param name The name of the profile
* @param profile The profile to update
* @param activate Whether to activate the profile after update; defaults to true
* @returns The ID of the updated profile
* @throws Error if the profile does not exist
*/
updateProfile(name: string, profile: ProviderSettings, activate?: boolean): Promise<string | undefined>
/**
* Creates a new API configuration profile or updates an existing one
* @param name The name of the profile
* @param profile The profile to create or update; defaults to an empty object
* @param activate Whether to activate the profile after upsert; defaults to true
* @returns The ID of the upserted profile
*/
upsertProfile(name: string, profile: ProviderSettings, activate?: boolean): Promise<string | undefined>
/**
* Deletes a profile by name
* @param name The name of the profile to delete
* @throws Error if the profile does not exist
*/
deleteProfile(name: string): Promise<void>
/**
* Returns the name of the currently active profile
* @returns The profile name, or undefined if no profile is active
*/
getActiveProfile(): string | undefined
/**
* Changes the active API configuration profile
* @param name The name of the profile to activate
* @throws Error if the profile does not exist
*/
setActiveProfile(name: string): Promise<string | undefined>
/**
* Activates a process-wide VS Code terminal profile override for Zoo Code
* commands. This is intended for trusted extension integrations.
* Passing undefined restores the VS Code default profile behavior and
* closes idle terminals so the next command starts fresh.
*/
setTerminalProfile(name: string | undefined): void
}
export interface RooCodeIpcServer extends EventEmitter<IpcServerEvents> {
listen(): void
broadcast(message: IpcMessage): void
send(client: string | Socket, message: IpcMessage): void
get socketPath(): string
get isListening(): boolean
}