Tag

#typescript

43 posts

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
5 min readResonate HQ

Infinite AI chess workflow in TypeScript on GCP Cloud Functions

How an AI-vs-AI chess match becomes a generator on a serverless function — durable, bounded in replay, recursive across games via ctx.detached.

Two AI players take turns through a generator function on a Cloud Function. Each move is a durable checkpoint, each pause is a durable sleep, and a detached tail call re-roots the workflow after every game so replay scope stays bounded forever.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
4 min readResonate HQ

Priority queue with bounded per-tier concurrency in TypeScript on Resonate

A nested loop over priority tiers becomes the scheduler when every yield* is a durable Resonate checkpoint.

Process a batch of jobs in strict priority-tier order with up to 2 jobs running concurrently per tier. Each job is a durable checkpoint, so a mid-batch crash only retries the failing job — completed higher-priority jobs are not re-run.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
4 min readResonate HQ

Next.js Server Action backed by a durable workflow in TypeScript

How a Server Action and a status route share a durable promise id so the page can poll for completion without holding the request open.

A Next.js Server Action kicks off a 4-step background workflow keyed by a report id; a separate API route resolves the same id to poll for completion. The workflow and the status route share one in-process Resonate registry.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
4 min readResonate HQ

Durable entity as a long-running workflow in TypeScript on Resonate

How a user session lifecycle is expressed as a single generator function when each step is a Resonate durable checkpoint and the idle timer survives crashes.

Model a user session as a long-running generator: login, per-activity checkpoints, durable idle timeout, and cleanup. Crashes resume mid-lifecycle without re-recording earlier activities or restarting the timer.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
4 min readResonate HQ

Async RPC across services in TypeScript on Resonate

Three remote-invocation shapes — rpc, detached, rfi — across an Express gateway and nine service groups, with crash recovery.

Cross-process function calls survive node crashes when the call graph is a durable promise. The example shows await-chain, detached-chain, and fan-out flows using a single TypeScript SDK with three RFI shapes.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
4 min readResonate HQ

Hello World quickstart in TypeScript on Resonate

The smallest unit of a Resonate TypeScript program — a generator workflow, two leaf functions, a registered handle — annotated for retrieval.

The minimum durable program in the Resonate TypeScript SDK: one generator workflow, two async leaf functions, no server required. Each ctx.run call is a durable checkpoint that short-circuits on replay.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
5 min readResonate HQ

Durable multi-turn chatbot with checkpointed LLM calls in TypeScript

How a multi-turn chatbot stops re-prompting users and re-charging tokens when every LLM call is a Resonate durable checkpoint.

A multi-turn chatbot must survive transient LLM failures mid-turn without re-prompting the user or paying twice for the same completion. On Resonate, each turn is a workflow keyed by session and turn number, and the Claude call inside it is a ctx.run checkpoint.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
4 min readResonate HQ

Long-running Hacker News research agent in TypeScript on Resonate

How an infinite monitoring loop, an LLM call per story, and an in-memory deduplication set survive process restarts without an external state store.

A continuous LLM-driven monitor that scans Hacker News, scores stories for relevance, and notifies on findings. Each step is a durable checkpoint and the deduplication set rebuilds itself from the promise store on restart.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
5 min readResonate HQ

Saga with compensating actions in TypeScript on Resonate

How a saga collapses to a generator function with try/catch when every step is a Resonate durable checkpoint.

Book a flight, hotel, and car rental as a single transaction. If the car rental fails, hotel and flight are cancelled in reverse order. Each step is a durable checkpoint, so a crash mid-compensation resumes where it left off.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
4 min readResonate HQ

Human-in-the-loop Kubernetes node drain in TypeScript on Resonate

How a node drain that may block for arbitrary human response time is written as a single generator function with checkpointed steps and a blocking durable promise.

