@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
|
@@ -4,34 +4,89 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { createStore } from 'zustand/vanilla';
|
|
6
6
|
import { useStore } from 'zustand';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
7
|
+
import { listPersonas } from '../../specs/personas';
|
|
8
|
+
const DEFAULT_PRESENTATION = {
|
|
9
|
+
author: 'Datalayer',
|
|
10
|
+
lastEdited: 'just now',
|
|
11
|
+
screenshot: 'https://images.unsplash.com/photo-1531297484001-80022131f5a1?w=300&h=150&fit=crop',
|
|
12
|
+
status: 'paused',
|
|
13
|
+
protocol: 'vercel-ai',
|
|
14
|
+
avatarUrl: 'https://avatars.githubusercontent.com/datalayer',
|
|
15
|
+
notebookFile: '',
|
|
16
|
+
lexicalFile: '',
|
|
17
|
+
stars: 0,
|
|
18
|
+
notifications: 0,
|
|
19
|
+
};
|
|
20
|
+
const PERSONA_PRESENTATIONS = {
|
|
21
|
+
sentinel: {
|
|
22
|
+
author: 'Eric Charles',
|
|
23
|
+
lastEdited: '53 minutes ago',
|
|
24
|
+
screenshot: 'https://images.unsplash.com/photo-1589519160732-57fc498494f8?w=300&h=150&fit=crop',
|
|
25
|
+
status: 'paused',
|
|
26
|
+
protocol: 'ag-ui',
|
|
27
|
+
avatarUrl: 'https://avatars.githubusercontent.com/atom',
|
|
28
|
+
notebookFile: 'earthquake-detector.ipynb.json',
|
|
29
|
+
lexicalFile: 'earthquake-detector.lexical.json',
|
|
30
|
+
stars: 4,
|
|
31
|
+
},
|
|
32
|
+
trader: {
|
|
33
|
+
author: 'Gonzalo Peña-Castellanos',
|
|
34
|
+
lastEdited: '3 days ago',
|
|
35
|
+
screenshot: 'https://images.unsplash.com/photo-1611974789855-9c2a0a7236a3?w=300&h=150&fit=crop',
|
|
36
|
+
status: 'paused',
|
|
37
|
+
protocol: 'acp',
|
|
38
|
+
avatarUrl: 'https://avatars.githubusercontent.com/desktop',
|
|
39
|
+
notebookFile: 'stock-market.ipynb.json',
|
|
40
|
+
lexicalFile: 'stock-market.lexical.json',
|
|
41
|
+
stars: 1,
|
|
42
|
+
},
|
|
43
|
+
forecaster: {
|
|
44
|
+
author: 'Eric Charles',
|
|
45
|
+
lastEdited: '1 hour ago',
|
|
46
|
+
screenshot: 'https://images.unsplash.com/photo-1460925895917-afdab827c52f?w=300&h=150&fit=crop',
|
|
47
|
+
status: 'running',
|
|
48
|
+
protocol: 'vercel-ai',
|
|
49
|
+
avatarUrl: 'https://avatars.githubusercontent.com/github',
|
|
50
|
+
notebookFile: 'sales-forecaster.ipynb.json',
|
|
51
|
+
lexicalFile: 'sales-forecaster.lexical.json',
|
|
52
|
+
stars: 5,
|
|
53
|
+
notifications: 2,
|
|
54
|
+
},
|
|
55
|
+
marketing: {
|
|
56
|
+
author: 'Eric Charles',
|
|
57
|
+
lastEdited: '2 hours ago',
|
|
58
|
+
screenshot: 'https://images.unsplash.com/photo-1611926653458-09294b3142bf?w=300&h=150&fit=crop',
|
|
59
|
+
status: 'paused',
|
|
60
|
+
protocol: 'ag-ui',
|
|
61
|
+
avatarUrl: 'https://avatars.githubusercontent.com/primer',
|
|
62
|
+
notebookFile: 'social-post-generator.ipynb.json',
|
|
63
|
+
lexicalFile: 'social-post-generator.lexical.json',
|
|
64
|
+
stars: 3,
|
|
65
|
+
notifications: 1,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
// Build the agent list from the generated personas catalogue.
|
|
69
|
+
const initialAgents = listPersonas().map(persona => {
|
|
70
|
+
const presentation = {
|
|
71
|
+
...DEFAULT_PRESENTATION,
|
|
72
|
+
...(PERSONA_PRESENTATIONS[persona.id] ?? {}),
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
id: persona.id,
|
|
76
|
+
name: persona.name,
|
|
77
|
+
description: persona.description,
|
|
78
|
+
author: presentation.author,
|
|
79
|
+
lastEdited: presentation.lastEdited,
|
|
80
|
+
screenshot: presentation.screenshot,
|
|
81
|
+
status: presentation.status,
|
|
82
|
+
protocol: presentation.protocol,
|
|
83
|
+
avatarUrl: presentation.avatarUrl,
|
|
84
|
+
notebookFile: presentation.notebookFile,
|
|
85
|
+
lexicalFile: presentation.lexicalFile,
|
|
86
|
+
stars: presentation.stars,
|
|
87
|
+
notifications: presentation.notifications,
|
|
88
|
+
};
|
|
27
89
|
});
|
|
28
|
-
// Initialize agents from the agents folder
|
|
29
|
-
const initialAgents = [
|
|
30
|
-
transformAgentData(earthquakeDetectorData, 'earthquake-detector', 'earthquake-detector'),
|
|
31
|
-
transformAgentData(stocksWatcherData, 'stock-market', 'stock-market'),
|
|
32
|
-
transformAgentData(salesForecasterData, 'sales-forecaster', 'sales-forecaster'),
|
|
33
|
-
transformAgentData(socialPostGeneratorData, 'social-post-generator', 'social-post-generator'),
|
|
34
|
-
];
|
|
35
90
|
export const agentsStore = createStore(set => ({
|
|
36
91
|
agents: initialAgents,
|
|
37
92
|
getAgentById: (id) => {
|
package/lib/hooks/index.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export { useFrontendTool, useBackendTool, useRegisteredTools, useTool, usePendin
|
|
|
40
40
|
* ChatBase infrastructure hooks.
|
|
41
41
|
*/
|
|
42
42
|
export { useConfig } from './useConfig';
|
|
43
|
-
export { useSkills } from './useSkills';
|
|
43
|
+
export { useSkills, useSkillActions, useAgentRuntimeLoadedSkills as useAgentLoadedSkills, } from './useSkills';
|
|
44
44
|
export { useContextSnapshot } from './useContextSnapshot';
|
|
45
45
|
export { useSandbox } from './useSandbox';
|
|
46
46
|
/**
|
|
@@ -66,19 +66,19 @@ export { useVercelAI } from './useVercelAI';
|
|
|
66
66
|
/**
|
|
67
67
|
* Unified hook for managing agents — both ephemeral and durable.
|
|
68
68
|
*/
|
|
69
|
-
export {
|
|
69
|
+
export { useAgentRuntimes } from './useAgentRuntimes';
|
|
70
70
|
/**
|
|
71
71
|
* Runtime query and mutation hooks.
|
|
72
72
|
*/
|
|
73
|
-
export { useAgentsRuntimes,
|
|
73
|
+
export { useAgentsRuntimes, useAgentRuntimesQuery, useAgentRuntimeByPodName, useCreateAgentRuntime, useDeleteAgentRuntime, useRefreshAgentRuntimes, agentQueryKeys, AGENT_QUERY_OPTIONS, useAgentLifecycleStore, getAgentLifecycleKey, } from './useAgentRuntimes';
|
|
74
74
|
/**
|
|
75
|
-
* Agent
|
|
75
|
+
* Agent-runtime WebSocket stream hook.
|
|
76
76
|
*/
|
|
77
|
-
export {
|
|
77
|
+
export { useAgentRuntimeWebSocket, type UseAgentRuntimeWebSocketOptions, } from './useAgentRuntimes';
|
|
78
78
|
/**
|
|
79
|
-
* Agent registry
|
|
79
|
+
* Agent catalog store, AI Agents REST API, and registry hooks.
|
|
80
80
|
*/
|
|
81
|
-
export {
|
|
81
|
+
export { useAgentCatalogStore, type AgentCatalogStoreState, } from './useAgentsCatalog';
|
|
82
82
|
/**
|
|
83
83
|
* Agents Service REST API (deprecated).
|
|
84
84
|
*/
|
|
@@ -89,5 +89,5 @@ export { useAgentsService, useNotebookAgents } from './useAgentsService';
|
|
|
89
89
|
export { useCheckpoints, useCheckpointsQuery, useRefreshCheckpoints, useDeletePausedAgentRuntime, useResumePausedAgentRuntime, usePauseAgent, useResumeAgent, useCheckpointAgent, useTerminateAgent, useAgentLifecycle, type CheckpointData, type PauseAgentParams, type ResumeAgentParams, type CheckpointAgentParams, type TerminateAgentParams, type AgentLifecycleOptions, type AgentLifecycleReturn, } from './useCheckpoints';
|
|
90
90
|
export { useToolApprovals, useToolApprovalsQuery, usePendingApprovalCount, useApproveToolRequest, useRejectToolRequest, } from './useToolApprovals';
|
|
91
91
|
export { useNotifications, useFilteredNotifications, useUnreadNotificationCount, useMarkNotificationRead, useMarkAllNotificationsRead, useAllAgentEvents, useAgentEvents, useAgentEvent, useCreateAgentEvent, useUpdateAgentEvent, useDeleteAgentEvent, useMarkEventRead, useMarkEventUnread, } from './useNotifications';
|
|
92
|
-
export { useAIAgentsWebSocket, type UseAIAgentsWebSocketOptions, } from './useAIAgentsWebSocket';
|
|
92
|
+
export { useAIAgentsWebSocket, type UseAIAgentsWebSocketOptions, type UseAIAgentsWebSocketResult, type AIAgentsWebSocketCloseInfo, type AIAgentsWebSocketConnectionState, } from './useAIAgentsWebSocket';
|
|
93
93
|
export { useOtelTotalTokens, fetchOtelTotalTokens, fetchOtelMetricTotal, fetchOtelMetricRows, toMetricValue, } from './useMonitoring';
|
package/lib/hooks/index.js
CHANGED
|
@@ -47,7 +47,7 @@ export { useFrontendTool, useBackendTool, useRegisteredTools, useTool, usePendin
|
|
|
47
47
|
* ChatBase infrastructure hooks.
|
|
48
48
|
*/
|
|
49
49
|
export { useConfig } from './useConfig';
|
|
50
|
-
export { useSkills } from './useSkills';
|
|
50
|
+
export { useSkills, useSkillActions, useAgentRuntimeLoadedSkills as useAgentLoadedSkills, } from './useSkills';
|
|
51
51
|
export { useContextSnapshot } from './useContextSnapshot';
|
|
52
52
|
export { useSandbox } from './useSandbox';
|
|
53
53
|
// =============================================================================
|
|
@@ -79,19 +79,19 @@ export { useVercelAI } from './useVercelAI';
|
|
|
79
79
|
/**
|
|
80
80
|
* Unified hook for managing agents — both ephemeral and durable.
|
|
81
81
|
*/
|
|
82
|
-
export {
|
|
82
|
+
export { useAgentRuntimes } from './useAgentRuntimes';
|
|
83
83
|
/**
|
|
84
84
|
* Runtime query and mutation hooks.
|
|
85
85
|
*/
|
|
86
|
-
export { useAgentsRuntimes,
|
|
86
|
+
export { useAgentsRuntimes, useAgentRuntimesQuery, useAgentRuntimeByPodName, useCreateAgentRuntime, useDeleteAgentRuntime, useRefreshAgentRuntimes, agentQueryKeys, AGENT_QUERY_OPTIONS, useAgentLifecycleStore, getAgentLifecycleKey, } from './useAgentRuntimes';
|
|
87
87
|
/**
|
|
88
|
-
* Agent
|
|
88
|
+
* Agent-runtime WebSocket stream hook.
|
|
89
89
|
*/
|
|
90
|
-
export {
|
|
90
|
+
export { useAgentRuntimeWebSocket, } from './useAgentRuntimes';
|
|
91
91
|
/**
|
|
92
|
-
* Agent registry
|
|
92
|
+
* Agent catalog store, AI Agents REST API, and registry hooks.
|
|
93
93
|
*/
|
|
94
|
-
export {
|
|
94
|
+
export { useAgentCatalogStore, } from './useAgentsCatalog';
|
|
95
95
|
/**
|
|
96
96
|
* Agents Service REST API (deprecated).
|
|
97
97
|
*/
|
package/lib/hooks/useA2A.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { AgentCard, Task
|
|
2
|
-
export type { AgentCard, Task, TaskState };
|
|
1
|
+
import type { AgentCard, Task } from '@a2a-js/sdk';
|
|
3
2
|
export interface Message {
|
|
4
3
|
role: 'user' | 'assistant' | 'system';
|
|
5
4
|
content: string;
|
|
@@ -9,7 +8,7 @@ export interface Message {
|
|
|
9
8
|
}
|
|
10
9
|
export interface UseA2AOptions {
|
|
11
10
|
/**
|
|
12
|
-
* Base URL for the A2A endpoint (e.g.,
|
|
11
|
+
* Base URL for the A2A endpoint (e.g., `http://localhost:8000`).
|
|
13
12
|
*/
|
|
14
13
|
baseUrl?: string;
|
|
15
14
|
/**
|
|
@@ -1,15 +1,54 @@
|
|
|
1
1
|
/** A message pushed by the server. */
|
|
2
2
|
interface WSMessage {
|
|
3
|
-
channel
|
|
4
|
-
event
|
|
5
|
-
data
|
|
3
|
+
channel?: string;
|
|
4
|
+
event?: string;
|
|
5
|
+
data?: Record<string, unknown>;
|
|
6
|
+
type?: string;
|
|
7
|
+
payload?: unknown;
|
|
8
|
+
raw: unknown;
|
|
6
9
|
}
|
|
10
|
+
export interface AIAgentsWebSocketCloseInfo {
|
|
11
|
+
code: number;
|
|
12
|
+
reason: string;
|
|
13
|
+
wasClean: boolean;
|
|
14
|
+
detail: string;
|
|
15
|
+
}
|
|
16
|
+
export type AIAgentsWebSocketConnectionState = 'connecting' | 'connected' | 'closed';
|
|
7
17
|
/** Options for the WebSocket hook. */
|
|
8
18
|
export interface UseAIAgentsWebSocketOptions {
|
|
19
|
+
/** Enable/disable the socket lifecycle. */
|
|
20
|
+
enabled?: boolean;
|
|
21
|
+
/** Override the service base URL (defaults to aiagentsRunUrl). */
|
|
22
|
+
baseUrl?: string;
|
|
23
|
+
/** WebSocket path (or full http/https URL) for the stream endpoint. */
|
|
24
|
+
path?: string;
|
|
25
|
+
/** Query string parameters to append to the WebSocket URL. */
|
|
26
|
+
queryParams?: Record<string, string | number | boolean | null | undefined>;
|
|
27
|
+
/** Auto-reconnect on unexpected disconnects. */
|
|
28
|
+
autoReconnect?: boolean;
|
|
29
|
+
/** Max reconnect attempts before giving up (unbounded by default). */
|
|
30
|
+
maxReconnectAttempts?: number;
|
|
31
|
+
/** Reconnect delay strategy (ms) or static delay in ms. */
|
|
32
|
+
reconnectDelayMs?: number | ((attempt: number) => number);
|
|
9
33
|
/** Additional channels to subscribe to beyond the auto-subscribed user channel. */
|
|
10
34
|
channels?: string[];
|
|
35
|
+
/** Called when the socket opens. */
|
|
36
|
+
onOpen?: () => void;
|
|
11
37
|
/** Called for every incoming message (optional). */
|
|
12
38
|
onMessage?: (msg: WSMessage) => void;
|
|
39
|
+
/** Called when the socket closes. */
|
|
40
|
+
onClose?: (info: AIAgentsWebSocketCloseInfo) => void;
|
|
41
|
+
}
|
|
42
|
+
export interface UseAIAgentsWebSocketResult {
|
|
43
|
+
connectionState: AIAgentsWebSocketConnectionState;
|
|
44
|
+
lastClose: AIAgentsWebSocketCloseInfo | null;
|
|
45
|
+
reconnectAttempt: number;
|
|
46
|
+
/**
|
|
47
|
+
* Send a JSON payload on the underlying WebSocket.
|
|
48
|
+
* Returns `true` when the message was sent, `false` when the socket
|
|
49
|
+
* isn't open (the caller can retry once `connectionState === 'connected'`).
|
|
50
|
+
*/
|
|
51
|
+
send: (payload: unknown) => boolean;
|
|
13
52
|
}
|
|
14
53
|
/**
|
|
15
54
|
* Connect to the AI Agents generic WebSocket.
|
|
@@ -25,5 +64,5 @@ export interface UseAIAgentsWebSocketOptions {
|
|
|
25
64
|
* useAIAgentsWebSocket({ channels: [`agent:${agentId}`] });
|
|
26
65
|
* ```
|
|
27
66
|
*/
|
|
28
|
-
export declare function useAIAgentsWebSocket(options?: UseAIAgentsWebSocketOptions):
|
|
67
|
+
export declare function useAIAgentsWebSocket(options?: UseAIAgentsWebSocketOptions): UseAIAgentsWebSocketResult;
|
|
29
68
|
export {};
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @module hooks/useAIAgentsWebSocket
|
|
14
14
|
*/
|
|
15
|
-
import { useEffect, useRef } from 'react';
|
|
15
|
+
import { useEffect, useRef, useState } from 'react';
|
|
16
16
|
import { useQueryClient } from '@tanstack/react-query';
|
|
17
17
|
import { useCoreStore, useIAMStore } from '@datalayer/core/lib/state';
|
|
18
18
|
import { DEFAULT_SERVICE_URLS, API_BASE_PATHS, } from '@datalayer/core/lib/api/constants';
|
|
@@ -27,6 +27,8 @@ function useBaseUrl() {
|
|
|
27
27
|
}
|
|
28
28
|
// ─── Hook ────────────────────────────────────────────────────────────
|
|
29
29
|
const RECONNECT_DELAY_MS = 3_000;
|
|
30
|
+
const WS_DEFAULT_PATH = `${API_BASE_PATHS.AI_AGENTS}/ws`;
|
|
31
|
+
const isObject = (value) => !!value && typeof value === 'object';
|
|
30
32
|
/**
|
|
31
33
|
* Connect to the AI Agents generic WebSocket.
|
|
32
34
|
*
|
|
@@ -44,28 +46,68 @@ const RECONNECT_DELAY_MS = 3_000;
|
|
|
44
46
|
export function useAIAgentsWebSocket(options) {
|
|
45
47
|
const token = useAuthToken();
|
|
46
48
|
const baseUrl = useBaseUrl();
|
|
49
|
+
const configuredBaseUrl = options?.baseUrl ?? baseUrl;
|
|
50
|
+
const enabled = options?.enabled ?? true;
|
|
51
|
+
const wsPath = options?.path ?? WS_DEFAULT_PATH;
|
|
52
|
+
const queryParamsKey = JSON.stringify(options?.queryParams ?? {});
|
|
47
53
|
const queryClient = useQueryClient();
|
|
54
|
+
const [connectionState, setConnectionState] = useState('closed');
|
|
55
|
+
const [lastClose, setLastClose] = useState(null);
|
|
56
|
+
const [reconnectAttempt, setReconnectAttempt] = useState(0);
|
|
48
57
|
const wsRef = useRef(null);
|
|
49
58
|
const reconnectTimer = useRef(null);
|
|
50
59
|
// Keep a ref of channels so we can re-subscribe on reconnect without
|
|
51
60
|
// tearing down the socket when the array reference changes.
|
|
52
61
|
const channelsRef = useRef(options?.channels ?? []);
|
|
53
62
|
channelsRef.current = options?.channels ?? [];
|
|
63
|
+
const autoReconnectRef = useRef(options?.autoReconnect ?? true);
|
|
64
|
+
autoReconnectRef.current = options?.autoReconnect ?? true;
|
|
65
|
+
const maxReconnectAttemptsRef = useRef(options?.maxReconnectAttempts);
|
|
66
|
+
maxReconnectAttemptsRef.current = options?.maxReconnectAttempts;
|
|
67
|
+
const reconnectDelayRef = useRef(options?.reconnectDelayMs);
|
|
68
|
+
reconnectDelayRef.current = options?.reconnectDelayMs;
|
|
69
|
+
const onOpenRef = useRef(options?.onOpen);
|
|
70
|
+
onOpenRef.current = options?.onOpen;
|
|
54
71
|
const onMessageRef = useRef(options?.onMessage);
|
|
55
72
|
onMessageRef.current = options?.onMessage;
|
|
73
|
+
const onCloseRef = useRef(options?.onClose);
|
|
74
|
+
onCloseRef.current = options?.onClose;
|
|
56
75
|
useEffect(() => {
|
|
57
|
-
if (!token)
|
|
76
|
+
if (!enabled || !token) {
|
|
77
|
+
setConnectionState('closed');
|
|
58
78
|
return;
|
|
79
|
+
}
|
|
59
80
|
let disposed = false;
|
|
81
|
+
let reconnectAttempts = 0;
|
|
82
|
+
const toWsUrl = () => {
|
|
83
|
+
const httpUrl = wsPath.startsWith('http://') || wsPath.startsWith('https://')
|
|
84
|
+
? wsPath
|
|
85
|
+
: `${configuredBaseUrl}${wsPath.startsWith('/') ? '' : '/'}${wsPath}`;
|
|
86
|
+
const url = new URL(httpUrl.replace(/^http/, 'ws'));
|
|
87
|
+
url.searchParams.set('token', token);
|
|
88
|
+
const queryParams = JSON.parse(queryParamsKey);
|
|
89
|
+
Object.entries(queryParams).forEach(([key, value]) => {
|
|
90
|
+
if (value === null || value === undefined) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
url.searchParams.set(key, String(value));
|
|
94
|
+
});
|
|
95
|
+
return url.toString();
|
|
96
|
+
};
|
|
60
97
|
function connect() {
|
|
61
98
|
if (disposed)
|
|
62
99
|
return;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const wsUrl = httpUrl.replace(/^http/, 'ws') + `?token=${encodeURIComponent(token)}`;
|
|
100
|
+
const wsUrl = toWsUrl();
|
|
101
|
+
setConnectionState('connecting');
|
|
66
102
|
const ws = new WebSocket(wsUrl);
|
|
67
103
|
wsRef.current = ws;
|
|
68
104
|
ws.onopen = () => {
|
|
105
|
+
reconnectAttempts = 0;
|
|
106
|
+
setReconnectAttempt(0);
|
|
107
|
+
setConnectionState('connected');
|
|
108
|
+
setLastClose(null);
|
|
109
|
+
console.debug('[ws:connect] url=%s', wsUrl);
|
|
110
|
+
onOpenRef.current?.();
|
|
69
111
|
// Subscribe to extra channels.
|
|
70
112
|
const channels = channelsRef.current;
|
|
71
113
|
if (channels.length > 0) {
|
|
@@ -73,17 +115,33 @@ export function useAIAgentsWebSocket(options) {
|
|
|
73
115
|
}
|
|
74
116
|
};
|
|
75
117
|
ws.onmessage = ev => {
|
|
76
|
-
let
|
|
118
|
+
let raw;
|
|
77
119
|
try {
|
|
78
|
-
|
|
120
|
+
raw = JSON.parse(String(ev.data));
|
|
79
121
|
}
|
|
80
122
|
catch {
|
|
81
123
|
return;
|
|
82
124
|
}
|
|
125
|
+
const msg = isObject(raw)
|
|
126
|
+
? {
|
|
127
|
+
channel: typeof raw.channel === 'string' ? raw.channel : undefined,
|
|
128
|
+
event: typeof raw.event === 'string' ? raw.event : undefined,
|
|
129
|
+
data: isObject(raw.data)
|
|
130
|
+
? raw.data
|
|
131
|
+
: undefined,
|
|
132
|
+
type: typeof raw.type === 'string' ? raw.type : undefined,
|
|
133
|
+
payload: raw.payload,
|
|
134
|
+
raw,
|
|
135
|
+
}
|
|
136
|
+
: { raw };
|
|
83
137
|
// Fire optional callback.
|
|
138
|
+
console.debug('[ws:recv] type=%s', msg.type ?? msg.event ?? 'unknown');
|
|
84
139
|
onMessageRef.current?.(msg);
|
|
85
140
|
// Invalidate React Query caches based on the event type.
|
|
86
141
|
const { event } = msg;
|
|
142
|
+
if (typeof event !== 'string') {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
87
145
|
if (event.startsWith('event_')) {
|
|
88
146
|
queryClient.invalidateQueries({ queryKey: ['agent-events'] });
|
|
89
147
|
}
|
|
@@ -94,15 +152,43 @@ export function useAIAgentsWebSocket(options) {
|
|
|
94
152
|
queryClient.invalidateQueries({ queryKey: ['agent-notifications'] });
|
|
95
153
|
}
|
|
96
154
|
};
|
|
97
|
-
ws.onclose =
|
|
155
|
+
ws.onclose = event => {
|
|
98
156
|
wsRef.current = null;
|
|
99
|
-
|
|
100
|
-
|
|
157
|
+
setConnectionState('closed');
|
|
158
|
+
const closeInfo = {
|
|
159
|
+
code: event.code,
|
|
160
|
+
reason: event.reason,
|
|
161
|
+
wasClean: event.wasClean,
|
|
162
|
+
detail: `code ${event.code}${event.reason ? `: ${event.reason}` : ''}${event.wasClean ? ' (clean)' : ' (unclean)'}`,
|
|
163
|
+
};
|
|
164
|
+
setLastClose(closeInfo);
|
|
165
|
+
console.debug('[ws:disconnect] code=%d reason=%s', event.code, event.reason || '(none)');
|
|
166
|
+
onCloseRef.current?.(closeInfo);
|
|
167
|
+
if (disposed || !autoReconnectRef.current) {
|
|
168
|
+
return;
|
|
101
169
|
}
|
|
170
|
+
reconnectAttempts += 1;
|
|
171
|
+
setReconnectAttempt(reconnectAttempts);
|
|
172
|
+
const maxAttempts = maxReconnectAttemptsRef.current;
|
|
173
|
+
if (typeof maxAttempts === 'number' &&
|
|
174
|
+
Number.isFinite(maxAttempts) &&
|
|
175
|
+
reconnectAttempts > maxAttempts) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const configuredDelay = reconnectDelayRef.current;
|
|
179
|
+
const delay = typeof configuredDelay === 'function'
|
|
180
|
+
? configuredDelay(reconnectAttempts)
|
|
181
|
+
: typeof configuredDelay === 'number'
|
|
182
|
+
? configuredDelay
|
|
183
|
+
: RECONNECT_DELAY_MS;
|
|
184
|
+
reconnectTimer.current = setTimeout(connect, Math.max(0, delay));
|
|
102
185
|
};
|
|
103
186
|
ws.onerror = () => {
|
|
104
187
|
// onclose will fire after onerror; reconnect happens there.
|
|
105
|
-
ws.
|
|
188
|
+
if (ws.readyState === WebSocket.CONNECTING ||
|
|
189
|
+
ws.readyState === WebSocket.OPEN) {
|
|
190
|
+
ws.close();
|
|
191
|
+
}
|
|
106
192
|
};
|
|
107
193
|
}
|
|
108
194
|
connect();
|
|
@@ -110,11 +196,13 @@ export function useAIAgentsWebSocket(options) {
|
|
|
110
196
|
disposed = true;
|
|
111
197
|
if (reconnectTimer.current) {
|
|
112
198
|
clearTimeout(reconnectTimer.current);
|
|
199
|
+
reconnectTimer.current = null;
|
|
113
200
|
}
|
|
114
201
|
wsRef.current?.close();
|
|
115
202
|
wsRef.current = null;
|
|
203
|
+
setConnectionState('closed');
|
|
116
204
|
};
|
|
117
|
-
}, [token,
|
|
205
|
+
}, [token, configuredBaseUrl, wsPath, queryParamsKey, enabled, queryClient]);
|
|
118
206
|
// When the channel list changes, send subscribe/unsubscribe diffs.
|
|
119
207
|
const prevChannelsRef = useRef([]);
|
|
120
208
|
useEffect(() => {
|
|
@@ -133,4 +221,22 @@ export function useAIAgentsWebSocket(options) {
|
|
|
133
221
|
}
|
|
134
222
|
prevChannelsRef.current = [...channelsRef.current];
|
|
135
223
|
}, [options?.channels]);
|
|
224
|
+
return {
|
|
225
|
+
connectionState,
|
|
226
|
+
lastClose,
|
|
227
|
+
reconnectAttempt,
|
|
228
|
+
send: (payload) => {
|
|
229
|
+
const ws = wsRef.current;
|
|
230
|
+
if (!ws || ws.readyState !== WebSocket.OPEN) {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
try {
|
|
234
|
+
ws.send(typeof payload === 'string' ? payload : JSON.stringify(payload));
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
};
|
|
136
242
|
}
|
package/lib/hooks/useAcp.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type StopReason, type SessionUpdate, type AgentCapabilities, type
|
|
2
|
-
export type { StopReason, AgentCapabilities, ClientCapabilities, ToolCallUpdate, PermissionOption, };
|
|
1
|
+
import { type StopReason, type SessionUpdate, type AgentCapabilities, type PermissionOption, type ToolCallUpdate } from '@agentclientprotocol/sdk';
|
|
3
2
|
export type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'error';
|
|
4
3
|
export type SessionUpdateType = SessionUpdate extends {
|
|
5
4
|
sessionUpdate: infer T;
|
package/lib/hooks/useAgUi.d.ts
CHANGED
|
@@ -98,14 +98,14 @@ export declare const agentQueryKeys: {
|
|
|
98
98
|
* });
|
|
99
99
|
* ```
|
|
100
100
|
*/
|
|
101
|
-
export declare function
|
|
101
|
+
export declare function useAgentRuntimes(options?: UseAgentOptions): UseAgentReturn;
|
|
102
102
|
/**
|
|
103
103
|
* Hook to fetch user's agent runtimes (running agent instances).
|
|
104
104
|
*
|
|
105
105
|
* The backend returns active runtimes from the operator **plus** paused
|
|
106
106
|
* runtimes synthesised from Solr checkpoint records (with ``status="paused"``).
|
|
107
107
|
*/
|
|
108
|
-
export declare function
|
|
108
|
+
export declare function useAgentRuntimesQuery(): import("@tanstack/react-query").UseQueryResult<AgentRuntimeData[], Error>;
|
|
109
109
|
/**
|
|
110
110
|
* Hook to fetch a single agent runtime by pod name.
|
|
111
111
|
*/
|
|
@@ -150,3 +150,40 @@ export interface UseAgentsRuntimesReturn {
|
|
|
150
150
|
* Consolidated runtime list and mutations.
|
|
151
151
|
*/
|
|
152
152
|
export declare function useAgentsRuntimes(): UseAgentsRuntimesReturn;
|
|
153
|
+
export interface UseAgentRuntimeWebSocketOptions {
|
|
154
|
+
/** Enable/disable the connection. Defaults to `true`. */
|
|
155
|
+
enabled?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Base URL of the agent-runtime server
|
|
158
|
+
* (e.g. `http://localhost:8765`). The WS path is appended automatically.
|
|
159
|
+
*/
|
|
160
|
+
baseUrl: string;
|
|
161
|
+
/** Auth token passed as `?token=` query parameter. */
|
|
162
|
+
authToken?: string;
|
|
163
|
+
/** Optional `agent_id` query parameter to scope the stream. */
|
|
164
|
+
agentId?: string;
|
|
165
|
+
/** Auto-reconnect on unexpected disconnects. Defaults to `true`. */
|
|
166
|
+
autoReconnect?: boolean;
|
|
167
|
+
/** Delay between reconnection attempts (ms). Defaults to 3 000. */
|
|
168
|
+
reconnectDelayMs?: number | ((attempt: number) => number);
|
|
169
|
+
/** Maximum reconnect attempts. Unbounded by default. */
|
|
170
|
+
maxReconnectAttempts?: number;
|
|
171
|
+
/** Additional callback fired for every incoming WS message. */
|
|
172
|
+
onMessage?: (msg: {
|
|
173
|
+
type?: string;
|
|
174
|
+
payload?: unknown;
|
|
175
|
+
raw: unknown;
|
|
176
|
+
}) => void;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Connect to the agent-runtime monitoring WebSocket.
|
|
180
|
+
*
|
|
181
|
+
* The hook writes all incoming data into the `useAgentRuntimeStore` Zustand
|
|
182
|
+
* store. Components that need approvals, MCP status, context snapshots, or
|
|
183
|
+
* full-context data simply read from the store.
|
|
184
|
+
*
|
|
185
|
+
* Mount this hook **once** near the top of your component tree (e.g. in
|
|
186
|
+
* the example root or in `ChatBase`). All other components read from the
|
|
187
|
+
* store — no extra WebSocket connections needed.
|
|
188
|
+
*/
|
|
189
|
+
export declare function useAgentRuntimeWebSocket(options: UseAgentRuntimeWebSocketOptions): void;
|