Commit Graph

646 Commits

Author SHA1 Message Date
ollie 69b90de68f remove ensureElevateAdapter
The elevation adapter is now managed by the system service manager
(openrc/systemd), not started on-demand from inside the sandbox.
The on-demand approach was unreliable (needed master token access,
exec chain failures on Gentoo, stale instances on socket).
2026-07-21 11:48:53 +02:00
ollie edc96cc841 executeElevated: improve error message when exit non-zero with no output
When the elevated process exits with a non-zero code but produces no
stdout/stderr output, report a cleaner error message instead of the
confusing "Output: " with empty string.
2026-07-21 07:28:21 +02:00
Levi Neely 05e43b9a7c agent: resolve prompt from file paths and OLLIE_PROMPTS_PATH 2026-07-20 13:37:09 +02:00
ollie 663311daa0 remote: persist Remote field in session save/restore 2026-07-19 21:53:01 +02:00
ollie 9c1dd58474 streaming: tool output streams into [tool:] block, no new roles 2026-07-19 21:36:55 +02:00
ollie 805933453f streaming: tool output streams into tool block directly 2026-07-19 21:25:42 +02:00
ollie 5fc7bd816e streaming: emit partial tool output via context callback 2026-07-19 21:06:13 +02:00
ollie d501b47bf7 prompt: store PromptEnvExtra on agent for /agent reloads
Added PromptEnvExtra to AgentCoreConfig and agent struct. The /agent
command now uses stored PRIME_* vars instead of recomputing locally.
This ensures remote sessions get the correct remote host info on
every prompt rebuild.
2026-07-19 20:37:37 +02:00
ollie 95d9e9fd85 prompt: unified PromptEnv for local and remote sessions
Added PromptEnv(cwd) helper that returns PRIME_CWD, PRIME_PLATFORM,
PRIME_IS_GIT_REPO. All callers of BuildRuntime now pass these.
prime script is now a pure template renderer with no detection logic.
Removed ad-hoc PRIME_CWD injection from prompt_resolver.
2026-07-19 20:26:52 +02:00
ollie a53d5b9618 remote: fetch host_info, inject PWD for remote prompt resolution
prompt_resolver: when cmd.Dir cannot be set (remote CWD does not exist
locally), inject PWD=cwd into subprocess env so envsubst in prime sees
the correct working directory.

remote.Server: fetch host_info RPC after connect, expose HostInfo struct
with platform, arch, is_git_repo for the session to pass to prompts.
2026-07-19 20:17:32 +02:00
ollie 414220c2e5 fix: pass PWD and OLLIE_UNAME to BuildRuntime in /agent command
The /agent command rebuilds the runtime but only passed OLLIE_SESSION_ID.
For remote sessions where cmd.Dir falls through, the prompt scripts need
PWD explicitly set to the session CWD for envsubst in prime.
2026-07-19 20:05:22 +02:00
ollie f19236d6df remote: SSH bootstrap with auto-deploy
Dial() now bootstraps ollie-remote on the remote host automatically:
- Computes SHA-256 of the local ollie-remote binary
- Sends a bootstrap script over SSH stdin
- If the remote has a matching cached binary, skips transfer
- Otherwise transfers gzip+base64 encoded binary
- Monitors stderr for OLLIE_LOADER_START/READY signals
- After bootstrap, stdin/stdout switch to JSON-RPC

The local binary is found at ~/bin/ollie-remote (just build output)
or ~/.local/bin/ollie-remote or PATH.
2026-07-19 19:54:57 +02:00
ollie 609e399219 remote: implement ListTools RPC and fix CallTool routing
remote.Server.ListTools() now calls the remote via a list_tools RPC
method instead of returning nil. This ensures the model receives
proper tool definitions through the API.

remote.Server.CallTool() now passes the actual tool name (execute_code,
call_tool, pipe) as the RPC method instead of hardcoding execute.
Simplified result handling since resp.Result is already json.RawMessage.
2026-07-19 19:49:31 +02:00
ollie 160e285e68 fix: prompt resolution for remote sessions + vet context leaks
prompt_resolver: guard cmd.Dir with stat check so remote CWDs that
do not exist locally do not cause prompt commands to fail with ENOENT.

