@objectstack/service-ai 4.0.2 → 4.0.3
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +8 -0
- package/dist/index.cjs +1869 -1646
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -27
- package/dist/index.d.ts +32 -27
- package/dist/index.js +2135 -1906
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/__tests__/ai-service.test.ts +13 -1
- package/src/__tests__/auth-and-toolcalling.test.ts +51 -1
- package/src/__tests__/chatbot-features.test.ts +172 -24
- package/src/__tests__/metadata-tools.test.ts +35 -29
- package/src/__tests__/tool-routes.test.ts +191 -0
- package/src/__tests__/vercel-stream-encoder.test.ts +47 -0
- package/src/agents/metadata-assistant-agent.ts +4 -4
- package/src/ai-service.ts +7 -0
- package/src/index.ts +3 -2
- package/src/plugin.ts +83 -33
- package/src/routes/agent-routes.ts +43 -10
- package/src/routes/ai-routes.ts +3 -67
- package/src/routes/index.ts +1 -0
- package/src/routes/message-utils.ts +90 -0
- package/src/routes/tool-routes.ts +142 -0
- package/src/stream/vercel-stream-encoder.ts +24 -0
- package/src/tools/data-tools.ts +4 -101
- package/src/tools/describe-object.tool.ts +31 -0
- package/src/tools/index.ts +2 -2
- package/src/tools/{list-metadata-objects.tool.ts → list-objects.tool.ts} +9 -9
- package/src/tools/metadata-tools.ts +8 -8
- package/src/tools/describe-metadata-object.tool.ts +0 -32
package/dist/index.d.cts
CHANGED
|
@@ -363,23 +363,19 @@ declare class ObjectQLConversationService implements IAIConversationService {
|
|
|
363
363
|
interface DataToolContext {
|
|
364
364
|
/** ObjectQL data engine for record-level operations. */
|
|
365
365
|
dataEngine: IDataEngine;
|
|
366
|
-
/** Metadata service for schema/object introspection. */
|
|
367
|
-
metadataService: IMetadataService;
|
|
368
366
|
}
|
|
369
|
-
/** All built-in data
|
|
367
|
+
/** All built-in data tools definitions. */
|
|
370
368
|
declare const DATA_TOOL_DEFINITIONS: AIToolDefinition[];
|
|
371
369
|
/**
|
|
372
370
|
* Register all built-in data tools on the given {@link ToolRegistry}.
|
|
373
371
|
*
|
|
374
|
-
* Typically called from the `ai:ready` hook after
|
|
375
|
-
* and metadata service are available.
|
|
372
|
+
* Typically called from the `ai:ready` hook after the data engine is available.
|
|
376
373
|
*
|
|
377
374
|
* @example
|
|
378
375
|
* ```ts
|
|
379
376
|
* ctx.hook('ai:ready', async (aiService) => {
|
|
380
377
|
* const dataEngine = ctx.getService<IDataEngine>('data');
|
|
381
|
-
*
|
|
382
|
-
* registerDataTools(aiService.toolRegistry, { dataEngine, metadataService });
|
|
378
|
+
* registerDataTools(aiService.toolRegistry, { dataEngine });
|
|
383
379
|
* });
|
|
384
380
|
* ```
|
|
385
381
|
*/
|
|
@@ -400,7 +396,7 @@ declare const createObjectTool: {
|
|
|
400
396
|
requiresConfirmation: boolean;
|
|
401
397
|
active: boolean;
|
|
402
398
|
builtIn: boolean;
|
|
403
|
-
category?: "
|
|
399
|
+
category?: "action" | "flow" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
|
|
404
400
|
outputSchema?: Record<string, unknown> | undefined;
|
|
405
401
|
objectName?: string | undefined;
|
|
406
402
|
permissions?: string[] | undefined;
|
|
@@ -421,7 +417,7 @@ declare const addFieldTool: {
|
|
|
421
417
|
requiresConfirmation: boolean;
|
|
422
418
|
active: boolean;
|
|
423
419
|
builtIn: boolean;
|
|
424
|
-
category?: "
|
|
420
|
+
category?: "action" | "flow" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
|
|
425
421
|
outputSchema?: Record<string, unknown> | undefined;
|
|
426
422
|
objectName?: string | undefined;
|
|
427
423
|
permissions?: string[] | undefined;
|
|
@@ -441,7 +437,7 @@ declare const modifyFieldTool: {
|
|
|
441
437
|
requiresConfirmation: boolean;
|
|
442
438
|
active: boolean;
|
|
443
439
|
builtIn: boolean;
|
|
444
|
-
category?: "
|
|
440
|
+
category?: "action" | "flow" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
|
|
445
441
|
outputSchema?: Record<string, unknown> | undefined;
|
|
446
442
|
objectName?: string | undefined;
|
|
447
443
|
permissions?: string[] | undefined;
|
|
@@ -461,20 +457,20 @@ declare const deleteFieldTool: {
|
|
|
461
457
|
requiresConfirmation: boolean;
|
|
462
458
|
active: boolean;
|
|
463
459
|
builtIn: boolean;
|
|
464
|
-
category?: "
|
|
460
|
+
category?: "action" | "flow" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
|
|
465
461
|
outputSchema?: Record<string, unknown> | undefined;
|
|
466
462
|
objectName?: string | undefined;
|
|
467
463
|
permissions?: string[] | undefined;
|
|
468
464
|
};
|
|
469
465
|
|
|
470
466
|
/**
|
|
471
|
-
*
|
|
467
|
+
* list_objects — AI Tool Metadata
|
|
472
468
|
*
|
|
473
|
-
* Lists all registered
|
|
474
|
-
*
|
|
475
|
-
*
|
|
469
|
+
* Lists all registered data objects (tables) with optional filtering
|
|
470
|
+
* and field summaries. This is the single, unified tool for listing
|
|
471
|
+
* objects — used by both data_chat and metadata_assistant agents.
|
|
476
472
|
*/
|
|
477
|
-
declare const
|
|
473
|
+
declare const listObjectsTool: {
|
|
478
474
|
name: string;
|
|
479
475
|
label: string;
|
|
480
476
|
description: string;
|
|
@@ -482,21 +478,20 @@ declare const listMetadataObjectsTool: {
|
|
|
482
478
|
requiresConfirmation: boolean;
|
|
483
479
|
active: boolean;
|
|
484
480
|
builtIn: boolean;
|
|
485
|
-
category?: "
|
|
481
|
+
category?: "action" | "flow" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
|
|
486
482
|
outputSchema?: Record<string, unknown> | undefined;
|
|
487
483
|
objectName?: string | undefined;
|
|
488
484
|
permissions?: string[] | undefined;
|
|
489
485
|
};
|
|
490
486
|
|
|
491
487
|
/**
|
|
492
|
-
*
|
|
488
|
+
* describe_object — AI Tool Metadata
|
|
493
489
|
*
|
|
494
|
-
* Returns the full
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
* `describe_object` tool.
|
|
490
|
+
* Returns the full schema of a data object including all fields, types,
|
|
491
|
+
* relationships, and configuration. This is the single, unified tool for
|
|
492
|
+
* describing objects — used by both data_chat and metadata_assistant agents.
|
|
498
493
|
*/
|
|
499
|
-
declare const
|
|
494
|
+
declare const describeObjectTool: {
|
|
500
495
|
name: string;
|
|
501
496
|
label: string;
|
|
502
497
|
description: string;
|
|
@@ -504,7 +499,7 @@ declare const describeMetadataObjectTool: {
|
|
|
504
499
|
requiresConfirmation: boolean;
|
|
505
500
|
active: boolean;
|
|
506
501
|
builtIn: boolean;
|
|
507
|
-
category?: "
|
|
502
|
+
category?: "action" | "flow" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
|
|
508
503
|
outputSchema?: Record<string, unknown> | undefined;
|
|
509
504
|
objectName?: string | undefined;
|
|
510
505
|
permissions?: string[] | undefined;
|
|
@@ -969,7 +964,7 @@ declare const AiConversationObject: Omit<{
|
|
|
969
964
|
actions?: {
|
|
970
965
|
name: string;
|
|
971
966
|
label: string;
|
|
972
|
-
type: "url" | "
|
|
967
|
+
type: "url" | "flow" | "api" | "script" | "modal";
|
|
973
968
|
refreshAfter: boolean;
|
|
974
969
|
objectName?: string | undefined;
|
|
975
970
|
icon?: string | undefined;
|
|
@@ -2410,7 +2405,7 @@ declare const AiMessageObject: Omit<{
|
|
|
2410
2405
|
actions?: {
|
|
2411
2406
|
name: string;
|
|
2412
2407
|
label: string;
|
|
2413
|
-
type: "url" | "
|
|
2408
|
+
type: "url" | "flow" | "api" | "script" | "modal";
|
|
2414
2409
|
refreshAfter: boolean;
|
|
2415
2410
|
objectName?: string | undefined;
|
|
2416
2411
|
icon?: string | undefined;
|
|
@@ -3670,4 +3665,14 @@ declare function buildAIRoutes(aiService: IAIService, conversationService: IAICo
|
|
|
3670
3665
|
*/
|
|
3671
3666
|
declare function buildAgentRoutes(aiService: AIService, agentRuntime: AgentRuntime, logger: Logger): RouteDefinition[];
|
|
3672
3667
|
|
|
3673
|
-
|
|
3668
|
+
/**
|
|
3669
|
+
* Build tool-specific REST routes.
|
|
3670
|
+
*
|
|
3671
|
+
* | Method | Path | Description |
|
|
3672
|
+
* |:---|:---|:---|
|
|
3673
|
+
* | GET | /api/v1/ai/tools | List all registered tools |
|
|
3674
|
+
* | POST | /api/v1/ai/tools/:toolName/execute | Execute a tool with parameters |
|
|
3675
|
+
*/
|
|
3676
|
+
declare function buildToolRoutes(aiService: AIService, logger: Logger): RouteDefinition[];
|
|
3677
|
+
|
|
3678
|
+
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, buildToolRoutes, createObjectTool, deleteFieldTool, describeObjectTool, encodeStreamPart, encodeVercelDataStream, listObjectsTool, modifyFieldTool, registerDataTools, registerMetadataTools };
|
package/dist/index.d.ts
CHANGED
|
@@ -363,23 +363,19 @@ declare class ObjectQLConversationService implements IAIConversationService {
|
|
|
363
363
|
interface DataToolContext {
|
|
364
364
|
/** ObjectQL data engine for record-level operations. */
|
|
365
365
|
dataEngine: IDataEngine;
|
|
366
|
-
/** Metadata service for schema/object introspection. */
|
|
367
|
-
metadataService: IMetadataService;
|
|
368
366
|
}
|
|
369
|
-
/** All built-in data
|
|
367
|
+
/** All built-in data tools definitions. */
|
|
370
368
|
declare const DATA_TOOL_DEFINITIONS: AIToolDefinition[];
|
|
371
369
|
/**
|
|
372
370
|
* Register all built-in data tools on the given {@link ToolRegistry}.
|
|
373
371
|
*
|
|
374
|
-
* Typically called from the `ai:ready` hook after
|
|
375
|
-
* and metadata service are available.
|
|
372
|
+
* Typically called from the `ai:ready` hook after the data engine is available.
|
|
376
373
|
*
|
|
377
374
|
* @example
|
|
378
375
|
* ```ts
|
|
379
376
|
* ctx.hook('ai:ready', async (aiService) => {
|
|
380
377
|
* const dataEngine = ctx.getService<IDataEngine>('data');
|
|
381
|
-
*
|
|
382
|
-
* registerDataTools(aiService.toolRegistry, { dataEngine, metadataService });
|
|
378
|
+
* registerDataTools(aiService.toolRegistry, { dataEngine });
|
|
383
379
|
* });
|
|
384
380
|
* ```
|
|
385
381
|
*/
|
|
@@ -400,7 +396,7 @@ declare const createObjectTool: {
|
|
|
400
396
|
requiresConfirmation: boolean;
|
|
401
397
|
active: boolean;
|
|
402
398
|
builtIn: boolean;
|
|
403
|
-
category?: "
|
|
399
|
+
category?: "action" | "flow" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
|
|
404
400
|
outputSchema?: Record<string, unknown> | undefined;
|
|
405
401
|
objectName?: string | undefined;
|
|
406
402
|
permissions?: string[] | undefined;
|
|
@@ -421,7 +417,7 @@ declare const addFieldTool: {
|
|
|
421
417
|
requiresConfirmation: boolean;
|
|
422
418
|
active: boolean;
|
|
423
419
|
builtIn: boolean;
|
|
424
|
-
category?: "
|
|
420
|
+
category?: "action" | "flow" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
|
|
425
421
|
outputSchema?: Record<string, unknown> | undefined;
|
|
426
422
|
objectName?: string | undefined;
|
|
427
423
|
permissions?: string[] | undefined;
|
|
@@ -441,7 +437,7 @@ declare const modifyFieldTool: {
|
|
|
441
437
|
requiresConfirmation: boolean;
|
|
442
438
|
active: boolean;
|
|
443
439
|
builtIn: boolean;
|
|
444
|
-
category?: "
|
|
440
|
+
category?: "action" | "flow" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
|
|
445
441
|
outputSchema?: Record<string, unknown> | undefined;
|
|
446
442
|
objectName?: string | undefined;
|
|
447
443
|
permissions?: string[] | undefined;
|
|
@@ -461,20 +457,20 @@ declare const deleteFieldTool: {
|
|
|
461
457
|
requiresConfirmation: boolean;
|
|
462
458
|
active: boolean;
|
|
463
459
|
builtIn: boolean;
|
|
464
|
-
category?: "
|
|
460
|
+
category?: "action" | "flow" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
|
|
465
461
|
outputSchema?: Record<string, unknown> | undefined;
|
|
466
462
|
objectName?: string | undefined;
|
|
467
463
|
permissions?: string[] | undefined;
|
|
468
464
|
};
|
|
469
465
|
|
|
470
466
|
/**
|
|
471
|
-
*
|
|
467
|
+
* list_objects — AI Tool Metadata
|
|
472
468
|
*
|
|
473
|
-
* Lists all registered
|
|
474
|
-
*
|
|
475
|
-
*
|
|
469
|
+
* Lists all registered data objects (tables) with optional filtering
|
|
470
|
+
* and field summaries. This is the single, unified tool for listing
|
|
471
|
+
* objects — used by both data_chat and metadata_assistant agents.
|
|
476
472
|
*/
|
|
477
|
-
declare const
|
|
473
|
+
declare const listObjectsTool: {
|
|
478
474
|
name: string;
|
|
479
475
|
label: string;
|
|
480
476
|
description: string;
|
|
@@ -482,21 +478,20 @@ declare const listMetadataObjectsTool: {
|
|
|
482
478
|
requiresConfirmation: boolean;
|
|
483
479
|
active: boolean;
|
|
484
480
|
builtIn: boolean;
|
|
485
|
-
category?: "
|
|
481
|
+
category?: "action" | "flow" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
|
|
486
482
|
outputSchema?: Record<string, unknown> | undefined;
|
|
487
483
|
objectName?: string | undefined;
|
|
488
484
|
permissions?: string[] | undefined;
|
|
489
485
|
};
|
|
490
486
|
|
|
491
487
|
/**
|
|
492
|
-
*
|
|
488
|
+
* describe_object — AI Tool Metadata
|
|
493
489
|
*
|
|
494
|
-
* Returns the full
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
* `describe_object` tool.
|
|
490
|
+
* Returns the full schema of a data object including all fields, types,
|
|
491
|
+
* relationships, and configuration. This is the single, unified tool for
|
|
492
|
+
* describing objects — used by both data_chat and metadata_assistant agents.
|
|
498
493
|
*/
|
|
499
|
-
declare const
|
|
494
|
+
declare const describeObjectTool: {
|
|
500
495
|
name: string;
|
|
501
496
|
label: string;
|
|
502
497
|
description: string;
|
|
@@ -504,7 +499,7 @@ declare const describeMetadataObjectTool: {
|
|
|
504
499
|
requiresConfirmation: boolean;
|
|
505
500
|
active: boolean;
|
|
506
501
|
builtIn: boolean;
|
|
507
|
-
category?: "
|
|
502
|
+
category?: "action" | "flow" | "vector_search" | "data" | "utility" | "integration" | "analytics" | undefined;
|
|
508
503
|
outputSchema?: Record<string, unknown> | undefined;
|
|
509
504
|
objectName?: string | undefined;
|
|
510
505
|
permissions?: string[] | undefined;
|
|
@@ -969,7 +964,7 @@ declare const AiConversationObject: Omit<{
|
|
|
969
964
|
actions?: {
|
|
970
965
|
name: string;
|
|
971
966
|
label: string;
|
|
972
|
-
type: "url" | "
|
|
967
|
+
type: "url" | "flow" | "api" | "script" | "modal";
|
|
973
968
|
refreshAfter: boolean;
|
|
974
969
|
objectName?: string | undefined;
|
|
975
970
|
icon?: string | undefined;
|
|
@@ -2410,7 +2405,7 @@ declare const AiMessageObject: Omit<{
|
|
|
2410
2405
|
actions?: {
|
|
2411
2406
|
name: string;
|
|
2412
2407
|
label: string;
|
|
2413
|
-
type: "url" | "
|
|
2408
|
+
type: "url" | "flow" | "api" | "script" | "modal";
|
|
2414
2409
|
refreshAfter: boolean;
|
|
2415
2410
|
objectName?: string | undefined;
|
|
2416
2411
|
icon?: string | undefined;
|
|
@@ -3670,4 +3665,14 @@ declare function buildAIRoutes(aiService: IAIService, conversationService: IAICo
|
|
|
3670
3665
|
*/
|
|
3671
3666
|
declare function buildAgentRoutes(aiService: AIService, agentRuntime: AgentRuntime, logger: Logger): RouteDefinition[];
|
|
3672
3667
|
|
|
3673
|
-
|
|
3668
|
+
/**
|
|
3669
|
+
* Build tool-specific REST routes.
|
|
3670
|
+
*
|
|
3671
|
+
* | Method | Path | Description |
|
|
3672
|
+
* |:---|:---|:---|
|
|
3673
|
+
* | GET | /api/v1/ai/tools | List all registered tools |
|
|
3674
|
+
* | POST | /api/v1/ai/tools/:toolName/execute | Execute a tool with parameters |
|
|
3675
|
+
*/
|
|
3676
|
+
declare function buildToolRoutes(aiService: AIService, logger: Logger): RouteDefinition[];
|
|
3677
|
+
|
|
3678
|
+
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, buildToolRoutes, createObjectTool, deleteFieldTool, describeObjectTool, encodeStreamPart, encodeVercelDataStream, listObjectsTool, modifyFieldTool, registerDataTools, registerMetadataTools };
|