update for session API renames: Core→Session, NewAgentCore→New, etc.

This commit is contained in:
Levi Neely 2026-07-29 19:17:08 +02:00
parent d46cd21bdf
commit 50f4a06d2e
2 changed files with 12 additions and 12 deletions

View File

@ -18,7 +18,7 @@ import (
"olliesrv/session" "olliesrv/session"
) )
// --- stub agent.Core --- // --- stub agent.Session ---
type stubCore struct { type stubCore struct {
state string state string
@ -165,7 +165,7 @@ func newTestSessionManagerWithCore(t *testing.T) *session.Manager {
Sink: sink, Sink: sink,
ReadFile: func(string) ([]byte, error) { return []byte("#!/bin/sh\n"), nil }, ReadFile: func(string) ([]byte, error) { return []byte("#!/bin/sh\n"), nil },
MkdirAll: func(string, os.FileMode) error { return nil }, MkdirAll: func(string, os.FileMode) error { return nil },
NewCore: func(sessionID, agentName, cwd string) (agent.Core, error) { NewCore: func(sessionID, agentName, cwd string) (agent.Session, error) {
return &stubCore{state: "idle", backend_: "stub", model: "m", agentName: agentName, cwd: cwd}, nil return &stubCore{state: "idle", backend_: "stub", model: "m", agentName: agentName, cwd: cwd}, nil
}, },
}) })
@ -1221,7 +1221,7 @@ func TestSessionManagerCreateSessionEnvExpansion(t *testing.T) {
Sink: sink, Sink: sink,
ReadFile: func(string) ([]byte, error) { return []byte("#!/bin/sh\n"), nil }, ReadFile: func(string) ([]byte, error) { return []byte("#!/bin/sh\n"), nil },
MkdirAll: func(string, os.FileMode) error { return nil }, MkdirAll: func(string, os.FileMode) error { return nil },
NewCore: func(sessionID, agentName, cwd string) (agent.Core, error) { NewCore: func(sessionID, agentName, cwd string) (agent.Session, error) {
gotCwd = cwd gotCwd = cwd
return &stubCore{state: "idle", backend_: "stub", model: "m", agentName: agentName, cwd: cwd}, nil return &stubCore{state: "idle", backend_: "stub", model: "m", agentName: agentName, cwd: cwd}, nil
}, },
@ -1248,7 +1248,7 @@ func TestSessionManagerCreateSessionTildeExpansion(t *testing.T) {
Sink: sink, Sink: sink,
ReadFile: func(string) ([]byte, error) { return []byte("#!/bin/sh\n"), nil }, ReadFile: func(string) ([]byte, error) { return []byte("#!/bin/sh\n"), nil },
MkdirAll: func(string, os.FileMode) error { return nil }, MkdirAll: func(string, os.FileMode) error { return nil },
NewCore: func(sessionID, agentName, cwd string) (agent.Core, error) { NewCore: func(sessionID, agentName, cwd string) (agent.Session, error) {
gotCwd = cwd gotCwd = cwd
return &stubCore{state: "idle", backend_: "stub", model: "m", agentName: agentName, cwd: cwd}, nil return &stubCore{state: "idle", backend_: "stub", model: "m", agentName: agentName, cwd: cwd}, nil
}, },

View File

@ -29,7 +29,7 @@ type Session struct {
mu sync.RWMutex mu sync.RWMutex
id string id string
uname string // immutable user principal (numeric UID), set at creation uname string // immutable user principal (numeric UID), set at creation
Core agent.Core Core agent.Session
Ctx context.Context Ctx context.Context
cancel context.CancelFunc cancel context.CancelFunc
log []byte log []byte
@ -46,7 +46,7 @@ type Session struct {
modelsCacheAt time.Time modelsCacheAt time.Time
} }
func NewSession(id string, core agent.Core, ctx context.Context, cancel context.CancelFunc) *Session { func NewSession(id string, core agent.Session, ctx context.Context, cancel context.CancelFunc) *Session {
sess := &Session{id: id, Core: core, Ctx: ctx, cancel: cancel} sess := &Session{id: id, Core: core, Ctx: ctx, cancel: cancel}
sess.startEventLog() sess.startEventLog()
return sess return sess
@ -234,9 +234,9 @@ type ManagerConfig struct {
Sink *olog.Sink Sink *olog.Sink
ReadFile func(string) ([]byte, error) ReadFile func(string) ([]byte, error)
MkdirAll func(string, os.FileMode) error MkdirAll func(string, os.FileMode) error
// NewCore, if non-nil, replaces the default backend.New + agent.NewAgentCore // NewCore, if non-nil, replaces the default backend.New + agent.New
// path. It receives the session ID, agent name, and cwd, and returns a Core. // path. It receives the session ID, agent name, and cwd, and returns a Core.
NewCore func(sessionID, agentName, cwd string) (agent.Core, error) NewCore func(sessionID, agentName, cwd string) (agent.Session, error)
// Strict rejects inline code steps; only tool steps are allowed. // Strict rejects inline code steps; only tool steps are allowed.
Strict bool Strict bool
// Yolo skips the landrun sandbox. // Yolo skips the landrun sandbox.
@ -926,7 +926,7 @@ func (s *Manager) restoreSession(ps *agent.PersistedSession) error {
restoredSession := agent.RestoreHistory(ps) restoredSession := agent.RestoreHistory(ps)
var sessPtr *Session var sessPtr *Session
core := agent.NewAgentCore(agent.AgentCoreConfig{ core := agent.New(agent.Config{
Backend: be, Backend: be,
AgentName: agentName, AgentName: agentName,
AgentsDir: s.cfg.AgentsDir, AgentsDir: s.cfg.AgentsDir,
@ -1122,7 +1122,7 @@ func (s *Manager) CreateSession(args []string) (string, error) {
return "", fmt.Errorf("session already exists: %s", sessID) return "", fmt.Errorf("session already exists: %s", sessID)
} }
var core agent.Core var core agent.Session
var sessPtr *Session var sessPtr *Session
uname := s.nextUname() uname := s.nextUname()
if s.cfg.NewCore != nil { if s.cfg.NewCore != nil {
@ -1248,7 +1248,7 @@ func (s *Manager) CreateSession(args []string) (string, error) {
rt := agent.BuildRuntime(cfg, disp, cwd, env, sysPrompt, opModel, envBlock) rt := agent.BuildRuntime(cfg, disp, cwd, env, sysPrompt, opModel, envBlock)
// sessPtr is set after NewSession; the ReadPlanStep closure captures it. // sessPtr is set after NewSession; the ReadPlanStep closure captures it.
core = agent.NewAgentCore(agent.AgentCoreConfig{ core = agent.New(agent.Config{
Backend: be, Backend: be,
AgentName: agentName, AgentName: agentName,
AgentsDir: s.cfg.AgentsDir, AgentsDir: s.cfg.AgentsDir,
@ -1343,7 +1343,7 @@ func (s *Manager) renameSession(old, new string) error {
// LoadAgentConfig resolves and loads the config for a named agent. // LoadAgentConfig resolves and loads the config for a named agent.
// Returns nil if the config file does not exist; BuildRuntime handles nil configs. // Returns nil if the config file does not exist; BuildRuntime handles nil configs.
func LoadAgentConfig(agentsDir, name string, open func(string) (*os.File, error)) *agent.Config { func LoadAgentConfig(agentsDir, name string, open func(string) (*os.File, error)) *agent.AgentConfig {
if open == nil { if open == nil {
open = os.Open open = os.Open
} }