TypeScript usage
The @banh libraries are at 0.1.0-alpha.1 (MIT). They need Node.js 20+ and ESM. APIs may change during alpha.
npm install @banh/dsl@alpha @banh/runtime@alpha @banh/laya@alphaUsing the example files:
import { readFile } from 'node:fs/promises';import { parseProcess } from '@banh/dsl';import { ProcessRuntime } from '@banh/runtime';import { LayaBackend } from '@banh/laya';
const definition = parseProcess( await readFile('examples/support-triage.yaml', 'utf8'),);const input = JSON.parse( await readFile('examples/inputs/support-ticket.json', 'utf8'),);const backend = await LayaBackend.create();try { const runtime = new ProcessRuntime(backend); const result = await runtime.execute(definition, input); console.log(result.output); console.log(result.decisions); // Reuse this runtime and backend for subsequent inputs.} finally { await backend.close();}Backend lifetime
Section titled “Backend lifetime”You own the backend: reuse it across runs and close it when done. Parsing and validation don’t load Laya. There’s no automatic model fallback.
Execution result
Section titled “Execution result”| Field | Meaning |
|---|---|
process |
Workflow process name. |
output |
Value from the first matching rule. |
decisions |
Per decision: normalized and raw answer, policy result, metadata. |
timing.totalMs |
Execution duration, excluding model loading. |
timing.inferenceMs |
Inference duration, when available. |
usage |
Optional inputTokens and outputTokens. |
diagnostics |
Optional HTTP attempts, latency, size and status. |
Pass { onEvent } to new ProcessRuntime(backend, { onEvent }) to observe inference and flow events.
Select a provider
Section titled “Select a provider”Install @banh/providers@alpha and set BANH_INFERENCE_TOKEN. This runs the same definition and input on Jev:
import { createProvider } from '@banh/providers';
const backend = await createProvider({ provider: 'http', model: 'jev', options: { token: process.env.BANH_INFERENCE_TOKEN, modelId: 'jev-1.13.0', timeoutMs: 120_000, maxAttempts: 2, },});try { const result = await new ProcessRuntime(backend).execute(definition, input, { signal: AbortSignal.timeout(140_000), }); console.log(result.output);} finally { await backend.close();}createProvider() with no arguments returns native Laya. Unlike the CLI, the runtime doesn’t read the YAML model; pass the backend you want. See provider presets.
HTTP only, no native dependency: install @banh/dsl, @banh/runtime and @banh/typesafe (all @alpha). Construct TypeSafeHttpBackend with baseUrl and optional modelId, token, timeoutMs, maxAttempts (1 or 2) and retryDelayMs.