@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
|
@@ -10,7 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
* sidebar that streams WebSocket messages to and from the
|
|
11
11
|
* `/configure/sandbox/ws` endpoint.
|
|
12
12
|
*
|
|
13
|
-
* - Creates a local agent (spec:
|
|
13
|
+
* - Creates a local agent (spec: example-full) with codemode enabled
|
|
14
14
|
* - SegmentedControl toggles between "eval" and "jupyter" variants
|
|
15
15
|
* - Sidebar shows live sandbox status, WebSocket event log, and an
|
|
16
16
|
* interrupt button
|
|
@@ -31,8 +31,8 @@ import { Chat } from '../chat';
|
|
|
31
31
|
import { SANDBOX_STATUS_COLORS, SANDBOX_STATUS_LABELS } from '../types/sandbox';
|
|
32
32
|
// ─── Constants ─────────────────────────────────────────────────────────────
|
|
33
33
|
const queryClient = new QueryClient();
|
|
34
|
-
const AGENT_NAME = 'sandbox-
|
|
35
|
-
const AGENT_SPEC_ID = '
|
|
34
|
+
const AGENT_NAME = 'sandbox-example-agent';
|
|
35
|
+
const AGENT_SPEC_ID = 'example-full';
|
|
36
36
|
const DEFAULT_LOCAL_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
|
|
37
37
|
let _logId = 0;
|
|
38
38
|
function tsNow() {
|
|
@@ -360,7 +360,7 @@ const AgentSandboxInner = ({ onLogout, }) => {
|
|
|
360
360
|
flexDirection: 'column',
|
|
361
361
|
alignItems: 'center',
|
|
362
362
|
justifyContent: 'center',
|
|
363
|
-
height: '
|
|
363
|
+
height: '100%',
|
|
364
364
|
gap: 3,
|
|
365
365
|
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Launching sandbox demo\u2026" })] }));
|
|
366
366
|
}
|
|
@@ -454,7 +454,8 @@ const AgentSandboxInner = ({ onLogout, }) => {
|
|
|
454
454
|
fontWeight: entry.direction === 'sent' ? 600 : 400,
|
|
455
455
|
}, children: [entry.direction === 'sent' ? '▲ ' : '▼ ', entry.raw] })] }, entry.id)))) })] })] }));
|
|
456
456
|
return (_jsxs(Box, { sx: {
|
|
457
|
-
height: '
|
|
457
|
+
height: '100%',
|
|
458
|
+
minHeight: 0,
|
|
458
459
|
display: 'flex',
|
|
459
460
|
flexDirection: 'column',
|
|
460
461
|
}, children: [isReconnectedAgent && (_jsx(Box, { sx: {
|
|
@@ -462,7 +463,7 @@ const AgentSandboxInner = ({ onLogout, }) => {
|
|
|
462
463
|
py: 1,
|
|
463
464
|
borderBottom: '1px solid',
|
|
464
465
|
borderColor: 'border.default',
|
|
465
|
-
}, children: _jsx(Text, { sx: { color: 'fg.muted', fontSize: 0 }, children: "Agent already running \u2014 reconnected." }) })), _jsxs(Box, { sx: { flex: 1, minHeight: 0, display: 'flex' }, children: [_jsx(Box, { sx: { flex: 1, minWidth: 0 }, children: _jsxs(Box, { sx: { position: 'relative', height: '100%' }, children: [_jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: "Sandbox Agent", placeholder: "Ask the agent to write and run code\u2026", showHeader: true, showNewChatButton: true, showClearButton: false, 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(SegmentedControl, { "aria-label": "Sandbox variant", size: "small", onChange: index => {
|
|
466
|
+
}, children: _jsx(Text, { sx: { color: 'fg.muted', fontSize: 0 }, children: "Agent already running \u2014 reconnected." }) })), _jsxs(Box, { sx: { flex: 1, minHeight: 0, display: 'flex' }, children: [_jsx(Box, { sx: { flex: 1, minWidth: 0 }, children: _jsxs(Box, { sx: { position: 'relative', height: '100%' }, children: [_jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: "Sandbox Agent", brandIcon: _jsx(TerminalIcon, { size: 16 }), placeholder: "Ask the agent to write and run code\u2026", showHeader: true, showNewChatButton: true, showClearButton: false, 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(SegmentedControl, { "aria-label": "Sandbox variant", size: "small", onChange: index => {
|
|
466
467
|
if (isTransitionLocked)
|
|
467
468
|
return;
|
|
468
469
|
void switchVariant(index === 0 ? 'eval' : 'jupyter');
|
|
@@ -16,8 +16,8 @@ import { uniqueAgentId } from './utils/agentId';
|
|
|
16
16
|
import { Chat } from '../chat';
|
|
17
17
|
import { useSkills, useSkillActions } from '../hooks';
|
|
18
18
|
const queryClient = new QueryClient();
|
|
19
|
-
const AGENT_NAME = 'skills-
|
|
20
|
-
const AGENT_SPEC_ID = '
|
|
19
|
+
const AGENT_NAME = 'skills-example-agent';
|
|
20
|
+
const AGENT_SPEC_ID = 'example-skills';
|
|
21
21
|
const DEFAULT_LOCAL_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
|
|
22
22
|
const SkillCard = ({ skill, onToggle, onToggleApproval }) => {
|
|
23
23
|
const [showDefinition, setShowDefinition] = useState(false);
|
|
@@ -111,13 +111,13 @@ const AgentSkillsInner = ({ onLogout }) => {
|
|
|
111
111
|
setHookError(null);
|
|
112
112
|
setIsReconnectedAgent(false);
|
|
113
113
|
try {
|
|
114
|
-
// Create local agent runtime using the
|
|
114
|
+
// Create local agent runtime using the example-full spec.
|
|
115
115
|
// The spec contains module-based, package-based and file-based skills.
|
|
116
116
|
const response = await authFetch(`${agentBaseUrl}/api/v1/agents`, {
|
|
117
117
|
method: 'POST',
|
|
118
118
|
body: JSON.stringify({
|
|
119
119
|
name: agentName,
|
|
120
|
-
description: 'Agent with skills
|
|
120
|
+
description: 'Agent with skills example - module, package and file based skills',
|
|
121
121
|
agent_library: 'pydantic-ai',
|
|
122
122
|
transport: 'vercel-ai',
|
|
123
123
|
agent_spec_id: AGENT_SPEC_ID,
|
|
@@ -178,7 +178,7 @@ const AgentSkillsInner = ({ onLogout }) => {
|
|
|
178
178
|
justifyContent: 'center',
|
|
179
179
|
height: '100vh',
|
|
180
180
|
gap: 3,
|
|
181
|
-
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Launching skills
|
|
181
|
+
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Launching skills example agent..." })] }));
|
|
182
182
|
}
|
|
183
183
|
if (runtimeStatus === 'error' || hookError) {
|
|
184
184
|
return _jsx(ErrorView, { error: hookError, onLogout: onLogout });
|
|
@@ -192,7 +192,7 @@ const AgentSkillsInner = ({ onLogout }) => {
|
|
|
192
192
|
py: 1,
|
|
193
193
|
borderBottom: '1px solid',
|
|
194
194
|
borderColor: 'border.default',
|
|
195
|
-
}, children: _jsx(Text, { sx: { color: 'fg.muted', fontSize: 0 }, children: "Agent already running - reconnected." }) })), _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: `Skills Demo Agent`, placeholder: "Ask the agent to use its skills...", showHeader: true, showNewChatButton: true, showClearButton: false, showTokenUsage: true, showSkillsMenu: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, headerActions: _jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: _jsxs(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: ["Skills: ", skills.length] }) }), suggestions: [
|
|
195
|
+
}, children: _jsx(Text, { sx: { color: 'fg.muted', fontSize: 0 }, children: "Agent already running - reconnected." }) })), _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: `Skills Demo Agent`, brandIcon: _jsx(BriefcaseIcon, { size: 16 }), placeholder: "Ask the agent to use its skills...", showHeader: true, showNewChatButton: true, showClearButton: false, showTokenUsage: true, showSkillsMenu: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, headerActions: _jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: _jsxs(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: ["Skills: ", skills.length] }) }), suggestions: [
|
|
196
196
|
{
|
|
197
197
|
title: 'List available skills',
|
|
198
198
|
message: 'List all your available skills and what they can do.',
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* The parent agent orchestrates a researcher and a writer subagent,
|
|
6
6
|
* delegating tasks and combining results for the user.
|
|
7
7
|
*
|
|
8
|
-
* - Creates a local agent from the '
|
|
8
|
+
* - Creates a local agent from the 'example-subagents' spec
|
|
9
9
|
* - Shows a Chat component for interacting with the orchestrator
|
|
10
10
|
* - Sidebar displays subagent info and active task status
|
|
11
11
|
*/
|
|
@@ -10,7 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
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 a local agent from the '
|
|
13
|
+
* - Creates a local agent from the 'example-subagents' spec
|
|
14
14
|
* - Shows a Chat component for interacting with the orchestrator
|
|
15
15
|
* - Sidebar displays subagent info and active task status
|
|
16
16
|
*/
|
|
@@ -24,8 +24,8 @@ 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
|
-
const AGENT_NAME = 'subagents-
|
|
28
|
-
const AGENT_SPEC_ID = '
|
|
27
|
+
const AGENT_NAME = 'subagents-example-agent';
|
|
28
|
+
const AGENT_SPEC_ID = 'example-subagents';
|
|
29
29
|
const DEFAULT_LOCAL_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
|
|
30
30
|
const SUBAGENTS = [
|
|
31
31
|
{
|
|
@@ -73,7 +73,7 @@ const AgentSubagentsInner = ({ onLogout, }) => {
|
|
|
73
73
|
method: 'POST',
|
|
74
74
|
body: JSON.stringify({
|
|
75
75
|
name: agentName,
|
|
76
|
-
description: 'Subagents
|
|
76
|
+
description: 'Subagents example – multi-agent delegation with researcher and writer',
|
|
77
77
|
agent_library: 'pydantic-ai',
|
|
78
78
|
transport: 'vercel-ai',
|
|
79
79
|
agent_spec_id: AGENT_SPEC_ID,
|
|
@@ -134,7 +134,7 @@ const AgentSubagentsInner = ({ onLogout, }) => {
|
|
|
134
134
|
justifyContent: 'center',
|
|
135
135
|
height: '100vh',
|
|
136
136
|
gap: 3,
|
|
137
|
-
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Launching subagents
|
|
137
|
+
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Launching subagents example agent..." })] }));
|
|
138
138
|
}
|
|
139
139
|
if (runtimeStatus === 'error' || hookError) {
|
|
140
140
|
return _jsx(ErrorView, { error: hookError, onLogout: onLogout });
|
|
@@ -152,7 +152,7 @@ const AgentSubagentsInner = ({ onLogout, }) => {
|
|
|
152
152
|
borderBottom: '1px solid',
|
|
153
153
|
borderColor: 'border.default',
|
|
154
154
|
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", 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: [
|
|
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: [
|
|
156
156
|
{
|
|
157
157
|
title: 'Research & write',
|
|
158
158
|
message: 'Research the pros and cons of Python async patterns and write a summary.',
|
|
@@ -9,14 +9,15 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
|
9
9
|
import { Box } from '@datalayer/primer-addons';
|
|
10
10
|
import { AuthRequiredView, ErrorView } from './components';
|
|
11
11
|
import { Spinner, Text } from '@primer/react';
|
|
12
|
+
import { CheckCircleIcon } from '@primer/octicons-react';
|
|
12
13
|
import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
|
|
13
14
|
import { ThemedProvider } from './utils/themedProvider';
|
|
14
15
|
import { uniqueAgentId } from './utils/agentId';
|
|
15
16
|
import { Chat } from '../chat';
|
|
16
|
-
import {
|
|
17
|
+
import { useAgentRuntimeApprovals } from '../stores/agentRuntimeStore';
|
|
17
18
|
const queryClient = new QueryClient();
|
|
18
|
-
const AGENT_NAME_PREFIX = 'tool-approval-
|
|
19
|
-
const DEFAULT_AGENT_SPEC_ID = '
|
|
19
|
+
const AGENT_NAME_PREFIX = 'tool-approval-example-agent';
|
|
20
|
+
const DEFAULT_AGENT_SPEC_ID = 'example-tool-approvals';
|
|
20
21
|
const DEFAULT_LOCAL_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
|
|
21
22
|
const getSelectedAgentSpecIdFromUi = () => {
|
|
22
23
|
const params = new URLSearchParams(window.location.search);
|
|
@@ -63,7 +64,9 @@ const AgentToolApprovalsInner = ({ onLogout, }) => {
|
|
|
63
64
|
const chatAuthToken = token === null ? undefined : token;
|
|
64
65
|
const agentBaseUrl = DEFAULT_LOCAL_BASE_URL;
|
|
65
66
|
const podName = 'localhost';
|
|
66
|
-
const
|
|
67
|
+
const approvals = useAgentRuntimeApprovals();
|
|
68
|
+
const pendingApprovalCount = useMemo(() => approvals.filter(approval => approval.status === 'pending' &&
|
|
69
|
+
(!agentId || approval.agent_id === agentId)).length, [approvals, agentId]);
|
|
67
70
|
const createAttemptedRef = useRef(false);
|
|
68
71
|
const authFetch = useCallback((url, opts = {}) => fetch(url, {
|
|
69
72
|
...opts,
|
|
@@ -149,15 +152,16 @@ const AgentToolApprovalsInner = ({ onLogout, }) => {
|
|
|
149
152
|
flexDirection: 'column',
|
|
150
153
|
alignItems: 'center',
|
|
151
154
|
justifyContent: 'center',
|
|
152
|
-
height: '
|
|
155
|
+
height: '100%',
|
|
153
156
|
gap: 3,
|
|
154
|
-
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Launching tool approvals
|
|
157
|
+
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Launching tool approvals example agent..." })] }));
|
|
155
158
|
}
|
|
156
159
|
if (runtimeStatus === 'error' || hookError) {
|
|
157
160
|
return _jsx(ErrorView, { error: hookError, onLogout: onLogout });
|
|
158
161
|
}
|
|
159
162
|
return (_jsxs(Box, { sx: {
|
|
160
|
-
height: '
|
|
163
|
+
height: '100%',
|
|
164
|
+
minHeight: 0,
|
|
161
165
|
display: 'flex',
|
|
162
166
|
flexDirection: 'column',
|
|
163
167
|
}, children: [isReconnectedAgent && (_jsx(Box, { sx: {
|
|
@@ -165,19 +169,31 @@ const AgentToolApprovalsInner = ({ onLogout, }) => {
|
|
|
165
169
|
py: 1,
|
|
166
170
|
borderBottom: '1px solid',
|
|
167
171
|
borderColor: 'border.default',
|
|
168
|
-
}, 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}`, placeholder: "Ask for actions that require approval...", showHeader: true, showNewChatButton: true, showClearButton: false, showTokenUsage: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, headerActions: _jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: _jsxs(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: ["Pending: ", pendingApprovalCount] }) }), suggestions: [
|
|
172
|
+
}, 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: false, showTokenUsage: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, headerActions: _jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: _jsxs(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: ["Pending: ", pendingApprovalCount] }) }), suggestions: [
|
|
169
173
|
{
|
|
170
174
|
title: 'List your tools',
|
|
171
175
|
message: 'list your tools',
|
|
172
176
|
},
|
|
173
177
|
{
|
|
174
|
-
title: '
|
|
175
|
-
message: "Call the runtime_sensitive_echo tool with text 'hello' and reason 'audit', then reply with the tool result.",
|
|
178
|
+
title: 'Sensitive tool with delegated allow',
|
|
179
|
+
message: "Call the runtime_sensitive_echo tool with text 'hello' and reason 'audit', then explain the before_tool_execute decision and reply with the tool result.",
|
|
176
180
|
},
|
|
177
181
|
{
|
|
178
|
-
title: '
|
|
182
|
+
title: 'Sensitive tool denied by Python hook',
|
|
183
|
+
message: "Call the runtime_sensitive_echo tool with text 'danger' and reason 'delete project', then explain why it was denied.",
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
title: 'Non-sensitive tool baseline',
|
|
179
187
|
message: "Call the runtime_echo tool with text 'hello world', then reply with the tool result.",
|
|
180
188
|
},
|
|
189
|
+
{
|
|
190
|
+
title: 'Inspect audit entries',
|
|
191
|
+
message: 'Use execute_code to print the latest entries from /tmp/agent_runtimes_tool_approvals_audit.jsonl and summarize decision + execution status.',
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
title: 'Explain deferred approvals hook',
|
|
195
|
+
message: 'Explain how deferred_tool_calls resolves approval-required tool requests inline when a decision is already available.',
|
|
196
|
+
},
|
|
181
197
|
], submitOnSuggestionClick: true }) }) })] }));
|
|
182
198
|
};
|
|
183
199
|
const syncTokenToIamStore = (token) => {
|
|
@@ -32,10 +32,10 @@ import { VercelAIAdapter } from '../protocols';
|
|
|
32
32
|
import { createUserMessage } from '../types/messages';
|
|
33
33
|
const queryClient = new QueryClient();
|
|
34
34
|
// ─── Constants ─────────────────────────────────────────────────────────────
|
|
35
|
-
const AGENT_NAME = 'trigger-
|
|
36
|
-
const AGENT_SPEC_ID = '
|
|
37
|
-
const APPROVAL_AGENT_NAME = 'trigger-approval-
|
|
38
|
-
const APPROVAL_AGENT_SPEC_ID = '
|
|
35
|
+
const AGENT_NAME = 'trigger-example-agent';
|
|
36
|
+
const AGENT_SPEC_ID = 'example-one-trigger';
|
|
37
|
+
const APPROVAL_AGENT_NAME = 'trigger-approval-example-agent';
|
|
38
|
+
const APPROVAL_AGENT_SPEC_ID = 'example-one-trigger-approval';
|
|
39
39
|
const ONCE_TRIGGER_PROMPT = "List the user's top 3 public and top 3 private GitHub repositories, ranked by recent activity, and provide a brief summary of each. Execute exactly two tool calls: run_skill_script(skill_name='github', script_name='list_repos', kwargs={visibility:'public', sort:'updated', limit:3, format:'json'}) and run_skill_script(skill_name='github', script_name='list_repos', kwargs={visibility:'private', sort:'updated', limit:3, format:'json'}). Do not call list_skills/load_skill/read_skill_resource. Do not retry. If a tool call fails, report failure_reason/error/stderr exactly as returned.";
|
|
40
40
|
const ONCE_TRIGGER_APPROVAL_PROMPT = 'Use the runtime_sensitive_echo tool once.';
|
|
41
41
|
const DEFAULT_LOCAL_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
|
|
@@ -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", 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: false, 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, autoFocus: false, height: "100%", runtimeId: agentId, showInput: true, disableInputPrompt: true, showModelSelector: false, showToolsMenu: true, showSkillsMenu: true })) : (_jsx(Box, { sx: {
|
|
859
859
|
height: '100%',
|
|
860
860
|
display: 'flex',
|
|
861
861
|
alignItems: 'center',
|
|
@@ -85,5 +85,5 @@ type AgentRuntimeFormExampleProps = {
|
|
|
85
85
|
/** @deprecated Use identityProviders instead */
|
|
86
86
|
kaggleToken?: string;
|
|
87
87
|
};
|
|
88
|
-
declare const
|
|
89
|
-
export default
|
|
88
|
+
declare const AgentspecsExample: React.FC<AgentRuntimeFormExampleProps>;
|
|
89
|
+
export default AgentspecsExample;
|