@datalayer/core 0.0.15 → 0.0.17

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 (46) hide show
  1. package/lib/components/chat/ChatComponent.d.ts +4 -0
  2. package/lib/components/chat/ChatComponent.js +139 -0
  3. package/lib/components/chat/MessagePart.d.ts +11 -0
  4. package/lib/components/chat/MessagePart.js +23 -0
  5. package/lib/components/chat/display/DynamicToolPart.d.ts +6 -0
  6. package/lib/components/chat/display/DynamicToolPart.js +5 -0
  7. package/lib/components/chat/display/ReasoningPart.d.ts +6 -0
  8. package/lib/components/chat/display/ReasoningPart.js +54 -0
  9. package/lib/components/chat/display/TextPart.d.ts +9 -0
  10. package/lib/components/chat/display/TextPart.js +93 -0
  11. package/lib/components/chat/display/ToolPart.d.ts +6 -0
  12. package/lib/components/chat/display/ToolPart.js +144 -0
  13. package/lib/components/chat/display/index.d.ts +4 -0
  14. package/lib/components/chat/display/index.js +9 -0
  15. package/lib/components/chat/handler.d.ts +8 -0
  16. package/lib/components/chat/handler.js +39 -0
  17. package/lib/components/chat/index.d.ts +4 -0
  18. package/lib/components/chat/index.js +9 -0
  19. package/lib/components/index.d.ts +1 -1
  20. package/lib/components/index.js +1 -1
  21. package/lib/components/runtimes/RuntimeSimplePicker.d.ts +4 -0
  22. package/lib/components/runtimes/RuntimeSimplePicker.js +3 -3
  23. package/lib/examples/ChatExample.d.ts +8 -0
  24. package/lib/examples/ChatExample.js +51 -0
  25. package/lib/examples/example-selector.js +1 -0
  26. package/lib/hooks/useAIJupyterChat.d.ts +36 -0
  27. package/lib/hooks/useAIJupyterChat.js +49 -0
  28. package/lib/hooks/useCache.js +105 -45
  29. package/lib/hooks/useMobile.d.ts +1 -0
  30. package/lib/hooks/useMobile.js +22 -0
  31. package/lib/hooks/useUpload.js +29 -21
  32. package/lib/index.d.ts +1 -0
  33. package/lib/index.js +8 -4
  34. package/lib/stateful/index.d.ts +0 -1
  35. package/lib/stateful/index.js +0 -1
  36. package/lib/stateful/runtimes/actions.d.ts +1 -1
  37. package/lib/stateful/runtimes/actions.js +1 -1
  38. package/lib/theme/DatalayerTheme.d.ts +2 -2
  39. package/lib/theme/DatalayerTheme.js +4 -4
  40. package/lib/theme/DatalayerThemeProvider.js +2 -2
  41. package/lib/types.d.ts +5 -0
  42. package/lib/types.js +6 -0
  43. package/package.json +16 -2
  44. package/style/base.css +4 -0
  45. package/lib/sdk/index.d.ts +0 -27
  46. package/lib/sdk/index.js +0 -33
@@ -20,27 +20,35 @@ export const useUploadForm = (url) => {
20
20
  };
21
21
  const uploadAndSubmit = async (formData) => {
22
22
  setIsLoading(true);
23
- const { data } = await axios.post(url, formData, {
24
- headers: {
25
- 'Content-Type': 'multipart/form-data',
26
- Authorization: `Bearer ${token}`,
27
- },
28
- onUploadProgress: progressEvent => {
29
- const progress = (progressEvent.loaded / progressEvent.total) * 50;
30
- setProgress(progress);
31
- },
32
- onDownloadProgress: progressEvent => {
33
- const progress = 50 + (progressEvent.loaded / progressEvent.total) * 50;
34
- setProgress(progress);
35
- },
36
- });
37
- setProgress(100);
38
- await new Promise(resolve => {
39
- setTimeout(() => resolve('success'), 500);
40
- });
41
- setIsSuccess(true);
42
- setProgress(0);
43
- return data;
23
+ try {
24
+ const { data } = await axios.post(url, formData, {
25
+ headers: {
26
+ 'Content-Type': 'multipart/form-data',
27
+ Authorization: `Bearer ${token}`,
28
+ },
29
+ onUploadProgress: progressEvent => {
30
+ const progress = (progressEvent.loaded / progressEvent.total) * 50;
31
+ setProgress(progress);
32
+ },
33
+ onDownloadProgress: progressEvent => {
34
+ const progress = 50 + (progressEvent.loaded / progressEvent.total) * 50;
35
+ setProgress(progress);
36
+ },
37
+ });
38
+ setProgress(100);
39
+ await new Promise(resolve => {
40
+ setTimeout(() => resolve('success'), 500);
41
+ });
42
+ setIsSuccess(true);
43
+ setIsLoading(false);
44
+ setProgress(0);
45
+ return data;
46
+ }
47
+ catch (error) {
48
+ setIsLoading(false);
49
+ setProgress(0);
50
+ throw error;
51
+ }
44
52
  };
