@datalayer/agent-runtimes 1.0.19 → 1.0.21
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 +11 -3
- package/lib/AgentNode.js +141 -40
- package/lib/App.js +2 -2
- package/lib/agent-node/AgentNodeGallery.js +188 -25
- package/lib/api/runtimes/runtimes.d.ts +57 -0
- package/lib/api/runtimes/runtimes.js +55 -1
- package/lib/chat/Chat.d.ts +1 -1
- package/lib/chat/Chat.js +2 -2
- package/lib/chat/base/ChatBase.js +50 -13
- package/lib/chat/document/EphemeralDocument.d.ts +5 -1
- package/lib/chat/document/EphemeralDocument.js +7 -5
- package/lib/chat/header/ChatHeaderBase.d.ts +3 -1
- package/lib/chat/header/ChatHeaderBase.js +5 -3
- package/lib/chat/messages/ChatMessageList.d.ts +19 -0
- package/lib/chat/messages/ChatMessageList.js +180 -9
- package/lib/chat/notebook/EphemeralNotebook.d.ts +5 -1
- package/lib/chat/notebook/EphemeralNotebook.js +9 -6
- package/lib/chat/prompt/InputPrompt.js +1 -1
- package/lib/chat/tools/SubagentActivity.d.ts +20 -0
- package/lib/chat/tools/SubagentActivity.js +154 -0
- package/lib/chat/tools/index.d.ts +1 -0
- package/lib/chat/tools/index.js +1 -0
- package/lib/chat/usage/TokenUsageBar.js +3 -3
- package/lib/client/AgentRuntimesClient.d.ts +5 -0
- package/lib/client/AgentsMixin.js +3 -1
- package/lib/client/mixins/RuntimesMixin.d.ts +12 -0
- package/lib/client/mixins/RuntimesMixin.js +24 -1
- package/lib/components/AgentSummary.d.ts +1 -0
- package/lib/components/AgentSummary.js +66 -10
- package/lib/components/runtimes/RuntimePickerBase.js +64 -29
- package/lib/components/runtimes/RuntimePickerCell.js +1 -1
- package/lib/components/runtimes/RuntimePickerNotebook.js +1 -1
- package/lib/components/runtimes/RuntimeSimplePicker.js +3 -2
- package/lib/components/runtimes/RuntimeUtils.js +2 -2
- package/lib/context/GraphFlowChart.js +1 -1
- package/lib/context/TokenUsageChart.js +1 -1
- package/lib/context/TurnGraphChart.js +2 -2
- package/lib/examples/A2UiAgentExample.js +4 -4
- package/lib/examples/A2UiComponentsGalleryExample.js +3 -3
- package/lib/examples/A2UiContactCardExample.js +3 -3
- package/lib/examples/A2UiRestaurantExample.js +2 -2
- package/lib/examples/A2UiViewerExample.js +3 -3
- package/lib/examples/AgUiAgenticExample.js +3 -3
- package/lib/examples/AgUiBackendToolRenderingExample.js +2 -2
- package/lib/examples/AgUiHaikuGenUiExample.js +3 -3
- package/lib/examples/AgUiHumanInTheLoopExample.js +5 -5
- package/lib/examples/AgUiSharedStateExample.js +3 -3
- package/lib/examples/AgUiToolsBasedGenUiExample.js +7 -5
- package/lib/examples/AgentCheckpointsExample.js +6 -5
- package/lib/examples/{AgentSandboxExample.d.ts → AgentCodeSandboxExample.d.ts} +4 -4
- package/lib/examples/{AgentSandboxExample.js → AgentCodeSandboxExample.js} +10 -9
- package/lib/examples/AgentCodeSandboxesExample.js +2 -2
- package/lib/examples/AgentCodemodeExample.js +3 -3
- package/lib/examples/AgentCompactionExample.d.ts +12 -0
- package/lib/examples/AgentCompactionExample.js +244 -0
- package/lib/examples/AgentEvalsExample.js +10 -20
- package/lib/examples/AgentGuardrailsExample.js +2 -2
- package/lib/examples/AgentHooksExample.js +1 -1
- package/lib/examples/AgentInferenceProviderExample.js +6 -8
- package/lib/examples/AgentLoopExample.js +3 -3
- package/lib/examples/AgentMCPExample.js +3 -3
- package/lib/examples/AgentMemoryExample.d.ts +4 -2
- package/lib/examples/AgentMemoryExample.js +93 -10
- package/lib/examples/AgentMonitoringExample.js +2 -2
- package/lib/examples/AgentNotificationsExample.js +1 -1
- package/lib/examples/AgentOtelExample.d.ts +2 -3
- package/lib/examples/AgentOtelExample.js +7 -12
- package/lib/examples/AgentOutputsExample.js +5 -5
- package/lib/examples/AgentParametersExample.js +3 -3
- package/lib/examples/AgentSkillsExample.js +4 -4
- package/lib/examples/AgentSubagentsExample.d.ts +2 -2
- package/lib/examples/AgentSubagentsExample.js +43 -34
- package/lib/examples/AgentToolApprovalsExample.js +1 -1
- package/lib/examples/AgentTriggersExample.js +9 -11
- package/lib/examples/AgentspecsExample.js +13 -5
- package/lib/examples/CellExample.d.ts +6 -0
- package/lib/examples/CellExample.js +84 -0
- package/lib/examples/ChatCustomExample.js +1 -1
- package/lib/examples/ChatExample.js +1 -1
- package/lib/examples/ChatStandaloneExample.js +2 -2
- package/lib/examples/HomeExample.js +29 -28
- package/lib/examples/Lexical2Example.js +2 -2
- package/lib/examples/LexicalAgentExample.js +1 -1
- package/lib/examples/LexicalAgentSidebarExample.js +2 -2
- package/lib/examples/NotebookAgentSidebarExample.d.ts +1 -1
- package/lib/examples/NotebookAgentSidebarExample.js +5 -4
- package/lib/examples/NotebookCollaborationExample.js +3 -3
- package/lib/examples/NotebookExample.js +2 -2
- package/lib/examples/components/ExampleWrapper.js +5 -0
- package/lib/examples/components/Header.js +2 -2
- package/lib/examples/components/HeaderControls.js +1 -1
- package/lib/examples/components/LexicalEditor.js +1 -1
- package/lib/examples/components/MainContent.js +1 -1
- package/lib/examples/components/MockFileBrowser.js +8 -8
- package/lib/examples/components/TimeTravel.js +1 -1
- package/lib/examples/components/haiku/HaikuDisplay.js +2 -2
- package/lib/examples/example-selector.js +4 -3
- package/lib/examples/hooks/useExampleAgentRuntime.js +11 -1
- package/lib/examples/hooks/useExampleAgentRuntimes.d.ts +7 -0
- package/lib/examples/hooks/useExampleAgentRuntimes.js +82 -0
- package/lib/examples/index.d.ts +2 -1
- package/lib/examples/index.js +2 -1
- package/lib/examples/main.js +359 -46
- package/lib/examples/utils/agentSummaryStore.d.ts +17 -0
- package/lib/examples/utils/themedProvider.js +32 -2
- package/lib/examples/utils/useExampleAgentRuntimesUrl.js +2 -1
- package/lib/examples2/NotebookMutationsKernel.js +6 -3
- package/lib/examples2/NotebookMutationsServiceManager.js +6 -3
- package/lib/examples2/ReactRouterExample.js +5 -5
- package/lib/examples2/main.js +38 -0
- package/lib/hooks/useAIAgentsWebSocket.js +35 -0
- package/lib/hooks/useAgentRuntimes.d.ts +22 -0
- package/lib/hooks/useAgentRuntimes.js +192 -5
- package/lib/hooks/useCheckpoints.js +2 -2
- package/lib/hooks/useToolApprovals.d.ts +10 -4
- package/lib/hooks/useToolApprovals.js +11 -5
- package/lib/models/Runtime.d.ts +10 -8
- package/lib/models/RuntimeDTO.d.ts +5 -3
- package/lib/models/RuntimeDTO.js +3 -3
- package/lib/runtimes/actions.js +3 -1
- package/lib/runtimes/apis.d.ts +7 -0
- package/lib/specs/agents/agents.d.ts +51 -0
- package/lib/specs/agents/agents.js +3389 -94
- package/lib/specs/models.d.ts +2 -0
- package/lib/specs/models.js +37 -0
- package/lib/stores/agentRuntimeStore.d.ts +32 -1
- package/lib/stores/agentRuntimeStore.js +65 -1
- package/lib/stores/index.d.ts +1 -1
- package/lib/stores/index.js +1 -1
- package/lib/types/agents.d.ts +9 -3
- package/lib/types/agentspecs.d.ts +2 -0
- package/lib/types/chat.d.ts +12 -0
- package/lib/types/models.d.ts +5 -0
- package/lib/types/stream.d.ts +58 -1
- package/package.json +4 -4
- package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
- package/scripts/codegen/generate_agents.py +7 -0
- package/scripts/codegen/generate_models.py +22 -9
- package/scripts/gen_workers.py +340 -0
- package/lib/examples/CellSimpleExample.d.ts +0 -6
- package/lib/examples/CellSimpleExample.js +0 -20
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* AgentCompactionExample
|
|
8
|
+
*
|
|
9
|
+
* Demonstrates history compaction. Before launching, the user picks a context
|
|
10
|
+
* token ceiling (capped at the agentspec model's tokens_limit). A lower ceiling
|
|
11
|
+
* makes the agent summarize older messages sooner. When compaction runs, a
|
|
12
|
+
* live panel shows a spinner and the details (from/to tokens, from/to messages,
|
|
13
|
+
* and time taken).
|
|
14
|
+
*/
|
|
15
|
+
/// <reference types="vite/client" />
|
|
16
|
+
import { useEffect, useState, useCallback, useRef } from 'react';
|
|
17
|
+
import { Text, Spinner, Heading, Label, Button, FormControl, } from '@primer/react';
|
|
18
|
+
import { HistoryIcon, ClockIcon, ArrowRightIcon, CheckCircleIcon, StackIcon, } from '@primer/octicons-react';
|
|
19
|
+
import { Box } from '@datalayer/primer-addons';
|
|
20
|
+
import { AuthRequiredView, ErrorView } from './components';
|
|
21
|
+
import { ThemedProvider } from './utils/themedProvider';
|
|
22
|
+
import { uniqueAgentId } from './utils/agentId';
|
|
23
|
+
import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
|
|
24
|
+
import { Chat } from '../chat';
|
|
25
|
+
import { useAgentRuntimeCompaction, agentRuntimeStore } from '../stores';
|
|
26
|
+
import { getAgentspecs } from '../specs/agents';
|
|
27
|
+
import { AI_MODEL_CATALOGUE } from '../specs';
|
|
28
|
+
import { useExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
29
|
+
import { useRuntimeTargetStore } from './utils/runtimeTargetStore';
|
|
30
|
+
const AGENT_NAME = 'compaction-example-agent';
|
|
31
|
+
const AGENTSPEC_ID = 'example-monitoring';
|
|
32
|
+
const MIN_MAX_TOKENS = 1000;
|
|
33
|
+
const DEFAULT_MAX_TOKENS = 4000;
|
|
34
|
+
/** Resolve the agentspec model's token limit as the upper bound the user can set. */
|
|
35
|
+
function resolveAgentspecTokenLimit() {
|
|
36
|
+
const spec = getAgentspecs(AGENTSPEC_ID);
|
|
37
|
+
const model = spec?.model;
|
|
38
|
+
const limit = model ? AI_MODEL_CATALOGUE[model]?.tokensLimit : undefined;
|
|
39
|
+
return typeof limit === 'number' && limit > 0 ? limit : 64000;
|
|
40
|
+
}
|
|
41
|
+
const numberFmt = new Intl.NumberFormat();
|
|
42
|
+
/** Live compaction status: spinner while running, details when complete. */
|
|
43
|
+
const CompactionPanel = ({ maxTokens }) => {
|
|
44
|
+
const compaction = useAgentRuntimeCompaction();
|
|
45
|
+
return (_jsxs(Box, { sx: {
|
|
46
|
+
p: 3,
|
|
47
|
+
borderBottom: '1px solid',
|
|
48
|
+
borderColor: 'border.default',
|
|
49
|
+
}, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "Compaction" }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2, mb: 2 }, children: [_jsx(StackIcon, { size: 14 }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: ["Budget: ", numberFmt.format(maxTokens), " tokens"] })] }), !compaction && (_jsx(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', m: 0 }, children: "No compaction yet. Keep chatting \u2014 once the history exceeds the token budget, older messages are summarized automatically." })), compaction?.phase === 'start' && (_jsxs(Box, { sx: {
|
|
50
|
+
display: 'flex',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
gap: 2,
|
|
53
|
+
p: 2,
|
|
54
|
+
border: '1px solid',
|
|
55
|
+
borderColor: 'attention.emphasis',
|
|
56
|
+
borderRadius: 2,
|
|
57
|
+
bg: 'attention.subtle',
|
|
58
|
+
}, children: [_jsx(Spinner, { size: "small" }), _jsxs(Box, { children: [_jsx(Text, { sx: { fontSize: 1, fontWeight: 'bold' }, children: "Compacting\u2026" }), _jsxs(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', m: 0 }, children: ["Summarizing ", numberFmt.format(compaction.beforeMessages), " messages (~", numberFmt.format(compaction.beforeTokens), " tokens)"] })] })] })), compaction?.phase === 'end' && (_jsxs(Box, { sx: {
|
|
59
|
+
p: 2,
|
|
60
|
+
border: '1px solid',
|
|
61
|
+
borderColor: compaction.reduced
|
|
62
|
+
? 'success.emphasis'
|
|
63
|
+
: 'border.default',
|
|
64
|
+
borderRadius: 2,
|
|
65
|
+
bg: compaction.reduced ? 'success.subtle' : 'canvas.subtle',
|
|
66
|
+
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2, mb: 2 }, children: [_jsx(CheckCircleIcon, { size: 14 }), _jsx(Text, { sx: { fontSize: 1, fontWeight: 'bold' }, children: compaction.reduced ? 'Compacted' : 'History already minimal' })] }), _jsxs(Box, { sx: {
|
|
67
|
+
display: 'flex',
|
|
68
|
+
flexDirection: 'column',
|
|
69
|
+
gap: 1,
|
|
70
|
+
fontSize: 0,
|
|
71
|
+
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: [_jsx(Text, { sx: { color: 'fg.muted', minWidth: 64 }, children: "Tokens" }), _jsx(Text, { sx: { fontFamily: 'mono' }, children: numberFmt.format(compaction.beforeTokens) }), _jsx(ArrowRightIcon, { size: 12 }), _jsx(Text, { sx: { fontFamily: 'mono' }, children: numberFmt.format(compaction.afterTokens ?? compaction.beforeTokens) })] }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: [_jsx(Text, { sx: { color: 'fg.muted', minWidth: 64 }, children: "Messages" }), _jsx(Text, { sx: { fontFamily: 'mono' }, children: numberFmt.format(compaction.beforeMessages) }), _jsx(ArrowRightIcon, { size: 12 }), _jsx(Text, { sx: { fontFamily: 'mono' }, children: numberFmt.format(compaction.afterMessages ?? compaction.beforeMessages) })] }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: [_jsx(ClockIcon, { size: 12 }), _jsx(Text, { sx: { color: 'fg.muted', minWidth: 52 }, children: "Time" }), _jsxs(Text, { sx: { fontFamily: 'mono' }, children: [numberFmt.format(Math.round(compaction.durationMs ?? 0)), " ms"] })] }), typeof compaction.compactionCount === 'number' && (_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: [_jsx(Text, { sx: { color: 'fg.muted', minWidth: 64 }, children: "Total runs" }), _jsx(Text, { sx: { fontFamily: 'mono' }, children: numberFmt.format(compaction.compactionCount) })] }))] })] }))] }));
|
|
72
|
+
};
|
|
73
|
+
const AgentCompactionInner = ({ onLogout, }) => {
|
|
74
|
+
const { token } = useSimpleAuthStore();
|
|
75
|
+
const runtimeTarget = useRuntimeTargetStore(state => state.target);
|
|
76
|
+
const agentName = useRef(uniqueAgentId(AGENT_NAME)).current;
|
|
77
|
+
const tokenLimit = useRef(resolveAgentspecTokenLimit()).current;
|
|
78
|
+
const [maxTokensInput, setMaxTokensInput] = useState(Math.min(DEFAULT_MAX_TOKENS, tokenLimit));
|
|
79
|
+
const [launchedMaxTokens, setLaunchedMaxTokens] = useState(null);
|
|
80
|
+
const [runtimeStatus, setRuntimeStatus] = useState('idle');
|
|
81
|
+
const [isReady, setIsReady] = useState(false);
|
|
82
|
+
const [hookError, setHookError] = useState(null);
|
|
83
|
+
const [agentId, setAgentId] = useState(agentName);
|
|
84
|
+
const [isReconnectedAgent, setIsReconnectedAgent] = useState(false);
|
|
85
|
+
const agentBaseUrl = useExampleAgentRuntimesUrl();
|
|
86
|
+
const chatAuthToken = token === null ? undefined : token;
|
|
87
|
+
const authFetch = useCallback((url, opts = {}) => fetch(url, {
|
|
88
|
+
...opts,
|
|
89
|
+
headers: {
|
|
90
|
+
'Content-Type': 'application/json',
|
|
91
|
+
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
92
|
+
...(opts.headers ?? {}),
|
|
93
|
+
},
|
|
94
|
+
}), [token]);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (launchedMaxTokens === null)
|
|
97
|
+
return;
|
|
98
|
+
let isCancelled = false;
|
|
99
|
+
const createAgentForTarget = async () => {
|
|
100
|
+
setRuntimeStatus('launching');
|
|
101
|
+
setIsReady(false);
|
|
102
|
+
setHookError(null);
|
|
103
|
+
setIsReconnectedAgent(false);
|
|
104
|
+
// Clear any prior compaction status from a previous stream.
|
|
105
|
+
agentRuntimeStore.getState().setCompaction(null);
|
|
106
|
+
try {
|
|
107
|
+
const response = await authFetch(`${agentBaseUrl}/api/v1/agents`, {
|
|
108
|
+
method: 'POST',
|
|
109
|
+
body: JSON.stringify({
|
|
110
|
+
name: agentName,
|
|
111
|
+
description: 'Compaction example – history summarization under a token budget',
|
|
112
|
+
agent_library: 'pydantic-ai',
|
|
113
|
+
transport: 'vercel-ai',
|
|
114
|
+
agent_spec_id: AGENTSPEC_ID,
|
|
115
|
+
memory: 'ephemeral',
|
|
116
|
+
enable_skills: true,
|
|
117
|
+
tools: [],
|
|
118
|
+
compactionMaxTokens: launchedMaxTokens,
|
|
119
|
+
}),
|
|
120
|
+
});
|
|
121
|
+
let resolvedAgentId = agentName;
|
|
122
|
+
let isAlreadyRunning = false;
|
|
123
|
+
if (response.ok) {
|
|
124
|
+
const data = await response.json();
|
|
125
|
+
resolvedAgentId = data?.id || agentName;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const contentType = response.headers.get('content-type') || '';
|
|
129
|
+
let detail = '';
|
|
130
|
+
if (contentType.includes('application/json')) {
|
|
131
|
+
const data = await response.json().catch(() => null);
|
|
132
|
+
detail =
|
|
133
|
+
(typeof data?.detail === 'string' && data.detail) ||
|
|
134
|
+
(typeof data?.message === 'string' && data.message) ||
|
|
135
|
+
'';
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
detail = await response.text();
|
|
139
|
+
}
|
|
140
|
+
if (response.status === 409 || /already exists/i.test(detail || '')) {
|
|
141
|
+
isAlreadyRunning = true;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
throw new Error(detail || `Failed to create local agent: ${response.status}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (!isCancelled) {
|
|
148
|
+
setAgentId(resolvedAgentId);
|
|
149
|
+
setIsReconnectedAgent(isAlreadyRunning);
|
|
150
|
+
setIsReady(true);
|
|
151
|
+
setRuntimeStatus('ready');
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
if (!isCancelled) {
|
|
156
|
+
setHookError(error instanceof Error ? error.message : 'Agent failed to start');
|
|
157
|
+
setRuntimeStatus('error');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
void createAgentForTarget();
|
|
162
|
+
return () => {
|
|
163
|
+
isCancelled = true;
|
|
164
|
+
};
|
|
165
|
+
}, [agentBaseUrl, authFetch, runtimeTarget, launchedMaxTokens, agentName]);
|
|
166
|
+
// Setup phase: choose the compaction token budget before launching.
|
|
167
|
+
if (launchedMaxTokens === null) {
|
|
168
|
+
return (_jsx(Box, { sx: {
|
|
169
|
+
display: 'flex',
|
|
170
|
+
alignItems: 'center',
|
|
171
|
+
justifyContent: 'center',
|
|
172
|
+
height: '100%',
|
|
173
|
+
bg: 'canvas.default',
|
|
174
|
+
}, children: _jsxs(Box, { sx: {
|
|
175
|
+
width: 460,
|
|
176
|
+
maxWidth: '90%',
|
|
177
|
+
p: 4,
|
|
178
|
+
border: '1px solid',
|
|
179
|
+
borderColor: 'border.default',
|
|
180
|
+
borderRadius: 2,
|
|
181
|
+
bg: 'canvas.subtle',
|
|
182
|
+
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2, mb: 2 }, children: [_jsx(HistoryIcon, { size: 20 }), _jsx(Heading, { as: "h3", sx: { fontSize: 3 }, children: "History Compaction" })] }), _jsx(Text, { as: "p", sx: { fontSize: 1, color: 'fg.muted', mt: 0, mb: 3 }, children: "Set the context token budget before launching. When the conversation grows past this budget, older messages are summarized so the input stays within the limit. A lower budget triggers compaction sooner." }), _jsxs(FormControl, { children: [_jsxs(FormControl.Label, { children: ["Max context tokens: ", numberFmt.format(maxTokensInput)] }), _jsx(Box, { sx: { mt: 2 }, children: _jsx("input", { type: "range", min: MIN_MAX_TOKENS, max: tokenLimit, step: 500, value: maxTokensInput, onChange: e => setMaxTokensInput(Number(e.target.value)), style: { width: '100%' } }) }), _jsxs(FormControl.Caption, { children: ["Agentspec max: ", numberFmt.format(tokenLimit), " tokens (model limit)"] })] }), _jsx(Box, { sx: { display: 'flex', justifyContent: 'flex-end', mt: 3 }, children: _jsx(Button, { variant: "primary", leadingVisual: HistoryIcon, onClick: () => setLaunchedMaxTokens(maxTokensInput), children: "Launch agent" }) })] }) }));
|
|
183
|
+
}
|
|
184
|
+
if (!isReady && runtimeStatus !== 'error') {
|
|
185
|
+
return (_jsxs(Box, { sx: {
|
|
186
|
+
display: 'flex',
|
|
187
|
+
flexDirection: 'column',
|
|
188
|
+
alignItems: 'center',
|
|
189
|
+
justifyContent: 'center',
|
|
190
|
+
height: '100%',
|
|
191
|
+
gap: 3,
|
|
192
|
+
bg: 'canvas.default',
|
|
193
|
+
}, children: [_jsx(Spinner, { size: "large" }), _jsxs(Text, { sx: { color: 'fg.muted' }, children: ["Launching compaction example agent (", runtimeTarget, ")..."] })] }));
|
|
194
|
+
}
|
|
195
|
+
if (runtimeStatus === 'error' || hookError) {
|
|
196
|
+
return _jsx(ErrorView, { error: hookError, onLogout: onLogout });
|
|
197
|
+
}
|
|
198
|
+
return (_jsxs(Box, { sx: {
|
|
199
|
+
height: '100%',
|
|
200
|
+
display: 'flex',
|
|
201
|
+
flexDirection: 'column',
|
|
202
|
+
bg: 'canvas.default',
|
|
203
|
+
}, children: [_jsxs(Box, { sx: {
|
|
204
|
+
display: 'flex',
|
|
205
|
+
alignItems: 'center',
|
|
206
|
+
gap: 2,
|
|
207
|
+
px: 3,
|
|
208
|
+
py: 2,
|
|
209
|
+
borderBottom: '1px solid',
|
|
210
|
+
borderColor: 'border.default',
|
|
211
|
+
flexShrink: 0,
|
|
212
|
+
}, children: [_jsx(HistoryIcon, { size: 16 }), _jsx(Heading, { as: "h3", sx: { fontSize: 2, flex: 1 }, children: "Compaction Demo" }), isReconnectedAgent && (_jsx(Label, { variant: "secondary", size: "small", children: "Reconnected" })), _jsx(Label, { variant: "accent", children: runtimeTarget }), _jsxs(Label, { variant: "accent", children: [numberFmt.format(launchedMaxTokens), " tok budget"] })] }), _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: "Compaction Agent", brandIcon: _jsx(HistoryIcon, { size: 16 }), placeholder: "Chat until the history exceeds the token budget...", description: "History summarization under a token budget", showHeader: true, kernelIndicatorPlacement: "right", autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, suggestions: [
|
|
213
|
+
{
|
|
214
|
+
title: 'Fill the context',
|
|
215
|
+
message: 'Write a detailed, multi-paragraph essay on the history of computing, covering hardware, software, and networking eras.',
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
title: 'Keep going',
|
|
219
|
+
message: 'Now expand each section with more detail and concrete examples, adding at least three paragraphs per era.',
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
title: 'Recall earlier',
|
|
223
|
+
message: 'Summarize everything we have discussed so far in this conversation.',
|
|
224
|
+
},
|
|
225
|
+
], submitOnSuggestionClick: true }) }), _jsxs(Box, { sx: {
|
|
226
|
+
width: 320,
|
|
227
|
+
borderLeft: '1px solid',
|
|
228
|
+
borderColor: 'border.default',
|
|
229
|
+
display: 'flex',
|
|
230
|
+
flexDirection: 'column',
|
|
231
|
+
overflow: 'auto',
|
|
232
|
+
}, children: [_jsx(CompactionPanel, { maxTokens: launchedMaxTokens }), _jsxs(Box, { sx: { p: 3 }, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "How It Works" }), _jsxs(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mb: 2 }, children: ["Before each model request, the compaction capability estimates the history size. When it exceeds a fraction of the", ' ', numberFmt.format(launchedMaxTokens), "-token budget, older messages are replaced by an LLM-generated summary while recent messages are preserved."] }), _jsxs(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mb: 0 }, children: ["The budget is capped at the agentspec model's token limit (", numberFmt.format(tokenLimit), "). Lower it to trigger compaction with a shorter conversation."] })] })] })] })] }));
|
|
233
|
+
};
|
|
234
|
+
const AgentCompactionExample = () => {
|
|
235
|
+
const { token, clearAuth } = useSimpleAuthStore();
|
|
236
|
+
const handleLogout = useCallback(() => {
|
|
237
|
+
clearAuth();
|
|
238
|
+
}, [clearAuth]);
|
|
239
|
+
if (!token) {
|
|
240
|
+
return (_jsx(ThemedProvider, { children: _jsx(AuthRequiredView, {}) }));
|
|
241
|
+
}
|
|
242
|
+
return (_jsx(ThemedProvider, { children: _jsx(AgentCompactionInner, { onLogout: handleLogout }) }));
|
|
243
|
+
};
|
|
244
|
+
export default AgentCompactionExample;
|
|
@@ -17,24 +17,22 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
17
17
|
/// <reference types="vite/client" />
|
|
18
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,
|
|
20
|
+
import { Text, Button, Spinner, Heading, Label, Flash, ProgressBar, } from '@primer/react';
|
|
21
21
|
import { BeakerIcon, CheckCircleIcon, XCircleIcon, PlayIcon, } from '@primer/octicons-react';
|
|
22
22
|
import { Box } from '@datalayer/primer-addons';
|
|
23
23
|
import { AuthRequiredView, ErrorView } from './components';
|
|
24
24
|
import { ThemedProvider } from './utils/themedProvider';
|
|
25
25
|
import { uniqueAgentId } from './utils/agentId';
|
|
26
|
-
import { useExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
26
|
+
import { resolveExampleAgentRuntimesUrl, useExampleAgentRuntimesUrl, } from './utils/useExampleAgentRuntimesUrl';
|
|
27
|
+
import { useRuntimeTargetStore, } from './utils/runtimeTargetStore';
|
|
27
28
|
import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
|
|
28
29
|
import { useCoreStore } from '@datalayer/core';
|
|
29
30
|
import { Chat } from '../chat';
|
|
30
|
-
import { useAgentRuntimes } from '
|
|
31
|
+
import { useExampleAgentRuntimes as useAgentRuntimes } from './hooks/useExampleAgentRuntimes';
|
|
31
32
|
const queryClient = new QueryClient();
|
|
32
33
|
// ─── Constants ─────────────────────────────────────────────────────────────
|
|
33
34
|
const AGENT_NAME = 'eval-example-agent';
|
|
34
35
|
const AGENTSPEC_ID = 'example-evals';
|
|
35
|
-
const DEFAULT_EXECUTION_TARGET = (import.meta.env.VITE_AGENT_EVALS_TARGET || 'cloud').toLowerCase() === 'local'
|
|
36
|
-
? 'local'
|
|
37
|
-
: 'cloud';
|
|
38
36
|
const normalizeHttpUrl = (value) => {
|
|
39
37
|
if (typeof value !== 'string') {
|
|
40
38
|
return null;
|
|
@@ -72,25 +70,17 @@ const isLocalhostUrl = (value) => {
|
|
|
72
70
|
}
|
|
73
71
|
};
|
|
74
72
|
// ─── Inner component (rendered after auth) ─────────────────────────────────
|
|
75
|
-
const AgentEvalsInner = ({ onLogout, executionTarget
|
|
73
|
+
const AgentEvalsInner = ({ onLogout, executionTarget }) => {
|
|
76
74
|
const { token } = useSimpleAuthStore();
|
|
77
75
|
const { configuration } = useCoreStore();
|
|
78
76
|
const agentName = useRef(uniqueAgentId(AGENT_NAME)).current;
|
|
79
77
|
const localRuntimeBaseUrl = useExampleAgentRuntimesUrl();
|
|
80
78
|
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
79
|
const configuredRuntimesUrl = normalizeHttpUrl(configuration?.runtimesUrl);
|
|
84
|
-
if (envRuntimesUrl && !isLocalhostUrl(envRuntimesUrl)) {
|
|
85
|
-
return envRuntimesUrl;
|
|
86
|
-
}
|
|
87
80
|
if (configuredRuntimesUrl && !isLocalhostUrl(configuredRuntimesUrl)) {
|
|
88
81
|
return configuredRuntimesUrl;
|
|
89
82
|
}
|
|
90
|
-
|
|
91
|
-
return envAgentRuntimesUrl;
|
|
92
|
-
}
|
|
93
|
-
return 'https://r1.datalayer.run';
|
|
83
|
+
return resolveExampleAgentRuntimesUrl('cloud');
|
|
94
84
|
}, [configuration?.runtimesUrl]);
|
|
95
85
|
const { runtime, status: runtimeStatus, isReady, error: hookError, runtimeCreationBaseUrl, } = useAgentRuntimes({
|
|
96
86
|
agentSpecId: AGENTSPEC_ID,
|
|
@@ -420,9 +410,9 @@ const AgentEvalsInner = ({ onLogout, executionTarget, onExecutionTargetChange })
|
|
|
420
410
|
overflow: 'hidden',
|
|
421
411
|
textOverflow: 'ellipsis',
|
|
422
412
|
whiteSpace: 'nowrap',
|
|
423
|
-
}, children: ["Runtime API: ", runtimeCreationBaseUrl, "/api/runtimes/v1/runtimes"] })] }), _jsxs(
|
|
413
|
+
}, children: ["Runtime API: ", runtimeCreationBaseUrl, "/api/runtimes/v1/runtimes"] })] }), _jsxs(Label, { size: "small", variant: "accent", children: ["Target: ", executionTarget === 'cloud' ? 'Cloud' : '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
|
|
424
414
|
? `Last score: ${(latestScore * 100).toFixed(0)}%`
|
|
425
|
-
: 'No evaluations run yet', showHeader: true, autoFocus: true, height: "100%", runtimeId: podName, historyEndpoint: `${agentBaseUrl}/api/v1/history`, suggestions: [
|
|
415
|
+
: 'No evaluations run yet', showHeader: true, kernelIndicatorPlacement: "right", autoFocus: true, height: "100%", runtimeId: podName, historyEndpoint: `${agentBaseUrl}/api/v1/history`, suggestions: [
|
|
426
416
|
{
|
|
427
417
|
title: 'Summarize KPIs',
|
|
428
418
|
message: 'Summarize the latest KPI data',
|
|
@@ -474,7 +464,7 @@ const syncTokenToIamStore = (token) => {
|
|
|
474
464
|
const AgentEvalsExample = () => {
|
|
475
465
|
const { token, clearAuth } = useSimpleAuthStore();
|
|
476
466
|
const hasSynced = useRef(false);
|
|
477
|
-
const
|
|
467
|
+
const executionTarget = useRuntimeTargetStore(state => state.target);
|
|
478
468
|
useEffect(() => {
|
|
479
469
|
if (token && !hasSynced.current) {
|
|
480
470
|
hasSynced.current = true;
|
|
@@ -491,6 +481,6 @@ const AgentEvalsExample = () => {
|
|
|
491
481
|
if (!token) {
|
|
492
482
|
return (_jsx(ThemedProvider, { children: _jsx(AuthRequiredView, {}) }));
|
|
493
483
|
}
|
|
494
|
-
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(ThemedProvider, { children: _jsx(AgentEvalsInner, { onLogout: handleLogout, executionTarget: executionTarget
|
|
484
|
+
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(ThemedProvider, { children: _jsx(AgentEvalsInner, { onLogout: handleLogout, executionTarget: executionTarget }, executionTarget) }) }));
|
|
495
485
|
};
|
|
496
486
|
export default AgentEvalsExample;
|
|
@@ -227,7 +227,7 @@ const AgentGuardrailsInner = ({ onLogout, }) => {
|
|
|
227
227
|
configuration?.datalayerUrl ||
|
|
228
228
|
OTEL_BASE_URL_ENV ||
|
|
229
229
|
DATALAYER_URL_ENV ||
|
|
230
|
-
|
|
230
|
+
agentBaseUrl;
|
|
231
231
|
const podName = agentId;
|
|
232
232
|
const chatAuthToken = token === null ? undefined : token;
|
|
233
233
|
// Authenticated fetch helper (for sidecar endpoints)
|
|
@@ -487,7 +487,7 @@ const AgentGuardrailsInner = ({ onLogout, }) => {
|
|
|
487
487
|
? ` (over by $${overBudgetAmountUsd.toFixed(4)}).`
|
|
488
488
|
: '.', ' ', "Start a new run or increase the run budget before continuing."] }) })), approvals.map(req => (_jsx(Flash, { variant: "warning", sx: { mx: 3, mt: 2 }, children: _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsxs(Text, { sx: { flex: 1, fontSize: 1 }, children: [_jsx("strong", { children: req.tool_name }), " requests approval", req.tool_args
|
|
489
489
|
? ` — ${JSON.stringify(req.tool_args).slice(0, 120)}`
|
|
490
|
-
: ''] }), _jsx(Button, { size: "small", variant: "primary", leadingVisual: CheckIcon, onClick: () => handleApprove(req.id), disabled: approvalLoading === req.id, children: "Approve" }), _jsx(Button, { size: "small", variant: "danger", leadingVisual: XIcon, onClick: () => handleReject(req.id), disabled: approvalLoading === req.id, children: "Reject" })] }) }, req.id))), _jsx(Box, { sx: { flex: 1, minHeight: 0 }, children: _jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: "Guardrails Agent", brandIcon: _jsx(ShieldCheckIcon, { size: 16 }), placeholder: "Ask something that triggers tools\u2026", description: "Cost guardrail with OTEL-backed gauge and hook-aware approvals (before_tool_execute, after_tool_execute, on_tool_execute_error, deferred_tool_calls)", showHeader: true, showTokenUsage: true, errorBanner: overBudgetBanner, disableInputPrompt: isOverRunBudget, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, suggestions: [
|
|
490
|
+
: ''] }), _jsx(Button, { size: "small", variant: "primary", leadingVisual: CheckIcon, onClick: () => handleApprove(req.id), disabled: approvalLoading === req.id, children: "Approve" }), _jsx(Button, { size: "small", variant: "danger", leadingVisual: XIcon, onClick: () => handleReject(req.id), disabled: approvalLoading === req.id, children: "Reject" })] }) }, req.id))), _jsx(Box, { sx: { flex: 1, minHeight: 0 }, children: _jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: "Guardrails Agent", brandIcon: _jsx(ShieldCheckIcon, { size: 16 }), placeholder: "Ask something that triggers tools\u2026", description: "Cost guardrail with OTEL-backed gauge and hook-aware approvals (before_tool_execute, after_tool_execute, on_tool_execute_error, deferred_tool_calls)", showHeader: true, kernelIndicatorPlacement: "right", showTokenUsage: true, errorBanner: overBudgetBanner, disableInputPrompt: isOverRunBudget, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, suggestions: [
|
|
491
491
|
{ title: 'Update CRM', message: 'Update the CRM records for Q3' },
|
|
492
492
|
{
|
|
493
493
|
title: 'Trigger before_tool_execute',
|
|
@@ -43,7 +43,7 @@ const AgentHooksExample = () => {
|
|
|
43
43
|
if (error || !agentId) {
|
|
44
44
|
return (_jsx(ThemedProvider, { children: _jsx(ErrorView, { error: "Failed to start hooks agent", detail: error || 'No agent ID returned' }) }));
|
|
45
45
|
}
|
|
46
|
-
return (_jsx(Chat, { protocol: "vercel-ai", baseUrl: baseUrl, agentId: agentId, title: "Hooks Agent", brandIcon: _jsx(SyncIcon, { size: 16 }), placeholder: "Ask about lifecycle hooks...", description: "Demonstrates lifecycle hooks and pydantic-style tool hooks: before_tool_execute, after_tool_execute, on_tool_execute_error, deferred_tool_calls", showHeader: true, showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, showInformation: true, autoFocus: true, height: "100vh", runtimeId: agentId, historyEndpoint: `${baseUrl}/api/v1/history`, suggestions: [
|
|
46
|
+
return (_jsx(Chat, { protocol: "vercel-ai", baseUrl: baseUrl, agentId: agentId, title: "Hooks Agent", brandIcon: _jsx(SyncIcon, { size: 16 }), placeholder: "Ask about lifecycle hooks...", description: "Demonstrates lifecycle hooks and pydantic-style tool hooks: before_tool_execute, after_tool_execute, on_tool_execute_error, deferred_tool_calls", showHeader: true, kernelIndicatorPlacement: "right", showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, showInformation: true, autoFocus: true, height: "100vh", runtimeId: agentId, historyEndpoint: `${baseUrl}/api/v1/history`, suggestions: [
|
|
47
47
|
{
|
|
48
48
|
title: 'Read the pre-hook marker file',
|
|
49
49
|
message: 'Use execute_code to read /tmp/agent_runtimes_pre_hook_demo.txt and show its contents.',
|
|
@@ -37,7 +37,7 @@ const ProviderBadge = ({ provider, }) => (_jsx(Box, { sx: {
|
|
|
37
37
|
borderColor: 'border.default',
|
|
38
38
|
fontSize: 0,
|
|
39
39
|
color: 'fg.muted',
|
|
40
|
-
bg: 'canvas.
|
|
40
|
+
bg: 'canvas.default',
|
|
41
41
|
textTransform: 'uppercase',
|
|
42
42
|
letterSpacing: '0.03em',
|
|
43
43
|
}, children: provider }));
|
|
@@ -57,10 +57,8 @@ const AgentInferenceProviderExampleInner = () => {
|
|
|
57
57
|
return 'local inference';
|
|
58
58
|
}
|
|
59
59
|
const env = import.meta.env ?? {};
|
|
60
|
-
return (env.VITE_DATALAYER_AI_INFERENCE_URL ||
|
|
61
|
-
|
|
62
|
-
'https://prod1.datalayer.run');
|
|
63
|
-
}, [provider]);
|
|
60
|
+
return (env.VITE_DATALAYER_AI_INFERENCE_URL || env.VITE_DATALAYER_URL || baseUrl);
|
|
61
|
+
}, [provider, baseUrl]);
|
|
64
62
|
const authFetch = useCallback((url, init = {}) => {
|
|
65
63
|
return fetch(url, {
|
|
66
64
|
...init,
|
|
@@ -248,7 +246,7 @@ const AgentInferenceProviderExampleInner = () => {
|
|
|
248
246
|
borderRadius: 2,
|
|
249
247
|
overflow: 'hidden',
|
|
250
248
|
bg: 'canvas.default',
|
|
251
|
-
}, children: agentId && !isLaunching ? (_jsx(Chat, { protocol: "vercel-ai", baseUrl: baseUrl, agentId: agentId, authToken: token ?? undefined, title: "Agent Inference Provider Example", subtitle: `Spec: ${AGENTSPEC_ID}`, placeholder: "Ask the inference provider something...", showHeader: true, showNewChatButton: true, showClearButton: true, showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${baseUrl}/api/v1/history`, onMessageSent: content => {
|
|
249
|
+
}, children: agentId && !isLaunching ? (_jsx(Chat, { protocol: "vercel-ai", baseUrl: baseUrl, agentId: agentId, authToken: token ?? undefined, title: "Agent Inference Provider Example", subtitle: `Spec: ${AGENTSPEC_ID}`, placeholder: "Ask the inference provider something...", showHeader: true, kernelIndicatorPlacement: "right", showNewChatButton: true, showClearButton: true, showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${baseUrl}/api/v1/history`, onMessageSent: content => {
|
|
252
250
|
appendProviderEvent('provider.request', `Sent message via ${provider}`, {
|
|
253
251
|
provider,
|
|
254
252
|
agentId,
|
|
@@ -275,7 +273,7 @@ const AgentInferenceProviderExampleInner = () => {
|
|
|
275
273
|
gap: 2,
|
|
276
274
|
minHeight: 0,
|
|
277
275
|
overflow: 'hidden',
|
|
278
|
-
bg: 'canvas.
|
|
276
|
+
bg: 'canvas.default',
|
|
279
277
|
}, children: [_jsx(Heading, { as: "h3", sx: { fontSize: 2 }, children: "Provider Event Stream" }), _jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "Low-level request/response events exchanged with the inference provider (newest first)." }), _jsx(Box, { sx: {
|
|
280
278
|
flex: 1,
|
|
281
279
|
minHeight: 0,
|
|
@@ -317,7 +315,7 @@ const AgentInferenceProviderExampleInner = () => {
|
|
|
317
315
|
mb: 0,
|
|
318
316
|
p: 2,
|
|
319
317
|
borderRadius: 2,
|
|
320
|
-
bg: 'canvas.
|
|
318
|
+
bg: 'canvas.default',
|
|
321
319
|
fontSize: 0,
|
|
322
320
|
whiteSpace: 'pre-wrap',
|
|
323
321
|
fontFamily: 'mono',
|
|
@@ -135,8 +135,8 @@ function LoopSummary({ loop }) {
|
|
|
135
135
|
px: 2,
|
|
136
136
|
py: '2px',
|
|
137
137
|
borderRadius: 6,
|
|
138
|
-
bg: '
|
|
139
|
-
color: '
|
|
138
|
+
bg: 'neutral.muted',
|
|
139
|
+
color: 'fg.default',
|
|
140
140
|
fontWeight: 'bold',
|
|
141
141
|
}, children: [index + 1, ". ", phase] }, phase))) }), loop.objective && (_jsxs(Box, { sx: { color: 'fg.muted' }, children: [_jsx("strong", { children: "Objective:" }), " ", loop.objective] })), loop.termination && (_jsxs(Box, { sx: { color: 'fg.muted', mt: 1 }, children: [_jsx("strong", { children: "Max iterations:" }), " ", loop.termination.maxIterations, " \u00B7", ' ', _jsx("strong", { children: "On blocked:" }), " ", loop.termination.onBlocked] }))] }));
|
|
142
142
|
}
|
|
@@ -241,7 +241,7 @@ export function AgentLoopExampleInner({ serviceManager, }) {
|
|
|
241
241
|
p: 3,
|
|
242
242
|
borderBottom: '1px solid',
|
|
243
243
|
borderColor: 'border.default',
|
|
244
|
-
bg: 'canvas.
|
|
244
|
+
bg: 'canvas.default',
|
|
245
245
|
}, children: [_jsxs(Box, { sx: {
|
|
246
246
|
display: 'flex',
|
|
247
247
|
alignItems: 'center',
|
|
@@ -387,7 +387,7 @@ const AgentMCPInner = ({ onLogout }) => {
|
|
|
387
387
|
py: 1,
|
|
388
388
|
borderBottom: '1px solid',
|
|
389
389
|
borderColor: 'border.default',
|
|
390
|
-
}, 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: "MCP Demo Agent", brandIcon: _jsx(GlobeIcon, { size: 16 }), placeholder: "Ask the agent to search the web or explore GitHub...", showHeader: true, showNewChatButton: true, showClearButton: true, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, mcpStatusData: mcpStatusData, showToolApprovalBanner: true, headerActions: _jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: _jsxs(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: ["MCP Tools: ", totalTools] }) }), suggestions: [
|
|
390
|
+
}, 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: "MCP Demo Agent", brandIcon: _jsx(GlobeIcon, { size: 16 }), placeholder: "Ask the agent to search the web or explore GitHub...", showHeader: true, kernelIndicatorPlacement: "right", showNewChatButton: true, showClearButton: true, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, mcpStatusData: mcpStatusData, showToolApprovalBanner: true, headerActions: _jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: _jsxs(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: ["MCP Tools: ", totalTools] }) }), suggestions: [
|
|
391
391
|
{
|
|
392
392
|
title: '🔍 Search the web',
|
|
393
393
|
message: 'Search the web for recent news about AI agents.',
|
|
@@ -416,7 +416,7 @@ const AgentMCPInner = ({ onLogout }) => {
|
|
|
416
416
|
display: 'flex',
|
|
417
417
|
flexDirection: 'column',
|
|
418
418
|
minHeight: 0,
|
|
419
|
-
bg: 'canvas.
|
|
419
|
+
bg: 'canvas.default',
|
|
420
420
|
}, children: [_jsxs(Box, { sx: {
|
|
421
421
|
p: 2,
|
|
422
422
|
borderBottom: '1px solid',
|
|
@@ -438,7 +438,7 @@ const AgentMCPInner = ({ onLogout }) => {
|
|
|
438
438
|
mt: 3,
|
|
439
439
|
p: 2,
|
|
440
440
|
borderRadius: 2,
|
|
441
|
-
bg: 'canvas.
|
|
441
|
+
bg: 'canvas.default',
|
|
442
442
|
border: '1px solid',
|
|
443
443
|
borderColor: 'border.muted',
|
|
444
444
|
}, children: [_jsx(Heading, { as: "h5", sx: { fontSize: 0, mb: 1 }, children: "MCP (Model Context Protocol)" }), _jsxs(Box, { sx: { fontSize: 0, color: 'fg.muted' }, children: [_jsxs(Box, { sx: {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AgentMemoryExample
|
|
3
3
|
*
|
|
4
|
-
* Demonstrates
|
|
5
|
-
*
|
|
4
|
+
* Demonstrates durable agent memory.
|
|
5
|
+
* Uses a local SQLite store for local runs (offline, no API key) and
|
|
6
|
+
* pgvector-backed Mem0 (PostgreSQL) for cloud runs when server-side
|
|
7
|
+
* postgres env is configured.
|
|
6
8
|
*
|
|
7
9
|
* The left panel shows a standard Chat. The right panel shows the
|
|
8
10
|
* agent's memory contents (fetched from the runtime sidecar) and lets
|