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"
)
// --- stub agent.Core ---
// --- stub agent.Session ---
type stubCore struct {
state string
@ -165,7 +165,7 @@ func newTestSessionManagerWithCore(t *testing.T) *session.Manager {
Sink: sink,
ReadFile: func(string) ([]byte, error) { return []byte("#!/bin/sh\n"), 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
},
})
@ -1221,7 +1221,7 @@ func TestSessionManagerCreateSessionEnvExpansion(t *testing.T) {
Sink: sink,
ReadFile: func(string) ([]byte, error) { return []byte("#!/bin/sh\n"), 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
return &stubCore{state: "idle", backend_: "stub", model: "m", agentName: agentName, cwd: cwd}, nil
},
@ -1248,7 +1248,7 @@ func TestSessionManagerCreateSessionTildeExpansion(t *testing.T) {
Sink: sink,
ReadFile: func(string) ([]byte, error) { return []byte("#!/bin/sh\n"), 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
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
id string
uname string // immutable user principal (numeric UID), set at creation
Core agent.Core
Core agent.Session
Ctx context.Context
cancel context.CancelFunc
log []byte
@ -46,7 +46,7 @@ type Session struct {
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.startEventLog()
return sess
@ -234,9 +234,9 @@ type ManagerConfig struct {
Sink *olog.Sink
ReadFile func(string) ([]byte, 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.
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 bool
// Yolo skips the landrun sandbox.
@ -926,7 +926,7 @@ func (s *Manager) restoreSession(ps *agent.PersistedSession) error {
restoredSession := agent.RestoreHistory(ps)
var sessPtr *Session
core := agent.NewAgentCore(agent.AgentCoreConfig{
core := agent.New(agent.Config{
Backend: be,
AgentName: agentName,
AgentsDir: s.cfg.AgentsDir,
@ -1122,7 +1122,7 @@ func (s *Manager) CreateSession(args []string) (string, error) {
return "", fmt.Errorf("session already exists: %s", sessID)
}
var core agent.Core
var core agent.Session
var sessPtr *Session
uname := s.nextUname()
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)
// sessPtr is set after NewSession; the ReadPlanStep closure captures it.
core = agent.NewAgentCore(agent.AgentCoreConfig{
core = agent.New(agent.Config{
Backend: be,
AgentName: agentName,
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.
// 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 {
open = os.Open
}