These steps use Runtime and contracts 0.4.0 and an optional published Assistant. Start in a copy or a development environment. Preserve the application's existing tests, saved choices, configuration and dependency lockfile.
Use direct execution for one model and one set of settings. When you need saved choices or backups, define the operation's input/output contract, required capabilities, retry limits and deadline. Start with explicit model settings in your application and an empty Local library in your coding agent. Register the reviewed model metadata, review and save a Route, then export the exact saved revision of its route set. A single-Route set is valid. The Routes and catalogs guide walks through each step.
Install the matching package pair. Save the canonical Route-set snapshot JSON from the export. Record its request and the Route ID returned by authoring. This TypeScript example assumes your host supplies the export path, exact request, Route ID, instructions, connections and credential resolver. For an application-scoped set, the exported request includes its original applicationId.
import { createRouteAIClient, createFileRouteSetResolver, routeSetSource, type CreateRouteAIClientOptions } from "@techis/ai-runtime";
import type { RouteSetRequest } from "@techis/ai-contracts";
export async function openWorkflow(
host: Omit<CreateRouteAIClientOptions, "configurationSource">,
path: string,
request: RouteSetRequest,
expectedDigest: string
) {
const resolver = createFileRouteSetResolver({ path, request, expectedDigest });
return createRouteAIClient({ ...host, configurationSource: routeSetSource(resolver) }).captureWorkflow();
}
export async function summarize(
workflow: Awaited<ReturnType<typeof openWorkflow>>,
routeId: string,
systemInstructions: string,
input: string,
signal: AbortSignal
) {
const run = await workflow.startRun({ routeId, systemInstructions });
return run.responses.create({ input }, {
operationId: "summary.short",
signal,
execution: { timingPolicy: "caller", attemptTimeoutMs: 15_000, deadlineMs: 25_000 },
featurePolicy: { requiredFeatures: ["text"], unknownCapability: "reject" }
});
}
Use the snapshot's request exactly as exported, including the set ID, selection mode and any saved revision. Supply the lower-case SHA-256 of the final JSON file bytes as expectedDigest. On Windows use (Get-FileHash -Algorithm SHA256 -LiteralPath "route-set.json").Hash.ToLowerInvariant(). On macOS use shasum -a 256 route-set.json. Capture the workflow once for related calls. Handle the returned outcome and receipt using the Runtime API guide.
For durable application history, keep a separate application-owned adoption directory using createFileRouteAdoptionRepository({ directory, applicationId }). An application can supply its own RouteAdoptionStorage with immutable content and atomic compare-and-swap.
contentDigest. resolveRouteImportAssignments validates the result against the accepted proposal and maps local keys to authoritative Route IDs.previewImport to review the change and storeImport to write an immutable generation. After a lost authoring reply, recover the original operation using get_route_import with the same source and UUID.recordQualification(generation, reportDigest). Use inspectRouteReadiness to check adapter, declared feature, endpoint and credential readiness without inference.activateImport(generation, expectedActiveGeneration) after qualification. Use null for no prior active generation. If the expected generation has changed, reread and review the current state. An intentional source change also requires explicit allowance.readActive() and load its saved snapshot and assignments. Confirm the execution point still resolves the intended stable ID. To recover, use listHistory() and rollback(previousGeneration, expectedActiveGeneration) to select an earlier qualified generation.The installed Assistant's onboarding/examples/ includes adopted-route-host.ts, app-owned-route.ts and mixed-selection.ts for workflow capture, response adaptation and preserved native choices. onboarding/docs/embedded-models-adoption-api.md describes the installed CLI. In the CLI, application-qualify records an application-produced report. Run the qualification itself in your application.
For a CLI-managed activation, run the installed onboarding/cli.mjs using Node.js. Substitute its installed path, your application data directory and ID, and the actual generation and report values. This example assumes the candidate is generation 2 and generation 1 is active.
node "ASSISTANT_CLI" application-qualify --application-dir "APP_DATA_DIR" --application-id "APP_ID" --generation 2 --report "qualification.json"
node "ASSISTANT_CLI" application-activate --application-dir "APP_DATA_DIR" --application-id "APP_ID" --generation 2 --expected-generation 1
After a successful activation, generation 2 is the expected current generation for a return to the qualified generation 1. Check history before rolling back.
node "ASSISTANT_CLI" application-history --application-dir "APP_DATA_DIR" --application-id "APP_ID"
node "ASSISTANT_CLI" application-rollback --application-dir "APP_DATA_DIR" --application-id "APP_ID" --generation 1 --expected-generation 2
Routes, route sets and catalogs ยท Runtime API and adapters ยท Documentation index