@@ -14,6 +14,14 @@ import { handleSweepCommand } from "./commands/sweep"
1414import { handleManualToggleCommand , handleManualTriggerCommand } from "./commands/manual"
1515import { ensureSessionInitialized } from "./state/state"
1616import { getCurrentParams } from "./strategies/utils"
17+ import {
18+ DCPContextHandledError ,
19+ DCPStatsHandledError ,
20+ DCPSweepHandledError ,
21+ DCPManualHandledError ,
22+ DCPManualTriggerBlockedError ,
23+ DCPHelpHandledError ,
24+ } from "./errors"
1725
1826const INTERNAL_AGENT_SIGNATURES = [
1927 "You are a title generator" ,
@@ -172,12 +180,12 @@ export function createCommandExecuteHandler(
172180
173181 if ( subcommand === "context" ) {
174182 await handleContextCommand ( commandCtx )
175- throw new Error ( "__DCP_CONTEXT_HANDLED__" )
183+ throw new DCPContextHandledError ( )
176184 }
177185
178186 if ( subcommand === "stats" ) {
179187 await handleStatsCommand ( commandCtx )
180- throw new Error ( "__DCP_STATS_HANDLED__" )
188+ throw new DCPStatsHandledError ( )
181189 }
182190
183191 if ( subcommand === "sweep" ) {
@@ -186,12 +194,12 @@ export function createCommandExecuteHandler(
186194 args : subArgs ,
187195 workingDirectory,
188196 } )
189- throw new Error ( "__DCP_SWEEP_HANDLED__" )
197+ throw new DCPSweepHandledError ( )
190198 }
191199
192200 if ( subcommand === "manual" ) {
193201 await handleManualToggleCommand ( commandCtx , subArgs [ 0 ] ?. toLowerCase ( ) )
194- throw new Error ( "__DCP_MANUAL_HANDLED__" )
202+ throw new DCPManualHandledError ( )
195203 }
196204
197205 if (
@@ -201,7 +209,7 @@ export function createCommandExecuteHandler(
201209 const userFocus = subArgs . join ( " " ) . trim ( )
202210 const prompt = await handleManualTriggerCommand ( commandCtx , subcommand , userFocus )
203211 if ( ! prompt ) {
204- throw new Error ( "__DCP_MANUAL_TRIGGER_BLOCKED__" )
212+ throw new DCPManualTriggerBlockedError ( )
205213 }
206214
207215 state . pendingManualTrigger = {
@@ -218,7 +226,7 @@ export function createCommandExecuteHandler(
218226 }
219227
220228 await handleHelpCommand ( commandCtx )
221- throw new Error ( "__DCP_HELP_HANDLED__" )
229+ throw new DCPHelpHandledError ( )
222230 }
223231 }
224232}
0 commit comments