feat(agentic): delegate runner controls to pkg/runner
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
8c9ee8f2bd
commit
6adbf92277
2 changed files with 56 additions and 3 deletions
|
|
@ -2,10 +2,33 @@
|
|||
|
||||
package agentic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
core "dappco.re/go/core"
|
||||
)
|
||||
|
||||
// subsystem := agentic.NewPrep()
|
||||
// subsystem.StartRunner()
|
||||
func (s *PrepSubsystem) StartRunner() {}
|
||||
func (s *PrepSubsystem) StartRunner() {
|
||||
s.runRunnerAction("runner.start")
|
||||
}
|
||||
|
||||
// subsystem := agentic.NewPrep()
|
||||
// subsystem.Poke()
|
||||
func (s *PrepSubsystem) Poke() {}
|
||||
func (s *PrepSubsystem) Poke() {
|
||||
s.runRunnerAction("runner.poke")
|
||||
}
|
||||
|
||||
func (s *PrepSubsystem) runRunnerAction(name string) {
|
||||
if s == nil || s.ServiceRuntime == nil {
|
||||
return
|
||||
}
|
||||
|
||||
action := s.Core().Action(name)
|
||||
if action == nil || !action.Exists() {
|
||||
return
|
||||
}
|
||||
|
||||
action.Run(context.Background(), core.NewOptions())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@
|
|||
package agentic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
core "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// StartRunner and Poke are no-ops — queue drain is owned by pkg/runner.Service.
|
||||
// StartRunner and Poke delegate to pkg/runner.Service when it is registered.
|
||||
|
||||
func TestRunner_StartRunner_Good(t *testing.T) {
|
||||
s := newPrepWithProcess()
|
||||
|
|
@ -25,3 +27,31 @@ func TestRunner_Poke_Ugly_NilChannel(t *testing.T) {
|
|||
s := newPrepWithProcess()
|
||||
assert.NotPanics(t, func() { s.Poke() })
|
||||
}
|
||||
|
||||
func TestRunner_StartRunner_Good_DelegatesToRunnerStartAction(t *testing.T) {
|
||||
coreApp := core.New(core.WithOption("name", "test"))
|
||||
called := false
|
||||
coreApp.Action("runner.start", func(_ context.Context, _ core.Options) core.Result {
|
||||
called = true
|
||||
return core.Result{OK: true}
|
||||
})
|
||||
|
||||
s := &PrepSubsystem{ServiceRuntime: core.NewServiceRuntime(coreApp, AgentOptions{})}
|
||||
s.StartRunner()
|
||||
|
||||
assert.True(t, called)
|
||||
}
|
||||
|
||||
func TestRunner_Poke_Good_DelegatesToRunnerPokeAction(t *testing.T) {
|
||||
coreApp := core.New(core.WithOption("name", "test"))
|
||||
called := false
|
||||
coreApp.Action("runner.poke", func(_ context.Context, _ core.Options) core.Result {
|
||||
called = true
|
||||
return core.Result{OK: true}
|
||||
})
|
||||
|
||||
s := &PrepSubsystem{ServiceRuntime: core.NewServiceRuntime(coreApp, AgentOptions{})}
|
||||
s.Poke()
|
||||
|
||||
assert.True(t, called)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue