@datalayer/agent-runtimes 1.6.62 → 1.6.64
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/chunks/ChatView-Bg-IvVbM.js +32 -0
- package/dist-embed/datalayer-app-main.js +94 -94
- package/lib/apps/agentUiPlugins.d.ts +39 -10
- package/lib/apps/agentUiPlugins.js +159 -50
- package/lib/apps/apps/AppRenderer.js +3 -1
- package/lib/apps/apps/appspec.js +22 -4
- package/lib/apps/apps/checks.js +9 -0
- package/lib/apps/core/index.d.ts +6 -0
- package/lib/apps/core/index.js +6 -0
- package/lib/apps/embed/LoopEmbed.js +1 -1
- package/lib/apps/plugins/aws-savings/index.d.ts +10 -5
- package/lib/apps/plugins/aws-savings/index.js +35 -21
- package/lib/apps/plugins/aws-savings-badge/index.d.ts +28 -0
- package/lib/apps/plugins/aws-savings-badge/index.js +58 -0
- package/lib/apps/plugins/bank-reconciliation/index.d.ts +19 -7
- package/lib/apps/plugins/bank-reconciliation/index.js +68 -63
- package/lib/apps/plugins/basket-total/index.d.ts +25 -0
- package/lib/apps/plugins/basket-total/index.js +41 -0
- package/lib/apps/plugins/chat/ChatView.js +4 -1
- package/lib/apps/plugins/earth-area/index.d.ts +27 -0
- package/lib/apps/plugins/earth-area/index.js +50 -0
- package/lib/apps/plugins/earth-index/index.d.ts +8 -3
- package/lib/apps/plugins/earth-index/index.js +39 -27
- package/lib/apps/plugins/earth-scenes/index.d.ts +8 -3
- package/lib/apps/plugins/earth-scenes/index.js +30 -31
- package/lib/apps/plugins/linkedin-link/index.d.ts +5 -4
- package/lib/apps/plugins/linkedin-link/index.js +7 -16
- package/lib/apps/plugins/odoo-context/index.d.ts +30 -0
- package/lib/apps/plugins/odoo-context/index.js +54 -0
- package/lib/apps/plugins/product-comparison/index.d.ts +7 -1
- package/lib/apps/plugins/product-comparison/index.js +37 -30
- package/lib/apps/plugins/shopping-basket/index.d.ts +19 -5
- package/lib/apps/plugins/shopping-basket/index.js +69 -24
- package/lib/apps/plugins/social-accounts/index.d.ts +10 -0
- package/lib/apps/plugins/social-accounts/index.js +51 -1
- package/lib/apps/plugins/trip-options/index.d.ts +15 -5
- package/lib/apps/plugins/trip-options/index.js +67 -21
- package/lib/apps/plugins/trip-summary/index.d.ts +26 -0
- package/lib/apps/plugins/trip-summary/index.js +59 -0
- package/lib/apps/plugins/x-budget/index.d.ts +3 -2
- package/lib/apps/plugins/x-budget/index.js +8 -17
- package/lib/apps/presets.d.ts +2 -1
- package/lib/apps/presets.js +2 -2
- package/lib/apps/toolCards/a2uiCard.d.ts +63 -0
- package/lib/apps/toolCards/a2uiCard.js +104 -0
- package/lib/apps/toolCards/chrome.d.ts +50 -0
- package/lib/apps/toolCards/chrome.js +57 -0
- package/lib/apps/toolCards/postPreview.d.ts +6 -2
- package/lib/apps/toolCards/postPreview.js +28 -18
- package/lib/apps/toolCards/toolResults.d.ts +37 -0
- package/lib/apps/toolCards/toolResults.js +85 -0
- package/lib/chat/Chat.js +47 -36
- package/lib/chat/base/ChatBase.js +2 -2
- package/lib/chat/messages/ChatMessageList.js +7 -0
- package/lib/specs/actions.js +32 -0
- package/lib/specs/agents/agents.js +1 -1
- package/lib/specs/appspecSchema.js +18 -0
- package/lib/specs/backendTools.js +29 -14
- package/lib/specs/mcpServers.js +19 -10
- package/lib/specs/skills.js +7 -3
- package/lib/specs/ui.d.ts +5 -0
- package/lib/specs/ui.js +172 -11
- package/lib/types/agentspecs.d.ts +8 -0
- package/lib/types/chat.d.ts +5 -0
- package/package.json +1 -1
- package/scripts/codegen/generate_ui.py +2 -0
- package/dist-embed/chunks/ChatView-LldnraOq.js +0 -32
|
@@ -23,11 +23,20 @@
|
|
|
23
23
|
*
|
|
24
24
|
* @module apps/agentUiPlugins
|
|
25
25
|
*/
|
|
26
|
+
import type { ComponentType } from 'react';
|
|
26
27
|
import type { PluginRef } from '@datalayer/reactor';
|
|
28
|
+
import type { UiChoice } from '../types/agentspecs';
|
|
29
|
+
import { type ChromeComponentProps, type ChromePlacement, type UiPlacement } from './toolCards/chrome';
|
|
30
|
+
export type { UiPlacement, ChromePlacement } from './toolCards/chrome';
|
|
27
31
|
export type AgentUiPlugin = {
|
|
28
|
-
plugin: PluginRef;
|
|
29
32
|
/** Whether it needs the person's own connection: kept from a visitor. */
|
|
30
33
|
needsConnection: boolean;
|
|
34
|
+
/** Its card in the conversation, when it has one. */
|
|
35
|
+
message?: PluginRef;
|
|
36
|
+
/** Its plugin for a chrome placement, when it has one (a Loop workspace). */
|
|
37
|
+
chrome?: (placement: ChromePlacement) => PluginRef;
|
|
38
|
+
/** What it draws in the chat's chrome (`Chat`, outside a Loop workspace). */
|
|
39
|
+
Chrome?: ComponentType<ChromeComponentProps>;
|
|
31
40
|
};
|
|
32
41
|
/** Each agent UI plugin, by its UI spec's id. */
|
|
33
42
|
export declare const AGENT_UI_PLUGINS: Readonly<Record<string, AgentUiPlugin>>;
|
|
@@ -37,6 +46,14 @@ export declare const AGENT_UI_PLUGINS: Readonly<Record<string, AgentUiPlugin>>;
|
|
|
37
46
|
* workspace and by `Chat` itself (its button) once a spec brings it.
|
|
38
47
|
*/
|
|
39
48
|
export declare const PRESET_UI: Set<string>;
|
|
49
|
+
/** A UI the chat injects, where it goes. */
|
|
50
|
+
export type AgentUiChoice = {
|
|
51
|
+
plugin: string;
|
|
52
|
+
placement: UiPlacement;
|
|
53
|
+
renderer?: string;
|
|
54
|
+
};
|
|
55
|
+
/** Where a UI goes: its declaration's placement, else its spec's first, else a message. */
|
|
56
|
+
export declare function placementOf(choice: UiChoice): UiPlacement;
|
|
40
57
|
/** What the chat knows of the agent's components while it runs. */
|
|
41
58
|
export type AgentUiComponents = {
|
|
42
59
|
/** The MCP servers running, by id; unsaid, the spec's, but those left out. */
|
|
@@ -47,20 +64,32 @@ export type AgentUiComponents = {
|
|
|
47
64
|
leftOut?: readonly string[];
|
|
48
65
|
};
|
|
49
66
|
/**
|
|
50
|
-
* The chat's UI,
|
|
51
|
-
* the mcp and skills to define a list of ui that will also be
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
67
|
+
* The chat's UI, each where it goes (the user, 15 November 2026: "Add the
|
|
68
|
+
* ability for the mcp and skills to define a list of ui that will also be
|
|
69
|
+
* injected", then "make sure ui can be used to be injected in the chat
|
|
70
|
+
* itself (toolbar, header...) or as chat message (a2ui)"): the agent's own
|
|
71
|
+
* `ui`, then the `ui` of each MCP server running, of each skill enabled, of
|
|
72
|
+
* each backend tool it carries — each plugin once, at the first placement
|
|
73
|
+
* named. An optional server or skill left out brings none.
|
|
55
74
|
*/
|
|
75
|
+
export declare function agentUiChoicesOf(specId: string | undefined, components?: AgentUiComponents): AgentUiChoice[];
|
|
76
|
+
/** The chat's UI, by id, in order (`agentUiChoicesOf` without the placements). */
|
|
56
77
|
export declare function agentUiIdsOf(specId: string | undefined, components?: AgentUiComponents): string[];
|
|
57
78
|
/** The UI plugin ids of an agent spec: its own and its components'. */
|
|
58
79
|
export declare function uiPluginIdsOfSpec(specId: string | undefined): string[];
|
|
59
80
|
/**
|
|
60
|
-
* The
|
|
61
|
-
*
|
|
62
|
-
*
|
|
81
|
+
* The Reactor plugins of these UIs, each once, in the order named, each for
|
|
82
|
+
* its placement: a message UI's card plugin, a chrome UI's plugin in its
|
|
83
|
+
* placement's slot. Ids the preset mounts anyway (`chat`, `a2ui-surface`…),
|
|
84
|
+
* unknown, or placed where the chat has no slot (`panel`) are passed over.
|
|
85
|
+
* For an anonymous visitor, only those that need no connection.
|
|
63
86
|
*/
|
|
64
|
-
export declare function agentUiPluginsFor(
|
|
87
|
+
export declare function agentUiPluginsFor(given: ReadonlyArray<string | UiChoice | AgentUiChoice> | undefined, options?: {
|
|
65
88
|
anonymous?: boolean;
|
|
66
89
|
}): PluginRef[];
|
|
90
|
+
/** The chrome UIs of these choices, by placement, for a `Chat` to draw. */
|
|
91
|
+
export declare function agentUiChromeOf(given: ReadonlyArray<string | UiChoice | AgentUiChoice> | undefined, options?: {
|
|
92
|
+
anonymous?: boolean;
|
|
93
|
+
}): Record<ChromePlacement, string[]>;
|
|
94
|
+
/** The plugin of a UI at its default placement: what its UI spec says it registers. */
|
|
95
|
+
export declare function defaultPluginOf(id: string): PluginRef | undefined;
|
|
@@ -4,65 +4,111 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { AGENTSPECS } from '../specs/agents/index.js';
|
|
6
6
|
import { getSkillSpec } from '../specs/skills.js';
|
|
7
|
+
import { UI_CATALOGUE } from '../specs/ui.js';
|
|
8
|
+
import { CHROME_SLOTS, isChromePlacement, } from './toolCards/chrome.js';
|
|
7
9
|
import { AwsSavingsPlugin } from './plugins/aws-savings/index.js';
|
|
10
|
+
import { AwsSavingsBadge, awsSavingsBadgePlugin, } from './plugins/aws-savings-badge/index.js';
|
|
8
11
|
import { BankReconciliationPlugin } from './plugins/bank-reconciliation/index.js';
|
|
12
|
+
import { BasketTotalChip, basketTotalPlugin } from './plugins/basket-total/index.js';
|
|
9
13
|
import { BlueskyPostPreviewPlugin } from './plugins/bluesky-post-preview/index.js';
|
|
14
|
+
import { EarthAreaChip, earthAreaPlugin } from './plugins/earth-area/index.js';
|
|
10
15
|
import { EarthIndexPlugin } from './plugins/earth-index/index.js';
|
|
11
16
|
import { EarthScenesPlugin } from './plugins/earth-scenes/index.js';
|
|
12
|
-
import {
|
|
17
|
+
import { LinkedInLinkButton, linkedInLinkPlugin, } from './plugins/linkedin-link/index.js';
|
|
13
18
|
import { LinkedInPostPreviewPlugin } from './plugins/linkedin-post-preview/index.js';
|
|
19
|
+
import { OdooContextChip, odooContextPlugin } from './plugins/odoo-context/index.js';
|
|
14
20
|
import { PapPurchasePlugin } from './plugins/pap-purchase/index.js';
|
|
15
21
|
import { ProductComparisonPlugin } from './plugins/product-comparison/index.js';
|
|
16
22
|
import { ShoppingBasketPlugin } from './plugins/shopping-basket/index.js';
|
|
17
|
-
import {
|
|
23
|
+
import { SocialAccountsChips, SocialAccountsMessagePlugin, socialAccountsPlugin, } from './plugins/social-accounts/index.js';
|
|
18
24
|
import { StripeCheckoutPlugin } from './plugins/stripe-checkout/index.js';
|
|
19
25
|
import { TrialBalancePlugin } from './plugins/trial-balance/index.js';
|
|
20
26
|
import { TripBudgetPlugin } from './plugins/trip-budget/index.js';
|
|
21
27
|
import { TripItineraryPlugin } from './plugins/trip-itinerary/index.js';
|
|
22
28
|
import { TripOptionsPlugin } from './plugins/trip-options/index.js';
|
|
29
|
+
import { TripSummaryChip, tripSummaryPlugin } from './plugins/trip-summary/index.js';
|
|
23
30
|
import { VatSummaryPlugin } from './plugins/vat-summary/index.js';
|
|
24
|
-
import {
|
|
31
|
+
import { XBudgetChip } from './plugins/x-budget/XBudgetChip.js';
|
|
32
|
+
import { xBudgetPlugin } from './plugins/x-budget/index.js';
|
|
25
33
|
import { XPostPreviewPlugin } from './plugins/x-post-preview/index.js';
|
|
26
34
|
/** Each agent UI plugin, by its UI spec's id. */
|
|
27
35
|
export const AGENT_UI_PLUGINS = {
|
|
28
36
|
// The Marketer.
|
|
29
|
-
'social-accounts': {
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
'social-accounts': {
|
|
38
|
+
needsConnection: true,
|
|
39
|
+
chrome: socialAccountsPlugin,
|
|
40
|
+
Chrome: SocialAccountsChips,
|
|
41
|
+
message: SocialAccountsMessagePlugin,
|
|
42
|
+
},
|
|
43
|
+
'x-budget': {
|
|
44
|
+
needsConnection: true,
|
|
45
|
+
chrome: xBudgetPlugin,
|
|
46
|
+
Chrome: () => XBudgetChip({}),
|
|
47
|
+
},
|
|
48
|
+
'x-post-preview': { needsConnection: true, message: XPostPreviewPlugin },
|
|
32
49
|
'bluesky-post-preview': {
|
|
33
|
-
plugin: BlueskyPostPreviewPlugin,
|
|
34
50
|
needsConnection: true,
|
|
51
|
+
message: BlueskyPostPreviewPlugin,
|
|
35
52
|
},
|
|
36
53
|
'linkedin-post-preview': {
|
|
37
|
-
plugin: LinkedInPostPreviewPlugin,
|
|
38
54
|
needsConnection: true,
|
|
55
|
+
message: LinkedInPostPreviewPlugin,
|
|
56
|
+
},
|
|
57
|
+
'linkedin-link': {
|
|
58
|
+
needsConnection: true,
|
|
59
|
+
chrome: linkedInLinkPlugin,
|
|
60
|
+
Chrome: () => LinkedInLinkButton({}),
|
|
39
61
|
},
|
|
40
|
-
'linkedin-link': { plugin: LinkedInLinkPlugin, needsConnection: true },
|
|
41
|
-
// Stripe (test mode).
|
|
42
|
-
'stripe-checkout': { plugin: StripeCheckoutPlugin, needsConnection: true },
|
|
43
62
|
// The Shopper.
|
|
44
63
|
'product-comparison': {
|
|
45
|
-
plugin: ProductComparisonPlugin,
|
|
46
64
|
needsConnection: false,
|
|
65
|
+
message: ProductComparisonPlugin,
|
|
66
|
+
},
|
|
67
|
+
'shopping-basket': { needsConnection: false, message: ShoppingBasketPlugin },
|
|
68
|
+
'basket-total': {
|
|
69
|
+
needsConnection: false,
|
|
70
|
+
chrome: basketTotalPlugin,
|
|
71
|
+
Chrome: BasketTotalChip,
|
|
47
72
|
},
|
|
48
|
-
'
|
|
49
|
-
'pap-purchase': { plugin: PapPurchasePlugin, needsConnection: true },
|
|
73
|
+
'pap-purchase': { needsConnection: true, message: PapPurchasePlugin },
|
|
50
74
|
// The Accountant.
|
|
51
75
|
'bank-reconciliation': {
|
|
52
|
-
plugin: BankReconciliationPlugin,
|
|
53
76
|
needsConnection: false,
|
|
77
|
+
message: BankReconciliationPlugin,
|
|
78
|
+
},
|
|
79
|
+
'trial-balance': { needsConnection: false, message: TrialBalancePlugin },
|
|
80
|
+
'vat-summary': { needsConnection: false, message: VatSummaryPlugin },
|
|
81
|
+
'odoo-context': {
|
|
82
|
+
needsConnection: false,
|
|
83
|
+
chrome: odooContextPlugin,
|
|
84
|
+
Chrome: OdooContextChip,
|
|
54
85
|
},
|
|
55
|
-
'trial-balance': { plugin: TrialBalancePlugin, needsConnection: false },
|
|
56
|
-
'vat-summary': { plugin: VatSummaryPlugin, needsConnection: false },
|
|
57
86
|
// The Voyager.
|
|
58
|
-
'trip-options': {
|
|
59
|
-
'trip-itinerary': {
|
|
60
|
-
'trip-budget': {
|
|
87
|
+
'trip-options': { needsConnection: false, message: TripOptionsPlugin },
|
|
88
|
+
'trip-itinerary': { needsConnection: false, message: TripItineraryPlugin },
|
|
89
|
+
'trip-budget': { needsConnection: false, message: TripBudgetPlugin },
|
|
90
|
+
'trip-summary': {
|
|
91
|
+
needsConnection: false,
|
|
92
|
+
chrome: tripSummaryPlugin,
|
|
93
|
+
Chrome: TripSummaryChip,
|
|
94
|
+
},
|
|
61
95
|
// Terra.
|
|
62
|
-
'earth-scenes': {
|
|
63
|
-
'earth-index': {
|
|
96
|
+
'earth-scenes': { needsConnection: false, message: EarthScenesPlugin },
|
|
97
|
+
'earth-index': { needsConnection: false, message: EarthIndexPlugin },
|
|
98
|
+
'earth-area': {
|
|
99
|
+
needsConnection: false,
|
|
100
|
+
chrome: earthAreaPlugin,
|
|
101
|
+
Chrome: EarthAreaChip,
|
|
102
|
+
},
|
|
64
103
|
// The Steward for AWS.
|
|
65
|
-
'aws-savings': {
|
|
104
|
+
'aws-savings': { needsConnection: false, message: AwsSavingsPlugin },
|
|
105
|
+
'aws-savings-badge': {
|
|
106
|
+
needsConnection: false,
|
|
107
|
+
chrome: awsSavingsBadgePlugin,
|
|
108
|
+
Chrome: AwsSavingsBadge,
|
|
109
|
+
},
|
|
110
|
+
// Stripe (test mode).
|
|
111
|
+
'stripe-checkout': { needsConnection: true, message: StripeCheckoutPlugin },
|
|
66
112
|
};
|
|
67
113
|
/**
|
|
68
114
|
* UI the preset mounts in every chat, which a spec may still name: never
|
|
@@ -75,20 +121,23 @@ export const PRESET_UI = new Set([
|
|
|
75
121
|
'pap-sign-in',
|
|
76
122
|
'browser-session',
|
|
77
123
|
]);
|
|
78
|
-
/**
|
|
79
|
-
function
|
|
80
|
-
return
|
|
124
|
+
/** Where a UI goes: its declaration's placement, else its spec's first, else a message. */
|
|
125
|
+
export function placementOf(choice) {
|
|
126
|
+
return (choice.placement ??
|
|
127
|
+
UI_CATALOGUE[choice.plugin]?.placements?.[0] ??
|
|
128
|
+
'message');
|
|
81
129
|
}
|
|
82
|
-
const pluginsOf = (choices) => (choices ?? []).map(choice => choice.plugin);
|
|
83
130
|
const bare = (id) => id.split(':')[0];
|
|
84
131
|
/**
|
|
85
|
-
* The chat's UI,
|
|
86
|
-
* the mcp and skills to define a list of ui that will also be
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
132
|
+
* The chat's UI, each where it goes (the user, 15 November 2026: "Add the
|
|
133
|
+
* ability for the mcp and skills to define a list of ui that will also be
|
|
134
|
+
* injected", then "make sure ui can be used to be injected in the chat
|
|
135
|
+
* itself (toolbar, header...) or as chat message (a2ui)"): the agent's own
|
|
136
|
+
* `ui`, then the `ui` of each MCP server running, of each skill enabled, of
|
|
137
|
+
* each backend tool it carries — each plugin once, at the first placement
|
|
138
|
+
* named. An optional server or skill left out brings none.
|
|
90
139
|
*/
|
|
91
|
-
export function
|
|
140
|
+
export function agentUiChoicesOf(specId, components = {}) {
|
|
92
141
|
// By its id, with or without its version (`worker-marketer:0.0.1`).
|
|
93
142
|
const spec = specId
|
|
94
143
|
? (AGENTSPECS[specId] ?? AGENTSPECS[bare(specId)])
|
|
@@ -109,36 +158,96 @@ export function agentUiIdsOf(specId, components = {}) {
|
|
|
109
158
|
const skills = (spec.skills ?? []).filter(skill => skill &&
|
|
110
159
|
!leftOut.has(skill.id) &&
|
|
111
160
|
(enabledSkills === undefined || enabledSkills.has(skill.id)));
|
|
112
|
-
|
|
113
|
-
...
|
|
114
|
-
...servers.flatMap(server =>
|
|
115
|
-
...skills.flatMap(skill =>
|
|
116
|
-
...(spec.backendTools ?? [])
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
]
|
|
161
|
+
const named = [
|
|
162
|
+
...(spec.ui ?? []),
|
|
163
|
+
...servers.flatMap(server => server.ui ?? []),
|
|
164
|
+
...skills.flatMap(skill => getSkillSpec(skill.id)?.ui ?? []),
|
|
165
|
+
...(spec.backendTools ?? []).filter(Boolean).flatMap(tool => tool.ui ?? []),
|
|
166
|
+
];
|
|
167
|
+
const seen = new Set();
|
|
168
|
+
const choices = [];
|
|
169
|
+
for (const choice of named) {
|
|
170
|
+
if (seen.has(choice.plugin)) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
seen.add(choice.plugin);
|
|
174
|
+
choices.push({
|
|
175
|
+
plugin: choice.plugin,
|
|
176
|
+
placement: placementOf(choice),
|
|
177
|
+
...(choice.renderer ? { renderer: choice.renderer } : {}),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return choices;
|
|
181
|
+
}
|
|
182
|
+
/** The chat's UI, by id, in order (`agentUiChoicesOf` without the placements). */
|
|
183
|
+
export function agentUiIdsOf(specId, components = {}) {
|
|
184
|
+
return agentUiChoicesOf(specId, components).map(choice => choice.plugin);
|
|
120
185
|
}
|
|
121
186
|
/** The UI plugin ids of an agent spec: its own and its components'. */
|
|
122
187
|
export function uiPluginIdsOfSpec(specId) {
|
|
123
188
|
return agentUiIdsOf(specId);
|
|
124
189
|
}
|
|
190
|
+
const asChoice = (given) => typeof given === 'string'
|
|
191
|
+
? { plugin: given, placement: placementOf({ plugin: given }) }
|
|
192
|
+
: { ...given, placement: placementOf(given) };
|
|
125
193
|
/**
|
|
126
|
-
* The
|
|
127
|
-
*
|
|
128
|
-
*
|
|
194
|
+
* The Reactor plugins of these UIs, each once, in the order named, each for
|
|
195
|
+
* its placement: a message UI's card plugin, a chrome UI's plugin in its
|
|
196
|
+
* placement's slot. Ids the preset mounts anyway (`chat`, `a2ui-surface`…),
|
|
197
|
+
* unknown, or placed where the chat has no slot (`panel`) are passed over.
|
|
198
|
+
* For an anonymous visitor, only those that need no connection.
|
|
129
199
|
*/
|
|
130
|
-
export function agentUiPluginsFor(
|
|
200
|
+
export function agentUiPluginsFor(given, options = {}) {
|
|
131
201
|
const seen = new Set();
|
|
132
202
|
const plugins = [];
|
|
133
|
-
for (const
|
|
134
|
-
const entry = AGENT_UI_PLUGINS[
|
|
203
|
+
for (const choice of (given ?? []).map(asChoice)) {
|
|
204
|
+
const entry = AGENT_UI_PLUGINS[choice.plugin];
|
|
135
205
|
if (!entry ||
|
|
136
|
-
seen.has(
|
|
206
|
+
seen.has(choice.plugin) ||
|
|
137
207
|
(options.anonymous && entry.needsConnection)) {
|
|
138
208
|
continue;
|
|
139
209
|
}
|
|
140
|
-
|
|
141
|
-
|
|
210
|
+
let plugin;
|
|
211
|
+
if (choice.placement === 'message') {
|
|
212
|
+
plugin = entry.message;
|
|
213
|
+
}
|
|
214
|
+
else if (isChromePlacement(choice.placement) &&
|
|
215
|
+
CHROME_SLOTS[choice.placement]) {
|
|
216
|
+
plugin = entry.chrome?.(choice.placement);
|
|
217
|
+
}
|
|
218
|
+
if (plugin) {
|
|
219
|
+
seen.add(choice.plugin);
|
|
220
|
+
plugins.push(plugin);
|
|
221
|
+
}
|
|
142
222
|
}
|
|
143
223
|
return plugins;
|
|
144
224
|
}
|
|
225
|
+
/** The chrome UIs of these choices, by placement, for a `Chat` to draw. */
|
|
226
|
+
export function agentUiChromeOf(given, options = {}) {
|
|
227
|
+
const placed = {
|
|
228
|
+
header: [],
|
|
229
|
+
toolbar: [],
|
|
230
|
+
footer: [],
|
|
231
|
+
banner: [],
|
|
232
|
+
panel: [],
|
|
233
|
+
};
|
|
234
|
+
for (const choice of (given ?? []).map(asChoice)) {
|
|
235
|
+
if (!isChromePlacement(choice.placement)) {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
const entry = AGENT_UI_PLUGINS[choice.plugin];
|
|
239
|
+
const preset = PRESET_UI.has(choice.plugin);
|
|
240
|
+
if ((!entry?.Chrome && !preset) ||
|
|
241
|
+
(options.anonymous && (entry?.needsConnection ?? true))) {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (!placed[choice.placement].includes(choice.plugin)) {
|
|
245
|
+
placed[choice.placement].push(choice.plugin);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return placed;
|
|
249
|
+
}
|
|
250
|
+
/** The plugin of a UI at its default placement: what its UI spec says it registers. */
|
|
251
|
+
export function defaultPluginOf(id) {
|
|
252
|
+
return agentUiPluginsFor([id])[0];
|
|
253
|
+
}
|
|
@@ -282,7 +282,9 @@ export function appPreset(app, options = {}) {
|
|
|
282
282
|
// Its agent's own UI plugins, as its `ui` names them (the Marketer's
|
|
283
283
|
// post previews, the Shopper's basket…): to a visitor, only those
|
|
284
284
|
// that need no connection of theirs.
|
|
285
|
-
...agentUiPluginsFor(app.ui
|
|
285
|
+
...agentUiPluginsFor(app.ui, {
|
|
286
|
+
anonymous: options.kept?.visitor ?? false,
|
|
287
|
+
}),
|
|
286
288
|
],
|
|
287
289
|
workspace: appLayoutOptions(app),
|
|
288
290
|
};
|
package/lib/apps/apps/appspec.js
CHANGED
|
@@ -173,6 +173,9 @@ const uiChoices = (value) => Array.isArray(value)
|
|
|
173
173
|
? value.filter(isData).map(item => ({
|
|
174
174
|
plugin: text(item.plugin),
|
|
175
175
|
...(text(item.renderer) ? { renderer: text(item.renderer) } : {}),
|
|
176
|
+
...(text(item.placement)
|
|
177
|
+
? { placement: text(item.placement) }
|
|
178
|
+
: {}),
|
|
176
179
|
}))
|
|
177
180
|
: [];
|
|
178
181
|
/**
|
|
@@ -347,6 +350,8 @@ function parseConnection(data) {
|
|
|
347
350
|
access: oneOf(data.access, ['read', 'write'], 'read'),
|
|
348
351
|
as: oneOf(data.as, ['owner', 'user'], 'owner'),
|
|
349
352
|
only: texts(data.only),
|
|
353
|
+
// Optional as its agent says (agentspecs 0.0.189): it starts without it.
|
|
354
|
+
optional: data.optional === true,
|
|
350
355
|
};
|
|
351
356
|
}
|
|
352
357
|
/** The Personal Agent Protocol profiles Datalayer speaks, as agentspecs' `PAP_PROFILES`. */
|
|
@@ -1280,6 +1285,15 @@ export function uiProblems(app) {
|
|
|
1280
1285
|
: ''));
|
|
1281
1286
|
continue;
|
|
1282
1287
|
}
|
|
1288
|
+
if (choice.placement !== undefined) {
|
|
1289
|
+
const allowed = spec.placements ?? [];
|
|
1290
|
+
if (allowed.length === 0) {
|
|
1291
|
+
problems.push(`The UI plugin ${spec.name} ('${id}') has no place in the chat: it takes no \`placement\`.`);
|
|
1292
|
+
}
|
|
1293
|
+
else if (!allowed.includes(choice.placement)) {
|
|
1294
|
+
problems.push(`The UI plugin ${spec.name} ('${id}') does not go in the chat's ${choice.placement}: in its ${allowed.join(', ')} only.`);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1283
1297
|
if (choice.renderer === undefined) {
|
|
1284
1298
|
continue;
|
|
1285
1299
|
}
|
|
@@ -1609,11 +1623,15 @@ export function dumpAppspec(app) {
|
|
|
1609
1623
|
.text('server', connection.server, '\u0000')
|
|
1610
1624
|
.value('access', connection.access, 'read')
|
|
1611
1625
|
.value('as', connection.as, 'owner')
|
|
1612
|
-
.list('only', connection.only)
|
|
1626
|
+
.list('only', connection.only)
|
|
1627
|
+
.value('optional', connection.optional ?? false, false)
|
|
1628
|
+
.data))
|
|
1613
1629
|
.list('protocols', app.protocols)
|
|
1614
|
-
.list('ui', app.ui.map(choice =>
|
|
1615
|
-
|
|
1616
|
-
|
|
1630
|
+
.list('ui', app.ui.map(choice => ({
|
|
1631
|
+
plugin: choice.plugin,
|
|
1632
|
+
...(choice.renderer ? { renderer: choice.renderer } : {}),
|
|
1633
|
+
...(choice.placement ? { placement: choice.placement } : {}),
|
|
1634
|
+
})))
|
|
1617
1635
|
.part('pap', dumpPap(app.pap))
|
|
1618
1636
|
.part('pact', dumpPact(app.pact))
|
|
1619
1637
|
.part('commerce', dumpCommerce(app.commerce))
|
package/lib/apps/apps/checks.js
CHANGED
|
@@ -460,10 +460,17 @@ function referenceProblems(app, organizationFrames) {
|
|
|
460
460
|
problems.push(`Its organization has no context named “${ref}”.`);
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
|
+
// An optional connection follows its agent's rule (agentspecs 0.0.189): the
|
|
464
|
+
// agent starts without that server, and its groups say which one at least
|
|
465
|
+
// it needs; only a server the agent says optional may be.
|
|
466
|
+
const agentOptional = new Set((agent?.optional?.mcpServers ?? []).map(idOf));
|
|
463
467
|
for (const connection of app.connections) {
|
|
464
468
|
if (!own(MCP_SERVER_LIBRARY, idOf(connection.server))) {
|
|
465
469
|
missing('MCP server', connection.server);
|
|
466
470
|
}
|
|
471
|
+
if (connection.optional && !agentOptional.has(idOf(connection.server))) {
|
|
472
|
+
problems.push(`The connection “${connection.server}” is optional, and its agent does not start without it: only a server the agent says optional may be.`);
|
|
473
|
+
}
|
|
467
474
|
}
|
|
468
475
|
for (const ref of app.skills) {
|
|
469
476
|
if (!getSkillSpec(idOf(ref)))
|
|
@@ -855,6 +862,8 @@ export function documentShapeProblems(document) {
|
|
|
855
862
|
oneOf(item.access, ENUMS.access, `${where}.access`);
|
|
856
863
|
oneOf(item.as, ENUMS.as, `${where}.as`);
|
|
857
864
|
texts(item.only, `${where}.only`);
|
|
865
|
+
if (item.optional !== undefined && typeof item.optional !== 'boolean')
|
|
866
|
+
at(`${where}.optional`, 'is true or false');
|
|
858
867
|
});
|
|
859
868
|
records(d.rules, 'rules', (item, where) => {
|
|
860
869
|
required(item, 'action', where);
|
package/lib/apps/core/index.d.ts
CHANGED
|
@@ -1000,6 +1000,12 @@ export declare const LoopSlots: {
|
|
|
1000
1000
|
* before it draws anything, so an unfilled slot costs nothing.
|
|
1001
1001
|
*/
|
|
1002
1002
|
readonly chatHeader: "loop.chatHeader";
|
|
1003
|
+
/**
|
|
1004
|
+
* Above the conversation, under the chat's title bar: a band, as the
|
|
1005
|
+
* anonymous preview's box stands (the `banner` placement of an agent's UI,
|
|
1006
|
+
* 15 November 2026: *Link LinkedIn in Settings*). Empty, nothing drawn.
|
|
1007
|
+
*/
|
|
1008
|
+
readonly chatBanner: "loop.chatBanner";
|
|
1003
1009
|
/** Buttons beside the prompt. */
|
|
1004
1010
|
readonly promptAction: "loop.promptAction";
|
|
1005
1011
|
/**
|
package/lib/apps/core/index.js
CHANGED
|
@@ -305,6 +305,12 @@ export const LoopSlots = {
|
|
|
305
305
|
* before it draws anything, so an unfilled slot costs nothing.
|
|
306
306
|
*/
|
|
307
307
|
chatHeader: 'loop.chatHeader',
|
|
308
|
+
/**
|
|
309
|
+
* Above the conversation, under the chat's title bar: a band, as the
|
|
310
|
+
* anonymous preview's box stands (the `banner` placement of an agent's UI,
|
|
311
|
+
* 15 November 2026: *Link LinkedIn in Settings*). Empty, nothing drawn.
|
|
312
|
+
*/
|
|
313
|
+
chatBanner: 'loop.chatBanner',
|
|
308
314
|
/** Buttons beside the prompt. */
|
|
309
315
|
promptAction: 'loop.promptAction',
|
|
310
316
|
/**
|
|
@@ -97,7 +97,7 @@ export function LoopEmbed({ agentId = '', showHeader = false, chatHeaderActions,
|
|
|
97
97
|
JSON.stringify(preset.datalayerVisitors ?? null),
|
|
98
98
|
preset.datalayerKept?.url,
|
|
99
99
|
// The agent's own UI plugins, by their ids.
|
|
100
|
-
(preset.uiPlugins ?? [])
|
|
100
|
+
JSON.stringify(preset.uiPlugins ?? []),
|
|
101
101
|
preset.embedToken,
|
|
102
102
|
preset.defaultEditor,
|
|
103
103
|
preset.showViewSelector,
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@datalayer/loop-plugin-aws-savings` — the Steward's savings, largest
|
|
3
|
-
* first
|
|
4
|
-
* whose estimate it is, its state,
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* first, as a message drawn by the A2UI renderer: each finding with its
|
|
4
|
+
* resource, the estimated monthly saving and whose estimate it is, its state,
|
|
5
|
+
* and the reads it rests on; their sum at the top. Draws
|
|
6
|
+
* `list_recommendations`, which the Steward ends a scan with. Each
|
|
7
|
+
* recommendation's own card (Approve, Dismiss) is the A2UI surface
|
|
8
|
+
* `record_recommendation` draws (`a2ui-surface`).
|
|
8
9
|
*
|
|
9
10
|
* @module apps/plugins/aws-savings
|
|
10
11
|
*/
|
|
11
12
|
import type { JSX } from 'react';
|
|
12
13
|
import type { ToolCallRenderContext } from '../../../types/chat';
|
|
14
|
+
import { type CardSpec } from '../../toolCards/a2uiCard';
|
|
15
|
+
import { type Savings } from './read';
|
|
13
16
|
export declare const AWS_SAVINGS_PLUGIN_NAME = "@datalayer/loop-plugin-aws-savings";
|
|
14
17
|
export declare const AWS_SAVINGS_WORDS: {
|
|
15
18
|
readonly title: "Savings";
|
|
@@ -21,6 +24,8 @@ export declare const AWS_SAVINGS_WORDS: {
|
|
|
21
24
|
readonly none: "No recommendation recorded yet.";
|
|
22
25
|
readonly changesNothing: "The Steward changes nothing in your account.";
|
|
23
26
|
};
|
|
27
|
+
/** The savings as an A2UI card: a section per recommendation, largest first. */
|
|
28
|
+
export declare function savingsCard({ savings, monthly }: Savings, id: string): CardSpec;
|
|
24
29
|
export declare function AwsSavingsCard({ context, }: {
|
|
25
30
|
context: ToolCallRenderContext;
|
|
26
31
|
}): JSX.Element;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { CardFrame, CardSkeleton, cardData, defineToolCardPlugin, money, } from '../../toolCards/kit.js';
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CardSkeleton, cardData, defineToolCardPlugin, money, } from '../../toolCards/kit.js';
|
|
3
|
+
import { A2uiCard } from '../../toolCards/a2uiCard.js';
|
|
5
4
|
import { readSavings } from './read.js';
|
|
6
5
|
export const AWS_SAVINGS_PLUGIN_NAME = '@datalayer/loop-plugin-aws-savings';
|
|
7
6
|
export const AWS_SAVINGS_WORDS = {
|
|
@@ -14,13 +13,37 @@ export const AWS_SAVINGS_WORDS = {
|
|
|
14
13
|
none: 'No recommendation recorded yet.',
|
|
15
14
|
changesNothing: 'The Steward changes nothing in your account.',
|
|
16
15
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
/** The savings as an A2UI card: a section per recommendation, largest first. */
|
|
17
|
+
export function savingsCard({ savings, monthly }, id) {
|
|
18
|
+
return {
|
|
19
|
+
id: `savings-${id}`,
|
|
20
|
+
title: AWS_SAVINGS_WORDS.title,
|
|
21
|
+
captions: [
|
|
22
|
+
savings.length > 0
|
|
23
|
+
? AWS_SAVINGS_WORDS.total(money(monthly, 'USD'), savings.length)
|
|
24
|
+
: AWS_SAVINGS_WORDS.none,
|
|
25
|
+
AWS_SAVINGS_WORDS.changesNothing,
|
|
26
|
+
],
|
|
27
|
+
sections: savings.map((saving, index) => ({
|
|
28
|
+
id: saving.id || `saving-${index}`,
|
|
29
|
+
title: saving.monthlySaving !== undefined
|
|
30
|
+
? `${saving.finding} — ${AWS_SAVINGS_WORDS.perMonth(money(saving.monthlySaving, 'USD'))}`
|
|
31
|
+
: saving.finding,
|
|
32
|
+
lines: [
|
|
33
|
+
[
|
|
34
|
+
saving.state,
|
|
35
|
+
saving.category,
|
|
36
|
+
saving.service,
|
|
37
|
+
saving.region,
|
|
38
|
+
saving.by ? AWS_SAVINGS_WORDS.by(saving.by) : '',
|
|
39
|
+
]
|
|
40
|
+
.filter(Boolean)
|
|
41
|
+
.join(' · '),
|
|
42
|
+
...saving.evidence.map(read => AWS_SAVINGS_WORDS.read(read.source, read.call, read.readAt)),
|
|
43
|
+
],
|
|
44
|
+
})),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
24
47
|
export function AwsSavingsCard({ context, }) {
|
|
25
48
|
const read = cardData(context);
|
|
26
49
|
if (!read) {
|
|
@@ -29,16 +52,7 @@ export function AwsSavingsCard({ context, }) {
|
|
|
29
52
|
if (!read.done) {
|
|
30
53
|
return _jsx(CardSkeleton, { label: AWS_SAVINGS_WORDS.writing });
|
|
31
54
|
}
|
|
32
|
-
|
|
33
|
-
return (_jsxs(CardFrame, { title: AWS_SAVINGS_WORDS.title, subtitle: savings.length > 0
|
|
34
|
-
? AWS_SAVINGS_WORDS.total(money(monthly, 'USD'), savings.length)
|
|
35
|
-
: AWS_SAVINGS_WORDS.none, maxWidth: 720, children: [_jsx(Box, { as: "ol", m: 0, p: 0, sx: { listStyle: 'none' }, children: savings.map((saving, index) => (_jsxs(Box, { as: "li", py: 2, borderTop: index === 0 ? undefined : '1px solid', borderColor: "border.muted", children: [_jsxs(Box, { display: "flex", justifyContent: "space-between", gap: 2, flexWrap: "wrap", children: [_jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: saving.finding }), saving.monthlySaving !== undefined ? (_jsx(Text, { sx: { fontSize: 1, fontWeight: 'bold', whiteSpace: 'nowrap' }, children: AWS_SAVINGS_WORDS.perMonth(money(saving.monthlySaving, 'USD')) })) : null] }), _jsxs(Box, { display: "flex", gap: 1, alignItems: "center", flexWrap: "wrap", mt: 1, children: [_jsx(Label, { variant: STATE_VARIANT[saving.state] ?? 'secondary', children: saving.state }), saving.category ? _jsx(Label, { children: saving.category }) : null, _jsx(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [
|
|
36
|
-
saving.service,
|
|
37
|
-
saving.region,
|
|
38
|
-
saving.by ? AWS_SAVINGS_WORDS.by(saving.by) : '',
|
|
39
|
-
]
|
|
40
|
-
.filter(Boolean)
|
|
41
|
-
.join(' · ') })] }), saving.evidence.map((evidence, evidenceIndex) => (_jsx(Text, { as: "div", sx: { fontSize: 0, color: 'fg.muted', mt: 1 }, children: AWS_SAVINGS_WORDS.read(evidence.source, evidence.call, evidence.readAt) }, `${evidence.call}-${evidenceIndex}`)))] }, saving.id || index))) }), _jsx(Text, { as: "p", sx: { mt: 2, mb: 0, fontSize: 0, color: 'fg.muted' }, children: AWS_SAVINGS_WORDS.changesNothing })] }));
|
|
55
|
+
return (_jsx(A2uiCard, { spec: savingsCard(readSavings(read.data), context.toolCallId), maxWidth: 720 }));
|
|
42
56
|
}
|
|
43
57
|
export const AwsSavingsPlugin = defineToolCardPlugin({
|
|
44
58
|
id: 'aws-savings',
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@datalayer/loop-plugin-aws-savings-badge` — the savings the Steward found
|
|
3
|
+
* in this session, in the chat's title bar: the estimated monthly sum and the
|
|
4
|
+
* AWS account, from the last `list_recommendations`, else summed over the
|
|
5
|
+
* recommendations recorded (`record_recommendation`). Nothing before one.
|
|
6
|
+
* Brought by the recommendation tools.
|
|
7
|
+
*
|
|
8
|
+
* @module apps/plugins/aws-savings-badge
|
|
9
|
+
*/
|
|
10
|
+
import type { JSX } from 'react';
|
|
11
|
+
export declare const AWS_SAVINGS_BADGE_WORDS: {
|
|
12
|
+
readonly short: (monthly: string, account: string) => string;
|
|
13
|
+
readonly title: (monthly: string, count: number, account: string) => string;
|
|
14
|
+
};
|
|
15
|
+
type Call = {
|
|
16
|
+
args: Record<string, unknown>;
|
|
17
|
+
result: unknown;
|
|
18
|
+
};
|
|
19
|
+
/** The sum, the count and the account; undefined before any recommendation. */
|
|
20
|
+
export declare function savingsFoundOf(listed: Call | undefined, recorded: readonly Call[]): {
|
|
21
|
+
monthly: number;
|
|
22
|
+
count: number;
|
|
23
|
+
account: string;
|
|
24
|
+
} | undefined;
|
|
25
|
+
export declare function AwsSavingsBadge(): JSX.Element | null;
|
|
26
|
+
export declare const awsSavingsBadgePlugin: (placement: import("../../agentUiPlugins").ChromePlacement) => import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
|
|
27
|
+
export declare const AwsSavingsBadgePlugin: import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
|
|
28
|
+
export default AwsSavingsBadgePlugin;
|