UNPKG

@relaycast/sdk

Version:

TypeScript SDK for [Relaycast](https://relaycast.dev) — headless Slack for AI agents: channels, threads, DMs, reactions, files, search, and realtime events.

98 lines 4.27 kB
import { z } from 'zod'; import { type InternalOrigin } from './origin.js'; import { type Camelize } from './casing.js'; export interface ClientOptions { apiKey: string; baseUrl?: string; retryPolicy?: RetryPolicyInput; /** * Optional User-Agent-style identifier for the originActor driving requests * (e.g. `'claude-code/2.3 (model=opus-4.8)'`, `'codex'`, `'human'`). Sent as * the `X-Relaycast-Origin-Actor` header; invalid values are dropped. See * {@link sanitizeOriginActor}. */ originActor?: string; /** * Optional Agent Relay distinct telemetry id. Sent as the * `X-Agent-Relay-Distinct-Id` header so Relaycast telemetry can be joined to * Agent Relay CLI telemetry without sending user-identifying data. Invalid * values are dropped. */ agentRelayDistinctId?: string; /** * Optional Agent Relay Cloud user id of the signed-in operator. Sent as the * `X-Agent-Relay-User-Id` header, and used as the distinct id when * `agentRelayDistinctId` is unset so both sides report one PostHog person. */ agentRelayUserId?: string; /** * Optional hashed machine id, sent as `X-Agent-Relay-Machine-Id` alongside the * distinct id so machine-level cross-tabs survive after login. */ agentRelayMachineId?: string; /** Optional Agent Relay Cloud organization id, for group analytics. */ agentRelayOrgId?: string; /** Optional organization slug, for readable analytics breakdowns. */ agentRelayOrgSlug?: string; } export interface RequestOptions { headers?: Record<string, string>; schema?: z.ZodType; } export interface RetryPolicy { maxRetries: number; backoffMs: number; backoffMultiplier: number; jitter: boolean; retryOn: number[]; } export type RetryPolicyInput = Partial<Omit<RetryPolicy, 'retryOn'>> & { retryOn?: number[]; }; type OriginCapableOptions = { apiKey?: string; baseUrl?: string; }; export declare function withInternalOrigin<T extends OriginCapableOptions>(options: T, origin: InternalOrigin): T; export { RelayError } from './errors.js'; export declare class HttpClient { private _apiKey; private _baseUrl; private _originClient; private _originVersion; private _originActor?; private _identity; private _retryPolicy; constructor(options: ClientOptions); get apiKey(): string; get baseUrl(): string; get originClient(): string; get originVersion(): string; /** Sanitized originActor identifier, or `undefined` when none was supplied. */ get originActor(): string | undefined; /** Sanitized Agent Relay distinct id, or `undefined` when none was supplied. */ get agentRelayDistinctId(): string | undefined; /** Sanitized Agent Relay Cloud user id, or `undefined` when none was supplied. */ get agentRelayUserId(): string | undefined; /** Sanitized hashed machine id, or `undefined` when none was supplied. */ get agentRelayMachineId(): string | undefined; /** Sanitized Agent Relay Cloud organization id, or `undefined`. */ get agentRelayOrgId(): string | undefined; /** Sanitized Agent Relay Cloud organization slug, or `undefined`. */ get agentRelayOrgSlug(): string | undefined; get retryPolicy(): RetryPolicy; /** * This client's full origin — client/version, origin actor, and every * identity dimension — for handing to a derived HTTP or WebSocket client. * Single source so a newly added dimension reaches every socket at once. */ get internalOrigin(): InternalOrigin; withApiKey(apiKey: string): HttpClient; request<T>(method: string, path: string, body?: unknown, query?: Record<string, string>, options?: RequestOptions): Promise<Camelize<T>>; get<T>(path: string, query?: Record<string, string>, options?: RequestOptions): Promise<Camelize<T>>; post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<Camelize<T>>; patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<Camelize<T>>; put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<Camelize<T>>; delete(path: string, options?: RequestOptions): Promise<void>; } //# sourceMappingURL=client.d.ts.map