@objectstack/service-ai 4.0.1 → 4.0.2

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.
Files changed (39) hide show
  1. package/.turbo/turbo-build.log +11 -11
  2. package/CHANGELOG.md +9 -0
  3. package/dist/index.cjs +1120 -66
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +316 -78
  6. package/dist/index.d.ts +316 -78
  7. package/dist/index.js +1105 -63
  8. package/dist/index.js.map +1 -1
  9. package/package.json +26 -4
  10. package/src/__tests__/ai-service.test.ts +248 -27
  11. package/src/__tests__/auth-and-toolcalling.test.ts +30 -28
  12. package/src/__tests__/chatbot-features.test.ts +229 -82
  13. package/src/__tests__/metadata-tools.test.ts +964 -0
  14. package/src/__tests__/objectql-conversation-service.test.ts +34 -16
  15. package/src/__tests__/vercel-stream-encoder.test.ts +263 -0
  16. package/src/adapters/index.ts +2 -0
  17. package/src/adapters/memory-adapter.ts +17 -9
  18. package/src/adapters/vercel-adapter.ts +148 -0
  19. package/src/agent-runtime.ts +27 -3
  20. package/src/agents/index.ts +1 -0
  21. package/src/agents/metadata-assistant-agent.ts +87 -0
  22. package/src/ai-service.ts +68 -36
  23. package/src/conversation/in-memory-conversation-service.ts +2 -2
  24. package/src/conversation/objectql-conversation-service.ts +67 -18
  25. package/src/index.ts +21 -2
  26. package/src/plugin.ts +166 -9
  27. package/src/routes/agent-routes.ts +26 -3
  28. package/src/routes/ai-routes.ts +156 -13
  29. package/src/stream/index.ts +3 -0
  30. package/src/stream/vercel-stream-encoder.ts +129 -0
  31. package/src/tools/add-field.tool.ts +70 -0
  32. package/src/tools/create-object.tool.ts +66 -0
  33. package/src/tools/delete-field.tool.ts +38 -0
  34. package/src/tools/describe-metadata-object.tool.ts +32 -0
  35. package/src/tools/index.ts +12 -1
  36. package/src/tools/list-metadata-objects.tool.ts +34 -0
  37. package/src/tools/metadata-tools.ts +430 -0
  38. package/src/tools/modify-field.tool.ts +44 -0
  39. package/src/tools/tool-registry.ts +32 -9
package/dist/index.d.cts CHANGED
@@ -1,6 +1,9 @@
1
- import { AIToolDefinition, AIToolCall, AIToolResult, IAIService, IAIConversationService, LLMAdapter, Logger, AIMessage, AIRequestOptions, AIResult, AIStreamEvent, ChatWithToolsOptions, AIConversation, IDataEngine, IMetadataService } from '@objectstack/spec/contracts';
1
+ import { AIToolDefinition, ToolCallPart, ToolResultPart, IAIService, IAIConversationService, LLMAdapter, Logger, ModelMessage, AIRequestOptions, AIResult, TextStreamPart, ToolSet, ChatWithToolsOptions, AIConversation, IDataEngine, IMetadataService } from '@objectstack/spec/contracts';
2
2
  export { LLMAdapter } from '@objectstack/spec/contracts';
3
3
  import { Plugin, PluginContext } from '@objectstack/core';
4
+ import { LanguageModelV2 } from '@ai-sdk/provider';
5
+ import { TextStreamPart as TextStreamPart$1, ToolSet as ToolSet$1 } from 'ai';
6
+ import { Tool } from '@objectstack/spec/ai';
4
7
  import { Agent } from '@objectstack/spec';
5
8
  import { z } from 'zod';
6
9
  import * as _objectstack_spec_data from '@objectstack/spec/data';
@@ -11,6 +14,13 @@ import * as _objectstack_spec_data from '@objectstack/spec/data';
11
14
  * Receives parsed arguments and returns the tool output as a string.
12
15
  */
13
16
  type ToolHandler = (args: Record<string, unknown>) => Promise<string> | string;
