Upgrading
Move an app to the newest release in the order the upgrade is done: packages, database, installed pages, your own files, then the checks.
Upgrading from 1.2.x to 1.3.0. 1.3.0 is the first stable release of the 1.3 line; 1.3.0-next.1 and
1.3.0-next.2 were its prereleases. This guide is the upgrade in the
order it is executed: packages, database, installed pages, the app’s own
files, then the checks. The detail behind each step is in CHANGELOG.md
under [1.3.0], [1.3.0-next.2] and [1.3.0-next.1].
Do it on a branch, against a copy of the production database.
1. Packages
Every @intelligo-dev/* package moves together; mixing versions is
unsupported. intelligo doctor (1.3.0) reports an error when the
installed ones differ, or when two copies of @intelligo-dev/core are
installed.
pnpm add @intelligo-dev/core@1.3.0 @intelligo-dev/auth@1.3.0 \
@intelligo-dev/billing@1.3.0 @intelligo-dev/executions@1.3.0 \
@intelligo-dev/chat@1.3.0 @intelligo-dev/next@1.3.0 # …every one you use
pnpm add -D @intelligo-dev/cli@1.3.02. Database
pnpm exec intelligo migrate
pnpm exec intelligo migrate --checkThree migrations since 1.2.4, and all only add, so they can run ahead of the deploy:
0010_deployment_spendadds thedeployment_spend_dailytable, aprovider_estimate_microscolumn oncredit_reservationswith an index on its status and expiry, and aprovider_cost_microscolumn onexecutions.0011_list_indexesadds two indexes, one onconversations(a reader’s own list, newest change first) and one onusage_records(the whole ledger, newest first). Each blocks writes to its table while it builds, so on a table of many millions of rows run it in a quiet window.0012_maintenance_runsadds themaintenance_runstable: one row per scheduled route, written by the route when it runs.0013_jobs_dedupeadds a nullablededupe_keycolumn tojobsand a unique index on a kind and its key over the jobs still waiting or running. Existing rows have no key and are not in it.0014_execution_progressadds a nullablelast_progress_atcolumn toexecutions. A run in flight during the deploy has none and is counted from its start, as before.0015_cache_token_countsadds nullablecache_read_tokensandcache_write_tokenscolumns tousage_recordsandexecutions. Existing rows keep null: what they read from a cache is not known.0016_message_originadds nullableexecution_idandmodel_idcolumns tomessages, and a nullablereasontovotes. A reply stored before it has neither; a vote on one is reported with the conversation’s model and no run.0017_run_payeradds a nullablebill_tocolumn tousage_recordsandexecutions. It isplatformon a run begun withbillTo: "platform"and null on every other row, old and new: the workspace paid.0018_message_stop_reasonadds nullablestop_reasonandstop_codecolumns tomessages. A reply stored before it has neither and reads as finished.0019_two_factoradds thetwo_factortable and atwo_factor_enabledcolumn onusers, false for everyone until they set an authenticator up.
intelligo doctor now warns when the database keeps time off UTC. The
schema’s timestamps carry no zone, so a database on local time stamps
rows hours away from the times the app compares them with: a pending
local payment is never settled. If it warns:
ALTER DATABASE <name> SET timezone TO 'UTC';and reconnect. Rows already written keep the local time they were stamped with.
3. Installed pages
pnpm exec intelligo sync --check # what will change
pnpm exec intelligo syncSync installs four new seams, each empty or a no-op as shipped, so nothing changes until you fill them in, and one new component, which every password field now uses:
| File | Item | What it sets |
|---|---|---|
lib/brand-config.tsx |
app-shell |
the product’s mark and name in the sidebar |
lib/auth-config.tsx |
auth-login |
the mark, frame and label style of the sign-in pages |
lib/dashboard-panels.tsx |
dashboard |
the product’s own server components on the dashboard |
lib/privacy-export.ts |
privacy-settings |
what the product adds to a person’s data export |
components/auth/password-input.tsx |
auth-login |
not a seam: the password field with a show button |
Seams that got shorter. Four seams no longer carry the types their values are written against, nor the framework’s own defaults: those now arrive in files a sync keeps current. Your seam files are not touched and keep working as they are.
| Seam | Its types and defaults now live in |
|---|---|
lib/shell-config.tsx |
lib/seams/shell.ts |
lib/chat-config.tsx |
lib/seams/chat.ts |
lib/chat-renderers.tsx |
components/chat/renderers/ (types, cards, resolve) |
lib/chat-canvas-config.tsx |
components/chat/canvas/ (types, kinds, resolve) |
To take the shorter form, keep your entries and replace the rest of the
file with the registry’s: import the types from the synced file, and for
the two configs write defineShellConfig({ … }) or
defineChatConfig({ … }). A field added in a later release is then
yours to set without another edit.
A file you edited by hand. Sync refuses to replace it without
--force. Three ways on, per file:
- the edit is now a seam above: take the registry’s file (
--force) and set the seam; - the edit is yours to keep: list the path under
registry.ownedinintelligo.manifest.jsonwith the reason. Sync then keeps your copy,sync --checkpasses, and a release that changes the registry’s version of the file is reported asowned-changed; - neither: move what the change does into a seam or a message file.
{
"registry": {
"owned": {
"components/chat/message.tsx": "our own reply footer"
}
}
}Your stylesheet. The design-system base writes its tokens into
app/globals.css. A sync that changes a token’s value now copies your
stylesheet to .intelligo/backup/ and names the tokens. To keep your
own through every sync, list app/globals.css under registry.owned.
The file is then yours to keep current: when a release adds a token, the
sync names it and you add it, with the registry’s value or your own.
Messages. New keys arrive in the files sync merges: password.show,
password.hide and the keys under twoFactor in auth-login; route.spendCapReached,
creditBanner.spendCap, creditBanner.spendCapUntil,
creditBanner.spendCapDescription, message.unanswered, the four
message.stopped.* keys and the five under canvas.unsaved in chat;
revenue.ledger.platformPaid and the keys under workspace.executions
in admin-console; errors.alreadyInvited and
errors.alreadyMember in team-settings; impersonation.acting and
impersonation.stop in app-shell; the keys under types in
notifications, one title and one message for each built-in
notification, which is how a notification now reads in a locale of your
own. Add them to any locale you own that
the registry does not ship.
A dependency sync raises. The auth forms are now built against
@hookform/resolvers 7 (it was 5), and sync moves an app on an older
major up to it. A form of your own that uses the package moves with it:
run pnpm type-check after the sync, and read that package’s release
notes for 6 and 7 if a resolver of yours stops compiling.
4. The app’s own files
Scaffold files are yours, so intelligo upgrade --check lists what the
templates changed and you apply it.
proxy.ts (app-scaffold 1.29.0). Record the path each request asks
for, so a reader sent to sign in or to onboarding comes back to it:
import type { NextRequest } from "next/server";
import createIntlMiddleware from "next-intl/middleware";
import { recordRequestedPath } from "@intelligo-dev/auth/edge";
import { routing } from "./i18n/routing";
const intl = createIntlMiddleware(routing);
export default function proxy(request: NextRequest) {
recordRequestedPath(request);
return intl(request);
}Without it the redirects carry no ?next=, as before. A proxy that
already redirects on its own keeps doing so; add the call before it.
instrumentation.ts (app-scaffold 1.29.0). Export onRequestError
to log every server error Next.js catches; the template has it.
app/api/health/route.ts and app/api/health/detail/route.ts
(app-scaffold 1.30.0). Two new routes, both optional: a public one that
answers ok or unavailable for a load balancer or an uptime monitor,
and one behind the cron secret that returns every integration check as
JSON. intelligo upgrade --check lists them as missing; copy them from
the template if you want them.
app/api/cron/maintenance/route.ts (maintenance 1.8.0). A route
written from the 1.2 template lacks two steps the template has had
since 1.4.0. Without them a deleted account is never removed once its
grace period (ACCOUNT_DELETION_GRACE_DAYS, 30 by default) ends, and
read notifications are kept for ever. Add both to the route’s summary:
import { eraseActorFromAuditEvents } from "@intelligo-dev/audit";
import { purgeDeletedAccounts } from "@intelligo-dev/auth";
import { pruneNotifications } from "@intelligo-dev/core/notifications";
// Read notifications older than 90 days; unread ones stay.
await pruneNotifications(new Date(Date.now() - 90 * 24 * 60 * 60_000));
// Accounts whose grace period has ended, and their trace in the audit trail.
await purgeDeletedAccounts({
beforePurge: async (userId) => {
await eraseActorFromAuditEvents(userId);
},
});The template also wraps its handler in withCronSecret from
@intelligo-dev/next/route in place of its own bearer check; nothing
changes for the scheduler. And it now expires trials and lapsed plan
grants before it reconciles, and gives reconciling a time budget: after
an incident a backlog of stale executions used to end the run at
maxDuration with every later step unrun, on every run until it
cleared. What the budget leaves is in the summary as
reconcileDeferred. A third new step, pruneExpiredAuthRows() from
@intelligo-dev/auth, deletes sessions and verification tokens that
expired more than a week ago; without it both tables grow by a row per
sign-in and per email sent. And the route’s last step is
recordMaintenanceRun(MAINTENANCE_RUN, { ok, summary }) from
@intelligo-dev/admin: the new maintenance health check reads it and
reports down once three expected runs are missed, which is how anyone
learns that a scheduler stopped. Until a route records a run the check
reads unconfigured and alarms nobody. It expects a run every five
minutes; on another schedule, call setMaintenanceCadence(everyMs) in
lib/intelligo.ts.
intelligo upgrade --diff app/api/cron/maintenance/route.ts shows the
current template against your route.
5. Changes of behaviour to check
From the prereleases (### Upgrading under each):
createNotificationreturns its metadata parsed. Code that ranJSON.parse(created.metadata)readscreated.metadataas an object.- A
streamTurnruntime’s reasoning reaches the reader only withreasoning: truein the chat server config, as on thestreamTextpath. - The admin plugin’s user writes answer 404 over HTTP. A browser
client that called
authClient.admin.createUserand its siblings calls them from the server throughauth.api. saveMessageAsArtifacttakes{ conversationId, messageId, title? }.intelligo sync chatbrings the action and the page that calls it.
From 1.3.0:
- The chat and upload routes take a write only from the app’s own
origin, or one in
cors.origins. A page on another origin that calls them with the reader’s cookie, such as a widget embedded on another site or a client served from its own host, is answered 401 until its origin is listed. A caller that sends noOrigin(a server, a script, a native client) is unaffected. - A tool-using chat turn is held a step at a time, at the agent’s
own output cap. A plan with a small allowance can now start turns it
was refused before; a turn whose next step cannot be held ends with
the steps it took (
stopReason: "hold_refused"). - The workspace ceiling counts owned workspaces. Five remains the
default; someone invited into five can now create their own. Set
another ceiling with
setWorkspaceCeiling(n). - Sidebar section labels are sentence case, the workspace switcher shows no slug, and a reply’s sources come before its actions.
- An image document loads only from a host you named. A generated
image saved as its own data (
data:,blob:) is drawn as before; one saved as anhttpsaddress is drawn only under a prefix inimageHostsoflib/chat-config.tsx, and shows as its address otherwise. An app that stores generated images on its own storage names that host there, and passes the same list to the artifacts page’sDocumentListasimagePrefixes. - Enter takes the highlighted
/command or@mention while the picker is open, and no longer sends the message. - Closing the canvas with an unsaved edit asks first: save, discard or keep editing.
- The Better-Auth instance is built on first use, not when
@intelligo-dev/authloads. A test that rebuilds it under another environment (vi.resetModules()and a freshimport) also clears the registry ref it is kept in:createRegistryRef("auth/instance", null).set(null)from@intelligo-dev/core/registry. - The server holds the password rule. A new password on sign-up,
reset and change needs 8 to 128 characters with an upper-case letter,
a lower-case one and a number, which the installed forms already
asked for. A product whose own form asks for something else gives its
rule to
configureAuth({ passwordRule }). Passwords already set are not checked. - An admin acting as a user cannot change that user’s password or email, delete the account or end its sessions. Those endpoints answer 403 to an impersonated session.
6. Optional: what 1.3.0 adds
- A cap on what the deployment spends, for a free tier or a launch:
registerSpendCap({ dailyUsd, totalUsd })inlib/intelligo.ts. setPersonalWorkspaceName(fn)names the workspace made at signup.- The invitation page shows a product’s own label for an invitation’s
productFields: addproductFields.<field>.<value>to theinvitation-acceptmessages. - Work the deployment gives away:
billTo: "platform"onexecutions.beginand onrunWithExecution. The workspace’s balance is neither checked nor charged, and a spend cap still counts the run. - Your own Better-Auth plugins, session settings and user fields:
configureAuth({ plugins, tables, session, user, hooks })in alib/auth.tsthe composition root imports, andcreateIntelligoAuthClient({ plugins })for the client half. - A security page:
pnpm exec shadcn add @intelligo/security-settingsinstalls/settings/security, where a person changes their password, turns two-step sign-in on or off, and sees and ends the sessions their account is signed in from. Without the page nobody can turn two-step sign-in on, and sign-in is as it was; the syncedauth-loginform already asks for the code of an account that has it.PLATFORM_ADMIN_REQUIRE_2FA=truerefuses the console to a platform admin without it. Add its tab tolib/settings-nav.ts(value: "security",href: "/settings/security",titleKey: "settings-shell.tabs.security") and thetabs.securitykey to thesettings-shellmessages. - A signup bootstrap that is retried:
setWorkspaceCreatedDeliveryputs the created workspace on the job queue andrunWorkspaceCreatedis its handler (the background jobs guide has both bindings). The handler must be safe to run twice for one workspace. - A sharing mode per workspace:
setConversationSharingResolver((workspaceId) => mode)besidesetConversationSharing. The workspace settings page now lists what a workspace has shared for its owner, who can take a link back; new message keys undersharedinworkspace-settings. - A runtime that falls back to another model: the agent’s
fallbackModelIds, andturn.answeredByfor the one that answered. - Three more response headers, which a new app sends (app-scaffold
1.33.0): add
object-src 'none'; base-uri 'self'to theContent-Security-Policyinnext.config.mjs, with aPermissions-Policyand aCross-Origin-Opener-Policyofsame-origin-allow-popupsbeside it.contentSecurityPolicy()from@intelligo-dev/next/cspwrites a report-only policy for scripts, images and frames to try before enforcing one.
7. Checks
pnpm exec intelligo doctor
pnpm exec intelligo sync --check
pnpm exec intelligo migrate --check
pnpm type-check && pnpm build # and your own tests, if the app has any