2026-02-10 09:10:18 +00:00
|
|
|
/**
|
|
|
|
|
* Management request sent to the Rust binary via stdin.
|
|
|
|
|
*/
|
|
|
|
|
export interface IManagementRequest {
|
|
|
|
|
id: string;
|
|
|
|
|
method: string;
|
|
|
|
|
params: Record<string, any>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Management response received from the Rust binary via stdout.
|
|
|
|
|
*/
|
|
|
|
|
export interface IManagementResponse {
|
|
|
|
|
id: string;
|
|
|
|
|
success: boolean;
|
|
|
|
|
result?: any;
|
|
|
|
|
error?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Management event received from the Rust binary (unsolicited, no id field).
|
|
|
|
|
*/
|
|
|
|
|
export interface IManagementEvent {
|
|
|
|
|
event: string;
|
|
|
|
|
data: any;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Definition of a single command supported by a Rust binary.
|
|
|
|
|
*/
|
|
|
|
|
export interface ICommandDefinition<TParams = any, TResult = any> {
|
|
|
|
|
params: TParams;
|
|
|
|
|
result: TResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Map of command names to their definitions.
|
|
|
|
|
* Used to type-safe the bridge's sendCommand method.
|
|
|
|
|
*/
|
|
|
|
|
export type TCommandMap = Record<string, ICommandDefinition>;
|
2026-02-11 00:12:56 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Stream chunk message received from the Rust binary during a streaming command.
|
|
|
|
|
*/
|
|
|
|
|
export interface IManagementStreamChunk {
|
|
|
|
|
id: string;
|
|
|
|
|
stream: true;
|
|
|
|
|
data: any;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Extract keys from a command map whose definitions include a `chunk` field,
|
|
|
|
|
* indicating they support streaming responses.
|
|
|
|
|
*/
|
|
|
|
|
export type TStreamingCommandKeys<TCommands extends TCommandMap> = {
|
|
|
|
|
[K in keyof TCommands]: TCommands[K] extends { chunk: any } ? K : never;
|
|
|
|
|
}[keyof TCommands];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Extract the chunk type from a command definition that has a `chunk` field.
|
|
|
|
|
*/
|
|
|
|
|
export type TExtractChunk<TDef> = TDef extends { chunk: infer C } ? C : never;
|