@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
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Chip, defineChromePlugin } from '../../toolCards/chrome.js';
|
|
3
|
+
import { useLatestToolCall, useToolCalls } from '../../toolCards/toolResults.js';
|
|
4
|
+
import { amount, money, record, words } from '../../toolCards/kit.js';
|
|
5
|
+
import { readSavings } from '../aws-savings/read.js';
|
|
6
|
+
export const AWS_SAVINGS_BADGE_WORDS = {
|
|
7
|
+
short: (monthly, account) => `Savings: ${monthly}/month${account ? ` · ${account}` : ''}`,
|
|
8
|
+
title: (monthly, count, account) => `${count} ${count === 1 ? 'recommendation' : 'recommendations'} found in this session, ${monthly} a month estimated${account ? `, in AWS account ${account}` : ''}. Nothing is changed in the account.`,
|
|
9
|
+
};
|
|
10
|
+
/** The sum, the count and the account; undefined before any recommendation. */
|
|
11
|
+
export function savingsFoundOf(listed, recorded) {
|
|
12
|
+
const accountOf = (recommendation) => words(record(record(recommendation)?.resource)?.account);
|
|
13
|
+
if (listed) {
|
|
14
|
+
const said = record(listed.result);
|
|
15
|
+
if (said) {
|
|
16
|
+
const { savings, monthly } = readSavings(said);
|
|
17
|
+
if (savings.length > 0) {
|
|
18
|
+
const raw = Array.isArray(said.recommendations)
|
|
19
|
+
? said.recommendations
|
|
20
|
+
: [];
|
|
21
|
+
return {
|
|
22
|
+
monthly,
|
|
23
|
+
count: savings.length,
|
|
24
|
+
account: raw.map(accountOf).find(Boolean) ?? '',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const kept = recorded
|
|
30
|
+
.map(call => record(record(call.result)?.recommendation))
|
|
31
|
+
.filter((each) => each !== null);
|
|
32
|
+
if (kept.length === 0) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
monthly: Math.round(kept.reduce((sum, each) => sum + (amount(record(each.estimate)?.monthly_saving_usd) ?? 0), 0) * 100) / 100,
|
|
37
|
+
count: kept.length,
|
|
38
|
+
account: kept.map(accountOf).find(Boolean) ?? '',
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function AwsSavingsBadge() {
|
|
42
|
+
const found = savingsFoundOf(useLatestToolCall(['list_recommendations']), useToolCalls(['record_recommendation']));
|
|
43
|
+
if (!found) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const monthly = money(found.monthly, 'USD');
|
|
47
|
+
return (_jsx(Chip, { title: AWS_SAVINGS_BADGE_WORDS.title(monthly, found.count, found.account), data: "aws-savings-badge", children: AWS_SAVINGS_BADGE_WORDS.short(monthly, found.account) }));
|
|
48
|
+
}
|
|
49
|
+
export const awsSavingsBadgePlugin = defineChromePlugin({
|
|
50
|
+
id: 'aws-savings-badge',
|
|
51
|
+
displayName: 'Savings found',
|
|
52
|
+
description: 'This session’s estimated monthly savings and the AWS account they were found in, in the chat’s title bar.',
|
|
53
|
+
octicon: 'graph',
|
|
54
|
+
emoji: '\u{1F4B8}',
|
|
55
|
+
Component: AwsSavingsBadge,
|
|
56
|
+
});
|
|
57
|
+
export const AwsSavingsBadgePlugin = awsSavingsBadgePlugin('header');
|
|
58
|
+
export default AwsSavingsBadgePlugin;
|
|
@@ -1,24 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@datalayer/loop-plugin-bank-reconciliation` — the Accountant's proposed
|
|
3
|
-
* matches
|
|
4
|
-
* difference computed here,
|
|
5
|
-
*
|
|
6
|
-
* reconciled in Odoo before
|
|
3
|
+
* matches, as a message drawn by the A2UI renderer: each bank line beside the
|
|
4
|
+
* invoice it would settle, the difference computed here, how sure the agent
|
|
5
|
+
* is, and **Approve** per match. Each press sends that match back as the
|
|
6
|
+
* person's next turn; nothing is reconciled in Odoo before. Draws
|
|
7
|
+
* `show_reconciliation`.
|
|
7
8
|
*
|
|
8
9
|
* @module apps/plugins/bank-reconciliation
|
|
9
10
|
*/
|
|
10
11
|
import type { JSX } from 'react';
|
|
11
12
|
import type { ToolCallRenderContext } from '../../../types/chat';
|
|
13
|
+
import { type CardSpec } from '../../toolCards/a2uiCard';
|
|
14
|
+
import { type Reconciliation } from './read';
|
|
12
15
|
export declare const BANK_RECONCILIATION_PLUGIN_NAME = "@datalayer/loop-plugin-bank-reconciliation";
|
|
13
16
|
export declare const BANK_RECONCILIATION_WORDS: {
|
|
14
17
|
readonly title: "Bank lines and invoices";
|
|
15
|
-
readonly subtitle: "
|
|
18
|
+
readonly subtitle: "Approve each match you agree with. Nothing is reconciled in Odoo before you do.";
|
|
16
19
|
readonly writing: "Matching bank lines…";
|
|
17
20
|
readonly noMatch: "No invoice";
|
|
18
|
-
readonly approve:
|
|
19
|
-
readonly
|
|
21
|
+
readonly approve: "Approve";
|
|
22
|
+
readonly approved: "Approved: sent to the agent.";
|
|
23
|
+
readonly confidence: (confidence: string) => string;
|
|
24
|
+
readonly difference: (difference: string) => string;
|
|
20
25
|
readonly form: "Reconciliation";
|
|
21
26
|
};
|
|
27
|
+
/** The action each **Approve** sends. */
|
|
28
|
+
export declare const APPROVE_MATCH_ACTION = "approve_match";
|
|
29
|
+
/** The reconciliation as an A2UI card: one section per bank line. */
|
|
30
|
+
export declare function reconciliationCard(reconciliation: Reconciliation, id: string, options?: {
|
|
31
|
+
approve?: boolean;
|
|
32
|
+
approved?: ReadonlySet<string>;
|
|
33
|
+
}): CardSpec;
|
|
22
34
|
export declare function BankReconciliationCard({ context, }: {
|
|
23
35
|
context: ToolCallRenderContext;
|
|
24
36
|
}): JSX.Element;
|
|
@@ -1,89 +1,94 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { readReconciliation, reconciliationDecision, } from './read.js';
|
|
3
|
+
import { CardSkeleton, cardData, defineToolCardPlugin, money, submitCard, useToolCardSend, } from '../../toolCards/kit.js';
|
|
4
|
+
import { A2uiCard } from '../../toolCards/a2uiCard.js';
|
|
5
|
+
import { readReconciliation } from './read.js';
|
|
7
6
|
export const BANK_RECONCILIATION_PLUGIN_NAME = '@datalayer/loop-plugin-bank-reconciliation';
|
|
8
7
|
export const BANK_RECONCILIATION_WORDS = {
|
|
9
8
|
title: 'Bank lines and invoices',
|
|
10
|
-
subtitle: '
|
|
9
|
+
subtitle: 'Approve each match you agree with. Nothing is reconciled in Odoo before you do.',
|
|
11
10
|
writing: 'Matching bank lines…',
|
|
12
11
|
noMatch: 'No invoice',
|
|
13
|
-
approve:
|
|
14
|
-
|
|
12
|
+
approve: 'Approve',
|
|
13
|
+
approved: 'Approved: sent to the agent.',
|
|
14
|
+
confidence: (confidence) => `Confidence: ${confidence}`,
|
|
15
|
+
difference: (difference) => `Difference: ${difference}`,
|
|
15
16
|
form: 'Reconciliation',
|
|
16
17
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
18
|
+
/** The action each **Approve** sends. */
|
|
19
|
+
export const APPROVE_MATCH_ACTION = 'approve_match';
|
|
20
|
+
/** The reconciliation as an A2UI card: one section per bank line. */
|
|
21
|
+
export function reconciliationCard(reconciliation, id, options = {}) {
|
|
22
|
+
const { currency } = reconciliation;
|
|
23
|
+
return {
|
|
24
|
+
id: `reconciliation-${id}`,
|
|
25
|
+
title: BANK_RECONCILIATION_WORDS.title,
|
|
26
|
+
captions: [BANK_RECONCILIATION_WORDS.subtitle],
|
|
27
|
+
sections: reconciliation.lines.map(line => ({
|
|
28
|
+
id: line.id,
|
|
29
|
+
title: `${line.date ? `${line.date} · ` : ''}${line.label} · ${money(line.amount, currency)}`,
|
|
30
|
+
lines: [
|
|
31
|
+
line.invoice
|
|
32
|
+
? `${line.invoice}${line.partner ? ` · ${line.partner}` : ''} · ${money(line.invoiceAmount, currency)}`
|
|
33
|
+
: BANK_RECONCILIATION_WORDS.noMatch,
|
|
34
|
+
...(line.difference !== undefined && line.difference !== 0
|
|
35
|
+
? [
|
|
36
|
+
BANK_RECONCILIATION_WORDS.difference(money(line.difference, currency)),
|
|
37
|
+
]
|
|
38
|
+
: []),
|
|
39
|
+
...(line.confidence
|
|
40
|
+
? [BANK_RECONCILIATION_WORDS.confidence(line.confidence)]
|
|
41
|
+
: []),
|
|
42
|
+
...(options.approved?.has(line.id)
|
|
43
|
+
? [BANK_RECONCILIATION_WORDS.approved]
|
|
44
|
+
: []),
|
|
45
|
+
],
|
|
46
|
+
actions: options.approve && line.invoice && !options.approved?.has(line.id)
|
|
47
|
+
? [
|
|
48
|
+
{
|
|
49
|
+
name: APPROVE_MATCH_ACTION,
|
|
50
|
+
label: BANK_RECONCILIATION_WORDS.approve,
|
|
51
|
+
context: { line: line.id, invoice: line.invoice },
|
|
52
|
+
primary: true,
|
|
53
|
+
},
|
|
54
|
+
]
|
|
55
|
+
: [],
|
|
56
|
+
})),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
22
59
|
export function BankReconciliationCard({ context, }) {
|
|
23
60
|
const send = useToolCardSend();
|
|
24
61
|
const [approved, setApproved] = useState(new Set());
|
|
25
|
-
const [sent, setSent] = useState(false);
|
|
26
62
|
const read = cardData(context);
|
|
27
63
|
if (!read) {
|
|
28
64
|
return _jsx(_Fragment, { children: context.defaultUI });
|
|
29
65
|
}
|
|
30
|
-
const
|
|
31
|
-
if (lines.length === 0) {
|
|
66
|
+
const reconciliation = readReconciliation(read.data);
|
|
67
|
+
if (reconciliation.lines.length === 0) {
|
|
32
68
|
return read.done ? (_jsx(_Fragment, { children: context.defaultUI })) : (_jsx(CardSkeleton, { label: BANK_RECONCILIATION_WORDS.writing }));
|
|
33
69
|
}
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
70
|
+
const onAction = (action) => {
|
|
71
|
+
const lineId = String((action.context ?? {}).line ?? '');
|
|
72
|
+
const line = reconciliation.lines.find(each => each.id === lineId);
|
|
73
|
+
if (action.name !== APPROVE_MATCH_ACTION || !line || !send) {
|
|
74
|
+
return;
|
|
38
75
|
}
|
|
39
|
-
|
|
40
|
-
|
|
76
|
+
if (submitCard(send, {
|
|
77
|
+
title: BANK_RECONCILIATION_WORDS.form,
|
|
78
|
+
values: { approved: [line.id], invoice: line.invoice },
|
|
79
|
+
})) {
|
|
80
|
+
setApproved(current => new Set(current).add(line.id));
|
|
41
81
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
key: 'approve',
|
|
48
|
-
title: 'Approve',
|
|
49
|
-
align: 'center',
|
|
50
|
-
cell: row => row.invoice ? (_jsx(Checkbox, { "aria-label": `Approve ${row.label} against ${row.invoice}`, checked: approved.has(row.id), disabled: sent || !read.done, onChange: () => toggle(row.id) })) : null,
|
|
51
|
-
},
|
|
52
|
-
{ key: 'date', title: 'Date', cell: row => row.date },
|
|
53
|
-
{ key: 'label', title: 'Bank line', cell: row => row.label },
|
|
54
|
-
{
|
|
55
|
-
key: 'amount',
|
|
56
|
-
title: 'Amount',
|
|
57
|
-
align: 'right',
|
|
58
|
-
cell: row => money(row.amount, currency),
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
key: 'invoice',
|
|
62
|
-
title: 'Invoice',
|
|
63
|
-
cell: row => row.invoice ? (_jsxs(_Fragment, { children: [row.invoice, row.partner ? (_jsx(Text, { as: "div", sx: { color: 'fg.muted', fontSize: 0 }, children: row.partner })) : null] })) : (_jsx(Text, { sx: { color: 'fg.muted' }, children: BANK_RECONCILIATION_WORDS.noMatch })),
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
key: 'difference',
|
|
67
|
-
title: 'Difference',
|
|
68
|
-
align: 'right',
|
|
69
|
-
cell: row => row.difference === undefined ? ('') : (_jsx(Text, { sx: {
|
|
70
|
-
color: row.difference === 0 ? 'fg.default' : 'attention.fg',
|
|
71
|
-
}, children: money(row.difference, currency) })),
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
key: 'confidence',
|
|
75
|
-
title: 'Confidence',
|
|
76
|
-
cell: row => row.confidence ? (_jsx(Label, { variant: CONFIDENCE_VARIANT[row.confidence], children: row.confidence })) : null,
|
|
77
|
-
},
|
|
78
|
-
] }), send && read.done ? (_jsx(Box, { mt: 2, display: "flex", alignItems: "center", gap: 2, children: sent ? (_jsx(Text, { sx: { fontSize: 1, color: 'success.fg' }, children: BANK_RECONCILIATION_WORDS.sent })) : (_jsx(Button, { variant: "primary", disabled: decision.approved.length === 0, onClick: () => setSent(submitCard(send, {
|
|
79
|
-
title: BANK_RECONCILIATION_WORDS.form,
|
|
80
|
-
values: decision,
|
|
81
|
-
})), children: BANK_RECONCILIATION_WORDS.approve(decision.approved.length) })) })) : null] }));
|
|
82
|
+
};
|
|
83
|
+
return (_jsx(A2uiCard, { spec: reconciliationCard(reconciliation, context.toolCallId, {
|
|
84
|
+
approve: Boolean(send) && read.done,
|
|
85
|
+
approved,
|
|
86
|
+
}), onAction: onAction, maxWidth: 720 }));
|
|
82
87
|
}
|
|
83
88
|
export const BankReconciliationPlugin = defineToolCardPlugin({
|
|
84
89
|
id: 'bank-reconciliation',
|
|
85
90
|
displayName: 'Bank reconciliation',
|
|
86
|
-
description: 'Bank lines beside the invoices they would settle, with the difference; the person approves
|
|
91
|
+
description: 'Bank lines beside the invoices they would settle, with the difference; the person approves each match.',
|
|
87
92
|
octicon: 'git-compare',
|
|
88
93
|
emoji: '\u{1F9FE}',
|
|
89
94
|
tools: ['show_reconciliation'],
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@datalayer/loop-plugin-basket-total` — the Shopper's basket in the chat's
|
|
3
|
+
* title bar (or under the prompt): how many items and its total, read from
|
|
4
|
+
* the last basket it showed (`show_basket`); nothing before one. Brought by
|
|
5
|
+
* the `show-basket` tool.
|
|
6
|
+
*
|
|
7
|
+
* @module apps/plugins/basket-total
|
|
8
|
+
*/
|
|
9
|
+
import type { JSX } from 'react';
|
|
10
|
+
export declare const BASKET_TOTAL_WORDS: {
|
|
11
|
+
readonly short: (count: number, total: string) => string;
|
|
12
|
+
readonly title: (count: number, total: string) => string;
|
|
13
|
+
};
|
|
14
|
+
/** The basket's count and total from a `show_basket` call; undefined without items. */
|
|
15
|
+
export declare function basketTotalOf(call: {
|
|
16
|
+
args: Record<string, unknown>;
|
|
17
|
+
result: unknown;
|
|
18
|
+
} | undefined): {
|
|
19
|
+
count: number;
|
|
20
|
+
total: string;
|
|
21
|
+
} | undefined;
|
|
22
|
+
export declare function BasketTotalChip(): JSX.Element | null;
|
|
23
|
+
export declare const basketTotalPlugin: (placement: import("../../agentUiPlugins").ChromePlacement) => import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
|
|
24
|
+
export declare const BasketTotalPlugin: import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
|
|
25
|
+
export default BasketTotalPlugin;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { money, record } from '../../toolCards/kit.js';
|
|
5
|
+
import { readBasket } from '../shopping-basket/read.js';
|
|
6
|
+
export const BASKET_TOTAL_WORDS = {
|
|
7
|
+
short: (count, total) => `Basket: ${count} ${count === 1 ? 'item' : 'items'} · ${total}`,
|
|
8
|
+
title: (count, total) => `The basket shown last holds ${count} ${count === 1 ? 'item' : 'items'}, ${total} in all. Nothing is bought until you approve the purchase.`,
|
|
9
|
+
};
|
|
10
|
+
/** The basket's count and total from a `show_basket` call; undefined without items. */
|
|
11
|
+
export function basketTotalOf(call) {
|
|
12
|
+
if (!call) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const answered = record(call.result);
|
|
16
|
+
const basket = readBasket(answered && 'shown' in answered ? answered : call.args);
|
|
17
|
+
if (basket.items.length === 0) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
count: basket.items.reduce((sum, item) => sum + item.quantity, 0),
|
|
22
|
+
total: money(basket.total, basket.currency),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function BasketTotalChip() {
|
|
26
|
+
const said = basketTotalOf(useLatestToolCall(['show_basket']));
|
|
27
|
+
if (!said) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return (_jsx(Chip, { title: BASKET_TOTAL_WORDS.title(said.count, said.total), data: "basket-total", children: BASKET_TOTAL_WORDS.short(said.count, said.total) }));
|
|
31
|
+
}
|
|
32
|
+
export const basketTotalPlugin = defineChromePlugin({
|
|
33
|
+
id: 'basket-total',
|
|
34
|
+
displayName: 'Basket total',
|
|
35
|
+
description: 'The basket the agent is putting together, in the chat’s title bar: how many items and its total.',
|
|
36
|
+
octicon: 'package',
|
|
37
|
+
emoji: '\u{1F6D2}',
|
|
38
|
+
Component: BasketTotalChip,
|
|
39
|
+
});
|
|
40
|
+
export const BasketTotalPlugin = basketTotalPlugin('header');
|
|
41
|
+
export default BasketTotalPlugin;
|
|
@@ -1324,6 +1324,8 @@ export default function ChatView({ workspace }) {
|
|
|
1324
1324
|
const promptActions = useSlotComponents(LoopSlots.promptAction);
|
|
1325
1325
|
// Same question for the chat's own title bar, which plugins may add to.
|
|
1326
1326
|
const chatHeaderItems = useSlotComponents(LoopSlots.chatHeader);
|
|
1327
|
+
// And for the band above the conversation (an agent's `banner` UI).
|
|
1328
|
+
const chatBannerItems = useSlotComponents(LoopSlots.chatBanner);
|
|
1327
1329
|
const footerAgents = useMemo(() => team?.members.map(entry => ({
|
|
1328
1330
|
id: entry.id,
|
|
1329
1331
|
name: entry.name,
|
|
@@ -2107,7 +2109,8 @@ export default function ChatView({ workspace }) {
|
|
|
2107
2109
|
// its name (T-08); an agent's chat keeps its header as it is.
|
|
2108
2110
|
headerContent:
|
|
2109
2111
|
// Not *Ready* with no runtime: the header says why instead.
|
|
2110
|
-
|
|
2112
|
+
// Then the agent's `banner` UI, above the conversation.
|
|
2113
|
+
(presence && !noRuntime) || chatBannerItems.length > 0 ? (_jsxs(_Fragment, { children: [presence && !noRuntime ? (_jsx(PresenceLine, { state: presenceNow })) : null, chatBannerItems.length > 0 ? (_jsx(ReactorSlot, { slot: LoopSlots.chatBanner, props: { workspace } })) : null] })) : undefined, emptyState: {
|
|
2111
2114
|
// An application's own face, at the page's size of the three
|
|
2112
2115
|
// (T-08, T-19): the thing a person's eye lands on first.
|
|
2113
2116
|
icon: presence?.face ? (_jsx("span", { "aria-hidden": true, style: { fontSize: FACE_LARGE, lineHeight: 1 }, children: _jsx(FaceDrawing, { face: presence.face, size: FACE_LARGE }) })) : (_jsx(BrandIcon, { size: 48 })),
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@datalayer/loop-plugin-earth-area` — the area and the dates Terra
|
|
3
|
+
* searched, in the chat's title bar: from the last scenes it showed
|
|
4
|
+
* (`show_scenes`: the area, the period, the most cloud cover), else from its
|
|
5
|
+
* last granule search's bounding box and dates (`search_earth_datagranules`,
|
|
6
|
+
* with or without the gateway's prefix). Nothing before a search. Brought by
|
|
7
|
+
* the `earthdata` server.
|
|
8
|
+
*
|
|
9
|
+
* @module apps/plugins/earth-area
|
|
10
|
+
*/
|
|
11
|
+
import type { JSX } from 'react';
|
|
12
|
+
export declare const EARTH_AREA_WORDS: {
|
|
13
|
+
readonly short: (parts: string[]) => string;
|
|
14
|
+
readonly title: (parts: string[]) => string;
|
|
15
|
+
};
|
|
16
|
+
/** What a search said of its area and dates; empty when nothing. */
|
|
17
|
+
export declare function earthAreaOf(scenes: {
|
|
18
|
+
args: Record<string, unknown>;
|
|
19
|
+
result: unknown;
|
|
20
|
+
} | undefined, search: {
|
|
21
|
+
args: Record<string, unknown>;
|
|
22
|
+
result: unknown;
|
|
23
|
+
} | undefined): string[];
|
|
24
|
+
export declare function EarthAreaChip(): JSX.Element | null;
|
|
25
|
+
export declare const earthAreaPlugin: (placement: import("../../agentUiPlugins").ChromePlacement) => import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
|
|
26
|
+
export declare const EarthAreaPlugin: import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
|
|
27
|
+
export default EarthAreaPlugin;
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { amount, record, words } from '../../toolCards/kit.js';
|
|
5
|
+
export const EARTH_AREA_WORDS = {
|
|
6
|
+
short: (parts) => `Area: ${parts.join(' · ')}`,
|
|
7
|
+
title: (parts) => `Searched: ${parts.join(', ')}.`,
|
|
8
|
+
};
|
|
9
|
+
/** What a search said of its area and dates; empty when nothing. */
|
|
10
|
+
export function earthAreaOf(scenes, search) {
|
|
11
|
+
if (scenes) {
|
|
12
|
+
const said = record(scenes.result) ?? scenes.args;
|
|
13
|
+
const cloud = amount(said.max_cloud_cover);
|
|
14
|
+
const parts = [
|
|
15
|
+
words(said.area),
|
|
16
|
+
words(said.period),
|
|
17
|
+
cloud !== undefined ? `≤ ${cloud}% cloud` : '',
|
|
18
|
+
].filter(Boolean);
|
|
19
|
+
if (parts.length > 0) {
|
|
20
|
+
return parts;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (search) {
|
|
24
|
+
const box = search.args.bounding_box;
|
|
25
|
+
const area = Array.isArray(box) ? box.map(words).join(', ') : words(box);
|
|
26
|
+
const temporal = search.args.temporal;
|
|
27
|
+
const dates = Array.isArray(temporal)
|
|
28
|
+
? temporal.map(words).filter(Boolean).join(' – ')
|
|
29
|
+
: words(temporal);
|
|
30
|
+
return [area ? `[${area}]` : '', dates].filter(Boolean);
|
|
31
|
+
}
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
export function EarthAreaChip() {
|
|
35
|
+
const parts = earthAreaOf(useLatestToolCall(['show_scenes']), useLatestToolCall(['search_earth_datagranules']));
|
|
36
|
+
if (parts.length === 0) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return (_jsx(Chip, { title: EARTH_AREA_WORDS.title(parts), data: "earth-area", children: EARTH_AREA_WORDS.short(parts) }));
|
|
40
|
+
}
|
|
41
|
+
export const earthAreaPlugin = defineChromePlugin({
|
|
42
|
+
id: 'earth-area',
|
|
43
|
+
displayName: 'Area and dates',
|
|
44
|
+
description: 'The area and the dates searched, in the chat’s title bar.',
|
|
45
|
+
octicon: 'location',
|
|
46
|
+
emoji: '\u{1F5FA}\u{FE0F}',
|
|
47
|
+
Component: EarthAreaChip,
|
|
48
|
+
});
|
|
49
|
+
export const EarthAreaPlugin = earthAreaPlugin('header');
|
|
50
|
+
export default EarthAreaPlugin;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@datalayer/loop-plugin-earth-index` — what Terra computed from the
|
|
3
|
-
* pixels: an index (NDVI, NDWI,
|
|
4
|
-
*
|
|
5
|
-
* what limits the reading. Draws
|
|
3
|
+
* pixels, as a message drawn by the A2UI renderer: an index (NDVI, NDWI,
|
|
4
|
+
* NBR…) over an area on each date with the scene it came from, the change
|
|
5
|
+
* between the dates, the map it drew and what limits the reading. Draws
|
|
6
|
+
* `show_index_result`.
|
|
6
7
|
*
|
|
7
8
|
* @module apps/plugins/earth-index
|
|
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 IndexResult } from './read';
|
|
11
14
|
export declare const EARTH_INDEX_PLUGIN_NAME = "@datalayer/loop-plugin-earth-index";
|
|
12
15
|
export declare const EARTH_INDEX_WORDS: {
|
|
13
16
|
readonly title: (index: string, area: string) => string;
|
|
@@ -16,6 +19,8 @@ export declare const EARTH_INDEX_WORDS: {
|
|
|
16
19
|
readonly changed: (pct: number, threshold?: number) => string;
|
|
17
20
|
readonly map: (index: string) => string;
|
|
18
21
|
};
|
|
22
|
+
/** The result as an A2UI card: the map, a table by date, the change. */
|
|
23
|
+
export declare function indexCard(result: IndexResult, id: string): CardSpec;
|
|
19
24
|
export declare function EarthIndexCard({ context, }: {
|
|
20
25
|
context: ToolCallRenderContext;
|
|
21
26
|
}): JSX.Element;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx
|
|
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 { readIndexResult } from './read.js';
|
|
6
5
|
export const EARTH_INDEX_PLUGIN_NAME = '@datalayer/loop-plugin-earth-index';
|
|
7
6
|
const fixed = (value) => value === undefined ? '' : value.toFixed(3);
|
|
@@ -14,6 +13,41 @@ export const EARTH_INDEX_WORDS = {
|
|
|
14
13
|
: `${pct.toFixed(1)}% of the area changed by more than ${threshold}`,
|
|
15
14
|
map: (index) => `${index || 'Index'} map`,
|
|
16
15
|
};
|
|
16
|
+
/** The result as an A2UI card: the map, a table by date, the change. */
|
|
17
|
+
export function indexCard(result, id) {
|
|
18
|
+
const { change } = result;
|
|
19
|
+
return {
|
|
20
|
+
id: `index-${id}`,
|
|
21
|
+
title: EARTH_INDEX_WORDS.title(result.index, result.area),
|
|
22
|
+
...(result.image
|
|
23
|
+
? {
|
|
24
|
+
image: {
|
|
25
|
+
url: result.image,
|
|
26
|
+
alt: EARTH_INDEX_WORDS.map(result.index),
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
: {}),
|
|
30
|
+
table: {
|
|
31
|
+
columns: ['Date', 'Scene', 'Mean', 'Min', 'Max'],
|
|
32
|
+
rows: result.readings.map(reading => ({
|
|
33
|
+
Date: reading.date,
|
|
34
|
+
Scene: reading.scene,
|
|
35
|
+
Mean: fixed(reading.mean),
|
|
36
|
+
Min: fixed(reading.min),
|
|
37
|
+
Max: fixed(reading.max),
|
|
38
|
+
})),
|
|
39
|
+
},
|
|
40
|
+
lines: [
|
|
41
|
+
...(change?.meanDelta !== undefined
|
|
42
|
+
? [`**${EARTH_INDEX_WORDS.delta(change.meanDelta)}**`]
|
|
43
|
+
: []),
|
|
44
|
+
...(change?.changedAreaPct !== undefined
|
|
45
|
+
? [EARTH_INDEX_WORDS.changed(change.changedAreaPct, change.threshold)]
|
|
46
|
+
: []),
|
|
47
|
+
...(result.notes ? [result.notes] : []),
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
17
51
|
export function EarthIndexCard({ context, }) {
|
|
18
52
|
const read = cardData(context);
|
|
19
53
|
if (!read) {
|
|
@@ -23,29 +57,7 @@ export function EarthIndexCard({ context, }) {
|
|
|
23
57
|
if (result.readings.length === 0) {
|
|
24
58
|
return read.done ? (_jsx(_Fragment, { children: context.defaultUI })) : (_jsx(CardSkeleton, { label: EARTH_INDEX_WORDS.writing }));
|
|
25
59
|
}
|
|
26
|
-
|
|
27
|
-
return (_jsxs(CardFrame, { title: EARTH_INDEX_WORDS.title(result.index, result.area), children: [result.image ? (_jsx(Box, { as: "img", src: result.image, alt: EARTH_INDEX_WORDS.map(result.index), width: "100%", maxHeight: 320, borderRadius: 2, mb: 2, sx: { objectFit: 'contain', bg: 'canvas.default' } })) : null, _jsx(CardTable, { caption: `${result.readings.length} dates`, rows: result.readings, rowKey: (row, index) => `${row.date}-${index}`, columns: [
|
|
28
|
-
{ key: 'date', title: 'Date', cell: row => row.date },
|
|
29
|
-
{ key: 'scene', title: 'Scene', cell: row => row.scene },
|
|
30
|
-
{
|
|
31
|
-
key: 'mean',
|
|
32
|
-
title: 'Mean',
|
|
33
|
-
align: 'right',
|
|
34
|
-
cell: row => fixed(row.mean),
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
key: 'min',
|
|
38
|
-
title: 'Min',
|
|
39
|
-
align: 'right',
|
|
40
|
-
cell: row => fixed(row.min),
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
key: 'max',
|
|
44
|
-
title: 'Max',
|
|
45
|
-
align: 'right',
|
|
46
|
-
cell: row => fixed(row.max),
|
|
47
|
-
},
|
|
48
|
-
] }), change ? (_jsxs(Box, { mt: 2, children: [change.meanDelta !== undefined ? (_jsx(Text, { as: "div", sx: { fontSize: 2, fontWeight: 'bold' }, "data-index-delta": true, children: EARTH_INDEX_WORDS.delta(change.meanDelta) })) : null, change.changedAreaPct !== undefined ? (_jsx(Text, { as: "div", sx: { fontSize: 1 }, children: EARTH_INDEX_WORDS.changed(change.changedAreaPct, change.threshold) })) : null] })) : null, result.notes ? (_jsx(Text, { as: "p", sx: { mt: 2, mb: 0, fontSize: 1, color: 'fg.muted' }, children: result.notes })) : null] }));
|
|
60
|
+
return _jsx(A2uiCard, { spec: indexCard(result, context.toolCallId) });
|
|
49
61
|
}
|
|
50
62
|
export const EarthIndexPlugin = defineToolCardPlugin({
|
|
51
63
|
id: 'earth-index',
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@datalayer/loop-plugin-earth-scenes` — the satellite scenes Terra found,
|
|
3
|
-
* by date
|
|
4
|
-
* gave them, the area and the dates
|
|
3
|
+
* by date, as a message drawn by the A2UI renderer: each with its collection,
|
|
4
|
+
* sensor and cloud cover as the catalogue gave them, the area and the dates
|
|
5
|
+
* searched. Draws `show_scenes`.
|
|
5
6
|
*
|
|
6
7
|
* @module apps/plugins/earth-scenes
|
|
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 EarthScenes } from './read';
|
|
10
13
|
export declare const EARTH_SCENES_PLUGIN_NAME = "@datalayer/loop-plugin-earth-scenes";
|
|
11
14
|
export declare const EARTH_SCENES_WORDS: {
|
|
12
15
|
readonly title: "Scenes";
|
|
13
16
|
readonly writing: "Searching the catalogue…";
|
|
14
17
|
readonly searched: (area: string, period: string, maxCloud?: number) => string;
|
|
15
|
-
readonly
|
|
18
|
+
readonly count: (count: number) => string;
|
|
16
19
|
};
|
|
20
|
+
/** The scenes as an A2UI card: a table by date. */
|
|
21
|
+
export declare function scenesCard(found: EarthScenes, id: string): CardSpec;
|
|
17
22
|
export declare function EarthScenesCard({ context, }: {
|
|
18
23
|
context: ToolCallRenderContext;
|
|
19
24
|
}): JSX.Element;
|