Commit Graph

66 Commits

Author SHA1 Message Date
Levi Neely 1207e26a07 remove trustedTools and Confirm callback; trust is implicit via allowExecutors 2026-05-17 15:21:26 +02:00
Levi Neely bfc7f15254 tier: built-in default cold table for known read-only tools 2026-05-17 11:03:54 +02:00
Levi Neely 779b99fd9b tool results: tier classification (hot/warm/cold) with immediate cold summarization 2026-05-17 10:59:17 +02:00
Levi Neely 22d72f143d fix: wire allowExecutors/allowTools in BuildAgentEnv; add missing IncrToolCallCount field 2026-05-17 00:05:34 +02:00
Levi Neely 161d0d237f add allowExecutors/allowTools two-layer tool restriction 2026-05-16 23:54:55 +02:00
Levi Neely 6dfae368d0 fix: wire PlanFile, add missing rate-limit constants, simplify test helpers, fix regex
- Wire PlanFile from $OLLIE/s/{id}/plan into agentConfig so plan
  re-injection is no longer dead code
- Add missing failureWindow/maxFailures/blockDuration constants
- Replace hand-rolled contains() with strings.Contains
- Fix rm -rf .. regex to match end-of-string and whitespace
- Add TestPlanReinjection covering periodic plan re-surfacing
- Add loop_maxsteps_helpers_test.go with mockResponse/newState/sequentialStream
2026-05-16 23:54:04 +02:00
Levi Neely 860b1ce64d execute: fix test suite — Yolo mode for CI, correct classifyStep expectation 2026-05-15 18:54:20 +00:00
Levi Neely 8cf82f3551 execute: update tests for split execute_code / call_tool / pipe tools 2026-05-15 18:50:20 +00:00
Levi Neely 0903254c6c execute: wire call_tool and pipe dispatch; execute_code is code-only 2026-05-15 18:48:23 +00:00
Levi Neely f8299effdf execute: split execute_code into execute_code, call_tool, pipe 2026-05-15 18:47:07 +00:00
Levi Neely c02607aa60 execute: separate steps (parallel) from pipe (sequential)
- steps: independent, run in parallel when annotated safe, outputs
  concatenated. No stdout chaining.
- pipe: explicit pipeline, sequential, stdout of each stage feeds
  stdin of the next.

