omnichatkit 0.0.22-b → 0.0.24-b
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/README.md +54 -17
- package/dist/index.cjs +1198 -738
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +859 -2701
- package/dist/index.d.mts +859 -2701
- package/dist/index.mjs +1086 -625
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +2 -3
- package/dist/server/index.d.mts +2 -3
- package/dist/server/index.mjs.map +1 -1
- package/dist/style.css +1728 -0
- package/package.json +44 -20
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ OmniChatKit is designed to be highly flexible. You can use the all-in-one `<Omni
|
|
|
40
40
|
|
|
41
41
|
### 1. The `<OmniChat>` Wrapper (Recommended)
|
|
42
42
|
|
|
43
|
-
The `<OmniChat>` component is the easiest way to orchestrate providers, generative UI, and chat interfaces. Simply choose your `
|
|
43
|
+
The `<OmniChat>` component is the easiest way to orchestrate providers, generative UI, and chat interfaces. Simply choose your `apiMode` and drop in your components.
|
|
44
44
|
|
|
45
45
|
```tsx
|
|
46
46
|
import { OmniChat, SessionManager } from 'omnichatkit';
|
|
@@ -48,9 +48,8 @@ import { OmniChat, SessionManager } from 'omnichatkit';
|
|
|
48
48
|
export default function ChatPage() {
|
|
49
49
|
return (
|
|
50
50
|
<OmniChat
|
|
51
|
-
|
|
51
|
+
apiMode="ag-ui" // "ag-ui" or "classic"
|
|
52
52
|
apiEndpoint="/api/agent"
|
|
53
|
-
useA2UI={true}
|
|
54
53
|
a2uiProps={{
|
|
55
54
|
a2uiToolName: "render-dynamic-ui",
|
|
56
55
|
agentId: "orchestratr_agent",
|
|
@@ -97,9 +96,9 @@ export default function ChatPage() {
|
|
|
97
96
|
|
|
98
97
|
### 3. API Route Setup
|
|
99
98
|
|
|
100
|
-
Depending on your `
|
|
99
|
+
Depending on your `apiMode`, you need to set up your backend endpoint.
|
|
101
100
|
|
|
102
|
-
#### Vercel AI SDK Route (`
|
|
101
|
+
#### Vercel AI SDK Route (`apiMode="classic"`)
|
|
103
102
|
```typescript
|
|
104
103
|
// app/api/chat/route.ts
|
|
105
104
|
import { streamText } from 'ai';
|
|
@@ -115,7 +114,7 @@ export async function POST(req: Request) {
|
|
|
115
114
|
}
|
|
116
115
|
```
|
|
117
116
|
|
|
118
|
-
#### AG-UI Protocol Route (`
|
|
117
|
+
#### AG-UI Protocol Route (`apiMode="ag-ui"`)
|
|
119
118
|
```typescript
|
|
120
119
|
// app/api/agent/route.ts
|
|
121
120
|
import { AGUIServer } from '@ag-ui/server';
|
|
@@ -131,11 +130,11 @@ export async function POST(req: Request) {
|
|
|
131
130
|
|
|
132
131
|
### 4. `chatApiSchema` — Custom Backend Mapping (`classic` mode)
|
|
133
132
|
|
|
134
|
-
When `
|
|
133
|
+
When `apiMode="classic"`, OmniChatKit uses the Vercel AI SDK's `useChat` hook under the hood, which sends messages in its own standard body shape. If your backend API expects a **different request/response format**, pass a `chatApiSchema` prop to `<OmniChat>` to act as a transparent mapper between the two.
|
|
135
134
|
|
|
136
135
|
```tsx
|
|
137
136
|
<OmniChat
|
|
138
|
-
|
|
137
|
+
apiMode="classic"
|
|
139
138
|
apiEndpoint="/api/my-custom-agent"
|
|
140
139
|
chatApiSchema={{
|
|
141
140
|
apiRequestSchema: { /* how to serialize the outbound request */ },
|
|
@@ -147,7 +146,7 @@ When `api_mode="classic"`, OmniChatKit uses the Vercel AI SDK's `useChat` hook u
|
|
|
147
146
|
```
|
|
148
147
|
|
|
149
148
|
> [!NOTE]
|
|
150
|
-
> `chatApiSchema` is a **compile-time narrowed prop** — TypeScript will reject it (type error) if you pass it while `
|
|
149
|
+
> `chatApiSchema` is a **compile-time narrowed prop** — TypeScript will reject it (type error) if you pass it while `apiMode="ag-ui"`.
|
|
151
150
|
|
|
152
151
|
#### `apiRequestSchema`
|
|
153
152
|
|
|
@@ -250,7 +249,7 @@ The `ChatManager` component comes with extensive styling and layout capabilities
|
|
|
250
249
|
- **`display`** (`"floating" | "embedded"`): Controls the layout mode of the chat manager.
|
|
251
250
|
- **`displayOptions`** (`object`): Configuration for the selected display mode.
|
|
252
251
|
- `collapsible` (`boolean`): When display is "embedded", renders the component as a floating drawer (`<Sheet>`) with a dynamic toggle button.
|
|
253
|
-
- `
|
|
252
|
+
- `resizable` (`object`): Enables a drag-to-resize handle for embedded panels without needing an external wrapper. Provide sizing bounds via `{ defaultSize: number, minSize?: number, maxSize?: number }`.
|
|
254
253
|
- **`position`** (`"left" | "right" | "top" | "bottom"`): Controls where the drawer docks and automatically aligns the close button correctly.
|
|
255
254
|
- **`welcomeScreen`** (`boolean | ReactNode`): Set to `true` (default) to show the default welcome screen, or pass a custom React element.
|
|
256
255
|
- **`maxInputCharacter`** (`number`): Optional limit for the maximum number of characters allowed in the chat input box.
|
|
@@ -377,7 +376,7 @@ The `SessionManager` handles chat history.
|
|
|
377
376
|
Enable sessions on `OmniChat` (or either chat provider) before rendering it. Session handling is disabled by default, so chats have no session creation, persistence, or rename requests unless you opt in.
|
|
378
377
|
|
|
379
378
|
```tsx
|
|
380
|
-
<OmniChat
|
|
379
|
+
<OmniChat apiMode="ag-ui" sessionStorageMode="api">
|
|
381
380
|
<SessionManager />
|
|
382
381
|
<ChatManager />
|
|
383
382
|
</OmniChat>
|
|
@@ -385,8 +384,14 @@ Enable sessions on `OmniChat` (or either chat provider) before rendering it. Ses
|
|
|
385
384
|
|
|
386
385
|
#### Props
|
|
387
386
|
- **`sessionStorageMode`** (`"disabled" | "api" | "memory"`): Set on `OmniChat` or a chat provider. `"disabled"` is the default; `SessionManager` throws if it is rendered in this mode.
|
|
388
|
-
- **`collapsible`** (`boolean`):
|
|
389
|
-
- **`
|
|
387
|
+
- **`collapsible`** (`boolean`): If true, allows the session manager to be collapsed.
|
|
388
|
+
- **`variant`** (`"sheet" | "inline-sheet" | "drawer" | "inline-drawer"`): Controls the visual style and collapse behavior. Defaults to `"inline-sheet"`.
|
|
389
|
+
- `"sheet"`: A slide-out panel that overlays the content.
|
|
390
|
+
- `"drawer"`: A swipeable slide-out panel that overlays the content.
|
|
391
|
+
- `"inline-sheet"`: A collapsible sidebar with Sheet styling that stays in the page flow.
|
|
392
|
+
- `"inline-drawer"`: A collapsible sidebar with Drawer styling (rounded floating design) that stays in the page flow.
|
|
393
|
+
- *Note: If `collapsible` is `false`, only inline variants (`"inline-sheet"` or `"inline-drawer"`) are allowed.*
|
|
394
|
+
- **`position`** (`"left" | "right" | "top" | "bottom"`): Where the manager should dock.
|
|
390
395
|
|
|
391
396
|
#### Session list style slots
|
|
392
397
|
|
|
@@ -432,7 +437,7 @@ function MyCustomChatUI() {
|
|
|
432
437
|
|
|
433
438
|
**Resolution logic:**
|
|
434
439
|
1. **Only one provider in the tree** → returns that context directly. No store lookup needed.
|
|
435
|
-
2. **Both providers present** → uses the `
|
|
440
|
+
2. **Both providers present** → uses the `apiMode` registered by `<OmniChat>` as a tiebreaker.
|
|
436
441
|
3. **Neither present** → throws a descriptive error.
|
|
437
442
|
|
|
438
443
|
> [!NOTE]
|
|
@@ -480,6 +485,37 @@ This proxy ensures unauthorized requests are immediately dropped (returning `401
|
|
|
480
485
|
### 9. Working with AI Reasoning (e.g. DeepSeek `<think>`)
|
|
481
486
|
OmniChatKit automatically parses and extracts `<think>` tags from incoming model streams. It strips these out of the primary text response and renders them natively as a beautiful, collapsible "Reasoning" accordion inside the message block! No extra configuration is required.
|
|
482
487
|
|
|
488
|
+
### 10. Frontend Action Tooling (AG-UI)
|
|
489
|
+
|
|
490
|
+
OmniChatKit provides a powerful way to define frontend tools that the AI agent can call using the `useAGUIAction` hook. This allows you to integrate application-specific behaviors like UI actions, user confirmations, or data fetching seamlessly into the agent's workflow.
|
|
491
|
+
|
|
492
|
+
```tsx
|
|
493
|
+
import { useAGUIAction } from "omnichatkit";
|
|
494
|
+
|
|
495
|
+
function MyInteractiveComponent() {
|
|
496
|
+
useAGUIAction({
|
|
497
|
+
name: "confirmAction",
|
|
498
|
+
description: "Ask the user to confirm a specific action before proceeding",
|
|
499
|
+
parameters: {
|
|
500
|
+
type: "object",
|
|
501
|
+
properties: {
|
|
502
|
+
action: { type: "string", description: "The action that needs user confirmation" }
|
|
503
|
+
},
|
|
504
|
+
required: ["action"],
|
|
505
|
+
},
|
|
506
|
+
handler: async ({ action }) => {
|
|
507
|
+
// Execute your frontend logic, like showing a confirmation dialog
|
|
508
|
+
const confirmed = window.confirm(`Proceed with: ${action}?`);
|
|
509
|
+
return confirmed ? "approved" : "rejected";
|
|
510
|
+
},
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
return <div>My Component</div>;
|
|
514
|
+
}
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
Registered tools are automatically injected into the `RunAgentInput.tools` payload during the AG-UI agent turn, and the chat hook natively awaits the `handler` execution and appends the result to the conversation automatically.
|
|
518
|
+
|
|
483
519
|
---
|
|
484
520
|
|
|
485
521
|
## Core Architecture
|
|
@@ -510,10 +546,11 @@ OmniChatKit exports all necessary hooks, components, and types to give you full
|
|
|
510
546
|
|
|
511
547
|
**Hooks**
|
|
512
548
|
- `useAIChatStore`
|
|
513
|
-
- `useChatContext`
|
|
514
|
-
- `useAIChatContext`
|
|
515
|
-
- `useAGUIChatContext`
|
|
549
|
+
- `useChatContext` — auto-selects the correct context based on the active provider
|
|
550
|
+
- `useAIChatContext` — explicit classic (Vercel AI SDK) context accessor
|
|
551
|
+
- `useAGUIChatContext` — explicit AG-UI context accessor
|
|
516
552
|
- `useAGUIChat`
|
|
553
|
+
- `useAGUIAction`
|
|
517
554
|
- `useHITL`
|
|
518
555
|
- `useInterrupts`
|
|
519
556
|
|