@@ -137,53 +137,53 @@ export class ApiMachineClient {
137137 effort
138138 } = params || { }
139139
140- if ( ! directory ) {
141- throw new Error ( 'Directory is required' )
142- }
140+ if ( ! directory ) {
141+ throw new Error ( 'Directory is required' )
142+ }
143143
144- const result = await spawnSession ( {
145- directory,
146- sessionId,
147- resumeSessionId,
148- machineId,
149- approvedNewDirectoryCreation,
150- agent,
151- model,
152- yolo,
153- token,
154- sessionType,
155- worktreeName,
156- effort
144+ const result = await spawnSession ( {
145+ directory,
146+ sessionId,
147+ resumeSessionId,
148+ machineId,
149+ approvedNewDirectoryCreation,
150+ agent,
151+ model,
152+ yolo,
153+ token,
154+ sessionType,
155+ worktreeName,
156+ effort
157+ } )
158+
159+ switch ( result . type ) {
160+ case 'success' :
161+ return { type : 'success' , sessionId : result . sessionId }
162+ case 'requestToApproveDirectoryCreation' :
163+ return { type : 'requestToApproveDirectoryCreation' , directory : result . directory }
164+ case 'error' :
165+ return { type : 'error' , errorMessage : result . errorMessage }
166+ default :
167+ // 兜底:未知 result.type
168+ throw new Error ( `Unknown result type: ${ String ( ( result as { type ?: string } ) . type ) } ` )
169+ }
157170 } )
158171
159- switch ( result . type ) {
160- case 'success' :
161- return { type : 'success' , sessionId : result . sessionId }
162- case 'requestToApproveDirectoryCreation' :
163- return { type : 'requestToApproveDirectoryCreation' , directory : result . directory }
164- case 'error' :
165- return { type : 'error' , errorMessage : result . errorMessage }
166- default :
167- // 兜底:未知 result.type
168- throw new Error ( `Unknown result type: ${ String ( ( result as { type ?: string } ) . type ) } ` )
169- }
170- } )
171-
172172 this . rpcHandlerManager . registerHandler < { sessionId ?: string } , { message : string } > (
173173 'stop-session' ,
174174 ( params ) => {
175175 const { sessionId } = params || { }
176- if ( ! sessionId ) {
177- throw new Error ( 'Session ID is required' )
178- }
176+ if ( ! sessionId ) {
177+ throw new Error ( 'Session ID is required' )
178+ }
179179
180- const success = stopSession ( sessionId )
181- if ( ! success ) {
182- throw new Error ( 'Session not found or failed to stop' )
183- }
180+ const success = stopSession ( sessionId )
181+ if ( ! success ) {
182+ throw new Error ( 'Session not found or failed to stop' )
183+ }
184184
185- return { message : 'Session stopped' }
186- } )
185+ return { message : 'Session stopped' }
186+ } )
187187
188188 this . rpcHandlerManager . registerHandler ( 'stop-runner' , ( ) => {
189189 setTimeout ( ( ) => requestShutdown ( ) , 100 )
0 commit comments