server.go: add cancel on all early-return paths to fix go vet
cancel-not-used-on-all-paths warnings.
2026-07-19 19:43:12 +02:00
ollie 64ab94f121 hooks: skip non-existent CWD for remote sessions
If the session CWD does not exist locally (remote execution), do not
set cmd.Dir. This prevents fork/exec failures when the CWD only
exists on the remote host.
2026-07-19 19:18:28 +02:00
ollie 01e97daefc remote: parse port from user@host:port SSH target 2026-07-19 19:11:32 +02:00
ollie b218706f76 remote: use full path to ollie-remote binary
SSH non-interactive shells do not source .bashrc/.profile, so
~/.cache/ollie/bin is not in PATH. Use the full path directly.
2026-07-19 19:02:28 +02:00
ollie adb90e4e7c execute: skip sandbox config loading when Yolo is set
Previously loadSandboxConfig was called unconditionally, causing
failures on hosts without ~/.config/ollie/sandbox/ even when yolo
mode was enabled. Move the load inside the !Yolo branch.
2026-07-19 18:44:25 +02:00
ollie e468e15672 remote: add SSH-based remote execution client
Package remote provides a tools.Server implementation that forwards
tool calls to an ollie-remote process over SSH via JSON-RPC.

Key components:
- Dial(): opens SSH, launches ollie-remote, verifies with ping
- Server: implements tools.Server, forwards CallTool over RPC
- Decl(): factory compatible with tools.NewDispatcherFunc
- Config: SSH target, CWD, tools path, yolo flag

Integration: swap execute.Decl() with remote.Decl() in session
creation when remote= config is set.
2026-07-19 18:19:38 +02:00
ollie b4b0f2068d remove Makefile and mkfile (consolidated into root justfile) 2026-07-19 13:02:47 +02:00
ollie 519869a003 execute: ensure elevate adapter is running before elevated calls
Add ensureElevateAdapter() which probes the adapter socket and starts
elevate-adapter-start if unreachable. Runs in the execute server
process (outside the sandbox) so the adapter starts unsandboxed.
2026-07-19 11:33:34 +02:00
ollie 6f35059d83 agent/hooks: add run/fail summary to HookResult
Track Total, Succeeded, Failed counts and FailedCmds in HookResult.
Add Summary() method producing "(N of X hooks run) (K of X failed: cmd)".
Emit hook summary as info event at all lifecycle hook call sites and
on preTool/postTool failure.
2026-07-19 10:25:09 +02:00
ollie 4a96f6259a readme: document all 3 built-in tools (execute_code, call_tool, pipe) 2026-07-18 22:54:07 +02:00
ollie ae0b26e0a0 readme: update Core interface, fix backend list, remove nonexistent pkg/store 2026-07-18 22:52:36 +02:00
ollie 8645e6d2a1 readme: remove stale anvillm reference 2026-07-18 22:45:35 +02:00
ollie 2f93a45031 backend: shared HTTP transport pool for connection multiplexing
All backend constructors now use SharedClient() which returns an
*http.Client backed by a per-host shared *http.Transport. This enables
HTTP/2 multiplexing: multiple sessions targeting the same API host
share a single TLS connection instead of each maintaining their own.

The pool is keyed by "backend:baseURL" so different endpoints get
separate transports while same-host sessions multiplex.
2026-07-18 22:02:10 +02:00
ollie b4c88a33d3 route: fetch real models from backends, pick by number
Route() now queries all configured backends for their model lists,
presents them numbered to the classifier, and parses the number.
No more hardcoded OLLIE_ROUTE_MODEL_FAST/POWER env vars.
2026-07-18 17:09:55 +02:00
ollie 8a995c1b13 route: use numbered classification for reliability
Ask classifier to reply with 1 or 2 instead of full model names.
Previous approach produced garbled partial names.
2026-07-18 17:05:48 +02:00
ollie 1b92c49c27 backend: add Generate() and Route() stateless one-shot functions
Moves /generate and /route logic from 9p server to core so both
9p and dbus frontends can use them.
2026-07-18 16:59:29 +02:00
ollie 3a6be7a8a9 kiro: use q.<region>.amazonaws.com for ListModels (same as kiro-cli)
The management.*.kiro.dev endpoint was slower/less reliable. Switch to
the same q.<region>.amazonaws.com endpoint that kiro-cli uses, deriving
the region from the profile ARN or runtime endpoint.
2026-07-18 12:54:38 +02:00
ollie 93f672df20 kiro backend: cache Models() for 24h, cache sqlite tokens for 60s
Models() now caches at the backend level (shared across sessions) with
a 24h TTL, eliminating repeated expensive HTTP calls to AWS.

