agent/pkg/agentic/register.go
Snider d9e7fa092b feat: complete DI migration — IPC pipeline + Config + Locks
Phase 4 complete:
- Auto-PR handler emits PRCreated message
- Verify handler listens for PRCreated, emits PRMerged/PRNeedsReview
- findWorkspaceByPR() for workspace lookup from PR events
- Remove legacy inline fallback from dispatch goroutine

Phase 5 complete:
- agents.yaml loaded once at startup into c.Config()
- canDispatchAgent reads from c.Config() (no re-parsing)
- drainQueue uses c.Lock("drain") when Core available

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-24 16:44:19 +00:00

51 lines
1.3 KiB
Go

// SPDX-License-Identifier: EUPL-1.2
package agentic
import (
core "dappco.re/go/core"
)
// Register is the service factory for core.WithService.
// It creates the PrepSubsystem, wires Core, registers lifecycle hooks,
// and registers IPC handlers — all during Core construction.
//
// core.New(
// core.WithService(agentic.Register),
// )
// Register is the service factory for core.WithService.
// It creates the PrepSubsystem, wires Core, registers lifecycle hooks,
// and registers IPC handlers — all during Core construction.
// The PrepSubsystem instance is stored in Config for retrieval by MCP.
//
// core.New(
// core.WithService(agentic.Register),
// )
func Register(c *core.Core) core.Result {
prep := NewPrep()
prep.core = c
// Load agents config once into Core shared config
cfg := prep.loadAgentsConfig()
c.Config().Set("agents.concurrency", cfg.Concurrency)
c.Config().Set("agents.rates", cfg.Rates)
c.Config().Set("agents.dispatch", cfg.Dispatch)
c.Service("agentic", core.Service{
OnStart: func() core.Result {
prep.StartRunner()
return core.Result{OK: true}
},
OnStop: func() core.Result {
prep.frozen = true
return core.Result{OK: true}
},
})
RegisterHandlers(c, prep)
// Store instance for MCP tool registration
c.Config().Set("agentic.instance", prep)
return core.Result{OK: true}
}