@datalayer/agent-runtimes 1.5.6 → 1.5.7

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.
@@ -47,6 +47,8 @@ export declare function negotiateCapabilities(profile: Json, reactor: ReactorPla
47
47
  export declare function revisionOf(checkout: Json): Promise<string>;
48
48
  /** What an agent may see of a checkout: no payment credential, no token. */
49
49
  export declare function checkoutSummary(checkout: Json): Json;
50
+ /** What an agent may see of an order: its lines, how far each is fulfilled, its totals and link. */
51
+ export declare function orderSummary(order: Json): Json;
50
52
  /** A platform's client of one business, over the REST binding. */
51
53
  export declare class UcpClient {
52
54
  private readonly business;
@@ -67,6 +69,8 @@ export declare class UcpClient {
67
69
  updateCheckout(id: string, update: Json): Promise<Json>;
68
70
  getCheckout(id: string): Promise<Json>;
69
71
  cancelCheckout(id: string): Promise<Json>;
72
+ /** After the sale: an order the business placed, its lines and how far each is fulfilled (`read`). */
73
+ getOrder(id: string): Promise<Json>;
70
74
  /** The exact purchase a `ready_for_complete` checkout would make. */
71
75
  proposeCompletion(id: string): Promise<CheckoutProposal>;
72
76
  /** Complete an approved proposal, once: refused if unapproved, spent, changed or expired. */
@@ -16,7 +16,7 @@
16
16
  * @module protocols/ucp
17
17
  */
18
18
  import { contribution, defineContributionPoint, definePlugin, } from '@datalayer/reactor';
19
- import { ExtendedCheckoutResponseSchema } from '@ucp-js/sdk';
19
+ import { ExtendedCheckoutResponseSchema, OrderSchema } from '@ucp-js/sdk';
20
20
  import { InMemoryProposalStore, digest, operationClasses, } from '../commerce';
21
21
  import { DEFAULT_ORDER, ProtocolDescriptions, firstContribution, } from '../core';
22
22
  export const UCP_VERSION = '2026-08-25';
@@ -131,6 +131,32 @@ export function checkoutSummary(checkout) {
131
131
  ...(checkout.order ? { order: { id: checkout.order.id } } : {}),
132
132
  };
133
133
  }
134
+ function readOrder(body) {
135
+ if (body?.ucp?.status === 'error') {
136
+ const said = (body.messages ?? []).map((m) => m.content).join('; ');
137
+ throw new UcpError(`the business refused: ${said}`);
138
+ }
139
+ OrderSchema.parse(body);
140
+ return body;
141
+ }
142
+ /** What an agent may see of an order: its lines, how far each is fulfilled, its totals and link. */
143
+ export function orderSummary(order) {
144
+ return {
145
+ id: order.id,
146
+ checkoutId: order.checkout_id,
147
+ permalinkUrl: order.permalink_url,
148
+ currency: order.currency,
149
+ lines: (order.line_items ?? []).map((line) => ({
150
+ title: line.item?.title ?? line.item?.id,
151
+ quantity: line.quantity?.total,
152
+ fulfilled: line.quantity?.fulfilled,
153
+ status: line.status,
154
+ })),
155
+ totals: Object.fromEntries((order.totals ?? []).map((t) => [t.type, t.amount])),
156
+ events: (order.fulfillment?.events ?? []).map((event) => event.type),
157
+ messages: (order.messages ?? []).map((m) => m.content),
158
+ };
159
+ }
134
160
  /** A platform's client of one business, over the REST binding. */
135
161
  export class UcpClient {
136
162
  business;
@@ -218,6 +244,10 @@ export class UcpClient {
218
244
  async cancelCheckout(id) {
219
245
  return readCheckout(await this.call('POST', `/checkout-sessions/${id}/cancel`, {}, crypto.randomUUID()));
220
246
  }
247
+ /** After the sale: an order the business placed, its lines and how far each is fulfilled (`read`). */
248
+ async getOrder(id) {
249
+ return readOrder(await this.call('GET', `/orders/${id}`));
250
+ }
221
251
  /** The exact purchase a `ready_for_complete` checkout would make. */
222
252
  async proposeCompletion(id) {
223
253
  const checkout = await this.getCheckout(id);
@@ -53,6 +53,8 @@ export function exampleStore(base = 'https://store.example') {
53
53
  const checkouts = new Map();
54
54
  const replies = new Map();
55
55
  const orders = [];
56
+ // Each order placed, by id: what was bought, as the order answers it.
57
+ const placed = new Map();
56
58
  const render = (checkout) => {
57
59
  let subtotal = 0;
58
60
  const lines = checkout.lines.map((line, index) => {
@@ -130,7 +132,13 @@ export function exampleStore(base = 'https://store.example') {
130
132
  checkouts.set(checkout.id, checkout);
131
133
  return { status: 201, body: render(checkout) };
132
134
  }
133
- const [, , id, action] = path.split('/');
135
+ const [, collection, id, action] = path.split('/');
136
+ if (collection === 'orders') {
137
+ const order = method === 'GET' && !action ? placed.get(id) : undefined;
138
+ return order
139
+ ? { status: 200, body: order }
140
+ : { status: 404, body: { messages: [{ content: 'No such order' }] } };
141
+ }
134
142
  const checkout = checkouts.get(id);
135
143
  if (!checkout) {
136
144
  return { status: 404, body: { messages: [{ content: 'No checkout' }] } };
@@ -180,7 +188,24 @@ export function exampleStore(base = 'https://store.example') {
180
188
  checkout.status = 'completed';
181
189
  checkout.order = order;
182
190
  orders.push({ order: order.id, checkout: checkout.id });
183
- return { status: 200, body: render(checkout) };
191
+ const rendered = render(checkout);
192
+ placed.set(order.id, {
193
+ ucp: { version: UCP_VERSION, status: 'success' },
194
+ id: order.id,
195
+ checkout_id: checkout.id,
196
+ permalink_url: order.permalink_url,
197
+ line_items: rendered.line_items.map((line) => ({
198
+ id: line.id,
199
+ item: line.item,
200
+ quantity: { total: line.quantity, fulfilled: 0 },
201
+ totals: line.totals,
202
+ status: 'processing',
203
+ })),
204
+ fulfillment: { events: [] },
205
+ currency: rendered.currency,
206
+ totals: rendered.totals,
207
+ });
208
+ return { status: 200, body: rendered };
184
209
  }
185
210
  if (method === 'POST' && action === 'cancel') {
186
211
  if (checkout.status !== 'completed') {
@@ -713,6 +713,7 @@ export const PROTOCOL_TOOL_CLASSES = {
713
713
  ucp_update_checkout: ['write'],
714
714
  ucp_cancel_checkout: ['write'],
715
715
  ucp_complete: ['buy'],
716
+ ucp_get_order: ['read'],
716
717
  },
717
718
  },
718
719
  };
@@ -773,6 +774,7 @@ export const APP_BEHAVIOURS = {
773
774
  'odoo-accounting.odoo_accounting_trial_balance': 'do_it',
774
775
  'odoo-accounting.odoo_accounting_unreconcile_lines': 'leave_to_me',
775
776
  },
777
+ 'bookkeeping-desk': {},
776
778
  'change-detection': {
777
779
  'earthdata.download_earth_data_granules': 'leave_to_me',
778
780
  'earthdata.search_earth_datagranules': 'do_it',
@@ -915,6 +917,7 @@ export const APP_BEHAVIOURS = {
915
917
  'google-workspace.update_drive_file': 'leave_to_me',
916
918
  'google-workspace.update_paragraph_style': 'leave_to_me',
917
919
  },
920
+ 'live-shop-chat': {},
918
921
  'model-choice': {},
919
922
  'month-end-close': {
920
923
  'odoo-accounting.odoo_accounting_aged_balance': 'do_it',
@@ -968,12 +971,16 @@ export const APP_BEHAVIOURS = {
968
971
  'odoo-accounting.odoo_accounting_unreconcile_lines': 'leave_to_me',
969
972
  },
970
973
  'order-desk': {},
974
+ 'order-tracker': {},
971
975
  'pipeline-report': {},
972
976
  'quote-calculator': {},
973
977
  'report-from-a-file': {},
978
+ 'returns-desk': {},
974
979
  sales: {},
975
980
  'ship-or-fix': {},
981
+ 'shop-concierge': {},
976
982
  'shopping-desk': {},
983
+ 'sign-in-desk': {},
977
984
  'supplier-comparison': {},
978
985
  'support-desk': {},
979
986
  'travel-desk': {},
@@ -991,6 +998,7 @@ export const APP_BEHAVIOURS = {
991
998
  */
992
999
  export const APP_ESCALATIONS = {
993
1000
  accounting: {},
1001
+ 'bookkeeping-desk': {},
994
1002
  'change-detection': {},
995
1003
  'crop-monitoring': {},
996
1004
  'customer-interview': {},
@@ -1033,15 +1041,20 @@ export const APP_ESCALATIONS = {
1033
1041
  },
1034
1042
  ],
1035
1043
  },
1044
+ 'live-shop-chat': {},
1036
1045
  'model-choice': {},
1037
1046
  'month-end-close': {},
1038
1047
  'order-desk': {},
1048
+ 'order-tracker': {},
1039
1049
  'pipeline-report': {},
1040
1050
  'quote-calculator': {},
1041
1051
  'report-from-a-file': {},
1052
+ 'returns-desk': {},
1042
1053
  sales: {},
1043
1054
  'ship-or-fix': {},
1055
+ 'shop-concierge': {},
1044
1056
  'shopping-desk': {},
1057
+ 'sign-in-desk': {},
1045
1058
  'supplier-comparison': {},
1046
1059
  'support-desk': {},
1047
1060
  'travel-desk': {},
@@ -9,6 +9,7 @@
9
9
  */
10
10
  import type { AppBuilt, AppKind, AppSpec } from '../types/agentspecs';
11
11
  export declare const ACCOUNTING_APP_0_0_1: AppSpec;
12
+ export declare const BOOKKEEPING_DESK_APP_0_0_1: AppSpec;
12
13
  export declare const CHANGE_DETECTION_APP_0_0_1: AppSpec;
13
14
  export declare const CROP_MONITORING_APP_0_0_1: AppSpec;
14
15
  export declare const CUSTOMER_INTERVIEW_APP_0_0_1: AppSpec;
@@ -18,15 +19,20 @@ export declare const DISASTER_ASSESSMENT_APP_0_0_1: AppSpec;
18
19
  export declare const EVENT_RESPONSE_APP_0_0_1: AppSpec;
19
20
  export declare const EXCHANGE_DESK_APP_0_0_1: AppSpec;
20
21
  export declare const INBOX_TRIAGE_APP_0_0_1: AppSpec;
22
+ export declare const LIVE_SHOP_CHAT_APP_0_0_1: AppSpec;
21
23
  export declare const MODEL_CHOICE_APP_0_0_1: AppSpec;
22
24
  export declare const MONTH_END_CLOSE_APP_0_0_1: AppSpec;
23
25
  export declare const ORDER_DESK_APP_0_0_1: AppSpec;
26
+ export declare const ORDER_TRACKER_APP_0_0_1: AppSpec;
24
27
  export declare const PIPELINE_REPORT_APP_0_0_1: AppSpec;
25
28
  export declare const QUOTE_CALCULATOR_APP_0_0_1: AppSpec;
26
29
  export declare const REPORT_FROM_A_FILE_APP_0_0_1: AppSpec;
30
+ export declare const RETURNS_DESK_APP_0_0_1: AppSpec;
27
31
  export declare const SALES_APP_0_0_1: AppSpec;
28
32
  export declare const SHIP_OR_FIX_APP_0_0_1: AppSpec;
33
+ export declare const SHOP_CONCIERGE_APP_0_0_1: AppSpec;
29
34
  export declare const SHOPPING_DESK_APP_0_0_1: AppSpec;
35
+ export declare const SIGN_IN_DESK_APP_0_0_1: AppSpec;
30
36
  export declare const SUPPLIER_COMPARISON_APP_0_0_1: AppSpec;
31
37
  export declare const SUPPORT_DESK_APP_0_0_1: AppSpec;
32
38
  export declare const TRAVEL_DESK_APP_0_0_1: AppSpec;