@datalayer/agent-runtimes 1.0.20 → 1.0.25
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/code-sandboxes/CodeSandboxLauncher.d.ts +59 -0
- package/lib/components/code-sandboxes/CodeSandboxLauncher.js +272 -0
- package/lib/components/code-sandboxes/CodeSandboxPicker.d.ts +71 -0
- package/lib/components/code-sandboxes/CodeSandboxPicker.js +163 -0
- 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 +3 -0
- package/lib/components/code-sandboxes/index.js +7 -0
- package/lib/components/progress/CreditsIndicator.d.ts +7 -0
- package/lib/components/progress/CreditsIndicator.js +2 -2
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +5 -55
- package/lib/components/runtimes/RuntimeLauncherDialog.js +5 -269
- package/lib/components/runtimes/RuntimePickerBase.d.ts +6 -67
- package/lib/components/runtimes/RuntimePickerBase.js +6 -151
- package/lib/components/runtimes/RuntimePickerCell.d.ts +2 -2
- package/lib/components/runtimes/RuntimePickerCell.js +4 -4
- package/lib/components/runtimes/RuntimePickerNotebook.js +35 -70
- package/lib/components/runtimes/RuntimeReservationControl.js +8 -1
- package/lib/components/runtimes/RuntimeSimplePicker.js +1 -1
- package/lib/components/runtimes/RuntimeUtils.js +34 -18
- package/lib/components/runtimes/index.d.ts +1 -0
- package/lib/components/runtimes/index.js +2 -0
- 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 +3 -3
- package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
- 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
|
@@ -4,24 +4,22 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
6
|
import { useCallback, useEffect, useState } from 'react';
|
|
7
|
-
import { ActionList
|
|
7
|
+
import { ActionList } from '@primer/react';
|
|
8
8
|
import { Box } from '@datalayer/primer-addons';
|
|
9
|
-
import { AlertIcon } from '@primer/octicons-react';
|
|
10
9
|
import { JSONExt } from '@lumino/coreutils';
|
|
11
10
|
import { KernelExecutor } from '@datalayer/jupyter-react';
|
|
12
11
|
import { RuntimeSnippetsFacade } from '../../jupyter';
|
|
13
12
|
import { ExternalTokenSilentLogin } from '@datalayer/core/lib/components/iam';
|
|
14
|
-
import {
|
|
15
|
-
import { RuntimeReservationControl, MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES, } from './RuntimeReservationControl';
|
|
13
|
+
import { useIAMStore } from '../../state/substates';
|
|
16
14
|
import { RuntimeVariables } from './RuntimeVariables';
|
|
17
|
-
import {
|
|
15
|
+
import { CodeSandboxPicker } from '../code-sandboxes/CodeSandboxPicker';
|
|
16
|
+
import { creditsLimitFor, NewCodeSandboxControls, useNewCodeSandboxAllowance, } from '../code-sandboxes/NewCodeSandboxControls';
|
|
18
17
|
/**
|
|
19
18
|
* Runtime Picker components for a Notebook.
|
|
20
19
|
*/
|
|
21
20
|
export function RuntimePickerNotebook(props) {
|
|
22
21
|
const { multiServiceManager, sessionContext, setValue, translator } = props;
|
|
23
|
-
const {
|
|
24
|
-
const { credits, refreshCredits, token, user } = useIAMStore();
|
|
22
|
+
const { refreshCredits, token } = useIAMStore();
|
|
25
23
|
const [selectedRuntimeDesc, setSelectedRuntimeDesc] = useState();
|
|
26
24
|
const [timeLimit, setTimeLimit] = useState(10);
|
|
27
25
|
const [userStorage, setUserStorage] = useState(false);
|
|
@@ -107,36 +105,22 @@ export function RuntimePickerNotebook(props) {
|
|
|
107
105
|
setTransferTo(RuntimeSnippetsFacade.supports(runtimeDesc.language));
|
|
108
106
|
}
|
|
109
107
|
}, [selectedRuntimeDesc]);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
// The burning rate of the choice, and what the account allows for it —
|
|
109
|
+
// the same one copy of the arithmetic the launcher uses.
|
|
110
|
+
const resolvedBurningRate = selectedRuntimeDesc?.burningRate ??
|
|
111
|
+
multiServiceManager.remote?.environments
|
|
112
|
+
.get()
|
|
113
|
+
.find(env => env.name === selectedRuntimeDesc?.name)?.burning_rate;
|
|
114
|
+
const allowance = useNewCodeSandboxAllowance(resolvedBurningRate);
|
|
114
115
|
useEffect(() => {
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
.get()
|
|
118
|
-
.find(env => env.name === selectedRuntimeDesc?.name)?.burning_rate;
|
|
119
|
-
const includedRuns = user?.subscription?.usage?.included_runs ??
|
|
120
|
-
user?.subscription?.included_runs;
|
|
121
|
-
const currentRuns = user?.subscription?.usage?.current_runs ??
|
|
122
|
-
user?.subscription?.current_runs ??
|
|
123
|
-
user?.subscription?.used_runs;
|
|
124
|
-
const hasKnownRunAllowance = typeof includedRuns === 'number';
|
|
125
|
-
const hasRemainingRuns = hasKnownRunAllowance &&
|
|
126
|
-
typeof currentRuns === 'number' &&
|
|
127
|
-
includedRuns > 0 &&
|
|
128
|
-
currentRuns < includedRuns;
|
|
129
|
-
const hasKnownCredits = typeof credits?.available === 'number';
|
|
130
|
-
const maxMinutes = selectedRuntimeDesc?.location === 'remote' && resolvedBurningRate
|
|
131
|
-
? Math.floor((credits?.available ?? 0) / resolvedBurningRate / 60.0)
|
|
116
|
+
const maxMinutes = selectedRuntimeDesc?.location === 'remote'
|
|
117
|
+
? allowance.maxFromCredits
|
|
132
118
|
: undefined;
|
|
133
119
|
const effectiveTimeLimit = selectedRuntimeDesc?.location === 'remote'
|
|
134
120
|
? Math.max(1, Math.min(timeLimit, maxMinutes && maxMinutes > 0 ? maxMinutes : 10))
|
|
135
121
|
: timeLimit;
|
|
136
122
|
const creditsLimit = selectedRuntimeDesc?.location === 'remote' && resolvedBurningRate
|
|
137
|
-
?
|
|
138
|
-
resolvedBurningRate *
|
|
139
|
-
60
|
|
123
|
+
? creditsLimitFor(effectiveTimeLimit, resolvedBurningRate)
|
|
140
124
|
: undefined;
|
|
141
125
|
const requiresRuntimeStart = !!selectedRuntimeDesc && !selectedRuntimeDesc.kernelId;
|
|
142
126
|
if (requiresRuntimeStart && selectedRuntimeDesc.location === 'remote') {
|
|
@@ -144,9 +128,9 @@ export function RuntimePickerNotebook(props) {
|
|
|
144
128
|
setValue({ runtime: null, selectedVariables: toTransfer });
|
|
145
129
|
return;
|
|
146
130
|
}
|
|
147
|
-
if (hasKnownCredits &&
|
|
148
|
-
hasKnownRunAllowance &&
|
|
149
|
-
!hasRemainingRuns &&
|
|
131
|
+
if (allowance.hasKnownCredits &&
|
|
132
|
+
allowance.hasKnownRunAllowance &&
|
|
133
|
+
!allowance.hasRemainingRuns &&
|
|
150
134
|
(!creditsLimit || creditsLimit <= 0)) {
|
|
151
135
|
setValue({ runtime: null, selectedVariables: toTransfer });
|
|
152
136
|
return;
|
|
@@ -171,38 +155,18 @@ export function RuntimePickerNotebook(props) {
|
|
|
171
155
|
toTransfer,
|
|
172
156
|
timeLimit,
|
|
173
157
|
multiServiceManager.remote,
|
|
174
|
-
|
|
175
|
-
|
|
158
|
+
resolvedBurningRate,
|
|
159
|
+
allowance,
|
|
176
160
|
]);
|
|
177
161
|
const { kernelPreference: { canStart }, } = sessionContext;
|
|
178
|
-
const resolvedBurningRate = selectedRuntimeDesc?.burningRate ??
|
|
179
|
-
multiServiceManager.remote?.environments
|
|
180
|
-
.get()
|
|
181
|
-
.find(env => env.name === selectedRuntimeDesc?.name)?.burning_rate;
|
|
182
|
-
const maxFromCredits = resolvedBurningRate
|
|
183
|
-
? Math.floor((credits?.available ?? 0) / resolvedBurningRate / 60.0)
|
|
184
|
-
: -1;
|
|
185
|
-
const includedRuns = user?.subscription?.usage?.included_runs ??
|
|
186
|
-
user?.subscription?.included_runs;
|
|
187
|
-
const currentRuns = user?.subscription?.usage?.current_runs ??
|
|
188
|
-
user?.subscription?.current_runs ??
|
|
189
|
-
user?.subscription?.used_runs;
|
|
190
|
-
const hasKnownRunAllowance = typeof includedRuns === 'number';
|
|
191
|
-
const hasRemainingRuns = hasKnownRunAllowance &&
|
|
192
|
-
typeof currentRuns === 'number' &&
|
|
193
|
-
includedRuns > 0 &&
|
|
194
|
-
currentRuns < includedRuns;
|
|
195
|
-
const hasKnownCredits = typeof credits?.available === 'number';
|
|
196
162
|
const effectiveMaxMinutes = selectedRuntimeDesc?.location === 'remote'
|
|
197
|
-
?
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
maxFromCredits < Number.EPSILON;
|
|
205
|
-
return (_jsxs(Box, { as: "form", className: "dla-Runtimes-picker", children: [_jsx(Box, { sx: { padding: 'var(--stack-padding-condensed) 0' }, children: _jsx(RuntimePickerBase, { display: "radio", disabled: canStart === false, preference: {
|
|
163
|
+
? allowance.effectiveMaxMinutes
|
|
164
|
+
: Math.max(1, allowance.maxFromCredits ?? -1);
|
|
165
|
+
const outOfCredits = allowance.hasKnownCredits &&
|
|
166
|
+
allowance.hasKnownRunAllowance &&
|
|
167
|
+
!allowance.hasRemainingRuns &&
|
|
168
|
+
(allowance.maxFromCredits ?? -1) < Number.EPSILON;
|
|
169
|
+
return (_jsxs(Box, { as: "form", className: "dla-Runtimes-picker", children: [_jsx(Box, { sx: { padding: 'var(--stack-padding-condensed) 0' }, children: _jsx(CodeSandboxPicker, { display: "radio", disabled: canStart === false, preference: {
|
|
206
170
|
id: sessionContext.session?.id,
|
|
207
171
|
kernelDisplayName: sessionContext.kernelPreference.shouldStart
|
|
208
172
|
? sessionContext.kernelDisplayName
|
|
@@ -221,12 +185,13 @@ export function RuntimePickerNotebook(props) {
|
|
|
221
185
|
</Button>
|
|
222
186
|
*/
|
|
223
187
|
_jsx(_Fragment, {})) : (_jsx(ActionList.Item, { onSelect: props.logIn, title: 'Runtime Provider.', children: _jsx(ExternalTokenSilentLogin, { message: "Click to sign in." }) })) }) }), !selectedRuntimeDesc?.kernelId &&
|
|
224
|
-
selectedRuntimeDesc?.location === 'remote' && (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
188
|
+
selectedRuntimeDesc?.location === 'remote' && (
|
|
189
|
+
// The user asked for a NEW sandbox: the questions are the
|
|
190
|
+
// launcher's, asked through the launcher's own controls.
|
|
191
|
+
_jsx(NewCodeSandboxControls, { burningRate: selectedRuntimeDesc.burningRate, timeLimit: timeLimit, onTimeChange: setTimeLimit, max: effectiveMaxMinutes, disabled: outOfCredits, error: outOfCredits && (allowance.maxFromCredits ?? -1) >= 0
|
|
192
|
+
? 'You must add credits to your account.'
|
|
193
|
+
: timeLimit === 0
|
|
194
|
+
? 'You must set a time limit.'
|
|
195
|
+
: undefined, userStorage: userStorage, onUserStorageToggle: () => setUserStorage(current => !current) })), canTransferFrom && canTransferTo && (_jsx(RuntimeVariables, { selectedVariables: toTransfer, setSelectVariable: setSelectedVariables, transferVariables: transferVariables, setTransferVariable: setTransferVariable, kernelVariables: kernelVariables, translator: translator }))] }));
|
|
231
196
|
}
|
|
232
197
|
export default RuntimePickerNotebook;
|
|
@@ -18,7 +18,14 @@ export const MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES = 24 * 60;
|
|
|
18
18
|
*/
|
|
19
19
|
export function RuntimeReservationControl(props) {
|
|
20
20
|
const { addCredits, burningRate, disabled, error, label, max: maxProps, onTimeChange, time, } = props;
|
|
21
|
-
|
|
21
|
+
// The caller computes its maximum from the credits and the burning rate of
|
|
22
|
+
// an environment, either of which may not be known yet — and a slider given
|
|
23
|
+
// `NaN` renders nothing but warnings. Fall back to what a reservation may
|
|
24
|
+
// hold in any case.
|
|
25
|
+
const requestedMax = Number.isFinite(maxProps)
|
|
26
|
+
? maxProps
|
|
27
|
+
: MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES;
|
|
28
|
+
const max = Math.max(1, Math.min(requestedMax, MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES));
|
|
22
29
|
const displayedTime = Number.isFinite(time)
|
|
23
30
|
? Math.min(max, Math.max(1, time))
|
|
24
31
|
: 1;
|
|
@@ -146,7 +146,7 @@ export function RuntimeSimplePicker(props) {
|
|
|
146
146
|
});
|
|
147
147
|
}, children: [_jsx(ActionList.LeadingVisual, { children: _jsx(ArtifactIcon, { type: "runtime" }) }), kernelModel.given_name, _jsx(ActionList.Description, { variant: "block", children: kernelModel.environment.title ||
|
|
148
148
|
kernelModel.environment.name })] }, kernelModel.id));
|
|
149
|
-
})] })), _jsx(ActionList.Divider, {}), _jsxs(ActionList.Group, { children: [_jsxs(ActionList.Item, { selected: false, onSelect: handleLaunchRemoteKernel, children: [_jsx(ActionList.LeadingVisual, { children: _jsx(PlusIcon, {}) }), "Launch a new
|
|
149
|
+
})] })), _jsx(ActionList.Divider, {}), _jsxs(ActionList.Group, { children: [_jsxs(ActionList.Item, { selected: false, onSelect: handleLaunchRemoteKernel, children: [_jsx(ActionList.LeadingVisual, { children: _jsx(PlusIcon, {}) }), "Launch a new Code Sandbox\u2026"] }), _jsxs(ActionList.Item, { disabled: runtimeLocation !== 'browser', selected: false, onSelect: () => {
|
|
150
150
|
setDialogCause(RuntimeDialogCause.Transfer);
|
|
151
151
|
}, title: "Transfer the state of the current Runtime to a new Remote Runtime.", children: [_jsx(ActionList.LeadingVisual, { children: _jsx(UnfoldIcon, {}) }), "Transfer state to a new Runtime\u2026"] })] })] }) })] }), multiServiceManager?.remote && dialogCause > 0 && (_jsx(RuntimeLauncherDialog, { dialogTitle: dialogCause === RuntimeDialogCause.Transfer
|
|
152
152
|
? 'Switch to a new Cloud Runtime'
|
|
@@ -13,20 +13,22 @@ const ASSIGN_EXISTING_RUNTIME_LABEL = 'Assign an existing Runtime';
|
|
|
13
13
|
export function getGroupedRuntimeDescs(multiServiceManager, kernelId, translator, filterKernels = () => true, variant) {
|
|
14
14
|
translator = translator ?? nullTranslator;
|
|
15
15
|
const trans = translator.load('jupyterlab');
|
|
16
|
+
// The specifications land asynchronously, and a runtime that already runs
|
|
17
|
+
// is listed with or without them: what a kernel needs to be picked is its
|
|
18
|
+
// identifier, the specification only names it. Only the environments to
|
|
19
|
+
// start a new runtime in come from the specifications, and they wait.
|
|
16
20
|
const specs = multiServiceManager.local.kernelspecs.specs;
|
|
17
21
|
const sessions = multiServiceManager.local.sessions.running();
|
|
18
22
|
const kernels = {};
|
|
19
23
|
// Add the sessions.
|
|
20
24
|
const runningSessions = Array.from(sessions)
|
|
21
|
-
.filter(session => session.kernel &&
|
|
22
|
-
session.kernel.id !== kernelId &&
|
|
23
|
-
specs.kernelspecs[session.kernel.name])
|
|
25
|
+
.filter(session => session.kernel && session.kernel.id !== kernelId)
|
|
24
26
|
.map(session => {
|
|
25
|
-
const spec = specs
|
|
27
|
+
const spec = specs?.kernelspecs[session.kernel.name];
|
|
26
28
|
return {
|
|
27
29
|
kernelId: session.kernel.id,
|
|
28
|
-
name: spec.name,
|
|
29
|
-
language: spec
|
|
30
|
+
name: spec?.name ?? session.kernel.name,
|
|
31
|
+
language: spec?.language ?? '',
|
|
30
32
|
displayName: session.name || PathExt.basename(session.path),
|
|
31
33
|
location: 'local',
|
|
32
34
|
};
|
|
@@ -34,12 +36,13 @@ export function getGroupedRuntimeDescs(multiServiceManager, kernelId, translator
|
|
|
34
36
|
.concat(Array.from(multiServiceManager.browser?.sessions.running() ?? [])
|
|
35
37
|
.filter(session => session.kernel && session.kernel.id !== kernelId)
|
|
36
38
|
.map(session => {
|
|
37
|
-
|
|
39
|
+
// The browser specifications load on their own schedule.
|
|
40
|
+
const spec = multiServiceManager.browser?.kernelspecs.specs?.kernelspecs[session.kernel.name];
|
|
38
41
|
return {
|
|
39
42
|
id: '', // TODO Assign a proper ID.
|
|
40
43
|
kernelId: session.kernel.id,
|
|
41
|
-
name: spec.name,
|
|
42
|
-
language: spec
|
|
44
|
+
name: spec?.name ?? session.kernel.name,
|
|
45
|
+
language: spec?.language ?? '',
|
|
43
46
|
displayName: session.name || PathExt.basename(session.path),
|
|
44
47
|
location: 'browser',
|
|
45
48
|
};
|
|
@@ -50,12 +53,12 @@ export function getGroupedRuntimeDescs(multiServiceManager, kernelId, translator
|
|
|
50
53
|
const runningKernels = Array.from(multiServiceManager.local.kernels.running())
|
|
51
54
|
.filter(k => !listedAsSession.includes(k.id))
|
|
52
55
|
.map(k => {
|
|
53
|
-
const spec = specs
|
|
56
|
+
const spec = specs?.kernelspecs[k.name];
|
|
54
57
|
return {
|
|
55
58
|
kernelId: k.id,
|
|
56
|
-
name: spec.name,
|
|
57
|
-
language: spec
|
|
58
|
-
displayName: spec.
|
|
59
|
+
name: spec?.name ?? k.name,
|
|
60
|
+
language: spec?.language ?? '',
|
|
61
|
+
displayName: spec?.display_name ?? k.name,
|
|
59
62
|
location: 'local',
|
|
60
63
|
};
|
|
61
64
|
})
|
|
@@ -78,17 +81,30 @@ export function getGroupedRuntimeDescs(multiServiceManager, kernelId, translator
|
|
|
78
81
|
.concat(Array.from(multiServiceManager.browser?.kernels.running() ?? [])
|
|
79
82
|
.filter(k => !listedAsSession.includes(k.id))
|
|
80
83
|
.map(k => {
|
|
81
|
-
const spec = multiServiceManager.browser
|
|
84
|
+
const spec = multiServiceManager.browser?.kernelspecs.specs?.kernelspecs[k.name];
|
|
82
85
|
return {
|
|
83
86
|
kernelId: k.id,
|
|
84
|
-
name: spec.name,
|
|
85
|
-
language: spec
|
|
86
|
-
displayName: spec.
|
|
87
|
+
name: spec?.name ?? k.name,
|
|
88
|
+
language: spec?.language ?? '',
|
|
89
|
+
displayName: spec?.display_name ?? k.name,
|
|
87
90
|
location: 'browser',
|
|
88
91
|
};
|
|
89
92
|
}))
|
|
90
93
|
.filter(filterKernels);
|
|
91
94
|
runningSessions.push(...runningKernels);
|
|
95
|
+
// The sources overlap — a kernel of a session, a manager standing in for
|
|
96
|
+
// another — and a runtime listed twice would be picked twice.
|
|
97
|
+
const seen = new Set();
|
|
98
|
+
const distinctRunning = runningSessions.filter(desc => {
|
|
99
|
+
const key = `${desc.location}:${desc.kernelId ?? desc.name}`;
|
|
100
|
+
if (seen.has(key)) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
seen.add(key);
|
|
104
|
+
return true;
|
|
105
|
+
});
|
|
106
|
+
runningSessions.length = 0;
|
|
107
|
+
runningSessions.push(...distinctRunning);
|
|
92
108
|
if (runningSessions.length) {
|
|
93
109
|
const key = variant === 'cell'
|
|
94
110
|
? ASSIGN_EXISTING_REMOTE_RUNTIME_LABEL
|
|
@@ -96,7 +112,7 @@ export function getGroupedRuntimeDescs(multiServiceManager, kernelId, translator
|
|
|
96
112
|
kernels[key] = runningSessions;
|
|
97
113
|
}
|
|
98
114
|
// Environments.
|
|
99
|
-
const environments = Object.values(specs
|
|
115
|
+
const environments = Object.values(specs?.kernelspecs ?? {})
|
|
100
116
|
.filter(spec => !!spec)
|
|
101
117
|
.map(spec => ({
|
|
102
118
|
name: spec.name,
|
|
@@ -3,11 +3,11 @@ export interface CostUsageChartProps {
|
|
|
3
3
|
agentId?: string;
|
|
4
4
|
runtimeId?: string;
|
|
5
5
|
apiKey?: string;
|
|
6
|
-
|
|
6
|
+
otelUrl?: string;
|
|
7
7
|
wsUrl?: string;
|
|
8
8
|
liveCumulativeUsd?: number;
|
|
9
9
|
liveTimestampMs?: number | null;
|
|
10
10
|
height?: number;
|
|
11
11
|
}
|
|
12
|
-
export declare function CostUsageChart({ serviceName, agentId, runtimeId, apiKey,
|
|
12
|
+
export declare function CostUsageChart({ serviceName, agentId, runtimeId, apiKey, otelUrl, wsUrl, liveCumulativeUsd, liveTimestampMs, height, }: CostUsageChartProps): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export default CostUsageChart;
|
|
@@ -278,7 +278,7 @@ function maxDefined(rows, selector) {
|
|
|
278
278
|
return max === undefined ? value : Math.max(max, value);
|
|
279
279
|
}, undefined);
|
|
280
280
|
}
|
|
281
|
-
export function CostUsageChart({ serviceName, agentId, runtimeId, apiKey,
|
|
281
|
+
export function CostUsageChart({ serviceName, agentId, runtimeId, apiKey, otelUrl, wsUrl, liveCumulativeUsd, liveTimestampMs, height = 160, }) {
|
|
282
282
|
const cacheServiceKey = String(serviceName || runtimeId || '').trim() || undefined;
|
|
283
283
|
const monitoringCache = useAgentRuntimeStore(s => s.monitoringCache);
|
|
284
284
|
const mergeCostPoints = useAgentRuntimeStore(s => s.mergeCostPoints);
|
|
@@ -327,7 +327,7 @@ export function CostUsageChart({ serviceName, agentId, runtimeId, apiKey, datala
|
|
|
327
327
|
}, [agentId, cacheServiceKey, cachedEntry]);
|
|
328
328
|
// Bootstrap chart with existing OTEL cost metrics before websocket updates.
|
|
329
329
|
useEffect(() => {
|
|
330
|
-
if (!cacheServiceKey || !apiKey || !
|
|
330
|
+
if (!cacheServiceKey || !apiKey || !otelUrl) {
|
|
331
331
|
return;
|
|
332
332
|
}
|
|
333
333
|
let cancelled = false;
|
|
@@ -337,14 +337,14 @@ export function CostUsageChart({ serviceName, agentId, runtimeId, apiKey, datala
|
|
|
337
337
|
fetchOtelMetricRows({
|
|
338
338
|
metric: COST_RUN_METRIC,
|
|
339
339
|
serviceName,
|
|
340
|
-
|
|
340
|
+
otelUrl,
|
|
341
341
|
apiKey,
|
|
342
342
|
limit: 1000,
|
|
343
343
|
}),
|
|
344
344
|
fetchOtelMetricRows({
|
|
345
345
|
metric: COST_CUMULATIVE_METRIC,
|
|
346
346
|
serviceName,
|
|
347
|
-
|
|
347
|
+
otelUrl,
|
|
348
348
|
apiKey,
|
|
349
349
|
limit: 1000,
|
|
350
350
|
}),
|
|
@@ -391,7 +391,7 @@ export function CostUsageChart({ serviceName, agentId, runtimeId, apiKey, datala
|
|
|
391
391
|
agentId,
|
|
392
392
|
apiKey,
|
|
393
393
|
cacheServiceKey,
|
|
394
|
-
|
|
394
|
+
otelUrl,
|
|
395
395
|
mergeCostPoints,
|
|
396
396
|
runtimeId,
|
|
397
397
|
serviceName,
|
|
@@ -439,7 +439,7 @@ export function CostUsageChart({ serviceName, agentId, runtimeId, apiKey, datala
|
|
|
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 CostUsageChart({ serviceName, agentId, runtimeId, apiKey, datala
|
|
|
496
496
|
apiKey,
|
|
497
497
|
cacheServiceKey,
|
|
498
498
|
mergeCostPoints,
|
|
499
|
-
|
|
499
|
+
otelUrl,
|
|
500
500
|
runtimeId,
|
|
501
501
|
serviceName,
|
|
502
502
|
wsUrl,
|
|
@@ -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`:
|