@datalayer/agent-runtimes 1.3.73 → 1.3.74
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/chat/ChatFloating.d.ts +9 -2
- package/lib/chat/ChatFloating.js +30 -9
- package/lib/chat/assistant/AssistantStage.d.ts +29 -5
- package/lib/chat/assistant/AssistantStage.js +20 -2
- package/lib/chat/assistant/BalloonVisual.d.ts +57 -0
- package/lib/chat/assistant/BalloonVisual.js +58 -0
- package/lib/chat/assistant/SpeechBalloon.d.ts +22 -2
- package/lib/chat/assistant/SpeechBalloon.js +61 -7
- package/lib/chat/assistant/state.d.ts +19 -0
- package/lib/chat/assistant/state.js +44 -17
- package/lib/components/teams/A2ATeamGraph.d.ts +12 -2
- package/lib/components/teams/A2ATeamGraph.js +14 -5
- package/lib/components/teams/NotebookPreview.d.ts +11 -2
- package/lib/components/teams/NotebookPreview.js +6 -3
- package/lib/components/teams/TeamNotebook.d.ts +7 -0
- package/lib/components/teams/TeamNotebook.js +13 -1
- package/lib/examples/AgentA2ATeamExample.d.ts +3 -2
- package/lib/examples/AgentA2ATeamExample.js +6 -2
- package/lib/examples/{ChatAssistantExample.d.ts → AssistantExample.d.ts} +2 -2
- package/lib/examples/{ChatAssistantExample.js → AssistantExample.js} +7 -5
- package/lib/examples/{ChatAssistantGalleryExample.d.ts → AssistantGalleryExample.d.ts} +2 -2
- package/lib/examples/{ChatAssistantGalleryExample.js → AssistantGalleryExample.js} +45 -13
- package/lib/examples/example-selector.js +4 -2
- package/lib/examples/exampleGroups.d.ts +9 -0
- package/lib/examples/exampleGroups.js +56 -0
- package/lib/examples/index.d.ts +1 -1
- package/lib/examples/index.js +1 -1
- package/lib/examples/main.js +3 -43
- package/lib/examples/utils/AssistantGalleryGrid.d.ts +6 -1
- package/lib/examples/utils/AssistantGalleryGrid.js +16 -3
- package/lib/examples/utils/assistantGallery.d.ts +51 -2
- package/lib/examples/utils/assistantGallery.js +32 -7
- package/package.json +1 -1
package/lib/examples/main.js
CHANGED
|
@@ -27,6 +27,7 @@ import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
|
|
|
27
27
|
import { teardownExampleAgents } from './utils/teardownAgents';
|
|
28
28
|
import { OAuthCallback } from '../identity';
|
|
29
29
|
import { EXAMPLES, getExampleEntries, } from './example-selector';
|
|
30
|
+
import { EXAMPLE_GROUP_ORDER, getExampleGroup } from './exampleGroups';
|
|
30
31
|
import { RUNTIME_TARGETS, runtimeTargetCapabilities, runtimeTargetStore, targetHasAgent, useRuntimeTargetStore, } from './utils/runtimeTargetStore';
|
|
31
32
|
import { resolveExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
32
33
|
import { isLocalUrl } from './utils/localUrl';
|
|
@@ -46,18 +47,6 @@ const DEFAULT_RUNTIMES_URL = 'https://r1.datalayer.run';
|
|
|
46
47
|
const DEFAULT_LOCAL_JUPYTER_SERVER_URL = 'http://localhost:8888/api/jupyter-server';
|
|
47
48
|
const DEFAULT_LOCAL_JUPYTER_SERVER_TOKEN = '60c1661cc408f978c309d04157af55c9588ff9557c9380e4fb50785750703da6';
|
|
48
49
|
const DEFAULT_CLOUD_RUNTIME_ENVIRONMENT = 'ai-agents-env';
|
|
49
|
-
const EXAMPLE_GROUP_ORDER = [
|
|
50
|
-
'Apps',
|
|
51
|
-
'A2UI',
|
|
52
|
-
'A2A',
|
|
53
|
-
'AG-UI',
|
|
54
|
-
'Chat',
|
|
55
|
-
'Document',
|
|
56
|
-
'Notebook',
|
|
57
|
-
'Capabilities',
|
|
58
|
-
'Cell',
|
|
59
|
-
'CopilotKit',
|
|
60
|
-
];
|
|
61
50
|
/**
|
|
62
51
|
* The examples that open without an account.
|
|
63
52
|
*
|
|
@@ -88,42 +77,13 @@ const ANONYMOUS_EXAMPLES = new Set([
|
|
|
88
77
|
'DecksAgent',
|
|
89
78
|
// The floating assistant: the character, its balloon and its motions need
|
|
90
79
|
// no runtime; a conversation does, and says so when there is none.
|
|
91
|
-
'
|
|
80
|
+
'AssistantExample',
|
|
92
81
|
// Every character in every state, from static data: no agent at all.
|
|
93
|
-
'
|
|
82
|
+
'AssistantGalleryExample',
|
|
94
83
|
// Voice: heard in the page, the agent on the local server, the speech
|
|
95
84
|
// service named in the address.
|
|
96
85
|
'VoiceChatExample',
|
|
97
86
|
]);
|
|
98
|
-
const getExampleGroup = (id) => {
|
|
99
|
-
if (id === 'AgentspecsExample' ||
|
|
100
|
-
id.startsWith('Loop') ||
|
|
101
|
-
id === 'DecksAgent') {
|
|
102
|
-
return 'Apps';
|
|
103
|
-
}
|
|
104
|
-
if (id.startsWith('A2Ui'))
|
|
105
|
-
return 'A2UI';
|
|
106
|
-
// Agents reached over the A2A protocol: their own category, after A2UI.
|
|
107
|
-
if (id.startsWith('AgentA2A'))
|
|
108
|
-
return 'A2A';
|
|
109
|
-
if (id.startsWith('AgUi'))
|
|
110
|
-
return 'AG-UI';
|
|
111
|
-
if (id.startsWith('CopilotKit'))
|
|
112
|
-
return 'CopilotKit';
|
|
113
|
-
// Each remaining Agent* example demonstrates one capability of the
|
|
114
|
-
// runtime: checkpoints, hooks, memory, guardrails…
|
|
115
|
-
if (id.startsWith('Agent'))
|
|
116
|
-
return 'Capabilities';
|
|
117
|
-
if (id.startsWith('Chat') || id === 'VoiceChatExample')
|
|
118
|
-
return 'Chat';
|
|
119
|
-
// The document examples: the ones on the Lexical editor, and the page
|
|
120
|
-
// with a document on it.
|
|
121
|
-
if (id.startsWith('Lexical') || id.startsWith('Document'))
|
|
122
|
-
return 'Document';
|
|
123
|
-
if (id.startsWith('Notebook'))
|
|
124
|
-
return 'Notebook';
|
|
125
|
-
return 'Cell';
|
|
126
|
-
};
|
|
127
87
|
const wait = (ms) => new Promise(resolve => {
|
|
128
88
|
window.setTimeout(resolve, ms);
|
|
129
89
|
});
|
|
@@ -46,7 +46,12 @@ export declare function GalleryNotebook({ onOpen, }: {
|
|
|
46
46
|
onOpen?: () => void;
|
|
47
47
|
}): JSX.Element;
|
|
48
48
|
/**
|
|
49
|
-
* The balloon's
|
|
49
|
+
* The sample notebook as the balloon's large visual: expanded, the notebook
|
|
50
|
+
* that runs and is edited on the browser sandbox (`TeamNotebook`).
|
|
51
|
+
*/
|
|
52
|
+
export declare function galleryNotebookVisual(): import("../../chat/assistant/BalloonVisual").BalloonVisual;
|
|
53
|
+
/**
|
|
54
|
+
* The balloon's displays (T-23), one character: the history, every message listed, the
|
|
50
55
|
* current balloon with a tool line, and with a notebook given — the same
|
|
51
56
|
* read-only jupyter-react notebook as in the stage, loaded when drawn.
|
|
52
57
|
*/
|
|
@@ -7,8 +7,9 @@ import { AssistantStage } from '../../chat/assistant/AssistantStage';
|
|
|
7
7
|
import { AssistantCharactersPlugin, assistantCharactersOf, } from '../../loop/plugins/assistant-characters';
|
|
8
8
|
import { OWL_CHARACTER, OwlCharacterPlugin } from './owlCharacterPlugin';
|
|
9
9
|
import { NotebookPreview } from '../../components/teams/NotebookPreview';
|
|
10
|
+
import { notebookBalloonVisual } from '../../components/teams/TeamNotebook';
|
|
10
11
|
import { readTestSpriteCharacter } from './testSpriteCharacter';
|
|
11
|
-
import { GALLERY_POSES, GALLERY_POSE_LABELS, SAMPLE_NOTEBOOK, SAMPLE_NOTEBOOK_SAYING, sampleSaying, sampleToolLine, stateOfPose, } from './assistantGallery';
|
|
12
|
+
import { GALLERY_POSES, GALLERY_POSE_LABELS, SAMPLE_NOTEBOOK, SAMPLE_NOTEBOOK_ARTIFACT, SAMPLE_NOTEBOOK_SAYING, sampleHistory, sampleSaying, sampleToolLine, stateOfPose, } from './assistantGallery';
|
|
12
13
|
/** The plugins the gallery enables: Datalayer's characters and the owl's. */
|
|
13
14
|
const reactor = buildReactorFromPlugins([
|
|
14
15
|
AssistantCharactersPlugin,
|
|
@@ -127,6 +128,13 @@ export const GALLERY_NOTEBOOK_HEIGHT = 160;
|
|
|
127
128
|
export function GalleryNotebook({ onOpen, }) {
|
|
128
129
|
return (_jsx(NotebookPreview, { notebook: SAMPLE_NOTEBOOK, title: "Accounting\u2019s notebook", maxHeight: GALLERY_NOTEBOOK_HEIGHT, onOpen: onOpen }));
|
|
129
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* The sample notebook as the balloon's large visual: expanded, the notebook
|
|
133
|
+
* that runs and is edited on the browser sandbox (`TeamNotebook`).
|
|
134
|
+
*/
|
|
135
|
+
export function galleryNotebookVisual() {
|
|
136
|
+
return notebookBalloonVisual(SAMPLE_NOTEBOOK_ARTIFACT, 'Accounting’s notebook', 420);
|
|
137
|
+
}
|
|
130
138
|
/** One balloon display, pictured: a character with what its balloon says. */
|
|
131
139
|
function BalloonCell({ character, label, display, balloon, height, }) {
|
|
132
140
|
const stageRef = useRef(null);
|
|
@@ -147,18 +155,23 @@ function BalloonCell({ character, label, display, balloon, height, }) {
|
|
|
147
155
|
}, children: label }), _jsx(AssistantStage, { character: character.character, state: balloon.tool ? 'working' : 'speaking', size: 48, place: { position: 'absolute', left: '12px', bottom: '8px' }, stageRef: stageRef, onDragStart: () => undefined, open: false, onToggle: () => undefined, onDismiss: () => undefined, balloon: balloon, balloonDisplay: display, insist: true })] }));
|
|
148
156
|
}
|
|
149
157
|
/**
|
|
150
|
-
* The balloon's displays (T-23), one character:
|
|
158
|
+
* The balloon's displays (T-23), one character: the history, every message listed, the
|
|
151
159
|
* current balloon with a tool line, and with a notebook given — the same
|
|
152
160
|
* read-only jupyter-react notebook as in the stage, loaded when drawn.
|
|
153
161
|
*/
|
|
154
162
|
export function GalleryBalloons({ character, }) {
|
|
155
|
-
return (_jsxs(Box, { "data-gallery-balloons": "", sx: { display: 'flex', gap: 3, flexWrap: 'wrap', mt: 3 }, children: [_jsx(BalloonCell, { character: character, label: "History", display: "history", height:
|
|
163
|
+
return (_jsxs(Box, { "data-gallery-balloons": "", sx: { display: 'flex', gap: 3, flexWrap: 'wrap', mt: 3 }, children: [_jsx(BalloonCell, { character: character, label: "History", display: "history", height: 340, balloon: {
|
|
164
|
+
...sampleSaying(1),
|
|
165
|
+
history: sampleHistory(2),
|
|
166
|
+
onDismiss: () => undefined,
|
|
167
|
+
} }), _jsx(BalloonCell, { character: character, label: "Current \u00B7 tool", display: "current", height: 180, balloon: {
|
|
156
168
|
text: 'Using list_invoices…',
|
|
157
169
|
tool: sampleToolLine('running'),
|
|
158
170
|
busy: true,
|
|
159
171
|
} }), _jsx(BalloonCell, { character: character, label: "Current \u00B7 notebook", display: "current", height: GALLERY_NOTEBOOK_HEIGHT + 210, balloon: {
|
|
160
172
|
text: SAMPLE_NOTEBOOK_SAYING,
|
|
161
173
|
attachment: _jsx(GalleryNotebook, {}),
|
|
174
|
+
visual: galleryNotebookVisual(),
|
|
162
175
|
} })] }));
|
|
163
176
|
}
|
|
164
177
|
export default AssistantGalleryGrid;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { AssistantStageProps } from '../../chat/assistant/AssistantStage';
|
|
10
10
|
import { type BalloonToolLine, type ToolLinePhase } from '../../chat/assistant/toolLine';
|
|
11
|
-
import { type AssistantState, type BalloonApproval } from '../../chat/assistant/state';
|
|
11
|
+
import { type AssistantState, type BalloonApproval, type BalloonHistoryMessage } from '../../chat/assistant/state';
|
|
12
12
|
/** What the gallery poses a character in: a state, or stepped aside. */
|
|
13
13
|
export type GalleryPose = AssistantState | 'aside';
|
|
14
14
|
/** Every state, in the order an assistant lives them, then stepped aside. */
|
|
@@ -28,6 +28,12 @@ export declare function sampleSaying(index: number): {
|
|
|
28
28
|
text: string;
|
|
29
29
|
more: boolean;
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* The conversation so far, after `count` sample exchanges (wrapping), as the
|
|
33
|
+
* `history` balloon lists it: every message, the person's and the agent's,
|
|
34
|
+
* read by `balloonHistoryOf` as the floating assistant reads the chat.
|
|
35
|
+
*/
|
|
36
|
+
export declare function sampleHistory(count: number): BalloonHistoryMessage[];
|
|
31
37
|
/** The tool the gallery calls (T-23): Odoo's, as Accounting calls it. */
|
|
32
38
|
export declare const SAMPLE_TOOL = "list_invoices";
|
|
33
39
|
/** The sample tool's line, at a phase: "Using list_invoices…", "Done: …", "… failed". */
|
|
@@ -69,6 +75,45 @@ export declare const SAMPLE_NOTEBOOK: {
|
|
|
69
75
|
}[];
|
|
70
76
|
})[];
|
|
71
77
|
};
|
|
78
|
+
/** The sample notebook as a peer gives one: an A2A artifact. */
|
|
79
|
+
export declare const SAMPLE_NOTEBOOK_ARTIFACT: {
|
|
80
|
+
mediaType: string;
|
|
81
|
+
name: string;
|
|
82
|
+
filename: string;
|
|
83
|
+
data: {
|
|
84
|
+
nbformat: number;
|
|
85
|
+
nbformat_minor: number;
|
|
86
|
+
metadata: {
|
|
87
|
+
kernelspec: {
|
|
88
|
+
name: string;
|
|
89
|
+
display_name: string;
|
|
90
|
+
language: string;
|
|
91
|
+
};
|
|
92
|
+
language_info: {
|
|
93
|
+
name: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
cells: ({
|
|
97
|
+
id: string;
|
|
98
|
+
cell_type: string;
|
|
99
|
+
metadata: {};
|
|
100
|
+
source: string;
|
|
101
|
+
execution_count?: undefined;
|
|
102
|
+
outputs?: undefined;
|
|
103
|
+
} | {
|
|
104
|
+
id: string;
|
|
105
|
+
cell_type: string;
|
|
106
|
+
metadata: {};
|
|
107
|
+
execution_count: number;
|
|
108
|
+
source: string;
|
|
109
|
+
outputs: {
|
|
110
|
+
output_type: string;
|
|
111
|
+
name: string;
|
|
112
|
+
text: string;
|
|
113
|
+
}[];
|
|
114
|
+
})[];
|
|
115
|
+
};
|
|
116
|
+
};
|
|
72
117
|
/** What the gallery says with the notebook it was given. */
|
|
73
118
|
export declare const SAMPLE_NOTEBOOK_SAYING = "Here is the notebook Accounting gave: the open invoices.";
|
|
74
119
|
/** The approval the gallery waits on (T-23): answered in the balloon. */
|
|
@@ -77,7 +122,7 @@ export declare function sampleApproval(onApprove: () => void, onDeny: () => void
|
|
|
77
122
|
* The balloon for a pose: waiting holds the approval, paused says so, and
|
|
78
123
|
* any other pose says the sample's words when asked to (`saying`).
|
|
79
124
|
*/
|
|
80
|
-
export declare function balloonForPose(pose: GalleryPose, { saying, approval, tool, attachment, }: {
|
|
125
|
+
export declare function balloonForPose(pose: GalleryPose, { saying, approval, tool, attachment, history, visual, }: {
|
|
81
126
|
saying?: {
|
|
82
127
|
text: string;
|
|
83
128
|
more: boolean;
|
|
@@ -87,4 +132,8 @@ export declare function balloonForPose(pose: GalleryPose, { saying, approval, to
|
|
|
87
132
|
tool?: BalloonToolLine;
|
|
88
133
|
/** What goes with the words in a `current` balloon: a notebook. */
|
|
89
134
|
attachment?: NonNullable<AssistantStageProps['balloon']>['attachment'];
|
|
135
|
+
/** The conversation so far, listed in a `history` balloon. */
|
|
136
|
+
history?: readonly BalloonHistoryMessage[];
|
|
137
|
+
/** The large visual the attachment is the compact form of: expandable. */
|
|
138
|
+
visual?: NonNullable<AssistantStageProps['balloon']>['visual'];
|
|
90
139
|
}): AssistantStageProps['balloon'];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
import { toolLineText, } from '../../chat/assistant/toolLine';
|
|
6
|
-
import { ASSISTANT_WORDS, latestSaying, } from '../../chat/assistant/state';
|
|
6
|
+
import { ASSISTANT_WORDS, balloonHistoryOf, latestSaying, } from '../../chat/assistant/state';
|
|
7
7
|
/** Every state, in the order an assistant lives them, then stepped aside. */
|
|
8
8
|
export const GALLERY_POSES = [
|
|
9
9
|
'idle',
|
|
@@ -74,6 +74,22 @@ export function sampleSaying(index) {
|
|
|
74
74
|
}
|
|
75
75
|
return { text: saying.text, more: saying.more };
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* The conversation so far, after `count` sample exchanges (wrapping), as the
|
|
79
|
+
* `history` balloon lists it: every message, the person's and the agent's,
|
|
80
|
+
* read by `balloonHistoryOf` as the floating assistant reads the chat.
|
|
81
|
+
*/
|
|
82
|
+
export function sampleHistory(count) {
|
|
83
|
+
const items = [];
|
|
84
|
+
for (let turn = 0; turn < count; turn += 1) {
|
|
85
|
+
const conversation = SAMPLE_CONVERSATIONS[turn % SAMPLE_CONVERSATIONS.length];
|
|
86
|
+
for (const item of conversation) {
|
|
87
|
+
const message = item;
|
|
88
|
+
items.push({ ...message, id: `${turn}-${message.id}` });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return balloonHistoryOf(items);
|
|
92
|
+
}
|
|
77
93
|
/** The tool the gallery calls (T-23): Odoo's, as Accounting calls it. */
|
|
78
94
|
export const SAMPLE_TOOL = 'list_invoices';
|
|
79
95
|
/** The sample tool's line, at a phase: "Using list_invoices…", "Done: …", "… failed". */
|
|
@@ -112,6 +128,13 @@ export const SAMPLE_NOTEBOOK = {
|
|
|
112
128
|
},
|
|
113
129
|
],
|
|
114
130
|
};
|
|
131
|
+
/** The sample notebook as a peer gives one: an A2A artifact. */
|
|
132
|
+
export const SAMPLE_NOTEBOOK_ARTIFACT = {
|
|
133
|
+
mediaType: 'application/x-ipynb+json',
|
|
134
|
+
name: 'Open invoices',
|
|
135
|
+
filename: 'open-invoices.ipynb',
|
|
136
|
+
data: SAMPLE_NOTEBOOK,
|
|
137
|
+
};
|
|
115
138
|
/** What the gallery says with the notebook it was given. */
|
|
116
139
|
export const SAMPLE_NOTEBOOK_SAYING = 'Here is the notebook Accounting gave: the open invoices.';
|
|
117
140
|
/** The approval the gallery waits on (T-23): answered in the balloon. */
|
|
@@ -129,9 +152,12 @@ export function sampleApproval(onApprove, onDeny) {
|
|
|
129
152
|
* The balloon for a pose: waiting holds the approval, paused says so, and
|
|
130
153
|
* any other pose says the sample's words when asked to (`saying`).
|
|
131
154
|
*/
|
|
132
|
-
export function balloonForPose(pose, { saying, approval, tool, attachment, }) {
|
|
155
|
+
export function balloonForPose(pose, { saying, approval, tool, attachment, history, visual, }) {
|
|
156
|
+
const listed = history && history.length > 0 ? { history } : {};
|
|
157
|
+
// What goes with the words stays while a tool runs, in either display.
|
|
158
|
+
const given = attachment ? { attachment, ...(visual ? { visual } : {}) } : {};
|
|
133
159
|
if (pose === 'waiting') {
|
|
134
|
-
return { text: ASSISTANT_WORDS.approval, approval };
|
|
160
|
+
return { text: ASSISTANT_WORDS.approval, approval, ...listed };
|
|
135
161
|
}
|
|
136
162
|
if (pose === 'paused') {
|
|
137
163
|
return { text: ASSISTANT_WORDS.paused };
|
|
@@ -144,10 +170,9 @@ export function balloonForPose(pose, { saying, approval, tool, attachment, }) {
|
|
|
144
170
|
text: toolLineText(tool),
|
|
145
171
|
tool,
|
|
146
172
|
busy: tool.phase === 'running',
|
|
173
|
+
...listed,
|
|
174
|
+
...given,
|
|
147
175
|
};
|
|
148
176
|
}
|
|
149
|
-
|
|
150
|
-
return { ...saying, attachment };
|
|
151
|
-
}
|
|
152
|
-
return saying;
|
|
177
|
+
return saying ? { ...saying, ...listed, ...given } : undefined;
|
|
153
178
|
}
|