Phase 1 run-control semantics and run_state events
This commit is contained in:
@@ -331,8 +331,9 @@ describe('createAgentHandlers command fast-path', () => {
|
||||
await handlers['agent.send'](req, send);
|
||||
|
||||
expect(mockAgent.process).toHaveBeenCalledWith('/not-a-real-command', undefined);
|
||||
expect((sent[0] as GatewayEvent).event).toBe('done');
|
||||
expect(((sent[0] as GatewayEvent).data as { content: string }).content).toBe('agent response');
|
||||
const doneEvent = sent.find((msg) => (msg as GatewayEvent).event === 'done') as GatewayEvent | undefined;
|
||||
expect(doneEvent).toBeTruthy();
|
||||
expect(((doneEvent as GatewayEvent).data as { content: string }).content).toBe('agent response');
|
||||
});
|
||||
|
||||
it('handles /approvals command via fast-path when hook engine is available', async () => {
|
||||
@@ -421,7 +422,7 @@ describe('createAgentHandlers command fast-path', () => {
|
||||
state: 'cancelled',
|
||||
}),
|
||||
);
|
||||
expect((sent[0] as GatewayEvent).event).toBe('done');
|
||||
expect(sent.some((msg) => (msg as GatewayEvent).event === 'done')).toBe(true);
|
||||
});
|
||||
|
||||
it('emits run.cancel telemetry for agent.cancel requests', async () => {
|
||||
@@ -429,7 +430,7 @@ describe('createAgentHandlers command fast-path', () => {
|
||||
id: 16,
|
||||
method: 'agent.cancel',
|
||||
params: { connectionId: 'conn-1' },
|
||||
});
|
||||
}, vi.fn());
|
||||
|
||||
expect(sessionBridge.cancel).toHaveBeenCalledWith('conn-1');
|
||||
expect(mockAuditLogger.runCancel).toHaveBeenCalledWith(
|
||||
@@ -492,9 +493,10 @@ describe('createAgentHandlers command fast-path', () => {
|
||||
params: { message: 'hello', connectionId: 'conn-1' },
|
||||
}, send);
|
||||
|
||||
expect(sent).toHaveLength(2);
|
||||
expect((sent[0] as GatewayEvent).event).toBe('context_warning');
|
||||
expect((sent[1] as GatewayEvent).event).toBe('done');
|
||||
const events = sent.map((msg) => (msg as GatewayEvent).event);
|
||||
expect(events).toContain('context_warning');
|
||||
expect(events).toContain('done');
|
||||
expect(events.indexOf('context_warning')).toBeLessThan(events.indexOf('done'));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -706,8 +708,9 @@ describe('createAgentHandlers queue policy resolution', () => {
|
||||
mode: 'interrupt',
|
||||
cancelled_active_run: true,
|
||||
}));
|
||||
expect((sent[0] as GatewayEvent).event).toBe('content');
|
||||
expect(((sent[0] as GatewayEvent).data as { text: string }).text).toContain('Interrupt mode');
|
||||
expect((sent[1] as GatewayEvent).event).toBe('done');
|
||||
const contentEvent = sent.find((msg) => (msg as GatewayEvent).event === 'content') as GatewayEvent | undefined;
|
||||
expect(contentEvent).toBeTruthy();
|
||||
expect(((contentEvent as GatewayEvent).data as { text: string }).text).toContain('Interrupt mode');
|
||||
expect(sent.some((msg) => (msg as GatewayEvent).event === 'done')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user