@@ -316,119 +316,6 @@ export class APIService {
316316 }
317317
318318
319- /**
320- * Update a step with new status and optional feedback
321- * @param sessionId Session ID
322- * @param planId Plan ID
323- * @param stepId Step ID
324- * @param update Update object with status and optional feedback
325- * @returns Promise with the updated step
326- */
327- async updateStep (
328- sessionId : string ,
329- planId : string ,
330- stepId : string ,
331- update : {
332- status : StepStatus ;
333- human_feedback ?: string ;
334- updated_action ?: string ;
335- }
336- ) : Promise < Step > {
337- const response = await this . provideStepFeedback (
338- stepId ,
339- planId ,
340- sessionId ,
341- update . status === StepStatus . APPROVED ,
342- update . human_feedback ,
343- update . updated_action
344- ) ;
345-
346- // Invalidate cached data
347- this . _cache . invalidate ( new RegExp ( `^(plan|steps)_${ planId } ` ) ) ;
348- this . _cache . invalidate ( new RegExp ( `^plans_` ) ) ;
349-
350- // Get fresh step data
351- const steps = await this . getSteps ( planId , false ) ; // Force fresh data
352- const updatedStep = steps . find ( step => step . id === stepId ) ;
353-
354- if ( ! updatedStep ) {
355- throw new Error ( `Step with ID ${ stepId } not found after update` ) ;
356- }
357-
358- return updatedStep ;
359- }
360-
361- /**
362- * Provide feedback for a specific step
363- * @param stepId Step ID
364- * @param planId Plan ID
365- * @param sessionId Session ID
366- * @param approved Whether the step is approved
367- * @param humanFeedback Optional human feedback
368- * @param updatedAction Optional updated action
369- * @returns Promise with response object
370- */
371- async provideStepFeedback (
372- stepId : string ,
373- planId : string ,
374- sessionId : string ,
375- approved : boolean ,
376- humanFeedback ?: string ,
377- updatedAction ?: string
378- ) : Promise < { status : string ; session_id : string ; step_id : string } > {
379- const response = await apiClient . post (
380- API_ENDPOINTS . HUMAN_FEEDBACK ,
381- {
382- step_id : stepId ,
383- plan_id : planId ,
384- session_id : sessionId ,
385- approved,
386- human_feedback : humanFeedback ,
387- updated_action : updatedAction
388- }
389- ) ;
390-
391- // Invalidate cached data
392- this . _cache . invalidate ( new RegExp ( `^(plan|steps)_${ planId } ` ) ) ;
393- this . _cache . invalidate ( new RegExp ( `^plans_` ) ) ;
394-
395- return response ;
396- }
397-
398-
399-
400- /**
401- * Approve one or more steps
402- * @param planId Plan ID
403- * @param sessionId Session ID
404- * @param approved Whether the step(s) are approved
405- * @param stepId Optional specific step ID
406- * @param humanFeedback Optional human feedback
407- * @param updatedAction Optional updated action
408- * @returns Promise with response object
409- */
410- async stepStatus (
411- planId : string ,
412- sessionId : string ,
413- approved : boolean ,
414- stepId ?: string ,
415- ) : Promise < { status : string } > {
416- const response = await apiClient . post (
417- API_ENDPOINTS . APPROVE_STEPS ,
418- {
419- step_id : stepId ,
420- plan_id : planId ,
421- session_id : sessionId ,
422- approved
423- }
424- ) ;
425-
426- // Invalidate cached data
427- this . _cache . invalidate ( new RegExp ( `^(plan|steps)_${ planId } ` ) ) ;
428- this . _cache . invalidate ( new RegExp ( `^plans_` ) ) ;
429-
430- return response ;
431- }
432319
433320 /**
434321 * Submit clarification for a plan
@@ -523,75 +410,14 @@ export class APIService {
523410 return fetcher ( ) ;
524411 }
525412
526- // Utility methods
527-
528- /**
529- * Check if a plan is complete (all steps are completed or failed)
530- * @param plan Plan with steps
531- * @returns Boolean indicating if plan is complete
532- */
533- isPlanComplete ( plan : PlanWithSteps ) : boolean {
534- return plan . steps . every ( step =>
535- [ StepStatus . COMPLETED , StepStatus . FAILED ] . includes ( step . status )
536- ) ;
537- }
538-
539- /**
540- * Get steps that are awaiting human feedback
541- * @param plan Plan with steps
542- * @returns Array of steps awaiting feedback
543- */
544- getStepsAwaitingFeedback ( plan : PlanWithSteps ) : Step [ ] {
545- return plan . steps . filter ( step => step . status === StepStatus . AWAITING_FEEDBACK ) ;
546- } /**
547- * Get steps assigned to a specific agent type
548- * @param plan Plan with steps
549- * @param agentType Agent type to filter by
550- * @returns Array of steps for the specified agent
551- */
552- getStepsForAgent ( plan : PlanWithSteps , agentType : AgentType ) : Step [ ] {
553- return plan . steps . filter ( step => step . agent === agentType ) ;
554- }
555-
556413 /**
557414 * Clear all cached data
558415 */
559416 clearCache ( ) : void {
560417 this . _cache . clear ( ) ;
561418 }
562419
563- /**
564- * Get progress status counts for a plan
565- * @param plan Plan with steps
566- * @returns Object with counts for each step status
567- */
568- getPlanProgressStatus ( plan : PlanWithSteps ) : Record < StepStatus , number > {
569- const result = Object . values ( StepStatus ) . reduce ( ( acc , status ) => {
570- acc [ status ] = 0 ;
571- return acc ;
572- } , { } as Record < StepStatus , number > ) ;
573-
574- plan . steps . forEach ( step => {
575- result [ step . status ] ++ ;
576- } ) ;
577420
578- return result ;
579- }
580-
581- /**
582- * Get completion percentage for a plan
583- * @param plan Plan with steps
584- * @returns Completion percentage (0-100)
585- */
586- getPlanCompletionPercentage ( plan : PlanWithSteps ) : number {
587- if ( ! plan . steps . length ) return 0 ;
588-
589- const completedSteps = plan . steps . filter (
590- step => [ StepStatus . COMPLETED , StepStatus . FAILED ] . includes ( step . status )
591- ) . length ;
592-
593- return Math . round ( ( completedSteps / plan . steps . length ) * 100 ) ;
594- }
595421
596422 /**
597423 * Send the user's browser language to the backend
0 commit comments