Skip to main content
By the end of this guide, a short TypeScript program follows one of your Reliant runs as it happens, printing each message and status change, then closes and picks up where it left off without fetching the chat again. That is the same live stream, resume and state the Reliant app itself is built on, from @reliantlabs/sdk, so you can put a run’s progress in your own tools: an internal dashboard, a status page for your team, a script.

Before you begin

1

Install the SDK

The package is not on the npm registry yet. Build reliantlabs-sdk-0.1.0.tgz from the Reliant repository as the TypeScript SDK page describes, then install it with its peer dependencies and a Connect transport:
terminal
2

Start a run to watch

terminal
Copy the Chat/Execution ID it prints: a run lives in a chat, and the stream is per chat.
3

Write the watcher

watch.ts
reliant.chat() returns a ChatSession. It opens the chat’s stream, folds every update into one state object, and calls your listener on each change. onCaughtUp reports how each connection synced: a snapshot of the whole chat, or a replay of what was missed since the state’s cursor. Passing a saved state as initialState is what turns the second connection into a replay.
4

Run it, answer, and watch it resume

terminal
After eight seconds the first connection closes with the question still pending. Answer it from another terminal with reliant workflow answer <chat-id> --select Ship (or in the app), then press Enter:
The second connection started from cursor 7 and received only the seven updates since then, among them the answer, the final message and the completion, not the whole chat again. The same happens on its own when a connection drops: the session reconnects with backoff and asks for everything after its cursor.
5

Move it into a browser

In a frontend, swap staticTokenProvider for an AuthTokenProvider over the signed-in user’s own session (getToken, hasSession, refresh), and feed chat.subscribe and chat.getState to your framework’s external-store hook, such as React’s useSyncExternalStore. Never ship an API token to a browser (Where the token comes from). To resume across a page reload, save the state yourself: its cursor is a bigint and some fields are Maps and Sets, so write a serializer rather than JSON.stringify.

What this does not do

  • It shows a signed-in user their own chats. Every stream acts as the Reliant user whose credential it holds, and a chat that is not theirs is refused. It is not a way to give your own customers a chat with your app.
  • It doesn’t start runs or answer questions. The TypeScript SDK streams chats and sends messages. Starting runs, answering questions and firing triggers are in the Go SDK, on your server.
  • It doesn’t decide approvals. The state lists pending approvals so you can show them; deciding one takes a person in the app.

Troubleshooting

The server refused the chat: it does not exist, or is not the signed-in user’s. The two cases look the same on purpose. Check the chat ID and whose token getToken returns.
npm install in a copy of sdk/ts failed while resolving peer dependencies. Install there with npm install --legacy-peer-deps, or build it inside the repository’s frontends/web workspace with pnpm install.

Next steps

Start runs from Go

Start the runs this watcher follows, from your server.

TypeScript SDK reference

Sends with retry, tool bodies, the reducer on its own.

Pause and steer a run

Change what a running agent does from the app or the CLI.

SDK credentials and scopes

Which token goes where, and what each scope allows.