Local SDK
createLocalSdk creates a typed client that triggers workflows through a WorkflowInvoker in the same process. The SDK is parameterized with your Router type, so workflowId and params are checked at compile time.
Setup
import { createLocalSdk } from "yieldstar";
import type { Router } from "./shared";
const sdk = createLocalSdk<Router>(invoker);sdk.trigger
Triggers a workflow and returns { executionId } immediately. The workflow runs in the background.
const { executionId } = await sdk.trigger({
workflowId: "process-order",
params: { orderId: "abc123" },
});sdk.triggerAndWait
Triggers a workflow and blocks until it completes. Returns the workflow's return value.
const result = await sdk.triggerAndWait({
workflowId: "process-order",
params: { orderId: "abc123" },
});The promise resolves when the WorkflowInvoker emits the executionId on its workflowEndEmitter. If the workflow throws, the error propagates to the caller.
Trigger event shape
| Field | Type | Required | Description |
|---|---|---|---|
workflowId | string | Yes | ID matching a key in the router |
params | Record<string, any> | Depends on workflow type | Input data accessible via event.params inside the workflow |
executionId | string | No | Custom execution ID. Auto-generated via nanoid if omitted |