@sqlrooms/ai 0.29.0-rc.0 → 0.29.0-rc.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.
package/README.md CHANGED
@@ -67,7 +67,9 @@ import {Chat} from '@sqlrooms/ai';
67
67
  import {useRoomStore} from './store';
68
68
 
69
69
  function AiPanel() {
70
- const updateProvider = useRoomStore((state) => state.aiSettings.updateProvider);
70
+ const updateProvider = useRoomStore(
71
+ (state) => state.aiSettings.updateProvider,
72
+ );
71
73
 
72
74
  return (
73
75
  <Chat>
@@ -93,7 +95,11 @@ function AiPanel() {
93
95
 
94
96
  ```tsx
95
97
  import {z} from 'zod';
96
- import {createAiSlice, createDefaultAiInstructions, createDefaultAiTools} from '@sqlrooms/ai';
98
+ import {
99
+ createAiSlice,
100
+ createDefaultAiInstructions,
101
+ createDefaultAiTools,
102
+ } from '@sqlrooms/ai';
97
103
 
98
104
  // inside createRoomStore(...):
99
105
  createAiSlice({
package/dist/index.d.ts CHANGED
@@ -2,21 +2,21 @@
2
2
  * {@include ../README.md}
3
3
  * @packageDocumentation
4
4
  */
5
- export { QueryToolResult } from './tools/query/QueryToolResult';
6
- export { QueryToolParameters, createQueryTool, getQuerySummary, type QueryToolLlmResult, type QueryToolAdditionalData, type QueryToolOptions, } from './tools/query/queryTool';
5
+ export { QueryToolResult, createQueryToolRenderer, type QueryToolRendererOptions, } from './tools/query/QueryToolResult';
6
+ export { QueryToolParameters, createQueryTool, getQuerySummary, type QueryToolOutput, type QueryToolOptions, } from './tools/query/queryTool';
7
7
  export { createCommandTools, ExecuteCommandToolParameters, ListCommandsToolParameters, } from './tools/commandTools';
8
- export type { CommandToolDescriptor, CommandToolsOptions, ExecuteCommandToolLlmResult, ListCommandsToolLlmResult, } from './tools/commandTools';
9
- export { createDefaultAiTools } from './tools/defaultTools';
10
- export type { DefaultToolsOptions } from './tools/defaultTools';
8
+ export type { CommandToolDescriptor, CommandToolsOptions, DefaultCommandTools, ExecuteCommandToolLlmResult, ListCommandsToolLlmResult, } from './tools/commandTools';
9
+ export { createDefaultAiTools, createDefaultAiToolRenderers, } from './tools/defaultTools';
10
+ export type { DefaultToolsOptions, DefaultAiToolRenderers, } from './tools/defaultTools';
11
11
  export { createDefaultAiInstructions, formatTablesForLLM, } from './tools/defaultInstructions';
12
12
  export { createAiSlice, useStoreWithAi } from '@sqlrooms/ai-core';
13
13
  export type { AiSliceState } from '@sqlrooms/ai-core';
14
14
  export { useScrollToBottom } from '@sqlrooms/ai-core';
15
15
  export { AiThinkingDots } from '@sqlrooms/ai-core';
16
16
  export { cleanupPendingAnalysisResults, ToolAbortError } from '@sqlrooms/ai-core';
17
- export { convertToAiSDKTools, fixIncompleteToolCalls } from '@sqlrooms/ai-core';
18
- export { processAgentStream, updateAgentToolCallData } from '@sqlrooms/ai-core';
19
- export type { AgentStreamResult, UIMessageChunk, AgentToolCall, AgentToolCallAdditionalData, } from '@sqlrooms/ai-core';
17
+ export { fixIncompleteToolCalls } from '@sqlrooms/ai-core';
18
+ export { streamSubAgent, updateAgentToolCallData } from '@sqlrooms/ai-core';
19
+ export type { AddToolOutput, AgentStreamOutput, AgentToolCall, AgentToolCallAdditionalData, ToolRenderers, ToolRenderer, ToolRendererProps, ToolRendererRegistry, StoredTool, StoredToolSet, AiSliceOptions, } from '@sqlrooms/ai-core';
20
20
  export { AnalysisResultsContainer } from '@sqlrooms/ai-core';
21
21
  export { AnalysisResult } from '@sqlrooms/ai-core';
22
22
  export { ErrorMessage } from '@sqlrooms/ai-core';
@@ -32,7 +32,7 @@ export { SessionTitle } from '@sqlrooms/ai-core';
32
32
  export type { SessionType } from '@sqlrooms/ai-core';
33
33
  export { ToolErrorMessage } from '@sqlrooms/ai-core';
34
34
  export { ToolCallInfo } from '@sqlrooms/ai-core';
35
- export { ReasoningBox } from '@sqlrooms/ai-core';
35
+ export { ShowToolCallDetailsProvider } from '@sqlrooms/ai-core';
36
36
  export { Chat } from '@sqlrooms/ai-core';
37
37
  export { AiSliceConfig, createDefaultAiConfig, AiSettingsSliceConfig, AnalysisSessionSchema, AnalysisResultSchema, ErrorMessageSchema, } from '@sqlrooms/ai-config';
38
38
  export type { ToolUIPart, UIMessagePart } from '@sqlrooms/ai-config';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAC,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAChE,YAAY,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,6BAA6B,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAC,mBAAmB,EAAE,sBAAsB,EAAC,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAC,kBAAkB,EAAE,uBAAuB,EAAC,MAAM,mBAAmB,CAAC;AAC9E,YAAY,EACV,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mB,CAAC;AAC9D,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAGvC,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAGnE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAC,6BAA6B,EAAC,MAAM,uBAAuB,CAAC;AAGpE,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACnD,YAAY,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC"}
package/dist/index.js CHANGED
@@ -3,18 +3,18 @@
3
3
  * @packageDocumentation
4
4
  */
5
5
  // Tools
6
- export { QueryToolResult } from './tools/query/QueryToolResult';
6
+ export { QueryToolResult, createQueryToolRenderer, } from './tools/query/QueryToolResult';
7
7
  export { QueryToolParameters, createQueryTool, getQuerySummary, } from './tools/query/queryTool';
8
8
  export { createCommandTools, ExecuteCommandToolParameters, ListCommandsToolParameters, } from './tools/commandTools';
9
- export { createDefaultAiTools } from './tools/defaultTools';
9
+ export { createDefaultAiTools, createDefaultAiToolRenderers, } from './tools/defaultTools';
10
10
  export { createDefaultAiInstructions, formatTablesForLLM, } from './tools/defaultInstructions';
11
11
  // From @sqlrooms/ai-core - State/Logic
12
12
  export { createAiSlice, useStoreWithAi } from '@sqlrooms/ai-core';
13
13
  export { useScrollToBottom } from '@sqlrooms/ai-core';
14
14
  export { AiThinkingDots } from '@sqlrooms/ai-core';
15
15
  export { cleanupPendingAnalysisResults, ToolAbortError } from '@sqlrooms/ai-core';
16
- export { convertToAiSDKTools, fixIncompleteToolCalls } from '@sqlrooms/ai-core';
17
- export { processAgentStream, updateAgentToolCallData } from '@sqlrooms/ai-core';
16
+ export { fixIncompleteToolCalls } from '@sqlrooms/ai-core';
17
+ export { streamSubAgent, updateAgentToolCallData } from '@sqlrooms/ai-core';
18
18
  // From @sqlrooms/ai-core - Components
19
19
  // @deprecated Use `Chat.Messages` instead.
20
20
  export { AnalysisResultsContainer } from '@sqlrooms/ai-core';
@@ -30,7 +30,7 @@ export { SessionDropdown } from '@sqlrooms/ai-core';
30
30
  export { SessionTitle } from '@sqlrooms/ai-core';
31
31
  export { ToolErrorMessage } from '@sqlrooms/ai-core';
32
32
  export { ToolCallInfo } from '@sqlrooms/ai-core';
33
- export { ReasoningBox } from '@sqlrooms/ai-core';
33
+ export { ShowToolCallDetailsProvider } from '@sqlrooms/ai-core';
34
34
  export { Chat } from '@sqlrooms/ai-core';
35
35
  // From @sqlrooms/ai-config
36
36
  export { AiSliceConfig, createDefaultAiConfig, AiSettingsSliceConfig, AnalysisSessionSchema, AnalysisResultSchema, ErrorMessageSchema, } from '@sqlrooms/ai-config';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,QAAQ;AACR,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,eAAe,GAIhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAO9B,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAE1D,OAAO,E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AmB,CAAC;AAEvC,2BAA2B;AAC3B,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAG7B,2CAA2C;AAC3C,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAC,6BAA6B,EAAC,MAAM,uBAAuB,CAAC;AAEpE,0CAA0C;AAC1C,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\n\n// Tools\nexport {QueryToolResult} from './tools/query/QueryToolResult';\nexport {\n QueryToolParameters,\n createQueryTool,\n getQuerySummary,\n type QueryToolLlmResult,\n type QueryToolAdditionalData,\n type QueryToolOptions,\n} from './tools/query/queryTool';\nexport {\n createCommandTools,\n ExecuteCommandToolParameters,\n ListCommandsToolParameters,\n} from './tools/commandTools';\nexport type {\n CommandToolDescriptor,\n CommandToolsOptions,\n ExecuteCommandToolLlmResult,\n ListCommandsToolLlmResult,\n} from './tools/commandTools';\nexport {createDefaultAiTools} from './tools/defaultTools';\nexport type {DefaultToolsOptions} from './tools/defaultTools';\nexport {\n createDefaultAiInstructions,\n formatTablesForLLM,\n} from './tools/defaultInstructions';\n\n// From @sqlrooms/ai-core - State/Logic\nexport {createAiSlice, useStoreWithAi} from '@sqlrooms/ai-core';\nexport type {AiSliceState} from '@sqlrooms/ai-core';\nexport {useScrollToBottom} from '@sqlrooms/ai-core';\nexport {AiThinkingDots} from '@sqlrooms/ai-core';\nexport {cleanupPendingAnalysisResults, ToolAbortError} from '@sqlrooms/ai-core';\nexport {convertToAiSDKTools, fixIncompleteToolCalls} from '@sqlrooms/ai-core';\nexport {processAgentStream, updateAgentToolCallData} from '@sqlrooms/ai-core';\nexport type {\n AgentStreamResult,\n UIMessageChunk,\n AgentToolCall,\n AgentToolCallAdditionalData,\n} from '@sqlrooms/ai-core';\n\n// From @sqlrooms/ai-core - Components\n// @deprecated Use `Chat.Messages` instead.\nexport {AnalysisResultsContainer} from '@sqlrooms/ai-core';\nexport {AnalysisResult} from '@sqlrooms/ai-core';\nexport {ErrorMessage} from '@sqlrooms/ai-core';\nexport type {ErrorMessageComponentProps} from '@sqlrooms/ai-core';\nexport {PromptSuggestions} from '@sqlrooms/ai-core';\nexport {ModelSelector} from '@sqlrooms/ai-core';\nexport {SessionControls} from '@sqlrooms/ai-core';\nexport {QueryControls} from '@sqlrooms/ai-core';\nexport {DeleteSessionDialog} from '@sqlrooms/ai-core';\nexport {SessionActions} from '@sqlrooms/ai-core';\nexport {SessionDropdown} from '@sqlrooms/ai-core';\nexport {SessionTitle} from '@sqlrooms/ai-core';\nexport type {SessionType} from '@sqlrooms/ai-core';\nexport {ToolErrorMessage} from '@sqlrooms/ai-core';\nexport {ToolCallInfo} from '@sqlrooms/ai-core';\nexport {ReasoningBox} from '@sqlrooms/ai-core';\nexport {Chat} from '@sqlrooms/ai-core';\n\n// From @sqlrooms/ai-config\nexport {\n AiSliceConfig,\n createDefaultAiConfig,\n AiSettingsSliceConfig,\n AnalysisSessionSchema,\n AnalysisResultSchema,\n ErrorMessageSchema,\n} from '@sqlrooms/ai-config';\nexport type {ToolUIPart, UIMessagePart} from '@sqlrooms/ai-config';\n\n// From @sqlrooms/ai-settings - State/Logic\nexport {\n createAiSettingsSlice,\n useStoreWithAiSettings,\n} from '@sqlrooms/ai-settings';\nexport type {AiSettingsSliceState} from '@sqlrooms/ai-settings';\nexport {createDefaultAiSettingsConfig} from '@sqlrooms/ai-settings';\n\n// From @sqlrooms/ai-settings - Components\nexport {AiSettingsPanel} from '@sqlrooms/ai-settings';\nexport {AiProvidersSettings} from '@sqlrooms/ai-settings';\nexport {AiModelsSettings} from '@sqlrooms/ai-settings';\nexport {AiModelParameters} from '@sqlrooms/ai-settings';\nexport {AiModelUsage} from '@sqlrooms/ai-settings';\nexport type {ModelUsageData} from '@sqlrooms/ai-settings';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,QAAQ;AACR,OAAO,EACL,eAAe,EACf,uBAAuB,GAExB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,eAAe,GAGhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,EACL,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AAErC,uCAAuC;AACvC,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,6BAA6B,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAC,sBAAsB,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,cAAc,EAAE,uBAAuB,EAAC,MAAM,mBAAmB,CAAC;AAe1E,sCAAsC;AACtC,2CAA2C;AAC3C,OAAO,EAAC,wBAAwB,EAAC,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;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\n QueryToolResult,\n createQueryToolRenderer,\n type QueryToolRendererOptions,\n} from './tools/query/QueryToolResult';\nexport {\n QueryToolParameters,\n createQueryTool,\n getQuerySummary,\n type QueryToolOutput,\n type QueryToolOptions,\n} from './tools/query/queryTool';\nexport {\n createCommandTools,\n ExecuteCommandToolParameters,\n ListCommandsToolParameters,\n} from './tools/commandTools';\nexport type {\n CommandToolDescriptor,\n CommandToolsOptions,\n DefaultCommandTools,\n ExecuteCommandToolLlmResult,\n ListCommandsToolLlmResult,\n} from './tools/commandTools';\nexport {\n createDefaultAiTools,\n createDefaultAiToolRenderers,\n} from './tools/defaultTools';\nexport type {\n DefaultToolsOptions,\n DefaultAiToolRenderers,\n} from './tools/defaultTools';\nexport {\n createDefaultAiInstructions,\n formatTablesForLLM,\n} from './tools/defaultInstructions';\n\n// From @sqlrooms/ai-core - State/Logic\nexport {createAiSlice, useStoreWithAi} from '@sqlrooms/ai-core';\nexport type {AiSliceState} from '@sqlrooms/ai-core';\nexport {useScrollToBottom} from '@sqlrooms/ai-core';\nexport {AiThinkingDots} from '@sqlrooms/ai-core';\nexport {cleanupPendingAnalysisResults, ToolAbortError} from '@sqlrooms/ai-core';\nexport {fixIncompleteToolCalls} from '@sqlrooms/ai-core';\nexport {streamSubAgent, updateAgentToolCallData} from '@sqlrooms/ai-core';\nexport type {\n AddToolOutput,\n AgentStreamOutput,\n AgentToolCall,\n AgentToolCallAdditionalData,\n ToolRenderers,\n ToolRenderer,\n ToolRendererProps,\n ToolRendererRegistry,\n StoredTool,\n StoredToolSet,\n AiSliceOptions,\n} from '@sqlrooms/ai-core';\n\n// From @sqlrooms/ai-core - Components\n// @deprecated Use `Chat.Messages` instead.\nexport {AnalysisResultsContainer} from '@sqlrooms/ai-core';\nexport {AnalysisResult} from '@sqlrooms/ai-core';\nexport {ErrorMessage} from '@sqlrooms/ai-core';\nexport type {ErrorMessageComponentProps} from '@sqlrooms/ai-core';\nexport {PromptSuggestions} from '@sqlrooms/ai-core';\nexport {ModelSelector} from '@sqlrooms/ai-core';\nexport {SessionControls} from '@sqlrooms/ai-core';\nexport {QueryControls} from '@sqlrooms/ai-core';\nexport {DeleteSessionDialog} from '@sqlrooms/ai-core';\nexport {SessionActions} from '@sqlrooms/ai-core';\nexport {SessionDropdown} from '@sqlrooms/ai-core';\nexport {SessionTitle} from '@sqlrooms/ai-core';\nexport type {SessionType} from '@sqlrooms/ai-core';\nexport {ToolErrorMessage} from '@sqlrooms/ai-core';\nexport {ToolCallInfo} from '@sqlrooms/ai-core';\nexport {ShowToolCallDetailsProvider} from '@sqlrooms/ai-core';\nexport {Chat} from '@sqlrooms/ai-core';\n\n// From @sqlrooms/ai-config\nexport {\n AiSliceConfig,\n createDefaultAiConfig,\n AiSettingsSliceConfig,\n AnalysisSessionSchema,\n AnalysisResultSchema,\n ErrorMessageSchema,\n} from '@sqlrooms/ai-config';\nexport type {ToolUIPart, UIMessagePart} from '@sqlrooms/ai-config';\n\n// From @sqlrooms/ai-settings - State/Logic\nexport {\n createAiSettingsSlice,\n useStoreWithAiSettings,\n} from '@sqlrooms/ai-settings';\nexport type {AiSettingsSliceState} from '@sqlrooms/ai-settings';\nexport {createDefaultAiSettingsConfig} from '@sqlrooms/ai-settings';\n\n// From @sqlrooms/ai-settings - Components\nexport {AiSettingsPanel} from '@sqlrooms/ai-settings';\nexport {AiProvidersSettings} from '@sqlrooms/ai-settings';\nexport {AiModelsSettings} from '@sqlrooms/ai-settings';\nexport {AiModelParameters} from '@sqlrooms/ai-settings';\nexport {AiModelUsage} from '@sqlrooms/ai-settings';\nexport type {ModelUsageData} from '@sqlrooms/ai-settings';\n"]}
@@ -1,4 +1,4 @@
1
- import type { OpenAssistantToolSet } from '@openassistant/utils';
1
+ import type { Tool, ToolSet } from 'ai';
2
2
  import type { BaseRoomStoreState, RoomCommandDescriptor, StoreApi } from '@sqlrooms/room-shell';
3
3
  import { z } from 'zod';
4
4
  export declare const ListCommandsToolParameters: z.ZodObject<{
@@ -36,5 +36,14 @@ export type CommandToolsOptions = {
36
36
  includeInvisibleCommandsByDefault?: boolean;
37
37
  includeDisabledCommandsInList?: boolean;
38
38
  };
39
- export declare function createCommandTools<RS extends BaseRoomStoreState>(store: StoreApi<RS>, options?: CommandToolsOptions): OpenAssistantToolSet;
39
+ /**
40
+ * The typed shape returned by {@link createCommandTools} when using the default tool names.
41
+ * Consumed by {@link createDefaultAiTools} to give its return type literal string keys.
42
+ */
43
+ export type DefaultCommandTools = {
44
+ list_commands: Tool<ListCommandsToolParameters, ListCommandsToolLlmResult>;
45
+ execute_command: Tool<ExecuteCommandToolParameters, ExecuteCommandToolLlmResult>;
46
+ };
47
+ export declare function createCommandTools<RS extends BaseRoomStoreState>(store: StoreApi<RS>): DefaultCommandTools;
48
+ export declare function createCommandTools<RS extends BaseRoomStoreState>(store: StoreApi<RS>, options: CommandToolsOptions): ToolSet;
40
49
  //# sourceMappingURL=commandTools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commandTools.d.ts","sourceRoot":"","sources":["../../src/tools/commandTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,eAAO,MAAM,0BAA0B;;;;iBAsBrC,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,0BAA0B,CAClC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,qBAAqB,CAAC;AAE1D,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAE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Q,CAAC,EAAE,CAAC,EACnB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { tool } from 'ai';
1
2
  import { hasCommandSliceState } from '@sqlrooms/room-shell';
2
3
  import { z } from 'zod';
3
4
  export const ListCommandsToolParameters = z.object({
@@ -30,19 +31,16 @@ export function createCommandTools(store, options) {
30
31
  const listToolName = options?.listToolName ?? DEFAULT_LIST_TOOL_NAME;
31
32
  const executeToolName = options?.executeToolName ?? DEFAULT_EXECUTE_TOOL_NAME;
32
33
  return {
33
- [listToolName]: {
34
- name: listToolName,
34
+ [listToolName]: tool({
35
35
  description: `List available room commands, including whether they are enabled and whether they require input.
36
36
  Use this before executing commands so you can pick a valid command ID and understand input expectations.`,
37
- parameters: ListCommandsToolParameters,
37
+ inputSchema: ListCommandsToolParameters,
38
38
  execute: async (params) => {
39
39
  const state = store.getState();
40
40
  if (!hasCommandSliceState(state)) {
41
41
  return {
42
- llmResult: {
43
- success: false,
44
- errorMessage: 'Command registry is not available in this room.',
45
- },
42
+ success: false,
43
+ errorMessage: 'Command registry is not available in this room.',
46
44
  };
47
45
  }
48
46
  const descriptors = state.commands.listCommands({
@@ -52,37 +50,30 @@ Use this before executing commands so you can pick a valid command ID and unders
52
50
  includeInputSchema: params.includeInputSchema,
53
51
  });
54
52
  return {
55
- llmResult: {
56
- success: true,
57
- commands: descriptors,
58
- details: `Found ${descriptors.length} commands.`,
59
- },
53
+ success: true,
54
+ commands: descriptors,
55
+ details: `Found ${descriptors.length} commands.`,
60
56
  };
61
57
  },
62
- },
63
- [executeToolName]: {
64
- name: executeToolName,
58
+ }),
59
+ [executeToolName]: tool({
65
60
  description: `Execute a room command by ID.
66
61
  Call ${listToolName} first to discover valid command IDs and input requirements.`,
67
- parameters: ExecuteCommandToolParameters,
62
+ inputSchema: ExecuteCommandToolParameters,
68
63
  execute: async ({ commandId, input }) => {
69
64
  const state = store.getState();
70
65
  if (!hasCommandSliceState(state)) {
71
66
  return {
72
- llmResult: {
73
- success: false,
74
- commandId,
75
- errorMessage: 'Command registry is not available in this room.',
76
- },
67
+ success: false,
68
+ commandId,
69
+ errorMessage: 'Command registry is not available in this room.',
77
70
  };
78
71
  }
79
72
  if (!state.commands.getCommand(commandId)) {
80
73
  return {
81
- llmResult: {
82
- success: false,
83
- commandId,
84
- errorMessage: `Unknown command ID "${commandId}".`,
85
- },
74
+ success: false,
75
+ commandId,
76
+ errorMessage: `Unknown command ID "${commandId}".`,
86
77
  };
87
78
  }
88
79
  const result = await state.commands.invokeCommand(commandId, input, {
@@ -90,31 +81,29 @@ Call ${listToolName} first to discover valid command IDs and input requirements.
90
81
  });
91
82
  if (result.success) {
92
83
  return {
93
- llmResult: {
94
- success: true,
95
- commandId,
96
- details: `Executed command "${commandId}".`,
97
- result: {
98
- code: result.code,
99
- message: result.message,
100
- data: result.data,
101
- },
102
- },
103
- };
104
- }
105
- return {
106
- llmResult: {
107
- success: false,
84
+ success: true,
108
85
  commandId,
109
- errorMessage: result.error ?? 'Command execution failed.',
86
+ details: `Executed command "${commandId}".`,
110
87
  result: {
111
88
  code: result.code,
112
89
  message: result.message,
90
+ data: result.data,
113
91
  },
92
+ };
93
+ }
94
+ return {
95
+ success: false,
96
+ commandId,
97
+ errorMessage: result.error ?? 'Command execution failed.',
98
+ result: {
99
+ code: result.code,
100
+ message: result.message,
114
101
  },
115
102
  };
116
103
  },
117
- },
104
+ }),
105
+ // Single cast required: TypeScript cannot narrow computed property names
106
+ // ([listToolName], [executeToolName]) to their literal string types.
118
107
  };
119
108
  }
120
109
  //# sourceMappingURL=commandTools.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"commandTools.js","sourceRoot":"","sources":["../../src/tools/commandTools.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAM1D,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAA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AAO,EAAE,IAAI;iBACd,CAAC,CAAC;gBACH,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;oBACnB,OAAO;wBACL,SAAS,EAAE;4BACT,OAAO,EAAE,IAAI;4BACb,SAAS;4BACT,OAAO,EAAE,qBAAqB,SAAS,IAAI;4BAC3C,MAAM,EAAE;gCACN,IAAI,EAAE,MAAM,CAAC,IAAI;gCACjB,OAAO,EAAE,MAAM,CAAC,OAAO;gCACvB,IAAI,EAAE,MAAM,CAAC,IAAI;6BAClB;yBACoC;qBACxC,CAAC;gBACJ,CAAC;gBACD,OAAO;oBACL,SAAS,EAAE;wBACT,OAAO,EAAE,KAAK;wBACd,SAAS;wBACT,YAAY,EAAE,MAAM,CAAC,KAAK,IAAI,2BAA2B;wBACzD,MAAM,EAAE;4BACN,IAAI,EAAE,MAAM,CAAC,IAAI;4BACjB,OAAO,EAAE,MAAM,CAAC,OAAO;yBACxB;qBACoC;iBACxC,CAAC;YACJ,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type {OpenAssistantToolSet} from '@openassistant/utils';\nimport {hasCommandSliceState} from '@sqlrooms/room-shell';\nimport type {\n BaseRoomStoreState,\n RoomCommandDescriptor,\n StoreApi,\n} from '@sqlrooms/room-shell';\nimport {z} from 'zod';\n\nexport const ListCommandsToolParameters = z.object({\n includeInvisible: z\n .boolean()\n .optional()\n .default(false)\n .describe(\n 'Whether to include commands hidden from user-facing UIs (default: false).',\n ),\n includeDisabled: z\n .boolean()\n .optional()\n .default(true)\n .describe(\n 'Whether to include currently disabled commands (default: true).',\n ),\n includeInputSchema: z\n .boolean()\n .optional()\n .default(true)\n .describe(\n 'Whether to include portable input schemas in the listed command descriptors.',\n ),\n});\n\nexport type ListCommandsToolParameters = z.infer<\n typeof ListCommandsToolParameters\n>;\n\nexport type CommandToolDescriptor = RoomCommandDescriptor;\n\nexport type ListCommandsToolLlmResult = {\n success: boolean;\n commands?: CommandToolDescriptor[];\n details?: string;\n errorMessage?: string;\n};\n\nexport const ExecuteCommandToolParameters = z.object({\n commandId: z.string().describe('The command ID to execute.'),\n input: z\n .unknown()\n .optional()\n .describe('Optional command input. Must satisfy the command input schema.'),\n});\n\nexport type ExecuteCommandToolParameters = z.infer<\n typeof ExecuteCommandToolParameters\n>;\n\nexport type ExecuteCommandToolLlmResult = {\n success: boolean;\n commandId?: string;\n details?: string;\n errorMessage?: string;\n result?: {\n code?: string;\n message?: string;\n data?: unknown;\n };\n};\n\nexport type CommandToolsOptions = {\n listToolName?: string;\n executeToolName?: string;\n includeInvisibleCommandsByDefault?: boolean;\n includeDisabledCommandsInList?: boolean;\n};\n\nconst DEFAULT_LIST_TOOL_NAME = 'list_commands';\nconst DEFAULT_EXECUTE_TOOL_NAME = 'execute_command';\n\nexport function createCommandTools<RS extends BaseRoomStoreState>(\n store: StoreApi<RS>,\n options?: CommandToolsOptions,\n): OpenAssistantToolSet {\n const listToolName = options?.listToolName ?? DEFAULT_LIST_TOOL_NAME;\n const executeToolName = options?.executeToolName ?? DEFAULT_EXECUTE_TOOL_NAME;\n\n return {\n [listToolName]: {\n name: listToolName,\n description: `List available room commands, including whether they are enabled and whether they require input.\nUse this before executing commands so you can pick a valid command ID and understand input expectations.`,\n parameters: ListCommandsToolParameters,\n execute: async (params: ListCommandsToolParameters) => {\n const state = store.getState();\n if (!hasCommandSliceState(state)) {\n return {\n llmResult: {\n success: false,\n errorMessage: 'Command registry is not available in this room.',\n } satisfies ListCommandsToolLlmResult,\n };\n }\n\n const descriptors = state.commands.listCommands({\n surface: 'ai',\n includeInvisible: params.includeInvisible,\n includeDisabled: params.includeDisabled,\n includeInputSchema: params.includeInputSchema,\n });\n\n return {\n llmResult: {\n success: true,\n commands: descriptors,\n details: `Found ${descriptors.length} commands.`,\n } satisfies ListCommandsToolLlmResult,\n };\n },\n },\n [executeToolName]: {\n name: executeToolName,\n description: `Execute a room command by ID.\nCall ${listToolName} first to discover valid command IDs and input requirements.`,\n parameters: ExecuteCommandToolParameters,\n execute: async ({commandId, input}: ExecuteCommandToolParameters) => {\n const state = store.getState();\n if (!hasCommandSliceState(state)) {\n return {\n llmResult: {\n success: false,\n commandId,\n errorMessage: 'Command registry is not available in this room.',\n } satisfies ExecuteCommandToolLlmResult,\n };\n }\n\n if (!state.commands.getCommand(commandId)) {\n return {\n llmResult: {\n success: false,\n commandId,\n errorMessage: `Unknown command ID \"${commandId}\".`,\n } satisfies ExecuteCommandToolLlmResult,\n };\n }\n\n const result = await state.commands.invokeCommand(commandId, input, {\n surface: 'ai',\n });\n if (result.success) {\n return {\n llmResult: {\n success: true,\n commandId,\n details: `Executed command \"${commandId}\".`,\n result: {\n code: result.code,\n message: result.message,\n data: result.data,\n },\n } satisfies ExecuteCommandToolLlmResult,\n };\n }\n return {\n llmResult: {\n success: false,\n commandId,\n errorMessage: result.error ?? 'Command execution failed.',\n result: {\n code: result.code,\n message: result.message,\n },\n } satisfies ExecuteCommandToolLlmResult,\n };\n },\n },\n };\n}\n"]}
1
+ {"version":3,"file":"commandTools.js","sourceRoot":"","sources":["../../src/tools/commandTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,IAAI,CAAC;AAExB,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAM1D,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,gBAAgB,EAAE,CAAC;SAChB,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,OAAO,CAAC,KAAK,CAAC;SACd,QAAQ,CACP,2EAA2E,CAC5E;IACH,eAAe,EAAE,CAAC;SACf,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,OAAO,CAAC,IAAI,CAAC;SACb,QAAQ,CACP,iEAAiE,CAClE;IACH,kBAAkB,EAAE,CAAC;SAClB,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,OAAO,CAAC,IAAI,CAAC;SACb,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,CAAC,IAAI;wBACjB,OAAO,EAAE,MAAM,CAAC,OAAO;qBACxB;iBACoC,CAAC;YAC1C,CAAC;SACF,CAAC;QACF,yEAAyE;QACzE,qEAAqE;KAC/C,CAAC;AAC3B,CAAC","sourcesContent":["import {tool} from 'ai';\nimport type {Tool, ToolSet} from 'ai';\nimport {hasCommandSliceState} from '@sqlrooms/room-shell';\nimport type {\n BaseRoomStoreState,\n RoomCommandDescriptor,\n StoreApi,\n} from '@sqlrooms/room-shell';\nimport {z} from 'zod';\n\nexport const ListCommandsToolParameters = z.object({\n includeInvisible: z\n .boolean()\n .optional()\n .default(false)\n .describe(\n 'Whether to include commands hidden from user-facing UIs (default: false).',\n ),\n includeDisabled: z\n .boolean()\n .optional()\n .default(true)\n .describe(\n 'Whether to include currently disabled commands (default: true).',\n ),\n includeInputSchema: z\n .boolean()\n .optional()\n .default(true)\n .describe(\n 'Whether to include portable input schemas in the listed command descriptors.',\n ),\n});\n\nexport type ListCommandsToolParameters = z.infer<\n typeof ListCommandsToolParameters\n>;\n\nexport type CommandToolDescriptor = RoomCommandDescriptor;\n\nexport type ListCommandsToolLlmResult = {\n success: boolean;\n commands?: CommandToolDescriptor[];\n details?: string;\n errorMessage?: string;\n};\n\nexport const ExecuteCommandToolParameters = z.object({\n commandId: z.string().describe('The command ID to execute.'),\n input: z\n .unknown()\n .optional()\n .describe('Optional command input. Must satisfy the command input schema.'),\n});\n\nexport type ExecuteCommandToolParameters = z.infer<\n typeof ExecuteCommandToolParameters\n>;\n\nexport type ExecuteCommandToolLlmResult = {\n success: boolean;\n commandId?: string;\n details?: string;\n errorMessage?: string;\n result?: {\n code?: string;\n message?: string;\n data?: unknown;\n };\n};\n\nexport type CommandToolsOptions = {\n listToolName?: string;\n executeToolName?: string;\n includeInvisibleCommandsByDefault?: boolean;\n includeDisabledCommandsInList?: boolean;\n};\n\nconst DEFAULT_LIST_TOOL_NAME = 'list_commands';\nconst DEFAULT_EXECUTE_TOOL_NAME = 'execute_command';\n\n/**\n * The typed shape returned by {@link createCommandTools} when using the default tool names.\n * Consumed by {@link createDefaultAiTools} to give its return type literal string keys.\n */\nexport type DefaultCommandTools = {\n list_commands: Tool<ListCommandsToolParameters, ListCommandsToolLlmResult>;\n execute_command: Tool<\n ExecuteCommandToolParameters,\n ExecuteCommandToolLlmResult\n >;\n};\n\nexport function createCommandTools<RS extends BaseRoomStoreState>(\n store: StoreApi<RS>,\n): DefaultCommandTools;\nexport function createCommandTools<RS extends BaseRoomStoreState>(\n store: StoreApi<RS>,\n options: CommandToolsOptions,\n): ToolSet;\nexport function createCommandTools<RS extends BaseRoomStoreState>(\n store: StoreApi<RS>,\n options?: CommandToolsOptions,\n): ToolSet {\n const listToolName = options?.listToolName ?? DEFAULT_LIST_TOOL_NAME;\n const executeToolName = options?.executeToolName ?? DEFAULT_EXECUTE_TOOL_NAME;\n\n return {\n [listToolName]: tool({\n description: `List available room commands, including whether they are enabled and whether they require input.\nUse this before executing commands so you can pick a valid command ID and understand input expectations.`,\n inputSchema: ListCommandsToolParameters,\n execute: async (params: ListCommandsToolParameters) => {\n const state = store.getState();\n if (!hasCommandSliceState(state)) {\n return {\n success: false,\n errorMessage: 'Command registry is not available in this room.',\n } satisfies ListCommandsToolLlmResult;\n }\n\n const descriptors = state.commands.listCommands({\n surface: 'ai',\n includeInvisible: params.includeInvisible,\n includeDisabled: params.includeDisabled,\n includeInputSchema: params.includeInputSchema,\n });\n\n return {\n success: true,\n commands: descriptors,\n details: `Found ${descriptors.length} commands.`,\n } satisfies ListCommandsToolLlmResult;\n },\n }),\n [executeToolName]: tool({\n description: `Execute a room command by ID.\nCall ${listToolName} first to discover valid command IDs and input requirements.`,\n inputSchema: ExecuteCommandToolParameters,\n execute: async ({commandId, input}: ExecuteCommandToolParameters) => {\n const state = store.getState();\n if (!hasCommandSliceState(state)) {\n return {\n success: false,\n commandId,\n errorMessage: 'Command registry is not available in this room.',\n } satisfies ExecuteCommandToolLlmResult;\n }\n\n if (!state.commands.getCommand(commandId)) {\n return {\n success: false,\n commandId,\n errorMessage: `Unknown command ID \"${commandId}\".`,\n } satisfies ExecuteCommandToolLlmResult;\n }\n\n const result = await state.commands.invokeCommand(commandId, input, {\n surface: 'ai',\n });\n if (result.success) {\n return {\n success: true,\n commandId,\n details: `Executed command \"${commandId}\".`,\n result: {\n code: result.code,\n message: result.message,\n data: result.data,\n },\n } satisfies ExecuteCommandToolLlmResult;\n }\n return {\n success: false,\n commandId,\n errorMessage: result.error ?? 'Command execution failed.',\n result: {\n code: result.code,\n message: result.message,\n },\n } satisfies ExecuteCommandToolLlmResult;\n },\n }),\n // Single cast required: TypeScript cannot narrow computed property names\n // ([listToolName], [executeToolName]) to their literal string types.\n } as DefaultCommandTools;\n}\n"]}
@@ -1,18 +1,41 @@
1
1
  import type { AiSliceState } from '@sqlrooms/ai-core';
2
2
  import type { DuckDbSliceState } from '@sqlrooms/duckdb';
3
3
  import type { BaseRoomStoreState, StoreApi } from '@sqlrooms/room-shell';
4
- import type { QueryToolOptions } from './query/queryTool';
5
- import type { OpenAssistantToolSet } from '@openassistant/utils';
6
- import type { CommandToolsOptions } from './commandTools';
4
+ import type { QueryToolOptions, QueryToolParameters, QueryToolOutput } from './query/queryTool';
5
+ import type { Tool } from 'ai';
6
+ import type { ToolRenderer } from '@sqlrooms/ai-core';
7
+ import type { CommandToolsOptions, DefaultCommandTools } from './commandTools';
7
8
  export type DefaultToolsOptions = {
8
9
  query?: QueryToolOptions;
9
10
  commands?: CommandToolsOptions | false;
10
11
  };
12
+ type QueryTool = Tool<QueryToolParameters, QueryToolOutput>;
11
13
  /**
12
- * Default tools available to the AI assistant for data analysis
14
+ * Default tools available to the AI assistant for data analysis.
13
15
  * Includes:
14
16
  * - query: Executes SQL queries against DuckDB
15
17
  * - list_commands / execute_command: Bridge to room command registry
18
+ *
19
+ * Pass `commands: false` to opt out of the command tools (e.g. in rooms
20
+ * without a command registry).
16
21
  */
17
- export declare function createDefaultAiTools(store: StoreApi<BaseRoomStoreState & AiSliceState & DuckDbSliceState>, options?: DefaultToolsOptions): OpenAssistantToolSet;
22
+ export declare function createDefaultAiTools(store: StoreApi<BaseRoomStoreState & AiSliceState & DuckDbSliceState>, options: DefaultToolsOptions & {
23
+ commands: false;
24
+ }): {
25
+ query: QueryTool;
26
+ };
27
+ export declare function createDefaultAiTools(store: StoreApi<BaseRoomStoreState & AiSliceState & DuckDbSliceState>, options?: DefaultToolsOptions): {
28
+ query: QueryTool;
29
+ } & DefaultCommandTools;
30
+ /** The typed shape returned by {@link createDefaultAiToolRenderers}. */
31
+ export type DefaultAiToolRenderers = {
32
+ query: ToolRenderer<QueryToolOutput, QueryToolParameters>;
33
+ };
34
+ /**
35
+ * Creates the default tool renderer registry for the built-in AI tools.
36
+ * Returns a typed map so it contributes to the `toolRenderers` constraint
37
+ * when spread alongside custom renderers in {@link createAiSlice}.
38
+ */
39
+ export declare function createDefaultAiToolRenderers(): DefaultAiToolRenderers;
40
+ export {};
18
41
  //# sourceMappingURL=defaultTools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaultTools.d.ts","sourceRoot":"","sources":["../../src/tools/defaultTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAC,kBAAkB,EAAE,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAEvE,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,gBAAgB,CAAC;AAExD,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,QAAQ,CAAC,EAAE,mBAAmB,GAAG,KAAK,CAAC;CACxC,CAAC;AAEF;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AC,EACrE,OAAO,CAAC,EAAE,mBAAmB,GAC5B;IAAC,KAAK,EAAE,SAAS,CAAA;CAAC,GAAG,mBAAmB,CAAC;AAkB5C,wEAAwE;AACxE,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,YAAY,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC;CAC3D,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,4BAA4B,IAAI,sBAAsB,CAIrE"}
@@ -1,17 +1,26 @@
1
1
  import { createQueryTool } from './query/queryTool';
2
2
  import { createCommandTools } from './commandTools';
3
- /**
4
- * Default tools available to the AI assistant for data analysis
5
- * Includes:
6
- * - query: Executes SQL queries against DuckDB
7
- * - list_commands / execute_command: Bridge to room command registry
8
- */
3
+ import { QueryToolResult } from './query/QueryToolResult';
9
4
  export function createDefaultAiTools(store, options) {
10
5
  const { query, commands } = options || {};
11
- const commandTools = commands === false ? {} : createCommandTools(store, commands || undefined);
6
+ const commandTools = commands === false
7
+ ? {}
8
+ : commands != null
9
+ ? createCommandTools(store, commands)
10
+ : createCommandTools(store);
12
11
  return {
13
12
  query: createQueryTool(store, query),
14
13
  ...commandTools,
15
14
  };
16
15
  }
16
+ /**
17
+ * Creates the default tool renderer registry for the built-in AI tools.
18
+ * Returns a typed map so it contributes to the `toolRenderers` constraint
19
+ * when spread alongside custom renderers in {@link createAiSlice}.
20
+ */
21
+ export function createDefaultAiToolRenderers() {
22
+ return {
23
+ query: QueryToolResult,
24
+ };
25
+ }
17
26
  //# sourceMappingURL=defaultTools.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaultTools.js","sourceRoot":"","sources":["../../src/tools/defaultTools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAQlD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAqE,EACrE,OAA6B;IAE7B,MAAM,EAAC,KAAK,EAAE,QAAQ,EAAC,GAAG,OAAO,IAAI,EAAE,CAAC;IACxC,MAAM,YAAY,GAChB,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,EAAE,QAAQ,IAAI,SAAS,CAAC,CAAC;IAC7E,OAAO;QACL,KAAK,EAAE,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC;QACpC,GAAG,YAAY;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import type {AiSliceState} from '@sqlrooms/ai-core';\nimport type {DuckDbSliceState} from '@sqlrooms/duckdb';\nimport type {BaseRoomStoreState, StoreApi} from '@sqlrooms/room-shell';\nimport {createQueryTool} from './query/queryTool';\nimport type {QueryToolOptions} from './query/queryTool';\nimport type {OpenAssistantToolSet} from '@openassistant/utils';\nimport {createCommandTools} from './commandTools';\nimport type {CommandToolsOptions} from './commandTools';\n\nexport type DefaultToolsOptions = {\n query?: QueryToolOptions;\n commands?: CommandToolsOptions | false;\n};\n\n/**\n * Default tools available to the AI assistant for data analysis\n * Includes:\n * - query: Executes SQL queries against DuckDB\n * - list_commands / execute_command: Bridge to room command registry\n */\nexport function createDefaultAiTools(\n store: StoreApi<BaseRoomStoreState & AiSliceState & DuckDbSliceState>,\n options?: DefaultToolsOptions,\n): OpenAssistantToolSet {\n const {query, commands} = options || {};\n const commandTools =\n commands === false ? {} : createCommandTools(store, commands || undefined);\n return {\n query: createQueryTool(store, query),\n ...commandTools,\n };\n}\n"]}
1
+ {"version":3,"file":"defaultTools.js","sourceRoot":"","sources":["../../src/tools/defaultTools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAQlD,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AA0BxD,MAAM,UAAU,oBAAoB,CAClC,KAAqE,EACrE,OAA6B;IAE7B,MAAM,EAAC,KAAK,EAAE,QAAQ,EAAC,GAAG,OAAO,IAAI,EAAE,CAAC;IACxC,MAAM,YAAY,GAChB,QAAQ,KAAK,KAAK;QAChB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,QAAQ,IAAI,IAAI;YAChB,CAAC,CAAC,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC;YACrC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAClC,OAAO;QACL,KAAK,EAAE,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC;QACpC,GAAG,YAAY;KAChB,CAAC;AACJ,CAAC;AAOD;;;;GAIG;AACH,MAAM,UAAU,4BAA4B;IAC1C,OAAO;QACL,KAAK,EAAE,eAAe;KACvB,CAAC;AACJ,CAAC","sourcesContent":["import type {AiSliceState} from '@sqlrooms/ai-core';\nimport type {DuckDbSliceState} from '@sqlrooms/duckdb';\nimport type {BaseRoomStoreState, StoreApi} from '@sqlrooms/room-shell';\nimport {createQueryTool} from './query/queryTool';\nimport type {\n QueryToolOptions,\n QueryToolParameters,\n QueryToolOutput,\n} from './query/queryTool';\nimport type {Tool, ToolSet} from 'ai';\nimport type {ToolRenderer} from '@sqlrooms/ai-core';\nimport {createCommandTools} from './commandTools';\nimport type {CommandToolsOptions, DefaultCommandTools} from './commandTools';\nimport {QueryToolResult} from './query/QueryToolResult';\n\nexport type DefaultToolsOptions = {\n query?: QueryToolOptions;\n commands?: CommandToolsOptions | false;\n};\n\ntype QueryTool = Tool<QueryToolParameters, QueryToolOutput>;\n\n/**\n * Default tools available to the AI assistant for data analysis.\n * Includes:\n * - query: Executes SQL queries against DuckDB\n * - list_commands / execute_command: Bridge to room command registry\n *\n * Pass `commands: false` to opt out of the command tools (e.g. in rooms\n * without a command registry).\n */\nexport function createDefaultAiTools(\n store: StoreApi<BaseRoomStoreState & AiSliceState & DuckDbSliceState>,\n options: DefaultToolsOptions & {commands: false},\n): {query: QueryTool};\nexport function createDefaultAiTools(\n store: StoreApi<BaseRoomStoreState & AiSliceState & DuckDbSliceState>,\n options?: DefaultToolsOptions,\n): {query: QueryTool} & DefaultCommandTools;\nexport function createDefaultAiTools(\n store: StoreApi<BaseRoomStoreState & AiSliceState & DuckDbSliceState>,\n options?: DefaultToolsOptions,\n): ToolSet {\n const {query, commands} = options || {};\n const commandTools =\n commands === false\n ? {}\n : commands != null\n ? createCommandTools(store, commands)\n : createCommandTools(store);\n return {\n query: createQueryTool(store, query),\n ...commandTools,\n };\n}\n\n/** The typed shape returned by {@link createDefaultAiToolRenderers}. */\nexport type DefaultAiToolRenderers = {\n query: ToolRenderer<QueryToolOutput, QueryToolParameters>;\n};\n\n/**\n * Creates the default tool renderer registry for the built-in AI tools.\n * Returns a typed map so it contributes to the `toolRenderers` constraint\n * when spread alongside custom renderers in {@link createAiSlice}.\n */\nexport function createDefaultAiToolRenderers(): DefaultAiToolRenderers {\n return {\n query: QueryToolResult,\n };\n}\n"]}
@@ -1,15 +1,33 @@
1
- import { ArrowDataTableValueFormatter } from '@sqlrooms/data-table';
2
- import * as arrow from 'apache-arrow';
3
- type QueryToolResultProps = {
4
- title: string;
5
- sqlQuery: string;
6
- /** Provided in case the query result is already an arrow table */
7
- arrowTable?: arrow.Table;
8
- /** Whether to show the SQL text in the result */
1
+ import type { ToolRenderer, ToolRendererProps } from '@sqlrooms/ai-core';
2
+ import { type ArrowDataTableValueFormatter } from '@sqlrooms/data-table';
3
+ import type { QueryToolOutput, QueryToolParameters } from './queryTool';
4
+ export type QueryToolRendererOptions = {
5
+ /** Whether to show the SQL text in the result. Defaults to true. */
9
6
  showSql?: boolean;
10
7
  /** Optional custom value formatter for binary/geometry data */
11
8
  formatValue?: ArrowDataTableValueFormatter;
12
9
  };
13
- export declare function QueryToolResult(props: QueryToolResultProps): import("react/jsx-runtime").JSX.Element;
14
- export {};
10
+ /**
11
+ * Creates a configured renderer for query tool results.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * toolRenderers: {
16
+ * query: createQueryToolRenderer({
17
+ * showSql: false,
18
+ * formatValue: myGeomFormatter,
19
+ * }),
20
+ * }
21
+ * ```
22
+ */
23
+ export declare function createQueryToolRenderer(options?: QueryToolRendererOptions): ToolRenderer<QueryToolOutput, QueryToolParameters>;
24
+ /**
25
+ * Default renderer for query tool results.
26
+ * For custom configuration (showSql, formatValue) use {@link createQueryToolRenderer}.
27
+ */
28
+ export declare const QueryToolResult: import("react").ComponentType<ToolRendererProps<QueryToolOutput, {
29
+ type: "query";
30
+ sqlQuery: string;
31
+ reasoning: string;
32
+ }>>;
15
33
  //# sourceMappingURL=QueryToolResult.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"QueryToolResult.d.ts","sourceRoot":"","sources":["../../../src/tools/query/QueryToolResult.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAE7B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,KAAK,oBAAoB,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,UAAU,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;IACzB,iDAAiD;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,4BAA4B,CAAC;CAC5C,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CA+C1D"}
1
+ {"version":3,"file":"QueryToolResult.d.ts","sourceRoot":"","sources":["../../../src/tools/query/QueryToolResult.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AACvE,OAAO,EACL,KAAK,4BAA4B,EAElC,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAC,eAAe,EAAE,mBAAmB,EAAC,MAAM,aAAa,CAAC;AAEtE,MAAM,MAAM,wBAAwB,GAAG;IACrC,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,4BAA4B,CAAC;CAC5C,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,CAAC,EAAE,wBAAwB,GACjC,YAAY,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAoDpD;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;GAA4B,CAAC"}
@@ -2,9 +2,34 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { DataTableModal, } from '@sqlrooms/data-table';
3
3
  import { Button, CopyButton, useDisclosure } from '@sqlrooms/ui';
4
4
  import { TableIcon } from 'lucide-react';
5
- export function QueryToolResult(props) {
6
- const { title, sqlQuery, showSql = true, formatValue } = props;
7
- const tableModal = useDisclosure();
8
- return (_jsxs(_Fragment, { children: [showSql && (_jsxs("div", { className: "text-muted-foreground group/sql bg-muted relative max-h-[150px] w-full overflow-auto rounded-md p-2 font-mono text-xs", children: [_jsx("pre", { className: "pr-8 wrap-break-word whitespace-pre-wrap", children: sqlQuery }), _jsx("div", { className: "absolute top-1 right-1 opacity-0 transition-opacity group-focus-within/sql:opacity-100 group-hover/sql:opacity-100", children: _jsx(CopyButton, { text: sqlQuery, tooltipLabel: "Copy SQL query", className: "h-6 w-6" }) })] })), _jsx("div", { className: "flex items-center gap-1 text-gray-500 dark:text-gray-400", children: _jsxs(Button, { variant: "ghost", size: "xs", onClick: tableModal.onOpen, children: [_jsx(TableIcon, { className: "h-4 w-4" }), _jsx("h3", { className: "text-xs", children: "Show Query Result" })] }) }), 'arrowTable' in props ? (props.arrowTable ? (_jsx(DataTableModal, { title: title, arrowTable: props.arrowTable, tableModal: tableModal, formatValue: formatValue })) : (_jsx("div", { className: "p-4 text-xs", children: "No data" }))) : (_jsx(DataTableModal, { title: title, query: sqlQuery, tableModal: tableModal, formatValue: formatValue }))] }));
5
+ /**
6
+ * Creates a configured renderer for query tool results.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * toolRenderers: {
11
+ * query: createQueryToolRenderer({
12
+ * showSql: false,
13
+ * formatValue: myGeomFormatter,
14
+ * }),
15
+ * }
16
+ * ```
17
+ */
18
+ export function createQueryToolRenderer(options) {
19
+ const { showSql = true, formatValue } = options ?? {};
20
+ return function QueryToolResultRenderer({ output, input, }) {
21
+ const tableModal = useDisclosure();
22
+ if (!output)
23
+ return null;
24
+ const sqlQuery = output.sqlQuery ?? input?.sqlQuery ?? '';
25
+ const title = output.title ?? 'Query Result';
26
+ const shouldShowSql = output.showSql ?? showSql;
27
+ return (_jsxs(_Fragment, { children: [shouldShowSql && (_jsxs("div", { className: "text-muted-foreground group/sql bg-muted relative max-h-[150px] w-full overflow-auto rounded-md p-2 font-mono text-xs", children: [_jsx("pre", { className: "min-h-4 pr-8 wrap-break-word whitespace-pre-wrap", children: sqlQuery }), _jsx("div", { className: "absolute top-1 right-1 opacity-0 transition-opacity group-focus-within/sql:opacity-100 group-hover/sql:opacity-100", children: _jsx(CopyButton, { text: sqlQuery, tooltipLabel: "Copy SQL query", className: "h-6 w-6" }) })] })), output.success === false ? (_jsx("div", { className: "text-destructive bg-destructive/10 rounded-md p-2 text-xs", children: output.error ?? output.details ?? 'Query execution failed.' })) : (_jsxs(_Fragment, { children: [_jsx("div", { className: "flex items-center gap-1 text-gray-500 dark:text-gray-400", children: _jsxs(Button, { variant: "ghost", size: "xs", onClick: tableModal.onOpen, children: [_jsx(TableIcon, { className: "h-4 w-4" }), _jsx("h3", { className: "text-xs", children: "Show Query Result" })] }) }), _jsx(DataTableModal, { title: title, query: sqlQuery, tableModal: tableModal, formatValue: formatValue })] }))] }));
28
+ };
9
29
  }
30
+ /**
31
+ * Default renderer for query tool results.
32
+ * For custom configuration (showSql, formatValue) use {@link createQueryToolRenderer}.
33
+ */
34
+ export const QueryToolResult = createQueryToolRenderer();
10
35
  //# sourceMappingURL=QueryToolResult.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QueryToolResult.js","sourceRoot":"","sources":["../../../src/tools/query/QueryToolResult.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAavC,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,MAAM,EAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,EAAE,WAAW,EAAC,GAAG,KAAK,CAAC;IAC7D,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,OAAO,CACL,8BACG,OAAO,IAAI,CACV,eAAK,SAAS,EAAC,uHAAuH,aACpI,cAAK,SAAS,EAAC,0CAA0C,YACtD,QAAQ,GACL,EACN,cAAK,SAAS,EAAC,oHAAoH,YACjI,KAAC,UAAU,IACT,IAAI,EAAE,QAAQ,EACd,YAAY,EAAC,gBAAgB,EAC7B,SAAS,EAAC,SAAS,GACnB,GACE,IACF,CACP,EACD,cAAK,SAAS,EAAC,0DAA0D,YACvE,MAAC,MAAM,IAAC,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,UAAU,CAAC,MAAM,aAC1D,KAAC,SAAS,IAAC,SAAS,EAAC,SAAS,GAAG,EACjC,aAAI,SAAS,EAAC,SAAS,kCAAuB,IACvC,GACL,EAEL,YAAY,IAAI,KAAK,CAAC,CAAC,CAAC,CACvB,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CACjB,KAAC,cAAc,IACb,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,GACxB,CACH,CAAC,CAAC,CAAC,CACF,cAAK,SAAS,EAAC,aAAa,wBAAc,CAC3C,CACF,CAAC,CAAC,CAAC,CACF,KAAC,cAAc,IACb,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,QAAQ,EACf,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,GACxB,CACH,IACA,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import {\n ArrowDataTableValueFormatter,\n DataTableModal,\n} from '@sqlrooms/data-table';\nimport {Button, CopyButton, useDisclosure} from '@sqlrooms/ui';\nimport * as arrow from 'apache-arrow';\nimport {TableIcon} from 'lucide-react';\n\ntype QueryToolResultProps = {\n title: string;\n sqlQuery: string;\n /** Provided in case the query result is already an arrow table */\n arrowTable?: arrow.Table;\n /** Whether to show the SQL text in the result */\n showSql?: boolean;\n /** Optional custom value formatter for binary/geometry data */\n formatValue?: ArrowDataTableValueFormatter;\n};\n\nexport function QueryToolResult(props: QueryToolResultProps) {\n const {title, sqlQuery, showSql = true, formatValue} = props;\n const tableModal = useDisclosure();\n return (\n <>\n {showSql && (\n <div className=\"text-muted-foreground group/sql bg-muted relative max-h-[150px] w-full overflow-auto rounded-md p-2 font-mono text-xs\">\n <pre className=\"pr-8 wrap-break-word whitespace-pre-wrap\">\n {sqlQuery}\n </pre>\n <div className=\"absolute top-1 right-1 opacity-0 transition-opacity group-focus-within/sql:opacity-100 group-hover/sql:opacity-100\">\n <CopyButton\n text={sqlQuery}\n tooltipLabel=\"Copy SQL query\"\n className=\"h-6 w-6\"\n />\n </div>\n </div>\n )}\n <div className=\"flex items-center gap-1 text-gray-500 dark:text-gray-400\">\n <Button variant=\"ghost\" size=\"xs\" onClick={tableModal.onOpen}>\n <TableIcon className=\"h-4 w-4\" />\n <h3 className=\"text-xs\">Show Query Result</h3>\n </Button>\n </div>\n\n {'arrowTable' in props ? (\n props.arrowTable ? (\n <DataTableModal\n title={title}\n arrowTable={props.arrowTable}\n tableModal={tableModal}\n formatValue={formatValue}\n />\n ) : (\n <div className=\"p-4 text-xs\">No data</div>\n )\n ) : (\n <DataTableModal\n title={title}\n query={sqlQuery}\n tableModal={tableModal}\n formatValue={formatValue}\n />\n )}\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"QueryToolResult.js","sourceRoot":"","sources":["../../../src/tools/query/QueryToolResult.tsx"],"names":[],"mappings":";AACA,OAAO,EAEL,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAUvC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAkC;IAElC,MAAM,EAAC,OAAO,GAAG,IAAI,EAAE,WAAW,EAAC,GAAG,OAAO,IAAI,EAAE,CAAC;IAEpD,OAAO,SAAS,uBAAuB,CAAC,EACtC,MAAM,EACN,KAAK,GACmD;QACxD,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACzB,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,KAAK,EAAE,QAAQ,IAAI,EAAE,CAAC;QAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,cAAc,CAAC;QAC7C,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC;QAChD,OAAO,CACL,8BACG,aAAa,IAAI,CAChB,eAAK,SAAS,EAAC,uHAAuH,aACpI,cAAK,SAAS,EAAC,kDAAkD,YAC9D,QAAQ,GACL,EACN,cAAK,SAAS,EAAC,oHAAoH,YACjI,KAAC,UAAU,IACT,IAAI,EAAE,QAAQ,EACd,YAAY,EAAC,gBAAgB,EAC7B,SAAS,EAAC,SAAS,GACnB,GACE,IACF,CACP,EACA,MAAM,CAAC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAC1B,cAAK,SAAS,EAAC,2DAA2D,YACvE,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,OAAO,IAAI,yBAAyB,GACxD,CACP,CAAC,CAAC,CAAC,CACF,8BACE,cAAK,SAAS,EAAC,0DAA0D,YACvE,MAAC,MAAM,IAAC,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,UAAU,CAAC,MAAM,aAC1D,KAAC,SAAS,IAAC,SAAS,EAAC,SAAS,GAAG,EACjC,aAAI,SAAS,EAAC,SAAS,kCAAuB,IACvC,GACL,EAEN,KAAC,cAAc,IACb,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,QAAQ,EACf,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,GACxB,IACD,CACJ,IACA,CACJ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,uBAAuB,EAAE,CAAC","sourcesContent":["import type {ToolRenderer, ToolRendererProps} from '@sqlrooms/ai-core';\nimport {\n type ArrowDataTableValueFormatter,\n DataTableModal,\n} from '@sqlrooms/data-table';\nimport {Button, CopyButton, useDisclosure} from '@sqlrooms/ui';\nimport {TableIcon} from 'lucide-react';\nimport type {QueryToolOutput, QueryToolParameters} from './queryTool';\n\nexport type QueryToolRendererOptions = {\n /** Whether to show the SQL text in the result. Defaults to true. */\n showSql?: boolean;\n /** Optional custom value formatter for binary/geometry data */\n formatValue?: ArrowDataTableValueFormatter;\n};\n\n/**\n * Creates a configured renderer for query tool results.\n *\n * @example\n * ```ts\n * toolRenderers: {\n * query: createQueryToolRenderer({\n * showSql: false,\n * formatValue: myGeomFormatter,\n * }),\n * }\n * ```\n */\nexport function createQueryToolRenderer(\n options?: QueryToolRendererOptions,\n): ToolRenderer<QueryToolOutput, QueryToolParameters> {\n const {showSql = true, formatValue} = options ?? {};\n\n return function QueryToolResultRenderer({\n output,\n input,\n }: ToolRendererProps<QueryToolOutput, QueryToolParameters>) {\n const tableModal = useDisclosure();\n if (!output) return null;\n const sqlQuery = output.sqlQuery ?? input?.sqlQuery ?? '';\n const title = output.title ?? 'Query Result';\n const shouldShowSql = output.showSql ?? showSql;\n return (\n <>\n {shouldShowSql && (\n <div className=\"text-muted-foreground group/sql bg-muted relative max-h-[150px] w-full overflow-auto rounded-md p-2 font-mono text-xs\">\n <pre className=\"min-h-4 pr-8 wrap-break-word whitespace-pre-wrap\">\n {sqlQuery}\n </pre>\n <div className=\"absolute top-1 right-1 opacity-0 transition-opacity group-focus-within/sql:opacity-100 group-hover/sql:opacity-100\">\n <CopyButton\n text={sqlQuery}\n tooltipLabel=\"Copy SQL query\"\n className=\"h-6 w-6\"\n />\n </div>\n </div>\n )}\n {output.success === false ? (\n <div className=\"text-destructive bg-destructive/10 rounded-md p-2 text-xs\">\n {output.error ?? output.details ?? 'Query execution failed.'}\n </div>\n ) : (\n <>\n <div className=\"flex items-center gap-1 text-gray-500 dark:text-gray-400\">\n <Button variant=\"ghost\" size=\"xs\" onClick={tableModal.onOpen}>\n <TableIcon className=\"h-4 w-4\" />\n <h3 className=\"text-xs\">Show Query Result</h3>\n </Button>\n </div>\n\n <DataTableModal\n title={title}\n query={sqlQuery}\n tableModal={tableModal}\n formatValue={formatValue}\n />\n </>\n )}\n </>\n );\n };\n}\n\n/**\n * Default renderer for query tool results.\n * For custom configuration (showSql, formatValue) use {@link createQueryToolRenderer}.\n */\nexport const QueryToolResult = createQueryToolRenderer();\n"]}
@@ -2,68 +2,58 @@ import { AiSliceState } from '@sqlrooms/ai-core';
2
2
  import { DuckDbConnector, DuckDbSliceState } from '@sqlrooms/duckdb';
3
3
  import type { StoreApi } from '@sqlrooms/room-shell';
4
4
  import { z } from 'zod';
5
- import { QueryToolResult } from './QueryToolResult';
6
5
  export declare const QueryToolParameters: z.ZodObject<{
7
6
  type: z.ZodLiteral<"query">;
8
7
  sqlQuery: z.ZodString;
9
8
  reasoning: z.ZodString;
10
9
  }, z.core.$strip>;
11
10
  export type QueryToolParameters = z.infer<typeof QueryToolParameters>;
12
- export type QueryToolLlmResult = {
11
+ export type QueryToolOutput = {
13
12
  success: boolean;
14
13
  data?: {
15
14
  type: 'query';
16
15
  summary: Record<string, unknown>[] | null;
17
16
  firstRows?: Record<string, unknown>[];
18
17
  };
19
- details?: string;
20
- errorMessage?: string;
21
- };
22
- export type QueryToolAdditionalData = {
23
18
  title: string;
24
19
  sqlQuery: string;
20
+ details?: string;
21
+ error?: string;
22
+ /**
23
+ * Whether to show the SQL query block in the renderer.
24
+ * Overrides the `showSql` option passed to {@link createQueryToolRenderer}.
25
+ * Defaults to the renderer's `showSql` option when not set (which itself defaults to true).
26
+ */
27
+ showSql?: boolean;
25
28
  };
26
29
  export type QueryToolOptions = {
27
30
  readOnly?: boolean;
28
31
  autoSummary?: boolean;
29
32
  numberOfRowsToShareWithLLM?: number;
30
33
  };
31
- export declare function createQueryTool(store: StoreApi<AiSliceState & DuckDbSliceState>, options?: QueryToolOptions): {
32
- name: string;
33
- description: string;
34
- parameters: z.ZodObject<{
35
- type: z.ZodLiteral<"query">;
36
- sqlQuery: z.ZodString;
37
- reasoning: z.ZodString;
38
- }, z.core.$strip>;
39
- execute: (params: QueryToolParameters, options?: {
40
- abortSignal?: AbortSignal;
41
- }) => Promise<{
42
- llmResult: {
43
- success: boolean;
44
- data: {
45
- firstRows?: Record<string, unknown>[] | undefined;
46
- type: "query";
47
- summary: Record<string, unknown>[] | null;
48
- };
49
- details?: undefined;
50
- errorMessage?: undefined;
51
- };
52
- additionalData: {
53
- title: string;
54
- sqlQuery: string;
55
- };
56
- } | {
57
- llmResult: {
58
- success: boolean;
59
- details: string;
60
- errorMessage: string;
61
- data?: undefined;
62
- };
63
- additionalData?: undefined;
64
- }>;
65
- component: typeof QueryToolResult;
66
- };
34
+ export declare function createQueryTool(store: StoreApi<AiSliceState & DuckDbSliceState>, options?: QueryToolOptions): import("ai").Tool<{
35
+ type: "query";
36
+ sqlQuery: string;
37
+ reasoning: string;
38
+ }, {
39
+ success: boolean;
40
+ data: {
41
+ firstRows?: Record<string, unknown>[] | undefined;
42
+ type: "query";
43
+ summary: Record<string, unknown>[] | null;
44
+ };
45
+ title: string;
46
+ sqlQuery: string;
47
+ details?: undefined;
48
+ error?: undefined;
49
+ } | {
50
+ success: boolean;
51
+ details: string;
52
+ error: string;
53
+ title: string;
54
+ sqlQuery: string;
55
+ data?: undefined;
56
+ }>;
67
57
  /**
68
58
  * Generates summary statistics for a SQL query result
69
59
  * @param connector - DuckDB connection instance
@@ -1 +1 @@
1
- {"version":3,"file":"queryTool.d.ts","sourceRoot":"","sources":["../../../src/tools/query/queryTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAEL,eAAe,EACf,gBAAgB,EAEjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,eAAO,MAAM,mBAAmB;;;;iBAI9B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE;QACL,IAAI,EAAE,OAAO,CAAC;QACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC;QAC1C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;KACvC,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAA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ACF,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC,CAAC;AAEF,wBAAgB,eAAe,CAC7B,KAAK,EAAE,QAAQ,CAAC,YAAY,GAAG,gBAAgB,CAAC,EAChD,OAAO,CAAC,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;GAuG3B;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,WAAW,6CAkB1B"}
@@ -1,6 +1,6 @@
1
+ import { tool } from 'ai';
1
2
  import { arrowTableToJson, splitSqlStatements, } from '@sqlrooms/duckdb';
2
3
  import { z } from 'zod';
3
- import { QueryToolResult } from './QueryToolResult';
4
4
  export const QueryToolParameters = z.object({
5
5
  type: z.literal('query'),
6
6
  sqlQuery: z.string(),
@@ -8,12 +8,11 @@ export const QueryToolParameters = z.object({
8
8
  });
9
9
  export function createQueryTool(store, options) {
10
10
  const { readOnly = true, autoSummary = false, numberOfRowsToShareWithLLM = 0, } = options || {};
11
- return {
12
- name: 'query',
11
+ return tool({
13
12
  description: `A tool for running SQL queries on the tables in the database.
14
- Please only run one query at a time.
15
- If a query fails, please don't try to run it again with the same syntax.`,
16
- parameters: QueryToolParameters,
13
+ Please only run one query at a time.
14
+ If a query fails, please don't try to run it again with the same syntax.`,
15
+ inputSchema: QueryToolParameters,
17
16
  execute: async (params, options) => {
18
17
  const { type, sqlQuery } = params;
19
18
  const abortSignal = options?.abortSignal;
@@ -58,32 +57,36 @@ If a query fails, please don't try to run it again with the same syntax.`,
58
57
  ? arrowTableToJson(result.slice(0, numberOfRowsToShareWithLLM))
59
58
  : [];
60
59
  return {
61
- llmResult: {
62
- success: true,
63
- data: {
64
- type,
65
- summary: summaryData,
66
- ...(numberOfRowsToShareWithLLM > 0 ? { firstRows } : {}),
67
- },
68
- },
69
- additionalData: {
70
- title: 'Query Result',
71
- sqlQuery,
60
+ success: true,
61
+ data: {
62
+ type,
63
+ summary: summaryData,
64
+ ...(numberOfRowsToShareWithLLM > 0 ? { firstRows } : {}),
72
65
  },
66
+ title: 'Query Result',
67
+ sqlQuery,
73
68
  };
74
69
  }
75
70
  catch (error) {
76
71
  return {
77
- llmResult: {
78
- success: false,
79
- details: 'Query execution failed.',
80
- errorMessage: error instanceof Error ? error.message : 'Unknown error',
81
- },
72
+ success: false,
73
+ details: 'Query execution failed.',
74
+ error: error instanceof Error ? error.message : 'Unknown error',
75
+ title: 'Query Result',
76
+ sqlQuery: params.sqlQuery,
82
77
  };
83
78
  }
84
79
  },
85
- component: QueryToolResult,
86
- };
80
+ toModelOutput: ({ output }) => ({
81
+ type: 'text',
82
+ value: JSON.stringify({
83
+ success: output.success,
84
+ data: output.data,
85
+ ...(output.details ? { details: output.details } : {}),
86
+ ...(output.error ? { error: output.error } : {}),
87
+ }),
88
+ }),
89
+ });
87
90
  }
88
91
  /**
89
92
  * Generates summary statistics for a SQL query result
@@ -1 +1 @@
1
- {"version":3,"file":"queryTool.js","sourceRoot":"","sources":["../../../src/tools/query/queryTool.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAGhB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,CAAC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Statements,\n} from '@sqlrooms/duckdb';\nimport type {StoreApi} from '@sqlrooms/room-shell';\nimport {z} from 'zod';\nimport {QueryToolResult} from './QueryToolResult';\n\nexport const QueryToolParameters = z.object({\n type: z.literal('query'),\n sqlQuery: z.string(),\n reasoning: z.string(),\n});\n\nexport type QueryToolParameters = z.infer<typeof QueryToolParameters>;\n\nexport type QueryToolLlmResult = {\n success: boolean;\n data?: {\n type: 'query';\n summary: Record<string, unknown>[] | null;\n firstRows?: Record<string, unknown>[];\n };\n details?: string;\n errorMessage?: string;\n};\n\nexport type QueryToolAdditionalData = {\n title: string;\n sqlQuery: string;\n};\n\nexport type QueryToolOptions = {\n readOnly?: boolean;\n autoSummary?: boolean;\n numberOfRowsToShareWithLLM?: number;\n};\n\nexport function createQueryTool(\n store: StoreApi<AiSliceState & DuckDbSliceState>,\n options?: QueryToolOptions,\n) {\n const {\n readOnly = true,\n autoSummary = false,\n numberOfRowsToShareWithLLM = 0,\n } = options || {};\n return {\n name: 'query',\n description: `A tool for running SQL queries on the tables in the database.\nPlease only run one query at a time.\nIf a query fails, please don't try to run it again with the same syntax.`,\n parameters: QueryToolParameters,\n execute: async (\n params: QueryToolParameters,\n options?: {abortSignal?: AbortSignal},\n ) => {\n const {type, sqlQuery} = params;\n const abortSignal = options?.abortSignal;\n\n try {\n const connector = await store.getState().db.getConnector();\n const parsedQuery = await store.getState().db.sqlSelectToJson(sqlQuery);\n\n if (\n parsedQuery.error &&\n // Only SELECT statements can be serialized to json, so we ignore not implemented errors\n parsedQuery.error_type !== 'not implemented'\n ) {\n throw new Error(parsedQuery.error_message);\n }\n\n if (readOnly) {\n if (parsedQuery.error) {\n throw new Error(\n `Query is not a valid SELECT statement: ${parsedQuery.error_message}`,\n );\n }\n if (\n parsedQuery.statements.length !== 1 || // only one statement allowed\n parsedQuery.statements[0]?.node.type !== 'SELECT_NODE' // only SELECT statements allowed\n ) {\n throw new Error('Query is not a valid SELECT statement');\n }\n }\n\n const result = await connector.query(sqlQuery, {signal: abortSignal});\n\n const summaryData = await (async () => {\n if (!autoSummary) return null;\n if (parsedQuery.error) return null;\n\n const lastNode =\n parsedQuery.statements[parsedQuery.statements.length - 1]?.node;\n\n // Only get summary if the last statement isn't already a SUMMARIZE query\n if (\n lastNode?.type === 'SELECT_NODE' &&\n lastNode?.from_table?.show_type === 'SUMMARY'\n ) {\n return arrowTableToJson(result);\n }\n const statements = splitSqlStatements(sqlQuery);\n const lastStatement = statements[statements.length - 1];\n if (!lastStatement) return null;\n return await getQuerySummary(connector, lastStatement, abortSignal);\n })();\n\n // Conditionally get rows of the result as a json object based on numberOfRowsToShareWithLLM\n const firstRows =\n numberOfRowsToShareWithLLM > 0\n ? arrowTableToJson(result.slice(0, numberOfRowsToShareWithLLM))\n : [];\n\n return {\n llmResult: {\n success: true,\n data: {\n type,\n summary: summaryData,\n ...(numberOfRowsToShareWithLLM > 0 ? {firstRows} : {}),\n },\n },\n additionalData: {\n title: 'Query Result',\n sqlQuery,\n },\n };\n } catch (error) {\n return {\n llmResult: {\n success: false,\n details: 'Query execution failed.',\n errorMessage:\n error instanceof Error ? error.message : 'Unknown error',\n },\n };\n }\n },\n component: QueryToolResult,\n };\n}\n\n/**\n * Generates summary statistics for a SQL query result\n * @param connector - DuckDB connection instance\n * @param sqlQuery - SQL SELECT query to analyze\n * @returns Summary statistics as JSON object, or null if the query is not a SELECT statement or if summary generation fails\n */\nexport async function getQuerySummary(\n connector: DuckDbConnector,\n sqlQuery: string,\n abortSignal?: AbortSignal,\n) {\n if (!sqlQuery.toLowerCase().trim().startsWith('select')) {\n return null;\n }\n\n try {\n const summaryResult = await connector.query(\n `SUMMARIZE (\n ${sqlQuery}\n )`,\n {signal: abortSignal},\n );\n return arrowTableToJson(summaryResult);\n } catch (error) {\n console.warn('Failed to get summary for query. Error:', error);\n return null;\n }\n}\n"]}
1
+ {"version":3,"file":"queryTool.js","sourceRoot":"","sources":["../../../src/tools/query/queryTool.ts"],"names":[],"mappings":"AAAA,OAAO,E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,CAAC;KACH,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,SAA0B,EAC1B,QAAgB,EAChB,WAAyB;IAEzB,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,KAAK,CACzC;QACE,QAAQ;MACV,EACA,EAAC,MAAM,EAAE,WAAW,EAAC,CACtB,CAAC;QACF,OAAO,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import {tool} from 'ai';\nimport {AiSliceState} from '@sqlrooms/ai-core';\nimport {\n arrowTableToJson,\n DuckDbConnector,\n DuckDbSliceState,\n splitSqlStatements,\n} from '@sqlrooms/duckdb';\nimport type {StoreApi} from '@sqlrooms/room-shell';\nimport {z} from 'zod';\n\nexport const QueryToolParameters = z.object({\n type: z.literal('query'),\n sqlQuery: z.string(),\n reasoning: z.string(),\n});\n\nexport type QueryToolParameters = z.infer<typeof QueryToolParameters>;\n\nexport type QueryToolOutput = {\n success: boolean;\n data?: {\n type: 'query';\n summary: Record<string, unknown>[] | null;\n firstRows?: Record<string, unknown>[];\n };\n title: string;\n sqlQuery: string;\n details?: string;\n error?: string;\n /**\n * Whether to show the SQL query block in the renderer.\n * Overrides the `showSql` option passed to {@link createQueryToolRenderer}.\n * Defaults to the renderer's `showSql` option when not set (which itself defaults to true).\n */\n showSql?: boolean;\n};\n\nexport type QueryToolOptions = {\n readOnly?: boolean;\n autoSummary?: boolean;\n numberOfRowsToShareWithLLM?: number;\n};\n\nexport function createQueryTool(\n store: StoreApi<AiSliceState & DuckDbSliceState>,\n options?: QueryToolOptions,\n) {\n const {\n readOnly = true,\n autoSummary = false,\n numberOfRowsToShareWithLLM = 0,\n } = options || {};\n return tool({\n description: `A tool for running SQL queries on the tables in the database.\n Please only run one query at a time.\n If a query fails, please don't try to run it again with the same syntax.`,\n inputSchema: QueryToolParameters,\n execute: async (\n params: QueryToolParameters,\n options?: {abortSignal?: AbortSignal},\n ) => {\n const {type, sqlQuery} = params;\n const abortSignal = options?.abortSignal;\n\n try {\n const connector = await store.getState().db.getConnector();\n const parsedQuery = await store.getState().db.sqlSelectToJson(sqlQuery);\n\n if (\n parsedQuery.error &&\n // Only SELECT statements can be serialized to json, so we ignore not implemented errors\n parsedQuery.error_type !== 'not implemented'\n ) {\n throw new Error(parsedQuery.error_message);\n }\n\n if (readOnly) {\n if (parsedQuery.error) {\n throw new Error(\n `Query is not a valid SELECT statement: ${parsedQuery.error_message}`,\n );\n }\n if (\n parsedQuery.statements.length !== 1 || // only one statement allowed\n parsedQuery.statements[0]?.node.type !== 'SELECT_NODE' // only SELECT statements allowed\n ) {\n throw new Error('Query is not a valid SELECT statement');\n }\n }\n\n const result = await connector.query(sqlQuery, {signal: abortSignal});\n\n const summaryData = await (async () => {\n if (!autoSummary) return null;\n if (parsedQuery.error) return null;\n\n const lastNode =\n parsedQuery.statements[parsedQuery.statements.length - 1]?.node;\n\n // Only get summary if the last statement isn't already a SUMMARIZE query\n if (\n lastNode?.type === 'SELECT_NODE' &&\n lastNode?.from_table?.show_type === 'SUMMARY'\n ) {\n return arrowTableToJson(result);\n }\n const statements = splitSqlStatements(sqlQuery);\n const lastStatement = statements[statements.length - 1];\n if (!lastStatement) return null;\n return await getQuerySummary(connector, lastStatement, abortSignal);\n })();\n\n // Conditionally get rows of the result as a json object based on numberOfRowsToShareWithLLM\n const firstRows =\n numberOfRowsToShareWithLLM > 0\n ? arrowTableToJson(result.slice(0, numberOfRowsToShareWithLLM))\n : [];\n\n return {\n success: true,\n data: {\n type,\n summary: summaryData,\n ...(numberOfRowsToShareWithLLM > 0 ? {firstRows} : {}),\n },\n title: 'Query Result',\n sqlQuery,\n };\n } catch (error) {\n return {\n success: false,\n details: 'Query execution failed.',\n error: error instanceof Error ? error.message : 'Unknown error',\n title: 'Query Result',\n sqlQuery: params.sqlQuery,\n };\n }\n },\n toModelOutput: ({output}: {output: QueryToolOutput}) => ({\n type: 'text',\n value: JSON.stringify({\n success: output.success,\n data: output.data,\n ...(output.details ? {details: output.details} : {}),\n ...(output.error ? {error: output.error} : {}),\n }),\n }),\n });\n}\n\n/**\n * Generates summary statistics for a SQL query result\n * @param connector - DuckDB connection instance\n * @param sqlQuery - SQL SELECT query to analyze\n * @returns Summary statistics as JSON object, or null if the query is not a SELECT statement or if summary generation fails\n */\nexport async function getQuerySummary(\n connector: DuckDbConnector,\n sqlQuery: string,\n abortSignal?: AbortSignal,\n) {\n if (!sqlQuery.toLowerCase().trim().startsWith('select')) {\n return null;\n }\n\n try {\n const summaryResult = await connector.query(\n `SUMMARIZE (\n ${sqlQuery}\n )`,\n {signal: abortSignal},\n );\n return arrowTableToJson(summaryResult);\n } catch (error) {\n console.warn('Failed to get summary for query. Error:', error);\n return null;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqlrooms/ai",
3
- "version": "0.29.0-rc.0",
3
+ "version": "0.29.0-rc.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -10,7 +10,7 @@
10
10
  "license": "MIT",
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "https://github.com/sqlrooms/sqlrooms.git"
13
+ "url": "git+https://github.com/sqlrooms/sqlrooms.git"
14
14
  },
15
15
  "files": [
16
16
  "dist"
@@ -19,14 +19,14 @@
19
19
  "access": "public"
20
20
  },
21
21
  "dependencies": {
22
- "@openassistant/utils": "1.0.0-alpha.0",
23
- "@sqlrooms/ai-config": "0.29.0-rc.0",
24
- "@sqlrooms/ai-core": "0.29.0-rc.0",
25
- "@sqlrooms/ai-settings": "0.29.0-rc.0",
26
- "@sqlrooms/data-table": "0.29.0-rc.0",
27
- "@sqlrooms/duckdb": "0.29.0-rc.0",
28
- "@sqlrooms/room-shell": "0.29.0-rc.0",
29
- "@sqlrooms/ui": "0.29.0-rc.0",
22
+ "@sqlrooms/ai-config": "0.29.0-rc.2",
23
+ "@sqlrooms/ai-core": "0.29.0-rc.2",
24
+ "@sqlrooms/ai-settings": "0.29.0-rc.2",
25
+ "@sqlrooms/data-table": "0.29.0-rc.2",
26
+ "@sqlrooms/duckdb": "0.29.0-rc.2",
27
+ "@sqlrooms/room-shell": "0.29.0-rc.2",
28
+ "@sqlrooms/ui": "0.29.0-rc.2",
29
+ "ai": "^6.0.154",
30
30
  "lucide-react": "^0.556.0",
31
31
  "zod": "^4.1.8"
32
32
  },
@@ -42,5 +42,5 @@
42
42
  "typecheck": "tsc --noEmit",
43
43
  "typedoc": "typedoc"
44
44
  },
45
- "gitHead": "afdb949c9601b4cdeaae966157a25a54aea2ae54"
45
+ "gitHead": "5d511631992c1af8852ea79ced488867aad4a555"
46
46
  }