mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-06 08:18:39 +00:00
Get rid of VSCodeCommand
This commit is contained in:
parent
f06cd96da2
commit
6082ec2798
6 changed files with 25 additions and 86 deletions
|
|
@ -346,19 +346,14 @@ const runExercise = async ({ run, task, server }: { run: Run; task: Task; server
|
|||
|
||||
if (!isClientDisconnected) {
|
||||
try {
|
||||
client.sendMessage({
|
||||
type: IpcMessageType.VSCodeCommand,
|
||||
origin: IpcOrigin.Client,
|
||||
clientId: client.clientId!,
|
||||
data: "workbench.action.files.saveFiles",
|
||||
})
|
||||
|
||||
client.sendMessage({
|
||||
type: IpcMessageType.VSCodeCommand,
|
||||
origin: IpcOrigin.Client,
|
||||
clientId: client.clientId!,
|
||||
data: "workbench.action.closeWindow",
|
||||
})
|
||||
if (rooTaskId) {
|
||||
client.sendMessage({
|
||||
type: IpcMessageType.TaskCommand,
|
||||
origin: IpcOrigin.Client,
|
||||
clientId: client.clientId!,
|
||||
data: { commandName: TaskCommandName.CloseTask, data: rooTaskId },
|
||||
})
|
||||
}
|
||||
|
||||
client.disconnect()
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ type IpcServerEvents = {
|
|||
[IpcMessageType.Disconnect]: [clientId: string]
|
||||
[IpcMessageType.TaskCommand]: [clientId: string, data: TaskCommand]
|
||||
[IpcMessageType.TaskEvent]: [relayClientId: string | undefined, data: TaskEvent]
|
||||
[IpcMessageType.VSCodeCommand]: [clientId: string, data: string]
|
||||
}
|
||||
|
||||
export class IpcServer extends EventEmitter<IpcServerEvents> {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ export type Ack = z.infer<typeof ackSchema>
|
|||
export enum TaskCommandName {
|
||||
StartNewTask = "StartNewTask",
|
||||
CancelTask = "CancelTask",
|
||||
CloseTask = "CloseTask",
|
||||
}
|
||||
|
||||
export const taskCommandSchema = z.discriminatedUnion("commandName", [
|
||||
|
|
@ -37,6 +38,10 @@ export const taskCommandSchema = z.discriminatedUnion("commandName", [
|
|||
commandName: z.literal(TaskCommandName.CancelTask),
|
||||
data: z.string(),
|
||||
}),
|
||||
z.object({
|
||||
commandName: z.literal(TaskCommandName.CloseTask),
|
||||
data: z.string(),
|
||||
}),
|
||||
])
|
||||
|
||||
export type TaskCommand = z.infer<typeof taskCommandSchema>
|
||||
|
|
@ -115,7 +120,6 @@ export enum IpcMessageType {
|
|||
Ack = "Ack",
|
||||
TaskCommand = "TaskCommand",
|
||||
TaskEvent = "TaskEvent",
|
||||
VSCodeCommand = "VSCodeCommand",
|
||||
}
|
||||
|
||||
export enum IpcOrigin {
|
||||
|
|
@ -141,12 +145,6 @@ export const ipcMessageSchema = z.discriminatedUnion("type", [
|
|||
relayClientId: z.string().optional(),
|
||||
data: taskEventSchema,
|
||||
}),
|
||||
z.object({
|
||||
type: z.literal(IpcMessageType.VSCodeCommand),
|
||||
origin: z.literal(IpcOrigin.Client),
|
||||
clientId: z.string(),
|
||||
data: z.string(),
|
||||
}),
|
||||
])
|
||||
|
||||
export type IpcMessage = z.infer<typeof ipcMessageSchema>
|
||||
|
|
|
|||
|
|
@ -38,67 +38,20 @@ export class API extends EventEmitter<RooCodeEvents> implements RooCodeAPI {
|
|||
ipc.on(IpcMessageType.TaskCommand, async (_clientId, { commandName, data }) => {
|
||||
switch (commandName) {
|
||||
case TaskCommandName.StartNewTask:
|
||||
this.log(`[API] StartNewTask -> ${data.text}`)
|
||||
this.log(`[API] StartNewTask -> ${JSON.stringify(data.configuration)}`)
|
||||
|
||||
try {
|
||||
await this.startNewTask(data)
|
||||
|
||||
ipc.broadcast({
|
||||
type: IpcMessageType.TaskEvent,
|
||||
origin: IpcOrigin.Server,
|
||||
data: {
|
||||
eventName: RooCodeEventName.Message,
|
||||
payload: [
|
||||
{
|
||||
taskId: "[system]",
|
||||
action: "created",
|
||||
message: {
|
||||
ts: Date.now(),
|
||||
type: "say",
|
||||
text: `ACK: TaskCommand -> ${commandName}`,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
} catch (error) {
|
||||
this.log(`[API] error starting new task: ${error}`)
|
||||
}
|
||||
|
||||
this.log(`[API] StartNewTask -> ${data.text}, ${JSON.stringify(data.configuration)}`)
|
||||
await this.startNewTask(data)
|
||||
break
|
||||
case TaskCommandName.CancelTask:
|
||||
this.log(`[API] CancelTask -> ${data}`)
|
||||
|
||||
await this.cancelTask(data)
|
||||
|
||||
ipc.broadcast({
|
||||
type: IpcMessageType.TaskEvent,
|
||||
origin: IpcOrigin.Server,
|
||||
data: {
|
||||
eventName: RooCodeEventName.Message,
|
||||
payload: [
|
||||
{
|
||||
taskId: "[system]",
|
||||
action: "created",
|
||||
message: {
|
||||
ts: Date.now(),
|
||||
type: "say",
|
||||
text: `ACK: CancelTask -> ${data}`,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
break
|
||||
case TaskCommandName.CloseTask:
|
||||
this.log(`[API] CloseTask -> ${data}`)
|
||||
await vscode.commands.executeCommand("workbench.action.files.saveFiles")
|
||||
await vscode.commands.executeCommand("workbench.action.closeWindow")
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
ipc.on(IpcMessageType.VSCodeCommand, async (_clientId, command) => {
|
||||
this.log(`[API] VSCodeCommand -> ${command}`)
|
||||
await vscode.commands.executeCommand(command)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ type IpcServerEvents = {
|
|||
[IpcMessageType.Disconnect]: [clientId: string]
|
||||
[IpcMessageType.TaskCommand]: [clientId: string, data: TaskCommand]
|
||||
[IpcMessageType.TaskEvent]: [relayClientId: string | undefined, data: TaskEvent]
|
||||
[IpcMessageType.VSCodeCommand]: [clientId: string, data: string]
|
||||
}
|
||||
|
||||
export class IpcServer extends EventEmitter<IpcServerEvents> {
|
||||
|
|
@ -99,9 +98,6 @@ export class IpcServer extends EventEmitter<IpcServerEvents> {
|
|||
case IpcMessageType.TaskCommand:
|
||||
this.emit(IpcMessageType.TaskCommand, payload.clientId, payload.data)
|
||||
break
|
||||
case IpcMessageType.VSCodeCommand:
|
||||
this.emit(IpcMessageType.VSCodeCommand, payload.clientId, payload.data)
|
||||
break
|
||||
default:
|
||||
throw new Error(`[server#onMessage] unhandled payload: ${JSON.stringify(payload)}`)
|
||||
break
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ export type Ack = z.infer<typeof ackSchema>
|
|||
export enum TaskCommandName {
|
||||
StartNewTask = "StartNewTask",
|
||||
CancelTask = "CancelTask",
|
||||
CloseTask = "CloseTask",
|
||||
}
|
||||
|
||||
export const taskCommandSchema = z.discriminatedUnion("commandName", [
|
||||
|
|
@ -37,6 +38,10 @@ export const taskCommandSchema = z.discriminatedUnion("commandName", [
|
|||
commandName: z.literal(TaskCommandName.CancelTask),
|
||||
data: z.string(),
|
||||
}),
|
||||
z.object({
|
||||
commandName: z.literal(TaskCommandName.CloseTask),
|
||||
data: z.string(),
|
||||
}),
|
||||
])
|
||||
|
||||
export type TaskCommand = z.infer<typeof taskCommandSchema>
|
||||
|
|
@ -100,7 +105,6 @@ export enum IpcMessageType {
|
|||
Ack = "Ack",
|
||||
TaskCommand = "TaskCommand",
|
||||
TaskEvent = "TaskEvent",
|
||||
VSCodeCommand = "VSCodeCommand",
|
||||
}
|
||||
|
||||
export enum IpcOrigin {
|
||||
|
|
@ -126,12 +130,6 @@ export const ipcMessageSchema = z.discriminatedUnion("type", [
|
|||
relayClientId: z.string().optional(),
|
||||
data: taskEventSchema,
|
||||
}),
|
||||
z.object({
|
||||
type: z.literal(IpcMessageType.VSCodeCommand),
|
||||
origin: z.literal(IpcOrigin.Client),
|
||||
clientId: z.string(),
|
||||
data: z.string(),
|
||||
}),
|
||||
])
|
||||
|
||||
export type IpcMessage = z.infer<typeof ipcMessageSchema>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue