@datalayer/agent-runtimes 0.0.12 → 1.0.1

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 (41) hide show
  1. package/lib/Agent.js +1 -2
  2. package/lib/AgentLexical.d.ts +0 -1
  3. package/lib/AgentLexical.js +1 -3
  4. package/lib/AgentNotebook.js +1 -2
  5. package/lib/components/chat/components/ChatFloating.d.ts +4 -2
  6. package/lib/components/chat/components/ChatFloating.js +1 -1
  7. package/lib/examples/A2UiRestaurantExample.js +2 -2
  8. package/lib/examples/AgUiAgenticExample.js +3 -3
  9. package/lib/examples/AgUiBackendToolRenderingExample.js +4 -3
  10. package/lib/examples/AgUiHaikuGenUIExample.js +4 -3
  11. package/lib/examples/AgUiHumanInTheLoopExample.js +4 -3
  12. package/lib/examples/AgUiSharedStateExample.js +4 -3
  13. package/lib/examples/AgUiToolsBasedGenUIExample.js +4 -3
  14. package/lib/examples/AgentRuntimeChatExample.js +3 -3
  15. package/lib/examples/AgentRuntimeCustomExample.js +2 -2
  16. package/lib/examples/AgentRuntimeFormExample.js +2 -2
  17. package/lib/examples/AgentRuntimeLexical2Example.d.ts +0 -1
  18. package/lib/examples/AgentRuntimeLexical2Example.js +3 -3
  19. package/lib/examples/AgentRuntimeLexicalExample.d.ts +0 -1
  20. package/lib/examples/AgentRuntimeLexicalExample.js +4 -4
  21. package/lib/examples/AgentRuntimeLexicalSidebarExample.d.ts +0 -1
  22. package/lib/examples/AgentRuntimeLexicalSidebarExample.js +3 -3
  23. package/lib/examples/AgentRuntimeNotebookExample.js +4 -3
  24. package/lib/examples/AgentRuntimeNotebookSidebarExample.js +3 -2
  25. package/lib/examples/AgentRuntimeStandaloneExample.js +3 -3
  26. package/lib/examples/CopilotKitLexicalExample.d.ts +0 -1
  27. package/lib/examples/CopilotKitLexicalExample.js +3 -3
  28. package/lib/examples/CopilotKitNotebookExample.js +3 -2
  29. package/lib/examples/DatalayerNotebookExample.js +3 -2
  30. package/lib/examples/JupyterCellExample.js +3 -2
  31. package/lib/examples/JupyterNotebookExample.js +3 -2
  32. package/lib/examples/main.js +68 -18
  33. package/lib/examples/stores/themeStore.d.ts +33 -0
  34. package/lib/examples/stores/themeStore.js +38 -0
  35. package/lib/examples/stores/themedProvider.d.ts +45 -0
  36. package/lib/examples/stores/themedProvider.js +54 -0
  37. package/lib/lexical/ChatInlinePlugin.js +28 -7
  38. package/lib/lexical/index.d.ts +1 -1
  39. package/lib/lexical/useChatInlineToolbarItems.d.ts +9 -2
  40. package/lib/lexical/useChatInlineToolbarItems.js +22 -94
  41. package/package.json +4 -3
@@ -6,13 +6,14 @@
6
6
  * useChatInlineToolbarItems - Hook that creates ToolbarItem[] for the
7
7
  * FloatingTextFormatToolbarPlugin's extraItems prop.
8
8
  *
9
- * Registers an AI sparkle button + dropdown with AI actions
10
- * (Improve, Fix, Simplify, Add detail, Summarise, Explain, Translate)
11
- * into the floating inline toolbar.
9
+ * Registers an AI sparkle button in the floating inline toolbar.
10
+ * Clicking the sparkle button directly opens the ChatInlinePlugin
11
+ * floating panel, where users can type free-form AI prompts.
12
12
  *
13
13
  * Usage:
14
14
  * ```tsx
15
- * const { toolbarItems, isAiOpen, submitPrompt, closeAi } = useChatInlineToolbarItems();
15
+ * const { toolbarItems, isAiOpen, pendingPrompt, clearPendingPrompt, closeAi } =
16
+ * useChatInlineToolbarItems();
16
17
  *
17
18
  * <FloatingTextFormatToolbarPlugin
18
19
  * anchorElem={floatingAnchorElem}
@@ -20,82 +21,25 @@
20
21
  * extraItems={toolbarItems}
21
22
  * />
22
23
  *
23
- * {isAiOpen && <ChatInlinePlugin ... />}
24
+ * <ChatInlinePlugin
25
+ * isOpen={isAiOpen}
26
+ * onClose={closeAi}
27
+ * pendingPrompt={pendingPrompt}
28
+ * onPendingPromptConsumed={clearPendingPrompt}
29
+ * />
24
30
  * ```
25
31
  *
26
32
  * @module lexical/useChatInlineToolbarItems
27
33
  */
28
34
  import { useState, useMemo, useCallback } from 'react';
