Commit Graph

32 Commits

Author SHA1 Message Date
Ollie Agent cbfc08875b fs: unify ctl — all levels use rdwrHandler + rdwrDispatch
Root, session, and agent ctl files all share the same dispatch
mechanism: rdwrHandler map → rdwrDispatch → Request (rdwr).

- ctlHandler/ctlDispatch (write-only) removed
- Root and session ctl upgraded to Request (rdwr), return 'ok'
- systemprompt moved to agent ctl command
- nopRead removed (dead)
2026-08-09 02:58:09 +02:00
Ollie Agent 993d5a812a fs: move tools to ctl commands, remove tools file
/tools        — lists loaded tools
/tool_load X  — loads a tool by name

System prompt updated to instruct the agent to use ctl for tool
management instead of writing to a tools file.
2026-08-09 02:52:06 +02:00
Ollie Agent 94088ccc94 fs: move cwd to ctl command, remove cwd file
/cwd returns current directory, /cwd X changes it (with stat check).
One fewer file in the agent namespace.
2026-08-09 02:48:50 +02:00
Ollie Agent 2561e01574 fs: move per-agent models to ctl command, remove models file
/models now lists available models for the agent's backend via ctl.
One fewer file in the agent namespace. The root-level models file
(all backends) remains unchanged.
2026-08-09 02:47:26 +02:00
Ollie Agent c05f4d1ef0 fs: agent ctl becomes rdwr (request-response)
The ctl file is now a Request handler: write a command, read the
response. Commands with no args return current state:

  /model        → prints current model
  /agent        → prints current profile
  /cwd          → prints working directory
  /name         → prints agent name
  /model X      → switches model, returns new model
  /compact      → compacts, returns 'ok'

o ctl now uses 'ollie-9p rdwr' to get the response.
This enables /model (no args) to show the current model from
any frontend.
2026-08-09 02:44:21 +02:00
Ollie Agent c7aea0db59 rename elevate→bypass throughout
The sandbox escape mechanism is a bypass, not privilege elevation.
The old name caused the agent to confuse it with sudo.

- elevate/ → bypass/ (package, types, tests)
- elevate_notify.go → bypass_notify.go
- Namespace: /elevate → /bypass, session/*/elevate → session/*/bypass
- Tool arg: "elevated" → "bypass"
- Env: OLLIE_ELEVATE_SOCKET → OLLIE_BYPASS_SOCKET
- File: elevate-policy.yaml → bypass-policy.yaml
- All docs, prompts, and scripts updated
2026-08-09 02:22:39 +02:00
Ollie Agent 72db6d900d fs: namespace cleanup — merge and remove dead files
- fifo.in + fifo.out → single fifo (write enqueues, read dequeues)
- cost + usage + ctxsz → single stats (key=value lines)
- Remove connection (no consumers, heartbeat handles it)
- Remove dead prevPrompt field and write (prompt.prev gone from spec)
- Clean AGENT_FILES: remove state, context, tail (all already absent
  from spec, were only in the tab-completion list)
2026-08-09 01:57:41 +02:00
Ollie Agent 744f775eb5 fs: split chat into chat (filtered text) and chat.raw (full markup)
chat — strips [[[...]]] markers and source fences at the byte level.
Partial lines pass through immediately for true streaming. Terminals
and text editors use this.

chat.raw — full block-structured stream with markers and fences.
GUIs that parse blocks (KDE, web) use this.

The TUI no longer pipes through grep (which was line-buffering and
killing char-by-char streaming since Aug 4).

