agent/cmd/core-agent/main.go

102 lines
2.4 KiB
Go
Raw Permalink Normal View History

// SPDX-License-Identifier: EUPL-1.2
package main
import (
"context"
"syscall"
agentpkg "dappco.re/go/agent"
"dappco.re/go/core"
"dappco.re/go/agent/pkg/agentic"
"dappco.re/go/agent/pkg/brain"
"dappco.re/go/agent/pkg/monitor"
"dappco.re/go/agent/pkg/runner"
"dappco.re/go/agent/pkg/setup"
)
func main() {
if err := runCoreAgent(); err != nil {
core.Error("core-agent failed", "err", err)
syscall.Exit(1)
}
}
// app := newCoreAgent()
// core.Println(app.App().Name) // "core-agent"
// core.Println(app.App().Version) // "dev" or linked version
func newCoreAgent() *core.Core {
coreApp := core.New(
core.WithOption("name", "core-agent"),
core.WithService(agentic.ProcessRegister),
core.WithService(agentic.Register),
core.WithService(runner.Register),
core.WithService(monitor.Register),
core.WithService(brain.Register),
core.WithService(setup.Register),
core.WithService(registerMCPService),
)
coreApp.App().Version = applicationVersion()
coreApp.Cli().SetBanner(func(_ *core.Cli) string {
return core.Concat("core-agent ", coreApp.App().Version, " — agentic orchestration for the Core ecosystem")
})
registerApplicationCommands(coreApp)
return coreApp
}
feat: AX v0.8.0 upgrade — Core features + quality gates AX Quality Gates (RFC-025): - Eliminate os/exec from all test + production code (12+ files) - Eliminate encoding/json from all test files (15 files, 66 occurrences) - Eliminate os from all test files except TestMain (Go runtime contract) - Eliminate path/filepath, net/url from all files - String concat: 39 violations replaced with core.Concat() - Test naming AX-7: 264 test functions renamed across all 6 packages - Example test 1:1 coverage complete Core Features Adopted: - Task Composition: agent.completion pipeline (QA → PR → Verify → Ingest → Poke) - PerformAsync: completion pipeline runs with WaitGroup + progress tracking - Config: agents.yaml loaded once, feature flags (auto-qa/pr/merge/ingest) - Named Locks: c.Lock("drain") for queue serialisation - Registry: workspace state with cross-package QUERY access - QUERY: c.QUERY(WorkspaceQuery{Status: "running"}) for cross-service queries - Action descriptions: 25+ Actions self-documenting - Data mounts: prompts/tasks/flows/personas/workspaces via c.Data() - Content Actions: agentic.prompt/task/flow/persona callable via IPC - Drive endpoints: forge + brain registered with tokens - Drive REST helpers: DriveGet/DrivePost/DriveDo for Drive-aware HTTP - HandleIPCEvents: auto-discovered by WithService (no manual wiring) - Entitlement: frozen-queue gate on write Actions - CLI dispatch: workspace dispatch wired to real dispatch method - CLI: --quiet/-q and --debug/-d global flags - CLI: banner, version, check (with service/action/command counts), env - main.go: minimal — 5 services + c.Run(), no os import - cmd tests: 84.2% coverage (was 0%) Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 06:38:02 +00:00
// agentpkg.Version = "0.15.0"
// applicationVersion() // "0.15.0"
func applicationVersion() string {
if agentpkg.Version != "" {
return agentpkg.Version
feat: AX v0.8.0 upgrade — Core features + quality gates AX Quality Gates (RFC-025): - Eliminate os/exec from all test + production code (12+ files) - Eliminate encoding/json from all test files (15 files, 66 occurrences) - Eliminate os from all test files except TestMain (Go runtime contract) - Eliminate path/filepath, net/url from all files - String concat: 39 violations replaced with core.Concat() - Test naming AX-7: 264 test functions renamed across all 6 packages - Example test 1:1 coverage complete Core Features Adopted: - Task Composition: agent.completion pipeline (QA → PR → Verify → Ingest → Poke) - PerformAsync: completion pipeline runs with WaitGroup + progress tracking - Config: agents.yaml loaded once, feature flags (auto-qa/pr/merge/ingest) - Named Locks: c.Lock("drain") for queue serialisation - Registry: workspace state with cross-package QUERY access - QUERY: c.QUERY(WorkspaceQuery{Status: "running"}) for cross-service queries - Action descriptions: 25+ Actions self-documenting - Data mounts: prompts/tasks/flows/personas/workspaces via c.Data() - Content Actions: agentic.prompt/task/flow/persona callable via IPC - Drive endpoints: forge + brain registered with tokens - Drive REST helpers: DriveGet/DrivePost/DriveDo for Drive-aware HTTP - HandleIPCEvents: auto-discovered by WithService (no manual wiring) - Entitlement: frozen-queue gate on write Actions - CLI dispatch: workspace dispatch wired to real dispatch method - CLI: --quiet/-q and --debug/-d global flags - CLI: banner, version, check (with service/action/command counts), env - main.go: minimal — 5 services + c.Run(), no os import - cmd tests: 84.2% coverage (was 0%) Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 06:38:02 +00:00
}
return "dev"
}
// if err := runCoreAgent(); err != nil {
// core.Error("core-agent failed", "err", err)
// }
func runCoreAgent() error {
return runApp(newCoreAgent(), startupArgs())
}
// app := newCoreAgent()
// _ = runApp(app, []string{"version"})
func runApp(coreApp *core.Core, cliArgs []string) error {
if coreApp == nil {
return core.E("main.runApp", "core is required", nil)
}
defer coreApp.ServiceShutdown(context.Background())
result := coreApp.ServiceStartup(coreApp.Context(), nil)
if !result.OK {
return resultError("main.runApp", "startup failed", result)
}
if cli := coreApp.Cli(); cli != nil {
result = cli.Run(cliArgs...)
if !result.OK {
return resultError("main.runApp", "cli failed", result)
}
}
return nil
}
// result := core.Result{OK: false, Value: core.E("main.runApp", "startup failed", nil)}
// err := resultError("main.runApp", "startup failed", result)
func resultError(op, msg string, result core.Result) error {
if result.OK {
return nil
}
if err, ok := result.Value.(error); ok && err != nil {
return err
}
return core.E(op, msg, nil)
}