@datalayer/agent-runtimes 1.0.4 → 1.0.5
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 +34 -0
- package/lib/App.js +1 -1
- package/lib/agents/AgentDetails.d.ts +22 -1
- package/lib/agents/AgentDetails.js +34 -47
- package/lib/api/index.d.ts +0 -1
- package/lib/api/index.js +4 -2
- package/lib/chat/Chat.d.ts +5 -106
- package/lib/chat/Chat.js +4 -4
- package/lib/chat/ChatFloating.d.ts +7 -140
- package/lib/chat/ChatFloating.js +2 -2
- package/lib/chat/ChatPopupStandalone.d.ts +8 -47
- package/lib/chat/ChatPopupStandalone.js +3 -3
- package/lib/chat/ChatSidebar.d.ts +4 -69
- package/lib/chat/ChatSidebar.js +2 -2
- package/lib/chat/ChatStandalone.d.ts +4 -54
- package/lib/chat/ChatStandalone.js +3 -3
- package/lib/chat/base/ChatBase.js +1083 -157
- package/lib/chat/header/ChatHeaderBase.d.ts +11 -6
- package/lib/chat/header/ChatHeaderBase.js +18 -16
- package/lib/chat/indicators/McpStatusIndicator.d.ts +7 -4
- package/lib/chat/indicators/McpStatusIndicator.js +7 -32
- package/lib/chat/indicators/SandboxStatusIndicator.d.ts +4 -1
- package/lib/chat/indicators/SandboxStatusIndicator.js +9 -9
- package/lib/chat/indicators/SkillsStatusIndicator.d.ts +7 -0
- package/lib/chat/indicators/SkillsStatusIndicator.js +88 -0
- package/lib/chat/indicators/index.d.ts +1 -0
- package/lib/chat/indicators/index.js +1 -0
- package/lib/chat/messages/ChatMessageList.d.ts +1 -1
- package/lib/chat/messages/ChatMessageList.js +108 -113
- package/lib/chat/prompt/InputFooter.d.ts +19 -6
- package/lib/chat/prompt/InputFooter.js +71 -18
- package/lib/chat/prompt/InputPrompt.d.ts +3 -1
- package/lib/chat/prompt/InputPrompt.js +4 -4
- package/lib/chat/prompt/InputPromptFooter.js +1 -1
- package/lib/chat/prompt/InputPromptLexical.d.ts +3 -1
- package/lib/chat/prompt/InputPromptLexical.js +12 -5
- package/lib/chat/prompt/InputPromptText.d.ts +3 -1
- package/lib/chat/prompt/InputPromptText.js +2 -2
- package/lib/chat/tools/ToolApprovalBanner.js +1 -1
- package/lib/chat/tools/ToolCallDisplay.d.ts +3 -1
- package/lib/chat/tools/ToolCallDisplay.js +2 -2
- package/lib/chat/usage/TokenUsageBar.js +20 -2
- package/lib/client/AgentRuntimesClientContext.d.ts +53 -0
- package/lib/client/AgentRuntimesClientContext.js +55 -0
- package/lib/client/AgentsMixin.d.ts +0 -18
- package/lib/client/AgentsMixin.js +6 -30
- package/lib/client/IAgentRuntimesClient.d.ts +215 -0
- package/lib/client/IAgentRuntimesClient.js +5 -0
- package/lib/client/SdkAgentRuntimesClient.d.ts +151 -0
- package/lib/client/SdkAgentRuntimesClient.js +134 -0
- package/lib/client/index.d.ts +4 -1
- package/lib/client/index.js +3 -1
- package/lib/components/NotificationEventCard.js +5 -1
- package/lib/config/AgentConfiguration.js +3 -3
- package/lib/context/ContextDistribution.d.ts +3 -1
- package/lib/context/ContextDistribution.js +8 -27
- package/lib/context/ContextInspector.d.ts +3 -1
- package/lib/context/ContextInspector.js +19 -67
- package/lib/context/ContextPanel.d.ts +3 -1
- package/lib/context/ContextPanel.js +104 -64
- package/lib/context/ContextUsage.d.ts +3 -1
- package/lib/context/ContextUsage.js +3 -3
- package/lib/context/CostTracker.d.ts +9 -3
- package/lib/context/CostTracker.js +26 -47
- package/lib/context/CostUsageChart.d.ts +12 -0
- package/lib/context/CostUsageChart.js +378 -0
- package/lib/context/GraphFlowChart.d.ts +16 -0
- package/lib/context/GraphFlowChart.js +182 -0
- package/lib/context/TokenUsageChart.d.ts +8 -1
- package/lib/context/TokenUsageChart.js +349 -211
- package/lib/context/TurnGraphChart.d.ts +39 -0
- package/lib/context/TurnGraphChart.js +538 -0
- package/lib/context/otelWsPool.d.ts +20 -0
- package/lib/context/otelWsPool.js +69 -0
- package/lib/examples/A2UiComponentGalleryExample.d.ts +0 -17
- package/lib/examples/A2UiComponentGalleryExample.js +315 -522
- package/lib/examples/A2UiContactCardExample.d.ts +0 -18
- package/lib/examples/A2UiContactCardExample.js +154 -411
- package/lib/examples/A2UiRestaurantExample.d.ts +0 -30
- package/lib/examples/A2UiRestaurantExample.js +114 -212
- package/lib/examples/A2UiViewerExample.d.ts +0 -18
- package/lib/examples/A2UiViewerExample.js +283 -532
- package/lib/examples/AgUiBackendToolRenderingExample.js +1 -1
- package/lib/examples/AgUiHaikuGenUiExample.d.ts +1 -1
- package/lib/examples/AgUiHaikuGenUiExample.js +1 -1
- package/lib/examples/AgentCheckpointsExample.js +13 -27
- package/lib/examples/AgentCodemodeExample.d.ts +4 -6
- package/lib/examples/AgentCodemodeExample.js +591 -169
- package/lib/examples/AgentEvalsExample.js +12 -16
- package/lib/examples/AgentGuardrailsExample.js +370 -64
- package/lib/examples/AgentHooksExample.d.ts +3 -0
- package/lib/examples/AgentHooksExample.js +104 -0
- package/lib/examples/AgentMCPExample.d.ts +3 -0
- package/lib/examples/AgentMCPExample.js +480 -0
- package/lib/examples/AgentMemoryExample.js +13 -17
- package/lib/examples/AgentMonitoringExample.js +260 -199
- package/lib/examples/AgentNotificationsExample.js +49 -17
- package/lib/examples/AgentOtelExample.js +2 -3
- package/lib/examples/AgentOutputsExample.d.ts +11 -6
- package/lib/examples/AgentOutputsExample.js +382 -81
- package/lib/examples/AgentParametersExample.d.ts +3 -0
- package/lib/examples/AgentParametersExample.js +246 -0
- package/lib/examples/AgentSandboxExample.d.ts +2 -2
- package/lib/examples/AgentSandboxExample.js +68 -40
- package/lib/examples/AgentSkillsExample.js +91 -99
- package/lib/examples/{AgentspecExample.js → AgentSpecsExample.js} +10 -21
- package/lib/examples/AgentSubagentsExample.d.ts +14 -0
- package/lib/examples/AgentSubagentsExample.js +228 -0
- package/lib/examples/AgentToolApprovalsExample.js +29 -557
- package/lib/examples/AgentTriggersExample.js +819 -565
- package/lib/examples/ChatCustomExample.js +11 -24
- package/lib/examples/ChatExample.js +7 -24
- package/lib/examples/CopilotKitLexicalExample.js +2 -1
- package/lib/examples/CopilotKitNotebookExample.js +2 -1
- package/lib/examples/HomeExample.d.ts +15 -0
- package/lib/examples/HomeExample.js +77 -0
- package/lib/examples/Lexical2Example.js +4 -2
- package/lib/examples/{LexicalExample.d.ts → LexicalAgentExample.d.ts} +4 -4
- package/lib/examples/{LexicalExample.js → LexicalAgentExample.js} +65 -16
- package/lib/examples/{LexicalSidebarExample.d.ts → LexicalAgentSidebarExample.d.ts} +5 -5
- package/lib/examples/LexicalAgentSidebarExample.js +261 -0
- package/lib/examples/NotebookAgentExample.d.ts +9 -0
- package/lib/examples/NotebookAgentExample.js +192 -0
- package/lib/examples/{NotebookSidebarExample.d.ts → NotebookAgentSidebarExample.d.ts} +2 -2
- package/lib/examples/NotebookAgentSidebarExample.js +221 -0
- package/lib/examples/{DatalayerNotebookExample.d.ts → NotebookCollaborationExample.d.ts} +4 -4
- package/lib/examples/{DatalayerNotebookExample.js → NotebookCollaborationExample.js} +3 -3
- package/lib/examples/NotebookExample.d.ts +4 -7
- package/lib/examples/NotebookExample.js +14 -146
- package/lib/examples/components/AuthRequiredView.d.ts +6 -0
- package/lib/examples/components/AuthRequiredView.js +33 -0
- package/lib/examples/components/ExampleWrapper.d.ts +7 -0
- package/lib/examples/components/ExampleWrapper.js +25 -6
- package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.js +1 -1
- package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.js +1 -1
- package/lib/examples/{ag-ui → components}/haiku/index.d.ts +1 -1
- package/lib/examples/{ag-ui → components}/haiku/index.js +1 -1
- package/lib/examples/components/index.d.ts +3 -0
- package/lib/examples/components/index.js +4 -0
- package/lib/examples/{ag-ui → components}/weather/index.d.ts +1 -1
- package/lib/examples/{ag-ui → components}/weather/index.js +1 -1
- package/lib/examples/example-selector.d.ts +17 -4
- package/lib/examples/example-selector.js +107 -41
- package/lib/examples/index.d.ts +9 -6
- package/lib/examples/index.js +9 -6
- package/lib/examples/main.js +217 -27
- package/lib/examples/utils/a2ui.d.ts +18 -0
- package/lib/examples/utils/a2ui.js +69 -0
- package/lib/examples/utils/a2uiMarkdownProvider.d.ts +7 -0
- package/lib/examples/utils/a2uiMarkdownProvider.js +9 -0
- package/lib/examples/utils/agentId.d.ts +18 -0
- package/lib/examples/utils/agentId.js +54 -0
- package/lib/examples/utils/agents/earthquake-detector.json +11 -11
- package/lib/examples/utils/agents/sales-forecaster.json +11 -11
- package/lib/examples/utils/agents/social-post-generator.json +11 -11
- package/lib/examples/utils/agents/stock-market.json +11 -11
- package/lib/examples/utils/examplesStore.js +82 -27
- package/lib/hooks/index.d.ts +8 -8
- package/lib/hooks/index.js +7 -7
- package/lib/hooks/useA2A.d.ts +2 -3
- package/lib/hooks/useAIAgentsWebSocket.d.ts +43 -4
- package/lib/hooks/useAIAgentsWebSocket.js +118 -12
- package/lib/hooks/useAcp.d.ts +1 -2
- package/lib/hooks/useAgUi.d.ts +1 -1
- package/lib/hooks/{useAgents.d.ts → useAgentRuntimes.d.ts} +39 -2
- package/lib/hooks/{useAgents.js → useAgentRuntimes.js} +125 -15
- package/lib/hooks/useAgentsCatalog.js +1 -1
- package/lib/hooks/useAgentsService.d.ts +2 -2
- package/lib/hooks/useAgentsService.js +7 -7
- package/lib/hooks/useCheckpoints.js +1 -1
- package/lib/hooks/useConfig.d.ts +4 -1
- package/lib/hooks/useConfig.js +10 -3
- package/lib/hooks/useContextSnapshot.d.ts +9 -4
- package/lib/hooks/useContextSnapshot.js +9 -37
- package/lib/hooks/useMonitoring.js +3 -0
- package/lib/hooks/useSandbox.d.ts +20 -8
- package/lib/hooks/useSandbox.js +105 -40
- package/lib/hooks/useSkills.d.ts +23 -5
- package/lib/hooks/useSkills.js +94 -39
- package/lib/hooks/useToolApprovals.d.ts +60 -36
- package/lib/hooks/useToolApprovals.js +318 -69
- package/lib/hooks/useVercelAI.d.ts +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -0
- package/lib/inference/index.d.ts +0 -1
- package/lib/middleware/index.d.ts +0 -1
- package/lib/protocols/AGUIAdapter.js +6 -0
- package/lib/protocols/VercelAIAdapter.d.ts +7 -0
- package/lib/protocols/VercelAIAdapter.js +59 -7
- package/lib/specs/agents/agents.d.ts +10 -0
- package/lib/specs/agents/agents.js +2139 -262
- package/lib/specs/agents/index.js +3 -1
- package/lib/specs/envvars.d.ts +1 -0
- package/lib/specs/envvars.js +38 -20
- package/lib/specs/evals.js +6 -6
- package/lib/specs/events.d.ts +3 -10
- package/lib/specs/events.js +127 -84
- package/lib/specs/frontendTools.js +2 -2
- package/lib/specs/guardrails.d.ts +0 -7
- package/lib/specs/guardrails.js +240 -159
- package/lib/specs/index.d.ts +1 -0
- package/lib/specs/index.js +1 -0
- package/lib/specs/mcpServers.js +35 -6
- package/lib/specs/memory.d.ts +0 -2
- package/lib/specs/memory.js +4 -17
- package/lib/specs/models.js +25 -5
- package/lib/specs/notifications.js +102 -18
- package/lib/specs/outputs.js +15 -9
- package/lib/specs/personas.d.ts +41 -0
- package/lib/specs/personas.js +168 -0
- package/lib/specs/skills.d.ts +2 -1
- package/lib/specs/skills.js +41 -23
- package/lib/specs/teams/index.js +3 -1
- package/lib/specs/teams/teams.js +468 -348
- package/lib/specs/tools.js +4 -4
- package/lib/specs/triggers.js +61 -11
- package/lib/stores/agentRuntimeStore.d.ts +204 -0
- package/lib/stores/agentRuntimeStore.js +636 -0
- package/lib/stores/index.d.ts +1 -1
- package/lib/stores/index.js +1 -1
- package/lib/tools/adapters/copilotkit/lexicalHooks.d.ts +1 -2
- package/lib/tools/adapters/copilotkit/lexicalHooks.js +1 -3
- package/lib/tools/adapters/copilotkit/notebookHooks.d.ts +1 -2
- package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -3
- package/lib/tools/index.d.ts +0 -2
- package/lib/tools/index.js +0 -1
- package/lib/types/agentspecs.d.ts +50 -1
- package/lib/types/chat.d.ts +309 -8
- package/lib/types/context.d.ts +27 -0
- package/lib/types/cost.d.ts +2 -2
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +2 -0
- package/lib/types/mcp.d.ts +8 -0
- package/lib/types/models.d.ts +2 -2
- package/lib/types/personas.d.ts +25 -0
- package/lib/types/personas.js +5 -0
- package/lib/types/skills.d.ts +43 -1
- package/lib/types/stream.d.ts +110 -0
- package/lib/types/stream.js +36 -0
- package/lib/utils/utils.d.ts +9 -5
- package/lib/utils/utils.js +9 -5
- package/package.json +13 -9
- package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_events.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
- package/scripts/codegen/generate_agents.py +102 -6
- package/scripts/codegen/generate_events.py +35 -13
- package/scripts/codegen/generate_personas.py +319 -0
- package/scripts/codegen/generate_skills.py +9 -9
- package/scripts/sync-jupyter.sh +26 -7
- package/lib/api/tool-approvals.d.ts +0 -62
- package/lib/api/tool-approvals.js +0 -145
- package/lib/examples/LexicalSidebarExample.js +0 -163
- package/lib/examples/NotebookSidebarExample.js +0 -119
- package/lib/examples/NotebookSimpleExample.d.ts +0 -6
- package/lib/examples/NotebookSimpleExample.js +0 -22
- package/lib/examples/ag-ui/index.d.ts +0 -10
- package/lib/examples/ag-ui/index.js +0 -16
- package/lib/hooks/useAgentsRegistry.d.ts +0 -10
- package/lib/hooks/useAgentsRegistry.js +0 -20
- package/lib/stores/agentsStore.d.ts +0 -123
- package/lib/stores/agentsStore.js +0 -270
- /package/lib/examples/{AgentspecExample.d.ts → AgentSpecsExample.d.ts} +0 -0
- /package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.js +0 -0
|
@@ -1,14 +1,27 @@
|
|
|
1
|
+
export type ExampleLoader = () => Promise<{
|
|
2
|
+
default: React.ComponentType;
|
|
3
|
+
}>;
|
|
4
|
+
export interface ExampleEntry {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
tags: string[];
|
|
9
|
+
loader: ExampleLoader;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Central examples registry. Keep all example definitions in this list so
|
|
13
|
+
* the header dropdown and the home cards always stay in sync.
|
|
14
|
+
*/
|
|
15
|
+
export declare const EXAMPLE_ENTRIES: ExampleEntry[];
|
|
1
16
|
/**
|
|
2
17
|
* Registry of available examples with dynamic imports.
|
|
3
|
-
* Add new examples here to make them available in the example runner.
|
|
4
18
|
*/
|
|
5
|
-
export declare const EXAMPLES: Record<string,
|
|
6
|
-
default: React.ComponentType;
|
|
7
|
-
}>>;
|
|
19
|
+
export declare const EXAMPLES: Record<string, ExampleLoader>;
|
|
8
20
|
/**
|
|
9
21
|
* Get the list of available example names
|
|
10
22
|
*/
|
|
11
23
|
export declare function getExampleNames(): string[];
|
|
24
|
+
export declare function getExampleEntries(): ExampleEntry[];
|
|
12
25
|
/**
|
|
13
26
|
* Get the selected example based on environment variable
|
|
14
27
|
* Falls back to 'NotebookExample' if not specified or invalid
|
|
@@ -3,54 +3,120 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
/// <reference types="vite/client" />
|
|
6
|
+
const DISPLAY_NAME_EXCEPTIONS = [
|
|
7
|
+
[/\bAg Ui\b/g, 'AG-UI'],
|
|
8
|
+
[/\bA2 Ui\b/g, 'A2UI'],
|
|
9
|
+
[/\bCopilot Kit\b/g, 'CopilotKit'],
|
|
10
|
+
[/\bGen Ui\b/g, 'Gen UI'],
|
|
11
|
+
[/\bM C P\b/g, 'MCP'],
|
|
12
|
+
[/\bOtel\b/g, 'OTEL'],
|
|
13
|
+
[/\bAgent Specs\b/g, 'Agent Specifications'],
|
|
14
|
+
];
|
|
15
|
+
function humanizeExampleName(name) {
|
|
16
|
+
let result = name
|
|
17
|
+
.replace(/Example$/, '')
|
|
18
|
+
.replace(/([A-Z])/g, ' $1')
|
|
19
|
+
.replace(/^\s+/, '')
|
|
20
|
+
.trim();
|
|
21
|
+
for (const [pattern, replacement] of DISPLAY_NAME_EXCEPTIONS) {
|
|
22
|
+
result = result.replace(pattern, replacement);
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
function inferTags(id) {
|
|
27
|
+
const tags = new Set(['example']);
|
|
28
|
+
if (id.startsWith('Agent'))
|
|
29
|
+
tags.add('agent');
|
|
30
|
+
if (id.startsWith('AgUi'))
|
|
31
|
+
tags.add('ag-ui');
|
|
32
|
+
if (id.startsWith('A2Ui'))
|
|
33
|
+
tags.add('a2ui');
|
|
34
|
+
if (id.includes('Notebook'))
|
|
35
|
+
tags.add('notebook');
|
|
36
|
+
if (id.includes('Lexical'))
|
|
37
|
+
tags.add('lexical');
|
|
38
|
+
if (id.includes('Chat'))
|
|
39
|
+
tags.add('chat');
|
|
40
|
+
if (id.includes('Sandbox'))
|
|
41
|
+
tags.add('sandbox');
|
|
42
|
+
if (id.includes('Monitoring') || id.includes('Otel'))
|
|
43
|
+
tags.add('observability');
|
|
44
|
+
if (id.includes('Skills'))
|
|
45
|
+
tags.add('skills');
|
|
46
|
+
if (id.includes('Subagent'))
|
|
47
|
+
tags.add('subagents');
|
|
48
|
+
if (id.includes('MCP'))
|
|
49
|
+
tags.add('mcp');
|
|
50
|
+
return Array.from(tags);
|
|
51
|
+
}
|
|
52
|
+
function makeEntry(id, loader, description, tags) {
|
|
53
|
+
return {
|
|
54
|
+
id,
|
|
55
|
+
title: humanizeExampleName(id),
|
|
56
|
+
description,
|
|
57
|
+
tags: tags ?? inferTags(id),
|
|
58
|
+
loader,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Central examples registry. Keep all example definitions in this list so
|
|
63
|
+
* the header dropdown and the home cards always stay in sync.
|
|
64
|
+
*/
|
|
65
|
+
export const EXAMPLE_ENTRIES = [
|
|
66
|
+
makeEntry('HomeExample', () => import('./HomeExample'), 'Browse all available examples with search and quick navigation.', ['home', 'navigation']),
|
|
67
|
+
makeEntry('A2UiComponentGalleryExample', () => import('./A2UiComponentGalleryExample'), 'Gallery showcasing A2UI component patterns.'),
|
|
68
|
+
makeEntry('A2UiContactCardExample', () => import('./A2UiContactCardExample'), 'A2UI example rendering contact card interactions.'),
|
|
69
|
+
makeEntry('A2UiRestaurantExample', () => import('./A2UiRestaurantExample'), 'A2UI restaurant flow example.'),
|
|
70
|
+
makeEntry('A2UiViewerExample', () => import('./A2UiViewerExample'), 'A2UI viewer integration example.'),
|
|
71
|
+
makeEntry('AgUiAgenticExample', () => import('./AgUiAgenticExample'), 'AG-UI agentic workflow example.'),
|
|
72
|
+
makeEntry('AgUiBackendToolRenderingExample', () => import('./AgUiBackendToolRenderingExample'), 'AG-UI backend tool rendering example.'),
|
|
73
|
+
makeEntry('AgUiHaikuGenUiExample', () => import('./AgUiHaikuGenUiExample'), 'AG-UI generative UI Haiku example.'),
|
|
74
|
+
makeEntry('AgUiHumanInTheLoopExample', () => import('./AgUiHumanInTheLoopExample'), 'AG-UI human-in-the-loop approvals example.'),
|
|
75
|
+
makeEntry('AgUiSharedStateExample', () => import('./AgUiSharedStateExample'), 'AG-UI shared state synchronization example.'),
|
|
76
|
+
makeEntry('AgUiToolsBasedGenUiExample', () => import('./AgUiToolsBasedGenUiExample'), 'AG-UI tool-based generative UI example.'),
|
|
77
|
+
makeEntry('AgentSpecsExample', () => import('./AgentSpecsExample'), 'Configure and run agents from specs and transports.'),
|
|
78
|
+
makeEntry('CellSimpleExample', () => import('./CellSimpleExample'), 'Simple Jupyter cell integration example.'),
|
|
79
|
+
makeEntry('ChatCustomExample', () => import('./ChatCustomExample'), 'Custom chat experience composition example.'),
|
|
80
|
+
makeEntry('ChatExample', () => import('./ChatExample'), 'Baseline chat integration example.'),
|
|
81
|
+
makeEntry('ChatStandaloneExample', () => import('./ChatStandaloneExample'), 'Standalone chat component usage example.'),
|
|
82
|
+
makeEntry('CopilotKitLexicalExample', () => import('./CopilotKitLexicalExample'), 'CopilotKit integration with Lexical editor.'),
|
|
83
|
+
makeEntry('CopilotKitNotebookExample', () => import('./CopilotKitNotebookExample'), 'CopilotKit integration with notebook workflows.'),
|
|
84
|
+
makeEntry('AgentCheckpointsExample', () => import('./AgentCheckpointsExample'), 'Checkpoint and resume lifecycle for agents.'),
|
|
85
|
+
makeEntry('AgentCodemodeExample', () => import('./AgentCodemodeExample'), 'Code mode execution and tool orchestration example.'),
|
|
86
|
+
makeEntry('AgentEvalsExample', () => import('./AgentEvalsExample'), 'Evaluation workflows for agent outputs.'),
|
|
87
|
+
makeEntry('AgentGuardrailsExample', () => import('./AgentGuardrailsExample'), 'Guardrails and safety checks for agent runs.'),
|
|
88
|
+
makeEntry('AgentHooksExample', () => import('./AgentHooksExample'), 'Pre-hooks and post-hooks lifecycle execution example.'),
|
|
89
|
+
makeEntry('AgentToolApprovalsExample', () => import('./AgentToolApprovalsExample'), 'Tool approval workflows and manual decisions.'),
|
|
90
|
+
makeEntry('AgentMemoryExample', () => import('./AgentMemoryExample'), 'Memory-aware conversation and retrieval example.'),
|
|
91
|
+
makeEntry('AgentSkillsExample', () => import('./AgentSkillsExample'), 'Skills discovery, execution, and monitoring example.'),
|
|
92
|
+
makeEntry('AgentMCPExample', () => import('./AgentMCPExample'), 'MCP servers and toolset integration example.'),
|
|
93
|
+
makeEntry('AgentOtelExample', () => import('./AgentOtelExample'), 'OpenTelemetry instrumentation and traces example.'),
|
|
94
|
+
makeEntry('AgentSandboxExample', () => import('./AgentSandboxExample'), 'Sandbox execution variants and context controls.'),
|
|
95
|
+
makeEntry('AgentMonitoringExample', () => import('./AgentMonitoringExample'), 'Runtime monitoring and live metrics example.'),
|
|
96
|
+
makeEntry('AgentSubagentsExample', () => import('./AgentSubagentsExample'), 'Multi-agent delegation with subagents-pydantic-ai.'),
|
|
97
|
+
makeEntry('AgentNotificationsExample', () => import('./AgentNotificationsExample'), 'Notifications and event routing example.'),
|
|
98
|
+
makeEntry('AgentOutputsExample', () => import('./AgentOutputsExample'), 'Structured outputs and rendering patterns.'),
|
|
99
|
+
makeEntry('AgentParametersExample', () => import('./AgentParametersExample'), 'Launch-time parameterized agent creation with JSON schema.'),
|
|
100
|
+
makeEntry('AgentTriggersExample', () => import('./AgentTriggersExample'), 'Scheduled and one-shot trigger flows.'),
|
|
101
|
+
makeEntry('LexicalAgentExample', () => import('./LexicalAgentExample'), 'Lexical document integration example.'),
|
|
102
|
+
makeEntry('LexicalAgentSidebarExample', () => import('./LexicalAgentSidebarExample'), 'Lexical with sidebar orchestration example.'),
|
|
103
|
+
makeEntry('NotebookAgentExample', () => import('./NotebookAgentExample'), 'Notebook orchestration and runtime example.'),
|
|
104
|
+
makeEntry('NotebookAgentSidebarExample', () => import('./NotebookAgentSidebarExample'), 'Notebook plus sidebar controls example.'),
|
|
105
|
+
makeEntry('NotebookExample', () => import('./NotebookExample'), 'Minimal notebook integration example.'),
|
|
106
|
+
makeEntry('NotebookCollaborationExample', () => import('./NotebookCollaborationExample'), 'Notebook collaboration runtime integration example.'),
|
|
107
|
+
];
|
|
6
108
|
/**
|
|
7
109
|
* Registry of available examples with dynamic imports.
|
|
8
|
-
* Add new examples here to make them available in the example runner.
|
|
9
110
|
*/
|
|
10
|
-
export const EXAMPLES =
|
|
11
|
-
// Lexical2Example: () => import('./Lexical2Example'),
|
|
12
|
-
A2UiComponentGalleryExample: () => import('./A2UiComponentGalleryExample'),
|
|
13
|
-
A2UiContactCardExample: () => import('./A2UiContactCardExample'),
|
|
14
|
-
A2UiRestaurantExample: () => import('./A2UiRestaurantExample'),
|
|
15
|
-
A2UiViewerExample: () => import('./A2UiViewerExample'),
|
|
16
|
-
AgUiAgenticExample: () => import('./AgUiAgenticExample'),
|
|
17
|
-
AgUiBackendToolRenderingExample: () => import('./AgUiBackendToolRenderingExample'),
|
|
18
|
-
AgUiHaikuGenUiExample: () => import('./AgUiHaikuGenUiExample'),
|
|
19
|
-
AgUiHumanInTheLoopExample: () => import('./AgUiHumanInTheLoopExample'),
|
|
20
|
-
AgUiSharedStateExample: () => import('./AgUiSharedStateExample'),
|
|
21
|
-
AgUiToolsBasedGenUiExample: () => import('./AgUiToolsBasedGenUiExample'),
|
|
22
|
-
AgentspecExample: () => import('./AgentspecExample'),
|
|
23
|
-
CellSimpleExample: () => import('./CellSimpleExample'),
|
|
24
|
-
ChatCustomExample: () => import('./ChatCustomExample'),
|
|
25
|
-
ChatExample: () => import('./ChatExample'),
|
|
26
|
-
ChatStandaloneExample: () => import('./ChatStandaloneExample'),
|
|
27
|
-
CopilotKitLexicalExample: () => import('./CopilotKitLexicalExample'),
|
|
28
|
-
CopilotKitNotebookExample: () => import('./CopilotKitNotebookExample'),
|
|
29
|
-
DatalayerNotebookExample: () => import('./DatalayerNotebookExample'),
|
|
30
|
-
AgentCheckpointsExample: () => import('./AgentCheckpointsExample'),
|
|
31
|
-
AgentCodemodeExample: () => import('./AgentCodemodeExample'),
|
|
32
|
-
AgentEvalsExample: () => import('./AgentEvalsExample'),
|
|
33
|
-
AgentGuardrailsExample: () => import('./AgentGuardrailsExample'),
|
|
34
|
-
AgentToolApprovalsExample: () => import('./AgentToolApprovalsExample'),
|
|
35
|
-
AgentMemoryExample: () => import('./AgentMemoryExample'),
|
|
36
|
-
AgentSkillsExample: () => import('./AgentSkillsExample'),
|
|
37
|
-
AgentOtelExample: () => import('./AgentOtelExample'),
|
|
38
|
-
AgentSandboxExample: () => import('./AgentSandboxExample'),
|
|
39
|
-
AgentMonitoringExample: () => import('./AgentMonitoringExample'),
|
|
40
|
-
AgentNotificationsExample: () => import('./AgentNotificationsExample'),
|
|
41
|
-
AgentOutputsExample: () => import('./AgentOutputsExample'),
|
|
42
|
-
AgentTriggersExample: () => import('./AgentTriggersExample'),
|
|
43
|
-
LexicalExample: () => import('./LexicalExample'),
|
|
44
|
-
LexicalSidebarExample: () => import('./LexicalSidebarExample'),
|
|
45
|
-
NotebookExample: () => import('./NotebookExample'),
|
|
46
|
-
NotebookSidebarExample: () => import('./NotebookSidebarExample'),
|
|
47
|
-
NotebookSimpleExample: () => import('./NotebookSimpleExample'),
|
|
48
|
-
};
|
|
111
|
+
export const EXAMPLES = Object.fromEntries(EXAMPLE_ENTRIES.map(entry => [entry.id, entry.loader]));
|
|
49
112
|
/**
|
|
50
113
|
* Get the list of available example names
|
|
51
114
|
*/
|
|
52
115
|
export function getExampleNames() {
|
|
53
|
-
return
|
|
116
|
+
return EXAMPLE_ENTRIES.map(entry => entry.id);
|
|
117
|
+
}
|
|
118
|
+
export function getExampleEntries() {
|
|
119
|
+
return [...EXAMPLE_ENTRIES];
|
|
54
120
|
}
|
|
55
121
|
/**
|
|
56
122
|
* Get the selected example based on environment variable
|
package/lib/examples/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as AgentSpecsExample } from './AgentSpecsExample';
|
|
2
2
|
export { default as A2UiComponentGalleryExample } from './A2UiComponentGalleryExample';
|
|
3
3
|
export { default as A2UiContactCardExample } from './A2UiContactCardExample';
|
|
4
4
|
export { default as A2UiRestaurantExample } from './A2UiRestaurantExample';
|
|
@@ -14,21 +14,24 @@ export { default as ChatStandaloneExample } from './ChatStandaloneExample';
|
|
|
14
14
|
export { default as CopilotKitLexicalExample } from './CopilotKitLexicalExample';
|
|
15
15
|
export { default as CopilotKitNotebookExample } from './CopilotKitNotebookExample';
|
|
16
16
|
export { default as CustomExample } from './ChatCustomExample';
|
|
17
|
-
export { default as
|
|
17
|
+
export { default as NotebookCollaborationExample } from './NotebookCollaborationExample';
|
|
18
18
|
export { default as AgentCheckpointsExample } from './AgentCheckpointsExample';
|
|
19
19
|
export { default as AgentCodemodeExample } from './AgentCodemodeExample';
|
|
20
20
|
export { default as AgentEvalsExample } from './AgentEvalsExample';
|
|
21
21
|
export { default as AgentGuardrailsExample } from './AgentGuardrailsExample';
|
|
22
|
+
export { default as AgentHooksExample } from './AgentHooksExample';
|
|
22
23
|
export { default as AgentToolApprovalsExample } from './AgentToolApprovalsExample';
|
|
23
24
|
export { default as AgentMemoryExample } from './AgentMemoryExample';
|
|
24
25
|
export { default as AgentOtelExample } from './AgentOtelExample';
|
|
26
|
+
export { default as AgentMCPExample } from './AgentMCPExample';
|
|
25
27
|
export { default as AgentMonitoringExample } from './AgentMonitoringExample';
|
|
26
28
|
export { default as AgentNotificationsExample } from './AgentNotificationsExample';
|
|
27
29
|
export { default as AgentOutputsExample } from './AgentOutputsExample';
|
|
30
|
+
export { default as AgentParametersExample } from './AgentParametersExample';
|
|
28
31
|
export { default as AgentTriggersExample } from './AgentTriggersExample';
|
|
29
32
|
export { default as Lexical2Example } from './Lexical2Example';
|
|
30
|
-
export { default as
|
|
31
|
-
export { default as
|
|
33
|
+
export { default as LexicalAgentExample } from './LexicalAgentExample';
|
|
34
|
+
export { default as LexicalAgentSidebarExample } from './LexicalAgentSidebarExample';
|
|
35
|
+
export { default as NotebookAgentExample } from './NotebookAgentExample';
|
|
36
|
+
export { default as NotebookAgentSidebarExample } from './NotebookAgentSidebarExample';
|
|
32
37
|
export { default as NotebookExample } from './NotebookExample';
|
|
33
|
-
export { default as NotebookSidebarExample } from './NotebookSidebarExample';
|
|
34
|
-
export { default as NotebookSimpleExample } from './NotebookSimpleExample';
|
package/lib/examples/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
export { default as
|
|
5
|
+
export { default as AgentSpecsExample } from './AgentSpecsExample';
|
|
6
6
|
export { default as A2UiComponentGalleryExample } from './A2UiComponentGalleryExample';
|
|
7
7
|
export { default as A2UiContactCardExample } from './A2UiContactCardExample';
|
|
8
8
|
export { default as A2UiRestaurantExample } from './A2UiRestaurantExample';
|
|
@@ -18,21 +18,24 @@ export { default as ChatStandaloneExample } from './ChatStandaloneExample';
|
|
|
18
18
|
export { default as CopilotKitLexicalExample } from './CopilotKitLexicalExample';
|
|
19
19
|
export { default as CopilotKitNotebookExample } from './CopilotKitNotebookExample';
|
|
20
20
|
export { default as CustomExample } from './ChatCustomExample';
|
|
21
|
-
export { default as
|
|
21
|
+
export { default as NotebookCollaborationExample } from './NotebookCollaborationExample';
|
|
22
22
|
export { default as AgentCheckpointsExample } from './AgentCheckpointsExample';
|
|
23
23
|
export { default as AgentCodemodeExample } from './AgentCodemodeExample';
|
|
24
24
|
export { default as AgentEvalsExample } from './AgentEvalsExample';
|
|
25
25
|
export { default as AgentGuardrailsExample } from './AgentGuardrailsExample';
|
|
26
|
+
export { default as AgentHooksExample } from './AgentHooksExample';
|
|
26
27
|
export { default as AgentToolApprovalsExample } from './AgentToolApprovalsExample';
|
|
27
28
|
export { default as AgentMemoryExample } from './AgentMemoryExample';
|
|
28
29
|
export { default as AgentOtelExample } from './AgentOtelExample';
|
|
30
|
+
export { default as AgentMCPExample } from './AgentMCPExample';
|
|
29
31
|
export { default as AgentMonitoringExample } from './AgentMonitoringExample';
|
|
30
32
|
export { default as AgentNotificationsExample } from './AgentNotificationsExample';
|
|
31
33
|
export { default as AgentOutputsExample } from './AgentOutputsExample';
|
|
34
|
+
export { default as AgentParametersExample } from './AgentParametersExample';
|
|
32
35
|
export { default as AgentTriggersExample } from './AgentTriggersExample';
|
|
33
36
|
export { default as Lexical2Example } from './Lexical2Example';
|
|
34
|
-
export { default as
|
|
35
|
-
export { default as
|
|
37
|
+
export { default as LexicalAgentExample } from './LexicalAgentExample';
|
|
38
|
+
export { default as LexicalAgentSidebarExample } from './LexicalAgentSidebarExample';
|
|
39
|
+
export { default as NotebookAgentExample } from './NotebookAgentExample';
|
|
40
|
+
export { default as NotebookAgentSidebarExample } from './NotebookAgentSidebarExample';
|
|
36
41
|
export { default as NotebookExample } from './NotebookExample';
|
|
37
|
-
export { default as NotebookSidebarExample } from './NotebookSidebarExample';
|
|
38
|
-
export { default as NotebookSimpleExample } from './NotebookSimpleExample';
|
package/lib/examples/main.js
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
/*
|
|
3
3
|
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
6
|
/// <reference types="vite/client" />
|
|
7
|
-
import { useEffect, useState } from 'react';
|
|
7
|
+
import { useCallback, useEffect, useMemo, 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 { DatalayerThemeProvider,
|
|
11
|
+
import { DatalayerThemeProvider, DatalayerLogoText, getLogoColors, themeConfigs, Box, } from '@datalayer/primer-addons';
|
|
12
|
+
import { HomeIcon, SignInIcon, SignOutIcon } from '@primer/octicons-react';
|
|
13
|
+
import { Button } from '@primer/react';
|
|
12
14
|
import { AppearanceControlsWithStore } from '@datalayer/primer-addons/lib/components/appearance';
|
|
13
15
|
import { coreStore, iamStore, createDatalayerServiceManager, } from '@datalayer/core';
|
|
14
|
-
import {
|
|
16
|
+
import { SignInSimple } from '@datalayer/core/lib/views/iam';
|
|
17
|
+
import { UserBadge } from '@datalayer/core/lib/views/profile';
|
|
18
|
+
import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
|
|
19
|
+
import { agentRuntimeStore, useChatStore, useConversationStore, } from '../stores';
|
|
15
20
|
import { OAuthCallback } from '../identity';
|
|
16
|
-
import { EXAMPLES } from './example-selector';
|
|
21
|
+
import { EXAMPLES, getExampleEntries, } from './example-selector';
|
|
17
22
|
import { useExampleThemeStore } from './utils/themeStore';
|
|
18
23
|
import { ExampleWrapper } from './components/ExampleWrapper';
|
|
19
24
|
import nbformatExample from './utils/notebooks/NotebookExample1.ipynb.json';
|
|
@@ -60,7 +65,7 @@ const loadConfigurations = () => {
|
|
|
60
65
|
CLI: 0,
|
|
61
66
|
VSCode: 0,
|
|
62
67
|
},
|
|
63
|
-
position:
|
|
68
|
+
position: 'top',
|
|
64
69
|
tours: {},
|
|
65
70
|
},
|
|
66
71
|
events: [],
|
|
@@ -91,13 +96,15 @@ const loadConfigurations = () => {
|
|
|
91
96
|
}
|
|
92
97
|
}
|
|
93
98
|
};
|
|
94
|
-
const
|
|
99
|
+
const getExampleEntriesList = () => getExampleEntries();
|
|
100
|
+
const getInitialSearchQuery = () => {
|
|
101
|
+
const params = new URLSearchParams(window.location.search);
|
|
102
|
+
return (params.get('q') || '').trim();
|
|
103
|
+
};
|
|
95
104
|
// Check if we're on the notebook-only route
|
|
96
105
|
const isNotebookOnlyRoute = () => {
|
|
97
106
|
const path = window.location.pathname;
|
|
98
|
-
console.log('Current pathname:', path);
|
|
99
107
|
const isNotebookRoute = path === '/datalayer/notebook';
|
|
100
|
-
console.log('Is notebook-only route:', isNotebookRoute);
|
|
101
108
|
return isNotebookRoute;
|
|
102
109
|
};
|
|
103
110
|
// Check if we're handling an OAuth callback (code and state in URL params)
|
|
@@ -139,7 +146,6 @@ const NotebookOnlyApp = () => {
|
|
|
139
146
|
runUrl: configuration.runUrl,
|
|
140
147
|
token: configuration.token,
|
|
141
148
|
});
|
|
142
|
-
console.log('[NotebookOnlyApp] Created collaboration provider:', provider);
|
|
143
149
|
setCollaborationProvider(provider);
|
|
144
150
|
}
|
|
145
151
|
catch (error) {
|
|
@@ -193,11 +199,6 @@ const NotebookOnlyApp = () => {
|
|
|
193
199
|
return null;
|
|
194
200
|
}
|
|
195
201
|
const NOTEBOOK_ID = '01JZQRQ35GG871QQCZW9TB1A8J';
|
|
196
|
-
console.log('[NotebookOnlyApp] Rendering with:', {
|
|
197
|
-
hasServiceManager: !!serviceManager,
|
|
198
|
-
hasCollaborationProvider: !!collaborationProvider,
|
|
199
|
-
notebookId: NOTEBOOK_ID,
|
|
200
|
-
});
|
|
201
202
|
return (_jsx(JupyterReactTheme, { children: _jsx("div", { style: { width: '100vw', height: '100vh' }, children: _jsx(NotebookComponent, { id: NOTEBOOK_ID, height: "100vh", nbformat: nbformat, readonly: false, serviceManager: serviceManager, startDefaultKernel: true, collaborationProvider: collaborationProvider }) }) }));
|
|
202
203
|
};
|
|
203
204
|
// Main App component that loads and renders the selected example
|
|
@@ -207,7 +208,26 @@ export const ExampleApp = () => {
|
|
|
207
208
|
const [error, setError] = useState(null);
|
|
208
209
|
const [serviceManager, setServiceManager] = useState(null);
|
|
209
210
|
const [selectedExample, setSelectedExample] = useState(getDefaultExampleName());
|
|
211
|
+
const [searchQuery, setSearchQuery] = useState(getInitialSearchQuery());
|
|
210
212
|
const [isChangingExample, setIsChangingExample] = useState(false);
|
|
213
|
+
const filteredExampleEntries = useMemo(() => {
|
|
214
|
+
const normalized = searchQuery.trim().toLowerCase();
|
|
215
|
+
const all = getExampleEntriesList();
|
|
216
|
+
if (!normalized) {
|
|
217
|
+
return all;
|
|
218
|
+
}
|
|
219
|
+
return all.filter(entry => {
|
|
220
|
+
const haystack = [
|
|
221
|
+
entry.id,
|
|
222
|
+
entry.title,
|
|
223
|
+
entry.description,
|
|
224
|
+
entry.tags.join(' '),
|
|
225
|
+
]
|
|
226
|
+
.join(' ')
|
|
227
|
+
.toLowerCase();
|
|
228
|
+
return haystack.includes(normalized);
|
|
229
|
+
});
|
|
230
|
+
}, [searchQuery]);
|
|
211
231
|
const loadExample = async (exampleName, _manager) => {
|
|
212
232
|
try {
|
|
213
233
|
setIsChangingExample(true);
|
|
@@ -276,8 +296,75 @@ export const ExampleApp = () => {
|
|
|
276
296
|
const handleExampleChange = async (newExample) => {
|
|
277
297
|
if (newExample === selectedExample || !serviceManager)
|
|
278
298
|
return;
|
|
279
|
-
//
|
|
280
|
-
|
|
299
|
+
// 1) Unmount the current example FIRST so its useEffect cleanup hooks
|
|
300
|
+
// (e.g. AGUIAdapter.disconnect → /ag-ui/terminate, abort fetches,
|
|
301
|
+
// close runtime sandboxes) run against a still-valid store state.
|
|
302
|
+
setIsChangingExample(true);
|
|
303
|
+
setExampleComponent(null);
|
|
304
|
+
// Yield to React so the unmount actually commits before we wipe stores.
|
|
305
|
+
await new Promise(resolve => {
|
|
306
|
+
requestAnimationFrame(() => resolve());
|
|
307
|
+
});
|
|
308
|
+
// 2) Tear down any server-side agents created by the previous example.
|
|
309
|
+
// Each example caches its agent id in sessionStorage via
|
|
310
|
+
// `uniqueAgentId(baseName)` under key `agent-runtimes:agentId:<base>`.
|
|
311
|
+
// Delete those agents on the server and drop the cached ids so the
|
|
312
|
+
// next example (and a future re-entry into this one) boots fresh.
|
|
313
|
+
const agentBaseUrl = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
|
|
314
|
+
const token = useSimpleAuthStore.getState().token;
|
|
315
|
+
const agentIdKeys = [];
|
|
316
|
+
try {
|
|
317
|
+
for (let i = 0; i < sessionStorage.length; i++) {
|
|
318
|
+
const key = sessionStorage.key(i);
|
|
319
|
+
if (key && key.startsWith('agent-runtimes:agentId:')) {
|
|
320
|
+
agentIdKeys.push(key);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
// sessionStorage unavailable; skip teardown.
|
|
326
|
+
}
|
|
327
|
+
await Promise.all(agentIdKeys.map(async (key) => {
|
|
328
|
+
let agentId = null;
|
|
329
|
+
try {
|
|
330
|
+
agentId = sessionStorage.getItem(key);
|
|
331
|
+
}
|
|
332
|
+
catch {
|
|
333
|
+
/* ignore */
|
|
334
|
+
}
|
|
335
|
+
if (!agentId)
|
|
336
|
+
return;
|
|
337
|
+
try {
|
|
338
|
+
await fetch(`${agentBaseUrl}/api/v1/agents/${encodeURIComponent(agentId)}`, {
|
|
339
|
+
method: 'DELETE',
|
|
340
|
+
headers: token ? { Authorization: `Bearer ${token}` } : {},
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
// Best-effort teardown: ignore network / 404 errors.
|
|
345
|
+
}
|
|
346
|
+
try {
|
|
347
|
+
sessionStorage.removeItem(key);
|
|
348
|
+
}
|
|
349
|
+
catch {
|
|
350
|
+
/* ignore */
|
|
351
|
+
}
|
|
352
|
+
}));
|
|
353
|
+
// 3) Wipe every piece of in-process agent state so the next example boots
|
|
354
|
+
// with a clean slate (no leftover messages, threads, pending tool
|
|
355
|
+
// calls, runtime snapshots, monitoring caches, or sockets).
|
|
356
|
+
useChatStore.getState().reset();
|
|
357
|
+
useConversationStore.getState().clearAll();
|
|
358
|
+
agentRuntimeStore.getState().reset();
|
|
359
|
+
// 4) Drop the persisted slice from localStorage so a fresh example never
|
|
360
|
+
// rehydrates a previous example's agents / monitoring cache.
|
|
361
|
+
try {
|
|
362
|
+
localStorage.removeItem('agent-runtimes-storage');
|
|
363
|
+
}
|
|
364
|
+
catch {
|
|
365
|
+
// Ignore storage failures (e.g. private mode).
|
|
366
|
+
}
|
|
367
|
+
// 5) Load and mount the new example.
|
|
281
368
|
setSelectedExample(newExample);
|
|
282
369
|
localStorage.setItem('selectedExample', newExample);
|
|
283
370
|
await loadExample(newExample, serviceManager);
|
|
@@ -297,16 +384,42 @@ export const ExampleApp = () => {
|
|
|
297
384
|
if (serviceManager) {
|
|
298
385
|
exampleProps.serviceManager = serviceManager;
|
|
299
386
|
}
|
|
300
|
-
|
|
387
|
+
exampleProps.examples = filteredExampleEntries.filter(entry => entry.id !== 'HomeExample');
|
|
388
|
+
exampleProps.searchQuery = searchQuery;
|
|
389
|
+
exampleProps.onSearchChange = (value) => setSearchQuery(value);
|
|
390
|
+
exampleProps.onSelectExample = (name) => {
|
|
391
|
+
void handleExampleChange(name);
|
|
392
|
+
};
|
|
393
|
+
return (_jsx(ExampleAppThemed, { selectedExample: selectedExample, isChangingExample: isChangingExample, error: error, ExampleComponent: ExampleComponent, exampleProps: exampleProps, onExampleChange: handleExampleChange, availableExamples: getExampleEntriesList() }));
|
|
301
394
|
};
|
|
302
395
|
/**
|
|
303
396
|
* Inner shell that reads from the theme store and wires
|
|
304
397
|
* DatalayerThemeProvider + the header bar with selectors.
|
|
305
398
|
*/
|
|
306
|
-
const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleComponent, exampleProps, onExampleChange, }) => {
|
|
399
|
+
const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleComponent, exampleProps, onExampleChange, availableExamples, }) => {
|
|
307
400
|
const { colorMode, theme: themeVariant } = useExampleThemeStore();
|
|
308
401
|
const cfg = themeConfigs[themeVariant];
|
|
309
402
|
const logoColors = getLogoColors(themeVariant, colorMode);
|
|
403
|
+
const { token, setAuth, clearAuth } = useSimpleAuthStore();
|
|
404
|
+
const [showSignIn, setShowSignIn] = useState(false);
|
|
405
|
+
const syncTokenToIamStore = useCallback((newToken) => {
|
|
406
|
+
import('@datalayer/core/lib/state').then(({ iamStore: coreIamStore }) => {
|
|
407
|
+
coreIamStore.setState({ token: newToken });
|
|
408
|
+
});
|
|
409
|
+
}, []);
|
|
410
|
+
useEffect(() => {
|
|
411
|
+
// Keep iamStore aligned with persisted auth token on app load/refresh.
|
|
412
|
+
syncTokenToIamStore(token || undefined);
|
|
413
|
+
}, [token, syncTokenToIamStore]);
|
|
414
|
+
const handleHeaderSignIn = useCallback((newToken, handle) => {
|
|
415
|
+
setAuth(newToken, handle);
|
|
416
|
+
syncTokenToIamStore(newToken);
|
|
417
|
+
setShowSignIn(false);
|
|
418
|
+
}, [setAuth, syncTokenToIamStore]);
|
|
419
|
+
const handleHeaderLogout = useCallback(() => {
|
|
420
|
+
clearAuth();
|
|
421
|
+
syncTokenToIamStore(undefined);
|
|
422
|
+
}, [clearAuth, syncTokenToIamStore]);
|
|
310
423
|
return (_jsx(DatalayerThemeProvider, { colorMode: colorMode, theme: cfg.primerTheme, themeStyles: cfg.themeStyles, children: _jsxs(Box, { sx: {
|
|
311
424
|
width: '100vw',
|
|
312
425
|
height: '100vh',
|
|
@@ -328,7 +441,19 @@ const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleCo
|
|
|
328
441
|
bg: 'canvas.subtle',
|
|
329
442
|
borderBottom: '1px solid',
|
|
330
443
|
borderColor: 'border.default',
|
|
331
|
-
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsx(Box, { as: "
|
|
444
|
+
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsx(Box, { as: "button", onClick: () => void onExampleChange('HomeExample'), title: "Home", "aria-label": "Go to examples home", sx: {
|
|
445
|
+
display: 'inline-flex',
|
|
446
|
+
alignItems: 'center',
|
|
447
|
+
justifyContent: 'center',
|
|
448
|
+
width: '32px',
|
|
449
|
+
height: '32px',
|
|
450
|
+
border: '1px solid',
|
|
451
|
+
borderColor: 'border.default',
|
|
452
|
+
borderRadius: 2,
|
|
453
|
+
bg: 'canvas.default',
|
|
454
|
+
color: 'fg.default',
|
|
455
|
+
cursor: isChangingExample ? 'not-allowed' : 'pointer',
|
|
456
|
+
}, disabled: isChangingExample, children: _jsx(HomeIcon, { size: 16 }) }), _jsx(Box, { as: "select", value: selectedExample, onChange: (e) => onExampleChange(e.target.value), disabled: isChangingExample, sx: {
|
|
332
457
|
px: 2,
|
|
333
458
|
py: '6px',
|
|
334
459
|
fontSize: 1,
|
|
@@ -344,13 +469,81 @@ const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleCo
|
|
|
344
469
|
'&:focus-visible': {
|
|
345
470
|
boxShadow: '0 0 0 2px var(--bgColor-accent-muted, rgba(9,105,218,0.3))',
|
|
346
471
|
},
|
|
347
|
-
}, children:
|
|
348
|
-
.
|
|
349
|
-
|
|
472
|
+
}, children: (() => {
|
|
473
|
+
const home = availableExamples.find(e => e.id === 'HomeExample');
|
|
474
|
+
const rest = availableExamples.filter(e => e.id !== 'HomeExample');
|
|
475
|
+
// Classify each example into a named group.
|
|
476
|
+
const groupOf = (id) => {
|
|
477
|
+
if (id === 'AgentSpecsExample')
|
|
478
|
+
return 'Personas';
|
|
479
|
+
if (id.startsWith('A2Ui'))
|
|
480
|
+
return 'A2UI';
|
|
481
|
+
if (id.startsWith('AgUi'))
|
|
482
|
+
return 'AG-UI';
|
|
483
|
+
if (id.startsWith('CopilotKit'))
|
|
484
|
+
return 'CopilotKit';
|
|
485
|
+
if (id.startsWith('Agent'))
|
|
486
|
+
return 'Agent';
|
|
487
|
+
if (id.startsWith('Chat'))
|
|
488
|
+
return 'Chat';
|
|
489
|
+
if (id.startsWith('Lexical'))
|
|
490
|
+
return 'Lexical';
|
|
491
|
+
if (id.startsWith('Notebook') ||
|
|
492
|
+
id === 'NotebookCollaborationExample')
|
|
493
|
+
return 'Notebook';
|
|
494
|
+
return 'Cell';
|
|
495
|
+
};
|
|
496
|
+
const groupOrder = [
|
|
497
|
+
'Personas',
|
|
498
|
+
'A2UI',
|
|
499
|
+
'AG-UI',
|
|
500
|
+
'Agent',
|
|
501
|
+
'Chat',
|
|
502
|
+
'Lexical',
|
|
503
|
+
'Notebook',
|
|
504
|
+
'Cell',
|
|
505
|
+
'CopilotKit',
|
|
506
|
+
];
|
|
507
|
+
const grouped = new Map();
|
|
508
|
+
for (const ex of rest) {
|
|
509
|
+
const g = groupOf(ex.id);
|
|
510
|
+
if (!grouped.has(g))
|
|
511
|
+
grouped.set(g, []);
|
|
512
|
+
grouped.get(g).push(ex);
|
|
513
|
+
}
|
|
514
|
+
for (const list of grouped.values()) {
|
|
515
|
+
list.sort((a, b) => a.title.localeCompare(b.title));
|
|
516
|
+
}
|
|
517
|
+
const nodes = [];
|
|
518
|
+
if (home) {
|
|
519
|
+
nodes.push(_jsx("option", { value: home.id, children: home.title }, home.id));
|
|
520
|
+
}
|
|
521
|
+
let sepIndex = 0;
|
|
522
|
+
for (const g of groupOrder) {
|
|
523
|
+
const items = grouped.get(g);
|
|
524
|
+
if (!items || items.length === 0)
|
|
525
|
+
continue;
|
|
526
|
+
nodes.push(_jsxs("option", { disabled: true, value: `__sep_${sepIndex}`, children: ["\u2500\u2500\u2500\u2500\u2500\u2500 ", g, " \u2500\u2500\u2500\u2500\u2500\u2500"] }, `__sep_${sepIndex++}`));
|
|
527
|
+
for (const example of items) {
|
|
528
|
+
nodes.push(_jsx("option", { value: example.id, children: example.title }, example.id));
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return _jsx(_Fragment, { children: nodes });
|
|
532
|
+
})() }), isChangingExample && (_jsx(Box, { as: "span", sx: { color: 'fg.muted', fontSize: 0 }, children: "Loading\u2026" })), error && (_jsxs(Box, { as: "span", sx: { color: 'danger.fg', fontSize: 0 }, children: ["Error: ", error] }))] }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 3 }, children: [_jsx(AppearanceControlsWithStore, { useStore: useExampleThemeStore }), _jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: token ? (_jsxs(_Fragment, { children: [_jsx(UserBadge, { token: token, variant: "small" }), _jsx(Button, { size: "small", variant: "invisible", onClick: handleHeaderLogout, leadingVisual: SignOutIcon, sx: { color: 'fg.muted' }, children: "Sign out" })] })) : (_jsx(Button, { size: "small", variant: "invisible", onClick: () => setShowSignIn(true), leadingVisual: SignInIcon, sx: { color: 'fg.muted' }, children: "Sign in" })) }), _jsx(Box, { as: "a", href: "https://datalayer.ai", target: "_blank", rel: "noopener noreferrer", "aria-label": "Open Datalayer website", sx: { display: 'inline-flex', alignItems: 'center' }, children: _jsx(DatalayerLogoText, { size: 24, variant: themeVariant, colorMode: colorMode, primaryColor: logoColors.primary, secondaryColor: logoColors.secondary, textColor: logoColors.textColor, primaryGradient: logoColors.primaryGradient, secondaryGradient: logoColors.secondaryGradient, gradient: true }) })] })] }), showSignIn && !token && (_jsx(Box, { sx: {
|
|
533
|
+
position: 'fixed',
|
|
534
|
+
top: 60,
|
|
535
|
+
left: 0,
|
|
536
|
+
right: 0,
|
|
537
|
+
bottom: 0,
|
|
538
|
+
zIndex: 150,
|
|
539
|
+
bg: 'canvas.backdrop',
|
|
540
|
+
p: 3,
|
|
541
|
+
overflow: 'auto',
|
|
542
|
+
}, children: _jsxs(Box, { sx: { maxWidth: 640, mx: 'auto' }, children: [_jsx(SignInSimple, { onSignIn: handleHeaderSignIn, onApiKeySignIn: apiKey => handleHeaderSignIn(apiKey, 'api-key-user'), title: "Agent Runtimes Examples", description: "Sign in to run authenticated examples and tools.", leadingIcon: _jsx(HomeIcon, { size: 24 }) }), _jsx(Box, { sx: { mt: 2, display: 'flex', justifyContent: 'center' }, children: _jsx(Button, { size: "small", variant: "invisible", onClick: () => setShowSignIn(false), children: "Cancel" }) })] }) })), _jsx(Box, { sx: {
|
|
350
543
|
marginTop: '60px',
|
|
351
544
|
height: 'calc(100vh - 60px)',
|
|
352
545
|
overflow: 'hidden',
|
|
353
|
-
}, children: isChangingExample ? (_jsxs(Box, { sx: { p: 5, textAlign: 'center', color: 'fg.muted' }, children: [_jsxs("h3", { children: ["Loading ", selectedExample, "\u2026"] }), _jsx("p", { children: "Please wait while the example loads." })] })) : ExampleComponent ? (_jsx(ExampleWrapper, { children: _jsx(ExampleComponent, { ...exampleProps }) })) : null })] }) }));
|
|
546
|
+
}, children: isChangingExample ? (_jsxs(Box, { sx: { p: 5, textAlign: 'center', color: 'fg.muted' }, children: [_jsxs("h3", { children: ["Loading ", selectedExample, "\u2026"] }), _jsx("p", { children: "Please wait while the example loads." })] })) : ExampleComponent ? (_jsx(ExampleWrapper, { children: _jsx(ExampleComponent, { ...exampleProps }, selectedExample) }, selectedExample)) : null })] }) }));
|
|
354
547
|
};
|
|
355
548
|
// Mount the app - check route to determine which app to render
|
|
356
549
|
const root = document.getElementById('root');
|
|
@@ -359,15 +552,12 @@ if (root) {
|
|
|
359
552
|
(window.__agentRuntimesExamplesRoot = createRoot(root));
|
|
360
553
|
if (isOAuthCallback()) {
|
|
361
554
|
// Handle OAuth callback - render OAuthCallback component
|
|
362
|
-
console.log('Rendering OAuthCallback (popup flow)');
|
|
363
555
|
appRoot.render(_jsx(JupyterReactTheme, { children: _jsx(OAuthCallback, { autoClose: true, autoCloseDelay: 1000 }) }));
|
|
364
556
|
}
|
|
365
557
|
else if (isNotebookOnlyRoute()) {
|
|
366
|
-
console.log('Rendering NotebookOnlyApp');
|
|
367
558
|
appRoot.render(_jsx(NotebookOnlyApp, {}));
|
|
368
559
|
}
|
|
369
560
|
else {
|
|
370
|
-
console.log('Rendering ExampleApp');
|
|
371
561
|
appRoot.render(_jsx(ExampleApp, {}));
|
|
372
562
|
}
|
|
373
563
|
}
|