theater-client
Version:
TypeScript client library for Theater actor system TCP protocol
102 lines • 3.33 kB
TypeScript
/**
* High-level Theater client with hygienic connection management
* Each operation gets its own TCP connection to avoid response multiplexing
*/
import type { TheaterId, ChannelParticipant, ActorStatus, ManifestConfig, ChainEvent } from '../types/protocol.js';
import type { TheaterClientConfig, StartActorParams, ActorInfo, ChannelStream, ActorEventStream } from '../types/client.js';
import { Actor } from './Actor.js';
/**
* High-level Theater client that manages operations using hygienic connections
* Each operation gets its own TCP connection to avoid response multiplexing issues
*/
export declare class TheaterClient {
private readonly host;
private readonly port;
private readonly config;
constructor(host?: string, port?: number, config?: Partial<TheaterClientConfig>);
/**
* Create and connect a new Theater connection for a specific operation
*/
private createConnection;
/**
* Execute an operation with a dedicated connection and automatic cleanup
*/
private withConnection;
/**
* Handle error responses from the server
*/
private handleErrorResponse;
/**
* Get an Actor wrapper for an existing actor ID
*/
actor(id: TheaterId): Actor;
/**
* Start a new actor and return an Actor wrapper
*/
startActor(params: StartActorParams): Promise<Actor>;
/**
* Start a supervised actor with event streaming
*/
private startSupervisedActor;
/**
* Start a regular actor (current behavior)
*/
private startRegularActor;
/**
* Start a new actor with the given parameters (returns raw ID)
*/
startActorRaw(params: StartActorParams): Promise<TheaterId>;
/**
* Stop a running actor
*/
stopActor(id: TheaterId): Promise<void>;
/**
* List all running actors and return Actor wrappers
*/
listActors(): Promise<Actor[]>;
/**
* List all running actors (returns raw actor info)
*/
listActorsRaw(): Promise<ActorInfo[]>;
/**
* Get the status of a specific actor
*/
getActorStatus(id: TheaterId): Promise<ActorStatus>;
/**
* Restart an actor
*/
restartActor(id: TheaterId): Promise<void>;
/**
* Get the manifest configuration of an actor
*/
getActorManifest(id: TheaterId): Promise<ManifestConfig>;
/**
* Get the current state of an actor
*/
getActorState(id: TheaterId): Promise<Uint8Array | null>;
/**
* Get the event history for an actor
*/
getActorEvents(id: TheaterId): Promise<ChainEvent[]>;
/**
* Get metrics for an actor
*/
getActorMetrics(id: TheaterId): Promise<any>;
/**
* Send a fire-and-forget message to an actor
*/
sendActorMessage(id: TheaterId, data: Uint8Array): Promise<void>;
/**
* Send a request message to an actor and wait for response
*/
requestActorMessage(id: TheaterId, data: Uint8Array): Promise<Uint8Array>;
/**
* Open a communication channel with an actor
*/
openChannel(participant: ChannelParticipant, initialMessage?: Uint8Array): Promise<ChannelStream>;
/**
* Subscribe to events from an actor
*/
subscribeToActor(id: TheaterId): Promise<ActorEventStream>;
}
//# sourceMappingURL=TheaterClient.d.ts.map