Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | import type { AgentEvent } from "./events";
/**
* The transport PORT. UI/state depend only on this interface + `AgentEvent`,
* never on a concrete transport. Swapping SSE → CopilotKit later means
* providing a different implementation of THIS interface — nothing else moves.
*
* `streamTurn` is the only member that differs between transports; the REST
* methods are plain JSON on both.
*/
export type Thread = {
id: string;
scope: string;
status: string;
createdAt: string;
updatedAt: string;
};
export type ActionResult = {
pendingActionId: string;
status: string;
};
export type ImageAttachment = {
name: string;
mimeType: string;
url: string;
};
export type TurnInput = {
threadId: string;
message: string;
system?: string;
images?: ImageAttachment[];
};
export type StreamHandlers = {
onEvent: (event: AgentEvent) => void;
signal?: AbortSignal;
};
export interface AgentTransport {
createThread(scope?: string): Promise<Thread>;
confirm(threadId: string, pendingActionId: string): Promise<ActionResult>;
cancel(threadId: string, pendingActionId: string): Promise<ActionResult>;
/** Resolves when the turn's stream ends (RunFinished/RunError delivered via onEvent). */
streamTurn(input: TurnInput, handlers: StreamHandlers): Promise<void>;
}
/** Injected auth: returns a fresh bearer token (Firebase idToken) or null. */
export type GetToken = () => Promise<string | null>;
export type TransportConfig = {
/** e.g. http://localhost:8787 (iOS simulator reaches the host directly). */
baseUrl: string;
getToken: GetToken;
};
|