feat: pass through approval.request events + approval endpoint
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 38s
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 38s
This commit is contained in:
parent
fc2725b5df
commit
2753063b6f
@ -34,8 +34,18 @@ export class AdminAiChatController {
|
||||
@AdminRoles('SUPER_ADMIN' as AdminRole)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: '停止正在运行的 AI 任务' })
|
||||
async stopChat(@Body('runId') runId: string) {
|
||||
return this.aiChatService.stopRun(runId);
|
||||
async stopChat(@Body() body: { runId: string; action?: string }) {
|
||||
if (body.action) {
|
||||
// Approval action: forward to Hermes
|
||||
try {
|
||||
await fetch(`http://10.2.0.7:8642/v1/runs/${body.runId}/approval`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Authorization: 'Bearer zhixi-hermes-key-2026' },
|
||||
body: JSON.stringify({ choice: body.action }),
|
||||
});
|
||||
} catch {}
|
||||
}
|
||||
return this.aiChatService.stopRun(body.runId);
|
||||
}
|
||||
|
||||
@Get('dashboard')
|
||||
|
||||
@ -143,6 +143,13 @@ export class AdminAiChatService {
|
||||
res.write(`data: ${JSON.stringify({ ...event, runId })}\n\n`);
|
||||
|
||||
// Forward tool events
|
||||
if (event.event === 'approval.request') {
|
||||
res.write(`data: ${JSON.stringify({ event: 'approval.request', command: (event as any).command, description: (event as any).description, choices: (event as any).choices, runId: runId })}
|
||||
|
||||
`);
|
||||
// Wait for approval — frontend calls /stop endpoint which we use for this
|
||||
break;
|
||||
}
|
||||
if (event.event === 'tool.started' || event.event === 'tool.completed') {
|
||||
res.write(`data: ${JSON.stringify({ event: event.event, tool: (event as any).tool, preview: (event as any).preview, duration: (event as any).duration, error: (event as any).error })}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user