Files
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

52 lines
1.2 KiB
Go

package agenthost
import (
"context"
"errors"
)
// Run supervises the runtime-operation, goal-operation, and goal-reconcile-inbox
// workers as one lifecycle. Per-item step errors
// remain retryable inside their worker; an infrastructure-level worker exit
// cancels its siblings so adapters cannot silently continue with a partially
// running Host.
func (h *Host) Run(ctx context.Context) error {
if h == nil {
return nil
}
return runSupervisedWorkers(ctx, []func(context.Context) error{
h.runRuntimeOperationWorker,
h.runGoalOperationWorker,
h.runGoalReconcileInboxWorker,
})
}
func runSupervisedWorkers(ctx context.Context, workers []func(context.Context) error) error {
runCtx, cancel := context.WithCancelCause(ctx)
defer cancel(nil)
results := make(chan error, len(workers))
for _, worker := range workers {
worker := worker
go func() {
results <- worker(runCtx)
}()
}
var workerErr error
for range workers {
err := <-results
if err == nil || (runCtx.Err() != nil && errors.Is(err, runCtx.Err())) {
continue
}
if workerErr == nil {
workerErr = err
cancel(err)
}
}
if workerErr != nil {
return workerErr
}
return ctx.Err()
}