The sqliteKiroAuth.load() now caches token reads for 60s, avoiding
shelling out to sqlite3 on every API call (previously 3x per Models
fetch).
2026-07-18 01:40:19 +02:00
ollie 42361e6505 execute: support elevated+detach combination
Rewrite executeElevated to use the same select/detachCh pattern as
executeWithStdin. When both elevated and detach are set, the process
is immediately backgrounded into the detach registry with streaming
output captured in the ring buffer.

Also adds the detach field to the execute_code JSON schema description.
2026-07-18 00:16:20 +02:00
ollie c1124b588d execute: add detach field for autonomous background processes
When detach: true is set on a CodeStep, the process is immediately
backgrounded after start. Its stdout/stderr are captured in a 64KB
ring buffer accessible via GetDetachedOutput. The agent can then
inspect and manage the process via process_list/process_output tools.
2026-07-17 23:28:14 +02:00
Levi Neely b6d0653d0b execute: fix detached process killed by WaitDelay
After detach, cmd.WaitDelay was still 1s, causing Go exec to
kill the process after context cancellation + 1s delay. Clear
both cmd.Cancel and cmd.WaitDelay in the detach path.
2026-07-17 22:15:05 +02:00
Levi Neely f8ed2189f1 agent: inject detached process output on exit
When a detached process exits, its output (last 2KB of ring buffer)
is queued as a prompt wrapped in <detached-process-result> tags.
The agent sees it on its next turn (or immediately if idle via Queue).

- InjectSystemEvent(content) added to Core interface
- SetOnExit(fn) added to execute.Server for external hook wiring
2026-07-17 22:07:26 +02:00
Levi Neely c0a52a8031 execute: timeout=0 means no timeout
Allows long-running daemons to be started without a deadline.
timeout < 0 still defaults to 30s. Schema descriptions updated.
2026-07-17 17:06:12 +02:00
Levi Neely 5df603a9e3 agent: expose detach methods on Core interface
Adds Detach, ListDetached, SignalDetached, GetDetachedOutput,
DismissDetached to the Core interface. Implemented on agent struct
via interface type assertions to the execute server.

Also adds ListDetachedRaw() to execute.Server for cross-package
consumption without import cycles.
2026-07-17 16:49:29 +02:00
Levi Neely 16d057741c execute: add process detach mechanism
Allows the user to detach a running process from the agent mid-execution.
The process continues running; output flows to a 64KB ring buffer.
Detached processes can be listed, signaled (TERM/KILL), and dismissed.

- DetachedProcess struct with ring buffer, signal, output methods
- Server.Detach() signals the currently executing process to detach
- Execute() rewritten: cmd.Start() + select on wait/ctx/detach
- cleanupDetached() on Close() sends SIGTERM to all
- OnDetach/OnExit hooks for integration with D-Bus layer
2026-07-17 16:43:07 +02:00
Levi Neely aca0250b65 sandbox: handle colon-separated paths in env vars
OLLIE_SKILLS_PATH, OLLIE_AGENTS_PATH, OLLIE_PROMPTS_PATH can be
colon-separated (like PATH). Both WrapCommand and checkPath now
split expanded values on ":" so each component is granted access
individually.
2026-07-17 15:13:55 +02:00
ollie 817814ab62 Ensure execute processes terminate promptly 2026-07-16 19:58:15 +02:00
ollie 451dc96d47 agent: add SaveSession to Core interface for external persistence
- Add Backend/Model fields to PersistedSession for full restore metadata
- Add saveToFull() that includes backend/model in persisted state
- Add exported LoadPersistedSession(path) helper
- Add SaveSession(path) to Core interface, implemented on agent struct
- Existing saveTo() preserved as backward-compatible wrapper
2026-07-14 20:41:38 +02:00
ollie a50149d075 fix: send profileArn for social accounts, improve error messages
- Remove IsSocial guard from sqliteKiroAuth.ProfileARN(); the Kiro API
  now requires profileArn on all requests including personal accounts
