@datagrok/grokky 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/.claude/skills/deploy-grokky/SKILL.md +193 -0
  2. package/.grokignore +2 -0
  3. package/.turbo/turbo-build.log +24 -0
  4. package/.vscode/settings.json +16 -0
  5. package/CHANGELOG.md +151 -8
  6. package/CLAUDE.md +284 -0
  7. package/CREDITS.md +173 -0
  8. package/LICENSE.md +16 -0
  9. package/README.md +24 -0
  10. package/bdd/bdd.config.json +1 -0
  11. package/bdd/bindings/elements.ts +9 -0
  12. package/bdd/bindings/steps.ts +787 -0
  13. package/bdd/features/ai-panel/platform-work.feature +63 -0
  14. package/bdd/features/ai-panel/session.feature +69 -0
  15. package/bdd/features/ai-panel/table-work.feature +99 -0
  16. package/bdd/generated/ai-panel/platform-work.test.ts +103 -0
  17. package/bdd/generated/ai-panel/session.test.ts +100 -0
  18. package/bdd/generated/ai-panel/table-work.test.ts +150 -0
  19. package/bdd/package.json +1 -0
  20. package/bdd/tsconfig.json +13 -0
  21. package/css/ai.css +637 -49
  22. package/dist/package-test.js +4 -1707
  23. package/dist/package-test.js.map +1 -1
  24. package/dist/package.js +742 -92317
  25. package/dist/package.js.map +1 -1
  26. package/dockerfiles/claude-runtime/.dockerignore +1 -0
  27. package/{.eslintrc.json → dockerfiles/claude-runtime/.eslintrc.json} +7 -16
  28. package/dockerfiles/claude-runtime/Dockerfile +73 -13
  29. package/dockerfiles/claude-runtime/agent/grokky_agent/__init__.py +0 -0
  30. package/dockerfiles/claude-runtime/agent/grokky_agent/__main__.py +80 -0
  31. package/dockerfiles/claude-runtime/agent/grokky_agent/browser_tools.py +180 -0
  32. package/dockerfiles/claude-runtime/agent/grokky_agent/config.py +26 -0
  33. package/dockerfiles/claude-runtime/agent/grokky_agent/formats.py +155 -0
  34. package/dockerfiles/claude-runtime/agent/grokky_agent/guard.py +87 -0
  35. package/dockerfiles/claude-runtime/agent/grokky_agent/hermes.py +212 -0
  36. package/dockerfiles/claude-runtime/agent/grokky_agent/hermes.yaml +45 -0
  37. package/dockerfiles/claude-runtime/agent/grokky_agent/hermes_plugin/__init__.py +8 -0
  38. package/dockerfiles/claude-runtime/agent/grokky_agent/hermes_plugin/plugin.yaml +3 -0
  39. package/dockerfiles/claude-runtime/agent/grokky_agent/protocol.py +174 -0
  40. package/dockerfiles/claude-runtime/agent/grokky_agent/providers/__init__.py +21 -0
  41. package/dockerfiles/claude-runtime/agent/grokky_agent/providers/anthropic.py +21 -0
  42. package/dockerfiles/claude-runtime/agent/grokky_agent/providers/azure.py +46 -0
  43. package/dockerfiles/claude-runtime/agent/grokky_agent/providers/base.py +127 -0
  44. package/dockerfiles/claude-runtime/agent/grokky_agent/providers/bedrock.py +46 -0
  45. package/dockerfiles/claude-runtime/agent/grokky_agent/providers/custom.py +40 -0
  46. package/dockerfiles/claude-runtime/agent/grokky_agent/providers/databricks.py +54 -0
  47. package/dockerfiles/claude-runtime/agent/grokky_agent/providers/openai_platform.py +41 -0
  48. package/dockerfiles/claude-runtime/agent/grokky_agent/providers/openrouter.py +46 -0
  49. package/dockerfiles/claude-runtime/agent/grokky_agent/session.py +471 -0
  50. package/dockerfiles/claude-runtime/agent/grokky_agent/skills.py +44 -0
  51. package/dockerfiles/claude-runtime/agent/grokky_agent/structured.py +40 -0
  52. package/dockerfiles/claude-runtime/container.json +2 -2
  53. package/dockerfiles/claude-runtime/entrypoint.sh +20 -0
  54. package/dockerfiles/claude-runtime/package-lock.json +1721 -306
  55. package/dockerfiles/claude-runtime/package.json +20 -5
  56. package/dockerfiles/claude-runtime/plugin/.claude-plugin/plugin.json +5 -0
  57. package/dockerfiles/claude-runtime/plugin/skills/datagrok-calc-column/SKILL.md +92 -0
  58. package/dockerfiles/claude-runtime/plugin/skills/datagrok-chem-data/SKILL.md +250 -0
  59. package/dockerfiles/claude-runtime/plugin/skills/datagrok-chem-toolkit/SKILL.md +395 -0
  60. package/dockerfiles/claude-runtime/plugin/skills/datagrok-df-and-columns/SKILL.md +454 -0
  61. package/dockerfiles/claude-runtime/plugin/skills/datagrok-entities/SKILL.md +38 -0
  62. package/dockerfiles/claude-runtime/plugin/skills/datagrok-exec/SKILL.md +209 -0
  63. package/dockerfiles/claude-runtime/plugin/skills/datagrok-filtering/SKILL.md +185 -0
  64. package/dockerfiles/claude-runtime/plugin/skills/datagrok-grid-customization/SKILL.md +270 -0
  65. package/dockerfiles/claude-runtime/plugin/skills/datagrok-projects/SKILL.md +100 -0
  66. package/dockerfiles/claude-runtime/plugin/skills/datagrok-selection/SKILL.md +344 -0
  67. package/dockerfiles/claude-runtime/plugin/skills/datagrok-undo/SKILL.md +78 -0
  68. package/dockerfiles/claude-runtime/plugin/skills/datagrok-viewers/SKILL.md +303 -0
  69. package/dockerfiles/claude-runtime/pyproject.toml +18 -0
  70. package/dockerfiles/claude-runtime/src/agent/pool.ts +411 -0
  71. package/dockerfiles/claude-runtime/src/agent/turn.ts +153 -0
  72. package/dockerfiles/claude-runtime/src/constants.ts +20 -0
  73. package/dockerfiles/claude-runtime/src/credentials.ts +45 -0
  74. package/dockerfiles/claude-runtime/src/grounding.ts +104 -0
  75. package/dockerfiles/claude-runtime/src/help-index.ts +118 -0
  76. package/dockerfiles/claude-runtime/src/privileges.ts +8 -0
  77. package/dockerfiles/claude-runtime/src/prompts.ts +211 -0
  78. package/dockerfiles/claude-runtime/src/server.ts +134 -234
  79. package/dockerfiles/claude-runtime/src/session.ts +328 -0
  80. package/dockerfiles/claude-runtime/src/shared-api-client.ts +112 -0
  81. package/dockerfiles/claude-runtime/src/stream-filter.ts +80 -0
  82. package/dockerfiles/claude-runtime/src/sync/home-files.ts +80 -0
  83. package/dockerfiles/claude-runtime/src/sync/orchestrator.ts +214 -0
  84. package/dockerfiles/claude-runtime/src/sync/packages.ts +145 -0
  85. package/dockerfiles/claude-runtime/src/sync/shared-connections.ts +87 -0
  86. package/dockerfiles/claude-runtime/src/sync/workspace.ts +68 -0
  87. package/dockerfiles/claude-runtime/src/tasks.ts +124 -0
  88. package/dockerfiles/claude-runtime/src/tool-summary.ts +66 -0
  89. package/dockerfiles/claude-runtime/src/types.ts +142 -23
  90. package/dockerfiles/claude-runtime/src/user/installed-packages.ts +17 -0
  91. package/dockerfiles/claude-runtime/src/user/staged-workspace.ts +80 -0
  92. package/dockerfiles/claude-runtime/src/user/user-dir.ts +108 -0
  93. package/dockerfiles/claude-runtime/src/verify.ts +136 -0
  94. package/dockerfiles/claude-runtime/src/watchdog.ts +115 -0
  95. package/dockerfiles/claude-runtime/test/credentials.test.js +43 -0
  96. package/dockerfiles/claude-runtime/test/grounding.test.js +191 -0
  97. package/dockerfiles/claude-runtime/test/help-index.test.js +115 -0
  98. package/dockerfiles/claude-runtime/test/plugin-skills.test.js +57 -0
  99. package/dockerfiles/claude-runtime/test/prompts.test.js +62 -0
  100. package/dockerfiles/claude-runtime/test/reaper.test.js +60 -0
  101. package/dockerfiles/claude-runtime/test/stream-filter.test.js +132 -0
  102. package/dockerfiles/claude-runtime/test/tasks.test.js +74 -0
  103. package/dockerfiles/claude-runtime/test/user-dir.test.js +71 -0
  104. package/dockerfiles/claude-runtime/test/verify.test.js +187 -0
  105. package/dockerfiles/claude-runtime/test/watchdog.test.js +43 -0
  106. package/dockerfiles/mcp-server/.eslintrc.json +39 -0
  107. package/dockerfiles/mcp-server/Dockerfile +10 -2
  108. package/dockerfiles/mcp-server/package-lock.json +1743 -98
  109. package/dockerfiles/mcp-server/package.json +27 -5
  110. package/dockerfiles/mcp-server/src/api-client.ts +123 -66
  111. package/dockerfiles/mcp-server/src/format.ts +51 -0
  112. package/dockerfiles/mcp-server/src/index.ts +44 -113
  113. package/dockerfiles/mcp-server/src/ops.ts +325 -0
  114. package/dockerfiles/mcp-server/src/shared-api-client.ts +81 -0
  115. package/dockerfiles/mcp-server/test/format.test.js +62 -0
  116. package/dockerfiles/mcp-server/test/ops.test.js +84 -0
  117. package/dockerfiles/mcp-server/test/shared-api-client.test.js +35 -0
  118. package/dockerfiles/queue/Dockerfile +2 -0
  119. package/dockerfiles/queue/container.json +7 -0
  120. package/docs/AUDIT-2026-08-03.md +1064 -0
  121. package/docs/BENCHMARK.md +292 -0
  122. package/docs/CLAUDE_CODE_FLOW.md +746 -0
  123. package/docs/EXAMPLES.md +82 -0
  124. package/docs/FEATURES.md +71 -0
  125. package/docs/IMPLEMENTATION.md +128 -0
  126. package/docs/LATENCY.md +170 -0
  127. package/docs/VISION.md +36 -0
  128. package/files/benchmark/suite.yaml +404 -0
  129. package/files/scripts/process-cro-results.md +14 -0
  130. package/files/suggestions.yaml +344 -0
  131. package/package.json +39 -97
  132. package/src/ai/ai-window.ts +157 -0
  133. package/src/ai/benchmark/benchmark.ts +737 -0
  134. package/src/ai/db-view-functions.ts +56 -0
  135. package/src/ai/engine.ts +98 -0
  136. package/src/ai/gemma-engine.ts +81 -0
  137. package/src/ai/panel.ts +1385 -0
  138. package/src/ai/prompt-suggestions.ts +209 -0
  139. package/src/ai/search/combined-search.ts +244 -0
  140. package/src/{llm-utils → ai/search}/query-matching.ts +46 -167
  141. package/src/{llm-utils → ai}/storage.ts +0 -1
  142. package/src/ai/table-tools.ts +145 -0
  143. package/src/ai/ui.ts +720 -0
  144. package/src/ai/usage-limiter.ts +105 -0
  145. package/src/ai/view-tools.ts +352 -0
  146. package/src/claude/ai-feature.ts +16 -0
  147. package/src/claude/exec-blocks.ts +176 -0
  148. package/src/claude/queue-task.ts +84 -0
  149. package/src/claude/runtime-client.ts +310 -0
  150. package/src/claude/turn-log.ts +114 -0
  151. package/src/claude/undoable.ts +105 -0
  152. package/src/{llm-utils → db}/db-index-tools.ts +24 -32
  153. package/src/db/sql-tools.ts +336 -0
  154. package/src/depr/LLM-client.ts +251 -0
  155. package/src/depr/ai-panel.ts +174 -0
  156. package/src/depr/chatgpt-assistant.ts +257 -0
  157. package/src/depr/creds.ts +30 -0
  158. package/src/depr/deepwikiclient.ts +118 -0
  159. package/src/depr/indexes/dg-repository-index.ts +266 -0
  160. package/src/depr/interfaces.ts +170 -0
  161. package/src/depr/is-help-request.ts +39 -0
  162. package/src/depr/prompt-engine.ts +52 -0
  163. package/src/depr/rendering-tools.ts +103 -0
  164. package/src/depr/script-tools.ts +785 -0
  165. package/src/depr/tableview-tools.ts +746 -0
  166. package/src/depr/viewers-ai.ts +67 -0
  167. package/src/package-api.ts +87 -28
  168. package/src/package-test.ts +1 -0
  169. package/src/package.g.ts +98 -48
  170. package/src/package.ts +211 -157
  171. package/src/polyfills.ts +12 -0
  172. package/src/utils.ts +128 -0
  173. package/tsconfig.json +8 -70
  174. package/webpack.config.js +3 -49
  175. package/.eslintignore +0 -2
  176. package/src/ai-panel.ts +0 -174
  177. package/src/claude-code/claude-panel.ts +0 -34
  178. package/src/claude-code/claude-runtime-client.ts +0 -148
  179. package/src/llm-utils/LLM-client.ts +0 -251
  180. package/src/llm-utils/combined-search.ts +0 -162
  181. package/src/llm-utils/creds.ts +0 -30
  182. package/src/llm-utils/deepwikiclient.ts +0 -118
  183. package/src/llm-utils/indexes/dg-repository-index.ts +0 -266
  184. package/src/llm-utils/panel.ts +0 -866
  185. package/src/llm-utils/script-tools.ts +0 -784
  186. package/src/llm-utils/sql-tools.ts +0 -840
  187. package/src/llm-utils/tableview-tools.ts +0 -704
  188. package/src/llm-utils/ui.ts +0 -315
  189. package/src/prompt-engine/chatgpt-assistant.ts +0 -257
  190. package/src/prompt-engine/interfaces.ts +0 -170
  191. package/src/prompt-engine/prompt-engine.ts +0 -52
  192. package/src/prompt-engine/rendering-tools.ts +0 -103
  193. package/src/prompts/is-help-request.ts +0 -26
  194. package/src/viewers-ai.ts +0 -67
  195. /package/src/{llm-utils → db}/indexes/biologics-index.ts +0 -0
  196. /package/src/{llm-utils → db}/indexes/chembl-index.ts +0 -0
  197. /package/src/{llm-utils → db}/query-meta-utils.ts +0 -0
  198. /package/src/{llm-utils/depr → depr}/AI-API-providers/openai-chat-completions-provider.ts +0 -0
  199. /package/src/{llm-utils/depr → depr}/AI-API-providers/openai-responses-provider.ts +0 -0
  200. /package/src/{llm-utils/depr → depr}/AI-API-providers/types.ts +0 -0
  201. /package/src/{llm-utils/depr → depr}/depr.ts +0 -0
  202. /package/src/{llm-utils/depr → depr}/embeddings.ts +0 -0
  203. /package/src/{llm-utils/depr → depr}/sql-utils.ts +0 -0
