Commit Graph
393 Commits
Author SHA1 Message Date
Chris Scott cbe92c92ad refactor(goals): replace the Manager session-goal API with OpenCode built-in /goal 2026-10-29 12:38:39 -04:00
Chris Scott 82c46bbdb2 Merge pull request #469 from chriswritescode-dev/feat/schedules-sandbox
feat(schedules): run scheduled jobs in a per-job sandbox microVM
2026-10-25 16:44:02 -04:00
Chris Scott b46dd27e5b fix(schedules): retry run sandbox removal after the session sandbox is turned off mid-run 2026-10-25 16:39:28 -04:00
Chris Scott 060159f10b fix(schedules): validate sandbox only when updated and tear down by the run session's sandbox state 2026-10-25 16:28:40 -04:00
Chris Scott 070cb2f729 feat(schedules): run scheduled jobs in a per-job sandbox microVM 2026-10-25 14:49:38 -04:00
Chris Scott 8747cfece9 fix(notifications): phrase permission labels without losing acronyms
The always-allow summary interpolated the raw action id ("always allow
shell") while every other surface shows the label ("Run Command"), and
the permission dialog lowercased the whole label, turning "Fetch URL"
into "fetch url". getPermissionPhrase lowercases each word of the label
unless it is all caps, and both the scope summary and the dialog
question use it.
2026-10-25 11:20:21 -04:00
Chris Scott a769d3fd34 fix(notifications): reject push registrations from revoked sessions
POST /subscribe re-checks the registering auth session inside the same synchronous transaction as the upsert, so a request accepted before a logout cannot restore a revoked session_id over a newer registration. A stale request gets 401, which the session sync already tolerates.
2026-10-24 19:26:21 -04:00
Chris Scott 6e398c4d40 fix(device-pairing): clean up push subscriptions on admin reset and share URL helpers
The admin password reset finds the admin case-insensitively and deletes the push subscriptions of the sessions it ends. The app re-sends its push subscription once per signed-in session so revoke reaches re-signed-in devices, and the upsert keeps the stored device name. Plain-HTTP and URL parsing checks are shared helpers.
2026-10-24 19:26:21 -04:00
Chris Scott cbe4f7ed9e refactor(auth): reset the admin and count users through the Better Auth adapter
The admin password reset and the first-user check read and wrote the
Better Auth tables with raw SQL, so session delete hooks never ran on the
reset path.

- the admin is found with findUserByEmail and its credential account is
  updated by id with the configured password hasher
- sessions are removed with deleteUserSessions, which runs the session
  delete hooks
- a missing credential account logs a warning instead of updating nothing
- /api/auth-info/config counts users through the adapter
2026-10-24 19:26:21 -04:00
Chris Scott b9d8d18124 fix(device-pairing): refuse to mint pairing codes from an address that cannot pair
A loopback origin in production or plain HTTP on a public address still
minted a code and showed a browser QR no other device could use.

- one availability rule decides untrusted, loopback and public plain-HTTP
  origins; POST /api/device-pairing/links checks it before minting
- GET /api/device-pairing/availability reports the rule for the page origin
  without minting
- Connect a device disables "Show QR code" and explains the fix when the
  address cannot pair
- private-network plain HTTP keeps the browser QR; the app QR still needs
  the toggle
2026-10-24 19:26:21 -04:00
Chris Scott f8e4cfe136 feat(device-pairing): pair phones and browsers with a QR code
Settings -> Account gets "Connect a device", a paired-devices list, and a
remote access headers editor, so the mobile app and other browsers can sign
in without typing a password and pass a reverse proxy such as Cloudflare
Access.

- one-time pairing codes (3 min TTL) minted by a Better Auth plugin and
  redeemed into a new session that records the device name
- POST /api/device-pairing/links builds the ocm://link app link with the
  stored headers as h= parameters and a browser /pair link; plain-HTTP and
  loopback origins are blocked or warned about
- remote access headers are stored encrypted, returned by name only, and
  validated (8 headers, 512-char values, 1800 encoded characters, reserved
  transport names blocked); a Cloudflare Access service token preset fills
  CF-Access-Client-Id and CF-Access-Client-Secret
- login offers "Sign in with QR code" and /pair redeems a scanned code,
  returning to the login redirect target
- revoking a device deletes its session, closes its live connections and
  removes its push subscriptions; the current session cannot be revoked
2026-10-24 19:26:21 -04:00
Chris Scott 5b0e629182 Merge pull request #432 from chriswritescode-dev/feat/repo-secrets
feat(secrets): repository secrets and variables for agent shells and terminals
2026-10-24 19:25:22 -04:00
Chris Scott 92c2d49e5c fix(backend): classify clone auth failures before not-found and isolate server tests from host PIDs
Clone error mapping matched a bare '404' anywhere in git's stderr, so an authentication failure on a URL whose port contained 404 was reported as repository not found. 401 and 404 are now matched as HTTP statuses and authentication is checked first. The single-server tests stub process.kill so they never probe or signal real host processes; PID 1234 existing on a Linux runner made them fail.
2026-10-24 19:15:00 -04:00
Chris Scott 21c60edd09 fix(secrets): collapse legacy scope duplicates on rollback and verify repo worktrees
Rolling back the scope-index migration now keeps the newest of a colliding global and Assistant-repo secret, matching the legacy last-write-wins upsert, so the legacy unique index can be recreated. The repo-env fallback now returns a registered repo only when the directory shares its Git metadata, so a separate clone of the same origin no longer receives the registered repo's secrets; external worktrees still resolve. The migration uses a named export.
2026-10-24 11:06:30 -04:00
Chris Scott e3557f8eec fix(secrets): separate global from assistant-repo scope and require an exact repo root
Global secrets used COALESCE(repo_id, 0), the same key as the Assistant repo (id 0), so same-named values overwrote each other. A new migration rebuilds idx_secrets_scope with a -1 sentinel shared with the upsert target, so databases that already applied the secrets migration upgrade cleanly. Repo env resolution now requires an exact registered git root, so an unregistered nested repository no longer receives its ancestor's secrets.
2026-10-24 10:37:45 -04:00
Chris Scott 4b7652451b fix: order linked-server projects by session activity and stop waking idle projects
OpenCode stamps project time.active whenever a location boots, and directory-scoped requests boot it, so the Manager's reconnect made every idle linked-server project look recently active. Remote projects are now ordered and labelled by their newest session's update time (one global session list per server), falling back to time.updated. Pending permission, form and shell lists, and the backend replay, only run for linked-server directories with running sessions, tracked pending work or the viewed route. The hard-coded status dot on remote project cards is removed.
2026-10-24 00:32:13 -04:00
Chris Scott 3e51280894 fix(secrets): forward only planned variables into the sandbox and cache repo env resolution
The sandbox shim forwards only the plan's pinned names, so turning sandbox Git credentials off withholds tokens. Sandboxed shells resolve repo env once, terminals on linked servers get no local env, mapping keys cannot override git credentials, masks are kept per directory, and directory resolution is cached. A legacy gh-env alias keeps adopted OpenCode processes working for one release.
2026-10-23 23:47:44 -04:00
Chris Scott a0d1d91f18 fix(secrets): target the scope index in the secrets upsert
A bare ON CONFLICT DO UPDATE fires on any unique constraint violation; naming idx_secrets_scope keeps a future constraint from silently redirecting the update.
2026-10-23 22:59:57 -04:00
Chris Scott e0331b43bf feat(secrets): repository secrets and variables injected into agent shells and terminals
Add a GitHub Actions-style store for secrets and variables so tests can read
credentials from the environment without .env files in the repo.

- secrets table keyed by kind, repo (NULL for global) and environment;
  secrets are encrypted with encryptSecret and write-only, variables are plain
  text. Names follow GitHub's rules and reject Manager-reserved names.
- Global (/api/secrets, /api/variables) and repo
  (/api/repos/:id/secrets|variables) routes.
- The trusted .ocm/project.json gains environment and env fields that map
  names to ${{ secrets.X }} / ${{ vars.X }} expressions. Both are part of the
  trust hash; files without them hash as before, so existing trust survives.
- RepoEnvService.resolveForDirectory resolves the repo and approved mapping
  for any directory, including worktrees outside the repo folder, with
  environment > repo > global precedence. It never throws.
- /api/internal/shell-env replaces /git-credentials/gh-env and feeds the
  ocm-gh-env plugin, the sandbox shell plan and TerminalService.create.
- The plugin masks injected secret values as *** in completed tool results.
- The sandbox shell plan is now the only source of the guest environment: the
  plugin pins OCM_SANDBOX_FORWARD_ENV and the shim forwards only those names.
2026-10-23 22:59:57 -04:00
Chris Scott ac9e584448 fix(terminal): limit output capture to action terminals and release them by handshake
- only action and setup terminals get a hub; shells use the shared bridge
  and keep OpenCode's full replay
- upstream close 1000 or 4404 ends the stream with that code; any other
  close fails the hub with 1011 so viewers reconnect through the bridge
- each connect attempt times out, and pre-open input overflow closes with
  1013 instead of dropping keystrokes
- deferred commands wait for a release line instead of sleeping; the hub
  sends it once on open, and the bridge fallback sends it if the hub failed
2026-10-23 15:45:36 -04:00
Chris Scott 20017d2f7d chore(opencode): move the typed OpenCode SDK to the 2.1.2 pin
The runtime pin moved to 2.1.2 while @opencode/client stayed at 2.0.15, so
the shared typed contract no longer matched the server.

- @opencode/client and @opencode/plugin move to 2.1.2
- session projection follows the 2.1 event shape (native replaces
  providerState and state, compaction drops recent)
- worktree error stubs carry the _tag discriminator
- the contract test fails when the SDK version drifts from the pin
2026-10-23 15:45:36 -04:00
Chris Scott 0c4c024dcc fix(settings): validate git identity emails only on the request path
A stored identity email that failed the stricter rule made every settings
read fall back to defaults, and the next save persisted that reset.

- the stored preferences schema accepts any email string again
- PATCH /api/settings rejects an invalid gitIdentity or gitIdentities email
  with a field path, and saves the trimmed address
- the rule accepts local hosts such as root@localhost
2026-10-23 15:45:36 -04:00
Chris Scott 19b52ecd58 chore(opencode): move the pinned OpenCode version to 2.1.2
The supported floor is derived from the pin, so this raises the accepted
range to >=2.1.2 <3.0.0 for the bundled image, managed installs, and the
version check that gates startup.

- Dockerfile ARG OPENCODE_VERSION and the shared pin move together
- CI e2e installs 2.1.2 instead of 2.0.24
- contract, installer, manager, registry and settings fixtures follow the new
  floor, keeping their below-floor and wrong-major rejection cases
2026-10-23 14:41:48 -04:00
Chris Scott 10190940bd fix(stt): accept speech endpoints configured with a trailing /v1
An endpoint saved as http://host/v1 was turned into /v1/v1/audio/transcriptions
and every transcription returned 404. Strip a trailing /v1 when deriving the
server base URL, which also covers TTS and model discovery.
2026-10-23 14:08:33 -04:00
ioplex dabe750920 fix: key auth rate limiting on the socket address only and clear sent drafts after unmount
- auth: drop the AUTH_TRUSTED_PROXY_HEADERS opt-in. Configured headers were
  trusted from any peer, so direct access to the published port could still
  rotate them. Better Auth now reads only the Manager-set socket address
  header; the env, compose forwarding, docs and tests are removed.
- composer: a send that completes after the composer unmounted (session
  switched mid-send) left the submitted text in the per-session draft store.
  Sends now complete through mutateAsync and clear the stored draft only if
  it still matches what was submitted, so newer edits are kept.
2026-10-23 12:49:53 -04:00
ioplex 4ec62cd4e7 fix: address findings from the full Docker evaluation of main
Critical and high:
- repos: unlinking a local repo removes only the Manager reference and alias,
  never the repository files; confirm button reads "Unlink"
- auth: rate-limit by the socket address; trust proxy headers only when
  AUTH_TRUSTED_PROXY_HEADERS is set (documented and forwarded in compose)
- composer: per-session in-memory drafts (text, bash mode, attachments);
  Escape no longer clears the prompt
- url params: compose same-tick updates so schedule dialogs stay closed after
  create/delete; delete dialog names the job

Medium:
- tool rows show failures (non-zero shell exit, failed exploration members)
- voice conversation shows the specific error and a starting state
- settings: Escape in dropdowns and the shortcut recorder no longer closes
  the dialog; mobile deep links open the requested section; one content tree
  per platform
- closing pushed sheets, settings, tool panels and schedule dialogs goes back
  in history
- login returns to the requested page; signed-out pages make no
  authenticated requests
- action terminals keep their output (Manager-side output capture and replay)
- unpushed-commit detection, commit message kept on failure
- binary files with unknown extensions are detected and not editable
- tool panel resizes when docked and floats as a dismissible sheet when the
  page is too narrow
- Docker image runs tini as PID 1

Low: not-found states, add-repo and branch validation errors (4xx),
search-aware empty states, mobile repo sort/filter/select cues, sidebar
resize affordance and collapse shortcut, mobile unread badge, preview port
filtering, terminal close handling, walkthrough empty state and helper
session filtering, placeholder contrast, permission labels and focus,
TTS task-list sanitizing, git identity email validation, quieter git
logging, hermetic worktree tests, and accessible names for icon-only
controls.
2026-10-23 11:42:37 -04:00
Chris Scott 993a635ce0 fix(auth): make session revocation immediate
Deleting session rows did not end a session while the 5 minute cookie
cache served the signed cookie without reading the database, so an admin
password reset left the old session usable. Drop the cache so session
state is always authoritative, and cover revocation with a test.
2026-10-21 15:18:50 +00:00
Chris Scott eb3937ef7e fix(auth): update auth stack and remove token logging
Upgrade better-auth and @better-auth/passkey to 1.7.12 and hono to
4.13.13, which clears every auth-related advisory in pnpm audit. The
lockfile also picks up patched kysely, @simplewebauthn/server and defu.

Drop the Set-Cookie and cookie-name logging that exposed session tokens,
match ADMIN_EMAIL case-insensitively, revoke admin sessions when
ADMIN_PASSWORD_RESET rotates the password, and require user verification
for passkeys.
2026-10-21 11:00:15 -04:00
Chris Scott 382b26806e fix(events): clear stale pending questions from remote servers
- Drop pending forms and permissions when a session is deleted or its page returns 404
- Reconcile remembered remote directories on browser reconnect, not only local repos
- Purge pending items from remote servers that are disabled or removed
- Prefer the viewed session's pending item over a pinned item from another session
- Time out remote proxy GET/HEAD requests that never send headers (504)
2026-10-20 21:01:16 +00:00
Chris Scott 24745597f2 Merge remote-tracking branch 'origin/feat/linked-opencode-servers' into feat/remote-server-automation
# Conflicts:
#	frontend/src/lib/navigation.test.ts
2026-10-19 11:37:57 -04:00
Chris Scott 1659664d53 fix(servers): test edited server URLs with the stored password
Test always checks the draft URL. When the password is left blank, the stored password is reused only if the draft URL has the same origin as the saved server.
2026-10-19 11:37:40 -04:00
Chris Scott cb9b7645e6 fix(opencode-import): skip caches and worktrees when importing host state
First-run state import copied the entire host OpenCode data directory, including snapshots, repos, binaries, logs and worktrees, which could reach tens of gigabytes, block startup, and recurse into the manager's own checkout. Skip those top-level entries and any entry containing the destination.
2026-10-19 10:16:32 -04:00
Chris Scott e4a4afbad4 fix(schedules): recover runs across reconnects and cancel on unavailable servers
Re-check monitored schedule sessions when their server's event stream reconnects, finalize cancellation without contacting a disabled or removed linked server, and tighten the disabled-server goal recovery test.
2026-10-18 21:59:15 -04:00
Chris Scott 5586120ba2 fix(servers): guard stored credentials and reconcile remote session status
Reject a server address change to a new origin unless a password or
pairing is supplied, so the stored password is never sent to another
host. Test connection now checks the edited values and warns when an
origin change needs credentials. Replay and reconcile remote session
statuses on stream reconnect and browser resync so linked-server
sessions no longer stay busy. Treat malformed server session URLs as
not found instead of throwing.
2026-10-18 21:53:19 -04:00
Chris Scott 7874afdab9 feat(servers): bring linked-server sessions to parity with local
Add a read-only Source Control panel for linked servers backed by the OpenCode VCS API, broadcast remote events to every client, include recent linked-server sessions in Activity with per-server sidebar indicators, and enable the session picker, tool shortcuts, mobile activity, remote Skills panel and remote permission prompt titles.
2026-10-18 21:46:14 -04:00
Chris Scott 9ec2ed5903 fix(servers): address CodeRabbit review on linked-server automation
Scope session permission modes and schedule locks by server, keep remote schedule cleanup working when a server is disabled or removed, harden the session server-scope migration and rollback, reject local server multi-run targets, widen schedule query invalidation, and update CLI fixtures for server-scoped schemas.
2026-10-18 21:01:53 -04:00
Chris Scott 780d31087b Merge remote-tracking branch 'origin/feat/linked-opencode-servers' into feat/remote-server-automation
# Conflicts:
#	backend/src/services/remote-server-events.ts
#	frontend/src/components/navigation/MoreDrawer.test.tsx
#	frontend/src/components/navigation/moreDrawerItems.test.ts
#	frontend/src/lib/opencode-event-stream/openCodeEventStream.ts
#	frontend/src/pages/SessionDetail.tsx
#	frontend/src/pages/__tests__/SessionDetail.remote.test.tsx
2026-10-18 20:53:23 -04:00
Chris Scott f566556fd6 feat(servers): harden pairing and run linked-server sessions in the UI
Replace the plaintext pairing exchange with a nonce and HMAC proof plus
AES-256-GCM encrypted credentials, bumping links to v2. Track session
ownership per linked server so activity, session picker, transcript, MCP
and skills views work against remote servers. Share encrypted secret
access, event routing and URL helpers across backend, shared and CLI.
2026-10-18 20:27:34 -04:00
Chris Scott a9bdb8358f feat(servers): run Manager automation on linked servers 2026-10-19 00:06:34 +00:00
Chris Scott c591c15743 feat(servers): link remote OpenCode servers with QR pairing 2026-10-18 22:35:39 +00:00
Chris Scott a0bdecd9fc fix(walkthrough): wait for the walkthrough to be ready before completing open_walkthrough 2026-10-16 20:09:20 +00:00
Chris Scott 33d9523666 Merge pull request #436 from chriswritescode-dev/feat/activity-switcher
feat(activity): surface active work across the session picker, tool rail and mobile
2026-10-16 12:48:52 -04:00
Chris Scott 84cdffa261 fix(activity): roll subagent activity up to its root and accept only selectable windows
- List child sessions in the activity query and credit each child's latest update
  to its root, so Recent includes roots whose subagents were active inside the
  window; children never become rows, and only roots of in-window children are
  fetched
- Show and sort activity rows by that rolled-up time
- Restrict activityWindowMinutes to the selectable options on write, and coerce a
  stored unknown value to the default on read so it cannot reset every preference
2026-10-16 11:57:52 -04:00
Chris Scott 0b637cadf4 feat(walkthrough): build the change walkthrough in a spawned agent session
Replace the fixed, stop-based walkthrough with an agent-built one. Every
request (Generate, Update, Regenerate, /walkthrough, the multi-run button
and the agent's open_walkthrough) now spawns a separate walkthrough
session. That session reads the diff through a new walkthrough_changes
action, writes one self-contained HTML file into a Manager-owned
directory, and calls publish_walkthrough; the panel renders the file in a
sandboxed frame shared with the inline artifact card and the file browser
HTML preview.

Publication marks the walkthrough ready while execution is tracked
separately, so Stop, the 15-minute limit, polling, refine gating and
interruption when the target session is deleted follow the agent instead
of the first publish. One diff copy is reused per run. Regenerate
interrupts the previous session and removes its output directory.

Walkthrough sessions are kept and listed, with their completion and error
push notifications muted. The stop pipeline, its wire schemas and the
concurrency limiter it used are removed.
2026-10-16 03:58:31 +00:00
Chris Scott e0a1c093c7 fix(sandbox): reject core.worktree and symlinked .git redirects when deriving VM mounts 2026-10-15 16:53:49 -04:00
Chris Scott 2d2921a6c6 fix(sandbox): verify worktree back-links, fail fast on root lookup, and tidy settings saves 2026-10-15 16:53:49 -04:00
Chris Scott 1d001bc43e feat(sandbox): remove session VMs when the sandbox is turned off or idle
Turning a session's sandbox off now removes its microVM and Docker data volume in the background. The idle sweep removes idle session VMs instead of stopping them, covering stopped VMs and VMs left from before a Manager restart, and starts when the Manager boots. Removal is serialized against boots so a command planned during a removal gets a fresh VM.
2026-10-15 16:53:49 -04:00
Chris Scott 27c673d830 fix(sandbox): recreate orphaned microVMs with --replace
A session VM create that fails partway leaves an orphaned msb sandbox that msb ls omits but every later create rejects as already existing, so the session could never get a VM again. Retry the create once with --replace when msb reports the name already exists.
2026-10-15 16:53:49 -04:00
Chris Scott 052218d5d6 fix(sse): notify listeners of events that cannot be routed to a directory
session.deleted carries only a session id, so after a Manager restart the aggregator could not resolve a directory for sessions created earlier and dropped the event before any listener ran. Deleting such a session leaked its sandbox microVM and volume, its sandbox and permission mode rows, goals, and walkthroughs. Listeners now receive unroutable events with a null directory.
2026-10-15 16:53:49 -04:00
Chris Scott b21fdf5b94 feat(sandbox): per-session sandbox VMs with resource settings and provider arbitration
- Sandbox new root sessions by default with a per-session composer toggle;
  child sessions inherit their root session's mode (OM-82)
- Run each sandboxed root session in its own microVM that mounts only the
  session's repository, with per-session CPU/memory overrides, Settings
  defaults, idle stop, and a cap on running VMs (OM-89)
- Arbitrate shell sandboxing with other plugins (opencode-forge) through the
  shared opencode.sandbox-arbiter.v1 registry so exactly one provider
  sandboxes each call regardless of load order; fail closed on claim errors
- Throw when another plugin rewrites a pinned sandbox shell setting
- Tag sandboxed tool results with the owning provider and show it in the badge
- Hint the agent to start Docker inside the VM only when OCM owns the session
2026-10-15 16:53:49 -04:00