Commit Graph
297 Commits
Author SHA1 Message Date
Chris Scott 64e87ba1ea fix: guard the Assistant config conversion and place agent permission fallbacks after catch-all rules (OM-179)
The Assistant v1-to-v2 conversion now skips the write when OpenCode returns no converted assistant agent for a customized v1 one, or when the converted config fails validation, and it shares a file lock with ensureAssistantMode so the two never overwrite each other.

A new agent wildcard permission rule is inserted after the last catch-all * * rule instead of before it, so the catch-all cannot override it. The event subscription also counts each received event as stream activity.
2026-11-05 16:16:49 -05:00
Chris Scott 670c66f85b fix: add a Default agent permission choice and stop forwarding cookies to OpenCode (OM-179)
Each agent permission select now offers Default, shown when the agent has no wildcard rule for the action. Choosing Allow, Ask or Deny writes an agent rule even when it matches the inherited effect; choosing Default removes the agent's wildcard rules so the global permission applies.

The local OpenCode proxy drops the browser's Cookie header, as the linked-server proxy already does.
2026-11-05 15:58:53 -05:00
Chris Scott 38d618be9b fix: limit the restart-pending 409 to entity patches and keep inherited agent permissions (OM-179)
PATCH /opencode-config refuses only patches that name an agent, command, provider or MCP server while a restart is pending; other keys still apply. The assistant API reference documents the new 409.

The agent dialog adds a wildcard permission rule only for an action whose effect the user changed, so saving an agent no longer overrides an inherited global ask or deny.
2026-11-05 12:43:42 -05:00
Chris Scott 8d92f86142 fix: apply CodeRabbit auto-fixes 2026-11-03 08:29:59 -05:00
Chris Scott 3e6ebbd1dc fix: hold the upstream resync until the OpenCode proxy accepts requests (OM-179) 2026-11-03 00:06:39 -05:00
Chris Scott 9fca96ecea fix: refuse entity saves while a restart is pending and share replay payloads (OM-179) 2026-11-02 23:47:42 -05:00
Chris Scott 8a6fd56e9a fix: keep config references on save and apply review batch 2 fixes (OM-179) 2026-11-02 23:21:33 -05:00
Chris Scott 49bb4ebd36 loop: om-179-finish-adopting-op completed after 19 iterations 2026-11-02 13:13:31 -05:00
Chris Scott 0b2303a870 section 11: Phase 11: Assistant Mode writes v2 config; remove the hand-w 2026-11-02 11:20:39 -05:00
Chris Scott 6578e11eeb section 8: Phase 8: Managed effective config read through api.config.ge 2026-11-02 10:36:56 -05:00
Chris Scott 19d4ae25b6 section 7: Phase 7: Entity saves replace the matching v1 entry in the s 2026-11-02 10:32:28 -05:00
Chris Scott 48ca38c4e3 section 6: Phase 6: Config.Info validation owner and v2 config types in 2026-11-02 10:23:14 -05:00
Chris Scott 66b5d1ac06 section 5: Phase 5: Stop buffering in /api/opencode/* 2026-11-02 10:15:37 -05:00
Chris Scott 2b00825b0a section 4: Phase 4: One streaming proxy forwarder used by both proxy ro 2026-11-02 10:11:15 -05:00
Chris Scott 680a336a24 section 3: Phase 3: Remote server events use the registry client; remov 2026-11-02 10:08:00 -05:00
Chris Scott d749084163 section 2: Phase 2: Local SSE aggregator streams through the local Open 2026-11-02 09:57:21 -05:00
Chris Scott 01d8f0825a section 1: Phase 1: Shared reconnecting OpenCode event subscription and 2026-11-02 09:51:53 -05:00
Chris Scott 65066ab0dc feat(schedules): per-schedule switch to keep runs out of the inbox and notifications 2026-10-30 13:11:35 -04:00
Chris Scott 5db74e3fa7 fix(goals): validate the goal RPC output before returning it 2026-10-30 01:03:14 -04:00
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 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