Upgrade
Move an existing instance to the latest release without losing data.
A release may contain a reviewed migration that removes data. Before upgrading, check the release changes and record a restore point before every upgrade.
Steps
-
Go to the existing install:
cdinto the directory setup cloned into (by default~/open-artifacts). If it’s gone, for example on a new machine or in CI, clone the latest release as in setup and continue from step 4. Without its saved state, add the install’s--name(and--account-idif the login has several accounts); setup reads the hosts and owner email from the deployed Worker. It also re-verifies Access, so you may need the Access token again if the Cloudflare login can’t read Access; save it as in setup. -
Check the git remote for credentials. Never print the remote URL or the git settings: a token in the URL would be exposed. This prints a line only if the URL has a login in it:
if git remote get-url origin | grep -qE '^https?://[^/]*@'; then echo "origin has credentials"; fiIf it prints that line, take the login out of the URL before you go on. The repository is public, so fetching needs no login. Then revoke that token where you made it, since it was stored in plain text.
git remote set-url origin "$(git remote get-url origin | sed -E 's#^(https?://)[^/]*@#\1#')"To show the remote without the login:
git remote get-url origin | sed -E 's#^(https?://)[^/]*@#\1***@#'. -
Check out the latest release. This is the latest stable GitHub release; pre-releases are skipped. Release tags look like
vX.Y.Z:TAG=$(curl -fsSL https://api.github.com/repos/open-artifacts-ai/open-artifacts/releases/latest | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p') git fetch --depth 1 origin tag "$TAG" git checkout "$TAG"If
TAGcomes back empty orcurlfails, stop and tell the user: “Open Artifacts has no stable release yet; check back later.”An instance below 0.109.0 upgrades to
v0.109.0first, then to the latest: from 0.109.0 the agent bus’s storage ships one release before the code that turns it on. Setup stops withaction_requiredand says so. -
Install dependencies:
pnpm install --frozen-lockfile. -
Preview, if you like:
pnpm --reporter=silent oa:setup --upgrade --check --jsonis read-only. It reports each step asdoneortodowithout changing anything, so you can see what the upgrade would do. Steps that always run showtodo; that isn’t pending work. -
Record a restore point before every upgrade. Replace
<name>with the install name. Save the version ID serving 100% of the current Worker deployment and the D1 Time Travel bookmark. Stop if either is unavailable.pnpm -s --filter @oa/server exec wrangler deployments list --name <name> --json pnpm -s --filter @oa/server exec wrangler d1 time-travel info <name> --json -
Run the upgrade:
pnpm --reporter=silent oa:setup --upgrade --json. It uses yourwrangler login. In CI, or on a machine with no login, use a Cloudflare deploy token instead, as your instance’s/upgrade.mddoes.pnpm --reporter=silent oa:setup --token-links --jsonprints the link that creates it (with the permissions it needs) and the line that saves it as~/.open-artifacts/<name>-cloudflare-token. Run that line in your own terminal, then putCLOUDFLARE_API_TOKEN="$(cat ~/.open-artifacts/<name>-cloudflare-token)"in front of the command. It reuses the hostnames and email saved by setup. Every step runs, but onlydeploy(new database migrations, then a redeploy),healthcheck,selftestandagent-configdo work:prereqsreportsok(itsdata.warningsanddata.noteshold plan warnings and notes) andresourcesverifies,recallfinds or creates the recall index, andaccess,secretsandowner-tokenreportskippedunless something is missing. It keeps the existing owner token and needs noOA_ACCESS_TOKENwhen the state is saved. It never creates the required resources (database, file storage, OAuth store): if one is missing, it reportsaction_requiredand asks for a full setup. The one exception is the optional recall index: therecallstep creates it on an upgrade (see Recall by meaning). If it can’t (the deploy token lacks Vectorize Write, which is added by hand, or the existing index does not fit, or creation fails), recall stays off, the step says so in one line, and the upgrade goes on; it is neveraction_required. Go by the exit code, as in setup:- 0: continue to verification.
- 2: relay the
action_requiredline’smessageto the user verbatim, wait until they’ve done it, then run the same command again. - 1: show the user the
errorline’smessage. If it says to rerun setup without--upgrade, runpnpm --reporter=silent oa:setup --json, then the upgrade again. That run may need the Access token again. Get its save line frompnpm --reporter=silent oa:setup --token-links --json(saveCommand) and have the user run it in their own terminal (in Claude Code, type!then the line). Never paste a token into the chat. Ifreadfails, the shell can’t hide input, so use a real terminal. Setup then reads~/.open-artifacts/<name>-access-token.
-
Verify the release. Set
TAGto the exact release tag you checked out,NAMEto the install name andORIGINto the instance origin. Use the same Cloudflare credentials as setup. From the release checkout, compare the remote D1 ledger to the tag and check that the live instance is healthy on that version.PROD_NAME="$NAME" TAG="$TAG" bash scripts/ci/prod-migration-guard.sh verify && health="$(curl -fsS "$ORIGIN/healthz")" && printf '%s' "$health" | node -e 'const h = JSON.parse(require("node:fs").readFileSync(0, "utf8")); process.exit(h?.ok === true && h.version === process.argv[1] ? 0 : 1)' "${TAG#v}"On either mismatch or command failure, stop and retain the recorded Worker version and bookmark. Restoring D1 discards writes made since the bookmark and requires a separate decision. Report success only when both checks pass.
If the Cloudflare login has expired
The prereqs step fails with an error. Ask the user to run npx wrangler login again, then re-run the upgrade.