Commit Graph

75 Commits

Author SHA1 Message Date
Levi Neely 2a3798ae39 session: add agent/{aid} sublevel routing
The 9P namespace now supports:
  session/{sid}/plan, env           (session-level)
  session/{sid}/agent/{aid}/*       (agent-level files)
  session/{sid}/agent/{aid}/proc/*  (agent detached processes)

Routing updated in stat, openEntry, and Readdir.
Existing flat access ({sid}/{file}) preserved for backward compat.
Tests pass unchanged.
2026-07-29 20:49:59 +02:00
Levi Neely 44a6dda695 session: split FileList into SessionFileList + AgentFileList
Prepare for agent/{aid} sublevel:
- SessionFileList: plan, env (session-level)
- AgentFileList: 21 agent-level files (prompt, state, cfg, etc.)
- NewAgentTree builder for agent file tree
- FileList kept as combined for backward compat

No routing changes yet — existing flat layout still works.
2026-07-29 20:47:04 +02:00
Levi Neely 47c4890037 update prompts and scripts path: s/ → session/ 2026-07-29 20:34:42 +02:00
Levi Neely f75dbc33a7 session: follow Config.Uname → Config.AgentID rename 2026-07-29 20:28:19 +02:00
Levi Neely 19939cc074 session: split session.go into focused files
Break the 1522-line monolith into logical modules:
- session.go (201) — Session struct + basic methods
- manager.go (535) — Manager lifecycle, peers, stat/open
- persist.go (347) — save/restore, shutdown
- create.go (297) — CreateSession, renameSession
- format.go (94) — FormatEvent, LoadAgentConfig
- complete.go (103) — code completion

No behavioral changes. All tests pass.
2026-07-29 20:03:27 +02:00
Levi Neely 3d2172d93a session: eliminate Core interface, use concrete *agent.Session
- Delete session/core.go (the consumer-defined interface)
- Change Session.Core field from interface to *agent.Session
- Change NewSession and ManagerConfig.NewCore to use concrete type
- Rewrite all tests to use real sessions with backend.Noop

The 9p layer now depends directly on the concrete type from
ollie/session. No more interface indirection. Tests exercise
real session behavior instead of stub methods.
2026-07-29 20:00:47 +02:00
Levi Neely cf894920fa session: define Core interface at consumer, use concrete *session.Session
Core interface defined in 9p/session/core.go lists the methods
the 9P layer needs. The real *session.Session satisfies it implicitly.
Test stubs continue to work via interface satisfaction.
2026-07-29 19:25:27 +02:00
Levi Neely 50f4a06d2e update for session API renames: Core→Session, NewAgentCore→New, etc. 2026-07-29 19:17:08 +02:00
Levi Neely d46cd21bdf update imports: ollie/agent → ollie/session (aliased as agent) 2026-07-29 19:13:33 +02:00
Levi Neely 731810ae28 update for agent.Session → agent.History rename 2026-07-29 18:21:39 +02:00
Levi Neely c96982c1ec update imports for core/ restructure
ollie/pkg/X → ollie/X, execute.Registry → tools.Registry,
remote.Dial → execute.RemoteDial, config.Load → agent.Load
2026-07-29 18:10:32 +02:00
Levi Neely 563c6dce2f elevate: wire turn rate limiter reset on prompt submission
Adds resetElevation callback to sessionHelper, called when a new
prompt is written (turn boundary). The Manager passes
broker.ResetTurn(sessionID) via ManagerConfig.ResetElevation.
2026-07-29 16:22:28 +02:00
Levi Neely 2d4ce13272 dbus: emit ConfigChanged on agent switch, fix agent default override
- Add agent watcher goroutine that emits ConfigChanged(session, key, value)
  D-Bus signal when the per-session agent name changes
- Add ConfigChanged to introspection XML
- Fix CreateSession: only apply OLLIE_DEFAULT_AGENT when no agent arg was
  explicitly provided. Previously, passing agent=default would trigger the
  env override, making it impossible to select a specific agent from the GUI.
2026-07-29 11:04:01 +02:00
Levi Neely f0942e81ba session: wire registries via Options instead of post-hoc
Pass WithToolRegistry/WithSkillsRegistry into execute.Decl() so every
Server the factory creates has registries set. Removes fragile post-
construction wiring that only applied to the first dispatcher instance.
2026-07-29 10:50:26 +02:00
lkn aa1b7d1e1c add skills registry and skill_list/skill_load/skill_active built-in dispatchers 2026-07-29 00:16:39 +02:00
lkn d5ed0a545f remove allowExecutors from config, execute server, and agent JSONs 2026-07-28 22:39:15 +02:00
lkn 7c15f9ec3b session wiring: use execute.SetToolRegistry instead of separate registry server 2026-07-28 22:08:53 +02:00
lkn 96dda6e5f0 9p: files for per-session dynamic tool loading and inspection 2026-07-28 14:12:41 +02:00
lkn ecbe8067f2 add reactions file to 9P session tree 2026-07-27 19:59:50 +02:00
lkn 57053c4e48 add reactions file to 9P session tree 2026-07-27 19:52:49 +02:00
lkn 8c7dba5cf7 9P/D-Bus ReactTo and assistant:id headers 2026-07-27 19:12:12 +02:00
Levi Neely d95313d682 add react file and reaction semantics in system prompt
New 9P file s/{id}/react: write an emoji to record a reaction to the
most recent assistant response. The reaction is passive feedback —
no model turn is triggered.

The system prompt now documents how agents should interpret emoji
reactions (positive/negative/confused) and silently adjust behavior.
2026-07-27 15:26:14 +02:00
Levi Neely 300d07b2aa remove ollie-9p-mount binary, inline FUSE into olliesrv
The mount logic is now a library package (mount/) called directly
by `olliesrv mount`. No external binary needed.

Per-session auto-mounts are gone entirely. The mount subcommand
remains for network-transparent human access to remote servers.
2026-07-27 11:51:56 +02:00
Levi Neely cafe38292f session: remove auto-mount on session creation
Agents now use the 9p client binary directly instead of FUSE mounts.
Remove startMount() calls and OLLIE= env var from session env.
Mounts remain available for human use but are no longer auto-started.
2026-07-27 11:41:42 +02:00
Levi Neely e40d266206 session: parallelize session restoration on startup
Load persisted session JSONs sequentially (fast disk reads),
then fan out restoreSession calls in parallel. Each session
restoration involves backend init, prompt resolution, and
potentially SSH connections for remote sessions.
2026-07-27 11:13:36 +02:00
lkn 76807dd879 sort D-Bus ListModels results 2026-07-26 19:01:19 +02:00
lkn 1a545be58f restore active sessions from data directory 2026-07-26 12:10:11 +02:00
lkn c7c8fd1b8b session: inject operational model into restore path
Restored sessions were calling BuildRuntime without baseLayers,
so the 9P/D-Bus operational model never appeared in the system prompt.
Now computes sysPrompt, opModel, envBlock and passes them as BaseLayers.
2026-07-21 14:40:46 +02:00
lkn 686fa5d0c8 embed layered system prompt: system + operational model + environment
The preamble is now composed as:
  system_prompt + operational_model + environment + agent_prompts

- Embed SYSTEM_PROMPT.md, session-9p.md, session-dbus.md in the binary
- Render environment block at runtime with live cwd/platform/date values
- Inject operational model based on server mode (Enable9P/EnableDBus)
- Accept system_prompt= override in session creation and D-Bus CreateSession
- Agent configs no longer need to reference system/session prompt files
2026-07-21 13:06:55 +02:00
Levi Neely c4e1950f8c remote: restore sessions with remote= reconnect to remote host 2026-07-19 21:53:01 +02:00
Levi Neely 208db7ba68 streaming: handle tool streaming via empty-content start signal 2026-07-19 21:36:55 +02:00
Levi Neely 4b24b33377 streaming: tool as first-class streaming role in chat log 2026-07-19 21:25:58 +02:00
Levi Neely bba14ddcde session: pass PromptEnvExtra to AgentCoreConfig 2026-07-19 20:37:37 +02:00
Levi Neely 03a29b0877 session: pass PromptEnv to all BuildRuntime calls
Both restore and create paths now include PRIME_* env vars.
Remote path uses HostInfo; local path uses PromptEnv(cwd).
2026-07-19 20:26:52 +02:00
Levi Neely 28232fd833 remote sessions: eager dial, pass host info to prompt resolution
Dial the remote eagerly during session creation so HostInfo is available
for BuildRuntime. Pass PRIME_PLATFORM and PRIME_IS_GIT_REPO as env vars
so the system prompt reflects the remote host, not the local machine.
2026-07-19 20:17:32 +02:00
Levi Neely b95bab0ef8 fix: start FUSE mount for remote sessions
Remote sessions had no local mount because WithMount9P hooks into the
local execute.Server which does not exist for remote sessions. Start
the mount directly and tear it down on kill/shutdown.
2026-07-19 19:43:19 +02:00
Levi Neely fce23afd28 session: store remote target, expose in cfg read
The remote= field is now visible when reading s/{id}/cfg,
and stored on the Session struct for future persistence.
2026-07-19 19:10:02 +02:00
Levi Neely 4f8e0c2768 session: wire remote= config for split-brain execution
When creating a session with remote=user@host, the session manager
uses remote.Decl() instead of execute.Decl() for the tool dispatcher.
This forwards all tool calls over SSH to an ollie-remote process on
the target host.

Usage: printf "cwd=/path\nremote=user@host\n" > \$OLLIE/s/new
2026-07-19 18:57:26 +02:00
Levi Neely 8fa630f65c share active-sessions dir with dbus backend
Both backends now use ~/.local/share/ollie/sessions/active since
they are mutually exclusive.
2026-07-19 13:27:46 +02:00
Levi Neely b050ef4ab7 9p: replay last 20 messages into chat log on session restore 2026-07-19 00:10:05 +02:00
Levi Neely f630c644e1 complete: use backend.Generate instead of copilot session 2026-07-18 23:34:24 +02:00
Levi Neely da611d3ef2 dbus: add Complete and missing session methods; readme: add -nodbus flag 2026-07-18 22:36:24 +02:00
Levi Neely f065429d24 9p: add embedded D-Bus protocol adapter
Expose org.ollie.SessionManager on the session bus directly from olliesrv.
The adapter emits StateChanged, ChatUpdated, SessionCreated, SessionKilled,
SessionRenamed, ProcessDetached, and ProcessExited signals. All KDE frontends
work without ollied.

Fixes:
- ListSessions: use Manager.List() instead of broken Readdir("")
- RenameSession: delegate to Manager.RenameSession()
- WatchExisting: start signal watchers for sessions restored at startup
- Introspection XML: declare all methods and signals
2026-07-18 21:36:07 +02:00
Levi Neely 9d21601edf fix: session persistence across restart
Shutdown() was calling KillSession() which deleted the persisted
JSON files immediately after saveAllSessions() wrote them. Now
Shutdown() closes sessions directly without removing persistence
files, allowing restoreAllSessions() to find them on next start.
2026-07-18 16:28:12 +02:00
Levi Neely d8e0b9b5ba 9p: add /complete file for stateless code completion
Follows the Plan 9 /net/dns pattern: per-fid request-response.
Write JSON request (or plain prefix), write blocks during LLM call,
read returns the completion result. Per-fid state means concurrent
clients get independent request/response pairs.

Also includes the Complete method, findOrCreateCopilot, and noise
stripping helpers in the session package.
2026-07-18 16:00:54 +02:00
Levi Neely b13f42778a 9p: add session persistence across restarts
Sessions are saved to ~/.local/share/ollie/sessions/active-9p/ on
shutdown and restored on startup. Core auto-saves to SessionsDir
during turns. KillSession removes persisted files.

Closes the major feature gap with the D-Bus daemon.
2026-07-18 15:12:11 +02:00
Levi Neely 4ff3961dfd 9p: add proc/ directory for detached process inspection
- ls /s/{id}/proc/ lists detached PIDs
- cat /s/{id}/proc/{pid} reads ring buffer output
- rm /s/{id}/proc/{pid} dismisses the process
- echo detach > /s/{id}/ctl detaches running process
- echo "signal {pid} [TERM|KILL]" > /s/{id}/ctl signals detached process

Walk validates PID exists in detached list before succeeding.
2026-07-18 13:29:35 +02:00
Levi Neely 61240e02de 9p: add peer directory for bidirectional session communication
Implement /s/{id}/peer/ directory:
- touch /s/{id}/peer/{peer-id}: creates bidirectional peer link
- rm /s/{id}/peer/{peer-id}: removes bidirectional peer link
- ls /s/{id}/peer/: lists registered peers
- echo "prompt" > /s/{id}/peer/{peer-id}: submits prompt to peer

Peer management lives in the session Manager (core layer).
Walk validates peer existence before reporting file found.
Peer files have mode 0666 (writable).
2026-07-18 13:17:57 +02:00
Levi Neely 1db7fb9177 fix deadlock in CachedListModels: use dedicated modelsMu
content() holds sess.mu.RLock, then calls CachedListModels which
tried to acquire sess.mu.Lock for cache write — classic RLock/Lock
deadlock. Fix by giving the models cache its own mutex independent
of the session mu.
2026-07-18 12:54:38 +02:00
Levi Neely bb9b899e4e 9p: eliminate expensive API calls during readdir/stat
- Add CachedListModels() with 24h TTL to avoid repeated Models() API calls
- Cache readdir serialized bytes per-fid (rebuild only at offset=0)
- Skip all session file size computation in makeStat (report len=0)
- Short-circuit pathType() for session paths to avoid triggering Stat
- Remove e.Info() call from subdirectory readdir (unused mtime)
- Add monotonic timer to handle() for profiling 9p operations
- Add fcallTypeName() helper
- Fix stubCore for new Detach/SaveSession interface methods
- Add tools-process.md prompt

Before: ls inside a session dir took 1.38s (kiro) / 67ms (openrouter)
After: 182µs regardless of backend (7500x improvement)
2026-07-18 01:31:06 +02:00