|
@@ -1,59 +1,37 @@
|
|
|
-import { EventEmitter } from "events"
|
|
|
|
|
-import { Socket } from "node:net"
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * Types
|
|
|
|
|
- */
|
|
|
|
|
|
|
+import type { EventEmitter } from "events"
|
|
|
|
|
+import type { Socket } from "net"
|
|
|
|
|
|
|
|
import type {
|
|
import type {
|
|
|
- GlobalSettings,
|
|
|
|
|
- ProviderName,
|
|
|
|
|
- ProviderSettings,
|
|
|
|
|
|
|
+ RooCodeSettings,
|
|
|
ProviderSettingsEntry,
|
|
ProviderSettingsEntry,
|
|
|
- ClineMessage,
|
|
|
|
|
- TokenUsage,
|
|
|
|
|
- RooCodeEvents,
|
|
|
|
|
- IpcMessage,
|
|
|
|
|
- TaskCommand,
|
|
|
|
|
- TaskEvent,
|
|
|
|
|
-} from "./types"
|
|
|
|
|
-
|
|
|
|
|
-export type {
|
|
|
|
|
- GlobalSettings,
|
|
|
|
|
- ProviderName,
|
|
|
|
|
ProviderSettings,
|
|
ProviderSettings,
|
|
|
- ProviderSettingsEntry,
|
|
|
|
|
ClineMessage,
|
|
ClineMessage,
|
|
|
TokenUsage,
|
|
TokenUsage,
|
|
|
- RooCodeEvents,
|
|
|
|
|
- IpcMessage,
|
|
|
|
|
|
|
+ ToolUsage,
|
|
|
|
|
+ ToolName,
|
|
|
TaskCommand,
|
|
TaskCommand,
|
|
|
TaskEvent,
|
|
TaskEvent,
|
|
|
|
|
+ IpcMessage,
|
|
|
|
|
+} from "./index.js"
|
|
|
|
|
+import { IpcMessageType } from "./index.js"
|
|
|
|
|
+
|
|
|
|
|
+// TODO: Make sure this matches `RooCodeEvents` from `@roo-code/types`.
|
|
|
|
|
+export interface RooCodeAPIEvents {
|
|
|
|
|
+ message: [data: { taskId: string; action: "created" | "updated"; message: ClineMessage }]
|
|
|
|
|
+ taskCreated: [taskId: string]
|
|
|
|
|
+ taskStarted: [taskId: string]
|
|
|
|
|
+ taskModeSwitched: [taskId: string, mode: string]
|
|
|
|
|
+ taskPaused: [taskId: string]
|
|
|
|
|
+ taskUnpaused: [taskId: string]
|
|
|
|
|
+ taskAskResponded: [taskId: string]
|
|
|
|
|
+ taskAborted: [taskId: string]
|
|
|
|
|
+ taskSpawned: [parentTaskId: string, childTaskId: string]
|
|
|
|
|
+ taskCompleted: [taskId: string, tokenUsage: TokenUsage, toolUsage: ToolUsage]
|
|
|
|
|
+ taskTokenUsageUpdated: [taskId: string, tokenUsage: TokenUsage]
|
|
|
|
|
+ taskToolFailed: [taskId: string, toolName: ToolName, error: string]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
- * Enums
|
|
|
|
|
- */
|
|
|
|
|
-
|
|
|
|
|
-import { RooCodeEventName, IpcOrigin, IpcMessageType } from "../schemas"
|
|
|
|
|
-
|
|
|
|
|
-export { RooCodeEventName, IpcOrigin, IpcMessageType }
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * Constants
|
|
|
|
|
- */
|
|
|
|
|
-
|
|
|
|
|
-import { providerNames, Package } from "../schemas"
|
|
|
|
|
-
|
|
|
|
|
-export { providerNames, Package }
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * RooCodeAPI
|
|
|
|
|
- */
|
|
|
|
|
-
|
|
|
|
|
-export type RooCodeSettings = GlobalSettings & ProviderSettings
|
|
|
|
|
-
|
|
|
|
|
-export interface RooCodeAPI extends EventEmitter<RooCodeEvents> {
|
|
|
|
|
|
|
+export interface RooCodeAPI extends EventEmitter<RooCodeAPIEvents> {
|
|
|
/**
|
|
/**
|
|
|
* Starts a new task with an optional initial message and images.
|
|
* Starts a new task with an optional initial message and images.
|
|
|
* @param task Optional initial task message.
|
|
* @param task Optional initial task message.
|
|
@@ -71,84 +49,70 @@ export interface RooCodeAPI extends EventEmitter<RooCodeEvents> {
|
|
|
images?: string[]
|
|
images?: string[]
|
|
|
newTab?: boolean
|
|
newTab?: boolean
|
|
|
}): Promise<string>
|
|
}): Promise<string>
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Resumes a task with the given ID.
|
|
* Resumes a task with the given ID.
|
|
|
* @param taskId The ID of the task to resume.
|
|
* @param taskId The ID of the task to resume.
|
|
|
* @throws Error if the task is not found in the task history.
|
|
* @throws Error if the task is not found in the task history.
|
|
|
*/
|
|
*/
|
|
|
resumeTask(taskId: string): Promise<void>
|
|
resumeTask(taskId: string): Promise<void>
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Checks if a task with the given ID is in the task history.
|
|
* Checks if a task with the given ID is in the task history.
|
|
|
* @param taskId The ID of the task to check.
|
|
* @param taskId The ID of the task to check.
|
|
|
* @returns True if the task is in the task history, false otherwise.
|
|
* @returns True if the task is in the task history, false otherwise.
|
|
|
*/
|
|
*/
|
|
|
isTaskInHistory(taskId: string): Promise<boolean>
|
|
isTaskInHistory(taskId: string): Promise<boolean>
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Returns the current task stack.
|
|
* Returns the current task stack.
|
|
|
* @returns An array of task IDs.
|
|
* @returns An array of task IDs.
|
|
|
*/
|
|
*/
|
|
|
getCurrentTaskStack(): string[]
|
|
getCurrentTaskStack(): string[]
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Clears the current task.
|
|
* Clears the current task.
|
|
|
*/
|
|
*/
|
|
|
clearCurrentTask(lastMessage?: string): Promise<void>
|
|
clearCurrentTask(lastMessage?: string): Promise<void>
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Cancels the current task.
|
|
* Cancels the current task.
|
|
|
*/
|
|
*/
|
|
|
cancelCurrentTask(): Promise<void>
|
|
cancelCurrentTask(): Promise<void>
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Sends a message to the current task.
|
|
* Sends a message to the current task.
|
|
|
* @param message Optional message to send.
|
|
* @param message Optional message to send.
|
|
|
* @param images Optional array of image data URIs (e.g., "data:image/webp;base64,...").
|
|
* @param images Optional array of image data URIs (e.g., "data:image/webp;base64,...").
|
|
|
*/
|
|
*/
|
|
|
sendMessage(message?: string, images?: string[]): Promise<void>
|
|
sendMessage(message?: string, images?: string[]): Promise<void>
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Simulates pressing the primary button in the chat interface.
|
|
* Simulates pressing the primary button in the chat interface.
|
|
|
*/
|
|
*/
|
|
|
pressPrimaryButton(): Promise<void>
|
|
pressPrimaryButton(): Promise<void>
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Simulates pressing the secondary button in the chat interface.
|
|
* Simulates pressing the secondary button in the chat interface.
|
|
|
*/
|
|
*/
|
|
|
pressSecondaryButton(): Promise<void>
|
|
pressSecondaryButton(): Promise<void>
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Returns true if the API is ready to use.
|
|
* Returns true if the API is ready to use.
|
|
|
*/
|
|
*/
|
|
|
isReady(): boolean
|
|
isReady(): boolean
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Returns the current configuration.
|
|
* Returns the current configuration.
|
|
|
* @returns The current configuration.
|
|
* @returns The current configuration.
|
|
|
*/
|
|
*/
|
|
|
getConfiguration(): RooCodeSettings
|
|
getConfiguration(): RooCodeSettings
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Sets the configuration for the current task.
|
|
* Sets the configuration for the current task.
|
|
|
* @param values An object containing key-value pairs to set.
|
|
* @param values An object containing key-value pairs to set.
|
|
|
*/
|
|
*/
|
|
|
setConfiguration(values: RooCodeSettings): Promise<void>
|
|
setConfiguration(values: RooCodeSettings): Promise<void>
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Returns a list of all configured profile names
|
|
* Returns a list of all configured profile names
|
|
|
* @returns Array of profile names
|
|
* @returns Array of profile names
|
|
|
*/
|
|
*/
|
|
|
getProfiles(): string[]
|
|
getProfiles(): string[]
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Returns the profile entry for a given name
|
|
* Returns the profile entry for a given name
|
|
|
* @param name The name of the profile
|
|
* @param name The name of the profile
|
|
|
* @returns The profile entry, or undefined if the profile does not exist
|
|
* @returns The profile entry, or undefined if the profile does not exist
|
|
|
*/
|
|
*/
|
|
|
getProfileEntry(name: string): ProviderSettingsEntry | undefined
|
|
getProfileEntry(name: string): ProviderSettingsEntry | undefined
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Creates a new API configuration profile
|
|
* Creates a new API configuration profile
|
|
|
* @param name The name of the profile
|
|
* @param name The name of the profile
|
|
@@ -158,7 +122,6 @@ export interface RooCodeAPI extends EventEmitter<RooCodeEvents> {
|
|
|
* @throws Error if the profile already exists
|
|
* @throws Error if the profile already exists
|
|
|
*/
|
|
*/
|
|
|
createProfile(name: string, profile?: ProviderSettings, activate?: boolean): Promise<string>
|
|
createProfile(name: string, profile?: ProviderSettings, activate?: boolean): Promise<string>
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Updates an existing API configuration profile
|
|
* Updates an existing API configuration profile
|
|
|
* @param name The name of the profile
|
|
* @param name The name of the profile
|
|
@@ -168,7 +131,6 @@ export interface RooCodeAPI extends EventEmitter<RooCodeEvents> {
|
|
|
* @throws Error if the profile does not exist
|
|
* @throws Error if the profile does not exist
|
|
|
*/
|
|
*/
|
|
|
updateProfile(name: string, profile: ProviderSettings, activate?: boolean): Promise<string | undefined>
|
|
updateProfile(name: string, profile: ProviderSettings, activate?: boolean): Promise<string | undefined>
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Creates a new API configuration profile or updates an existing one
|
|
* Creates a new API configuration profile or updates an existing one
|
|
|
* @param name The name of the profile
|
|
* @param name The name of the profile
|
|
@@ -177,20 +139,17 @@ export interface RooCodeAPI extends EventEmitter<RooCodeEvents> {
|
|
|
* @returns The ID of the upserted profile
|
|
* @returns The ID of the upserted profile
|
|
|
*/
|
|
*/
|
|
|
upsertProfile(name: string, profile: ProviderSettings, activate?: boolean): Promise<string | undefined>
|
|
upsertProfile(name: string, profile: ProviderSettings, activate?: boolean): Promise<string | undefined>
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Deletes a profile by name
|
|
* Deletes a profile by name
|
|
|
* @param name The name of the profile to delete
|
|
* @param name The name of the profile to delete
|
|
|
* @throws Error if the profile does not exist
|
|
* @throws Error if the profile does not exist
|
|
|
*/
|
|
*/
|
|
|
deleteProfile(name: string): Promise<void>
|
|
deleteProfile(name: string): Promise<void>
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Returns the name of the currently active profile
|
|
* Returns the name of the currently active profile
|
|
|
* @returns The profile name, or undefined if no profile is active
|
|
* @returns The profile name, or undefined if no profile is active
|
|
|
*/
|
|
*/
|
|
|
getActiveProfile(): string | undefined
|
|
getActiveProfile(): string | undefined
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Changes the active API configuration profile
|
|
* Changes the active API configuration profile
|
|
|
* @param name The name of the profile to activate
|
|
* @param name The name of the profile to activate
|
|
@@ -199,10 +158,6 @@ export interface RooCodeAPI extends EventEmitter<RooCodeEvents> {
|
|
|
setActiveProfile(name: string): Promise<string | undefined>
|
|
setActiveProfile(name: string): Promise<string | undefined>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
- * RooCodeIpcServer
|
|
|
|
|
- */
|
|
|
|
|
-
|
|
|
|
|
export type IpcServerEvents = {
|
|
export type IpcServerEvents = {
|
|
|
[IpcMessageType.Connect]: [clientId: string]
|
|
[IpcMessageType.Connect]: [clientId: string]
|
|
|
[IpcMessageType.Disconnect]: [clientId: string]
|
|
[IpcMessageType.Disconnect]: [clientId: string]
|
|
@@ -212,12 +167,8 @@ export type IpcServerEvents = {
|
|
|
|
|
|
|
|
export interface RooCodeIpcServer extends EventEmitter<IpcServerEvents> {
|
|
export interface RooCodeIpcServer extends EventEmitter<IpcServerEvents> {
|
|
|
listen(): void
|
|
listen(): void
|
|
|
-
|
|
|
|
|
broadcast(message: IpcMessage): void
|
|
broadcast(message: IpcMessage): void
|
|
|
-
|
|
|
|
|
send(client: string | Socket, message: IpcMessage): void
|
|
send(client: string | Socket, message: IpcMessage): void
|
|
|
-
|
|
|
|
|
get socketPath(): string
|
|
get socketPath(): string
|
|
|
-
|
|
|
|
|
get isListening(): boolean
|
|
get isListening(): boolean
|
|
|
}
|
|
}
|