Skip to content
Night Owls.dev
Jump to a page

@nightowlsdev/engine-ai-sdk

EngineNative

The second native engine, a governed ai@^7 streamText loop. Single-agent v1 (no delegation/workflows/semantic recall yet), full HITL + governance, tier-3 events.

What it does

@nightowlsdev/engine-ai-sdk is the second native engine in the `engine-*` family: a from-scratch swarm loop built directly on the raw Vercel AI SDK (`ai@^7` `streamText`) instead of Mastra. It reuses the SAME governance plane as `engine-mastra` verbatim, `HookDispatcher`/`ToolApprovalPolicy` (preGeneration reserve + preToolCall), `CostGovernor`/pricing, tier routing, secrets, telemetry, and passes both `verifyEngineContract` (the shared conformance suite) and a golden-trajectory parity gate against `engine-mastra`. Tool approvals map onto `ai@7`'s NATIVE per-tool `needsApproval`, backstopped engine-side by a fail-closed `executeToolWithGate` so a deny can never reach the model as an approval question. History and reads are derived from the persisted event log (`EventStore.listForContainer`), not a separate message store. v1 is deliberately single-agent: `delegation`, `workflows`, and semantic recall are all declared `false` on `AI_SDK_ENGINE_CAPABILITIES`, multi-agent packs still require `engine-mastra` until `ask_slug`-based delegation ships in v1.1. `aiSdkEngine({ durable: true })` flips `hitl.durableResume` on for storage that persists suspend/resume snapshots across processes (e.g. `storage-supabase`); the default `false` keeps `runner-background`/`mcp-server` treating resumes as non-durable. Ships a `nightOwlsPlugin` manifest (`kind: 'engine'`) so `owl install engine-ai-sdk` wires `defineSwarm({ engine: aiSdkEngine() })` into the config template.

Install

pnpm add @nightowlsdev/engine-ai-sdk

Key exports

  • aiSdkEngine
  • AiSdkEngine
  • AI_SDK_ENGINE_CAPABILITIES
  • nightOwlsPlugin

Usage

engine-ai-sdk.ts
import { defineSwarm } from "@nightowlsdev/core";
import { aiSdkEngine, AI_SDK_ENGINE_CAPABILITIES } from "@nightowlsdev/engine-ai-sdk";

// The second native engine, a governed ai@^7 streamText loop. Single-agent v1:
// no delegation/workflows/semantic recall yet (multi-agent packs still need
// engine-mastra). Same governance plane (cost, secrets, tool-approval gate).
const swarm = defineSwarm({ agents, engine: aiSdkEngine() });

// Pass { durable: true } only when your StorageAdapter persists suspend/resume
// snapshots ACROSS PROCESSES (e.g. storage-supabase), otherwise leave the
// default false so runner-background/mcp-server treat resumes as non-durable.
const durableSwarm = defineSwarm({ agents, engine: aiSdkEngine({ durable: true }) });

console.log(AI_SDK_ENGINE_CAPABILITIES.delegation); // false, v1 is single-agent