@datalayer/agent-runtimes 1.0.5 → 1.0.6
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 +157 -10
- package/lib/AgentNode.d.ts +3 -0
- package/lib/AgentNode.js +676 -0
- package/lib/agent-node/themeStore.d.ts +3 -0
- package/lib/agent-node/themeStore.js +156 -0
- package/lib/agent-node-main.d.ts +1 -0
- package/lib/agent-node-main.js +14 -0
- package/lib/chat/Chat.js +16 -10
- package/lib/chat/ChatFloating.js +1 -1
- package/lib/chat/ChatSidebar.js +81 -49
- package/lib/chat/base/ChatBase.js +388 -74
- package/lib/chat/display/FloatingBrandButton.js +8 -1
- package/lib/chat/header/ChatHeader.d.ts +3 -1
- package/lib/chat/header/ChatHeader.js +15 -12
- package/lib/chat/header/ChatHeaderBase.d.ts +29 -9
- package/lib/chat/header/ChatHeaderBase.js +26 -3
- package/lib/chat/indicators/SandboxStatusIndicator.js +82 -47
- package/lib/chat/messages/ChatMessageList.js +46 -1
- package/lib/chat/messages/ChatMessages.js +6 -2
- package/lib/chat/prompt/InputFooter.d.ts +3 -1
- package/lib/chat/prompt/InputFooter.js +8 -5
- package/lib/chat/prompt/InputPrompt.d.ts +3 -1
- package/lib/chat/prompt/InputPrompt.js +2 -2
- package/lib/chat/prompt/InputPromptFooter.d.ts +3 -1
- package/lib/chat/prompt/InputPromptFooter.js +3 -3
- package/lib/client/AgentsMixin.js +14 -0
- package/lib/config/AgentConfiguration.d.ts +22 -0
- package/lib/config/AgentConfiguration.js +319 -64
- package/lib/examples/AgUiSharedStateExample.js +2 -1
- package/lib/examples/AgentCheckpointsExample.js +3 -3
- package/lib/examples/AgentCodemodeExample.d.ts +3 -3
- package/lib/examples/AgentCodemodeExample.js +24 -12
- package/lib/examples/AgentEvalsExample.js +330 -40
- package/lib/examples/AgentGuardrailsExample.js +16 -5
- package/lib/examples/AgentHooksExample.js +27 -9
- package/lib/examples/AgentInferenceProviderExample.d.ts +3 -0
- package/lib/examples/AgentInferenceProviderExample.js +329 -0
- package/lib/examples/AgentMCPExample.js +6 -5
- package/lib/examples/AgentMemoryExample.d.ts +1 -2
- package/lib/examples/AgentMemoryExample.js +71 -22
- package/lib/examples/AgentMonitoringExample.js +5 -5
- package/lib/examples/AgentNotificationsExample.d.ts +1 -2
- package/lib/examples/AgentNotificationsExample.js +71 -22
- package/lib/examples/AgentOtelExample.js +31 -40
- package/lib/examples/AgentOutputsExample.d.ts +1 -1
- package/lib/examples/AgentOutputsExample.js +67 -16
- package/lib/examples/AgentParametersExample.js +10 -8
- package/lib/examples/AgentSandboxExample.d.ts +1 -1
- package/lib/examples/AgentSandboxExample.js +7 -6
- package/lib/examples/AgentSkillsExample.js +6 -6
- package/lib/examples/AgentSubagentsExample.d.ts +1 -1
- package/lib/examples/AgentSubagentsExample.js +6 -6
- package/lib/examples/AgentToolApprovalsExample.js +27 -11
- package/lib/examples/AgentTriggersExample.js +5 -5
- package/lib/examples/{AgentSpecsExample.d.ts → AgentspecsExample.d.ts} +2 -2
- package/lib/examples/AgentspecsExample.js +1096 -0
- package/lib/examples/ChatCustomExample.js +6 -5
- package/lib/examples/ChatExample.js +6 -5
- package/lib/examples/Lexical2Example.js +1 -1
- package/lib/examples/LexicalAgentExample.js +1 -1
- package/lib/examples/NotebookAgentExample.js +3 -3
- package/lib/examples/components/ExampleWrapper.d.ts +6 -7
- package/lib/examples/components/ExampleWrapper.js +27 -10
- package/lib/examples/example-selector.js +2 -1
- package/lib/examples/index.d.ts +2 -1
- package/lib/examples/index.js +2 -1
- package/lib/examples/lexical/initial-content.json +6 -6
- package/lib/examples/main.js +56 -16
- package/lib/examples/utils/agentId.d.ts +1 -1
- package/lib/examples/utils/agentId.js +1 -1
- package/lib/examples/utils/useExampleAgentRuntimesUrl.d.ts +5 -0
- package/lib/examples/utils/useExampleAgentRuntimesUrl.js +19 -0
- package/lib/hooks/useAIAgentsWebSocket.js +35 -0
- package/lib/hooks/useAgentRuntimes.d.ts +32 -3
- package/lib/hooks/useAgentRuntimes.js +114 -19
- package/lib/index.d.ts +1 -1
- package/lib/specs/agents/agents.d.ts +20 -13
- package/lib/specs/agents/agents.js +1267 -581
- package/lib/specs/benchmarks.d.ts +20 -0
- package/lib/specs/benchmarks.js +205 -0
- package/lib/specs/envvars.d.ts +0 -1
- package/lib/specs/envvars.js +0 -11
- package/lib/specs/evals.d.ts +10 -9
- package/lib/specs/evals.js +128 -88
- package/lib/specs/index.d.ts +0 -1
- package/lib/specs/index.js +0 -1
- package/lib/specs/models.d.ts +0 -2
- package/lib/specs/models.js +0 -15
- package/lib/specs/skills.d.ts +0 -1
- package/lib/specs/skills.js +0 -18
- package/lib/stores/agentRuntimeStore.d.ts +5 -1
- package/lib/stores/agentRuntimeStore.js +22 -8
- package/lib/stores/conversationStore.js +2 -2
- package/lib/types/agents-lifecycle.d.ts +18 -0
- package/lib/types/agents.d.ts +6 -0
- package/lib/types/agentspecs.d.ts +4 -0
- package/lib/types/benchmarks.d.ts +43 -0
- package/lib/types/benchmarks.js +5 -0
- package/lib/types/chat.d.ts +16 -0
- package/lib/types/evals.d.ts +26 -17
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/package.json +9 -5
- package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_benchmarks.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_evals.cpython-313.pyc +0 -0
- package/scripts/codegen/generate_agents.py +89 -43
- package/scripts/codegen/generate_benchmarks.py +441 -0
- package/scripts/codegen/generate_evals.py +94 -16
- package/scripts/codegen/generate_events.py +0 -1
- package/lib/examples/AgentSpecsExample.js +0 -694
|
@@ -1,694 +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
|
-
/// <reference types="vite/client" />
|
|
7
|
-
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
8
|
-
import { PageLayout, IconButton } from '@primer/react';
|
|
9
|
-
import { SidebarCollapseIcon, SidebarExpandIcon } from '@primer/octicons-react';
|
|
10
|
-
import { AiAgentIcon } from '@datalayer/icons-react';
|
|
11
|
-
import { Blankslate } from '@primer/react/experimental';
|
|
12
|
-
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
13
|
-
import { Box } from '@datalayer/primer-addons';
|
|
14
|
-
import { AgentConfiguration } from '../config';
|
|
15
|
-
import { Chat } from '../chat';
|
|
16
|
-
import { DEFAULT_MODEL } from '../specs';
|
|
17
|
-
import { useIdentity } from '../identity';
|
|
18
|
-
import { useAgentsStore } from './utils/examplesStore';
|
|
19
|
-
import { ThemedProvider } from './utils/themedProvider';
|
|
20
|
-
import { isSpecSelection, getSpecId } from '../config/AgentConfiguration';
|
|
21
|
-
import { MockFileBrowser, MainContent, Header } from './components';
|
|
22
|
-
import { useChatStore } from '../stores';
|
|
23
|
-
// Create a query client for React Query
|
|
24
|
-
const queryClient = new QueryClient({
|
|
25
|
-
defaultOptions: {
|
|
26
|
-
queries: {
|
|
27
|
-
staleTime: 1000 * 60 * 5, // 5 minutes
|
|
28
|
-
gcTime: 1000 * 60 * 10, // 10 minutes
|
|
29
|
-
retry: 1,
|
|
30
|
-
refetchOnWindowFocus: false,
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
/**
|
|
35
|
-
* Hook to fetch codemode status and compute Jupyter error banner.
|
|
36
|
-
* Must be used inside QueryClientProvider.
|
|
37
|
-
*/
|
|
38
|
-
function useJupyterSandboxStatus(baseUrl, isConfigured, enableCodemode, useJupyterSandbox, codemodeStatusData) {
|
|
39
|
-
// REST polling removed — data comes exclusively via WS `agent.snapshot`.
|
|
40
|
-
const codemodeStatus = codemodeStatusData;
|
|
41
|
-
return React.useMemo(() => {
|
|
42
|
-
if (!isConfigured || !enableCodemode || !useJupyterSandbox) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
const sandbox = codemodeStatus?.sandbox;
|
|
46
|
-
if (!sandbox) {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
// Check if Jupyter variant is selected but not connected
|
|
50
|
-
if (sandbox.variant === 'jupyter' && !sandbox.jupyter_connected) {
|
|
51
|
-
return {
|
|
52
|
-
message: sandbox.jupyter_error
|
|
53
|
-
? `Jupyter Sandbox Error: ${sandbox.jupyter_error}`
|
|
54
|
-
: 'Jupyter Sandbox not connected. Code execution may fail.',
|
|
55
|
-
variant: 'danger',
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return undefined;
|
|
59
|
-
}, [isConfigured, enableCodemode, useJupyterSandbox, codemodeStatus]);
|
|
60
|
-
}
|
|
61
|
-
function ChatWithJupyterStatus({ baseUrl, isConfigured, enableCodemode, useJupyterSandbox, chatProps, }) {
|
|
62
|
-
const jupyterErrorBanner = useJupyterSandboxStatus(baseUrl, isConfigured, enableCodemode, useJupyterSandbox);
|
|
63
|
-
return _jsx(Chat, { ...chatProps, errorBanner: jupyterErrorBanner });
|
|
64
|
-
}
|
|
65
|
-
// Default configuration - use environment variable if available
|
|
66
|
-
// Note: Vercel AI connects to Jupyter server (8888), other protocols connect to agent-runtimes server (8765)
|
|
67
|
-
const DEFAULT_WS_URL = import.meta.env.VITE_ACP_WS_URL || 'ws://localhost:8765/api/v1/acp/ws';
|
|
68
|
-
const DEFAULT_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
|
|
69
|
-
const DEFAULT_AGENT_ID = 'demo-agent';
|
|
70
|
-
const DEFAULT_SYSTEM_PROMPT = 'You are a helpful AI assistant.';
|
|
71
|
-
const RIGHT_PANE_WIDTH = {
|
|
72
|
-
min: '420px',
|
|
73
|
-
default: '80vw',
|
|
74
|
-
max: '95vw',
|
|
75
|
-
};
|
|
76
|
-
// GitHub OAuth client ID - set via environment variable for security
|
|
77
|
-
// For development, you can create a GitHub OAuth App at:
|
|
78
|
-
// https://github.com/settings/developers
|
|
79
|
-
const GITHUB_CLIENT_ID = import.meta.env.VITE_GITHUB_CLIENT_ID || 'demo-client-id';
|
|
80
|
-
// Kaggle API token - set via environment variable
|
|
81
|
-
// Get your token at: https://www.kaggle.com/settings/account (API section)
|
|
82
|
-
// Download kaggle.json and use the "key" value
|
|
83
|
-
const KAGGLE_TOKEN = import.meta.env.VITE_KAGGLE_TOKEN || '';
|
|
84
|
-
const MOCK_SKILLS = [];
|
|
85
|
-
// Skills are now fetched dynamically from the backend API (/api/v1/skills)
|
|
86
|
-
// when Codemode is enabled. The AgentConfiguration component handles this.
|
|
87
|
-
// Build default identity providers from env vars (backward compatibility)
|
|
88
|
-
const DEFAULT_IDENTITY_PROVIDERS = {
|
|
89
|
-
...(GITHUB_CLIENT_ID
|
|
90
|
-
? {
|
|
91
|
-
github: {
|
|
92
|
-
type: 'oauth',
|
|
93
|
-
clientId: GITHUB_CLIENT_ID,
|
|
94
|
-
scopes: ['read:user', 'user:email', 'repo'],
|
|
95
|
-
},
|
|
96
|
-
}
|
|
97
|
-
: {}),
|
|
98
|
-
...(KAGGLE_TOKEN
|
|
99
|
-
? {
|
|
100
|
-
kaggle: {
|
|
101
|
-
type: 'token',
|
|
102
|
-
token: KAGGLE_TOKEN,
|
|
103
|
-
displayName: 'Kaggle',
|
|
104
|
-
iconUrl: 'https://www.kaggle.com/static/images/favicon.ico',
|
|
105
|
-
},
|
|
106
|
-
}
|
|
107
|
-
: {}),
|
|
108
|
-
};
|
|
109
|
-
const AgentRuntimeFormExample = ({ initialWsUrl = DEFAULT_WS_URL, initialBaseUrl = DEFAULT_BASE_URL, initialAgentName = DEFAULT_AGENT_ID, initialAgentLibrary = 'pydantic-ai', initialTransport = 'vercel-ai', initialModel = DEFAULT_MODEL, initialEnableCodemode = false, initialAllowDirectToolCalls = false, initialEnableToolReranker = false, initialSelectedMcpServers = [], autoSelectMcpServers = false, identityProviders = DEFAULT_IDENTITY_PROVIDERS,
|
|
110
|
-
// Deprecated props - merged into identityProviders for backward compat
|
|
111
|
-
githubClientId, kaggleToken, }) => {
|
|
112
|
-
const [wsUrl, setWsUrl] = useState(initialWsUrl);
|
|
113
|
-
const [baseUrl, setBaseUrl] = useState(initialBaseUrl);
|
|
114
|
-
const [agentName, setAgentName] = useState(initialAgentName);
|
|
115
|
-
const [selectedAgentId, setSelectedAgentId] = useState('new-agent');
|
|
116
|
-
const [agentLibrary, setAgentLibrary] = useState(initialAgentLibrary);
|
|
117
|
-
const [transport, setTransport] = useState(initialTransport);
|
|
118
|
-
const [extensions, setExtensions] = useState([]);
|
|
119
|
-
const [model, setModel] = useState(initialModel);
|
|
120
|
-
const [description, setDescription] = useState('');
|
|
121
|
-
const [goal, setGoal] = useState('');
|
|
122
|
-
const [systemPrompt, setSystemPrompt] = useState(DEFAULT_SYSTEM_PROMPT);
|
|
123
|
-
const [systemPromptCodemodeAddons, setSystemPromptCodemodeAddons] = useState('');
|
|
124
|
-
const [tools, setTools] = useState([]);
|
|
125
|
-
const [sandboxVariant, setSandboxVariant] = useState('');
|
|
126
|
-
const [selectedLibrarySpec, setSelectedLibrarySpec] = useState(null);
|
|
127
|
-
const [isConfigured, setIsConfigured] = useState(false);
|
|
128
|
-
// Agent capabilities state (moved from Header toggles)
|
|
129
|
-
const [selectedSkills, setSelectedSkills] = useState([]);
|
|
130
|
-
const [enableCodemode, setEnableCodemode] = useState(initialEnableCodemode);
|
|
131
|
-
const [useJupyterSandbox, setUseJupyterSandbox] = useState(false);
|
|
132
|
-
const [allowDirectToolCalls, setAllowDirectToolCalls] = useState(initialAllowDirectToolCalls);
|
|
133
|
-
const [enableToolReranker, setEnableToolReranker] = useState(initialEnableToolReranker);
|
|
134
|
-
const [selectedMcpServers, setSelectedMcpServers] = useState(initialSelectedMcpServers);
|
|
135
|
-
const autoSelectRef = useRef(false);
|
|
136
|
-
const enableSkills = selectedSkills.length > 0;
|
|
137
|
-
// =====================================================================
|
|
138
|
-
// Two-Container Codemode Architecture
|
|
139
|
-
// =====================================================================
|
|
140
|
-
//
|
|
141
|
-
// When Jupyter sandbox is enabled, the architecture uses two containers:
|
|
142
|
-
//
|
|
143
|
-
// ┌─────────────────────────────────────┐ ┌─────────────────────────────────┐
|
|
144
|
-
// │ agent-runtimes (port 8765) │ │ jupyter server (port 8888) │
|
|
145
|
-
// │ ┌─────────────────────────────┐ │ │ ┌─────────────────────────┐ │
|
|
146
|
-
// │ │ MCP Servers (stdio) │ │ │ │ Jupyter Kernel │ │
|
|
147
|
-
// │ │ - github, filesystem, etc │◀───┼──┼──│ executes generated │ │
|
|
148
|
-
// │ └─────────────────────────────┘ │ │ │ Python code │ │
|
|
149
|
-
// │ ┌─────────────────────────────┐ │ │ └─────────────────────────┘ │
|
|
150
|
-
// │ │ /api/v1/mcp/proxy/* │ │ │ │
|
|
151
|
-
// │ │ HTTP proxy for tool calls │ │ │ Tool calls go via HTTP to │
|
|
152
|
-
// │ └─────────────────────────────┘ │ │ agent-runtimes MCP proxy │
|
|
153
|
-
// └─────────────────────────────────────┘ └─────────────────────────────────┘
|
|
154
|
-
//
|
|
155
|
-
// The backend automatically configures mcp_proxy_url when jupyter_sandbox
|
|
156
|
-
// is provided, defaulting to http://0.0.0.0:8765/api/v1/mcp/proxy
|
|
157
|
-
//
|
|
158
|
-
// =====================================================================
|
|
159
|
-
// Jupyter sandbox URL (used when useJupyterSandbox is true)
|
|
160
|
-
// Can be configured via VITE_JUPYTER_SANDBOX_URL environment variable
|
|
161
|
-
const jupyterSandboxUrl = import.meta.env.VITE_JUPYTER_SANDBOX_URL ||
|
|
162
|
-
'http://localhost:8888/api/jupyter-server?token=60c1661cc408f978c309d04157af55c9588ff9557c9380e4fb50785750703da6';
|
|
163
|
-
const handleSelectedServersChange = React.useCallback((newServers) => {
|
|
164
|
-
const oldServers = selectedMcpServers;
|
|
165
|
-
// Find added and removed servers
|
|
166
|
-
const oldIds = new Set(oldServers.map(s => `${s.id}:${s.origin}`));
|
|
167
|
-
const newIds = new Set(newServers.map(s => `${s.id}:${s.origin}`));
|
|
168
|
-
const added = newServers.filter(s => !oldIds.has(`${s.id}:${s.origin}`));
|
|
169
|
-
const removed = oldServers.filter(s => !newIds.has(`${s.id}:${s.origin}`));
|
|
170
|
-
// Add system message about tool changes if there are any
|
|
171
|
-
if ((added.length > 0 || removed.length > 0) && isConfigured) {
|
|
172
|
-
let messageContent = '';
|
|
173
|
-
if (added.length > 0) {
|
|
174
|
-
const addedNames = added.map(s => `${s.id} (${s.origin})`).join(', ');
|
|
175
|
-
messageContent += `🔧 Tools added: ${addedNames}. `;
|
|
176
|
-
}
|
|
177
|
-
if (removed.length > 0) {
|
|
178
|
-
const removedNames = removed
|
|
179
|
-
.map(s => `${s.id} (${s.origin})`)
|
|
180
|
-
.join(', ');
|
|
181
|
-
messageContent += `🔧 Tools removed: ${removedNames}. You no longer have access to these tools.`;
|
|
182
|
-
}
|
|
183
|
-
if (messageContent) {
|
|
184
|
-
const systemMessage = {
|
|
185
|
-
id: `system-mcp-${Date.now()}`,
|
|
186
|
-
role: 'system',
|
|
187
|
-
content: messageContent.trim(),
|
|
188
|
-
createdAt: new Date(),
|
|
189
|
-
};
|
|
190
|
-
useChatStore.getState().addMessage(systemMessage);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
setSelectedMcpServers(newServers);
|
|
194
|
-
}, [selectedMcpServers, isConfigured]);
|
|
195
|
-
// Merge deprecated props into identityProviders for backward compatibility
|
|
196
|
-
const mergedIdentityProviders = React.useMemo(() => {
|
|
197
|
-
const merged = { ...identityProviders };
|
|
198
|
-
// Add deprecated githubClientId if provided and not already in config
|
|
199
|
-
if (githubClientId && !merged.github) {
|
|
200
|
-
merged.github = {
|
|
201
|
-
type: 'oauth',
|
|
202
|
-
clientId: githubClientId,
|
|
203
|
-
scopes: ['read:user', 'user:email', 'repo'],
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
// Add deprecated kaggleToken if provided and not already in config
|
|
207
|
-
if (kaggleToken && !merged.kaggle) {
|
|
208
|
-
merged.kaggle = {
|
|
209
|
-
type: 'token',
|
|
210
|
-
token: kaggleToken,
|
|
211
|
-
displayName: 'Kaggle',
|
|
212
|
-
iconUrl: 'https://www.kaggle.com/static/images/favicon.ico',
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
return merged;
|
|
216
|
-
}, [identityProviders, githubClientId, kaggleToken]);
|
|
217
|
-
// Extract OAuth providers for useIdentity hook (token providers are handled separately)
|
|
218
|
-
const oauthProvidersConfig = React.useMemo(() => {
|
|
219
|
-
const providers = {};
|
|
220
|
-
for (const [provider, config] of Object.entries(mergedIdentityProviders)) {
|
|
221
|
-
if (config.type === 'oauth') {
|
|
222
|
-
providers[provider] = {
|
|
223
|
-
clientId: config.clientId,
|
|
224
|
-
scopes: config.scopes,
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
return Object.keys(providers).length > 0 ? providers : undefined;
|
|
229
|
-
}, [mergedIdentityProviders]);
|
|
230
|
-
// Extract token-based providers for auto-connection
|
|
231
|
-
const tokenProviders = React.useMemo(() => {
|
|
232
|
-
const providers = [];
|
|
233
|
-
for (const [provider, config] of Object.entries(mergedIdentityProviders)) {
|
|
234
|
-
if (config.type === 'token') {
|
|
235
|
-
providers.push({
|
|
236
|
-
provider,
|
|
237
|
-
token: config.token,
|
|
238
|
-
displayName: config.displayName,
|
|
239
|
-
iconUrl: config.iconUrl,
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
return providers;
|
|
244
|
-
}, [mergedIdentityProviders]);
|
|
245
|
-
// Identity state - pass OAuth providers to configure them before callback is processed
|
|
246
|
-
const { connectWithToken, isConnected: isIdentityConnected } = useIdentity({
|
|
247
|
-
providers: oauthProvidersConfig,
|
|
248
|
-
autoHandleCallback: true,
|
|
249
|
-
});
|
|
250
|
-
// Track which token providers we've attempted to connect
|
|
251
|
-
const connectedTokenProvidersRef = useRef(new Set());
|
|
252
|
-
// Auto-connect all token-based providers if available and not already connected
|
|
253
|
-
useEffect(() => {
|
|
254
|
-
for (const { provider, token, displayName, iconUrl } of tokenProviders) {
|
|
255
|
-
// Skip if we've already attempted to connect this provider
|
|
256
|
-
if (connectedTokenProvidersRef.current.has(provider)) {
|
|
257
|
-
continue;
|
|
258
|
-
}
|
|
259
|
-
// Skip if already connected
|
|
260
|
-
if (isIdentityConnected(provider)) {
|
|
261
|
-
connectedTokenProvidersRef.current.add(provider);
|
|
262
|
-
continue;
|
|
263
|
-
}
|
|
264
|
-
// Mark as attempted
|
|
265
|
-
connectedTokenProvidersRef.current.add(provider);
|
|
266
|
-
connectWithToken(provider, token, { displayName, iconUrl })
|
|
267
|
-
.then(() => {
|
|
268
|
-
console.log(`[AgentRuntimeFormExample] ${provider} connected with token`);
|
|
269
|
-
})
|
|
270
|
-
.catch(err => {
|
|
271
|
-
console.error(`[AgentRuntimeFormExample] Failed to connect ${provider}:`, err);
|
|
272
|
-
// Remove from attempted set so we can retry
|
|
273
|
-
connectedTokenProvidersRef.current.delete(provider);
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
}, [tokenProviders, connectWithToken, isIdentityConnected]);
|
|
277
|
-
// Handle identity connect/disconnect
|
|
278
|
-
const handleIdentityConnect = useCallback((identity) => {
|
|
279
|
-
console.log('[AgentRuntimeFormExample] Identity connected:', identity.provider, identity.userInfo?.name || identity.userInfo?.email);
|
|
280
|
-
}, []);
|
|
281
|
-
const handleIdentityDisconnect = useCallback((provider) => {
|
|
282
|
-
console.log('[AgentRuntimeFormExample] Identity disconnected:', provider);
|
|
283
|
-
}, []);
|
|
284
|
-
// Handle codemode change - keep MCP server selections to scope codemode tools
|
|
285
|
-
const handleEnableCodemodeChange = (enabled) => {
|
|
286
|
-
setEnableCodemode(enabled);
|
|
287
|
-
if (!enabled) {
|
|
288
|
-
setAllowDirectToolCalls(false);
|
|
289
|
-
setEnableToolReranker(false);
|
|
290
|
-
setUseJupyterSandbox(false);
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
// UI state
|
|
294
|
-
const [activeSession, setActiveSession] = useState('session-1');
|
|
295
|
-
const [codemode, _] = useState(false);
|
|
296
|
-
const [showContextTree, setShowContextTree] = useState(false);
|
|
297
|
-
const [leftPaneVisible, setLeftPaneVisible] = useState(false);
|
|
298
|
-
const [rightPaneVisible, setRightPaneVisible] = useState(true);
|
|
299
|
-
const [isCreatingAgent, setIsCreatingAgent] = useState(false);
|
|
300
|
-
const [createError, setCreateError] = useState(null);
|
|
301
|
-
// Get agents and current agent from store
|
|
302
|
-
const agents = useAgentsStore(state => state.agents);
|
|
303
|
-
const currentAgent = useAgentsStore(state => state.getAgentById(selectedAgentId));
|
|
304
|
-
const toggleAgentStatus = useAgentsStore(state => state.toggleAgentStatus);
|
|
305
|
-
// Initialize transport from selected agent on mount
|
|
306
|
-
useEffect(() => {
|
|
307
|
-
if (currentAgent) {
|
|
308
|
-
setTransport(currentAgent.protocol);
|
|
309
|
-
setAgentName(currentAgent.id);
|
|
310
|
-
}
|
|
311
|
-
}, [currentAgent]);
|
|
312
|
-
// Auto-select MCP servers for codemode when requested
|
|
313
|
-
useEffect(() => {
|
|
314
|
-
if (!autoSelectMcpServers || autoSelectRef.current)
|
|
315
|
-
return;
|
|
316
|
-
if (!enableCodemode)
|
|
317
|
-
return;
|
|
318
|
-
if (selectedMcpServers.length > 0)
|
|
319
|
-
return;
|
|
320
|
-
if (!baseUrl)
|
|
321
|
-
return;
|
|
322
|
-
const loadServers = async () => {
|
|
323
|
-
try {
|
|
324
|
-
const response = await fetch(`${baseUrl}/api/v1/configure`);
|
|
325
|
-
if (!response.ok)
|
|
326
|
-
return;
|
|
327
|
-
const data = await response.json();
|
|
328
|
-
const servers = data?.mcpServers || [];
|
|
329
|
-
const available = servers.filter((s) => s.isAvailable);
|
|
330
|
-
if (available.length > 0) {
|
|
331
|
-
setSelectedMcpServers([{ id: available[0].id, origin: 'config' }]);
|
|
332
|
-
autoSelectRef.current = true;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
catch {
|
|
336
|
-
// no-op
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
void loadServers();
|
|
340
|
-
}, [autoSelectMcpServers, enableCodemode, selectedMcpServers, baseUrl]);
|
|
341
|
-
// Track previous MCP servers to detect changes
|
|
342
|
-
const prevMcpServersRef = useRef(selectedMcpServers);
|
|
343
|
-
// Cache for library specs (fetched on-demand, outside QueryClientProvider)
|
|
344
|
-
const librarySpecsRef = useRef(null);
|
|
345
|
-
const fetchLibrarySpecs = useCallback(async () => {
|
|
346
|
-
if (librarySpecsRef.current)
|
|
347
|
-
return librarySpecsRef.current;
|
|
348
|
-
try {
|
|
349
|
-
const response = await fetch(`${baseUrl}/api/v1/agents/library`);
|
|
350
|
-
if (!response.ok)
|
|
351
|
-
return [];
|
|
352
|
-
const data = await response.json();
|
|
353
|
-
librarySpecsRef.current = data;
|
|
354
|
-
return data;
|
|
355
|
-
}
|
|
356
|
-
catch {
|
|
357
|
-
return [];
|
|
358
|
-
}
|
|
359
|
-
}, [baseUrl]);
|
|
360
|
-
const handleAgentSelect = async (agentId) => {
|
|
361
|
-
setSelectedAgentId(agentId);
|
|
362
|
-
setCreateError(null);
|
|
363
|
-
if (agentId === 'new-agent') {
|
|
364
|
-
// Reset to defaults for new agent
|
|
365
|
-
setAgentName(DEFAULT_AGENT_ID);
|
|
366
|
-
setDescription('');
|
|
367
|
-
setGoal('');
|
|
368
|
-
setSystemPrompt(DEFAULT_SYSTEM_PROMPT);
|
|
369
|
-
setSystemPromptCodemodeAddons('');
|
|
370
|
-
setTools([]);
|
|
371
|
-
setSandboxVariant('');
|
|
372
|
-
setSelectedSkills([]);
|
|
373
|
-
setSelectedMcpServers([]);
|
|
374
|
-
setSelectedLibrarySpec(null);
|
|
375
|
-
setEnableCodemode(false);
|
|
376
|
-
setAllowDirectToolCalls(false);
|
|
377
|
-
setEnableToolReranker(false);
|
|
378
|
-
setUseJupyterSandbox(false);
|
|
379
|
-
setTransport('vercel-ai');
|
|
380
|
-
}
|
|
381
|
-
else if (isSpecSelection(agentId)) {
|
|
382
|
-
// Populate form fields from the selected library spec
|
|
383
|
-
const specId = getSpecId(agentId);
|
|
384
|
-
const specs = await fetchLibrarySpecs();
|
|
385
|
-
const spec = specs.find(s => s.id === specId);
|
|
386
|
-
if (spec) {
|
|
387
|
-
setSelectedLibrarySpec(spec);
|
|
388
|
-
setAgentName(spec.id);
|
|
389
|
-
setDescription(spec.description || '');
|
|
390
|
-
setGoal(spec.goal || '');
|
|
391
|
-
setSystemPrompt(spec.systemPrompt || spec.goal || DEFAULT_SYSTEM_PROMPT);
|
|
392
|
-
setSystemPromptCodemodeAddons(spec.systemPromptCodemodeAddons || '');
|
|
393
|
-
setTools(spec.tools || []);
|
|
394
|
-
setSandboxVariant(spec.sandboxVariant || '');
|
|
395
|
-
if (spec.model) {
|
|
396
|
-
setModel(spec.model);
|
|
397
|
-
}
|
|
398
|
-
if (spec.protocol === 'ag-ui' ||
|
|
399
|
-
spec.protocol === 'acp' ||
|
|
400
|
-
spec.protocol === 'vercel-ai' ||
|
|
401
|
-
spec.protocol === 'a2a') {
|
|
402
|
-
setTransport(spec.protocol);
|
|
403
|
-
}
|
|
404
|
-
setSelectedMcpServers((spec.mcpServers || []).map(server => ({
|
|
405
|
-
id: server.id,
|
|
406
|
-
origin: 'config',
|
|
407
|
-
})));
|
|
408
|
-
setSelectedSkills(spec.skills || []);
|
|
409
|
-
const codemodeConfig = spec.codemode && typeof spec.codemode === 'object'
|
|
410
|
-
? spec.codemode
|
|
411
|
-
: null;
|
|
412
|
-
const codemodeEnabled = !!spec.systemPromptCodemodeAddons || !!codemodeConfig?.enabled;
|
|
413
|
-
setEnableCodemode(codemodeEnabled);
|
|
414
|
-
setAllowDirectToolCalls(Boolean(codemodeConfig?.allowDirectToolCalls ??
|
|
415
|
-
codemodeConfig?.allow_direct_tool_calls));
|
|
416
|
-
setEnableToolReranker(Boolean(codemodeConfig?.enableToolReranker ??
|
|
417
|
-
codemodeConfig?.enable_tool_reranker));
|
|
418
|
-
setUseJupyterSandbox(spec.sandboxVariant === 'jupyter');
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
setSelectedLibrarySpec(null);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
else {
|
|
425
|
-
setSelectedLibrarySpec(null);
|
|
426
|
-
const agent = agents.find(a => a.id === agentId);
|
|
427
|
-
if (agent) {
|
|
428
|
-
setAgentName(agent.id);
|
|
429
|
-
setTransport(agent.protocol);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
/**
|
|
434
|
-
* Create a new agent via the API
|
|
435
|
-
*/
|
|
436
|
-
const createAgentOnServer = useCallback(async () => {
|
|
437
|
-
setIsCreatingAgent(true);
|
|
438
|
-
setCreateError(null);
|
|
439
|
-
try {
|
|
440
|
-
// Resolve spec ID if creating from a library spec
|
|
441
|
-
const specId = isSpecSelection(selectedAgentId)
|
|
442
|
-
? getSpecId(selectedAgentId)
|
|
443
|
-
: undefined;
|
|
444
|
-
const response = await fetch(`${baseUrl}/api/v1/agents`, {
|
|
445
|
-
method: 'POST',
|
|
446
|
-
headers: {
|
|
447
|
-
'Content-Type': 'application/json',
|
|
448
|
-
},
|
|
449
|
-
body: JSON.stringify({
|
|
450
|
-
name: agentName,
|
|
451
|
-
description: description || `Agent created via UI (${agentLibrary})`,
|
|
452
|
-
goal: goal || undefined,
|
|
453
|
-
agent_library: agentLibrary,
|
|
454
|
-
transport: transport,
|
|
455
|
-
model: model,
|
|
456
|
-
system_prompt: systemPrompt || DEFAULT_SYSTEM_PROMPT,
|
|
457
|
-
system_prompt_codemode_addons: systemPromptCodemodeAddons || undefined,
|
|
458
|
-
tools: tools,
|
|
459
|
-
sandbox_variant: sandboxVariant || undefined,
|
|
460
|
-
enable_skills: enableSkills,
|
|
461
|
-
enable_codemode: enableCodemode,
|
|
462
|
-
allow_direct_tool_calls: allowDirectToolCalls,
|
|
463
|
-
enable_tool_reranker: enableToolReranker,
|
|
464
|
-
selected_mcp_servers: selectedMcpServers,
|
|
465
|
-
skills: selectedSkills,
|
|
466
|
-
jupyter_sandbox: useJupyterSandbox ? jupyterSandboxUrl : undefined,
|
|
467
|
-
agent_spec: selectedLibrarySpec || undefined,
|
|
468
|
-
...(specId ? { agent_spec_id: specId } : {}),
|
|
469
|
-
}),
|
|
470
|
-
});
|
|
471
|
-
if (!response.ok) {
|
|
472
|
-
const errorData = await response
|
|
473
|
-
.json()
|
|
474
|
-
.catch(() => ({ detail: 'Unknown error' }));
|
|
475
|
-
throw new Error(errorData.detail || `Failed to create agent: ${response.status}`);
|
|
476
|
-
}
|
|
477
|
-
const data = await response.json();
|
|
478
|
-
console.log('[AgentRuntimeExample] Agent created:', data);
|
|
479
|
-
return data.id;
|
|
480
|
-
}
|
|
481
|
-
catch (error) {
|
|
482
|
-
const errorMessage = error instanceof Error ? error.message : 'Failed to create agent';
|
|
483
|
-
console.error('[AgentRuntimeExample] Error creating agent:', errorMessage);
|
|
484
|
-
setCreateError(errorMessage);
|
|
485
|
-
return null;
|
|
486
|
-
}
|
|
487
|
-
finally {
|
|
488
|
-
setIsCreatingAgent(false);
|
|
489
|
-
}
|
|
490
|
-
}, [
|
|
491
|
-
baseUrl,
|
|
492
|
-
agentName,
|
|
493
|
-
agentLibrary,
|
|
494
|
-
description,
|
|
495
|
-
goal,
|
|
496
|
-
transport,
|
|
497
|
-
model,
|
|
498
|
-
systemPrompt,
|
|
499
|
-
systemPromptCodemodeAddons,
|
|
500
|
-
tools,
|
|
501
|
-
sandboxVariant,
|
|
502
|
-
enableSkills,
|
|
503
|
-
enableCodemode,
|
|
504
|
-
allowDirectToolCalls,
|
|
505
|
-
enableToolReranker,
|
|
506
|
-
selectedMcpServers,
|
|
507
|
-
selectedSkills,
|
|
508
|
-
useJupyterSandbox,
|
|
509
|
-
jupyterSandboxUrl,
|
|
510
|
-
selectedAgentId,
|
|
511
|
-
selectedLibrarySpec,
|
|
512
|
-
]);
|
|
513
|
-
/**
|
|
514
|
-
* Delete an agent via the API
|
|
515
|
-
*/
|
|
516
|
-
const deleteAgentOnServer = useCallback(async (agentId) => {
|
|
517
|
-
try {
|
|
518
|
-
const response = await fetch(`${baseUrl}/api/v1/agents/${agentId}`, {
|
|
519
|
-
method: 'DELETE',
|
|
520
|
-
});
|
|
521
|
-
if (!response.ok) {
|
|
522
|
-
console.warn(`[AgentRuntimeExample] Failed to delete agent: ${response.status}`);
|
|
523
|
-
return false;
|
|
524
|
-
}
|
|
525
|
-
console.log('[AgentRuntimeExample] Agent deleted:', agentId);
|
|
526
|
-
return true;
|
|
527
|
-
}
|
|
528
|
-
catch (error) {
|
|
529
|
-
console.warn('[AgentRuntimeExample] Error deleting agent:', error);
|
|
530
|
-
return false;
|
|
531
|
-
}
|
|
532
|
-
}, [baseUrl]);
|
|
533
|
-
// Track MCP servers for reference (no longer triggers recreation)
|
|
534
|
-
// MCP server updates are now handled via PATCH endpoint by McpServerManager
|
|
535
|
-
useEffect(() => {
|
|
536
|
-
prevMcpServersRef.current = selectedMcpServers;
|
|
537
|
-
}, [selectedMcpServers]);
|
|
538
|
-
// True when creating a new agent (blank or from a library spec)
|
|
539
|
-
const isNewMode = selectedAgentId === 'new-agent' || isSpecSelection(selectedAgentId);
|
|
540
|
-
const handleConnect = async () => {
|
|
541
|
-
// For existing agents (not new-agent or spec), ensure transport and agentName are set
|
|
542
|
-
if (!isNewMode) {
|
|
543
|
-
const agent = agents.find(a => a.id === selectedAgentId);
|
|
544
|
-
if (agent) {
|
|
545
|
-
setTransport(agent.protocol);
|
|
546
|
-
setAgentName(agent.id);
|
|
547
|
-
}
|
|
548
|
-
setIsConfigured(true);
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
// For vercel-ai-jupyter, no server-side agent creation needed
|
|
552
|
-
// It uses Jupyter server's built-in agent endpoint
|
|
553
|
-
if (transport === 'vercel-ai-jupyter') {
|
|
554
|
-
setIsConfigured(true);
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
// For new agents, first create the agent on the server
|
|
558
|
-
if (transport === 'acp' && wsUrl && agentName) {
|
|
559
|
-
const createdAgentId = await createAgentOnServer();
|
|
560
|
-
if (createdAgentId) {
|
|
561
|
-
setAgentName(createdAgentId);
|
|
562
|
-
setIsConfigured(true);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
else if ((transport === 'ag-ui' ||
|
|
566
|
-
transport === 'vercel-ai' ||
|
|
567
|
-
transport === 'a2a') &&
|
|
568
|
-
baseUrl &&
|
|
569
|
-
agentName) {
|
|
570
|
-
const createdAgentId = await createAgentOnServer();
|
|
571
|
-
if (createdAgentId) {
|
|
572
|
-
setAgentName(createdAgentId);
|
|
573
|
-
setIsConfigured(true);
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
};
|
|
577
|
-
const handleReset = async () => {
|
|
578
|
-
// Delete the agent from the server if we created it
|
|
579
|
-
if ((selectedAgentId === 'new-agent' || isSpecSelection(selectedAgentId)) &&
|
|
580
|
-
agentName) {
|
|
581
|
-
await deleteAgentOnServer(agentName);
|
|
582
|
-
}
|
|
583
|
-
setIsConfigured(false);
|
|
584
|
-
};
|
|
585
|
-
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(ThemedProvider, { children: _jsxs(PageLayout, { containerWidth: "full", children: [_jsx(Header, { activeSession: activeSession, agentName: isNewMode ? undefined : currentAgent?.name, agentDescription: isNewMode ? undefined : currentAgent?.description, agentStatus: currentAgent?.status, showContextTree: showContextTree, isNewAgent: isNewMode, isConfigured: isConfigured, onSessionChange: setActiveSession, onToggleContextTree: () => setShowContextTree(!showContextTree), onToggleStatus: currentAgent
|
|
586
|
-
? () => toggleAgentStatus(currentAgent.id)
|
|
587
|
-
: undefined }), leftPaneVisible ? (_jsxs(_Fragment, { children: [_jsx(Box, { sx: {
|
|
588
|
-
position: 'fixed',
|
|
589
|
-
left: 0,
|
|
590
|
-
top: '50%',
|
|
591
|
-
transform: 'translateY(-50%)',
|
|
592
|
-
zIndex: 100,
|
|
593
|
-
}, children: _jsx(IconButton, { icon: SidebarCollapseIcon, "aria-label": "Collapse left pane", size: "small", onClick: () => setLeftPaneVisible(false), sx: {
|
|
594
|
-
borderRadius: '0 6px 6px 0',
|
|
595
|
-
bg: 'canvas.default',
|
|
596
|
-
border: '1px solid',
|
|
597
|
-
borderLeft: 'none',
|
|
598
|
-
borderColor: 'border.default',
|
|
599
|
-
} }) }), _jsx(PageLayout.Pane, { position: "start", "aria-label": "File browser pane", resizable: true, sticky: true, width: { min: '250px', default: '300px', max: '90px' }, children: isNewMode ? (_jsxs(Blankslate, { border: true, spacious: true, narrow: true, children: [_jsx(Blankslate.Visual, { children: _jsx(AiAgentIcon, { colored: true, size: 48 }) }), _jsx(Blankslate.Heading, { children: "Agent Runtimes" }), _jsx(Box, { sx: { textAlign: 'center' }, children: _jsx(Blankslate.Description, { children: "Expose AI Agents through multiple protocols." }) })] })) : (_jsx(MockFileBrowser, { codemode: codemode })) })] })) : (_jsx(Box, { sx: {
|
|
600
|
-
position: 'fixed',
|
|
601
|
-
left: 0,
|
|
602
|
-
top: '50%',
|
|
603
|
-
transform: 'translateY(-50%)',
|
|
604
|
-
zIndex: 100,
|
|
605
|
-
}, children: _jsx(IconButton, { icon: SidebarExpandIcon, "aria-label": "Expand left pane", size: "small", onClick: () => setLeftPaneVisible(true), sx: {
|
|
606
|
-
borderRadius: '0 6px 6px 0',
|
|
607
|
-
bg: 'canvas.default',
|
|
608
|
-
border: '1px solid',
|
|
609
|
-
borderLeft: 'none',
|
|
610
|
-
borderColor: 'border.default',
|
|
611
|
-
} }) })), _jsx(PageLayout.Content, { children: _jsx(MainContent, { showWelcomeMessage: true, isConfigured: isConfigured, baseUrl: baseUrl, agentId: currentAgent?.id || agentName, enableCodemode: enableCodemode, selectedMcpServers: selectedMcpServers, onSelectedMcpServersChange: handleSelectedServersChange, onMcpServersChange: () => {
|
|
612
|
-
// Trigger codemode tool regeneration when MCP servers change at runtime
|
|
613
|
-
console.log('[AgentRuntimeFormExample] MCP servers changed, regenerating codemode tools...');
|
|
614
|
-
// The Chat component will pick up the new selectedMcpServers via props
|
|
615
|
-
} }) }), rightPaneVisible ? (_jsxs(_Fragment, { children: [_jsx(Box, { sx: {
|
|
616
|
-
position: 'fixed',
|
|
617
|
-
right: 0,
|
|
618
|
-
top: '50%',
|
|
619
|
-
transform: 'translateY(-50%)',
|
|
620
|
-
zIndex: 100,
|
|
621
|
-
}, children: _jsx(IconButton, { icon: SidebarCollapseIcon, "aria-label": "Collapse right pane", size: "small", onClick: () => setRightPaneVisible(false), sx: {
|
|
622
|
-
borderRadius: '6px 0 0 6px',
|
|
623
|
-
bg: 'canvas.default',
|
|
624
|
-
border: '1px solid',
|
|
625
|
-
borderRight: 'none',
|
|
626
|
-
borderColor: 'border.default',
|
|
627
|
-
} }) }), _jsx(PageLayout.Pane, { position: "end", "aria-label": "Agent configuration and chat pane", width: RIGHT_PANE_WIDTH, resizable: true, sticky: true, children: _jsx(Box, { sx: {
|
|
628
|
-
height: '100%',
|
|
629
|
-
display: 'flex',
|
|
630
|
-
flexDirection: 'column',
|
|
631
|
-
p: 2,
|
|
632
|
-
}, children: !isConfigured ? (_jsx(AgentConfiguration, { agentLibrary: agentLibrary, protocol: currentAgent?.protocol || transport, extensions: extensions, wsUrl: wsUrl, baseUrl: baseUrl, agentName: agentName, description: description, goal: goal, model: model, systemPrompt: systemPrompt, systemPromptCodemodeAddons: systemPromptCodemodeAddons, tools: tools, sandboxVariant: sandboxVariant, agents: agents, selectedAgentId: selectedAgentId, isCreatingAgent: isCreatingAgent, createError: createError, enableCodemode: enableCodemode, useJupyterSandbox: useJupyterSandbox, allowDirectToolCalls: allowDirectToolCalls, enableToolReranker: enableToolReranker, availableSkills: MOCK_SKILLS, selectedSkills: selectedSkills, selectedMcpServers: selectedMcpServers, identityProviders: oauthProvidersConfig, onIdentityConnect: handleIdentityConnect, onIdentityDisconnect: handleIdentityDisconnect, onAgentLibraryChange: setAgentLibrary, onTransportChange: setTransport, onExtensionsChange: setExtensions, onWsUrlChange: setWsUrl, onBaseUrlChange: setBaseUrl, onAgentNameChange: setAgentName, onDescriptionChange: setDescription, onGoalChange: setGoal, onModelChange: setModel, onSystemPromptChange: setSystemPrompt, onSystemPromptCodemodeAddonsChange: setSystemPromptCodemodeAddons, onToolsChange: setTools, onSandboxVariantChange: setSandboxVariant, onAgentSelect: handleAgentSelect, onConnect: handleConnect, onEnableCodemodeChange: handleEnableCodemodeChange, onUseJupyterSandboxChange: setUseJupyterSandbox, onAllowDirectToolCallsChange: setAllowDirectToolCalls, onEnableToolRerankerChange: setEnableToolReranker, onSelectedSkillsChange: setSelectedSkills, onSelectedMcpServersChange: setSelectedMcpServers })) : (
|
|
633
|
-
/* Chat Interface */
|
|
634
|
-
_jsx(Box, { sx: { flex: 1, minHeight: 0 }, children: _jsx(ChatWithJupyterStatus, { baseUrl: baseUrl, isConfigured: isConfigured, enableCodemode: enableCodemode, useJupyterSandbox: useJupyterSandbox, chatProps: {
|
|
635
|
-
protocol: currentAgent?.protocol || transport,
|
|
636
|
-
extensions: extensions,
|
|
637
|
-
wsUrl: wsUrl,
|
|
638
|
-
baseUrl: baseUrl,
|
|
639
|
-
agentId: currentAgent?.id || agentName,
|
|
640
|
-
title: currentAgent?.name || agentName || 'AI Assistant',
|
|
641
|
-
autoConnect: true,
|
|
642
|
-
autoFocus: true,
|
|
643
|
-
placeholder: 'Type your message to the agent...',
|
|
644
|
-
height: 'calc(100vh - 150px)',
|
|
645
|
-
showModelSelector: true,
|
|
646
|
-
showToolsMenu: true,
|
|
647
|
-
showSkillsMenu: true,
|
|
648
|
-
codemodeEnabled: enableCodemode,
|
|
649
|
-
initialModel: model,
|
|
650
|
-
mcpServers: selectedMcpServers,
|
|
651
|
-
initialSkills: selectedSkills,
|
|
652
|
-
identityProviders: oauthProvidersConfig,
|
|
653
|
-
onIdentityConnect: handleIdentityConnect,
|
|
654
|
-
onIdentityDisconnect: handleIdentityDisconnect,
|
|
655
|
-
suggestions: [
|
|
656
|
-
{
|
|
657
|
-
title: '👋 Say hello',
|
|
658
|
-
message: 'Hello! What can you help me with today?',
|
|
659
|
-
},
|
|
660
|
-
{
|
|
661
|
-
title: '💡 Get ideas',
|
|
662
|
-
message: 'Can you suggest some creative project ideas?',
|
|
663
|
-
},
|
|
664
|
-
{
|
|
665
|
-
title: '📝 Explain concepts',
|
|
666
|
-
message: 'Can you explain how AI agents work?',
|
|
667
|
-
},
|
|
668
|
-
{
|
|
669
|
-
title: '🔧 Help with code',
|
|
670
|
-
message: 'Can you help me write some Python code?',
|
|
671
|
-
},
|
|
672
|
-
],
|
|
673
|
-
onDisconnect: handleReset,
|
|
674
|
-
onMessageSent: (_content) => {
|
|
675
|
-
// Message sent
|
|
676
|
-
},
|
|
677
|
-
onMessageReceived: (_message) => {
|
|
678
|
-
// Message received
|
|
679
|
-
},
|
|
680
|
-
} }) })) }) })] })) : (_jsx(Box, { sx: {
|
|
681
|
-
position: 'fixed',
|
|
682
|
-
right: 0,
|
|
683
|
-
top: '50%',
|
|
684
|
-
transform: 'translateY(-50%)',
|
|
685
|
-
zIndex: 100,
|
|
686
|
-
}, children: _jsx(IconButton, { icon: SidebarExpandIcon, "aria-label": "Expand right pane", size: "small", onClick: () => setRightPaneVisible(true), sx: {
|
|
687
|
-
borderRadius: '6px 0 0 6px',
|
|
688
|
-
bg: 'canvas.default',
|
|
689
|
-
border: '1px solid',
|
|
690
|
-
borderRight: 'none',
|
|
691
|
-
borderColor: 'border.default',
|
|
692
|
-
} }) }))] }) }) }));
|
|
693
|
-
};
|
|
694
|
-
export default AgentRuntimeFormExample;
|