Skip to content

Packages

AI lifecycle helpers

Private maintained runtime copied into generated desktop and Node apps.

Content reviewed 16 October 2026

packages/runtime-ai is maintained source, not a public AI dependency. Generators copy it into .unstoppable/runtime-ai/. Apps own prompts, schemas, UI, history and domain logic; runtime-specific adapters own native inference.

Run the session contract without a model

Use Node 22.17+ in a repository checkout. Save the following as runtime-smoke.mjs at the repository root. The mock adapter has no native SDK or model dependency; it demonstrates loading, consuming a stream and closing the session.

js
import { createAISession, createMockAdapter } from './packages/runtime-ai/src/index.js'

const ai = createAISession({ adapter: createMockAdapter(), byteBudget: 4096 })
try {
  await ai.load()
  let result = ''
  for await (const token of ai.stream(
    [{ role: 'user', content: 'Hello' }],
    { requestId: 'first-message' }
  )) result += token
  console.log(result)
} finally {
  await ai.close()
}
bash
node runtime-smoke.mjs

Expected output: Mock: Hello. In a generated app, import from its .unstoppable/runtime-ai/index.js instead and keep the session in the worker. This run checks the session protocol; use the Local AI guide for native inference and cancellation validation.

Session operations and ownership

  • createAISession({ adapter, byteBudget }) owns model loading, bounded history, one active request, cancellation, error codes and unloading.
  • load(options) prepares the model; stream(history, { requestId, signal, onTrim }) yields output; cancel(requestId) stops a request; close() releases resources.
  • Cancellation keeps the session busy until native work settles. Consume or return the stream before waiting on cleanup; do not replay partially emitted output automatically.
  • Bare and Node adapters load native modules lazily. Mock output is visibly labelled. Expo uses a separate experimental implementation.
  • Existing apps retain their vendored runtime until explicitly migrated. Compatibility checks report differences; regeneration with --force is not an upgrade workflow.

Personal Node's delegated completion adapter is a separate host composition. P2P transports granted calls; it does not own models. Contract tests do not prove real inference, native cancellation/reuse or cached offline startup.

Need help? Report an issue with your CLI version, platform, command and first relevant error.