@@ -0,0 +1,67 @@
1
+ // import * as grok from 'datagrok-api/grok';
2
+ // import * as ui from 'datagrok-api/ui';
3
+ // import * as DG from 'datagrok-api/dg';
4
+ // import {getCurrentViewersString, getDataFrameDescription, getViewerDescriptionsString} from '../../utils';
5
+ // import {ModelType, LLMClient} from './LLM-client';
6
+
7
+ // type IViewerResponse = {
8
+ // viewerType: string;
9
+ // properties: {[index: string]: any};
10
+ // }
11
+
12
+ // /**
13
+ // * Examples of queries:
14
+ // * - plot width by height
15
+ // * - show me age distribution
16
+ // * - age distribution by disease
17
+ // * - plot age, height, and weight on the 3d scatter plot
18
+ // * - Plot width by height in a trellis plot split by race
19
+ // * - Plot weight by height for selected rows only
20
+ // * - form with all columns starting with "s"
21
+ // * */
22
+ // export async function askAiTableView(view: DG.TableView, question: string) {
23
+ // const prompt = getPrompt(view, question);
24
+ // //console.log(prompt);
25
+ // // TODO: substitute with the OpenAI client call
26
+ // const res = LLMClient.getInstance();
27
+ // const answer = await res.generalPromptCached(ModelType.Fast, '', prompt);
28
+ // //console.log(answer);
29
+ // //grok.shell.info(answer);
30
+
31
+ // const response: IViewerResponse = JSON.parse(answer);
32
+ // if (DG.Viewer.CORE_VIEWER_TYPES.includes(response.viewerType))
33
+ // view.addViewer(response.viewerType, response.properties);
34
+ // }
35
+
36
+ // export function askAiTableViewDialog(view: DG.TableView) {
37
+ // const input = ui.input.textArea('Question', {value: 'Plot width by height'});
38
+
39
+ // ui.dialog('Ask AI')
40
+ // .addInput('Question', input)
41
+ // .onOK(async () => {
42
+ // askAiTableView(view, input.value);
43
+ // })
44
+ // .show();
45
+ // }
46
+
47
+ // const getPrompt = (view: DG.TableView, question: string) => {
48
+ // return `
49
+ // Below is the structure of the dataframe a user is working with, and the interfaces for Datagrok visualizations.
50
+ // Your task is to identify which visualization to use, and which properties to set for what the user asks.
51
+ // For column name properties, you can only use names from the dataframe.
52
+ // Give the answer in the JSON format that can be directly parsed (no annotations or anything like that)
53
+ // with the "viewerType" identifying viewer type, and
54
+ // "properties" containing properties, like in this example:
55
+ // {"viewerType": "Histogram", "properties": {"valueColumnName": "Age", "markerSize": 15}}
56
+
57
+ // ${getCurrentViewersString(view)}
58
+
59
+ // User question: ${question}
60
+
61
+ // DataFrame structure:
62
+ // ${JSON.stringify(getDataFrameDescription(view.dataFrame))}
63
+
64
+ // Viewers:
65
+ // ${getViewerDescriptionsString()}`;
66
+ // };
67
+
@@ -20,61 +20,120 @@ export namespace funcs {
20
20
  return await grok.functions.call('Grokky:CombinedLLMSearchProvider', {});
21
21
  }
