UNPKG

@copilotkit/runtime

Version:

<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />

68 lines (66 loc) 2.98 kB
import { AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest } from "./agent-runner.cjs"; import { Observable } from "rxjs"; import { BaseEvent } from "@ag-ui/client"; //#region src/v2/runtime/runner/intelligence.d.ts interface IntelligenceAgentRunnerOptions { /** Phoenix runner websocket URL, e.g. "ws://localhost:4000/runner" */ url: string; /** Optional Phoenix socket auth token used during websocket connect. */ authToken?: string; /** Max delay (ms) for WebSocket reconnect backoff. @default 10_000 */ maxReconnectMs?: number; /** Max delay (ms) for channel rejoin backoff. @default 30_000 */ maxRejoinMs?: number; } interface RunnerStartupBoundary { events: Observable<BaseEvent>; startup: Promise<void>; } declare class IntelligenceAgentRunner extends AgentRunner { private options; private threads; constructor(options: IntelligenceAgentRunnerOptions); /** * Create a new Phoenix socket with explicit exponential backoff. * * Each run/connect gets its own socket so that: * - A socket failure only affects a single thread, not all threads. * - Cleanup is simple: channel.leave() + socket.disconnect() tears * down everything for that run with no shared-state concerns. * - Each run gets its own independent retry budget. * * reconnectAfterMs — delay before Phoenix reconnects the WebSocket * after an unclean close. 100ms base, doubling up to maxReconnectMs (default 10s). * * rejoinAfterMs — delay before Phoenix re-joins a channel that * entered the "errored" state. 1s base, doubling up to maxRejoinMs (default 30s). * * These are set explicitly because Phoenix's default schedule is a * fixed stepped array (not exponential), and any code that calls * socket.disconnect() in an onError handler will set * closeWasClean = true and reset the reconnect timer — permanently * killing retries. */ private createSocket; private createRunnerEventPayload; private stampCanonicalRunOwnership; private stampRunnerMetadata; run(request: AgentRunnerRunRequest): Observable<BaseEvent>; runWithStartupBoundary(request: AgentRunnerRunRequest): RunnerStartupBoundary; private createRunObservable; connect(request: AgentRunnerConnectRequest): Observable<BaseEvent>; isRunning(request: AgentRunnerIsRunningRequest): Promise<boolean>; stop(request: AgentRunnerStopRequest): Promise<boolean | undefined>; private executeAgentRun; /** * Tear down all resources for a thread: leave the channel, * disconnect the per-run socket, and remove the thread state. * * Idempotent — safe to call multiple times for the same threadId * (e.g. from join error handlers, finalize, and Observable teardown). */ private removeThread; } //#endregion export { IntelligenceAgentRunner, IntelligenceAgentRunnerOptions, RunnerStartupBoundary }; //# sourceMappingURL=intelligence.d.cts.map