feat(11-01): update MockAgentManager for mode support
- Add context_complete scenario for discuss mode - Add breakdown_complete scenario for breakdown mode - Import Decision and PhaseBreakdown types from schema - Handle context_complete status with decisions array - Handle breakdown_complete status with phases array - Extend AgentStoppedEvent reason type for new completion reasons
This commit is contained in:
@@ -16,6 +16,7 @@ import type {
|
||||
PendingQuestions,
|
||||
QuestionItem,
|
||||
} from './types.js';
|
||||
import type { Decision, PhaseBreakdown } from './schema.js';
|
||||
import type {
|
||||
EventBus,
|
||||
AgentSpawnedEvent,
|
||||
@@ -28,8 +29,14 @@ import type {
|
||||
/**
|
||||
* Scenario configuration for mock agent behavior.
|
||||
* Uses discriminated union on status to match agent output schema.
|
||||
*
|
||||
* Supports all three agent modes:
|
||||
* - execute: done/questions/unrecoverable_error
|
||||
* - discuss: questions/context_complete/unrecoverable_error
|
||||
* - breakdown: questions/breakdown_complete/unrecoverable_error
|
||||
*/
|
||||
export type MockAgentScenario =
|
||||
// Execute mode statuses
|
||||
| {
|
||||
status: 'done';
|
||||
result?: string;
|
||||
@@ -46,6 +53,19 @@ export type MockAgentScenario =
|
||||
error: string;
|
||||
attempted?: string;
|
||||
delay?: number;
|
||||
}
|
||||
// Discuss mode status
|
||||
| {
|
||||
status: 'context_complete';
|
||||
decisions: Decision[];
|
||||
summary: string;
|
||||
delay?: number;
|
||||
}
|
||||
// Breakdown mode status
|
||||
| {
|
||||
status: 'breakdown_complete';
|
||||
phases: PhaseBreakdown[];
|
||||
delay?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -261,6 +281,54 @@ export class MockAgentManager implements AgentManager {
|
||||
this.eventBus.emit(event);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'context_complete':
|
||||
// Discuss mode completion - captured all decisions
|
||||
record.result = {
|
||||
success: true,
|
||||
message: scenario.summary,
|
||||
};
|
||||
record.info.status = 'idle';
|
||||
record.info.updatedAt = new Date();
|
||||
|
||||
if (this.eventBus) {
|
||||
const event: AgentStoppedEvent = {
|
||||
type: 'agent:stopped',
|
||||
timestamp: new Date(),
|
||||
payload: {
|
||||
agentId,
|
||||
name: info.name,
|
||||
taskId: info.taskId,
|
||||
reason: 'context_complete',
|
||||
},
|
||||
};
|
||||
this.eventBus.emit(event);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'breakdown_complete':
|
||||
// Breakdown mode completion - decomposed into phases
|
||||
record.result = {
|
||||
success: true,
|
||||
message: `Decomposed into ${scenario.phases.length} phases`,
|
||||
};
|
||||
record.info.status = 'idle';
|
||||
record.info.updatedAt = new Date();
|
||||
|
||||
if (this.eventBus) {
|
||||
const event: AgentStoppedEvent = {
|
||||
type: 'agent:stopped',
|
||||
timestamp: new Date(),
|
||||
payload: {
|
||||
agentId,
|
||||
name: info.name,
|
||||
taskId: info.taskId,
|
||||
reason: 'breakdown_complete',
|
||||
},
|
||||
};
|
||||
this.eventBus.emit(event);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,13 @@ export interface AgentStoppedEvent extends DomainEvent {
|
||||
agentId: string;
|
||||
name: string;
|
||||
taskId: string;
|
||||
reason: 'user_requested' | 'task_complete' | 'error' | 'waiting_for_input';
|
||||
reason:
|
||||
| 'user_requested'
|
||||
| 'task_complete'
|
||||
| 'error'
|
||||
| 'waiting_for_input'
|
||||
| 'context_complete'
|
||||
| 'breakdown_complete';
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user