@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/AGENTS.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
Guidance for AI agents contributing to **kaboo-react**. Humans: see
|
|
4
|
+
[CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
5
|
+
|
|
6
|
+
## Commands
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
corepack enable # once; Yarn 4 is pinned via packageManager
|
|
10
|
+
yarn install --immutable # install
|
|
11
|
+
yarn build # tsup -> dist/ (both barrels + styles.css)
|
|
12
|
+
yarn test # vitest run
|
|
13
|
+
yarn typecheck # tsc --noEmit (src, excludes tests)
|
|
14
|
+
yarn docs:api # typedoc + regenerate docs/api-inventory.md (completeness gate)
|
|
15
|
+
yarn docs:verify # type-check every tsx/ts snippet in README + docs
|
|
16
|
+
yarn docs:llms # regenerate llms.txt + llms-full.txt
|
|
17
|
+
yarn examples:typecheck # type-check examples/ against built types
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`prepack` runs build + docs:api + docs:llms + docs:verify + test (fires on
|
|
21
|
+
`yarn pack` and `yarn npm publish`).
|
|
22
|
+
|
|
23
|
+
## Architecture & conventions
|
|
24
|
+
|
|
25
|
+
- **Two barrels.**
|
|
26
|
+
- `kaboo-react` (`src/index.ts`) — framework-agnostic contexts, hooks,
|
|
27
|
+
components, utils, formatters, types.
|
|
28
|
+
- `@pgege/kaboo-react/copilotkit` (`src/copilotkit.ts`) — integrations coupled to
|
|
29
|
+
CopilotKit. **Put any CopilotKit-dependent code here, never in the main
|
|
30
|
+
barrel.**
|
|
31
|
+
- **Stylesheet.** `src/styles.css` is copied to `dist/styles.css` by tsup and
|
|
32
|
+
exported as `@pgege/kaboo-react/styles.css`. Theming is via CSS variables only
|
|
33
|
+
(`--background`/`--foreground`/`--card`/`--muted`/`--border` + `--kaboo-*`
|
|
34
|
+
overrides). Do not add a CSS-in-JS dependency.
|
|
35
|
+
- **Peer deps.** `react`, `react-dom`, `@copilotkit/react-core`. Do not add
|
|
36
|
+
runtime dependencies without discussion.
|
|
37
|
+
- **CopilotChat slots** each integration targets:
|
|
38
|
+
- `KabooMessageView` → the `messageView` slot (carries a `Cursor` static so it
|
|
39
|
+
is a drop-in slot component).
|
|
40
|
+
- `KabooAssistantMessage` → the assistant-message slot (used by
|
|
41
|
+
`KabooMessageView`).
|
|
42
|
+
- `KabooInlineCards`, `KabooInterruptHandler` → auto-mounted by `KabooProvider`.
|
|
43
|
+
|
|
44
|
+
## Playbooks
|
|
45
|
+
|
|
46
|
+
### Add a component or hook
|
|
47
|
+
|
|
48
|
+
1. Implement it under `src/` (main-barrel code) or `src/integrations/`
|
|
49
|
+
(CopilotKit-coupled → `copilotkit` barrel).
|
|
50
|
+
2. Add a TSDoc description **and at least one `@example`** (`tsx` for
|
|
51
|
+
components/providers, `ts` for utils/formatters). The completeness gate fails
|
|
52
|
+
on any undocumented export.
|
|
53
|
+
3. Export it from the correct barrel (`src/index.ts` or `src/copilotkit.ts`).
|
|
54
|
+
4. Add a test under the same folder (`*.test.tsx`), following the existing
|
|
55
|
+
`vi.hoisted` + `vi.mock("@copilotkit/react-core/v2", …)` pattern.
|
|
56
|
+
5. Run `yarn docs:api` (regenerates `docs/api` + `docs/api-inventory.md`).
|
|
57
|
+
|
|
58
|
+
### Add a guide
|
|
59
|
+
|
|
60
|
+
1. Create `docs/<name>.md`. Every `tsx`/`ts` fence must be self-contained and
|
|
61
|
+
type-check under `docs:verify` (tag illustrative fragments ```` ```tsx no-verify ````).
|
|
62
|
+
2. Add it to `mkdocs.yml` nav **and** to the `NAV` list in
|
|
63
|
+
`scripts/generate-llms.mjs` (same order).
|
|
64
|
+
3. Run `yarn docs:verify` and `yarn docs:llms`.
|
|
65
|
+
|
|
66
|
+
### Add an example
|
|
67
|
+
|
|
68
|
+
1. Create `examples/<name>/` with `package.json`, `tsconfig.json` (map
|
|
69
|
+
`kaboo-react` → `../../dist`), `README.md`, and `src/`.
|
|
70
|
+
2. If a guide/README snippet copies from it, wrap the region with
|
|
71
|
+
`// #region <name>` / `// #endregion` and reference it with
|
|
72
|
+
`<!-- source: examples/<name>/src/File.tsx#<name> -->` above the fence.
|
|
73
|
+
3. Run `yarn build && yarn examples:typecheck`.
|
|
74
|
+
|
|
75
|
+
## Definition of done
|
|
76
|
+
|
|
77
|
+
- `yarn test` green.
|
|
78
|
+
- `yarn docs:api` passes the TypeDoc completeness gate across **both** barrels
|
|
79
|
+
and produces no `docs/api` / `docs/api-inventory.md` drift.
|
|
80
|
+
- `yarn docs:verify` green.
|
|
81
|
+
- `yarn docs:llms` produces no `llms.txt` / `llms-full.txt` drift.
|
|
82
|
+
- `yarn examples:typecheck` green.
|
|
83
|
+
- `mkdocs build --strict` green.
|
|
84
|
+
- `yarn pack --dry-run` clean (both barrels + `styles.css` resolve).
|
|
85
|
+
|
|
86
|
+
## Guardrails
|
|
87
|
+
|
|
88
|
+
- Never add an undocumented public export.
|
|
89
|
+
- Never add an unverified `tsx`/`ts` snippet to the docs.
|
|
90
|
+
- Never point URLs at the old `kaboo/kaboo-workflows` monorepo path — use
|
|
91
|
+
`gl-pgege/kaboo-react`.
|
|
92
|
+
- Never plan or run a live publish; the deliverable is a dry run + the publish
|
|
93
|
+
command for a human to run.
|
|
94
|
+
|
|
95
|
+
## Related
|
|
96
|
+
|
|
97
|
+
- [kaboo-workflows](https://github.com/gl-pgege/kaboo-workflows)
|
|
98
|
+
- [kaboo-runtime](https://github.com/gl-pgege/kaboo-runtime)
|
|
99
|
+
- [kaboo-workflows-demo](https://github.com/gl-pgege/kaboo-docs/tree/main/examples/kaboo-workflows-demo) — the
|
|
100
|
+
runnable, end-to-end reference that consumes this library.
|
|
101
|
+
- [The kaboo stack](https://gl-pgege.github.io/kaboo-docs/) — umbrella landing.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0]
|
|
11
|
+
|
|
12
|
+
Initial release.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- `kaboo-react` main barrel: `KabooProvider` (batteries-included CopilotKit
|
|
17
|
+
plugin), `KabooActivityProvider`, `DrillProvider`, `InterruptBridgeProvider`,
|
|
18
|
+
hooks (`useActivity`, `useDrill`, `useInterruptBridge`, `useInterruptFor`),
|
|
19
|
+
activity components (`ActivityPanel`, `AgentCard`, `Timeline`, `ToolRow`,
|
|
20
|
+
`MiniTable`, `GlassTabs`, `DrillDetailView`, `MarkdownContent`,
|
|
21
|
+
`InterruptRenderer`), group helpers (`topLevelGroups`, `directChildren`) and
|
|
22
|
+
formatters (`formatToolInput`, `formatToolResult`, `normalizeResult`).
|
|
23
|
+
- `@pgege/kaboo-react/copilotkit` subpath: CopilotKit-coupled integrations
|
|
24
|
+
(`KabooMessageView`, `KabooAssistantMessage`, `KabooInlineCards`,
|
|
25
|
+
`KabooInterruptHandler`, `KabooAskUser`, `KabooToolRender`).
|
|
26
|
+
- `@pgege/kaboo-react/styles.css` stylesheet with themeable `--kaboo-*` design tokens.
|
|
27
|
+
|
|
28
|
+
[Unreleased]: https://github.com/gl-pgege/kaboo-react/compare/v0.1.0...HEAD
|
|
29
|
+
[0.1.0]: https://github.com/gl-pgege/kaboo-react/releases/tag/v0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 gl-pgege
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# kaboo-react
|
|
2
|
+
|
|
3
|
+
> React components + hooks for rendering kaboo multi-agent activity in a
|
|
4
|
+
> [CopilotKit](https://copilotkit.ai) app, with batteries-included CopilotKit
|
|
5
|
+
> integrations.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/kaboo-react)
|
|
8
|
+
[](./LICENSE)
|
|
9
|
+
[](https://gl-pgege.github.io/kaboo-react/)
|
|
10
|
+
[](https://github.com/gl-pgege/kaboo-react/actions/workflows/ci.yml)
|
|
11
|
+
|
|
12
|
+
kaboo-react renders a live, hierarchical view of what your agents are doing —
|
|
13
|
+
sub-agent cards, tool calls, streamed tokens, structured outputs, drill-down
|
|
14
|
+
navigation, and human-in-the-loop interrupts. Activity rides the **same AG-UI run
|
|
15
|
+
stream** as the chat (as `ACTIVITY_SNAPSHOT` events), so there is no separate
|
|
16
|
+
endpoint to wire up: kaboo-react is a batteries-included CopilotKit plugin.
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- **Live hierarchical activity** — nested agent/tool cards that stream in as work
|
|
21
|
+
happens, inside the chat transcript.
|
|
22
|
+
- **Drill-down navigation** — breadcrumb + detail view to explore any sub-agent.
|
|
23
|
+
- **Human-in-the-loop** — approval gates and forms, with N parallel interrupts
|
|
24
|
+
resolved independently.
|
|
25
|
+
- **Structured renderers** — plug custom UI for schema-shaped agent output.
|
|
26
|
+
- **Batteries included** — one `KabooProvider` renders `<CopilotKit>` and mounts
|
|
27
|
+
every context and handler for you.
|
|
28
|
+
- **Themeable** — styled with CSS variables and `--kaboo-*` tokens.
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
yarn add @pgege/kaboo-react
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Peer dependencies: `react`, `react-dom`, and `@copilotkit/react-core` (>= 1.62).
|
|
37
|
+
|
|
38
|
+
Import the stylesheet once, near your app root:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import "@pgege/kaboo-react/styles.css";
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick start
|
|
45
|
+
|
|
46
|
+
`KabooProvider` renders `<CopilotKit>` for you and mounts every kaboo context and
|
|
47
|
+
handler inside it. Give it the runtime URL, the entry agent, and a thread id —
|
|
48
|
+
then drop in the components.
|
|
49
|
+
|
|
50
|
+
<!-- source: examples/minimal/src/App.tsx#quickstart -->
|
|
51
|
+
```tsx
|
|
52
|
+
import { CopilotChat } from "@copilotkit/react-core/v2";
|
|
53
|
+
import { KabooProvider, GlassTabs, DrillDetailView } from "@pgege/kaboo-react";
|
|
54
|
+
import { KabooMessageView } from "@pgege/kaboo-react/copilotkit";
|
|
55
|
+
import "@pgege/kaboo-react/styles.css";
|
|
56
|
+
|
|
57
|
+
export function App({ agent, threadId }: { agent: string; threadId: string }) {
|
|
58
|
+
return (
|
|
59
|
+
<KabooProvider runtimeUrl="/api/copilotkit" agent={agent} threadId={threadId}>
|
|
60
|
+
<GlassTabs />
|
|
61
|
+
<CopilotChat messageView={KabooMessageView} />
|
|
62
|
+
<DrillDetailView />
|
|
63
|
+
</KabooProvider>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
That's it — `KabooProvider` nests the three contexts (`KabooActivityProvider`,
|
|
69
|
+
`DrillProvider`, `InterruptBridgeProvider`) plus the built-in `KabooInlineCards`
|
|
70
|
+
and `KabooInterruptHandler`. Disable the auto-mounted handlers with
|
|
71
|
+
`disableInlineCards` / `disableInterruptHandler`, and forward extra CopilotKit
|
|
72
|
+
props via `copilotKitProps`.
|
|
73
|
+
|
|
74
|
+
## Core concepts
|
|
75
|
+
|
|
76
|
+
- **Activity rides the run stream.** The backend emits activity as
|
|
77
|
+
`ACTIVITY_SNAPSHOT` events on the same AG-UI run stream as the chat, so there is
|
|
78
|
+
no separate activity endpoint. `KabooActivityProvider` subscribes to the
|
|
79
|
+
CopilotKit agent and exposes it via `useActivity()`.
|
|
80
|
+
- **Providers nest under `KabooProvider`.** Activity → drill → interrupt bridge,
|
|
81
|
+
with the built-in handlers mounted inside.
|
|
82
|
+
- **Two barrels.** Import framework-agnostic pieces from `kaboo-react`, and the
|
|
83
|
+
CopilotKit-coupled integrations from `@pgege/kaboo-react/copilotkit`.
|
|
84
|
+
- **The `threadId` scopes everything.** Each conversation gets its own
|
|
85
|
+
hierarchical activity view automatically.
|
|
86
|
+
- **Theming via CSS variables.** Components read standard design-system tokens and
|
|
87
|
+
accept `--kaboo-*` overrides.
|
|
88
|
+
|
|
89
|
+
## Guides
|
|
90
|
+
|
|
91
|
+
- [Getting started](./docs/getting-started.md)
|
|
92
|
+
- [Theming](./docs/theming.md)
|
|
93
|
+
- [Structured renderers](./docs/structured-renderers.md)
|
|
94
|
+
- [Human-in-the-loop](./docs/hitl.md)
|
|
95
|
+
- [Activity panel & drill-down](./docs/activity-panel.md)
|
|
96
|
+
- [The `@pgege/kaboo-react/copilotkit` subpath](./docs/copilotkit-subpath.md)
|
|
97
|
+
|
|
98
|
+
## API reference
|
|
99
|
+
|
|
100
|
+
Full, auto-generated API docs for both barrels live on the
|
|
101
|
+
[documentation site](https://gl-pgege.github.io/kaboo-react/api/). A flat index
|
|
102
|
+
of every public export is in [docs/api-inventory.md](./docs/api-inventory.md).
|
|
103
|
+
|
|
104
|
+
## Examples
|
|
105
|
+
|
|
106
|
+
- [`examples/minimal`](./examples/minimal) — the smallest end-to-end wiring
|
|
107
|
+
(this README's quick start).
|
|
108
|
+
- The [kaboo-workflows-demo](https://github.com/gl-pgege/kaboo-docs/tree/main/examples/kaboo-workflows-demo)
|
|
109
|
+
frontend is the canonical, production-shaped consumer.
|
|
110
|
+
|
|
111
|
+
## Compatibility & versioning
|
|
112
|
+
|
|
113
|
+
- **React** 18 and 19 (`react` / `react-dom` >= 18 as peer deps).
|
|
114
|
+
- **CopilotKit** `@copilotkit/react-core` >= 1.62 (peer dep).
|
|
115
|
+
- Follows [semantic versioning](https://semver.org). See
|
|
116
|
+
[CHANGELOG.md](./CHANGELOG.md).
|
|
117
|
+
|
|
118
|
+
## The kaboo stack
|
|
119
|
+
|
|
120
|
+
kaboo-react is one of three libraries:
|
|
121
|
+
|
|
122
|
+
- [kaboo-workflows](https://github.com/gl-pgege/kaboo-workflows) — Python
|
|
123
|
+
multi-agent orchestration.
|
|
124
|
+
- [kaboo-runtime](https://github.com/gl-pgege/kaboo-runtime) — CopilotKit runtime
|
|
125
|
+
persistence/orchestration plugin.
|
|
126
|
+
- **kaboo-react** — this library, the UI layer.
|
|
127
|
+
|
|
128
|
+
## Contributing
|
|
129
|
+
|
|
130
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) (humans) and [AGENTS.md](./AGENTS.md)
|
|
131
|
+
(AI contributors).
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
MIT — see [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A single tool invocation captured within an agent's activity group. One
|
|
5
|
+
* `ToolCall` maps to one AG-UI tool-call and carries enough state to render the
|
|
6
|
+
* live tool row, its input summary, and its result (or cancellation).
|
|
7
|
+
*/
|
|
8
|
+
interface ToolCall {
|
|
9
|
+
/** AG-UI tool-call id. Stable key used to correlate rows, cards, and gates. */
|
|
10
|
+
toolUseId: string;
|
|
11
|
+
/** The tool's machine name (e.g. `run_sql`, `ask_user`). */
|
|
12
|
+
toolName: string;
|
|
13
|
+
/** Optional human-friendly label shown instead of `toolName`. */
|
|
14
|
+
toolLabel?: string;
|
|
15
|
+
/** The raw tool input (arbitrary JSON), summarized by the formatters. */
|
|
16
|
+
toolInput?: unknown;
|
|
17
|
+
/** The raw tool result, if the call has completed. */
|
|
18
|
+
toolResult?: string;
|
|
19
|
+
/** Lifecycle state of the call, driving the row's icon and status text. */
|
|
20
|
+
status: "running" | "done" | "success" | "error" | "cancelled";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* One chronological entry in an agent's timeline: either a streamed text segment
|
|
24
|
+
* or a tool call, interleaved in the order they occurred.
|
|
25
|
+
*/
|
|
26
|
+
type TimelineEntry = {
|
|
27
|
+
/** Discriminator: a streamed text segment. */
|
|
28
|
+
type: "text";
|
|
29
|
+
/** The streamed text for this segment. */
|
|
30
|
+
text: string;
|
|
31
|
+
} | {
|
|
32
|
+
/** Discriminator: a tool call. */
|
|
33
|
+
type: "tool";
|
|
34
|
+
/** The tool call for this entry. */
|
|
35
|
+
tool: ToolCall;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* A single question in a human-in-the-loop form interrupt. `type` selects the
|
|
39
|
+
* input control; `options` supplies the choices for `radio`/`checkbox`.
|
|
40
|
+
*/
|
|
41
|
+
interface FormQuestion {
|
|
42
|
+
/** The prompt text shown to the user. */
|
|
43
|
+
question: string;
|
|
44
|
+
/** Which input control to render for this question. */
|
|
45
|
+
type: "radio" | "checkbox" | "text";
|
|
46
|
+
/** Selectable choices for `radio`/`checkbox` questions. */
|
|
47
|
+
options?: string[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* An approval interrupt: the agent is asking the user to approve or reject a
|
|
51
|
+
* gated tool call before it runs.
|
|
52
|
+
*/
|
|
53
|
+
interface ApprovalReason {
|
|
54
|
+
/** Discriminator marking this as an approval gate. */
|
|
55
|
+
type: "approval";
|
|
56
|
+
/** Human-readable description of what is being approved. */
|
|
57
|
+
message: string;
|
|
58
|
+
/** Name of the gated tool awaiting approval. */
|
|
59
|
+
tool_name: string;
|
|
60
|
+
/** The proposed tool input, shown for review. */
|
|
61
|
+
tool_input?: unknown;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A form interrupt: the agent is asking the user one or more questions and
|
|
65
|
+
* waiting for the answers before it continues.
|
|
66
|
+
*/
|
|
67
|
+
interface FormReason {
|
|
68
|
+
/** Discriminator marking this as a form prompt. */
|
|
69
|
+
type: "form";
|
|
70
|
+
/** The questions to present, rendered in order. */
|
|
71
|
+
questions: FormQuestion[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The reason a run paused for human input — either an {@link ApprovalReason}
|
|
75
|
+
* (approve/reject a gated tool) or a {@link FormReason} (answer questions).
|
|
76
|
+
*/
|
|
77
|
+
type InterruptReason = ApprovalReason | FormReason;
|
|
78
|
+
/**
|
|
79
|
+
* A single open interrupt from the AG-UI run, as delivered by CopilotKit.
|
|
80
|
+
* Multiple can be open at once (e.g. parallel gates); each is resolved by `id`.
|
|
81
|
+
*/
|
|
82
|
+
interface InterruptData {
|
|
83
|
+
/** Unique interrupt id, used to resolve this gate independently. */
|
|
84
|
+
id: string;
|
|
85
|
+
/** The interrupt's name (typically the originating tool name). */
|
|
86
|
+
name: string;
|
|
87
|
+
/** Why the run paused, and what input it needs. */
|
|
88
|
+
reason: InterruptReason;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Props for a custom interrupt renderer supplied via `interruptRenderers`.
|
|
92
|
+
* Receives the reason plus resolve/cancel callbacks so a bespoke UI can drive
|
|
93
|
+
* the gate.
|
|
94
|
+
*/
|
|
95
|
+
interface InterruptRendererProps {
|
|
96
|
+
/** Why the run paused, and what input it needs. */
|
|
97
|
+
reason: InterruptReason;
|
|
98
|
+
/** Resume the run with the user's answer/approval payload. */
|
|
99
|
+
onResolve: (payload: unknown) => void;
|
|
100
|
+
/** Cancel/reject the gate, resuming the run without a positive answer. */
|
|
101
|
+
onCancel: () => void;
|
|
102
|
+
/**
|
|
103
|
+
* The interrupt's originating tool-call id, when available. Used to correlate
|
|
104
|
+
* the answered form with the durable tool-call card that renders the Q&A
|
|
105
|
+
* inline in the transcript.
|
|
106
|
+
*/
|
|
107
|
+
toolCallId?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* One node of kaboo's hierarchical activity tree: a single agent run and its
|
|
111
|
+
* streamed text, tool calls, timeline, structured output, and (optional)
|
|
112
|
+
* open interrupt. Groups nest via {@link StreamGroup.parentGroup} to form the
|
|
113
|
+
* drill-down hierarchy.
|
|
114
|
+
*/
|
|
115
|
+
interface StreamGroup {
|
|
116
|
+
/** Display title for the group's card. */
|
|
117
|
+
title: string;
|
|
118
|
+
/** The agent's machine name (used to correlate inline cards). */
|
|
119
|
+
agentName: string;
|
|
120
|
+
/** Parent group id, or `null` for a top-level group. */
|
|
121
|
+
parentGroup: string | null;
|
|
122
|
+
/**
|
|
123
|
+
* The delegating tool-call id (AG-UI `toolCallId`) that spawned this group.
|
|
124
|
+
* Stable key for correlating an inline chat card with its activity group.
|
|
125
|
+
* `null`/absent for the entry agent and non-delegated groups.
|
|
126
|
+
*/
|
|
127
|
+
toolCallId?: string | null;
|
|
128
|
+
/**
|
|
129
|
+
* The AG-UI `runId` of the turn that produced this group. `null`/absent for
|
|
130
|
+
* older streams. Note: an interrupt/resume changes the `runId` mid-turn, so
|
|
131
|
+
* prefer {@link StreamGroup.turnId} for turn scoping.
|
|
132
|
+
*/
|
|
133
|
+
runId?: string | null;
|
|
134
|
+
/**
|
|
135
|
+
* The logical turn that produced this group — stable across an
|
|
136
|
+
* interrupt/resume (server-stamped). All groups of one user turn share it, so
|
|
137
|
+
* the UI can bind them to that turn's single chat reply without fragmenting
|
|
138
|
+
* on `runId`. `null`/absent for older streams.
|
|
139
|
+
*/
|
|
140
|
+
turnId?: string | null;
|
|
141
|
+
/**
|
|
142
|
+
* The task this agent was handed (its latest human/handoff message), shown at
|
|
143
|
+
* the top of the card so you can see what each agent was asked to do.
|
|
144
|
+
*/
|
|
145
|
+
task?: string | null;
|
|
146
|
+
/**
|
|
147
|
+
* True when this agent's streamed text IS the chat reply (the swarm/graph
|
|
148
|
+
* `chat_output`, or a delegate manager). Inline cards suppress only this
|
|
149
|
+
* group's text so the answer isn't duplicated between the card and the bubble.
|
|
150
|
+
*/
|
|
151
|
+
isChatReply?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* True for a plain-agent entry group: its text and tool calls are already
|
|
154
|
+
* rendered inline in the chat by the host (CopilotKit), so this group exists
|
|
155
|
+
* only to enrich those tool rows (labels, formatted results, error status)
|
|
156
|
+
* and must never be drawn as its own card.
|
|
157
|
+
*/
|
|
158
|
+
inlineChatOwner?: boolean;
|
|
159
|
+
/** Lifecycle state of the group's run. */
|
|
160
|
+
status: "active" | "completed" | "error" | "interrupted";
|
|
161
|
+
/** Every tool call made in this group, in call order. */
|
|
162
|
+
tools: ToolCall[];
|
|
163
|
+
/** Accumulated streamed text tokens for this group. */
|
|
164
|
+
tokens: string;
|
|
165
|
+
/** Interleaved text/tool entries in chronological order. */
|
|
166
|
+
timeline: TimelineEntry[];
|
|
167
|
+
/** The open interrupt for this group, when it is paused for input. */
|
|
168
|
+
interrupt?: InterruptData;
|
|
169
|
+
/** Structured (schema-shaped) output emitted by the agent, if any. */
|
|
170
|
+
structuredOutput?: Record<string, unknown>;
|
|
171
|
+
/** Name of the schema for {@link StreamGroup.structuredOutput}, selecting a renderer. */
|
|
172
|
+
outputSchemaName?: string;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The full activity snapshot for a conversation: every {@link StreamGroup}
|
|
176
|
+
* keyed by group id. This is what {@link useActivity} exposes.
|
|
177
|
+
*/
|
|
178
|
+
interface ActivityState {
|
|
179
|
+
/** All activity groups for the current thread, keyed by group id. */
|
|
180
|
+
groups: Record<string, StreamGroup>;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Drill-down navigation state: the current path into the activity tree plus the
|
|
184
|
+
* actions to move through it. Exposed by {@link useDrill}.
|
|
185
|
+
*/
|
|
186
|
+
interface DrillState {
|
|
187
|
+
/** Group ids from root to the current level. */
|
|
188
|
+
drillPath: string[];
|
|
189
|
+
/** The deepest group id in the path, or `null` at the root. */
|
|
190
|
+
activeDrill: string | null;
|
|
191
|
+
/** Push a group id, descending one level. */
|
|
192
|
+
drillIn: (groupId: string) => void;
|
|
193
|
+
/** Pop the last group id, ascending one level. */
|
|
194
|
+
drillUp: () => void;
|
|
195
|
+
/** Clear the path, returning to the root. */
|
|
196
|
+
drillToRoot: () => void;
|
|
197
|
+
/** Trim the path to `level` (0-based), jumping to a breadcrumb. */
|
|
198
|
+
drillToLevel: (level: number) => void;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Props for {@link KabooInterruptHandler}. */
|
|
202
|
+
interface KabooInterruptHandlerProps {
|
|
203
|
+
/** Restrict handling to a single CopilotKit agent (optional). */
|
|
204
|
+
agentId?: string;
|
|
205
|
+
/** Per-interrupt-type renderer overrides. */
|
|
206
|
+
renderers?: Partial<Record<InterruptReason["type"], React.ComponentType<InterruptRendererProps>>>;
|
|
207
|
+
/**
|
|
208
|
+
* Also publish the active interrupts to the InterruptBridge so each renders
|
|
209
|
+
* inside the drill-down detail view (not just the chat). Defaults to `true`;
|
|
210
|
+
* requires an `InterruptBridgeProvider` (included in `KabooProvider`).
|
|
211
|
+
*/
|
|
212
|
+
bridge?: boolean;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Ready-made human-in-the-loop interrupt handler. CopilotKit surfaces every open
|
|
216
|
+
* interrupt of a run at once (e.g. two gated tools called in parallel); we render
|
|
217
|
+
* one card per interrupt and resolve each independently by its own id. The client
|
|
218
|
+
* accumulates the per-id responses and only resumes the run once every open
|
|
219
|
+
* interrupt has been answered — so resolving with `intr.id` (never the bare
|
|
220
|
+
* `resolve()`, which would only ever answer the first) is what keeps N parallel
|
|
221
|
+
* gates from wedging. Prompts anchored to an on-screen tool render inline at that
|
|
222
|
+
* tool's position; the rest fall back to the chat slot.
|
|
223
|
+
*/
|
|
224
|
+
declare function KabooInterruptHandler({ agentId, renderers, bridge, }: KabooInterruptHandlerProps): ReactElement | null;
|
|
225
|
+
|
|
226
|
+
export { type ActivityState as A, type DrillState as D, type FormQuestion as F, type InterruptReason as I, KabooInterruptHandler as K, type StreamGroup as S, type ToolCall as T, type KabooInterruptHandlerProps as a, type InterruptRendererProps as b, type TimelineEntry as c, type ApprovalReason as d, type FormReason as e, type InterruptData as f };
|