Adapters & Examples
You don't have to hand-roll AgentEvents. Adapter packages translate popular framework streams into the Sharely wire protocol, and the SDK repository ships runnable reference servers for five integration patterns.
Adapters
Vercel AI SDK — @sharelyai/adapter-vercel-ai
Wrap a streamText call in fromVercelAI(...) and you have a compliant handler in ~15 lines — swap in any provider the AI SDK supports:
import { streamText } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';
import { fromVercelAI } from '@sharelyai/adapter-vercel-ai';
import type { Handler } from '@sharelyai/protocol';
export const handler: Handler = (input) =>
fromVercelAI(
streamText({
model: anthropic('claude-sonnet-4-5'),
messages: [
...input.history.map((m) => ({ role: m.role, content: m.content ?? '' })),
{ role: 'user', content: input.message },
],
abortSignal: input.signal,
})
);Temporal — @sharelyai/adapter-temporal
For agents orchestrated as Temporal workflows, fromTemporal({ client }) polls workflow signals and converts them into AgentEvents — giving you durable, resumable agent turns with the same streaming UX:
import { fromTemporal } from '@sharelyai/adapter-temporal';
export const handler: Handler = (input) =>
fromTemporal({
client: temporalClient,
workflow: 'agentTurn',
args: [input.message, input.context.threadId],
signal: input.signal,
});Anything else
Any framework that exposes a stream can be adapted — yield AgentEvents from an async generator as the stream arrives (see Handler & Wire Protocol). Validate custom adapters with @sharelyai/conformance.
Runnable Examples (no API keys required)
Each example in examples/ (opens in a new tab) is a handler.ts + server.ts wired into createSharelyServer, plus a smoke.mjs that mocks the platform so you can run it offline:
git clone https://github.com/sharelyai/sharely-server-sdk.git
cd sharely-server-sdk
npm install
npx turbo run build
node examples/anthropic-sdk-direct/smoke.mjs| Example | What it shows |
|---|---|
anthropic-sdk-direct (opens in a new tab) | Raw Anthropic SDK multi-turn loop with mid-stream tool calls |
openai-agents-sdk (opens in a new tab) | Observing an OpenAI Agents SDK streamed run |
langgraph (opens in a new tab) | Observing a compiled LangGraph's streamEvents |
raw-streaming (opens in a new tab) | No framework — a hand-rolled async generator |
adapter-vercel-ai (opens in a new tab) | fromVercelAI(...) — swap in any provider |
adapter-temporal (opens in a new tab) | fromTemporal({ client }) with a real Temporal client |
Live Demos (real workspace + LLM keys)
Full demo servers live in apps/ (opens in a new tab). Unlike the offline examples, these connect to a real Sharely workspace and LLM provider — copy the demo's .env.example to .env and fill in your keys:
| Demo | Stack | Port |
|---|---|---|
live-demo-vercel | Vercel AI SDK adapter | 8081 |
live-demo-temporal | Temporal adapter (server + worker) | 8082 |
live-demo-langgraph | LangGraph | 8083 |
live-demo-temporal-ai-sdk | Temporal orchestration + Vercel AI SDK inside activities | 8084 |
The Temporal demos run a separate worker process alongside the server — see each demo's README for the worker command.
Choosing a Pattern
- Fastest path: Vercel AI SDK adapter — one provider-agnostic dependency, streaming and tool use included
- Maximum control: raw streaming or the direct Anthropic/OpenAI SDK patterns — you own the loop, buffering, and replay
- Durable / long-running turns: Temporal adapter — workflow retries and resumability with the same streaming UX
- Graph-based agents: LangGraph pattern — observe
streamEventsfrom a compiled graph
Next Steps
- Quickstart — deploy and register your server
- Agent API Reference — thread, message, RAG, and registration contracts