add OLLIE_DEFAULT_AGENT support and update agent commands

This commit is contained in:
Levi Neely 2026-05-21 12:33:18 +02:00
parent 84533aed1a
commit 82ac183357
4 changed files with 20 additions and 4 deletions

View File

@ -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 {

View File

@ -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) {

View File

@ -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
}

View File

@ -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}