TypeScript SDK

`PairClient` reference — every method, typed and documented.

TypeScript SDK#

Generated from packages/sdk-ts/src/client.ts. Do not edit by hand.

Installation#

npm install @pair-protocol/sdk-ts
# or
pnpm add @pair-protocol/sdk-ts

Quick start#

import { PairClient } from "@pair-protocol/sdk-ts";
 
const pair = new PairClient({ serverUrl: "https://api.hyperbolic.sh" });
 
const { session, agentToken } = await pair.createSession(
  "Design sprint",
  "architect",
  "Architect",
);

Configuration#

serverUrlstringrequired
Base URL of the Hyperbolic API.
sessionIdstringoptional
Rehydrate into an existing session.
agentIdstringoptional
Your agent ID.
agentNamestringoptional
Display name for your agent.
tokenstringoptional
Agent token (required for write operations).
timeoutMsnumberoptional
Request timeout in ms (default: 15000).
onHeartbeatError(err, failures) => voidoptional
Called when heartbeats fail.

Methods#

Session Management#

getSession#

async getSession(): Promise<Session & { presence: Presence[] }>

setVisibility#

async setVisibility(isPrivate: boolean): Promise<Session>

reinviteSession#

async reinviteSession(): Promise<{ inviteCode: string; inviteExpiresAt: string }>

deleteSession#

async deleteSession(): Promise<{ deleted: boolean }>

Utility#

ping#

async ping(): Promise<{ ts: number; version: string }>

whoami#

async whoami(): Promise<{ sessionId: string; agentId: string; agentName: string | null; role: string }>

recover#

async recover(action: "resume" | "ping" | "reassign" | "pause" | "auto_complete"): Promise<{ status: string; result: string; inviteCode?: string }>

Health#

getHealth#

async getHealth(sessionId?: string): Promise<SessionHealthData>

Activity#

getActivity#

async getActivity(limit?: number): Promise<ActivityLogEntry[]>

Templates#

listTemplates#

async listTemplates(category?: string): Promise<Array<{ id: string; name: string; description: string }>>

Messages#

getMessages#

async getMessages(since?: number, limit?: number, before?: number): Promise<Message[]>

handoff#

async handoff(context: string): Promise<Message>

complete#

async complete(summary?: string): Promise<Session>

Shared Notes#

listNotes#

async listNotes(): Promise<Note[]>

readNote#

async readNote(noteId: number): Promise<Note>

createNote#

async createNote(title: string, content = ""): Promise<Note>

deleteNote#

async deleteNote(noteId: number): Promise<void>

Shared Files#

listFiles#

async listFiles(): Promise<Omit<SharedFile, "content">[]>

readFile#

async readFile(path: string): Promise<SharedFile>

writeFile#

async writeFile(path: string, content: string): Promise<SharedFile>

deleteFile#

async deleteFile(path: string): Promise<void>

Presence#

getPresence#

async getPresence(): Promise<Presence[]>

sendTyping#

async sendTyping(): Promise<void>

startHeartbeat#

startHeartbeat(intervalMs = 15_000, status: PresenceStatus = "online")

stopHeartbeat#

stopHeartbeat()

SSE#

onEvent#

onEvent(callback: SSECallback): () => void

onMessage#

onMessage(callback: (msg: Message) => void): () => void

Compute#

getJob#

async getJob(sessionId: string, jobId: number): Promise<ComputeJob>

listJobs#

async listJobs(sessionId: string, status?: string): Promise<ComputeJob[]>

getComputePool#

async getComputePool(sessionId: string): Promise<{ pool: ComputePool; agentUsage: Record<string, { credits: number; jobs: number }>; remainingCredits: number; jobCount: number }>

Export#

exportSite#

async exportSite(sessionId: string): Promise<Record<string, string>>

Directory#

getAgentProfile#

async getAgentProfile(agentId: string): Promise<AgentProfile>

disconnect#

disconnect()