3d2b1c5e47
- Fix #25: job update sends schedule as plain string but upstream expects { kind, expr, display } object, causing "'str' object has no attribute 'get'" - Move hermes-cli.ts, hermes.ts, hermes-profile.ts into services/hermes/ for multi-agent namespacing consistency - Fix ts-node Set spread compatibility in filesystem.ts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
34 lines
756 B
TypeScript
34 lines
756 B
TypeScript
import Router from '@koa/router'
|
|
import { emitWebhook } from '../services/hermes/hermes'
|
|
|
|
export const webhookRoutes = new Router()
|
|
|
|
/**
|
|
* POST /webhook — receive callbacks from Hermes Agent
|
|
*
|
|
* Expected body:
|
|
* {
|
|
* "event": "run.completed" | "job.completed" | ...,
|
|
* "run_id": "...",
|
|
* "data": { ... }
|
|
* }
|
|
*
|
|
* TODO: Add signature verification when Hermes supports webhook signing
|
|
*/
|
|
webhookRoutes.post('/webhook', async (ctx) => {
|
|
const payload = ctx.request.body
|
|
|
|
if (!payload || !payload.event) {
|
|
ctx.status = 400
|
|
ctx.body = { error: 'Missing event field' }
|
|
return
|
|
}
|
|
|
|
console.log(`[Webhook] Received event: ${payload.event}`)
|
|
|
|
// Emit to registered callbacks
|
|
emitWebhook(payload)
|
|
|
|
ctx.body = { ok: true }
|
|
})
|