@kibadist/agentui-ai 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/README.md +156 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/run-agent.d.ts +30 -0
- package/dist/run-agent.d.ts.map +1 -0
- package/dist/run-agent.js +26 -0
- package/dist/run-agent.js.map +1 -0
- package/dist/tool.d.ts +51 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +72 -0
- package/dist/tool.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# @kibadist/agentui-ai
|
|
2
|
+
|
|
3
|
+
Provider-agnostic AgentUI adapter built on the [Vercel AI SDK](https://ai-sdk.dev). Works with **any** AI SDK-compatible provider — OpenAI, Anthropic, Google, DeepSeek, Mistral, and more.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @kibadist/agentui-ai ai zod
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Peer dependencies:** `ai` ^6.0.0, `zod` ^3.24.2
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { openai } from "@ai-sdk/openai";
|
|
17
|
+
import { runAgentLoop } from "@kibadist/agentui-ai";
|
|
18
|
+
|
|
19
|
+
await runAgentLoop({
|
|
20
|
+
model: openai("gpt-4o"),
|
|
21
|
+
system: "You are a helpful assistant. Use emit_ui_event to render UI.",
|
|
22
|
+
prompt: "Show me a summary of recent sales",
|
|
23
|
+
allowedTypes: ["text-block", "info-card", "data-table"],
|
|
24
|
+
sessionId: "session-123",
|
|
25
|
+
onUIEvent: (event) => {
|
|
26
|
+
console.log(event);
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Using different providers
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// OpenAI
|
|
35
|
+
import { openai } from "@ai-sdk/openai";
|
|
36
|
+
const model = openai("gpt-4o");
|
|
37
|
+
|
|
38
|
+
// Anthropic
|
|
39
|
+
import { anthropic } from "@ai-sdk/anthropic";
|
|
40
|
+
const model = anthropic("claude-sonnet-4-5-20250514");
|
|
41
|
+
|
|
42
|
+
// Google
|
|
43
|
+
import { google } from "@ai-sdk/google";
|
|
44
|
+
const model = google("gemini-2.0-flash");
|
|
45
|
+
|
|
46
|
+
// DeepSeek
|
|
47
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
48
|
+
const deepseek = createOpenAI({ baseURL: "https://api.deepseek.com", apiKey: process.env.DEEPSEEK_API_KEY });
|
|
49
|
+
const model = deepseek("deepseek-chat");
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## How it works
|
|
53
|
+
|
|
54
|
+
`runAgentLoop` creates an `emit_ui_event` tool whose Zod schema constrains the agent to only emit your registered component types. It calls the AI SDK's `generateText` with multi-step tool calling — no manual loop, no JSON.parse, no message management.
|
|
55
|
+
|
|
56
|
+
The tool uses a `z.discriminatedUnion("op", [...])` so the model receives a precise schema for each operation (append, replace, remove, toast, navigate).
|
|
57
|
+
|
|
58
|
+
## Using the tool directly
|
|
59
|
+
|
|
60
|
+
If you need more control, use `createUIEmitterTool` directly:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { generateText, stepCountIs } from "ai";
|
|
64
|
+
import { createUIEmitterTool, UI_EMITTER_TOOL_NAME } from "@kibadist/agentui-ai";
|
|
65
|
+
|
|
66
|
+
const uiTool = createUIEmitterTool({
|
|
67
|
+
allowedTypes: ["text-block", "info-card"],
|
|
68
|
+
sessionId: "session-123",
|
|
69
|
+
onUIEvent: (event) => console.log(event),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const { text } = await generateText({
|
|
73
|
+
model: openai("gpt-4o"),
|
|
74
|
+
system: "You are a helpful assistant.",
|
|
75
|
+
prompt: "Show a welcome message",
|
|
76
|
+
tools: { [UI_EMITTER_TOOL_NAME]: uiTool },
|
|
77
|
+
stopWhen: stepCountIs(5),
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Options
|
|
82
|
+
|
|
83
|
+
### `runAgentLoop`
|
|
84
|
+
|
|
85
|
+
| Option | Type | Default | Description |
|
|
86
|
+
|---|---|---|---|
|
|
87
|
+
| `model` | `LanguageModel` | required | Any AI SDK model instance |
|
|
88
|
+
| `system` | `string` | required | Agent instructions |
|
|
89
|
+
| `prompt` | `string` | required | Current user message |
|
|
90
|
+
| `allowedTypes` | `string[]` | required | Component types the agent can emit |
|
|
91
|
+
| `sessionId` | `string` | required | Session ID injected into events |
|
|
92
|
+
| `onUIEvent` | `(event: UIEvent) => void` | required | Callback for each emitted UIEvent |
|
|
93
|
+
| `extraTools` | `ToolSet` | `{}` | Additional AI SDK tools beyond the UI emitter |
|
|
94
|
+
| `maxSteps` | `number` | `10` | Max tool-call steps before stopping |
|
|
95
|
+
|
|
96
|
+
### `createUIEmitterTool`
|
|
97
|
+
|
|
98
|
+
| Option | Type | Description |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| `allowedTypes` | `string[]` | Component types the agent can emit |
|
|
101
|
+
| `sessionId` | `string` | Session ID injected into events |
|
|
102
|
+
| `onUIEvent` | `(event: UIEvent) => void` | Callback for each emitted UIEvent |
|
|
103
|
+
|
|
104
|
+
## Migration from `@kibadist/agentui-openai`
|
|
105
|
+
|
|
106
|
+
| Old (`agentui-openai`) | New (`agentui-ai`) |
|
|
107
|
+
|---|---|
|
|
108
|
+
| `openai: OpenAI` | `model: LanguageModel` (any provider) |
|
|
109
|
+
| `systemPrompt: string` | `system: string` |
|
|
110
|
+
| `userMessage: string` | `prompt: string` |
|
|
111
|
+
| `extraTools?: ChatCompletionTool[]` | `extraTools?: ToolSet` |
|
|
112
|
+
| `onToolCall?` | removed (each tool has its own `execute`) |
|
|
113
|
+
| `maxRounds?: number` | `maxSteps?: number` |
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
// Before (openai package)
|
|
117
|
+
import OpenAI from "openai";
|
|
118
|
+
import { runAgentLoop } from "@kibadist/agentui-openai";
|
|
119
|
+
|
|
120
|
+
await runAgentLoop({
|
|
121
|
+
openai: new OpenAI(),
|
|
122
|
+
model: "gpt-4o",
|
|
123
|
+
systemPrompt: "...",
|
|
124
|
+
userMessage: "...",
|
|
125
|
+
allowedTypes: [...],
|
|
126
|
+
sessionId: "...",
|
|
127
|
+
onUIEvent: (e) => {},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// After (ai package)
|
|
131
|
+
import { openai } from "@ai-sdk/openai";
|
|
132
|
+
import { runAgentLoop } from "@kibadist/agentui-ai";
|
|
133
|
+
|
|
134
|
+
await runAgentLoop({
|
|
135
|
+
model: openai("gpt-4o"),
|
|
136
|
+
system: "...",
|
|
137
|
+
prompt: "...",
|
|
138
|
+
allowedTypes: [...],
|
|
139
|
+
sessionId: "...",
|
|
140
|
+
onUIEvent: (e) => {},
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Exports
|
|
145
|
+
|
|
146
|
+
| Export | Kind | Description |
|
|
147
|
+
|---|---|---|
|
|
148
|
+
| `runAgentLoop` | function | Multi-step agent loop with UI event emission |
|
|
149
|
+
| `createUIEmitterTool` | function | Generate the `emit_ui_event` AI SDK tool |
|
|
150
|
+
| `UI_EMITTER_TOOL_NAME` | constant | `"emit_ui_event"` |
|
|
151
|
+
| `RunAgentLoopOptions` | interface | Options for `runAgentLoop` |
|
|
152
|
+
| `CreateUIEmitterToolOptions` | interface | Options for `createUIEmitterTool` |
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,0BAA0B,GAChC,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GAErB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,YAAY,EAA4B,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type LanguageModel, type ToolSet } from "ai";
|
|
2
|
+
import type { UIEvent } from "@kibadist/agentui-protocol";
|
|
3
|
+
export interface RunAgentLoopOptions {
|
|
4
|
+
/** Any AI SDK LanguageModel (OpenAI, Anthropic, Google, etc.) */
|
|
5
|
+
model: LanguageModel;
|
|
6
|
+
/** System message (instructions for the agent) */
|
|
7
|
+
system: string;
|
|
8
|
+
/** Current user message / action description */
|
|
9
|
+
prompt: string;
|
|
10
|
+
/** Allowed component types from your registry */
|
|
11
|
+
allowedTypes: string[];
|
|
12
|
+
/** Session id injected into emitted events */
|
|
13
|
+
sessionId: string;
|
|
14
|
+
/** Called for each valid UI event produced by the model */
|
|
15
|
+
onUIEvent: (event: UIEvent) => void;
|
|
16
|
+
/** Optional: additional tools beyond the UI emitter */
|
|
17
|
+
extraTools?: ToolSet;
|
|
18
|
+
/** Max tool-call steps before stopping (default 10) */
|
|
19
|
+
maxSteps?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Runs an agent loop using the AI SDK's `generateText` with multi-step
|
|
23
|
+
* tool calling. No manual loop, no JSON.parse, no message management.
|
|
24
|
+
*
|
|
25
|
+
* Works with any AI SDK-compatible model (OpenAI, Anthropic, Google, etc.).
|
|
26
|
+
*
|
|
27
|
+
* Returns the final assistant text (if any).
|
|
28
|
+
*/
|
|
29
|
+
export declare function runAgentLoop(opts: RunAgentLoopOptions): Promise<string | null>;
|
|
30
|
+
//# sourceMappingURL=run-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-agent.d.ts","sourceRoot":"","sources":["../src/run-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,aAAa,EAAE,KAAK,OAAO,EAAE,MAAM,IAAI,CAAC;AACjF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAG1D,MAAM,WAAW,mBAAmB;IAClC,iEAAiE;IACjE,KAAK,EAAE,aAAa,CAAC;IACrB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,uDAAuD;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA0BxB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { generateText, stepCountIs } from "ai";
|
|
2
|
+
import { createUIEmitterTool, UI_EMITTER_TOOL_NAME } from "./tool.js";
|
|
3
|
+
/**
|
|
4
|
+
* Runs an agent loop using the AI SDK's `generateText` with multi-step
|
|
5
|
+
* tool calling. No manual loop, no JSON.parse, no message management.
|
|
6
|
+
*
|
|
7
|
+
* Works with any AI SDK-compatible model (OpenAI, Anthropic, Google, etc.).
|
|
8
|
+
*
|
|
9
|
+
* Returns the final assistant text (if any).
|
|
10
|
+
*/
|
|
11
|
+
export async function runAgentLoop(opts) {
|
|
12
|
+
const { model, system, prompt, allowedTypes, sessionId, onUIEvent, extraTools = {}, maxSteps = 10, } = opts;
|
|
13
|
+
const uiTool = createUIEmitterTool({ allowedTypes, sessionId, onUIEvent });
|
|
14
|
+
const { text } = await generateText({
|
|
15
|
+
model,
|
|
16
|
+
system,
|
|
17
|
+
prompt,
|
|
18
|
+
tools: {
|
|
19
|
+
[UI_EMITTER_TOOL_NAME]: uiTool,
|
|
20
|
+
...extraTools,
|
|
21
|
+
},
|
|
22
|
+
stopWhen: stepCountIs(maxSteps),
|
|
23
|
+
});
|
|
24
|
+
return text || null;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=run-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-agent.js","sourceRoot":"","sources":["../src/run-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAoC,MAAM,IAAI,CAAC;AAEjF,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAqBtE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAyB;IAEzB,MAAM,EACJ,KAAK,EACL,MAAM,EACN,MAAM,EACN,YAAY,EACZ,SAAS,EACT,SAAS,EACT,UAAU,GAAG,EAAE,EACf,QAAQ,GAAG,EAAE,GACd,GAAG,IAAI,CAAC;IAET,MAAM,MAAM,GAAG,mBAAmB,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;IAE3E,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,YAAY,CAAC;QAClC,KAAK;QACL,MAAM;QACN,MAAM;QACN,KAAK,EAAE;YACL,CAAC,oBAAoB,CAAC,EAAE,MAAM;YAC9B,GAAG,UAAU;SACd;QACD,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC;KAChC,CAAC,CAAC;IAEH,OAAO,IAAI,IAAI,IAAI,CAAC;AACtB,CAAC"}
|
package/dist/tool.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { UIEvent } from "@kibadist/agentui-protocol";
|
|
2
|
+
export declare const UI_EMITTER_TOOL_NAME = "emit_ui_event";
|
|
3
|
+
export interface CreateUIEmitterToolOptions {
|
|
4
|
+
/** Allowed component types from your registry */
|
|
5
|
+
allowedTypes: string[];
|
|
6
|
+
/** Session id injected into emitted events */
|
|
7
|
+
sessionId: string;
|
|
8
|
+
/** Called for each valid UI event produced by the model */
|
|
9
|
+
onUIEvent: (event: UIEvent) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates an AI SDK tool for emitting UI events.
|
|
13
|
+
*
|
|
14
|
+
* The returned tool uses a Zod `discriminatedUnion` on `op` so the model
|
|
15
|
+
* can only produce valid UI patch operations with your registered component types.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createUIEmitterTool(opts: CreateUIEmitterToolOptions): import("ai").Tool<{
|
|
18
|
+
op: "ui.append";
|
|
19
|
+
node: {
|
|
20
|
+
type: string;
|
|
21
|
+
key: string;
|
|
22
|
+
props: Record<string, unknown>;
|
|
23
|
+
slot?: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
index?: number | undefined;
|
|
26
|
+
} | {
|
|
27
|
+
op: "ui.replace";
|
|
28
|
+
key: string;
|
|
29
|
+
props: Record<string, unknown>;
|
|
30
|
+
replace?: boolean | undefined;
|
|
31
|
+
} | {
|
|
32
|
+
op: "ui.remove";
|
|
33
|
+
key: string;
|
|
34
|
+
} | {
|
|
35
|
+
op: "ui.toast";
|
|
36
|
+
message: string;
|
|
37
|
+
level: "info" | "success" | "warning" | "error";
|
|
38
|
+
} | {
|
|
39
|
+
op: "ui.navigate";
|
|
40
|
+
href: string;
|
|
41
|
+
replace?: boolean | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
ok: boolean;
|
|
44
|
+
eventId: `${string}-${string}-${string}-${string}-${string}`;
|
|
45
|
+
error?: undefined;
|
|
46
|
+
} | {
|
|
47
|
+
ok: boolean;
|
|
48
|
+
error: string;
|
|
49
|
+
eventId?: undefined;
|
|
50
|
+
}>;
|
|
51
|
+
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAG1D,eAAO,MAAM,oBAAoB,kBAAkB,CAAC;AAEpD,MAAM,WAAW,0BAA0B;IACzC,iDAAiD;IACjD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEnE"}
|
package/dist/tool.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { tool } from "ai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { safeParseUIEvent } from "@kibadist/agentui-validate";
|
|
4
|
+
export const UI_EMITTER_TOOL_NAME = "emit_ui_event";
|
|
5
|
+
/**
|
|
6
|
+
* Creates an AI SDK tool for emitting UI events.
|
|
7
|
+
*
|
|
8
|
+
* The returned tool uses a Zod `discriminatedUnion` on `op` so the model
|
|
9
|
+
* can only produce valid UI patch operations with your registered component types.
|
|
10
|
+
*/
|
|
11
|
+
export function createUIEmitterTool(opts) {
|
|
12
|
+
const { allowedTypes, sessionId, onUIEvent } = opts;
|
|
13
|
+
const typesEnum = z.enum(allowedTypes);
|
|
14
|
+
const appendSchema = z.object({
|
|
15
|
+
op: z.literal("ui.append"),
|
|
16
|
+
node: z.object({
|
|
17
|
+
key: z.string().min(1),
|
|
18
|
+
type: typesEnum,
|
|
19
|
+
props: z.record(z.unknown()),
|
|
20
|
+
slot: z.string().optional(),
|
|
21
|
+
}),
|
|
22
|
+
index: z.number().int().nonnegative().optional(),
|
|
23
|
+
});
|
|
24
|
+
const replaceSchema = z.object({
|
|
25
|
+
op: z.literal("ui.replace"),
|
|
26
|
+
key: z.string().min(1),
|
|
27
|
+
props: z.record(z.unknown()),
|
|
28
|
+
replace: z.boolean().optional(),
|
|
29
|
+
});
|
|
30
|
+
const removeSchema = z.object({
|
|
31
|
+
op: z.literal("ui.remove"),
|
|
32
|
+
key: z.string().min(1),
|
|
33
|
+
});
|
|
34
|
+
const toastSchema = z.object({
|
|
35
|
+
op: z.literal("ui.toast"),
|
|
36
|
+
level: z.enum(["info", "success", "warning", "error"]),
|
|
37
|
+
message: z.string().min(1),
|
|
38
|
+
});
|
|
39
|
+
const navigateSchema = z.object({
|
|
40
|
+
op: z.literal("ui.navigate"),
|
|
41
|
+
href: z.string().min(1),
|
|
42
|
+
replace: z.boolean().optional(),
|
|
43
|
+
});
|
|
44
|
+
const inputSchema = z.discriminatedUnion("op", [
|
|
45
|
+
appendSchema,
|
|
46
|
+
replaceSchema,
|
|
47
|
+
removeSchema,
|
|
48
|
+
toastSchema,
|
|
49
|
+
navigateSchema,
|
|
50
|
+
]);
|
|
51
|
+
return tool({
|
|
52
|
+
description: "Emit a UI event to render, update, or remove a component on the user's screen. " +
|
|
53
|
+
"Each call produces exactly one patch operation.",
|
|
54
|
+
inputSchema,
|
|
55
|
+
execute: async (args) => {
|
|
56
|
+
const event = {
|
|
57
|
+
...args,
|
|
58
|
+
v: 1,
|
|
59
|
+
id: crypto.randomUUID(),
|
|
60
|
+
ts: new Date().toISOString(),
|
|
61
|
+
sessionId,
|
|
62
|
+
};
|
|
63
|
+
const parsed = safeParseUIEvent(event);
|
|
64
|
+
if (parsed.ok) {
|
|
65
|
+
onUIEvent(parsed.value);
|
|
66
|
+
return { ok: true, eventId: event.id };
|
|
67
|
+
}
|
|
68
|
+
return { ok: false, error: parsed.error.message };
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=tool.js.map
|
package/dist/tool.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kibadist/agentui-ai",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AgentUI adapter for Vercel AI SDK — works with any provider (OpenAI, Anthropic, Google, etc.)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/kibadist/agentui.git",
|
|
9
|
+
"directory": "packages/ai"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/kibadist/agentui#readme",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc",
|
|
30
|
+
"clean": "rm -rf dist",
|
|
31
|
+
"typecheck": "tsc --noEmit"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@kibadist/agentui-protocol": "workspace:*",
|
|
35
|
+
"@kibadist/agentui-validate": "workspace:*"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"ai": "^6.0.0",
|
|
39
|
+
"zod": "^3.24.2"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"ai": "^6.0.0",
|
|
43
|
+
"zod": "^3.24.2",
|
|
44
|
+
"typescript": "^5.7.3"
|
|
45
|
+
}
|
|
46
|
+
}
|