22
22
 
23
+ export async function gemmaEngine(): Promise<any> {
24
+ return await grok.functions.call('Grokky:GemmaEngine', {});
25
+ }
26
+
27
+ export async function claudeEngine(): Promise<any> {
28
+ return await grok.functions.call('Grokky:ClaudeEngine', {});
29
+ }
30
+
23
31
  /**
24
- Get answers from DeepGROK AI assistant based on Datagrok documentation and public code.
25
- */
26
- export async function askHelpLLMProvider(prompt: string ): Promise<any> {
27
- return await grok.functions.call('Grokky:AskHelpLLMProvider', { prompt });
32
+ * Get answers from AI assistant based on Datagrok documentation and public code.
33
+ */
34
+ export async function askHelpLLMProvider(prompt: string , sessionId?: string ): Promise<any> {
35
+ return await grok.functions.call('Grokky:AskHelpLLMProvider', { prompt, sessionId });
28
36
  }
29
37
 
30
38
  /**
31
- Plans and executes function steps to achieve needed results
32
- */
33
- export async function smartChainExecutionProvider(prompt: string ): Promise<any> {
34
- return await grok.functions.call('Grokky:SmartChainExecutionProvider', { prompt });
39
+ * Run the Grokky latency/accuracy benchmark suite (files/benchmark/suite.yaml) and download a JSON + Markdown report tagged with the given label. Run after logging in; open no special view.
40
+ * @param {string} label - Config label for this run, e.g. baseline / medium-effort
41
+ * @param {number} reps - Repetitions per prompt (default 3)
42
+ * @param {string} only - Run only part of the suite: comma-separated categories, difficulties, or prompt substrings.
43
+ */
44
+ export async function runBenchmark(label: string , reps?: number , only?: string ): Promise<string> {
45
+ return await grok.functions.call('Grokky:RunBenchmark', { label, reps, only });
35
46
  }
36
47
 
37
48
  /**
38
- Tries to find a query which has the similar pattern as the prompt user entered and executes it
39
- */
40
- export async function llmSearchQueryProvider(prompt: string ): Promise<any> {
41
- return await grok.functions.call('Grokky:LlmSearchQueryProvider', { prompt });
49
+ * Holds the admission slot for one AI chat turn streaming over the browser WebSocket - see queue-task.ts
50
+ */
51
+ export async function aiChatTurnTask(sessionId: string , taskId: string ): Promise<string> {
52
+ return await grok.functions.call('Grokky:AiChatTurnTask', { sessionId, taskId });
42
53
  }
43
54
 
44
- export async function askAIGeneralCached(model: string , systemPrompt: string , prompt: string , schema: any ): Promise<string> {
45
- return await grok.functions.call('Grokky:AskAIGeneralCached', { model, systemPrompt, prompt, schema });
55
+ /**
56
+ * Compare two or more saved benchmark runs (comma-separated labels) into one Markdown report and download it.
57
+ * @param {string} labels - Comma-separated run labels, the first being the reference arm
58
+ */
59
+ export async function compareBenchmarks(labels: string ): Promise<string> {
60
+ return await grok.functions.call('Grokky:CompareBenchmarks', { labels });
46
61
  }
47
62
 
48
- export async function ask(question: string ): Promise<string> {
49
- return await grok.functions.call('Grokky:Ask', { question });
63
+ /**
64
+ * Plans and executes function steps to achieve needed results
65
+ */
66
+ export async function smartChainExecutionProvider(prompt: string , sessionId?: string ): Promise<any> {
67
+ return await grok.functions.call('Grokky:SmartChainExecutionProvider', { prompt, sessionId });
50
68
  }
51
69
 
52
- export async function getExecutionPlan(userGoal: string ): Promise<string> {
53
- return await grok.functions.call('Grokky:GetExecutionPlan', { userGoal });
70
+ /**
71
+ * Tries to find a query which has the similar pattern as the prompt user entered and executes it
72
+ */
73
+ export async function llmSearchQueryProvider(prompt: string , sessionId?: string ): Promise<any> {
74
+ return await grok.functions.call('Grokky:LlmSearchQueryProvider', { prompt, sessionId });
54
75
  }
55
76
 
56
77
  export async function findMatchingPatternQuery(prompt: string ): Promise<string> {
57
78
  return await grok.functions.call('Grokky:FindMatchingPatternQuery', { prompt });
58
79
  }
59
80
 
60
- export async function askDocumentationCached(prompt: string ): Promise<string> {
61
- return await grok.functions.call('Grokky:AskDocumentationCached', { prompt });
62
- }
63
-
64
81
  export async function setupAIQueryEditor(view: DG.View , connectionID: string , queryEditorRoot: any , setAndRunFunc: any ): Promise<boolean> {
65
82
  return await grok.functions.call('Grokky:SetupAIQueryEditor', { view, connectionID, queryEditorRoot, setAndRunFunc });
66
83
  }
67
84
 
68
- export async function moveMetaToDB(dbName: string ): Promise<void> {
69
- return await grok.functions.call('Grokky:MoveMetaToDB', { dbName });
85
+ /**
86
+ * List the catalogs available on this connection
87
+ */
88
+ export async function listDbCatalogs(view: DG.View ): Promise<string> {
89
+ return await grok.functions.call('Grokky:ListDbCatalogs', { view });
90
+ }
91
+
92
+ /**
93
+ * List schemas of a catalog (defaults to the connection default catalog)
94
+ */
95
+ export async function listDbSchemas(view: DG.View , catalogName?: string ): Promise<string> {
96
+ return await grok.functions.call('Grokky:ListDbSchemas', { view, catalogName });
97
+ }
98
+
99
+ /**
100
+ * List tables of a schema with row counts
101
+ */
102
+ export async function listDbTables(view: DG.View , schemaName: string , catalogName?: string ): Promise<string> {
103
+ return await grok.functions.call('Grokky:ListDbTables', { view, schemaName, catalogName });
104
+ }
105
+
106
+ /**
107
+ * Detailed column info (types, comments, ranges, sample values) for the given tables. Table refs: catalog.schema.table, schema.table, or table
108
+ * @param {string} tables - Comma-separated table references to describe
109
+ */
110
+ export async function getDbTableDetails(view: DG.View , tables: string ): Promise<string> {
111
+ return await grok.functions.call('Grokky:GetDbTableDetails', { view, tables });
70
112
  }
71
113
 
72
- export async function setupVectorStore(): Promise<void> {
73
- return await grok.functions.call('Grokky:SetupVectorStore', {});
114
+ /**
115
+ * Foreign-key relationships involving the given tables — use to build correct JOINs
116
+ * @param {string} tables - Comma-separated table references
117
+ */
118
+ export async function listDbJoins(view: DG.View , tables: string ): Promise<string> {
119
+ return await grok.functions.call('Grokky:ListDbJoins', { view, tables });
120
+ }
121
+
122
+ /**
123
+ * Test-execute a SELECT (auto-LIMITed) and report row count, columns, and a sample row. Use to validate SQL before setQueryAndRun
124
+ * @param {string} sql - The SQL to test
125
+ * @param {string} description - One line describing what the query does
126
+ */
127
+ export async function getSqlTestResult(view: DG.View , sql: string , description: string ): Promise<string> {
128
+ return await grok.functions.call('Grokky:GetSqlTestResult', { view, sql, description });
74
129
  }
75
130
 
76
- export async function searchForSomething(): Promise<void> {
77
- return await grok.functions.call('Grokky:SearchForSomething', {});
131
+ /**
132
+ * @param {string} dbName
133
+ * choices: ["biologics","chembl"]
134
+ */
135
+ export async function moveMetaToDB(dbName: string ): Promise<void> {
136
+ return await grok.functions.call('Grokky:MoveMetaToDB', { dbName });
78
137
  }
79
138
 
80
139
  export async function indexDatabaseSchema(): Promise<void> {
@@ -1,3 +1,4 @@
1
+ import './polyfills'; // must run before anything else, see polyfills.ts
1
2
  import * as DG from "datagrok-api/dg";
2
3
  import * as grok from 'datagrok-api/grok';
3
4
  import { runTests, tests, TestContext } from '@datagrok-libraries/test/src/test';
package/src/package.g.ts CHANGED
@@ -19,101 +19,151 @@ export function combinedLLMSearchProvider() : any {
19
19
  return PackageFunctions.combinedLLMSearchProvider();
20
20
  }
21
21
 
22
+ //output: dynamic result
23
+ //meta.role: aiEngine
24
+ export function gemmaEngine() : any {
25
+ return PackageFunctions.gemmaEngine();
26
+ }
27
+
28
+ //output: dynamic result
29
+ //meta.role: aiEngine
30
+ export function claudeEngine() : any {
31
+ return PackageFunctions.claudeEngine();
32
+ }
33
+
22
34
  //name: Help
23
- //description: Get answers from DeepGROK AI assistant based on Datagrok documentation and public code.
35
+ //description: Get answers from AI assistant based on Datagrok documentation and public code.
24
36
  //input: string prompt
37
+ //input: string sessionId { optional: true }
25
38
  //output: widget result
26
39
  //meta.role: aiSearchProvider
27
40
  //meta.useWhen: If the user is asking questions about how to do something, how to write the code on platform, how to execute tasks, or any other questions related to Datagrok platform functionalities and capabilities. The tone of the prompt should generally sound like "how do I do this" / "what is this". for example, "what sequence notations are supported?
28
- export async function askHelpLLMProvider(prompt: string) : Promise<any> {
29
- return await PackageFunctions.askHelpLLMProvider(prompt);
41
+ export async function askHelpLLMProvider(prompt: string, sessionId?: string) : Promise<any> {
42
+ return await PackageFunctions.askHelpLLMProvider(prompt, sessionId);
43
+ }
44
+
45
+ //description: Run the Grokky latency/accuracy benchmark suite (files/benchmark/suite.yaml) and download a JSON + Markdown report tagged with the given label. Run after logging in; open no special view.
46
+ //input: string label { description: Config label for this run, e.g. baseline / medium-effort }
47
+ //input: int reps { optional: true; description: Repetitions per prompt (default 3) }
48
+ //input: string only { optional: true; description: Run only part of the suite: comma-separated categories, difficulties, or prompt substrings. }
49
+ //output: string result
50
+ export async function runBenchmark(label: string, reps?: number, only?: string) : Promise<string> {
51
+ return await PackageFunctions.runBenchmark(label, reps, only);
52
+ }
53
+
54
+ //description: Holds the admission slot for one AI chat turn streaming over the browser WebSocket - see queue-task.ts
55
+ //input: string sessionId
56
+ //input: string taskId
57
+ //output: string result
58
+ //meta.queue: true
59
+ export async function aiChatTurnTask(sessionId: string, taskId: string) : Promise<string> {
60
+ return await PackageFunctions.aiChatTurnTask(sessionId, taskId);
61
+ }
62
+
63
+ //description: Compare two or more saved benchmark runs (comma-separated labels) into one Markdown report and download it.
64
+ //input: string labels { description: Comma-separated run labels, the first being the reference arm }
65
+ //output: string result
66
+ export async function compareBenchmarks(labels: string) : Promise<string> {
67
+ return await PackageFunctions.compareBenchmarks(labels);
30
68
  }
31
69
 
32
70
  //name: Execute
33
71
  //description: Plans and executes function steps to achieve needed results
34
72
  //input: string prompt
73
+ //input: string sessionId { optional: true }
35
74
  //output: widget result
36
75
  //meta.role: aiSearchProvider
37
76
  //meta.useWhen: If the prompt looks like a user has a goal to achieve something with concrete input(s), and wants the system to plan and execute a series of steps/functions to achieve that goal. This relates to functions that analyse or mutate data, not get it. for example, adme properties of CHEMBL1234, enumerate some peptide, etc... Also, if the tone of the prompt sounds like "Do something to something", use this function
38
- export async function smartChainExecutionProvider(prompt: string) : Promise<any> {
39
- return await PackageFunctions.smartChainExecutionProvider(prompt);
77
+ export async function smartChainExecutionProvider(prompt: string, sessionId?: string) : Promise<any> {
78
+ return await PackageFunctions.smartChainExecutionProvider(prompt, sessionId);
40
79
  }
41
80
 
42
81
  //name: Query
43
82
  //description: Tries to find a query which has the similar pattern as the prompt user entered and executes it
44
83
  //input: string prompt
84
+ //input: string sessionId { optional: true }
45
85
  //output: widget result
46
86
  //meta.role: aiSearchProvider
47
87
  //meta.useWhen: if the prompt suggest that the user is looking for a data table result and the prompt resembles a query pattern. for example, "bioactivity data for shigella" or "compounds similar to aspirin" or first 100 chembl compounds. there should be some parts of user prompt that could match parameters in some query, like shigella, aspirin, first 100 etc. Always use this function when user wants to get the data without any further processing or calculating
48
- export async function llmSearchQueryProvider(prompt: string) : Promise<any> {
49
- return await PackageFunctions.llmSearchQueryProvider(prompt);
88
+ export async function llmSearchQueryProvider(prompt: string, sessionId?: string) : Promise<any> {
89
+ return await PackageFunctions.llmSearchQueryProvider(prompt, sessionId);
50
90
  }
51
91
 
52
- //input: string model
53
- //input: string systemPrompt
54
92
  //input: string prompt
55
- //input: dynamic schema
56
93
  //output: string result
57
94
  //meta.cache: all
58
95
  //meta.cache.invalidateOn: 0 0 1 * *
59
- export async function askAIGeneralCached(model: string, systemPrompt: string, prompt: string, schema?: any) : Promise<string> {
60
- return await PackageFunctions.askAIGeneralCached(model, systemPrompt, prompt, schema);
96
+ export async function findMatchingPatternQuery(prompt: string) : Promise<string> {
97
+ return await PackageFunctions.findMatchingPatternQuery(prompt);
61
98
  }
62
99
 
63
- //input: string question
64
- //output: string result
65
- //meta.cache: all
66
- //meta.cache.invalidateOn: 0 0 1 * *
67
- export async function ask(question: string) : Promise<string> {
68
- return await PackageFunctions.ask(question);
100
+ //input: view view
101
+ //input: string connectionID
102
+ //input: dynamic queryEditorRoot
103
+ //input: dynamic setAndRunFunc
104
+ //output: bool result
105
+ export async function setupAIQueryEditor(view: DG.ViewBase, connectionID: string, queryEditorRoot: any, setAndRunFunc: any) : Promise<boolean> {
106
+ return await PackageFunctions.setupAIQueryEditor(view, connectionID, queryEditorRoot, setAndRunFunc);
69
107
  }
70
108
 
71
- //input: string userGoal
109
+ //description: List the catalogs available on this connection
110
+ //input: view view
72
111
  //output: string result
73
- //meta.cache: all
74
- //meta.cache.invalidateOn: 0 0 1 * *
75
- export async function getExecutionPlan(userGoal: string) : Promise<string> {
76
- return await PackageFunctions.getExecutionPlan(userGoal);
112
+ //meta.viewType: DataQueryView
113
+ export async function listDbCatalogs(view: any) : Promise<string> {
114
+ return await PackageFunctions.listDbCatalogs(view);
77
115
  }
78
116
 
79
- //input: string prompt
117
+ //description: List schemas of a catalog (defaults to the connection default catalog)
118
+ //input: view view
119
+ //input: string catalogName { optional: true }
80
120
  //output: string result
81
- //meta.cache: all
82
- //meta.cache.invalidateOn: 0 0 1 * *
83
- export async function findMatchingPatternQuery(prompt: string) : Promise<string> {
84
- return await PackageFunctions.findMatchingPatternQuery(prompt);
121
+ //meta.viewType: DataQueryView
122
+ export async function listDbSchemas(view: any, catalogName?: string) : Promise<string> {
123
+ return await PackageFunctions.listDbSchemas(view, catalogName);
85
124
  }
86
125
 
87
- //input: string prompt
126
+ //description: List tables of a schema with row counts
127
+ //input: view view
128
+ //input: string schemaName
129
+ //input: string catalogName { optional: true }
88
130
  //output: string result
89
- //meta.cache: all
90
- //meta.cache.invalidateOn: 0 0 1 * *
91
- export async function askDocumentationCached(prompt: string) : Promise<string> {
92
- return await PackageFunctions.askDocumentationCached(prompt);
131
+ //meta.viewType: DataQueryView
132
+ export async function listDbTables(view: any, schemaName: string, catalogName?: string) : Promise<string> {
133
+ return await PackageFunctions.listDbTables(view, schemaName, catalogName);
93
134
  }
94
135
 
136
+ //description: Detailed column info (types, comments, ranges, sample values) for the given tables. Table refs: catalog.schema.table, schema.table, or table
95
137
  //input: view view
96
- //input: string connectionID
97
- //input: dynamic queryEditorRoot
98
- //input: dynamic setAndRunFunc
99
- //output: bool result
100
- export async function setupAIQueryEditor(view: DG.ViewBase, connectionID: string, queryEditorRoot: any, setAndRunFunc: any) : Promise<boolean> {
101
- return await PackageFunctions.setupAIQueryEditor(view, connectionID, queryEditorRoot, setAndRunFunc);
138
+ //input: string tables { description: Comma-separated table references to describe }
139
+ //output: string result
140
+ //meta.viewType: DataQueryView
141
+ export async function getDbTableDetails(view: any, tables: string) : Promise<string> {
142
+ return await PackageFunctions.getDbTableDetails(view, tables);
102
143
  }
103
144
 
104
- //input: string dbName { choices: ["biologics","chembl"] }
105
- export async function moveMetaToDB(dbName: string) : Promise<void> {
106
- await PackageFunctions.moveMetaToDB(dbName);
145
+ //description: Foreign-key relationships involving the given tables — use to build correct JOINs
146
+ //input: view view
147
+ //input: string tables { description: Comma-separated table references }
148
+ //output: string result
149
+ //meta.viewType: DataQueryView
150
+ export async function listDbJoins(view: any, tables: string) : Promise<string> {
151
+ return await PackageFunctions.listDbJoins(view, tables);
107
152
  }
108
153
 
109
- //name: setupVectorStore
110
- export async function setupVectorStore() : Promise<void> {
111
- await PackageFunctions.setupVectorStore();
154
+ //description: Test-execute a SELECT (auto-LIMITed) and report row count, columns, and a sample row. Use to validate SQL before setQueryAndRun
155
+ //input: view view
156
+ //input: string sql { description: The SQL to test }
157
+ //input: string description { description: One line describing what the query does }
158
+ //output: string result
159
+ //meta.viewType: DataQueryView
160
+ export async function getSqlTestResult(view: any, sql: string, description: string) : Promise<string> {
161
+ return await PackageFunctions.getSqlTestResult(view, sql, description);
112
162
  }
113
163
 
114
- //name: searchForSomething
115
- export async function searchForSomething() : Promise<void> {
116
- await PackageFunctions.searchForSomething();
164
+ //input: string dbName { choices: ["biologics","chembl"] }
165
+ export async function moveMetaToDB(dbName: string) : Promise<void> {
166
+ await PackageFunctions.moveMetaToDB(dbName);
117
167
  }
118
168
 
119
169
  //name: indexDatabaseSchema