33 lines
1.0 KiB
Go
33 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"git.cin.su/m/Assistant/contracts/work"
|
|
)
|
|
|
|
// localFallbackExecutor keeps the durable work path alive when no external
|
|
// executor is reachable. It never claims that an external action happened.
|
|
// The work owner records the WAITING callback and can retry after a bridge is
|
|
// configured or a human chooses the next step.
|
|
type localFallbackExecutor struct {
|
|
now func() time.Time
|
|
}
|
|
|
|
func newLocalFallbackExecutor() localFallbackExecutor {
|
|
return localFallbackExecutor{now: time.Now}
|
|
}
|
|
|
|
func (e localFallbackExecutor) Execute(_ context.Context, request work.AgentExecutionRequest) (work.AgentExecutionResult, error) {
|
|
now := time.Now()
|
|
if e.now != nil {
|
|
now = e.now()
|
|
}
|
|
return work.AgentExecutionResult{
|
|
State: work.AgentExecutionWaiting,
|
|
Summary: "Внешний Agent Execution Bridge недоступен; локальный fallback сохранил durable работу и ожидает исполнителя.",
|
|
ObservedAtUnixMillis: now.UnixMilli(),
|
|
}, nil
|
|
}
|