Drain Kubernetes worker nodes durably: each node drain is a checkpoint, and when a Pod Disruption Budget blocks eviction the workflow blocks on a durable promise until an operator resolves it over HTTP.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
6 min readResonate HQ

Browser tab as a Resonate worker in TypeScript

How a browser tab registers as a Resonate worker, claims recursive factorial invocations addressed by the poll://any@default invoke tag, and resumes its work after a refresh.

Host a Resonate worker inside a browser tab so durable invocations are claimed and executed by client-side code. The tab subscribes to the Resonate server over SSE, claims tasks for its worker group, and resumes work after a refresh because every step is a durable promise.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
4 min readResonate HQ

One-click buy with a durable cancellation window in TypeScript on Resonate

A one-click checkout where the cancellation window is a durable `ctx.run` over a Promise race, not a `PENDING / CONFIRMED / CANCELLED` state row.

Start a purchase, open a 5-second window in which the user can cancel, then confirm or cancel. The window is one `ctx.run` over a Promise that races a timer against an EventEmitter signal — checkpointed, so a crash mid-window resumes from where it left off.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
4 min readResonate HQ

Infinite monitoring workflow in TypeScript on Resonate

How an unbounded health-check loop stays durable across step failures using ctx.run plus ctx.sleep, with no periodic history-reset step.

A health monitor that loops forever — check services, alert, sleep, repeat. The loop is a plain while; each iteration is a Resonate checkpoint, each pause is a durable sleep, and there is no history-size limit to reset by hand.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
4 min readResonate HQ

Multi-step food delivery saga in TypeScript on Resonate

How a six-step delivery pipeline with a no-driver compensation branch fits inside a single generator function when every yield is a Resonate durable checkpoint.

A six-step food delivery pipeline — order, prepare, assign driver, pickup, deliver, complete — where every step is a durable checkpoint and a transient mid-step failure retries in place without re-invoking earlier steps.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
6 min readResonate HQ

Resilient website summarization agent in TypeScript on Resonate

How a download/summarize/approve agent reads as straight-line generator code when scrape, LLM, notification, and human gate are all Resonate primitives.

Scrape a page, summarize it with an LLM, gate the result on human approval, and regenerate on rejection — as one generator workflow. Each step is a durable checkpoint and the approval pause is a latent durable promise the gateway settles from outside.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
5 min readResonate HQ

Durable order-lifecycle state machine in TypeScript on Resonate

How a six-state order workflow collapses to straight-line generator code when each ctx.run call is a durable checkpoint.

An order moves through created, confirmed, shipped, delivered (or cancelled, refunded), and must resume cleanly mid-transition after a crash. With Resonate the generator's execution position IS the state — each transition is a ctx.run checkpoint, no K/V store required.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
3 min readResonate HQ

Payload encryption at the promise store boundary in TypeScript

How a ~50-line AES-256-GCM Encryptor keeps PII out of the promise store without touching workflow logic.

Encrypt every value Resonate stores — function arguments, return values, intermediate state — by implementing a two-method Encryptor interface. Workflow code is unchanged; the codec calls encrypt() on the way in and decrypt() on the way out.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
5 min readResonate HQ

Load balancing across worker instances in TypeScript on Resonate

How a worker group plus a `poll://any@workers` target collapses service discovery, load balancing, and crash recovery into a constructor arg and an option string.

Run multiple TypeScript workers in a named group and dispatch durable RFIs to any one of them. The Resonate Server handles service discovery, load balancing, and dispatch recovery; the worker code is one function and a group string.

Resonate brand card on a dark background with a teal spectrum wave at the bottom and the post headline in white Sansation.
4 min readResonate HQ

Per-message Kafka worker with crash recovery in TypeScript

How a Kafka-fed worker collapses head-of-line blocking and crash-resume into straight-line code by treating each message as a durable promise.

A Kafka consumer kicks off one durable workflow per message and returns immediately. Each step is a checkpoint; a worker crash mid-deletion resumes from the last completed batch, and the record id deduplicates retries.