@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,82 @@
1
+ # Prompt examples
2
+
3
+ ## Function chaining
4
+
5
+ | prompt | interpretation | |
6
+ |-----------------------------------------------------------------------------------|----------------|---|
7
+ | Adme properties for aspirin | | |
8
+ | Gasteiger for CHEMBL1234 | | |
9
+ | Gasteiger for Apremilast | | |
10
+ | convert C[C@H](N)C(=O)N(C)CC(=O)N[C@@H](Cc1ccc(N)cc1)C(=O)O to helm | | |
11
+ | convert GROKPEP-000002 sequence to molecule | | |
12
+ | Convert to SMILES: GATTACA | | |
13
+ | Visualization of the aspirin synthesis path | | |
14
+ | generate different variations of CHEMBL1235 and calculate molecular mass and logS | | |
15
+ | generate molecular structures of GROKPEP-000001 variants | | |
16
+ | ongoing studies in rats | | |
17
+ | optimize PSA of GROKPEP-000001 | | |
18
+ | | | |
19
+ | | |
20
+
21
+ ## Database queries
22
+
23
+
24
+ | prompt | interpretation | |
25
+ |-----------------------------------------------|----------------|---|
26
+ | ADCs with ic50 above 400 | | |
27
+ | ADCs with caspase activity > 8 | | |
28
+ | Which compounds are active against CHEMBL1827 | | |
29
+ | Shigella bioactivity | | |
30
+ | PK for LEVOFLOXACIN | | |
31
+ | Northwind: sales by country | | |
32
+ | CHEMBL: targets involving thrombi | | |
33
+
34
+
35
+ ### DB identifiers
36
+
37
+ | prompt | interpretation | |
38
+ |-------------------------|----------------|---|
39
+ | CHEMBL1234, CHEMBL13566 | | |
40
+ | GROKPEP001 | | |
41
+
42
+ ## Context functions
43
+
44
+
45
+ | Context: prompt | interpretation | |
46
+ |---------------------------------------------------------------|----------------|---|
47
+ | MolCol: Show me the chemical space | | |
48
+ | MolCol: Calculate Lipinski descriptors | | |
49
+ | Scatter plot: zoom in, regression line, color by age | | |
50
+ | Table View: add a histogram, close scatter plot | | |
51
+ | Shell: show users view, switch to demog, show recent projects | | |
52
+
53
+
54
+ ## Code generation
55
+
56
+ | prompt | interpretation | |
57
+ |---------------------------------------------------------------------------------------------------------------------------------------------------|----------------|--------------------------------------------------------------------------------------------------------------------|
58
+ | JS: Add a view with the sketcher on the left, and the (predicted ADME properties | calculated MW | Gasteiger Partial Charges) on the right. As user sketches the molecule, the right part should update interactively | | |
59
+ | JS: given a dataframe “sales” parameter with “date” and “amount” columns, create a “cumsum” column with the cumulative sum of sales for that date | | |
60
+ | For demog table, compute the mean and sd of HEIGHT group by RACE, SEX | | |
61
+ | Python: write a function that accepts a molecule and renders Gasteiger partial charges as a result | | |
62
+
63
+
64
+ ## Visualizations
65
+
66
+ | prompt | interpretation | |
67
+ |-----------------------------------------------|----------------|---|
68
+ | Add a scatter plot, show height vs weight, show regression line, zoom in, color by age | | |
69
+ | Show me the distribution of activities per compound class | | |
70
+ | Which compounds are active against CHEMBL1827 | | |
71
+ | Shigella bioactivity | | |
72
+ | PK for LEVOFLOXACIN | | |
73
+
74
+
75
+ ## Visualizations
76
+
77
+ | prompt | dataset | |
78
+ |--------------------|---------|---------------------------------------|
79
+ | calculate bmi | demog | adds new column with (width / height) |
80
+ | calculate lipinski | smiles | computes lipinski |
81
+ | | | |
82
+ | | | |
@@ -0,0 +1,71 @@
1
+ ## Smart Assistant / NLP-driven UI
2
+
3
+ - Natural-language query interface: Allow users to ask “Which compounds have high toxicity risk and low solubility?” or
4
+ “Show me molecules with IC50 < 10 nM and Lipophilicity < 3” and translate into filters, visualizations, models.
5
+ - Search integration (help, etc)
6
+ - Classification of search string (id, entity, question, request, etc)
7
+ - Using LLMs to match the search-integrated query templates
8
+ - Querying databases (sort of already implemented but can be improved)
9
+ - Automatic collection of “useful” words
10
+ - Collecting statistics on the db
11
+ - Mapping query parameters to the database columns
12
+ - Invoking functions and chains of functions
13
+ - Filtering out available functions
14
+ - Contextual suggestions: Based on the semantic types detected (molecule, gene sequence, plate ID, etc), provide
15
+ suggestions: “Would you like to run an ADMET prediction model?” or “Try clustering these compounds on similarity”
16
+ automatically.
17
+ - Auto-narrative insights: For dashboards or result sets, auto-generate a short narrative (“In the hit list you see two
18
+ structural clusters; cluster A shows significantly more low-toxicity compounds than cluster B”) to aid non-technical
19
+ users.
20
+ - AI for chemists for managing molecules (“strip salts”), etc
21
+ - Working with dataframes (average height by race)
22
+ - Voice-driven chats
23
+
24
+ ## Self-guided database access
25
+
26
+ There are multiple ways to access data in Datagrok, and multiple ways where AI can be useful. A lot depends on how
27
+ much power and uncertainty you want to give users, and how much are you willing to invest to annotate your existing
28
+ databases with metadata to help guide the LLMs.
29
+
30
+ - Manually written parameterized SQL, annotated with description and search patterns to help LLMs associate it with the
31
+ user query and pass parameters, potentially using transformation functions to the parameters (like resolving compound
32
+ ids and drug names to SMILES, and then passing to the pre-defined SQL query)
33
+ - Visual editor - optimized UI for creating joins, filters, aggregations, pivots etc visually, with the UI suggesting
34
+ sensible options based on the knowledge of the schema (column names and types, foreign keys, etc). In the end, a visual
35
+ query produces a parameterized SQL.
36
+ - AI-driven query building and ad-hoc querying. You point to a database schema and write a query in English, and LLM
37
+ produces the SQL query, along with the visualization suitable to best interpret the results.
38
+
39
+ All of the approaches outlined above integrate into the AI-driven search engine that understands the nature of the
40
+ question, and routes it accordingly.
41
+
42
+ ## Help
43
+ - Answer questions using our wiki (just like DeepWiki). Fully integrated into the search system - the AI recognizes that
44
+ it’s a generic question about the platform, and answers it.
45
+ - Automatic troubleshooting
46
+ Get an error -> suggest how to fix (using our knowledge base, etc)
47
+
48
+ ## Vibe-coded apps (on the fly, by users)
49
+ - Produce apps based on the user input. Example: “I want a sketcher on the left, and predicted ADME properties appear on
50
+ the right as I sketch the molecule. When I click the SUBMIT button, the molecule should get registered in MolTrack”.
51
+ Amazingly, this is almost working out of the box.
52
+
53
+ ## Agents
54
+
55
+ Long-performing, collaborative tasks with memory
56
+
57
+ ## MCP
58
+
59
+ - Connect to external MCP servers, so that Datagrok can make use of them when executing user tasks. Availability of the
60
+ MCP servers is subject to standard Datagrok privileges, so you can easily specify who gets access to what.
61
+ - Expose the Datagrok MCP server(s) for others to use
62
+
63
+ ## Ideas
64
+
65
+ ### Different models
66
+
67
+ - Super-fast old-school, regex-based NLP for obvious things to keep UI snappy
68
+ - Client-side, Chrome-integrated (fast and does not make network calls - great for security) Gemini Nano for quick
69
+ triaging/classifying of requests
70
+ - ChatGPT for more complex reasoning, function chaining, etc
71
+ - Enterprise customers just bring their OpenAI token - your data stays within your infrastructure
@@ -0,0 +1,128 @@
1
+ # Skills & knowledge sync — implementation
2
+
3
+ Technical implementation of the skills & knowledge sync system. See [VISION.md](VISION.md)
4
+ for the user-facing concept.
5
+
6
+ ---
7
+
8
+ ## Folder bootstrap
9
+
10
+ On init, Grokky creates an `agents/` directory in the user's My Files with a `README.md`
11
+ placeholder.
12
+
13
+ ---
14
+
15
+ ## Shared folder discovery
16
+
17
+ When a user shares their `agents/` folder, the platform creates a sub-connection named
18
+ `MyFilesAgents`. The sync layer discovers these by querying
19
+ `/public/v1/connections?text=agents` and filtering by name. No tags or registration are
20
+ required — the named sub-connection is the entire contract.
21
+
22
+ ---
23
+
24
+ ## Working directory
25
+
26
+ The Claude runtime maintains a per-user directory on the container filesystem:
27
+
28
+ ```
29
+ /users/{userId}/
30
+ ├── agents/ ← all knowledge files land here
31
+ │ ├── my-notes.md ← personal (from My Files/agents/)
32
+ │ ├── <UserPackageName>-skills.md ← package (from <UserPackageName> package's agents/)
33
+ │ └── shared-abc123-onboard.md ← shared (from another user's agents/)
34
+ └── workspace/ ← links into the cloned Datagrok public repo (/workspace)
35
+ ```
36
+
37
+ The user ID is extracted from the JWT payload (`sub` or `usr.id`). `workspace/` links every top-level
38
+ entry of `/workspace` except `.git`, `CLAUDE.md` and `.claude`, and under `packages/` only the packages
39
+ installed on the instance ([`staged-workspace.ts`](../dockerfiles/claude-runtime/src/user/staged-workspace.ts)),
40
+ which gives Claude read access to the JS API source, samples, documentation and those packages.
41
+
42
+ The user directory is Claude's working directory whenever the message carries the user's key; a session
43
+ with no user directory (no key, or no known API URL in local dev) works in `/workspace`.
44
+
45
+ Agent files are read from disk on demand (`read_file` / `search_files`). The system prompt does not
46
+ enumerate them; the `datagrok-*` capability skills are listed in the full-mode system prompt and loaded
47
+ with Hermes' `skill_view` tool (`## Skills` in `DATAGROK_PROMPT`, `dockerfiles/claude-runtime/src/prompts.ts`).
48
+
49
+ User-created packages sync into `/users/{userId}/agents/` rather than the public workspace,
50
+ since their skills are personal.
51
+
52
+ ---
53
+
54
+ ## Sync
55
+
56
+ All three scopes sync independently using incremental sync — only new or changed files are
57
+ downloaded, and files deleted on the remote side are cleaned up locally. Naming conventions
58
+ prevent collisions across sources:
59
+
60
+ | Scope | Source | Local naming | Trigger |
61
+ |-------|--------|--------------|---------|
62
+ | Personal | User's `My Files/agents/` folder | `agents/{filename}` | File events (`d4-file-event`, `onFileEdited`) |
63
+ | Package | `agents/` folder inside a published package | `agents/{PackageName}-{filename}` | `onPackageLoaded` event + on-demand TTL refresh |
64
+ | Shared | `MyFilesAgents` sub-connections from other users | `agents/shared-{connId}-{filename}` | On-demand TTL refresh |
65
+
66
+ Package sync keys on the package's `buildHash` to skip unchanged packages. When a build changes,
67
+ the runtime lists the published-files folder
68
+ (`/packages/published/files/{name}/{version}/{buildHash}/{buildNumber}/agents/`) and downloads
69
+ each agent file individually. The per-user cache lives in process memory only and tracks
70
+ `buildHash` plus the files written for that build, so the previous build's files can be removed
71
+ before the new ones land.
72
+
73
+ Shared sync uses `updatedOn` timestamp caching. The seen version is recorded whether or not the
74
+ download succeeds, so a file that can't be fetched (e.g. invalid JSON) is not retried on every
75
+ refresh — it retries only when its `updatedOn` changes.
76
+
77
+ The first user message syncs all scopes blockingly (`scope=all`); later `scope=all` turns serve
78
+ on-disk state immediately and refresh the package and shared scopes in the background once a
79
+ 15-minute TTL elapses, so a turn never pays sync latency. A concurrency guard (`syncInFlight` per
80
+ user) prevents duplicate syncs.
81
+
82
+ ---
83
+
84
+ ## Package knowledge index
85
+
86
+ Packages can ship a structured `agents/package-knowledge.yaml` file that describes the package's
87
+ capabilities in a machine-readable format:
88
+
89
+ ```yaml
90
+ packageName: Admetica
91
+ description: ADMET property prediction for small molecules using ChemProp v2 neural networks
92
+ keywords:
93
+ - admet
94
+ - absorption
95
+ - molecules
96
+ - smiles
97
+ - chemprop
98
+ overview: |
99
+ Predicts ADMET molecular properties using ChemProp v2 neural networks.
100
+
101
+ Single molecule: click on a molecule cell — the Admetica panel appears
102
+ in the context panel (Biology section) with predictions.
103
+ apiRef: src/package-api.ts
104
+ docsRef: ../../help/datagrok/solutions/domains/chem/chem.md
105
+ ```
106
+
107
+ These files are not aggregated or injected anywhere — they simply sit in the synced workspace at
108
+ `workspace/packages/<Name>/agents/package-knowledge.yaml`, where Claude discovers them with
109
+ `search_files` / `read_file` like any other file. (Earlier iterations injected an `## Available Packages` prompt
110
+ table and later exposed a `get_package_knowledge` MCP tool; both were retired — the table bloated
111
+ the prompt and the tool went unused.)
112
+
113
+ **Future direction:** consolidate agent file listings and other dynamic context
114
+ into a generated `CLAUDE.md` or skills file rather than appending sections to the system prompt.
115
+ This would align with how Claude Code natively consumes project context and make the knowledge
116
+ layer easier to inspect and debug.
117
+
118
+ ---
119
+
120
+ ## Open design questions
121
+
122
+ 1. **File count scaling** — the system prompt currently lists up to 50 agent files. As the
123
+ number of packages and shared connections grows, a smarter selection or indexing strategy
124
+ may be needed (e.g., relevance-based filtering, embedding search).
125
+
126
+ 2. **Conflict resolution** — if a personal file and a package file have the same effective name,
127
+ the current naming convention prevents filesystem collisions, but Claude sees both. A priority
128
+ model (personal > shared > package) could help resolve contradictions in instructions.
@@ -0,0 +1,170 @@
1
+ # Grokky latency — measured findings and plan
2
+
3
+ Rewritten 2026-07-20 from **measured data** (benchmark harness, [BENCHMARK.md](./BENCHMARK.md)) plus a
4
+ full code sweep of the turn path (browser → WS → runtime → SDK → model → tool round-trips). Replaces
5
+ the earlier speculative version — several of its guesses are now disproven (see "Disproven" at the end).
6
+ Refs are to `dockerfiles/claude-runtime/src/` unless noted. Raw runs: `files/benchmarks/`.
7
+
8
+ The measurements were taken on the Claude Agent SDK runtime. The runtime now runs Hermes Agent, one
9
+ process per chat session ([CLAUDE_CODE_FLOW.md](CLAUDE_CODE_FLOW.md)); 2a, 2b and the SDK items below
10
+ are updated for it, and the numbers need a re-run before they are relied on.
11
+
12
+ ## Measured baseline (Sonnet, effort=high, thinking=1500)
13
+
14
+ 19 prompts × 3 reps through the real pipeline (`Grokky:runBenchmark`):
15
+
16
+ | | baseline (high) | medium-effort A/B |
17
+ |---|---|---|
18
+ | Median turn | 19.4 s | 15.9 s |
19
+ | Median TTFT | 17.7 s | 12.8 s |
20
+ | Help/doc turns | 42–61 s, 8–13 round-trips | 44–85 s, **20–33 round-trips** |
21
+ | Simple action turns (viz) | 11–15 s, 2 round-trips | 11–20 s, 2 round-trips |
22
+ | Accuracy | 16/18 | 18/19 |
23
+ | Cost (Σ per-prompt medians) | $1.62 | **$2.16 (+33%)** |
24
+ | Failures | 3 (all 120 s timeouts, doc-search spiral) | 4 (same mechanism) |
25
+
26
+ Linear fit across prompts:
27
+
28
+ ```
29
+ total_ms ≈ 12,400 + 3,600 × tool_round_trips (high, R²=0.47)
30
+ total_ms ≈ 14,200 + 2,300 × tool_round_trips (medium, R²=0.72)
31
+ ```
32
+
33
+ **The two numbers that matter: ~12–14 s fixed overhead per turn, ~2.3–3.6 s per tool round-trip.**
34
+ Round-trip *count* is the multiplier — each hop re-reads the ~35 k-token cached prefix and pays a full
35
+ model continuation. On action turns TTFT ≈ total because the model emits text *after* its tool calls
36
+ (output ordering, not a transport defect) — so the whole turn is user-visible spinner time.
37
+
38
+ ### The effort A/B result (why "just lower effort" failed)
39
+
40
+ Lowering effort cut the per-hop cost (3.6 → 2.3 s) but the model compensated for less deliberation
41
+ with **more searching** — help turns went from 8–13 to 20–33 round-trips, net slower and +33 % cost.
42
+ **Effort stays `high`**: deliberation is what keeps the round-trip count down while the grounding
43
+ gate stands. The two levers are coupled — effort can only come down together with Tier-1 fixes below.
44
+
45
+ ## Levers, re-ranked by measured impact
46
+
47
+ ### Tier 1 — cut the round-trip count (~3.6 s each; the only lever for 42–85 s help turns)
48
+
49
+ **1a. GroundingGate redesign** ([grounding.ts](../dockerfiles/claude-runtime/src/grounding.ts)).
50
+ Today: on Stop, if no `Read`/`Grep`/`Glob`/`Bash` whose input contains `'help/'` ran this turn, it
51
+ blocks the stop once — *after the model already wrote its answer* (a wasted full answer + a forced
52
+ grep chain). The prompt sends it grepping `workspace/help/` — **536 md files / 3.7 MB, no index** —
53
+ so it iterates Grep→Read→Grep, a full round-trip each. WebSearch/WebFetch and `js-api/src/` reads
54
+ do **not** count as grounded (a trap: legitimate grounding gets re-blocked). This mechanically
55
+ produced the 8–33-hop help turns and all the 120 s timeouts.
56
+ - ~~Ship a generated **index/TOC of `help/`**~~ — DONE (`help-index.ts`, 405 pages).
57
+ - ~~Count WebFetch/WebSearch/js-api reads as grounded~~ — DONE; `Skill` invocations too (2026-07-29).
58
+ - ~~Blunt post-answer Stop-block~~ — **narrowed 2026-07-29** after a 36-turn A/B showed 0 of 14
59
+ blocks ever changed an answer (BENCHMARK.md "Third result"): small talk never arms the gate,
60
+ and the block fires only when the visible answer makes ungrounded platform *UI-instruction*
61
+ claims (`makesPlatformClaims`). Contextual data answers end in one API call (measured: 2 → 1
62
+ calls, 7.6 → 3.6 s). Per-turn `gates: {grounding, verify}` overrides exist for future A/Bs.
63
+
64
+ **1b. Verifier scope-down** ([verify.ts](../dockerfiles/claude-runtime/src/verify.ts)).
65
+ Today: **every** `datagrok_exec` arms the verify gate — the exec's own result is never parsed, so
66
+ even an exec that already returned `{success:true, returnValue:…}` forces a separate
67
+ `datagrok_verify` round-trip (and a failing exec's error report is likewise ignored). Minimum
68
+ action turn = 2 round-trips — exactly the measured 11 s histogram. Cap is 3 Stop-blocks.
69
+ - Let a successful exec **self-verify**: return machine-checkable post-state from the same browser
70
+ round-trip (or auto-run the assertion browser-side inside exec), keep the Stop-gate only when the
71
+ exec returned nothing checkable.
72
+ - Verify once per turn, not per action.
73
+
74
+ **1c. Keep effort high** (measured, above). Revisit only after 1a/1b land — then re-benchmark
75
+ `medium`; with fewer forced hops it may win.
76
+
77
+ ### Tier 2 — cut the ~12–14 s fixed intercept
78
+
79
+ **2a. Persistent session process** — in place: each chat session keeps one agent process
80
+ ([agent/pool.ts](../dockerfiles/claude-runtime/src/agent/pool.ts)) that holds the conversation in
81
+ memory between turns, and new chats start on a warm spare. Only a session evicted for idleness or at the
82
+ process cap reloads its history from disk. Not yet re-measured.
83
+
84
+ **2b. mcp-server handshake** ([mcp-server/src/index.ts](../dockerfiles/mcp-server/src/index.ts#L72)).
85
+ The agent registers the `datagrok` MCP server once per process and reconnects only when the user's key
86
+ or URL changes (`_set_mcp` in
87
+ [session.py](../dockerfiles/claude-runtime/agent/grokky_agent/session.py)). The mcp-server still
88
+ constructs a fresh `McpServer` + transport per HTTP request, through two proxies; cache the server
89
+ instance if that shows up in a profile.
90
+
91
+ **2c. The rest of the intercept is model-side first-segment latency** (thinking + generation at
92
+ effort high before the first token/tool). The thinking setting (effort `high` for full-mode turns in
93
+ [session.ts](../dockerfiles/claude-runtime/src/session.ts), applied as the agent's `reasoning_config` in
94
+ [session.py](../dockerfiles/claude-runtime/agent/grokky_agent/session.py)) exists for the
95
+ grounding rule; after 1a lands, A/B a reduced/disabled budget **for action turns** via the harness.
96
+
97
+ ### Tier 3 — browser-side (real, smaller; two cliffs)
98
+
99
+ **3a. Streaming render is O(n²)** ([panel.ts:658](../src/ai/panel.ts#L658) — path from repo:
100
+ `src/ai/panel.ts`). Every chunk — and every `tool_activity` — re-renders the **entire accumulated
101
+ text** through Dart markdown (parse + sanitizer + `querySelectorAll('*')` walk) and forces a reflow.
102
+ Hundreds of ms to seconds per help turn, on the same thread that processes WS messages — it delays
103
+ chunk/tool/final handling, inflating real turn time. Fix: append plain text while streaming, render
104
+ markdown **once** in `finalizeStreaming` (which already re-renders anyway), or throttle to rAF/150 ms.
105
+
106
+ **3b. Cliffs**: cold on-demand container → `webSocketProxy` waits up to **60 s**
107
+ (js-api `src/dapi.ts:1172`); reconnect is lazy (next send pays it) — auto-reconnect on `onClose`
108
+ instead. `runVerification` has a **30 s** hang cap (`src/claude/exec-blocks.ts:27`) — lower it.
109
+
110
+ **3c. Pre-send serial gauntlet** (`src/ai/ui.ts:276-284`) — `grok.ai.processPrompt` (seven full-DOM
111
+ `querySelectorAll` sweeps; purely local) then the usage limiter, serial before send: 10–150 ms. Run
112
+ `ensureConnected` in parallel from `handleRun` entry; skip/parallelize `processPrompt` for long
113
+ prompts (its DOM-click interpreter targets terse commands).
114
+
115
+ **Not browser problems** (measured): `buildWorkspaceContext` ≈ 75–90 tokens for demog, sub-ms (only
116
+ cap the **ScriptView full-source** inline, `src/claude/exec-blocks.ts:58-63`); usage limiter ~1 ms,
117
+ no network; WS double-hop through Datlas is pure passthrough (~ms per leg, only matters × 4 legs ×
118
+ many hops); IndexedDB save is post-final jank only.
119
+
120
+ ### Tier 4 — context diet — LANDED 2026-07-28 (27,977 → 17,637 tok/call)
121
+
122
+ **Measured end to end on the suite** (`benchmark-diet-full` vs `benchmark-sonnet-clean`, 44 shared
123
+ prompts): median turn **26.6 s → 17.9 s (−33%)**, TTFT 17.9 s → 14.4 s, median cache-read per turn
124
+ 92 k → 56 k, accuracy **39/44 in both arms** — the whole saving was free. This also re-tests the
125
+ Tier-1 model: cutting the per-hop prefix cuts every hop, so it moves the intercept *and* the slope.
126
+
127
+
128
+ Measured with `dev/harness/context-probe.mjs` (see BENCHMARK.md "Context probe"), which
129
+ attributes the prefix by ablation. Three levers landed the same day: restricting the *declared*
130
+ built-in tool set (`tools:` — `allowedTools` only pre-approves, so Task/TodoWrite/NotebookEdit
131
+ schemas shipped unused, 7,572 tok/call), consolidating the MCP surface (below), and exempting
132
+ small talk from the grounding gate's second API call.
133
+
134
+ - ~~**34** datagrok MCP tool schemas attach to every turn — filter via `allowedTools`~~ — **DONE**,
135
+ differently: filtering by `allowedTools` would have made operations undiscoverable. Instead the 34
136
+ tools became **five domain tools** dispatching on an `op`, whose descriptions carry only operation
137
+ names; a call with no `op` returns the full parameter schema. **3,847 → 1,061 tok/call.**
138
+ - ~~`list_functions` & friends are unpaged and pretty-printed~~ — **DONE**: results are compact JSON,
139
+ arrays paged at 50 with `offset`/`limit`, everything capped
140
+ ([mcp-server/src/format.ts](../dockerfiles/mcp-server/src/format.ts)).
141
+ - **Still open — the plugin + system-prompt block is 6,363 tok/call**, the largest Datagrok-specific
142
+ contributor, bigger than all tool definitions combined. Trimming skill descriptions is worth
143
+ ~400 tok; the rest is plugin machinery and needs investigation before cutting.
144
+ - **Partly done — full mode costs a SECOND API call** (`numTurns` 2 vs 1), because the GroundingGate
145
+ blocks the Stop once on every turn that neither grounded nor acted, and the model burns a whole
146
+ call replying `NO_REVISION`. Small talk is now exempt (gate not armed at all — measured on
147
+ "hello": 2 calls → 1, 9.3 s → 6.0 s). The remaining case — real answers that made no tool call —
148
+ still pays the extra call; that is an accuracy feature and needs a `help`-category A/B (Tier 1a).
149
+ - ~~Staged user workspace symlinks the repo's `CLAUDE.md` and `.claude/` into the model's cwd~~ — **DONE**:
150
+ both are excluded ([staged-workspace.ts](../dockerfiles/claude-runtime/src/user/staged-workspace.ts)),
151
+ and the agent loads no context files (`skip_context_files` in
152
+ [session.py](../dockerfiles/claude-runtime/agent/grokky_agent/session.py)), so no repo `CLAUDE.md` or
153
+ `AGENTS.md` instructions reach the model unless it reads them.
154
+
155
+ ## Confirmed non-issues / disproven earlier guesses
156
+
157
+ - ~~"Turn down effort — biggest single win"~~ — **disproven by A/B**: net loss while gates force hops.
158
+ - ~~Per-turn `datagrok-view` tool defs bust the prompt cache~~ — defs are module-level constants,
159
+ byte-stable per session (`src/ai/view-tools.ts:131-160`). Cache works: measured input_tokens per
160
+ turn = 4–8, cache-read 55–140 k.
161
+ - ~~`buildWorkspaceContext` needs diffing~~ — it's ~80 tokens; only the ScriptView case needs a cap.
162
+ - Workspace git sync, user-file sync, `ensureUserDir` — all off the hot path (fire-and-forget/memoized).
163
+
164
+ ## Working method
165
+
166
+ Change one lever → rebuild the runtime image → `grok publish` →
167
+ `Grokky:runBenchmark("<lever>")` → `Grokky:compareBenchmarks("baseline", "<lever>")`.
168
+ Suggested order: **1a → 1b → re-A/B effort/thinking → 2a → 3a**, one benchmark row each.
169
+ Harness TODO: also aggregate `numTurns`/`durationApiMs` into the report (captured but not yet
170
+ summarized) to split model time from browser/exec time per turn.
package/docs/VISION.md ADDED
@@ -0,0 +1,36 @@
1
+ # Agentic force for scientists
2
+
3
+ ## Plugins
4
+
5
+ Plugins ship special instructions (collection of .md files?) that describe the plugin's
6
+ functionality and what could be done with it for the user.
7
+
8
+ Example 1: Chem plugin might ship a document with this
9
+
10
+ ```
11
+ for chemical space, call the ChemicalSpace function
12
+ ```
13
+
14
+ Example 2: Company-specific: A plugin (or file) with company-specific procedures or
15
+ instructions that get included to the session
16
+
17
+ ```
18
+ When registering a new chemical compound, do the following
19
+ - make sure it's a valid structure
20
+ - ask user to associate it with a project
21
+ - register in Global Compound Registration System
22
+ - kick off ADME prediction
23
+ - email John Smith the link to ADME results
24
+ ```
25
+
26
+ At the Grokky Claude Code session startup, these folders get loaded in the Claude Code
27
+ context. Perhaps as one CLAUDE.md with the index of available plugins and short
28
+ descriptions.
29
+
30
+ So this becomes both a mechanism that defines what is available to the user (via plugin
31
+ privileges), and a mechanism for efficient working.
32
+
33
+ ---
34
+
35
+ For the implementation of the skills & knowledge sync system, see
36
+ [IMPLEMENTATION.md](IMPLEMENTATION.md).