@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.
Files changed (133) hide show
  1. package/README.md +9 -13
  2. package/lib/client/auth/AuthenticationManager.d.ts +95 -0
  3. package/lib/client/auth/AuthenticationManager.js +214 -0
  4. package/lib/client/auth/index.d.ts +8 -0
  5. package/lib/client/auth/index.js +17 -0
  6. package/lib/client/auth/storage.d.ts +154 -0
  7. package/lib/client/auth/storage.js +447 -0
  8. package/lib/client/auth/strategies.d.ts +54 -0
  9. package/lib/client/auth/strategies.js +238 -0
  10. package/lib/client/auth/types.d.ts +151 -0
  11. package/lib/{examples/index.js → client/auth/types.js} +4 -2
  12. package/lib/client/base.d.ts +3 -0
  13. package/lib/client/base.js +9 -0
  14. package/lib/client/index.d.ts +1 -0
  15. package/lib/client/index.js +2 -0
  16. package/lib/components/auth/Login.d.ts +40 -0
  17. package/lib/components/auth/Login.js +173 -0
  18. package/lib/components/auth/Login.stories.d.ts +54 -0
  19. package/lib/components/auth/Login.stories.js +104 -0
  20. package/lib/components/auth/LoginToken.d.ts +16 -0
  21. package/lib/components/auth/LoginToken.js +63 -0
  22. package/lib/components/auth/index.d.ts +5 -0
  23. package/lib/components/auth/index.js +16 -0
  24. package/lib/components/avatars/BoringAvatar.d.ts +6 -15
  25. package/lib/components/avatars/BoringAvatar.js +30 -34
  26. package/lib/components/avatars/BoringAvatar.stories.d.ts +7 -16
  27. package/lib/components/avatars/UserProfileAvatar.d.ts +1 -6
  28. package/lib/components/avatars/UserProfileAvatar.js +3 -8
  29. package/lib/components/buttons/DownloadCSVButton.d.ts +2 -7
  30. package/lib/components/buttons/DownloadCSVButton.js +1 -5
  31. package/lib/components/buttons/DownloadJsonButton.d.ts +3 -10
  32. package/lib/components/buttons/DownloadJsonButton.js +1 -7
  33. package/lib/components/buttons/UploadButton.d.ts +1 -4
  34. package/lib/components/buttons/UploadButton.js +3 -7
  35. package/lib/components/chat/ChatComponent.d.ts +4 -0
  36. package/lib/components/chat/ChatComponent.js +143 -0
  37. package/lib/components/chat/MessagePart.d.ts +11 -0
  38. package/lib/components/chat/MessagePart.js +23 -0
  39. package/lib/components/chat/display/DynamicToolPart.d.ts +6 -0
  40. package/lib/components/chat/display/DynamicToolPart.js +5 -0
  41. package/lib/components/chat/display/ReasoningPart.d.ts +6 -0
  42. package/lib/components/chat/display/ReasoningPart.js +58 -0
  43. package/lib/components/chat/display/TextPart.d.ts +9 -0
  44. package/lib/components/chat/display/TextPart.js +93 -0
  45. package/lib/components/chat/display/ToolPart.d.ts +6 -0
  46. package/lib/components/chat/display/ToolPart.js +148 -0
  47. package/lib/components/chat/display/index.d.ts +4 -0
  48. package/lib/components/chat/display/index.js +13 -0
  49. package/lib/components/chat/handler.d.ts +8 -0
  50. package/lib/components/chat/handler.js +43 -0
  51. package/lib/components/chat/index.d.ts +4 -0
  52. package/lib/components/chat/index.js +13 -0
  53. package/lib/components/display/CenteredSpinner.d.ts +1 -4
  54. package/lib/components/display/CenteredSpinner.js +1 -5
  55. package/lib/components/display/HorizontalCenter.d.ts +1 -4
  56. package/lib/components/display/HorizontalCenter.js +1 -5
  57. package/lib/components/flashes/FlashClosable.d.ts +1 -4
  58. package/lib/components/flashes/FlashClosable.js +1 -5
  59. package/lib/components/flashes/FlashDisclaimer.js +1 -1
  60. package/lib/components/index.d.ts +2 -1
  61. package/lib/components/index.js +2 -1
  62. package/lib/components/notebooks/JupyterNotebook.d.ts +1 -6
  63. package/lib/components/notebooks/JupyterNotebook.js +1 -5
  64. package/lib/components/runtimes/RuntimeSimplePicker.d.ts +4 -0
  65. package/lib/components/runtimes/RuntimeSimplePicker.js +3 -3
  66. package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -4
  67. package/lib/components/snapshots/RuntimeSnapshotMenu.js +1 -5
  68. package/lib/config/Configuration.js +1 -1
  69. package/lib/examples/CellExample.js +11 -47
  70. package/lib/examples/lexical-theme.css +436 -0
  71. package/lib/examples/notebooks/Matplotlib.ipynb.json +1 -1
  72. package/lib/examples/notebooks/NotebookExample1.ipynb.json +1 -1
  73. package/lib/hooks/useAIJupyterChat.d.ts +36 -0
  74. package/lib/hooks/useAIJupyterChat.js +53 -0
  75. package/lib/hooks/useBackdrop.d.ts +4 -4
  76. package/lib/hooks/useBackdrop.js +5 -9
  77. package/lib/hooks/useCache.d.ts +5 -1
  78. package/lib/hooks/useCache.js +126 -58
  79. package/lib/hooks/useMobile.d.ts +1 -0
  80. package/lib/hooks/useMobile.js +26 -0
  81. package/lib/hooks/useScreenshot.d.ts +3 -5
  82. package/lib/hooks/useScreenshot.js +1 -8
  83. package/lib/hooks/useUpload.js +29 -21
  84. package/lib/index.d.ts +1 -0
  85. package/lib/index.js +8 -4
  86. package/lib/models/Outbound.d.ts +2 -0
  87. package/lib/models/Outbound.js +3 -1
  88. package/lib/state/substates/CoreState.js +1 -1
  89. package/lib/state/substates/IAMState.js +15 -6
  90. package/lib/stateful/index.d.ts +0 -1
  91. package/lib/stateful/index.js +0 -1
  92. package/lib/stateful/runtimes/actions.d.ts +1 -1
  93. package/lib/stateful/runtimes/actions.js +1 -1
  94. package/lib/theme/DatalayerTheme.d.ts +2 -2
  95. package/lib/theme/DatalayerTheme.js +4 -4
  96. package/lib/theme/DatalayerThemeProvider.js +2 -2
  97. package/lib/tools/adapters/agui/AgUIToolAdapter.d.ts +75 -0
  98. package/lib/tools/adapters/agui/AgUIToolAdapter.js +244 -0
  99. package/lib/tools/adapters/agui/index.d.ts +10 -0
  100. package/lib/tools/adapters/agui/index.js +19 -0
  101. package/lib/tools/adapters/agui/lexicalHooks.d.ts +27 -0
  102. package/lib/tools/adapters/agui/lexicalHooks.js +64 -0
  103. package/lib/tools/adapters/agui/notebookHooks.d.ts +27 -0
  104. package/lib/tools/adapters/agui/notebookHooks.js +61 -0
  105. package/lib/tools/index.d.ts +6 -0
  106. package/lib/tools/index.js +18 -0
  107. package/lib/types.d.ts +5 -0
  108. package/lib/types.js +5 -0
  109. package/lib/utils/cli/index.d.ts +4 -0
  110. package/lib/utils/cli/index.js +13 -0
  111. package/lib/utils/cli/query.d.ts +6 -0
  112. package/lib/utils/cli/query.js +26 -0
  113. package/lib/utils/index.d.ts +1 -0
  114. package/lib/utils/index.js +1 -0
  115. package/package.json +62 -5
  116. package/style/base.css +4 -0
  117. package/lib/examples/DatalayerNotebookExample.d.ts +0 -16
  118. package/lib/examples/DatalayerNotebookExample.js +0 -75
  119. package/lib/examples/NativeNavigationExample.d.ts +0 -8
  120. package/lib/examples/NativeNavigationExample.js +0 -97
  121. package/lib/examples/NotebookMutationsKernel.d.ts +0 -2
  122. package/lib/examples/NotebookMutationsKernel.js +0 -115
  123. package/lib/examples/NotebookMutationsServiceManager.d.ts +0 -2
  124. package/lib/examples/NotebookMutationsServiceManager.js +0 -107
  125. package/lib/examples/ReactRouterExample.d.ts +0 -6
  126. package/lib/examples/ReactRouterExample.js +0 -175
  127. package/lib/examples/example-selector.d.ts +0 -22
  128. package/lib/examples/example-selector.js +0 -45
  129. package/lib/examples/index.d.ts +0 -2
  130. package/lib/examples/main.d.ts +0 -1
  131. package/lib/examples/main.js +0 -153
  132. package/lib/examples/notebooks/OutputIPyWidgetsExample.d.ts +0 -145
  133. package/lib/examples/notebooks/OutputIPyWidgetsExample.js +0 -153
@@ -21,7 +21,7 @@
21
21
  "execution_count": 1,
22
22
  "metadata": {
23
23
  "datalayer": {
24
- "_about": "AI Platform for Data Analysis"
24
+ "_about": "AI Agents for Data Analysis"
25
25
  }
26
26
  },
27
27
  "outputs": [
@@ -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?: JSX.Element | JSX.Element[];
14
+ children?: ReactNode;
14
15
  zIndex?: number;
15
16
  disableDarken?: boolean;
16
17
  backdropSurface?: any;
17
18
  };
18
- export declare function BackdropProvider(props: IBackdropProviderProps): import("react/jsx-runtime").JSX.Element;
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.ReactElementLike>;
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 {};
@@ -48,8 +48,7 @@ const App = () => (
48
48
  )
49
49
  export default App
50
50
  */
51
- export function BackdropProvider(props) {
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.element,
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
- };
@@ -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) => import("@tanstack/react-query").UseQueryResult<IContact | undefined, Error>;
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];