feat(agentic): honour dispatch workspace root config
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
d5fb2dc50b
commit
88f4baed77
3 changed files with 32 additions and 0 deletions
|
|
@ -15,12 +15,21 @@ import (
|
|||
// if r.OK { core.Print(nil, "%s", r.Value.(string)) }
|
||||
var fs = (&core.Fs{}).NewUnrestricted()
|
||||
|
||||
var workspaceRootOverride string
|
||||
|
||||
func setWorkspaceRootOverride(root string) {
|
||||
workspaceRootOverride = core.Trim(root)
|
||||
}
|
||||
|
||||
// f := agentic.LocalFs()
|
||||
// r := f.Read("/tmp/agent-status.json")
|
||||
func LocalFs() *core.Fs { return fs }
|
||||
|
||||
// workspaceDir := core.JoinPath(agentic.WorkspaceRoot(), "core", "go-io", "task-42")
|
||||
func WorkspaceRoot() string {
|
||||
if root := core.Trim(workspaceRootOverride); root != "" {
|
||||
return root
|
||||
}
|
||||
return core.JoinPath(CoreRoot(), "workspace")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,9 +84,11 @@ func (s *PrepSubsystem) loadAgentsConfig() *AgentsConfig {
|
|||
if err := yaml.Unmarshal([]byte(readResult.Value.(string)), &config); err != nil {
|
||||
continue
|
||||
}
|
||||
setWorkspaceRootOverride(config.Dispatch.WorkspaceRoot)
|
||||
return &config
|
||||
}
|
||||
|
||||
setWorkspaceRootOverride("")
|
||||
return &AgentsConfig{
|
||||
Dispatch: DispatchConfig{
|
||||
DefaultAgent: "claude",
|
||||
|
|
|
|||
|
|
@ -30,6 +30,27 @@ func TestQueue_DispatchConfig_Good_Defaults(t *testing.T) {
|
|||
assert.Equal(t, 3, cfg.Concurrency["gemini"].Total)
|
||||
}
|
||||
|
||||
func TestQueue_DispatchConfig_Good_WorkspaceRootOverride(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
t.Setenv("CORE_WORKSPACE", root)
|
||||
customRoot := core.JoinPath(root, "agent-workspaces")
|
||||
require.True(t, fs.Write(core.JoinPath(root, "agents.yaml"), core.Concat(
|
||||
"version: 1\n",
|
||||
"dispatch:\n",
|
||||
" workspace_root: ", customRoot, "\n",
|
||||
)).OK)
|
||||
|
||||
t.Cleanup(func() {
|
||||
setWorkspaceRootOverride("")
|
||||
})
|
||||
|
||||
s := &PrepSubsystem{ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}), codePath: t.TempDir()}
|
||||
cfg := s.loadAgentsConfig()
|
||||
|
||||
assert.Equal(t, customRoot, cfg.Dispatch.WorkspaceRoot)
|
||||
assert.Equal(t, customRoot, WorkspaceRoot())
|
||||
}
|
||||
|
||||
func TestQueue_CanDispatchAgent_Good_NoConfig(t *testing.T) {
|
||||
// With no running workspaces and default config, should be able to dispatch
|
||||
root := t.TempDir()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue