Phase 1 (extract the Gateway Service), first stage. Repairs the half-migrated working tree so the default (inproc) daemon path works again while keeping the WIP's direction: - chatTaskActorAdapter is contract-only (no HTTP detour); nil contract returns ErrChatCapabilityUnavailable instead of panicking. - openStores opens the conversation store for both processes again; the standalone gateway no longer owns it exclusively. Phase 1 keeps the daemon's Telegram/email routers and session-memory curator reading the same SQLite file; remote conversations arrive when a process that cannot open the file needs them. - setupLLMAndChat composes the local gateway (setupGatewayChat) in default mode and a remote gRPC client in mode=remote; the returned contract is never nil, and Run handles the error. - taskactions.Service is now the single task-mutation implementation shared by the dashboard (webui TaskActionService), the daemon's local gateway actor, and the NATS responder. The daemon registers taskactions.Register so the standalone Gateway's client can forward actions; transport follows the repo's natsrpc pattern. - uncommitted sessions.proto / SessionStoreService gRPC contract deferred: it has no wired consumers (scope creep for this stage). - task_action_adapter_test.go rewritten against the contract chain. task check passes; archied and archie-gateway both build.
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
// Package taskactions adapts legacy task persistence to operator actions.
|
|
package taskactions
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/samcharles93/archie-core/internal/config"
|
|
"github.com/samcharles93/archie-core/internal/domain/taskactions"
|
|
"github.com/samcharles93/archie-core/internal/store"
|
|
)
|
|
|
|
type Store struct{ store.TaskStore }
|
|
|
|
func (s Store) TaskByID(ctx context.Context, id int64) (*taskactions.Task, error) {
|
|
t, err := s.TaskStore.TaskByID(ctx, id)
|
|
if err != nil || t == nil {
|
|
return nil, err
|
|
}
|
|
return &taskactions.Task{ID: t.ID, Owner: t.Owner, Repo: t.Repo, Identity: t.Identity, Status: t.Status, Stage: t.Stage, ParkReason: t.ParkReason, IssueNumber: t.IssueNumber, RetryCount: t.RetryCount, ForgeBacked: t.IsForgeBacked()}, nil
|
|
}
|
|
|
|
func MaxRetries(cfg *config.Holder) func(*taskactions.Task) int {
|
|
return func(t *taskactions.Task) int {
|
|
if cfg == nil {
|
|
return 0
|
|
}
|
|
c := cfg.Get()
|
|
for _, repo := range c.Repos {
|
|
if repo.Owner == t.Owner && repo.Name == t.Repo {
|
|
return repo.EffectiveMaxRetries(c.MaxRetries)
|
|
}
|
|
}
|
|
return c.MaxRetries
|
|
}
|
|
}
|