@datalayer/core 0.0.17 → 0.0.19
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/README.md +9 -13
- package/lib/client/auth/AuthenticationManager.d.ts +95 -0
- package/lib/client/auth/AuthenticationManager.js +214 -0
- package/lib/client/auth/index.d.ts +8 -0
- package/lib/client/auth/index.js +17 -0
- package/lib/client/auth/storage.d.ts +154 -0
- package/lib/client/auth/storage.js +447 -0
- package/lib/client/auth/strategies.d.ts +54 -0
- package/lib/client/auth/strategies.js +238 -0
- package/lib/client/auth/types.d.ts +151 -0
- package/lib/{examples/index.js → client/auth/types.js} +4 -2
- package/lib/client/base.d.ts +3 -0
- package/lib/client/base.js +9 -0
- package/lib/client/index.d.ts +1 -0
- package/lib/client/index.js +2 -0
- package/lib/components/auth/Login.d.ts +40 -0
- package/lib/components/auth/Login.js +173 -0
- package/lib/components/auth/Login.stories.d.ts +54 -0
- package/lib/components/auth/Login.stories.js +104 -0
- package/lib/components/auth/LoginToken.d.ts +16 -0
- package/lib/components/auth/LoginToken.js +63 -0
- package/lib/components/auth/index.d.ts +5 -0
- package/lib/components/auth/index.js +16 -0
- package/lib/components/avatars/BoringAvatar.d.ts +6 -15
- package/lib/components/avatars/BoringAvatar.js +30 -34
- package/lib/components/avatars/BoringAvatar.stories.d.ts +7 -16
- package/lib/components/avatars/UserProfileAvatar.d.ts +1 -6
- package/lib/components/avatars/UserProfileAvatar.js +3 -8
- package/lib/components/buttons/DownloadCSVButton.d.ts +2 -7
- package/lib/components/buttons/DownloadCSVButton.js +1 -5
- package/lib/components/buttons/DownloadJsonButton.d.ts +3 -10
- package/lib/components/buttons/DownloadJsonButton.js +1 -7
- package/lib/components/buttons/UploadButton.d.ts +1 -4
- package/lib/components/buttons/UploadButton.js +3 -7
- package/lib/components/chat/ChatComponent.js +4 -0
- package/lib/components/chat/display/ReasoningPart.js +4 -0
- package/lib/components/chat/display/ToolPart.js +4 -0
- package/lib/components/chat/display/index.js +4 -0
- package/lib/components/chat/handler.js +4 -0
- package/lib/components/chat/index.js +4 -0
- package/lib/components/display/CenteredSpinner.d.ts +1 -4
- package/lib/components/display/CenteredSpinner.js +1 -5
- package/lib/components/display/HorizontalCenter.d.ts +1 -4
- package/lib/components/display/HorizontalCenter.js +1 -5
- package/lib/components/flashes/FlashClosable.d.ts +1 -4
- package/lib/components/flashes/FlashClosable.js +1 -5
- package/lib/components/flashes/FlashDisclaimer.js +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -0
- package/lib/components/notebooks/JupyterNotebook.d.ts +1 -6
- package/lib/components/notebooks/JupyterNotebook.js +1 -5
- package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -4
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +1 -5
- package/lib/config/Configuration.js +1 -1
- package/lib/examples/CellExample.js +11 -47
- package/lib/examples/lexical-theme.css +436 -0
- package/lib/examples/notebooks/Matplotlib.ipynb.json +1 -1
- package/lib/examples/notebooks/NotebookExample1.ipynb.json +1 -1
- package/lib/hooks/useAIJupyterChat.js +4 -0
- package/lib/hooks/useBackdrop.d.ts +4 -4
- package/lib/hooks/useBackdrop.js +5 -9
- package/lib/hooks/useCache.d.ts +5 -1
- package/lib/hooks/useCache.js +27 -14
- package/lib/hooks/useMobile.js +4 -0
- package/lib/hooks/useScreenshot.d.ts +3 -5
- package/lib/hooks/useScreenshot.js +1 -8
- package/lib/models/Outbound.d.ts +2 -0
- package/lib/models/Outbound.js +3 -1
- package/lib/state/substates/CoreState.js +1 -1
- package/lib/state/substates/IAMState.js +15 -6
- package/lib/tools/adapters/agui/AgUIToolAdapter.d.ts +75 -0
- package/lib/tools/adapters/agui/AgUIToolAdapter.js +244 -0
- package/lib/tools/adapters/agui/index.d.ts +10 -0
- package/lib/tools/adapters/agui/index.js +19 -0
- package/lib/tools/adapters/agui/lexicalHooks.d.ts +27 -0
- package/lib/tools/adapters/agui/lexicalHooks.js +64 -0
- package/lib/tools/adapters/agui/notebookHooks.d.ts +27 -0
- package/lib/tools/adapters/agui/notebookHooks.js +61 -0
- package/lib/tools/index.d.ts +6 -0
- package/lib/tools/index.js +18 -0
- package/lib/types.js +2 -3
- package/lib/utils/cli/index.d.ts +4 -0
- package/lib/utils/cli/index.js +13 -0
- package/lib/utils/cli/query.d.ts +6 -0
- package/lib/utils/cli/query.js +26 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/package.json +49 -7
- package/lib/examples/ChatExample.d.ts +0 -8
- package/lib/examples/ChatExample.js +0 -51
- package/lib/examples/DatalayerNotebookExample.d.ts +0 -16
- package/lib/examples/DatalayerNotebookExample.js +0 -75
- package/lib/examples/NativeNavigationExample.d.ts +0 -8
- package/lib/examples/NativeNavigationExample.js +0 -97
- package/lib/examples/NotebookMutationsKernel.d.ts +0 -2
- package/lib/examples/NotebookMutationsKernel.js +0 -115
- package/lib/examples/NotebookMutationsServiceManager.d.ts +0 -2
- package/lib/examples/NotebookMutationsServiceManager.js +0 -107
- package/lib/examples/ReactRouterExample.d.ts +0 -6
- package/lib/examples/ReactRouterExample.js +0 -175
- package/lib/examples/example-selector.d.ts +0 -22
- package/lib/examples/example-selector.js +0 -46
- package/lib/examples/index.d.ts +0 -2
- package/lib/examples/main.d.ts +0 -1
- package/lib/examples/main.js +0 -153
- package/lib/examples/notebooks/OutputIPyWidgetsExample.d.ts +0 -145
- package/lib/examples/notebooks/OutputIPyWidgetsExample.js +0 -153
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ag-ui/CopilotKit adapter module.
|
|
3
|
+
* Exports: CopilotKit adapters, hooks (useNotebookToolActions, useLexicalToolActions).
|
|
4
|
+
* Note: DefaultExecutor is imported from datalayer-react/tools/core/executor
|
|
5
|
+
*
|
|
6
|
+
* @module tools/adapters/agui
|
|
7
|
+
*/
|
|
8
|
+
export * from './AgUIToolAdapter';
|
|
9
|
+
export * from './notebookHooks';
|
|
10
|
+
export * from './lexicalHooks';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/*
|
|
6
|
+
* Copyright (c) 2021-2025 Datalayer, Inc.
|
|
7
|
+
*
|
|
8
|
+
* MIT License
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* ag-ui/CopilotKit adapter module.
|
|
12
|
+
* Exports: CopilotKit adapters, hooks (useNotebookToolActions, useLexicalToolActions).
|
|
13
|
+
* Note: DefaultExecutor is imported from datalayer-react/tools/core/executor
|
|
14
|
+
*
|
|
15
|
+
* @module tools/adapters/agui
|
|
16
|
+
*/
|
|
17
|
+
export * from './AgUIToolAdapter';
|
|
18
|
+
export * from './notebookHooks';
|
|
19
|
+
export * from './lexicalHooks';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createAllCopilotKitActions, ActionRegistrar, type UseFrontendToolFn } from './AgUIToolAdapter';
|
|
2
|
+
type ToolExecutionContext = any;
|
|
3
|
+
export { ActionRegistrar, type UseFrontendToolFn };
|
|
4
|
+
/**
|
|
5
|
+
* Hook that creates CopilotKit actions for lexical tools.
|
|
6
|
+
* Returns stable actions array that won't cause re-renders.
|
|
7
|
+
*
|
|
8
|
+
* @param documentId - Document ID (lexical document identifier)
|
|
9
|
+
* @param contextOverrides - Optional context overrides (format, extras, etc.)
|
|
10
|
+
* @returns CopilotKit actions
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Default context (toon format for AI)
|
|
15
|
+
* const actions = useLexicalToolActions("doc-123");
|
|
16
|
+
*
|
|
17
|
+
* // Custom format
|
|
18
|
+
* const actions = useLexicalToolActions("doc-123", { format: 'json' });
|
|
19
|
+
*
|
|
20
|
+
* // With extras
|
|
21
|
+
* const actions = useLexicalToolActions("doc-123", {
|
|
22
|
+
* format: 'toon',
|
|
23
|
+
* extras: { userId: '123', theme: 'dark' }
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function useLexicalToolActions(documentId: string, contextOverrides?: Partial<Omit<ToolExecutionContext, 'executor' | 'documentId'>>): ReturnType<typeof createAllCopilotKitActions>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* React hooks and components for ag-ui (CopilotKit) lexical tool registration.
|
|
7
|
+
* Provides: useLexicalToolActions, ActionRegistrar, UseFrontendToolFn.
|
|
8
|
+
*
|
|
9
|
+
* @module tools/adapters/agui/lexicalHooks
|
|
10
|
+
*/
|
|
11
|
+
import { useMemo } from 'react';
|
|
12
|
+
// TODO: Re-enable when @datalayer/jupyter-react exports these
|
|
13
|
+
// import type { ToolExecutionContext } from '@datalayer/jupyter-react';
|
|
14
|
+
import { createAllCopilotKitActions, ActionRegistrar, } from './AgUIToolAdapter';
|
|
15
|
+
// TODO: Re-enable when @datalayer/jupyter-react exports these
|
|
16
|
+
// import type { ToolExecutionContext } from '@datalayer/jupyter-react';
|
|
17
|
+
// Import from patched @datalayer/jupyter-lexical package
|
|
18
|
+
import { useLexicalStore, DefaultExecutor as LexicalDefaultExecutor, lexicalToolDefinitions, lexicalToolOperations, } from '@datalayer/jupyter-lexical';
|
|
19
|
+
// Re-export shared types and components for convenience
|
|
20
|
+
export { ActionRegistrar };
|
|
21
|
+
/**
|
|
22
|
+
* Hook that creates CopilotKit actions for lexical tools.
|
|
23
|
+
* Returns stable actions array that won't cause re-renders.
|
|
24
|
+
*
|
|
25
|
+
* @param documentId - Document ID (lexical document identifier)
|
|
26
|
+
* @param contextOverrides - Optional context overrides (format, extras, etc.)
|
|
27
|
+
* @returns CopilotKit actions
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // Default context (toon format for AI)
|
|
32
|
+
* const actions = useLexicalToolActions("doc-123");
|
|
33
|
+
*
|
|
34
|
+
* // Custom format
|
|
35
|
+
* const actions = useLexicalToolActions("doc-123", { format: 'json' });
|
|
36
|
+
*
|
|
37
|
+
* // With extras
|
|
38
|
+
* const actions = useLexicalToolActions("doc-123", {
|
|
39
|
+
* format: 'toon',
|
|
40
|
+
* extras: { userId: '123', theme: 'dark' }
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function useLexicalToolActions(documentId, contextOverrides) {
|
|
45
|
+
// Call useLexicalStore() with no selector to get state object (matches notebook pattern)
|
|
46
|
+
const lexicalStoreState = useLexicalStore();
|
|
47
|
+
// Create LexicalDefaultExecutor (stable reference)
|
|
48
|
+
// Only recreate when documentId changes, not on every state update
|
|
49
|
+
// The executor holds a reference to the store which is always current
|
|
50
|
+
const executor = useMemo(() => new LexicalDefaultExecutor(documentId, lexicalStoreState), [documentId]);
|
|
51
|
+
// Create stable context object with useMemo
|
|
52
|
+
// Defaults: format='toon' for conversational AI responses
|
|
53
|
+
// Can be overridden with contextOverrides parameter
|
|
54
|
+
const context = useMemo(() => ({
|
|
55
|
+
documentId,
|
|
56
|
+
executor,
|
|
57
|
+
format: 'toon', // Default format
|
|
58
|
+
...contextOverrides, // Override with user-provided values
|
|
59
|
+
}), [documentId, executor, contextOverrides]);
|
|
60
|
+
// Create and return CopilotKit actions (stable reference)
|
|
61
|
+
// Only re-create when context changes (i.e., when documentId or contextOverrides change)
|
|
62
|
+
const actions = useMemo(() => createAllCopilotKitActions(lexicalToolDefinitions, lexicalToolOperations, context), [context]);
|
|
63
|
+
return actions;
|
|
64
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createAllCopilotKitActions, ActionRegistrar, type UseFrontendToolFn } from './AgUIToolAdapter';
|
|
2
|
+
type ToolExecutionContext = any;
|
|
3
|
+
export { ActionRegistrar, type UseFrontendToolFn };
|
|
4
|
+
/**
|
|
5
|
+
* Hook that creates CopilotKit actions for notebook tools.
|
|
6
|
+
* Returns stable actions array that won't cause re-renders.
|
|
7
|
+
*
|
|
8
|
+
* @param documentId - Document ID (notebook identifier)
|
|
9
|
+
* @param contextOverrides - Optional context overrides (format, extras, etc.)
|
|
10
|
+
* @returns CopilotKit actions
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Default context (toon format for AI)
|
|
15
|
+
* const actions = useNotebookToolActions("my-notebook-id");
|
|
16
|
+
*
|
|
17
|
+
* // Custom format
|
|
18
|
+
* const actions = useNotebookToolActions("my-notebook-id", { format: 'json' });
|
|
19
|
+
*
|
|
20
|
+
* // With extras
|
|
21
|
+
* const actions = useNotebookToolActions("my-notebook-id", {
|
|
22
|
+
* format: 'toon',
|
|
23
|
+
* extras: { userId: '123', theme: 'dark' }
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function useNotebookToolActions(documentId: string, contextOverrides?: Partial<Omit<ToolExecutionContext, 'executor' | 'documentId'>>): ReturnType<typeof createAllCopilotKitActions>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* React hooks and components for ag-ui (CopilotKit) notebook tool registration.
|
|
7
|
+
* Provides: useNotebookToolActions, ActionRegistrar, UseFrontendToolFn.
|
|
8
|
+
*
|
|
9
|
+
* @module tools/adapters/agui/notebookHooks
|
|
10
|
+
*/
|
|
11
|
+
import { useMemo } from 'react';
|
|
12
|
+
// TODO: Re-enable when @datalayer/jupyter-react exports these
|
|
13
|
+
// import type { ToolExecutionContext } from '@datalayer/jupyter-react';
|
|
14
|
+
import { createAllCopilotKitActions, ActionRegistrar, } from './AgUIToolAdapter';
|
|
15
|
+
// Import from patched @datalayer/jupyter-react package
|
|
16
|
+
import { notebookStore2, DefaultExecutor, notebookToolDefinitions, notebookToolOperations, } from '@datalayer/jupyter-react';
|
|
17
|
+
// Hook wrapper to get notebook store state
|
|
18
|
+
const useNotebookStore2 = () => notebookStore2.getState();
|
|
19
|
+
// Re-export shared types and components for convenience
|
|
20
|
+
export { ActionRegistrar };
|
|
21
|
+
/**
|
|
22
|
+
* Hook that creates CopilotKit actions for notebook tools.
|
|
23
|
+
* Returns stable actions array that won't cause re-renders.
|
|
24
|
+
*
|
|
25
|
+
* @param documentId - Document ID (notebook identifier)
|
|
26
|
+
* @param contextOverrides - Optional context overrides (format, extras, etc.)
|
|
27
|
+
* @returns CopilotKit actions
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // Default context (toon format for AI)
|
|
32
|
+
* const actions = useNotebookToolActions("my-notebook-id");
|
|
33
|
+
*
|
|
34
|
+
* // Custom format
|
|
35
|
+
* const actions = useNotebookToolActions("my-notebook-id", { format: 'json' });
|
|
36
|
+
*
|
|
37
|
+
* // With extras
|
|
38
|
+
* const actions = useNotebookToolActions("my-notebook-id", {
|
|
39
|
+
* format: 'toon',
|
|
40
|
+
* extras: { userId: '123', theme: 'dark' }
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function useNotebookToolActions(documentId, contextOverrides) {
|
|
45
|
+
const notebookStore = useNotebookStore2();
|
|
46
|
+
// Create DefaultExecutor (stable reference)
|
|
47
|
+
// Only recreate when documentId changes, not on every state update
|
|
48
|
+
// The executor holds a reference to the store which is always current
|
|
49
|
+
const executor = useMemo(() => new DefaultExecutor(documentId, notebookStore), [documentId]);
|
|
50
|
+
// Create stable context object with useMemo
|
|
51
|
+
// Defaults: format='toon' for conversational AI responses
|
|
52
|
+
// Can be overridden with contextOverrides parameter
|
|
53
|
+
const context = useMemo(() => ({
|
|
54
|
+
documentId,
|
|
55
|
+
executor,
|
|
56
|
+
format: 'toon', // Default format
|
|
57
|
+
...contextOverrides, // Override with user-provided values
|
|
58
|
+
}), [documentId, executor, contextOverrides]);
|
|
59
|
+
// Create and return CopilotKit actions (stable reference)
|
|
60
|
+
return useMemo(() => createAllCopilotKitActions(notebookToolDefinitions, notebookToolOperations, context), [context]);
|
|
61
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Platform-agnostic tools for notebook and lexical integration with AI frameworks
|
|
7
|
+
*
|
|
8
|
+
* @module tools
|
|
9
|
+
*/
|
|
10
|
+
// Export adapters
|
|
11
|
+
export * from './adapters/agui';
|
|
12
|
+
// TODO: Re-export tool types from jupyter-react when available
|
|
13
|
+
// export type {
|
|
14
|
+
// ToolDefinition,
|
|
15
|
+
// ToolConfig,
|
|
16
|
+
// ToolOperation,
|
|
17
|
+
// ToolExecutionContext,
|
|
18
|
+
// } from '@datalayer/jupyter-react';
|
package/lib/types.js
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/*
|
|
6
|
+
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
7
|
+
*
|
|
8
|
+
* Datalayer License
|
|
9
|
+
*/
|
|
10
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
11
|
+
/**
|
|
12
|
+
* Shared QueryClient instance for TanStack Query
|
|
13
|
+
* Used across the application for consistent cache management
|
|
14
|
+
*/
|
|
15
|
+
export const queryClient = new QueryClient({
|
|
16
|
+
defaultOptions: {
|
|
17
|
+
queries: {
|
|
18
|
+
staleTime: 1000 * 60 * 5, // 5 minutes
|
|
19
|
+
refetchOnMount: false, // Don't refetch on mount if data is still fresh
|
|
20
|
+
refetchOnWindowFocus: false,
|
|
21
|
+
retry: 1,
|
|
22
|
+
// Ensure queries prioritize cache over network when data is fresh
|
|
23
|
+
networkMode: 'online',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datalayer/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"workspaces": [
|
|
6
6
|
".",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"clean": "rimraf lib dist build tsconfig.tsbuildinfo",
|
|
49
49
|
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
|
|
50
50
|
"clean:dist": "rimraf dist",
|
|
51
|
+
"clean:cache": "rimraf node_modules/.vite",
|
|
51
52
|
"build": "npm run clean && gulp resources-to-lib && tsc -b && vite build",
|
|
52
53
|
"build:lib": "npm run clean:lib && gulp resources-to-lib && tsc -b",
|
|
53
54
|
"build:types": "npm run clean:lib && tsc -b",
|
|
@@ -84,23 +85,49 @@
|
|
|
84
85
|
"watch:lib:res": "gulp resources-to-lib-watch",
|
|
85
86
|
"watch:lib:src": "tsc -b -w",
|
|
86
87
|
"type-check:watch": "tsc -b -w --noEmit",
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
88
|
+
"examples": "vite --config vite.examples.config.ts",
|
|
89
|
+
"examples:chat": "run-p jupyter:start example:chat:vite",
|
|
90
|
+
"examples:chat:vite": "EXAMPLE=ChatExample vite --config vite.examples.config.ts",
|
|
91
|
+
"examples:nextjs": "npm run dev --workspace=nextjs-notebook-example",
|
|
91
92
|
"jupyter:start": "./dev/sh/start-jupyter-server.sh",
|
|
92
93
|
"prepare": "husky",
|
|
93
|
-
"kill": "./dev/sh/kill.sh || true"
|
|
94
|
+
"kill": "./dev/sh/kill.sh || true",
|
|
95
|
+
"sync:jupyter": "bash scripts/sync-jupyter.sh",
|
|
96
|
+
"sync:jupyter:watch": "bash scripts/sync-jupyter.sh --watch",
|
|
97
|
+
"create:patches": "bash scripts/create-patches.sh",
|
|
98
|
+
"apply:patches": "bash scripts/apply-patches.sh",
|
|
99
|
+
"examples:fresh": "npm run clean:cache && npm run examples",
|
|
100
|
+
"rebuild:fresh": "npm run create:patches && npm install && npm run build && npm run clean:cache"
|
|
94
101
|
},
|
|
95
102
|
"dependencies": {
|
|
96
103
|
"@ai-sdk/react": "^2.0.34",
|
|
104
|
+
"@copilotkit/react-core": "^1.10.6",
|
|
105
|
+
"@copilotkit/react-ui": "^1.10.6",
|
|
97
106
|
"@datalayer/icons-react": "^1.0.6",
|
|
98
|
-
"@datalayer/jupyter-
|
|
107
|
+
"@datalayer/jupyter-lexical": "^1.0.6",
|
|
108
|
+
"@datalayer/jupyter-react": "^1.1.8",
|
|
99
109
|
"@datalayer/primer-addons": "^1.0.4",
|
|
100
110
|
"@datalayer/primer-rjsf": "^1.0.1",
|
|
111
|
+
"@jupyter-widgets/base-manager": "^1.0.12",
|
|
112
|
+
"@jupyter-widgets/schema": "^0.5.6",
|
|
113
|
+
"@jupyterlab/apputils": "^4.6.0",
|
|
114
|
+
"@jupyterlab/cells": "^4.5.0",
|
|
115
|
+
"@jupyterlab/codeeditor": "^4.5.0",
|
|
101
116
|
"@jupyterlab/coreutils": "^6.0.0",
|
|
117
|
+
"@jupyterlab/documentsearch": "^4.5.0",
|
|
118
|
+
"@jupyterlab/rendermime": "^4.5.0",
|
|
102
119
|
"@jupyterlab/services": "^7.0.0",
|
|
120
|
+
"@jupyterlab/translation": "^4.5.0",
|
|
121
|
+
"@jupyterlab/ui-components": "^4.5.0",
|
|
103
122
|
"@jupyterlite/javascript-kernel-extension": "^0.3.0",
|
|
123
|
+
"@lumino/commands": "^2.3.3",
|
|
124
|
+
"@lumino/coreutils": "^2.2.2",
|
|
125
|
+
"@lumino/datagrid": "^2.5.3",
|
|
126
|
+
"@lumino/disposable": "^2.1.5",
|
|
127
|
+
"@lumino/polling": "^2.1.5",
|
|
128
|
+
"@lumino/signaling": "^2.1.5",
|
|
129
|
+
"@lumino/widgets": "^2.7.2",
|
|
130
|
+
"@primer/behaviors": "^1.8.4",
|
|
104
131
|
"@primer/brand-primitives": "^0.51.0",
|
|
105
132
|
"@primer/css": "^21.5.1",
|
|
106
133
|
"@primer/octicons-react": "^19.15.1",
|
|
@@ -108,13 +135,18 @@
|
|
|
108
135
|
"@primer/react": "^37.19.0",
|
|
109
136
|
"@primer/react-brand": "^0.58.0",
|
|
110
137
|
"@stripe/react-stripe-js": "^2.7.1",
|
|
138
|
+
"@stripe/stripe-js": "^4.0.0",
|
|
139
|
+
"@styled-system/css": "^5.1.5",
|
|
111
140
|
"@tailwindcss/vite": "^4.1.13",
|
|
112
141
|
"@tanstack/react-query": "^5.90.6",
|
|
142
|
+
"@toon-format/toon": "^1.3.0",
|
|
113
143
|
"ai": "^5.0.78",
|
|
144
|
+
"ansi-to-html": "^0.7.2",
|
|
114
145
|
"axios": "^1.7.7",
|
|
115
146
|
"boring-avatars": "^2.0.1",
|
|
116
147
|
"buffer": "^6.0.3",
|
|
117
148
|
"date-fns": "^2.29.3",
|
|
149
|
+
"deepmerge": "^4.3.1",
|
|
118
150
|
"echarts": "^5.5.0",
|
|
119
151
|
"echarts-for-react": "^3.0.2",
|
|
120
152
|
"fuse.js": "^7.0.0",
|
|
@@ -127,10 +159,13 @@
|
|
|
127
159
|
"react": "18.3.1",
|
|
128
160
|
"react-confetti": "^6.4.0",
|
|
129
161
|
"react-dom": "18.3.1",
|
|
162
|
+
"react-is": "^19.2.0",
|
|
130
163
|
"react-toastify": "^11.0.5",
|
|
131
164
|
"streamdown": "^1.6.6",
|
|
165
|
+
"styled-system": "^5.1.5",
|
|
132
166
|
"tailwind-merge": "^3.3.1",
|
|
133
167
|
"tailwindcss": "^4.1.13",
|
|
168
|
+
"tslib": "^2.8.1",
|
|
134
169
|
"tus-js-client": "^4.2.3",
|
|
135
170
|
"tw-animate-css": "^1.4.0",
|
|
136
171
|
"ulid": "^2.3.0",
|
|
@@ -138,6 +173,7 @@
|
|
|
138
173
|
"usehooks-ts": "^2.9.1",
|
|
139
174
|
"uuid": "^13.0.0",
|
|
140
175
|
"validator": "^13.7.0",
|
|
176
|
+
"zod": "^4.1.13",
|
|
141
177
|
"zustand": "^4.4.1"
|
|
142
178
|
},
|
|
143
179
|
"peerDependencies": {
|
|
@@ -166,6 +202,8 @@
|
|
|
166
202
|
"@vitest/browser": "^3.2.4",
|
|
167
203
|
"@vitest/coverage-v8": "^3.2.4",
|
|
168
204
|
"abort-controller": "^3.0.0",
|
|
205
|
+
"autoprefixer": "^10.4.21",
|
|
206
|
+
"buffer": "^6.0.3",
|
|
169
207
|
"crypto-browserify": "^3.12.1",
|
|
170
208
|
"dotenv": "^17.2.2",
|
|
171
209
|
"eslint": "^9.29.0",
|
|
@@ -184,6 +222,7 @@
|
|
|
184
222
|
"jsdom": "^26.0.0",
|
|
185
223
|
"lint-staged": "^16.1.5",
|
|
186
224
|
"npm-run-all": "^4.1.5",
|
|
225
|
+
"patch-package": "^8.0.0",
|
|
187
226
|
"playwright": "^1.53.2",
|
|
188
227
|
"prettier": "^3.6.2",
|
|
189
228
|
"react-router-dom": "^6.22.3",
|
|
@@ -219,5 +258,8 @@
|
|
|
219
258
|
"src/**/*.{css,json,md}": [
|
|
220
259
|
"prettier --write"
|
|
221
260
|
]
|
|
261
|
+
},
|
|
262
|
+
"optionalDependencies": {
|
|
263
|
+
"keytar": "^7.9.0"
|
|
222
264
|
}
|
|
223
265
|
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2024-2025 Datalayer, Inc.
|
|
4
|
-
*
|
|
5
|
-
* BSD 3-Clause License
|
|
6
|
-
*/
|
|
7
|
-
import { Text } from '@primer/react';
|
|
8
|
-
import { Box } from '@datalayer/primer-addons';
|
|
9
|
-
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
10
|
-
import { ChatComponent } from '../components/chat/ChatComponent';
|
|
11
|
-
import { datalayerTheme, DatalayerThemeProvider } from '@/theme';
|
|
12
|
-
// Create a query client for React Query
|
|
13
|
-
const queryClient = new QueryClient({
|
|
14
|
-
defaultOptions: {
|
|
15
|
-
queries: {
|
|
16
|
-
staleTime: 1000 * 60 * 5, // 5 minutes
|
|
17
|
-
gcTime: 1000 * 60 * 10, // 10 minutes
|
|
18
|
-
retry: 1,
|
|
19
|
-
refetchOnWindowFocus: false,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* Chat Example Component
|
|
25
|
-
*
|
|
26
|
-
* Demonstrates the ChatComponent with all necessary providers:
|
|
27
|
-
* - QueryClientProvider for data fetching
|
|
28
|
-
*/
|
|
29
|
-
const ChatExample = () => {
|
|
30
|
-
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(DatalayerThemeProvider, { theme: datalayerTheme, children: _jsxs(Box, { sx: {
|
|
31
|
-
display: 'flex',
|
|
32
|
-
flexDirection: 'column',
|
|
33
|
-
height: '100vh',
|
|
34
|
-
backgroundColor: 'canvas.default',
|
|
35
|
-
}, children: [_jsxs(Box, { as: "header", sx: {
|
|
36
|
-
borderBottom: '1px solid',
|
|
37
|
-
borderColor: 'border.default',
|
|
38
|
-
padding: 3,
|
|
39
|
-
}, children: [_jsx(Text, { sx: {
|
|
40
|
-
fontSize: 3,
|
|
41
|
-
fontWeight: 'bold',
|
|
42
|
-
display: 'block',
|
|
43
|
-
marginBottom: 1,
|
|
44
|
-
}, children: "Chat Example" }), _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Interactive chat interface with AI assistance" })] }), _jsx(Box, { as: "main", sx: {
|
|
45
|
-
flex: 1,
|
|
46
|
-
overflow: 'hidden',
|
|
47
|
-
display: 'flex',
|
|
48
|
-
flexDirection: 'column',
|
|
49
|
-
}, children: _jsx(ChatComponent, {}) })] }) }) }));
|
|
50
|
-
};
|
|
51
|
-
export default ChatExample;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ServiceManager } from '@jupyterlab/services';
|
|
2
|
-
/**
|
|
3
|
-
* Example demonstrating how to use Datalayer services with Notebook
|
|
4
|
-
*
|
|
5
|
-
* This example shows:
|
|
6
|
-
* 1. How to create and use DatalayerServiceManager for kernel management
|
|
7
|
-
* 2. How to create and use DatalayerCollaborationProvider for real-time collaboration
|
|
8
|
-
* 3. How to enable/disable Datalayer collaboration
|
|
9
|
-
* 4. How to pass these to the base Notebook component
|
|
10
|
-
* 5. Graceful fallback when Datalayer credentials are not available
|
|
11
|
-
*/
|
|
12
|
-
type IDatalayerNotebookExampleProps = {
|
|
13
|
-
serviceManager?: ServiceManager.IManager;
|
|
14
|
-
};
|
|
15
|
-
declare const DatalayerNotebookExample: (props: IDatalayerNotebookExampleProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export default DatalayerNotebookExample;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
-
* Distributed under the terms of the Modified BSD License.
|
|
5
|
-
*/
|
|
6
|
-
import { useState, useEffect, useMemo } from 'react';
|
|
7
|
-
import { Box, Checkbox, FormControl, Heading } from '@primer/react';
|
|
8
|
-
import { loadJupyterConfig, JupyterReactTheme, Notebook2, } from '@datalayer/jupyter-react';
|
|
9
|
-
import { DatalayerCollaborationProvider } from '../collaboration/DatalayerCollaborationProvider';
|
|
10
|
-
import { createDatalayerServiceManager } from '../services/DatalayerServiceManager';
|
|
11
|
-
import { useCoreStore } from '../state/substates/CoreState';
|
|
12
|
-
import nbformatExample from './notebooks/NotebookExample1.ipynb.json';
|
|
13
|
-
// This corresponds to the notebook ID in the URL when you open an existing notbook in your library
|
|
14
|
-
const NOTEBOOK_ID = '01JZQRQ35GG871QQCZW9TB1A8J';
|
|
15
|
-
const DatalayerNotebookExample = (props) => {
|
|
16
|
-
// Load config on component mount
|
|
17
|
-
loadJupyterConfig();
|
|
18
|
-
const [nbformat] = useState(nbformatExample);
|
|
19
|
-
const [enableCollaboration, setEnableCollaboration] = useState(false);
|
|
20
|
-
const [readonly] = useState(false);
|
|
21
|
-
const [serviceManager, setServiceManager] = useState(props.serviceManager);
|
|
22
|
-
const { configuration } = useCoreStore();
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
// Create DatalayerServiceManager if not provided
|
|
25
|
-
const createManager = async () => {
|
|
26
|
-
if (props.serviceManager) {
|
|
27
|
-
// Use provided service manager (should be DatalayerServiceManager from main.tsx)
|
|
28
|
-
// Wait for it to be ready
|
|
29
|
-
await props.serviceManager.ready;
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
// Create DatalayerServiceManager if we have credentials
|
|
33
|
-
if (configuration?.token && configuration?.runUrl) {
|
|
34
|
-
try {
|
|
35
|
-
console.log('Creating DatalayerServiceManager for Datalayer infrastructure');
|
|
36
|
-
// Now we can pass undefined to use config/defaults
|
|
37
|
-
const manager = await createDatalayerServiceManager(configuration?.cpuEnvironment, configuration?.credits);
|
|
38
|
-
await manager.ready;
|
|
39
|
-
setServiceManager(manager);
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
console.error('Failed to create DatalayerServiceManager:', error);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
console.warn('Datalayer credentials not configured. Please set runUrl and token.');
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
createManager();
|
|
50
|
-
}, [props.serviceManager, configuration]);
|
|
51
|
-
// Create the collaboration provider when enabled
|
|
52
|
-
const collaborationProvider = useMemo(() => {
|
|
53
|
-
if (!enableCollaboration) {
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
const runUrl = configuration?.runUrl;
|
|
57
|
-
const token = configuration?.token;
|
|
58
|
-
if (!runUrl || !token) {
|
|
59
|
-
console.warn('Datalayer collaboration enabled but runUrl or token not configured. ' +
|
|
60
|
-
'Please configure them in the Datalayer store or environment.');
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
// Create and return the Datalayer collaboration provider
|
|
64
|
-
return new DatalayerCollaborationProvider({
|
|
65
|
-
runUrl,
|
|
66
|
-
token,
|
|
67
|
-
});
|
|
68
|
-
}, [enableCollaboration, configuration]);
|
|
69
|
-
return (_jsx(JupyterReactTheme, { children: _jsxs(Box, { p: 3, children: [_jsx(Heading, { as: "h2", sx: { mb: 3 }, children: "DatalayerNotebook Collaboration Example" }), _jsx(Box, { sx: { mb: 3 }, children: _jsxs(FormControl, { children: [_jsx(Checkbox, { checked: enableCollaboration, onChange: e => setEnableCollaboration(e.target.checked) }), _jsx(FormControl.Label, { children: "Enable Datalayer Collaboration" })] }) }), (!configuration?.runUrl || !configuration?.token) && (_jsx(Box, { sx: { mb: 2, p: 2, bg: 'danger.subtle' }, children: "Warning: Datalayer configuration is missing. Please configure runUrl and token to use DatalayerServiceManager and collaboration features." })), !serviceManager && (_jsx(Box, { sx: { mb: 2, p: 2, bg: 'attention.subtle' }, children: "Note: DatalayerServiceManager is not available. Notebook functionality will be limited." })), _jsx(Box, { sx: {
|
|
70
|
-
border: '1px solid',
|
|
71
|
-
borderColor: 'border.default',
|
|
72
|
-
borderRadius: 2,
|
|
73
|
-
}, children: serviceManager ? (_jsx(Notebook2, { id: NOTEBOOK_ID, height: "calc(100vh - 200px)", nbformat: nbformat, readonly: readonly, serviceManager: serviceManager, startDefaultKernel: true, collaborationProvider: collaborationProvider })) : (_jsx(Box, { sx: { p: 4, textAlign: 'center' }, children: "Loading ServiceManager..." })) }), _jsxs(Box, { sx: { mt: 2, fontSize: 1, color: 'fg.subtle' }, children: [_jsx("p", { children: "This example demonstrates how to use Datalayer services with Notebook:" }), _jsxs("ul", { children: [_jsxs("li", { children: [_jsx("strong", { children: "DatalayerServiceManager:" }), " Connects to Datalayer infrastructure for kernel management"] }), _jsxs("li", { children: [_jsx("strong", { children: "DatalayerCollaborationProvider:" }), " Enables real-time collaboration"] }), _jsx("li", { children: "Both require Datalayer credentials (runUrl and token)" }), _jsx("li", { children: "Pass them directly to the base Notebook component" }), _jsx("li", { children: "No wrapper components needed - just create the services and pass them as props" }), _jsx("li", { children: "This shows the explicit, composable pattern for Datalayer integration" })] })] })] }) }));
|
|
74
|
-
};
|
|
75
|
-
export default DatalayerNotebookExample;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Native Navigation Example
|
|
4
|
-
* This example demonstrates the navigation hooks WITHOUT React Router.
|
|
5
|
-
* The hooks should automatically detect the absence of React Router and fall back to native browser navigation.
|
|
6
|
-
*/
|
|
7
|
-
export declare const NativeNavigationExample: React.FC;
|
|
8
|
-
export default NativeNavigationExample;
|