The stripMarkers state machine processes each chunk from the server:
- Complete lines starting with [[[ and ending with ]]] → dropped
- Fence lines (```...) → dropped (open toggles in-fence state)
- Partial lines (no trailing \n) → always emitted immediately
- Everything else → passed through
2026-08-09 01:43:39 +02:00
Ollie Agent f4caf29a35 fs: fix nil panic in sessionBindings — RootState captured at build time
The previous commit (3b83b9d) replaced globalRootState with
ctx.Root.Data.(*RootState), but ctx.Root is nil inside closures
captured by BuildTree (Root is set *after* the tree is built).

Fix: add RootState field to HandlerCtx and create it before BuildTree
so all closures capture the live pointer directly.
2026-08-08 16:17:42 +02:00
Ollie Agent 8152dec075 all: delete dead code, tighten API surface
toolsrv:
- Delete WithOnClose, WithOnEnvSet, SetOnExit (dead Options)
- Delete ListDetached, ListDetachedInfo (only ListDetachedRaw used)
- Delete Execute (dead wrapper)
- Delete CWD, ToolRegistry, SessionID, InjectContent (dead accessors)
- Delete ExecuteInSandbox, ExecuteElevated (zero external callers)
- Delete Summaries, RefreshLoaded from Registry (dead)
- Delete DialSSH (alias for RemoteDial)
- Simplify Dial: takes socket string directly, kill Addr/LocalAddr/SSHAddr
- Rename Server receiver e → s
- Unexport context import (no longer needed in tools.go)

session:
- Delete SaveFuncs, AgentAt, AgentCount, NextUncheckedStep
- Delete SetDisallowTools, SaveAllSessions

env:
- Delete Set, Get, All, Format, managed (dead exports)
- Unexport LoadFile → loadFile

fs:
- Delete HandlerCtx.ToolReg, Skills, SaveFn (never read by handlers)
- Delete Config.MkdirAll, Config.SkillsRegistry (dead plumbing)
- Delete AgentLog: Plan, SetPlan, PrevPrompt, Mu, LogInfo, Remote methods
- Delete unused type aliases (NodeOption, FileTree, FileConfig, etc.)

backend:
- Delete ClosePool, PoolStats (dead), New() (dead)
- Delete kiroTokenExpiringSoon standalone func (dead)
- Unexport SharedTransport/SharedClient → sharedTransport/sharedClient

skills:
- Delete entire package (zero importers; feature works via tool scripts)

agent:
- Delete BroadcastChange (dead duplicate of notifyChange)
- Delete HasHistory, ToolCallCount, CompactionModel, SetCompactionModel
- Unexport SetReply, BuildPreamble, DefaultPromptsDir
2026-08-08 15:51:13 +02:00
Ollie Agent 7c99d101b1 namespace audit: remove prompt.prev, state, offset, context, tail
- Removed from fs/spec.go: prompt.prev, state, offset, context, tail
- Removed handlers: readAgentPromptPrev, readAgentState, readAgentOffset, readAgentContext, readAgentTail
- statewait still exists but now has an inline read handler
- 5 files out of the namespace; 18 agent-level files remaining
- Reduces each agent dir by 5 entries
2026-08-07 08:19:54 +02:00
Ollie Agent 5ec208c5ea fsedsl: HandlerCtx composes context.Context — no more context.Background() in handlers
- HandlerCtx now embeds context.Context for per-operation cancellation/deadline
- Reverted fsedsl signatures back to simple (ctx Ctx) since context is embedded
- requestGenerate handler uses ctx instead of context.Background()
- cmdInject propagates its context parameter instead of using Background
2026-08-07 07:42:41 +02:00
Ollie Agent 7e29d28848 remove agent/complete.go — completions now go through /generate
- Delete agent/complete.go (110 lines) and its requestComplete handler
- Remove /complete 9P file from fs/spec.go
- Update KDE kate plugin to build the completion prompt inline and call
  ollie-9p rdwr generate instead of ollie-9p rdwr complete
- StripCompletionNoise and stripPrefixEcho moved into C++ helpers
2026-08-07 07:36:58 +02:00
Ollie Agent 97c8bcbb62 fs/spec.go: move GID("agent") to root node, let children inherit
- Removed 19 redundant GID("agent") calls from leaf nodes and subdirectories
- Root DirNode now sets GID once; all descendants inherit via fsedsl resolver
2026-08-07 07:19:24 +02:00
Ollie Agent fc0c368e91 Good idea fairy cleanup: ~960 lines removed
Phase 1:
- agent/hooks.go (entire hooks engine, 237 lines)
- backend/noop.go (unused test backend)
- backend/oneshot.go: Route/RouteRequest/RouteResult + /route 9P file
- cmd/ollie-9p/mount/ (FUSE mount, 336 lines)
- toolsrv/schema.go (ParseToolInfo, zero callers)
- toolsrv/discover.go: ToolPrompt/ReadTool (zero callers)
- agent/commands.go: CompactionSnapshot + history.go: PreCompactionSnapshot
- data/tools/route.meta + justfile route install

Phase 2:
- detach/process.go: stripped Signal(), Cmd field, unused imports
- SignalDetached reimplemented with syscall.Kill directly

24 files changed, 19 insertions, ~980 deletions
2026-08-05 21:51:55 +02:00
Levi Neely 0cefd03e9a update kde submodule; session/fs changes 2026-08-05 17:52:26 +02:00
Levi Neely f21cd99845 fix: eventwait should use BlockOnce, not Stream
eventwait returns a single event then closes, like statewait.
Stream is for continuous data like chat.
2026-08-04 14:39:26 +02:00
Levi Neely 2aa7db8445 refactor: split fs/ and session/ packages
session/ now owns all session business logic:
- Manager: session lifecycle (create, kill, rename, lookup)
- CreateAgent: agent creation within sessions
- SetupToolServer, BuildPromptLayers, LoadAutoLoadTools
- PublishEvent for SSE notifications
- NextUname generation

fs/ is now a thin 9P presentation layer:
- SessionNode wraps session.Session, adds AgentLogs and models cache
- RootState caches SessionNodes (GetOrCreateNode pattern)
- Handlers delegate to session.Manager
- persist.go uses session package for restore logic
2026-08-04 13:52:28 +02:00
Levi Neely bf80a63e8a fs: extract session setup, remove dead code and adapter
- Extract SetupToolServer, BuildPromptLayers, LoadAutoLoadTools into setup.go
- Deduplicate session infrastructure setup between CreateAgent and restoreSession
- Delete adapter.go, move HandlerCtx and type aliases into spec.go
- Delete session.go (only contained unused Get/All functions)
- Remove unused: GlobalRootState, PostEvent, LookupByUname, AddSession,
  CreateAgentFromRoot, KillFromRoot, RenameFromRoot, Session.Interrupt,
  Session.SetDisallowTools, Session.RunnableID
- Replace RunnableID() calls with ID()
- Remove comment banners

Net: -131 lines, better DRY compliance
2026-08-04 13:04:31 +02:00
Levi Neely aaacae40a8 fs: simplify adapter to type aliases only
- Remove wrapper functions from adapter.go (212 → 91 lines)
- Delete redundant adapter_test.go (fsedsl has 94.8% coverage)
- Add local function aliases in spec.go for clean EDSL usage
- Update handlers.go, newroot.go, tree_test.go to use fsedsl directly
- Update fsedsl README with cleaner integration pattern
2026-08-04 12:47:17 +02:00
Levi Neely 3a1c16878f fs: generate /help dynamically from Doc() strings
Add self-documenting filesystem:
- Doc() option on FsNodeDecl for human-readable descriptions
- /help now generated from spec at runtime, not loaded from file
- Every file/directory in spec.go has documentation

Also fix file-template Each nodes:
- Each without children but with Read/Write creates files, not dirs
- Update validator, listDir, statDir to recognize file templates
- Fix elevate/{reqid} and proc/{pid} to use file-template pattern
2026-08-04 11:43:14 +02:00
Levi Neely 0fa9dd5694 fs: remove comment banners
The code structure is self-evident. Banners add noise without value.
2026-08-04 11:32:09 +02:00
Levi Neely 6ea5b54940 fs: add comprehensive documentation to all file nodes
Add Doc() EDSL option and Desc field to FsNodeDecl for self-documenting
filesystem specification. Every file and directory now has a human-readable
description explaining its purpose, format, and usage.

Documentation covers:
- Root-level files (backends, models, agents, tools, ctl, etc.)
- Elevate broker (policy, pending requests)
- Session management (new, idx, per-session files)
- Agent management (prompt, chat, state, config, tools, proc)

This makes spec.go the single source of truth for both structure and
documentation. The Desc field can be used to generate help text or
API documentation programmatically.
2026-08-04 11:30:19 +02:00
Levi Neely b47792d8be fs: restructure package into logical files
Split fs/ package for better organization:
- edsl.go: EDSL types and constructors (HandlerCtx, FsNodeDecl, Binding, etc.)
- cache.go: ModelCache for backend model list caching
- file.go: File/FileTree interfaces (renamed from fs.go)
- handlers.go: all handler functions (extracted from spec.go)
- spec.go: filesystem declaration only

Renames:
- fsnode.go -> edsl.go (consolidated EDSL types)
- fs.go -> file.go (clearer name)
- each_test.go -> edsl_test.go
- fs_test.go -> tree_test.go, renamed TestFlatDir* -> TestTree*

Exports for potential future use:
- RootState (was rootState)
- GlobalRootState() getter
- BuildIndex() (was buildIndex)
2026-08-04 11:27:28 +02:00
Levi Neely ad286834f4 fix template names: {sname} and {aname}
The primary directory name comes from Instance.Name (session/agent name),
not the ID. The ID is just an alias for lookup.
2026-08-04 10:48:46 +02:00
Levi Neely 013d894ad8 rename Dynamic → Each
Each says exactly what it does: for each item in a collection,
create this directory structure.

DirNode, FileNode, Each - the EDSL is now clear and declarative.
2026-08-04 10:47:58 +02:00
Levi Neely 7c6dff4a01 rename EDSL constructors for clarity
- Leaf → FileNode (file node)
- Dir → DirNode (directory node)
- Blueprint → Dynamic (state-dependent directory)

The names now clearly indicate what they create:
- FileNode: a file
- DirNode: a directory
- Dynamic: a directory whose children depend on runtime state
2026-08-04 10:45:28 +02:00
Levi Neely 3a920998bd implement Blueprint pattern for EDSL
New EDSL construct: Blueprint(name, instancesFn, ...children)
- Declares static structure in treeSpec
- InstanceFn returns identity info (name, aliases, UID/GID, data binding)
- Handlers access instance data via ctx.Session/Agent/AgentLog
- No more closure captures for session/agent data

Changes:
- Add Instance type and InstanceFn to fsnode.go
- Add Blueprint() constructor
- Update builder.go to handle blueprint node expansion
- Convert session/{id} to Blueprint with sessionInstances
- Convert agent/{aid} to Blueprint with agentInstances
- Convert all handlers to use ctx fields instead of closures

Benefits:
- Full namespace structure visible in treeSpec at top of spec.go
- Handlers are stateless functions (easier to test/reason about)
- Less memory (no closure allocations per instance)
- Cleaner separation: structure vs data binding vs handlers
2026-08-04 10:35:18 +02:00
Levi Neely b6e2f9048b consolidate fs handlers into spec.go
Single source of truth for the 9P namespace:
- Move rootfiles.go handlers into spec.go
- Move sessionfiles.go (listSessions) into spec.go
- Move agentfiles.go (listAgents) into spec.go
- Move procfiles.go (listProcesses) into spec.go
- Move elevatefiles.go handlers into spec.go

The full namespace structure is now visible in one file with
structure comments documenting the layout of dynamic subtrees.

No functional changes - just reorganization.
2026-08-04 10:24:26 +02:00
Levi Neely 44f173214d fs: add Aliases to FsNodeDecl for immutable ID path resolution
Nodes in the 9P namespace can now declare alternate names (Aliases)
that resolve during Twalk but are invisible in directory listings.
Session dirs alias their immutable RunnableID(), agent dirs alias
their ID(). Clients can use session/{uuid}/agent/{uuid}/... paths
that remain valid across renames.

Changes:
- fs/fsnode.go: Add Aliases []string field, Alias() NodeOption
- fs/builder.go: findChild checks aliases via matchAlias helper
- fs/sessionfiles.go: Session dirs get Alias(s.RunnableID())
- fs/agentfiles.go: Agent dirs get Alias(a.ID())
- fs/spec.go: Add /aliases file (read-only alias→path table)
- fs/rootfiles.go: readAliases handler
- fs/lifecycle.go: buildIndex includes immutable ID in session/idx
- doc/edsl.md: Document Aliases field and behavior
- prompts: Update session/idx format documentation

The KDE GUI submodule now uses immutable IDs in all 9P paths,
fixing disconnected indicators after session rename.
2026-08-03 09:41:26 +02:00
Ollie Agent e25157ffcd multiplex toolsrv, wip zero-tool server 2026-08-02 19:18:39 +02:00
Ollie Agent 1e126ce76a Replace imperative 9P filesystem with declarative EDSL
The old fs/session/ package (14 files) and cmd/olliesrv/elevate_tree.go
(imperative FileTree implementations) are gone. Replaced by a single
declarative EDSL in fs/spec.go that declares the entire 9P namespace.

cmd/olliesrv/server.go simplified from 1430 to 825 lines:
- Deleted pathType() (110 lines) — tree.Stat() now handles all path resolution
- Deleted isSessionFile(), dirMode(), filePerm() — all from tree's info
- Deleted fsRoute/routes/route/routeDir — single rootTree, no route table
- Deleted elevateTree — EDSL handles /elevate/ in spec.go
- Deleted handleWrite(), readDNS(), helpPath() — dead code
- Deleted all 5 per-fid result fields — EDSL Request handlers manage state
- Deleted all path-based intercepts in read()/write() — entry.RequestRespMode()
- Deleted all path-depth hacks in makeStat() — custom Stat() closures in EDSL
- Deleted all content-length compute logic — info.Size() from tree
- Removed imports: agent, backend, elevate, paths, toolsrv, json

New fs/ package:
- spec.go — single EDSL declaration of the entire namespace
- builder.go — BuildTree() validates and compiles spec into *Tree
- tree.go — configurable FileTree implementation
- fsnode.go — Dir(), Leaf(), TemplateDir(), NodeOption constructors
- agentfiles.go / sessionfiles.go / rootfiles.go / elevatefiles.go
  — handler implementations wired by the EDSL
- lifecycle.go — Create, Kill, Rename, Shutdown, InterruptAll
- persist.go, procfiles.go
- edsl.md — documentation of the EDSL
2026-08-02 15:22:17 +02:00