@kibadist/agentui-ai 0.1.7 → 0.2.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/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { createUIEmitterTool, UI_EMITTER_TOOL_NAME, type CreateUIEmitterToolOptions, } from "./tool.js";
2
- export { runAgentLoop, type RunAgentLoopOptions } from "./run-agent.js";
2
+ export { runAgentLoop, type ResponseMessage, type RunAgentLoopOptions, type RunAgentLoopResult, } from "./run-agent.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
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,EACL,YAAY,EACZ,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { createUIEmitterTool, UI_EMITTER_TOOL_NAME, } from "./tool.js";
2
- export { runAgentLoop } from "./run-agent.js";
2
+ export { runAgentLoop, } from "./run-agent.js";
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +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"}
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,EACL,YAAY,GAIb,MAAM,gBAAgB,CAAC"}
@@ -1,12 +1,15 @@
1
- import { type LanguageModel, type ToolSet } from "ai";
1
+ import { type AssistantModelMessage, type LanguageModel, type ModelMessage, type ToolModelMessage, type ToolSet } from "ai";
2
2
  import type { UIEvent } from "@kibadist/agentui-protocol";
3
+ export type ResponseMessage = AssistantModelMessage | ToolModelMessage;
3
4
  export interface RunAgentLoopOptions {
4
5
  /** Any AI SDK LanguageModel (OpenAI, Anthropic, Google, etc.) */
5
6
  model: LanguageModel;
6
7
  /** System message (instructions for the agent) */
7
8
  system: string;
8
- /** Current user message / action description */
9
- prompt: string;
9
+ /** Single user prompt (first turn). Ignored when `messages` is provided. */
10
+ prompt?: string;
11
+ /** Full conversation history (multi-turn). Takes precedence over `prompt`. */
12
+ messages?: ModelMessage[];
10
13
  /** Allowed component types from your registry */
11
14
  allowedTypes: string[];
12
15
  /** Session id injected into emitted events */
@@ -18,13 +21,17 @@ export interface RunAgentLoopOptions {
18
21
  /** Max tool-call steps before stopping (default 10) */
19
22
  maxSteps?: number;
20
23
  }
24
+ export interface RunAgentLoopResult {
25
+ /** Final assistant text (if any) */
26
+ text: string | null;
27
+ /** Response messages generated during this turn (assistant + tool messages) */
28
+ responseMessages: ResponseMessage[];
29
+ }
21
30
  /**
22
31
  * Runs an agent loop using the AI SDK's `generateText` with multi-step
23
32
  * tool calling. No manual loop, no JSON.parse, no message management.
24
33
  *
25
34
  * Works with any AI SDK-compatible model (OpenAI, Anthropic, Google, etc.).
26
- *
27
- * Returns the final assistant text (if any).
28
35
  */
29
- export declare function runAgentLoop(opts: RunAgentLoopOptions): Promise<string | null>;
36
+ export declare function runAgentLoop(opts: RunAgentLoopOptions): Promise<RunAgentLoopResult>;
30
37
  //# sourceMappingURL=run-agent.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"run-agent.d.ts","sourceRoot":"","sources":["../src/run-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,OAAO,EACb,MAAM,IAAI,CAAC;AACZ,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAG1D,MAAM,MAAM,eAAe,GAAG,qBAAqB,GAAG,gBAAgB,CAAC;AAEvE,MAAM,WAAW,mBAAmB;IAClC,iEAAiE;IACjE,KAAK,EAAE,aAAa,CAAC;IACrB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;IAC1B,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,MAAM,WAAW,kBAAkB;IACjC,oCAAoC;IACpC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,+EAA+E;IAC/E,gBAAgB,EAAE,eAAe,EAAE,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,kBAAkB,CAAC,CA6B7B"}
package/dist/run-agent.js CHANGED
@@ -1,26 +1,25 @@
1
- import { generateText, stepCountIs } from "ai";
1
+ import { generateText, stepCountIs, } from "ai";
2
2
  import { createUIEmitterTool, UI_EMITTER_TOOL_NAME } from "./tool.js";
3
3
  /**
4
4
  * Runs an agent loop using the AI SDK's `generateText` with multi-step
5
5
  * tool calling. No manual loop, no JSON.parse, no message management.
6
6
  *
7
7
  * Works with any AI SDK-compatible model (OpenAI, Anthropic, Google, etc.).
8
- *
9
- * Returns the final assistant text (if any).
10
8
  */
11
9
  export async function runAgentLoop(opts) {
12
- const { model, system, prompt, allowedTypes, sessionId, onUIEvent, extraTools = {}, maxSteps = 10, } = opts;
10
+ const { model, system, messages, prompt, allowedTypes, sessionId, onUIEvent, extraTools = {}, maxSteps = 10, } = opts;
13
11
  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;
12
+ const tools = {
13
+ [UI_EMITTER_TOOL_NAME]: uiTool,
14
+ ...extraTools,
15
+ };
16
+ const genOpts = messages
17
+ ? { model, system, messages, tools, stopWhen: stepCountIs(maxSteps) }
18
+ : { model, system, prompt: prompt, tools, stopWhen: stepCountIs(maxSteps) };
19
+ const result = await generateText(genOpts);
20
+ return {
21
+ text: result.text || null,
22
+ responseMessages: result.response.messages,
23
+ };
25
24
  }
26
25
  //# sourceMappingURL=run-agent.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"run-agent.js","sourceRoot":"","sources":["../src/run-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,WAAW,GAMZ,MAAM,IAAI,CAAC;AAEZ,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAgCtE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAyB;IAEzB,MAAM,EACJ,KAAK,EACL,MAAM,EACN,QAAQ,EACR,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;IAC3E,MAAM,KAAK,GAAG;QACZ,CAAC,oBAAoB,CAAC,EAAE,MAAM;QAC9B,GAAG,UAAU;KACd,CAAC;IAEF,MAAM,OAAO,GAAG,QAAQ;QACtB,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE;QACrE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;IAE/E,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;IAE3C,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI;QACzB,gBAAgB,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;KAC3C,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kibadist/agentui-ai",
3
- "version": "0.1.7",
3
+ "version": "0.2.0",
4
4
  "description": "AgentUI adapter for Vercel AI SDK — works with any provider (OpenAI, Anthropic, Google, etc.)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,8 +26,8 @@
26
26
  "dist"
27
27
  ],
28
28
  "dependencies": {
29
- "@kibadist/agentui-protocol": "0.1.6",
30
- "@kibadist/agentui-validate": "0.1.6"
29
+ "@kibadist/agentui-protocol": "0.1.7",
30
+ "@kibadist/agentui-validate": "0.1.7"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "ai": "^6.0.0",