@ouro.bot/cli 0.1.0-alpha.653 → 0.1.0-alpha.655

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.
Files changed (37) hide show
  1. package/changelog.json +13 -0
  2. package/dist/a2a/card.js +56 -0
  3. package/dist/a2a/client.js +143 -0
  4. package/dist/a2a/config.js +50 -0
  5. package/dist/a2a/onboarding.js +111 -0
  6. package/dist/a2a/server.js +498 -0
  7. package/dist/a2a/task-store.js +69 -0
  8. package/dist/a2a/types.js +3 -0
  9. package/dist/commerce/store.js +755 -0
  10. package/dist/commerce/types.js +3 -0
  11. package/dist/heart/daemon/cli-exec.js +118 -3
  12. package/dist/heart/daemon/cli-help.js +29 -2
  13. package/dist/heart/daemon/cli-parse.js +88 -4
  14. package/dist/heart/daemon/daemon.js +2 -1
  15. package/dist/heart/daemon/process-manager.js +2 -1
  16. package/dist/heart/daemon/runtime-logging.js +1 -1
  17. package/dist/heart/daemon/sense-manager.js +71 -15
  18. package/dist/heart/identity.js +4 -1
  19. package/dist/heart/sense-truth.js +2 -0
  20. package/dist/heart/turn-context.js +6 -0
  21. package/dist/mind/friends/channel.js +10 -1
  22. package/dist/mind/friends/resolver.js +13 -2
  23. package/dist/mind/friends/store-file.js +13 -0
  24. package/dist/mind/friends/types.js +1 -1
  25. package/dist/mind/prompt.js +11 -0
  26. package/dist/repertoire/guardrails.js +25 -2
  27. package/dist/repertoire/tools-a2a.js +283 -0
  28. package/dist/repertoire/tools-base.js +4 -0
  29. package/dist/repertoire/tools-commerce.js +253 -0
  30. package/dist/repertoire/tools-flight.js +68 -5
  31. package/dist/repertoire/tools-stripe.js +49 -7
  32. package/dist/repertoire/tools.js +50 -2
  33. package/dist/senses/a2a-entry.js +78 -0
  34. package/dist/senses/pipeline.js +13 -0
  35. package/dist/senses/shared-turn.js +30 -5
  36. package/package.json +1 -1
  37. package/skills/agent-commerce.md +17 -10
