@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,303 @@
1
+ ---
2
+ name: datagrok-viewers
3
+ description: Add a viewer, configure a viewer, change viewer options, find viewer, close viewer, view a scatter plot, bar chart, histogram, line chart, box plot, pie chart, heat map, correlation plot, 3D scatter, trellis, density plot, statistics, on a Datagrok TableView via the datagrok_exec tool. Use whenever the user asks to plot, chart, visualize, show a graph, draw a distribution, color by a column, swap a viewer's axis, toggle a legend / regression line / log scale, replace one viewer with another, close every chart, reset the view to just the grid, or find an existing viewer by type. Plugin viewers like "Chem space", "sequence space", "activity cliffs" are NOT viewer types — they're registered functions — route those to `grok.functions.call`. Does NOT cover filtering (separate skill `datagrok-filtering`), selection (`datagrok-selection`), grid cell rendering (`datagrok-grid-customization`), layout save/restore, or custom-viewer authoring.
4
+ ---
5
+
6
+ # datagrok-viewers
7
+
8
+ Add, configure, find, and close viewers on a `DG.TableView` via the
9
+ `datagrok_exec` tool. Globals injected by the runtime: `grok`, `ui`, `DG`,
10
+ `view`, `t` (the current `DG.DataFrame`, when the view is a `TableView`).
11
+
12
+ A viewer is added with the `table_add_viewer` tool (`{type, options}`) or, in a script, with
13
+ `undoable.addViewer(view, type, options)` in place of `view.addViewer(type, options)`: both record the undo step
14
+ (see `datagrok-undo`). Changing a viewer's properties and closing a viewer are not undoable.
15
+
16
+ ## Quick reference
17
+
18
+ | Need | Call |
19
+ |--------------------------------------|-----------------------------------------------------------------------|
20
+ | Add a viewer | `view.addViewer(DG.VIEWER.SCATTER_PLOT, {xColumnName: 'a', ...})` |
21
+ | Configure an existing viewer | `viewer.setOptions({colorColumnName: 'logP'})` |
22
+ | Read a viewer's current setting | `viewer.props.splitColumnName` (any property name; also for verifying) |
23
+ | All non-grid viewers | `Array.from(view.viewers).slice(1)` |
24
+ | First viewer of a type | `Array.from(view.viewers).slice(1).find((v) => v.type === DG.VIEWER.SCATTER_PLOT)` |
25
+ | Close one viewer | `viewer.close()` (wrap in try/catch — throws if never attached) |
26
+ | Close every non-grid viewer | `Array.from(view.viewers).slice(1).forEach((v) => { try { v.close(); } catch {} })` |
27
+ | Inspect a viewer's option schema | `viewer.getProperties()` → `DG.Property[]` (each has `.name`) |
28
+ | Standalone (detached) viewer | `DG.Viewer.fromType(DG.VIEWER.SCATTER_PLOT, t, {...})` |
29
+
30
+ ## THE viewer footgun: column-binding properties always end in `ColumnName(s)`
31
+
32
+ Users say "x is mw, y is logp". You must emit `xColumnName` / `yColumnName` —
33
+ never bare `x` / `y` / `color`. Bare aliases are inconsistent across viewer
34
+ types and may silently do nothing for the canonical `addViewer`/`setOptions`
35
+ path. Always use the full `*ColumnName(s)` form.
36
+
37
+ | User says | Emit (single column) | Emit (multiple columns) |
38
+ |---------------------|-------------------------------------|---------------------------------|
39
+ | `x is mw` | `xColumnName: 'mw'` | `xColumnNames: ['mw', ...]` |
40
+ | `y is logp` | `yColumnName: 'logp'` | `yColumnNames: ['logp', ...]` |
41
+ | `color by activity` | `colorColumnName: 'activity'` | — |
42
+ | `size by mw` | `sizeColumnName: 'mw'` | — |
43
+ | `label by smiles` | `labelColumnName: 'smiles'` | — |
44
+ | `split by class` | `splitColumnName: 'class'` | `splitColumnNames: ['class']` |
45
+ | `value is ic50` | `valueColumnName: 'ic50'` | `valueColumnNames: ['ic50']` |
46
+ | `category is class` | `categoryColumnName: 'class'` | `categoryColumnNames: ['class']`|
47
+ | `columns are a, b` | — | `columnNames: ['a', 'b']` |
48
+
49
+ - **Single column** properties: singular `<role>ColumnName` (string).
50
+ - **Multi-column** properties: plural `<role>ColumnNames` (array of strings).
51
+ - Some viewers take both forms for different roles (Line chart has
52
+ `xColumnName` for the x axis and `yColumnNames` for the series).
53
+ - When in doubt, inspect the live schema: `viewer.getProperties()` returns
54
+ `DG.Property[]`. Each has `.name` (canonical), `.propertyType`, `.choices`.
55
+
56
+ Other naming conventions across viewers:
57
+
58
+ - **Boolean toggles start with `show`**: `showRegressionLine`, `showXAxis`,
59
+ `showLegend`, `showStatistics`, `showColorSelector`. Not `regressionLine`
60
+ / `legend` / `statistics`.
61
+ - **Axis scale**: `xAxisType: 'linear' | 'logarithmic'` (and `y`, `z`,
62
+ `colorAxisType`). Not `logX`, not `logScale`.
63
+ - **Axis bounds**: `xMin`, `xMax`, `yMin`, `yMax`. Not `xRange: [a, b]`.
64
+
65
+ ## Unconfirmed options
66
+
67
+ Options not documented here must be confirmed against the live schema before
68
+ setting: `viewer.getProperties()` → match `.name`, respect `.propertyType` and
69
+ `.choices`. Values are scalars — never objects/arrays: a wrong-typed value is
70
+ stored unchecked.
71
+
72
+ ## The viewers array
73
+
74
+ `view.viewers` is a synchronous array snapshot:
75
+
76
+ - `view.viewers[0]` is **always the grid**. Closing it breaks the table widget.
77
+ Every iteration must `.slice(1)` (or filter out `v.type === DG.VIEWER.GRID`).
78
+ - Every other entry is a non-grid viewer. Each has `.type` (a string equal to
79
+ one of the `DG.VIEWER.*` constants) and `.dataFrame`.
80
+
81
+ ## Viewer types catalog
82
+
83
+ Always use the `DG.VIEWER.*` constants, never literal strings:
84
+
85
+ | Constant | String value | Primary properties |
86
+ |--------------------------------|----------------------|-----------------------------------------------------------------------------------|
87
+ | `DG.VIEWER.SCATTER_PLOT` | `'Scatter plot'` | `xColumnName`, `yColumnName`, `colorColumnName`, `sizeColumnName`, `showRegressionLine` |
88
+ | `DG.VIEWER.HISTOGRAM` | `'Histogram'` | `valueColumnName`, `splitColumnName`, `bins` |
89
+ | `DG.VIEWER.LINE_CHART` | `'Line chart'` | `xColumnName`, `yColumnNames` (array) |
90
+ | `DG.VIEWER.BAR_CHART` | `'Bar chart'` | `splitColumnName`, `valueColumnName`, `valueAggrType` |
91
+ | `DG.VIEWER.PIE_CHART` | `'Pie chart'` | `categoryColumnName` |
92
+ | `DG.VIEWER.BOX_PLOT` | `'Box plot'` | `valueColumnName`, `category1ColumnName`, `category2ColumnName` (no `categoryColumnName`) |
93
+ | `DG.VIEWER.HEAT_MAP` | `'Heat map'` | (returns a Grid subclass — column tag-driven color coding) |
94
+ | `DG.VIEWER.STATISTICS` | `'Statistics'` | `columnNames` |
95
+ | `DG.VIEWER.CORR_PLOT` | `'Correlation plot'` | `columnNames` (or `xs` / `ys`) |
96
+ | `DG.VIEWER.DENSITY_PLOT` | `'Density plot'` | `xColumnName`, `yColumnName` |
97
+ | `DG.VIEWER.SCATTER_PLOT_3D` | `'3d scatter plot'` | `xColumnName`, `yColumnName`, `zColumnName`, `colorColumnName` |
98
+ | `DG.VIEWER.TRELLIS_PLOT` | `'Trellis plot'` | `xColumnNames`, `yColumnNames`, `viewerType` |
99
+ | `DG.VIEWER.PC_PLOT` | `'PC Plot'` | `columnNames` |
100
+ | `DG.VIEWER.TREE_MAP` | `'Tree map'` | `splitColumnNames`, `sizeColumnName` |
101
+ | `DG.VIEWER.MATRIX_PLOT` | `'Matrix plot'` | `xColumnNames`, `yColumnNames` |
102
+ | `DG.VIEWER.FILTERS` | `'Filters'` | `columnNames` (see `datagrok-filtering` for the real filtering API) |
103
+ | `DG.VIEWER.FORM` | `'Form'` | `columnNames` |
104
+ | `DG.VIEWER.MARKUP` | `'Markup'` | `content` (string) |
105
+ | `DG.VIEWER.NETWORK_DIAGRAM` | `'Network diagram'` | `node1ColumnName`, `node2ColumnName` |
106
+ | `DG.VIEWER.WORD_CLOUD` | `'Word cloud'` | column |
107
+ | `DG.VIEWER.TILE_VIEWER` | `'Tile Viewer'` | per-row cards |
108
+ | `DG.VIEWER.PIVOT_TABLE` | `'Pivot table'` | `groupByColumnNames`, `pivotColumnNames`, `aggregateColumnNames`, `aggregateAggTypes` (arrays, e.g. `['avg']`) |
109
+ | `DG.VIEWER.SHAPE_MAP` | `'Shape Map'` | choropleth |
110
+ | `DG.VIEWER.CALENDAR` | `'Calendar'` | `dateColumnName` |
111
+ | `DG.VIEWER.GLOBE` | `'Globe'` | `latitudeColumnName`, `longitudeColumnName` |
112
+ | `DG.VIEWER.GOOGLE_MAP` | `'Google map'` | `latitudeColumnName`, `longitudeColumnName` |
113
+ | `DG.VIEWER.TIMELINES` | `'Timelines'` | `startColumnName`, `endColumnName` |
114
+ | `DG.VIEWER.RADAR_VIEWER` | `'Radar'` | `columnNames` |
115
+ | `DG.VIEWER.GRID` | `'Grid'` | (the main grid — `view.grid` is the typed accessor) |
116
+
117
+ Full canonical list at runtime: `Object.values(DG.VIEWER)`.
118
+
119
+ ## Adding viewers
120
+
121
+ Use the in-scope `view` global, not `grok.shell.tv` (the *globally* active
122
+ view, which may be a different tab when the user has several open).
123
+
124
+ ```js
125
+ // Scatter plot of MW vs LogP, colored by activity, with regression line.
126
+ view.addViewer(DG.VIEWER.SCATTER_PLOT, {
127
+ xColumnName: 'MW',
128
+ yColumnName: 'LogP',
129
+ colorColumnName: 'activity',
130
+ showRegressionLine: true,
131
+ });
132
+ ```
133
+
134
+ ```js
135
+ // Line chart with multiple y series — yColumnNames is the plural form (array).
136
+ view.addViewer(DG.VIEWER.LINE_CHART, {
137
+ xColumnName: 'date',
138
+ yColumnNames: ['revenue', 'expenses', 'profit'],
139
+ });
140
+ ```
141
+
142
+ ```js
143
+ // Bar chart of count by category.
144
+ view.addViewer(DG.VIEWER.BAR_CHART, {
145
+ splitColumnName: 'category',
146
+ valueColumnName: 'count',
147
+ valueAggrType: 'sum',
148
+ });
149
+ ```
150
+
151
+ ## Configuring an existing viewer
152
+
153
+ `viewer.setOptions({...})` applies a batch of property changes and re-renders
154
+ once. Same property-name rules as `addViewer`.
155
+
156
+ ```js
157
+ // Recolor the existing scatter plot by a different column.
158
+ const sp = Array.from(view.viewers).slice(1)
159
+ .find((v) => v.type === DG.VIEWER.SCATTER_PLOT);
160
+ if (sp)
161
+ sp.setOptions({colorColumnName: 'logP'});
162
+ ```
163
+
164
+ `view.addViewer(...)` returns the freshly attached viewer, so you can chain
165
+ create + configure:
166
+
167
+ ```js
168
+ const sp = view.addViewer(DG.VIEWER.SCATTER_PLOT, {
169
+ xColumnName: 'height',
170
+ yColumnName: 'weight',
171
+ showRegressionLine: true,
172
+ });
173
+ sp.setOptions({xMin: 150, xMax: 200, colorColumnName: 'age'});
174
+ ```
175
+
176
+ To discover property names, ask the viewer:
177
+
178
+ ```js
179
+ const v = view.addViewer(DG.VIEWER.SCATTER_PLOT);
180
+ const names = v.getProperties().map((p) => p.name);
181
+ return ui.divText(names.join(', '));
182
+ ```
183
+
184
+ ## Finding viewers
185
+
186
+ `view.viewers` is an array; **index 0 is always the grid**, so iteration always
187
+ starts with `.slice(1)`.
188
+
189
+ ```js
190
+ // First scatter plot on the view (or undefined).
191
+ const sp = Array.from(view.viewers).slice(1)
192
+ .find((v) => v.type === DG.VIEWER.SCATTER_PLOT);
193
+ ```
194
+
195
+ ```js
196
+ // All histograms.
197
+ const hs = Array.from(view.viewers).slice(1)
198
+ .filter((v) => v.type === DG.VIEWER.HISTOGRAM);
199
+ ```
200
+
201
+ ## Closing viewers
202
+
203
+ `viewer.close()` closes and detaches the viewer. It **throws** if the viewer
204
+ was never attached to a view, so wrap in try/catch.
205
+
206
+ ```js
207
+ // Close every scatter plot on the view.
208
+ Array.from(view.viewers).slice(1)
209
+ .filter((v) => v.type === DG.VIEWER.SCATTER_PLOT)
210
+ .forEach((v) => { try { v.close(); } catch {} });
211
+ ```
212
+
213
+ ```js
214
+ // Close every non-grid viewer (reset the view to just the grid).
215
+ Array.from(view.viewers).slice(1)
216
+ .forEach((v) => { try { v.close(); } catch {} });
217
+ ```
218
+
219
+ Close-and-replace pattern for "show me X instead of Y":
220
+
221
+ ```js
222
+ // Close all scatter plots, then add a histogram.
223
+ Array.from(view.viewers).slice(1)
224
+ .filter((v) => v.type === DG.VIEWER.SCATTER_PLOT)
225
+ .forEach((v) => { try { v.close(); } catch {} });
226
+ view.addViewer(DG.VIEWER.HISTOGRAM, {valueColumnName: 'activity'});
227
+ ```
228
+
229
+ ## Plugin viewers — they are functions, not types
230
+
231
+ Some "viewers" users name are actually package-registered functions that
232
+ *create* a viewer as a side effect. They aren't in `DG.VIEWER`. Route via
233
+ `grok.functions.call`:
234
+
235
+ | User phrase | Function call |
236
+ |------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
237
+ | "chem space" / "chemical space" | `grok.functions.call('Chem:chemSpaceTopMenu', {table: t, molecules: t.col('smiles'), methodName: 'UMAP', similarityMetric: 'Tanimoto', plotEmbeddings: true})` |
238
+ | "sequence space" | `grok.functions.call('Bio:sequenceSpaceTopMenu', {table: t, molecules: t.col('sequence'), methodName: 'UMAP', similarityMetric: 'Levenshtein', plotEmbeddings: true})` |
239
+ | "activity cliffs" | `grok.functions.call('Chem:activityCliffs', {table: t, molecules: t.col('smiles'), activities: t.col('activity'), similarity: 80, methodName: 'UMAP'})` |
240
+ | "elemental analysis" | `grok.functions.call('Chem:elementalAnalysis', {table: t, molecules: t.col('smiles')})` |
241
+
242
+ Each mutates the DataFrame and attaches a viewer to the current TableView.
243
+ Only the *Space functions return the freshly-attached viewer (`Chem:chemSpaceTopMenu`,
244
+ `Bio:sequenceSpaceTopMenu`). `Chem:activityCliffs` and `Chem:elementalAnalysis`
245
+ return `void`, so to keep configuring you must find the new viewer via
246
+ `view.viewers`:
247
+
248
+ ```js
249
+ const sp = await grok.functions.call('Chem:chemSpaceTopMenu', {
250
+ table: t, molecules: t.col('smiles'),
251
+ methodName: 'UMAP', similarityMetric: 'Tanimoto', plotEmbeddings: true,
252
+ });
253
+ if (sp)
254
+ sp.setOptions({colorColumnName: 'activity'});
255
+ ```
256
+
257
+ ## Standalone (detached) viewers
258
+
259
+ Use `DG.Viewer.fromType` **only** when embedding a viewer in a custom UI
260
+ element you return from the block. The caller is responsible for placing the
261
+ result. For everything else, prefer `view.addViewer`.
262
+
263
+ ```js
264
+ // Build a scatter plot of t and embed its DOM root in the chat.
265
+ const sp = DG.Viewer.fromType(DG.VIEWER.SCATTER_PLOT, t, {
266
+ xColumnName: 'mw', yColumnName: 'logp',
267
+ });
268
+ return sp.root;
269
+ ```
270
+
271
+ ## Anti-patterns
272
+
273
+ 1. **Bare `x` / `y` / `color` in options** — `{x: 'mw', y: 'logp'}` silently
274
+ does nothing. The property is `xColumnName`.
275
+ 2. **Literal strings instead of `DG.VIEWER.*`** — use `DG.VIEWER.SCATTER_PLOT`,
276
+ not `'scatter plot'`.
277
+ 3. **`view.scatterPlot(opts)` / `view.histogram(opts)` / `view.barChart(opts)`** —
278
+ per-type shorthands are deprecated. Use `view.addViewer(DG.VIEWER.*, opts)`.
279
+ 4. **`new DG.Viewer(...)`** — internal constructor over a Dart handle. Use
280
+ `view.addViewer(type, opts)` or `DG.Viewer.fromType(type, df, opts?)`.
281
+ 5. **`grok.shell.addViewer(...)`** — no such method. Use `view.addViewer(...)`.
282
+ 6. **`grok.shell.tv` when `view` is in scope** — `view` is the in-scope
283
+ TableView. `grok.shell.tv` is the globally active view and may be a
284
+ different tab.
285
+ 7. **Treating "chem space" / "sequence space" / "activity cliffs" as viewer
286
+ types** — they're functions called via `grok.functions.call`.
287
+ 8. **Iterating `view.viewers` without `.slice(1)`** — index 0 is the grid.
288
+ `view.viewers.forEach(v => v.close())` closes the grid.
289
+ 9. **`viewer.close()` on a never-attached viewer** — throws. Guard with
290
+ try/catch.
291
+ 10. **`await view.addViewer(...)`** — synchronous for built-in types. Only
292
+ plugin viewers via `grok.functions.call(...)` are async.
293
+
294
+ ## Out of scope
295
+
296
+ - **Row filtering** (`df.filter`) — `datagrok-filtering`.
297
+ - **Grid customization** (visibility, widths, pinning) —
298
+ `datagrok-grid-customization`; column color coding —
299
+ `datagrok-df-and-columns`.
300
+ - **The Filters viewer (`DG.VIEWER.FILTERS`)** — `view.getFiltersGroup()`
301
+ is the right API and is covered by `datagrok-filtering`. Only add a
302
+ Filters viewer here if the user explicitly says "add a filter panel as a
303
+ viewer".
@@ -0,0 +1,18 @@
1
+ [tool.mypy]
2
+ strict = true
3
+ python_version = "3.11"
4
+ mypy_path = "agent"
5
+ files = ["agent/grokky_agent"]
6
+
7
+ [[tool.mypy.overrides]]
8
+ module = ["run_agent", "model_tools", "hermes_constants", "hermes_state", "hermes_state_registry", "hermes_cli.*",
9
+ "tools.*", "agent.*", "pm", "pm.*", "boto3", "botocore.*"]
10
+ ignore_missing_imports = true
11
+
12
+ [tool.ruff]
13
+ line-length = 120
14
+ target-version = "py311"
15
+ src = ["agent"]
16
+
17
+ [tool.ruff.lint]
18
+ select = ["E", "F", "W", "I", "UP", "B", "RUF"]