The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.
import assert from 'node:assert/strict'
import { presentLogLines, type RawLogLine } from './console-logs'
import { humanChange } from './console-deployment'
import type { Deployment } from './db'
const line = (n: number, source: string, level: string, text: string, deployment: number | null = 3): RawLogLine => ({
id: `l${n}`,
ts: `2026-10-22T10:00:${String(n).padStart(2, '0')}.000Z`,
source,
level,
line: text,
deployment,
})
const dep = (over: Partial<Deployment>): Deployment =>
({
number: 3,
kind: 'deploy',
by: 'key:…abcd',
started_at: '2026-10-22T10:00:00.000Z',
live_at: '2026-10-22T10:00:12.500Z',
...over,
}) as Deployment
test('the console reads milestones for people and keeps platform detail behind its source', async () => {
const out = await presentLogLines(
[
line(1, 'system', 'info', 'deploy #3: snapshot snap_abc extracted to /home/boxlite/app/releases/3'),
line(2, 'build', 'error', 'npm notice New major version of npm available! 10.9.8 -> 12.2.0'),
line(3, 'build', 'error', 'npm ERR! code ERESOLVE'),
line(4, 'system', 'info', 'applying migration 0003_add_deals.sql'),
line(5, 'system', 'info', 'applying migration 0004_index.sql'),
line(6, 'system', 'info', 'applied 2 migration(s)'),
line(7, 'system', 'info', 'deployment #3 is live at https://10001-d-x.proxy.dev.boxlite.ai'),
line(8, 'web', 'info', 'listening on 20000'),
line(9, 'system', 'error', 'service web exited with code 143 after 23m31.936s; restarting in 1s'),
line(10, 'system', 'error', 'health check for web: unhealthy after 25ms'),
line(11, 'access', 'error', 'GET /api/deals 502 40ms', null),
line(12, 'system', 'error', 'failed at build: build step 2 (npm run build) exited with code 1', 4),
line(
13,
'system',
'error',
'deployment #4 failed at step build: build step 2 (npm run build) exited with code 1 (previous release stays live)',
4,
),
line(
14,
'build',
'error',
'npm warn exec The following package was not found and will be installed: [email protected]',
4,
),
],
async (n) => (n === 3 ? dep({}) : undefined),
)
const byId = new Map(out.map((l) => [l.id, l]))
// Newest first.
assert.equal(out[0]!.id, 'l14')
assert.deepEqual(byId.get('l7'), {
id: 'l7',
ts: line(7, '', '', '').ts,
source: 'deploy',
level: 'info',
line: '#3 is live · by key …abcd in 13 s',
deployment: 3,
detail: false,
})
assert.equal(byId.get('l6')!.source, 'db')
assert.equal(byId.get('l6')!.line, '2 migrations applied: 0003_add_deals.sql, 0004_index.sql (#3)')
assert.equal(byId.get('l13')!.line, '#4 failed at build: build step 2 (npm run build) exited with code 1')
assert.equal(byId.get('l13')!.level, 'error')
// The orchestrator's duplicate of that failure stays for the CLI, out of the console's way.
assert.equal(byId.get('l12')!.detail, true)
// Platform chatter is detail; the app's own output is not.
assert.equal(byId.get('l1')!.detail, true)
assert.equal(byId.get('l4')!.detail, true)
assert.equal(byId.get('l8')!.detail, false)
// stderr progress of a build tool is not an error; a real build error is, and stays in view.
assert.equal(byId.get('l2')!.level, 'info')
assert.equal(byId.get('l2')!.detail, true)
assert.equal(byId.get('l3')!.level, 'error')
assert.equal(byId.get('l3')!.detail, false)
// SIGTERM is a planned stop, not a crash; a failing health check stays a visible error.
assert.equal(byId.get('l9')!.level, 'info')
assert.equal(byId.get('l9')!.detail, true)
assert.equal(byId.get('l10')!.level, 'error')
assert.equal(byId.get('l10')!.detail, false)
// A build tool's warning is a warning even when it names something "not found"; it stays with the build output.
assert.equal(byId.get('l14')!.level, 'warn')
assert.equal(byId.get('l14')!.detail, true)
// Requests are listed only under their own source, errors included.
assert.equal(byId.get('l11')!.detail, true)
assert.equal(byId.get('l11')!.level, 'error')
})
test('what a deployment changed reads as sentences, not diff paths; variable values stay out', async () => {
assert.equal(
humanChange({ kind: '+', path: 'migrations/0003_import.sql', to: 'pending' }),
'New migration 0003_import.sql',
)
assert.equal(humanChange({ kind: '+', path: 'services.worker', to: {} }), 'New service worker')
assert.equal(humanChange({ kind: '-', path: 'services.worker', from: {} }), 'Removed service worker')
assert.equal(
humanChange({ kind: '~', path: 'services.web.command', from: 'node a.js', to: 'node b.js' }),
'web: start command changed',
)
assert.equal(
humanChange({ kind: '~', path: 'service.web.health', from: '/', to: '/healthz' }),
'web: health check path changed',
'the singular form the diff also uses',
)
assert.equal(
humanChange({ kind: '~', path: 'public_paths', from: [], to: ['/webhooks/*'] }),
'Open without signing in (webhooks): /webhooks/*',
)
assert.equal(humanChange({ kind: '+', path: 'database', to: 'neon branch main' }), 'Added a database')
assert.equal(humanChange({ kind: '+', path: 'variables.LOG_LEVEL', to: 'debug' }), 'New variable LOG_LEVEL')
assert.equal(humanChange({ kind: '~', path: 'variables.GREETING', from: 'a', to: 'b' }), 'Changed variable GREETING')
assert.equal(
humanChange({ kind: '+', path: 'secrets.OPENAI_API_KEY', to: 'org/openai' }),
'OPENAI_API_KEY now comes from org/openai',
)
assert.equal(humanChange({ kind: '~', path: 'access', from: 'private', to: 'public' }), 'Access: private → public')
assert.equal(
humanChange({ kind: '~', path: 'runtime.size', from: 'small', to: 'medium' }),
'Box size: small → medium',
)
})
it.each([
['-', 'migrations/0001_initial.sql', null, 'Migration 0001_initial.sql removed'],
['~', 'migrations/0001_initial.sql', null, 'Migration 0001_initial.sql changed'],
['~', 'public_paths', [], 'No paths open without signing in'],
['~', 'database.migrations', 'db', 'Migrations folder changed'],
['-', 'database', null, 'Removed the database'],
['~', 'database', null, 'Database changed'],
['-', 'secrets.MAIL', null, 'Removed secret MAIL'],
['+', 'auth', {}, 'Sign-in turned on'],
['-', 'auth', null, 'Sign-in turned off'],
['~', 'auth', {}, 'Sign-in settings changed'],
['+', 'access', 'private', 'Access: private'],
['~', 'runtime.build', ['make'], 'Build commands changed'],
['+', 'runtime', 'node', 'Runtime: node'],
['~', 'runtime', {}, 'Runtime changed'],
['~', 'domains.custom', [], 'Custom domains changed'],
['online_only', 'region', 'us', 'online region: us'],
['-', 'volumes.data', null, 'Removed volume data'],
['~', 'schedules.daily.target', 'web', 'daily: what it calls changed'],
] as const)('summarizes %s %s', (kind, path, to, expected) => {
expect(humanChange({ kind, path, to })).toBe(expected)
})
it('describes rollback, config-only releases, cancellation and migrations even with missing history', async () => {
const inputs = [
line(8, 'system', 'info', 'cancelled', 4),
line(2, 'system', 'info', 'applied 1 migration(s)', null),
line(5, 'system', 'info', 'deployment #2 is live at example', 2),
line(5, 'system', 'info', 'deployment #1 is live at example', 1),
line(7, 'system', 'info', 'deployment #3 is live at example', 3),
]
const output = await presentLogLines(inputs, async (n) =>
n === 1
? dep({ kind: 'apply', by: 'console', started_at: null })
: n === 2
? dep({ kind: 'rollback', by: 'admin', live_at: '2026-10-22T10:00:01.500Z' })
: undefined,
)
expect(output.map((row) => row.line)).toEqual(
expect.arrayContaining([
'#4 cancelled',
'1 migration applied',
'#1 is live with new configuration · by console',
'#2 is rolled back and live · by admin in 1.5 s',
'#3 is live',
]),
)
})