@datalayer/agent-runtimes 1.6.62 → 1.6.63

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.
Files changed (66) hide show
  1. package/dist-embed/chunks/ChatView-Bg-IvVbM.js +32 -0
  2. package/dist-embed/datalayer-app-main.js +94 -94
  3. package/lib/apps/agentUiPlugins.d.ts +39 -10
  4. package/lib/apps/agentUiPlugins.js +159 -50
  5. package/lib/apps/apps/AppRenderer.js +3 -1
  6. package/lib/apps/apps/appspec.js +17 -3
  7. package/lib/apps/core/index.d.ts +6 -0
  8. package/lib/apps/core/index.js +6 -0
  9. package/lib/apps/embed/LoopEmbed.js +1 -1
  10. package/lib/apps/plugins/aws-savings/index.d.ts +10 -5
  11. package/lib/apps/plugins/aws-savings/index.js +35 -21
  12. package/lib/apps/plugins/aws-savings-badge/index.d.ts +28 -0
  13. package/lib/apps/plugins/aws-savings-badge/index.js +58 -0
  14. package/lib/apps/plugins/bank-reconciliation/index.d.ts +19 -7
  15. package/lib/apps/plugins/bank-reconciliation/index.js +68 -63
  16. package/lib/apps/plugins/basket-total/index.d.ts +25 -0
  17. package/lib/apps/plugins/basket-total/index.js +41 -0
  18. package/lib/apps/plugins/chat/ChatView.js +4 -1
  19. package/lib/apps/plugins/earth-area/index.d.ts +27 -0
  20. package/lib/apps/plugins/earth-area/index.js +50 -0
  21. package/lib/apps/plugins/earth-index/index.d.ts +8 -3
  22. package/lib/apps/plugins/earth-index/index.js +39 -27
  23. package/lib/apps/plugins/earth-scenes/index.d.ts +8 -3
  24. package/lib/apps/plugins/earth-scenes/index.js +30 -31
  25. package/lib/apps/plugins/linkedin-link/index.d.ts +5 -4
  26. package/lib/apps/plugins/linkedin-link/index.js +7 -16
  27. package/lib/apps/plugins/odoo-context/index.d.ts +30 -0
  28. package/lib/apps/plugins/odoo-context/index.js +54 -0
  29. package/lib/apps/plugins/product-comparison/index.d.ts +7 -1
  30. package/lib/apps/plugins/product-comparison/index.js +37 -30
  31. package/lib/apps/plugins/shopping-basket/index.d.ts +19 -5
  32. package/lib/apps/plugins/shopping-basket/index.js +69 -24
  33. package/lib/apps/plugins/social-accounts/index.d.ts +10 -0
  34. package/lib/apps/plugins/social-accounts/index.js +51 -1
  35. package/lib/apps/plugins/trip-options/index.d.ts +15 -5
  36. package/lib/apps/plugins/trip-options/index.js +67 -21
  37. package/lib/apps/plugins/trip-summary/index.d.ts +26 -0
  38. package/lib/apps/plugins/trip-summary/index.js +59 -0
  39. package/lib/apps/plugins/x-budget/index.d.ts +3 -2
  40. package/lib/apps/plugins/x-budget/index.js +8 -17
  41. package/lib/apps/presets.d.ts +2 -1
  42. package/lib/apps/presets.js +2 -2
  43. package/lib/apps/toolCards/a2uiCard.d.ts +63 -0
  44. package/lib/apps/toolCards/a2uiCard.js +104 -0
  45. package/lib/apps/toolCards/chrome.d.ts +50 -0
  46. package/lib/apps/toolCards/chrome.js +57 -0
  47. package/lib/apps/toolCards/postPreview.d.ts +6 -2
  48. package/lib/apps/toolCards/postPreview.js +28 -18
  49. package/lib/apps/toolCards/toolResults.d.ts +37 -0
  50. package/lib/apps/toolCards/toolResults.js +85 -0
  51. package/lib/chat/Chat.js +47 -36
  52. package/lib/chat/base/ChatBase.js +2 -2
  53. package/lib/chat/messages/ChatMessageList.js +7 -0
  54. package/lib/specs/actions.js +32 -0
  55. package/lib/specs/agents/agents.js +1 -1
  56. package/lib/specs/appspecSchema.js +18 -0
  57. package/lib/specs/backendTools.js +29 -14
  58. package/lib/specs/mcpServers.js +19 -10
  59. package/lib/specs/skills.js +7 -3
  60. package/lib/specs/ui.d.ts +5 -0
  61. package/lib/specs/ui.js +172 -11
  62. package/lib/types/agentspecs.d.ts +8 -0
  63. package/lib/types/chat.d.ts +5 -0
  64. package/package.json +1 -1
  65. package/scripts/codegen/generate_ui.py +2 -0
  66. 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, by id (the user, 15 November 2026: "Add the ability for
51
- * the mcp and skills to define a list of ui that will also be injected"):
52
- * the agent's own `ui`, then the `ui` of each MCP server running, then that
53
- * of each skill enabled, then that of each backend tool it carries — each
54
- * once, in that order. An optional server or skill left out brings none.
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 agent UI plugins among these ids, each once, in the order named; ids
61
- * the preset mounts anyway (`chat`, `a2ui-surface`…) or unknown are passed
62
- * over. For an anonymous visitor, only those that need no connection.
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(ids: readonly string[] | undefined, options?: {
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 { LinkedInLinkPlugin } from './plugins/linkedin-link/index.js';
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 { SocialAccountsPlugin } from './plugins/social-accounts/index.js';
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 { XBudgetPlugin } from './plugins/x-budget/index.js';
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': { plugin: SocialAccountsPlugin, needsConnection: true },
30
- 'x-budget': { plugin: XBudgetPlugin, needsConnection: true },
31
- 'x-post-preview': { plugin: XPostPreviewPlugin, needsConnection: true },
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
- 'shopping-basket': { plugin: ShoppingBasketPlugin, needsConnection: false },
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': { plugin: TripOptionsPlugin, needsConnection: false },
59
- 'trip-itinerary': { plugin: TripItineraryPlugin, needsConnection: false },
60
- 'trip-budget': { plugin: TripBudgetPlugin, needsConnection: false },
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': { plugin: EarthScenesPlugin, needsConnection: false },
63
- 'earth-index': { plugin: EarthIndexPlugin, needsConnection: false },
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': { plugin: AwsSavingsPlugin, needsConnection: false },
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
- /** Ids, each once, in the order first named. */
79
- function once(ids) {
80
- return [...new Set(ids)];
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, by id (the user, 15 November 2026: "Add the ability for
86
- * the mcp and skills to define a list of ui that will also be injected"):
87
- * the agent's own `ui`, then the `ui` of each MCP server running, then that
88
- * of each skill enabled, then that of each backend tool it carries — each
89
- * once, in that order. An optional server or skill left out brings none.
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 agentUiIdsOf(specId, components = {}) {
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
- return once([
113
- ...pluginsOf(spec.ui),
114
- ...servers.flatMap(server => pluginsOf(server.ui)),
115
- ...skills.flatMap(skill => pluginsOf(getSkillSpec(skill.id)?.ui)),
116
- ...(spec.backendTools ?? [])
117
- .filter(Boolean)
118
- .flatMap(tool => pluginsOf(tool?.ui)),
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 agent UI plugins among these ids, each once, in the order named; ids
127
- * the preset mounts anyway (`chat`, `a2ui-surface`…) or unknown are passed
128
- * over. For an anonymous visitor, only those that need no connection.
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(ids, options = {}) {
200
+ export function agentUiPluginsFor(given, options = {}) {
131
201
  const seen = new Set();
132
202
  const plugins = [];
133
- for (const id of ids ?? []) {
134
- const entry = AGENT_UI_PLUGINS[id];
203
+ for (const choice of (given ?? []).map(asChoice)) {
204
+ const entry = AGENT_UI_PLUGINS[choice.plugin];
135
205
  if (!entry ||
136
- seen.has(id) ||
206
+ seen.has(choice.plugin) ||
137
207
  (options.anonymous && entry.needsConnection)) {
138
208
  continue;
139
209
  }
140
- seen.add(id);
141
- plugins.push(entry.plugin);
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.map(choice => choice.plugin), { anonymous: options.kept?.visitor ?? false }),
285
+ ...agentUiPluginsFor(app.ui, {
286
+ anonymous: options.kept?.visitor ?? false,
287
+ }),
286
288
  ],
287
289
  workspace: appLayoutOptions(app),
288
290
  };
@@ -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
  /**
@@ -1280,6 +1283,15 @@ export function uiProblems(app) {
1280
1283
  : ''));
1281
1284
  continue;
1282
1285
  }
1286
+ if (choice.placement !== undefined) {
1287
+ const allowed = spec.placements ?? [];
1288
+ if (allowed.length === 0) {
1289
+ problems.push(`The UI plugin ${spec.name} ('${id}') has no place in the chat: it takes no \`placement\`.`);
1290
+ }
1291
+ else if (!allowed.includes(choice.placement)) {
1292
+ problems.push(`The UI plugin ${spec.name} ('${id}') does not go in the chat's ${choice.placement}: in its ${allowed.join(', ')} only.`);
1293
+ }
1294
+ }
1283
1295
  if (choice.renderer === undefined) {
1284
1296
  continue;
1285
1297
  }
@@ -1611,9 +1623,11 @@ export function dumpAppspec(app) {
1611
1623
  .value('as', connection.as, 'owner')
1612
1624
  .list('only', connection.only).data))
1613
1625
  .list('protocols', app.protocols)
1614
- .list('ui', app.ui.map(choice => choice.renderer
1615
- ? { plugin: choice.plugin, renderer: choice.renderer }
1616
- : { plugin: choice.plugin }))
1626
+ .list('ui', app.ui.map(choice => ({
1627
+ plugin: choice.plugin,
1628
+ ...(choice.renderer ? { renderer: choice.renderer } : {}),
1629
+ ...(choice.placement ? { placement: choice.placement } : {}),
1630
+ })))
1617
1631
  .part('pap', dumpPap(app.pap))
1618
1632
  .part('pact', dumpPact(app.pact))
1619
1633
  .part('commerce', dumpCommerce(app.commerce))
@@ -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
  /**
@@ -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 ?? []).join(','),
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: each finding with its resource, the estimated monthly saving and
4
- * whose estimate it is, its state, and the reads it rests on; the sum of the
5
- * savings at the top. Draws `list_recommendations`, which the Steward ends a
6
- * scan with. Each recommendation's own card (Approve, Dismiss) is the A2UI
7
- * surface `record_recommendation` draws; this plugin is the list.
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, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Label, Text } from '@primer/react';
3
- import { Box } from '@datalayer/primer-addons';
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
- const STATE_VARIANT = {
18
- open: 'attention',
19
- approved: 'accent',
20
- applied: 'success',
21
- dismissed: 'secondary',
22
- expired: 'secondary',
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
- const { savings, monthly } = readSavings(read.data);
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;