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.

69 lines 2.79 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; } 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 _agentRelayDistinctId?; 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; get retryPolicy(): RetryPolicy; 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