Files
kandev/apps/backend/internal/agentctl/server/utility/spawn_command_test.go
T
João Manso f2d52f1826 feat(agents): let a custom agent speak ACP (#3863)
Co-authored-by: Joao Manso <X363081@bcpcorp.net>
Co-authored-by: Carlos Florencio <carlosmflorencio@gmail.com>
2026-09-23 11:01:32 +01:00

54 lines
1.6 KiB
Go

package utility
import "testing"
// A built-in agent's command is compiled into the binary, so it keeps
// resolving to the allow-list literal the taint tracker can follow.
func TestResolveSpawnCommand_BuiltinUsesAllowlistLiteral(t *testing.T) {
t.Parallel()
cmd, errMsg := resolveSpawnCommand(&InferenceConfigDTO{Command: []string{"goose", "acp"}})
if errMsg != "" {
t.Fatalf("errMsg = %q, want empty", errMsg)
}
if cmd != "goose" {
t.Errorf("cmd = %q, want %q", cmd, "goose")
}
}
// A command that is neither allow-listed nor operator-defined is still
// refused: for a built-in that means the allow-list and the agent definition
// have drifted apart, which is a bug rather than a configuration choice.
func TestResolveSpawnCommand_RejectsUnlistedBuiltin(t *testing.T) {
t.Parallel()
cmd, errMsg := resolveSpawnCommand(&InferenceConfigDTO{Command: []string{"my-agent", "--acp"}})
if errMsg == "" {
t.Fatal("errMsg is empty; an unlisted built-in command must be refused")
}
if cmd != "" {
t.Errorf("cmd = %q, want empty", cmd)
}
}
// A custom agent's command is typed by the install operator in Settings. The
// same string is already spawned unrestricted when a session starts, so
// refusing it here only denies the agent its models and modes.
func TestResolveSpawnCommand_AllowsOperatorDefined(t *testing.T) {
t.Parallel()
cmd, errMsg := resolveSpawnCommand(&InferenceConfigDTO{
Command: []string{"my-agent", "--acp"},
OperatorDefined: true,
})
if errMsg != "" {
t.Fatalf("errMsg = %q, want empty", errMsg)
}
if cmd != "my-agent" {
t.Errorf("cmd = %q, want %q", cmd, "my-agent")
}
}