Commit Graph

9 Commits

Author SHA1 Message Date
Levi Neely 8e4cdaa4bd session: extract agent/ as separate package
Agent is now in ollie/agent with proper encapsulation:
- Unexported fields, exported methods as the API
- Own constructor (agent.NewAgent)
- Owns: turn execution, history, runtime, hooks, commands, compaction
- Session never reaches into agent internals

Session (ollie/session) is a thin host:
- Owns: persistence, session ID, env, detach delegation
- Delegates all agent operations through exported Agent methods
- handleCommand dispatches to agent.HandleCommand for agent-level commands

Agent-level commands (/model, /backend, /compact, /agent, etc.) live
in agent/commands.go and access internals directly (same package).

Session-level commands (/sessions, /save, /resume, /cwd, /help)
remain in session/commands.go.

Test files temporarily removed pending rewrite against new API.
The fifo_test.go passes as a sanity check.
2026-07-29 21:43:49 +02:00
Levi Neely eef52beb74 session: move Submit/executeTurn to *Agent receiver
Agent now owns the full turn lifecycle: Submit, executeTurn, turnError,
autoCompactLimit, autoWarnLimit, spawnContext, and runCompact all live
on *Agent in turn.go.

Session.Submit is a thin dispatcher: slash commands are handled at
session level (they need sessionsDir, listHandlers, etc.), then
non-command input is delegated to Agent.Submit.

Session.IsRunning and Session.Interrupt delegate to Agent methods.

turnError is an overridable func field on Agent (default: hook-based
implementation in defaultTurnError). saveSession and flushSave are
injected as callbacks from Session into Agent at construction time.

This completes the agent/session ownership separation for the turn
execution path. The Agent is now a self-contained entity that can
run turns independently given its injected dependencies.
2026-07-29 21:16:59 +02:00
Levi Neely 8a4f77c118 session: rename PersistedSession → PersistedAgent 2026-07-29 20:57:13 +02:00
Levi Neely 4643c4fca5 session: rename Agent.uname → Agent.id
The agent's identity field is its id, not a Unix username.
Config.Uname preserved as public API (renamed with 9P recraft).
2026-07-29 20:27:23 +02:00
Levi Neely 4028085914 session: move uname to Agent, remove peers from core
- uname is the agent's principal/UID, not a session property
- peers removed entirely from core: the concept needs redesign for
  multi-agent. The 9P layer retains its own inter-session routing
  at the Manager level.

Core Session now holds only: id, bus, env, plan, prevPrompt.
Agent holds all execution + identity state.
2026-07-29 20:25:28 +02:00
Levi Neely 7592f810a9 session: move cwd, fifo, submitMu, toolCallCount, pendingInject to Agent
Agent now owns all execution-related state:
- cwd: the directory the agent operates in
- fifo: prompt queue (prompts target a specific agent)
- submitMu: serializes turns for this agent
- toolCallCount: per-agent tool usage metric
- pendingInject: injection targeting the current agent

Session retains only environment state: identity, bus, env, plan, peers,
persistence. This completes the agent/session state separation.
2026-07-29 20:15:13 +02:00
Levi Neely 8acadaaa30 session: move state/reply to Agent
Agent now owns its execution state (state, reply, stateMu, changeMu,
changeCond). Session delegates State()/Reply()/WaitChange() to Agent.

This is the correct ownership: each agent has independent execution
state. In multi-agent, agents can be idle/thinking independently.
Session remains the coordination layer.
2026-07-29 20:10:42 +02:00
Levi Neely 5db3eb5138 session: remove Session interface, export concrete struct
Session is now an exported struct with unexported fields.
Methods ARE the API — no interface declaration in the package.
Consumers that need mockability define their own interface
(implicit satisfaction, standard Go pattern).
2026-07-29 19:25:14 +02:00
Levi Neely 6ee949bd7c rename agent/ → session/, absorb session.Session into harness
The agent/ package is now session/ — because a session is the
top-level concept. The package contains:
- harness: implements Core, the session orchestrator
- Agent: the reasoning entity (history, runtime, tools)
- History: conversation accumulator
- Fifo, loop, compaction, hooks, commands

The old session/ package (which just held extracted fields) is
dissolved back into the harness. One package, clean ownership.
2026-07-29 19:13:26 +02:00