@datalayer/core 0.0.16 → 0.0.18
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.d.ts +4 -0
- package/lib/components/chat/ChatComponent.js +143 -0
- package/lib/components/chat/MessagePart.d.ts +11 -0
- package/lib/components/chat/MessagePart.js +23 -0
- package/lib/components/chat/display/DynamicToolPart.d.ts +6 -0
- package/lib/components/chat/display/DynamicToolPart.js +5 -0
- package/lib/components/chat/display/ReasoningPart.d.ts +6 -0
- package/lib/components/chat/display/ReasoningPart.js +58 -0
- package/lib/components/chat/display/TextPart.d.ts +9 -0
- package/lib/components/chat/display/TextPart.js +93 -0
- package/lib/components/chat/display/ToolPart.d.ts +6 -0
- package/lib/components/chat/display/ToolPart.js +148 -0
- package/lib/components/chat/display/index.d.ts +4 -0
- package/lib/components/chat/display/index.js +13 -0
- package/lib/components/chat/handler.d.ts +8 -0
- package/lib/components/chat/handler.js +43 -0
- package/lib/components/chat/index.d.ts +4 -0
- package/lib/components/chat/index.js +13 -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 +2 -1
- package/lib/components/index.js +2 -1
- package/lib/components/notebooks/JupyterNotebook.d.ts +1 -6
- package/lib/components/notebooks/JupyterNotebook.js +1 -5
- package/lib/components/runtimes/RuntimeSimplePicker.d.ts +4 -0
- package/lib/components/runtimes/RuntimeSimplePicker.js +3 -3
- 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.d.ts +36 -0
- package/lib/hooks/useAIJupyterChat.js +53 -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 +126 -58
- package/lib/hooks/useMobile.d.ts +1 -0
- package/lib/hooks/useMobile.js +26 -0
- package/lib/hooks/useScreenshot.d.ts +3 -5
- package/lib/hooks/useScreenshot.js +1 -8
- package/lib/hooks/useUpload.js +29 -21
- package/lib/index.d.ts +1 -0
- package/lib/index.js +8 -4
- 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/stateful/index.d.ts +0 -1
- package/lib/stateful/index.js +0 -1
- package/lib/stateful/runtimes/actions.d.ts +1 -1
- package/lib/stateful/runtimes/actions.js +1 -1
- package/lib/theme/DatalayerTheme.d.ts +2 -2
- package/lib/theme/DatalayerTheme.js +4 -4
- package/lib/theme/DatalayerThemeProvider.js +2 -2
- 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.d.ts +5 -0
- package/lib/types.js +5 -0
- 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 +62 -5
- package/style/base.css +4 -0
- 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 -45
- 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,36 @@
|
|
|
1
|
+
export interface IUseAIJupyterChatOptions {
|
|
2
|
+
apiUrl?: string;
|
|
3
|
+
initialMessages?: unknown[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Hook to manage chat state with JupyterLab backend.
|
|
7
|
+
* Adapts Vercel AI SDK's useChat for Datalayer AI context.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useAIJupyterChat(_options?: IUseAIJupyterChatOptions): {
|
|
10
|
+
messages: import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[];
|
|
11
|
+
sendMessage: (message?: (Omit<import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>, "id" | "role"> & {
|
|
12
|
+
id?: string | undefined;
|
|
13
|
+
role?: "user" | "system" | "assistant" | undefined;
|
|
14
|
+
} & {
|
|
15
|
+
text?: never;
|
|
16
|
+
files?: never;
|
|
17
|
+
messageId?: string;
|
|
18
|
+
}) | {
|
|
19
|
+
text: string;
|
|
20
|
+
files?: FileList | import("ai").FileUIPart[];
|
|
21
|
+
metadata?: unknown;
|
|
22
|
+
parts?: never;
|
|
23
|
+
messageId?: string;
|
|
24
|
+
} | {
|
|
25
|
+
files: FileList | import("ai").FileUIPart[];
|
|
26
|
+
metadata?: unknown;
|
|
27
|
+
parts?: never;
|
|
28
|
+
messageId?: string;
|
|
29
|
+
} | undefined, options?: import("ai").ChatRequestOptions) => Promise<void>;
|
|
30
|
+
status: import("ai").ChatStatus;
|
|
31
|
+
setMessages: (messages: import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[] | ((messages: import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[]) => import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[])) => void;
|
|
32
|
+
regenerate: ({ messageId, ...options }?: {
|
|
33
|
+
messageId?: string;
|
|
34
|
+
} & import("ai").ChatRequestOptions) => Promise<void>;
|
|
35
|
+
clearChat: () => void;
|
|
36
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/*
|
|
6
|
+
* Copyright (c) 2024-2025 Datalayer, Inc.
|
|
7
|
+
*
|
|
8
|
+
* BSD 3-Clause License
|
|
9
|
+
*/
|
|
10
|
+
import { useCallback, useMemo } from 'react';
|
|
11
|
+
import { useChat } from '@ai-sdk/react';
|
|
12
|
+
import { DefaultChatTransport } from 'ai';
|
|
13
|
+
import { ServerConnection } from '@jupyterlab/services';
|
|
14
|
+
import { URLExt } from '@jupyterlab/coreutils';
|
|
15
|
+
/**
|
|
16
|
+
* Hook to manage chat state with JupyterLab backend.
|
|
17
|
+
* Adapts Vercel AI SDK's useChat for Datalayer AI context.
|
|
18
|
+
*/
|
|
19
|
+
export function useAIJupyterChat(_options = {}) {
|
|
20
|
+
// Build the full API URL for the chat endpoint
|
|
21
|
+
const settings = ServerConnection.makeSettings();
|
|
22
|
+
const chatEndpoint = URLExt.join(settings.baseUrl, 'datalayer', 'chat');
|
|
23
|
+
const { messages, sendMessage, status, setMessages, regenerate } = useChat({
|
|
24
|
+
id: 'ai-jupyter-chat',
|
|
25
|
+
transport: new DefaultChatTransport({
|
|
26
|
+
api: chatEndpoint,
|
|
27
|
+
credentials: settings.token ? 'include' : 'omit',
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `token ${settings.token || ''}`,
|
|
30
|
+
'X-XSRFToken': settings.token || '',
|
|
31
|
+
},
|
|
32
|
+
fetch: async (input, init) => {
|
|
33
|
+
return fetch(input, {
|
|
34
|
+
...init,
|
|
35
|
+
mode: 'cors',
|
|
36
|
+
credentials: settings.token ? 'include' : 'omit',
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
// Clear chat history
|
|
42
|
+
const clearChat = useCallback(() => {
|
|
43
|
+
setMessages([]);
|
|
44
|
+
}, [setMessages]);
|
|
45
|
+
return useMemo(() => ({
|
|
46
|
+
messages,
|
|
47
|
+
sendMessage,
|
|
48
|
+
status,
|
|
49
|
+
setMessages,
|
|
50
|
+
regenerate,
|
|
51
|
+
clearChat,
|
|
52
|
+
}), [messages, sendMessage, status, setMessages, regenerate, clearChat]);
|
|
53
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import PropTypes from 'prop-types';
|
|
2
3
|
type BackdropContextType = {
|
|
3
4
|
closeBackdrop: () => void;
|
|
@@ -10,19 +11,18 @@ export declare function useBackdrop(): BackdropContextType;
|
|
|
10
11
|
*/
|
|
11
12
|
export declare const BackdropContextProvider: import("react").Provider<BackdropContextType>;
|
|
12
13
|
type IBackdropProviderProps = {
|
|
13
|
-
children?:
|
|
14
|
+
children?: ReactNode;
|
|
14
15
|
zIndex?: number;
|
|
15
16
|
disableDarken?: boolean;
|
|
16
17
|
backdropSurface?: any;
|
|
17
18
|
};
|
|
18
|
-
export declare function BackdropProvider(
|
|
19
|
+
export declare function BackdropProvider({ children, zIndex, disableDarken, backdropSurface, }: IBackdropProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
19
20
|
export declare namespace BackdropProvider {
|
|
20
21
|
var propTypes: {
|
|
21
|
-
children: PropTypes.Requireable<PropTypes.
|
|
22
|
+
children: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
22
23
|
zIndex: PropTypes.Requireable<number>;
|
|
23
24
|
disableDarken: PropTypes.Requireable<boolean>;
|
|
24
25
|
backdropSurface: PropTypes.Requireable<(...args: any[]) => any>;
|
|
25
26
|
};
|
|
26
|
-
var defaultProps: IBackdropProviderProps;
|
|
27
27
|
}
|
|
28
28
|
export {};
|
package/lib/hooks/useBackdrop.js
CHANGED
|
@@ -48,8 +48,7 @@ const App = () => (
|
|
|
48
48
|
)
|
|
49
49
|
export default App
|
|
50
50
|
*/
|
|
51
|
-
export function BackdropProvider(
|
|
52
|
-
const { children, zIndex, disableDarken, backdropSurface } = props;
|
|
51
|
+
export function BackdropProvider({ children = null, zIndex = 9999, disableDarken = false, backdropSurface = null, }) {
|
|
53
52
|
const defaultBackdropSurface = {
|
|
54
53
|
position: 'fixed',
|
|
55
54
|
top: 0,
|
|
@@ -82,7 +81,10 @@ export function BackdropProvider(props) {
|
|
|
82
81
|
(backdropSurface ? (backdropSurface(backdrop.render(closeBackdrop))) : (_jsx("div", { style: defaultBackdropSurface, children: backdrop.render(closeBackdrop) })))] }));
|
|
83
82
|
}
|
|
84
83
|
BackdropProvider.propTypes = {
|
|
85
|
-
children: PropTypes.
|
|
84
|
+
children: PropTypes.oneOfType([
|
|
85
|
+
PropTypes.node,
|
|
86
|
+
PropTypes.arrayOf(PropTypes.node),
|
|
87
|
+
]),
|
|
86
88
|
// zIndex of the backdrop surface. Unused if backdropSurface is overridden.
|
|
87
89
|
zIndex: PropTypes.number,
|
|
88
90
|
// If true, backdrop background is transparent.
|
|
@@ -92,9 +94,3 @@ BackdropProvider.propTypes = {
|
|
|
92
94
|
// See /example/src/ExampleApp.jsx for proper use.
|
|
93
95
|
backdropSurface: PropTypes.func,
|
|
94
96
|
};
|
|
95
|
-
BackdropProvider.defaultProps = {
|
|
96
|
-
children: undefined,
|
|
97
|
-
disableBackdrop: false,
|
|
98
|
-
zIndex: 9999,
|
|
99
|
-
backdropSurface: null,
|
|
100
|
-
};
|
package/lib/hooks/useCache.d.ts
CHANGED
|
@@ -173,6 +173,7 @@ export declare const queryKeys: {
|
|
|
173
173
|
};
|
|
174
174
|
readonly contacts: {
|
|
175
175
|
readonly all: () => readonly ["contacts"];
|
|
176
|
+
readonly lists: () => readonly ["contacts", "list"];
|
|
176
177
|
readonly details: () => readonly ["contacts", "detail"];
|
|
177
178
|
readonly detail: (id: string) => readonly ["contacts", "detail", string];
|
|
178
179
|
readonly byHandle: (handle: string) => readonly ["contacts", "handle", string];
|
|
@@ -683,7 +684,9 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
683
684
|
useRefreshInvite: (options?: UseMutationOptions<unknown, Error, string>) => import("@tanstack/react-query").UseMutationResult<unknown, Error, string, unknown>;
|
|
684
685
|
useRefreshInvites: (options?: UseMutationOptions<unknown, Error, string>) => import("@tanstack/react-query").UseMutationResult<unknown, Error, string, unknown>;
|
|
685
686
|
useClearCachedInvites: (options?: UseMutationOptions<void, Error, void>) => import("@tanstack/react-query").UseMutationResult<void, Error, void, unknown>;
|
|
686
|
-
useContact: (contactId: string
|
|
687
|
+
useContact: (contactId: string, options?: {
|
|
688
|
+
enabled?: boolean;
|
|
689
|
+
}) => import("@tanstack/react-query").UseQueryResult<IContact | undefined, Error>;
|
|
687
690
|
useContactByHandle: (handle: string) => import("@tanstack/react-query").UseQueryResult<IContact | null | undefined, Error>;
|
|
688
691
|
useSearchContacts: (query: string) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
689
692
|
useCreateContact: () => import("@tanstack/react-query").UseMutationResult<any, Error, IContact, unknown>;
|
|
@@ -893,6 +896,7 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
893
896
|
};
|
|
894
897
|
readonly contacts: {
|
|
895
898
|
readonly all: () => readonly ["contacts"];
|
|
899
|
+
readonly lists: () => readonly ["contacts", "list"];
|
|
896
900
|
readonly details: () => readonly ["contacts", "detail"];
|
|
897
901
|
readonly detail: (id: string) => readonly ["contacts", "detail", string];
|
|
898
902
|
readonly byHandle: (handle: string) => readonly ["contacts", "handle", string];
|