17
+ /**
18
+ * Extended ToolResultPart that carries an `isError` flag for internal
19
+ * error-tracking in the tool-call loop.
20
+ */
21
+ interface ToolExecutionResult extends ToolResultPart {
22
+ isError?: boolean;
23
+ }
14
24
  /**
15
25
  * ToolRegistry — Central registry for AI-callable tools.
16
26
  *
@@ -50,11 +60,11 @@ declare class ToolRegistry {
50
60
  /**
51
61
  * Execute a tool call and return the result.
52
62
  */
53
- execute(toolCall: AIToolCall): Promise<AIToolResult>;
63
+ execute(toolCall: ToolCallPart): Promise<ToolExecutionResult>;
54
64
  /**
55
65
  * Execute multiple tool calls in parallel.
56
66
  */
57
- executeAll(toolCalls: AIToolCall[]): Promise<AIToolResult[]>;
67
+ executeAll(toolCalls: ToolCallPart[]): Promise<ToolExecutionResult[]>;
58
68
  /**
59
69
  * Clear all registered tools.
60
70
  */
@@ -97,13 +107,15 @@ declare class AIService implements IAIService {
97
107
  constructor(config?: AIServiceConfig);
98
108
  /** The name of the active LLM adapter. */
99
109
  get adapterName(): string;
100
- chat(messages: AIMessage[], options?: AIRequestOptions): Promise<AIResult>;
110
+ chat(messages: ModelMessage[], options?: AIRequestOptions): Promise<AIResult>;
101
111
  complete(prompt: string, options?: AIRequestOptions): Promise<AIResult>;
102
- streamChat(messages: AIMessage[], options?: AIRequestOptions): AsyncIterable<AIStreamEvent>;
112
+ streamChat(messages: ModelMessage[], options?: AIRequestOptions): AsyncIterable<TextStreamPart<ToolSet>>;
103
113
  embed(input: string | string[], model?: string): Promise<number[][]>;
104
114
  listModels(): Promise<string[]>;
105
115
  /** Default maximum iterations for the tool call loop. */
106
116
  static readonly DEFAULT_MAX_ITERATIONS = 10;
117
+ /** Extract the text value from a ToolExecutionResult's output. */
118
+ private static extractOutputText;
107
119
  /**
108
120
  * Chat with automatic tool call resolution.
109
121
  *
@@ -115,7 +127,7 @@ declare class AIService implements IAIService {
115
127
  * 4. Repeats until the model produces a final text response or the
116
128
  * maximum number of iterations (`maxIterations`) is reached.
117
129
  */
118
- chatWithTools(messages: AIMessage[], options?: ChatWithToolsOptions): Promise<AIResult>;
130
+ chatWithTools(messages: ModelMessage[], options?: ChatWithToolsOptions): Promise<AIResult>;
119
131
  /**
120
132
  * Stream chat with automatic tool call resolution.
121
133
  *
@@ -123,7 +135,7 @@ declare class AIService implements IAIService {
123
135
  * requests tool calls during streaming, they are executed and the results
124
136
  * fed back until a final text stream is produced.
125
137
  */
126
- streamChatWithTools(messages: AIMessage[], options?: ChatWithToolsOptions): AsyncIterable<AIStreamEvent>;
138
+ streamChatWithTools(messages: ModelMessage[], options?: ChatWithToolsOptions): AsyncIterable<TextStreamPart<ToolSet>>;
127
139
  }
128
140
 
129
141
  /**
@@ -168,6 +180,19 @@ declare class AIServicePlugin implements Plugin {
168
180
  private service?;
169
181
  private readonly options;
170
182
  constructor(options?: AIServicePluginOptions);
183
+ /**
184
+ * Auto-detect LLM provider from environment variables.
185
+ *
186
+ * Priority order:
187
+ * 1. AI_GATEWAY_MODEL → Vercel AI Gateway
188
+ * 2. OPENAI_API_KEY → OpenAI
189
+ * 3. ANTHROPIC_API_KEY → Anthropic
190
+ * 4. GOOGLE_GENERATIVE_AI_API_KEY → Google
191
+ * 5. Fallback → MemoryLLMAdapter
192
+ *
193
+ * Returns the adapter and a description for logging.
194
+ */
195
+ private detectAdapter;
171
196
  init(ctx: PluginContext): Promise<void>;
172
197
  start(ctx: PluginContext): Promise<void>;
