@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.
- 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 +17 -3
- 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
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { CardFrame, CardSkeleton, CardTable, cardData, defineToolCardPlugin, } from '../../toolCards/kit.js';
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CardSkeleton, cardData, defineToolCardPlugin, } from '../../toolCards/kit.js';
|
|
3
|
+
import { A2uiCard } from '../../toolCards/a2uiCard.js';
|
|
5
4
|
import { readEarthScenes } from './read.js';
|
|
6
5
|
export const EARTH_SCENES_PLUGIN_NAME = '@datalayer/loop-plugin-earth-scenes';
|
|
7
6
|
export const EARTH_SCENES_WORDS = {
|
|
@@ -10,14 +9,33 @@ export const EARTH_SCENES_WORDS = {
|
|
|
10
9
|
searched: (area, period, maxCloud) => [area, period, maxCloud !== undefined ? `up to ${maxCloud}% cloud` : '']
|
|
11
10
|
.filter(Boolean)
|
|
12
11
|
.join(' · '),
|
|
13
|
-
|
|
12
|
+
count: (count) => (count === 1 ? '1 scene' : `${count} scenes`),
|
|
14
13
|
};
|
|
15
|
-
/**
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
/** The scenes as an A2UI card: a table by date. */
|
|
15
|
+
export function scenesCard(found, id) {
|
|
16
|
+
const searched = EARTH_SCENES_WORDS.searched(found.area, found.period, found.maxCloud);
|
|
17
|
+
return {
|
|
18
|
+
id: `scenes-${id}`,
|
|
19
|
+
title: EARTH_SCENES_WORDS.title,
|
|
20
|
+
captions: [
|
|
21
|
+
EARTH_SCENES_WORDS.count(found.scenes.length),
|
|
22
|
+
...(searched ? [searched] : []),
|
|
23
|
+
],
|
|
24
|
+
table: {
|
|
25
|
+
columns: ['Date', 'Collection', 'Sensor', 'Cloud cover'],
|
|
26
|
+
rows: found.scenes.map(scene => ({
|
|
27
|
+
Date: scene.date,
|
|
28
|
+
Collection: scene.collection,
|
|
29
|
+
Sensor: scene.sensor,
|
|
30
|
+
'Cloud cover': scene.cloudCover === undefined
|
|
31
|
+
? ''
|
|
32
|
+
: `${scene.cloudCover.toFixed(0)}%`,
|
|
33
|
+
})),
|
|
34
|
+
},
|
|
35
|
+
lines: found.scenes
|
|
36
|
+
.filter(scene => scene.url)
|
|
37
|
+
.map(scene => `[${scene.date} ${scene.collection}](${scene.url})`),
|
|
38
|
+
};
|
|
21
39
|
}
|
|
22
40
|
export function EarthScenesCard({ context, }) {
|
|
23
41
|
const read = cardData(context);
|
|
@@ -28,26 +46,7 @@ export function EarthScenesCard({ context, }) {
|
|
|
28
46
|
if (found.scenes.length === 0) {
|
|
29
47
|
return read.done ? (_jsx(_Fragment, { children: context.defaultUI })) : (_jsx(CardSkeleton, { label: EARTH_SCENES_WORDS.writing }));
|
|
30
48
|
}
|
|
31
|
-
|
|
32
|
-
return (_jsx(CardFrame, { title: EARTH_SCENES_WORDS.title, subtitle: searched || undefined, children: _jsx(CardTable, { caption: `${found.scenes.length} scenes`, rows: found.scenes, rowKey: row => row.id, columns: [
|
|
33
|
-
{
|
|
34
|
-
key: 'date',
|
|
35
|
-
title: 'Date',
|
|
36
|
-
cell: row => row.url ? (_jsx(Link, { href: row.url, target: "_blank", rel: "noreferrer", children: row.date })) : (row.date),
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
key: 'collection',
|
|
40
|
-
title: 'Collection',
|
|
41
|
-
cell: row => row.collection,
|
|
42
|
-
},
|
|
43
|
-
{ key: 'sensor', title: 'Sensor', cell: row => row.sensor },
|
|
44
|
-
{
|
|
45
|
-
key: 'cloud',
|
|
46
|
-
title: 'Cloud cover',
|
|
47
|
-
align: 'right',
|
|
48
|
-
cell: row => _jsx(CloudBar, { cover: row.cloudCover }),
|
|
49
|
-
},
|
|
50
|
-
] }) }));
|
|
49
|
+
return _jsx(A2uiCard, { spec: scenesCard(found, context.toolCallId) });
|
|
51
50
|
}
|
|
52
51
|
export const EarthScenesPlugin = defineToolCardPlugin({
|
|
53
52
|
id: 'earth-scenes',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@datalayer/loop-plugin-linkedin-link` — *Link LinkedIn in Settings*,
|
|
3
|
-
* the
|
|
2
|
+
* `@datalayer/loop-plugin-linkedin-link` — *Link LinkedIn in Settings*,
|
|
3
|
+
* above the conversation (its `banner` placement; or the title bar), while the person's LinkedIn is not linked through
|
|
4
4
|
* Datalayer (IAM's `/social/accounts`) or its 60-day grant lapsed
|
|
5
5
|
* (*Reconnect LinkedIn in Settings*). Brought by the `datalayer-social`
|
|
6
6
|
* LinkedIn tools (`social-post-linkedin`, `social-comment-linkedin`, the
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
* @module apps/plugins/linkedin-link
|
|
12
12
|
*/
|
|
13
13
|
import type { JSX } from 'react';
|
|
14
|
-
import type { ReactorPlugin } from '@datalayer/reactor';
|
|
15
14
|
export declare const LINKEDIN_LINK_PLUGIN_NAME = "@datalayer/loop-plugin-linkedin-link";
|
|
16
15
|
/** Where Settings › LinkedIn is, on Datalayer's pages. */
|
|
17
16
|
export declare const LINKEDIN_SETTINGS_PATH = "/settings/linkedin";
|
|
@@ -28,5 +27,7 @@ export declare function LinkedInLinkButton({ settingsUrl, }: {
|
|
|
28
27
|
}): JSX.Element | null;
|
|
29
28
|
/** The button in the chat's title-bar slot. */
|
|
30
29
|
export declare function LinkedInLinkSlot(): JSX.Element | null;
|
|
31
|
-
|
|
30
|
+
/** The plugin for a placement: `banner` (its default) or `header`. */
|
|
31
|
+
export declare const linkedInLinkPlugin: (placement: import("../../agentUiPlugins").ChromePlacement) => import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
|
|
32
|
+
export declare const LinkedInLinkPlugin: import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
|
|
32
33
|
export default LinkedInLinkPlugin;
|
|
@@ -2,11 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
import { Button } from '@primer/react';
|
|
4
4
|
import { LinkIcon } from '@primer/octicons-react';
|
|
5
|
-
import { definePlugin } from '@datalayer/reactor';
|
|
6
5
|
import { useCoreStore } from '@datalayer/core';
|
|
7
6
|
import { useIAMStore } from '@datalayer/core/lib/state/index.js';
|
|
8
7
|
import { requestDatalayerAPI } from '@datalayer/core/lib/api/DatalayerApi.js';
|
|
9
|
-
import {
|
|
8
|
+
import { defineChromePlugin } from '../../toolCards/chrome.js';
|
|
10
9
|
import { record } from '../../toolCards/kit.js';
|
|
11
10
|
export const LINKEDIN_LINK_PLUGIN_NAME = '@datalayer/loop-plugin-linkedin-link';
|
|
12
11
|
/** Where Settings › LinkedIn is, on Datalayer's pages. */
|
|
@@ -64,22 +63,14 @@ export function LinkedInLinkButton({ settingsUrl = LINKEDIN_SETTINGS_PATH, }) {
|
|
|
64
63
|
export function LinkedInLinkSlot() {
|
|
65
64
|
return _jsx(LinkedInLinkButton, {});
|
|
66
65
|
}
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
/** The plugin for a placement: `banner` (its default) or `header`. */
|
|
67
|
+
export const linkedInLinkPlugin = defineChromePlugin({
|
|
68
|
+
id: 'linkedin-link',
|
|
69
69
|
displayName: 'Link LinkedIn',
|
|
70
|
-
description: 'Link LinkedIn in Settings,
|
|
70
|
+
description: 'Link LinkedIn in Settings, above the conversation, while the person’s LinkedIn is not linked through Datalayer or needs connecting again.',
|
|
71
71
|
octicon: 'link',
|
|
72
72
|
emoji: '\u{1F517}',
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
components: [
|
|
76
|
-
{
|
|
77
|
-
slot: LoopSlots.chatHeader,
|
|
78
|
-
id: 'linkedin-link',
|
|
79
|
-
Component: LinkedInLinkSlot,
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
};
|
|
83
|
-
},
|
|
73
|
+
Component: () => LinkedInLinkButton({}),
|
|
84
74
|
});
|
|
75
|
+
export const LinkedInLinkPlugin = linkedInLinkPlugin('banner');
|
|
85
76
|
export default LinkedInLinkPlugin;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@datalayer/loop-plugin-odoo-context` — the Odoo company the Accountant
|
|
3
|
+
* works in and the period it reads, in the chat's title bar: the company as
|
|
4
|
+
* Odoo answered it (`odoo_get_context`, with or without the gateway's
|
|
5
|
+
* prefix), the period of the last trial balance or VAT it showed. Nothing
|
|
6
|
+
* until Odoo or a card said it. Brought by the `odoo` and `odoo-accounting`
|
|
7
|
+
* servers.
|
|
8
|
+
*
|
|
9
|
+
* @module apps/plugins/odoo-context
|
|
10
|
+
*/
|
|
11
|
+
import type { JSX } from 'react';
|
|
12
|
+
/** The tools that say the company. */
|
|
13
|
+
export declare const ODOO_CONTEXT_TOOLS: string[];
|
|
14
|
+
/** The cards that say the period. */
|
|
15
|
+
export declare const ODOO_PERIOD_TOOLS: string[];
|
|
16
|
+
export declare const ODOO_CONTEXT_WORDS: {
|
|
17
|
+
readonly short: (parts: string[]) => string;
|
|
18
|
+
readonly title: (company: string, period: string) => string;
|
|
19
|
+
};
|
|
20
|
+
/** The company Odoo answered, from its context. */
|
|
21
|
+
export declare function odooCompanyOf(result: unknown): string;
|
|
22
|
+
/** The period a trial balance or a VAT card said. */
|
|
23
|
+
export declare function odooPeriodOf(call: {
|
|
24
|
+
args: Record<string, unknown>;
|
|
25
|
+
result: unknown;
|
|
26
|
+
} | undefined): string;
|
|
27
|
+
export declare function OdooContextChip(): JSX.Element | null;
|
|
28
|
+
export declare const odooContextPlugin: (placement: import("../../agentUiPlugins").ChromePlacement) => import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
|
|
29
|
+
export declare const OdooContextPlugin: import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
|
|
30
|
+
export default OdooContextPlugin;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Chip, defineChromePlugin } from '../../toolCards/chrome.js';
|
|
3
|
+
import { useLatestToolCall } from '../../toolCards/toolResults.js';
|
|
4
|
+
import { record, words } from '../../toolCards/kit.js';
|
|
5
|
+
/** The tools that say the company. */
|
|
6
|
+
export const ODOO_CONTEXT_TOOLS = ['odoo_get_context'];
|
|
7
|
+
/** The cards that say the period. */
|
|
8
|
+
export const ODOO_PERIOD_TOOLS = ['show_trial_balance', 'show_vat_summary'];
|
|
9
|
+
export const ODOO_CONTEXT_WORDS = {
|
|
10
|
+
short: (parts) => `Odoo: ${parts.join(' · ')}`,
|
|
11
|
+
title: (company, period) => [
|
|
12
|
+
company ? `Odoo company: ${company}` : '',
|
|
13
|
+
period ? `Period: ${period}` : '',
|
|
14
|
+
]
|
|
15
|
+
.filter(Boolean)
|
|
16
|
+
.join('. ') + '.',
|
|
17
|
+
};
|
|
18
|
+
/** The company Odoo answered, from its context. */
|
|
19
|
+
export function odooCompanyOf(result) {
|
|
20
|
+
const answer = record(result);
|
|
21
|
+
if (!answer) {
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
const company = record(answer.company);
|
|
25
|
+
return (words(company?.name) ||
|
|
26
|
+
words(answer.company_name) ||
|
|
27
|
+
words(answer.company) ||
|
|
28
|
+
words(record(answer.context)?.company_name));
|
|
29
|
+
}
|
|
30
|
+
/** The period a trial balance or a VAT card said. */
|
|
31
|
+
export function odooPeriodOf(call) {
|
|
32
|
+
if (!call) {
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
return words(record(call.result)?.period) || words(call.args.period);
|
|
36
|
+
}
|
|
37
|
+
export function OdooContextChip() {
|
|
38
|
+
const company = odooCompanyOf(useLatestToolCall(ODOO_CONTEXT_TOOLS)?.result);
|
|
39
|
+
const period = odooPeriodOf(useLatestToolCall(ODOO_PERIOD_TOOLS));
|
|
40
|
+
if (!company && !period) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return (_jsx(Chip, { title: ODOO_CONTEXT_WORDS.title(company, period), data: "odoo-context", children: ODOO_CONTEXT_WORDS.short([company, period].filter(Boolean)) }));
|
|
44
|
+
}
|
|
45
|
+
export const odooContextPlugin = defineChromePlugin({
|
|
46
|
+
id: 'odoo-context',
|
|
47
|
+
displayName: 'Odoo company and period',
|
|
48
|
+
description: 'The Odoo company the agent works in and the period it reads, in the chat’s title bar.',
|
|
49
|
+
octicon: 'briefcase',
|
|
50
|
+
emoji: '\u{1F3E2}',
|
|
51
|
+
Component: OdooContextChip,
|
|
52
|
+
});
|
|
53
|
+
export const OdooContextPlugin = odooContextPlugin('header');
|
|
54
|
+
export default OdooContextPlugin;
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@datalayer/loop-plugin-product-comparison` — the Shopper's short list,
|
|
3
3
|
* side by side: price, variant, availability, rating and seller, the one it
|
|
4
|
-
* would pick marked with why. Draws `show_comparison
|
|
4
|
+
* would pick marked with why. Draws `show_comparison` as a message, with the
|
|
5
|
+
* A2UI renderer (`toolCards/a2uiCard`).
|
|
5
6
|
*
|
|
6
7
|
* @module apps/plugins/product-comparison
|
|
7
8
|
*/
|
|
8
9
|
import type { JSX } from 'react';
|
|
9
10
|
import type { ToolCallRenderContext } from '../../../types/chat';
|
|
11
|
+
import { type CardSpec } from '../../toolCards/a2uiCard';
|
|
12
|
+
import { type Comparison } from './read';
|
|
10
13
|
export declare const PRODUCT_COMPARISON_PLUGIN_NAME = "@datalayer/loop-plugin-product-comparison";
|
|
11
14
|
export declare const PRODUCT_COMPARISON_WORDS: {
|
|
12
15
|
readonly title: "Compared";
|
|
13
16
|
readonly pick: (title: string) => string;
|
|
14
17
|
readonly writing: "Comparing products…";
|
|
15
18
|
readonly picked: "Picked";
|
|
19
|
+
readonly count: (count: number) => string;
|
|
16
20
|
};
|
|
21
|
+
/** The comparison as an A2UI card: a table, the pick and why. */
|
|
22
|
+
export declare function comparisonCard(comparison: Comparison, id: string): CardSpec;
|
|
17
23
|
export declare function ProductComparisonCard({ context, }: {
|
|
18
24
|
context: ToolCallRenderContext;
|
|
19
25
|
}): JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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';
|
|
4
4
|
import { readComparison } from './read.js';
|
|
5
5
|
export const PRODUCT_COMPARISON_PLUGIN_NAME = '@datalayer/loop-plugin-product-comparison';
|
|
6
6
|
export const PRODUCT_COMPARISON_WORDS = {
|
|
@@ -8,41 +8,48 @@ export const PRODUCT_COMPARISON_WORDS = {
|
|
|
8
8
|
pick: (title) => `My pick: ${title}`,
|
|
9
9
|
writing: 'Comparing products…',
|
|
10
10
|
picked: 'Picked',
|
|
11
|
+
count: (count) => `${count} products`,
|
|
11
12
|
};
|
|
13
|
+
/** The comparison as an A2UI card: a table, the pick and why. */
|
|
14
|
+
export function comparisonCard(comparison, id) {
|
|
15
|
+
return {
|
|
16
|
+
id: `comparison-${id}`,
|
|
17
|
+
title: PRODUCT_COMPARISON_WORDS.title,
|
|
18
|
+
captions: [
|
|
19
|
+
PRODUCT_COMPARISON_WORDS.count(comparison.products.length),
|
|
20
|
+
...(comparison.pick
|
|
21
|
+
? [PRODUCT_COMPARISON_WORDS.pick(comparison.pick)]
|
|
22
|
+
: []),
|
|
23
|
+
],
|
|
24
|
+
table: {
|
|
25
|
+
columns: ['Product', 'Price', 'Seller', 'Availability', 'Rating'],
|
|
26
|
+
rows: comparison.products.map(product => ({
|
|
27
|
+
Product: (product.picked ? `✓ ${product.title}` : product.title) +
|
|
28
|
+
(product.variant ? ` (${product.variant})` : ''),
|
|
29
|
+
Price: money(product.price, product.currency),
|
|
30
|
+
Seller: product.seller,
|
|
31
|
+
Availability: product.availability,
|
|
32
|
+
Rating: product.rating === undefined ? '' : product.rating.toFixed(1),
|
|
33
|
+
})),
|
|
34
|
+
},
|
|
35
|
+
lines: [
|
|
36
|
+
...(comparison.reason ? [comparison.reason] : []),
|
|
37
|
+
...comparison.products
|
|
38
|
+
.filter(product => product.url)
|
|
39
|
+
.map(product => `[${product.title}](${product.url})`),
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
12
43
|
export function ProductComparisonCard({ context, }) {
|
|
13
44
|
const read = cardData(context);
|
|
14
45
|
if (!read) {
|
|
15
46
|
return _jsx(_Fragment, { children: context.defaultUI });
|
|
16
47
|
}
|
|
17
|
-
const
|
|
18
|
-
if (products.length === 0) {
|
|
48
|
+
const comparison = readComparison(read.data);
|
|
49
|
+
if (comparison.products.length === 0) {
|
|
19
50
|
return read.done ? (_jsx(_Fragment, { children: context.defaultUI })) : (_jsx(CardSkeleton, { label: PRODUCT_COMPARISON_WORDS.writing }));
|
|
20
51
|
}
|
|
21
|
-
return (
|
|
22
|
-
{
|
|
23
|
-
key: 'title',
|
|
24
|
-
title: 'Product',
|
|
25
|
-
cell: row => (_jsxs(_Fragment, { children: [row.url ? (_jsx(Link, { href: row.url, target: "_blank", rel: "noreferrer", children: row.title })) : (row.title), ' ', row.picked ? (_jsx(Label, { variant: "success", children: PRODUCT_COMPARISON_WORDS.picked })) : null, row.variant ? (_jsx(Text, { as: "div", sx: { color: 'fg.muted', fontSize: 0 }, children: row.variant })) : null] })),
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
key: 'price',
|
|
29
|
-
title: 'Price',
|
|
30
|
-
align: 'right',
|
|
31
|
-
cell: row => money(row.price, row.currency),
|
|
32
|
-
},
|
|
33
|
-
{ key: 'seller', title: 'Seller', cell: row => row.seller },
|
|
34
|
-
{
|
|
35
|
-
key: 'availability',
|
|
36
|
-
title: 'Availability',
|
|
37
|
-
cell: row => row.availability,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
key: 'rating',
|
|
41
|
-
title: 'Rating',
|
|
42
|
-
align: 'right',
|
|
43
|
-
cell: row => row.rating === undefined ? '' : row.rating.toFixed(1),
|
|
44
|
-
},
|
|
45
|
-
] }), reason ? (_jsx(Text, { as: "p", sx: { mt: 2, mb: 0, fontSize: 1 }, children: reason })) : null] }));
|
|
52
|
+
return _jsx(A2uiCard, { spec: comparisonCard(comparison, context.toolCallId) });
|
|
46
53
|
}
|
|
47
54
|
export const ProductComparisonPlugin = defineToolCardPlugin({
|
|
48
55
|
id: 'product-comparison',
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@datalayer/loop-plugin-shopping-basket` — the Shopper's basket
|
|
3
|
-
*
|
|
4
|
-
* and the
|
|
5
|
-
*
|
|
6
|
-
* the company
|
|
2
|
+
* `@datalayer/loop-plugin-shopping-basket` — the Shopper's basket, as a
|
|
3
|
+
* message drawn by the A2UI renderer: each item with its seller, quantity
|
|
4
|
+
* and price, the shipping, the total summed here. **Buy** sends *buy this
|
|
5
|
+
* basket* as the person's next turn: the agent then proposes the purchase at
|
|
6
|
+
* the company, which is approved on its exact terms (`pap-purchase`), or
|
|
7
|
+
* gives the seller's checkout. Nothing is bought from the card itself.
|
|
8
|
+
* Draws `show_basket`.
|
|
7
9
|
*
|
|
8
10
|
* @module apps/plugins/shopping-basket
|
|
9
11
|
*/
|
|
10
12
|
import type { JSX } from 'react';
|
|
11
13
|
import type { ToolCallRenderContext } from '../../../types/chat';
|
|
14
|
+
import { type CardSpec } from '../../toolCards/a2uiCard';
|
|
15
|
+
import { type Basket } from './read';
|
|
12
16
|
export declare const SHOPPING_BASKET_PLUGIN_NAME = "@datalayer/loop-plugin-shopping-basket";
|
|
13
17
|
export declare const SHOPPING_BASKET_WORDS: {
|
|
14
18
|
readonly title: "Your basket";
|
|
@@ -18,7 +22,17 @@ export declare const SHOPPING_BASKET_WORDS: {
|
|
|
18
22
|
readonly partial: "A price is missing: the total is not the whole.";
|
|
19
23
|
readonly nothingBought: "Nothing is bought until you approve the exact purchase: the items, the seller and the total.";
|
|
20
24
|
readonly checkout: "Pay at the seller’s checkout";
|
|
25
|
+
readonly buy: "Buy";
|
|
26
|
+
readonly asked: "Asked: approve the purchase when the agent shows it.";
|
|
27
|
+
readonly form: "Buy this basket";
|
|
21
28
|
};
|
|
29
|
+
/** The action **Buy** sends. */
|
|
30
|
+
export declare const BUY_ACTION = "buy_basket";
|
|
31
|
+
/** The basket as an A2UI card. */
|
|
32
|
+
export declare function basketCard(basket: Basket, id: string, options?: {
|
|
33
|
+
buy?: boolean;
|
|
34
|
+
asked?: boolean;
|
|
35
|
+
}): CardSpec;
|
|
22
36
|
export declare function ShoppingBasketCard({ context, }: {
|
|
23
37
|
context: ToolCallRenderContext;
|
|
24
38
|
}): JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { CardSkeleton, cardData, defineToolCardPlugin, money, submitCard, useToolCardSend, } from '../../toolCards/kit.js';
|
|
4
|
+
import { A2uiCard } from '../../toolCards/a2uiCard.js';
|
|
5
5
|
import { readBasket } from './read.js';
|
|
6
6
|
export const SHOPPING_BASKET_PLUGIN_NAME = '@datalayer/loop-plugin-shopping-basket';
|
|
7
7
|
export const SHOPPING_BASKET_WORDS = {
|
|
@@ -12,8 +12,58 @@ export const SHOPPING_BASKET_WORDS = {
|
|
|
12
12
|
partial: 'A price is missing: the total is not the whole.',
|
|
13
13
|
nothingBought: 'Nothing is bought until you approve the exact purchase: the items, the seller and the total.',
|
|
14
14
|
checkout: 'Pay at the seller’s checkout',
|
|
15
|
+
buy: 'Buy',
|
|
16
|
+
asked: 'Asked: approve the purchase when the agent shows it.',
|
|
17
|
+
form: 'Buy this basket',
|
|
15
18
|
};
|
|
19
|
+
/** The action **Buy** sends. */
|
|
20
|
+
export const BUY_ACTION = 'buy_basket';
|
|
21
|
+
/** The basket as an A2UI card. */
|
|
22
|
+
export function basketCard(basket, id, options = {}) {
|
|
23
|
+
const { currency } = basket;
|
|
24
|
+
return {
|
|
25
|
+
id: `basket-${id}`,
|
|
26
|
+
title: SHOPPING_BASKET_WORDS.title,
|
|
27
|
+
captions: basket.note ? [basket.note] : [],
|
|
28
|
+
table: {
|
|
29
|
+
columns: ['Item', 'Qty', 'Price'],
|
|
30
|
+
rows: basket.items.map(item => ({
|
|
31
|
+
Item: [item.title, item.variant, item.seller]
|
|
32
|
+
.filter(Boolean)
|
|
33
|
+
.join(' · '),
|
|
34
|
+
Qty: String(item.quantity),
|
|
35
|
+
Price: money(item.price, currency),
|
|
36
|
+
})),
|
|
37
|
+
},
|
|
38
|
+
lines: [
|
|
39
|
+
...(basket.shipping !== undefined
|
|
40
|
+
? [
|
|
41
|
+
`${SHOPPING_BASKET_WORDS.shipping}: ${money(basket.shipping, currency)}`,
|
|
42
|
+
]
|
|
43
|
+
: []),
|
|
44
|
+
`**${SHOPPING_BASKET_WORDS.total}: ${money(basket.total, currency)}**`,
|
|
45
|
+
...(basket.partial ? [SHOPPING_BASKET_WORDS.partial] : []),
|
|
46
|
+
options.asked
|
|
47
|
+
? SHOPPING_BASKET_WORDS.asked
|
|
48
|
+
: SHOPPING_BASKET_WORDS.nothingBought,
|
|
49
|
+
...(basket.checkoutUrl
|
|
50
|
+
? [`[${SHOPPING_BASKET_WORDS.checkout}](${basket.checkoutUrl})`]
|
|
51
|
+
: []),
|
|
52
|
+
],
|
|
53
|
+
actions: options.buy && !options.asked
|
|
54
|
+
? [
|
|
55
|
+
{
|
|
56
|
+
name: BUY_ACTION,
|
|
57
|
+
label: SHOPPING_BASKET_WORDS.buy,
|
|
58
|
+
primary: true,
|
|
59
|
+
},
|
|
60
|
+
]
|
|
61
|
+
: [],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
16
64
|
export function ShoppingBasketCard({ context, }) {
|
|
65
|
+
const send = useToolCardSend();
|
|
66
|
+
const [asked, setAsked] = useState(false);
|
|
17
67
|
const read = cardData(context);
|
|
18
68
|
if (!read) {
|
|
19
69
|
return _jsx(_Fragment, { children: context.defaultUI });
|
|
@@ -22,26 +72,21 @@ export function ShoppingBasketCard({ context, }) {
|
|
|
22
72
|
if (basket.items.length === 0) {
|
|
23
73
|
return read.done ? (_jsx(_Fragment, { children: context.defaultUI })) : (_jsx(CardSkeleton, { label: SHOPPING_BASKET_WORDS.writing }));
|
|
24
74
|
}
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
title: 'Price',
|
|
41
|
-
align: 'right',
|
|
42
|
-
cell: row => money(row.price, currency),
|
|
43
|
-
},
|
|
44
|
-
] }), _jsxs(Box, { display: "flex", justifyContent: "flex-end", flexDirection: "column", alignItems: "flex-end", mt: 2, children: [basket.shipping !== undefined ? (_jsxs(Text, { sx: { fontSize: 1 }, children: [SHOPPING_BASKET_WORDS.shipping, ": ", money(basket.shipping, currency)] })) : null, _jsxs(Text, { sx: { fontSize: 2, fontWeight: 'bold' }, "data-basket-total": true, children: [SHOPPING_BASKET_WORDS.total, ": ", money(basket.total, currency)] }), basket.partial ? (_jsx(Text, { sx: { fontSize: 0, color: 'attention.fg' }, children: SHOPPING_BASKET_WORDS.partial })) : null] }), _jsx(Text, { as: "p", sx: { mt: 2, mb: 0, fontSize: 0, color: 'fg.muted' }, children: SHOPPING_BASKET_WORDS.nothingBought }), basket.checkoutUrl ? (_jsx(Link, { href: basket.checkoutUrl, target: "_blank", rel: "noreferrer", children: SHOPPING_BASKET_WORDS.checkout })) : null] }));
|
|
75
|
+
const onAction = (action) => {
|
|
76
|
+
if (action.name === BUY_ACTION && send) {
|
|
77
|
+
setAsked(submitCard(send, {
|
|
78
|
+
title: SHOPPING_BASKET_WORDS.form,
|
|
79
|
+
values: {
|
|
80
|
+
items: basket.items.map(item => `${item.quantity} × ${item.title}`),
|
|
81
|
+
total: money(basket.total, basket.currency),
|
|
82
|
+
},
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return (_jsx(A2uiCard, { spec: basketCard(basket, context.toolCallId, {
|
|
87
|
+
buy: Boolean(send) && read.done,
|
|
88
|
+
asked,
|
|
89
|
+
}), onAction: onAction }));
|
|
45
90
|
}
|
|
46
91
|
export const ShoppingBasketPlugin = defineToolCardPlugin({
|
|
47
92
|
id: 'shopping-basket',
|
|
@@ -27,6 +27,16 @@ export declare const SOCIAL_ACCOUNTS_WORDS: {
|
|
|
27
27
|
export declare function SocialAccountsCard({ context, }: {
|
|
28
28
|
context: ToolCallRenderContext;
|
|
29
29
|
}): JSX.Element;
|
|
30
|
+
/** In a message: drawn where `social_accounts` answers. */
|
|
31
|
+
export declare const SocialAccountsMessagePlugin: import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* In the chat's title bar (its default placement): one chip per network,
|
|
34
|
+
* read from IAM's `/social/accounts` with the person's own token (no token
|
|
35
|
+
* is ever named there); nothing for a visitor nor while it is read.
|
|
36
|
+
*/
|
|
37
|
+
export declare function SocialAccountsChips(): JSX.Element | null;
|
|
38
|
+
/** The plugin for a placement: `header` (its default); `message` is `SocialAccountsMessagePlugin`. */
|
|
39
|
+
export declare const socialAccountsPlugin: (placement: import("../../agentUiPlugins").ChromePlacement) => import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
|
|
30
40
|
export declare const SocialAccountsPlugin: import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
|
|
31
41
|
export { SOCIAL_NETWORKS, SOCIAL_NETWORK_NAMES, readSocialAccounts, type SocialAccount, type SocialAccountState, type SocialNetwork, } from './read';
|
|
32
42
|
export default SocialAccountsPlugin;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { useCoreStore } from '@datalayer/core';
|
|
4
|
+
import { useIAMStore } from '@datalayer/core/lib/state/index.js';
|
|
5
|
+
import { requestDatalayerAPI } from '@datalayer/core/lib/api/DatalayerApi.js';
|
|
6
|
+
import { Chip, defineChromePlugin } from '../../toolCards/chrome.js';
|
|
2
7
|
import { Label, Link, Text } from '@primer/react';
|
|
3
8
|
import { Box } from '@datalayer/primer-addons';
|
|
4
9
|
import { CardFrame, CardSkeleton, cardData, defineToolCardPlugin, } from '../../toolCards/kit.js';
|
|
@@ -37,7 +42,8 @@ export function SocialAccountsCard({ context, }) {
|
|
|
37
42
|
const accounts = readSocialAccounts(read.data);
|
|
38
43
|
return (_jsx(CardFrame, { title: SOCIAL_ACCOUNTS_WORDS.title, maxWidth: 480, children: _jsx(Box, { as: "ul", m: 0, p: 0, sx: { listStyle: 'none' }, children: accounts.map(account => (_jsxs(Box, { as: "li", py: 1, display: "flex", flexDirection: "column", "data-social-account": account.network, children: [_jsxs(Box, { display: "flex", alignItems: "center", gap: 2, children: [_jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold', minWidth: 72 }, children: SOCIAL_NETWORK_NAMES[account.network] }), _jsx(Label, { variant: VARIANT[account.state], children: SOCIAL_ACCOUNTS_WORDS.states[account.state] }), account.who ? (account.url ? (_jsx(Link, { href: account.url, target: "_blank", rel: "noreferrer", sx: { fontSize: 1 }, children: account.who })) : (_jsx(Text, { sx: { fontSize: 1 }, children: account.who }))) : null, account.expiresAt && account.state === 'linked' ? (_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: SOCIAL_ACCOUNTS_WORDS.until(account.expiresAt) })) : null] }), SOCIAL_ACCOUNTS_WORDS.fix[account.state] ? (_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', pl: '80px' }, children: SOCIAL_ACCOUNTS_WORDS.fix[account.state] })) : null] }, account.network))) }) }));
|
|
39
44
|
}
|
|
40
|
-
|
|
45
|
+
/** In a message: drawn where `social_accounts` answers. */
|
|
46
|
+
export const SocialAccountsMessagePlugin = defineToolCardPlugin({
|
|
41
47
|
id: 'social-accounts',
|
|
42
48
|
displayName: 'Linked social accounts',
|
|
43
49
|
description: 'Which of X, Bluesky and LinkedIn the person linked, as whom, and whether each posts, reads or needs connecting again.',
|
|
@@ -46,5 +52,49 @@ export const SocialAccountsPlugin = defineToolCardPlugin({
|
|
|
46
52
|
tools: ['social_accounts'],
|
|
47
53
|
Card: SocialAccountsCard,
|
|
48
54
|
});
|
|
55
|
+
/**
|
|
56
|
+
* In the chat's title bar (its default placement): one chip per network,
|
|
57
|
+
* read from IAM's `/social/accounts` with the person's own token (no token
|
|
58
|
+
* is ever named there); nothing for a visitor nor while it is read.
|
|
59
|
+
*/
|
|
60
|
+
export function SocialAccountsChips() {
|
|
61
|
+
const { configuration } = useCoreStore();
|
|
62
|
+
const { token } = useIAMStore();
|
|
63
|
+
const iamUrl = String(configuration?.iamUrl || '');
|
|
64
|
+
const [answer, setAnswer] = useState();
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!token || !iamUrl) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
const controller = new AbortController();
|
|
70
|
+
requestDatalayerAPI({
|
|
71
|
+
url: `${iamUrl.replace(/\/$/, '')}/api/iam/v1/social/accounts`,
|
|
72
|
+
method: 'GET',
|
|
73
|
+
token,
|
|
74
|
+
signal: controller.signal,
|
|
75
|
+
})
|
|
76
|
+
.then(setAnswer)
|
|
77
|
+
.catch(() => {
|
|
78
|
+
if (!controller.signal.aborted) {
|
|
79
|
+
setAnswer(null);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return () => controller.abort();
|
|
83
|
+
}, [token, iamUrl]);
|
|
84
|
+
if (!token || !answer) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return (_jsx(Box, { display: "inline-flex", gap: 1, "data-social-accounts-chips": "", children: readSocialAccounts(answer).map(account => (_jsx(Chip, { attention: account.state !== 'linked', title: `${SOCIAL_NETWORK_NAMES[account.network]}: ${SOCIAL_ACCOUNTS_WORDS.states[account.state]}${account.who ? ` (${account.who})` : ''}`, data: account.network, children: `${SOCIAL_NETWORK_NAMES[account.network]} ${account.state === 'linked' ? '✓' : account.state === 'not-linked' ? '–' : '!'}` }, account.network))) }));
|
|
88
|
+
}
|
|
89
|
+
/** The plugin for a placement: `header` (its default); `message` is `SocialAccountsMessagePlugin`. */
|
|
90
|
+
export const socialAccountsPlugin = defineChromePlugin({
|
|
91
|
+
id: 'social-accounts',
|
|
92
|
+
displayName: 'Linked social accounts',
|
|
93
|
+
description: 'Which of X, Bluesky and LinkedIn the person linked, in the chat’s title bar.',
|
|
94
|
+
octicon: 'person',
|
|
95
|
+
emoji: '\u{1FAAA}',
|
|
96
|
+
Component: SocialAccountsChips,
|
|
97
|
+
});
|
|
98
|
+
export const SocialAccountsPlugin = socialAccountsPlugin('header');
|
|
49
99
|
export { SOCIAL_NETWORKS, SOCIAL_NETWORK_NAMES, readSocialAccounts, } from './read.js';
|
|
50
100
|
export default SocialAccountsPlugin;
|
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@datalayer/loop-plugin-trip-options` — the Voyager's three options,
|
|
3
|
-
*
|
|
4
|
-
* the
|
|
5
|
-
*
|
|
2
|
+
* `@datalayer/loop-plugin-trip-options` — the Voyager's three options, as a
|
|
3
|
+
* message drawn by the A2UI renderer, one card each: the dates and nights,
|
|
4
|
+
* the price, what stands out, a link to the offer, and **Choose this one**,
|
|
5
|
+
* which sends the choice back as the person's next turn. Nothing is booked.
|
|
6
|
+
* Draws `show_trip_options`.
|
|
6
7
|
*
|
|
7
8
|
* @module apps/plugins/trip-options
|
|
8
9
|
*/
|
|
9
10
|
import type { JSX } from 'react';
|
|
10
11
|
import type { ToolCallRenderContext } from '../../../types/chat';
|
|
12
|
+
import { type CardSpec } from '../../toolCards/a2uiCard';
|
|
13
|
+
import { type TripOption } from './read';
|
|
11
14
|
export declare const TRIP_OPTIONS_PLUGIN_NAME = "@datalayer/loop-plugin-trip-options";
|
|
12
15
|
export declare const TRIP_OPTIONS_WORDS: {
|
|
13
16
|
readonly label: "Trip options";
|
|
14
17
|
readonly writing: "Looking for trips…";
|
|
15
18
|
readonly nights: (nights: number) => string;
|
|
16
19
|
readonly choose: "Choose this one";
|
|
17
|
-
readonly chosen:
|
|
20
|
+
readonly chosen: (title: string) => string;
|
|
18
21
|
readonly offer: "See the offer";
|
|
19
22
|
readonly nothingBooked: "Nothing is booked until you say so.";
|
|
20
23
|
};
|
|
24
|
+
/** The action **Choose this one** sends. */
|
|
25
|
+
export declare const CHOOSE_TRIP_ACTION = "choose_trip";
|
|
26
|
+
/** The options as an A2UI card: a section each, with its choice. */
|
|
27
|
+
export declare function tripOptionsCard(options: TripOption[], id: string, state?: {
|
|
28
|
+
choose?: boolean;
|
|
29
|
+
chosen?: string;
|
|
30
|
+
}): CardSpec;
|
|
21
31
|
export declare function TripOptionsCard({ context, }: {
|
|
22
32
|
context: ToolCallRenderContext;
|
|
23
33
|
}): JSX.Element;
|