-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcancelTaskHandler.ts
More file actions
25 lines (22 loc) · 842 Bytes
/
Copy pathcancelTaskHandler.ts
File metadata and controls
25 lines (22 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { logger } from './logger.js';
import { BridgeMessage } from './types.js';
import { HandlerContext } from './handlerContext.js';
export async function handleCancelTask(msg: BridgeMessage, ctx: HandlerContext): Promise<void> {
const { taskId, agentId } = msg;
if (!taskId) {
logger.warn('cancel_task.missing_task_id', { agentId });
return;
}
const provider = ctx.provider;
if (typeof provider.cancelRun !== 'function') {
logger.warn('cancel_task.not_supported', { agentId, taskId, provider: provider.constructor?.name });
return;
}
logger.info('cancel_task.received', { agentId, taskId });
try {
await provider.cancelRun(taskId);
logger.info('cancel_task.done', { agentId, taskId });
} catch (err: any) {
logger.error('cancel_task.error', { agentId, taskId, error: err.message });
}
}