173
198
  destroy(): Promise<void>;
@@ -181,13 +206,81 @@ declare class AIServicePlugin implements Plugin {
181
206
  */
182
207
  declare class MemoryLLMAdapter implements LLMAdapter {
183
208
  readonly name = "memory";
184
- chat(messages: AIMessage[], options?: AIRequestOptions): Promise<AIResult>;
209
+ chat(messages: ModelMessage[], options?: AIRequestOptions): Promise<AIResult>;
185
210
  complete(prompt: string, options?: AIRequestOptions): Promise<AIResult>;
186
- streamChat(messages: AIMessage[], _options?: AIRequestOptions): AsyncIterable<AIStreamEvent>;
211
+ streamChat(messages: ModelMessage[], _options?: AIRequestOptions): AsyncIterable<TextStreamPart<ToolSet>>;
187
212
  embed(input: string | string[]): Promise<number[][]>;
188
213
  listModels(): Promise<string[]>;
189
214
  }
190
215
 
216
+ /**
217
+ * VercelLLMAdapter — Production LLM adapter powered by the Vercel AI SDK.
218
+ *
219
+ * Wraps `generateText` / `streamText` from the `ai` package, delegating to
220
+ * any Vercel AI SDK–compatible model provider (OpenAI, Anthropic, Google,
221
+ * Ollama, etc.).
222
+ *
223
+ * @example
224
+ * ```typescript
225
+ * import { openai } from '@ai-sdk/openai';
226
+ * import { VercelLLMAdapter } from '@objectstack/service-ai';
227
+ *
228
+ * const adapter = new VercelLLMAdapter({ model: openai('gpt-4o') });
229
+ * ```
230
+ */
231
+ declare class VercelLLMAdapter implements LLMAdapter {
232
+ readonly name = "vercel";
233
+ private readonly model;
234
+ constructor(config: VercelLLMAdapterConfig);
235
+ chat(messages: ModelMessage[], options?: AIRequestOptions): Promise<AIResult>;
236
+ complete(prompt: string, options?: AIRequestOptions): Promise<AIResult>;
237
+ streamChat(messages: ModelMessage[], options?: AIRequestOptions): AsyncIterable<TextStreamPart<ToolSet>>;
238
+ embed(_input: string | string[]): Promise<number[][]>;
239
+ listModels(): Promise<string[]>;
240
+ }
241
+ /**
242
+ * Configuration for the Vercel LLM adapter.
243
+ */
244
+ interface VercelLLMAdapterConfig {
245
+ /**
246
+ * A Vercel AI SDK–compatible language model instance.
247
+ *
248
+ * @example `openai('gpt-4o')` or `anthropic('claude-sonnet-4-20250514')`
249
+ */
250
+ model: LanguageModelV2;
251
+ }
252
+
253
+ /**
254
+ * Vercel AI SDK v6 — UI Message Stream Encoder
255
+ *
256
+ * Converts `AsyncIterable<TextStreamPart<ToolSet>>` (the internal ObjectStack
257
+ * streaming format) into the Vercel AI SDK v6 **UI Message Stream Protocol**.
258
+ *
259
+ * Wire format: Server-Sent Events (SSE) with JSON payloads.
260
+ * `data: {"type":"text-delta","id":"0","delta":"Hello"}\n\n`
261
+ *
262
+ * The client-side `DefaultChatTransport` from `ai` v6 uses
263
+ * `parseJsonEventStream` to parse these SSE events.
264
+ *
265
+ * @see https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol
266
+ */
267
+
268
+ /**
269
+ * Encode a single `TextStreamPart` event into SSE-formatted UI Message
270
+ * Stream chunk(s).
271
+ *
272
+ * Returns an empty string for event types that have no wire-format mapping.
273
+ */
274
+ declare function encodeStreamPart(part: TextStreamPart$1<ToolSet$1>): string;
275
+ /**
276
+ * Transform an `AsyncIterable<TextStreamPart>` into an `AsyncIterable<string>`
277
+ * where each yielded string is an SSE-formatted UI Message Stream chunk.
278
+ *
279
+ * Lifecycle order required by the client:
280
+ * start → start-step → text-start → text-delta* → text-end → finish-step → finish → [DONE]
281
+ */
282
+ declare function encodeVercelDataStream(events: AsyncIterable<TextStreamPart$1<ToolSet$1>>): AsyncIterable<string>;
283
+
191
284
  /**
192
285
  * InMemoryConversationService — Reference implementation of IAIConversationService.
193
286
  *
@@ -211,7 +304,7 @@ declare class InMemoryConversationService implements IAIConversationService {
211
304
  limit?: number;
212
305
  cursor?: string;
213
306
  }): Promise<AIConversation[]>;
214
- addMessage(conversationId: string, message: AIMessage): Promise<AIConversation>;
307
+ addMessage(conversationId: string, message: ModelMessage): Promise<AIConversation>;
215
308
  delete(conversationId: string): Promise<void>;
216
309
  /** Total number of stored conversations. */
217
310
  get size(): number;
@@ -245,7 +338,7 @@ declare class ObjectQLConversationService implements IAIConversationService {
245
338
  limit?: number;
246
339
  cursor?: string;
247
340
  }): Promise<AIConversation[]>;
