Files
archie/internal/infrastructure/taskactions/service.go
T
sam 8e41bb9a66 feat(gateway): consolidate task actions and repair daemon default path
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.
2026-09-06 01:35:15 +10:00

33 lines
908 B
Go

package taskactions
import (
"context"
"github.com/samcharles93/archie-core/internal/domain/taskactions"
"github.com/samcharles93/archie-core/internal/events"
)
// NewService assembles the operator task-action service from its production
// dependencies. Both the dashboard's in-process service (webui) and the
// daemon's NATS responder build through this one constructor so the two
// surfaces cannot diverge.
func NewService(
store taskactions.Store,
maxRetries func(*taskactions.Task) int,
cancel func(int64) bool,
closeIssue func(context.Context, string, string, int, string) error,
removeLogs func(int64) error,
publish func(events.Event),
warn func(string, ...any),
) taskactions.Service {
return taskactions.Service{
Store: store,
MaxRetries: maxRetries,
CancelTask: cancel,
CloseIssue: closeIssue,
RemoveLogs: removeLogs,
Publish: publish,
Warn: warn,
}
}