Changeset 0.27.3 (#170)

This commit is contained in:
2026-03-11 09:12:57 +00:00
parent dcb915555e
commit a46ec63464
14 changed files with 561 additions and 110 deletions

View File

@@ -22,6 +22,7 @@ import (
"git.gobha.me/xcaliber/chat-switchboard/providers"
"git.gobha.me/xcaliber/chat-switchboard/store"
"git.gobha.me/xcaliber/chat-switchboard/tools"
"git.gobha.me/xcaliber/chat-switchboard/webhook"
)
// Executor runs task completions headlessly (no HTTP client).
@@ -200,6 +201,19 @@ func (e *Executor) Execute(ctx context.Context, task models.Task, run *models.Ta
// ── 9. Owner notification ──────────────────
e.notifyOwner(ctx, task, status, errMsg)
// ── 10. Webhook delivery (v0.27.3) ─────────
if task.WebhookURL != "" {
go webhook.Deliver(task.WebhookURL, task.WebhookSecret, webhook.Payload{
TaskID: task.ID,
TaskName: task.Name,
ChannelID: channelID,
Status: status,
CompletedAt: time.Now().UTC(),
Output: result.Content,
Error: errMsg,
})
}
}
// failRun marks a run as failed before completion was attempted.
@@ -207,6 +221,15 @@ func (e *Executor) failRun(ctx context.Context, task models.Task, run *models.Ta
log.Printf("[executor] Task %s (%s) pre-execution failure: %s", task.ID, task.Name, errMsg)
_ = e.stores.Tasks.UpdateRun(ctx, run.ID, "failed", 0, 0, 0, errMsg)
e.notifyOwner(ctx, task, "failed", errMsg)
if task.WebhookURL != "" {
go webhook.Deliver(task.WebhookURL, task.WebhookSecret, webhook.Payload{
TaskID: task.ID,
TaskName: task.Name,
Status: "failed",
CompletedAt: time.Now().UTC(),
Error: errMsg,
})
}
}
// notifyOwner sends a notification based on task outcome and preferences.