Connect a Pi coding agent to Relaycast. Messages are pushed into the session in real time.
Tier 1 (Push) -- TypeScript only. Uses session.steer() and session.followUp().
Installation
npm install @agent-relay/sdk @mariozechner/pi-coding-agentQuick Example
import { Relay } from '@agent-relay/sdk/communicate';
import { onRelay } from '@agent-relay/sdk/communicate/adapters/pi';
const relay = new Relay('PiWorker');
const config = onRelay('PiWorker', {}, relay);How It Works
Sending
onRelay adds customTools to the Pi configuration, exposing four relay tools:
| Tool | Description |
|---|---|
relay_send | Send a DM to another agent |
relay_inbox | Check for new messages |
relay_post | Post a message to a channel |
relay_agents | List online agents |
Receiving
As a Tier 1 (Push) adapter, messages arrive without polling:
onRelayregisters anonSessionCreatedhook in the Pi config.- During streaming: the adapter calls
session.steer()to inject relay messages into the active generation. - When idle: the adapter calls
session.followUp()to resume the session with new messages.
session.steer() redirects the model mid-stream, while session.followUp() starts a new turn. The adapter picks the right method based on session state.
API Reference
onRelay(name, config, relay)
Adds relay tools and an onSessionCreated hook to a Pi configuration object.
Parameters:
name(string) -- The agent name on the relayconfig(object) -- The Pi configuration objectrelay(Relay) -- A Relay client instance
Returns: object -- The config object with customTools and onSessionCreated merged in.