45
53
  return { uploadAndSubmit, isSuccess, isLoading, progress, reset };
46
54
  };
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './components';
1
2
  export * from './utils';
2
3
  export * from './state';
3
4
  export * from './collaboration';
package/lib/index.js CHANGED
@@ -2,6 +2,8 @@
2
2
  * Copyright (c) 2023-2025 Datalayer, Inc.
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
+ // Export core components and utilities
6
+ export * from './components';
5
7
  export * from './utils';
6
8
  export * from './state';
7
9
  export * from './collaboration';
@@ -9,14 +11,16 @@ export * from './services';
9
11
  // Export navigation before hooks to avoid conflicts
10
12
  export * from './navigation';
11
13
  export * from './hooks';
12
- // Export API and SDK layers
14
+ // Export API.
13
15
  export { requestDatalayerAPI, RunResponseError, NetworkError, } from './api/DatalayerApi';
14
16
  export { API_BASE_PATHS } from './api/constants';
15
17
  export * as runtimesApi from './api/runtimes';
16
18
  export * as iamApi from './api/iam';
17
19
  export * as spacerApi from './api/spacer';
18
- export { DatalayerClient,
19
- // Export SDK models
20
+ export {
21
+ // Export client and config types
22
+ DatalayerClient,
23
+ // Export domain models
20
24
  User, Runtime, Environment, Snapshot, Space, Notebook, LexicalDTO, Credits, Item, } from './client';
21
- // Export commonly used SDK functions directly for convenience
25
+ // Export commonly used functions directly for convenience
22
26
  export { getEnvironments, createRuntime, getRuntimes, deleteRuntime, snapshotRuntime, getRuntimeSnapshots, loadRuntimeSnapshot, } from './stateful/runtimes/actions';
@@ -1,3 +1,2 @@
1
1
  export * from './jupyter';
2
2
  export * from './runtimes';
3
- export * from '../api/DatalayerApi';
@@ -4,4 +4,3 @@
4
4
  */
5
5
  export * from './jupyter';
6
6
  export * from './runtimes';
7
- export * from '../api/DatalayerApi';
@@ -1,4 +1,4 @@
1
- import { IRuntimeOptions } from '..';
1
+ import { IRuntimeOptions } from '../../api';
2
2
  import type { IRuntimeSnapshot, IDatalayerEnvironment, IRuntimePod } from '../../models';
3
3
  /**
4
4
  * Get available Environments.
@@ -8,7 +8,7 @@
8
8
  import { URLExt } from '@jupyterlab/coreutils';
9
9
  import { PromiseDelegate } from '@lumino/coreutils';
10
10
  import { Upload } from 'tus-js-client';
11
- import { requestDatalayerAPI, } from '..';
11
+ import { requestDatalayerAPI, } from '../../api';
12
12
  import { asRuntimeSnapshot } from '../../models';
13
13
  import { iamStore, runtimesStore } from '../../state';
14
14
  import { sleep } from '../../utils';
@@ -1,4 +1,4 @@
1
- declare const theme: {
1
+ declare const datalayerTheme: {
2
2
  animation: {
3
3
  easeOutCubic: string;
4
4
  };
@@ -34,4 +34,4 @@ declare const theme: {
34
34
  dark: {};
35
35
  };
36
36
  };
37
- export { theme as datalayerTheme };
37
+ export { datalayerTheme };
@@ -48,15 +48,15 @@ const datalayerThemeDefs = {
48
48
  const { colorSchemes: primerSchemes, ...primerOthers } = cloneDeep(primerTheme);
49
49
  const { colorSchemes: jupyterSchemes, ...datalayerOthers } = datalayerThemeDefs;
50
50
  // Merge with the light theme to ensure all variables are defined (although the style may be ugly).
51
- const theme = merge(primerOthers, datalayerOthers, {
51
+ const datalayerTheme = merge(primerOthers, datalayerOthers, {
52
52
  colorSchemes: { light: {}, dark: {} },
53
53
  });
54
- theme.colorSchemes.light = {
54
+ datalayerTheme.colorSchemes.light = {
55
55
  colors: merge(primerSchemes.light.colors, jupyterSchemes.light.colors),
56
56
  shadows: merge(primerSchemes.light.shadows, jupyterSchemes.light.shadows),
57
57
  };
58
- theme.colorSchemes.dark = {
58
+ datalayerTheme.colorSchemes.dark = {
59
59
  colors: merge(primerSchemes.dark.colors, jupyterSchemes.dark.colors),
60
60
  shadows: merge(primerSchemes.dark.shadows, jupyterSchemes.dark.shadows),
61
61
  };
62
- export { theme as datalayerTheme };
62
+ export { datalayerTheme };
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { BaseStyles, ThemeProvider as PrimerThemeProvider, } from '@primer/react';
2
+ import { BaseStyles, ThemeProvider } from '@primer/react';
3
3
  export function DatalayerThemeProvider(props) {
4
4
  const { children, colorMode, baseStyles, ...rest } = props;
5
- return (_jsx(PrimerThemeProvider, { colorMode: colorMode, ...rest, children: _jsx(BaseStyles, { style: {
5
+ return (_jsx(ThemeProvider, { colorMode: colorMode, ...rest, children: _jsx(BaseStyles, { style: {
6
6
  backgroundColor: 'var(--bgColor-default)',
7
7
  color: 'var(--fgColor-default)',
8
8
  fontSize: 'var(--text-body-size-medium)',
package/lib/types.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export interface ConversationEntry {
2
+ id: string;
3
+ firstMessage?: string;
4
+ timestamp: number;
5
+ }
package/lib/types.js ADDED
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (c) 2024-2025 Datalayer, Inc.
3
+ *
4
+ * BSD 3-Clause License
5
+ */
6
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/core",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "type": "module",
5
5
  "workspaces": [
6
6
  ".",
@@ -85,10 +85,15 @@
85
85
  "watch:lib:src": "tsc -b -w",
86
86
  "type-check:watch": "tsc -b -w --noEmit",
87
87
  "example": "vite --config vite.examples.config.ts",
88
+ "example:chat": "run-p jupyter:start example:chat:vite",
89
+ "example:chat:vite": "EXAMPLE=ChatExample vite --config vite.examples.config.ts",
88
90
  "example:nextjs": "npm run dev --workspace=nextjs-notebook-example",
89
- "prepare": "husky"
91
+ "jupyter:start": "./dev/sh/start-jupyter-server.sh",
92
+ "prepare": "husky",
93
+ "kill": "./dev/sh/kill.sh || true"
90
94
  },
91
95
  "dependencies": {
96
+ "@ai-sdk/react": "^2.0.34",
92
97
  "@datalayer/icons-react": "^1.0.6",
93
98
  "@datalayer/jupyter-react": "^1.1.0",
94
99
  "@datalayer/primer-addons": "^1.0.4",
@@ -103,7 +108,9 @@
103
108
  "@primer/react": "^37.19.0",
104
109
  "@primer/react-brand": "^0.58.0",
105
110
  "@stripe/react-stripe-js": "^2.7.1",
111
+ "@tailwindcss/vite": "^4.1.13",
106
112
  "@tanstack/react-query": "^5.90.6",
113
+ "ai": "^5.0.78",
107
114
  "axios": "^1.7.7",
108
115
  "boring-avatars": "^2.0.1",
109
116
  "buffer": "^6.0.3",
@@ -114,13 +121,18 @@
114
121
  "html2canvas": "^1.4.1",
115
122
  "jwt-decode": "^2.2.0",
116
123
  "localforage": "^1.10.0",
124
+ "lucide-react": "^0.542.0",
117
125
  "marked": "^4.0.10",
118
126
  "mock-socket": "^9.3.1",
119
127
  "react": "18.3.1",
120
128
  "react-confetti": "^6.4.0",
121
129
  "react-dom": "18.3.1",
122
130
  "react-toastify": "^11.0.5",
131
+ "streamdown": "^1.6.6",
132
+ "tailwind-merge": "^3.3.1",
133
+ "tailwindcss": "^4.1.13",
123
134
  "tus-js-client": "^4.2.3",
135
+ "tw-animate-css": "^1.4.0",
124
136
  "ulid": "^2.3.0",
125
137
  "unique-names-generator": "^4.7.1",
126
138
  "usehooks-ts": "^2.9.1",
@@ -145,9 +157,11 @@
145
157
  "@storybook/addon-vitest": "^9.1.1",
146
158
  "@storybook/builder-vite": "^9.1.1",
147
159
  "@storybook/react-vite": "^9.1.1",
160
+ "@tailwindcss/postcss": "^4.1.16",
148
161
  "@types/node": "^20.11.0",
149
162
  "@types/react": "18.3.20",
150
163
  "@types/react-dom": "18.3.6",
164
+ "@types/react-syntax-highlighter": "^15.5.13",
151
165
  "@vitejs/plugin-react": "^4.5.2",
152
166
  "@vitest/browser": "^3.2.4",
153
167
  "@vitest/coverage-v8": "^3.2.4",
package/style/base.css CHANGED
@@ -3,6 +3,10 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
 
6
+ @import 'tailwindcss';
7
+
8
+ @import 'tw-animate-css';
9
+
6
10
  :root {
7
11
  --dla-color-green-light: #2ECC71;
8
12
  --dla-color-green-main: #1ABC9C;
@@ -1,27 +0,0 @@
1
- /**
2
- * Main SDK entry point for the Datalayer platform.
3
- *
4
- * This module provides the unified DatalayerSDK class with a flat, intuitive API
5
- * for all Datalayer platform services. The SDK uses TypeScript mixins to provide
6
- * excellent discoverability and ease of use.
7
- *
8
- * @example
9
- * ```typescript
10
- * import { DatalayerSDK } from '@datalayer/core/sdk';
11
- *
12
- * const sdk = new DatalayerSDK({
13
- * token: 'your-api-token',
14
- * baseUrl: 'https://prod1.datalayer.run'
15
- * });
16
- *
17
- * // Flat, intuitive API - all methods directly accessible
18
- * const user = await sdk.whoami();
19
- * const environments = await sdk.listEnvironments();
20
- * const runtime = await sdk.createRuntime(config);
21
- * const notebook = await sdk.createNotebook(data);
22
- * ```
23
- *
24
- * @module sdk
25
- */
26
- export { DatalayerClient, type DatalayerClientConfig } from '../client';
27
- export * from '../stateful';
package/lib/sdk/index.js DELETED
@@ -1,33 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- /**
6
- * Main SDK entry point for the Datalayer platform.
7
- *
8
- * This module provides the unified DatalayerSDK class with a flat, intuitive API
9
- * for all Datalayer platform services. The SDK uses TypeScript mixins to provide
10
- * excellent discoverability and ease of use.
11
- *
12
- * @example
13
- * ```typescript
14
- * import { DatalayerSDK } from '@datalayer/core/sdk';
15
- *
16
- * const sdk = new DatalayerSDK({
17
- * token: 'your-api-token',
18
- * baseUrl: 'https://prod1.datalayer.run'
19
- * });
20
- *
21
- * // Flat, intuitive API - all methods directly accessible
22
- * const user = await sdk.whoami();
23
- * const environments = await sdk.listEnvironments();
24
- * const runtime = await sdk.createRuntime(config);
25
- * const notebook = await sdk.createNotebook(data);
26
- * ```
27
- *
28
- * @module sdk
29
- */
30
- // Export the main Client class with flat API
31
- export { DatalayerClient } from '../client';
32
- // Export stateful modules for advanced use cases
33
- export * from '../stateful';