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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | /**
* Normalized agent events — the mobile app's OWN vocabulary.
*
* This file must stay free of any transport/SDK import (`react-native-sse`,
* `@copilotkit/*`, `@ag-ui/*`). Every transport maps its wire format into this
* union; the UI and the reducer depend ONLY on this. That is what makes the
* transport swappable (SSE now, CopilotKit later) with zero UI changes.
*/
export type UsageInfo = { inputTokens: number; outputTokens: number };
/** A structured render block from the backend's `message.blocks` custom event. */
export type Block = {
type: string;
text?: string;
[key: string]: unknown;
};
/** A quick-reply chip: `label` renders on the chip, `value` is the message
* sent when tapped. Plain-string chips from older backends are normalized
* to label === value at the mapping boundary (agui-map). */
export type Suggestion = { label: string; value: string };
export type TurnMetadata = {
usage: UsageInfo;
steps: number;
toolCalls: string[];
latencyMs: number;
};
/** A pending mutation awaiting the user's confirm/cancel (HITL). */
export type PendingAction = {
pendingActionId: string;
actionType?: string;
message?: string;
};
/**
* Curated agent state from the backend's STATE_SNAPSHOT event — mirrors
* flash-agent-langchain `src/transport/shared-state.ts` (AgentSharedState).
* `pendingAction: null` is the authoritative "nothing awaits confirmation".
*/
export type AgentSharedState = {
scope: string;
pendingAction: {
id: string;
actionType: string;
summary?: string;
/** ISO expiry of the confirm window — disable Confirm past it. */
expiresAt?: string;
} | null;
/** Actor may mutate — hide mutation affordances when false. */
canMutate: boolean;
/** An earlier upload is cached and will attach to the next create/update. */
hasCachedImage: boolean;
suggestions: Suggestion[];
};
export type AgentEvent =
| { _tag: "RunStarted"; threadId: string; runId: string }
| { _tag: "TextStart"; messageId: string }
| { _tag: "TextDelta"; messageId: string; delta: string }
| { _tag: "TextEnd"; messageId: string }
| { _tag: "ToolCallStart"; toolCallId: string; name: string }
| { _tag: "ToolCallArgs"; toolCallId: string; argsDelta: string }
| { _tag: "ToolCallEnd"; toolCallId: string }
| { _tag: "ToolResult"; toolCallId: string; content: string }
| { _tag: "Blocks"; blocks: Block[]; suggestions: Suggestion[] }
| { _tag: "SharedState"; state: AgentSharedState }
| { _tag: "Metadata"; metadata: TurnMetadata }
| { _tag: "PendingAction"; pending: PendingAction }
| { _tag: "RunFinished" }
| { _tag: "RunError"; message: string };
|