- Add OLLIE_KIRO_PROFILE_ARN env var for static token auth
- Add repeated error detection (3x identical error triggers corrective nudge)
- Include expected format in tool dispatch error messages
2026-07-11 16:08:44 +02:00
Levi Neely 75f137dda5 backend/kiro: port fixes from goq amzcodewhisp
- Switch endpoint from q.*.amazonaws.com to runtime.*.kiro.dev
- Use management.*.kiro.dev for ListModels
- Fix content encoding: plain string instead of json.RawMessage
- Fix tool results: always use text field (upstream rejects bare JSON primitives)
- Normalize tool call arguments (deduplicate keys)
- Expand retry conditions: add 502, 503, 408, InsufficientModelCapacity
- Add SQLite busy-timeout and Go-level retry for lock contention
- Add 30s refresh timeout and fullLoad before refresh
- Add SSO cache fallback for token refresh
- Add jitter to token expiry checks
- Add sqliteHasNewUsableAccessToken for cross-process recovery
- Add envState to current message
- Update user-agent strings to 1.3.15/2.5.1
- Set X-Amzn-Codewhisperer-Optout to true
- Add reasoning/thinking support (additionalModelRequestFields)
- Add counter-thinking tags on user messages before assistants
- Handle reasoningContentEvent in stream
2026-07-10 11:43:18 +02:00
Levi Neely 0fc9c9613c kiro: update API version and retry transient 500s
The Kiro/CodeWhisperer API started rejecting tool-use requests from
older API versions (0.1.14474) with InternalServerException. Update
to 0.1.16551 and appVersion 0.12.333 to match kiro-cli.

Also add retry with linear backoff (1-5s) for transient 500 errors
which still occur intermittently even with the correct version.
2026-07-10 10:28:48 +02:00
Levi Neely fd20070294 refactor: remove 9P mount logic from core execute server
Moved all 9P FUSE mount code from core to 9p module using lifecycle hooks.

Changes:
- Removed 9P-specific fields (mountProc, mountPath, mountEnabled) from execute.Server
- Removed WithMount(), MountPath(), startMount(), remountIfStale() functions
- Added lifecycle hooks: OnPreDispatch, OnClose, OnEnvSet with corresponding options
- Updated SetEnv(), Close(), and Dispatch() to call hooks instead of hardcoded mount logic
- Fixed tool descriptions to use $OLLIE_TOOLS_PATH instead of 9P-specific $OLLIE/s/$SID/t paths
- Removed unused execute import from agent/commands.go

The core execute server is now harness-agnostic.
2026-07-08 15:55:10 +02:00
ollie f05b736af9 agent: update preamble when cwd changes
SetCWD now replaces old cwd references in the system prompt,
matching the pattern used by SetSessionID. Without this, the
model continued to see the original cwd in its environment
section after a directory change.
2026-07-07 12:20:48 +02:00
ollie 331edc332d fix test 2026-07-01 21:22:16 +02:00
ollie 8e7dd60a8b agent: remove $OLLIE mount dependency from core
- Add ListHandlers map to AgentCoreConfig/agent struct; /skills and /tools
  dispatch through it instead of reading local paths directly
- Add ReadPlanStep to AgentCoreConfig; wired by 9p/ directly from sess.plan
- Export NextUncheckedStep([]byte) as pure helper
- Fix prependOlliePath to use OLLIE_CFG_PATH/scripts/x/ instead of $OLLIE/x/
- Add OLLIE_CFG_PATH to EnsureDefaults and managed env var list
2026-06-16 12:30:36 +02:00
ollie 72ae801e3f add GNU Makefile mirroring mkfile 2026-06-16 06:50:55 +02:00
Levi Neely 391f633785 env: Format() emits only managed vars, not entire process env 2026-06-15 10:49:30 +02:00