Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/types/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export interface RooCodeAPIEvents {
message: [data: { taskId: string; action: "created" | "updated"; message: ClineMessage }]
taskCreated: [taskId: string]
taskStarted: [taskId: string]
taskModeSwitched: [taskId: string, mode: string]
taskAgentSwitched: [taskId: string, agent: string]
taskModeSwitched: [taskId: string, mode: string] // Backward compatibility alias
taskPaused: [taskId: string]
taskUnpaused: [taskId: string]
taskAskResponded: [taskId: string]
Expand Down
11 changes: 7 additions & 4 deletions packages/types/src/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export enum RooCodeEventName {
Message = "message",
TaskCreated = "taskCreated",
TaskStarted = "taskStarted",
TaskModeSwitched = "taskModeSwitched",
TaskAgentSwitched = "taskAgentSwitched",
TaskPaused = "taskPaused",
TaskUnpaused = "taskUnpaused",
TaskAskResponded = "taskAskResponded",
Expand All @@ -33,6 +33,9 @@ export enum RooCodeEventName {
EvalFail = "evalFail",
}

// Backward compatibility alias
export const TaskModeSwitched = RooCodeEventName.TaskAgentSwitched

export const rooCodeEventsSchema = z.object({
[RooCodeEventName.Message]: z.tuple([
z.object({
Expand All @@ -43,7 +46,7 @@ export const rooCodeEventsSchema = z.object({
]),
[RooCodeEventName.TaskCreated]: z.tuple([z.string()]),
[RooCodeEventName.TaskStarted]: z.tuple([z.string()]),
[RooCodeEventName.TaskModeSwitched]: z.tuple([z.string(), z.string()]),
[RooCodeEventName.TaskAgentSwitched]: z.tuple([z.string(), z.string()]),
[RooCodeEventName.TaskPaused]: z.tuple([z.string()]),
[RooCodeEventName.TaskUnpaused]: z.tuple([z.string()]),
[RooCodeEventName.TaskAskResponded]: z.tuple([z.string()]),
Expand Down Expand Up @@ -121,8 +124,8 @@ export const taskEventSchema = z.discriminatedUnion("eventName", [
taskId: z.number().optional(),
}),
z.object({
eventName: z.literal(RooCodeEventName.TaskModeSwitched),
payload: rooCodeEventsSchema.shape[RooCodeEventName.TaskModeSwitched],
eventName: z.literal(RooCodeEventName.TaskAgentSwitched),
payload: rooCodeEventsSchema.shape[RooCodeEventName.TaskAgentSwitched],
taskId: z.number().optional(),
}),
z.object({
Expand Down
37 changes: 26 additions & 11 deletions packages/types/src/mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const groupEntrySchema = z.union([toolGroupsSchema, z.tuple([toolGroupsSc
export type GroupEntry = z.infer<typeof groupEntrySchema>

/**
* ModeConfig
* AgentConfig
*/

const groupEntryArraySchema = z.array(groupEntrySchema).refine(
Expand All @@ -61,7 +61,7 @@ const groupEntryArraySchema = z.array(groupEntrySchema).refine(
{ message: "Duplicate groups are not allowed" },
)

export const modeConfigSchema = z.object({
export const agentConfigSchema = z.object({
slug: z.string().regex(/^[a-zA-Z0-9-]+$/, "Slug must contain only letters numbers and dashes"),
name: z.string().min(1, "Name is required"),
roleDefinition: z.string().min(1, "Role definition is required"),
Expand All @@ -72,14 +72,18 @@ export const modeConfigSchema = z.object({
source: z.enum(["global", "project"]).optional(),
})

export type ModeConfig = z.infer<typeof modeConfigSchema>
export type AgentConfig = z.infer<typeof agentConfigSchema>

// Keep ModeConfig as an alias for backward compatibility (will be removed in later phase)
export const modeConfigSchema = agentConfigSchema
export type ModeConfig = AgentConfig

/**
* CustomModesSettings
* CustomAgentsSettings
*/

export const customModesSettingsSchema = z.object({
customModes: z.array(modeConfigSchema).refine(
export const customAgentsSettingsSchema = z.object({
customModes: z.array(agentConfigSchema).refine(
(modes) => {
const slugs = new Set()

Expand All @@ -98,7 +102,11 @@ export const customModesSettingsSchema = z.object({
),
})

export type CustomModesSettings = z.infer<typeof customModesSettingsSchema>
export type CustomAgentsSettings = z.infer<typeof customAgentsSettingsSchema>

// Keep CustomModesSettings as an alias for backward compatibility (will be removed in later phase)
export const customModesSettingsSchema = customAgentsSettingsSchema
export type CustomModesSettings = CustomAgentsSettings

/**
* PromptComponent
Expand All @@ -114,12 +122,16 @@ export const promptComponentSchema = z.object({
export type PromptComponent = z.infer<typeof promptComponentSchema>

/**
* CustomModePrompts
* CustomAgentPrompts
*/

export const customModePromptsSchema = z.record(z.string(), promptComponentSchema.optional())
export const customAgentPromptsSchema = z.record(z.string(), promptComponentSchema.optional())

export type CustomModePrompts = z.infer<typeof customModePromptsSchema>
export type CustomAgentPrompts = z.infer<typeof customAgentPromptsSchema>

// Keep CustomModePrompts as an alias for backward compatibility (will be removed in later phase)
export const customModePromptsSchema = customAgentPromptsSchema
export type CustomModePrompts = CustomAgentPrompts

/**
* CustomSupportPrompts
Expand All @@ -133,7 +145,7 @@ export type CustomSupportPrompts = z.infer<typeof customSupportPromptsSchema>
* DEFAULT_MODES
*/

export const DEFAULT_MODES: readonly ModeConfig[] = [
export const DEFAULT_AGENTS: readonly AgentConfig[] = [
{
slug: "architect",
name: "🏗️ Architect",
Expand Down Expand Up @@ -193,3 +205,6 @@ export const DEFAULT_MODES: readonly ModeConfig[] = [
"Your role is to coordinate complex workflows by delegating tasks to specialized modes. As an orchestrator, you should:\n\n1. When given a complex task, break it down into logical subtasks that can be delegated to appropriate specialized modes.\n\n2. For each subtask, use the `new_task` tool to delegate. Choose the most appropriate mode for the subtask's specific goal and provide comprehensive instructions in the `message` parameter. These instructions must include:\n * All necessary context from the parent task or previous subtasks required to complete the work.\n * A clearly defined scope, specifying exactly what the subtask should accomplish.\n * An explicit statement that the subtask should *only* perform the work outlined in these instructions and not deviate.\n * An instruction for the subtask to signal completion by using the `attempt_completion` tool, providing a concise yet thorough summary of the outcome in the `result` parameter, keeping in mind that this summary will be the source of truth used to keep track of what was completed on this project.\n * A statement that these specific instructions supersede any conflicting general instructions the subtask's mode might have.\n\n3. Track and manage the progress of all subtasks. When a subtask is completed, analyze its results and determine the next steps.\n\n4. Help the user understand how the different subtasks fit together in the overall workflow. Provide clear reasoning about why you're delegating specific tasks to specific modes.\n\n5. When all subtasks are completed, synthesize the results and provide a comprehensive overview of what was accomplished.\n\n6. Ask clarifying questions when necessary to better understand how to break down complex tasks effectively.\n\n7. Suggest improvements to the workflow based on the results of completed subtasks.\n\nUse subtasks to maintain clarity. If a request significantly shifts focus or requires a different expertise (mode), consider creating a subtask rather than overloading the current one.",
},
] as const

// Keep DEFAULT_MODES as an alias for backward compatibility (will be removed in later phase)
export const DEFAULT_MODES = DEFAULT_AGENTS
14 changes: 7 additions & 7 deletions src/core/assistant-message/presentAssistantMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { serializeError } from "serialize-error"
import type { ToolName, ClineAsk, ToolProgressStatus } from "@roo-code/types"
import { TelemetryService } from "@roo-code/telemetry"

import { defaultModeSlug, getModeBySlug } from "../../shared/modes"
import { defaultAgentSlug, getAgentBySlug } from "../../shared/agents"
import type { ToolParamName, ToolResponse } from "../../shared/tools"

import { fetchInstructionsTool } from "../tools/fetchInstructionsTool"
Expand Down Expand Up @@ -209,10 +209,10 @@ export async function presentAssistantMessage(cline: Task) {
case "update_todo_list":
return `[${block.name}]`
case "new_task": {
const mode = block.params.mode ?? defaultModeSlug
const agent = block.params.mode ?? defaultAgentSlug
const message = block.params.message ?? "(no message)"
const modeName = getModeBySlug(mode, customModes)?.name ?? mode
return `[${block.name} in ${modeName} mode: '${message}']`
// We'll get the custom agents when we actually need them
return `[${block.name} in ${agent} agent: '${message}']`
}
}
}
Expand Down Expand Up @@ -352,13 +352,13 @@ export async function presentAssistantMessage(cline: Task) {
}

// Validate tool use before execution.
const { mode, customModes } = (await cline.providerRef.deref()?.getState()) ?? {}
const { mode: agent, customModes: customAgents } = (await cline.providerRef.deref()?.getState()) ?? {}

try {
validateToolUse(
block.name as ToolName,
mode ?? defaultModeSlug,
customModes ?? [],
agent ?? defaultAgentSlug,
customAgents ?? [],
{ apply_diff: cline.diffEnabled },
block.params,
)
Expand Down
Loading
Loading