@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.
- package/.claude/skills/deploy-grokky/SKILL.md +193 -0
- package/.grokignore +2 -0
- package/.turbo/turbo-build.log +24 -0
- package/.vscode/settings.json +16 -0
- package/CHANGELOG.md +151 -8
- package/CLAUDE.md +284 -0
- package/CREDITS.md +173 -0
- package/LICENSE.md +16 -0
- package/README.md +24 -0
- package/bdd/bdd.config.json +1 -0
- package/bdd/bindings/elements.ts +9 -0
- package/bdd/bindings/steps.ts +787 -0
- package/bdd/features/ai-panel/platform-work.feature +63 -0
- package/bdd/features/ai-panel/session.feature +69 -0
- package/bdd/features/ai-panel/table-work.feature +99 -0
- package/bdd/generated/ai-panel/platform-work.test.ts +103 -0
- package/bdd/generated/ai-panel/session.test.ts +100 -0
- package/bdd/generated/ai-panel/table-work.test.ts +150 -0
- package/bdd/package.json +1 -0
- package/bdd/tsconfig.json +13 -0
- package/css/ai.css +637 -49
- package/dist/package-test.js +4 -1707
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +742 -92317
- package/dist/package.js.map +1 -1
- package/dockerfiles/claude-runtime/.dockerignore +1 -0
- package/{.eslintrc.json → dockerfiles/claude-runtime/.eslintrc.json} +7 -16
- package/dockerfiles/claude-runtime/Dockerfile +73 -13
- package/dockerfiles/claude-runtime/agent/grokky_agent/__init__.py +0 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/__main__.py +80 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/browser_tools.py +180 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/config.py +26 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/formats.py +155 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/guard.py +87 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/hermes.py +212 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/hermes.yaml +45 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/hermes_plugin/__init__.py +8 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/hermes_plugin/plugin.yaml +3 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/protocol.py +174 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/__init__.py +21 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/anthropic.py +21 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/azure.py +46 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/base.py +127 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/bedrock.py +46 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/custom.py +40 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/databricks.py +54 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/openai_platform.py +41 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/openrouter.py +46 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/session.py +471 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/skills.py +44 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/structured.py +40 -0
- package/dockerfiles/claude-runtime/container.json +2 -2
- package/dockerfiles/claude-runtime/entrypoint.sh +20 -0
- package/dockerfiles/claude-runtime/package-lock.json +1721 -306
- package/dockerfiles/claude-runtime/package.json +20 -5
- package/dockerfiles/claude-runtime/plugin/.claude-plugin/plugin.json +5 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-calc-column/SKILL.md +92 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-chem-data/SKILL.md +250 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-chem-toolkit/SKILL.md +395 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-df-and-columns/SKILL.md +454 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-entities/SKILL.md +38 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-exec/SKILL.md +209 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-filtering/SKILL.md +185 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-grid-customization/SKILL.md +270 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-projects/SKILL.md +100 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-selection/SKILL.md +344 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-undo/SKILL.md +78 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-viewers/SKILL.md +303 -0
- package/dockerfiles/claude-runtime/pyproject.toml +18 -0
- package/dockerfiles/claude-runtime/src/agent/pool.ts +411 -0
- package/dockerfiles/claude-runtime/src/agent/turn.ts +153 -0
- package/dockerfiles/claude-runtime/src/constants.ts +20 -0
- package/dockerfiles/claude-runtime/src/credentials.ts +45 -0
- package/dockerfiles/claude-runtime/src/grounding.ts +104 -0
- package/dockerfiles/claude-runtime/src/help-index.ts +118 -0
- package/dockerfiles/claude-runtime/src/privileges.ts +8 -0
- package/dockerfiles/claude-runtime/src/prompts.ts +211 -0
- package/dockerfiles/claude-runtime/src/server.ts +134 -234
- package/dockerfiles/claude-runtime/src/session.ts +328 -0
- package/dockerfiles/claude-runtime/src/shared-api-client.ts +112 -0
- package/dockerfiles/claude-runtime/src/stream-filter.ts +80 -0
- package/dockerfiles/claude-runtime/src/sync/home-files.ts +80 -0
- package/dockerfiles/claude-runtime/src/sync/orchestrator.ts +214 -0
- package/dockerfiles/claude-runtime/src/sync/packages.ts +145 -0
- package/dockerfiles/claude-runtime/src/sync/shared-connections.ts +87 -0
- package/dockerfiles/claude-runtime/src/sync/workspace.ts +68 -0
- package/dockerfiles/claude-runtime/src/tasks.ts +124 -0
- package/dockerfiles/claude-runtime/src/tool-summary.ts +66 -0
- package/dockerfiles/claude-runtime/src/types.ts +142 -23
- package/dockerfiles/claude-runtime/src/user/installed-packages.ts +17 -0
- package/dockerfiles/claude-runtime/src/user/staged-workspace.ts +80 -0
- package/dockerfiles/claude-runtime/src/user/user-dir.ts +108 -0
- package/dockerfiles/claude-runtime/src/verify.ts +136 -0
- package/dockerfiles/claude-runtime/src/watchdog.ts +115 -0
- package/dockerfiles/claude-runtime/test/credentials.test.js +43 -0
- package/dockerfiles/claude-runtime/test/grounding.test.js +191 -0
- package/dockerfiles/claude-runtime/test/help-index.test.js +115 -0
- package/dockerfiles/claude-runtime/test/plugin-skills.test.js +57 -0
- package/dockerfiles/claude-runtime/test/prompts.test.js +62 -0
- package/dockerfiles/claude-runtime/test/reaper.test.js +60 -0
- package/dockerfiles/claude-runtime/test/stream-filter.test.js +132 -0
- package/dockerfiles/claude-runtime/test/tasks.test.js +74 -0
- package/dockerfiles/claude-runtime/test/user-dir.test.js +71 -0
- package/dockerfiles/claude-runtime/test/verify.test.js +187 -0
- package/dockerfiles/claude-runtime/test/watchdog.test.js +43 -0
- package/dockerfiles/mcp-server/.eslintrc.json +39 -0
- package/dockerfiles/mcp-server/Dockerfile +10 -2
- package/dockerfiles/mcp-server/package-lock.json +1743 -98
- package/dockerfiles/mcp-server/package.json +27 -5
- package/dockerfiles/mcp-server/src/api-client.ts +123 -66
- package/dockerfiles/mcp-server/src/format.ts +51 -0
- package/dockerfiles/mcp-server/src/index.ts +44 -113
- package/dockerfiles/mcp-server/src/ops.ts +325 -0
- package/dockerfiles/mcp-server/src/shared-api-client.ts +81 -0
- package/dockerfiles/mcp-server/test/format.test.js +62 -0
- package/dockerfiles/mcp-server/test/ops.test.js +84 -0
- package/dockerfiles/mcp-server/test/shared-api-client.test.js +35 -0
- package/dockerfiles/queue/Dockerfile +2 -0
- package/dockerfiles/queue/container.json +7 -0
- package/docs/AUDIT-2026-08-03.md +1064 -0
- package/docs/BENCHMARK.md +292 -0
- package/docs/CLAUDE_CODE_FLOW.md +746 -0
- package/docs/EXAMPLES.md +82 -0
- package/docs/FEATURES.md +71 -0
- package/docs/IMPLEMENTATION.md +128 -0
- package/docs/LATENCY.md +170 -0
- package/docs/VISION.md +36 -0
- package/files/benchmark/suite.yaml +404 -0
- package/files/scripts/process-cro-results.md +14 -0
- package/files/suggestions.yaml +344 -0
- package/package.json +39 -97
- package/src/ai/ai-window.ts +157 -0
- package/src/ai/benchmark/benchmark.ts +737 -0
- package/src/ai/db-view-functions.ts +56 -0
- package/src/ai/engine.ts +98 -0
- package/src/ai/gemma-engine.ts +81 -0
- package/src/ai/panel.ts +1385 -0
- package/src/ai/prompt-suggestions.ts +209 -0
- package/src/ai/search/combined-search.ts +244 -0
- package/src/{llm-utils → ai/search}/query-matching.ts +46 -167
- package/src/{llm-utils → ai}/storage.ts +0 -1
- package/src/ai/table-tools.ts +145 -0
- package/src/ai/ui.ts +720 -0
- package/src/ai/usage-limiter.ts +105 -0
- package/src/ai/view-tools.ts +352 -0
- package/src/claude/ai-feature.ts +16 -0
- package/src/claude/exec-blocks.ts +176 -0
- package/src/claude/queue-task.ts +84 -0
- package/src/claude/runtime-client.ts +310 -0
- package/src/claude/turn-log.ts +114 -0
- package/src/claude/undoable.ts +105 -0
- package/src/{llm-utils → db}/db-index-tools.ts +24 -32
- package/src/db/sql-tools.ts +336 -0
- package/src/depr/LLM-client.ts +251 -0
- package/src/depr/ai-panel.ts +174 -0
- package/src/depr/chatgpt-assistant.ts +257 -0
- package/src/depr/creds.ts +30 -0
- package/src/depr/deepwikiclient.ts +118 -0
- package/src/depr/indexes/dg-repository-index.ts +266 -0
- package/src/depr/interfaces.ts +170 -0
- package/src/depr/is-help-request.ts +39 -0
- package/src/depr/prompt-engine.ts +52 -0
- package/src/depr/rendering-tools.ts +103 -0
- package/src/depr/script-tools.ts +785 -0
- package/src/depr/tableview-tools.ts +746 -0
- package/src/depr/viewers-ai.ts +67 -0
- package/src/package-api.ts +87 -28
- package/src/package-test.ts +1 -0
- package/src/package.g.ts +98 -48
- package/src/package.ts +211 -157
- package/src/polyfills.ts +12 -0
- package/src/utils.ts +128 -0
- package/tsconfig.json +8 -70
- package/webpack.config.js +3 -49
- package/.eslintignore +0 -2
- package/src/ai-panel.ts +0 -174
- package/src/claude-code/claude-panel.ts +0 -34
- package/src/claude-code/claude-runtime-client.ts +0 -148
- package/src/llm-utils/LLM-client.ts +0 -251
- package/src/llm-utils/combined-search.ts +0 -162
- package/src/llm-utils/creds.ts +0 -30
- package/src/llm-utils/deepwikiclient.ts +0 -118
- package/src/llm-utils/indexes/dg-repository-index.ts +0 -266
- package/src/llm-utils/panel.ts +0 -866
- package/src/llm-utils/script-tools.ts +0 -784
- package/src/llm-utils/sql-tools.ts +0 -840
- package/src/llm-utils/tableview-tools.ts +0 -704
- package/src/llm-utils/ui.ts +0 -315
- package/src/prompt-engine/chatgpt-assistant.ts +0 -257
- package/src/prompt-engine/interfaces.ts +0 -170
- package/src/prompt-engine/prompt-engine.ts +0 -52
- package/src/prompt-engine/rendering-tools.ts +0 -103
- package/src/prompts/is-help-request.ts +0 -26
- package/src/viewers-ai.ts +0 -67
- /package/src/{llm-utils → db}/indexes/biologics-index.ts +0 -0
- /package/src/{llm-utils → db}/indexes/chembl-index.ts +0 -0
- /package/src/{llm-utils → db}/query-meta-utils.ts +0 -0
- /package/src/{llm-utils/depr → depr}/AI-API-providers/openai-chat-completions-provider.ts +0 -0
- /package/src/{llm-utils/depr → depr}/AI-API-providers/openai-responses-provider.ts +0 -0
- /package/src/{llm-utils/depr → depr}/AI-API-providers/types.ts +0 -0
- /package/src/{llm-utils/depr → depr}/depr.ts +0 -0
- /package/src/{llm-utils/depr → depr}/embeddings.ts +0 -0
- /package/src/{llm-utils/depr → depr}/sql-utils.ts +0 -0
package/tsconfig.json
CHANGED
|
@@ -1,72 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
|
-
// "checkJs": true, /* Report errors in .js files. */
|
|
12
|
-
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
|
|
13
|
-
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
|
-
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
15
|
-
"sourceMap": true, /* Generates corresponding '.map' file. */
|
|
16
|
-
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
|
-
// "outDir": "./", /* Redirect output structure to the directory. */
|
|
18
|
-
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
19
|
-
// "composite": true, /* Enable project compilation */
|
|
20
|
-
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
21
|
-
// "removeComments": true, /* Do not emit comments to output. */
|
|
22
|
-
// "noEmit": true, /* Do not emit outputs. */
|
|
23
|
-
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
24
|
-
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
25
|
-
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
26
|
-
|
|
27
|
-
/* Strict Type-Checking Options */
|
|
28
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
29
|
-
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
30
|
-
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
31
|
-
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
32
|
-
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
33
|
-
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
34
|
-
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
35
|
-
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
36
|
-
|
|
37
|
-
/* Additional Checks */
|
|
38
|
-
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
39
|
-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
40
|
-
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
41
|
-
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
42
|
-
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
|
43
|
-
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
|
|
44
|
-
|
|
45
|
-
/* Module Resolution Options */
|
|
46
|
-
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
47
|
-
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
48
|
-
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
49
|
-
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
50
|
-
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
51
|
-
// "types": [], /* Type declaration files to be included in compilation. */
|
|
52
|
-
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
53
|
-
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
54
|
-
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
55
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
56
|
-
|
|
57
|
-
/* Source Map Options */
|
|
58
|
-
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
59
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
60
|
-
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
61
|
-
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
62
|
-
|
|
63
|
-
/* Experimental Options */
|
|
64
|
-
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
65
|
-
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
66
|
-
|
|
67
|
-
/* Advanced Options */
|
|
68
|
-
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
|
69
|
-
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
70
|
-
},
|
|
71
|
-
"exclude": ["dockerfiles"]
|
|
2
|
+
"extends": "@datagrok/build-config/tsconfig.base.json",
|
|
3
|
+
"include": [
|
|
4
|
+
"src"
|
|
5
|
+
],
|
|
6
|
+
"exclude": [
|
|
7
|
+
"dockerfiles",
|
|
8
|
+
"bdd"
|
|
9
|
+
]
|
|
72
10
|
}
|
package/webpack.config.js
CHANGED
|
@@ -1,49 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
cache: {
|
|
7
|
-
type: 'filesystem',
|
|
8
|
-
},
|
|
9
|
-
mode: 'development',
|
|
10
|
-
entry: {
|
|
11
|
-
test: {filename: 'package-test.js', library: {type: 'var', name: `${packageName}_test`}, import: './src/package-test.ts'},
|
|
12
|
-
package: './src/package.ts',
|
|
13
|
-
},
|
|
14
|
-
resolve: {
|
|
15
|
-
extensions: ['.wasm', '.mjs', '.ts', '.json', '.js', '.tsx'],
|
|
16
|
-
},
|
|
17
|
-
module: {
|
|
18
|
-
rules: [
|
|
19
|
-
{test: /\.tsx?$/, loader: 'ts-loader', options: {allowTsInNodeModules: true}},
|
|
20
|
-
{
|
|
21
|
-
test: /\.css$/,
|
|
22
|
-
use: ['style-loader', 'css-loader']
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
plugins: [
|
|
27
|
-
new FuncGeneratorPlugin({outputPath: './src/package.g.ts'}),
|
|
28
|
-
],
|
|
29
|
-
devtool: 'source-map',
|
|
30
|
-
externals: {
|
|
31
|
-
'datagrok-api/dg': 'DG',
|
|
32
|
-
'datagrok-api/grok': 'grok',
|
|
33
|
-
'datagrok-api/ui': 'ui',
|
|
34
|
-
'openchemlib/full.js': 'OCL',
|
|
35
|
-
'rxjs': 'rxjs',
|
|
36
|
-
'rxjs/operators': 'rxjs.operators',
|
|
37
|
-
'cash-dom': '$',
|
|
38
|
-
'dayjs': 'dayjs',
|
|
39
|
-
'wu': 'wu',
|
|
40
|
-
'exceljs': 'ExcelJS',
|
|
41
|
-
'html2canvas': 'html2canvas',
|
|
42
|
-
},
|
|
43
|
-
output: {
|
|
44
|
-
filename: '[name].js',
|
|
45
|
-
library: packageName,
|
|
46
|
-
libraryTarget: 'var',
|
|
47
|
-
path: path.resolve(__dirname, 'dist'),
|
|
48
|
-
},
|
|
49
|
-
};
|
|
1
|
+
// Generated at npm publish for servers before 1.28.0, which detect a bundled
|
|
2
|
+
// package by this file. The bundle itself is built by @datagrok/build-config.
|
|
3
|
+
module.exports = {};
|
package/.eslintignore
DELETED
package/src/ai-panel.ts
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
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 {askAiTableView} from './viewers-ai';
|
|
5
|
-
import {popupMenu} from 'datagrok-api/ui';
|
|
6
|
-
|
|
7
|
-
export const aiPanel: HTMLElement = ui.divV([]);
|
|
8
|
-
const input: HTMLTextAreaElement = ui.element('textarea');
|
|
9
|
-
const api: any = (typeof window !== 'undefined' ? window : global.window) as any;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export function initAiPanel() {
|
|
13
|
-
input.placeholder = 'Ask a question, or tell what to do...';
|
|
14
|
-
input.style.overflow = 'none';
|
|
15
|
-
input.style.boxShadow = 'none';
|
|
16
|
-
input.style.outline = 'none';
|
|
17
|
-
input.style.borderColor = '--var(grey-2)';
|
|
18
|
-
input.style.width = '100%';
|
|
19
|
-
const spinner = ui.icons.spinner();
|
|
20
|
-
const messagesDiv = ui.div();
|
|
21
|
-
|
|
22
|
-
const prompt = async (question: string) => {
|
|
23
|
-
messagesDiv.append(ui.divText(question, {classes: 'ai-panel-question'}));
|
|
24
|
-
|
|
25
|
-
//@ts-ignore
|
|
26
|
-
if (await api.grok_Shell_AI_Prompt(question))
|
|
27
|
-
return;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const currentView = grok.shell.v;
|
|
31
|
-
if (currentView && currentView.type === DG.VIEW_TYPE.TABLE_VIEW && question) {
|
|
32
|
-
const tableView = currentView as DG.TableView;
|
|
33
|
-
messagesDiv.append(spinner);
|
|
34
|
-
try {
|
|
35
|
-
await askAiTableView(tableView, input.value);
|
|
36
|
-
} finally {
|
|
37
|
-
spinner.remove();
|
|
38
|
-
}
|
|
39
|
-
input.value = '';
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// Add Enter key event listener
|
|
44
|
-
input.addEventListener('keydown', async (event) => {
|
|
45
|
-
if (event.code === 'Enter' && !event.shiftKey) {
|
|
46
|
-
console.log('prompt');
|
|
47
|
-
event.preventDefault();
|
|
48
|
-
prompt(input.value.trim());
|
|
49
|
-
input.value = '';
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
let listening: boolean = false;
|
|
54
|
-
const recognitions: Set<SpeechRecognition> = new Set();
|
|
55
|
-
|
|
56
|
-
function refreshUI() {
|
|
57
|
-
mikeIcon.style.color = listening ? 'var(--blue-1)' : 'initial';
|
|
58
|
-
listeningLabel.style.display = listening ? 'initial' : 'none';
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function listen() {
|
|
62
|
-
const sr = new SpeechRecognition();
|
|
63
|
-
recognitions.add(sr);
|
|
64
|
-
sr.lang = 'en-US';
|
|
65
|
-
sr.onresult = (x) => {
|
|
66
|
-
const transcript = x.results[0][0].transcript;
|
|
67
|
-
|
|
68
|
-
if (transcript === 'stop') {
|
|
69
|
-
listening = false;
|
|
70
|
-
refreshUI();
|
|
71
|
-
} else
|
|
72
|
-
prompt(transcript);
|
|
73
|
-
};
|
|
74
|
-
sr.onend = () => {
|
|
75
|
-
recognitions.delete(sr);
|
|
76
|
-
if (listening)
|
|
77
|
-
listen();
|
|
78
|
-
};
|
|
79
|
-
sr.start();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const mikeIcon = ui.iconFA('microphone', () => {}, 'Toggle microphone input');
|
|
83
|
-
const listeningLabel = ui.divText('Listening...', {style: {
|
|
84
|
-
display: 'none',
|
|
85
|
-
verticalAlign: 'middle'
|
|
86
|
-
}});
|
|
87
|
-
|
|
88
|
-
const prompts = {
|
|
89
|
-
'Scatter plot': [
|
|
90
|
-
'set x to age',
|
|
91
|
-
'y by height',
|
|
92
|
-
'set title to Foo',
|
|
93
|
-
'invert y axis',
|
|
94
|
-
'set marker default size to 30',
|
|
95
|
-
'increase marker default size',
|
|
96
|
-
'show regression line',
|
|
97
|
-
'hide color selector',
|
|
98
|
-
'decrease marker opacity',
|
|
99
|
-
'color by race',
|
|
100
|
-
'set marker color to age',
|
|
101
|
-
'size-code by age',
|
|
102
|
-
'marker by sex',
|
|
103
|
-
'zoom in',
|
|
104
|
-
'select all rows',
|
|
105
|
-
],
|
|
106
|
-
'Grid': [
|
|
107
|
-
'next page', 'next page', 'scroll down',
|
|
108
|
-
'page up', 'page down',
|
|
109
|
-
'move right', 'next column',
|
|
110
|
-
'scroll to the top', 'scroll to the bottom',
|
|
111
|
-
'select column age', 'select column weight',
|
|
112
|
-
'color-code height',
|
|
113
|
-
'sort by age',
|
|
114
|
-
],
|
|
115
|
-
'Table view': [
|
|
116
|
-
'activate spreadsheet',
|
|
117
|
-
'focus on scatter plot',
|
|
118
|
-
'spreadsheet',
|
|
119
|
-
'grid',
|
|
120
|
-
'table',
|
|
121
|
-
],
|
|
122
|
-
'Shell': [
|
|
123
|
-
'open plugins view',
|
|
124
|
-
'show users',
|
|
125
|
-
'show plugins'
|
|
126
|
-
]
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const convosIcon = ui.icons.settings(() => {
|
|
130
|
-
const menu = ui.popupMenu();
|
|
131
|
-
for (const name of Object.keys(prompts))
|
|
132
|
-
menu.group(name).items(prompts[name as keyof typeof prompts], (s) => prompt(s));
|
|
133
|
-
|
|
134
|
-
menu.show();
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const toggle = () => {
|
|
138
|
-
listening = !listening;
|
|
139
|
-
refreshUI();
|
|
140
|
-
|
|
141
|
-
if (listening)
|
|
142
|
-
listen();
|
|
143
|
-
else {
|
|
144
|
-
for (const sr of recognitions.values())
|
|
145
|
-
sr.stop();
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
mikeIcon.onclick = () => toggle();
|
|
150
|
-
listeningLabel.onclick = () => toggle();
|
|
151
|
-
|
|
152
|
-
const clearIcon = ui.iconFA('trash', () => ui.empty(messagesDiv), 'Clear console');
|
|
153
|
-
|
|
154
|
-
aiPanel.append(ui.divH([clearIcon, mikeIcon, convosIcon, listeningLabel], 'd4-ribbon-item'));
|
|
155
|
-
aiPanel.append();
|
|
156
|
-
aiPanel.append(input);
|
|
157
|
-
aiPanel.append(messagesDiv);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export function setAiPanelVisibility(visible: boolean) {
|
|
161
|
-
if (visible) {
|
|
162
|
-
const contextRoot = grok.shell.windows.context.root;
|
|
163
|
-
const contextNode = contextRoot ? grok.shell.dockManager.findNode(contextRoot) : null;
|
|
164
|
-
//@ts-ignore
|
|
165
|
-
grok.shell.dockManager.dock(aiPanel, contextNode ? 'down' : 'right', contextNode, '', 0.4);
|
|
166
|
-
input.tabIndex = 0;
|
|
167
|
-
input.focus();
|
|
168
|
-
} else
|
|
169
|
-
grok.shell.dockManager.close(aiPanel);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export function getAiPanelVisibility(): boolean {
|
|
173
|
-
return document.body.contains(aiPanel);
|
|
174
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
|
|
5
|
-
export function executeDatagrokBlocks(content: string, view: DG.ViewBase): void {
|
|
6
|
-
const re = /```datagrok-exec\n([\s\S]*?)```/g;
|
|
7
|
-
let match: RegExpExecArray | null;
|
|
8
|
-
while ((match = re.exec(content)) !== null) {
|
|
9
|
-
const code = match[1];
|
|
10
|
-
try {
|
|
11
|
-
const t = view.type === DG.VIEW_TYPE.TABLE_VIEW ? (view as DG.TableView).dataFrame : undefined;
|
|
12
|
-
new Function('grok', 'ui', 'DG', 'view', 't',
|
|
13
|
-
'return (async () => {' + code + '})()',
|
|
14
|
-
)(grok, ui, DG, view, t)
|
|
15
|
-
.catch((e: any) => grok.shell.error(`datagrok-exec error: ${e.message}`));
|
|
16
|
-
}
|
|
17
|
-
catch (e: any) {
|
|
18
|
-
grok.shell.error(`datagrok-exec error: ${e.message}`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function buildViewContext(view: DG.ViewBase): string {
|
|
24
|
-
if (view.type === DG.VIEW_TYPE.TABLE_VIEW) {
|
|
25
|
-
const df = (view as DG.TableView).dataFrame;
|
|
26
|
-
if (!df)
|
|
27
|
-
return '';
|
|
28
|
-
const cols = df.columns.toList().map((c) => `${c.name}(${c.type})`).join(', ');
|
|
29
|
-
return `Table "${df.name}" (${df.rowCount} rows): ${cols}`;
|
|
30
|
-
}
|
|
31
|
-
if (view.type === 'ScriptView')
|
|
32
|
-
return `ScriptView "${view.name}"`;
|
|
33
|
-
return '';
|
|
34
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import * as grok from 'datagrok-api/grok';
|
|
2
|
-
import * as rxjs from 'rxjs';
|
|
3
|
-
|
|
4
|
-
export type ChunkEvent = {sessionId: string, content: string};
|
|
5
|
-
export type ToolActivityEvent = {sessionId: string, summary: string};
|
|
6
|
-
export type ToolResultEvent = {sessionId: string, content: string};
|
|
7
|
-
export type FinalEvent = {sessionId: string, content: string};
|
|
8
|
-
export type ErrorEvent = {sessionId: string, message: string};
|
|
9
|
-
|
|
10
|
-
export class ClaudeRuntimeClient {
|
|
11
|
-
private static instance: ClaudeRuntimeClient | null = null;
|
|
12
|
-
private ws: WebSocket | null = null;
|
|
13
|
-
private containerId: string | null = null;
|
|
14
|
-
private mcpServerUrl: string | null = null;
|
|
15
|
-
|
|
16
|
-
public onChunk = new rxjs.Subject<ChunkEvent>();
|
|
17
|
-
public onToolActivity = new rxjs.Subject<ToolActivityEvent>();
|
|
18
|
-
public onToolResult = new rxjs.Subject<ToolResultEvent>();
|
|
19
|
-
public onFinal = new rxjs.Subject<FinalEvent>();
|
|
20
|
-
public onError = new rxjs.Subject<ErrorEvent>();
|
|
21
|
-
public onClose = new rxjs.Subject<void>();
|
|
22
|
-
|
|
23
|
-
private constructor() {}
|
|
24
|
-
|
|
25
|
-
static getInstance(): ClaudeRuntimeClient {
|
|
26
|
-
if (!ClaudeRuntimeClient.instance)
|
|
27
|
-
ClaudeRuntimeClient.instance = new ClaudeRuntimeClient();
|
|
28
|
-
return ClaudeRuntimeClient.instance;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
get connected(): boolean {
|
|
32
|
-
return this.ws !== null && this.ws.readyState === WebSocket.OPEN;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async ensureConnected(): Promise<void> {
|
|
36
|
-
if (!this.connected)
|
|
37
|
-
await this.connect();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async connect(): Promise<void> {
|
|
41
|
-
if (this.connected)
|
|
42
|
-
return;
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
const [runtimeContainers, mcpContainers] = await Promise.all([
|
|
46
|
-
grok.dapi.docker.dockerContainers.filter('name = "grokky-claude-runtime"').list(),
|
|
47
|
-
grok.dapi.docker.dockerContainers.filter('name = "grokky-mcp-server"').list(),
|
|
48
|
-
]);
|
|
49
|
-
if (runtimeContainers.length > 0) {
|
|
50
|
-
this.containerId = runtimeContainers[0].id;
|
|
51
|
-
this.ws = await grok.dapi.docker.dockerContainers.webSocketProxy(this.containerId, '/ws');
|
|
52
|
-
}
|
|
53
|
-
if (mcpContainers.length > 0)
|
|
54
|
-
this.mcpServerUrl = `${grok.dapi.root}/docker/containers/proxy/${mcpContainers[0].id}/mcp`;
|
|
55
|
-
} catch (e) {
|
|
56
|
-
console.error('Failed to connect to Claude runtime:', e);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
this.ws!.onmessage = (event: MessageEvent) => {
|
|
60
|
-
let data: any;
|
|
61
|
-
try {
|
|
62
|
-
data = JSON.parse(event.data);
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
console.error('ClaudeRuntimeClient: failed to parse message', event.data);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
switch (data.type) {
|
|
70
|
-
case 'chunk':
|
|
71
|
-
this.onChunk.next({sessionId: data.sessionId, content: data.content});
|
|
72
|
-
break;
|
|
73
|
-
case 'tool_activity':
|
|
74
|
-
this.onToolActivity.next({sessionId: data.sessionId, summary: data.summary});
|
|
75
|
-
break;
|
|
76
|
-
case 'tool_result':
|
|
77
|
-
this.onToolResult.next({sessionId: data.sessionId, content: data.content});
|
|
78
|
-
break;
|
|
79
|
-
case 'final':
|
|
80
|
-
this.onFinal.next({
|
|
81
|
-
sessionId: data.sessionId, content: data.content,
|
|
82
|
-
});
|
|
83
|
-
break;
|
|
84
|
-
case 'error':
|
|
85
|
-
this.onError.next({sessionId: data.sessionId, message: data.message});
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
this.ws!.onclose = () => {
|
|
91
|
-
this.ws = null;
|
|
92
|
-
this.onClose.next();
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
this.ws!.onerror = () => {
|
|
96
|
-
this.ws = null;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
send(sessionId: string, message: string): void {
|
|
101
|
-
if (!this.ws || this.ws.readyState !== WebSocket.OPEN)
|
|
102
|
-
throw new Error('ClaudeRuntimeClient: WebSocket is not connected');
|
|
103
|
-
this.ws.send(JSON.stringify({
|
|
104
|
-
type: 'user_message', sessionId, message,
|
|
105
|
-
apiKey: grok.dapi.token,
|
|
106
|
-
mcpServerUrl: this.mcpServerUrl,
|
|
107
|
-
}));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async query(message: string, sessionId?: string): Promise<string> {
|
|
111
|
-
await this.ensureConnected();
|
|
112
|
-
const sid = sessionId ?? `query-${Date.now()}`;
|
|
113
|
-
return new Promise<string>((resolve, reject) => {
|
|
114
|
-
const subs: {unsubscribe: () => void}[] = [];
|
|
115
|
-
const cleanup = () => { subs.forEach((s) => s.unsubscribe()); };
|
|
116
|
-
subs.push(this.onFinal.subscribe((evt) => {
|
|
117
|
-
if (evt.sessionId !== sid) return;
|
|
118
|
-
cleanup();
|
|
119
|
-
resolve(evt.content);
|
|
120
|
-
}));
|
|
121
|
-
subs.push(this.onError.subscribe((evt) => {
|
|
122
|
-
if (evt.sessionId !== sid) return;
|
|
123
|
-
cleanup();
|
|
124
|
-
reject(new Error(evt.message));
|
|
125
|
-
}));
|
|
126
|
-
this.send(sid, message);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
disconnect(): void {
|
|
131
|
-
if (this.ws) {
|
|
132
|
-
this.ws.close();
|
|
133
|
-
this.ws = null;
|
|
134
|
-
}
|
|
135
|
-
this.onChunk.complete();
|
|
136
|
-
this.onToolActivity.complete();
|
|
137
|
-
this.onToolResult.complete();
|
|
138
|
-
this.onFinal.complete();
|
|
139
|
-
this.onError.complete();
|
|
140
|
-
this.onClose.complete();
|
|
141
|
-
this.onChunk = new rxjs.Subject<ChunkEvent>();
|
|
142
|
-
this.onToolActivity = new rxjs.Subject<ToolActivityEvent>();
|
|
143
|
-
this.onToolResult = new rxjs.Subject<ToolResultEvent>();
|
|
144
|
-
this.onFinal = new rxjs.Subject<FinalEvent>();
|
|
145
|
-
this.onError = new rxjs.Subject<ErrorEvent>();
|
|
146
|
-
this.onClose = new rxjs.Subject<void>();
|
|
147
|
-
}
|
|
148
|
-
}
|