@datalayer/agent-runtimes 1.6.81 → 1.6.83
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/dist-embed/datalayer-app-main.js +41 -41
- package/lib/addresses/AgentWebPage.d.ts +36 -1
- package/lib/addresses/AgentWebPage.js +92 -3
- package/lib/chat/assistant/AssistantStage.d.ts +3 -1
- package/lib/chat/assistant/AssistantStage.js +2 -2
- package/lib/chat/assistant/BalloonParts.js +1 -1
- package/lib/chat/assistant/SpeechBalloon.d.ts +9 -3
- package/lib/chat/assistant/SpeechBalloon.js +7 -14
- package/lib/components/teams/A2ATeamGraph.d.ts +3 -1
- package/lib/components/teams/A2ATeamGraph.js +3 -2
- package/lib/components/teams/backdrops/hero.js +3 -1
- package/lib/components/teams/backdrops/nodes.js +2 -2
- package/lib/components/teams/backdrops/types.d.ts +2 -0
- package/lib/examples/pap/PapCompanyDiscoveryView.js +8 -1
- package/lib/examples/pap/PapGuidedJourneyView.js +1 -0
- package/lib/specs/apps.js +16 -10
- package/lib/specs/scenes.js +6 -6
- package/lib/specs/teams/teams.js +4 -1
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { JSX } from 'react';
|
|
2
|
+
import { type ProductCardItem } from '../apps/plugins/product-cards/read';
|
|
2
3
|
/** A JSON schema, as an operation's inputs or answer say it. */
|
|
3
4
|
export type JsonSchema = {
|
|
4
5
|
type?: string;
|
|
@@ -46,6 +47,11 @@ export interface AgentView {
|
|
|
46
47
|
};
|
|
47
48
|
operations: AgentViewOperation[];
|
|
48
49
|
declares_openapi: boolean;
|
|
50
|
+
/** The operation whose answer is shown as product cards, and the gallery's title. */
|
|
51
|
+
gallery?: {
|
|
52
|
+
operation_id: string;
|
|
53
|
+
title: string;
|
|
54
|
+
} | null;
|
|
49
55
|
protocols: string[];
|
|
50
56
|
visibility: 'public' | 'private';
|
|
51
57
|
addresses: Record<'agent' | 'mcp' | 'api' | 'web', {
|
|
@@ -68,6 +74,33 @@ export declare function readAgentView(doc?: Document): AgentView;
|
|
|
68
74
|
export declare function roleOf(view: Pick<AgentView, 'role' | 'acts_for'>): string;
|
|
69
75
|
/** Who may open it, as a person reads it. */
|
|
70
76
|
export declare function visibilityOf(visibility: AgentView['visibility']): string;
|
|
77
|
+
/** Where the page reads its gallery: its own web host, behind its access check. */
|
|
78
|
+
export declare const GALLERY_PATH = "/api/gallery";
|
|
79
|
+
export declare const GALLERY_WORDS: {
|
|
80
|
+
readonly title: "Products";
|
|
81
|
+
readonly loading: "Loading the products…";
|
|
82
|
+
readonly none: "No products to show yet.";
|
|
83
|
+
readonly failed: (detail: string) => string;
|
|
84
|
+
};
|
|
85
|
+
/** What the gallery shows: loading, its products, or why it has none. */
|
|
86
|
+
export type GalleryState = {
|
|
87
|
+
kind: 'loading';
|
|
88
|
+
} | {
|
|
89
|
+
kind: 'shown';
|
|
90
|
+
products: ProductCardItem[];
|
|
91
|
+
count: number;
|
|
92
|
+
} | {
|
|
93
|
+
kind: 'failed';
|
|
94
|
+
detail: string;
|
|
95
|
+
};
|
|
96
|
+
/** The gallery operation's answer, read for the product cards. */
|
|
97
|
+
export declare function galleryOf(answer: unknown): GalleryState;
|
|
98
|
+
/** The gallery's items, read from the page's own address. */
|
|
99
|
+
export declare function loadGallery(fetcher?: typeof fetch): Promise<GalleryState>;
|
|
100
|
+
/** The application's products, as its chat draws them. */
|
|
101
|
+
export declare function Gallery({ fetcher }: {
|
|
102
|
+
fetcher?: typeof fetch;
|
|
103
|
+
}): JSX.Element;
|
|
71
104
|
/** The four addresses, in the order they are said, each with what it is for. */
|
|
72
105
|
export declare const ADDRESS_KINDS: {
|
|
73
106
|
kind: 'agent' | 'mcp' | 'api' | 'web';
|
|
@@ -75,7 +108,9 @@ export declare const ADDRESS_KINDS: {
|
|
|
75
108
|
says: string;
|
|
76
109
|
}[];
|
|
77
110
|
/** The page: the agent, in its own theme. */
|
|
78
|
-
export declare function AgentWebPage({ view }: {
|
|
111
|
+
export declare function AgentWebPage({ view, fetcher, }: {
|
|
79
112
|
view: AgentView;
|
|
113
|
+
/** How the gallery is read; `fetch` when unsaid. */
|
|
114
|
+
fetcher?: typeof fetch;
|
|
80
115
|
}): JSX.Element;
|
|
81
116
|
export default AgentWebPage;
|
|
@@ -13,12 +13,20 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
* skills, tools), its operations with their inputs and outputs, its protocols,
|
|
14
14
|
* who may open it, and its four addresses.
|
|
15
15
|
*
|
|
16
|
+
* An application whose `openapi` names a gallery (the operation carrying
|
|
17
|
+
* `x-datalayer-gallery`) shows its products first: the page reads them at its
|
|
18
|
+
* own `/api/gallery` (the operation called with no input, behind the page's
|
|
19
|
+
* access check) and draws them with the product cards its chat draws
|
|
20
|
+
* (`ProductGrid`), skeletons while they load.
|
|
21
|
+
*
|
|
16
22
|
* @module addresses/AgentWebPage
|
|
17
23
|
*/
|
|
18
|
-
import { useState } from 'react';
|
|
24
|
+
import { useEffect, useState } from 'react';
|
|
19
25
|
import { Box, Card, useSystemColorMode } from '@datalayer/primer-addons';
|
|
20
26
|
import { Button, Heading, Label, Text } from '@primer/react';
|
|
21
27
|
import { EmbedThemed } from '../apps/embed/AppEmbed.js';
|
|
28
|
+
import { ProductGrid } from '../apps/plugins/product-cards/index.js';
|
|
29
|
+
import { readProductCards, } from '../apps/plugins/product-cards/read.js';
|
|
22
30
|
/** The script tag the runtime writes the view in. */
|
|
23
31
|
export const AGENT_VIEW_ID = 'agent-runtimes-agent-view';
|
|
24
32
|
/** The view written into the page; an error when there is none. */
|
|
@@ -45,6 +53,87 @@ export function visibilityOf(visibility) {
|
|
|
45
53
|
? 'Anyone, under its spend limit and a rate cap per caller.'
|
|
46
54
|
: 'Only the people its owner allowed: with a Datalayer API key or their sign-in.';
|
|
47
55
|
}
|
|
56
|
+
/** Where the page reads its gallery: its own web host, behind its access check. */
|
|
57
|
+
export const GALLERY_PATH = '/api/gallery';
|
|
58
|
+
export const GALLERY_WORDS = {
|
|
59
|
+
title: 'Products',
|
|
60
|
+
loading: 'Loading the products…',
|
|
61
|
+
none: 'No products to show yet.',
|
|
62
|
+
failed: (detail) => `The products could not be shown: ${detail}`,
|
|
63
|
+
};
|
|
64
|
+
/** The gallery operation's answer, read for the product cards. */
|
|
65
|
+
export function galleryOf(answer) {
|
|
66
|
+
const cards = readProductCards(answer && typeof answer === 'object'
|
|
67
|
+
? answer
|
|
68
|
+
: {});
|
|
69
|
+
return cards.kind === 'products'
|
|
70
|
+
? { kind: 'shown', products: cards.products, count: cards.count }
|
|
71
|
+
: { kind: 'shown', products: [], count: 0 };
|
|
72
|
+
}
|
|
73
|
+
/** The gallery's items, read from the page's own address. */
|
|
74
|
+
export async function loadGallery(fetcher = fetch) {
|
|
75
|
+
try {
|
|
76
|
+
const response = await fetcher(GALLERY_PATH, {
|
|
77
|
+
headers: { Accept: 'application/json' },
|
|
78
|
+
credentials: 'same-origin',
|
|
79
|
+
});
|
|
80
|
+
const body = await response.json().catch(() => ({}));
|
|
81
|
+
if (!response.ok) {
|
|
82
|
+
const detail = body && typeof body.detail === 'string'
|
|
83
|
+
? body.detail
|
|
84
|
+
: `HTTP ${response.status}`;
|
|
85
|
+
return { kind: 'failed', detail };
|
|
86
|
+
}
|
|
87
|
+
return galleryOf(body);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
return {
|
|
91
|
+
kind: 'failed',
|
|
92
|
+
detail: error instanceof Error ? error.message : String(error),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function GallerySkeleton() {
|
|
97
|
+
return (_jsx(Box, { as: "ul", "aria-busy": "true", "aria-label": GALLERY_WORDS.loading, sx: {
|
|
98
|
+
listStyle: 'none',
|
|
99
|
+
m: 0,
|
|
100
|
+
p: 0,
|
|
101
|
+
display: 'grid',
|
|
102
|
+
gap: 2,
|
|
103
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(160px, 1fr))',
|
|
104
|
+
maxWidth: 720,
|
|
105
|
+
}, children: [0, 1, 2, 3, 4, 5].map(card => (_jsxs(Card, { as: "li", border: true, shadow: "none", overflow: "hidden", "data-skeleton": true, children: [_jsx(Box, { sx: { height: 140, bg: 'neutral.muted' } }), _jsxs(Card.Content, { p: 2, children: [_jsx(Box, { sx: { height: 12, mb: 2, borderRadius: 2, bg: 'neutral.muted' } }), _jsx(Box, { sx: {
|
|
106
|
+
height: 12,
|
|
107
|
+
width: '50%',
|
|
108
|
+
borderRadius: 2,
|
|
109
|
+
bg: 'neutral.muted',
|
|
110
|
+
} })] })] }, card))) }));
|
|
111
|
+
}
|
|
112
|
+
/** The application's products, as its chat draws them. */
|
|
113
|
+
export function Gallery({ fetcher }) {
|
|
114
|
+
const [state, setState] = useState({ kind: 'loading' });
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
let current = true;
|
|
117
|
+
void loadGallery(fetcher).then(loaded => {
|
|
118
|
+
if (current) {
|
|
119
|
+
setState(loaded);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return () => {
|
|
123
|
+
current = false;
|
|
124
|
+
};
|
|
125
|
+
}, [fetcher]);
|
|
126
|
+
if (state.kind === 'loading') {
|
|
127
|
+
return _jsx(GallerySkeleton, {});
|
|
128
|
+
}
|
|
129
|
+
if (state.kind === 'failed') {
|
|
130
|
+
return (_jsx(Text, { sx: { color: 'fg.muted' }, children: GALLERY_WORDS.failed(state.detail) }));
|
|
131
|
+
}
|
|
132
|
+
if (state.products.length === 0) {
|
|
133
|
+
return _jsx(Text, { sx: { color: 'fg.muted' }, children: GALLERY_WORDS.none });
|
|
134
|
+
}
|
|
135
|
+
return _jsx(ProductGrid, { products: state.products, count: state.count });
|
|
136
|
+
}
|
|
48
137
|
/** The four addresses, in the order they are said, each with what it is for. */
|
|
49
138
|
export const ADDRESS_KINDS = [
|
|
50
139
|
{ kind: 'agent', label: 'Agent', says: 'A2A, its chat, poppy.json' },
|
|
@@ -78,7 +167,7 @@ function Section({ title, children, }) {
|
|
|
78
167
|
return (_jsxs(Box, { as: "section", sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [_jsx(Heading, { as: "h2", sx: { fontSize: 3 }, children: title }), children] }));
|
|
79
168
|
}
|
|
80
169
|
/** The page: the agent, in its own theme. */
|
|
81
|
-
export function AgentWebPage({ view }) {
|
|
170
|
+
export function AgentWebPage({ view, fetcher, }) {
|
|
82
171
|
const system = useSystemColorMode();
|
|
83
172
|
const mode = view.interface.theme?.mode;
|
|
84
173
|
const colorMode = mode === 'light' || mode === 'dark' ? mode : system;
|
|
@@ -95,7 +184,7 @@ export function AgentWebPage({ view }) {
|
|
|
95
184
|
gap: 4,
|
|
96
185
|
bg: 'canvas.default',
|
|
97
186
|
minHeight: '100vh',
|
|
98
|
-
}, children: [_jsxs(Box, { as: "header", sx: { display: 'flex', gap: 3, alignItems: 'center' }, children: [_jsx(Text, { sx: { fontSize: 6 }, "aria-hidden": true, children: view.emoji }), _jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 1 }, children: [_jsx(Heading, { as: "h1", children: view.name }), _jsx(Text, { sx: { color: 'fg.muted' }, children: roleOf(view) })] })] }), view.description ? (_jsx(Text, { sx: { fontSize: 2 }, children: view.description })) : null, view.addresses ? (_jsx(Section, { title: "Where it is", children: _jsx(Card, { sx: { p: 3, gap: 2 }, children: ADDRESS_KINDS.map(({ kind, label, says }) => (_jsx(Address, { label: label, says: says, url: view.addresses[kind].url }, kind))) }) })) : null, _jsx(Section, { title: "Who may open it", children: _jsx(Text, { children: visibilityOf(view.visibility) }) }), _jsxs(Section, { title: "What it answers", children: [!view.declares_openapi ? (_jsx(Text, { sx: { color: 'fg.muted' }, children: "It declares no operations of its own: ask it anything." })) : null, view.operations.map(operation => (_jsx(Operation, { operation: operation }, operation.operation_id)))] }), _jsx(Section, { title: "Its agent", children: _jsxs(Card, { sx: { p: 3, gap: 2 }, children: [_jsx(Text, { sx: { fontWeight: 'bold' }, children: agent.name }), agent.description ? _jsx(Text, { children: agent.description }) : null, agent.model ? (_jsxs(Text, { sx: { fontSize: 1 }, children: ["Model ", _jsx(Text, { sx: { fontFamily: 'mono' }, children: agent.model })] })) : null, [
|
|
187
|
+
}, children: [_jsxs(Box, { as: "header", sx: { display: 'flex', gap: 3, alignItems: 'center' }, children: [_jsx(Text, { sx: { fontSize: 6 }, "aria-hidden": true, children: view.emoji }), _jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 1 }, children: [_jsx(Heading, { as: "h1", children: view.name }), _jsx(Text, { sx: { color: 'fg.muted' }, children: roleOf(view) })] })] }), view.description ? (_jsx(Text, { sx: { fontSize: 2 }, children: view.description })) : null, view.gallery ? (_jsx(Section, { title: view.gallery.title || GALLERY_WORDS.title, children: _jsx(Gallery, { fetcher: fetcher }) })) : null, view.addresses ? (_jsx(Section, { title: "Where it is", children: _jsx(Card, { sx: { p: 3, gap: 2 }, children: ADDRESS_KINDS.map(({ kind, label, says }) => (_jsx(Address, { label: label, says: says, url: view.addresses[kind].url }, kind))) }) })) : null, _jsx(Section, { title: "Who may open it", children: _jsx(Text, { children: visibilityOf(view.visibility) }) }), _jsxs(Section, { title: "What it answers", children: [!view.declares_openapi ? (_jsx(Text, { sx: { color: 'fg.muted' }, children: "It declares no operations of its own: ask it anything." })) : null, view.operations.map(operation => (_jsx(Operation, { operation: operation }, operation.operation_id)))] }), _jsx(Section, { title: "Its agent", children: _jsxs(Card, { sx: { p: 3, gap: 2 }, children: [_jsx(Text, { sx: { fontWeight: 'bold' }, children: agent.name }), agent.description ? _jsx(Text, { children: agent.description }) : null, agent.model ? (_jsxs(Text, { sx: { fontSize: 1 }, children: ["Model ", _jsx(Text, { sx: { fontFamily: 'mono' }, children: agent.model })] })) : null, [
|
|
99
188
|
['MCP servers', agent.mcp_servers],
|
|
100
189
|
['Skills', agent.skills],
|
|
101
190
|
['Tools', agent.tools.map(tool => tool.name)],
|
|
@@ -133,6 +133,8 @@ export type AssistantAside = 'obstacle' | 'pointer' | undefined;
|
|
|
133
133
|
*/
|
|
134
134
|
export declare function useKeepClear(stageRef: RefObject<HTMLElement | null>, own: RefObject<HTMLElement | null> | undefined, paused: boolean): AssistantAside;
|
|
135
135
|
export interface AssistantStageProps {
|
|
136
|
+
/** Its balloon's width, fixed (`BALLOON_WIDTH`, 300, unless given). */
|
|
137
|
+
balloonWidth?: number;
|
|
136
138
|
/**
|
|
137
139
|
* The avatar: one Datalayer ships, by id (T-25), one loaded from a file
|
|
138
140
|
* (T-26), or a 3D model.
|
|
@@ -322,5 +324,5 @@ export { mouthOpening };
|
|
|
322
324
|
* `data-assistant-mouth`, each frame, without drawing the character again.
|
|
323
325
|
*/
|
|
324
326
|
export declare function useMouth(stageRef: RefObject<HTMLElement | null>, mouthLevel: (() => number) | undefined, speaking: boolean): void;
|
|
325
|
-
export declare function AssistantStage({ character, state, size, replay, place, stageRef, onDragStart, open, onToggle, onCharacterClick, onCharacterKeyDown, balloon, insist, onDismiss, ownRef, decide, mouthLevel, stayPut, dismissHidesBalloon, prompt, balloonDisplay, expandTarget, expandOnArrival, suggestions, onSuggestion, inspector, inspectAgent, conversationLabel, onBalloonDisplayChange, onStop, onNewChat, onClear, onChangeCharacter, speech, onResetPosition, about, sandbox, contextMenu, agentName, label, }: AssistantStageProps): JSX.Element;
|
|
327
|
+
export declare function AssistantStage({ balloonWidth, character, state, size, replay, place, stageRef, onDragStart, open, onToggle, onCharacterClick, onCharacterKeyDown, balloon, insist, onDismiss, ownRef, decide, mouthLevel, stayPut, dismissHidesBalloon, prompt, balloonDisplay, expandTarget, expandOnArrival, suggestions, onSuggestion, inspector, inspectAgent, conversationLabel, onBalloonDisplayChange, onStop, onNewChat, onClear, onChangeCharacter, speech, onResetPosition, about, sandbox, contextMenu, agentName, label, }: AssistantStageProps): JSX.Element;
|
|
326
328
|
export default AssistantStage;
|
|
@@ -371,7 +371,7 @@ export function useMouth(stageRef, mouthLevel, speaking) {
|
|
|
371
371
|
};
|
|
372
372
|
}, [stageRef, mouthLevel, speaking]);
|
|
373
373
|
}
|
|
374
|
-
export function AssistantStage({ character, state, size = 88, replay, place, stageRef, onDragStart, open, onToggle, onCharacterClick, onCharacterKeyDown, balloon, insist = false, onDismiss, ownRef, decide, mouthLevel, stayPut = false, dismissHidesBalloon = false, prompt, balloonDisplay = 'history', expandTarget, expandOnArrival = false, suggestions, onSuggestion, inspector, inspectAgent, conversationLabel, onBalloonDisplayChange, onStop, onNewChat, onClear, onChangeCharacter, speech, onResetPosition, about, sandbox, contextMenu, agentName, label, }) {
|
|
374
|
+
export function AssistantStage({ balloonWidth, character, state, size = 88, replay, place, stageRef, onDragStart, open, onToggle, onCharacterClick, onCharacterKeyDown, balloon, insist = false, onDismiss, ownRef, decide, mouthLevel, stayPut = false, dismissHidesBalloon = false, prompt, balloonDisplay = 'history', expandTarget, expandOnArrival = false, suggestions, onSuggestion, inspector, inspectAgent, conversationLabel, onBalloonDisplayChange, onStop, onNewChat, onClear, onChangeCharacter, speech, onResetPosition, about, sandbox, contextMenu, agentName, label, }) {
|
|
375
375
|
const chatText = useChatWords();
|
|
376
376
|
// A shipped one by id, a drawing contributed by a plugin (T-24), a
|
|
377
377
|
// character read from a file (T-26), or a 3D model.
|
|
@@ -689,7 +689,7 @@ export function AssistantStage({ character, state, size = 88, replay, place, sta
|
|
|
689
689
|
: undefined, suggestions: waitsForQuestion ? suggestions : undefined, fullText: balloon.fullText, waiting: (state === 'thinking' ||
|
|
690
690
|
state === 'working' ||
|
|
691
691
|
state === 'waiting') &&
|
|
692
|
-
!balloon.speaking, onSuggestion: onSuggestion, decide: decide, onDecisionActive: setDeciding,
|
|
692
|
+
!balloon.speaking, onSuggestion: onSuggestion, decide: decide, onDecisionActive: setDeciding, ...(balloonWidth ? { width: balloonWidth } : {}), onOpen: onToggle, above: size + 8, side: balloonSide(place).side, align: balloonSide(place).align, tailAt: size / 2 }) })), _jsxs(Box, { as: "button", type: "button", "aria-label": label ??
|
|
693
693
|
(open ? `Close the conversation with ${name}` : `Talk to ${name}`), "aria-describedby": described ? describedBy : undefined, "aria-expanded": open, "aria-haspopup": "menu", ref: characterRef, "data-assistant-figure": "", onContextMenu: (event) => {
|
|
694
694
|
event.preventDefault();
|
|
695
695
|
clearTimeout(longPress.current);
|
|
@@ -159,5 +159,5 @@ export function CurrentBalloonBody({ text, tool, busy = false, speaking = false,
|
|
|
159
159
|
}, [text, whole, onOverflow]);
|
|
160
160
|
return (_jsxs(Box, { "data-balloon-current": "", display: "flex", flexDirection: "column", gap: 1, minWidth: 0, children: [_jsx(BalloonNow, { busy: busy }), tool ? (_jsx(BalloonToolCall, { line: tool, waiting: waiting })) : text ? (_jsxs(Box
|
|
161
161
|
// Read in place, not live: `WordsAnnouncer` says the words.
|
|
162
|
-
, { "aria-busy": speaking, ref: textRef, "data-balloon-current-text": whole ? 'whole' : '', maxHeight: whole ? 240 : '5.6em', overflowY: whole ? 'auto' : undefined, overflowWrap: whole ? 'anywhere' : 'anywhere', pr: whole ? 1 : undefined, overflow: whole ? undefined : 'hidden', children: [cut ? (_jsxs(_Fragment, { children: [_jsx(Box, { "aria-hidden": "true", children: _jsx(ChatMarkdown, { density: "compact", text: text }) }), _jsx(Box, { as: "span", "data-balloon-words-whole": "", ...VISUALLY_HIDDEN, children: plainWords(fullText ?? '') })] })) : (_jsx(ChatMarkdown, { density: "compact", text: whole ? (fullText ?? text) : text })), waiting && (_jsx(Box, { as: "span", ml: 2, display: "inline-flex", children: _jsx(TypingDots, { size: 5 }) }))] })) : waiting ? (_jsx(TypingDots, { size: 6 })) : null, attachment, _jsx(WordsAnnouncer, { text: tool ? undefined : (fullText ?? text), speaking: speaking }), _jsx(ToolLineAnnouncer, { line: tool })] }));
|
|
162
|
+
, { "aria-busy": speaking, ref: textRef, "data-balloon-current-text": whole ? 'whole' : '', maxHeight: whole ? 240 : '5.6em', overflowY: whole ? 'auto' : undefined, overflowWrap: whole ? 'anywhere' : 'anywhere', pr: whole ? 1 : undefined, overflow: whole ? undefined : 'hidden', children: [cut ? (_jsxs(_Fragment, { children: [_jsx(Box, { "aria-hidden": "true", children: _jsx(ChatMarkdown, { density: "compact", text: fullText ?? text }) }), _jsx(Box, { as: "span", "data-balloon-words-whole": "", ...VISUALLY_HIDDEN, children: plainWords(fullText ?? '') })] })) : (_jsx(ChatMarkdown, { density: "compact", text: whole ? (fullText ?? text) : text })), waiting && (_jsx(Box, { as: "span", ml: 2, display: "inline-flex", children: _jsx(TypingDots, { size: 5 }) }))] })) : waiting ? (_jsx(TypingDots, { size: 6 })) : null, attachment, _jsx(WordsAnnouncer, { text: tool ? undefined : (fullText ?? text), speaking: speaking }), _jsx(ToolLineAnnouncer, { line: tool })] }));
|
|
163
163
|
}
|
|
@@ -83,8 +83,12 @@ export interface SpeechBalloonProps {
|
|
|
83
83
|
decide?: DecisionAsker;
|
|
84
84
|
/** The decision's form or answer is on screen: it stays, and is wider. */
|
|
85
85
|
onDecisionActive?: (active: boolean) => void;
|
|
86
|
-
/**
|
|
87
|
-
|
|
86
|
+
/**
|
|
87
|
+
* The balloon's width, fixed whatever it says (the user, 17 November 2026:
|
|
88
|
+
* "stable and fixed"), never wider than its container; `BALLOON_WIDTH`
|
|
89
|
+
* unless given.
|
|
90
|
+
*/
|
|
91
|
+
width?: number;
|
|
88
92
|
/** Puts the peek away: a × beside its line. Never for an approval. */
|
|
89
93
|
onDismissPeek?: () => void;
|
|
90
94
|
/**
|
|
@@ -153,5 +157,7 @@ export declare function BalloonHistoryLarge({ history, tool, attachment, }: {
|
|
|
153
157
|
tool?: BalloonToolLine;
|
|
154
158
|
attachment?: ReactNode;
|
|
155
159
|
}): JSX.Element;
|
|
156
|
-
|
|
160
|
+
/** A balloon's width unless given: room for a table, a form or a list without growing. */
|
|
161
|
+
export declare const BALLOON_WIDTH = 300;
|
|
162
|
+
export declare function SpeechBalloon({ text, more, onOpen, above, side, align, tailAt, approval, decide, onDecisionActive, width, onDismissPeek, display, tool, speaking, busy, attachment, history, onExpand, expandTitle, suggestions, onSuggestion, waiting, fullText, onExpandHistory, prompt, }: SpeechBalloonProps): JSX.Element;
|
|
157
163
|
export default SpeechBalloon;
|
|
@@ -87,7 +87,9 @@ function BalloonHistory({ history, onOpen, maxHeight = BALLOON_HISTORY_MAX_HEIGH
|
|
|
87
87
|
}, []);
|
|
88
88
|
return (_jsxs(Box, { "data-balloon-history": "", flex: 1, minWidth: 0, display: "flex", flexDirection: "column", children: [_jsx(Box, { as: "button", type: "button", "data-balloon-peek": "", "data-balloon-header": "", onClick: onOpen, m: 0, p: 0, pb: 1, border: 0, bg: "transparent", font: "inherit", textAlign: "left", cursor: "pointer", fontSize: 0, fontWeight: "semibold", color: "fg.muted", hover: { textDecoration: 'underline' }, children: conversationHeaderText(conversationCount(history), chatText) }), onExpand ? (_jsx(IconButton, { icon: ScreenFullIcon, size: "small", variant: "invisible", "aria-label": chatText.expandConversation, "data-balloon-history-expand": "", onClick: onExpand, sx: { position: 'absolute', top: '4px', right: '28px' } })) : null, _jsx(Box, { ref: listRef, role: "log", "aria-label": chatText.conversation, "data-balloon-history-list": "", maxHeight: maxHeight, overflowY: "auto", display: "flex", flexDirection: "column", pr: 1, children: _jsx(BalloonChatItems, { items: withToolCall(history, tool), waiting: waiting }) })] }));
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
/** A balloon's width unless given: room for a table, a form or a list without growing. */
|
|
91
|
+
export const BALLOON_WIDTH = 300;
|
|
92
|
+
export function SpeechBalloon({ text, more = false, onOpen, above, side = 'above', align, tailAt, approval, decide, onDecisionActive, width = BALLOON_WIDTH, onDismissPeek, display = 'history', tool, speaking = false, busy = false, attachment, history, onExpand, expandTitle, suggestions, onSuggestion, waiting = false, fullText, onExpandHistory, prompt, }) {
|
|
91
93
|
const chatText = useChatWords();
|
|
92
94
|
// *more*: the words whole, when they were cut or overflow their lines.
|
|
93
95
|
const [whole, setWhole] = useState(false);
|
|
@@ -116,24 +118,15 @@ export function SpeechBalloon({ text, more = false, onOpen, above, side = 'above
|
|
|
116
118
|
const current = display === 'current';
|
|
117
119
|
// History with messages to list: all of them, not the newest line alone.
|
|
118
120
|
const listed = !current && history && history.length > 0 ? history : null;
|
|
119
|
-
return (_jsxs(Box, { "data-speech-balloon": "", "data-balloon-display": display,
|
|
120
|
-
? 300
|
|
121
|
-
: current
|
|
122
|
-
? 260
|
|
123
|
-
: 280, px: 3, py: 2, color: "fg.default", border: "1px solid", borderRadius: "bubble", boxShadow: "shadow.medium", fontSize: 1, textAlign: "left",
|
|
121
|
+
return (_jsxs(Box, { "data-speech-balloon": "", "data-balloon-display": display, px: 3, py: 2, color: "fg.default", border: "1px solid", borderRadius: "bubble", boxShadow: "shadow.medium", fontSize: 1, textAlign: "left",
|
|
124
122
|
// Pixels, as strings: a number here is read as the theme's space
|
|
125
123
|
// scale (`-7` would be `-space[7]`, 48px).
|
|
126
124
|
bottom: side === 'above' ? `${above}px` : undefined, top: side === 'above' ? undefined : `${above}px`, sx: {
|
|
127
125
|
position: 'absolute',
|
|
128
126
|
[align]: 0,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
whole ||
|
|
133
|
-
prompt ||
|
|
134
|
-
(current && attachment)
|
|
135
|
-
? 300
|
|
136
|
-
: 'max-content',
|
|
127
|
+
// Fixed, whatever it says: never sized by its words.
|
|
128
|
+
width,
|
|
129
|
+
maxWidth: '100%',
|
|
137
130
|
bg: 'canvas.overlay',
|
|
138
131
|
// The current balloon is the agent's voice now: its accent's edge.
|
|
139
132
|
borderColor: current ? 'accent.muted' : 'border.default',
|
|
@@ -94,6 +94,8 @@ export type A2ATeamGraphProps = {
|
|
|
94
94
|
* a balloon gets at least its own. Unsaid, the backdrop's.
|
|
95
95
|
*/
|
|
96
96
|
balloonRoom?: number;
|
|
97
|
+
/** Every member's balloon width, fixed (`BALLOON_WIDTH`, 300, unless given). */
|
|
98
|
+
balloonWidth?: number;
|
|
97
99
|
/**
|
|
98
100
|
* How the stage is drawn (`SceneStageSpec.backdrop`): `studio`, the
|
|
99
101
|
* drawing every scene had first, `hero` or `plain`. `studio` when unsaid,
|
|
@@ -175,5 +177,5 @@ export declare function placeMembers(entryId: string, peerIds: readonly string[]
|
|
|
175
177
|
/** The one flow the graph reports for all its edges: asking before answering before still. */
|
|
176
178
|
export declare function flowOfAll(flows: readonly A2ATeamFlow[]): A2ATeamFlow;
|
|
177
179
|
/** Draw a team over A2A, each link moving with what travels on it. */
|
|
178
|
-
export declare function A2ATeamGraph({ entry, peer, peers: more, flow, flows, connected, label, labels, links, positions, size, calls, balloonRoom, backdrop, minHeight, selected, onSelectEdge, }: A2ATeamGraphProps): JSX.Element;
|
|
180
|
+
export declare function A2ATeamGraph({ entry, peer, peers: more, flow, flows, connected, label, labels, links, positions, size, calls, balloonRoom, balloonWidth, backdrop, minHeight, selected, onSelectEdge, }: A2ATeamGraphProps): JSX.Element;
|
|
179
181
|
export default A2ATeamGraph;
|
|
@@ -194,7 +194,7 @@ function stageRules(theme, clickable) {
|
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
196
|
/** Draw a team over A2A, each link moving with what travels on it. */
|
|
197
|
-
export function A2ATeamGraph({ entry, peer, peers: more = NO_PEERS, flow, flows, connected, label = 'A2A', labels, links, positions, size = 96, calls = [], balloonRoom, backdrop, minHeight, selected, onSelectEdge, }) {
|
|
197
|
+
export function A2ATeamGraph({ entry, peer, peers: more = NO_PEERS, flow, flows, connected, label = 'A2A', labels, links, positions, size = 96, calls = [], balloonRoom, balloonWidth, backdrop, minHeight, selected, onSelectEdge, }) {
|
|
198
198
|
// How the stage is drawn: its nodes and edges, its colours, its layout.
|
|
199
199
|
const look = sceneBackdrop(backdrop);
|
|
200
200
|
const { layout: sized, theme } = look;
|
|
@@ -340,7 +340,7 @@ export function A2ATeamGraph({ entry, peer, peers: more = NO_PEERS, flow, flows,
|
|
|
340
340
|
selectable: false,
|
|
341
341
|
// Above the edge and its label: a balloon overflows its node.
|
|
342
342
|
zIndex: 10,
|
|
343
|
-
data: { id, side, size },
|
|
343
|
+
data: { id, side, size, ...(balloonWidth ? { balloonWidth } : {}) },
|
|
344
344
|
},
|
|
345
345
|
// A member's connections move with it.
|
|
346
346
|
...connections.map((connection, at) => {
|
|
@@ -371,6 +371,7 @@ export function A2ATeamGraph({ entry, peer, peers: more = NO_PEERS, flow, flows,
|
|
|
371
371
|
CONNECTION_X,
|
|
372
372
|
CONNECTION_WIDTH,
|
|
373
373
|
NODE_WIDTH,
|
|
374
|
+
balloonWidth,
|
|
374
375
|
]);
|
|
375
376
|
// The notebook open under the graph runs on a Pyodide kernel in the page:
|
|
376
377
|
// the entry's sandbox, while it is open.
|
|
@@ -13,7 +13,9 @@ const CONNECTION_WIDTH = 88;
|
|
|
13
13
|
/** The hero's layout: faces closer together than the studio's characters, a smaller ring beside each. */
|
|
14
14
|
export const HERO_LAYOUT = {
|
|
15
15
|
nodeWidth: NODE_WIDTH,
|
|
16
|
-
|
|
16
|
+
// Room between the faces for their balloons side by side (up to 300 px
|
|
17
|
+
// each): at 200 the two balloons overlapped (the user, 17 November 2026).
|
|
18
|
+
gap: 320,
|
|
17
19
|
rowGap: 40,
|
|
18
20
|
// The face, its name and where it runs.
|
|
19
21
|
memberHeight: size => size + 50,
|
|
@@ -147,7 +147,7 @@ export function memberDetails(member, state) {
|
|
|
147
147
|
}
|
|
148
148
|
/** A member of the team, drawn in a look. */
|
|
149
149
|
export function MemberNodeBase({ data, look, }) {
|
|
150
|
-
const { id, side, size } = data;
|
|
150
|
+
const { id, side, size, balloonWidth } = data;
|
|
151
151
|
const member = useContext(Members)[id];
|
|
152
152
|
const moving = useContext(Moving);
|
|
153
153
|
const offset = moving.offsetOf(id);
|
|
@@ -230,7 +230,7 @@ export function MemberNodeBase({ data, look, }) {
|
|
|
230
230
|
? `${Math.round(offset.dx)},${Math.round(offset.dy)}`
|
|
231
231
|
: undefined, "data-member-state": persona.state, "data-member-color": member.color || undefined, style: tone ? { '--scene-member': tone } : undefined, children: [_jsx(Handle, { id: MEMBER_HANDLES.inLeft, type: "target", position: Position.Left, style: HANDLE(size), isConnectable: false }), _jsx(Handle, { id: MEMBER_HANDLES.inRight, type: "target", position: Position.Right, style: HANDLE(size), isConnectable: false }), _jsx(Handle, { id: MEMBER_HANDLES.inTop, type: "target", position: Position.Top, style: { ...HANDLE(size), top: 0 }, isConnectable: false }), _jsx(Handle, { id: MEMBER_HANDLES.inBottom, type: "target", position: Position.Bottom, style: { ...HANDLE(size), top: size }, isConnectable: false }), _jsx(Box, { width: size, height: size, position: "relative",
|
|
232
232
|
// Hovered or focused, its details peek (its card, under its words).
|
|
233
|
-
onMouseEnter: details.peekOn, onMouseLeave: details.peekOff, onFocus: details.peekOn, onBlur: details.peekOff, children: persona.away ? (_jsxs(Button, { size: "small", sx: { position: 'absolute', top: size / 2 - 16, left: -24 }, onClick: () => member.onAway?.(false), children: ["Call ", member.name, " back"] })) : (_jsx(AssistantStage, { character: look.figure(member), state: persona.state, size: size,
|
|
233
|
+
onMouseEnter: details.peekOn, onMouseLeave: details.peekOff, onFocus: details.peekOn, onBlur: details.peekOff, children: persona.away ? (_jsxs(Button, { size: "small", sx: { position: 'absolute', top: size / 2 - 16, left: -24 }, onClick: () => member.onAway?.(false), children: ["Call ", member.name, " back"] })) : (_jsx(AssistantStage, { balloonWidth: balloonWidth, character: look.figure(member), state: persona.state, size: size,
|
|
234
234
|
// In the node, not over the page; the balloon opens toward the
|
|
235
235
|
// middle of the graph: rightward from the left member.
|
|
236
236
|
place: side === 'left'
|
|
@@ -140,6 +140,8 @@ export type MemberData = {
|
|
|
140
140
|
side: 'left' | 'right';
|
|
141
141
|
/** Its figure's size, in pixels at full scale. */
|
|
142
142
|
size: number;
|
|
143
|
+
/** Its balloon's width, fixed (`BALLOON_WIDTH` unless given). */
|
|
144
|
+
balloonWidth?: number;
|
|
143
145
|
};
|
|
144
146
|
/** What a connection's node is given. */
|
|
145
147
|
export type ConnectionData = {
|
|
@@ -28,7 +28,14 @@ const sampleCompany = (domain) => ({
|
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
30
|
agent: {
|
|
31
|
-
protocols: [
|
|
31
|
+
protocols: [
|
|
32
|
+
{
|
|
33
|
+
type: 'a2a',
|
|
34
|
+
endpoint: `https://${domain}/agent`,
|
|
35
|
+
// What its agent can help with (1.0 §3.1, required).
|
|
36
|
+
description: 'Orders, exchanges and the catalogue',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
32
39
|
},
|
|
33
40
|
apis: [
|
|
34
41
|
{
|