Changeset 0.27.4 (#171)
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"git.gobha.me/xcaliber/chat-switchboard/notifications"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/providers"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/store"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/taskutil"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/tools"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/webhook"
|
||||
)
|
||||
@@ -59,6 +60,15 @@ func (e *Executor) Execute(ctx context.Context, task models.Task, run *models.Ta
|
||||
return
|
||||
}
|
||||
|
||||
// v0.27.4: Enforce personal_require_byok — personal tasks must use BYOK provider
|
||||
if task.Scope == "personal" && res.ProviderScope != "personal" {
|
||||
cfg := taskutil.LoadTaskConfig(ctx, e.stores.GlobalConfig)
|
||||
if cfg.PersonalRequireBYOK {
|
||||
e.failRun(ctx, task, run, "personal tasks require a BYOK provider — add an API key in Settings → Providers")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
provider, err := providers.Get(res.ProviderID)
|
||||
if err != nil {
|
||||
e.failRun(ctx, task, run, "provider unavailable: "+err.Error())
|
||||
@@ -162,16 +172,36 @@ func (e *Executor) Execute(ctx context.Context, task models.Task, run *models.Ta
|
||||
Streaming: false, // headless — use ChatCompletion
|
||||
}, sink)
|
||||
|
||||
// ── 6. Persist assistant response ──────────
|
||||
// ── 6. Persist output based on output_mode ──
|
||||
wallClock := int(time.Since(startTime).Seconds())
|
||||
|
||||
if result.Content != "" && e.stores.Messages != nil {
|
||||
_ = e.stores.Messages.Create(ctx, &models.Message{
|
||||
ChannelID: channelID,
|
||||
Role: "assistant",
|
||||
Content: result.Content,
|
||||
Model: res.Model,
|
||||
})
|
||||
if result.Content != "" {
|
||||
switch task.OutputMode {
|
||||
case "note":
|
||||
// v0.27.4: Save output as a note
|
||||
if e.stores.Notes != nil {
|
||||
noteTitle := task.Name + " — " + time.Now().Format("2006-01-02 15:04")
|
||||
_ = e.stores.Notes.Create(ctx, &models.Note{
|
||||
UserID: task.OwnerID,
|
||||
Title: noteTitle,
|
||||
Content: result.Content,
|
||||
SourceChannelID: &channelID,
|
||||
TeamID: task.TeamID,
|
||||
Tags: []string{"task-output"},
|
||||
})
|
||||
}
|
||||
case "webhook":
|
||||
// Webhook delivery handled in step 10 below
|
||||
default: // "channel"
|
||||
if e.stores.Messages != nil {
|
||||
_ = e.stores.Messages.Create(ctx, &models.Message{
|
||||
ChannelID: channelID,
|
||||
Role: "assistant",
|
||||
Content: result.Content,
|
||||
Model: res.Model,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── 7. Determine terminal status ───────────
|
||||
|
||||
Reference in New Issue
Block a user