248
- addMessage(conversationId: string, message: AIMessage): Promise<AIConversation>;
341
+ addMessage(conversationId: string, message: ModelMessage): Promise<AIConversation>;
249
342
  delete(conversationId: string): Promise<void>;
250
343
  /**
251
344
  * Safely parse a JSON string, returning `undefined` on failure.
@@ -256,7 +349,7 @@ declare class ObjectQLConversationService implements IAIConversationService {
256
349
  */
257
350
  private toConversation;
258
351
  /**
259
- * Map a database row to an AIMessage.
352
+ * Map a database row to a ModelMessage.
260
353
  */
261
354
  private toMessage;
262
355
  }
@@ -292,6 +385,158 @@ declare const DATA_TOOL_DEFINITIONS: AIToolDefinition[];
292
385
  */
293
386
  declare function registerDataTools(registry: ToolRegistry, context: DataToolContext): void;
294
387
 
388
+ /**
389
+ * create_object — AI Tool Metadata
390
+ *
391
+ * Creates a new data object (table) with schema validation.
392
+ * Validates snake_case naming for object and initial fields,
393
+ * checks for duplicates, and registers the object definition.
394
+ */
395
+ declare const createObjectTool: {
396
+ name: string;
397
+ label: string;
398
+ description: string;
399
+ parameters: Record<string, unknown>;
400
+ requiresConfirmation: boolean;
401
+ active: boolean;
402
+ builtIn: boolean;
403
+ category?: "flow" | "action" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
404
+ outputSchema?: Record<string, unknown> | undefined;
405
+ objectName?: string | undefined;
406
+ permissions?: string[] | undefined;
407
+ };
408
+
409
+ /**
410
+ * add_field — AI Tool Metadata
411
+ *
412
+ * Adds a new field (column) to an existing data object.
413
+ * Validates snake_case for objectName, field name, reference,
414
+ * and select option values before merging into the definition.
415
+ */
416
+ declare const addFieldTool: {
417
+ name: string;
418
+ label: string;
419
+ description: string;
420
+ parameters: Record<string, unknown>;
421
+ requiresConfirmation: boolean;
422
+ active: boolean;
423
+ builtIn: boolean;
424
+ category?: "flow" | "action" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
425
+ outputSchema?: Record<string, unknown> | undefined;
426
+ objectName?: string | undefined;
427
+ permissions?: string[] | undefined;
428
+ };
429
+
430
+ /**
431
+ * modify_field — AI Tool Metadata
432
+ *
433
+ * Modifies an existing field definition (label, type, required, default value, etc.)
434
+ * on a data object. Does not support renaming the field.
435
+ */
436
+ declare const modifyFieldTool: {
437
+ name: string;
438
+ label: string;
439
+ description: string;
440
+ parameters: Record<string, unknown>;
441
+ requiresConfirmation: boolean;
442
+ active: boolean;
443
+ builtIn: boolean;
444
+ category?: "flow" | "action" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
445
+ outputSchema?: Record<string, unknown> | undefined;
446
+ objectName?: string | undefined;
447
+ permissions?: string[] | undefined;
448
+ };
449
+
450
+ /**
451
+ * delete_field — AI Tool Metadata
452
+ *
453
+ * Removes a field (column) from an existing data object.
454
+ * This is a destructive operation.
455
+ */
456
+ declare const deleteFieldTool: {
457
+ name: string;
458
+ label: string;
459
+ description: string;
460
+ parameters: Record<string, unknown>;
461
+ requiresConfirmation: boolean;
462
+ active: boolean;
463
+ builtIn: boolean;
464
+ category?: "flow" | "action" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
465
+ outputSchema?: Record<string, unknown> | undefined;
466
+ objectName?: string | undefined;
467
+ permissions?: string[] | undefined;
468
+ };
469
+
470
+ /**
471
+ * list_metadata_objects — AI Tool Metadata
472
+ *
473
+ * Lists all registered metadata objects (tables) with optional filtering.
474
+ * Uses a unique name (`list_metadata_objects`) to avoid collision with
475
+ * the data-tools `list_objects` tool.
476
+ */
477
+ declare const listMetadataObjectsTool: {
478
+ name: string;
479
+ label: string;
480
+ description: string;
481
+ parameters: Record<string, unknown>;
482
+ requiresConfirmation: boolean;
483
+ active: boolean;
484
+ builtIn: boolean;
485
+ category?: "flow" | "action" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
486
+ outputSchema?: Record<string, unknown> | undefined;
487
+ objectName?: string | undefined;
488
+ permissions?: string[] | undefined;
489
+ };
490
+
491
+ /**
492
+ * describe_metadata_object — AI Tool Metadata
493
+ *
494
+ * Returns the full metadata schema of a data object including all
495
+ * fields, types, relationships, and configuration. Uses a unique name
496
+ * (`describe_metadata_object`) to avoid collision with the data-tools
497
+ * `describe_object` tool.
498
+ */
499
+ declare const describeMetadataObjectTool: {
500
+ name: string;
501
+ label: string;
502
+ description: string;
503
+ parameters: Record<string, unknown>;
504
+ requiresConfirmation: boolean;
505
+ active: boolean;
506
+ builtIn: boolean;
507
+ category?: "flow" | "action" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
508
+ outputSchema?: Record<string, unknown> | undefined;
509
+ objectName?: string | undefined;
510
+ permissions?: string[] | undefined;
511
+ };
512
+
513
+ /** All built-in metadata management tool definitions (Tool metadata). */
514
+ declare const METADATA_TOOL_DEFINITIONS: Tool[];
515
+ /**
516
+ * Services required by the metadata management tools.
517
+ *
518
+ * Provided by the kernel at `ai:ready` time and closed over
519
+ * by the handler functions so they stay framework-agnostic.
520
+ */
521
+ interface MetadataToolContext {
522
+ /** Metadata service for schema CRUD operations. */
523
+ metadataService: IMetadataService;
524
+ }
525
+ /**
526
+ * Register all built-in metadata management tools on the given {@link ToolRegistry}.
527
+ *
528
+ * Typically called from the `ai:ready` hook after the metadata service is available.
529
+ *
530
+ * @example
531
+ * ```ts
532
+ * ctx.hook('ai:ready', async (aiService) => {
533
+ * const metadataService = ctx.getService<IMetadataService>('metadata');
534
+ * registerMetadataTools(aiService.toolRegistry, { metadataService });
535
+ * });
536
+ * ```
537
+ */
538
+ declare function registerMetadataTools(registry: ToolRegistry, context: MetadataToolContext): void;
539
+
295
540
  /**
296
541
  * Context passed alongside a user message when chatting with an agent.
297
542
  *
@@ -320,6 +565,17 @@ interface AgentChatContext {
320
565
  declare class AgentRuntime {
321
566
  private readonly metadataService;
322
567
  constructor(metadataService: IMetadataService);
568
+ /**
569
+ * List all active agents registered in the metadata service.
570
+ *
571
+ * Returns a summary for each agent (name, label, role) suitable
572
+ * for populating an agent selector dropdown in the UI.
573
+ */
574
+ listAgents(): Promise<Array<{
575
+ name: string;
576
+ label: string;
577
+ role: string;
578
+ }>>;
323
579
  /**
324
580
  * Load and validate an agent definition by name.
325
581
  *
@@ -333,7 +589,7 @@ declare class AgentRuntime {
333
589
  * Build the system message(s) that should be prepended to the
334
590
  * conversation when chatting with the given agent.
335
591
  */
