Commit Graph

81 Commits

Author SHA1 Message Date
Ollie Agent 8f7d21fc38 toolsrv: fire OnToolsChanged after LoadTool
The system prompt tool listing now refreshes immediately on tool_load
instead of only on file-watcher events. buildToolListing helper added
to format the listing in the same format BuildPreamble uses.

Also updates kde submodule: GUI auto-switches to newly created agent,
removes remote field from agent dialog.
2026-08-08 14:02:22 +02:00
Levi Neely e84b4ffef7 feat: add resetsCounter tool property to reset step budget on active progress
Tools like file_write, file_edit, and shell now reset the agent's step
counter when called successfully. This allows the agent to continue
working without hitting the soft step-budget guardrail as long as it's
making active progress (writing files, running commands) rather than
looping on research/reading.

Changes:
- Add ResetsCounter bool to ToolInfo and MetaFile structs
- Parse resetsCounter from .meta JSON files
- Reset step counter in agent loop when ResetsCounter tool succeeds
- Add resetsCounter: true to file_write, file_edit, shell
- Reduce maxSteps from 50 to 25 (resetsCounter makes this safe)
2026-08-07 17:13:14 +02:00
Ollie Agent d80a87eb86 clean up OLLIE_* env vars: replace with XDG conventions
- Remove all OLLIE_*_PATH vars (TOOLS_PATH, CFG_PATH, DATA_PATH, etc.)
  Use XDG_CONFIG_HOME/ollie/* and XDG_DATA_HOME/ollie/* instead
- Replace OLLIE_<TAG>_LOG per-component logging with single OLLIE_LOG={level}
- Replace OLLIE_USAGE_LOG with XDG_DATA_HOME-based path
- Replace OLLIE_OLLAMA_URL with standard OLLAMA_HOST (or omit entirely)
- Rename protocol markers: OLLIE_LISTEN_READY → ListenReady, OLLIE_9P_OPEN → Open
- Remove freeloader hooks from agent configs
- Update sandbox YAMLs to use XDG paths instead of OLLIE_*_PATH tokens
- Update shell tools to use $(dirname "$0") fallback instead of OLLIE_TOOLS_PATH
- Update docs and prompts accordingly
2026-08-07 07:11:53 +02:00
Levi Neely 44592065d8 fix: respect agent-provided timeout and sandbox params in callPromotedTool
callPromotedTool was hardcoding timeout=30 and sandbox="default" for all
promoted tool executions, ignoring the timeout and sandbox parameters
provided by the agent in tool call args. Extract these from the JSON args
map (same pattern as elevated) and pass them through to the execution
functions.
2026-08-06 11:17:10 +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
Ollie Agent 1372a6b55b Remove OLLIE_ELEVATE_SOCKET from config: derived from XDG_RUNTIME_DIR convention
- Removed from env.go managed list and defaults map
- main.go and shell.go derive path from XDG_RUNTIME_DIR directly
- main.go sets OLLIE_ELEVATE_SOCKET in process env for subprocesses
2026-08-05 19:43:52 +02:00
Ollie Agent 2bd6d6f66a Remove OLLIE_*_PATH env vars: paths follow ~/.config/ollie/ convention
- Stripped OLLIE_TOOLS_PATH, OLLIE_AGENTS_PATH, OLLIE_SKILLS_PATH,
  OLLIE_PROMPTS_PATH, OLLIE_MEMORY_PATH, OLLIE_TMP_PATH from managed
  list and defaults in env.go
- ToolsPath(), SkillsPath(), PromptsDirs(), AgentsDirs(), ollieTmpDir()
  now derive from paths.CfgDir()/paths.DataDir() directly
- Removed shell-exec fallback from resolveExecPrompt() — only file
  resolution remains
- Cleaned up env_test.go to match reduced managed set
- Updated stale comments referencing /home/lkn/.config/ollie/tools
2026-08-05 19:37:13 +02:00
Levi Neely fbb2a767f6 session: pause/resume persistence, restore paused sessions without spawning processes
- Skip SetupToolServer for paused sessions during restore
- Pause() and Resume() now persist state to disk
- Resume() sets up tool server from scratch for sessions restored paused
- IsConnected() returns false when paused
- Add SetPaused(), SetToolServer() methods
- ProcessKeeper.SetContext() for resume after pause
- Session index sorts active-first, paused-last
- CreateAgent accepts name= parameter
- Remove duplicate SetCwd method
2026-08-04 16:05:22 +02:00
Levi Neely e5ebf0550a test(toolsrv): add integration tests for RPC protocol
Comprehensive tests for the ollie-remote JSON-RPC 2.0 protocol:

Direct RPC dispatch tests:
- ping: liveness check returns 'pong'
- host_info: returns platform, arch, git repo status
- list_tools: empty list when no tools loaded
- set_env: environment variable injection with hook verification
- set_cwd: working directory updates
- set_allow_tools: tool restriction configuration
- is_parallel_read: parallel safety classification
- result_tier / result_tier_args: retention tier lookup
- detach: returns false when no process running
- list_detached: empty list initially
- signal_detached: error for nonexistent PID
- get_detached_output: error for nonexistent PID
- dismiss_detached: returns false for nonexistent PID
- tool call: error for unloaded tools
- invalid params: -32602 error code

Pipe-based client/server tests:
- Full roundtrip through toolsrv.Conn client
- Concurrent request handling (10 parallel pings)
- Context cancellation propagation
- Connection close detection

JSON-RPC protocol compliance:
- Table-driven tests for request/response format
- Error code verification (-32602 invalid params, -32000 server error)
2026-08-03 16:31:04 +02:00
Levi Neely fe2348c0cc toolsrv: add ProcessKeeper for resilient ollie-remote lifecycle
ProcessKeeper maintains a running ollie-remote process and respawns
it on failure. Multiple agents Dial() the same keeper to get
independent connections. If the process dies, the next Dial()
triggers a respawn (up to 3 attempts with backoff).

All session creation and restore paths now use ProcessKeeper.
Kill/Shutdown close the keeper (which closes the current process).
This fixes 'connection closed' errors persisting indefinitely
after ollie-remote crashes — the next tool call respawns it.
2026-08-03 12:21:54 +02:00
Levi Neely 3f1e8bfd8b toolsrv: use ToolsPath() for local ollie-remote bootstrap
Remove hardcoded ~/.config/ollie/tools path and XXX hack.
Local ollie-remote now inherits OLLIE_TOOLS_PATH from the environment
via os.Environ(), same as remote bootstrap sets it explicitly.

ToolsPath() reads OLLIE_TOOLS_PATH with fallback to ~/.config/ollie/tools.
Tools added to the directory are picked up immediately on next
tool_load — no restart needed.

Removed dead appendEnvVar helper.
2026-08-03 10:17:58 +02:00
Ollie Agent 60fafd5381 remove tools/builtin/ — zero built-in tools, all tools are external scripts
With the zero-tools transition complete, the tools/builtin/ package
served no purpose — Builtins() returned nil. Removed:

- tools/builtin/builtins.go and the directory
- builtins field, WithBuiltins, Dispatch from toolsrv.Server
- Handler type from toolsrv (only used by builtins)
- OnPreDispatch/WithOnPreDispatch (dead code)
- Strict field and WithStrict (dead code, never read)
- CallTool simplified — no fallback to Dispatch
- builtin import and WithBuiltins/WithStrict calls from ollie-remote
- tools/builtin from justfile build/test targets

Updated AGENTS.md, ARCHITECTURE.md, README.md, EVOLUTION.md
2026-08-03 00:55:22 +02:00
Ollie Agent d3860304af Add formatted tool output fences 2026-08-02 22:57:17 +02:00
Ollie Agent 8fba664f11 cleanup / unify toolsrv bootstrap 2026-08-02 20:08:45 +02:00
Ollie Agent e25157ffcd multiplex toolsrv, wip zero-tool server 2026-08-02 19:18:39 +02:00
Levi Neely 7eb022faba remove built-in skill handlers, replace with external tools
skill_list and skill_load are now external shell scripts (data/tools/).
Removed from builtins: SkillList, SkillLoad, SkillActive.
Removed: toolsrv/skills.go, tools/builtin/skill.go, WithSkillsRegistry,
SkillsRegistry accessor, ListSkillsTools.
ollie-remote no longer initializes a skills registry.

The demarcation: built-ins mutate agent internals (tool schema, context
injection). Skills are just file reads — no special treatment needed.
2026-07-31 16:45:37 +02:00
Levi Neely 59b672966f toolsrv: unified socket-based execution
Execution is now identical for local and remote:
- Session calls Spawn()/SpawnRemote() → owns *Process with socket
- Clients call Dial(LocalAddr(socket)) → *Conn over Unix socket
- ollie-remote serves --listen mode with multi-client accept loop
- Builtins (shell, tool_load, skill_load) run in subprocess with registries

Lifecycle:
- Pdeathsig ensures children die with parent (no orphans)
- Cleanup: SIGTERM → 3s grace → SIGKILL (guaranteed)
- Socket paths use atomic counter for uniqueness
- Session Kill() closes Process

Protocol:
- Extended RPC: set_env, set_cwd, detach, list_detached, etc.
- Shell goes through builtin dispatch (parses 'cmd' field correctly)
- Streaming output via JSON-RPC notifications
2026-07-31 14:10:47 +02:00
Levi Neely 0c75d06c59 remote: auto-upgrade ollie-remote on each tool call
Before each CallTool, check if the local ollie-remote binary hash
differs from what was deployed. If so, close the SSH connection,
re-dial (triggering bootstrap to upload the new binary), and swap
the connection transparently.

Emits info events when upgrade is detected and when it completes.
2026-07-31 11:23:15 +02:00
Levi Neely c88ed95b94 remote: deploy landrun alongside ollie-remote
The bootstrap script now also checks for and deploys the landrun
sandbox binary to ~/.cache/ollie/bin/landrun on the remote host.
Without this, ollie-remote couldn't sandbox tool execution.

Protocol extended: OLLIE_LOADER_START now includes need_landrun field.
Transfers are sequential: ollie-remote first, then landrun if needed.
Each binary has independent hash-based caching.
2026-07-31 11:13:38 +02:00
Levi Neely c031cb430e session/remote: fail fast on SSH auth and deploy errors
- Skip cwd existence check when remote is specified (cwd is on remote)
- Add BatchMode=yes to SSH: pubkey-only, no password fallback
- Add StrictHostKeyChecking=accept-new: auto-accept new hosts, reject
  changed keys
- Deploy failure already propagates as session creation error via
  RemoteDial returning error
2026-07-31 11:00:07 +02:00
Levi Neely ae59151344 toolsrv: export USER and NAMESPACE to shell environment
ollie-9p computes its namespace path from $USER and $DISPLAY via
client.Namespace(). When run inside the sandboxed shell, USER was not
guaranteed to be in the environment, producing /tmp/ns..:0/ollie.

Fix: explicitly inject USER into envExtra in SetSessionEnv (alongside
OLLIE_SESSION_ID and OLLIE_UNAME). Also export the computed NAMESPACE
to cmd.Env so ollie-9p can use it directly without recomputing.
2026-07-31 09:22:43 +02:00
Ollie Agent 7a69f14277 toolsrv: typed RateLimitedError, agent loop: don't count rate-limited calls as consecutive errors 2026-07-31 07:46:32 +02:00
Ollie Agent cb5f99b332 fix ResolveTool to check OLLIE_TOOLS_PATH for variant cmd names 2026-07-30 23:40:24 +02:00
Ollie Agent 3d65d787a2 elevate: broker credential support for privileged tool execution 2026-07-30 23:37:57 +02:00
Ollie Agent 5955562c1d system_logs: first variant-based tool + OR match support
Adds system_logs with two variants:
- journalctl (systemd hosts): unit, since, lines, grep
- dmesg (any Linux): source, lines, grep

Both declare sudo: true — privilege escalation is handled by dispatch.

Also adds OR support in match conditions: array values mean any must
pass. Combined with AND across keys:
  {"binary": ["journalctl", "systemd-cat"], "os": "linux"}
  = (journalctl OR systemd-cat) AND linux
2026-07-30 23:28:37 +02:00
Ollie Agent ca8af814e9 toolsrv: conditional tool variants for heterogeneous hosts
A .meta file can now declare multiple variants, each gated by match
conditions. The first variant where all conditions pass determines the
tool's schema, documentation, and executable. If no variant matches,
the tool is hidden from the registry on that host.

Match conditions:
  binary  — exec.LookPath or absolute path stat
  file    — os.Stat (file or dir exists)
  os      — runtime.GOOS
  arch    — runtime.GOARCH
  env     — environment variable is non-empty
  nenv    — environment variable is empty

This enables network-transparent tool declarations: one .meta file
works across heterogeneous hosts (systemd vs syslog, apt vs pacman,
GUI vs headless). When ollie-remote deploys to a different machine,
tools adapt their contract to what's actually available.

No variants field = current behavior, zero breaking changes.
2026-07-30 23:13:31 +02:00
Ollie Agent 44e420fc7e toolsrv: support cmd field in .meta for external tool resolution
Tools no longer need to be co-located in $OLLIE_TOOLS_PATH. The .meta
sidecar can specify a cmd field pointing to any executable:
- Absolute path: use directly
- Bare name: resolve via $PATH

Resolution order: OLLIE_TOOLS_PATH/<name> → meta.cmd → PATH lookup.
Local wrappers always win, enabling simplified interfaces over complex
system binaries.

Rewrites doc/WRITING_TOOLS.md to document the plugin model: any
executable + .meta = tool, no source tree integration required.
2026-07-30 23:02:08 +02:00
Ollie Agent 5a84e8b326 toolsrv: fix Registry.discover() to use .meta files
The Registry had its own discover() method that still required
'ollie:prompt' in file content — the old header-based check that was
removed from DiscoverTools(). This caused tool_load to fail for ALL
tools (not just Go binaries) since .meta is now the sole metadata source.

Fix: delegate to DiscoverTools() which correctly scans .meta files.
2026-07-30 22:50:49 +02:00
Ollie Agent 69b2c2cc40 tool metadata: replace header comment parsing with .meta sidecar files
The tool registry now reads metadata exclusively from JSON .meta sidecar
files alongside each tool executable. Header comment parsing (ollie:prompt,
ollie:tier, ollie:parallel, args_json) is removed entirely.

- Add toolsrv/meta.go: MetaFile struct, LoadMetaFile, ToolInfoFromMeta
- Rewrite discover.go: scans .meta files only
- Rewrite schema.go: ParseToolInfo reads .meta only
- Rewrite tier.go: tier/readOnly from .meta only
- Generate .meta for all 35 tools
- Update all docs: README, AGENTS.md, ARCHITECTURE, CORE, USAGE, WRITING_TOOLS
2026-07-30 21:48:42 +02:00
Ollie Agent ddddb1f53b remove s/, u/, x/ script namespaces and 9P backing
All session scripts (s/sh, s/b, s/bfg, s/bbg, s/ls, s/kill, s/cleanup),
utility scripts (u/optimize, u/complete, u/cascade, u/escalate), and
internal scripts (x/bd, x/prime, x/freeloader, x/task) are removed.

These are replaced by:
- generate, complete, route files (ollie-9p rdwr)
- integrated elevation broker
- D-Bus/9P session management

Also removes:
- 9P rootFileOrder entries and permission map for script files
- Script-serving catch-all in rootOpen
- prependOlliePath (no x/ scripts to shadow PATH with)

ollie-watchdog moved to contrib/scripts/ alongside ollie-remount.
2026-07-30 21:36:54 +02:00
Ollie Agent 9b6ddb7df1 flatten: absorb submodules into single Go module
- Remove submodules: core, 9p, acme, httpgw, remote, el
- Keep submodules: kde, webui (separate build systems)
- Collapse core/ packages into root: agent/, backend/, detach/, elevate/,
  env/, log/, paths/, sandbox/, session/, skills/, tools/, toolsrv/
- Collapse 9p/ packages: fs/session/, mount/, dbus/, cmd/olliesrv/
- Move binaries: acme/ → cmd/Ollie/, httpgw/ → cmd/ollie-httpgw/,
  remote/ → cmd/ollie-remote/, 9p/cmd/ollie-9p/ → cmd/ollie-9p/
- Move data: agents/, prompts/, tools/, scripts/, skills/ → contrib/
- Move services/ → contrib/services/, experiments/ → doc/experiments/
- Delete .beads/, .claude/, .kiro
- Single go.mod at root (module ollie)
- Fix all import paths, merge fs/ + session/ packages
- Extract dbus/ and elevate/notify.go from 9p server package
- Update justfile for new paths and single-module build
2026-07-30 18:57:51 +02:00