Skip to content

Commit 7f2fddf

Browse files
committed
feat(appkit): agent chat UI primitives
Signed-off-by: Hubert Zub <hubert.zub@databricks.com>
1 parent db77efa commit 7f2fddf

17 files changed

Lines changed: 1867 additions & 434 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import type { UIMessage } from "ai";
2+
3+
/**
4+
* AppKit-only data parts emitted by the client `ResponsesApiTransport`
5+
* when it sees an `appkit.approval_pending` SSE event from the agents
6+
* plugin. The transport exposes them via `useChat`'s `onData` callback;
7+
* the route renders an approval card and POSTs the decision back to
8+
* `/api/agents/approve`.
9+
*/
10+
// Declared as a `type` (not `interface`) so it structurally satisfies
11+
// the AI SDK's `UIDataTypes = Record<string, unknown>` constraint —
12+
// `interface`s lack the implicit string index signature `Record` wants.
13+
export type AgentDataParts = {
14+
/**
15+
* A destructive tool call is paused on the server-side approval gate.
16+
* The client renders an approval card and POSTs the user's decision
17+
* to `/api/agents/approve`. The approval gate auto-denies on timeout.
18+
*/
19+
"approval-pending": {
20+
approvalId: string;
21+
streamId: string;
22+
toolName: string;
23+
args: unknown;
24+
annotations?: {
25+
effect?: "read" | "write" | "update" | "destructive";
26+
readOnly?: boolean;
27+
destructive?: boolean;
28+
idempotent?: boolean;
29+
};
30+
};
31+
};
32+
33+
/**
34+
* Strongly-typed UIMessage for the AppKit agent chat. Used as the type
35+
* parameter to `useChat<AgentUIMessage>()` so message metadata, data-part
36+
* dispatch, and `onData` callbacks are all type-checked.
37+
*/
38+
export type AgentUIMessage = UIMessage<unknown, AgentDataParts>;

0 commit comments

Comments
 (0)