@@ -188,6 +188,16 @@ function emitObligationTransitionEpisodes(agentRoot, preTurnObligationIds, postT
188
188
  function providerLaneForChannel(channel) {
189
189
  return channel === "inner" ? "inner" : "outward";
190
190
  }
191
+ function latestUserAuthoredText(messages, continuityIngressTexts) {
192
+ const ingress = continuityIngressTexts?.map((entry) => entry.trim()).filter(Boolean);
193
+ if (ingress?.length)
194
+ return ingress[ingress.length - 1];
195
+ const userMessages = messages
196
+ .filter((message) => message.role === "user")
197
+ .map((message) => typeof message.content === "string" ? message.content.trim() : "")
198
+ .filter(Boolean);
199
+ return userMessages[userMessages.length - 1];
200
+ }
191
201
  function resolveCurrentFailoverBinding(agentName, lane) {
192
202
  const agentRoot = (0, identity_1.getAgentRoot)();
193
203
  const { config: agentConfig } = (0, auth_flow_1.readAgentConfigForAgent)(agentName, path.dirname(agentRoot));
@@ -676,6 +686,8 @@ async function handleInboundTurn(input) {
676
686
  }
677
687
  // Step 5: runAgent
678
688
  const existingToolContext = input.runAgentOptions?.toolContext;
689
+ const currentUserMessage = existingToolContext?.currentUserMessage
690
+ ?? latestUserAuthoredText(input.messages, input.continuityIngressTexts);
679
691
  const runAgentOptions = {
680
692
  ...input.runAgentOptions,
681
693
  ...(orientationFrame ? { orientationFrame } : {}),
@@ -702,6 +714,7 @@ async function handleInboundTurn(input) {
702
714
  /* v8 ignore next -- default no-op signin satisfies interface; real signin injected by sense adapter @preserve */
703
715
  signin: async () => undefined,
704
716
  ...existingToolContext,
717
+ ...(currentUserMessage ? { currentUserMessage } : {}),
705
718
  context: resolvedContext,
706
719
  friendStore: input.friendStore,
707
720
  currentSession,
@@ -199,7 +199,16 @@ async function runSenseTurn(options) {
199
199
  // Otherwise, resolve as a local user (same pattern as CLI sense).
200
200
  const isUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-/.test(friendId);
201
201
  let resolverParams;
202
- if (isUuid) {
202
+ if (options.identity) {
203
+ resolverParams = {
204
+ provider: options.identity.provider,
205
+ externalId: options.identity.externalId,
206
+ displayName: options.identity.displayName,
207
+ channel,
208
+ ...(options.identity.tenantId ? { tenantId: options.identity.tenantId } : {}),
209
+ };
210
+ }
211
+ else if (isUuid) {
203
212
  const existingFriend = await friendStore.get(friendId);
204
213
  if (existingFriend) {
205
214
  // Use the friend's first external ID for resolver context
@@ -298,7 +307,7 @@ async function runSenseTurn(options) {
298
307
  // Run the pipeline
299
308
  const userMsg = { role: "user", content: userMessage };
300
309
  (0, session_events_1.stampIngressTime)(userMsg);
301
- await (0, pipeline_1.handleInboundTurn)({
310
+ const turnResult = await (0, pipeline_1.handleInboundTurn)({
302
311
  channel,
303
312
  latencyMode: options.latencyMode,
304
313
  sessionKey,
@@ -319,14 +328,19 @@ async function runSenseTurn(options) {
319
328
  /* v8 ignore stop */
320
329
  pendingDir,
321
330
  friendStore,
322
- provider: "local",
323
- externalId: friendId,
331
+ provider: resolverParams.provider,
332
+ externalId: resolverParams.externalId,
333
+ tenantId: resolverParams.tenantId,
324
334
  enforceTrustGate: trust_gate_1.enforceTrustGate,
325
335
  drainPending: pending_1.drainPending,
326
336
  runAgentOptions: {
327
337
  mcpManager,
328
338
  ...(options.latencyMode === "live" ? { skipKeptNotes: true } : {}),
329
- ...(options.toolContext ? { toolContext: options.toolContext } : {}),
339
+ toolContext: {
340
+ signin: async () => undefined,
341
+ ...(options.toolContext ? options.toolContext : {}),
342
+ currentUserMessage: userMessage,
343
+ },
330
344
  },
331
345
  /* v8 ignore start — delegation wrappers; these just forward to the real functions */
332
346
  runAgent: (msgs, cb, ch, sig, opts) => (0, core_1.runAgent)(msgs, cb, ch, sig, opts),
@@ -338,6 +352,17 @@ async function runSenseTurn(options) {
338
352
  /* v8 ignore stop */
339
353
  accumulateFriendTokens: tokens_1.accumulateFriendTokens,
340
354
  });
355
+ if (turnResult.gateResult && !turnResult.gateResult.allowed) {
356
+ const blockedResponse = "autoReply" in turnResult.gateResult
357
+ ? turnResult.gateResult.autoReply
358
+ : `(blocked by trust gate: ${turnResult.gateResult.reason})`;
359
+ return {
360
+ response: blockedResponse,
361
+ ponderDeferred: false,
362
+ deliveries,
363
+ deliveryFailures,
364
+ };
365
+ }
341
366
  await deliverPending(terminalDeliveryKind, { throwOnError: false });
342
367
  const ponderDeferred = false;
343
368
  // Build response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.653",
3
+ "version": "0.1.0-alpha.655",
4
4
  "main": "dist/heart/daemon/ouro-entry.js",
5
5
  "bin": {
6
6
  "cli": "dist/heart/daemon/ouro-bot-entry.js",
@@ -10,14 +10,16 @@ For services with direct API access: Duffel flights, LiteAPI hotels.
10
10
 
11
11
  1. Search using the API tool (`flight_search`, LiteAPI MCP)
12
12
  2. Present options to the human with prices and details
13
- 3. Human approves a specific option and price
14
- 4. Book using the API tool with passenger data from `user_profile_get`
15
- 5. Create a single-use virtual card via `stripe_create_card`
16
- 6. Complete payment through the API
17
- 7. Deactivate the card via `stripe_deactivate_card`
18
- 8. Confirm booking to the human
13
+ 3. Create a checkout preview with `commerce_checkout_preview` for the exact merchant, item, amount, currency, allowed tool, and exact tool constraints
14
+ 4. Human approves in a new message that exactly equals the preview's `confirmationMessage`, including checkout id, digest, merchant, amount, currency, allowed tool, and constraints
15
+ 5. Commit the preview with `commerce_checkout_commit`; then call the approved payment or booking tool with the exact amount, currency, and constraints from the preview. Ouro consumes the matching authority without exposing a bearer token in the transcript.
16
+ 6. Book using the API tool with passenger data from `user_profile_get`
17
+ 7. Create a single-use virtual card via `stripe_create_card` when needed
18
+ 8. Complete payment through the API
19
+ 9. Deactivate the card via `stripe_deactivate_card`
20
+ 10. Confirm booking to the human and record/read back the receipt with `commerce_receipt_get`
19
21
 
20
- **Key tools**: `flight_search`, `flight_book`, `flight_cancel`, `user_profile_get`, `user_profile_store`, `stripe_create_card`, `stripe_deactivate_card`, `stripe_list_cards`
22
+ **Key tools**: `commerce_checkout_preview`, `commerce_checkout_commit`, `commerce_receipt_get`, `flight_search`, `flight_book`, `flight_cancel`, `user_profile_get`, `user_profile_store`, `stripe_create_card`, `stripe_deactivate_card`, `stripe_list_cards`
21
23
 
22
24
  ### Pattern B: Browser (Best-Effort)
23
25
 
@@ -26,9 +28,10 @@ For sites without API access, use browser automation via Playwright MCP.
26
28
  1. Navigate to the booking site
27
29
  2. Search for the requested service
28
30
  3. Fill forms using data from `user_profile_get`
29
- 4. Use a virtual card from `stripe_create_card` for payment
30
- 5. If blocked by anti-bot measures, fall back to Pattern C
31
- 6. Complete and confirm the booking
31
+ 4. Create and commit a checkout preview before entering payment details
32
+ 5. Use a virtual card from `stripe_create_card` for payment
33
+ 6. If blocked by anti-bot measures, fall back to Pattern C
34
+ 7. Complete and confirm the booking
32
35
 
33
36
  **Limitations**: Browser automation is fragile. Sites may block, layouts change, CAPTCHAs appear. Always have Pattern C as fallback.
34
37
 
@@ -52,6 +55,10 @@ For sites that block automation or require complex human interaction.
52
55
 
53
56
  Default is Level 1. Level changes require explicit human approval.
54
57
 
58
+ ## Commerce Authority
59
+
60
+ Money-moving tools (`stripe_create_card`, `flight_hold`, `flight_book`) require a one-use confirmed commerce authority. This is the local AP2-compatible primitive: an exact mandate record with merchant, amount, currency, allowed tool, exact tool constraints, reason, digest, expiry, confirmation, reservation/attempt/consumption state, and access log. `commerce_checkout_commit` confirms the authority but does not reveal a live bearer token to the model; the runtime reserves the one matching confirmed authority under a checkout lock, marks it attempted before crossing an external provider boundary, and consumes it only after the successful side effect is verified. A pre-attempt validation failure can release the reservation; an attempted Stripe/Duffel call stays non-replayable so ambiguous provider failures cannot create duplicate cards or bookings. Stripe card authority must include exact `type` and `merchant_categories` constraints so the card is counterparty/category-bound. If the tool, amount, currency, offer id, card type, merchant category, or other constraint changes, create a new preview and get a new confirmation.
61
+
55
62
  ## Error Handling
56
63
 
57
64
  ### Price Change Guard