336
- buildSystemMessages(agent: Agent, context?: AgentChatContext): AIMessage[];
592
+ buildSystemMessages(agent: Agent, context?: AgentChatContext): ModelMessage[];
337
593
  /**
338
594
  * Derive {@link AIRequestOptions} from an agent definition.
339
595
  *
@@ -368,6 +624,27 @@ declare class AgentRuntime {
368
624
  */
369
625
  declare const DATA_CHAT_AGENT: Agent;
370
626
 
627
+ /**
628
+ * Built-in `metadata_assistant` agent definition.
629
+ *
630
+ * This agent powers AI-driven metadata management — users can create objects,
631
+ * add/modify/delete fields, and inspect schema definitions through natural
632
+ * language conversation.
633
+ *
634
+ * It is registered automatically by the AI service plugin alongside the
635
+ * `data_chat` agent when the metadata service is available.
636
+ *
637
+ * @example
638
+ * ```
639
+ * POST /api/v1/ai/agents/metadata_assistant/chat
640
+ * {
641
+ * "messages": [{ "role": "user", "content": "Create a contracts table with name, value, and status fields" }],
642
+ * "context": {}
643
+ * }
644
+ * ```
645
+ */
646
+ declare const METADATA_ASSISTANT_AGENT: Agent;
647
+
371
648
  /**
372
649
  * XState-inspired State Machine Protocol
373
650
  * Used to define strict business logic constraints and lifecycle management.
@@ -431,7 +708,7 @@ declare const AiConversationObject: Omit<{
431
708
  abstract: boolean;
432
709
  datasource: string;
433
710
  fields: Record<string, {
434
- type: "number" | "boolean" | "file" | "json" | "text" | "avatar" | "vector" | "date" | "tags" | "lookup" | "url" | "textarea" | "email" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "image" | "video" | "audio" | "formula" | "summary" | "autonumber" | "location" | "address" | "code" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress";
711
+ type: "number" | "boolean" | "file" | "text" | "json" | "code" | "avatar" | "vector" | "date" | "tags" | "lookup" | "url" | "textarea" | "email" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "image" | "video" | "audio" | "formula" | "summary" | "autonumber" | "location" | "address" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress";
435
712
  required: boolean;
436
713
  searchable: boolean;
437
714
  multiple: boolean;
@@ -615,7 +892,7 @@ declare const AiConversationObject: Omit<{
615
892
  } | undefined;
616
893
  versioning?: {
617
894
  enabled: boolean;
618
- strategy: "snapshot" | "delta" | "event-sourcing";
895
+ strategy: "delta" | "snapshot" | "event-sourcing";
619
896
  versionField: string;
620
897
  retentionDays?: number | undefined;
621
898
  } | undefined;
@@ -691,11 +968,7 @@ declare const AiConversationObject: Omit<{
691
968
  keyPrefix?: string | undefined;
692
969
  actions?: {
693
970
  name: string;
694
- label: string | {
695
- key: string;
696
- defaultValue?: string | undefined;
697
- params?: Record<string, string | number | boolean> | undefined;
698
- };
971
+ label: string;
699
972
  type: "url" | "script" | "modal" | "flow" | "api";
700
973
  refreshAfter: boolean;
701
974
  objectName?: string | undefined;
@@ -706,44 +979,24 @@ declare const AiConversationObject: Omit<{
706
979
  execute?: string | undefined;
707
980
  params?: {
708
981
  name: string;
709
- label: string | {
710
- key: string;
711
- defaultValue?: string | undefined;
712
- params?: Record<string, string | number | boolean> | undefined;
713
- };
982
+ label: string;
714
983
  type: "number" | "boolean" | "date" | "lookup" | "file" | "url" | "json" | "text" | "textarea" | "email" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "image" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "location" | "address" | "code" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress" | "tags" | "vector";
715
984
  required: boolean;
716
985
  options?: {
717
- label: string | {
718
- key: string;
719
- defaultValue?: string | undefined;
720
- params?: Record<string, string | number | boolean> | undefined;
721
- };
986
+ label: string;
722
987
  value: string;
723
988
  }[] | undefined;
724
989
  }[] | undefined;
725
990
  variant?: "link" | "primary" | "secondary" | "danger" | "ghost" | undefined;
726
- confirmText?: string | {
727
- key: string;
728
- defaultValue?: string | undefined;
729
- params?: Record<string, string | number | boolean> | undefined;
730
- } | undefined;
731
- successMessage?: string | {
732
- key: string;
733
- defaultValue?: string | undefined;
734
- params?: Record<string, string | number | boolean> | undefined;
735
- } | undefined;
991
+ confirmText?: string | undefined;
992
+ successMessage?: string | undefined;
736
993
  visible?: string | undefined;
737
994
  disabled?: string | boolean | undefined;
738
995
  shortcut?: string | undefined;
739
996
  bulkEnabled?: boolean | undefined;
740
997
  timeout?: number | undefined;
741
998
  aria?: {
742
- ariaLabel?: string | {
743
- key: string;
744
- defaultValue?: string | undefined;
745
- params?: Record<string, string | number | boolean> | undefined;
746
- } | undefined;
999
+ ariaLabel?: string | undefined;
747
1000
  ariaDescribedBy?: string | undefined;
748
1001
  role?: string | undefined;
749
1002
  } | undefined;
@@ -1896,7 +2149,7 @@ declare const AiMessageObject: Omit<{
1896
2149
  abstract: boolean;
1897
2150
  datasource: string;
1898
2151
  fields: Record<string, {
1899
- type: "number" | "boolean" | "file" | "json" | "text" | "avatar" | "vector" | "date" | "tags" | "lookup" | "url" | "textarea" | "email" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "image" | "video" | "audio" | "formula" | "summary" | "autonumber" | "location" | "address" | "code" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress";
2152
+ type: "number" | "boolean" | "file" | "text" | "json" | "code" | "avatar" | "vector" | "date" | "tags" | "lookup" | "url" | "textarea" | "email" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "image" | "video" | "audio" | "formula" | "summary" | "autonumber" | "location" | "address" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress";
1900
2153
  required: boolean;
1901
2154
  searchable: boolean;
1902
2155
  multiple: boolean;
@@ -2080,7 +2333,7 @@ declare const AiMessageObject: Omit<{
2080
2333
  } | undefined;
2081
2334
  versioning?: {
2082
2335
  enabled: boolean;
2083
- strategy: "snapshot" | "delta" | "event-sourcing";
2336
+ strategy: "delta" | "snapshot" | "event-sourcing";
2084
2337
  versionField: string;
2085
2338
  retentionDays?: number | undefined;
2086
2339
  } | undefined;
@@ -2156,11 +2409,7 @@ declare const AiMessageObject: Omit<{
2156
2409
  keyPrefix?: string | undefined;
2157
2410
  actions?: {
2158
2411
  name: string;
2159
- label: string | {
2160
- key: string;
2161
- defaultValue?: string | undefined;
2162
- params?: Record<string, string | number | boolean> | undefined;
2163
- };
2412
+ label: string;
2164
2413
  type: "url" | "script" | "modal" | "flow" | "api";
2165
2414
  refreshAfter: boolean;
2166
2415
  objectName?: string | undefined;
@@ -2171,44 +2420,24 @@ declare const AiMessageObject: Omit<{
2171
2420
  execute?: string | undefined;
2172
2421
  params?: {
2173
2422
  name: string;
2174
- label: string | {
2175
- key: string;
2176
- defaultValue?: string | undefined;
2177
- params?: Record<string, string | number | boolean> | undefined;
2178
- };
2423
+ label: string;
2179
2424
  type: "number" | "boolean" | "date" | "lookup" | "file" | "url" | "json" | "text" | "textarea" | "email" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "image" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "location" | "address" | "code" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress" | "tags" | "vector";
2180
2425
  required: boolean;
2181
2426
  options?: {
2182
- label: string | {
2183
- key: string;
2184
- defaultValue?: string | undefined;
2185
- params?: Record<string, string | number | boolean> | undefined;
2186
- };
2427
+ label: string;
2187
2428
  value: string;
2188
2429
  }[] | undefined;
2189
2430
  }[] | undefined;
2190
2431
  variant?: "link" | "primary" | "secondary" | "danger" | "ghost" | undefined;
2191
- confirmText?: string | {
2192
- key: string;
2193
- defaultValue?: string | undefined;
2194
- params?: Record<string, string | number | boolean> | undefined;
2195
- } | undefined;
2196
- successMessage?: string | {
2197
- key: string;
2198
- defaultValue?: string | undefined;
2199
- params?: Record<string, string | number | boolean> | undefined;
2200
- } | undefined;
2432
+ confirmText?: string | undefined;
2433
+ successMessage?: string | undefined;
2201
2434
  visible?: string | undefined;
2202
2435
  disabled?: string | boolean | undefined;
2203
2436
  shortcut?: string | undefined;
2204
2437
  bulkEnabled?: boolean | undefined;
2205
2438
  timeout?: number | undefined;
2206
2439
  aria?: {
2207
- ariaLabel?: string | {
2208
- key: string;
2209
- defaultValue?: string | undefined;
2210
- params?: Record<string, string | number | boolean> | undefined;
2211
- } | undefined;
2440
+ ariaLabel?: string | undefined;
2212
2441
  ariaDescribedBy?: string | undefined;
2213
2442
  role?: string | undefined;
2214
2443
  } | undefined;
@@ -3401,6 +3630,14 @@ interface RouteResponse {
3401
3630
  stream?: boolean;
3402
3631
  /** Async iterable of SSE events (when stream=true) */
