@datalayer/agent-runtimes 1.0.21 → 1.0.26
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 +2 -2
- package/lib/AgentNode.js +26 -26
- package/lib/chat/Chat.d.ts +1 -1
- package/lib/chat/Chat.js +2 -2
- package/lib/chat/base/ChatBase.js +44 -9
- package/lib/chat/document/EphemeralDocument.d.ts +12 -1
- package/lib/chat/document/EphemeralDocument.js +4 -4
- package/lib/chat/notebook/EphemeralNotebook.d.ts +11 -1
- package/lib/chat/notebook/EphemeralNotebook.js +13 -2
- package/lib/collaboration/DatalayerCollaborationProvider.d.ts +1 -1
- package/lib/collaboration/DatalayerCollaborationProvider.js +5 -5
- package/lib/components/agents/index.d.ts +6 -0
- package/lib/components/{students → agents}/index.js +6 -1
- package/lib/components/{NotificationEventCard.js → cards/NotificationEventCard.js} +1 -1
- package/lib/components/{OutputCard.js → cards/OutputCard.js} +1 -1
- package/lib/components/cards/index.d.ts +9 -0
- package/lib/components/cards/index.js +13 -0
- package/lib/components/{runtimes/RuntimeCellVariables.d.ts → code-sandboxes/CodeSandboxCellVariables.d.ts} +3 -3
- package/lib/components/{runtimes/RuntimeCellVariables.js → code-sandboxes/CodeSandboxCellVariables.js} +2 -2
- package/lib/components/{runtimes/RuntimeCellVariablesDialog.d.ts → code-sandboxes/CodeSandboxCellVariablesDialog.d.ts} +4 -4
- package/lib/components/{runtimes/RuntimeCellVariablesDialog.js → code-sandboxes/CodeSandboxCellVariablesDialog.js} +4 -4
- package/lib/components/{runtimes/RuntimeLauncherDialog.d.ts → code-sandboxes/CodeSandboxLauncher.d.ts} +4 -4
- package/lib/components/{runtimes/RuntimeLauncherDialog.js → code-sandboxes/CodeSandboxLauncher.js} +33 -38
- package/lib/components/code-sandboxes/CodeSandboxPicker.d.ts +96 -0
- package/lib/components/code-sandboxes/CodeSandboxPicker.js +296 -0
- package/lib/components/{runtimes/RuntimePickerCell.d.ts → code-sandboxes/CodeSandboxPickerCell.d.ts} +5 -5
- package/lib/components/{runtimes/RuntimePickerCell.js → code-sandboxes/CodeSandboxPickerCell.js} +7 -7
- package/lib/components/{runtimes/RuntimeReservationControl.d.ts → code-sandboxes/CodeSandboxReservationControl.d.ts} +3 -3
- package/lib/components/{runtimes/RuntimeReservationControl.js → code-sandboxes/CodeSandboxReservationControl.js} +11 -4
- package/lib/components/{runtimes/RuntimeTransfer.d.ts → code-sandboxes/CodeSandboxTransfer.d.ts} +1 -1
- package/lib/components/{runtimes/RuntimeUtils.d.ts → code-sandboxes/CodeSandboxUtils.d.ts} +3 -3
- package/lib/components/{runtimes/RuntimeUtils.js → code-sandboxes/CodeSandboxUtils.js} +35 -19
- package/lib/components/code-sandboxes/CodeSandboxVariables.d.ts +71 -0
- package/lib/components/{runtimes/RuntimeVariables.js → code-sandboxes/CodeSandboxVariables.js} +77 -2
- package/lib/components/code-sandboxes/NewCodeSandboxControls.d.ts +42 -0
- package/lib/components/code-sandboxes/NewCodeSandboxControls.js +76 -0
- package/lib/components/code-sandboxes/index.d.ts +21 -0
- package/lib/components/code-sandboxes/index.js +25 -0
- package/lib/components/index.d.ts +4 -6
- package/lib/components/index.js +4 -6
- package/lib/components/progress/CreditsIndicator.d.ts +7 -0
- package/lib/components/progress/CreditsIndicator.js +3 -3
- package/lib/context/CostUsageChart.d.ts +2 -2
- package/lib/context/CostUsageChart.js +7 -7
- package/lib/context/TokenUsageChart.d.ts +2 -2
- package/lib/context/TokenUsageChart.js +6 -6
- package/lib/context/TurnGraphChart.d.ts +1 -1
- package/lib/context/TurnGraphChart.js +6 -6
- package/lib/examples/AgentEvalsExample.js +1 -1
- package/lib/examples/AgentGuardrailsExample.js +3 -3
- package/lib/examples/AgentInferenceProviderExample.js +1 -1
- package/lib/examples/AgentMonitoringExample.js +6 -6
- package/lib/examples/AgentOtelExample.d.ts +2 -2
- package/lib/examples/AgentOtelExample.js +5 -5
- package/lib/examples/AgentspecsExample.js +1 -1
- package/lib/examples/NotebookCollaborationExample.js +8 -8
- package/lib/examples/main.js +5 -5
- package/lib/examples2/DatalayerNotebookExample.js +8 -8
- package/lib/examples2/main.js +5 -5
- package/lib/hooks/useAgentRuntimes.js +3 -3
- package/lib/hooks/useMonitoring.d.ts +5 -5
- package/lib/hooks/useMonitoring.js +10 -10
- package/lib/protocols/AGUIAdapter.js +4 -0
- package/lib/protocols/VercelAIAdapter.js +3 -0
- package/lib/types/chat.d.ts +23 -0
- package/lib/types/tools.d.ts +11 -0
- package/package.json +4 -4
- package/lib/components/runtimes/RuntimePickerBase.d.ts +0 -69
- package/lib/components/runtimes/RuntimePickerBase.js +0 -157
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +0 -42
- package/lib/components/runtimes/RuntimePickerNotebook.js +0 -232
- package/lib/components/runtimes/RuntimeSimplePicker.d.ts +0 -38
- package/lib/components/runtimes/RuntimeSimplePicker.js +0 -156
- package/lib/components/runtimes/RuntimeVariables.d.ts +0 -38
- package/lib/components/runtimes/index.d.ts +0 -11
- package/lib/components/runtimes/index.js +0 -15
- package/lib/components/students/StudentItemStatus.d.ts +0 -7
- package/lib/components/students/StudentItemStatus.js +0 -68
- package/lib/components/students/index.d.ts +0 -1
- package/lib/components/toolbars/AssignmentEditorToolbar.d.ts +0 -4
- package/lib/components/toolbars/AssignmentEditorToolbar.js +0 -18
- package/lib/components/toolbars/DocumentEditorToolbar.d.ts +0 -2
- package/lib/components/toolbars/DocumentEditorToolbar.js +0 -12
- package/lib/components/toolbars/NotebookEditorToolbar.d.ts +0 -29
- package/lib/components/toolbars/NotebookEditorToolbar.js +0 -30
- package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
- /package/lib/components/{AgentSummary.d.ts → agents/AgentSummary.d.ts} +0 -0
- /package/lib/components/{AgentSummary.js → agents/AgentSummary.js} +0 -0
- /package/lib/components/{NotificationEventCard.d.ts → cards/NotificationEventCard.d.ts} +0 -0
- /package/lib/components/{OutputCard.d.ts → cards/OutputCard.d.ts} +0 -0
- /package/lib/components/{ToolApprovalCard.d.ts → cards/ToolApprovalCard.d.ts} +0 -0
- /package/lib/components/{ToolApprovalCard.js → cards/ToolApprovalCard.js} +0 -0
- /package/lib/components/{runtimes/RuntimeTransfer.js → code-sandboxes/CodeSandboxTransfer.js} +0 -0
|
@@ -3,7 +3,7 @@ export interface TokenUsageChartProps {
|
|
|
3
3
|
agentId?: string;
|
|
4
4
|
runtimeId?: string;
|
|
5
5
|
apiKey?: string;
|
|
6
|
-
|
|
6
|
+
otelUrl?: string;
|
|
7
7
|
wsUrl?: string;
|
|
8
8
|
liveSystemPromptTokens?: number;
|
|
9
9
|
liveToolsDescriptionTokens?: number;
|
|
@@ -14,5 +14,5 @@ export interface TokenUsageChartProps {
|
|
|
14
14
|
height?: number;
|
|
15
15
|
days?: number;
|
|
16
16
|
}
|
|
17
|
-
export declare function TokenUsageChart({ serviceName, agentId, runtimeId, apiKey,
|
|
17
|
+
export declare function TokenUsageChart({ serviceName, agentId, runtimeId, apiKey, otelUrl, wsUrl, liveSystemPromptTokens, liveToolsDescriptionTokens, liveUserMessageTokens, liveAgentMessageTokens, liveToolsUsageTokens, liveTimestampMs, height, }: TokenUsageChartProps): import("react/jsx-runtime").JSX.Element;
|
|
18
18
|
export default TokenUsageChart;
|
|
@@ -280,7 +280,7 @@ function extractAgentId(row) {
|
|
|
280
280
|
return aid;
|
|
281
281
|
return undefined;
|
|
282
282
|
}
|
|
283
|
-
export function TokenUsageChart({ serviceName, agentId, runtimeId, apiKey,
|
|
283
|
+
export function TokenUsageChart({ serviceName, agentId, runtimeId, apiKey, otelUrl, wsUrl, liveSystemPromptTokens, liveToolsDescriptionTokens, liveUserMessageTokens, liveAgentMessageTokens, liveToolsUsageTokens, liveTimestampMs, height = 160, }) {
|
|
284
284
|
const cacheServiceKey = String(serviceName || runtimeId || '').trim() || undefined;
|
|
285
285
|
const monitoringCache = useAgentRuntimeStore(s => s.monitoringCache);
|
|
286
286
|
const mergeTokenTurns = useAgentRuntimeStore(s => s.mergeTokenTurns);
|
|
@@ -311,7 +311,7 @@ export function TokenUsageChart({ serviceName, agentId, runtimeId, apiKey, datal
|
|
|
311
311
|
// Bootstrap chart with historical OTEL metrics so charts are populated even
|
|
312
312
|
// before the first websocket update arrives.
|
|
313
313
|
useEffect(() => {
|
|
314
|
-
if (!cacheServiceKey || !apiKey || !
|
|
314
|
+
if (!cacheServiceKey || !apiKey || !otelUrl) {
|
|
315
315
|
return;
|
|
316
316
|
}
|
|
317
317
|
let cancelled = false;
|
|
@@ -321,7 +321,7 @@ export function TokenUsageChart({ serviceName, agentId, runtimeId, apiKey, datal
|
|
|
321
321
|
const results = await Promise.all(metricNames.map(metric => fetchOtelMetricRows({
|
|
322
322
|
metric,
|
|
323
323
|
serviceName,
|
|
324
|
-
|
|
324
|
+
otelUrl,
|
|
325
325
|
apiKey,
|
|
326
326
|
limit: 1000,
|
|
327
327
|
})));
|
|
@@ -375,7 +375,7 @@ export function TokenUsageChart({ serviceName, agentId, runtimeId, apiKey, datal
|
|
|
375
375
|
agentId,
|
|
376
376
|
apiKey,
|
|
377
377
|
cacheServiceKey,
|
|
378
|
-
|
|
378
|
+
otelUrl,
|
|
379
379
|
mergeTokenTurns,
|
|
380
380
|
runtimeId,
|
|
381
381
|
serviceName,
|
|
@@ -439,7 +439,7 @@ export function TokenUsageChart({ serviceName, agentId, runtimeId, apiKey, datal
|
|
|
439
439
|
if (!cacheServiceKey || !apiKey)
|
|
440
440
|
return;
|
|
441
441
|
const rawBaseUrl = wsUrl ||
|
|
442
|
-
|
|
442
|
+
otelUrl ||
|
|
443
443
|
(typeof window !== 'undefined' ? window.location.origin : '');
|
|
444
444
|
if (!rawBaseUrl)
|
|
445
445
|
return;
|
|
@@ -496,7 +496,7 @@ export function TokenUsageChart({ serviceName, agentId, runtimeId, apiKey, datal
|
|
|
496
496
|
apiKey,
|
|
497
497
|
cacheServiceKey,
|
|
498
498
|
mergeTokenTurns,
|
|
499
|
-
|
|
499
|
+
otelUrl,
|
|
500
500
|
runtimeId,
|
|
501
501
|
serviceName,
|
|
502
502
|
wsUrl,
|
|
@@ -24,7 +24,7 @@ export interface TurnGraphChartProps {
|
|
|
24
24
|
/** Filter spans to this agent ID (matches ``agent.id`` span attribute). */
|
|
25
25
|
agentId?: string;
|
|
26
26
|
/** Base URL for the Datalayer OTEL service. */
|
|
27
|
-
|
|
27
|
+
otelUrl?: string;
|
|
28
28
|
/** JWT / API key for OTEL auth. */
|
|
29
29
|
apiKey?: string;
|
|
30
30
|
/**
|
|
@@ -386,7 +386,7 @@ function buildOption(run) {
|
|
|
386
386
|
],
|
|
387
387
|
};
|
|
388
388
|
}
|
|
389
|
-
export const TurnGraphChart = ({ serviceName, agentId,
|
|
389
|
+
export const TurnGraphChart = ({ serviceName, agentId, otelUrl, apiKey, autoRefreshMs = 10_000, height = 320, style, }) => {
|
|
390
390
|
const [runs, setRuns] = useState([]);
|
|
391
391
|
const [selectedIdx, setSelectedIdx] = useState(0);
|
|
392
392
|
const [loading, setLoading] = useState(false);
|
|
@@ -440,12 +440,12 @@ export const TurnGraphChart = ({ serviceName, agentId, datalayerUrl, apiKey, aut
|
|
|
440
440
|
};
|
|
441
441
|
}, []);
|
|
442
442
|
const fetchData = useCallback(async () => {
|
|
443
|
-
if (!
|
|
443
|
+
if (!otelUrl || !apiKey)
|
|
444
444
|
return;
|
|
445
445
|
setLoading(true);
|
|
446
446
|
setError(null);
|
|
447
447
|
try {
|
|
448
|
-
const client = createOtelClient({ baseUrl:
|
|
448
|
+
const client = createOtelClient({ baseUrl: otelUrl, token: apiKey });
|
|
449
449
|
const result = await client.fetchTraces({ serviceName, limit: 200 });
|
|
450
450
|
if (mountedRef.current)
|
|
451
451
|
upsertRunsFromSpans(result.data, 'replace');
|
|
@@ -459,9 +459,9 @@ export const TurnGraphChart = ({ serviceName, agentId, datalayerUrl, apiKey, aut
|
|
|
459
459
|
if (mountedRef.current)
|
|
460
460
|
setLoading(false);
|
|
461
461
|
}
|
|
462
|
-
}, [
|
|
462
|
+
}, [otelUrl, apiKey, serviceName, upsertRunsFromSpans]);
|
|
463
463
|
const { connected: wsConnected, error: wsError } = useOtelWebSocket({
|
|
464
|
-
baseUrl:
|
|
464
|
+
baseUrl: otelUrl,
|
|
465
465
|
token: apiKey,
|
|
466
466
|
callbacks: {
|
|
467
467
|
onTraces: spans => {
|
|
@@ -480,7 +480,7 @@ export const TurnGraphChart = ({ serviceName, agentId, datalayerUrl, apiKey, aut
|
|
|
480
480
|
const selectedRun = runs[selectedIdx];
|
|
481
481
|
const option = useMemo(() => (selectedRun ? buildOption(selectedRun) : null), [selectedRun]);
|
|
482
482
|
// Not configured — caller didn't pass auth.
|
|
483
|
-
if (!
|
|
483
|
+
if (!otelUrl || !apiKey)
|
|
484
484
|
return null;
|
|
485
485
|
if (loading && runs.length === 0) {
|
|
486
486
|
return (_jsx(Box, { sx: { color: 'fg.muted', fontSize: 1, py: 2 }, children: "Loading OTEL traces\u2026" }));
|
|
@@ -113,7 +113,7 @@ const AgentEvalsInner = ({ onLogout, executionTarget }) => {
|
|
|
113
113
|
? `local:${agentId}`
|
|
114
114
|
: runtime?.podName || '(launching…)';
|
|
115
115
|
const controlPlaneBaseUrl = import.meta.env.VITE_RUN_URL ||
|
|
116
|
-
configuration?.
|
|
116
|
+
configuration?.aiAgentsUrl ||
|
|
117
117
|
(cloudAgentBaseUrl ? new URL(cloudAgentBaseUrl).origin : '');
|
|
118
118
|
const isAgentReady = executionTarget === 'local' ? localStatus === 'ready' : isReady;
|
|
119
119
|
const agentStatus = executionTarget === 'local' ? localStatus : runtimeStatus;
|
|
@@ -41,7 +41,7 @@ const OTEL_BASE_URL_ENV = import.meta.env.VITE_OTEL_BASE_URL;
|
|
|
41
41
|
// Consume-side OTEL override (DATALAYER_OTEL_IN_URL). When set, telemetry is
|
|
42
42
|
// read from here instead of VITE_OTEL_BASE_URL (e.g. prod during local dev).
|
|
43
43
|
const OTEL_IN_BASE_URL_ENV = import.meta.env.VITE_OTEL_IN_BASE_URL;
|
|
44
|
-
const
|
|
44
|
+
const AI_AGENTS_URL_ENV = import.meta.env.VITE_DATALAYER_AI_AGENTS_URL;
|
|
45
45
|
const OTEL_SERVICE_NAME = 'agent-runtimes';
|
|
46
46
|
const COST_RUN_METRIC = 'agent_runtimes.capability.cost.run.usd';
|
|
47
47
|
const COST_CUMULATIVE_METRIC = 'agent_runtimes.capability.cost.cumulative.usd';
|
|
@@ -224,9 +224,9 @@ const AgentGuardrailsInner = ({ onLogout, }) => {
|
|
|
224
224
|
const otelBaseUrl = configuration?.otelInUrl ||
|
|
225
225
|
OTEL_IN_BASE_URL_ENV ||
|
|
226
226
|
configuration?.otelUrl ||
|
|
227
|
-
configuration?.
|
|
227
|
+
configuration?.aiAgentsUrl ||
|
|
228
228
|
OTEL_BASE_URL_ENV ||
|
|
229
|
-
|
|
229
|
+
AI_AGENTS_URL_ENV ||
|
|
230
230
|
agentBaseUrl;
|
|
231
231
|
const podName = agentId;
|
|
232
232
|
const chatAuthToken = token === null ? undefined : token;
|
|
@@ -57,7 +57,7 @@ const AgentInferenceProviderExampleInner = () => {
|
|
|
57
57
|
return 'local inference';
|
|
58
58
|
}
|
|
59
59
|
const env = import.meta.env ?? {};
|
|
60
|
-
return
|
|
60
|
+
return env.VITE_DATALAYER_AI_INFERENCE_URL || baseUrl;
|
|
61
61
|
}, [provider, baseUrl]);
|
|
62
62
|
const authFetch = useCallback((url, init = {}) => {
|
|
63
63
|
return fetch(url, {
|
|
@@ -41,7 +41,7 @@ const OTEL_BASE_URL_ENV = import.meta.env.VITE_OTEL_BASE_URL;
|
|
|
41
41
|
// Consume-side OTEL override (DATALAYER_OTEL_IN_URL). When set, telemetry is
|
|
42
42
|
// read from here instead of VITE_OTEL_BASE_URL (e.g. prod during local dev).
|
|
43
43
|
const OTEL_IN_BASE_URL_ENV = import.meta.env.VITE_OTEL_IN_BASE_URL;
|
|
44
|
-
const
|
|
44
|
+
const OTEL_URL_ENV = import.meta.env.VITE_DATALAYER_OTEL_URL;
|
|
45
45
|
const AgentMonitoringInner = ({ onLogout, }) => {
|
|
46
46
|
const { token } = useSimpleAuthStore();
|
|
47
47
|
const agentName = useRef(uniqueAgentId(AGENT_NAME)).current;
|
|
@@ -62,9 +62,9 @@ const AgentMonitoringInner = ({ onLogout, }) => {
|
|
|
62
62
|
const otelBaseUrl = configuration?.otelInUrl ||
|
|
63
63
|
OTEL_IN_BASE_URL_ENV ||
|
|
64
64
|
configuration?.otelUrl ||
|
|
65
|
-
configuration?.
|
|
65
|
+
configuration?.otelUrl ||
|
|
66
66
|
OTEL_BASE_URL_ENV ||
|
|
67
|
-
|
|
67
|
+
OTEL_URL_ENV ||
|
|
68
68
|
agentBaseUrl;
|
|
69
69
|
const podName = agentId;
|
|
70
70
|
// The OTEL service_name resource attribute is 'agent-runtimes' (the
|
|
@@ -324,11 +324,11 @@ const AgentMonitoringInner = ({ onLogout, }) => {
|
|
|
324
324
|
p: 3,
|
|
325
325
|
borderBottom: '1px solid',
|
|
326
326
|
borderColor: 'border.default',
|
|
327
|
-
}, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "Token Usage" }), _jsx(TokenUsageChart, { serviceName: otelServiceName, agentId: agentId, apiKey: token ?? undefined,
|
|
327
|
+
}, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "Token Usage" }), _jsx(TokenUsageChart, { serviceName: otelServiceName, agentId: agentId, apiKey: token ?? undefined, otelUrl: otelBaseUrl, liveSystemPromptTokens: liveContextSnapshot?.systemPromptTokens, liveUserMessageTokens: liveContextSnapshot?.userMessageTokens, liveAgentMessageTokens: liveContextSnapshot?.assistantMessageTokens, liveToolsUsageTokens: liveContextSnapshot?.toolTokens, liveTimestampMs: monitorLastSnapshotAt, height: 180 })] }), _jsxs(Box, { sx: {
|
|
328
328
|
p: 3,
|
|
329
329
|
borderBottom: '1px solid',
|
|
330
330
|
borderColor: 'border.default',
|
|
331
|
-
}, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "Cost" }), _jsx(CostUsageChart, { serviceName: otelServiceName, agentId: agentId, apiKey: token ?? undefined,
|
|
331
|
+
}, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "Cost" }), _jsx(CostUsageChart, { serviceName: otelServiceName, agentId: agentId, apiKey: token ?? undefined, otelUrl: otelBaseUrl, liveCumulativeUsd: liveCost?.cumulativeCostUsd, liveTimestampMs: monitorLastSnapshotAt, height: 180 })] }), _jsxs(Box, { sx: {
|
|
332
332
|
p: 3,
|
|
333
333
|
borderBottom: '1px solid',
|
|
334
334
|
borderColor: 'border.default',
|
|
@@ -405,7 +405,7 @@ const AgentMonitoringInner = ({ onLogout, }) => {
|
|
|
405
405
|
p: 3,
|
|
406
406
|
borderBottom: '1px solid',
|
|
407
407
|
borderColor: 'border.default',
|
|
408
|
-
}, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "Turn Execution Graph (OTEL traces)" }), _jsx(TurnGraphChart, { serviceName: otelServiceName, agentId: agentId,
|
|
408
|
+
}, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "Turn Execution Graph (OTEL traces)" }), _jsx(TurnGraphChart, { serviceName: otelServiceName, agentId: agentId, otelUrl: otelBaseUrl, apiKey: token ?? undefined, autoRefreshMs: 10_000, height: 280 })] })] })] })] }));
|
|
409
409
|
};
|
|
410
410
|
const syncTokenToIamStore = (token) => {
|
|
411
411
|
import('../state/substates').then(({ iamStore }) => {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* list and launched on demand.
|
|
9
9
|
*
|
|
10
10
|
* The OTEL backend is configured via `configuration.otelUrl` when available
|
|
11
|
-
* (falling back to `configuration.
|
|
12
|
-
* `
|
|
11
|
+
* (falling back to `configuration.otelUrl`, then `VITE_OTEL_BASE_URL`, then
|
|
12
|
+
* `VITE_DATALAYER_OTEL_URL`, then the resolved runtime base URL).
|
|
13
13
|
* Agent routes resolve from the shared local/cloud runtime target hook.
|
|
14
14
|
*
|
|
15
15
|
* For Python-side observability, wire in `agent_runtimes/otel.py`:
|
|
@@ -13,8 +13,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
13
13
|
* list and launched on demand.
|
|
14
14
|
*
|
|
15
15
|
* The OTEL backend is configured via `configuration.otelUrl` when available
|
|
16
|
-
* (falling back to `configuration.
|
|
17
|
-
* `
|
|
16
|
+
* (falling back to `configuration.otelUrl`, then `VITE_OTEL_BASE_URL`, then
|
|
17
|
+
* `VITE_DATALAYER_OTEL_URL`, then the resolved runtime base URL).
|
|
18
18
|
* Agent routes resolve from the shared local/cloud runtime target hook.
|
|
19
19
|
*
|
|
20
20
|
* For Python-side observability, wire in `agent_runtimes/otel.py`:
|
|
@@ -37,7 +37,7 @@ const OTEL_BASE_URL_ENV = import.meta.env.VITE_OTEL_BASE_URL ?? '';
|
|
|
37
37
|
// Consume-side OTEL override (DATALAYER_OTEL_IN_URL). When set, telemetry is
|
|
38
38
|
// read from here instead of VITE_OTEL_BASE_URL (e.g. prod during local dev).
|
|
39
39
|
const OTEL_IN_BASE_URL_ENV = import.meta.env.VITE_OTEL_IN_BASE_URL ?? '';
|
|
40
|
-
const
|
|
40
|
+
const OTEL_URL_ENV = import.meta.env.VITE_DATALAYER_OTEL_URL ?? '';
|
|
41
41
|
const DEFAULT_AGENT_PROTOCOL = 'vercel-ai';
|
|
42
42
|
const DEFAULT_AGENT_LIBRARY = 'pydantic-ai';
|
|
43
43
|
/** Spec id this example always launches. */
|
|
@@ -138,9 +138,9 @@ const AgentOtelExampleInner = ({ token }) => {
|
|
|
138
138
|
const resolvedUrl = configuration?.otelInUrl ||
|
|
139
139
|
OTEL_IN_BASE_URL_ENV ||
|
|
140
140
|
configuration?.otelUrl ||
|
|
141
|
-
configuration?.
|
|
141
|
+
configuration?.otelUrl ||
|
|
142
142
|
OTEL_BASE_URL_ENV ||
|
|
143
|
-
|
|
143
|
+
OTEL_URL_ENV ||
|
|
144
144
|
agentBaseUrl;
|
|
145
145
|
const otelBaseUrl = resolvedUrl;
|
|
146
146
|
// ── OTEL view state ─────────────────────────────────────────────
|
|
@@ -32,7 +32,7 @@ const NotebookCollaborationExample = (props) => {
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
// Create DatalayerServiceManager if we have credentials
|
|
35
|
-
if (configuration?.token && configuration?.
|
|
35
|
+
if (configuration?.token && configuration?.spacerUrl) {
|
|
36
36
|
try {
|
|
37
37
|
// Now we can pass undefined to use config/defaults
|
|
38
38
|
const manager = await createDatalayerServiceManager(configuration?.cpuEnvironment, configuration?.credits);
|
|
@@ -44,7 +44,7 @@ const NotebookCollaborationExample = (props) => {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
|
-
console.warn('Datalayer credentials not configured. Please set
|
|
47
|
+
console.warn('Datalayer credentials not configured. Please set spacerUrl and token.');
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
createManager();
|
|
@@ -54,20 +54,20 @@ const NotebookCollaborationExample = (props) => {
|
|
|
54
54
|
if (!enableCollaboration) {
|
|
55
55
|
return undefined;
|
|
56
56
|
}
|
|
57
|
-
const
|
|
57
|
+
const spacerUrl = configuration?.spacerUrl;
|
|
58
58
|
const token = configuration?.token;
|
|
59
|
-
if (!
|
|
60
|
-
console.warn('Datalayer collaboration enabled but
|
|
59
|
+
if (!spacerUrl || !token) {
|
|
60
|
+
console.warn('Datalayer collaboration enabled but spacerUrl or token not configured. ' +
|
|
61
61
|
'Please configure them in the Datalayer store or environment.');
|
|
62
62
|
return undefined;
|
|
63
63
|
}
|
|
64
64
|
// Create and return the Datalayer collaboration provider
|
|
65
65
|
return new DatalayerCollaborationProvider({
|
|
66
|
-
|
|
66
|
+
spacerUrl,
|
|
67
67
|
token,
|
|
68
68
|
});
|
|
69
69
|
}, [enableCollaboration, configuration]);
|
|
70
|
-
return (_jsx(ThemedJupyterProvider, { children: _jsxs(Box, { p: 3, children: [_jsx(Heading, { as: "h2", sx: { mb: 3 }, children: "Notebook Collaboration Example" }), _jsx(Box, { sx: { mb: 3 }, children: _jsxs(FormControl, { children: [_jsx(Checkbox, { checked: enableCollaboration, onChange: e => setEnableCollaboration(e.target.checked) }), _jsx(FormControl.Label, { children: "Enable Datalayer Collaboration" })] }) }), (!configuration?.
|
|
70
|
+
return (_jsx(ThemedJupyterProvider, { children: _jsxs(Box, { p: 3, children: [_jsx(Heading, { as: "h2", sx: { mb: 3 }, children: "Notebook Collaboration Example" }), _jsx(Box, { sx: { mb: 3 }, children: _jsxs(FormControl, { children: [_jsx(Checkbox, { checked: enableCollaboration, onChange: e => setEnableCollaboration(e.target.checked) }), _jsx(FormControl.Label, { children: "Enable Datalayer Collaboration" })] }) }), (!configuration?.spacerUrl || !configuration?.token) && (_jsx(Box, { sx: { mb: 2, p: 2, bg: 'danger.subtle' }, children: "Warning: Datalayer configuration is missing. Please configure spacerUrl and token to use DatalayerServiceManager and collaboration features." })), !serviceManager && (_jsx(Box, { sx: { mb: 2, p: 2, bg: 'attention.subtle' }, children: "Note: DatalayerServiceManager is not available. Notebook functionality will be limited." })), enableCollaboration ? (_jsxs(Box, { sx: {
|
|
71
71
|
display: 'flex',
|
|
72
72
|
gap: 2,
|
|
73
73
|
flexDirection: 'row',
|
|
@@ -97,6 +97,6 @@ const NotebookCollaborationExample = (props) => {
|
|
|
97
97
|
border: '1px solid',
|
|
98
98
|
borderColor: 'border.default',
|
|
99
99
|
borderRadius: 2,
|
|
100
|
-
}, children: serviceManager ? (_jsx(Notebook, { id: NOTEBOOK_ID, height: "calc(100vh - 200px)", nbformat: nbformat, readonly: readonly, serviceManager: serviceManager, startDefaultKernel: true, collaborationProvider: collaborationProvider })) : (_jsx(Box, { sx: { p: 4, textAlign: 'center' }, children: "Loading ServiceManager..." })) })), _jsxs(Box, { sx: { mt: 2, fontSize: 1, color: 'fg.subtle' }, children: [_jsx(Box, { as: "p", sx: { m: 0, mb: 2 }, children: "This example demonstrates how to use Datalayer services with Notebook:" }), _jsxs(Box, { as: "ul", sx: { m: 0, pl: 3, '& li': { mb: 1 } }, children: [_jsxs("li", { children: [_jsx("strong", { children: "DatalayerServiceManager:" }), " Connects to Datalayer infrastructure for kernel management"] }), _jsxs("li", { children: [_jsx("strong", { children: "DatalayerCollaborationProvider:" }), " Enables real-time collaboration"] }), _jsx("li", { children: "Both require Datalayer credentials (
|
|
100
|
+
}, children: serviceManager ? (_jsx(Notebook, { id: NOTEBOOK_ID, height: "calc(100vh - 200px)", nbformat: nbformat, readonly: readonly, serviceManager: serviceManager, startDefaultKernel: true, collaborationProvider: collaborationProvider })) : (_jsx(Box, { sx: { p: 4, textAlign: 'center' }, children: "Loading ServiceManager..." })) })), _jsxs(Box, { sx: { mt: 2, fontSize: 1, color: 'fg.subtle' }, children: [_jsx(Box, { as: "p", sx: { m: 0, mb: 2 }, children: "This example demonstrates how to use Datalayer services with Notebook:" }), _jsxs(Box, { as: "ul", sx: { m: 0, pl: 3, '& li': { mb: 1 } }, children: [_jsxs("li", { children: [_jsx("strong", { children: "DatalayerServiceManager:" }), " Connects to Datalayer infrastructure for kernel management"] }), _jsxs("li", { children: [_jsx("strong", { children: "DatalayerCollaborationProvider:" }), " Enables real-time collaboration"] }), _jsx("li", { children: "Both require Datalayer credentials (spacerUrl and token)" }), _jsx("li", { children: "Pass them directly to the base Notebook component" }), _jsx("li", { children: "No wrapper components needed - just create the services and pass them as props" }), _jsx("li", { children: "This shows the explicit, composable pattern for Datalayer integration" })] })] })] }) }));
|
|
101
101
|
};
|
|
102
102
|
export default NotebookCollaborationExample;
|
package/lib/examples/main.js
CHANGED
|
@@ -114,7 +114,7 @@ const withTokenQueryParam = (rawUrl, token) => {
|
|
|
114
114
|
};
|
|
115
115
|
const resolveRuntimesUrl = (configured) => {
|
|
116
116
|
const envRuntimeUrl = import.meta.env.VITE_DATALAYER_RUNTIMES_URL;
|
|
117
|
-
const envBaseUrl = import.meta.env.
|
|
117
|
+
const envBaseUrl = import.meta.env.VITE_DATALAYER_IAM_URL;
|
|
118
118
|
const candidate = configured || envRuntimeUrl || envBaseUrl;
|
|
119
119
|
if (!candidate) {
|
|
120
120
|
return DEFAULT_RUNTIMES_URL;
|
|
@@ -193,7 +193,7 @@ const loadConfigurations = () => {
|
|
|
193
193
|
datalayerConfig.token = envToken;
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
if (datalayerConfig.
|
|
196
|
+
if (datalayerConfig.iamUrl) {
|
|
197
197
|
datalayerConfig.runtimesUrl = resolveRuntimesUrl(datalayerConfig.runtimesUrl);
|
|
198
198
|
coreStore.getState().setConfiguration(datalayerConfig);
|
|
199
199
|
// Also set the token in the IAM store for API authentication
|
|
@@ -466,12 +466,12 @@ const NotebookOnlyApp = () => {
|
|
|
466
466
|
const initializeApp = async () => {
|
|
467
467
|
try {
|
|
468
468
|
const { configuration } = coreStore.getState();
|
|
469
|
-
// Always try to create collaboration provider if we have token and
|
|
470
|
-
if (configuration?.token && configuration?.
|
|
469
|
+
// Always try to create collaboration provider if we have token and spacerUrl
|
|
470
|
+
if (configuration?.token && configuration?.spacerUrl) {
|
|
471
471
|
try {
|
|
472
472
|
const { DatalayerCollaborationProvider } = await import('../collaboration/DatalayerCollaborationProvider');
|
|
473
473
|
const provider = new DatalayerCollaborationProvider({
|
|
474
|
-
|
|
474
|
+
spacerUrl: configuration.spacerUrl,
|
|
475
475
|
token: configuration.token,
|
|
476
476
|
});
|
|
477
477
|
setCollaborationProvider(provider);
|
|
@@ -31,7 +31,7 @@ const DatalayerNotebookExample = (props) => {
|
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
33
|
// Create DatalayerServiceManager if we have credentials
|
|
34
|
-
if (configuration?.token && configuration?.
|
|
34
|
+
if (configuration?.token && configuration?.spacerUrl) {
|
|
35
35
|
try {
|
|
36
36
|
// Now we can pass undefined to use config/defaults
|
|
37
37
|
const manager = await createDatalayerServiceManager(configuration?.cpuEnvironment, configuration?.credits);
|
|
@@ -43,7 +43,7 @@ const DatalayerNotebookExample = (props) => {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
|
-
console.warn('Datalayer credentials not configured. Please set
|
|
46
|
+
console.warn('Datalayer credentials not configured. Please set spacerUrl and token.');
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
createManager();
|
|
@@ -53,20 +53,20 @@ const DatalayerNotebookExample = (props) => {
|
|
|
53
53
|
if (!enableCollaboration) {
|
|
54
54
|
return undefined;
|
|
55
55
|
}
|
|
56
|
-
const
|
|
56
|
+
const spacerUrl = configuration?.spacerUrl;
|
|
57
57
|
const token = configuration?.token;
|
|
58
|
-
if (!
|
|
59
|
-
console.warn('Datalayer collaboration enabled but
|
|
58
|
+
if (!spacerUrl || !token) {
|
|
59
|
+
console.warn('Datalayer collaboration enabled but spacerUrl or token not configured. ' +
|
|
60
60
|
'Please configure them in the Datalayer store or environment.');
|
|
61
61
|
return undefined;
|
|
62
62
|
}
|
|
63
63
|
// Create and return the Datalayer collaboration provider
|
|
64
64
|
return new DatalayerCollaborationProvider({
|
|
65
|
-
|
|
65
|
+
spacerUrl,
|
|
66
66
|
token,
|
|
67
67
|
});
|
|
68
68
|
}, [enableCollaboration, configuration]);
|
|
69
|
-
return (_jsx(JupyterReactTheme, { children: _jsxs(Box, { p: 3, children: [_jsx(Heading, { as: "h2", sx: { mb: 3 }, children: "Datalayer Notebook Collaboration Example" }), _jsx(Box, { sx: { mb: 3 }, children: _jsxs(FormControl, { children: [_jsx(Checkbox, { checked: enableCollaboration, onChange: e => setEnableCollaboration(e.target.checked) }), _jsx(FormControl.Label, { children: "Enable Datalayer Collaboration" })] }) }), (!configuration?.
|
|
69
|
+
return (_jsx(JupyterReactTheme, { children: _jsxs(Box, { p: 3, children: [_jsx(Heading, { as: "h2", sx: { mb: 3 }, children: "Datalayer Notebook Collaboration Example" }), _jsx(Box, { sx: { mb: 3 }, children: _jsxs(FormControl, { children: [_jsx(Checkbox, { checked: enableCollaboration, onChange: e => setEnableCollaboration(e.target.checked) }), _jsx(FormControl.Label, { children: "Enable Datalayer Collaboration" })] }) }), (!configuration?.spacerUrl || !configuration?.token) && (_jsx(Box, { sx: { mb: 2, p: 2, bg: 'danger.subtle' }, children: "Warning: Datalayer configuration is missing. Please configure spacerUrl and token to use DatalayerServiceManager and collaboration features." })), !serviceManager && (_jsx(Box, { sx: { mb: 2, p: 2, bg: 'attention.subtle' }, children: "Note: DatalayerServiceManager is not available. Notebook functionality will be limited." })), enableCollaboration ? (_jsxs(Box, { sx: {
|
|
70
70
|
display: 'flex',
|
|
71
71
|
gap: 2,
|
|
72
72
|
flexDirection: 'row',
|
|
@@ -104,6 +104,6 @@ const DatalayerNotebookExample = (props) => {
|
|
|
104
104
|
border: '1px solid',
|
|
105
105
|
borderColor: 'border.default',
|
|
106
106
|
borderRadius: 2,
|
|
107
|
-
}, children: serviceManager ? (_jsx(Notebook, { id: NOTEBOOK_ID, height: "calc(100vh - 200px)", nbformat: nbformat, readonly: readonly, serviceManager: serviceManager, startDefaultKernel: true, collaborationProvider: collaborationProvider })) : (_jsx(Box, { sx: { p: 4, textAlign: 'center' }, children: "Loading ServiceManager..." })) })), _jsxs(Box, { sx: { mt: 2, fontSize: 1, color: 'fg.subtle' }, children: [_jsx("p", { children: "This example demonstrates how to use Datalayer services with Notebook:" }), _jsxs("ul", { children: [_jsxs("li", { children: [_jsx("strong", { children: "DatalayerServiceManager:" }), " Connects to Datalayer infrastructure for kernel management"] }), _jsxs("li", { children: [_jsx("strong", { children: "DatalayerCollaborationProvider:" }), " Enables real-time collaboration"] }), _jsx("li", { children: "Both require Datalayer credentials (
|
|
107
|
+
}, children: serviceManager ? (_jsx(Notebook, { id: NOTEBOOK_ID, height: "calc(100vh - 200px)", nbformat: nbformat, readonly: readonly, serviceManager: serviceManager, startDefaultKernel: true, collaborationProvider: collaborationProvider })) : (_jsx(Box, { sx: { p: 4, textAlign: 'center' }, children: "Loading ServiceManager..." })) })), _jsxs(Box, { sx: { mt: 2, fontSize: 1, color: 'fg.subtle' }, children: [_jsx("p", { children: "This example demonstrates how to use Datalayer services with Notebook:" }), _jsxs("ul", { children: [_jsxs("li", { children: [_jsx("strong", { children: "DatalayerServiceManager:" }), " Connects to Datalayer infrastructure for kernel management"] }), _jsxs("li", { children: [_jsx("strong", { children: "DatalayerCollaborationProvider:" }), " Enables real-time collaboration"] }), _jsx("li", { children: "Both require Datalayer credentials (spacerUrl and token)" }), _jsx("li", { children: "Pass them directly to the base Notebook component" }), _jsx("li", { children: "No wrapper components needed - just create the services and pass them as props" }), _jsx("li", { children: "This shows the explicit, composable pattern for Datalayer integration" })] })] })] }) }));
|
|
108
108
|
};
|
|
109
109
|
export default DatalayerNotebookExample;
|
package/lib/examples2/main.js
CHANGED
|
@@ -19,7 +19,7 @@ const DEFAULT_LOCAL_JUPYTER_SERVER_URL = 'http://0.0.0.0:8888/api/jupyter-server
|
|
|
19
19
|
const DEFAULT_LOCAL_JUPYTER_SERVER_TOKEN = '60c1661cc408f978c309d04157af55c9588ff9557c9380e4fb50785750703da6';
|
|
20
20
|
const resolveRuntimesUrl = (configured) => {
|
|
21
21
|
const envRuntimeUrl = import.meta.env.VITE_DATALAYER_RUNTIMES_URL;
|
|
22
|
-
const envBaseUrl = import.meta.env.
|
|
22
|
+
const envBaseUrl = import.meta.env.VITE_DATALAYER_IAM_URL;
|
|
23
23
|
const candidate = configured || envRuntimeUrl || envBaseUrl;
|
|
24
24
|
if (!candidate) {
|
|
25
25
|
return DEFAULT_RUNTIMES_URL;
|
|
@@ -72,7 +72,7 @@ const loadConfigurations = () => {
|
|
|
72
72
|
datalayerConfig.token = envToken;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
if (datalayerConfig.
|
|
75
|
+
if (datalayerConfig.iamUrl) {
|
|
76
76
|
datalayerConfig.runtimesUrl = resolveRuntimesUrl(datalayerConfig.runtimesUrl);
|
|
77
77
|
coreStore.getState().setConfiguration(datalayerConfig);
|
|
78
78
|
// Also set the token in the IAM store for API authentication
|
|
@@ -154,12 +154,12 @@ const NotebookOnlyApp = () => {
|
|
|
154
154
|
const initializeApp = async () => {
|
|
155
155
|
try {
|
|
156
156
|
const { configuration } = coreStore.getState();
|
|
157
|
-
// Always try to create collaboration provider if we have token and
|
|
158
|
-
if (configuration?.token && configuration?.
|
|
157
|
+
// Always try to create collaboration provider if we have token and spacerUrl
|
|
158
|
+
if (configuration?.token && configuration?.spacerUrl) {
|
|
159
159
|
try {
|
|
160
160
|
const { DatalayerCollaborationProvider } = await import('../collaboration/DatalayerCollaborationProvider');
|
|
161
161
|
const provider = new DatalayerCollaborationProvider({
|
|
162
|
-
|
|
162
|
+
spacerUrl: configuration.spacerUrl,
|
|
163
163
|
token: configuration.token,
|
|
164
164
|
});
|
|
165
165
|
console.warn('[NotebookOnlyApp] Created collaboration provider:', provider);
|
|
@@ -395,12 +395,12 @@ export function useAgentRuntimes(options = {}) {
|
|
|
395
395
|
const { iamStore, coreStore } = await import('@datalayer/core/lib/state');
|
|
396
396
|
const token = iamStore.getState().token || '';
|
|
397
397
|
const config = coreStore.getState().configuration;
|
|
398
|
-
const
|
|
398
|
+
const aiAgentsUrl = config?.aiAgentsUrl || '';
|
|
399
399
|
const runtimesUrl = resolvedRuntimeCreationBaseUrl;
|
|
400
|
-
return { token,
|
|
400
|
+
return { token, aiAgentsUrl, runtimesUrl };
|
|
401
401
|
}
|
|
402
402
|
catch {
|
|
403
|
-
return { token: '',
|
|
403
|
+
return { token: '', aiAgentsUrl: '', runtimesUrl: '' };
|
|
404
404
|
}
|
|
405
405
|
}, [resolvedRuntimeCreationBaseUrl]);
|
|
406
406
|
// ─── Launch Runtime ─────────────────────────────────────────────────
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface OtelQueryOptions {
|
|
2
2
|
metric: string;
|
|
3
3
|
serviceName?: string;
|
|
4
|
-
|
|
4
|
+
otelUrl?: string;
|
|
5
5
|
apiKey?: string;
|
|
6
6
|
limit?: number;
|
|
7
7
|
accountUid?: string;
|
|
@@ -12,15 +12,15 @@ interface MetricValueRow {
|
|
|
12
12
|
value_int?: unknown;
|
|
13
13
|
}
|
|
14
14
|
export declare function toMetricValue(row: MetricValueRow): number;
|
|
15
|
-
export declare function fetchOtelMetricRows({ metric, serviceName,
|
|
15
|
+
export declare function fetchOtelMetricRows({ metric, serviceName, otelUrl, apiKey, limit, accountUid, }: OtelQueryOptions): Promise<MetricValueRow[]>;
|
|
16
16
|
export declare function fetchOtelMetricTotal(options: OtelQueryOptions): Promise<number>;
|
|
17
17
|
export interface OtelTotalTokensOptions {
|
|
18
18
|
serviceName?: string;
|
|
19
|
-
|
|
19
|
+
otelUrl?: string;
|
|
20
20
|
apiKey?: string;
|
|
21
21
|
limit?: number;
|
|
22
22
|
accountUid?: string;
|
|
23
23
|
}
|
|
24
|
-
export declare function fetchOtelTotalTokens({ serviceName,
|
|
25
|
-
export declare function useOtelTotalTokens({ serviceName,
|
|
24
|
+
export declare function fetchOtelTotalTokens({ serviceName, otelUrl, apiKey, limit, accountUid, }: OtelTotalTokensOptions): Promise<number>;
|
|
25
|
+
export declare function useOtelTotalTokens({ serviceName, otelUrl, apiKey, limit, accountUid, }: OtelTotalTokensOptions): string;
|
|
26
26
|
export {};
|
|
@@ -24,12 +24,12 @@ export function toMetricValue(row) {
|
|
|
24
24
|
}
|
|
25
25
|
return 0;
|
|
26
26
|
}
|
|
27
|
-
export async function fetchOtelMetricRows({ metric, serviceName,
|
|
28
|
-
if (!
|
|
27
|
+
export async function fetchOtelMetricRows({ metric, serviceName, otelUrl, apiKey, limit = 500, accountUid, }) {
|
|
28
|
+
if (!otelUrl || !apiKey) {
|
|
29
29
|
return [];
|
|
30
30
|
}
|
|
31
31
|
const client = createOtelClient({
|
|
32
|
-
baseUrl:
|
|
32
|
+
baseUrl: otelUrl,
|
|
33
33
|
token: apiKey,
|
|
34
34
|
});
|
|
35
35
|
const filtered = await client.fetchMetrics({
|
|
@@ -52,11 +52,11 @@ export async function fetchOtelMetricTotal(options) {
|
|
|
52
52
|
const rows = await fetchOtelMetricRows(options);
|
|
53
53
|
return rows.reduce((sum, row) => sum + toMetricValue(row), 0);
|
|
54
54
|
}
|
|
55
|
-
export async function fetchOtelTotalTokens({ serviceName,
|
|
55
|
+
export async function fetchOtelTotalTokens({ serviceName, otelUrl, apiKey, limit = 500, accountUid, }) {
|
|
56
56
|
const total = await fetchOtelMetricTotal({
|
|
57
57
|
metric: 'agent_runtimes.prompt.turn.total_tokens',
|
|
58
58
|
serviceName,
|
|
59
|
-
|
|
59
|
+
otelUrl,
|
|
60
60
|
apiKey,
|
|
61
61
|
limit,
|
|
62
62
|
accountUid,
|
|
@@ -67,7 +67,7 @@ export async function fetchOtelTotalTokens({ serviceName, datalayerUrl, apiKey,
|
|
|
67
67
|
const prompt = await fetchOtelMetricTotal({
|
|
68
68
|
metric: 'agent_runtimes.prompt.turn.prompt_tokens',
|
|
69
69
|
serviceName,
|
|
70
|
-
|
|
70
|
+
otelUrl,
|
|
71
71
|
apiKey,
|
|
72
72
|
limit,
|
|
73
73
|
accountUid,
|
|
@@ -75,14 +75,14 @@ export async function fetchOtelTotalTokens({ serviceName, datalayerUrl, apiKey,
|
|
|
75
75
|
const completion = await fetchOtelMetricTotal({
|
|
76
76
|
metric: 'agent_runtimes.prompt.turn.completion_tokens',
|
|
77
77
|
serviceName,
|
|
78
|
-
|
|
78
|
+
otelUrl,
|
|
79
79
|
apiKey,
|
|
80
80
|
limit,
|
|
81
81
|
accountUid,
|
|
82
82
|
});
|
|
83
83
|
return prompt + completion;
|
|
84
84
|
}
|
|
85
|
-
export function useOtelTotalTokens({ serviceName,
|
|
85
|
+
export function useOtelTotalTokens({ serviceName, otelUrl, apiKey, limit = 500, accountUid, }) {
|
|
86
86
|
const [tokensLabel, setTokensLabel] = useState('-');
|
|
87
87
|
useEffect(() => {
|
|
88
88
|
let cancelled = false;
|
|
@@ -90,7 +90,7 @@ export function useOtelTotalTokens({ serviceName, datalayerUrl, apiKey, limit =
|
|
|
90
90
|
try {
|
|
91
91
|
const total = await fetchOtelTotalTokens({
|
|
92
92
|
serviceName,
|
|
93
|
-
|
|
93
|
+
otelUrl,
|
|
94
94
|
apiKey,
|
|
95
95
|
limit,
|
|
96
96
|
accountUid,
|
|
@@ -115,6 +115,6 @@ export function useOtelTotalTokens({ serviceName, datalayerUrl, apiKey, limit =
|
|
|
115
115
|
return () => {
|
|
116
116
|
cancelled = true;
|
|
117
117
|
};
|
|
118
|
-
}, [apiKey, limit,
|
|
118
|
+
}, [apiKey, limit, otelUrl, serviceName, accountUid]);
|
|
119
119
|
return tokensLabel;
|
|
120
120
|
}
|
|
@@ -539,6 +539,8 @@ export class AGUIAdapter extends BaseProtocolAdapter {
|
|
|
539
539
|
toolCallId,
|
|
540
540
|
toolName,
|
|
541
541
|
args: {},
|
|
542
|
+
// TOOL_CALL_START: the args stream in afterwards.
|
|
543
|
+
argsComplete: false,
|
|
542
544
|
},
|
|
543
545
|
timestamp: new Date(),
|
|
544
546
|
});
|
|
@@ -582,6 +584,8 @@ export class AGUIAdapter extends BaseProtocolAdapter {
|
|
|
582
584
|
toolCallId: pending.toolCallId,
|
|
583
585
|
toolName: pending.toolName,
|
|
584
586
|
args: parsedArgs,
|
|
587
|
+
// TOOL_CALL_END: this is the full argument set.
|
|
588
|
+
argsComplete: true,
|
|
585
589
|
},
|
|
586
590
|
timestamp: new Date(),
|
|
587
591
|
});
|
|
@@ -485,6 +485,9 @@ export class VercelAIAdapter extends BaseProtocolAdapter {
|
|
|
485
485
|
toolCallId,
|
|
486
486
|
toolName,
|
|
487
487
|
args,
|
|
488
|
+
// `tool-input-available` carries the final input:
|
|
489
|
+
// empty args are an answer, not a promise of more.
|
|
490
|
+
argsComplete: true,
|
|
488
491
|
},
|
|
489
492
|
timestamp: new Date(),
|
|
490
493
|
});
|