@datalayer/agent-runtimes 0.0.10 → 0.0.12
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 +2 -2
- package/lib/Agent.d.ts +29 -0
- package/lib/Agent.js +131 -0
- package/lib/AgentLexical.d.ts +34 -0
- package/lib/AgentLexical.js +296 -0
- package/lib/AgentNotebook.d.ts +19 -0
- package/lib/AgentNotebook.js +192 -0
- package/lib/agent-lexical-main.d.ts +1 -0
- package/lib/agent-lexical-main.js +11 -0
- package/lib/agent-main.d.ts +1 -0
- package/lib/agent-main.js +11 -0
- package/lib/agent-notebook-main.d.ts +1 -0
- package/lib/agent-notebook-main.js +12 -0
- package/lib/components/AgentConfiguration.d.ts +33 -21
- package/lib/components/AgentConfiguration.js +76 -21
- package/lib/components/chat/components/AgentDetails.d.ts +3 -1
- package/lib/components/chat/components/AgentDetails.js +164 -6
- package/lib/components/chat/components/Chat.d.ts +29 -3
- package/lib/components/chat/components/Chat.js +64 -59
- package/lib/components/chat/components/ChatFloating.d.ts +34 -12
- package/lib/components/chat/components/ChatFloating.js +54 -21
- package/lib/components/chat/components/ChatInline.d.ts +5 -1
- package/lib/components/chat/components/ChatInline.js +8 -1
- package/lib/components/chat/components/ChatSidebar.d.ts +6 -1
- package/lib/components/chat/components/ChatSidebar.js +2 -2
- package/lib/components/chat/components/ChatStandalone.d.ts +6 -1
- package/lib/components/chat/components/ChatStandalone.js +2 -2
- package/lib/components/chat/components/ContextDistribution.js +2 -2
- package/lib/components/chat/components/ContextInspector.js +4 -2
- package/lib/components/chat/components/ContextPanel.js +1 -6
- package/lib/components/chat/components/base/ChatBase.d.ts +49 -8
- package/lib/components/chat/components/base/ChatBase.js +544 -149
- package/lib/components/chat/components/base/InputPrompt.d.ts +42 -0
- package/lib/components/chat/components/base/InputPrompt.js +131 -0
- package/lib/components/chat/components/index.d.ts +3 -3
- package/lib/components/chat/components/index.js +1 -1
- package/lib/components/chat/components/parts/ReasoningPart.js +2 -4
- package/lib/components/chat/components/parts/TextPart.js +2 -70
- package/lib/components/chat/components/styles/streamdownStyles.d.ts +23 -0
- package/lib/components/chat/components/styles/streamdownStyles.js +319 -0
- package/lib/components/chat/index.d.ts +1 -1
- package/lib/components/chat/index.js +1 -1
- package/lib/components/chat/inference/DatalayerInferenceProvider.js +16 -12
- package/lib/components/chat/inference/SelfHostedInferenceProvider.js +16 -12
- package/lib/components/chat/protocols/AGUIAdapter.d.ts +10 -3
- package/lib/components/chat/protocols/AGUIAdapter.js +123 -44
- package/lib/components/chat/types/tool.d.ts +5 -2
- package/lib/components/index.d.ts +2 -19
- package/lib/components/index.js +1 -10
- package/lib/config/index.d.ts +0 -3
- package/lib/config/index.js +0 -3
- package/lib/examples/A2UiRestaurantExample.js +1 -1
- package/lib/examples/AgentRuntimeChatExample.d.ts +15 -0
- package/lib/examples/AgentRuntimeChatExample.js +126 -0
- package/lib/examples/{AgentSpaceFormExample.d.ts → AgentRuntimeFormExample.d.ts} +3 -3
- package/lib/examples/{AgentSpaceFormExample.js → AgentRuntimeFormExample.js} +61 -17
- package/lib/examples/AgentRuntimeLexicalExample.js +6 -3
- package/lib/examples/AgentRuntimeLexicalSidebarExample.js +8 -1
- package/lib/examples/AgentRuntimeNotebookExample.js +6 -5
- package/lib/examples/CopilotKitNotebookExample.js +2 -2
- package/lib/examples/JupyterNotebookExample.js +2 -2
- package/lib/{components → examples/components}/Header.d.ts +2 -1
- package/lib/{components → examples/components}/HeaderControls.js +1 -1
- package/lib/{components → examples/components}/LexicalEditor.d.ts +6 -1
- package/lib/{components → examples/components}/LexicalEditor.js +4 -4
- package/lib/{components → examples/components}/MainContent.d.ts +1 -1
- package/lib/{components → examples/components}/MainContent.js +7 -5
- package/lib/examples/components/index.d.ts +16 -0
- package/lib/examples/components/index.js +13 -0
- package/lib/examples/example-selector.js +2 -1
- package/lib/examples/index.d.ts +1 -1
- package/lib/examples/index.js +1 -1
- package/lib/examples/main.js +2 -2
- package/lib/examples/stores/examplesStore.d.ts +2 -23
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -0
- package/lib/lexical/ChatInlinePlugin.d.ts +13 -2
- package/lib/lexical/ChatInlinePlugin.js +41 -179
- package/lib/lexical/index.d.ts +1 -0
- package/lib/lexical/index.js +1 -0
- package/lib/lexical/useChatInlineToolbarItems.d.ts +28 -0
- package/lib/lexical/useChatInlineToolbarItems.js +163 -0
- package/lib/runtime/useAgentRuntime.d.ts +1 -1
- package/lib/runtime/useAgentRuntime.js +1 -1
- package/lib/specs/agents/codeai/agents.d.ts +28 -0
- package/lib/specs/agents/codeai/agents.js +151 -0
- package/lib/specs/agents/codeai/index.d.ts +1 -0
- package/lib/specs/agents/codeai/index.js +5 -0
- package/lib/{config → specs/agents/codemode-paper}/agents.d.ts +4 -6
- package/lib/specs/agents/codemode-paper/agents.js +308 -0
- package/lib/specs/agents/codemode-paper/index.d.ts +1 -0
- package/lib/specs/agents/codemode-paper/index.js +5 -0
- package/lib/specs/agents/datalayer-ai/agents.d.ts +31 -0
- package/lib/{config → specs/agents/datalayer-ai}/agents.js +42 -184
- package/lib/specs/agents/datalayer-ai/index.d.ts +1 -0
- package/lib/specs/agents/datalayer-ai/index.js +5 -0
- package/lib/specs/agents/index.d.ts +21 -0
- package/lib/specs/agents/index.js +47 -0
- package/lib/specs/envvars.d.ts +29 -0
- package/lib/specs/envvars.js +125 -0
- package/lib/specs/index.d.ts +5 -0
- package/lib/specs/index.js +9 -0
- package/lib/{config → specs}/mcpServers.d.ts +2 -1
- package/lib/{config → specs}/mcpServers.js +47 -1
- package/lib/specs/models.d.ts +68 -0
- package/lib/specs/models.js +239 -0
- package/lib/{config → specs}/skills.d.ts +2 -0
- package/lib/{config → specs}/skills.js +6 -0
- package/lib/state/substates/AIAgentState.d.ts +0 -1
- package/lib/tools/adapters/agent-runtimes/AgentRuntimesToolAdapter.d.ts +11 -22
- package/lib/tools/adapters/agent-runtimes/AgentRuntimesToolAdapter.js +5 -5
- package/lib/tools/adapters/agent-runtimes/lexicalHooks.d.ts +6 -6
- package/lib/tools/adapters/agent-runtimes/lexicalHooks.js +4 -4
- package/lib/tools/adapters/agent-runtimes/notebookHooks.d.ts +6 -6
- package/lib/tools/adapters/agent-runtimes/notebookHooks.js +4 -4
- package/lib/{types.d.ts → types/Types.d.ts} +42 -8
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/package.json +11 -5
- package/scripts/codegen/generate_agents.py +608 -157
- package/scripts/codegen/generate_envvars.py +302 -0
- package/scripts/codegen/generate_mcp_servers.py +33 -21
- package/scripts/codegen/generate_models.py +486 -0
- package/scripts/codegen/generate_skills.py +21 -8
- package/style/primer-primitives.css +22 -0
- package/lib/components/chat/components/elements/ChatInputPrompt.d.ts +0 -37
- package/lib/components/chat/components/elements/ChatInputPrompt.js +0 -150
- /package/lib/{components → examples/components}/FooterMetrics.d.ts +0 -0
- /package/lib/{components → examples/components}/FooterMetrics.js +0 -0
- /package/lib/{components → examples/components}/Header.js +0 -0
- /package/lib/{components → examples/components}/HeaderControls.d.ts +0 -0
- /package/lib/{components → examples/components}/MockFileBrowser.d.ts +0 -0
- /package/lib/{components → examples/components}/MockFileBrowser.js +0 -0
- /package/lib/{components → examples/components}/SessionTabs.d.ts +0 -0
- /package/lib/{components → examples/components}/SessionTabs.js +0 -0
- /package/lib/{components → examples/components}/TimeTravel.d.ts +0 -0
- /package/lib/{components → examples/components}/TimeTravel.js +0 -0
- /package/lib/{types.js → types/Types.js} +0 -0
|
@@ -13,9 +13,12 @@ import { QueryClient, QueryClientProvider, useQuery, } from '@tanstack/react-que
|
|
|
13
13
|
import { Box } from '@datalayer/primer-addons';
|
|
14
14
|
import { DatalayerThemeProvider } from '@datalayer/core';
|
|
15
15
|
import { Chat, useChatStore } from '../components/chat';
|
|
16
|
+
import { DEFAULT_MODEL } from '../specs';
|
|
16
17
|
import { useAgentsStore } from './stores/examplesStore';
|
|
17
18
|
import { useIdentity } from '../identity';
|
|
18
|
-
import { MockFileBrowser, MainContent, Header, FooterMetrics,
|
|
19
|
+
import { MockFileBrowser, MainContent, Header, FooterMetrics, } from './components';
|
|
20
|
+
import { AgentConfiguration, } from '../components';
|
|
21
|
+
import { isSpecSelection, getSpecId } from '../components/AgentConfiguration';
|
|
19
22
|
// Create a query client for React Query
|
|
20
23
|
const queryClient = new QueryClient({
|
|
21
24
|
defaultOptions: {
|
|
@@ -106,7 +109,7 @@ const DEFAULT_IDENTITY_PROVIDERS = {
|
|
|
106
109
|
}
|
|
107
110
|
: {}),
|
|
108
111
|
};
|
|
109
|
-
const
|
|
112
|
+
const AgentRuntimeFormExample = ({ initialWsUrl = DEFAULT_WS_URL, initialBaseUrl = DEFAULT_BASE_URL, initialAgentName = DEFAULT_AGENT_ID, initialAgentLibrary = 'pydantic-ai', initialTransport = 'ag-ui', initialModel = DEFAULT_MODEL, initialEnableCodemode = false, initialAllowDirectToolCalls = false, initialEnableToolReranker = false, initialSelectedMcpServers = [], autoSelectMcpServers = false, identityProviders = DEFAULT_IDENTITY_PROVIDERS,
|
|
110
113
|
// Deprecated props - merged into identityProviders for backward compat
|
|
111
114
|
githubClientId, kaggleToken, }) => {
|
|
112
115
|
const [wsUrl, setWsUrl] = useState(initialWsUrl);
|
|
@@ -258,10 +261,10 @@ githubClientId, kaggleToken, }) => {
|
|
|
258
261
|
connectedTokenProvidersRef.current.add(provider);
|
|
259
262
|
connectWithToken(provider, token, { displayName, iconUrl })
|
|
260
263
|
.then(() => {
|
|
261
|
-
console.log(`[
|
|
264
|
+
console.log(`[AgentRuntimeFormExample] ${provider} connected with token`);
|
|
262
265
|
})
|
|
263
266
|
.catch(err => {
|
|
264
|
-
console.error(`[
|
|
267
|
+
console.error(`[AgentRuntimeFormExample] Failed to connect ${provider}:`, err);
|
|
265
268
|
// Remove from attempted set so we can retry
|
|
266
269
|
connectedTokenProvidersRef.current.delete(provider);
|
|
267
270
|
});
|
|
@@ -269,10 +272,10 @@ githubClientId, kaggleToken, }) => {
|
|
|
269
272
|
}, [tokenProviders, connectWithToken, isIdentityConnected]);
|
|
270
273
|
// Handle identity connect/disconnect
|
|
271
274
|
const handleIdentityConnect = useCallback((identity) => {
|
|
272
|
-
console.log('[
|
|
275
|
+
console.log('[AgentRuntimeFormExample] Identity connected:', identity.provider, identity.userInfo?.name || identity.userInfo?.email);
|
|
273
276
|
}, []);
|
|
274
277
|
const handleIdentityDisconnect = useCallback((provider) => {
|
|
275
|
-
console.log('[
|
|
278
|
+
console.log('[AgentRuntimeFormExample] Identity disconnected:', provider);
|
|
276
279
|
}, []);
|
|
277
280
|
// Handle codemode change - keep MCP server selections to scope codemode tools
|
|
278
281
|
const handleEnableCodemodeChange = (enabled) => {
|
|
@@ -335,7 +338,24 @@ githubClientId, kaggleToken, }) => {
|
|
|
335
338
|
}, [autoSelectMcpServers, enableCodemode, selectedMcpServers, baseUrl]);
|
|
336
339
|
// Track previous MCP servers to detect changes
|
|
337
340
|
const prevMcpServersRef = useRef(selectedMcpServers);
|
|
338
|
-
|
|
341
|
+
// Cache for library specs (fetched on-demand, outside QueryClientProvider)
|
|
342
|
+
const librarySpecsRef = useRef(null);
|
|
343
|
+
const fetchLibrarySpecs = useCallback(async () => {
|
|
344
|
+
if (librarySpecsRef.current)
|
|
345
|
+
return librarySpecsRef.current;
|
|
346
|
+
try {
|
|
347
|
+
const response = await fetch(`${baseUrl}/api/v1/agents/library`);
|
|
348
|
+
if (!response.ok)
|
|
349
|
+
return [];
|
|
350
|
+
const data = await response.json();
|
|
351
|
+
librarySpecsRef.current = data;
|
|
352
|
+
return data;
|
|
353
|
+
}
|
|
354
|
+
catch {
|
|
355
|
+
return [];
|
|
356
|
+
}
|
|
357
|
+
}, [baseUrl]);
|
|
358
|
+
const handleAgentSelect = async (agentId) => {
|
|
339
359
|
setSelectedAgentId(agentId);
|
|
340
360
|
setCreateError(null);
|
|
341
361
|
if (agentId === 'new-agent') {
|
|
@@ -343,6 +363,23 @@ githubClientId, kaggleToken, }) => {
|
|
|
343
363
|
setAgentName(DEFAULT_AGENT_ID);
|
|
344
364
|
setTransport('ag-ui');
|
|
345
365
|
}
|
|
366
|
+
else if (isSpecSelection(agentId)) {
|
|
367
|
+
// Populate form fields from the selected library spec
|
|
368
|
+
const specId = getSpecId(agentId);
|
|
369
|
+
const specs = await fetchLibrarySpecs();
|
|
370
|
+
const spec = specs.find(s => s.id === specId);
|
|
371
|
+
if (spec) {
|
|
372
|
+
setAgentName(spec.id);
|
|
373
|
+
// Keep current transport, model, agentLibrary - user can override
|
|
374
|
+
if (spec.skills.length > 0) {
|
|
375
|
+
setSelectedSkills(spec.skills);
|
|
376
|
+
setEnableCodemode(true);
|
|
377
|
+
}
|
|
378
|
+
if (spec.systemPromptCodemodeAddons) {
|
|
379
|
+
setEnableCodemode(true);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
346
383
|
else {
|
|
347
384
|
const agent = agents.find(a => a.id === agentId);
|
|
348
385
|
if (agent) {
|
|
@@ -358,6 +395,10 @@ githubClientId, kaggleToken, }) => {
|
|
|
358
395
|
setIsCreatingAgent(true);
|
|
359
396
|
setCreateError(null);
|
|
360
397
|
try {
|
|
398
|
+
// Resolve spec ID if creating from a library spec
|
|
399
|
+
const specId = isSpecSelection(selectedAgentId)
|
|
400
|
+
? getSpecId(selectedAgentId)
|
|
401
|
+
: undefined;
|
|
361
402
|
const response = await fetch(`${baseUrl}/api/v1/agents`, {
|
|
362
403
|
method: 'POST',
|
|
363
404
|
headers: {
|
|
@@ -377,6 +418,7 @@ githubClientId, kaggleToken, }) => {
|
|
|
377
418
|
selected_mcp_servers: selectedMcpServers,
|
|
378
419
|
skills: selectedSkills,
|
|
379
420
|
jupyter_sandbox: useJupyterSandbox ? jupyterSandboxUrl : undefined,
|
|
421
|
+
...(specId ? { agent_spec_id: specId } : {}),
|
|
380
422
|
}),
|
|
381
423
|
});
|
|
382
424
|
if (!response.ok) {
|
|
@@ -412,6 +454,7 @@ githubClientId, kaggleToken, }) => {
|
|
|
412
454
|
selectedSkills,
|
|
413
455
|
useJupyterSandbox,
|
|
414
456
|
jupyterSandboxUrl,
|
|
457
|
+
selectedAgentId,
|
|
415
458
|
]);
|
|
416
459
|
/**
|
|
417
460
|
* Delete an agent via the API
|
|
@@ -438,9 +481,11 @@ githubClientId, kaggleToken, }) => {
|
|
|
438
481
|
useEffect(() => {
|
|
439
482
|
prevMcpServersRef.current = selectedMcpServers;
|
|
440
483
|
}, [selectedMcpServers]);
|
|
484
|
+
// True when creating a new agent (blank or from a library spec)
|
|
485
|
+
const isNewMode = selectedAgentId === 'new-agent' || isSpecSelection(selectedAgentId);
|
|
441
486
|
const handleConnect = async () => {
|
|
442
|
-
// For existing agents (not new-agent), ensure transport and agentName are set
|
|
443
|
-
if (
|
|
487
|
+
// For existing agents (not new-agent or spec), ensure transport and agentName are set
|
|
488
|
+
if (!isNewMode) {
|
|
444
489
|
const agent = agents.find(a => a.id === selectedAgentId);
|
|
445
490
|
if (agent) {
|
|
446
491
|
setTransport(agent.transport);
|
|
@@ -477,14 +522,13 @@ githubClientId, kaggleToken, }) => {
|
|
|
477
522
|
};
|
|
478
523
|
const handleReset = async () => {
|
|
479
524
|
// Delete the agent from the server if we created it
|
|
480
|
-
if (selectedAgentId === 'new-agent'
|
|
525
|
+
if ((selectedAgentId === 'new-agent' || isSpecSelection(selectedAgentId)) &&
|
|
526
|
+
agentName) {
|
|
481
527
|
await deleteAgentOnServer(agentName);
|
|
482
528
|
}
|
|
483
529
|
setIsConfigured(false);
|
|
484
530
|
};
|
|
485
|
-
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(DatalayerThemeProvider, { children: _jsxs(PageLayout, { containerWidth: "full", children: [_jsx(Header, { activeSession: activeSession, agentName:
|
|
486
|
-
? undefined
|
|
487
|
-
: currentAgent?.description, agentStatus: currentAgent?.status, showContextTree: showContextTree, isNewAgent: selectedAgentId === 'new-agent', isConfigured: isConfigured, onSessionChange: setActiveSession, onToggleContextTree: () => setShowContextTree(!showContextTree), onToggleStatus: currentAgent
|
|
531
|
+
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(DatalayerThemeProvider, { children: _jsxs(PageLayout, { containerWidth: "full", children: [_jsx(Header, { activeSession: activeSession, agentName: isNewMode ? undefined : currentAgent?.name, agentDescription: isNewMode ? undefined : currentAgent?.description, agentStatus: currentAgent?.status, showContextTree: showContextTree, isNewAgent: isNewMode, isConfigured: isConfigured, onSessionChange: setActiveSession, onToggleContextTree: () => setShowContextTree(!showContextTree), onToggleStatus: currentAgent
|
|
488
532
|
? () => toggleAgentStatus(currentAgent.id)
|
|
489
533
|
: undefined }), leftPaneVisible ? (_jsxs(_Fragment, { children: [_jsx(Box, { sx: {
|
|
490
534
|
position: 'fixed',
|
|
@@ -498,7 +542,7 @@ githubClientId, kaggleToken, }) => {
|
|
|
498
542
|
border: '1px solid',
|
|
499
543
|
borderLeft: 'none',
|
|
500
544
|
borderColor: 'border.default',
|
|
501
|
-
} }) }), _jsx(PageLayout.Pane, { position: "start", resizable: true, sticky: true, width: { min: '250px', default: '300px', max: '90px' }, children:
|
|
545
|
+
} }) }), _jsx(PageLayout.Pane, { position: "start", resizable: true, sticky: true, width: { min: '250px', default: '300px', max: '90px' }, children: isNewMode ? (_jsxs(Blankslate, { border: true, spacious: true, narrow: true, children: [_jsx(Blankslate.Visual, { children: _jsx(AiAgentIcon, { colored: true, size: 48 }) }), _jsx(Blankslate.Heading, { children: "Agent Runtimes" }), _jsx(Box, { sx: { textAlign: 'center' }, children: _jsx(Blankslate.Description, { children: "Expose AI Agents through multiple protocols." }) })] })) : (_jsx(MockFileBrowser, { codemode: codemode })) })] })) : (_jsx(Box, { sx: {
|
|
502
546
|
position: 'fixed',
|
|
503
547
|
left: 0,
|
|
504
548
|
top: '50%',
|
|
@@ -510,9 +554,9 @@ githubClientId, kaggleToken, }) => {
|
|
|
510
554
|
border: '1px solid',
|
|
511
555
|
borderLeft: 'none',
|
|
512
556
|
borderColor: 'border.default',
|
|
513
|
-
} }) })), _jsx(PageLayout.Content, { children: _jsx(MainContent, { showNotebook: showNotebook, timeTravel: timeTravel, onTimeTravelChange: setTimeTravel, richEditor: false, notebookFile: currentAgent?.notebookFile, lexicalFile: currentAgent?.lexicalFile, isNewAgent:
|
|
557
|
+
} }) })), _jsx(PageLayout.Content, { children: _jsx(MainContent, { showNotebook: showNotebook, timeTravel: timeTravel, onTimeTravelChange: setTimeTravel, richEditor: false, notebookFile: currentAgent?.notebookFile, lexicalFile: currentAgent?.lexicalFile, isNewAgent: isNewMode, isConfigured: isConfigured, baseUrl: baseUrl, agentId: currentAgent?.id || agentName, enableCodemode: enableCodemode, selectedMcpServers: selectedMcpServers, onSelectedMcpServersChange: handleSelectedServersChange, onMcpServersChange: () => {
|
|
514
558
|
// Trigger codemode tool regeneration when MCP servers change at runtime
|
|
515
|
-
console.log('[
|
|
559
|
+
console.log('[AgentRuntimeFormExample] MCP servers changed, regenerating codemode tools...');
|
|
516
560
|
// The Chat component will pick up the new selectedMcpServers via props
|
|
517
561
|
} }) }), rightPaneVisible ? (_jsxs(_Fragment, { children: [_jsx(Box, { sx: {
|
|
518
562
|
position: 'fixed',
|
|
@@ -600,4 +644,4 @@ githubClientId, kaggleToken, }) => {
|
|
|
600
644
|
zIndex: 10,
|
|
601
645
|
}, children: selectedAgentId !== 'new-agent' && (_jsx(FooterMetrics, { tokens: 1523552, cost: 2.01 })) })] }) }) }));
|
|
602
646
|
};
|
|
603
|
-
export default
|
|
647
|
+
export default AgentRuntimeFormExample;
|
|
@@ -49,6 +49,7 @@ import { ComponentPickerMenuPlugin, JupyterCellPlugin, JupyterInputOutputPlugin,
|
|
|
49
49
|
// Agent-runtimes imports
|
|
50
50
|
import { ChatFloating } from '../components/chat';
|
|
51
51
|
import { ChatInlinePlugin } from '../lexical/ChatInlinePlugin';
|
|
52
|
+
import { useChatInlineToolbarItems } from '../lexical/useChatInlineToolbarItems';
|
|
52
53
|
import { useLexicalTools } from '../tools/adapters/agent-runtimes/lexicalHooks';
|
|
53
54
|
import { editorConfig } from './lexical/editorConfig';
|
|
54
55
|
import '@datalayer/jupyter-lexical/style/index.css';
|
|
@@ -187,6 +188,8 @@ function LexicalToolsPlugin({ onToolsReady, }) {
|
|
|
187
188
|
const LexicalUI = React.memo(function LexicalUI({ content = INITIAL_CONTENT, serviceManager, onToolsReady, }) {
|
|
188
189
|
const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
|
|
189
190
|
const [_isLinkEditMode, setIsLinkEditMode] = useState(false);
|
|
191
|
+
// AI actions registered as toolbar items via the primer-addons toolbar extensibility
|
|
192
|
+
const { toolbarItems, isAiOpen, pendingPrompt, clearPendingPrompt, closeAi } = useChatInlineToolbarItems();
|
|
190
193
|
const onRef = (_floatingAnchorElem) => {
|
|
191
194
|
if (_floatingAnchorElem !== null) {
|
|
192
195
|
setFloatingAnchorElem(_floatingAnchorElem);
|
|
@@ -213,10 +216,10 @@ const LexicalUI = React.memo(function LexicalUI({ content = INITIAL_CONTENT, ser
|
|
|
213
216
|
padding: 3,
|
|
214
217
|
backgroundColor: 'canvas.default',
|
|
215
218
|
minHeight: '600px',
|
|
216
|
-
}, children: _jsxs(LexicalConfigProvider, { lexicalId: LEXICAL_ID, serviceManager: serviceManager, children: [_jsx(LexicalToolsPlugin, { onToolsReady: onToolsReady }), _jsx(LexicalComposer, { initialConfig: editorConfig, children: _jsxs("div", { className: "lexical-editor-inner", ref: onRef, children: [_jsx(LexicalStatePlugin, {}), _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "lexical-editor-content", "aria-label": "Lexical Editor" }), ErrorBoundary: LexicalErrorBoundary }), _jsx(OnChangePlugin, { onChange: handleChange }), _jsx(HistoryPlugin, {}), _jsx(AutoFocusPlugin, {}), _jsx(ListPlugin, {}), _jsx(CheckListPlugin, {}), _jsx(LinkPlugin, {}), _jsx(AutoLinkPlugin, {}), _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), _jsx(MarkdownShortcutPlugin, { transformers: TRANSFORMERS }), _jsx(LoadContentPlugin, { content: content }), _jsx(CodeHighlightPlugin, {}), _jsx(ImagesPlugin, { captionsEnabled: false }), _jsx(HorizontalRulePlugin, {}), _jsx(EquationsPlugin, {}), _jsx(YouTubePlugin, {}), _jsx(ExcalidrawPlugin, {}), _jsx(CollapsiblePlugin, {}), _jsx(AutoEmbedPlugin, {}), _jsx(TablePlugin, {}), _jsx(TableCellResizerPlugin, {}), _jsx(JupyterCellPlugin, {}), _jsx(JupyterReactTheme, { children: _jsx(SimpleKernelPluginsInner, {}) }), floatingAnchorElem && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem, setIsLinkEditMode: setIsLinkEditMode }), _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem })] })), _jsx(ChatInlinePlugin, { protocol: {
|
|
219
|
+
}, children: _jsxs(LexicalConfigProvider, { lexicalId: LEXICAL_ID, serviceManager: serviceManager, children: [_jsx(LexicalToolsPlugin, { onToolsReady: onToolsReady }), _jsx(LexicalComposer, { initialConfig: editorConfig, children: _jsxs("div", { className: "lexical-editor-inner", ref: onRef, children: [_jsx(LexicalStatePlugin, {}), _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "lexical-editor-content", "aria-label": "Lexical Editor" }), ErrorBoundary: LexicalErrorBoundary }), _jsx(OnChangePlugin, { onChange: handleChange }), _jsx(HistoryPlugin, {}), _jsx(AutoFocusPlugin, {}), _jsx(ListPlugin, {}), _jsx(CheckListPlugin, {}), _jsx(LinkPlugin, {}), _jsx(AutoLinkPlugin, {}), _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), _jsx(MarkdownShortcutPlugin, { transformers: TRANSFORMERS }), _jsx(LoadContentPlugin, { content: content }), _jsx(CodeHighlightPlugin, {}), _jsx(ImagesPlugin, { captionsEnabled: false }), _jsx(HorizontalRulePlugin, {}), _jsx(EquationsPlugin, {}), _jsx(YouTubePlugin, {}), _jsx(ExcalidrawPlugin, {}), _jsx(CollapsiblePlugin, {}), _jsx(AutoEmbedPlugin, {}), _jsx(TablePlugin, {}), _jsx(TableCellResizerPlugin, {}), _jsx(JupyterCellPlugin, {}), _jsx(JupyterReactTheme, { children: _jsx(SimpleKernelPluginsInner, {}) }), floatingAnchorElem && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem, setIsLinkEditMode: setIsLinkEditMode, extraItems: toolbarItems }), _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem })] })), _jsx(ChatInlinePlugin, { protocol: {
|
|
217
220
|
type: 'ag-ui',
|
|
218
221
|
endpoint: AG_UI_ENDPOINT,
|
|
219
|
-
} })] }) })] }) })] }));
|
|
222
|
+
}, isOpen: isAiOpen, onClose: closeAi, pendingPrompt: pendingPrompt, onPendingPromptConsumed: clearPendingPrompt })] }) })] }) })] }));
|
|
220
223
|
});
|
|
221
224
|
function LexicalWithChat({ content, serviceManager, }) {
|
|
222
225
|
// Ensure the agent exists before rendering chat
|
|
@@ -244,7 +247,7 @@ function LexicalWithChat({ content, serviceManager, }) {
|
|
|
244
247
|
color: 'danger.fg',
|
|
245
248
|
borderRadius: 2,
|
|
246
249
|
maxWidth: 300,
|
|
247
|
-
}, children: [_jsx("strong", { children: "Error:" }), " ", error] })), isReady && (_jsx(ChatFloating, { endpoint: AG_UI_ENDPOINT, title: "Lexical AI Agent Runtime", description: "Hi! I can help you edit documents. Try: 'Insert a heading', 'Add a code block', or 'Create a list'", defaultOpen: true, defaultViewMode: "panel", position: "bottom-right", brandColor: "#7c3aed",
|
|
250
|
+
}, children: [_jsx("strong", { children: "Error:" }), " ", error] })), isReady && (_jsx(ChatFloating, { endpoint: AG_UI_ENDPOINT, title: "Lexical AI Agent Runtime", description: "Hi! I can help you edit documents. Try: 'Insert a heading', 'Add a code block', or 'Create a list'", defaultOpen: true, defaultViewMode: "panel", position: "bottom-right", brandColor: "#7c3aed", frontendTools: tools, useStore: false, showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, suggestions: [
|
|
248
251
|
{
|
|
249
252
|
title: 'Insert heading',
|
|
250
253
|
message: 'Insert a heading that says "Welcome"',
|
|
@@ -49,6 +49,8 @@ import { JupyterReactTheme, useJupyter } from '@datalayer/jupyter-react';
|
|
|
49
49
|
import { ComponentPickerMenuPlugin, JupyterCellPlugin, JupyterInputOutputPlugin, DraggableBlockPlugin, ImagesPlugin, HorizontalRulePlugin, EquationsPlugin, YouTubePlugin, ExcalidrawPlugin, CollapsiblePlugin, AutoLinkPlugin, AutoEmbedPlugin, FloatingTextFormatToolbarPlugin, CodeActionMenuPlugin, ListMaxIndentLevelPlugin, LexicalConfigProvider, LexicalStatePlugin, TableCellResizerPlugin, TablePlugin, } from '@datalayer/jupyter-lexical';
|
|
50
50
|
// Import Chat components
|
|
51
51
|
import { ChatSidebar, } from '../components/chat';
|
|
52
|
+
import { ChatInlinePlugin } from '../lexical/ChatInlinePlugin';
|
|
53
|
+
import { useChatInlineToolbarItems } from '../lexical/useChatInlineToolbarItems';
|
|
52
54
|
import { useLexicalTools } from '../tools/adapters/agent-runtimes/lexicalHooks';
|
|
53
55
|
import { editorConfig } from './lexical/editorConfig';
|
|
54
56
|
import '@datalayer/jupyter-lexical/style/index.css';
|
|
@@ -72,6 +74,8 @@ function CodeHighlightingPlugin() {
|
|
|
72
74
|
function LexicalEditor({ serviceManager }) {
|
|
73
75
|
const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
|
|
74
76
|
const [_isLinkEditMode, setIsLinkEditMode] = useState(false);
|
|
77
|
+
// AI actions registered as toolbar items
|
|
78
|
+
const { toolbarItems, isAiOpen, pendingPrompt, clearPendingPrompt, closeAi } = useChatInlineToolbarItems();
|
|
75
79
|
const onRef = (_floatingAnchorElem) => {
|
|
76
80
|
if (_floatingAnchorElem !== null) {
|
|
77
81
|
setFloatingAnchorElem(_floatingAnchorElem);
|
|
@@ -98,7 +102,10 @@ function LexicalEditor({ serviceManager }) {
|
|
|
98
102
|
left: '24px',
|
|
99
103
|
color: 'var(--fgColor-muted)',
|
|
100
104
|
pointerEvents: 'none',
|
|
101
|
-
}, children: "Start typing or use the chat to create content..." }), ErrorBoundary: LexicalErrorBoundary }), _jsx(HistoryPlugin, {}), _jsx(AutoFocusPlugin, {}), _jsx(OnChangePlugin, { onChange: onChange }), _jsx(MarkdownShortcutPlugin, { transformers: TRANSFORMERS }), _jsx(CodeHighlightingPlugin, {}), _jsx(ListPlugin, {}), _jsx(CheckListPlugin, {}), _jsx(LinkPlugin, {}), _jsx(TablePlugin, {}), _jsx(TableCellResizerPlugin, {}), _jsx(JupyterCellPlugin, {}), _jsx(JupyterInputOutputPlugin, {}), _jsx(ImagesPlugin, {}), _jsx(HorizontalRulePlugin, {}), _jsx(EquationsPlugin, {}), _jsx(YouTubePlugin, {}), _jsx(ExcalidrawPlugin, {}), _jsx(CollapsiblePlugin, {}), _jsx(AutoLinkPlugin, {}), _jsx(AutoEmbedPlugin, {}), _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), floatingAnchorElem && (_jsxs(_Fragment, { children: [_jsx(ComponentPickerMenuPlugin, {}), _jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem, setIsLinkEditMode: setIsLinkEditMode }), _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem })] }))
|
|
105
|
+
}, children: "Start typing or use the chat to create content..." }), ErrorBoundary: LexicalErrorBoundary }), _jsx(HistoryPlugin, {}), _jsx(AutoFocusPlugin, {}), _jsx(OnChangePlugin, { onChange: onChange }), _jsx(MarkdownShortcutPlugin, { transformers: TRANSFORMERS }), _jsx(CodeHighlightingPlugin, {}), _jsx(ListPlugin, {}), _jsx(CheckListPlugin, {}), _jsx(LinkPlugin, {}), _jsx(TablePlugin, {}), _jsx(TableCellResizerPlugin, {}), _jsx(JupyterCellPlugin, {}), _jsx(JupyterInputOutputPlugin, {}), _jsx(ImagesPlugin, {}), _jsx(HorizontalRulePlugin, {}), _jsx(EquationsPlugin, {}), _jsx(YouTubePlugin, {}), _jsx(ExcalidrawPlugin, {}), _jsx(CollapsiblePlugin, {}), _jsx(AutoLinkPlugin, {}), _jsx(AutoEmbedPlugin, {}), _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), floatingAnchorElem && (_jsxs(_Fragment, { children: [_jsx(ComponentPickerMenuPlugin, {}), _jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem, setIsLinkEditMode: setIsLinkEditMode, extraItems: toolbarItems }), _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem })] })), _jsx(ChatInlinePlugin, { protocol: {
|
|
106
|
+
type: 'ag-ui',
|
|
107
|
+
endpoint: `${DEFAULT_BASE_URL}/api/v1/examples/${DEFAULT_AGENT_ID}/`,
|
|
108
|
+
}, isOpen: isAiOpen, onClose: closeAi, pendingPrompt: pendingPrompt, onPendingPromptConsumed: clearPendingPrompt })] })] }) }));
|
|
102
109
|
}
|
|
103
110
|
export function ChatLexicalExampleInner({ serviceManager, }) {
|
|
104
111
|
// Get lexical tools for ChatSidebar
|
|
@@ -17,12 +17,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
17
17
|
*/
|
|
18
18
|
import React, { useEffect, useState } from 'react';
|
|
19
19
|
import { Box } from '@datalayer/primer-addons';
|
|
20
|
-
import { Notebook } from '@datalayer/jupyter-react';
|
|
20
|
+
import { JupyterReactTheme, Notebook } from '@datalayer/jupyter-react';
|
|
21
21
|
// Agent-runtimes imports
|
|
22
22
|
import { ChatFloating } from '../components/chat';
|
|
23
23
|
import { useNotebookTools } from '../tools/adapters/agent-runtimes/notebookHooks';
|
|
24
24
|
// Import Matplotlib notebook
|
|
25
25
|
import MatplotlibNotebook from './stores/notebooks/Matplotlib.ipynb.json';
|
|
26
|
+
import { DEFAULT_MODEL } from '../specs';
|
|
26
27
|
// Fixed notebook ID
|
|
27
28
|
const NOTEBOOK_ID = 'agui-notebook-example';
|
|
28
29
|
// Use the imported Matplotlib notebook
|
|
@@ -54,7 +55,7 @@ function useEnsureAgent(agentId, baseUrl) {
|
|
|
54
55
|
description: 'Demo agent for notebook example',
|
|
55
56
|
agent_library: 'pydantic-ai',
|
|
56
57
|
transport: 'ag-ui',
|
|
57
|
-
model:
|
|
58
|
+
model: DEFAULT_MODEL,
|
|
58
59
|
system_prompt: 'You are a helpful AI assistant that helps users work with Jupyter notebooks. You can help with code, explanations, and data analysis.',
|
|
59
60
|
}),
|
|
60
61
|
});
|
|
@@ -106,13 +107,13 @@ const NotebookUI = React.memo(function NotebookUI({ serviceManager, }) {
|
|
|
106
107
|
borderRadius: 2,
|
|
107
108
|
padding: 3,
|
|
108
109
|
backgroundColor: 'canvas.default',
|
|
109
|
-
}, children: serviceManager ? (_jsx(Notebook, { nbformat: NOTEBOOK_CONTENT, id: NOTEBOOK_ID, serviceManager: serviceManager, height: "600px", cellSidebarMargin: 120, startDefaultKernel: true })) : (_jsx(Box, { sx: { padding: 3 }, children: _jsx("p", { children: "Loading service manager..." }) })) })] }));
|
|
110
|
+
}, children: serviceManager ? (_jsx(JupyterReactTheme, { children: _jsx(Notebook, { nbformat: NOTEBOOK_CONTENT, id: NOTEBOOK_ID, serviceManager: serviceManager, height: "600px", cellSidebarMargin: 120, startDefaultKernel: true }) })) : (_jsx(Box, { sx: { padding: 3 }, children: _jsx("p", { children: "Loading service manager..." }) })) })] }));
|
|
110
111
|
});
|
|
111
112
|
function NotebookWithChat({ serviceManager, }) {
|
|
112
113
|
// Ensure the agent exists before rendering chat
|
|
113
114
|
const { isReady, error } = useEnsureAgent(AGENT_ID, BASE_URL);
|
|
114
115
|
// Get notebook tools for ChatFloating
|
|
115
|
-
const
|
|
116
|
+
const frontendTools = useNotebookTools(NOTEBOOK_ID);
|
|
116
117
|
return (_jsxs(Box, { sx: {
|
|
117
118
|
height: '100vh',
|
|
118
119
|
width: '100vw',
|
|
@@ -127,7 +128,7 @@ function NotebookWithChat({ serviceManager, }) {
|
|
|
127
128
|
color: 'danger.fg',
|
|
128
129
|
borderRadius: 2,
|
|
129
130
|
maxWidth: 300,
|
|
130
|
-
}, children: [_jsx("strong", { children: "Error:" }), " ", error] })), isReady && (_jsx(ChatFloating, { endpoint: AG_UI_ENDPOINT, title: "Notebook AI Agent Runtime", description: "Hi! I can help you edit notebook cells. Try: 'Add a new code cell', 'Run cell 1', or 'Delete the last cell'", defaultOpen: true, defaultViewMode: "panel", position: "bottom-right", brandColor: "#7c3aed",
|
|
131
|
+
}, children: [_jsx("strong", { children: "Error:" }), " ", error] })), isReady && (_jsx(ChatFloating, { endpoint: AG_UI_ENDPOINT, title: "Notebook AI Agent Runtime", description: "Hi! I can help you edit notebook cells. Try: 'Add a new code cell', 'Run cell 1', or 'Delete the last cell'", defaultOpen: true, defaultViewMode: "panel", position: "bottom-right", brandColor: "#7c3aed", frontendTools: frontendTools, useStore: false, showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, suggestions: [
|
|
131
132
|
{
|
|
132
133
|
title: 'Add a cell',
|
|
133
134
|
message: 'Insert a random cell to the notebook',
|
|
@@ -16,7 +16,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
16
16
|
*/
|
|
17
17
|
import React from 'react';
|
|
18
18
|
import { Box } from '@datalayer/primer-addons';
|
|
19
|
-
import { Notebook } from '@datalayer/jupyter-react';
|
|
19
|
+
import { JupyterReactTheme, Notebook } from '@datalayer/jupyter-react';
|
|
20
20
|
// CopilotKit imports
|
|
21
21
|
import { CopilotKit, useFrontendTool } from '@copilotkit/react-core';
|
|
22
22
|
import { CopilotSidebar } from '@copilotkit/react-ui';
|
|
@@ -50,7 +50,7 @@ const NotebookUI = React.memo(function NotebookUI({ serviceManager, }) {
|
|
|
50
50
|
borderRadius: 8,
|
|
51
51
|
padding: 24,
|
|
52
52
|
backgroundColor: 'var(--bgColor-default)',
|
|
53
|
-
}, children: serviceManager ? (_jsx(Notebook, { nbformat: NOTEBOOK_CONTENT, id: NOTEBOOK_ID, serviceManager: serviceManager, height: "600px", cellSidebarMargin: 120, startDefaultKernel: true })) : (_jsx(Box, { style: { padding: 24 }, children: _jsx("p", { children: "Loading service manager..." }) })) })] }) }));
|
|
53
|
+
}, children: serviceManager ? (_jsx(JupyterReactTheme, { children: _jsx(Notebook, { nbformat: NOTEBOOK_CONTENT, id: NOTEBOOK_ID, serviceManager: serviceManager, height: "600px", cellSidebarMargin: 120, startDefaultKernel: true }) })) : (_jsx(Box, { style: { padding: 24 }, children: _jsx("p", { children: "Loading service manager..." }) })) })] }) }));
|
|
54
54
|
});
|
|
55
55
|
/**
|
|
56
56
|
* Component to register actions with CopilotKit.
|
|
@@ -10,12 +10,12 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
10
10
|
*/
|
|
11
11
|
import { useMemo } from 'react';
|
|
12
12
|
import { Box } from '@datalayer/primer-addons';
|
|
13
|
-
import { Notebook, NotebookToolbar, CellSidebarExtension, CellSidebarButton, } from '@datalayer/jupyter-react';
|
|
13
|
+
import { JupyterReactTheme, Notebook, NotebookToolbar, CellSidebarExtension, CellSidebarButton, } from '@datalayer/jupyter-react';
|
|
14
14
|
import nbformatExample from './stores/notebooks/NotebookExample1.ipynb.json';
|
|
15
15
|
const NOTEBOOK_ID = 'notebook-example-1';
|
|
16
16
|
export const JupyterNotebookExample = (props) => {
|
|
17
17
|
const { serviceManager } = props;
|
|
18
18
|
const extensions = useMemo(() => [new CellSidebarExtension({ factory: CellSidebarButton })], []);
|
|
19
|
-
return (_jsxs(_Fragment, { children: [_jsx(Box, { as: "h1", children: "Jupyter Notebook Example" }), serviceManager && (_jsx(Notebook, { id: NOTEBOOK_ID, nbformat: nbformatExample, serviceManager: serviceManager, startDefaultKernel: true, extensions: extensions, Toolbar: NotebookToolbar }))] }));
|
|
19
|
+
return (_jsxs(_Fragment, { children: [_jsx(Box, { as: "h1", children: "Jupyter Notebook Example" }), serviceManager && (_jsx(JupyterReactTheme, { children: _jsx(Notebook, { id: NOTEBOOK_ID, nbformat: nbformatExample, serviceManager: serviceManager, startDefaultKernel: true, extensions: extensions, Toolbar: NotebookToolbar }) }))] }));
|
|
20
20
|
};
|
|
21
21
|
export default JupyterNotebookExample;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { AgentStatus } from '../../types/Types';
|
|
2
3
|
export interface HeaderProps {
|
|
3
4
|
activeSession: string;
|
|
4
5
|
agentName?: string;
|
|
5
6
|
agentDescription?: string;
|
|
6
|
-
agentStatus?:
|
|
7
|
+
agentStatus?: AgentStatus;
|
|
7
8
|
showContextTree: boolean;
|
|
8
9
|
isNewAgent?: boolean;
|
|
9
10
|
isConfigured?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Box } from '@datalayer/primer-addons';
|
|
3
|
-
import { Sparklines, SparklinesLine } from '
|
|
3
|
+
import { Sparklines, SparklinesLine } from '../../components/sparklines';
|
|
4
4
|
/**
|
|
5
5
|
* Header Controls Component
|
|
6
6
|
*
|
|
@@ -12,11 +12,16 @@ import 'prismjs/components/prism-rust';
|
|
|
12
12
|
import 'prismjs/components/prism-swift';
|
|
13
13
|
import React from 'react';
|
|
14
14
|
import type { ServiceManager } from '@jupyterlab/services';
|
|
15
|
+
import type { ToolbarItem } from '@datalayer/primer-addons';
|
|
15
16
|
import '@datalayer/jupyter-lexical/style/index.css';
|
|
16
|
-
import '../
|
|
17
|
+
import '../lexical/lexical-theme.css';
|
|
17
18
|
export interface LexicalEditorProps {
|
|
18
19
|
content?: string;
|
|
19
20
|
serviceManager?: ServiceManager.IManager;
|
|
21
|
+
/** Optional extra toolbar items (e.g. AI actions from useChatInlineToolbarItems) */
|
|
22
|
+
extraItems?: ToolbarItem[];
|
|
23
|
+
/** Optional additional children to render inside the LexicalComposer */
|
|
24
|
+
children?: React.ReactNode;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
* Lexical Editor Component
|
|
@@ -34,9 +34,9 @@ import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
|
|
|
34
34
|
import { Box } from '@datalayer/primer-addons';
|
|
35
35
|
import { JupyterReactTheme, useJupyter } from '@datalayer/jupyter-react';
|
|
36
36
|
import { ComponentPickerMenuPlugin, JupyterCellPlugin, JupyterInputOutputPlugin, DraggableBlockPlugin, ImagesPlugin, HorizontalRulePlugin, EquationsPlugin, YouTubePlugin, AutoLinkPlugin, AutoEmbedPlugin, LexicalConfigProvider, LexicalStatePlugin, FloatingTextFormatToolbarPlugin, CodeActionMenuPlugin, ListMaxIndentLevelPlugin, } from '@datalayer/jupyter-lexical';
|
|
37
|
-
import { editorConfig } from '../
|
|
37
|
+
import { editorConfig } from '../lexical/editorConfig';
|
|
38
38
|
import '@datalayer/jupyter-lexical/style/index.css';
|
|
39
|
-
import '../
|
|
39
|
+
import '../lexical/lexical-theme.css';
|
|
40
40
|
const LEXICAL_ID = 'agent-runtime-lexical-editor';
|
|
41
41
|
const INITIAL_CONTENT = undefined;
|
|
42
42
|
/**
|
|
@@ -97,7 +97,7 @@ function SimpleKernelPluginsInner() {
|
|
|
97
97
|
*
|
|
98
98
|
* Rich text editor with Simple integration.
|
|
99
99
|
*/
|
|
100
|
-
export const LexicalEditor = ({ content = INITIAL_CONTENT, serviceManager, }) => {
|
|
100
|
+
export const LexicalEditor = ({ content = INITIAL_CONTENT, serviceManager, extraItems, children, }) => {
|
|
101
101
|
const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
|
|
102
102
|
const [_isLinkEditMode, setIsLinkEditMode] = useState(false);
|
|
103
103
|
const onRef = (_floatingAnchorElem) => {
|
|
@@ -115,5 +115,5 @@ export const LexicalEditor = ({ content = INITIAL_CONTENT, serviceManager, }) =>
|
|
|
115
115
|
padding: 3,
|
|
116
116
|
backgroundColor: 'canvas.default',
|
|
117
117
|
minHeight: '600px',
|
|
118
|
-
}, children: _jsx(LexicalConfigProvider, { lexicalId: LEXICAL_ID, serviceManager: serviceManager, children: _jsx(LexicalComposer, { initialConfig: editorConfig, children: _jsxs("div", { className: "lexical-editor-inner", ref: onRef, children: [_jsx(LexicalStatePlugin, {}), _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "lexical-editor-content", "aria-label": "Lexical Editor" }), ErrorBoundary: LexicalErrorBoundary }), _jsx(OnChangePlugin, { onChange: handleChange }), _jsx(HistoryPlugin, {}), _jsx(AutoFocusPlugin, {}), _jsx(ListPlugin, {}), _jsx(CheckListPlugin, {}), _jsx(LinkPlugin, {}), _jsx(AutoLinkPlugin, {}), _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), _jsx(MarkdownShortcutPlugin, { transformers: TRANSFORMERS }), _jsx(LoadContentPlugin, { content: content }), _jsx(CodeHighlightPlugin, {}), _jsx(ImagesPlugin, { captionsEnabled: false }), _jsx(HorizontalRulePlugin, {}), _jsx(EquationsPlugin, {}), _jsx(YouTubePlugin, {}), _jsx(AutoEmbedPlugin, {}), _jsx(JupyterCellPlugin, {}), _jsx(JupyterReactTheme, { children: _jsx(SimpleKernelPluginsInner, {}) }), floatingAnchorElem && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem, setIsLinkEditMode: setIsLinkEditMode }), _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem })] }))] }) }) }) }));
|
|
118
|
+
}, children: _jsx(LexicalConfigProvider, { lexicalId: LEXICAL_ID, serviceManager: serviceManager, children: _jsx(LexicalComposer, { initialConfig: editorConfig, children: _jsxs("div", { className: "lexical-editor-inner", ref: onRef, children: [_jsx(LexicalStatePlugin, {}), _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "lexical-editor-content", "aria-label": "Lexical Editor" }), ErrorBoundary: LexicalErrorBoundary }), _jsx(OnChangePlugin, { onChange: handleChange }), _jsx(HistoryPlugin, {}), _jsx(AutoFocusPlugin, {}), _jsx(ListPlugin, {}), _jsx(CheckListPlugin, {}), _jsx(LinkPlugin, {}), _jsx(AutoLinkPlugin, {}), _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), _jsx(MarkdownShortcutPlugin, { transformers: TRANSFORMERS }), _jsx(LoadContentPlugin, { content: content }), _jsx(CodeHighlightPlugin, {}), _jsx(ImagesPlugin, { captionsEnabled: false }), _jsx(HorizontalRulePlugin, {}), _jsx(EquationsPlugin, {}), _jsx(YouTubePlugin, {}), _jsx(AutoEmbedPlugin, {}), _jsx(JupyterCellPlugin, {}), _jsx(JupyterReactTheme, { children: _jsx(SimpleKernelPluginsInner, {}) }), floatingAnchorElem && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem, setIsLinkEditMode: setIsLinkEditMode, extraItems: extraItems }), _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem })] })), children] }) }) }) }));
|
|
119
119
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ServiceManager } from '@jupyterlab/services';
|
|
3
|
-
import { type McpServerSelection } from '
|
|
3
|
+
import { type McpServerSelection } from '../../components/McpServerManager';
|
|
4
4
|
export interface MainContentProps {
|
|
5
5
|
showNotebook: boolean;
|
|
6
6
|
timeTravel: number;
|
|
@@ -9,9 +9,9 @@ import { Box } from '@datalayer/primer-addons';
|
|
|
9
9
|
import { JupyterReactTheme, Viewer } from '@datalayer/jupyter-react';
|
|
10
10
|
import { TimeTravel } from './TimeTravel';
|
|
11
11
|
import { LexicalEditor } from './LexicalEditor';
|
|
12
|
-
import { McpServerManager } from '
|
|
13
|
-
import matplotlib from '../
|
|
14
|
-
import emptyNotebook from '../
|
|
12
|
+
import { McpServerManager, } from '../../components/McpServerManager';
|
|
13
|
+
import matplotlib from '../stores/notebooks/NotebookExample2.ipynb.json';
|
|
14
|
+
import emptyNotebook from '../stores/notebooks/Empty.ipynb.json';
|
|
15
15
|
/**
|
|
16
16
|
* Main Content Component
|
|
17
17
|
*
|
|
@@ -30,7 +30,8 @@ export const MainContent = ({ showNotebook, timeTravel, onTimeTravelChange, rich
|
|
|
30
30
|
}
|
|
31
31
|
else if (notebookFile) {
|
|
32
32
|
// Dynamically import the notebook based on the file name
|
|
33
|
-
import(
|
|
33
|
+
import(
|
|
34
|
+
/* webpackIgnore: true */ /* @vite-ignore */ `../stores/agents/${notebookFile}`)
|
|
34
35
|
.then(module => {
|
|
35
36
|
setNotebookData(module.default);
|
|
36
37
|
})
|
|
@@ -46,7 +47,8 @@ export const MainContent = ({ showNotebook, timeTravel, onTimeTravelChange, rich
|
|
|
46
47
|
React.useEffect(() => {
|
|
47
48
|
if (lexicalFile && !isNewAgent) {
|
|
48
49
|
// Dynamically import the lexical file based on the file name
|
|
49
|
-
import(
|
|
50
|
+
import(
|
|
51
|
+
/* webpackIgnore: true */ /* @vite-ignore */ `../stores/agents/${lexicalFile}`)
|
|
50
52
|
.then(module => {
|
|
51
53
|
// Convert the JSON to a string if needed
|
|
52
54
|
setLexicalContent(typeof module.default === 'string'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { MockFileBrowser } from './MockFileBrowser';
|
|
2
|
+
export type { MockFileBrowserProps } from './MockFileBrowser';
|
|
3
|
+
export { MainContent } from './MainContent';
|
|
4
|
+
export type { MainContentProps } from './MainContent';
|
|
5
|
+
export { SessionTabs } from './SessionTabs';
|
|
6
|
+
export type { SessionTabsProps, Session } from './SessionTabs';
|
|
7
|
+
export { Header } from './Header';
|
|
8
|
+
export type { HeaderProps } from './Header';
|
|
9
|
+
export { HeaderControls } from './HeaderControls';
|
|
10
|
+
export type { HeaderControlsProps } from './HeaderControls';
|
|
11
|
+
export { FooterMetrics } from './FooterMetrics';
|
|
12
|
+
export type { FooterMetricsProps } from './FooterMetrics';
|
|
13
|
+
export { TimeTravel } from './TimeTravel';
|
|
14
|
+
export type { TimeTravelProps } from './TimeTravel';
|
|
15
|
+
export { LexicalEditor } from './LexicalEditor';
|
|
16
|
+
export type { LexicalEditorProps } from './LexicalEditor';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
// Example/layout components
|
|
6
|
+
export { MockFileBrowser } from './MockFileBrowser';
|
|
7
|
+
export { MainContent } from './MainContent';
|
|
8
|
+
export { SessionTabs } from './SessionTabs';
|
|
9
|
+
export { Header } from './Header';
|
|
10
|
+
export { HeaderControls } from './HeaderControls';
|
|
11
|
+
export { FooterMetrics } from './FooterMetrics';
|
|
12
|
+
export { TimeTravel } from './TimeTravel';
|
|
13
|
+
export { LexicalEditor } from './LexicalEditor';
|
|
@@ -16,7 +16,7 @@ export const EXAMPLES = {
|
|
|
16
16
|
AgUiSharedStateExample: () => import('./AgUiSharedStateExample'),
|
|
17
17
|
AgUiToolsBasedGenUIExample: () => import('./AgUiToolsBasedGenUIExample'),
|
|
18
18
|
AgentRuntimeCustomExample: () => import('./AgentRuntimeCustomExample'),
|
|
19
|
-
|
|
19
|
+
AgentRuntimeFormExample: () => import('./AgentRuntimeFormExample'),
|
|
20
20
|
AgentRuntimeLexicalSidebarExample: () => import('./AgentRuntimeLexicalSidebarExample'),
|
|
21
21
|
AgentRuntimeNotebookExample: () => import('./AgentRuntimeNotebookExample'),
|
|
22
22
|
AgentRuntimeNotebookSidebarExample: () => import('./AgentRuntimeNotebookSidebarExample'),
|
|
@@ -24,6 +24,7 @@ export const EXAMPLES = {
|
|
|
24
24
|
// AgentRuntimeLexical2Example: () =>
|
|
25
25
|
// import('./AgentRuntimeLexical2Example'),
|
|
26
26
|
AgentRuntimeStandaloneExample: () => import('./AgentRuntimeStandaloneExample'),
|
|
27
|
+
AgentRuntimeChatExample: () => import('./AgentRuntimeChatExample'),
|
|
27
28
|
CopilotKitNotebookExample: () => import('./CopilotKitNotebookExample'),
|
|
28
29
|
CopilotKitLexicalExample: () => import('./CopilotKitLexicalExample'),
|
|
29
30
|
DatalayerNotebookExample: () => import('./DatalayerNotebookExample'),
|
package/lib/examples/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { default as AgentRuntimeLexicalSidebarExample } from './AgentRuntimeLexi
|
|
|
12
12
|
export { default as AgentRuntimeNotebookExample } from './AgentRuntimeNotebookExample';
|
|
13
13
|
export { default as AgentRuntimeNotebookSidebarExample } from './AgentRuntimeNotebookSidebarExample';
|
|
14
14
|
export { default as AgentRuntimeStandaloneExample } from './AgentRuntimeStandaloneExample';
|
|
15
|
-
export { default as
|
|
15
|
+
export { default as AgentRuntimeFormExample } from './AgentRuntimeFormExample';
|
|
16
16
|
export { default as CopilotKitLexicalExample } from './CopilotKitLexicalExample';
|
|
17
17
|
export { default as CopilotKitNotebookExample } from './CopilotKitNotebookExample';
|
|
18
18
|
export { default as DatalayerNotebookExample } from './DatalayerNotebookExample';
|
package/lib/examples/index.js
CHANGED
|
@@ -16,7 +16,7 @@ export { default as AgentRuntimeLexicalSidebarExample } from './AgentRuntimeLexi
|
|
|
16
16
|
export { default as AgentRuntimeNotebookExample } from './AgentRuntimeNotebookExample';
|
|
17
17
|
export { default as AgentRuntimeNotebookSidebarExample } from './AgentRuntimeNotebookSidebarExample';
|
|
18
18
|
export { default as AgentRuntimeStandaloneExample } from './AgentRuntimeStandaloneExample';
|
|
19
|
-
export { default as
|
|
19
|
+
export { default as AgentRuntimeFormExample } from './AgentRuntimeFormExample';
|
|
20
20
|
export { default as CopilotKitLexicalExample } from './CopilotKitLexicalExample';
|
|
21
21
|
export { default as CopilotKitNotebookExample } from './CopilotKitNotebookExample';
|
|
22
22
|
export { default as DatalayerNotebookExample } from './DatalayerNotebookExample';
|
package/lib/examples/main.js
CHANGED
|
@@ -8,7 +8,7 @@ import { useEffect, useState } from 'react';
|
|
|
8
8
|
import { createRoot } from 'react-dom/client';
|
|
9
9
|
import { loadJupyterConfig, JupyterReactTheme, createServerSettings, setJupyterServerUrl, setJupyterServerToken, getJupyterServerUrl, getJupyterServerToken, } from '@datalayer/jupyter-react';
|
|
10
10
|
import { ServiceManager } from '@jupyterlab/services';
|
|
11
|
-
import { coreStore, iamStore, createDatalayerServiceManager, } from '@datalayer/core';
|
|
11
|
+
import { coreStore, iamStore, createDatalayerServiceManager, DatalayerThemeProvider, } from '@datalayer/core';
|
|
12
12
|
import { useChatStore } from '../components/chat/store';
|
|
13
13
|
import { OAuthCallback } from '../identity';
|
|
14
14
|
import { EXAMPLES } from './example-selector';
|
|
@@ -292,7 +292,7 @@ export const ExampleApp = () => {
|
|
|
292
292
|
if (serviceManager) {
|
|
293
293
|
exampleProps.serviceManager = serviceManager;
|
|
294
294
|
}
|
|
295
|
-
return (_jsx(
|
|
295
|
+
return (_jsx(DatalayerThemeProvider, { children: _jsxs("div", { style: { width: '100vw', height: '100vh', overflow: 'hidden' }, children: [_jsxs("div", { style: {
|
|
296
296
|
position: 'fixed',
|
|
297
297
|
top: 0,
|
|
298
298
|
left: 0,
|
|
@@ -1,26 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export type
|
|
3
|
-
export interface Agent {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
description: string;
|
|
7
|
-
author: string;
|
|
8
|
-
lastEdited: string;
|
|
9
|
-
screenshot: string;
|
|
10
|
-
status?: AgentStatus;
|
|
11
|
-
transport: Transport;
|
|
12
|
-
avatarUrl: string;
|
|
13
|
-
notebookFile: string;
|
|
14
|
-
lexicalFile: string;
|
|
15
|
-
stars: number;
|
|
16
|
-
notifications: number;
|
|
17
|
-
}
|
|
18
|
-
export type AgentsState = {
|
|
19
|
-
agents: readonly Agent[];
|
|
20
|
-
getAgentById: (id: string) => Agent | undefined;
|
|
21
|
-
updateAgentStatus: (id: string, status: AgentStatus) => void;
|
|
22
|
-
toggleAgentStatus: (id: string) => void;
|
|
23
|
-
};
|
|
1
|
+
import type { Agent, AgentStatus, AgentsState, Transport } from '../../types/Types';
|
|
2
|
+
export type { Agent, AgentStatus, AgentsState, Transport };
|
|
24
3
|
export declare const agentsStore: any;
|
|
25
4
|
export declare function useAgentsStore(): AgentsState;
|
|
26
5
|
export declare function useAgentsStore<T>(selector: (state: AgentsState) => T): T;
|
package/lib/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export * from './state';
|
|
|
3
3
|
export * from './runtime';
|
|
4
4
|
export * from './identity';
|
|
5
5
|
export * from './config';
|
|
6
|
-
export
|
|
6
|
+
export * from './specs';
|
|
7
|
+
export type { ConversationEntry, MCPServer, AgentSkillSpec, AgentSpec, AIModelRuntime, FrontendConfig, BuiltinTool, MCPServerTool, } from './types/Types';
|
package/lib/index.js
CHANGED