@pgege/kaboo-react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +101 -0
- package/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +135 -0
- package/dist/KabooInterruptHandler-BO2Uv3gS.d.cts +226 -0
- package/dist/KabooInterruptHandler-BO2Uv3gS.d.ts +226 -0
- package/dist/chunk-RXZWOBSI.js +1177 -0
- package/dist/chunk-RXZWOBSI.js.map +1 -0
- package/dist/copilotkit.cjs +1248 -0
- package/dist/copilotkit.cjs.map +1 -0
- package/dist/copilotkit.d.cts +111 -0
- package/dist/copilotkit.d.ts +111 -0
- package/dist/copilotkit.js +123 -0
- package/dist/copilotkit.js.map +1 -0
- package/dist/index.cjs +1366 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +557 -0
- package/dist/index.d.ts +557 -0
- package/dist/index.js +200 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +712 -0
- package/llms-full.txt +786 -0
- package/llms.txt +31 -0
- package/package.json +96 -0
package/llms-full.txt
ADDED
|
@@ -0,0 +1,786 @@
|
|
|
1
|
+
# README.md
|
|
2
|
+
|
|
3
|
+
# kaboo-react
|
|
4
|
+
|
|
5
|
+
> React components + hooks for rendering kaboo multi-agent activity in a
|
|
6
|
+
> [CopilotKit](https://copilotkit.ai) app, with batteries-included CopilotKit
|
|
7
|
+
> integrations.
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/kaboo-react)
|
|
10
|
+
[](./LICENSE)
|
|
11
|
+
[](https://gl-pgege.github.io/kaboo-react/)
|
|
12
|
+
[](https://github.com/gl-pgege/kaboo-react/actions/workflows/ci.yml)
|
|
13
|
+
|
|
14
|
+
kaboo-react renders a live, hierarchical view of what your agents are doing —
|
|
15
|
+
sub-agent cards, tool calls, streamed tokens, structured outputs, drill-down
|
|
16
|
+
navigation, and human-in-the-loop interrupts. Activity rides the **same AG-UI run
|
|
17
|
+
stream** as the chat (as `ACTIVITY_SNAPSHOT` events), so there is no separate
|
|
18
|
+
endpoint to wire up: kaboo-react is a batteries-included CopilotKit plugin.
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- **Live hierarchical activity** — nested agent/tool cards that stream in as work
|
|
23
|
+
happens, inside the chat transcript.
|
|
24
|
+
- **Drill-down navigation** — breadcrumb + detail view to explore any sub-agent.
|
|
25
|
+
- **Human-in-the-loop** — approval gates and forms, with N parallel interrupts
|
|
26
|
+
resolved independently.
|
|
27
|
+
- **Structured renderers** — plug custom UI for schema-shaped agent output.
|
|
28
|
+
- **Batteries included** — one `KabooProvider` renders `<CopilotKit>` and mounts
|
|
29
|
+
every context and handler for you.
|
|
30
|
+
- **Themeable** — styled with CSS variables and `--kaboo-*` tokens.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
yarn add @pgege/kaboo-react
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Peer dependencies: `react`, `react-dom`, and `@copilotkit/react-core` (>= 1.62).
|
|
39
|
+
|
|
40
|
+
Import the stylesheet once, near your app root:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import "@pgege/kaboo-react/styles.css";
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick start
|
|
47
|
+
|
|
48
|
+
`KabooProvider` renders `<CopilotKit>` for you and mounts every kaboo context and
|
|
49
|
+
handler inside it. Give it the runtime URL, the entry agent, and a thread id —
|
|
50
|
+
then drop in the components.
|
|
51
|
+
|
|
52
|
+
<!-- source: examples/minimal/src/App.tsx#quickstart -->
|
|
53
|
+
```tsx
|
|
54
|
+
import { CopilotChat } from "@copilotkit/react-core/v2";
|
|
55
|
+
import { KabooProvider, GlassTabs, DrillDetailView } from "@pgege/kaboo-react";
|
|
56
|
+
import { KabooMessageView } from "@pgege/kaboo-react/copilotkit";
|
|
57
|
+
import "@pgege/kaboo-react/styles.css";
|
|
58
|
+
|
|
59
|
+
export function App({ agent, threadId }: { agent: string; threadId: string }) {
|
|
60
|
+
return (
|
|
61
|
+
<KabooProvider runtimeUrl="/api/copilotkit" agent={agent} threadId={threadId}>
|
|
62
|
+
<GlassTabs />
|
|
63
|
+
<CopilotChat messageView={KabooMessageView} />
|
|
64
|
+
<DrillDetailView />
|
|
65
|
+
</KabooProvider>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
That's it — `KabooProvider` nests the three contexts (`KabooActivityProvider`,
|
|
71
|
+
`DrillProvider`, `InterruptBridgeProvider`) plus the built-in `KabooInlineCards`
|
|
72
|
+
and `KabooInterruptHandler`. Disable the auto-mounted handlers with
|
|
73
|
+
`disableInlineCards` / `disableInterruptHandler`, and forward extra CopilotKit
|
|
74
|
+
props via `copilotKitProps`.
|
|
75
|
+
|
|
76
|
+
## Core concepts
|
|
77
|
+
|
|
78
|
+
- **Activity rides the run stream.** The backend emits activity as
|
|
79
|
+
`ACTIVITY_SNAPSHOT` events on the same AG-UI run stream as the chat, so there is
|
|
80
|
+
no separate activity endpoint. `KabooActivityProvider` subscribes to the
|
|
81
|
+
CopilotKit agent and exposes it via `useActivity()`.
|
|
82
|
+
- **Providers nest under `KabooProvider`.** Activity → drill → interrupt bridge,
|
|
83
|
+
with the built-in handlers mounted inside.
|
|
84
|
+
- **Two barrels.** Import framework-agnostic pieces from `kaboo-react`, and the
|
|
85
|
+
CopilotKit-coupled integrations from `@pgege/kaboo-react/copilotkit`.
|
|
86
|
+
- **The `threadId` scopes everything.** Each conversation gets its own
|
|
87
|
+
hierarchical activity view automatically.
|
|
88
|
+
- **Theming via CSS variables.** Components read standard design-system tokens and
|
|
89
|
+
accept `--kaboo-*` overrides.
|
|
90
|
+
|
|
91
|
+
## Guides
|
|
92
|
+
|
|
93
|
+
- [Getting started](./docs/getting-started.md)
|
|
94
|
+
- [Theming](./docs/theming.md)
|
|
95
|
+
- [Structured renderers](./docs/structured-renderers.md)
|
|
96
|
+
- [Human-in-the-loop](./docs/hitl.md)
|
|
97
|
+
- [Activity panel & drill-down](./docs/activity-panel.md)
|
|
98
|
+
- [The `@pgege/kaboo-react/copilotkit` subpath](./docs/copilotkit-subpath.md)
|
|
99
|
+
|
|
100
|
+
## API reference
|
|
101
|
+
|
|
102
|
+
Full, auto-generated API docs for both barrels live on the
|
|
103
|
+
[documentation site](https://gl-pgege.github.io/kaboo-react/api/). A flat index
|
|
104
|
+
of every public export is in [docs/api-inventory.md](./docs/api-inventory.md).
|
|
105
|
+
|
|
106
|
+
## Examples
|
|
107
|
+
|
|
108
|
+
- [`examples/minimal`](./examples/minimal) — the smallest end-to-end wiring
|
|
109
|
+
(this README's quick start).
|
|
110
|
+
- The [kaboo-workflows-demo](https://github.com/gl-pgege/kaboo-docs/tree/main/examples/kaboo-workflows-demo)
|
|
111
|
+
frontend is the canonical, production-shaped consumer.
|
|
112
|
+
|
|
113
|
+
## Compatibility & versioning
|
|
114
|
+
|
|
115
|
+
- **React** 18 and 19 (`react` / `react-dom` >= 18 as peer deps).
|
|
116
|
+
- **CopilotKit** `@copilotkit/react-core` >= 1.62 (peer dep).
|
|
117
|
+
- Follows [semantic versioning](https://semver.org). See
|
|
118
|
+
[CHANGELOG.md](./CHANGELOG.md).
|
|
119
|
+
|
|
120
|
+
## The kaboo stack
|
|
121
|
+
|
|
122
|
+
kaboo-react is one of three libraries:
|
|
123
|
+
|
|
124
|
+
- [kaboo-workflows](https://github.com/gl-pgege/kaboo-workflows) — Python
|
|
125
|
+
multi-agent orchestration.
|
|
126
|
+
- [kaboo-runtime](https://github.com/gl-pgege/kaboo-runtime) — CopilotKit runtime
|
|
127
|
+
persistence/orchestration plugin.
|
|
128
|
+
- **kaboo-react** — this library, the UI layer.
|
|
129
|
+
|
|
130
|
+
## Contributing
|
|
131
|
+
|
|
132
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) (humans) and [AGENTS.md](./AGENTS.md)
|
|
133
|
+
(AI contributors).
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
MIT — see [LICENSE](./LICENSE).
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
# docs/index.md
|
|
142
|
+
|
|
143
|
+
# kaboo-react
|
|
144
|
+
|
|
145
|
+
> React components + hooks for rendering kaboo multi-agent activity in a
|
|
146
|
+
> [CopilotKit](https://copilotkit.ai) app, with batteries-included CopilotKit
|
|
147
|
+
> integrations.
|
|
148
|
+
|
|
149
|
+
kaboo-react renders a live, hierarchical view of what your agents are doing —
|
|
150
|
+
sub-agent cards, tool calls, streamed tokens, structured outputs, drill-down
|
|
151
|
+
navigation, and human-in-the-loop interrupts. Activity rides the **same AG-UI run
|
|
152
|
+
stream** as the chat (as `ACTIVITY_SNAPSHOT` events), so there is no separate
|
|
153
|
+
endpoint to wire up.
|
|
154
|
+
|
|
155
|
+
## Install
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
yarn add @pgege/kaboo-react
|
|
159
|
+
# or
|
|
160
|
+
npm install @pgege/kaboo-react
|
|
161
|
+
# or
|
|
162
|
+
pnpm add @pgege/kaboo-react
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Peer dependencies: `react`, `react-dom`, `@copilotkit/react-core` (>= 1.62).
|
|
166
|
+
|
|
167
|
+
Import the stylesheet once, near your app root:
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
import "@pgege/kaboo-react/styles.css";
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Quick start
|
|
174
|
+
|
|
175
|
+
<!-- source: examples/minimal/src/App.tsx#quickstart -->
|
|
176
|
+
```tsx
|
|
177
|
+
import { CopilotChat } from "@copilotkit/react-core/v2";
|
|
178
|
+
import { KabooProvider, GlassTabs, DrillDetailView } from "@pgege/kaboo-react";
|
|
179
|
+
import { KabooMessageView } from "@pgege/kaboo-react/copilotkit";
|
|
180
|
+
import "@pgege/kaboo-react/styles.css";
|
|
181
|
+
|
|
182
|
+
export function App({ agent, threadId }: { agent: string; threadId: string }) {
|
|
183
|
+
return (
|
|
184
|
+
<KabooProvider runtimeUrl="/api/copilotkit" agent={agent} threadId={threadId}>
|
|
185
|
+
<GlassTabs />
|
|
186
|
+
<CopilotChat messageView={KabooMessageView} />
|
|
187
|
+
<DrillDetailView />
|
|
188
|
+
</KabooProvider>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Next steps
|
|
194
|
+
|
|
195
|
+
- [Getting started](getting-started.md) — a step-by-step walkthrough.
|
|
196
|
+
- [Concepts](concepts.md) — the data model (`ACTIVITY_SNAPSHOT` → `StreamGroup`).
|
|
197
|
+
- [Theming](theming.md) — CSS variables and `--kaboo-*` tokens.
|
|
198
|
+
- [Structured renderers](structured-renderers.md) — custom UI for schema output.
|
|
199
|
+
- [Human-in-the-loop](hitl.md) — approvals, forms, and parallel gates.
|
|
200
|
+
- [Activity panel & drill-down](activity-panel.md) — the activity tree.
|
|
201
|
+
- [CopilotKit subpath](copilotkit-subpath.md) — the `@pgege/kaboo-react/copilotkit` barrel.
|
|
202
|
+
- [Troubleshooting](troubleshooting.md) — styles, empty tree, peer versions.
|
|
203
|
+
- [API inventory](api-inventory.md) and the [API reference](api/README.md).
|
|
204
|
+
|
|
205
|
+
## The kaboo stack
|
|
206
|
+
|
|
207
|
+
kaboo-react is the UI layer. It pairs with
|
|
208
|
+
[kaboo-workflows](https://gl-pgege.github.io/kaboo-workflows/) (agent
|
|
209
|
+
orchestration) and [kaboo-runtime](https://gl-pgege.github.io/kaboo-runtime/)
|
|
210
|
+
(persistence). See [the kaboo stack](https://gl-pgege.github.io/kaboo-docs/) for
|
|
211
|
+
the whole picture.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
# docs/getting-started.md
|
|
216
|
+
|
|
217
|
+
# Getting started
|
|
218
|
+
|
|
219
|
+
!!! note "Compatibility"
|
|
220
|
+
kaboo-react needs **React 18+**, **Node.js 18+**, and
|
|
221
|
+
**`@copilotkit/react-core` >= 1.62** as peers.
|
|
222
|
+
|
|
223
|
+
This guide wires kaboo-react into a CopilotKit app from scratch.
|
|
224
|
+
|
|
225
|
+
## Prerequisites
|
|
226
|
+
|
|
227
|
+
You need a **CopilotKit runtime endpoint** that streams kaboo activity as
|
|
228
|
+
`ACTIVITY_SNAPSHOT` events on the AG-UI run stream. The
|
|
229
|
+
[kaboo-runtime](https://github.com/gl-pgege/kaboo-runtime) package (a CopilotKit
|
|
230
|
+
runtime persistence/orchestration plugin) plus a
|
|
231
|
+
[kaboo-workflows](https://github.com/gl-pgege/kaboo-workflows) backend is the
|
|
232
|
+
canonical server; the
|
|
233
|
+
[kaboo-workflows-demo](https://github.com/gl-pgege/kaboo-docs/tree/main/examples/kaboo-workflows-demo)
|
|
234
|
+
shows a complete setup.
|
|
235
|
+
|
|
236
|
+
## Install
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
yarn add @pgege/kaboo-react
|
|
240
|
+
# or
|
|
241
|
+
npm install @pgege/kaboo-react
|
|
242
|
+
# or
|
|
243
|
+
pnpm add @pgege/kaboo-react
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Peer dependencies (install if you don't already have them):
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
yarn add react react-dom @copilotkit/react-core
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Import the stylesheet
|
|
253
|
+
|
|
254
|
+
Import it once, near your app root:
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
import "@pgege/kaboo-react/styles.css";
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Wrap your app in `KabooProvider`
|
|
261
|
+
|
|
262
|
+
`KabooProvider` renders `<CopilotKit>` and nests every kaboo context and handler.
|
|
263
|
+
Pass the runtime URL, the entry agent id, and a thread id:
|
|
264
|
+
|
|
265
|
+
<!-- source: examples/minimal/src/App.tsx#quickstart -->
|
|
266
|
+
```tsx
|
|
267
|
+
import { CopilotChat } from "@copilotkit/react-core/v2";
|
|
268
|
+
import { KabooProvider, GlassTabs, DrillDetailView } from "@pgege/kaboo-react";
|
|
269
|
+
import { KabooMessageView } from "@pgege/kaboo-react/copilotkit";
|
|
270
|
+
import "@pgege/kaboo-react/styles.css";
|
|
271
|
+
|
|
272
|
+
export function App({ agent, threadId }: { agent: string; threadId: string }) {
|
|
273
|
+
return (
|
|
274
|
+
<KabooProvider runtimeUrl="/api/copilotkit" agent={agent} threadId={threadId}>
|
|
275
|
+
<GlassTabs />
|
|
276
|
+
<CopilotChat messageView={KabooMessageView} />
|
|
277
|
+
<DrillDetailView />
|
|
278
|
+
</KabooProvider>
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Render the chat with `KabooMessageView`
|
|
284
|
+
|
|
285
|
+
Pass `KabooMessageView` to `CopilotChat`'s `messageView` slot. It renders the
|
|
286
|
+
normal message list **and** live agent activity cards inside the transcript, from
|
|
287
|
+
the moment the first agent starts:
|
|
288
|
+
|
|
289
|
+
```tsx
|
|
290
|
+
import { CopilotChat } from "@copilotkit/react-core/v2";
|
|
291
|
+
import { KabooMessageView } from "@pgege/kaboo-react/copilotkit";
|
|
292
|
+
|
|
293
|
+
export function Chat() {
|
|
294
|
+
return <CopilotChat messageView={KabooMessageView} />;
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Add drill-down
|
|
299
|
+
|
|
300
|
+
`GlassTabs` renders a breadcrumb once you drill into a sub-agent, and
|
|
301
|
+
`DrillDetailView` renders the selected group's detail. Place them alongside the
|
|
302
|
+
chat (as in the quick start above).
|
|
303
|
+
|
|
304
|
+
## What auto-mounts
|
|
305
|
+
|
|
306
|
+
`KabooProvider` mounts these for you:
|
|
307
|
+
|
|
308
|
+
- `KabooInlineCards` — inline delegate sub-agent cards at their tool-call
|
|
309
|
+
position.
|
|
310
|
+
- `KabooInterruptHandler` — the human-in-the-loop handler.
|
|
311
|
+
|
|
312
|
+
Escape hatches:
|
|
313
|
+
|
|
314
|
+
```tsx
|
|
315
|
+
import { KabooProvider } from "@pgege/kaboo-react";
|
|
316
|
+
|
|
317
|
+
export function App({ agent, threadId }: { agent: string; threadId: string }) {
|
|
318
|
+
return (
|
|
319
|
+
<KabooProvider
|
|
320
|
+
runtimeUrl="/api/copilotkit"
|
|
321
|
+
agent={agent}
|
|
322
|
+
threadId={threadId}
|
|
323
|
+
disableInlineCards={false}
|
|
324
|
+
disableInterruptHandler={false}
|
|
325
|
+
copilotKitProps={{}}
|
|
326
|
+
>
|
|
327
|
+
<div />
|
|
328
|
+
</KabooProvider>
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
- `disableInlineCards` / `disableInterruptHandler` — skip an auto-mounted handler
|
|
334
|
+
(e.g. to render your own).
|
|
335
|
+
- `copilotKitProps` — forward extra props to the underlying `<CopilotKit>`.
|
|
336
|
+
|
|
337
|
+
## Next steps
|
|
338
|
+
|
|
339
|
+
- [Concepts](concepts.md) — the data model behind the activity tree.
|
|
340
|
+
- [Activity panel & drill-down](activity-panel.md) — render and navigate it.
|
|
341
|
+
- [Human-in-the-loop](hitl.md) — approvals, forms, and parallel gates.
|
|
342
|
+
- [Troubleshooting](troubleshooting.md) — styles, empty tree, peer versions.
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
# docs/theming.md
|
|
347
|
+
|
|
348
|
+
# Theming
|
|
349
|
+
|
|
350
|
+
kaboo-react ships a single stylesheet and styles everything with CSS variables,
|
|
351
|
+
so it blends into your app's design system and is easy to override.
|
|
352
|
+
|
|
353
|
+
## How styling works
|
|
354
|
+
|
|
355
|
+
Components read standard design-system tokens with neutral fallbacks:
|
|
356
|
+
|
|
357
|
+
- `--background`, `--foreground`
|
|
358
|
+
- `--card`
|
|
359
|
+
- `--muted`, `--muted-foreground`
|
|
360
|
+
- `--border`
|
|
361
|
+
|
|
362
|
+
If your app already defines these (as most design systems / shadcn setups do),
|
|
363
|
+
kaboo-react inherits them automatically. Otherwise it falls back to sensible
|
|
364
|
+
neutral defaults.
|
|
365
|
+
|
|
366
|
+
## Import the stylesheet
|
|
367
|
+
|
|
368
|
+
Import it once, near your app root:
|
|
369
|
+
|
|
370
|
+
```ts
|
|
371
|
+
import "@pgege/kaboo-react/styles.css";
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
The package sets `"sideEffects": ["*.css"]`, so bundlers keep the stylesheet even
|
|
375
|
+
with tree-shaking enabled.
|
|
376
|
+
|
|
377
|
+
## Override tokens
|
|
378
|
+
|
|
379
|
+
Status colors and other accents are exposed as `--kaboo-*` variables. Set them on
|
|
380
|
+
any parent element (e.g. `:root`) to override:
|
|
381
|
+
|
|
382
|
+
```css
|
|
383
|
+
:root {
|
|
384
|
+
--kaboo-running: #d97706;
|
|
385
|
+
--kaboo-warning: #f59e0b;
|
|
386
|
+
--kaboo-success: #16a34a;
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
## Dark mode
|
|
391
|
+
|
|
392
|
+
Because components read `--background` / `--foreground` / `--card` etc., dark mode
|
|
393
|
+
works by toggling those tokens the same way you do for the rest of your app (for
|
|
394
|
+
example, a `.dark` class on `<html>` that redefines the variables). No
|
|
395
|
+
kaboo-specific dark-mode configuration is required.
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
# docs/structured-renderers.md
|
|
400
|
+
|
|
401
|
+
# Structured renderers
|
|
402
|
+
|
|
403
|
+
Agents can emit **structured output** — a schema-shaped JSON object plus the
|
|
404
|
+
schema's name. Structured renderers let you render that object with a custom React
|
|
405
|
+
component instead of the default collapsible JSON view.
|
|
406
|
+
|
|
407
|
+
## What they are
|
|
408
|
+
|
|
409
|
+
A `StructuredRenderers` map is keyed by the output schema name. Each renderer
|
|
410
|
+
receives the structured output object (`Record<string, unknown>`) and returns a
|
|
411
|
+
`ReactElement`:
|
|
412
|
+
|
|
413
|
+
```ts
|
|
414
|
+
import { createElement } from "react";
|
|
415
|
+
import type { StructuredRenderers } from "@pgege/kaboo-react";
|
|
416
|
+
|
|
417
|
+
const renderers: StructuredRenderers = {
|
|
418
|
+
WeatherReport: (data) => createElement("div", null, String(data.summary)),
|
|
419
|
+
};
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
## Provide renderers
|
|
423
|
+
|
|
424
|
+
Pass the map to `KabooProvider` (or `KabooActivityProvider` if you compose
|
|
425
|
+
providers by hand):
|
|
426
|
+
|
|
427
|
+
```tsx
|
|
428
|
+
import { KabooProvider } from "@pgege/kaboo-react";
|
|
429
|
+
import type { StructuredRenderers } from "@pgege/kaboo-react";
|
|
430
|
+
|
|
431
|
+
const renderers: StructuredRenderers = {
|
|
432
|
+
WeatherReport: (data) => <div>Summary: {String(data.summary)}</div>,
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
export function App({ agent, threadId }: { agent: string; threadId: string }) {
|
|
436
|
+
return (
|
|
437
|
+
<KabooProvider
|
|
438
|
+
runtimeUrl="/api/copilotkit"
|
|
439
|
+
agent={agent}
|
|
440
|
+
threadId={threadId}
|
|
441
|
+
structuredRenderers={renderers}
|
|
442
|
+
>
|
|
443
|
+
<div />
|
|
444
|
+
</KabooProvider>
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
## How a renderer is selected
|
|
450
|
+
|
|
451
|
+
When an activity group carries both `structuredOutput` (the data) and
|
|
452
|
+
`outputSchemaName` (the key), kaboo-react looks up `renderers[outputSchemaName]`:
|
|
453
|
+
|
|
454
|
+
- **Match found** → your component renders the data.
|
|
455
|
+
- **No match** → a collapsible "Structured output (`<schemaName>`)" JSON view is
|
|
456
|
+
shown instead.
|
|
457
|
+
|
|
458
|
+
This means you can add renderers incrementally: unrendered schemas degrade
|
|
459
|
+
gracefully to JSON.
|
|
460
|
+
|
|
461
|
+
---
|
|
462
|
+
|
|
463
|
+
# docs/hitl.md
|
|
464
|
+
|
|
465
|
+
# Human-in-the-loop
|
|
466
|
+
|
|
467
|
+
When a run pauses for human input, kaboo-react surfaces the prompt in the UI and
|
|
468
|
+
resumes the run once the user answers. This works for a single gate and for many
|
|
469
|
+
gates open at once.
|
|
470
|
+
|
|
471
|
+
## Interrupt model
|
|
472
|
+
|
|
473
|
+
An interrupt's `reason` is one of two shapes (`InterruptReason`):
|
|
474
|
+
|
|
475
|
+
- **`ApprovalReason`** — approve or reject a gated tool call (`type: "approval"`).
|
|
476
|
+
- **`FormReason`** — answer one or more questions (`type: "form"`).
|
|
477
|
+
|
|
478
|
+
Each open interrupt has a unique `id` and is resolved independently.
|
|
479
|
+
|
|
480
|
+
## The built-in handler
|
|
481
|
+
|
|
482
|
+
`KabooProvider` mounts `KabooInterruptHandler` for you. CopilotKit can surface
|
|
483
|
+
**several** open interrupts at once (e.g. two gated tools called in parallel); the
|
|
484
|
+
handler renders one card per interrupt and resolves each by its own `id`, so N
|
|
485
|
+
parallel gates never wedge.
|
|
486
|
+
|
|
487
|
+
## Inline vs chat-slot placement
|
|
488
|
+
|
|
489
|
+
- If an interrupt is anchored to a tool call that is still visible on screen, the
|
|
490
|
+
prompt renders **inline at that tool's position**, in chronological order.
|
|
491
|
+
- Otherwise it renders in a fallback slot in the chat.
|
|
492
|
+
|
|
493
|
+
You don't configure this — it's automatic — but it's why prompts appear "in the
|
|
494
|
+
right place" rather than floating on top of the turn.
|
|
495
|
+
|
|
496
|
+
## The InterruptBridge
|
|
497
|
+
|
|
498
|
+
The bridge lets an owning agent card (and the drill-down view) render a prompt
|
|
499
|
+
inline. Use `useInterruptFor(toolCallId)` to find the open interrupt anchored to a
|
|
500
|
+
specific tool call:
|
|
501
|
+
|
|
502
|
+
```tsx
|
|
503
|
+
import { useInterruptFor } from "@pgege/kaboo-react";
|
|
504
|
+
|
|
505
|
+
function GateBadge({ toolCallId }: { toolCallId: string }) {
|
|
506
|
+
const interrupt = useInterruptFor(toolCallId);
|
|
507
|
+
return <span>{interrupt ? "Awaiting input" : "OK"}</span>;
|
|
508
|
+
}
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
`InterruptBridgeProvider` and `InterruptBridgePublisher` are the lower-level
|
|
512
|
+
pieces; both are wired for you by `KabooProvider` + `KabooInterruptHandler`.
|
|
513
|
+
|
|
514
|
+
## Custom renderers
|
|
515
|
+
|
|
516
|
+
Override the default approval/form UI per interrupt type via `interruptRenderers`.
|
|
517
|
+
A renderer receives `InterruptRendererProps` (the `reason` plus
|
|
518
|
+
`onResolve`/`onCancel`):
|
|
519
|
+
|
|
520
|
+
```tsx
|
|
521
|
+
import { KabooProvider, InterruptRenderer } from "@pgege/kaboo-react";
|
|
522
|
+
import type { InterruptRendererProps } from "@pgege/kaboo-react";
|
|
523
|
+
|
|
524
|
+
function MyApproval(props: InterruptRendererProps) {
|
|
525
|
+
// Wrap or fully replace the default UI.
|
|
526
|
+
return <InterruptRenderer {...props} />;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export function App({ agent, threadId }: { agent: string; threadId: string }) {
|
|
530
|
+
return (
|
|
531
|
+
<KabooProvider
|
|
532
|
+
runtimeUrl="/api/copilotkit"
|
|
533
|
+
agent={agent}
|
|
534
|
+
threadId={threadId}
|
|
535
|
+
interruptRenderers={{ approval: MyApproval }}
|
|
536
|
+
>
|
|
537
|
+
<div />
|
|
538
|
+
</KabooProvider>
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
---
|
|
544
|
+
|
|
545
|
+
# docs/activity-panel.md
|
|
546
|
+
|
|
547
|
+
# Activity panel & drill-down
|
|
548
|
+
|
|
549
|
+
kaboo-react models agent work as a **tree of groups** and gives you components to
|
|
550
|
+
render and navigate it.
|
|
551
|
+
|
|
552
|
+
## The activity tree
|
|
553
|
+
|
|
554
|
+
Activity is a set of `StreamGroup`s keyed by group id, exposed by `useActivity()`.
|
|
555
|
+
Each group links to its parent via `parentGroup`, forming the hierarchy. Read the
|
|
556
|
+
root groups with `topLevelGroups`:
|
|
557
|
+
|
|
558
|
+
```tsx
|
|
559
|
+
import { useActivity, topLevelGroups } from "@pgege/kaboo-react";
|
|
560
|
+
|
|
561
|
+
export function RootAgents() {
|
|
562
|
+
const { groups } = useActivity();
|
|
563
|
+
return <div>{topLevelGroups(groups).length} root agents</div>;
|
|
564
|
+
}
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
## Rendering primitives
|
|
568
|
+
|
|
569
|
+
- **`ActivityPanel`** — renders the current level of the tree as a list of
|
|
570
|
+
`AgentCard`s. Use it for a standalone activity view (outside the chat).
|
|
571
|
+
- **`AgentCard`** — one agent run: title, status, task, timeline, result.
|
|
572
|
+
- **`Timeline`** — the chronological text/tool stream inside a card.
|
|
573
|
+
- **`ToolRow`** — a single tool call (input summary + result).
|
|
574
|
+
- **`MiniTable`** — tabular tool results.
|
|
575
|
+
|
|
576
|
+
```tsx
|
|
577
|
+
import { ActivityPanel } from "@pgege/kaboo-react";
|
|
578
|
+
|
|
579
|
+
export function Sidebar() {
|
|
580
|
+
return (
|
|
581
|
+
<aside>
|
|
582
|
+
<ActivityPanel />
|
|
583
|
+
</aside>
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
## Drill-down
|
|
589
|
+
|
|
590
|
+
To let users explore sub-agents, pair the breadcrumb and detail components:
|
|
591
|
+
|
|
592
|
+
```tsx
|
|
593
|
+
import { GlassTabs, DrillDetailView } from "@pgege/kaboo-react";
|
|
594
|
+
|
|
595
|
+
export function DrillArea() {
|
|
596
|
+
return (
|
|
597
|
+
<>
|
|
598
|
+
<GlassTabs />
|
|
599
|
+
<DrillDetailView />
|
|
600
|
+
</>
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
- **`GlassTabs`** — breadcrumb of the drill path (renders nothing at the root).
|
|
606
|
+
- **`DrillDetailView`** — the drilled-in group's full detail.
|
|
607
|
+
- **`useDrill()`** — the navigation state and actions (`drillIn`, `drillUp`,
|
|
608
|
+
`drillToRoot`, `drillToLevel`).
|
|
609
|
+
|
|
610
|
+
```tsx
|
|
611
|
+
import { useDrill } from "@pgege/kaboo-react";
|
|
612
|
+
|
|
613
|
+
export function BackButton() {
|
|
614
|
+
const { drillUp, activeDrill } = useDrill();
|
|
615
|
+
if (!activeDrill) return null;
|
|
616
|
+
return <button onClick={drillUp}>Back</button>;
|
|
617
|
+
}
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
## Group helpers
|
|
621
|
+
|
|
622
|
+
- **`topLevelGroups(groups)`** — the parentless roots.
|
|
623
|
+
- **`directChildren(groups, parentId)`** — one level of children.
|
|
624
|
+
|
|
625
|
+
```ts
|
|
626
|
+
import { directChildren } from "@pgege/kaboo-react";
|
|
627
|
+
|
|
628
|
+
export function childCount(
|
|
629
|
+
groups: Parameters<typeof directChildren>[0],
|
|
630
|
+
parentId: string,
|
|
631
|
+
) {
|
|
632
|
+
return directChildren(groups, parentId).length;
|
|
633
|
+
}
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
---
|
|
637
|
+
|
|
638
|
+
# docs/copilotkit-subpath.md
|
|
639
|
+
|
|
640
|
+
# The `@pgege/kaboo-react/copilotkit` subpath
|
|
641
|
+
|
|
642
|
+
kaboo-react ships two barrels:
|
|
643
|
+
|
|
644
|
+
- **`kaboo-react`** — framework-agnostic contexts, hooks, components, and utils.
|
|
645
|
+
- **`@pgege/kaboo-react/copilotkit`** — integrations coupled to CopilotKit's chat
|
|
646
|
+
surfaces.
|
|
647
|
+
|
|
648
|
+
## Why a separate barrel
|
|
649
|
+
|
|
650
|
+
The `copilotkit` integrations plug into specific slots of `CopilotChat` and depend
|
|
651
|
+
on CopilotKit's v2 APIs. Keeping them behind a subpath makes that coupling
|
|
652
|
+
explicit and keeps the main barrel usable in more contexts.
|
|
653
|
+
|
|
654
|
+
## The exports
|
|
655
|
+
|
|
656
|
+
| Export | Purpose | Wiring |
|
|
657
|
+
| --- | --- | --- |
|
|
658
|
+
| `KabooMessageView` | Live in-chat member cards, from the first agent. | `CopilotChat` `messageView` slot. |
|
|
659
|
+
| `KabooAssistantMessage` | Cards above a settled assistant reply. | Used by `KabooMessageView` (assistant-message slot). |
|
|
660
|
+
| `KabooInlineCards` | Delegate sub-agent cards at the tool-call position. | Auto-mounted by `KabooProvider`. |
|
|
661
|
+
| `KabooInterruptHandler` | Human-in-the-loop handler. | Auto-mounted by `KabooProvider`. |
|
|
662
|
+
| `KabooAskUser` | Answered `ask_user` prompts, inline. | Used by the interrupt handler. |
|
|
663
|
+
| `KabooToolRender` | Wildcard tool renderer. | Used by `KabooInlineCards`. |
|
|
664
|
+
|
|
665
|
+
Most apps only import **`KabooMessageView`** directly — the rest are auto-mounted
|
|
666
|
+
by `KabooProvider`.
|
|
667
|
+
|
|
668
|
+
## Wiring `KabooMessageView`
|
|
669
|
+
|
|
670
|
+
```tsx
|
|
671
|
+
import { CopilotChat } from "@copilotkit/react-core/v2";
|
|
672
|
+
import { KabooMessageView } from "@pgege/kaboo-react/copilotkit";
|
|
673
|
+
|
|
674
|
+
export function Chat() {
|
|
675
|
+
return <CopilotChat messageView={KabooMessageView} />;
|
|
676
|
+
}
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
`KabooMessageView` is a drop-in `messageView`: it carries a `Cursor` static like
|
|
680
|
+
CopilotKit's own message view, so it satisfies the slot type directly.
|
|
681
|
+
|
|
682
|
+
## Using the handlers yourself
|
|
683
|
+
|
|
684
|
+
If you disable an auto-mounted handler on `KabooProvider`
|
|
685
|
+
(`disableInterruptHandler` / `disableInlineCards`), you can mount your own from
|
|
686
|
+
this subpath:
|
|
687
|
+
|
|
688
|
+
```tsx
|
|
689
|
+
import { KabooProvider } from "@pgege/kaboo-react";
|
|
690
|
+
import { KabooInterruptHandler } from "@pgege/kaboo-react/copilotkit";
|
|
691
|
+
|
|
692
|
+
export function App({ agent, threadId }: { agent: string; threadId: string }) {
|
|
693
|
+
return (
|
|
694
|
+
<KabooProvider
|
|
695
|
+
runtimeUrl="/api/copilotkit"
|
|
696
|
+
agent={agent}
|
|
697
|
+
threadId={threadId}
|
|
698
|
+
disableInterruptHandler
|
|
699
|
+
>
|
|
700
|
+
<KabooInterruptHandler agentId={agent} />
|
|
701
|
+
</KabooProvider>
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
---
|
|
707
|
+
|
|
708
|
+
# docs/api-inventory.md
|
|
709
|
+
|
|
710
|
+
# API inventory
|
|
711
|
+
|
|
712
|
+
Generated by `yarn docs:api` from the TypeDoc output. Every public export of both barrels is listed here. Do not edit by hand.
|
|
713
|
+
|
|
714
|
+
## `@pgege/kaboo-react`
|
|
715
|
+
|
|
716
|
+
### Functions / components / hooks
|
|
717
|
+
|
|
718
|
+
- [`ActivityPanel`](api/index/functions/ActivityPanel.md)
|
|
719
|
+
- [`AgentCard`](api/index/functions/AgentCard.md)
|
|
720
|
+
- [`directChildren`](api/index/functions/directChildren.md)
|
|
721
|
+
- [`DrillDetailView`](api/index/functions/DrillDetailView.md)
|
|
722
|
+
- [`DrillProvider`](api/index/functions/DrillProvider.md)
|
|
723
|
+
- [`formatToolInput`](api/index/functions/formatToolInput.md)
|
|
724
|
+
- [`formatToolResult`](api/index/functions/formatToolResult.md)
|
|
725
|
+
- [`GlassTabs`](api/index/functions/GlassTabs.md)
|
|
726
|
+
- [`InterruptBridgeProvider`](api/index/functions/InterruptBridgeProvider.md)
|
|
727
|
+
- [`InterruptBridgePublisher`](api/index/functions/InterruptBridgePublisher.md)
|
|
728
|
+
- [`InterruptRenderer`](api/index/functions/InterruptRenderer.md)
|
|
729
|
+
- [`KabooActivityProvider`](api/index/functions/KabooActivityProvider.md)
|
|
730
|
+
- [`KabooProvider`](api/index/functions/KabooProvider.md)
|
|
731
|
+
- [`MarkdownContent`](api/index/functions/MarkdownContent.md)
|
|
732
|
+
- [`MiniTable`](api/index/functions/MiniTable.md)
|
|
733
|
+
- [`normalizeResult`](api/index/functions/normalizeResult.md)
|
|
734
|
+
- [`Timeline`](api/index/functions/Timeline.md)
|
|
735
|
+
- [`ToolRow`](api/index/functions/ToolRow.md)
|
|
736
|
+
- [`topLevelGroups`](api/index/functions/topLevelGroups.md)
|
|
737
|
+
- [`useActivity`](api/index/functions/useActivity.md)
|
|
738
|
+
- [`useDrill`](api/index/functions/useDrill.md)
|
|
739
|
+
- [`useInterruptBridge`](api/index/functions/useInterruptBridge.md)
|
|
740
|
+
- [`useInterruptFor`](api/index/functions/useInterruptFor.md)
|
|
741
|
+
|
|
742
|
+
### Variables
|
|
743
|
+
|
|
744
|
+
- [`StructuredRenderersContext`](api/index/variables/StructuredRenderersContext.md)
|
|
745
|
+
|
|
746
|
+
### Interfaces
|
|
747
|
+
|
|
748
|
+
- [`ActiveInterrupt`](api/index/interfaces/ActiveInterrupt.md)
|
|
749
|
+
- [`ActivityState`](api/index/interfaces/ActivityState.md)
|
|
750
|
+
- [`AgentCardProps`](api/index/interfaces/AgentCardProps.md)
|
|
751
|
+
- [`ApprovalReason`](api/index/interfaces/ApprovalReason.md)
|
|
752
|
+
- [`DrillState`](api/index/interfaces/DrillState.md)
|
|
753
|
+
- [`FormQuestion`](api/index/interfaces/FormQuestion.md)
|
|
754
|
+
- [`FormReason`](api/index/interfaces/FormReason.md)
|
|
755
|
+
- [`InterruptData`](api/index/interfaces/InterruptData.md)
|
|
756
|
+
- [`InterruptRendererProps`](api/index/interfaces/InterruptRendererProps.md)
|
|
757
|
+
- [`KabooActivityProviderProps`](api/index/interfaces/KabooActivityProviderProps.md)
|
|
758
|
+
- [`KabooProviderProps`](api/index/interfaces/KabooProviderProps.md)
|
|
759
|
+
- [`StreamGroup`](api/index/interfaces/StreamGroup.md)
|
|
760
|
+
- [`TimelineProps`](api/index/interfaces/TimelineProps.md)
|
|
761
|
+
- [`ToolCall`](api/index/interfaces/ToolCall.md)
|
|
762
|
+
|
|
763
|
+
### Type aliases
|
|
764
|
+
|
|
765
|
+
- [`GroupEntry`](api/index/type-aliases/GroupEntry.md)
|
|
766
|
+
- [`InterruptReason`](api/index/type-aliases/InterruptReason.md)
|
|
767
|
+
- [`StructuredRenderers`](api/index/type-aliases/StructuredRenderers.md)
|
|
768
|
+
- [`TimelineEntry`](api/index/type-aliases/TimelineEntry.md)
|
|
769
|
+
|
|
770
|
+
## `@pgege/kaboo-react/copilotkit`
|
|
771
|
+
|
|
772
|
+
### Functions / components / hooks
|
|
773
|
+
|
|
774
|
+
- [`KabooAskUser`](api/copilotkit/functions/KabooAskUser.md)
|
|
775
|
+
- [`KabooAssistantMessage`](api/copilotkit/functions/KabooAssistantMessage.md)
|
|
776
|
+
- [`KabooInlineCards`](api/copilotkit/functions/KabooInlineCards.md)
|
|
777
|
+
- [`KabooInterruptHandler`](api/copilotkit/functions/KabooInterruptHandler.md)
|
|
778
|
+
- [`KabooToolRender`](api/copilotkit/functions/KabooToolRender.md)
|
|
779
|
+
|
|
780
|
+
### Variables
|
|
781
|
+
|
|
782
|
+
- [`KabooMessageView`](api/copilotkit/variables/KabooMessageView.md)
|
|
783
|
+
|
|
784
|
+
### Interfaces
|
|
785
|
+
|
|
786
|
+
- [`KabooInterruptHandlerProps`](api/copilotkit/interfaces/KabooInterruptHandlerProps.md)
|