@datalayer/agent-runtimes 1.0.25 → 1.0.28
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/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/code-sandboxes/CodeSandboxLauncher.d.ts +0 -2
- package/lib/components/code-sandboxes/CodeSandboxLauncher.js +98 -11
- package/lib/components/code-sandboxes/CodeSandboxNames.d.ts +47 -0
- package/lib/components/code-sandboxes/CodeSandboxNames.js +166 -0
- package/lib/components/code-sandboxes/CodeSandboxPicker.d.ts +30 -5
- package/lib/components/code-sandboxes/CodeSandboxPicker.js +239 -55
- package/lib/components/{runtimes/RuntimePickerCell.d.ts → code-sandboxes/CodeSandboxPickerCell.d.ts} +5 -5
- package/lib/components/{runtimes/RuntimePickerCell.js → code-sandboxes/CodeSandboxPickerCell.js} +6 -6
- package/lib/components/{runtimes/RuntimeReservationControl.d.ts → code-sandboxes/CodeSandboxReservationControl.d.ts} +3 -3
- package/lib/components/{runtimes/RuntimeReservationControl.js → code-sandboxes/CodeSandboxReservationControl.js} +5 -5
- package/lib/components/{runtimes/RuntimeTransfer.d.ts → code-sandboxes/CodeSandboxTransfer.d.ts} +7 -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} +15 -10
- 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 +17 -0
- package/lib/components/code-sandboxes/NewCodeSandboxControls.js +5 -5
- package/lib/components/code-sandboxes/index.d.ts +20 -1
- package/lib/components/code-sandboxes/index.js +20 -1
- package/lib/components/index.d.ts +4 -6
- package/lib/components/index.js +4 -6
- package/lib/components/progress/CreditsIndicator.js +1 -1
- package/package.json +2 -2
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +0 -7
- package/lib/components/runtimes/RuntimeLauncherDialog.js +0 -11
- package/lib/components/runtimes/RuntimePickerBase.d.ts +0 -8
- package/lib/components/runtimes/RuntimePickerBase.js +0 -12
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +0 -42
- package/lib/components/runtimes/RuntimePickerNotebook.js +0 -197
- 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 -12
- package/lib/components/runtimes/index.js +0 -17
- 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/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
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { ISessionContext } from '@jupyterlab/apputils';
|
|
3
|
+
import { ITranslator } from '@jupyterlab/translation';
|
|
4
|
+
import type { IRuntimeDesc } from '../../models';
|
|
5
|
+
/** What {@link useCodeSandboxVariablesTransfer} answers. */
|
|
6
|
+
export interface ICodeSandboxVariablesTransfer {
|
|
7
|
+
/**
|
|
8
|
+
* Whether carrying variables over is possible at all.
|
|
9
|
+
*
|
|
10
|
+
* Both ends must speak a language the snippets know how to serialize: the
|
|
11
|
+
* sandbox the variables come from, and the one they would go to.
|
|
12
|
+
*/
|
|
13
|
+
available: boolean;
|
|
14
|
+
/** The variables of the current sandbox, by name and type. */
|
|
15
|
+
variables?: {
|
|
16
|
+
[name: string]: string;
|
|
17
|
+
};
|
|
18
|
+
/** Those the user chose to carry over. */
|
|
19
|
+
selected: string[];
|
|
20
|
+
setSelected: (names: string[]) => void;
|
|
21
|
+
/** Whether the user asked for the transfer at all. */
|
|
22
|
+
transfer: boolean;
|
|
23
|
+
setTransfer: (value: boolean) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The variables of the current sandbox, and which of them to carry over.
|
|
27
|
+
*
|
|
28
|
+
* Listing them runs code in the sandbox — the snippet that names them — so it
|
|
29
|
+
* is deferred until the user asks for the transfer, and done once.
|
|
30
|
+
*
|
|
31
|
+
* @param sessionContext The session the variables are read from
|
|
32
|
+
* @param target The sandbox they would be carried to
|
|
33
|
+
* @param enabled Whether the transfer is offered at all
|
|
34
|
+
*/
|
|
35
|
+
export declare function useCodeSandboxVariablesTransfer(sessionContext: ISessionContext | undefined, target: IRuntimeDesc | undefined, enabled?: boolean): ICodeSandboxVariablesTransfer;
|
|
36
|
+
/**
|
|
37
|
+
* {@link CodeSandboxVariables} properties
|
|
38
|
+
*/
|
|
39
|
+
export interface ICodeSandboxVariablesProps {
|
|
40
|
+
/**
|
|
41
|
+
* Component class name
|
|
42
|
+
*/
|
|
43
|
+
className?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Available kernel variables
|
|
46
|
+
*
|
|
47
|
+
* Mapping (variable name, variable type)
|
|
48
|
+
*/
|
|
49
|
+
kernelVariables?: {
|
|
50
|
+
[name: string]: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Kernel variables to be transferred.
|
|
54
|
+
*/
|
|
55
|
+
selectedVariables: string[];
|
|
56
|
+
setSelectVariable: (l: string[]) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Whether to transfer the variable from the current
|
|
59
|
+
* to the selected kernel or not.
|
|
60
|
+
*/
|
|
61
|
+
transferVariables: boolean;
|
|
62
|
+
setTransferVariable: (v: boolean) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Application translator
|
|
65
|
+
*/
|
|
66
|
+
translator?: ITranslator;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Runtime variables selector component.
|
|
70
|
+
*/
|
|
71
|
+
export declare function CodeSandboxVariables(props: ICodeSandboxVariablesProps): ReactElement;
|
package/lib/components/{runtimes/RuntimeVariables.js → code-sandboxes/CodeSandboxVariables.js}
RENAMED
|
@@ -3,16 +3,91 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
|
-
import { useMemo } from 'react';
|
|
6
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
7
7
|
import { IconButton, ToggleSwitch, FormControl } from '@primer/react';
|
|
8
8
|
import { Box } from '@datalayer/primer-addons';
|
|
9
9
|
import { Blankslate, DataTable, Table } from '@primer/react/experimental';
|
|
10
10
|
import { nullTranslator } from '@jupyterlab/translation';
|
|
11
11
|
import { checkIcon } from '@jupyterlab/ui-components';
|
|
12
|
+
import { JSONExt } from '@lumino/coreutils';
|
|
13
|
+
import { KernelExecutor } from '@datalayer/jupyter-react';
|
|
14
|
+
import { RuntimeSnippetsFacade } from '../../jupyter';
|
|
15
|
+
/**
|
|
16
|
+
* The variables of the current sandbox, and which of them to carry over.
|
|
17
|
+
*
|
|
18
|
+
* Listing them runs code in the sandbox — the snippet that names them — so it
|
|
19
|
+
* is deferred until the user asks for the transfer, and done once.
|
|
20
|
+
*
|
|
21
|
+
* @param sessionContext The session the variables are read from
|
|
22
|
+
* @param target The sandbox they would be carried to
|
|
23
|
+
* @param enabled Whether the transfer is offered at all
|
|
24
|
+
*/
|
|
25
|
+
export function useCodeSandboxVariablesTransfer(sessionContext, target, enabled = true) {
|
|
26
|
+
const [variables, setVariables] = useState();
|
|
27
|
+
const [selected, setSelectedState] = useState([]);
|
|
28
|
+
const [transfer, setTransferState] = useState(false);
|
|
29
|
+
const [listed, setListed] = useState(false);
|
|
30
|
+
const sourceLanguage = sessionContext?.session?.kernel?.name && sessionContext.specsManager.specs
|
|
31
|
+
? sessionContext.specsManager.specs.kernelspecs[sessionContext.session.kernel.name]?.language
|
|
32
|
+
: undefined;
|
|
33
|
+
const available = enabled &&
|
|
34
|
+
RuntimeSnippetsFacade.supports(sourceLanguage ?? '') &&
|
|
35
|
+
RuntimeSnippetsFacade.supports(target?.language ?? '');
|
|
36
|
+
const list = useCallback(async () => {
|
|
37
|
+
if (listed) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
setListed(true);
|
|
41
|
+
const connection = sessionContext?.session?.kernel;
|
|
42
|
+
const spec = connection &&
|
|
43
|
+
sessionContext?.specsManager.specs?.kernelspecs[connection.model.name];
|
|
44
|
+
if (!connection || !spec) {
|
|
45
|
+
setVariables({});
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const snippets = new RuntimeSnippetsFacade(spec.language);
|
|
49
|
+
const outputs = await new KernelExecutor({ connection }).execute(snippets.listVariables());
|
|
50
|
+
const content = outputs.get(0).data['text/plain'];
|
|
51
|
+
if (!content) {
|
|
52
|
+
setVariables({});
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// The payload comes quoted, as the representation of a string.
|
|
56
|
+
const listedVariables = JSON.parse(content.slice(1, content.length - 1));
|
|
57
|
+
setVariables(listedVariables);
|
|
58
|
+
// Everything is carried over unless the user says otherwise.
|
|
59
|
+
setSelectedState(Object.keys(listedVariables ?? {}));
|
|
60
|
+
}, [listed, sessionContext]);
|
|
61
|
+
const setSelected = useCallback((names) => {
|
|
62
|
+
setSelectedState(current => JSONExt.deepEqual(current, names) ? current : names);
|
|
63
|
+
}, [setSelectedState]);
|
|
64
|
+
const setTransfer = useCallback((value) => {
|
|
65
|
+
setTransferState(current => {
|
|
66
|
+
if (current === value) {
|
|
67
|
+
return current;
|
|
68
|
+
}
|
|
69
|
+
if (value) {
|
|
70
|
+
list().catch(reason => {
|
|
71
|
+
console.error('Failed to list the variables of the sandbox', reason);
|
|
72
|
+
setListed(false);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
});
|
|
77
|
+
}, [list]);
|
|
78
|
+
return {
|
|
79
|
+
available,
|
|
80
|
+
variables,
|
|
81
|
+
selected: available && transfer ? selected : [],
|
|
82
|
+
setSelected,
|
|
83
|
+
transfer,
|
|
84
|
+
setTransfer,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
12
87
|
/**
|
|
13
88
|
* Runtime variables selector component.
|
|
14
89
|
*/
|
|
15
|
-
export function
|
|
90
|
+
export function CodeSandboxVariables(props) {
|
|
16
91
|
const { className, translator, selectedVariables, setSelectVariable, transferVariables, setTransferVariable, kernelVariables, } = props;
|
|
17
92
|
const trans = useMemo(() => (translator ?? nullTranslator).load('jupyterlab'), [translator]);
|
|
18
93
|
const nRows = Object.keys(kernelVariables ?? {}).length;
|
|
@@ -34,6 +34,23 @@ export interface INewCodeSandboxControlsProps {
|
|
|
34
34
|
userStorage: boolean;
|
|
35
35
|
onUserStorageToggle: () => void;
|
|
36
36
|
storageDisabled?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The name the sandbox is given, when the caller asks for that question.
|
|
39
|
+
*
|
|
40
|
+
* A sandbox of the platform is named through `given_name`; one of a server
|
|
41
|
+
* or of the browser has the name held for it by `CodeSandboxNames`. The
|
|
42
|
+
* question is the same either way, so it is asked in one place.
|
|
43
|
+
*/
|
|
44
|
+
givenName?: string;
|
|
45
|
+
onGivenNameChange?: (givenName: string) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the storage of the user is offered.
|
|
48
|
+
*
|
|
49
|
+
* A sandbox of this Jupyter Server runs on this machine, with the files of
|
|
50
|
+
* this machine: it reserves no time and mounts no storage of the platform,
|
|
51
|
+
* so neither question applies to it.
|
|
52
|
+
*/
|
|
53
|
+
withUserStorage?: boolean;
|
|
37
54
|
}
|
|
38
55
|
/**
|
|
39
56
|
* The two questions of a new sandbox: the time reservation, and the storage.
|
|
@@ -15,10 +15,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
15
15
|
*
|
|
16
16
|
* @module components/code-sandboxes/NewCodeSandboxControls
|
|
17
17
|
*/
|
|
18
|
-
import { FormControl, ToggleSwitch, Tooltip,
|
|
18
|
+
import { FormControl, IconButton, TextInput, ToggleSwitch, Tooltip, } from '@primer/react';
|
|
19
19
|
import { AlertIcon } from '@primer/octicons-react';
|
|
20
20
|
import { useCoreStore, useIAMStore } from '../../state/substates';
|
|
21
|
-
import {
|
|
21
|
+
import { CodeSandboxReservationControl, MAXIMAL_CODE_SANDBOX_TIME_RESERVATION_MINUTES, } from './CodeSandboxReservationControl';
|
|
22
22
|
/**
|
|
23
23
|
* The credits arithmetic both the launcher and the picker ask.
|
|
24
24
|
*
|
|
@@ -58,7 +58,7 @@ export function useNewCodeSandboxAllowance(burningRate) {
|
|
|
58
58
|
}
|
|
59
59
|
/** The credits a time reservation stands for. */
|
|
60
60
|
export function creditsLimitFor(timeLimitMinutes, burningRate) {
|
|
61
|
-
return (Math.min(timeLimitMinutes,
|
|
61
|
+
return (Math.min(timeLimitMinutes, MAXIMAL_CODE_SANDBOX_TIME_RESERVATION_MINUTES) *
|
|
62
62
|
burningRate *
|
|
63
63
|
60);
|
|
64
64
|
}
|
|
@@ -67,9 +67,9 @@ export function creditsLimitFor(timeLimitMinutes, burningRate) {
|
|
|
67
67
|
* The storage is withheld on white-label deployments, as it always was.
|
|
68
68
|
*/
|
|
69
69
|
export function NewCodeSandboxControls(props) {
|
|
70
|
-
const { addCredits, burningRate, withReservation = true, disabled, error, max, onTimeChange, onUserStorageToggle, storageDisabled, timeLimit, userStorage, } = props;
|
|
70
|
+
const { addCredits, burningRate, withReservation = true, disabled, error, givenName, max, onGivenNameChange, onTimeChange, onUserStorageToggle, storageDisabled, timeLimit, userStorage, withUserStorage = true, } = props;
|
|
71
71
|
const { configuration } = useCoreStore();
|
|
72
|
-
return (_jsxs(_Fragment, { children: [withReservation && (_jsx(
|
|
72
|
+
return (_jsxs(_Fragment, { children: [onGivenNameChange && (_jsxs(FormControl, { disabled: disabled, children: [_jsx(FormControl.Label, { children: "Given Name" }), _jsx(TextInput, { block: true, name: "given-name", value: givenName ?? '', onChange: event => onGivenNameChange(event.target.value) }), _jsx(FormControl.Caption, { children: "What this sandbox is called, wherever it is listed." })] })), withReservation && (_jsx(CodeSandboxReservationControl, { addCredits: addCredits, disabled: disabled, label: 'Time reservation', max: max, time: timeLimit, burningRate: burningRate, onTimeChange: onTimeChange, error: error })), withUserStorage && !configuration.whiteLabel && (_jsxs(FormControl, { disabled: storageDisabled, layout: "horizontal", children: [_jsxs(FormControl.Label, { id: "new-sandbox-user-storage-label", children: ["User storage", _jsx(Tooltip, { text: "The runtime will be slower to start.", direction: "e", style: { marginLeft: 3 }, children: _jsx(IconButton, { icon: AlertIcon, "aria-label": "", variant: "invisible" }) })] }), _jsx(ToggleSwitch, { disabled: storageDisabled, checked: userStorage, size: "small", onClick: event => {
|
|
73
73
|
event.preventDefault();
|
|
74
74
|
onUserStorageToggle();
|
|
75
75
|
}, "aria-labelledby": "new-sandbox-user-storage-label" })] }))] }));
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The code sandboxes: what runs the code of a notebook, a document or a cell.
|
|
3
|
+
*
|
|
4
|
+
* One launcher and one picker, and everything they are made of. The launcher
|
|
5
|
+
* asks for a NEW sandbox and starts it; the picker lists what already runs
|
|
6
|
+
* next to the environments a new one could be started in. The pickers of a
|
|
7
|
+
* notebook, of a cell and of a toolbar are compositions of those two — none
|
|
8
|
+
* of them carries a second copy of either.
|
|
9
|
+
*
|
|
10
|
+
* @module components/code-sandboxes
|
|
11
|
+
*/
|
|
12
|
+
export * from './CodeSandboxCellVariables';
|
|
13
|
+
export * from './CodeSandboxCellVariablesDialog';
|
|
2
14
|
export * from './CodeSandboxLauncher';
|
|
15
|
+
export * from './CodeSandboxPicker';
|
|
16
|
+
export * from './CodeSandboxPickerCell';
|
|
17
|
+
export * from './CodeSandboxReservationControl';
|
|
18
|
+
export * from './CodeSandboxTransfer';
|
|
19
|
+
export * from './CodeSandboxNames';
|
|
20
|
+
export * from './CodeSandboxUtils';
|
|
21
|
+
export * from './CodeSandboxVariables';
|
|
3
22
|
export * from './NewCodeSandboxControls';
|
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The code sandboxes: what runs the code of a notebook, a document or a cell.
|
|
7
|
+
*
|
|
8
|
+
* One launcher and one picker, and everything they are made of. The launcher
|
|
9
|
+
* asks for a NEW sandbox and starts it; the picker lists what already runs
|
|
10
|
+
* next to the environments a new one could be started in. The pickers of a
|
|
11
|
+
* notebook, of a cell and of a toolbar are compositions of those two — none
|
|
12
|
+
* of them carries a second copy of either.
|
|
13
|
+
*
|
|
14
|
+
* @module components/code-sandboxes
|
|
15
|
+
*/
|
|
16
|
+
export * from './CodeSandboxCellVariables';
|
|
17
|
+
export * from './CodeSandboxCellVariablesDialog';
|
|
6
18
|
export * from './CodeSandboxLauncher';
|
|
19
|
+
export * from './CodeSandboxPicker';
|
|
20
|
+
export * from './CodeSandboxPickerCell';
|
|
21
|
+
export * from './CodeSandboxReservationControl';
|
|
22
|
+
export * from './CodeSandboxTransfer';
|
|
23
|
+
export * from './CodeSandboxNames';
|
|
24
|
+
export * from './CodeSandboxUtils';
|
|
25
|
+
export * from './CodeSandboxVariables';
|
|
7
26
|
export * from './NewCodeSandboxControls';
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export * from './ToolApprovalCard';
|
|
2
|
-
export * from './NotificationEventCard';
|
|
3
|
-
export * from './OutputCard';
|
|
4
|
-
export * from './AgentSummary';
|
|
5
1
|
export * from './a2ui';
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
2
|
+
export * from './agents';
|
|
3
|
+
export * from './cards';
|
|
4
|
+
export * from './code-sandboxes';
|
|
8
5
|
export * from './scheduler';
|
|
6
|
+
export * from './snapshots';
|
package/lib/components/index.js
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
export * from './ToolApprovalCard';
|
|
6
|
-
export * from './NotificationEventCard';
|
|
7
|
-
export * from './OutputCard';
|
|
8
|
-
export * from './AgentSummary';
|
|
9
5
|
export * from './a2ui';
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
6
|
+
export * from './agents';
|
|
7
|
+
export * from './cards';
|
|
8
|
+
export * from './code-sandboxes';
|
|
12
9
|
export * from './scheduler';
|
|
10
|
+
export * from './snapshots';
|
|
@@ -5,8 +5,8 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
5
5
|
*/
|
|
6
6
|
import { useState, useEffect } from 'react';
|
|
7
7
|
import { Box } from '@datalayer/primer-addons';
|
|
8
|
-
import { useNavigate } from '@datalayer/core/lib/hooks/useNavigate';
|
|
9
8
|
import { ConsumptionBar } from '@datalayer/core/lib/components/progress/ConsumptionBar';
|
|
9
|
+
import { useNavigate } from '@datalayer/core/lib/hooks/useNavigate';
|
|
10
10
|
/**
|
|
11
11
|
* Credits indicator component.
|
|
12
12
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datalayer/agent-runtimes",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"workspaces": [
|
|
6
6
|
".",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"@agentclientprotocol/sdk": "^0.8.0",
|
|
139
139
|
"@ai-sdk/react": "4.0.23",
|
|
140
140
|
"@anthropic-ai/sdk": "^0.52.0",
|
|
141
|
-
"@datalayer/core": "^1.1.
|
|
141
|
+
"@datalayer/core": "^1.1.57",
|
|
142
142
|
"@datalayer/icons-react": "^1.0.7",
|
|
143
143
|
"@datalayer/jupyter-lexical": "^1.0.16",
|
|
144
144
|
"@datalayer/lexical-loro": "^1.0.0",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Moved: the launcher lives with the code sandboxes now.
|
|
3
|
-
*
|
|
4
|
-
* @deprecated Import from `components/code-sandboxes/CodeSandboxLauncher`.
|
|
5
|
-
* @module components/runtimes/RuntimeLauncherDialog
|
|
6
|
-
*/
|
|
7
|
-
export { CodeSandboxLauncher, RuntimeLauncherDialog, type ICodeSandboxLauncherProps, type IRuntimeLauncherDialogProps, } from '../code-sandboxes/CodeSandboxLauncher';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Moved: the launcher lives with the code sandboxes now.
|
|
7
|
-
*
|
|
8
|
-
* @deprecated Import from `components/code-sandboxes/CodeSandboxLauncher`.
|
|
9
|
-
* @module components/runtimes/RuntimeLauncherDialog
|
|
10
|
-
*/
|
|
11
|
-
export { CodeSandboxLauncher, RuntimeLauncherDialog, } from '../code-sandboxes/CodeSandboxLauncher';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Moved: the picker lives with the code sandboxes now.
|
|
3
|
-
*
|
|
4
|
-
* @deprecated Import from `components/code-sandboxes/CodeSandboxPicker`.
|
|
5
|
-
* @module components/runtimes/RuntimePickerBase
|
|
6
|
-
*/
|
|
7
|
-
export { CodeSandboxPicker, RuntimePickerBase, type ICodeSandboxPickerProps, type IRuntimePickerBaseProps, } from '../code-sandboxes/CodeSandboxPicker';
|
|
8
|
-
export { default } from '../code-sandboxes/CodeSandboxPicker';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Moved: the picker lives with the code sandboxes now.
|
|
7
|
-
*
|
|
8
|
-
* @deprecated Import from `components/code-sandboxes/CodeSandboxPicker`.
|
|
9
|
-
* @module components/runtimes/RuntimePickerBase
|
|
10
|
-
*/
|
|
11
|
-
export { CodeSandboxPicker, RuntimePickerBase, } from '../code-sandboxes/CodeSandboxPicker';
|
|
12
|
-
export { default } from '../code-sandboxes/CodeSandboxPicker';
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { ITranslator } from '@jupyterlab/translation';
|
|
2
|
-
import { CommandRegistry } from '@lumino/commands';
|
|
3
|
-
import type { IMultiServiceManager, IDatalayerSessionContext } from '../../runtimes';
|
|
4
|
-
import { RuntimeTransfer } from './RuntimeTransfer';
|
|
5
|
-
/**
|
|
6
|
-
* {@link RuntimePickerNotebook} properties
|
|
7
|
-
*/
|
|
8
|
-
export interface IRuntimePickerNotebookProps {
|
|
9
|
-
/**
|
|
10
|
-
* Callback to allow the user to login
|
|
11
|
-
*/
|
|
12
|
-
logIn?: () => void;
|
|
13
|
-
/**
|
|
14
|
-
* Document session context
|
|
15
|
-
*/
|
|
16
|
-
sessionContext: IDatalayerSessionContext;
|
|
17
|
-
/**
|
|
18
|
-
* Multi service manager
|
|
19
|
-
*/
|
|
20
|
-
multiServiceManager: IMultiServiceManager;
|
|
21
|
-
/**
|
|
22
|
-
* Set the selected kernel
|
|
23
|
-
*/
|
|
24
|
-
setValue: (v: RuntimeTransfer | Error) => void;
|
|
25
|
-
/**
|
|
26
|
-
* Close the dialog
|
|
27
|
-
*/
|
|
28
|
-
close: () => void;
|
|
29
|
-
/**
|
|
30
|
-
* Command registry
|
|
31
|
-
*/
|
|
32
|
-
commands: CommandRegistry;
|
|
33
|
-
/**
|
|
34
|
-
* Application translator
|
|
35
|
-
*/
|
|
36
|
-
translator?: ITranslator;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Runtime Picker components for a Notebook.
|
|
40
|
-
*/
|
|
41
|
-
export declare function RuntimePickerNotebook(props: IRuntimePickerNotebookProps): JSX.Element;
|
|
42
|
-
export default RuntimePickerNotebook;
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, 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
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
7
|
-
import { ActionList } from '@primer/react';
|
|
8
|
-
import { Box } from '@datalayer/primer-addons';
|
|
9
|
-
import { JSONExt } from '@lumino/coreutils';
|
|
10
|
-
import { KernelExecutor } from '@datalayer/jupyter-react';
|
|
11
|
-
import { RuntimeSnippetsFacade } from '../../jupyter';
|
|
12
|
-
import { ExternalTokenSilentLogin } from '@datalayer/core/lib/components/iam';
|
|
13
|
-
import { useIAMStore } from '../../state/substates';
|
|
14
|
-
import { RuntimeVariables } from './RuntimeVariables';
|
|
15
|
-
import { CodeSandboxPicker } from '../code-sandboxes/CodeSandboxPicker';
|
|
16
|
-
import { creditsLimitFor, NewCodeSandboxControls, useNewCodeSandboxAllowance, } from '../code-sandboxes/NewCodeSandboxControls';
|
|
17
|
-
/**
|
|
18
|
-
* Runtime Picker components for a Notebook.
|
|
19
|
-
*/
|
|
20
|
-
export function RuntimePickerNotebook(props) {
|
|
21
|
-
const { multiServiceManager, sessionContext, setValue, translator } = props;
|
|
22
|
-
const { refreshCredits, token } = useIAMStore();
|
|
23
|
-
const [selectedRuntimeDesc, setSelectedRuntimeDesc] = useState();
|
|
24
|
-
const [timeLimit, setTimeLimit] = useState(10);
|
|
25
|
-
const [userStorage, setUserStorage] = useState(false);
|
|
26
|
-
const [canTransferFrom, setTransferFrom] = useState(false);
|
|
27
|
-
const [canTransferTo, setTransferTo] = useState(false);
|
|
28
|
-
const [transferVariables, setTransferVariables] = useState(false);
|
|
29
|
-
const [hasLoadedVariables, setHasLoadedVariables] = useState(false);
|
|
30
|
-
const [kernelVariables, setRuntimeVariables] = useState();
|
|
31
|
-
const [toTransfer, setToTransfer] = useState([]);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
refreshCredits();
|
|
34
|
-
}, []);
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
const specs = sessionContext.specsManager.specs?.kernelspecs;
|
|
37
|
-
if (sessionContext.session?.kernel?.name && specs) {
|
|
38
|
-
const spec = Object.values(specs).find(spec => spec?.name === sessionContext.session.kernel.name);
|
|
39
|
-
if (spec) {
|
|
40
|
-
setSelectedRuntimeDesc({
|
|
41
|
-
name: spec.name,
|
|
42
|
-
kernelId: sessionContext.session.kernel.id,
|
|
43
|
-
location: sessionContext.location,
|
|
44
|
-
language: spec.language,
|
|
45
|
-
displayName: sessionContext.kernelDisplayName,
|
|
46
|
-
});
|
|
47
|
-
setTransferFrom(RuntimeSnippetsFacade.supports(spec.language));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}, [sessionContext]);
|
|
51
|
-
const listRuntimeVariables = useCallback(async () => {
|
|
52
|
-
if (hasLoadedVariables) {
|
|
53
|
-
return Promise.resolve();
|
|
54
|
-
}
|
|
55
|
-
setHasLoadedVariables(true);
|
|
56
|
-
const connection = sessionContext.session.kernel;
|
|
57
|
-
const spec = sessionContext.specsManager.specs.kernelspecs[connection.model.name];
|
|
58
|
-
const snippets = new RuntimeSnippetsFacade(spec.language);
|
|
59
|
-
const outputs = await new KernelExecutor({ connection }).execute(snippets.listVariables());
|
|
60
|
-
const content = outputs.get(0).data['text/plain'];
|
|
61
|
-
if (content) {
|
|
62
|
-
setRuntimeVariables(JSON.parse(
|
|
63
|
-
// We need to remove the quotes prior to parsing.
|
|
64
|
-
content.slice(1, content.length - 1)));
|
|
65
|
-
if (toTransfer.length) {
|
|
66
|
-
const candidates = Object.keys(kernelVariables ?? {});
|
|
67
|
-
setToTransfer(toTransfer.filter(n => candidates.includes(n)));
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
// By default select all variables.
|
|
71
|
-
setToTransfer(Object.keys(kernelVariables ?? {}));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
setRuntimeVariables({});
|
|
76
|
-
}
|
|
77
|
-
}, [hasLoadedVariables, kernelVariables, toTransfer]);
|
|
78
|
-
const setSelectedVariables = useCallback((l) => {
|
|
79
|
-
if (!JSONExt.deepEqual(toTransfer, l)) {
|
|
80
|
-
setToTransfer(l);
|
|
81
|
-
}
|
|
82
|
-
}, [toTransfer]);
|
|
83
|
-
const setTransferVariable = useCallback((value) => {
|
|
84
|
-
if (transferVariables !== value) {
|
|
85
|
-
if (value) {
|
|
86
|
-
listRuntimeVariables().catch(error => {
|
|
87
|
-
console.error('Failed to list the runtime variable', error);
|
|
88
|
-
setHasLoadedVariables(false);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
setTransferVariables(value);
|
|
92
|
-
}
|
|
93
|
-
}, [transferVariables]);
|
|
94
|
-
const setRuntimeDesc = useCallback((runtimeDesc) => {
|
|
95
|
-
if (!runtimeDesc) {
|
|
96
|
-
if (selectedRuntimeDesc) {
|
|
97
|
-
setSelectedRuntimeDesc(undefined);
|
|
98
|
-
setTransferTo(false);
|
|
99
|
-
}
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (selectedRuntimeDesc?.displayName !== runtimeDesc.displayName ||
|
|
103
|
-
selectedRuntimeDesc?.kernelId !== runtimeDesc.kernelId) {
|
|
104
|
-
setSelectedRuntimeDesc({ ...runtimeDesc });
|
|
105
|
-
setTransferTo(RuntimeSnippetsFacade.supports(runtimeDesc.language));
|
|
106
|
-
}
|
|
107
|
-
}, [selectedRuntimeDesc]);
|
|
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);
|
|
115
|
-
useEffect(() => {
|
|
116
|
-
const maxMinutes = selectedRuntimeDesc?.location === 'remote'
|
|
117
|
-
? allowance.maxFromCredits
|
|
118
|
-
: undefined;
|
|
119
|
-
const effectiveTimeLimit = selectedRuntimeDesc?.location === 'remote'
|
|
120
|
-
? Math.max(1, Math.min(timeLimit, maxMinutes && maxMinutes > 0 ? maxMinutes : 10))
|
|
121
|
-
: timeLimit;
|
|
122
|
-
const creditsLimit = selectedRuntimeDesc?.location === 'remote' && resolvedBurningRate
|
|
123
|
-
? creditsLimitFor(effectiveTimeLimit, resolvedBurningRate)
|
|
124
|
-
: undefined;
|
|
125
|
-
const requiresRuntimeStart = !!selectedRuntimeDesc && !selectedRuntimeDesc.kernelId;
|
|
126
|
-
if (requiresRuntimeStart && selectedRuntimeDesc.location === 'remote') {
|
|
127
|
-
if (!resolvedBurningRate || !Number.isFinite(resolvedBurningRate)) {
|
|
128
|
-
setValue({ runtime: null, selectedVariables: toTransfer });
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (allowance.hasKnownCredits &&
|
|
132
|
-
allowance.hasKnownRunAllowance &&
|
|
133
|
-
!allowance.hasRemainingRuns &&
|
|
134
|
-
(!creditsLimit || creditsLimit <= 0)) {
|
|
135
|
-
setValue({ runtime: null, selectedVariables: toTransfer });
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
setValue({
|
|
140
|
-
runtime: selectedRuntimeDesc
|
|
141
|
-
? {
|
|
142
|
-
environmentName: ['browser', 'remote'].includes(selectedRuntimeDesc.location)
|
|
143
|
-
? `${selectedRuntimeDesc.location}-${selectedRuntimeDesc.name}`
|
|
144
|
-
: selectedRuntimeDesc.name,
|
|
145
|
-
id: selectedRuntimeDesc.kernelId,
|
|
146
|
-
creditsLimit,
|
|
147
|
-
capabilities: userStorage ? ['user_storage'] : undefined,
|
|
148
|
-
}
|
|
149
|
-
: null,
|
|
150
|
-
selectedVariables: toTransfer,
|
|
151
|
-
});
|
|
152
|
-
}, [
|
|
153
|
-
selectedRuntimeDesc,
|
|
154
|
-
userStorage,
|
|
155
|
-
toTransfer,
|
|
156
|
-
timeLimit,
|
|
157
|
-
multiServiceManager.remote,
|
|
158
|
-
resolvedBurningRate,
|
|
159
|
-
allowance,
|
|
160
|
-
]);
|
|
161
|
-
const { kernelPreference: { canStart }, } = sessionContext;
|
|
162
|
-
const effectiveMaxMinutes = selectedRuntimeDesc?.location === 'remote'
|
|
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: {
|
|
170
|
-
id: sessionContext.session?.id,
|
|
171
|
-
kernelDisplayName: sessionContext.kernelPreference.shouldStart
|
|
172
|
-
? sessionContext.kernelDisplayName
|
|
173
|
-
: undefined,
|
|
174
|
-
}, sessionContext: sessionContext, multiServiceManager: multiServiceManager, translator: translator, runtimeDesc: selectedRuntimeDesc, setRuntimeDesc: setRuntimeDesc, postActions: token || !props.logIn ? (
|
|
175
|
-
/*
|
|
176
|
-
<Button
|
|
177
|
-
variant="default"
|
|
178
|
-
onClick={e => {
|
|
179
|
-
e.preventDefault();
|
|
180
|
-
commands.execute(CommandIDs.launchRemoteRuntime);
|
|
181
|
-
close();
|
|
182
|
-
}}
|
|
183
|
-
>
|
|
184
|
-
Launch a New Runtime
|
|
185
|
-
</Button>
|
|
186
|
-
*/
|
|
187
|
-
_jsx(_Fragment, {})) : (_jsx(ActionList.Item, { onSelect: props.logIn, title: 'Runtime Provider.', children: _jsx(ExternalTokenSilentLogin, { message: "Click to sign in." }) })) }) }), !selectedRuntimeDesc?.kernelId &&
|
|
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 }))] }));
|
|
196
|
-
}
|
|
197
|
-
export default RuntimePickerNotebook;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Session } from '@jupyterlab/services';
|
|
2
|
-
import { IRuntimeModel, type IRuntimeDesc } from '../../models';
|
|
3
|
-
export interface IRuntimeAssignOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Runtime description.
|
|
6
|
-
*/
|
|
7
|
-
runtimeDesc?: IRuntimeDesc;
|
|
8
|
-
/**
|
|
9
|
-
* Runtime model to connect to.
|
|
10
|
-
*/
|
|
11
|
-
runtimeModel?: IRuntimeModel;
|
|
12
|
-
/**
|
|
13
|
-
* Whether to transfer the state to the runtime model.
|
|
14
|
-
*/
|
|
15
|
-
transferState?: boolean;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Runtime picker component properties.
|
|
19
|
-
*/
|
|
20
|
-
interface IRuntimeSimplePickerProps {
|
|
21
|
-
/**
|
|
22
|
-
* Runtime assignment callback.
|
|
23
|
-
*/
|
|
24
|
-
assignRuntime: (options: IRuntimeAssignOptions) => Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* Connection to the active runtime.
|
|
27
|
-
*/
|
|
28
|
-
sessionConnection?: Session.ISessionConnection;
|
|
29
|
-
/**
|
|
30
|
-
* Whether browser runtime is available.
|
|
31
|
-
*/
|
|
32
|
-
browserRuntimeAvailable?: boolean;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Runtime simple picker component.
|
|
36
|
-
*/
|
|
37
|
-
export declare function RuntimeSimplePicker(props: IRuntimeSimplePickerProps): JSX.Element;
|
|
38
|
-
export {};
|