@datalayer/agent-runtimes 1.0.18 → 1.0.20
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 +14 -6
- package/lib/AgentNode.js +567 -67
- package/lib/App.js +2 -2
- package/lib/agent-node/AgentNodeGallery.d.ts +80 -0
- package/lib/agent-node/AgentNodeGallery.js +627 -0
- package/lib/agent-notebook-main.js +0 -1
- package/lib/api/runtimes/runtimes.d.ts +57 -0
- package/lib/api/runtimes/runtimes.js +55 -1
- package/lib/chat/Chat.d.ts +14 -1
- package/lib/chat/Chat.js +22 -7
- package/lib/chat/base/ChatBase.js +86 -23
- package/lib/chat/document/EphemeralDocument.d.ts +49 -1
- package/lib/chat/document/EphemeralDocument.js +141 -15
- package/lib/chat/header/ChatHeaderBase.d.ts +3 -1
- package/lib/chat/header/ChatHeaderBase.js +5 -3
- package/lib/chat/messages/ChatMessageList.d.ts +19 -0
- package/lib/chat/messages/ChatMessageList.js +180 -9
- package/lib/chat/notebook/EphemeralNotebook.d.ts +40 -1
- package/lib/chat/notebook/EphemeralNotebook.js +49 -13
- package/lib/chat/prompt/InputPrompt.js +1 -1
- package/lib/chat/tools/SubagentActivity.d.ts +20 -0
- package/lib/chat/tools/SubagentActivity.js +154 -0
- package/lib/chat/tools/index.d.ts +1 -0
- package/lib/chat/tools/index.js +1 -0
- package/lib/chat/usage/TokenUsageBar.js +3 -3
- package/lib/client/AgentRuntimesClient.d.ts +5 -0
- package/lib/client/AgentsMixin.js +3 -1
- package/lib/client/mixins/RuntimesMixin.d.ts +12 -0
- package/lib/client/mixins/RuntimesMixin.js +24 -1
- package/lib/components/AgentSummary.d.ts +1 -0
- package/lib/components/AgentSummary.js +66 -10
- package/lib/components/runtimes/RuntimePickerBase.js +64 -29
- package/lib/components/runtimes/RuntimePickerCell.js +1 -1
- package/lib/components/runtimes/RuntimePickerNotebook.js +1 -1
- package/lib/components/runtimes/RuntimeSimplePicker.js +3 -2
- package/lib/components/runtimes/RuntimeUtils.js +2 -2
- package/lib/context/GraphFlowChart.js +1 -1
- package/lib/context/TokenUsageChart.js +1 -1
- package/lib/context/TurnGraphChart.js +2 -2
- package/lib/examples/A2UiAgentExample.js +4 -4
- package/lib/examples/A2UiComponentsGalleryExample.js +3 -3
- package/lib/examples/A2UiContactCardExample.js +3 -3
- package/lib/examples/A2UiRestaurantExample.js +2 -2
- package/lib/examples/A2UiViewerExample.js +3 -3
- package/lib/examples/AgUiAgenticExample.js +3 -3
- package/lib/examples/AgUiBackendToolRenderingExample.js +2 -2
- package/lib/examples/AgUiHaikuGenUiExample.js +3 -3
- package/lib/examples/AgUiHumanInTheLoopExample.js +5 -5
- package/lib/examples/AgUiSharedStateExample.js +3 -3
- package/lib/examples/AgUiToolsBasedGenUiExample.js +7 -5
- package/lib/examples/AgentCheckpointsExample.js +6 -5
- package/lib/examples/{AgentSandboxExample.d.ts → AgentCodeSandboxExample.d.ts} +4 -4
- package/lib/examples/{AgentSandboxExample.js → AgentCodeSandboxExample.js} +10 -9
- package/lib/examples/AgentCodeSandboxesExample.js +2 -2
- package/lib/examples/AgentCodemodeExample.js +3 -3
- package/lib/examples/AgentCompactionExample.d.ts +12 -0
- package/lib/examples/AgentCompactionExample.js +244 -0
- package/lib/examples/AgentEvalsExample.js +10 -20
- package/lib/examples/AgentGuardrailsExample.js +2 -2
- package/lib/examples/AgentHooksExample.js +1 -1
- package/lib/examples/AgentInferenceProviderExample.js +6 -8
- package/lib/examples/AgentLoopExample.js +3 -3
- package/lib/examples/AgentMCPExample.js +3 -3
- package/lib/examples/AgentMemoryExample.d.ts +4 -2
- package/lib/examples/AgentMemoryExample.js +93 -10
- package/lib/examples/AgentMonitoringExample.js +2 -2
- package/lib/examples/AgentNotificationsExample.js +1 -1
- package/lib/examples/AgentOtelExample.d.ts +2 -3
- package/lib/examples/AgentOtelExample.js +7 -12
- package/lib/examples/AgentOutputsExample.js +5 -5
- package/lib/examples/AgentParametersExample.js +3 -3
- package/lib/examples/AgentSkillsExample.js +4 -4
- package/lib/examples/AgentSubagentsExample.d.ts +2 -2
- package/lib/examples/AgentSubagentsExample.js +43 -34
- package/lib/examples/AgentToolApprovalsExample.js +1 -1
- package/lib/examples/AgentTriggersExample.js +9 -11
- package/lib/examples/AgentspecsExample.js +13 -5
- package/lib/examples/CellExample.d.ts +6 -0
- package/lib/examples/CellExample.js +84 -0
- package/lib/examples/ChatCustomExample.js +1 -1
- package/lib/examples/ChatExample.js +1 -1
- package/lib/examples/ChatStandaloneExample.js +2 -2
- package/lib/examples/HomeExample.js +29 -28
- package/lib/examples/Lexical2Example.js +2 -2
- package/lib/examples/LexicalAgentExample.js +1 -1
- package/lib/examples/LexicalAgentSidebarExample.js +2 -2
- package/lib/examples/NotebookAgentSidebarExample.d.ts +1 -1
- package/lib/examples/NotebookAgentSidebarExample.js +5 -4
- package/lib/examples/NotebookCollaborationExample.js +3 -3
- package/lib/examples/NotebookExample.js +2 -2
- package/lib/examples/components/ExampleWrapper.js +5 -0
- package/lib/examples/components/Header.js +2 -2
- package/lib/examples/components/HeaderControls.js +1 -1
- package/lib/examples/components/LexicalEditor.js +1 -1
- package/lib/examples/components/MainContent.js +1 -1
- package/lib/examples/components/MockFileBrowser.js +8 -8
- package/lib/examples/components/TimeTravel.js +1 -1
- package/lib/examples/components/haiku/HaikuDisplay.js +2 -2
- package/lib/examples/example-selector.js +4 -3
- package/lib/examples/hooks/useExampleAgentRuntime.js +11 -1
- package/lib/examples/hooks/useExampleAgentRuntimes.d.ts +7 -0
- package/lib/examples/hooks/useExampleAgentRuntimes.js +82 -0
- package/lib/examples/index.d.ts +2 -1
- package/lib/examples/index.js +2 -1
- package/lib/examples/main.js +359 -46
- package/lib/examples/utils/agentSummaryStore.d.ts +17 -0
- package/lib/examples/utils/themedProvider.js +32 -2
- package/lib/examples/utils/useExampleAgentRuntimesUrl.js +2 -1
- package/lib/examples2/NotebookMutationsKernel.js +6 -3
- package/lib/examples2/NotebookMutationsServiceManager.js +6 -3
- package/lib/examples2/ReactRouterExample.js +5 -5
- package/lib/examples2/main.js +38 -0
- package/lib/hooks/useAIAgentsWebSocket.js +35 -0
- package/lib/hooks/useAgentRuntimes.d.ts +22 -0
- package/lib/hooks/useAgentRuntimes.js +192 -5
- package/lib/hooks/useCheckpoints.js +2 -2
- package/lib/hooks/useToolApprovals.d.ts +10 -4
- package/lib/hooks/useToolApprovals.js +11 -5
- package/lib/identity/AgentIdentity.js +1 -2
- package/lib/models/Runtime.d.ts +10 -8
- package/lib/models/RuntimeDTO.d.ts +5 -3
- package/lib/models/RuntimeDTO.js +3 -3
- package/lib/runtimes/actions.js +3 -1
- package/lib/runtimes/apis.d.ts +7 -0
- package/lib/shims/primerAddonsBox.d.ts +1 -0
- package/lib/shims/primerAddonsBox.js +7 -0
- package/lib/specs/agents/agents.d.ts +51 -0
- package/lib/specs/agents/agents.js +3389 -94
- package/lib/specs/models.d.ts +2 -0
- package/lib/specs/models.js +37 -0
- package/lib/stores/agentRuntimeStore.d.ts +32 -1
- package/lib/stores/agentRuntimeStore.js +65 -1
- package/lib/stores/index.d.ts +1 -1
- package/lib/stores/index.js +1 -1
- package/lib/types/agents.d.ts +9 -3
- package/lib/types/agentspecs.d.ts +2 -0
- package/lib/types/chat.d.ts +83 -0
- package/lib/types/models.d.ts +5 -0
- package/lib/types/stream.d.ts +58 -1
- package/package.json +6 -5
- package/scripts/codegen/generate_agents.py +7 -0
- package/scripts/codegen/generate_models.py +22 -9
- package/scripts/gen_workers.py +340 -0
- package/lib/examples/CellSimpleExample.d.ts +0 -6
- package/lib/examples/CellSimpleExample.js +0 -20
- package/scripts/codegen/__pycache__/generate_sandbox_agents.cpython-313.pyc +0 -0
|
@@ -6,45 +6,66 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
/**
|
|
7
7
|
* AgentSubagentsExample
|
|
8
8
|
*
|
|
9
|
-
* Demonstrates multi-agent delegation using subagents
|
|
9
|
+
* Demonstrates multi-agent delegation using the in-repo subagents capability.
|
|
10
10
|
* The parent agent orchestrates a researcher and a writer subagent,
|
|
11
11
|
* delegating tasks and combining results for the user.
|
|
12
12
|
*
|
|
13
|
-
* - Creates
|
|
13
|
+
* - Creates an agent from the 'example-subagents' spec on the selected target
|
|
14
14
|
* - Shows a Chat component for interacting with the orchestrator
|
|
15
15
|
* - Sidebar displays subagent info and active task status
|
|
16
16
|
*/
|
|
17
17
|
/// <reference types="vite/client" />
|
|
18
18
|
import { useEffect, useState, useCallback, useRef } from 'react';
|
|
19
19
|
import { Text, Spinner, Heading, Label, Timeline } from '@primer/react';
|
|
20
|
-
import { PeopleIcon, PersonIcon
|
|
20
|
+
import { PeopleIcon, PersonIcon } from '@primer/octicons-react';
|
|
21
21
|
import { Box } from '@datalayer/primer-addons';
|
|
22
22
|
import { AuthRequiredView, ErrorView } from './components';
|
|
23
23
|
import { ThemedProvider } from './utils/themedProvider';
|
|
24
24
|
import { uniqueAgentId } from './utils/agentId';
|
|
25
25
|
import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
|
|
26
26
|
import { Chat } from '../chat';
|
|
27
|
+
import { SubagentChatPanel } from '../chat/messages/ChatMessageList';
|
|
28
|
+
import { useAgentRuntimeActiveSubagentToolCallId } from '../stores';
|
|
27
29
|
import { useExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
30
|
+
import { useRuntimeTargetStore } from './utils/runtimeTargetStore';
|
|
28
31
|
const AGENT_NAME = 'subagents-example-agent';
|
|
29
32
|
const AGENTSPEC_ID = 'example-subagents';
|
|
30
33
|
const SUBAGENTS = [
|
|
31
34
|
{
|
|
32
35
|
name: 'researcher',
|
|
33
36
|
description: 'Researches topics, gathers facts, and provides detailed analysis',
|
|
34
|
-
preferredMode: 'sync',
|
|
35
|
-
typicalComplexity: 'moderate',
|
|
36
|
-
canAskQuestions: true,
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
name: 'writer',
|
|
40
40
|
description: 'Writes clear, structured content based on research or instructions',
|
|
41
|
-
preferredMode: 'sync',
|
|
42
|
-
typicalComplexity: 'moderate',
|
|
43
|
-
canAskQuestions: false,
|
|
44
41
|
},
|
|
45
42
|
];
|
|
43
|
+
/** Fixed height (px) for the active-subagent chat viewport. */
|
|
44
|
+
const ACTIVE_PANEL_HEIGHT = 280;
|
|
45
|
+
/**
|
|
46
|
+
* Shows the currently active (running) subagent and its streamed messages.
|
|
47
|
+
* Falls back to a placeholder when no subagent is active.
|
|
48
|
+
*/
|
|
49
|
+
const ActiveSubagentPanel = () => {
|
|
50
|
+
const activeToolCallId = useAgentRuntimeActiveSubagentToolCallId();
|
|
51
|
+
return (_jsxs(Box, { sx: {
|
|
52
|
+
p: 3,
|
|
53
|
+
borderBottom: '1px solid',
|
|
54
|
+
borderColor: 'border.default',
|
|
55
|
+
}, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "Active Subagent" }), activeToolCallId ? (_jsx(SubagentChatPanel, { toolCallId: activeToolCallId, height: ACTIVE_PANEL_HEIGHT })) : (_jsx(Box, { sx: {
|
|
56
|
+
height: ACTIVE_PANEL_HEIGHT,
|
|
57
|
+
display: 'flex',
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
justifyContent: 'center',
|
|
60
|
+
border: '1px solid',
|
|
61
|
+
borderColor: 'border.muted',
|
|
62
|
+
borderRadius: 2,
|
|
63
|
+
bg: 'canvas.subtle',
|
|
64
|
+
}, children: _jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', m: 0 }, children: "No active Subagent" }) }))] }));
|
|
65
|
+
};
|
|
46
66
|
const AgentSubagentsInner = ({ onLogout, }) => {
|
|
47
67
|
const { token } = useSimpleAuthStore();
|
|
68
|
+
const runtimeTarget = useRuntimeTargetStore(state => state.target);
|
|
48
69
|
const agentName = useRef(uniqueAgentId(AGENT_NAME)).current;
|
|
49
70
|
const [runtimeStatus, setRuntimeStatus] = useState('launching');
|
|
50
71
|
const [isReady, setIsReady] = useState(false);
|
|
@@ -63,7 +84,7 @@ const AgentSubagentsInner = ({ onLogout, }) => {
|
|
|
63
84
|
}), [token]);
|
|
64
85
|
useEffect(() => {
|
|
65
86
|
let isCancelled = false;
|
|
66
|
-
const
|
|
87
|
+
const createAgentForTarget = async () => {
|
|
67
88
|
setRuntimeStatus('launching');
|
|
68
89
|
setIsReady(false);
|
|
69
90
|
setHookError(null);
|
|
@@ -77,6 +98,7 @@ const AgentSubagentsInner = ({ onLogout, }) => {
|
|
|
77
98
|
agent_library: 'pydantic-ai',
|
|
78
99
|
transport: 'vercel-ai',
|
|
79
100
|
agent_spec_id: AGENTSPEC_ID,
|
|
101
|
+
memory: 'ephemeral',
|
|
80
102
|
enable_skills: true,
|
|
81
103
|
tools: [],
|
|
82
104
|
}),
|
|
@@ -121,11 +143,11 @@ const AgentSubagentsInner = ({ onLogout, }) => {
|
|
|
121
143
|
}
|
|
122
144
|
}
|
|
123
145
|
};
|
|
124
|
-
void
|
|
146
|
+
void createAgentForTarget();
|
|
125
147
|
return () => {
|
|
126
148
|
isCancelled = true;
|
|
127
149
|
};
|
|
128
|
-
}, [agentBaseUrl, authFetch]);
|
|
150
|
+
}, [agentBaseUrl, authFetch, runtimeTarget]);
|
|
129
151
|
if (!isReady && runtimeStatus !== 'error') {
|
|
130
152
|
return (_jsxs(Box, { sx: {
|
|
131
153
|
display: 'flex',
|
|
@@ -134,7 +156,8 @@ const AgentSubagentsInner = ({ onLogout, }) => {
|
|
|
134
156
|
justifyContent: 'center',
|
|
135
157
|
height: '100%',
|
|
136
158
|
gap: 3,
|
|
137
|
-
|
|
159
|
+
bg: 'canvas.default',
|
|
160
|
+
}, children: [_jsx(Spinner, { size: "large" }), _jsxs(Text, { sx: { color: 'fg.muted' }, children: ["Launching subagents example agent (", runtimeTarget, ")..."] })] }));
|
|
138
161
|
}
|
|
139
162
|
if (runtimeStatus === 'error' || hookError) {
|
|
140
163
|
return _jsx(ErrorView, { error: hookError, onLogout: onLogout });
|
|
@@ -143,6 +166,7 @@ const AgentSubagentsInner = ({ onLogout, }) => {
|
|
|
143
166
|
height: '100%',
|
|
144
167
|
display: 'flex',
|
|
145
168
|
flexDirection: 'column',
|
|
169
|
+
bg: 'canvas.default',
|
|
146
170
|
}, children: [_jsxs(Box, { sx: {
|
|
147
171
|
display: 'flex',
|
|
148
172
|
alignItems: 'center',
|
|
@@ -152,7 +176,7 @@ const AgentSubagentsInner = ({ onLogout, }) => {
|
|
|
152
176
|
borderBottom: '1px solid',
|
|
153
177
|
borderColor: 'border.default',
|
|
154
178
|
flexShrink: 0,
|
|
155
|
-
}, children: [_jsx(PeopleIcon, { size: 16 }), _jsx(Heading, { as: "h3", sx: { fontSize: 2, flex: 1 }, children: "Subagents Demo" }), isReconnectedAgent && (_jsx(Label, { variant: "secondary", size: "small", children: "Reconnected" })), _jsxs(Label, { variant: "accent", children: [SUBAGENTS.length, " subagents"] })] }), _jsxs(Box, { sx: { flex: 1, minHeight: 0, display: 'flex' }, children: [_jsx(Box, { sx: { flex: 1, minWidth: 0 }, children: _jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: "Subagents Orchestrator", brandIcon: _jsx(PeopleIcon, { size: 16 }), placeholder: "Ask me to research a topic, write content, or both...", description: "Multi-agent delegation with researcher & writer", showHeader: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, suggestions: [
|
|
179
|
+
}, children: [_jsx(PeopleIcon, { size: 16 }), _jsx(Heading, { as: "h3", sx: { fontSize: 2, flex: 1 }, children: "Subagents Demo" }), isReconnectedAgent && (_jsx(Label, { variant: "secondary", size: "small", children: "Reconnected" })), _jsx(Label, { variant: "accent", children: runtimeTarget }), _jsxs(Label, { variant: "accent", children: [SUBAGENTS.length, " subagents"] })] }), _jsxs(Box, { sx: { flex: 1, minHeight: 0, display: 'flex' }, children: [_jsx(Box, { sx: { flex: 1, minWidth: 0 }, children: _jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: "Subagents Orchestrator", brandIcon: _jsx(PeopleIcon, { size: 16 }), placeholder: "Ask me to research a topic, write content, or both...", description: "Multi-agent delegation with researcher & writer", showHeader: true, kernelIndicatorPlacement: "right", autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, suggestions: [
|
|
156
180
|
{
|
|
157
181
|
title: 'Research & write',
|
|
158
182
|
message: 'Research the pros and cons of Python async patterns and write a summary.',
|
|
@@ -172,35 +196,20 @@ const AgentSubagentsInner = ({ onLogout, }) => {
|
|
|
172
196
|
display: 'flex',
|
|
173
197
|
flexDirection: 'column',
|
|
174
198
|
overflow: 'auto',
|
|
175
|
-
}, children: [_jsxs(Box, { sx: {
|
|
199
|
+
}, children: [_jsx(ActiveSubagentPanel, {}), _jsxs(Box, { sx: {
|
|
176
200
|
p: 3,
|
|
177
201
|
borderBottom: '1px solid',
|
|
178
202
|
borderColor: 'border.default',
|
|
179
|
-
}, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "Available Subagents" }), _jsx(Timeline, { children: SUBAGENTS.map(sa => (_jsxs(Timeline.Item, { children: [_jsx(Timeline.Badge, { children: _jsx(PersonIcon, {}) }), _jsxs(Timeline.Body, { children: [_jsx(Box, { sx: { mb: 1 }, children: _jsx(Text, { sx: { fontWeight: 'bold', fontSize: 1 }, children: sa.name }) }), _jsx(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mt: 0, mb: 1 }, children: sa.description })
|
|
203
|
+
}, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "Available Subagents" }), _jsx(Timeline, { children: SUBAGENTS.map(sa => (_jsxs(Timeline.Item, { children: [_jsx(Timeline.Badge, { children: _jsx(PersonIcon, {}) }), _jsxs(Timeline.Body, { children: [_jsx(Box, { sx: { mb: 1 }, children: _jsx(Text, { sx: { fontWeight: 'bold', fontSize: 1 }, children: sa.name }) }), _jsx(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mt: 0, mb: 1 }, children: sa.description })] })] }, sa.name))) })] }), _jsxs(Box, { sx: {
|
|
180
204
|
p: 3,
|
|
181
205
|
borderBottom: '1px solid',
|
|
182
206
|
borderColor: 'border.default',
|
|
183
207
|
}, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "Delegation Tools" }), _jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [
|
|
184
208
|
{
|
|
185
|
-
name: '
|
|
186
|
-
desc: '
|
|
187
|
-
icon: ClockIcon,
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
name: 'check_task',
|
|
191
|
-
desc: 'Check status of a running task',
|
|
192
|
-
icon: CheckCircleFillIcon,
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
name: 'list_active_tasks',
|
|
196
|
-
desc: 'View all active delegated tasks',
|
|
209
|
+
name: 'delegate_task',
|
|
210
|
+
desc: 'Run a named subagent on a task and return its answer',
|
|
197
211
|
icon: PeopleIcon,
|
|
198
212
|
},
|
|
199
|
-
{
|
|
200
|
-
name: 'soft_cancel_task',
|
|
201
|
-
desc: 'Gracefully cancel a task',
|
|
202
|
-
icon: XCircleFillIcon,
|
|
203
|
-
},
|
|
204
213
|
].map(tool => (_jsxs(Box, { sx: {
|
|
205
214
|
p: 2,
|
|
206
215
|
border: '1px solid',
|
|
@@ -213,7 +222,7 @@ const AgentSubagentsInner = ({ onLogout, }) => {
|
|
|
213
222
|
fontSize: 1,
|
|
214
223
|
fontWeight: 'bold',
|
|
215
224
|
fontFamily: 'mono',
|
|
216
|
-
}, children: tool.name }), _jsx(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mt: 0, mb: 0 }, children: tool.desc })] })] }, tool.name))) })] }), _jsxs(Box, { sx: { p: 3 }, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "How It Works" }), _jsxs(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mb: 2 }, children: ["The orchestrator agent delegates tasks to specialised subagents using the ", _jsx("code", { children: "
|
|
225
|
+
}, children: tool.name }), _jsx(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mt: 0, mb: 0 }, children: tool.desc })] })] }, tool.name))) })] }), _jsxs(Box, { sx: { p: 3 }, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "How It Works" }), _jsxs(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mb: 2 }, children: ["The orchestrator agent delegates tasks to specialised subagents using the ", _jsx("code", { children: "delegate_task" }), " tool. Each subagent runs in an isolated child run with its own model and instructions."] }), _jsx(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mb: 0 }, children: "Token and request usage from each delegation is forwarded to the parent run, so budget limits stay accurate across delegation." })] })] })] })] }));
|
|
217
226
|
};
|
|
218
227
|
const AgentSubagentsExample = () => {
|
|
219
228
|
const { token, clearAuth } = useSimpleAuthStore();
|
|
@@ -188,7 +188,7 @@ const AgentToolApprovalsInner = ({ onLogout, }) => {
|
|
|
188
188
|
py: 1,
|
|
189
189
|
borderBottom: '1px solid',
|
|
190
190
|
borderColor: 'border.default',
|
|
191
|
-
}, children: _jsx(Text, { sx: { color: 'fg.muted', fontSize: 0 }, children: "Agent already running - reconnected." }) })), _jsx(Box, { sx: { flex: 1, minHeight: 0, display: 'flex' }, children: _jsx(Box, { sx: { flex: 1, minWidth: 0 }, children: _jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: `Tool Approval Agent - ${podName}`, brandIcon: _jsx(CheckCircleIcon, { size: 16 }), placeholder: "Ask for actions that require approval...", showHeader: true, showNewChatButton: true, showClearButton: true, showTokenUsage: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, headerActions: _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsxs(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: ["Pending: ", pendingApprovalCount] }), _jsxs("label", { style: {
|
|
191
|
+
}, children: _jsx(Text, { sx: { color: 'fg.muted', fontSize: 0 }, children: "Agent already running - reconnected." }) })), _jsx(Box, { sx: { flex: 1, minHeight: 0, display: 'flex' }, children: _jsx(Box, { sx: { flex: 1, minWidth: 0 }, children: _jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: `Tool Approval Agent - ${podName}`, brandIcon: _jsx(CheckCircleIcon, { size: 16 }), placeholder: "Ask for actions that require approval...", showHeader: true, kernelIndicatorPlacement: "right", showNewChatButton: true, showClearButton: true, showTokenUsage: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, headerActions: _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsxs(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: ["Pending: ", pendingApprovalCount] }), _jsxs("label", { style: {
|
|
192
192
|
display: 'flex',
|
|
193
193
|
alignItems: 'center',
|
|
194
194
|
gap: 6,
|
|
@@ -855,7 +855,7 @@ const AgentTriggerInner = ({ onLogout, }) => {
|
|
|
855
855
|
setActiveApproval(null);
|
|
856
856
|
}
|
|
857
857
|
}
|
|
858
|
-
}, onClose: () => setActiveApproval(null) }), approvalError && (_jsx(Box, { sx: { px: 3, py: 1 }, children: _jsx(Text, { sx: { color: 'danger.fg', fontSize: 0 }, children: approvalError }) })), _jsxs(Box, { sx: { flex: 1, minHeight: 0, display: 'flex' }, children: [_jsx(Box, { sx: { flex: 1, minWidth: 0 }, children: isReady ? (_jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: "Trigger Agent", brandIcon: _jsx(ZapIcon, { size: 16 }), description: `View-only trigger output. Cron: ${cronExpr} | Webhook: ${webhookEnabled ? 'on' : 'off'} | Event: ${eventSubscribed ? eventTopic : 'none'}`, showHeader: true, autoFocus: false, height: "100%", runtimeId: agentId, showInput: true, disableInputPrompt: true, showModelSelector: true, showToolsMenu: true, showSkillsMenu: true })) : (_jsx(Box, { sx: {
|
|
858
|
+
}, onClose: () => setActiveApproval(null) }), approvalError && (_jsx(Box, { sx: { px: 3, py: 1 }, children: _jsx(Text, { sx: { color: 'danger.fg', fontSize: 0 }, children: approvalError }) })), _jsxs(Box, { sx: { flex: 1, minHeight: 0, display: 'flex' }, children: [_jsx(Box, { sx: { flex: 1, minWidth: 0 }, children: isReady ? (_jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: "Trigger Agent", brandIcon: _jsx(ZapIcon, { size: 16 }), description: `View-only trigger output. Cron: ${cronExpr} | Webhook: ${webhookEnabled ? 'on' : 'off'} | Event: ${eventSubscribed ? eventTopic : 'none'}`, showHeader: true, kernelIndicatorPlacement: "right", autoFocus: false, height: "100%", runtimeId: agentId, showInput: true, disableInputPrompt: true, showModelSelector: true, showToolsMenu: true, showSkillsMenu: true })) : (_jsx(Box, { sx: {
|
|
859
859
|
height: '100%',
|
|
860
860
|
display: 'flex',
|
|
861
861
|
alignItems: 'center',
|
|
@@ -900,7 +900,7 @@ const AgentTriggerInner = ({ onLogout, }) => {
|
|
|
900
900
|
borderBottom: '1px solid',
|
|
901
901
|
borderColor: 'border.default',
|
|
902
902
|
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, mb: 2 }, children: [_jsx(ZapIcon, { size: 16 }), _jsx(Heading, { as: "h3", sx: { fontSize: 2 }, children: "Once Trigger" })] }), _jsx(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mb: 3 }, children: "Launch a single streaming run for the once-trigger prompt and watch tool calls, tool results, and assistant text update in real time." }), _jsxs(Box, { sx: {
|
|
903
|
-
bg: 'canvas.
|
|
903
|
+
bg: 'canvas.default',
|
|
904
904
|
border: '1px solid',
|
|
905
905
|
borderColor: 'border.default',
|
|
906
906
|
borderRadius: 2,
|
|
@@ -1029,7 +1029,7 @@ const AgentTriggerInner = ({ onLogout, }) => {
|
|
|
1029
1029
|
: JSON.stringify(msg.content);
|
|
1030
1030
|
return (_jsxs(Box, { sx: {
|
|
1031
1031
|
p: 2,
|
|
1032
|
-
bg: 'canvas.
|
|
1032
|
+
bg: 'canvas.default',
|
|
1033
1033
|
borderRadius: 2,
|
|
1034
1034
|
border: '1px solid',
|
|
1035
1035
|
borderColor: 'border.default',
|
|
@@ -1183,7 +1183,7 @@ const AgentTriggerInner = ({ onLogout, }) => {
|
|
|
1183
1183
|
: JSON.stringify(msg.content);
|
|
1184
1184
|
return (_jsxs(Box, { sx: {
|
|
1185
1185
|
p: 2,
|
|
1186
|
-
bg: 'canvas.
|
|
1186
|
+
bg: 'canvas.default',
|
|
1187
1187
|
borderRadius: 2,
|
|
1188
1188
|
border: '1px solid',
|
|
1189
1189
|
borderColor: 'border.default',
|
|
@@ -1212,7 +1212,7 @@ const AgentTriggerInner = ({ onLogout, }) => {
|
|
|
1212
1212
|
: content })] }, `approval-msg-${msg.id}`));
|
|
1213
1213
|
}) }))] })), _jsxs(Box, { sx: { mt: 2, display: 'grid', gap: 2 }, children: [_jsxs(Box, { children: [_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: "Stream once (local curl)" }), _jsx(Box, { sx: {
|
|
1214
1214
|
mt: 1,
|
|
1215
|
-
bg: 'canvas.
|
|
1215
|
+
bg: 'canvas.default',
|
|
1216
1216
|
borderRadius: 2,
|
|
1217
1217
|
p: 2,
|
|
1218
1218
|
fontFamily: 'mono',
|
|
@@ -1227,7 +1227,7 @@ const AgentTriggerInner = ({ onLogout, }) => {
|
|
|
1227
1227
|
borderBottom: '1px solid',
|
|
1228
1228
|
borderColor: 'border.default',
|
|
1229
1229
|
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, mb: 2 }, children: [_jsx(GlobeIcon, { size: 16 }), _jsx(Heading, { as: "h3", sx: { fontSize: 2 }, children: "Webhook Trigger" })] }), _jsx(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mb: 3 }, children: "Generate a unique URL that triggers this agent on incoming HTTP POST requests. Useful for CI/CD pipelines, external services, or custom integrations." }), webhookUrl ? (_jsxs(_Fragment, { children: [_jsx(Label, { variant: webhookEnabled ? 'success' : 'secondary', sx: { mb: 2, display: 'inline-block' }, children: webhookEnabled ? 'Active' : 'Disabled' }), _jsx(Box, { sx: {
|
|
1230
|
-
bg: 'canvas.
|
|
1230
|
+
bg: 'canvas.default',
|
|
1231
1231
|
p: 2,
|
|
1232
1232
|
borderRadius: 2,
|
|
1233
1233
|
mb: 2,
|
|
@@ -1235,7 +1235,7 @@ const AgentTriggerInner = ({ onLogout, }) => {
|
|
|
1235
1235
|
fontSize: 0,
|
|
1236
1236
|
wordBreak: 'break-all',
|
|
1237
1237
|
}, children: webhookUrl }), webhookSecret && (_jsxs(Box, { sx: { mb: 2 }, children: [_jsx(Text, { sx: { fontSize: 0, fontWeight: 'bold' }, children: "Secret:" }), _jsx(Box, { sx: {
|
|
1238
|
-
bg: 'canvas.
|
|
1238
|
+
bg: 'canvas.default',
|
|
1239
1239
|
p: 2,
|
|
1240
1240
|
borderRadius: 2,
|
|
1241
1241
|
mt: 1,
|
|
@@ -1258,12 +1258,10 @@ const AgentTriggerInner = ({ onLogout, }) => {
|
|
|
1258
1258
|
new Date(a.created_at).getTime())
|
|
1259
1259
|
.map((evt) => (_jsxs(Box, { sx: {
|
|
1260
1260
|
p: 2,
|
|
1261
|
-
bg: evt.read ? 'canvas.
|
|
1261
|
+
bg: evt.read ? 'canvas.default' : 'neutral.muted',
|
|
1262
1262
|
borderRadius: 2,
|
|
1263
1263
|
border: '1px solid',
|
|
1264
|
-
borderColor:
|
|
1265
|
-
? 'border.default'
|
|
1266
|
-
: 'accent.muted',
|
|
1264
|
+
borderColor: 'border.default',
|
|
1267
1265
|
}, children: [_jsxs(Box, { sx: {
|
|
1268
1266
|
display: 'flex',
|
|
1269
1267
|
alignItems: 'center',
|
|
@@ -22,7 +22,8 @@ import { ThemedProvider } from './utils/themedProvider';
|
|
|
22
22
|
import { isSpecSelection, getSpecId, isCloudSpecSelection, getCloudSpecId, } from '../config/AgentConfiguration';
|
|
23
23
|
import { MockFileBrowser, MainContent, Header } from './components';
|
|
24
24
|
import { useChatStore } from '../stores';
|
|
25
|
-
import { useAgentRuntimes } from '
|
|
25
|
+
import { useExampleAgentRuntimes as useAgentRuntimes } from './hooks/useExampleAgentRuntimes';
|
|
26
|
+
import { resolveExampleAgentRuntimesUrl, useExampleAgentRuntimesUrl, } from './utils/useExampleAgentRuntimesUrl';
|
|
26
27
|
// Create a query client for React Query
|
|
27
28
|
const queryClient = new QueryClient({
|
|
28
29
|
defaultOptions: {
|
|
@@ -68,7 +69,7 @@ function ChatWithJupyterStatus({ baseUrl, isConfigured, enableCodemode, useJupyt
|
|
|
68
69
|
// Default configuration - use environment variable if available
|
|
69
70
|
// Note: Vercel AI connects to Jupyter server (8888), other protocols connect to agent-runtimes server (8765)
|
|
70
71
|
const DEFAULT_WS_URL = import.meta.env.VITE_ACP_WS_URL || 'ws://localhost:8765/api/v1/acp/ws';
|
|
71
|
-
const DEFAULT_BASE_URL =
|
|
72
|
+
const DEFAULT_BASE_URL = resolveExampleAgentRuntimesUrl('local');
|
|
72
73
|
const DEFAULT_AGENT_ID = 'example-agent';
|
|
73
74
|
const DEFAULT_SYSTEM_PROMPT = 'You are a helpful AI assistant.';
|
|
74
75
|
const RIGHT_PANE_WIDTH = {
|
|
@@ -297,15 +298,21 @@ githubClientId, kaggleToken, }) => {
|
|
|
297
298
|
const enableSkills = selectedSkills.length > 0;
|
|
298
299
|
const { configuration } = useCoreStore();
|
|
299
300
|
const { token } = useSimpleAuthStore();
|
|
301
|
+
const localAgentRuntimesBaseUrl = useExampleAgentRuntimesUrl();
|
|
300
302
|
const cloudCatalogBaseUrl = useMemo(() => {
|
|
301
303
|
const configured = normalizeHttpUrl(configuration?.runtimesUrl);
|
|
302
|
-
const
|
|
304
|
+
const resolvedCloudBaseUrl = normalizeHttpUrl(resolveExampleAgentRuntimesUrl('cloud'));
|
|
303
305
|
if (configured && !isLocalhostUrl(configured)) {
|
|
304
306
|
return configured;
|
|
305
307
|
}
|
|
306
|
-
return
|
|
308
|
+
return resolvedCloudBaseUrl || DEFAULT_BASE_URL;
|
|
307
309
|
}, [configuration?.runtimesUrl]);
|
|
308
310
|
const isCloudMode = isCloudSpecSelection(selectedAgentId);
|
|
311
|
+
useEffect(() => {
|
|
312
|
+
if (!isCloudMode) {
|
|
313
|
+
setBaseUrl(localAgentRuntimesBaseUrl);
|
|
314
|
+
}
|
|
315
|
+
}, [isCloudMode, localAgentRuntimesBaseUrl]);
|
|
309
316
|
const selectedSpec = selectedCloudSpec || selectedLibrarySpec;
|
|
310
317
|
const cloudRuntimeCreationBaseUrl = useMemo(() => {
|
|
311
318
|
if (!isCloudMode) {
|
|
@@ -342,7 +349,7 @@ githubClientId, kaggleToken, }) => {
|
|
|
342
349
|
// Jupyter sandbox URL (used when useJupyterSandbox is true)
|
|
343
350
|
// Can be configured via VITE_JUPYTER_SANDBOX_URL environment variable
|
|
344
351
|
const jupyterSandboxUrl = import.meta.env.VITE_JUPYTER_SANDBOX_URL ||
|
|
345
|
-
'http://
|
|
352
|
+
'http://0.0.0.0:8888/api/jupyter-server?token=60c1661cc408f978c309d04157af55c9588ff9557c9380e4fb50785750703da6';
|
|
346
353
|
const handleSelectedServersChange = React.useCallback((newServers) => {
|
|
347
354
|
const oldServers = selectedMcpServers;
|
|
348
355
|
// Find added and removed servers
|
|
@@ -1036,6 +1043,7 @@ githubClientId, kaggleToken, }) => {
|
|
|
1036
1043
|
agentId: effectiveAgentId,
|
|
1037
1044
|
title: currentAgent?.name || agentName || 'AI Assistant',
|
|
1038
1045
|
brandIcon: _jsx(AgentIcon, { size: 16 }),
|
|
1046
|
+
kernelIndicatorPlacement: 'right',
|
|
1039
1047
|
autoConnect: true,
|
|
1040
1048
|
autoFocus: true,
|
|
1041
1049
|
placeholder: 'Type your message to the agent...',
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ServiceManager } from '@jupyterlab/services';
|
|
2
|
+
type IJupyterCellExampleProps = {
|
|
3
|
+
serviceManager?: ServiceManager.IManager;
|
|
4
|
+
};
|
|
5
|
+
export declare const CellExample: (props: IJupyterCellExampleProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default CellExample;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { Cell, KernelIndicator, useJupyter, useKernelsStore, useCellsStore, } from '@datalayer/jupyter-react';
|
|
4
|
+
import { getServiceManagerRuntimeEnvironmentDetails } from '../hooks/useAgentRuntimes';
|
|
5
|
+
import { ThemedJupyterProvider } from './utils/themedProvider';
|
|
6
|
+
import { Button, Heading, Label, Text } from '@primer/react';
|
|
7
|
+
import { Box } from '@datalayer/primer-addons';
|
|
8
|
+
const CELL_ID = 'cell-example-1';
|
|
9
|
+
const DEFAULT_SOURCE = `from IPython.display import display
|
|
10
|
+
|
|
11
|
+
for i in range(10):
|
|
12
|
+
display('I am a long string which is repeatedly added to the dom in separated divs: %d' % i)`;
|
|
13
|
+
const CellExampleContent = ({ serviceManager }) => {
|
|
14
|
+
const isLocalSandbox = useMemo(() => {
|
|
15
|
+
const rawBaseUrl = String(serviceManager?.serverSettings.baseUrl || '').trim();
|
|
16
|
+
if (!rawBaseUrl) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const parsed = new URL(rawBaseUrl);
|
|
21
|
+
return (parsed.hostname === 'localhost' ||
|
|
22
|
+
parsed.hostname === '127.0.0.1' ||
|
|
23
|
+
parsed.hostname === '0.0.0.0');
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
}, [serviceManager?.serverSettings.baseUrl]);
|
|
29
|
+
const { defaultKernel } = useJupyter({
|
|
30
|
+
serviceManager,
|
|
31
|
+
// Local mode: start a fresh kernel so the example always renders.
|
|
32
|
+
// Cloud mode: attach to the sandbox's already-running kernel.
|
|
33
|
+
startDefaultKernel: isLocalSandbox,
|
|
34
|
+
...(isLocalSandbox ? {} : { useRunningKernelIndex: 0 }),
|
|
35
|
+
});
|
|
36
|
+
const activeKernel = defaultKernel;
|
|
37
|
+
const fallbackKernelEnvironmentName = useMemo(() => {
|
|
38
|
+
const rawBaseUrl = String(serviceManager?.serverSettings.baseUrl || '').trim();
|
|
39
|
+
if (!rawBaseUrl) {
|
|
40
|
+
return 'local-jupyter-server';
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const parsed = new URL(rawBaseUrl);
|
|
44
|
+
if (parsed.hostname === 'localhost' ||
|
|
45
|
+
parsed.hostname === '127.0.0.1' ||
|
|
46
|
+
parsed.hostname === '0.0.0.0') {
|
|
47
|
+
return 'local-jupyter-server';
|
|
48
|
+
}
|
|
49
|
+
return `${parsed.hostname} jupyter-server`;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return 'local-jupyter-server';
|
|
53
|
+
}
|
|
54
|
+
}, [serviceManager?.serverSettings.baseUrl]);
|
|
55
|
+
const runtimeEnvironment = useMemo(() => getServiceManagerRuntimeEnvironmentDetails(serviceManager), [serviceManager]);
|
|
56
|
+
const kernelEnvironmentName = runtimeEnvironment?.environmentTitle ||
|
|
57
|
+
runtimeEnvironment?.environmentName ||
|
|
58
|
+
fallbackKernelEnvironmentName;
|
|
59
|
+
// `Cell` creates its adapter once and does not re-wire when the `kernel`
|
|
60
|
+
// prop changes. Key the cell by the kernel/server identity so switching
|
|
61
|
+
// runtimes (e.g. local -> cloud) remounts it against the new kernel.
|
|
62
|
+
const cellRemountKey = useMemo(() => {
|
|
63
|
+
if (!activeKernel) {
|
|
64
|
+
return 'no-kernel';
|
|
65
|
+
}
|
|
66
|
+
const base = String(activeKernel.connection?.serverSettings?.baseUrl ||
|
|
67
|
+
serviceManager?.serverSettings.baseUrl ||
|
|
68
|
+
'');
|
|
69
|
+
return `${base}::${activeKernel.id}`;
|
|
70
|
+
}, [activeKernel, serviceManager?.serverSettings.baseUrl]);
|
|
71
|
+
const cellsStore = useCellsStore();
|
|
72
|
+
const kernelsStore = useKernelsStore();
|
|
73
|
+
return (_jsxs(Box, { p: 4, children: [_jsx(Heading, { as: "h1", sx: { fontSize: 3, mb: 3 }, children: "Cell Example" }), _jsxs(Box, { sx: {
|
|
74
|
+
display: 'grid',
|
|
75
|
+
gridTemplateColumns: ['1fr', null, 'repeat(3, minmax(0, 1fr))'],
|
|
76
|
+
gap: 3,
|
|
77
|
+
mb: 3,
|
|
78
|
+
}, children: [_jsx(Box, { children: _jsxs(Text, { as: "p", sx: { mb: 0, wordBreak: 'break-word' }, children: ["Source: ", cellsStore.getSource(CELL_ID)] }) }), _jsxs(Box, { children: [_jsxs(Text, { as: "p", sx: { mb: 2 }, children: ["Outputs Count: ", cellsStore.getOutputsCount(CELL_ID)] }), _jsxs(Box, { sx: { mb: 2 }, children: ["Kernel State:", ' ', _jsx(Label, { children: activeKernel && kernelsStore.getExecutionState(activeKernel.id) })] }), _jsxs(Box, { children: ["Kernel Phase:", ' ', _jsx(Label, { children: activeKernel && kernelsStore.getExecutionPhase(activeKernel.id) })] })] }), _jsxs(Box, { children: [_jsx(Button, { sx: { mb: 3 }, onClick: () => cellsStore.execute(CELL_ID), disabled: !activeKernel, children: "Run Cell" }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2, mb: 3 }, children: [_jsx(Box, { children: "Code Sandbox:" }), _jsx(KernelIndicator, { kernel: activeKernel && activeKernel.connection, environmentName: kernelEnvironmentName, cpu: runtimeEnvironment?.cpu, memory: runtimeEnvironment?.memory, gpu: runtimeEnvironment?.gpu, bordered: false, position: "bottom-left" })] }), !activeKernel && (_jsx(Text, { as: "p", sx: { mb: 0, color: 'fg.muted' }, children: "Waiting for an existing sandbox kernel connection." }))] })] }), activeKernel ? (_jsx(Cell, { source: DEFAULT_SOURCE, id: CELL_ID, kernel: activeKernel }, cellRemountKey)) : null] }));
|
|
79
|
+
};
|
|
80
|
+
export const CellExample = (props) => {
|
|
81
|
+
const { serviceManager } = props;
|
|
82
|
+
return (_jsx(ThemedJupyterProvider, { children: _jsx(CellExampleContent, { serviceManager: serviceManager }) }));
|
|
83
|
+
};
|
|
84
|
+
export default CellExample;
|
|
@@ -95,7 +95,7 @@ Be concise, helpful, and provide working code examples when appropriate.`,
|
|
|
95
95
|
textDecoration: 'underline',
|
|
96
96
|
border: 'none',
|
|
97
97
|
background: 'none',
|
|
98
|
-
}, children: "Retry" })] })) : agentId ? (_jsx(Chat, { protocol: "ag-ui", agentId: agentId, showModelSelector: true, showToolsMenu: true, height: "100%", suggestions: [
|
|
98
|
+
}, children: "Retry" })] })) : agentId ? (_jsx(Chat, { kernelIndicatorPlacement: "right", protocol: "ag-ui", agentId: agentId, showModelSelector: true, showToolsMenu: true, height: "100%", suggestions: [
|
|
99
99
|
{
|
|
100
100
|
title: '👋 Say hello',
|
|
101
101
|
message: 'Hello! What can you help me with today?',
|
|
@@ -57,7 +57,7 @@ const AgentRuntimeChatExample = () => {
|
|
|
57
57
|
return (_jsx(ThemedProvider, { children: _jsx(ErrorView, { error: "Failed to start agent", detail: error || 'No agent ID returned' }) }));
|
|
58
58
|
}
|
|
59
59
|
// Agent is ready — render the Chat component
|
|
60
|
-
return (_jsx(Chat, { protocol: "ag-ui", baseUrl: baseUrl, agentId: agentId, title: "Simple Agent", placeholder: "Send a message...", description: "Chat with a simple AI assistant", showHeader: true, showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, showInformation: true, autoFocus: true, height: "100vh", runtimeId: agentId, historyEndpoint: `${baseUrl}/api/v1/history`, suggestions: [
|
|
60
|
+
return (_jsx(Chat, { protocol: "ag-ui", baseUrl: baseUrl, agentId: agentId, title: "Simple Agent", placeholder: "Send a message...", description: "Chat with a simple AI assistant", showHeader: true, kernelIndicatorPlacement: "right", showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, showInformation: true, autoFocus: true, height: "100vh", runtimeId: agentId, historyEndpoint: `${baseUrl}/api/v1/history`, suggestions: [
|
|
61
61
|
{
|
|
62
62
|
title: 'Hello',
|
|
63
63
|
message: 'Hello, what can you do?',
|
|
@@ -114,14 +114,14 @@ const AgentRuntimePopupStandaloneExample = () => {
|
|
|
114
114
|
marginBottom: 4,
|
|
115
115
|
}, children: "A standalone floating chat popup with props-based message handling. Click the chat button in the bottom-right corner to start!" }), _jsxs(Box, { sx: {
|
|
116
116
|
padding: 4,
|
|
117
|
-
backgroundColor: 'canvas.
|
|
117
|
+
backgroundColor: 'canvas.default',
|
|
118
118
|
borderRadius: 2,
|
|
119
119
|
border: '1px solid',
|
|
120
120
|
borderColor: 'border.default',
|
|
121
121
|
marginBottom: 4,
|
|
122
122
|
}, children: [_jsx(Text, { as: "h2", sx: { fontSize: 2, fontWeight: 'semibold', marginBottom: 2 }, children: "Key Features" }), _jsxs(Box, { as: "ul", sx: { paddingLeft: 3 }, children: [_jsxs(Box, { as: "li", sx: { marginBottom: 2 }, children: [_jsx(Text, { sx: { fontWeight: 'semibold' }, children: "Props-based Handler" }), _jsxs(Text, { sx: { fontSize: 1, color: 'fg.muted', display: 'block' }, children: ["Implement your own ", _jsx("code", { children: "onSendMessage" }), " function to connect to any AI backend"] })] }), _jsxs(Box, { as: "li", sx: { marginBottom: 2 }, children: [_jsx(Text, { sx: { fontWeight: 'semibold' }, children: "Streaming Support" }), _jsxs(Text, { sx: { fontSize: 1, color: 'fg.muted', display: 'block' }, children: ["Use the ", _jsx("code", { children: "onChunk" }), " callback for real-time streaming responses"] })] }), _jsxs(Box, { as: "li", sx: { marginBottom: 2 }, children: [_jsx(Text, { sx: { fontWeight: 'semibold' }, children: "Full Customization" }), _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted', display: 'block' }, children: "Brand colors, icons, position, keyboard shortcuts, and more" })] }), _jsxs(Box, { as: "li", sx: { marginBottom: 2 }, children: [_jsx(Text, { sx: { fontWeight: 'semibold' }, children: "No Backend Required" }), _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted', display: 'block' }, children: "Unlike AG-UI examples, this works without a server (demo mode)" })] })] })] }), _jsxs(Box, { sx: {
|
|
123
123
|
padding: 4,
|
|
124
|
-
backgroundColor: 'canvas.
|
|
124
|
+
backgroundColor: 'canvas.default',
|
|
125
125
|
borderRadius: 2,
|
|
126
126
|
border: '1px solid',
|
|
127
127
|
borderColor: 'border.default',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box } from '@datalayer/primer-addons';
|
|
3
|
-
import { Heading, Text, TextInput } from '@primer/react';
|
|
3
|
+
import { Heading, Text, TextInput, Label } from '@primer/react';
|
|
4
4
|
import { SearchIcon } from '@primer/octicons-react';
|
|
5
5
|
const HomeExample = ({ examples = [], searchQuery = '', onSearchChange, onSelectExample, }) => {
|
|
6
6
|
const sortedExamples = [...examples].sort((a, b) => a.title.localeCompare(b.title));
|
|
@@ -37,41 +37,42 @@ const HomeExample = ({ examples = [], searchQuery = '', onSearchChange, onSelect
|
|
|
37
37
|
'repeat(4, minmax(0, 1fr))',
|
|
38
38
|
],
|
|
39
39
|
gap: 3,
|
|
40
|
-
}, children: sortedExamples.map(example => (_jsxs(Box, {
|
|
41
|
-
|
|
40
|
+
}, children: sortedExamples.map(example => (_jsxs(Box, { role: "button", tabIndex: 0, onClick: () => onSelectExample?.(example.id), onKeyDown: event => {
|
|
41
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
onSelectExample?.(example.id);
|
|
44
|
+
}
|
|
45
|
+
}, sx: {
|
|
46
|
+
bg: 'canvas.default',
|
|
47
|
+
p: 4,
|
|
48
|
+
borderRadius: '12px',
|
|
42
49
|
border: '1px solid',
|
|
43
50
|
borderColor: 'border.default',
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
display: 'flex',
|
|
52
|
+
flexDirection: 'column',
|
|
53
|
+
gap: 2,
|
|
47
54
|
cursor: 'pointer',
|
|
48
|
-
transition: '
|
|
49
|
-
'
|
|
55
|
+
transition: 'box-shadow 0.2s, transform 0.2s, border-color 0.2s',
|
|
56
|
+
'&:hover': {
|
|
57
|
+
boxShadow: 'shadow.large',
|
|
50
58
|
transform: 'translateY(-2px)',
|
|
51
59
|
borderColor: 'accent.emphasis',
|
|
52
|
-
boxShadow: 'shadow.medium',
|
|
53
|
-
bg: 'canvas.default',
|
|
54
60
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
'&:focus-visible': {
|
|
62
|
+
outline: '2px solid',
|
|
63
|
+
outlineColor: 'accent.emphasis',
|
|
64
|
+
outlineOffset: '2px',
|
|
65
|
+
},
|
|
66
|
+
}, children: [_jsx(Heading, { as: "h3", sx: { fontSize: 2, fontWeight: 'bold' }, children: example.title }), _jsx(Text, { sx: { color: 'fg.muted', fontSize: 1, lineHeight: 1.6 }, children: example.description }), _jsx(Text, { sx: {
|
|
61
67
|
color: 'fg.muted',
|
|
62
68
|
fontSize: 0,
|
|
63
|
-
display: 'block',
|
|
64
|
-
mt: 2,
|
|
65
69
|
fontFamily: 'mono',
|
|
66
|
-
}, children: example.id }), example.tags.length > 0 && (_jsx(Box, { sx: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
border: '1px solid',
|
|
74
|
-
borderColor: 'border.muted',
|
|
75
|
-
}, children: tag }, `${example.id}-${tag}`))) }))] }, example.id))) }))] }) }));
|
|
70
|
+
}, children: example.id }), example.tags.length > 0 && (_jsx(Box, { sx: {
|
|
71
|
+
display: 'flex',
|
|
72
|
+
gap: 1,
|
|
73
|
+
flexWrap: 'wrap',
|
|
74
|
+
mt: 'auto',
|
|
75
|
+
pt: 2,
|
|
76
|
+
}, children: example.tags.map(tag => (_jsx(Label, { variant: "secondary", children: tag }, `${example.id}-${tag}`))) }))] }, example.id))) }))] }) }));
|
|
76
77
|
};
|
|
77
78
|
export default HomeExample;
|
|
@@ -187,7 +187,7 @@ export function ChatLexicalExampleInner({ serviceManager, }) {
|
|
|
187
187
|
p: 3,
|
|
188
188
|
borderBottom: '1px solid',
|
|
189
189
|
borderColor: 'border.default',
|
|
190
|
-
bg: 'canvas.
|
|
190
|
+
bg: 'canvas.default',
|
|
191
191
|
display: 'flex',
|
|
192
192
|
justifyContent: 'space-between',
|
|
193
193
|
alignItems: 'center',
|
|
@@ -207,7 +207,7 @@ export function ChatLexicalExampleInner({ serviceManager, }) {
|
|
|
207
207
|
display: 'flex',
|
|
208
208
|
overflow: 'hidden',
|
|
209
209
|
bg: 'canvas.default',
|
|
210
|
-
}, children: _jsx(LexicalEditor, { serviceManager: serviceManager }) })] }), _jsx(ChatFloating, { useStore: true, title: "AI Assistant", position: "bottom-right", width: 400, height: 550, defaultOpen: false, showNewChatButton: true, showClearButton: true, showSettingsButton: false, clickOutsideToClose: true, escapeToClose: true, enableKeyboardShortcuts: true, toggleShortcut: "/", buttonTooltip: "Open AI Assistant", showPoweredBy: true, poweredByProps: {
|
|
210
|
+
}, children: _jsx(LexicalEditor, { serviceManager: serviceManager }) })] }), _jsx(ChatFloating, { kernelIndicatorPlacement: "right", useStore: true, title: "AI Assistant", position: "bottom-right", width: 400, height: 550, defaultOpen: false, showNewChatButton: true, showClearButton: true, showSettingsButton: false, clickOutsideToClose: true, escapeToClose: true, enableKeyboardShortcuts: true, toggleShortcut: "/", buttonTooltip: "Open AI Assistant", showPoweredBy: true, poweredByProps: {
|
|
211
211
|
brandName: 'Datalayer',
|
|
212
212
|
brandUrl: 'https://datalayer.ai',
|
|
213
213
|
}, onOpen: () => {
|
|
@@ -245,7 +245,7 @@ function LexicalWithChat({ content, serviceManager, }) {
|
|
|
245
245
|
color: 'danger.fg',
|
|
246
246
|
borderRadius: 2,
|
|
247
247
|
maxWidth: 300,
|
|
248
|
-
}, children: [_jsx("strong", { children: "Error:" }), " ", error] })), effectiveReady && (_jsx(ChatFloating, { protocol: "vercel-ai", endpoint: vercelAiEndpoint, title: "Lexical AI Agent Runtime", description: "Hi! I can help you edit documents. Try: 'Insert a heading', 'Add a code block', or 'Create a list'", defaultOpen: true, defaultViewMode: "panel", position: "bottom-right", frontendTools: tools, useStore: false, showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, suggestions: [
|
|
248
|
+
}, children: [_jsx("strong", { children: "Error:" }), " ", error] })), effectiveReady && (_jsx(ChatFloating, { kernelIndicatorPlacement: "right", protocol: "vercel-ai", endpoint: vercelAiEndpoint, title: "Lexical AI Agent Runtime", description: "Hi! I can help you edit documents. Try: 'Insert a heading', 'Add a code block', or 'Create a list'", defaultOpen: true, defaultViewMode: "panel", position: "bottom-right", frontendTools: tools, useStore: false, showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, suggestions: [
|
|
249
249
|
{
|
|
250
250
|
title: 'Insert heading',
|
|
251
251
|
message: 'Insert a heading that says "Welcome"',
|
|
@@ -181,13 +181,13 @@ export function ChatLexicalAgentExampleInner({ serviceManager, }) {
|
|
|
181
181
|
p: 3,
|
|
182
182
|
borderBottom: '1px solid',
|
|
183
183
|
borderColor: 'border.default',
|
|
184
|
-
bg: 'canvas.
|
|
184
|
+
bg: 'canvas.default',
|
|
185
185
|
}, 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: {
|
|
186
186
|
flex: 1,
|
|
187
187
|
display: 'flex',
|
|
188
188
|
overflow: 'hidden',
|
|
189
189
|
bg: 'canvas.default',
|
|
190
|
-
}, children: _jsx(LexicalEditor, { serviceManager: serviceManager, endpoint: vercelAiEndpoint }) })] }), effectiveReady && (_jsx(ChatSidebar, { title: "AI Assistant", protocol: protocolConfig, position: "right", width: 400, showNewChatButton: true, showClearButton: true, showSettingsButton: true, defaultOpen: true, panelProps: {
|
|
190
|
+
}, children: _jsx(LexicalEditor, { serviceManager: serviceManager, endpoint: vercelAiEndpoint }) })] }), effectiveReady && (_jsx(ChatSidebar, { kernelIndicatorPlacement: "right", title: "AI Assistant", protocol: protocolConfig, position: "right", width: 400, showNewChatButton: true, showClearButton: true, showSettingsButton: true, defaultOpen: true, panelProps: {
|
|
191
191
|
protocol: protocolConfig,
|
|
192
192
|
frontendTools: tools,
|
|
193
193
|
useStore: true,
|