@agent-cards/commerce-sdk 0.18.3 → 0.18.4
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/client.d.ts +15 -1
- package/dist/client.js +7 -1
- package/dist/index.d.ts +1 -1
- package/package.json +2 -1
package/dist/client.d.ts
CHANGED
|
@@ -429,6 +429,19 @@ export interface BuyChoiceOption {
|
|
|
429
429
|
label: string;
|
|
430
430
|
/** What choosing it adds to the price, in cents: 0 when free, null when the store does not say. */
|
|
431
431
|
price_delta_cents: number | null;
|
|
432
|
+
/** On a `recipe_delivery` choice: the grocery store, when it arrives and what this way costs. Absent on every other choice. */
|
|
433
|
+
delivery?: BuyChoiceDelivery;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* One way a recipe's groceries can come: the DoorDash grocery store, its street when DoorDash names one, its delivery estimate in
|
|
437
|
+
* minutes (null when DoorDash shows none), the total with DoorDash's fees, and the part of that total that ships from Walmart or Amazon.
|
|
438
|
+
*/
|
|
439
|
+
export interface BuyChoiceDelivery {
|
|
440
|
+
store: string;
|
|
441
|
+
store_address: string | null;
|
|
442
|
+
eta_minutes: number | null;
|
|
443
|
+
total_cents: number;
|
|
444
|
+
shipped_cents: number;
|
|
432
445
|
}
|
|
433
446
|
/** One group of values, such as a sandwich's bread or a shirt's size. `min` and `max` count the values picked; `max` null for no limit. */
|
|
434
447
|
export interface BuyChoiceGroup {
|
|
@@ -441,7 +454,8 @@ export interface BuyChoiceGroup {
|
|
|
441
454
|
/**
|
|
442
455
|
* The choice an answer's reply asks the shopper to make, as data: the question, the item it is about, where the values come
|
|
443
456
|
* from (`menu_item`: a restaurant item's options, `store_checkout`: a store's own size or colour question, `catalog_variant`:
|
|
444
|
-
* a product's sizes or colours in stock
|
|
457
|
+
* a product's sizes or colours in stock, `recipe_delivery`: the ways a recipe's groceries can come, each option with its
|
|
458
|
+
* `delivery`), and every group with its values.
|
|
445
459
|
*/
|
|
446
460
|
export interface BuyChoice {
|
|
447
461
|
question: string | null;
|
package/dist/client.js
CHANGED
|
@@ -309,11 +309,17 @@ export function choiceOf(value) {
|
|
|
309
309
|
if (!isRecord(value) || !Array.isArray(value.groups))
|
|
310
310
|
return null;
|
|
311
311
|
const groups = value.groups.filter(isRecord).flatMap((g) => {
|
|
312
|
-
const options = (Array.isArray(g.options) ? g.options : []).filter(isRecord).flatMap((o) => str(o.label) ? [{ id: str(o.id), label: o.label.trim(), price_delta_cents: num(o.price_delta_cents) }] : []);
|
|
312
|
+
const options = (Array.isArray(g.options) ? g.options : []).filter(isRecord).flatMap((o) => str(o.label) ? [{ id: str(o.id), label: o.label.trim(), price_delta_cents: num(o.price_delta_cents), ...deliveryOf(o.delivery) }] : []);
|
|
313
313
|
return options.length ? [{ name: str(g.name) ?? '', required: g.required === true, min: num(g.min) ?? 0, max: num(g.max), options }] : [];
|
|
314
314
|
});
|
|
315
315
|
return groups.length ? { question: str(value.question), item: str(value.item), source: str(value.source) ?? '', groups } : null;
|
|
316
316
|
}
|
|
317
|
+
/** A recipe option's `delivery`, as `{ delivery }` when it names a store and a total, else nothing. */
|
|
318
|
+
function deliveryOf(value) {
|
|
319
|
+
if (!isRecord(value) || !str(value.store) || num(value.total_cents) === null)
|
|
320
|
+
return {};
|
|
321
|
+
return { delivery: { store: value.store, store_address: str(value.store_address), eta_minutes: num(value.eta_minutes), total_cents: num(value.total_cents), shipped_cents: num(value.shipped_cents) ?? 0 } };
|
|
322
|
+
}
|
|
317
323
|
/** A cart being built, as an answer, a refusal or the conversation read names it. */
|
|
318
324
|
export function cartBuildingOf(value) {
|
|
319
325
|
return isRecord(value) && str(value.store) ? { store: value.store, started_at: str(value.started_at) ?? '' } : null;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { readPurchaseMessage, type PurchaseMessage, type PurchaseMessageKind, ty
|
|
|
3
3
|
export { readShopperMessage, isStale, SHOPPER_EVENT_TYPES, NEXT_STEP_KINDS, type NextStepKind, type ShopperMessage, type ShopperMessageKind, type ShopperFacts, type ShopperEventType, type OrderStatus, } from './shopper-message.js';
|
|
4
4
|
export { ORDER_STEPS, updateOrder, arrivalText, type ShopperOrder, type OrderStep, type OrderPathStep, type OrderStepState, type ArrivalTextOptions, } from './order.js';
|
|
5
5
|
export { agentcardWebhook, purchaseAgentWebhook, type AgentcardWebhookOptions, type AgentcardWebhookHandler, type PurchaseAgentWebhookOptions, type WebhookFetchRequest, type WebhookRequest, type WebhookResponse, } from './handler.js';
|
|
6
|
-
export { AgentcardClient, AgentcardApiError, BUY_TURN_TIMEOUT_MS, DEFAULT_BASE_URL, type AgentcardClientOptions, type AgentcardTraceOptions, type OtelApi, type TraceContext, type FetchLike, type FetchLikeResponse, type BuyProgress, type BuyProgressStage, type BuyCatalogUpdate, type BuyAvailability, type BuyAvailabilityUpdate, type BuyFoundUpdate, type BuyTurnStatus, type BuySegmentUpdate, type BuyCartUpdate, type BuyDeltaUpdate, type BuyStreamHandlers, type Shopper, type BuyLastAnswer, type BuyRequest, type BuyDeliveryAddress, type BuyTurn, type BuyStatus, type BuyCart, type BuyCartBuilding, type BuyCartLine, type BuyCartFeeLine, type BuyStore, type BuyCatalog, type BuyCatalogItem, type BuyFlightItinerary, type BuyPaymentSource, type BuyConversation, type BuyLastCheckout, type BuyOrder, type VaultLink, type BuyNextAction, type BuyPick, type BuyStoreChoice, type BuyStorePick, type BuyStores, type BuyChoice, type BuyChoiceGroup, type BuyChoiceOption, } from './client.js';
|
|
6
|
+
export { AgentcardClient, AgentcardApiError, BUY_TURN_TIMEOUT_MS, DEFAULT_BASE_URL, type AgentcardClientOptions, type AgentcardTraceOptions, type OtelApi, type TraceContext, type FetchLike, type FetchLikeResponse, type BuyProgress, type BuyProgressStage, type BuyCatalogUpdate, type BuyAvailability, type BuyAvailabilityUpdate, type BuyFoundUpdate, type BuyTurnStatus, type BuySegmentUpdate, type BuyCartUpdate, type BuyDeltaUpdate, type BuyStreamHandlers, type Shopper, type BuyLastAnswer, type BuyRequest, type BuyDeliveryAddress, type BuyTurn, type BuyStatus, type BuyCart, type BuyCartBuilding, type BuyCartLine, type BuyCartFeeLine, type BuyStore, type BuyCatalog, type BuyCatalogItem, type BuyFlightItinerary, type BuyPaymentSource, type BuyConversation, type BuyLastCheckout, type BuyOrder, type VaultLink, type BuyNextAction, type BuyPick, type BuyStoreChoice, type BuyStorePick, type BuyStores, type BuyChoice, type BuyChoiceGroup, type BuyChoiceDelivery, type BuyChoiceOption, } from './client.js';
|
|
7
7
|
export { BUY_TOOL_NAME, BUY_TOOL_DESCRIPTION, buyToolDefinition, parseBuyToolInput, type BuyToolDefinition, type BuyToolInput, type BuyToolInputSchema, type BuyToolInputCheck, type BuyToolStandardSchema, type OpenAIBuyTool, } from './definition.js';
|
|
8
8
|
export { toMessages, messageStream, typingDelay, type MessagePace, type MessageStream, type MessageStreamOptions, } from './messages.js';
|
|
9
9
|
export { buyTool, nextStepPrompt, type BuyTool, type BuyToolOptions, type BuyToolResult, type BuyToolStatus, type BuyToolLink, type BuyToolFound, type BuyToolAvailability, type BuyToolProduct, type BuyToolProductAction, productAction, type BuyToolStore, type BuyToolTurn, type BuyToolTurnItem, type BuyToolTurnOptions, type BuyToolTurnMessage, type BuyAckMode, } from './buy-tool.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-cards/commerce-sdk",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.4",
|
|
4
4
|
"description": "Give your agent one tool that buys for your shoppers at real stores, and post each purchase update Agentcard sends into the shopper's chat, over a connection your server opens or a webhook endpoint.",
|
|
5
|
+
"homepage": "https://opencommerce.sh",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "dist/index.js",
|
|
7
8
|
"types": "dist/index.d.ts",
|