29
- import { SparkleFillIcon, PencilIcon, CheckIcon, XIcon, PlusIcon, CopyIcon, SyncIcon, InfoIcon, } from '@primer/octicons-react';
30
- /**
31
- * AI action groups for the toolbar dropdown.
32
- */
33
- const AI_ACTIONS = {
34
- modify: [
35
- {
36
- key: 'ai-improve',
37
- label: 'Improve writing',
38
- prompt: 'Improve the quality of the text',
39
- icon: PencilIcon,
40
- },
41
- {
42
- key: 'ai-fix',
43
- label: 'Fix mistakes',
44
- prompt: 'Fix any typos or general errors in the text',
45
- icon: CheckIcon,
46
- },
47
- {
48
- key: 'ai-simplify',
49
- label: 'Simplify',
50
- prompt: 'Shorten the text, simplifying it',
51
- icon: XIcon,
52
- },
53
- {
54
- key: 'ai-detail',
55
- label: 'Add more detail',
56
- prompt: 'Lengthen the text, going into more detail',
57
- icon: PlusIcon,
58
- },
59
- ],
60
- generate: [
61
- {
62
- key: 'ai-summarise',
63
- label: 'Summarise',
64
- prompt: 'Summarise the text',
65
- icon: CopyIcon,
66
- },
67
- {
68
- key: 'ai-explain',
69
- label: 'Explain',
70
- prompt: 'Explain what the text is about',
71
- icon: InfoIcon,
72
- },
73
- ],
74
- translate: [
75
- 'Arabic',
76
- 'Chinese',
77
- 'Dutch',
78
- 'English',
79
- 'French',
80
- 'German',
81
- 'Japanese',
82
- 'Korean',
83
- 'Portuguese',
84
- 'Spanish',
85
- ].map(lang => ({
86
- key: `ai-translate-${lang.toLowerCase()}`,
87
- label: lang,
88
- prompt: `Translate text into the ${lang} language`,
89
- icon: SyncIcon,
90
- })),
91
- };
35
+ import { SparkleFillIcon } from '@primer/octicons-react';
92
36
  /**
93
37
  * Hook that creates ToolbarItem[] for AI actions in the floating toolbar.
94
38
  *
95
- * Returns toolbar items (divider + AI dropdown + sparkle button) and
39
+ * Returns toolbar items (divider + AI sparkle button) and
96
40
  * state for controlling the ChatInline panel.
97
41
  */
98
- export function useChatInlineToolbarItems() {
42
+ export function useChatInlineToolbarItems(options) {
99
43
  const [isAiOpen, setIsAiOpen] = useState(false);
100
44
  const [pendingPrompt, setPendingPrompt] = useState(null);
101
45
  const openAi = useCallback(() => {
@@ -112,27 +56,8 @@ export function useChatInlineToolbarItems() {
112
56
  const clearPendingPrompt = useCallback(() => {
113
57
  setPendingPrompt(null);
114
58
  }, []);
59
+ const isDisabled = options?.disabled ?? false;
115
60
  const toolbarItems = useMemo(() => {
116
- const allOptions = [
117
- ...AI_ACTIONS.modify.map(action => ({
118
- key: action.key,
119
- label: action.label,
120
- icon: action.icon,
121
- onClick: () => submitPrompt(action.prompt),
122
- })),
123
- ...AI_ACTIONS.generate.map(action => ({
124
- key: action.key,
125
- label: action.label,
126
- icon: action.icon,
127
- onClick: () => submitPrompt(action.prompt),
128
- })),
129
- ...AI_ACTIONS.translate.map(action => ({
130
- key: action.key,
131
- label: action.label,
132
- icon: action.icon,
133
- onClick: () => submitPrompt(action.prompt),
134
- })),
135
- ];
136
61
  return [
137
62
  {
138
63
  key: 'ai-divider',
@@ -141,15 +66,18 @@ export function useChatInlineToolbarItems() {
141
66
  },
142
67
  {
143
68
  key: 'ai-actions',
144
- type: 'dropdown',
69
+ type: 'button',
145
70
  order: 901,
146
71
  ariaLabel: 'AI Actions',
147
- title: 'AI Actions',
72
+ title: isDisabled
73
+ ? 'Assign an agent to enable AI actions'
74
+ : 'AI Actions',
148
75
  icon: SparkleFillIcon,
149
- options: allOptions,
76
+ onClick: openAi,
77
+ disabled: isDisabled,
150
78
  },
151
79
  ];
152
- }, [submitPrompt]);
80
+ }, [openAi, isDisabled]);
153
81
  return {
154
82
  toolbarItems,
155
83
  isAiOpen,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/agent-runtimes",
3
- "version": "0.0.12",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "workspaces": [
6
6
  ".",
@@ -130,10 +130,11 @@
130
130
  "@anthropic-ai/sdk": "^0.52.0",
131
131
  "@datalayer/core": "^1.0.1",
132
132
  "@datalayer/icons-react": "^1.0.6",
133
- "@datalayer/jupyter-lexical": "^1.0.11",
133
+ "@datalayer/jupyter-lexical": "^1.0.13",
134
134
  "@datalayer/jupyter-react": "^2.0.3",
135
- "@datalayer/primer-addons": "^1.0.7",
135
+ "@datalayer/primer-addons": "^1.0.10",
136
136
  "@datalayer/primer-rjsf": "^1.0.1",
137
+ "@excalidraw/excalidraw": "^0.18.0",
137
138
  "@jupyter-widgets/base-manager": "^1.0.12",
138
139
  "@jupyter-widgets/schema": "^0.5.6",
139
140
  "@jupyterlab/apputils": "^4.6.0",