@datalayer/agent-runtimes 1.0.3 → 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 +35 -119
- 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 -104
- 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 +1118 -141
- 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 +110 -102
- 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 +48 -19
- package/lib/client/AgentsMixin.js +115 -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 +55 -26
- package/lib/components/OutputCard.js +21 -7
- package/lib/components/ToolApprovalCard.js +20 -2
- 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 +14 -34
- package/lib/examples/AgentCodemodeExample.d.ts +4 -6
- package/lib/examples/AgentCodemodeExample.js +591 -175
- package/lib/examples/AgentEvalsExample.js +13 -23
- package/lib/examples/AgentGuardrailsExample.js +371 -71
- 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 +14 -24
- package/lib/examples/AgentMonitoringExample.js +261 -206
- package/lib/examples/AgentNotificationsExample.js +50 -24
- package/lib/examples/AgentOtelExample.js +2 -3
- package/lib/examples/AgentOutputsExample.d.ts +11 -6
- package/lib/examples/AgentOutputsExample.js +383 -88
- 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 +69 -47
- package/lib/examples/AgentSkillsExample.js +92 -106
- 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 +30 -493
- package/lib/examples/AgentTriggersExample.js +1067 -246
- package/lib/examples/ChatCustomExample.js +11 -24
- package/lib/examples/ChatExample.js +9 -34
- 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/ErrorView.d.ts +14 -0
- package/lib/examples/components/ErrorView.js +20 -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 +5 -0
- package/lib/examples/components/index.js +5 -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.d.ts +1 -0
- package/lib/examples/main.js +218 -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 +9 -0
- package/lib/protocols/VercelAIAdapter.js +144 -26
- package/lib/shims/json5.d.ts +4 -0
- package/lib/shims/json5.js +8 -0
- package/lib/specs/agents/agents.d.ts +10 -0
- package/lib/specs/agents/agents.js +752 -24
- package/lib/specs/envvars.d.ts +1 -0
- package/lib/specs/envvars.js +11 -0
- package/lib/specs/events.d.ts +1 -0
- package/lib/specs/events.js +1 -0
- package/lib/specs/index.d.ts +1 -0
- package/lib/specs/index.js +1 -0
- 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 +23 -5
- package/lib/specs/tools.js +3 -0
- 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/types/tools.d.ts +2 -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 +106 -7
- package/scripts/codegen/generate_events.py +47 -17
- package/scripts/codegen/generate_personas.py +319 -0
- package/scripts/codegen/generate_skills.py +9 -9
- package/scripts/codegen/generate_tools.py +20 -0
- package/scripts/sync-jupyter.sh +26 -7
- package/style/primer-primitives.css +1 -6
- 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/scripts/codegen/__pycache__/generate_envvars.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_evals.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_guardrails.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_mcp_servers.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_memory.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_models.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_notifications.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_outputs.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_skills.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_teams.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_tools.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_triggers.cpython-313.pyc +0 -0
- /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,145 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Tool approvals API functions.
|
|
7
|
-
*
|
|
8
|
-
* Provides CRUD operations for agent tool approval requests.
|
|
9
|
-
* When an agent encounters a tool that requires human approval,
|
|
10
|
-
* a ToolApproval record is created that the user can approve or reject.
|
|
11
|
-
*
|
|
12
|
-
* @module api/tool-approvals
|
|
13
|
-
*/
|
|
14
|
-
import { requestDatalayerAPI } from '@datalayer/core/lib/api/DatalayerApi';
|
|
15
|
-
import { API_BASE_PATHS, DEFAULT_SERVICE_URLS, } from '@datalayer/core/lib/api/constants';
|
|
16
|
-
import { validateToken } from '@datalayer/core/lib/api/utils/validation';
|
|
17
|
-
/**
|
|
18
|
-
* List tool approvals with optional filters.
|
|
19
|
-
* @param token - Authentication token
|
|
20
|
-
* @param filters - Optional filters (agentId, status, toolName, limit, offset)
|
|
21
|
-
* @param baseUrl - Base URL
|
|
22
|
-
* @returns Promise resolving to list of tool approvals
|
|
23
|
-
*/
|
|
24
|
-
export const getToolApprovals = async (token, filters, baseUrl = DEFAULT_SERVICE_URLS.AI_AGENTS) => {
|
|
25
|
-
validateToken(token);
|
|
26
|
-
const params = new URLSearchParams();
|
|
27
|
-
if (filters?.agentId)
|
|
28
|
-
params.set('agent_id', filters.agentId);
|
|
29
|
-
if (filters?.status)
|
|
30
|
-
params.set('status', filters.status);
|
|
31
|
-
if (filters?.toolName)
|
|
32
|
-
params.set('tool_name', filters.toolName);
|
|
33
|
-
if (filters?.limit)
|
|
34
|
-
params.set('limit', String(filters.limit));
|
|
35
|
-
if (filters?.offset)
|
|
36
|
-
params.set('offset', String(filters.offset));
|
|
37
|
-
const query = params.toString() ? `?${params.toString()}` : '';
|
|
38
|
-
return requestDatalayerAPI({
|
|
39
|
-
url: `${baseUrl}${API_BASE_PATHS.AI_AGENTS}/tool-approvals${query}`,
|
|
40
|
-
method: 'GET',
|
|
41
|
-
token,
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Get a specific tool approval by ID.
|
|
46
|
-
* @param token - Authentication token
|
|
47
|
-
* @param id - Tool approval ID
|
|
48
|
-
* @param baseUrl - Base URL
|
|
49
|
-
*/
|
|
50
|
-
export const getToolApproval = async (token, id, baseUrl = DEFAULT_SERVICE_URLS.AI_AGENTS) => {
|
|
51
|
-
validateToken(token);
|
|
52
|
-
return requestDatalayerAPI({
|
|
53
|
-
url: `${baseUrl}${API_BASE_PATHS.AI_AGENTS}/tool-approvals/${encodeURIComponent(id)}`,
|
|
54
|
-
method: 'GET',
|
|
55
|
-
token,
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Approve a pending tool request.
|
|
60
|
-
* @param token - Authentication token
|
|
61
|
-
* @param id - Tool approval ID
|
|
62
|
-
* @param note - Optional note explaining the approval
|
|
63
|
-
* @param baseUrl - Base URL
|
|
64
|
-
*/
|
|
65
|
-
export const approveToolRequest = async (token, id, note, baseUrl = DEFAULT_SERVICE_URLS.AI_AGENTS) => {
|
|
66
|
-
validateToken(token);
|
|
67
|
-
await requestDatalayerAPI({
|
|
68
|
-
url: `${baseUrl}${API_BASE_PATHS.AI_AGENTS}/tool-approvals/${encodeURIComponent(id)}/approve`,
|
|
69
|
-
method: 'POST',
|
|
70
|
-
body: { note },
|
|
71
|
-
token,
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Reject a pending tool request.
|
|
76
|
-
* @param token - Authentication token
|
|
77
|
-
* @param id - Tool approval ID
|
|
78
|
-
* @param note - Optional note explaining the rejection
|
|
79
|
-
* @param baseUrl - Base URL
|
|
80
|
-
*/
|
|
81
|
-
export const rejectToolRequest = async (token, id, note, baseUrl = DEFAULT_SERVICE_URLS.AI_AGENTS) => {
|
|
82
|
-
validateToken(token);
|
|
83
|
-
await requestDatalayerAPI({
|
|
84
|
-
url: `${baseUrl}${API_BASE_PATHS.AI_AGENTS}/tool-approvals/${encodeURIComponent(id)}/reject`,
|
|
85
|
-
method: 'POST',
|
|
86
|
-
body: { note },
|
|
87
|
-
token,
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Mark a tool approval as read.
|
|
92
|
-
* @param token - Authentication token
|
|
93
|
-
* @param id - Tool approval ID
|
|
94
|
-
* @param baseUrl - Base URL
|
|
95
|
-
*/
|
|
96
|
-
export const markToolApprovalRead = async (token, id, baseUrl = DEFAULT_SERVICE_URLS.AI_AGENTS) => {
|
|
97
|
-
validateToken(token);
|
|
98
|
-
await requestDatalayerAPI({
|
|
99
|
-
url: `${baseUrl}${API_BASE_PATHS.AI_AGENTS}/tool-approvals/${encodeURIComponent(id)}/mark-read`,
|
|
100
|
-
method: 'POST',
|
|
101
|
-
token,
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Mark a tool approval as unread.
|
|
106
|
-
* @param token - Authentication token
|
|
107
|
-
* @param id - Tool approval ID
|
|
108
|
-
* @param baseUrl - Base URL
|
|
109
|
-
*/
|
|
110
|
-
export const markToolApprovalUnread = async (token, id, baseUrl = DEFAULT_SERVICE_URLS.AI_AGENTS) => {
|
|
111
|
-
validateToken(token);
|
|
112
|
-
await requestDatalayerAPI({
|
|
113
|
-
url: `${baseUrl}${API_BASE_PATHS.AI_AGENTS}/tool-approvals/${encodeURIComponent(id)}/mark-unread`,
|
|
114
|
-
method: 'POST',
|
|
115
|
-
token,
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* Delete a tool approval.
|
|
120
|
-
* @param token - Authentication token
|
|
121
|
-
* @param id - Tool approval ID
|
|
122
|
-
* @param baseUrl - Base URL
|
|
123
|
-
*/
|
|
124
|
-
export const deleteToolApproval = async (token, id, baseUrl = DEFAULT_SERVICE_URLS.AI_AGENTS) => {
|
|
125
|
-
validateToken(token);
|
|
126
|
-
await requestDatalayerAPI({
|
|
127
|
-
url: `${baseUrl}${API_BASE_PATHS.AI_AGENTS}/tool-approvals/${encodeURIComponent(id)}`,
|
|
128
|
-
method: 'DELETE',
|
|
129
|
-
token,
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* Get count of pending tool approvals.
|
|
134
|
-
* @param token - Authentication token
|
|
135
|
-
* @param baseUrl - Base URL
|
|
136
|
-
* @returns Promise resolving to pending count
|
|
137
|
-
*/
|
|
138
|
-
export const getPendingApprovalCount = async (token, baseUrl = DEFAULT_SERVICE_URLS.AI_AGENTS) => {
|
|
139
|
-
validateToken(token);
|
|
140
|
-
return requestDatalayerAPI({
|
|
141
|
-
url: `${baseUrl}${API_BASE_PATHS.AI_AGENTS}/tool-approvals/pending/count`,
|
|
142
|
-
method: 'GET',
|
|
143
|
-
token,
|
|
144
|
-
});
|
|
145
|
-
};
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
-
* Distributed under the terms of the Modified BSD License.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Agent Runtime Lexical Example - Next generation chat with Lexical editor.
|
|
8
|
-
*
|
|
9
|
-
* This example demonstrates using the chat component with:
|
|
10
|
-
* - Lexical editor integration
|
|
11
|
-
* - Frontend tool execution
|
|
12
|
-
* - Multiple protocol support (AG-UI, A2A)
|
|
13
|
-
* - Middleware and extensions
|
|
14
|
-
*
|
|
15
|
-
* To run this example, create a .env file with:
|
|
16
|
-
* - VITE_DATALAYER_API_KEY: Get from https://datalayer.app/settings/iam/tokens
|
|
17
|
-
*
|
|
18
|
-
* @module examples/ChatLexicalExample
|
|
19
|
-
*/
|
|
20
|
-
import '@datalayer/jupyter-react/lib/css/PrismCss';
|
|
21
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
22
|
-
import { LexicalComposer } from '@lexical/react/LexicalComposer';
|
|
23
|
-
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
|
|
24
|
-
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
|
|
25
|
-
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
|
|
26
|
-
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
|
|
27
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
28
|
-
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
29
|
-
import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
|
|
30
|
-
import { MarkdownShortcutPlugin } from '@lexical/react/LexicalMarkdownShortcutPlugin';
|
|
31
|
-
import { TRANSFORMERS } from '@lexical/markdown';
|
|
32
|
-
import { registerCodeHighlighting } from '@lexical/code';
|
|
33
|
-
import { ListPlugin } from '@lexical/react/LexicalListPlugin';
|
|
34
|
-
import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
|
|
35
|
-
import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
|
|
36
|
-
import { Box } from '@datalayer/primer-addons';
|
|
37
|
-
import { useJupyter } from '@datalayer/jupyter-react';
|
|
38
|
-
import { ThemedJupyterProvider } from './utils/themedProvider';
|
|
39
|
-
import { ComponentPickerMenuPlugin, JupyterCellPlugin, JupyterInputOutputPlugin, DraggableBlockPlugin, ImagesPlugin, HorizontalRulePlugin, EquationsPlugin, YouTubePlugin, ExcalidrawPlugin, CollapsiblePlugin, AutoLinkPlugin, AutoEmbedPlugin, FloatingTextFormatToolbarPlugin, CodeActionMenuPlugin, ListMaxIndentLevelPlugin, LexicalConfigProvider, LexicalStatePlugin, TableCellResizerPlugin, TablePlugin, } from '@datalayer/jupyter-lexical';
|
|
40
|
-
import { ChatSidebar } from '../chat';
|
|
41
|
-
import { ChatInlinePlugin } from '../lexical/ChatInlinePlugin';
|
|
42
|
-
import { useChatInlineToolbarItems } from '../lexical/useChatInlineToolbarItems';
|
|
43
|
-
import { useLexicalTools } from '../tools/adapters/agent-runtimes/lexicalHooks';
|
|
44
|
-
import { editorConfig } from './lexical/editorConfig';
|
|
45
|
-
import '@datalayer/jupyter-lexical/style/index.css';
|
|
46
|
-
import './lexical/lexical-theme.css';
|
|
47
|
-
// Fixed lexical document ID
|
|
48
|
-
const LEXICAL_ID = 'chat-lexical-example';
|
|
49
|
-
// Default configuration
|
|
50
|
-
const DEFAULT_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
|
|
51
|
-
const DEFAULT_AGENT_ID = import.meta.env.VITE_AGENT_ID || 'agentic_chat';
|
|
52
|
-
/**
|
|
53
|
-
* Lexical plugin for code highlighting
|
|
54
|
-
*/
|
|
55
|
-
function CodeHighlightingPlugin() {
|
|
56
|
-
const [editor] = useLexicalComposerContext();
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
return registerCodeHighlighting(editor);
|
|
59
|
-
}, [editor]);
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
function LexicalEditor({ serviceManager }) {
|
|
63
|
-
const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
|
|
64
|
-
const [_isLinkEditMode, setIsLinkEditMode] = useState(false);
|
|
65
|
-
// AI actions registered as toolbar items
|
|
66
|
-
const { toolbarItems, isAiOpen, pendingPrompt, clearPendingPrompt, closeAi } = useChatInlineToolbarItems();
|
|
67
|
-
const onRef = (_floatingAnchorElem) => {
|
|
68
|
-
if (_floatingAnchorElem !== null) {
|
|
69
|
-
setFloatingAnchorElem(_floatingAnchorElem);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
// Handle editor changes
|
|
73
|
-
const onChange = useCallback((_editorState) => {
|
|
74
|
-
// Could persist state here
|
|
75
|
-
}, []);
|
|
76
|
-
return (_jsx(LexicalConfigProvider, { lexicalId: LEXICAL_ID, serviceManager: serviceManager, children: _jsxs(LexicalComposer, { initialConfig: editorConfig, children: [_jsx(LexicalStatePlugin, {}), _jsxs(Box, { sx: {
|
|
77
|
-
position: 'relative',
|
|
78
|
-
flex: 1,
|
|
79
|
-
display: 'flex',
|
|
80
|
-
flexDirection: 'column',
|
|
81
|
-
overflow: 'hidden',
|
|
82
|
-
}, children: [_jsx(RichTextPlugin, { contentEditable: _jsx("div", { ref: onRef, style: { flex: 1, display: 'flex', flexDirection: 'column' }, children: _jsx(ContentEditable, { className: "lexical-editor-content", style: {
|
|
83
|
-
flex: 1,
|
|
84
|
-
padding: '24px',
|
|
85
|
-
outline: 'none',
|
|
86
|
-
overflow: 'auto',
|
|
87
|
-
} }) }), placeholder: _jsx("div", { style: {
|
|
88
|
-
position: 'absolute',
|
|
89
|
-
top: '24px',
|
|
90
|
-
left: '24px',
|
|
91
|
-
color: 'var(--fgColor-muted)',
|
|
92
|
-
pointerEvents: 'none',
|
|
93
|
-
}, 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: {
|
|
94
|
-
type: 'ag-ui',
|
|
95
|
-
endpoint: `${DEFAULT_BASE_URL}/api/v1/examples/${DEFAULT_AGENT_ID}/`,
|
|
96
|
-
}, isOpen: isAiOpen, onClose: closeAi, pendingPrompt: pendingPrompt, onPendingPromptConsumed: clearPendingPrompt })] })] }) }));
|
|
97
|
-
}
|
|
98
|
-
export function ChatLexicalExampleInner({ serviceManager, }) {
|
|
99
|
-
// Get lexical tools for ChatSidebar
|
|
100
|
-
const tools = useLexicalTools(LEXICAL_ID);
|
|
101
|
-
// Build AG-UI protocol config
|
|
102
|
-
const protocolConfig = useMemo(() => {
|
|
103
|
-
return {
|
|
104
|
-
type: 'ag-ui',
|
|
105
|
-
endpoint: `${DEFAULT_BASE_URL}/api/v1/examples/${DEFAULT_AGENT_ID}/`,
|
|
106
|
-
agentId: DEFAULT_AGENT_ID,
|
|
107
|
-
};
|
|
108
|
-
}, []);
|
|
109
|
-
return (_jsx(_Fragment, { children: _jsxs(Box, { sx: {
|
|
110
|
-
height: 'calc(100vh - 70px)',
|
|
111
|
-
width: '100vw',
|
|
112
|
-
display: 'flex',
|
|
113
|
-
overflow: 'hidden',
|
|
114
|
-
}, children: [_jsxs(Box, { sx: {
|
|
115
|
-
flex: 1,
|
|
116
|
-
display: 'flex',
|
|
117
|
-
flexDirection: 'column',
|
|
118
|
-
overflow: 'hidden',
|
|
119
|
-
}, children: [_jsxs(Box, { sx: {
|
|
120
|
-
p: 3,
|
|
121
|
-
borderBottom: '1px solid',
|
|
122
|
-
borderColor: 'border.default',
|
|
123
|
-
bg: 'canvas.subtle',
|
|
124
|
-
}, children: [_jsx("h1", { style: { margin: 0, fontSize: '1.5rem' }, children: "Agent Runtime Lexical Sidebar Example" }), _jsx("p", { style: { margin: '8px 0 0', color: 'var(--fgColor-muted)' }, children: "Next generation chat with Lexical editor integration (NO Provider!)" })] }), _jsx(Box, { sx: {
|
|
125
|
-
flex: 1,
|
|
126
|
-
display: 'flex',
|
|
127
|
-
overflow: 'hidden',
|
|
128
|
-
bg: 'canvas.default',
|
|
129
|
-
}, children: _jsx(LexicalEditor, { serviceManager: serviceManager }) })] }), _jsx(ChatSidebar, { title: "AI Assistant", protocol: protocolConfig, position: "right", width: 400, showNewChatButton: true, showClearButton: true, showSettingsButton: true, defaultOpen: true, panelProps: {
|
|
130
|
-
protocol: protocolConfig,
|
|
131
|
-
frontendTools: tools,
|
|
132
|
-
useStore: true,
|
|
133
|
-
suggestions: [
|
|
134
|
-
{
|
|
135
|
-
title: '✍️ Help me write',
|
|
136
|
-
message: 'Can you help me write a document?',
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
title: '📝 Summarize text',
|
|
140
|
-
message: 'Can you summarize the content in the editor?',
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
title: '🔍 Proofread',
|
|
144
|
-
message: 'Can you proofread and improve my text?',
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
title: '💡 Generate ideas',
|
|
148
|
-
message: 'Can you suggest some ideas for content?',
|
|
149
|
-
},
|
|
150
|
-
],
|
|
151
|
-
} })] }) }));
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Main example component with Simple wrapper
|
|
155
|
-
*/
|
|
156
|
-
export function AgentRuntimeLexicalSidebarExample() {
|
|
157
|
-
return (_jsx(ThemedJupyterProvider, { children: _jsx(SimpleWrapper, {}) }));
|
|
158
|
-
}
|
|
159
|
-
function SimpleWrapper() {
|
|
160
|
-
const { serviceManager } = useJupyter();
|
|
161
|
-
return _jsx(ChatLexicalExampleInner, { serviceManager: serviceManager });
|
|
162
|
-
}
|
|
163
|
-
export default AgentRuntimeLexicalSidebarExample;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
-
* Distributed under the terms of the Modified BSD License.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Agent Runtime Notebook Example - Next generation chat with Jupyter Notebook.
|
|
8
|
-
*
|
|
9
|
-
* This example demonstrates using the chat component with:
|
|
10
|
-
* - Jupyter Notebook integration
|
|
11
|
-
* - Frontend tool execution for notebook operations
|
|
12
|
-
* - AG-UI protocol support
|
|
13
|
-
* - HITL (Human-in-the-loop) tool approval
|
|
14
|
-
*
|
|
15
|
-
* To run this example:
|
|
16
|
-
* 1. Start the agent-runtimes server: `npm run start:ag-ui`
|
|
17
|
-
* 2. Create a .env file with VITE_BASE_URL if not using defaults
|
|
18
|
-
*
|
|
19
|
-
* @module examples/ChatJupyterNotebookExample
|
|
20
|
-
*/
|
|
21
|
-
import { useMemo } from 'react';
|
|
22
|
-
import { Box } from '@datalayer/primer-addons';
|
|
23
|
-
import { Notebook, useJupyter } from '@datalayer/jupyter-react';
|
|
24
|
-
import { useNotebookTools } from '../tools/adapters/agent-runtimes/notebookHooks';
|
|
25
|
-
import { ThemedJupyterProvider } from './utils/themedProvider';
|
|
26
|
-
import { ChatSidebar } from '../chat';
|
|
27
|
-
import MatplotlibNotebook from './utils/notebooks/Matplotlib.ipynb.json';
|
|
28
|
-
// Fixed notebook ID
|
|
29
|
-
const NOTEBOOK_ID = 'chat-notebook-example';
|
|
30
|
-
// Use the imported Matplotlib notebook
|
|
31
|
-
const NOTEBOOK_CONTENT = MatplotlibNotebook;
|
|
32
|
-
// Default configuration
|
|
33
|
-
const DEFAULT_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
|
|
34
|
-
const DEFAULT_AGENT_ID = import.meta.env.VITE_AGENT_ID || 'agentic_chat';
|
|
35
|
-
function NotebookUI({ serviceManager }) {
|
|
36
|
-
if (!serviceManager) {
|
|
37
|
-
return (_jsx(Box, { sx: {
|
|
38
|
-
display: 'flex',
|
|
39
|
-
alignItems: 'center',
|
|
40
|
-
justifyContent: 'center',
|
|
41
|
-
height: '100%',
|
|
42
|
-
color: 'fg.muted',
|
|
43
|
-
}, children: "Loading Simple services..." }));
|
|
44
|
-
}
|
|
45
|
-
return (_jsx(Notebook, { nbformat: NOTEBOOK_CONTENT, id: NOTEBOOK_ID, serviceManager: serviceManager, height: "100%", cellSidebarMargin: 120, startDefaultKernel: true }));
|
|
46
|
-
}
|
|
47
|
-
export function AgentRuntimeNotebookExampleInner({ serviceManager, }) {
|
|
48
|
-
// Get notebook tools for ChatSidebar
|
|
49
|
-
const tools = useNotebookTools(NOTEBOOK_ID);
|
|
50
|
-
// Build AG-UI protocol config
|
|
51
|
-
const protocolConfig = useMemo(() => {
|
|
52
|
-
return {
|
|
53
|
-
type: 'ag-ui',
|
|
54
|
-
endpoint: `${DEFAULT_BASE_URL}/api/v1/examples/${DEFAULT_AGENT_ID}/`,
|
|
55
|
-
agentId: DEFAULT_AGENT_ID,
|
|
56
|
-
};
|
|
57
|
-
}, []);
|
|
58
|
-
return (_jsx(_Fragment, { children: _jsxs(Box, { sx: {
|
|
59
|
-
height: 'calc(100vh - 70px)',
|
|
60
|
-
width: '100vw',
|
|
61
|
-
display: 'flex',
|
|
62
|
-
overflow: 'hidden',
|
|
63
|
-
}, children: [_jsxs(Box, { sx: {
|
|
64
|
-
flex: 1,
|
|
65
|
-
display: 'flex',
|
|
66
|
-
flexDirection: 'column',
|
|
67
|
-
overflow: 'hidden',
|
|
68
|
-
}, children: [_jsxs(Box, { sx: {
|
|
69
|
-
p: 3,
|
|
70
|
-
borderBottom: '1px solid',
|
|
71
|
-
borderColor: 'border.default',
|
|
72
|
-
bg: 'canvas.subtle',
|
|
73
|
-
}, children: [_jsx("h1", { style: { margin: 0, fontSize: '1.5rem' }, children: "Agent Runtime Notebook Sidebar Example" }), _jsx("p", { style: { margin: '8px 0 0', color: 'var(--fgColor-muted)' }, children: "Next generation chat with Jupyter Notebook integration" })] }), _jsx(Box, { sx: {
|
|
74
|
-
flex: 1,
|
|
75
|
-
display: 'flex',
|
|
76
|
-
overflow: 'hidden',
|
|
77
|
-
bg: 'canvas.default',
|
|
78
|
-
p: 3,
|
|
79
|
-
}, children: _jsx(Box, { sx: {
|
|
80
|
-
flex: 1,
|
|
81
|
-
border: '1px solid',
|
|
82
|
-
borderColor: 'border.default',
|
|
83
|
-
borderRadius: 2,
|
|
84
|
-
overflow: 'hidden',
|
|
85
|
-
}, children: _jsx(NotebookUI, { serviceManager: serviceManager }) }) })] }), _jsx(ChatSidebar, { title: "AI Assistant", protocol: protocolConfig, position: "right", width: 400, showNewChatButton: true, showClearButton: true, showSettingsButton: true, defaultOpen: true, panelProps: {
|
|
86
|
-
protocol: protocolConfig,
|
|
87
|
-
frontendTools: tools,
|
|
88
|
-
useStore: true,
|
|
89
|
-
suggestions: [
|
|
90
|
-
{
|
|
91
|
-
title: '📓 Explain notebook',
|
|
92
|
-
message: 'Can you explain what this notebook does?',
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
title: '🔧 Fix errors',
|
|
96
|
-
message: 'Can you help me fix any errors in the notebook?',
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
title: '📊 Add visualization',
|
|
100
|
-
message: 'Can you add a visualization to the notebook?',
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
title: '✨ Improve code',
|
|
104
|
-
message: 'Can you suggest improvements for the code?',
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
} })] }) }));
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Main example component with Simple wrapper
|
|
111
|
-
*/
|
|
112
|
-
export function AgentRuntimeNotebookSidebarExample() {
|
|
113
|
-
return (_jsx(ThemedJupyterProvider, { children: _jsx(SimpleWrapper, {}) }));
|
|
114
|
-
}
|
|
115
|
-
function SimpleWrapper() {
|
|
116
|
-
const { serviceManager } = useJupyter();
|
|
117
|
-
return _jsx(AgentRuntimeNotebookExampleInner, { serviceManager: serviceManager });
|
|
118
|
-
}
|
|
119
|
-
export default AgentRuntimeNotebookSidebarExample;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ServiceManager } from '@jupyterlab/services';
|
|
2
|
-
type IJupyterNotebookExampleProps = {
|
|
3
|
-
serviceManager?: ServiceManager.IManager;
|
|
4
|
-
};
|
|
5
|
-
export declare const JupyterNotebookExample: (props: IJupyterNotebookExampleProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
export default JupyterNotebookExample;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
-
* Distributed under the terms of the Modified BSD License.
|
|
5
|
-
*/
|
|
6
|
-
/*
|
|
7
|
-
* Copyright (c) 2021-2023 Datalayer, Inc.
|
|
8
|
-
*
|
|
9
|
-
* MIT License
|
|
10
|
-
*/
|
|
11
|
-
import { useMemo } from 'react';
|
|
12
|
-
import { Box } from '@datalayer/primer-addons';
|
|
13
|
-
import { Notebook, NotebookToolbar, CellSidebarExtension, CellSidebarButton, } from '@datalayer/jupyter-react';
|
|
14
|
-
import { ThemedJupyterProvider } from './utils/themedProvider';
|
|
15
|
-
import nbformatExample from './utils/notebooks/NotebookExample1.ipynb.json';
|
|
16
|
-
const NOTEBOOK_ID = 'notebook-example-1';
|
|
17
|
-
export const JupyterNotebookExample = (props) => {
|
|
18
|
-
const { serviceManager } = props;
|
|
19
|
-
const extensions = useMemo(() => [new CellSidebarExtension({ factory: CellSidebarButton })], []);
|
|
20
|
-
return (_jsxs(_Fragment, { children: [_jsx(Box, { as: "h1", children: "Jupyter Notebook Example" }), serviceManager && (_jsx(ThemedJupyterProvider, { children: _jsx(Notebook, { id: NOTEBOOK_ID, nbformat: nbformatExample, serviceManager: serviceManager, startDefaultKernel: true, extensions: extensions, Toolbar: NotebookToolbar }) }))] }));
|
|
21
|
-
};
|
|
22
|
-
export default JupyterNotebookExample;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AG-UI example components.
|
|
3
|
-
*
|
|
4
|
-
* This folder contains components that demonstrate various AG-UI patterns
|
|
5
|
-
* including weather cards, haiku generation, and other tool-based UIs.
|
|
6
|
-
*
|
|
7
|
-
* @module examples/ag-ui
|
|
8
|
-
*/
|
|
9
|
-
export { InlineWeatherCard, type InlineWeatherCardProps, type WeatherResult, } from './weather';
|
|
10
|
-
export { InlineHaikuCard, HaikuDisplay, type InlineHaikuCardProps, type HaikuDisplayProps, type HaikuResult, } from './haiku';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* AG-UI example components.
|
|
7
|
-
*
|
|
8
|
-
* This folder contains components that demonstrate various AG-UI patterns
|
|
9
|
-
* including weather cards, haiku generation, and other tool-based UIs.
|
|
10
|
-
*
|
|
11
|
-
* @module examples/ag-ui
|
|
12
|
-
*/
|
|
13
|
-
// Weather components
|
|
14
|
-
export { InlineWeatherCard, } from './weather';
|
|
15
|
-
// Haiku components
|
|
16
|
-
export { InlineHaikuCard, HaikuDisplay, } from './haiku';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare function useAgentRegistry(): {
|
|
2
|
-
agents: readonly import("..").AgentRegistryEntry[];
|
|
3
|
-
upsertAgent: (agent: Partial<import("..").AgentRegistryEntry> & {
|
|
4
|
-
id: string;
|
|
5
|
-
baseUrl: string;
|
|
6
|
-
protocol: import("../types").Protocol;
|
|
7
|
-
}) => void;
|
|
8
|
-
deleteAgent: (id: string) => void;
|
|
9
|
-
getAgentById: (id: string) => import("..").AgentRegistryEntry | undefined;
|
|
10
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Hook exposing the agent registry from the Zustand store.
|
|
7
|
-
*
|
|
8
|
-
* Provides CRUD operations on the in-memory agent map without coupling
|
|
9
|
-
* consumers directly to the low-level store.
|
|
10
|
-
*
|
|
11
|
-
* @module hooks/useAgentsRegistry
|
|
12
|
-
*/
|
|
13
|
-
import { useAgentStore } from '../stores/agentsStore';
|
|
14
|
-
export function useAgentRegistry() {
|
|
15
|
-
const agents = useAgentStore(state => state.agents);
|
|
16
|
-
const upsertAgent = useAgentStore(state => state.upsertAgent);
|
|
17
|
-
const deleteAgent = useAgentStore(state => state.deleteAgent);
|
|
18
|
-
const getAgentById = useAgentStore(state => state.getAgentById);
|
|
19
|
-
return { agents, upsertAgent, deleteAgent, getAgentById };
|
|
20
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import type { ServiceManager } from '@jupyterlab/services';
|
|
2
|
-
import type { IRuntimeOptions } from '@datalayer/core/lib/stateful/runtimes/apis';
|
|
3
|
-
import type { AgentStatus, AgentConnection, AgentConfig, Protocol } from '../types';
|
|
4
|
-
/**
|
|
5
|
-
* A URL-addressable agent that has been previously connected.
|
|
6
|
-
* May originate from an agent runtime pod OR from the stable agents service.
|
|
7
|
-
*/
|
|
8
|
-
export interface AgentRegistryEntry {
|
|
9
|
-
/** Unique agent identifier */
|
|
10
|
-
id: string;
|
|
11
|
-
/** Display name */
|
|
12
|
-
name: string;
|
|
13
|
-
/** Agent description */
|
|
14
|
-
description: string;
|
|
15
|
-
/** Base URL for the agent */
|
|
16
|
-
baseUrl: string;
|
|
17
|
-
/** Transport protocol used */
|
|
18
|
-
protocol: Protocol;
|
|
19
|
-
/** Current status */
|
|
20
|
-
status: AgentStatus;
|
|
21
|
-
/** Last error message if status is 'error' */
|
|
22
|
-
error?: string | null;
|
|
23
|
-
/** Timestamp of last update */
|
|
24
|
-
lastUpdated: number;
|
|
25
|
-
/** Document ID (for document-based agents) */
|
|
26
|
-
documentId?: string;
|
|
27
|
-
/** Runtime ID (for agent runtime pods) */
|
|
28
|
-
runtimeId?: string;
|
|
29
|
-
/** Author name (optional, for display) */
|
|
30
|
-
author?: string;
|
|
31
|
-
/** Avatar URL (optional, for display) */
|
|
32
|
-
avatarUrl?: string;
|
|
33
|
-
}
|
|
34
|
-
/** State for the currently-connected agent runtime pod. */
|
|
35
|
-
export interface agentsStoreState {
|
|
36
|
-
/** Current runtime connection (null if not connected) */
|
|
37
|
-
runtime: AgentConnection | null;
|
|
38
|
-
/** Current status */
|
|
39
|
-
status: AgentStatus;
|
|
40
|
-
/** Error message if any */
|
|
41
|
-
error: string | null;
|
|
42
|
-
/** Whether a launch is in progress */
|
|
43
|
-
isLaunching: boolean;
|
|
44
|
-
}
|
|
45
|
-
/** Actions for the agent runtime pod lifecycle. */
|
|
46
|
-
export interface agentsStoreActions {
|
|
47
|
-
/** Launch a new runtime pod */
|
|
48
|
-
launchAgent: (options: IRuntimeOptions) => Promise<AgentConnection>;
|
|
49
|
-
/** Connect to an existing runtime pod */
|
|
50
|
-
connectAgent: (connection: {
|
|
51
|
-
podName: string;
|
|
52
|
-
environmentName: string;
|
|
53
|
-
serviceManager?: ServiceManager.IManager;
|
|
54
|
-
jupyterBaseUrl?: string;
|
|
55
|
-
kernelId?: string;
|
|
56
|
-
}) => void;
|
|
57
|
-
/** Create an agent process on the connected runtime */
|
|
58
|
-
createAgent: (config?: AgentConfig) => Promise<Pick<AgentConnection, 'agentId' | 'endpoint' | 'isReady'>>;
|
|
59
|
-
/** Disconnect from the current runtime */
|
|
60
|
-
disconnect: () => void;
|
|
61
|
-
/** Clear any errors */
|
|
62
|
-
clearError: () => void;
|
|
63
|
-
/** Set error */
|
|
64
|
-
setError: (error: string) => void;
|
|
65
|
-
/** Reset store to initial state */
|
|
66
|
-
reset: () => void;
|
|
67
|
-
}
|
|
68
|
-
export type agentsStore = agentsStoreState & agentsStoreActions;
|
|
69
|
-
/** Persisted registry of URL-addressable agents. */
|
|
70
|
-
export type AgentRegistryState = {
|
|
71
|
-
/** Registered agents */
|
|
72
|
-
agents: readonly AgentRegistryEntry[];
|
|
73
|
-
/** Add or update an agent entry */
|
|
74
|
-
upsertAgent: (agent: Partial<AgentRegistryEntry> & {
|
|
75
|
-
id: string;
|
|
76
|
-
baseUrl: string;
|
|
77
|
-
protocol: Protocol;
|
|
78
|
-
}) => void;
|
|
79
|
-
/** Get agent by ID */
|
|
80
|
-
getAgentById: (id: string) => AgentRegistryEntry | undefined;
|
|
81
|
-
/** Get agent by baseUrl and transport */
|
|
82
|
-
getAgentByUrl: (baseUrl: string, protocol: Protocol) => AgentRegistryEntry | undefined;
|
|
83
|
-
/** Update agent status */
|
|
84
|
-
updateAgentStatus: (id: string, status: AgentStatus, error?: string | null) => void;
|
|
85
|
-
/** Toggle agent status between running/paused */
|
|
86
|
-
toggleAgentStatus: (id: string) => void;
|
|
87
|
-
/** Remove an agent entry */
|
|
88
|
-
deleteAgent: (id: string) => void;
|
|
89
|
-
/** Clear all agent entries */
|
|
90
|
-
clearAgents: () => void;
|
|
91
|
-
};
|
|
92
|
-
export type AgentState = AgentRegistryState & agentsStoreState & agentsStoreActions;
|
|
93
|
-
export declare const agentStore: Omit<import("zustand").StoreApi<AgentState>, "persist"> & {
|
|
94
|
-
persist: {
|
|
95
|
-
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<AgentState, unknown>>) => void;
|
|
96
|
-
clearStorage: () => void;
|
|
97
|
-
rehydrate: () => Promise<void> | void;
|
|
98
|
-
hasHydrated: () => boolean;
|
|
99
|
-
onHydrate: (fn: (state: AgentState) => void) => () => void;
|
|
100
|
-
onFinishHydration: (fn: (state: AgentState) => void) => () => void;
|
|
101
|
-
getOptions: () => Partial<import("zustand/middleware").PersistOptions<AgentState, unknown>>;
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
export declare function useAgentStore(): AgentState;
|
|
105
|
-
export declare function useAgentStore<T>(selector: (state: AgentState) => T): T;
|
|
106
|
-
/** Currently-connected agent runtime pod connection. */
|
|
107
|
-
export declare const useAgentRuntime: () => AgentConnection | null;
|
|
108
|
-
/**
|
|
109
|
-
* @deprecated Use useAgentRuntime() — agent fields are merged onto the runtime connection.
|
|
110
|
-
*/
|
|
111
|
-
export declare const useAgentFromStore: () => {
|
|
112
|
-
agentId: string | undefined;
|
|
113
|
-
endpoint: string | undefined;
|
|
114
|
-
isReady: boolean | undefined;
|
|
115
|
-
} | null;
|
|
116
|
-
export declare const useAgentStatus: () => AgentStatus;
|
|
117
|
-
export declare const useAgentError: () => string | null;
|
|
118
|
-
export declare const useIsLaunching: () => boolean;
|
|
119
|
-
/** Get agent runtime store state outside React. */
|
|
120
|
-
export declare const getAgentState: () => AgentState;
|
|
121
|
-
/** Subscribe to agent runtime store outside React. */
|
|
122
|
-
export declare const subscribeToAgent: (listener: (state: AgentState, prevState: AgentState) => void) => () => void;
|
|
123
|
-
export default useAgentStore;
|