From 82ac183357358b7a00b408a940e57ec1218a0c31 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Thu, 21 May 2026 12:33:18 +0200 Subject: [PATCH] add OLLIE_DEFAULT_AGENT support and update agent commands --- pkg/agent/commands.go | 3 ++- pkg/agent/core_test.go | 1 + pkg/agent/prompt_resolver.go | 13 +++++++++++-- pkg/tools/execute/server.go | 7 ++++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pkg/agent/commands.go b/pkg/agent/commands.go index 8386985..17aec46 100644 --- a/pkg/agent/commands.go +++ b/pkg/agent/commands.go @@ -11,6 +11,7 @@ import ( "strings" "ollie/pkg/config" + "ollie/pkg/tools/execute" ) func (s *agent) handleCommand(ctx context.Context, input string) bool { @@ -210,7 +211,7 @@ func (s *agent) handleCommand(ctx context.Context, input string) bool { return } d := s.newDispatcher() - env := BuildAgentEnv(cfg, d, s.cwd, []string{"OLLIE_SESSION_ID=" + s.sessionID}) + env := BuildAgentEnv(cfg, d, s.cwd, []string{"OLLIE_SESSION_ID=" + s.sessionID, "OLLIE=" + execute.MountPath(s.uname)}) if env.Backend != "" { newBe, err := s.newBackend(env.Backend) if err != nil { diff --git a/pkg/agent/core_test.go b/pkg/agent/core_test.go index 40fd8f0..ae1a9e8 100644 --- a/pkg/agent/core_test.go +++ b/pkg/agent/core_test.go @@ -704,6 +704,7 @@ func TestCommand_I_SetsInject(t *testing.T) { t.Errorf("pendingInject = %v; want %q", p, "my inject") } close(done) + waitState(t, c, "idle") } func TestCommand_I_SubmitsWhenIdle(t *testing.T) { diff --git a/pkg/agent/prompt_resolver.go b/pkg/agent/prompt_resolver.go index 956900b..8f97289 100644 --- a/pkg/agent/prompt_resolver.go +++ b/pkg/agent/prompt_resolver.go @@ -31,7 +31,7 @@ func resolvePrompt(p config.Prompt, cwd string, env []string) (string, error) { if p.IsExec { return resolveExecPrompt(p.Value, cwd, env) } - return resolveStringPrompt(p.Value[0], cwd) + return resolveStringPrompt(p.Value[0], cwd, env) } func resolveExecPrompt(cmds []string, cwd string, env []string) (string, error) { @@ -64,11 +64,20 @@ func resolveExecPrompt(cmds []string, cwd string, env []string) (string, error) return strings.Join(parts, "\n"), nil } -func resolveStringPrompt(prompt, cwd string) (string, error) { +func resolveStringPrompt(prompt, cwd string, env []string) (string, error) { if prompt == "" { return "", nil } + envMap := make(map[string]string, len(env)) + for _, e := range env { + if k, v, ok := strings.Cut(e, "="); ok { + envMap[k] = v + } + } expanded := os.Expand(prompt, func(key string) string { + if val, ok := envMap[key]; ok { + return val + } if val := os.Getenv(key); val != "" { return val } diff --git a/pkg/tools/execute/server.go b/pkg/tools/execute/server.go index df061f0..19c809b 100644 --- a/pkg/tools/execute/server.go +++ b/pkg/tools/execute/server.go @@ -373,6 +373,11 @@ func (e *Server) SetEnv(key, value string) { e.envMu.Unlock() } +// MountPath returns the per-session FUSE mount path for a given uname. +func MountPath(uname string) string { + return filepath.Join(os.TempDir(), "ollie-mount-"+uname) +} + // startMount launches ollie-9p-mount for this session. Must be called with envMu held. func (e *Server) startMount(sessionID string) { if !e.mountEnabled { @@ -382,7 +387,7 @@ func (e *Server) startMount(sessionID string) { if err != nil { return } - mnt := filepath.Join(os.TempDir(), "ollie-mount-"+sessionID) + mnt := MountPath(sessionID) os.MkdirAll(mnt, 0755) //nolint:errcheck cmd := exec.Command(bin, "-u", sessionID, mnt) cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}