From 962c183117bf656280f81ee67029af47f72aba41 Mon Sep 17 00:00:00 2001 From: w3cj Date: Tue, 24 Nov 2026 15:41:16 -0700 Subject: [PATCH] fix(agents): imported opencode history brings no automations, approvals or resumed turns An export of opencode's history held what opencode 2.4 acts on without asking, so a hostile VM's export could run commands in the VM that imports it (opencode v2.4.1's source): its automations (automation), each a trigger and a shell command that it approved once and never asks about again (core/src/automation/shell.ts); the requests you said always to allow (permission, which Permission.evaluate turns into allow rules); each session's own rules (session_v2.permission, a Permission.Ruleset); the subagents' jobs (job), the queued messages (session_inbox) and the suspended sessions (session_v2.time_suspended), which its service starts or resumes when it starts (core/src/session/execution/restart.ts), with the session's agent's own rules, explore's allowing shell; a project's commands (project.commands), whose start command it runs with bash -lc for each worktree (core/src/worktree.ts); and its git repositories in its data folder (snapshot, repos, worktree), whose config can name a clean filter or core.fsmonitor that its own git update-index runs (core/src/snapshot.ts, git.ts). opencodeClean now empties the tables opencodeUnattended picks (automation, permission, job, session_inbox, and any whose name starts so), sets the columns opencodeNulled picks to NULL (time_suspended, commands, in any case), keeps only the deny and ask rules with a text action of every permission column, each written again from what sqlite3 read, so a key written twice can't keep an allow effect for JSON.parse (opencodeAllowRules), drops every view, and fails its check on a generated column (opencodeHidden). Its check counts each and must print 0, so a sqlite3 without JSON leaves the database out. A view, an upper-case column, a generated column and a duplicate key bypassed the first version, as the security review showed. opencode's HistoryOwn now names its background service's registration on every channel and the files written beside it (service-*.json, service.json.*, service-*.json.*) and its git repositories (snapshot, repos, worktree): an export leaves them out and an import never writes them, while a VM made again keeps them. The import's clean-up loop expands each as a pattern; TestHistoryImportScript holds every skip to a path's plain characters. Tests that failed first (fedora's gate): TestOpencodeCleanSchema (automation and permission emptied, a session's allow rule gone), TestHistoryImportRuns and TestHistoryExportRuns (service-local.json, the handoff's and the registration's temporary files); TestOpencodeCleanSessionRules fails closed without the statements. The review's additions: TestOpencodeCleanSchema (job, session_inbox, a suspended session, a project's commands), TestOpencodeCleanSessionRules (a key written twice, a non-text action, an upper-case column), TestOpencodeCleanHidden (a view, a generated column), and the git folders in the export and import tests. The review's docs fixes across the stack land here too: the changelog's What to do steps, the release page, the coding agents page, How it works and the design note. A kept rule whose resource is missing or isn't text gets "*", as opencode's Permission.Rule needs one, and the check also counts a rule that isn't in the rebuilt form, so a copy whose rules weren't rebuilt fails closed. A stack-wide review's last docs fixes land here: devvm rm deletes opencode's worktrees with the VM, so the changelog has a What to do step to commit their work first. The export's and the import's scripts, which the stack doubled, now go on the VM's input (onInput): a line with the script's length, the script, then the import's export. In the command's arguments, quoted for ssh's shared connection, macOS's ssh failed to start the session (mm_send_fd: sendmsg: Message too long), which the mini's e2e hit, the export first and then the import. The VM reads exactly that many bytes (dd bs=1) and runs the script only when it read them all, so an input cut short runs nothing (TestOnInputCutShort), and the script gets the rest as its input. TestHistoryScriptsOnInput holds every argument under 4 KiB; TestHistoryExportRuns and the import's runs use onInput too. The stub guest takes such a script off its input (inputScript), matches its switches and files() against it and keeps an export's and an import's in history-export.sh and history-import.sh, which history, history_import, rm_vm, existing_agents and layer_add read. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 12 +- docs/content/docs/contributing/design.md | 12 +- docs/content/docs/contributing/maintaining.md | 2 +- docs/content/docs/internals/agents.md | 25 ++- docs/content/docs/releases/0.2.0.md | 31 +++- docs/content/docs/using/coding-agents.md | 16 +- internal/agents/agents.go | 27 ++-- internal/structure/scripts_test.go | 2 - internal/structure/structure_test.go | 9 +- internal/stubtest/stub/guest.go | 53 ++++++- internal/stubtest/stub/stub_test.go | 67 +++++++++ internal/vm/agents.go | 104 +++++++++++-- internal/vm/agents_test.go | 29 +++- internal/vm/lifecycle.go | 6 +- internal/vm/lifecycle_test.go | 110 ++++++++++++-- internal/vm/oninput.go | 30 ++++ internal/vm/opencodedb_test.go | 142 ++++++++++++++++-- internal/vm/remake_test.go | 5 +- internal/vm/testdata/golden/agents.txt | 31 +++- testdata/script/existing_agents.txtar | 5 +- testdata/script/history.txtar | 6 +- testdata/script/history_import.txtar | 29 ++-- testdata/script/layer_add.txtar | 2 +- testdata/script/rm_vm.txtar | 5 +- 24 files changed, 647 insertions(+), 113 deletions(-) create mode 100644 internal/vm/oninput.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d81664a..e9fa303e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -223,14 +223,20 @@ These changes are on `main` and go out in the next release. ### What to do 1. Run `devvm update` in each existing VM's folder, and give the first one several minutes, because it builds base and its shared tools again ([details](https://next.devvm.dev/docs/releases/0.2.0/#pins-since-020-rc1)). -2. If an export that `devvm history export`, `devvm rm` or a VM made again wrote holds `.local/state/opencode/machine/home-key`, replace that key in the VM it came from and in each VM you imported it into, and pair their machines again, because the machines opencode pairs trust it. The details page has the steps, and those for a VM you deleted ([history](https://next.devvm.dev/docs/using/coding-agents/#history), [details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-machine-key-in-history-exports)). -3. If you imported opencode's settings with `devvm agent import`, restart each running VM that has opencode with `devvm restart`, because its opencode service took the password `devvm-redacted`, which every VM had. If this machine's opencode has remote access on, turn it off and on again for a new route, because your VMs got its route ([opencode's service](https://next.devvm.dev/docs/using/coding-agents/#opencodes-service), [details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-service-settings-in-vms)). +2. If you pair machines with opencode and an export that devvm wrote holds `.local/state/opencode/machine/home-key`, replace that key and pair again in the VM it came from and in each VM you imported it into, because every machine paired with that VM trusts the key ([history](https://next.devvm.dev/docs/using/coding-agents/#history), [details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-machine-key-in-history-exports)). +3. If you ran `devvm agent import` or `devvm agent save` for opencode, restart each running VM that has opencode with `devvm restart`, because its service took the password `devvm-redacted`, which every VM had. If this machine's opencode has remote access on, run `opencode service set remote false` and then `opencode service set remote true` on this machine, because your VMs got its route ([opencode's service](https://next.devvm.dev/docs/using/coding-agents/#opencodes-service), [details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-service-settings-in-vms)). +4. Before `devvm rm` of a VM where opencode made worktrees, commit the work in them, because an export no longer holds opencode's worktrees, and their commits stay in your project's repository ([history](https://next.devvm.dev/docs/using/coding-agents/#importing-history), [details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-automations-and-permissions-in-history)).
If you use opencode -- `devvm history export` and `devvm history import` now leave out opencode's machine key (2.4 and later) and its paired machines, its service's password and its terminals' access tokens, while a VM made again keeps them ([details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-machine-key-in-history-exports)). +- `devvm history export` and `devvm history import` now leave out opencode 2.4's machine key and paired machines, its service's password and its terminals' access tokens, which a VM made again still keeps ([details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-machine-key-in-history-exports)). - Each VM's opencode service now has a password of its own, which `opencode service get password` shows in the VM, and this machine's service settings and remote route never reach devvm's agent store or a VM ([details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-service-settings-in-vms)). +
+
Security hardening: a VM's history export can no longer have opencode run commands unasked in the VM you import it into + +- `devvm history export` and `devvm history import` leave out opencode's automations, approvals, allow rules, resumable turns, project commands and git repositories, so make again any automation you want in the new VM ([details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-automations-and-permissions-in-history)). +
Internal changes diff --git a/docs/content/docs/contributing/design.md b/docs/content/docs/contributing/design.md index e695a20a..d5956df2 100644 --- a/docs/content/docs/contributing/design.md +++ b/docs/content/docs/contributing/design.md @@ -761,10 +761,10 @@ The volume tells two disks apart that each have a folder with the same inode and opencode 2 keeps its sessions and its logins in one SQLite database, `~/.local/share/opencode/opencode.db` (`opencode-.db` for another channel's build), in WAL mode. An export of agents' history goes to this machine and can go into another VM of the folder, so it must carry the sessions without the logins. Leaving the database out would lose opencode's history, and opencode's own `opencode session export` runs opencode and its server once per session, which an export before `devvm rm` can't count on. devvm copies the database in the VM with the `sqlite3` that base installs (`sqlite3` on Debian and Ubuntu, `sqlite` on Alpine), as the VM's user, in a temporary folder in `~/.cache` (`opencodeClean`): 1. `VACUUM INTO` copies the database as one snapshot, with what its `-wal` file holds, so a login that opencode saved last, which is still only in the WAL, is in the copy and taken out with the rest. -2. In the copy, devvm drops every trigger, so none can put a row back, and empties the tables that hold logins: opencode 2.2's `credential` (its logins and API keys), `account` and `control_account` (its console's access and refresh tokens) and `account_state`, the `session_share` table of an earlier opencode (each share's secret), and any other table whose name has `credential`, `account`, `auth`, `secret`, `token` or `share` in it, or that has a column such as `secret`, `api_key`, `access_token` or `password`, so a table that a later opencode adds for its logins is emptied too. It also deletes the rows of the `kv` table whose key starts with `wellknown:config:`, because each holds an organization's remote config, which opencode fetched with that organization's well-known login and which can hold the organization's keys. opencode fetches the config again once it has the login. +2. In the copy, devvm drops every trigger, so none can put a row back, and empties the tables that hold logins: opencode 2.2's `credential` (its logins and API keys), `account` and `control_account` (its console's access and refresh tokens) and `account_state`, the `session_share` table of an earlier opencode (each share's secret), and any other table whose name has `credential`, `account`, `auth`, `secret`, `token` or `share` in it, or that has a column such as `secret`, `api_key`, `access_token` or `password`, so a table that a later opencode adds for its logins is emptied too. It also deletes the rows of the `kv` table whose key starts with `wellknown:config:`, because each holds an organization's remote config, which opencode fetched with that organization's well-known login and which can hold the organization's keys. opencode fetches the config again once it has the login. It also empties what would run without asking in the VM that imports the copy (`opencodeUnattended`): opencode 2.4's `automation` table, each automation's trigger and the shell command it runs, which opencode approved once, as the automation was made, and never asks about again, its `permission` table, the requests you said always to allow in a project, its `job` table, the subagents' jobs, and its `session_inbox` table, a session's queued messages, which its service starts again when it starts (`restart.ts`), and any table whose name starts with one of those names. It sets to NULL, in every table, a column named `time_suspended`, which marks a session whose turn the service resumes on its own, and one named `commands`, a project's commands, whose start command opencode runs with `bash -lc` for each worktree it makes (`opencodeNulled`). It drops every view, as a view in an emptied table's name could show a renamed table's rows, and its check fails on any table with a generated column, which `pragma_table_info` doesn't list. Each session's own rules are the `permission` column of `session_v2`, a JSON array of rules, each with an `effect` of allow, deny or ask, so in every table with a `permission` column, its name in any case, devvm keeps only the deny and ask rules with a text action, and a value that isn't such an array becomes no rules (`opencodeAllowRules`). It writes each kept rule again from the values that `sqlite3` read, because `sqlite3` reads a key written twice by its first value and opencode's `JSON.parse` by its last, so `"effect":"deny","effect":"allow"` would otherwise stay as an allow rule for opencode. A kept rule whose resource is missing or isn't text gets `*`, every resource, because opencode's rules need one. It reads that JSON only where a `CASE` has found it valid, because `sqlite3` may read both sides of an `AND` and fail on text that isn't JSON. 3. It takes out the record of opencode's migration that imports `auth.json` (`20260805200742_import_legacy_credentials`), so the opencode that next opens the copy imports the logins that devvm's setup wrote in its own VM's `auth.json`, as it does when it first makes its database. 4. It turns WAL off, with `secure_delete` on, and runs `VACUUM`, which writes the file again, so no free page keeps a deleted row and no `-wal` or `-journal` file is left. -5. It checks what `sqlite3` printed, not only that it succeeded. Right after `VACUUM INTO`, the copy must have as many tables as the database, and at least one. At the end, devvm counts the triggers, the rows of each table it emptied and the `kv` rows it deleted, and each count must be `0`, so a `sqlite3` that runs nothing and prints nothing fails the check too. When a check or any step fails, the database is left out of the export and the run log says why. +5. It checks what `sqlite3` printed, not only that it succeeded. Right after `VACUUM INTO`, the copy must have as many tables as the database, and at least one. At the end, devvm counts the triggers and views, the generated columns, the rows of each table it emptied, the values left in each column it set to NULL, the rows whose `permission` still holds anything but deny and ask rules, and the `kv` rows it deleted, and each count must be `0`, so a `sqlite3` that runs nothing and prints nothing fails the check too. When a check or any step fails, the database is left out of the export and the run log says why. The export's `tar` leaves out the database and its `-wal`, `-shm` and `-journal` files as they are, matched within opencode's folder, and adds the copy at the database's path (`--transform`, which leaves symlinks' targets alone). The import does the same to an export it unpacks, in the VM, before anything reaches the home folder: it deletes the `-wal`, `-shm` and `-journal` files and any database that isn't a regular file, and puts in each database's copy, or deletes the database when the VM has no `sqlite3` or the copy fails. Each `sqlite3` runs with `trusted_schema` off, so an imported database's schema can't call the CLI's functions that write files. @@ -773,9 +773,12 @@ The export's `tar` leaves out the database and its `-wal`, `-shm` and `-journal` - **A secret that's in a session itself,** such as a key you pasted into a prompt, stays in the session, as it does in Claude Code's and Codex's transcripts. - **A plugin's own storage and a remote workspace's binding stay.** opencode keeps each plugin's storage in its `kv` table, under the plugin's own prefix, and each remote workspace's binding, the record its provider needs to reconnect, in its `workspace` table. opencode's built-in plugins keep model catalogs and session records there, but a plugin you install, or a workspace provider, that keeps a token there takes it into the export. - **A VM without `sqlite3`,** made from an image built without it, exports and imports no opencode database, and opencode's sessions are lost from that export. +- **opencode's own agents keep their rules.** A session keeps its agent, and a turn is checked against that agent's built-in rules too, such as `explore`'s, which allow its shell commands. With no suspended session, job or queued message, no turn starts until you send one. +- **A host password that looks like a variable's name or a number.** Settings' copies keep a value that looks like an environment variable's name or a switch (`envName`, `plainValue`), so a service password set by hand in that form reached VMs as it was, with no `devvm-redacted` for the setup's clean-up to find; the release page says what to do. +- **The `event` table stays as it is.** It holds the events that opencode's sessions were made from, a `session.permissions` event's rules among them, and opencode 2.4.1 writes an event into `session_v2` as it publishes it (its session projector), not when it opens a database, so the copy's rules are the ones opencode reads. A later opencode that rebuilt its sessions from that table would read the allow rules again. - **A remake's home folder copy** keeps opencode's database with its logins, and its home key, because it's the same VM's data going into the same folder's new VM ([the home folder's copy](#the-home-folders-copy)). -opencode 2.4 keeps the private Ed25519 key of its home, which every machine it pairs with `opencode machine add` trusts and which it never replaces, in a file of its own, `~/.local/state/opencode/machine/home-key`, not in the database. The database's `machine` table holds each paired machine's name and the public key it logs in to the home with, so it's the VM's own pairings, and the copy empties it with the login tables (`opencodeLogins`). The key's folder, the background service's registration (`service.json`, with the service's password, and `service.json.pty-handoff`, a terminal's handoff ticket) and the terminals' daemons (`pty`, their sockets and access tokens) are opencode's `HistoryOwn` in the agents' registry: the export leaves them out and the import never writes them, while a remake keeps them. Only the latest channel's registration is named, because that's the opencode devvm installs; another channel's is `service-.json`. +opencode 2.4 keeps the private Ed25519 key of its home, which every machine it pairs with `opencode machine add` trusts and which it never replaces, in a file of its own, `~/.local/state/opencode/machine/home-key`, not in the database. The database's `machine` table holds each paired machine's name and the public key it logs in to the home with, so it's the VM's own pairings, and the copy empties it with the login tables (`opencodeLogins`). The key's folder, the background service's registration (`service.json`, or `service-.json` on a channel other than latest, dev, beta or next, with the service's password, written through `..tmp`, and `.pty-handoff`, a terminal's handoff ticket, written through `.pty-handoff..tmp`) and the terminals' daemons (`pty`, their sockets and access tokens) are opencode's `HistoryOwn` in the agents' registry: the export leaves them out and the import never writes them, while a remake keeps them. The registrations are patterns, `service-*.json`, `service.json.*` and `service-*.json.*`, which the export's GNU `tar --exclude` and the import's `tar --exclude` and its clean-up loop, a shell glob, all expand. **Threat check** (the security-audit skill, guidance mode, with its data isolation companion): @@ -785,7 +788,8 @@ opencode 2.4 keeps the private Ed25519 key of its home, which every machine it p | The WAL or journal file carrying the rows | They never go into an export, and an import deletes them | `TestHistoryExportRuns` and `TestHistoryImportCleansOpencode` | | An export with the logins in it reaching another VM | The import makes the same copy in the VM before anything reaches its home folder, or leaves the database out | `TestHistoryImportCleansOpencode`, with and without `sqlite3` | | A trigger putting a row back as it's deleted | Every trigger is dropped first, and the rows are counted after | `TestOpencodeClean` plants one | -| opencode's home key reaching this machine's export or another VM | The export leaves out its `machine` folder, `service.json` and `pty`, and the import never writes them, by their paths after it unpacks too; the copy of the database empties its `machine` table, the paired machines' public keys | `TestHistoryExportRuns`, `TestHistoryImportRuns` and `TestHistoryImportV010` plant them; `TestOpencodeCleanSchema` empties `machine` from opencode 2.4.1's schema; `TestHomeSkipsEveryLogin` keeps them in a remake | +| A hostile VM's export running a command, or allowing one, without asking in the VM that imports it | The copy empties `automation`, `permission`, `job` and `session_inbox`, and every table whose name starts with one of those names, sets `time_suspended` and `commands` to NULL, keeps only the deny and ask rules of each `permission` column, written again, drops views and refuses generated columns; the counts after must be `0`. The export leaves out opencode's git repositories (`snapshot`, `repos`, `worktree`), and the import never writes them | `TestOpencodeCleanSchema` plants a row in each from opencode 2.4.1's schema, an allow rule, a suspended session and a project's commands; `TestOpencodeCleanSessionRules` plants rules that aren't deny or ask, a key written twice, values that aren't rules and a column in upper case; `TestOpencodeCleanHidden` a view and a generated column; `TestHistoryExportRuns` and `TestHistoryImportRuns` the git folders | +| opencode's home key reaching this machine's export or another VM | The export leaves out its `machine` folder, `service.json`, `service-.json`, their handoff and temporary files, and `pty`, and the import never writes them, by their paths after it unpacks too; the copy of the database empties its `machine` table, the paired machines' public keys | `TestHistoryExportRuns`, `TestHistoryImportRuns` and `TestHistoryImportV010` plant them; `TestOpencodeCleanSchema` empties `machine` from opencode 2.4.1's schema; `TestHomeSkipsEveryLogin` keeps them in a remake | | A hostile database's schema running code in the VM | `trusted_schema` is off, and it runs as the VM's user on the VM's own files, which the export's code could reach anyway | Reviewed | ## Links out of an agent's folder diff --git a/docs/content/docs/contributing/maintaining.md b/docs/content/docs/contributing/maintaining.md index c702cb89..9a9aaa5e 100644 --- a/docs/content/docs/contributing/maintaining.md +++ b/docs/content/docs/contributing/maintaining.md @@ -46,7 +46,7 @@ The tools, by group, as `--check` prints them: - `mise` moves base's mise (`assets/layers/base.sh`) and devvm's host mise (`internal/tools/mise.go`) together: the host one writes the lock base's installs from. `TestMisePins` fails when their versions or Linux checksums differ, and base's mise version is in the key of each tool image mise installs, so a bump builds them again. - The shared tools aren't pinned for users, except Cursor's CLI. Holds go in `assets/shared-tools/mise.toml` (`node = "24"` stays on that major). `testdata/mise.lock` is a fixed lock for the tests. - Their backends are named in `mise.toml`'s `[tool_alias]` table, for every tool that isn't one of mise's own `core:` tools, because mise's registry can move a tool to another backend in any release ([versions](../internals/images.md#versions)). A new shared tool gets its alias there, and `TestToolBackendsNamed` fails when a tool that isn't a `core:` tool has none, or when its alias isn't the backend that `tests/e2e-mise.lock` resolved. -- When opencode's major version changes, or a bump of `e2e-tools` moves opencode to a version that adds migrations, refresh `internal/vm/testdata/opencode-.sql`, the schema of opencode's database that `TestOpencodeCleanSchema` cleans. Print it with `sqlite3 ~/.local/share/opencode/opencode.db .schema` in a VM with that opencode, after `opencode auth list` has made the database, and copy only the schema, never rows. The release's own `packages/core/src/database/schema.gen.ts`, with its SQL unwrapped and the `migration` table's line after it, is the same schema line for line, so you can make the file from it instead. Name the file for the version, and in the test put each new table in its list of tables that devvm empties or keeps, which the test asks for. A table or a column that holds a login also goes into `opencodeLogins` (`internal/vm/agents.go`) and the design note's [opencode's database in history exports](design.md#opencodes-database-in-history-exports). +- When opencode's major version changes, or a bump of `e2e-tools` moves opencode to a version that adds migrations, refresh `internal/vm/testdata/opencode-.sql`, the schema of opencode's database that `TestOpencodeCleanSchema` cleans. Print it with `sqlite3 ~/.local/share/opencode/opencode.db .schema` in a VM with that opencode, after `opencode auth list` has made the database, and copy only the schema, never rows. You can also make the file from the release's `packages/core/src/database/schema.gen.ts` in opencode's repo: unwrap its SQL and add the `migration` table's line at the end, and it matches `.schema` line for line. Name the file for the version, and in the test put each new table in its list of tables that devvm empties or keeps, which the test asks for. A table or a column that holds a login also goes into `opencodeLogins` (`internal/vm/agents.go`) and the design note's [opencode's database in history exports](design.md#opencodes-database-in-history-exports). - `e2e-tools`, `e2e-from`, `e2e-curl` and `e2e-ubuntu` move the end-to-end tests' own pins, which keep their cached images valid between runs. `e2e-tools` resolves `tests/e2e-mise.lock` again, with devvm's pinned host mise, for both architectures' glibc and musl VMs, and refuses a tool whose download has no checksum on every platform yet. `e2e-from` moves the digests of `node:24`, `alpine:3` and `ubuntu:26.04` in `tests/e2e/from_test.go` to Docker Hub's. `e2e-curl` moves `curlImage` in `tests/e2e/transparent_test.go`, the curl image that the network checks run in containers, to curlimages/curl's newest release, by its digest. `e2e-ubuntu` moves `e2eUbuntuRelease` in `tests/e2e/sandbox_test.go`, the dated release of Ubuntu's cloud image that e2e pins base to in place of the newest, to the newest Ubuntu lists. Ubuntu removes dated releases after a few months, and e2e's going stops its first builds of base: bump `e2e-ubuntu` before that. Run `e2e-tools` after any change to `assets/shared-tools/mise.toml`, because the end-to-end tests refuse a lock resolved from another one ([end-to-end tests](tests.md#end-to-end-tests)). `mise run test` catches it first: `TestE2ELockPins` checks the lock's first line against `mise.toml` and that it locks each of its tools, and `TestE2EUbuntuPins` checks that `e2eUbuntuRelease` is a dated release of base's Ubuntu release, which `e2e-ubuntu` lists, and that `scripts/bump.sh` and `tests/e2e` name only that release. - `e2e-lima` moves the Lima release that CI's end-to-end workflow installs, `LIMA_VERSION` in `.github/workflows/e2e.yml`, to Lima's newest release, and `LIMA_SHA256` to its `Linux-x86_64` tarball's line in that release's `SHA256SUMS`. Lima's release notes print the SHA-256 of `SHA256SUMS` itself, so `e2e-lima` checks the downloaded file against that value first and edits nothing when they differ. - `assets/layers/ubuntu-cloud.gpg` is Ubuntu's cloud image signing key (fingerprint `D2EB44626FDDC30B513D5BB71A5D6C4C7DB87C81`), from keyserver.ubuntu.com. If Ubuntu changes it, pinning a new image (a first build of base, or `devvm rebuild base`) stops with `ubuntu_bad_signature`: fetch the new key, check its fingerprint against Ubuntu's announcement, and replace the file (`gpg --export FPR`). diff --git a/docs/content/docs/internals/agents.md b/docs/content/docs/internals/agents.md index 64cd075c..a48997fe 100644 --- a/docs/content/docs/internals/agents.md +++ b/docs/content/docs/internals/agents.md @@ -70,9 +70,9 @@ devvm merges the settings and MCP servers from the store's `.claude.json` into t ## opencode's service -opencode keeps its background service's settings in `~/.config/opencode/service.json`, or in `service-.json` for a channel other than latest, dev, beta and next, as an earlier build's `service-.json` is named, and it writes each one through a temporary file beside it, `..tmp`. They hold the service's password, 32 random bytes that the service makes when it starts and the file has none, and with remote access on, the route that the service is served on, a random name that keeps its address unguessable, so opencode's own `opencode service get` hides both. They also hold the service's port, host name, CORS origins and environment. That makes them each machine's own rather than settings, so the import and the save leave out every entry of `~/.config/opencode` with one of these names, what's in a folder of that name included, and the save's script in the VM never sends them, so the VM's own file never makes a save fail. The VM's file stays in the VM, so a VM made again keeps it, and no export of the VM's history holds it, because `~/.config/opencode` isn't history. +opencode keeps its background service's settings in `~/.config/opencode/service.json`, or in `service-.json` for a channel other than latest, dev, beta or next (an earlier build named it `service-.json`), and it writes each one through a temporary file beside it, `..tmp`. They hold the service's password, 32 random bytes that the service makes when it starts and the file has none, and with remote access on, the route that the service is served on, a random name that keeps its address unguessable. So `opencode service get` with no key hides both, and only `opencode service get password` shows the password. They also hold the service's port, host name, CORS origins and environment. That makes them each machine's own rather than settings, so the import and the save leave out every entry of `~/.config/opencode` with one of these names, what's in a folder of that name included, and the save's script in the VM never sends them, so the VM's own file never makes a save fail. The VM's file stays in the VM, so a VM made again keeps it, and no export of the VM's history holds it, because `~/.config/opencode` isn't history. -A store that an earlier import filled can hold them, so every start looks for them in the store's `~/.config/opencode`, which it opens as it opens [Claude Code's plugins](#claude-codes-plugins) folder, and once it finds any, it takes them out holding the store's lock and warns once, naming them. No VM gets them from the store meanwhile, because a VM's setup copies only the files that the import would copy, so a start whose clean-up fails only warns, naming the folder. An earlier devvm copied them into every VM with opencode on each launch, with `devvm-redacted` in place of the password and of each value of the environment, so every such VM's service took `devvm-redacted` as its password. Each launch's setup takes out each regular file in the VM's `~/.config/opencode` with one of these names that holds `devvm-redacted`, which only devvm's copy can, and leaves the VM's own files, links and folders, so the VM's opencode makes its own password when its service next starts. A service that's running keeps the password it started with until it stops, as when the VM restarts. +A store that an earlier import filled can hold them, so every start looks for them in the store's `~/.config/opencode`, which it opens as it opens [Claude Code's plugins](#claude-codes-plugins) folder, and once it finds any, it takes them out holding the store's lock and warns once, naming them. No VM gets them from the store meanwhile, because a VM's setup copies only the files that the import would copy, so a start whose clean-up fails only warns, naming the folder. devvm writes `devvm-redacted` in place of a secret in every copy of a settings file that it makes, so a file with one of these names that holds it is a copy that devvm made, whose password every VM with such a copy shares. Each launch's setup takes out each such regular file in the VM's `~/.config/opencode` and leaves the VM's own files, links and folders, so the VM's opencode makes its own password when its service next starts. A service that's running keeps the password it started with until it stops, as when the VM restarts. ## Claude Code's login @@ -130,10 +130,27 @@ With some of these keys, code in the VM can make a credential of its own that wo ## History exports -The agents' logins aren't in the export, which leaves out `~/.claude/.credentials.json`, `~/.codex/auth.json`, and opencode's `auth.json`, `account.json`, `mcp-auth.json` and `bin`, and holds nothing of `~/.pi/agent` but its sessions, so pi's `auth.json` stays out too. It also leaves out what of `~/.local/state/opencode` is the VM's own as a machine. That's its `machine` folder, whose `home-key` is the private key that every machine opencode pairs with `opencode machine add` trusts, its `service.json`, which holds the password of opencode's background service, and its `pty` folder, which holds the sockets of its terminals' daemons and their access tokens. The copy of opencode's database leaves out its `machine` table too, which holds the public keys that the machines it paired log in to it with. An import never writes them either, so the new VM's opencode makes its own, and a VM made again keeps the VM's own, because it's the same machine ([what a VM made again keeps](../using/images.md#what-a-vm-made-again-keeps)). It leaves out the VM's `~/.claude/plugins`, which holds settings and each plugin's data rather than history ([Claude Code's plugins](#claude-codes-plugins)). opencode keeps its sessions and its logins together in one database, `~/.local/share/opencode/opencode.db`, so the export holds a copy of that database without its logins. The VM makes the copy with `sqlite3`, which every base image has, and the copy has no logins, API keys or opencode account in any part of the file, not even a key you typed into opencode in the VM, while the VM's own database keeps them ([how](../contributing/design.md#opencodes-database-in-history-exports)). The export never holds the database's `-wal`, `-shm` or `-journal` files, which can hold logins that opencode saved last. When the VM has no `sqlite3`, such as a VM made from an image built without it, the export leaves the database out, so opencode's sessions aren't in it, and the run log says so. devvm starts a stopped VM for the export as a launch does, so it locks the folder's `.git` again and checks the VM's confinement first, and the VM stays running. devvm writes the file only once the export is complete, so a failed export leaves no file and leaves an existing FILE as it was. An export holds at most 2 GiB, because a VM could otherwise write until this machine's disk is full. When the VM sends more, devvm stops the export and keeps nothing of it, so `devvm history export` fails, while `devvm rm` and the commands that make a VM again warn that they kept no export and go on without one. Only you can read the file, and devvm makes the exports folder yours alone each time it writes one there, whatever its mode was before. When FILE is in a folder of your own, that folder keeps its mode. If the export fails, `devvm rm` keeps the VM, and `devvm rm --no-export` deletes it without exporting. `devvm rm VM`, for a VM whose folder is gone, exports in the same way, but only from a running VM or a `--clone` VM, because starting any other would make its folder again ([a VM whose folder is gone](../using/vms.md#a-vm-whose-folder-is-gone)). +The agents' logins aren't in the export, which leaves out `~/.claude/.credentials.json`, `~/.codex/auth.json`, and opencode's `auth.json`, `account.json`, `mcp-auth.json` and `bin`, and holds nothing of `~/.pi/agent` but its sessions, so pi's `auth.json` stays out too. It leaves out the VM's `~/.claude/plugins`, which holds settings and each plugin's data rather than history ([Claude Code's plugins](#claude-codes-plugins)). It also leaves out what of `~/.local/state/opencode` is the VM's own as a machine: + +- its `machine` folder, whose `home-key` is the private key that every machine opencode pairs with `opencode machine add` trusts +- its `service.json`, or `service-.json` for another channel's opencode, which holds the password of opencode's background service, and the handoff tickets and temporary files that opencode writes beside it +- its `pty` folder, which holds the sockets of its terminals' daemons and their access tokens + +The copy of opencode's database leaves out its `machine` table too, which holds the public keys that the machines it paired log in to it with. An import never writes them either, so the new VM's opencode makes its own, and a VM made again keeps the VM's own, because it's the same machine ([what a VM made again keeps](../using/images.md#what-a-vm-made-again-keeps)). + +opencode keeps its sessions and its logins together in one database, `~/.local/share/opencode/opencode.db`, so the export holds a copy of that database without its logins. The VM makes the copy with `sqlite3`, which every base image has, and the copy has no logins, API keys or opencode account in any part of the file, not even a key you typed into opencode in the VM, while the VM's own database keeps them ([how](../contributing/design.md#opencodes-database-in-history-exports)). The copy also leaves out what opencode 2.4 would act on without asking in the VM that imports it: + +- its `automation` table, because opencode runs each automation's shell command on its schedule or event without asking again +- its `permission` table, the requests you said always to allow +- its `job` table, the subagents' jobs, and its `session_inbox` table, the messages queued for a session's next turn, because opencode's service starts those jobs and turns when it starts +- each session's allow rules, as the session keeps only the deny and ask rules of its permission rules +- each suspended session's mark, so no session resumes its turn on its own +- each project's commands, whose start command opencode runs for each worktree it makes + +The export also leaves out opencode's git repositories in `~/.local/share/opencode`, which are `snapshot`, `repos` and `worktree`, because a repository's config can name a command that git runs, and opencode's own git commands would run it in the VM that imports it. So the export doesn't hold opencode's worktrees, and the work in them stays in the VM, which a VM made again keeps and `devvm rm` deletes. Their commits are in the project's own repository. A view or a generated column in the database could hide rows from these steps, so the copy drops every view, and it fails its check when a table has a generated column. The export never holds the database's `-wal`, `-shm` or `-journal` files, which can hold logins that opencode saved last. When the VM has no `sqlite3`, such as a VM made from an image built without it, the export leaves the database out, so opencode's sessions aren't in it, and the run log says so. It does the same when the VM's `sqlite3` can't read JSON, which the sessions' rules are. devvm starts a stopped VM for the export as a launch does, so it locks the folder's `.git` again and checks the VM's confinement first, and the VM stays running. devvm writes the file only once the export is complete, so a failed export leaves no file and leaves an existing FILE as it was. An export holds at most 2 GiB, because a VM could otherwise write until this machine's disk is full. When the VM sends more, devvm stops the export and keeps nothing of it, so `devvm history export` fails, while `devvm rm` and the commands that make a VM again warn that they kept no export and go on without one. Only you can read the file, and devvm makes the exports folder yours alone each time it writes one there, whatever its mode was before. When FILE is in a folder of your own, that folder keeps its mode. If the export fails, `devvm rm` keeps the VM, and `devvm rm --no-export` deletes it without exporting. `devvm rm VM`, for a VM whose folder is gone, exports in the same way, but only from a running VM or a `--clone` VM, because starting any other would make its folder again ([a VM whose folder is gone](../using/vms.md#a-vm-whose-folder-is-gone)). ## Importing history The import works on every VM, whether its base is Ubuntu's image or a Debian-, Ubuntu- or Alpine-based container image ([starting from a container image](../using/from.md)), because it unpacks the export with GNU `tar`, which Debian and Ubuntu always have and which devvm installs in every base made `--from alpine`. -An export holds what a VM wrote, so devvm treats it as untrusted. Its transcripts can hold what the old VM's agents read, and a VM on a less strict tier reaches more, such as your local network on the open tier. So when the export comes from a VM on a less strict tier than the VM you import it into, going from open to internet, allowlist and none, devvm warns you before it imports. devvm knows an export's tier only from the `.folder` file beside it in `~/.local/share/devvm/exports`, so it warns about an export with no tier recorded, or any FILE elsewhere, such as in the project folder that a VM can write, as if it came from an open VM. devvm never unpacks an export on this machine. It streams the file into the VM as it is, and the VM's own `tar` unpacks it there as the VM's user, so it can only write what that user can write. Before unpacking anything, the VM lists the paths in the export, and when one of them is outside `~/.claude`, `~/.claude.json`, `~/.codex`, `~/.local/share/opencode`, `~/.local/state/opencode`, `~/.pi/agent/sessions` and `~/.cursor/chats`, starts with `/` or has a `.`, `..` or empty part, such as `.claude/./plugins` or `.claude//plugins`, devvm imports nothing and says so, because `tar` matches the paths it leaves out against each name as the export writes it. Once it has unpacked the export, it also deletes each of those paths by its path, whatever name put a file there. It leaves out of that check, and never unpacks, the AppleDouble files whose names start with `._`, which macOS's `tar` puts beside each file that has extended attributes, so an export you packed yourself on a Mac imports. The import keeps no owner or mode from the export, so the VM user's umask applies and no file is set-user-ID. It also takes out every symbolic link that points outside the folder it's in, which is any link to an absolute path or one with a `..` part, so an agent writing to a session file can't follow a link out of its history. An export that devvm didn't write, such as a `.tar.gz` you made yourself, can hold opencode's database with its logins, so the import takes out the database's `-wal`, `-shm` and `-journal` files and puts in a copy of the database without its logins, as the export makes it, or leaves the database out when the VM has no `sqlite3`. opencode in the new VM then reads the logins that devvm gave the VM, as it does when it first makes its database. When the VM already has an opencode database, it keeps its own, and opencode's sessions from the export aren't imported. +An export holds what a VM wrote, so devvm treats it as untrusted. Its transcripts can hold what the old VM's agents read, and a VM on a less strict tier reaches more, such as your local network on the open tier. So when the export comes from a VM on a less strict tier than the VM you import it into, going from open to internet, allowlist and none, devvm warns you before it imports. devvm knows an export's tier only from the `.folder` file beside it in `~/.local/share/devvm/exports`, so it warns about an export with no tier recorded, or any FILE elsewhere, such as in the project folder that a VM can write, as if it came from an open VM. devvm never unpacks an export on this machine. It streams the file into the VM as it is, and the VM's own `tar` unpacks it there as the VM's user, so it can only write what that user can write. Before unpacking anything, the VM lists the paths in the export, and when one of them is outside `~/.claude`, `~/.claude.json`, `~/.codex`, `~/.local/share/opencode`, `~/.local/state/opencode`, `~/.pi/agent/sessions` and `~/.cursor/chats`, starts with `/` or has a `.`, `..` or empty part, such as `.claude/./plugins` or `.claude//plugins`, devvm imports nothing and says so, because `tar` matches the paths it leaves out against each name as the export writes it. Once it has unpacked the export, it also deletes each of those paths by its path, whatever name put a file there. It leaves out of that check, and never unpacks, the AppleDouble files whose names start with `._`, which macOS's `tar` puts beside each file that has extended attributes, so an export you packed yourself on a Mac imports. The import keeps no owner or mode from the export, so the VM user's umask applies and no file is set-user-ID. It also takes out every symbolic link that points outside the folder it's in, which is any link to an absolute path or one with a `..` part, so an agent writing to a session file can't follow a link out of its history. An export that devvm didn't write, such as a `.tar.gz` you made yourself, can hold opencode's database with its logins, so the import takes out the database's `-wal`, `-shm` and `-journal` files and puts in a copy of the database without its logins or what opencode would act on without asking, as the export makes it ([history exports](#history-exports)), or leaves the database out when the VM has no `sqlite3`. It never writes opencode's git repositories either. opencode in the new VM then reads the logins that devvm gave the VM, as it does when it first makes its database. When the VM already has an opencode database, it keeps its own, and opencode's sessions from the export aren't imported. diff --git a/docs/content/docs/releases/0.2.0.md b/docs/content/docs/releases/0.2.0.md index 2ceee850..ced1f2cb 100644 --- a/docs/content/docs/releases/0.2.0.md +++ b/docs/content/docs/releases/0.2.0.md @@ -283,7 +283,7 @@ When a VM's state file held a size devvm couldn't read as a number, such as `"cp ### opencode's machine key in history exports -opencode 2.4 keeps a private key in `~/.local/state/opencode/machine/home-key`, which it makes when it first needs one, such as when you pair a machine with `opencode machine add`. Every machine it pairs trusts that key, and opencode never replaces it. It sits in opencode's state folder beside its prompt history, so `devvm history export`, and the export that `devvm rm` and a VM made again write, used to copy it into the export, and `devvm history import` put it into the VM it imported into. The export also held the state folder's copy of the password of opencode's background service, in `service.json`, and the access tokens of its terminals' daemons, in `pty`, which earlier opencode releases keep there too. The copy of opencode's database also kept its `machine` table, which holds the public keys that the paired machines log in with. +opencode 2.4 keeps a private key in `~/.local/state/opencode/machine/home-key`, which it makes when it first needs one, such as when you pair a machine with `opencode machine add`. Every machine it pairs trusts that key, and opencode never replaces it. It sits in opencode's state folder beside its prompt history, so `devvm history export`, and the export that `devvm rm` and a VM made again write, used to copy it into the export, and `devvm history import` put it into the VM it imported into. The export also held the password of opencode's background service, which its state folder keeps in `service.json`, or in `service-.json` for another channel's opencode, with the handoff tickets and temporary files beside it. It held the access tokens of opencode's terminals' daemons too, which opencode keeps in the state folder's `pty`, as releases before 2.4 do as well. The copy of opencode's database also kept its `machine` table, which holds the public keys that the paired machines log in with. An export now leaves them out and empties that table, and an import never writes them, even from an older export, so the new VM's opencode makes its own. A VM made again keeps its own, because it's the same machine ([what an export holds](../internals/agents.md#history-exports)). @@ -291,24 +291,30 @@ If an export of a VM with opencode 2.4 or later holds `.local/state/opencode/mac 1. Quit opencode, its TUI and any `opencode serve` included, and stop its service with `opencode service stop`, because a running opencode keeps the key in memory. 2. Delete `~/.local/state/opencode/machine/home-key`, so opencode makes a new key when it next needs one. -3. Pair again each machine you paired there: `opencode machine add NAME --replace` prints a new join string, which that machine then joins with. In a VM you imported the export into, remove the machines it brought with `opencode machine remove NAME`. +3. Pair each machine you paired there again with `opencode machine add NAME --replace`, which prints a new join string for that machine to join with. In a VM you imported the export into, remove the machines it brought with `opencode machine remove NAME`. For a VM that you've deleted, unpair each machine it had paired, on that machine. Once the key is replaced, the old exports in `~/.local/share/devvm/exports` hold a key that nothing trusts. ### opencode's service settings in VMs -opencode 2 keeps its background service's settings in `~/.config/opencode/service.json`, or in `service-.json` on another channel. They hold the service's password, which the service makes when the file has none, and with remote access on, the secret route that the service's address is served on and your consent to remote access, beside its port, host name, CORS origins and environment. `devvm agent import` copied every file in `~/.config/opencode` into devvm's agent store, these included, and every VM with opencode got a copy at each launch, with `devvm-redacted` in place of the password and of each value of the environment, and with the route as it was. So each such VM's opencode service took `devvm-redacted` as its password, which anyone who knows devvm knows, and `devvm agent save` would have copied a VM's own file into the store. +opencode 2 keeps its background service's settings in `~/.config/opencode/service.json`, or in `service-.json` on another channel. They hold the service's password, which the service makes when the file has none, and with remote access on, the secret route that the service's address is served on and your consent to remote access, beside its port, host name, CORS origins and environment. `devvm agent import` copied every file in `~/.config/opencode` into devvm's agent store, these included, and every VM with opencode got a copy at each launch, with `devvm-redacted` in place of the password and of each value of the environment, and with the route as it was. So each such VM's opencode service took `devvm-redacted` as its password, which anyone who knows devvm knows. `devvm agent save` copied a VM's own file into the store in the same way, and from there into every VM. -`devvm agent import` and `devvm agent save` now leave these files out, and no VM gets them, even from a store that holds them. A VM's start takes them out of the store and warns once, and each VM's setup takes out the copy that an earlier devvm gave it, which it knows by the `devvm-redacted` in it, so each VM's opencode makes a password of its own the next time its service starts, which `opencode service get password` shows in the VM ([opencode's service](../using/coding-agents.md#opencodes-service)). +`devvm agent import` and `devvm agent save` now leave these files out, and no VM gets them, even from a store that holds them. A VM's start takes them out of the store and warns once, and each VM's setup takes out the copy that an earlier devvm gave it, which it knows by the `devvm-redacted` in it, so each VM's opencode makes a password of its own the next time its service starts. `opencode service get password` shows it in the VM ([opencode's service](../using/coding-agents.md#opencodes-service)). -A service that's running keeps its password until it stops, so restart each running VM that has opencode, with `devvm restart` in its folder. If this machine's opencode has remote access on, its route reached the store and your VMs, so turn remote access off and on again on this machine, which gives its service a new route: +If you ran `devvm agent import` or `devvm agent save` for opencode, your VMs got such a copy. A service that's running keeps its password until it stops, so restart each running VM that has opencode, with `devvm restart` in its folder. If this machine's opencode has remote access on, its route reached the store and your VMs, so turn remote access off and on again on this machine, which gives its service a new route: ```sh opencode service set remote false # on this machine: drop the route that your VMs got opencode service set remote true # and get a new one ``` -A copy of a file that held a route but no password, which only a service that never started since you turned remote access on writes, held no `devvm-redacted`, so it stays in the VM. Once this machine's route is new, the copy's route leads nowhere. +When this machine's service had remote access on but hadn't started since, its file held a route and no password, so the copy held no `devvm-redacted` and stays in the VM. Once this machine's route is new, that copy's route leads nowhere. A password you set yourself with `opencode service set password` reached your VMs as it was, with no `devvm-redacted` to mark the copies, when it looked to devvm like a variable's name or a number, which is any of these: + +- capital letters, digits and `_`, starting with a letter +- at most five digits +- `true` or `false` + +If yours is one, delete `~/.config/opencode/service.json` in each VM with opencode, then restart the VM, and set a new password on this machine. ## Hardening @@ -401,3 +407,16 @@ devvm's other logs are held to their caps as well: ### How deep a save goes A chain of thousands of folders used to keep `devvm agent save` busy for a long time while it held the agent store's lock. The save now has an import's bounds on depth, so a VM that sends folders nested more than 128 deep, or a path of more than 4,096 bytes, gets nothing saved, as an import of such folders does ([saving a VM's settings](../using/coding-agents.md#saving-a-vms-settings)). + +### opencode's automations and permissions in history + +opencode 2.4 keeps its automations in its database, each with a schedule or an event that triggers it and a shell command that it runs, which opencode asks you to approve once, as the automation is made, and then runs without asking again. The database also keeps the requests you said always to allow in a project, and each session's own permission rules. A copy of the database in a history export kept all of them, so a hostile VM could write an automation, an allow rule or a session that allows every command into its database, and `devvm history import` would put it into the VM you imported the export into, where opencode would run its command without asking. The same went for what opencode's service starts by itself when it starts: a suspended session's turn, a subagent's job and a message queued for a session's next turn. A project's start command, which opencode runs for each worktree it makes, was in the copy too. opencode's git repositories in `~/.local/share/opencode`, its snapshots, its cache of repositories and its worktrees, were in the export too, and a repository's config can name a command that opencode's own git commands then run. + +The copy in an export, and the copy that an import makes of a database in any export, now has: + +- no automations, subagents' jobs or queued messages +- no requests you said always to allow, and each session keeps only its deny and ask rules, each written again as sqlite3 reads it +- no suspended sessions, so no turn resumes on its own +- no project commands + +The copy drops every view and refuses a table with a generated column, which could hide rows from these steps, and its own check counts what's left and leaves the database out unless nothing is. An export also leaves out opencode's `snapshot`, `repos` and `worktree` folders, and an import never writes them, so an export doesn't hold opencode's worktrees. Their commits are in your project's own repository, but `devvm rm` deletes the worktrees' folders with the VM, so commit the work in them first. In the new VM, make again any automation you want, and opencode asks again before the requests you had always allowed. A VM made again keeps its own, because its home folder's copy isn't an export ([what an export holds](../internals/agents.md#history-exports)). diff --git a/docs/content/docs/using/coding-agents.md b/docs/content/docs/using/coding-agents.md index e33d8fae..b7d1d0fa 100644 --- a/docs/content/docs/using/coding-agents.md +++ b/docs/content/docs/using/coding-agents.md @@ -298,7 +298,7 @@ A login that Codex or opencode makes in a VM, whether `devvm agent login` runs i ### opencode's service -opencode's background service, which opencode starts when it needs one, signs you in with a password, and each VM's opencode makes its own the first time its service starts. To sign in to a VM's service, such as from opencode's app, read that VM's password in the VM: +opencode's background service, which opencode starts when it needs one, asks for a password when you sign in to it, and each VM's opencode makes its own the first time its service starts. To sign in to a VM's service, such as from opencode's app, read that VM's password in the VM: ```sh opencode service get password # in the VM: its service's password, made now if it has none @@ -306,7 +306,7 @@ opencode service set password PASSWORD # in the VM: choose another, which stops ``` - devvm never copies this machine's opencode service settings into its agent store or a VM. They're `service.json` in `~/.config/opencode`, or `service-.json` for another channel's opencode, and they hold this machine's service password and, with remote access on, the secret route that the service is served on. So `devvm agent import` and `devvm agent save` leave them out, and each VM's service settings stay in that VM. -- When the store holds them, because an earlier `devvm agent import` copied them, a VM's start takes them out of the store and warns once. Each VM's setup also takes out the copy that an earlier devvm gave it, whose password was `devvm-redacted` in every VM, so the VM's opencode makes its own ([how](../internals/agents.md#opencodes-service)). +- When devvm's agent store holds them, a VM's start takes them out and warns once, and each VM's setup takes out any copy of them that devvm made, so the VM's opencode makes its own password ([how](../internals/agents.md#opencodes-service)). - A service that's running keeps the password it started with, so after that warning, restart each running VM that has opencode: ```sh @@ -488,7 +488,7 @@ devvm looks for them only in the system's folders, never elsewhere on your `PATH ## History -Each VM's transcripts and sessions stay in that VM. `devvm history export [FILE]` saves them, and `devvm rm` saves them before it deletes a VM that has an agent. The export is a `.tar.gz` of the agents' history in the VM, `~/.claude`, `~/.claude.json`, `~/.codex`, `~/.local/share/opencode`, `~/.local/state/opencode`, `~/.pi/agent/sessions` and `~/.cursor/chats`, written to FILE or to `~/.local/share/devvm/exports/--