steps and pipe are mutually exclusive in a single execute_code call.
2026-05-11 13:50:01 +02:00
Levi Neely d638c2e75b Revert "execute: remove auto-batching from pipeline, fan-out is always explicit"
This reverts commit 2117f14a53.
2026-05-11 13:43:13 +02:00
Levi Neely 2117f14a53 execute: remove auto-batching from pipeline, fan-out is always explicit
steps is always a pipe (sequential, stdout chains to next stdin).
Concurrent fan-out requires explicit use of the parallel field.
The ollie:parallel annotation still drives agent-level tool call
parallelism via IsParallelRead, but no longer hijacks pipe semantics.
2026-05-11 13:40:47 +02:00
Levi Neely 36841b3667 execute/flock: make ollie:parallel annotation comment-syntax-agnostic
Now matches "ollie:parallel" anywhere in the line instead of requiring
a "# " prefix. Supports bash (#), lua (--), C-style (//), etc.
2026-05-11 13:26:55 +02:00
Logan Neely cafc55e038 execute: add Strict and Yolo server options
Strict rejects inline {code} steps, allowing only named {tool} steps.
Yolo skips the landrun sandbox entirely.
2026-05-07 22:27:22 +02:00
ollie 36d3021aae sandbox: require landrun, fail hard if unavailable
WrapCommand now returns an error instead of silently falling back to
unsandboxed execution when landrun is not in PATH. execute_code
propagates this as a hard failure.
2026-05-03 22:10:02 +02:00
Levi Neely ba9ab44565 execute: fix test sandbox for plan9 PATH, drop GNU-only bc -q flag
Add {PLAN9} to test sandbox rwx list so plan9 binaries (cat, sleep,
grep, bc, sed) are accessible. Drop -q from bc invocation since
plan9 bc does not support it; -l alone works on both GNU and plan9.
2026-05-02 10:40:00 +02:00
Levi Neely f32a2a6907 prompt: support literal strings in exec prompt arrays; clarify timeout schema
Entries in the prompt array that contain a newline are now treated as
literal text instead of shell commands. This enables JIT agent configs
to embed identity text directly without escaping.

Also clarify that execute_code timeout is a top-level parameter, not
per-step, to prevent models from placing it in the wrong location.
2026-05-02 10:29:01 +02:00
Levi Neely 6646740d67 change tools to hierarchical 2026-04-30 14:39:02 +02:00
Levi Neely bc59f6c40f core: loop-level parallel tool execution for read-safe tools
Tools annotated with "# ollie:parallel read" now run concurrently when
the LLM issues multiple such calls in a single round, without needing
an execute_code pipeline.

- tools.ParallelClassifier interface; execute.Server implements it via
  IsParallelRead, which reads the tool script and checks the annotation
- BuildAgentEnv wires IsParallelRead → AgentEnv.classifyTool →
  agentConfig.ClassifyTool (nil when execute server absent)
- loop.go: consecutive parallel-safe calls are fanned out with a
  WaitGroup; results are collected in submission order; cancellation
  fills remaining calls with interrupted results; serial tools and
  batches of one skip the goroutine overhead

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-28 13:05:15 +02:00
Levi Neely 386dc64753 tests: add flock/locking coverage for execute package
Covers detectParallelClass, sanitizeLockName, acquireFlock, classifyStep,
SetLockDir, and runReadBatch — bringing pkg/tools/execute from 70.9% to 92.4%.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 18:50:35 +02:00
Levi Neely 6abf0cdb3d execute: parallel dispatch via flock; agent: preTool/postTool hooks, turn rollback, mid-turn compact
execute_code auto-batches consecutive tool steps annotated '# ollie:parallel read'
into goroutine fan-outs. Write/global steps serialize. LOCK_SH/LOCK_EX via
syscall.Flock in a per-session lock dir for cross-process safety. Tool scripts
declare their own parallelism profile; no tool names hardcoded in Go.

- flock.go: lockClass, classifyStep (annotation-driven), acquireFlock
- tools.go: LockDirSetter interface
- server.go: lockDir field, SetLockDir method
- pipe.go: runReadBatch with shared-lock goroutine fan-out
- code.go: auto-batching pipeline loop
- core.go: pushLockDir wires session tmpdir to execute server at init;
  preTool/postTool hook callbacks in agentConfig; AutoCompact after each
  tool round; session snapshot/restore on turn failure

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 09:00:29 +02:00
Levi Neely a4bb7608c7 expand ~ in cwd across agent core, hooks, and execute server
- Add paths.ExpandHome() helper for tilde expansion
- Apply in NewAgentCore, SetCWD (agent + execute server), and hook runner
- Fixes 'chdir ~/path: no such file or directory' errors
2026-04-24 20:10:42 +02:00
Levi Neely 0fd3bf1cf8 test: paths 100%, execute 96.2% (was 71%)
- pkg/paths: cover CfgDir/DataDir env and default branches
- execute: cover all injectArgs languages, resolveCodeStep, runStage,
  dispatchExecuteCode, executeElevated via fake elevate script,
  elevated paths in runStage/dispatch, language branches (python, perl,
  bc, jq, awk, sed, ed, lua), limitedWriter edge cases, loadSandboxConfig,
  detectLanguage shebangs
2026-04-21 22:00:08 +02:00
Levi Neely 0b64808ef5 pkg/tools: add contract tests, remove Close from Server/Dispatcher
- Add contract tests for tools.Server and tools.Dispatcher interfaces
  (tools_test.go), covering all exported behavior including error paths.
  pkg/tools coverage: 0% -> 100%.
- Add contract test for execute.Server (ListTools, CallTool), Decl
  factory test, and executeElevated early-exit test. execute coverage:
  68% -> 71%.
- Remove Close() from Server and Dispatcher interfaces and all
  implementations/callers. These existed for MCP server cleanup which
  has been removed.
2026-04-21 13:38:02 +02:00
Levi Neely 85b0d7f6fa remove MCP support, add execute_code tests
- Remove pkg/mcp/ (client, transport, JSON-RPC handshake)
- Remove mcpServer adapter and NewServer() from tools.go
- Remove MCPServers/ServerConfig from config
- Remove MCP server connection loop from BuildAgentEnv
- Remove ListServers() from Core interface and agentCore
- Remove /mcp command and help line
- Rename extractMCPResult -> extractToolResult
- Rename mcpToolsToBackend -> toolInfosToBackend
- Add execute_test.go: 28 tests covering detectLanguage, injectArgs,
  ansiCEscape, ValidateCode, allowed, ReadTool, Execute, Dispatch
  (pipeline, parallel, tool steps), limitedWriter, rate limiting,
  SetEnv, SetCWD (68.2% coverage from 0%)
- Add testdata/sandbox/default.yaml for real sandboxed test execution
2026-04-21 13:25:32 +02:00
Levi Neely 46272f22a6 test: sandbox coverage + backend contract tests
- sandbox: remove dead code (DefaultConfig, Load/Save, LayeredConfig, Merge,
  Version, SystemDefaults, validateName, ConfigPath, OpenSandbox); unexport
  internal symbols; LoadSandbox now takes io.Reader; loadSandboxConfig owns
  file opening; 83% package coverage via new sandbox_test.go
- backend: add BaseURL field to AnthropicBackend for testability; new
  backend_test.go runs checkContract against all five implementations
  (Ollama, OpenAI, Copilot, Anthropic, CodeWhisperer) via httptest servers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 13:00:06 +02:00
Levi Neely aeeb0a3e22 execute: prepend \$OLLIE/x/ to PATH for tool subprocesses
Allows wrapper scripts in ~/.config/ollie/scripts/x/ to shadow system
binaries transparently without modifying the user's shell environment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 11:07:23 +02:00
Levi Neely 56c299d29b elevation: replace Elevator interface with x/elevate plugin script
Remove the elevation package and Elevator interface entirely. The
execute server now invokes x/elevate directly, with detection reduced
to a stat check. Decl() loses the elevator parameter.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 20:50:20 +02:00
Levi Neely e09a6c1250 elevation: add Elevator interface + superpowers backend; add elevated:true to execute_code steps
Remove session-scoped env injection from frontend (s/{id}/env, -e/-env flags) — superseded
by per-invocation superpowers run-session in the elevator. Keep agentCore env map and
OLLIE_SESSION_ID propagation via pushSessionEnv.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 20:06:43 +02:00
Levi Neely 44bff71a65 env: centralize daemon env in pkg/env; clean up session env propagation
- New pkg/env package owns EnsureDefaults, Set, Get, All, Format
- BuildAgentEnv reverted to 3-arg signature (no initialEnv)
- agentCore.setEnv removed; pushSessionEnv handles OLLIE_SESSION_ID only
- execute.Server.SetEnv no longer calls os.Setenv (session-scoped only)
- !cmd handler sets OLLIE_SESSION_ID explicitly in subprocess env
- mcp/transport: seed cmd.Env from os.Environ() so MCP servers inherit PATH etc.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 15:43:01 +02:00
Levi Neely 92034b5342 add OLLIE_CFG_PATH and OLLIE_DATA_PATH env vars
Replace all hard-coded ~/.config/ollie and ~/.local/share/ollie paths
with a new paths package that reads OLLIE_CFG_PATH and OLLIE_DATA_PATH,
falling back to the previous defaults when unset.
2026-04-17 15:31:19 +02:00
Levi Neely c2ba1728e4 execute: unify execute_pipe into execute_code as pipeline primitive
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 21:36:22 +02:00
Levi Neely ab96de2771 execute: remove execute_tool; use execute_code {tool} steps instead
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 21:18:12 +02:00
Levi Neely cf25268d80 execute: refactor execute_code to parallel steps; add parallel pipe stages
- execute_code now takes steps:[{code,language}|{tool,args}] instead of
  a single code/language pair. Single-step calls return raw output;
  multi-step calls run in parallel and return results under === step N ===
  headers in submission order.
- execute_pipe stages may now include {parallel:[...]} to fan out
  concurrently within a pipeline. Parallel outputs are concatenated in
  submission order and fed as stdin to the next stage.
- Stage execution is now Go-level (stdin chaining) rather than a single
  bash pipeline string, enabling parallel stages and tool/code mixing.
- CodeStep and resolveCodeStep are the shared primitives for both
  execute_code and execute_pipe parallel stages.
- executeWithStdin added to Server for stdin chaining between stages.
- Tool steps use shebang detection; language field applies only to
  inline code steps (default: bash).
- ListTools schemas and descriptions updated throughout.
2026-04-16 20:06:05 +02:00
Levi Neely da094e9803 Revert "execute_tool: resolve tools from $OLLIE/t"
This reverts commit 42b7b5b5c2.
2026-04-15 11:13:37 +02:00
Levi Neely 42b7b5b5c2 execute_tool: resolve tools from $OLLIE/t
ToolsPath() fell back to ~/.config/ollie/tools when OLLIE_TOOLS_PATH
was unset, ignoring the 9P mount entirely. Add /home/lkn/mnt/ollie/t as the
preferred fallback so execute_tool finds tools on the mounted
filesystem regardless of cwd.
2026-04-15 11:12:53 +02:00
Levi Neely 655b9e7060 fix: surface tool script errors to model; inject session env at startup
- extractMCPResult: parse isError from MCP response so tool failures
  are returned as Go errors and marked isErr=true in the loop
- CallTool: emit isError:true content block instead of bare {"error":...}
  so the model sees tool failures as error results, not success
- SetEnv: call os.Setenv so OLLIE_SESSION_ID/OLLIE are in the process
  env and inherited by sandboxed subprocesses
- NewAgentCore: inject session env into execute server at creation time,
  not only on rename, so tools have OLLIE_SESSION_ID from the first call

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 22:49:00 +02:00
Levi Neely 13590a84e7 implement TrustedTools: explicit trust replaces implicit allow-all
- Add TrustedToolsSetter interface and SetTrustedTools to execute.Server
- Add allowed(): trusted tools return true; untrusted with no Confirm
  return false (deny by default). Confirm returns true=allow, consistent
  with allowed() semantics throughout.
- BuildAgentEnv wires cfg.TrustedTools into the execute server

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 17:52:37 +02:00
Levi Neely 4e230d6f0c fix execute_tool: detect language for #!/usr/bin/env shebangs
detectLanguage only checked filepath.Base(fields[0]), which returns
"env" for #!/usr/bin/env python3. Every such script was run as bash,
producing syntax errors. Now checks fields[1] when fields[0] is "env".

Also add OLLIE_MEMORY_PATH to default env passthrough.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 17:29:19 +02:00
Levi Neely 87f056e221 prompt: idx-based tool/skill discovery; session self-awareness
- Replace {{.Tools}} injection with ollie/t/idx (generated at session
  start by rebuildToolsIdx); prompt now instructs grep-based discovery
- Replace {{.Skills}} injection with ollie/sk/idx (rebuildSkillsIdx);
  same grep pattern
- Add {{.SessionID}} to system prompt identity line
- Expand filesystem section: full ollie/s/ layout, all session files,
  ctl commands, s/idx cooperation pattern
- Fix execute_tool description: use ollie/t instead of physical ToolsPath()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 14:27:39 +02:00
Levi Neely 5d86326edf execute: language-specific dangerous patterns; skip domain-specific tools
universalPatterns: mkfs, dd if=/dev/, sudo/su, /etc/shadow|sudoers
bashPatterns: rm -rf flag syntax, fork bomb, redirects, eval "...$"
pythonPatterns: shutil.rmtree, os.system/subprocess with rm -rf, os.remove on sys paths
perlPatterns: system/exec/backtick with rm -rf, unlink glob on sys paths
luaPatterns: os.execute/io.popen with rm -rf, os.remove on sys paths
Domain-specific tools (awk, sed, jq, ed, bc, expect) skip validation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 13:36:18 +02:00
Levi Neely 109622ded1 execute: remove bash wrappers; use direct invocation and stdin piping
awk/sed/jq: exec.Command directly with program as arg — no shell, no escaping.
ed/expect/bc: exec.Command with cmd.Stdin — program piped without escaping.
execute_tool with file args: language switches to "bash" after injectArgs
since the resulting snippet is already a bash command.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 13:32:25 +02:00
Levi Neely cdbf3096be execute: add lua support via lua -e; arg table injection
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 13:28:16 +02:00
Levi Neely b65fc0fdf7 execute: add jq, expect, bc support
jq: filter as positional arg, file args appended, pipeline-safe.
expect: pipes script via printf '%s' $'...' | expect -.
bc: pipes via printf '%s' $'...' | bc -ql (quiet + math library).
All three use ANSI-C quoting consistently.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 13:25:43 +02:00
Levi Neely 9ec58b0ae8 execute: add sed and ed support; refactor detectLanguage to use shebang basename
sed: sed -e $'...' inline, file args appended, pipeline-safe.
ed: pipes script via printf '%s' $'...' | ed -s [file].
detectLanguage now parses shebang command basename rather than
using strings.Contains, fixing potential false matches.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 13:18:08 +02:00
Levi Neely 2ecdcc26c8 execute: add awk support via gawk -e; file args passed after --
Uses gawk -e $'...' (ANSI-C quoting) consistently across Execute() and
pipelines. injectArgs for awk produces a bash snippet with file args
after --. No BEGIN block hacks needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 13:15:27 +02:00
Levi Neely 3f0a77619b execute: add perl support (shebang detection, @ARGV injection, pipe support)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 13:07:03 +02:00
Levi Neely 2d122c70dd gate file tools with sandbox path checks
file_read, file_write, file_edit, file_grep, and file_glob now check
paths against the sandbox config before operating. Same policy that
landrun enforces on execute_code, applied at the application level.

- Add sandbox.LoadMerged: loads base config + named layer, graceful
  fallback if layer missing. Replaces duplicated logic in execute.
- Add sandbox.CheckPath: resolves symlinks, expands templates, checks
  path against allowed entries (RO/ROX for read, RW/RWX for write).
- file.Server.checkAccess wires the check into every file dispatch.
2026-04-13 18:37:17 +02:00
Levi Neely 809ad3472d rename workdir to cwd
Go API: WorkDir→CWD, SetWorkDir→SetCWD, WorkDirSetter→CWDSetter.
Unexported: workdir→cwd in fields, params, locals.
Docs: README.md updated.
2026-04-13 18:03:20 +02:00