3403
3632
  events?: AsyncIterable<unknown>;
3633
+ /**
3634
+ * When `true`, the HTTP server layer should encode the `events` iterable
3635
+ * using the Vercel AI Data Stream Protocol frame format (`0:`, `9:`, `d:`, …)
3636
+ * instead of generic SSE `data:` lines.
3637
+ *
3638
+ * @see https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol
3639
+ */
3640
+ vercelDataStream?: boolean;
3404
3641
  }
3405
3642
  /**
3406
3643
  * Build the standard AI REST/SSE routes.
@@ -3428,8 +3665,9 @@ declare function buildAIRoutes(aiService: IAIService, conversationService: IAICo
3428
3665
  *
3429
3666
  * | Method | Path | Description |
3430
3667
  * |:---|:---|:---|
3668
+ * | GET | /api/v1/ai/agents | List all active agents |
3431
3669
  * | POST | /api/v1/ai/agents/:agentName/chat | Chat with a specific agent |
3432
3670
  */
3433
3671
  declare function buildAgentRoutes(aiService: AIService, agentRuntime: AgentRuntime, logger: Logger): RouteDefinition[];
3434
3672
 
3435
- export { AIService, type AIServiceConfig, AIServicePlugin, type AIServicePluginOptions, type AgentChatContext, AgentRuntime, AiConversationObject, AiMessageObject, DATA_CHAT_AGENT, DATA_TOOL_DEFINITIONS, type DataToolContext, InMemoryConversationService, MemoryLLMAdapter, ObjectQLConversationService, type RouteDefinition, type RouteRequest, type RouteResponse, type RouteUserContext, type ToolHandler, ToolRegistry, buildAIRoutes, buildAgentRoutes, registerDataTools };
3673
+ export { AIService, type AIServiceConfig, AIServicePlugin, type AIServicePluginOptions, type AgentChatContext, AgentRuntime, AiConversationObject, AiMessageObject, DATA_CHAT_AGENT, DATA_TOOL_DEFINITIONS, type DataToolContext, InMemoryConversationService, METADATA_ASSISTANT_AGENT, METADATA_TOOL_DEFINITIONS, MemoryLLMAdapter, type MetadataToolContext, ObjectQLConversationService, type RouteDefinition, type RouteRequest, type RouteResponse, type RouteUserContext, type ToolExecutionResult, type ToolHandler, ToolRegistry, VercelLLMAdapter, type VercelLLMAdapterConfig, addFieldTool, buildAIRoutes, buildAgentRoutes, createObjectTool, deleteFieldTool, describeMetadataObjectTool, encodeStreamPart, encodeVercelDataStream, listMetadataObjectsTool, modifyFieldTool, registerDataTools, registerMetadataTools };