@datalayer/agent-runtimes 1.0.4 → 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 +182 -1
- package/lib/AgentNode.d.ts +3 -0
- package/lib/AgentNode.js +676 -0
- package/lib/App.js +1 -1
- 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/agents/AgentDetails.d.ts +22 -1
- package/lib/agents/AgentDetails.js +34 -47
- package/lib/api/index.d.ts +0 -1
- package/lib/api/index.js +4 -2
- package/lib/chat/Chat.d.ts +5 -106
- package/lib/chat/Chat.js +20 -14
- package/lib/chat/ChatFloating.d.ts +7 -140
- package/lib/chat/ChatFloating.js +3 -3
- package/lib/chat/ChatPopupStandalone.d.ts +8 -47
- package/lib/chat/ChatPopupStandalone.js +3 -3
- package/lib/chat/ChatSidebar.d.ts +4 -69
- package/lib/chat/ChatSidebar.js +83 -51
- package/lib/chat/ChatStandalone.d.ts +4 -54
- package/lib/chat/ChatStandalone.js +3 -3
- package/lib/chat/base/ChatBase.js +1414 -174
- 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 +30 -5
- package/lib/chat/header/ChatHeaderBase.js +41 -16
- package/lib/chat/indicators/McpStatusIndicator.d.ts +7 -4
- package/lib/chat/indicators/McpStatusIndicator.js +7 -32
- package/lib/chat/indicators/SandboxStatusIndicator.d.ts +4 -1
- package/lib/chat/indicators/SandboxStatusIndicator.js +91 -56
- package/lib/chat/indicators/SkillsStatusIndicator.d.ts +7 -0
- package/lib/chat/indicators/SkillsStatusIndicator.js +88 -0
- package/lib/chat/indicators/index.d.ts +1 -0
- package/lib/chat/indicators/index.js +1 -0
- package/lib/chat/messages/ChatMessageList.d.ts +1 -1
- package/lib/chat/messages/ChatMessageList.js +154 -114
- package/lib/chat/messages/ChatMessages.js +6 -2
- package/lib/chat/prompt/InputFooter.d.ts +21 -6
- package/lib/chat/prompt/InputFooter.js +76 -20
- package/lib/chat/prompt/InputPrompt.d.ts +5 -1
- package/lib/chat/prompt/InputPrompt.js +4 -4
- package/lib/chat/prompt/InputPromptFooter.d.ts +3 -1
- package/lib/chat/prompt/InputPromptFooter.js +3 -3
- package/lib/chat/prompt/InputPromptLexical.d.ts +3 -1
- package/lib/chat/prompt/InputPromptLexical.js +12 -5
- package/lib/chat/prompt/InputPromptText.d.ts +3 -1
- package/lib/chat/prompt/InputPromptText.js +2 -2
- package/lib/chat/tools/ToolApprovalBanner.js +1 -1
- package/lib/chat/tools/ToolCallDisplay.d.ts +3 -1
- package/lib/chat/tools/ToolCallDisplay.js +2 -2
- package/lib/chat/usage/TokenUsageBar.js +20 -2
- package/lib/client/AgentRuntimesClientContext.d.ts +53 -0
- package/lib/client/AgentRuntimesClientContext.js +55 -0
- package/lib/client/AgentsMixin.d.ts +0 -18
- package/lib/client/AgentsMixin.js +20 -30
- package/lib/client/IAgentRuntimesClient.d.ts +215 -0
- package/lib/client/IAgentRuntimesClient.js +5 -0
- package/lib/client/SdkAgentRuntimesClient.d.ts +151 -0
- package/lib/client/SdkAgentRuntimesClient.js +134 -0
- package/lib/client/index.d.ts +4 -1
- package/lib/client/index.js +3 -1
- package/lib/components/NotificationEventCard.js +5 -1
- package/lib/config/AgentConfiguration.d.ts +22 -0
- package/lib/config/AgentConfiguration.js +319 -64
- package/lib/context/ContextDistribution.d.ts +3 -1
- package/lib/context/ContextDistribution.js +8 -27
- package/lib/context/ContextInspector.d.ts +3 -1
- package/lib/context/ContextInspector.js +19 -67
- package/lib/context/ContextPanel.d.ts +3 -1
- package/lib/context/ContextPanel.js +104 -64
- package/lib/context/ContextUsage.d.ts +3 -1
- package/lib/context/ContextUsage.js +3 -3
- package/lib/context/CostTracker.d.ts +9 -3
- package/lib/context/CostTracker.js +26 -47
- package/lib/context/CostUsageChart.d.ts +12 -0
- package/lib/context/CostUsageChart.js +378 -0
- package/lib/context/GraphFlowChart.d.ts +16 -0
- package/lib/context/GraphFlowChart.js +182 -0
- package/lib/context/TokenUsageChart.d.ts +8 -1
- package/lib/context/TokenUsageChart.js +349 -211
- package/lib/context/TurnGraphChart.d.ts +39 -0
- package/lib/context/TurnGraphChart.js +538 -0
- package/lib/context/otelWsPool.d.ts +20 -0
- package/lib/context/otelWsPool.js +69 -0
- package/lib/examples/A2UiComponentGalleryExample.d.ts +0 -17
- package/lib/examples/A2UiComponentGalleryExample.js +315 -522
- package/lib/examples/A2UiContactCardExample.d.ts +0 -18
- package/lib/examples/A2UiContactCardExample.js +154 -411
- package/lib/examples/A2UiRestaurantExample.d.ts +0 -30
- package/lib/examples/A2UiRestaurantExample.js +114 -212
- package/lib/examples/A2UiViewerExample.d.ts +0 -18
- package/lib/examples/A2UiViewerExample.js +283 -532
- package/lib/examples/AgUiBackendToolRenderingExample.js +1 -1
- package/lib/examples/AgUiHaikuGenUiExample.d.ts +1 -1
- package/lib/examples/AgUiHaikuGenUiExample.js +1 -1
- package/lib/examples/AgUiSharedStateExample.js +2 -1
- package/lib/examples/AgentCheckpointsExample.js +14 -28
- package/lib/examples/AgentCodemodeExample.d.ts +4 -6
- package/lib/examples/AgentCodemodeExample.js +603 -169
- package/lib/examples/AgentEvalsExample.js +339 -53
- package/lib/examples/AgentGuardrailsExample.js +383 -66
- package/lib/examples/AgentHooksExample.d.ts +3 -0
- package/lib/examples/AgentHooksExample.js +122 -0
- package/lib/examples/AgentInferenceProviderExample.d.ts +3 -0
- package/lib/examples/AgentInferenceProviderExample.js +329 -0
- package/lib/examples/AgentMCPExample.d.ts +3 -0
- package/lib/examples/AgentMCPExample.js +481 -0
- package/lib/examples/AgentMemoryExample.d.ts +1 -2
- package/lib/examples/AgentMemoryExample.js +78 -33
- package/lib/examples/AgentMonitoringExample.js +261 -200
- package/lib/examples/AgentNotificationsExample.d.ts +1 -2
- package/lib/examples/AgentNotificationsExample.js +114 -33
- package/lib/examples/AgentOtelExample.js +32 -42
- package/lib/examples/AgentOutputsExample.d.ts +11 -6
- package/lib/examples/AgentOutputsExample.js +433 -81
- package/lib/examples/AgentParametersExample.d.ts +3 -0
- package/lib/examples/AgentParametersExample.js +248 -0
- package/lib/examples/AgentSandboxExample.d.ts +3 -3
- package/lib/examples/AgentSandboxExample.js +74 -45
- package/lib/examples/AgentSkillsExample.js +95 -103
- package/lib/examples/AgentSubagentsExample.d.ts +14 -0
- package/lib/examples/AgentSubagentsExample.js +228 -0
- package/lib/examples/AgentToolApprovalsExample.js +49 -561
- package/lib/examples/AgentTriggersExample.js +823 -569
- package/lib/examples/{AgentspecExample.d.ts → AgentspecsExample.d.ts} +2 -2
- package/lib/examples/AgentspecsExample.js +1096 -0
- package/lib/examples/ChatCustomExample.js +16 -28
- package/lib/examples/ChatExample.js +13 -29
- package/lib/examples/CopilotKitLexicalExample.js +2 -1
- package/lib/examples/CopilotKitNotebookExample.js +2 -1
- package/lib/examples/HomeExample.d.ts +15 -0
- package/lib/examples/HomeExample.js +77 -0
- package/lib/examples/Lexical2Example.js +4 -2
- package/lib/examples/{LexicalExample.d.ts → LexicalAgentExample.d.ts} +4 -4
- package/lib/examples/{LexicalExample.js → LexicalAgentExample.js} +66 -17
- package/lib/examples/{LexicalSidebarExample.d.ts → LexicalAgentSidebarExample.d.ts} +5 -5
- package/lib/examples/LexicalAgentSidebarExample.js +261 -0
- package/lib/examples/NotebookAgentExample.d.ts +9 -0
- package/lib/examples/NotebookAgentExample.js +192 -0
- package/lib/examples/{NotebookSidebarExample.d.ts → NotebookAgentSidebarExample.d.ts} +2 -2
- package/lib/examples/NotebookAgentSidebarExample.js +221 -0
- package/lib/examples/{DatalayerNotebookExample.d.ts → NotebookCollaborationExample.d.ts} +4 -4
- package/lib/examples/{DatalayerNotebookExample.js → NotebookCollaborationExample.js} +3 -3
- package/lib/examples/NotebookExample.d.ts +4 -7
- package/lib/examples/NotebookExample.js +14 -146
- package/lib/examples/components/AuthRequiredView.d.ts +6 -0
- package/lib/examples/components/AuthRequiredView.js +33 -0
- package/lib/examples/components/ExampleWrapper.d.ts +9 -3
- package/lib/examples/components/ExampleWrapper.js +45 -9
- package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.js +1 -1
- package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.js +1 -1
- package/lib/examples/{ag-ui → components}/haiku/index.d.ts +1 -1
- package/lib/examples/{ag-ui → components}/haiku/index.js +1 -1
- package/lib/examples/components/index.d.ts +3 -0
- package/lib/examples/components/index.js +4 -0
- package/lib/examples/{ag-ui → components}/weather/index.d.ts +1 -1
- package/lib/examples/{ag-ui → components}/weather/index.js +1 -1
- package/lib/examples/example-selector.d.ts +17 -4
- package/lib/examples/example-selector.js +108 -41
- package/lib/examples/index.d.ts +10 -6
- package/lib/examples/index.js +10 -6
- package/lib/examples/lexical/initial-content.json +6 -6
- package/lib/examples/main.js +257 -27
- package/lib/examples/utils/a2ui.d.ts +18 -0
- package/lib/examples/utils/a2ui.js +69 -0
- package/lib/examples/utils/a2uiMarkdownProvider.d.ts +7 -0
- package/lib/examples/utils/a2uiMarkdownProvider.js +9 -0
- package/lib/examples/utils/agentId.d.ts +18 -0
- package/lib/examples/utils/agentId.js +54 -0
- package/lib/examples/utils/agents/earthquake-detector.json +11 -11
- package/lib/examples/utils/agents/sales-forecaster.json +11 -11
- package/lib/examples/utils/agents/social-post-generator.json +11 -11
- package/lib/examples/utils/agents/stock-market.json +11 -11
- package/lib/examples/utils/examplesStore.js +82 -27
- package/lib/examples/utils/useExampleAgentRuntimesUrl.d.ts +5 -0
- package/lib/examples/utils/useExampleAgentRuntimesUrl.js +19 -0
- package/lib/hooks/index.d.ts +8 -8
- package/lib/hooks/index.js +7 -7
- package/lib/hooks/useA2A.d.ts +2 -3
- package/lib/hooks/useAIAgentsWebSocket.d.ts +43 -4
- package/lib/hooks/useAIAgentsWebSocket.js +153 -12
- package/lib/hooks/useAcp.d.ts +1 -2
- package/lib/hooks/useAgUi.d.ts +1 -1
- package/lib/hooks/{useAgents.d.ts → useAgentRuntimes.d.ts} +70 -4
- package/lib/hooks/{useAgents.js → useAgentRuntimes.js} +237 -32
- package/lib/hooks/useAgentsCatalog.js +1 -1
- package/lib/hooks/useAgentsService.d.ts +2 -2
- package/lib/hooks/useAgentsService.js +7 -7
- package/lib/hooks/useCheckpoints.js +1 -1
- package/lib/hooks/useConfig.d.ts +4 -1
- package/lib/hooks/useConfig.js +10 -3
- package/lib/hooks/useContextSnapshot.d.ts +9 -4
- package/lib/hooks/useContextSnapshot.js +9 -37
- package/lib/hooks/useMonitoring.js +3 -0
- package/lib/hooks/useSandbox.d.ts +20 -8
- package/lib/hooks/useSandbox.js +105 -40
- package/lib/hooks/useSkills.d.ts +23 -5
- package/lib/hooks/useSkills.js +94 -39
- package/lib/hooks/useToolApprovals.d.ts +60 -36
- package/lib/hooks/useToolApprovals.js +318 -69
- package/lib/hooks/useVercelAI.d.ts +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -0
- package/lib/inference/index.d.ts +0 -1
- package/lib/middleware/index.d.ts +0 -1
- package/lib/protocols/AGUIAdapter.js +6 -0
- package/lib/protocols/VercelAIAdapter.d.ts +7 -0
- package/lib/protocols/VercelAIAdapter.js +59 -7
- package/lib/specs/agents/agents.d.ts +21 -4
- package/lib/specs/agents/agents.js +2879 -316
- package/lib/specs/agents/index.js +3 -1
- package/lib/specs/benchmarks.d.ts +20 -0
- package/lib/specs/benchmarks.js +205 -0
- package/lib/specs/envvars.js +27 -20
- package/lib/specs/evals.d.ts +10 -9
- package/lib/specs/evals.js +128 -88
- package/lib/specs/events.d.ts +3 -10
- package/lib/specs/events.js +127 -84
- package/lib/specs/frontendTools.js +2 -2
- package/lib/specs/guardrails.d.ts +0 -7
- package/lib/specs/guardrails.js +240 -159
- package/lib/specs/mcpServers.js +35 -6
- package/lib/specs/memory.d.ts +0 -2
- package/lib/specs/memory.js +4 -17
- package/lib/specs/models.d.ts +0 -2
- package/lib/specs/models.js +20 -15
- package/lib/specs/notifications.js +102 -18
- package/lib/specs/outputs.js +15 -9
- package/lib/specs/personas.d.ts +41 -0
- package/lib/specs/personas.js +168 -0
- package/lib/specs/skills.d.ts +1 -1
- package/lib/specs/skills.js +23 -23
- package/lib/specs/teams/index.js +3 -1
- package/lib/specs/teams/teams.js +468 -348
- package/lib/specs/tools.js +4 -4
- package/lib/specs/triggers.js +61 -11
- package/lib/stores/agentRuntimeStore.d.ts +208 -0
- package/lib/stores/agentRuntimeStore.js +650 -0
- package/lib/stores/conversationStore.js +2 -2
- package/lib/stores/index.d.ts +1 -1
- package/lib/stores/index.js +1 -1
- package/lib/tools/adapters/copilotkit/lexicalHooks.d.ts +1 -2
- package/lib/tools/adapters/copilotkit/lexicalHooks.js +1 -3
- package/lib/tools/adapters/copilotkit/notebookHooks.d.ts +1 -2
- package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -3
- package/lib/tools/index.d.ts +0 -2
- package/lib/tools/index.js +0 -1
- package/lib/types/agents-lifecycle.d.ts +18 -0
- package/lib/types/agents.d.ts +6 -0
- package/lib/types/agentspecs.d.ts +54 -1
- package/lib/types/benchmarks.d.ts +43 -0
- package/lib/types/benchmarks.js +5 -0
- package/lib/types/chat.d.ts +325 -8
- package/lib/types/context.d.ts +27 -0
- package/lib/types/cost.d.ts +2 -2
- package/lib/types/evals.d.ts +26 -17
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.js +3 -0
- package/lib/types/mcp.d.ts +8 -0
- package/lib/types/models.d.ts +2 -2
- package/lib/types/personas.d.ts +25 -0
- package/lib/types/personas.js +5 -0
- package/lib/types/skills.d.ts +43 -1
- package/lib/types/stream.d.ts +110 -0
- package/lib/types/stream.js +36 -0
- package/lib/utils/utils.d.ts +9 -5
- package/lib/utils/utils.js +9 -5
- package/package.json +19 -11
- 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/__pycache__/generate_events.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
- package/scripts/codegen/generate_agents.py +187 -45
- package/scripts/codegen/generate_benchmarks.py +441 -0
- package/scripts/codegen/generate_evals.py +94 -16
- package/scripts/codegen/generate_events.py +35 -14
- package/scripts/codegen/generate_personas.py +319 -0
- package/scripts/codegen/generate_skills.py +9 -9
- package/scripts/sync-jupyter.sh +26 -7
- package/lib/api/tool-approvals.d.ts +0 -62
- package/lib/api/tool-approvals.js +0 -145
- package/lib/examples/AgentspecExample.js +0 -705
- package/lib/examples/LexicalSidebarExample.js +0 -163
- package/lib/examples/NotebookSidebarExample.js +0 -119
- package/lib/examples/NotebookSimpleExample.d.ts +0 -6
- package/lib/examples/NotebookSimpleExample.js +0 -22
- package/lib/examples/ag-ui/index.d.ts +0 -10
- package/lib/examples/ag-ui/index.js +0 -16
- package/lib/hooks/useAgentsRegistry.d.ts +0 -10
- package/lib/hooks/useAgentsRegistry.js +0 -20
- package/lib/stores/agentsStore.d.ts +0 -123
- package/lib/stores/agentsStore.js +0 -270
- /package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.js +0 -0
|
@@ -15,40 +15,119 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
15
15
|
* pass/fail status, and the ability to run eval suites
|
|
16
16
|
*/
|
|
17
17
|
/// <reference types="vite/client" />
|
|
18
|
-
import { useEffect, useState, useCallback, useRef } from 'react';
|
|
18
|
+
import { useEffect, useState, useCallback, useRef, useMemo, } from 'react';
|
|
19
19
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
20
|
-
import { Text, Button, Spinner, Heading, Label, Flash, ProgressBar, } from '@primer/react';
|
|
21
|
-
import { BeakerIcon, CheckCircleIcon, XCircleIcon, PlayIcon,
|
|
20
|
+
import { Text, Button, Spinner, Heading, Label, Flash, ProgressBar, Select, FormControl, } from '@primer/react';
|
|
21
|
+
import { BeakerIcon, CheckCircleIcon, XCircleIcon, PlayIcon, } from '@primer/octicons-react';
|
|
22
22
|
import { Box } from '@datalayer/primer-addons';
|
|
23
|
-
import { ErrorView } from './components';
|
|
23
|
+
import { AuthRequiredView, ErrorView } from './components';
|
|
24
24
|
import { ThemedProvider } from './utils/themedProvider';
|
|
25
|
+
import { uniqueAgentId } from './utils/agentId';
|
|
26
|
+
import { useExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
25
27
|
import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
|
|
26
|
-
import {
|
|
27
|
-
import { UserBadge } from '@datalayer/core/lib/views/profile';
|
|
28
|
+
import { useCoreStore } from '@datalayer/core';
|
|
28
29
|
import { Chat } from '../chat';
|
|
29
|
-
import {
|
|
30
|
+
import { useAgentRuntimes } from '../hooks/useAgentRuntimes';
|
|
30
31
|
const queryClient = new QueryClient();
|
|
31
32
|
// ─── Constants ─────────────────────────────────────────────────────────────
|
|
32
|
-
const AGENT_NAME = 'eval-
|
|
33
|
-
const AGENT_SPEC_ID = '
|
|
33
|
+
const AGENT_NAME = 'eval-example-agent';
|
|
34
|
+
const AGENT_SPEC_ID = 'example-evals';
|
|
35
|
+
const DEFAULT_EXECUTION_TARGET = (import.meta.env.VITE_AGENT_EVALS_TARGET || 'cloud').toLowerCase() === 'local'
|
|
36
|
+
? 'local'
|
|
37
|
+
: 'cloud';
|
|
38
|
+
const normalizeHttpUrl = (value) => {
|
|
39
|
+
if (typeof value !== 'string') {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const trimmed = value.trim();
|
|
43
|
+
if (!trimmed) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const url = new URL(trimmed);
|
|
48
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
url.pathname = '';
|
|
52
|
+
url.search = '';
|
|
53
|
+
url.hash = '';
|
|
54
|
+
return url.toString().replace(/\/$/, '');
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const isLocalhostUrl = (value) => {
|
|
61
|
+
if (!value) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const url = new URL(value);
|
|
66
|
+
return (url.hostname === 'localhost' ||
|
|
67
|
+
url.hostname === '127.0.0.1' ||
|
|
68
|
+
url.hostname === '0.0.0.0');
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
34
74
|
// ─── Inner component (rendered after auth) ─────────────────────────────────
|
|
35
|
-
const AgentEvalsInner = ({ onLogout }) => {
|
|
75
|
+
const AgentEvalsInner = ({ onLogout, executionTarget, onExecutionTargetChange }) => {
|
|
36
76
|
const { token } = useSimpleAuthStore();
|
|
37
|
-
const {
|
|
77
|
+
const { configuration } = useCoreStore();
|
|
78
|
+
const agentName = useRef(uniqueAgentId(AGENT_NAME)).current;
|
|
79
|
+
const localRuntimeBaseUrl = useExampleAgentRuntimesUrl();
|
|
80
|
+
const cloudRuntimeBaseUrl = useMemo(() => {
|
|
81
|
+
const envRuntimesUrl = normalizeHttpUrl(import.meta.env.VITE_DATALAYER_RUNTIMES_URL);
|
|
82
|
+
const envAgentRuntimesUrl = normalizeHttpUrl(import.meta.env.VITE_DATALAYER_AGENT_RUNTIMES_URL);
|
|
83
|
+
const configuredRuntimesUrl = normalizeHttpUrl(configuration?.runtimesRunUrl);
|
|
84
|
+
if (envRuntimesUrl && !isLocalhostUrl(envRuntimesUrl)) {
|
|
85
|
+
return envRuntimesUrl;
|
|
86
|
+
}
|
|
87
|
+
if (configuredRuntimesUrl && !isLocalhostUrl(configuredRuntimesUrl)) {
|
|
88
|
+
return configuredRuntimesUrl;
|
|
89
|
+
}
|
|
90
|
+
if (envAgentRuntimesUrl && !isLocalhostUrl(envAgentRuntimesUrl)) {
|
|
91
|
+
return envAgentRuntimesUrl;
|
|
92
|
+
}
|
|
93
|
+
return 'https://r1.datalayer.run';
|
|
94
|
+
}, [configuration?.runtimesRunUrl]);
|
|
95
|
+
const { runtime, status: runtimeStatus, isReady, error: hookError, runtimeCreationBaseUrl, } = useAgentRuntimes({
|
|
38
96
|
agentSpecId: AGENT_SPEC_ID,
|
|
39
|
-
autoStart:
|
|
97
|
+
autoStart: executionTarget === 'cloud',
|
|
98
|
+
runtimeCreationTarget: executionTarget === 'local' ? 'local-agent-runtimes' : 'backend-services',
|
|
99
|
+
runtimeCreationBaseUrl: executionTarget === 'local' ? localRuntimeBaseUrl : cloudRuntimeBaseUrl,
|
|
40
100
|
agentConfig: {
|
|
41
|
-
name:
|
|
42
|
-
|
|
101
|
+
name: agentName,
|
|
102
|
+
model: 'bedrock:us.anthropic.claude-sonnet-4-5-20250929-v1:0',
|
|
103
|
+
protocol: 'vercel-ai',
|
|
43
104
|
description: 'Agent with evaluation and quality scoring',
|
|
44
105
|
},
|
|
45
106
|
});
|
|
107
|
+
const [localAgentId, setLocalAgentId] = useState(null);
|
|
108
|
+
const [localStatus, setLocalStatus] = useState('launching');
|
|
109
|
+
const [localError, setLocalError] = useState(null);
|
|
46
110
|
const [evalRuns, setEvalRuns] = useState([]);
|
|
47
111
|
const [isRunning, setIsRunning] = useState(false);
|
|
48
112
|
const [flash, setFlash] = useState(null);
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
113
|
+
const [evalId, setEvalId] = useState(null);
|
|
114
|
+
const [experimentId, setExperimentId] = useState(null);
|
|
115
|
+
const [isBootstrapping, setIsBootstrapping] = useState(true);
|
|
116
|
+
const cloudAgentBaseUrl = runtime?.agentBaseUrl || '';
|
|
117
|
+
const localAgentBaseUrl = runtimeCreationBaseUrl;
|
|
118
|
+
const agentBaseUrl = executionTarget === 'local' ? localAgentBaseUrl : cloudAgentBaseUrl;
|
|
119
|
+
const agentId = executionTarget === 'local'
|
|
120
|
+
? localAgentId || agentName
|
|
121
|
+
: runtime?.agentId || AGENT_NAME;
|
|
122
|
+
const podName = executionTarget === 'local'
|
|
123
|
+
? `local:${agentId}`
|
|
124
|
+
: runtime?.podName || '(launching…)';
|
|
125
|
+
const controlPlaneBaseUrl = import.meta.env.VITE_RUN_URL ||
|
|
126
|
+
configuration?.runUrl ||
|
|
127
|
+
(cloudAgentBaseUrl ? new URL(cloudAgentBaseUrl).origin : '');
|
|
128
|
+
const isAgentReady = executionTarget === 'local' ? localStatus === 'ready' : isReady;
|
|
129
|
+
const agentStatus = executionTarget === 'local' ? localStatus : runtimeStatus;
|
|
130
|
+
const effectiveError = executionTarget === 'local' ? localError : hookError;
|
|
52
131
|
// Authenticated fetch helper
|
|
53
132
|
const authFetch = useCallback((url, opts = {}) => fetch(url, {
|
|
54
133
|
...opts,
|
|
@@ -58,67 +137,271 @@ const AgentEvalsInner = ({ onLogout }) => {
|
|
|
58
137
|
...(opts.headers ?? {}),
|
|
59
138
|
},
|
|
60
139
|
}), [token]);
|
|
140
|
+
const evalApiFetch = useCallback(async (path, opts = {}) => {
|
|
141
|
+
const response = await authFetch(`${controlPlaneBaseUrl}/api/ai-agents/v1${path}`, opts);
|
|
142
|
+
const payload = await response.json().catch(() => ({}));
|
|
143
|
+
if (!response.ok || payload?.success === false) {
|
|
144
|
+
throw new Error(payload?.detail ||
|
|
145
|
+
payload?.message ||
|
|
146
|
+
`Eval API request failed (${response.status})`);
|
|
147
|
+
}
|
|
148
|
+
return payload;
|
|
149
|
+
}, [authFetch, controlPlaneBaseUrl]);
|
|
150
|
+
const mapRuns = useCallback((rows) => {
|
|
151
|
+
return rows.map((run) => {
|
|
152
|
+
const passRateRaw = run?.metrics?.pass_rate ??
|
|
153
|
+
run?.summary?.pass_rate ??
|
|
154
|
+
run?.summary?.score ??
|
|
155
|
+
0;
|
|
156
|
+
const score = Math.max(0, Math.min(1, Number(passRateRaw) || 0));
|
|
157
|
+
const passed = Number(run?.summary?.passed ?? Math.round(score * 100));
|
|
158
|
+
const failed = Number(run?.summary?.failed ?? Math.max(0, 100 - passed));
|
|
159
|
+
return {
|
|
160
|
+
id: String(run?.id || Math.random()),
|
|
161
|
+
timestamp: String(run?.created_at || run?.updated_at || new Date().toISOString()),
|
|
162
|
+
suiteName: String(run?.summary?.suite_name || run?.summary?.name || 'default-suite'),
|
|
163
|
+
passed,
|
|
164
|
+
failed,
|
|
165
|
+
score,
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
}, []);
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
if (executionTarget !== 'local' || !agentBaseUrl) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
let isCancelled = false;
|
|
174
|
+
const createLocalAgent = async () => {
|
|
175
|
+
setLocalStatus('launching');
|
|
176
|
+
setLocalError(null);
|
|
177
|
+
try {
|
|
178
|
+
const response = await authFetch(`${agentBaseUrl}/api/v1/agents`, {
|
|
179
|
+
method: 'POST',
|
|
180
|
+
body: JSON.stringify({
|
|
181
|
+
name: agentName,
|
|
182
|
+
description: 'Agent with evaluation and quality scoring',
|
|
183
|
+
agent_library: 'pydantic-ai',
|
|
184
|
+
transport: 'vercel-ai',
|
|
185
|
+
agent_spec_id: AGENT_SPEC_ID,
|
|
186
|
+
enable_skills: true,
|
|
187
|
+
tools: [],
|
|
188
|
+
}),
|
|
189
|
+
});
|
|
190
|
+
let resolvedAgentId = agentName;
|
|
191
|
+
if (response.ok) {
|
|
192
|
+
const payload = await response.json().catch(() => ({}));
|
|
193
|
+
resolvedAgentId = payload?.id || agentName;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const contentType = response.headers.get('content-type') || '';
|
|
197
|
+
let detail = '';
|
|
198
|
+
if (contentType.includes('application/json')) {
|
|
199
|
+
const payload = await response.json().catch(() => null);
|
|
200
|
+
detail =
|
|
201
|
+
(typeof payload?.detail === 'string' && payload.detail) ||
|
|
202
|
+
(typeof payload?.message === 'string' && payload.message) ||
|
|
203
|
+
'';
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
detail = await response.text();
|
|
207
|
+
}
|
|
208
|
+
if (response.status !== 409 &&
|
|
209
|
+
!/already exists/i.test(detail || '')) {
|
|
210
|
+
throw new Error(detail || `Failed to create local agent: ${response.status}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (!isCancelled) {
|
|
214
|
+
setLocalAgentId(resolvedAgentId);
|
|
215
|
+
setLocalStatus('ready');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
if (!isCancelled) {
|
|
220
|
+
setLocalError(error instanceof Error ? error.message : 'Agent failed to start');
|
|
221
|
+
setLocalStatus('error');
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
void createLocalAgent();
|
|
226
|
+
return () => {
|
|
227
|
+
isCancelled = true;
|
|
228
|
+
};
|
|
229
|
+
}, [executionTarget, agentBaseUrl, agentName, authFetch]);
|
|
230
|
+
useEffect(() => {
|
|
231
|
+
if (!isAgentReady || !controlPlaneBaseUrl)
|
|
232
|
+
return;
|
|
233
|
+
const bootstrap = async () => {
|
|
234
|
+
setIsBootstrapping(true);
|
|
235
|
+
try {
|
|
236
|
+
const evalName = `agent-evals-${agentId}`;
|
|
237
|
+
const evalsRes = await evalApiFetch(`/evals/evals?source=hosted&q=${encodeURIComponent(evalName)}&limit=50`);
|
|
238
|
+
const evals = Array.isArray(evalsRes?.evals)
|
|
239
|
+
? evalsRes.evals
|
|
240
|
+
: [];
|
|
241
|
+
let evalRecord = evals.find((d) => d?.name === evalName);
|
|
242
|
+
if (!evalRecord) {
|
|
243
|
+
const createdEvalRes = await evalApiFetch('/evals/evals', {
|
|
244
|
+
method: 'POST',
|
|
245
|
+
body: JSON.stringify({
|
|
246
|
+
name: evalName,
|
|
247
|
+
description: `Hosted eval for ${agentId}`,
|
|
248
|
+
source: 'hosted',
|
|
249
|
+
kind: 'agent-quality',
|
|
250
|
+
schema: {},
|
|
251
|
+
tags: ['agent-runtimes', 'example'],
|
|
252
|
+
metadata: { agent_id: agentId },
|
|
253
|
+
cases: [],
|
|
254
|
+
}),
|
|
255
|
+
});
|
|
256
|
+
evalRecord = createdEvalRes?.eval;
|
|
257
|
+
}
|
|
258
|
+
if (!evalRecord?.id) {
|
|
259
|
+
throw new Error('Failed to initialize eval.');
|
|
260
|
+
}
|
|
261
|
+
setEvalId(evalRecord.id);
|
|
262
|
+
const experimentsRes = await evalApiFetch(`/evals/experiments?eval_id=${encodeURIComponent(evalRecord.id)}&limit=50`);
|
|
263
|
+
const experiments = Array.isArray(experimentsRes?.experiments)
|
|
264
|
+
? experimentsRes.experiments
|
|
265
|
+
: [];
|
|
266
|
+
let experiment = experiments.find((e) => e?.name === 'default-suite');
|
|
267
|
+
if (!experiment) {
|
|
268
|
+
const createdExperimentRes = await evalApiFetch('/evals/experiments', {
|
|
269
|
+
method: 'POST',
|
|
270
|
+
body: JSON.stringify({
|
|
271
|
+
eval_id: evalRecord.id,
|
|
272
|
+
name: 'default-suite',
|
|
273
|
+
description: 'Default evaluation suite for AgentEvalsExample.',
|
|
274
|
+
status: 'ready',
|
|
275
|
+
config: {
|
|
276
|
+
mode: 'offline',
|
|
277
|
+
target_agent_id: agentId,
|
|
278
|
+
target_pod_name: podName,
|
|
279
|
+
},
|
|
280
|
+
summary: {},
|
|
281
|
+
tags: ['example'],
|
|
282
|
+
}),
|
|
283
|
+
});
|
|
284
|
+
experiment = createdExperimentRes?.experiment;
|
|
285
|
+
}
|
|
286
|
+
if (!experiment?.id) {
|
|
287
|
+
throw new Error('Failed to initialize eval experiment.');
|
|
288
|
+
}
|
|
289
|
+
setExperimentId(experiment.id);
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
const message = error instanceof Error ? error.message : 'Eval bootstrap failed.';
|
|
293
|
+
setFlash(message);
|
|
294
|
+
}
|
|
295
|
+
finally {
|
|
296
|
+
setIsBootstrapping(false);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
void bootstrap();
|
|
300
|
+
}, [isAgentReady, controlPlaneBaseUrl, agentId, podName, evalApiFetch]);
|
|
61
301
|
// ── Poll eval results ─────────────────────────────────────────────────
|
|
62
302
|
useEffect(() => {
|
|
63
|
-
if (!
|
|
303
|
+
if (!isAgentReady || !controlPlaneBaseUrl || !experimentId)
|
|
64
304
|
return;
|
|
65
305
|
const poll = async () => {
|
|
66
306
|
try {
|
|
67
|
-
const res = await
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
setEvalRuns(Array.isArray(d) ? d : (d.runs ?? []));
|
|
71
|
-
}
|
|
307
|
+
const res = await evalApiFetch(`/evals/experiments/${encodeURIComponent(experimentId)}/runs?limit=50`);
|
|
308
|
+
const rows = Array.isArray(res?.runs) ? res.runs : [];
|
|
309
|
+
setEvalRuns(mapRuns(rows));
|
|
72
310
|
}
|
|
73
311
|
catch {
|
|
74
312
|
/* ok */
|
|
75
313
|
}
|
|
76
314
|
};
|
|
77
|
-
poll();
|
|
315
|
+
void poll();
|
|
78
316
|
const interval = setInterval(poll, 15_000);
|
|
79
317
|
return () => clearInterval(interval);
|
|
80
|
-
}, [
|
|
318
|
+
}, [isAgentReady, controlPlaneBaseUrl, experimentId, evalApiFetch, mapRuns]);
|
|
81
319
|
// ── Run eval suite ────────────────────────────────────────────────────
|
|
82
320
|
const handleRunEval = useCallback(async () => {
|
|
83
|
-
if (!
|
|
321
|
+
if (!controlPlaneBaseUrl || !experimentId)
|
|
84
322
|
return;
|
|
85
323
|
setIsRunning(true);
|
|
86
324
|
setFlash(null);
|
|
87
325
|
try {
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
326
|
+
const syntheticScore = Number((0.75 + Math.random() * 0.2).toFixed(3));
|
|
327
|
+
const passed = Math.round(syntheticScore * 100);
|
|
328
|
+
const failed = Math.max(0, 100 - passed);
|
|
329
|
+
await evalApiFetch(`/evals/experiments/${encodeURIComponent(experimentId)}/runs`, {
|
|
330
|
+
method: 'POST',
|
|
331
|
+
body: JSON.stringify({
|
|
332
|
+
status: 'completed',
|
|
333
|
+
metrics: {
|
|
334
|
+
pass_rate: syntheticScore,
|
|
335
|
+
avg_score: syntheticScore,
|
|
336
|
+
},
|
|
337
|
+
summary: {
|
|
338
|
+
suite_name: 'default-suite',
|
|
339
|
+
passed,
|
|
340
|
+
failed,
|
|
341
|
+
runtime_id: podName,
|
|
342
|
+
},
|
|
343
|
+
report: {
|
|
344
|
+
source: 'AgentEvalsExample',
|
|
345
|
+
eval_id: evalId,
|
|
346
|
+
experiment_id: experimentId,
|
|
347
|
+
agent_id: agentId,
|
|
348
|
+
},
|
|
349
|
+
}),
|
|
350
|
+
});
|
|
351
|
+
setFlash('Evaluation run persisted');
|
|
352
|
+
const updatedRuns = await evalApiFetch(`/evals/experiments/${encodeURIComponent(experimentId)}/runs?limit=50`);
|
|
353
|
+
const rows = Array.isArray(updatedRuns?.runs)
|
|
354
|
+
? updatedRuns.runs
|
|
355
|
+
: [];
|
|
356
|
+
setEvalRuns(mapRuns(rows));
|
|
95
357
|
}
|
|
96
358
|
catch {
|
|
97
|
-
setFlash('
|
|
359
|
+
setFlash('Failed to persist evaluation run');
|
|
98
360
|
}
|
|
99
361
|
finally {
|
|
100
362
|
setIsRunning(false);
|
|
101
363
|
}
|
|
102
|
-
}, [
|
|
364
|
+
}, [
|
|
365
|
+
controlPlaneBaseUrl,
|
|
366
|
+
experimentId,
|
|
367
|
+
evalApiFetch,
|
|
368
|
+
mapRuns,
|
|
369
|
+
podName,
|
|
370
|
+
evalId,
|
|
371
|
+
agentId,
|
|
372
|
+
]);
|
|
103
373
|
// ── Loading / Error ───────────────────────────────────────────────────
|
|
104
|
-
if (!
|
|
374
|
+
if (!isAgentReady && agentStatus !== 'error') {
|
|
105
375
|
return (_jsxs(Box, { sx: {
|
|
106
376
|
display: 'flex',
|
|
107
377
|
flexDirection: 'column',
|
|
108
378
|
alignItems: 'center',
|
|
109
379
|
justifyContent: 'center',
|
|
110
|
-
height: '
|
|
380
|
+
height: '100%',
|
|
111
381
|
gap: 3,
|
|
112
|
-
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children:
|
|
113
|
-
?
|
|
114
|
-
|
|
382
|
+
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: agentStatus === 'launching'
|
|
383
|
+
? executionTarget === 'local'
|
|
384
|
+
? 'Launching local eval example agent…'
|
|
385
|
+
: 'Launching runtime for eval agent…'
|
|
386
|
+
: 'Creating eval example agent…' })] }));
|
|
387
|
+
}
|
|
388
|
+
if (agentStatus === 'error' || effectiveError) {
|
|
389
|
+
return _jsx(ErrorView, { error: effectiveError, onLogout: onLogout });
|
|
115
390
|
}
|
|
116
|
-
if (
|
|
117
|
-
return
|
|
391
|
+
if (isBootstrapping) {
|
|
392
|
+
return (_jsxs(Box, { sx: {
|
|
393
|
+
display: 'flex',
|
|
394
|
+
flexDirection: 'column',
|
|
395
|
+
alignItems: 'center',
|
|
396
|
+
justifyContent: 'center',
|
|
397
|
+
height: '100%',
|
|
398
|
+
gap: 3,
|
|
399
|
+
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Preparing hosted eval and experiment..." })] }));
|
|
118
400
|
}
|
|
119
401
|
const latestScore = evalRuns.length > 0 ? evalRuns[0].score : null;
|
|
120
402
|
return (_jsxs(Box, { sx: {
|
|
121
|
-
height: '
|
|
403
|
+
height: '100%',
|
|
404
|
+
minHeight: 0,
|
|
122
405
|
display: 'flex',
|
|
123
406
|
flexDirection: 'column',
|
|
124
407
|
}, children: [_jsxs(Box, { sx: {
|
|
@@ -130,7 +413,14 @@ const AgentEvalsInner = ({ onLogout }) => {
|
|
|
130
413
|
borderBottom: '1px solid',
|
|
131
414
|
borderColor: 'border.default',
|
|
132
415
|
flexShrink: 0,
|
|
133
|
-
}, children: [_jsx(BeakerIcon, { size: 16 }), _jsxs(
|
|
416
|
+
}, children: [_jsx(BeakerIcon, { size: 16 }), _jsxs(Box, { sx: { flex: 1, minWidth: 0 }, children: [_jsxs(Heading, { as: "h3", sx: { fontSize: 2 }, children: ["Evaluation \u2014 ", podName] }), _jsxs(Text, { sx: {
|
|
417
|
+
fontSize: 0,
|
|
418
|
+
color: 'fg.muted',
|
|
419
|
+
display: 'block',
|
|
420
|
+
overflow: 'hidden',
|
|
421
|
+
textOverflow: 'ellipsis',
|
|
422
|
+
whiteSpace: 'nowrap',
|
|
423
|
+
}, children: ["Runtime API: ", runtimeCreationBaseUrl, "/api/runtimes/v1/runtimes"] })] }), _jsxs(FormControl, { sx: { minWidth: 160 }, children: [_jsx(FormControl.Label, { sx: { fontSize: 0, mb: 1 }, children: "Target" }), _jsxs(Select, { size: "small", value: executionTarget, onChange: e => onExecutionTargetChange(e.target.value), disabled: isRunning, children: [_jsx(Select.Option, { value: "cloud", children: "Cloud" }), _jsx(Select.Option, { value: "local", children: "Local" })] })] })] }), _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, title: "Eval Agent", brandIcon: _jsx(BeakerIcon, { size: 16 }), placeholder: "Chat with the agent, then run evaluations\u2026", description: latestScore != null
|
|
134
424
|
? `Last score: ${(latestScore * 100).toFixed(0)}%`
|
|
135
425
|
: 'No evaluations run yet', showHeader: true, autoFocus: true, height: "100%", runtimeId: podName, historyEndpoint: `${agentBaseUrl}/api/v1/history`, suggestions: [
|
|
136
426
|
{
|
|
@@ -152,7 +442,7 @@ const AgentEvalsInner = ({ onLogout }) => {
|
|
|
152
442
|
p: 3,
|
|
153
443
|
borderBottom: '1px solid',
|
|
154
444
|
borderColor: 'border.default',
|
|
155
|
-
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, mb: 2 }, children: [_jsx(BeakerIcon, { size: 16 }), _jsx(Heading, { as: "h3", sx: { fontSize: 2 }, children: "Run Evaluation" })] }), _jsx(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mb: 3 }, children: "Execute the default evaluation suite
|
|
445
|
+
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, mb: 2 }, children: [_jsx(BeakerIcon, { size: 16 }), _jsx(Heading, { as: "h3", sx: { fontSize: 2 }, children: "Run Evaluation" })] }), _jsx(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mb: 3 }, children: "Execute the default evaluation suite and persist results to /api/ai-agents/v1/evals." }), _jsx(Button, { size: "small", variant: "primary", leadingVisual: PlayIcon, onClick: handleRunEval, disabled: isRunning, sx: { width: '100%' }, children: isRunning ? 'Running…' : 'Run Eval Suite' }), flash && (_jsx(Flash, { variant: flash.toLowerCase().includes('failed') ? 'danger' : 'success', sx: { mt: 2, fontSize: 0 }, children: flash }))] }), _jsxs(Box, { sx: { p: 3, flex: 1, overflow: 'auto' }, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "Evaluation History" }), evalRuns.length === 0 ? (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 0 }, children: "No evaluation runs recorded yet." })) : (evalRuns.slice(0, 20).map(run => (_jsxs(Box, { sx: {
|
|
156
446
|
p: 2,
|
|
157
447
|
mb: 2,
|
|
158
448
|
border: '1px solid',
|
|
@@ -182,19 +472,15 @@ const syncTokenToIamStore = (token) => {
|
|
|
182
472
|
};
|
|
183
473
|
// ─── Main component with auth gate ─────────────────────────────────────────
|
|
184
474
|
const AgentEvalsExample = () => {
|
|
185
|
-
const { token,
|
|
475
|
+
const { token, clearAuth } = useSimpleAuthStore();
|
|
186
476
|
const hasSynced = useRef(false);
|
|
477
|
+
const [executionTarget, setExecutionTarget] = useState(DEFAULT_EXECUTION_TARGET);
|
|
187
478
|
useEffect(() => {
|
|
188
479
|
if (token && !hasSynced.current) {
|
|
189
480
|
hasSynced.current = true;
|
|
190
481
|
syncTokenToIamStore(token);
|
|
191
482
|
}
|
|
192
483
|
}, [token]);
|
|
193
|
-
const handleSignIn = useCallback((newToken, handle) => {
|
|
194
|
-
setAuth(newToken, handle);
|
|
195
|
-
hasSynced.current = true;
|
|
196
|
-
syncTokenToIamStore(newToken);
|
|
197
|
-
}, [setAuth]);
|
|
198
484
|
const handleLogout = useCallback(() => {
|
|
199
485
|
clearAuth();
|
|
200
486
|
hasSynced.current = false;
|
|
@@ -203,8 +489,8 @@ const AgentEvalsExample = () => {
|
|
|
203
489
|
});
|
|
204
490
|
}, [clearAuth]);
|
|
205
491
|
if (!token) {
|
|
206
|
-
return (_jsx(ThemedProvider, { children: _jsx(
|
|
492
|
+
return (_jsx(ThemedProvider, { children: _jsx(AuthRequiredView, {}) }));
|
|
207
493
|
}
|
|
208
|
-
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(ThemedProvider, { children: _jsx(AgentEvalsInner, { onLogout: handleLogout }) }) }));
|
|
494
|
+
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(ThemedProvider, { children: _jsx(AgentEvalsInner, { onLogout: handleLogout, executionTarget: executionTarget, onExecutionTargetChange: setExecutionTarget }, executionTarget) }) }));
|
|
209
495
|
};
|
|
210
496
|
export default AgentEvalsExample;
|