@agent-cards/commerce-sdk 0.16.0 → 0.17.0

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/texting.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { forModel, replyAsWritten as replyWithoutCardList } from './model-view.js';
2
+ import { toMessages } from './messages.js';
2
3
  /** The mark every list line starts with. */
3
4
  const BULLET = '• ';
4
5
  /** A line that is a list item: `- `, `* `, `• `, `1. ` or `1) `, then text. The number, when it has one, is group 2. */
@@ -184,6 +185,8 @@ function namesOne(item, names) {
184
185
  * 6"), and Agentcard and `directCall` read that number against the list. Null for any other answer, which your model
185
186
  * puts in its own words, for a line the tool wrote itself for your model, and once the shopper read the reply through
186
187
  * `onText` (`shopper_already_read_reply`). `{ textingStyle: true }` hands it over in the texting style (`textingStyle`).
188
+ * A paragraph that ends with a colon, such as `two options came in under $20:`, shares its message with the paragraph
189
+ * after it, and one that nothing follows loses its colon sentence, so the shopper never reads a message ending on a colon.
187
190
  *
188
191
  * ```ts
189
192
  * replyAsWritten(result); // 'which bread do you want?\n\n• Sourdough\n• Whole wheat'
@@ -196,7 +199,9 @@ export function replyAsWritten(result, options = {}) {
196
199
  const view = forModel(result);
197
200
  const names = [...view.products.map((product) => product.name), ...view.stores.map((store) => store.name)].map(wordsOf).filter((name) => name.length > 0);
198
201
  const bulleted = withChoice(bulletLists(reply, { keepNumbers: (items) => items.some((item) => namesOne(item, names)) }), result.choice ?? null);
199
- return (options.textingStyle ? styleLines(bulleted) : bulleted) || null;
202
+ // Read as the shopper's chat cuts it (toMessages), so a paragraph that leads in with a colon shares its message with
203
+ // the one after it, and one nothing follows loses its colon sentence: no message of it ends on a colon.
204
+ return toMessages(options.textingStyle ? styleLines(bulleted) : bulleted).join('\n\n') || null;
200
205
  }
201
206
  /**
202
207
  * One message of Agentcard's, as `onText` hands it to the app: its lists as `• ` bullet lines and, with `texting`, in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-cards/commerce-sdk",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
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
5
  "type": "module",
6
6
  "main": "dist/index.js",