Yoke.sh
SDK

TypeScript SDK

Complete reference for @yoke/sdk — defineRuntime, actors, portals, events, filters, queues, state, schedules, and context APIs.

The @yoke/sdk package is the author API for the internal TypeScript package the kernel loads. It is not your product's public SDK. Your users never import it.

Your product server embeds yoke-runtime (Rust). This package is what that runtime executes inside Deno — defineRuntime(), actors, portals, tools. See Embed Yoke in your product.

Every runtime loads a single default export from yoke.ts built with defineRuntime().

// yoke.ts — default export required
import { defineEvents, defineFor, defineRuntime, z } from "@yoke/sdk";

const events = defineEvents({
  "work.assigned": z.object({ role: z.string(), lang: z.string() }),
});

export default defineRuntime()
  .events(events)
  .portals(({ events }) => { /* ... */ })
  .actors(({ events, portals }) => { /* ... */ })
  .build();

Package contract

RequirementDetail
Entry fileyoke.ts at package root
Default exportMust be a defineRuntime() builder (call .build() or export the builder — the worker accepts both)
EventsDeclare once with defineEvents(); Zod schemas validate payloads at append and in process()
Zod re-exportImport z from @yoke/sdk (Zod 4)

The Deno worker loads your package, registers definitions in the Rust kernel, and bridges ctx.* calls over JSON-RPC. See Runtime for the IPC surface.

Core concepts

ConceptSDK entryRole
EventsdefineEvents, ctx.appendGlobal append-only stream; all communication flows through typed events
ActorsdefineActor, defineFor().actorStateful, queued handlers; one or many instances per definition
PortalsdefinePortal, defineFor().portalSingleton ingress/egress (HTTP routes + typed interface)
FiltersInstanceFilter, filterFromConfigInstance subscription to stream events
QueuesQueuePolicy, queueSelectFromConfigPer-instance drain order and concurrency
Statectx.state, ctx.sqliteDurable per-instance SQLite (typed document + raw SQL)
Schedulesctx.schedules, ctx.scheduleKeyed delayed events owned by an instance
ContextActorCtx, PortalCtxFull runtime surface inside process, start, routes, lifecycle hooks

Runtime builder flow

defineRuntime()
  .events(eventMap)           // register Zod payload schemas
  .inferenceStack(stack)       // optional LLM routing
  .agents(() => …)             // optional high-level agent definitions
  .chatPlatforms(({ agents }) => …)  // optional chat platform integrations
  .bootstrap(async (ctx) => …) // optional one-shot instance provisioning
  .portals(({ events }) => …)  // portal definitions; APIs flow to actors
  .actors(({ events, portals }) => …)
  .build()                     // RuntimeDefinition → loaded by DenoHost

Prefer the callback style (.portals(), .actors()) so events and portal APIs are threaded through types automatically. Legacy .portal(name, def) / .actor(name, def) methods remain available.

Reference pages

PageTopics
defineRuntimeBuilder methods, defineFor, defineEvents, agents, chatPlatforms, bootstrap, inferenceStack
ActorsdefineActor, process, lifecycle, queue, filters, sqliteStoreId
PortalsdefinePortal, routes, start, interface
EventsStreamEvent, AppendInput, Zod validation, priority, groupId
FiltersDeclarative vs function filters, FanoutIndex, filterFromConfig
QueuesFIFO/LIFO/random/custom, concurrency, priority groups, inherit
State & SQLitectx.state, CAS updates, __yoke_state, multi-store segments
SchedulesScheduleManager, keyed delayed events, HTTP client
Context APIFull ActorCtx / PortalCtx surface, conversations, instances, LLM

Type helpers

Common inference utilities exported from @yoke/sdk:

import type {
  InferSchema,
  InferConfig,
  InferState,
  InferActorConfig,
  InferActorState,
  InferPortalApi,
  InferPortalClients,
} from "@yoke/sdk";

On this page