@wix/himalaya-cli 0.1377.0 → 0.1379.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.
Files changed (178) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/app-info/src/index.d.ts +4 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/ecom/src/extensions.d.ts +113 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/app-info.mjs +2 -1
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap-checkout.mjs +2 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +2 -1
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-ecom.mjs +77 -0
  7. package/dist/cli.mjs +24 -23
  8. package/dist/preview-assets.generated.bin +0 -0
  9. package/guides/importable-sdks.md +1 -1
  10. package/guides/index.json +6 -0
  11. package/guides/sdk-reference.json +128 -2
  12. package/guides/wix-api-usage.md +7 -5
  13. package/guides/wix-pro-gallery.md +145 -0
  14. package/package.json +2 -2
  15. package/templates/beauty-salon/config.ts +23 -0
  16. package/templates/beauty-salon/dev/index.ts +2611 -1
  17. package/templates/beauty-salon/himalaya.content.json +9 -0
  18. package/templates/beauty-salon/tier5-src/_shared/branded-lite-hosted.ts +3 -0
  19. package/templates/beauty-salon/tier5-src/_shared/member-access.ts +14 -0
  20. package/templates/beauty-salon/tier5-src/_shared/member-account-routes.ts +43 -0
  21. package/templates/beauty-salon/tier5-src/_shared/member-address.ts +129 -0
  22. package/templates/beauty-salon/tier5-src/_shared/saved-card.ts +20 -0
  23. package/templates/beauty-salon/tier5-src/himi-branded-lite-address/index.ts +223 -0
  24. package/templates/beauty-salon/tier5-src/himi-branded-lite-addresses/index.ts +202 -0
  25. package/templates/beauty-salon/tier5-src/himi-branded-lite-wallet/index.ts +217 -0
  26. package/templates/beauty-salon/tier5-src/himi-store-account/index.ts +17 -0
  27. package/templates/beauty-salon-owner/dev/index.ts +5 -27
  28. package/templates/beauty-salon-owner/tier5-src/_shared/aria-chat.ts +99 -40
  29. package/templates/beauty-salon-owner/tier5-src/_shared/aria-widget-oauth.ts +42 -0
  30. package/templates/beauty-salon-owner/tier5-src/_shared/aria-widget-view.ts +6 -0
  31. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-aria/index.ts +12 -1
  32. package/templates/branded-lite/config.ts +23 -0
  33. package/templates/branded-lite/dev/index.ts +2614 -2
  34. package/templates/branded-lite/himalaya.content.json +9 -0
  35. package/templates/branded-lite/tier5-src/_shared/branded-lite-hosted.ts +3 -0
  36. package/templates/branded-lite/tier5-src/_shared/member-access.ts +14 -0
  37. package/templates/branded-lite/tier5-src/_shared/member-account-routes.ts +43 -0
  38. package/templates/branded-lite/tier5-src/_shared/member-address.ts +129 -0
  39. package/templates/branded-lite/tier5-src/_shared/saved-card.ts +20 -0
  40. package/templates/branded-lite/tier5-src/himi-branded-lite-address/index.ts +223 -0
  41. package/templates/branded-lite/tier5-src/himi-branded-lite-addresses/index.ts +202 -0
  42. package/templates/branded-lite/tier5-src/himi-branded-lite-wallet/index.ts +217 -0
  43. package/templates/branded-lite/tier5-src/himi-store-account/index.ts +17 -0
  44. package/templates/community-club/dev/index.ts +3 -1
  45. package/templates/community-club/tier5-src/_shared/branded-lite-hosted.ts +3 -0
  46. package/templates/community-club/tier5-src/_shared/member-access.ts +14 -0
  47. package/templates/community-club/tier5-src/_shared/member-account-routes.ts +43 -0
  48. package/templates/community-club/tier5-src/himi-store-account/index.ts +17 -0
  49. package/templates/community-club-owner/dev/index.ts +5 -27
  50. package/templates/community-club-owner/tier5-src/_shared/aria-chat.ts +99 -40
  51. package/templates/community-club-owner/tier5-src/_shared/aria-widget-oauth.ts +42 -0
  52. package/templates/community-club-owner/tier5-src/_shared/aria-widget-view.ts +6 -0
  53. package/templates/community-club-owner/tier5-src/himi-owner-lite-aria/index.ts +12 -1
  54. package/templates/events-meetups/dev/index.ts +3 -1
  55. package/templates/events-meetups/tier5-src/_shared/branded-lite-hosted.ts +3 -0
  56. package/templates/events-meetups/tier5-src/_shared/member-access.ts +14 -0
  57. package/templates/events-meetups/tier5-src/_shared/member-account-routes.ts +43 -0
  58. package/templates/events-meetups/tier5-src/himi-store-account/index.ts +17 -0
  59. package/templates/events-meetups-owner/dev/index.ts +5 -27
  60. package/templates/events-meetups-owner/tier5-src/_shared/aria-chat.ts +99 -40
  61. package/templates/events-meetups-owner/tier5-src/_shared/aria-widget-oauth.ts +42 -0
  62. package/templates/events-meetups-owner/tier5-src/_shared/aria-widget-view.ts +6 -0
  63. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-aria/index.ts +12 -1
  64. package/templates/gym-fitness/config.ts +23 -0
  65. package/templates/gym-fitness/dev/index.ts +2611 -1
  66. package/templates/gym-fitness/himalaya.content.json +9 -0
  67. package/templates/gym-fitness/tier5-src/_shared/branded-lite-hosted.ts +3 -0
  68. package/templates/gym-fitness/tier5-src/_shared/member-access.ts +14 -0
  69. package/templates/gym-fitness/tier5-src/_shared/member-account-routes.ts +43 -0
  70. package/templates/gym-fitness/tier5-src/_shared/member-address.ts +129 -0
  71. package/templates/gym-fitness/tier5-src/_shared/saved-card.ts +20 -0
  72. package/templates/gym-fitness/tier5-src/himi-branded-lite-address/index.ts +223 -0
  73. package/templates/gym-fitness/tier5-src/himi-branded-lite-addresses/index.ts +202 -0
  74. package/templates/gym-fitness/tier5-src/himi-branded-lite-wallet/index.ts +217 -0
  75. package/templates/gym-fitness/tier5-src/himi-store-account/index.ts +17 -0
  76. package/templates/gym-fitness-owner/dev/index.ts +5 -27
  77. package/templates/gym-fitness-owner/tier5-src/_shared/aria-chat.ts +99 -40
  78. package/templates/gym-fitness-owner/tier5-src/_shared/aria-widget-oauth.ts +42 -0
  79. package/templates/gym-fitness-owner/tier5-src/_shared/aria-widget-view.ts +6 -0
  80. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-aria/index.ts +12 -1
  81. package/templates/nonprofit-cause/config.ts +7 -0
  82. package/templates/nonprofit-cause/dev/index.ts +762 -1
  83. package/templates/nonprofit-cause/himalaya.content.json +3 -0
  84. package/templates/nonprofit-cause/tier5-src/_shared/branded-lite-hosted.ts +3 -0
  85. package/templates/nonprofit-cause/tier5-src/_shared/member-access.ts +14 -0
  86. package/templates/nonprofit-cause/tier5-src/_shared/member-account-routes.ts +43 -0
  87. package/templates/nonprofit-cause/tier5-src/_shared/saved-card.ts +20 -0
  88. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-wallet/index.ts +217 -0
  89. package/templates/nonprofit-cause/tier5-src/himi-store-account/index.ts +17 -0
  90. package/templates/nonprofit-cause-owner/dev/index.ts +5 -27
  91. package/templates/nonprofit-cause-owner/tier5-src/_shared/aria-chat.ts +99 -40
  92. package/templates/nonprofit-cause-owner/tier5-src/_shared/aria-widget-oauth.ts +42 -0
  93. package/templates/nonprofit-cause-owner/tier5-src/_shared/aria-widget-view.ts +6 -0
  94. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-aria/index.ts +12 -1
  95. package/templates/owner-lite/dev/index.ts +5 -27
  96. package/templates/owner-lite/tier5-src/_shared/aria-chat.ts +99 -40
  97. package/templates/owner-lite/tier5-src/_shared/aria-widget-oauth.ts +42 -0
  98. package/templates/owner-lite/tier5-src/_shared/aria-widget-view.ts +6 -0
  99. package/templates/owner-lite/tier5-src/himi-owner-lite-aria/index.ts +12 -1
  100. package/templates/podcast-creator/config.ts +7 -0
  101. package/templates/podcast-creator/dev/index.ts +762 -1
  102. package/templates/podcast-creator/himalaya.content.json +3 -0
  103. package/templates/podcast-creator/tier5-src/_shared/branded-lite-hosted.ts +3 -0
  104. package/templates/podcast-creator/tier5-src/_shared/member-access.ts +14 -0
  105. package/templates/podcast-creator/tier5-src/_shared/member-account-routes.ts +43 -0
  106. package/templates/podcast-creator/tier5-src/_shared/saved-card.ts +20 -0
  107. package/templates/podcast-creator/tier5-src/himi-branded-lite-wallet/index.ts +217 -0
  108. package/templates/podcast-creator/tier5-src/himi-store-account/index.ts +17 -0
  109. package/templates/podcast-creator-owner/dev/index.ts +5 -27
  110. package/templates/podcast-creator-owner/tier5-src/_shared/aria-chat.ts +99 -40
  111. package/templates/podcast-creator-owner/tier5-src/_shared/aria-widget-oauth.ts +42 -0
  112. package/templates/podcast-creator-owner/tier5-src/_shared/aria-widget-view.ts +6 -0
  113. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-aria/index.ts +12 -1
  114. package/templates/portfolio-creative/config.ts +23 -0
  115. package/templates/portfolio-creative/dev/index.ts +2611 -1
  116. package/templates/portfolio-creative/himalaya.content.json +9 -0
  117. package/templates/portfolio-creative/tier5-src/_shared/branded-lite-hosted.ts +3 -0
  118. package/templates/portfolio-creative/tier5-src/_shared/member-access.ts +14 -0
  119. package/templates/portfolio-creative/tier5-src/_shared/member-account-routes.ts +43 -0
  120. package/templates/portfolio-creative/tier5-src/_shared/member-address.ts +129 -0
  121. package/templates/portfolio-creative/tier5-src/_shared/saved-card.ts +20 -0
  122. package/templates/portfolio-creative/tier5-src/himi-branded-lite-address/index.ts +223 -0
  123. package/templates/portfolio-creative/tier5-src/himi-branded-lite-addresses/index.ts +202 -0
  124. package/templates/portfolio-creative/tier5-src/himi-branded-lite-wallet/index.ts +217 -0
  125. package/templates/portfolio-creative/tier5-src/himi-store-account/index.ts +17 -0
  126. package/templates/portfolio-creative-owner/dev/index.ts +5 -27
  127. package/templates/portfolio-creative-owner/tier5-src/_shared/aria-chat.ts +99 -40
  128. package/templates/portfolio-creative-owner/tier5-src/_shared/aria-widget-oauth.ts +42 -0
  129. package/templates/portfolio-creative-owner/tier5-src/_shared/aria-widget-view.ts +6 -0
  130. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-aria/index.ts +12 -1
  131. package/templates/restaurant/config.ts +23 -0
  132. package/templates/restaurant/dev/index.ts +2611 -1
  133. package/templates/restaurant/himalaya.content.json +9 -0
  134. package/templates/restaurant/tier5-src/_shared/branded-lite-hosted.ts +3 -0
  135. package/templates/restaurant/tier5-src/_shared/member-access.ts +14 -0
  136. package/templates/restaurant/tier5-src/_shared/member-account-routes.ts +43 -0
  137. package/templates/restaurant/tier5-src/_shared/member-address.ts +129 -0
  138. package/templates/restaurant/tier5-src/_shared/saved-card.ts +20 -0
  139. package/templates/restaurant/tier5-src/himi-branded-lite-address/index.ts +223 -0
  140. package/templates/restaurant/tier5-src/himi-branded-lite-addresses/index.ts +202 -0
  141. package/templates/restaurant/tier5-src/himi-branded-lite-wallet/index.ts +217 -0
  142. package/templates/restaurant/tier5-src/himi-store-account/index.ts +17 -0
  143. package/templates/restaurant-owner/dev/index.ts +5 -27
  144. package/templates/restaurant-owner/tier5-src/_shared/aria-chat.ts +99 -40
  145. package/templates/restaurant-owner/tier5-src/_shared/aria-widget-oauth.ts +42 -0
  146. package/templates/restaurant-owner/tier5-src/_shared/aria-widget-view.ts +6 -0
  147. package/templates/restaurant-owner/tier5-src/himi-owner-lite-aria/index.ts +12 -1
  148. package/templates/retail-store/config.ts +23 -0
  149. package/templates/retail-store/dev/index.ts +2611 -1
  150. package/templates/retail-store/himalaya.content.json +9 -0
  151. package/templates/retail-store/tier5-src/_shared/branded-lite-hosted.ts +3 -0
  152. package/templates/retail-store/tier5-src/_shared/member-access.ts +14 -0
  153. package/templates/retail-store/tier5-src/_shared/member-account-routes.ts +43 -0
  154. package/templates/retail-store/tier5-src/_shared/member-address.ts +129 -0
  155. package/templates/retail-store/tier5-src/_shared/saved-card.ts +20 -0
  156. package/templates/retail-store/tier5-src/himi-branded-lite-address/index.ts +223 -0
  157. package/templates/retail-store/tier5-src/himi-branded-lite-addresses/index.ts +202 -0
  158. package/templates/retail-store/tier5-src/himi-branded-lite-wallet/index.ts +217 -0
  159. package/templates/retail-store/tier5-src/himi-store-account/index.ts +17 -0
  160. package/templates/retail-store-owner/dev/index.ts +5 -27
  161. package/templates/retail-store-owner/tier5-src/_shared/aria-chat.ts +99 -40
  162. package/templates/retail-store-owner/tier5-src/_shared/aria-widget-oauth.ts +42 -0
  163. package/templates/retail-store-owner/tier5-src/_shared/aria-widget-view.ts +6 -0
  164. package/templates/retail-store-owner/tier5-src/himi-owner-lite-aria/index.ts +12 -1
  165. package/templates/yoga-studio/config.ts +7 -0
  166. package/templates/yoga-studio/dev/index.ts +762 -1
  167. package/templates/yoga-studio/himalaya.content.json +3 -0
  168. package/templates/yoga-studio/tier5-src/_shared/branded-lite-hosted.ts +3 -0
  169. package/templates/yoga-studio/tier5-src/_shared/member-access.ts +14 -0
  170. package/templates/yoga-studio/tier5-src/_shared/member-account-routes.ts +43 -0
  171. package/templates/yoga-studio/tier5-src/_shared/saved-card.ts +20 -0
  172. package/templates/yoga-studio/tier5-src/himi-branded-lite-wallet/index.ts +217 -0
  173. package/templates/yoga-studio/tier5-src/himi-store-account/index.ts +17 -0
  174. package/templates/yoga-studio-owner/dev/index.ts +5 -27
  175. package/templates/yoga-studio-owner/tier5-src/_shared/aria-chat.ts +99 -40
  176. package/templates/yoga-studio-owner/tier5-src/_shared/aria-widget-oauth.ts +42 -0
  177. package/templates/yoga-studio-owner/tier5-src/_shared/aria-widget-view.ts +6 -0
  178. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-aria/index.ts +12 -1
@@ -88,6 +88,7 @@ import {
88
88
  type WidgetOptionRow,
89
89
  type WidgetView,
90
90
  } from "./aria-widget-view.js";
91
+ import { oauthView, DEFAULT_OAUTH_COPY, OAUTH_AUTHORIZED_NOTE, OAUTH_DECLINED_NOTE, type OAuthCopy } from "./aria-widget-oauth.js";
91
92
  import { substituteSelection } from "./aria-widget-model.js";
92
93
  import { MENTION_PAGE_SIZE, allowlisted, emptyMentionModel, mentionView,
93
94
  type MentionItemRow, type MentionLabels, type MentionModel, type MentionProvider, type MentionView } from "./aria-mentions.js";
@@ -468,6 +469,7 @@ export interface AriaChatLabels {
468
469
  mentionItemsFailed?: (category: string) => string;
469
470
  /** Shown when a response widget's item provider cannot be queried. */
470
471
  widgetItemsFailed?: Resolvable<string>;
472
+ oauth?: Partial<Record<keyof OAuthCopy, Resolvable<string>>>;
471
473
  /** Shown when this host cannot reach Wix's item provider service. */
472
474
  widgetItemsUnavailable?: Resolvable<string>;
473
475
  /** Attachment copy — see `AriaChatOptions.attachments`. Chip states: */
@@ -994,13 +996,23 @@ function withAttachments(content: string, names: readonly string[]): { content:
994
996
  return { content, attachText, attachHidden: !attachText };
995
997
  }
996
998
 
999
+ /** Only OAuth protocol suffixes are hidden in owner replies. Ordinary owner text
1000
+ * stays literal; apply this to optimistic rows and their later server echoes. */
1001
+ function visibleOwnerReply(content: string): string {
1002
+ for (const note of [OAUTH_AUTHORIZED_NOTE, OAUTH_DECLINED_NOTE]) {
1003
+ const suffix = `<HIDDEN>${note}</HIDDEN>`;
1004
+ if (content.endsWith(suffix)) return content.slice(0, -suffix.length).trimEnd();
1005
+ }
1006
+ return content;
1007
+ }
1008
+
997
1009
  /** A greeting or optimistic bubble: no links, all slots defaulted. `attached`
998
1010
  * names the files an optimistic USER bubble is being sent with, and `refs` is
999
1011
  * its mention line, already formatted. */
1000
1012
  export function plainBubble(
1001
1013
  id: string, role: string, who: string, content: string, attached: readonly string[] = [], refs = "",
1002
1014
  ): AriaBubble {
1003
- const a = withAttachments(content, attached);
1015
+ const a = withAttachments(role === "USER" ? visibleOwnerReply(content) : content, attached);
1004
1016
  return { id, role, who, notUser: role !== "USER", notAria: role === "USER", spoken: spokenOf(who, a.content),
1005
1017
  refs, refsHidden: !refs, ...linkFieldsOf("", role), ...a };
1006
1018
  }
@@ -1086,7 +1098,7 @@ function bubbleOf(
1086
1098
  // A row the service is still writing is scanned as STREAMING: an
1087
1099
  // envelope whose `>>` has not arrived yet is held back rather than
1088
1100
  // painted as raw JSON until the row finishes.
1089
- const prose = role === "USER" ? raw : assistantProse(raw, !writing);
1101
+ const prose = role === "USER" ? visibleOwnerReply(raw) : assistantProse(raw, !writing);
1090
1102
  const content = role === "USER" ? prose : stripMarkdown(prose);
1091
1103
  // A turn that is only attachments still happened, and dropping it would hide
1092
1104
  // what the owner sent: `withAttachments` makes the file line its content.
@@ -1512,7 +1524,7 @@ export interface AriaChatCore {
1512
1524
  * region is `$service:`-bound and has no item, and the worker already holds
1513
1525
  * the value anyway — so the descriptor names the action and nothing else,
1514
1526
  * which is also one less place for a model-supplied url to travel through. */
1515
- widgetPrimary(s: AriaChatState): Promise<AriaChatState>;
1527
+ widgetPrimary(s: AriaChatState): Promise<AriaChatState | undefined>;
1516
1528
  widgetSecondary(s: AriaChatState): Promise<AriaChatState>;
1517
1529
  /** Toggle one option of a MULTI_SELECT-style widget. Synchronous: it is a
1518
1530
  * state edit, and making it async would put a turn boundary where there is
@@ -1651,6 +1663,16 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
1651
1663
  o.labels?.dictationEmpty ?? "Didn't catch that. Check microphone access and try again.",
1652
1664
  );
1653
1665
  const dictationFailedText = () => res(o.labels?.dictationFailed ?? "Dictation isn't available right now.");
1666
+ const oauthCopy = (): OAuthCopy => Object.fromEntries(
1667
+ Object.entries(DEFAULT_OAUTH_COPY).map(([key, fallback]) =>
1668
+ [key, res(o.labels?.oauth?.[key as keyof OAuthCopy] ?? fallback)]),
1669
+ ) as unknown as OAuthCopy;
1670
+ let oauthKey = "";
1671
+ let oauthSeq = 0;
1672
+ /** The identity of the OAuth ask on screen: its message and its URL. */
1673
+ const oauthKeyOf = (w: WidgetView): string => w.kind === "OAUTH_REQUIRED"
1674
+ ? `${w.sourceMessageId ?? ""}\0${w.oauthAuthorizationUrl ?? ""}` : "";
1675
+ let oauthOpening = "";
1654
1676
  const widgetItemsFailedText = () => res(o.labels?.widgetItemsFailed ?? "Couldn't load these items.");
1655
1677
  const widgetItemsUnavailableText = () => res(o.labels?.widgetItemsUnavailable ?? "Items aren't available here.");
1656
1678
  const attachUploadingText = () => res(o.labels?.attachUploading ?? "Uploading…");
@@ -2522,6 +2544,10 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
2522
2544
  // transcript row itself is unchanged.
2523
2545
  if (!next.sourceMessageId || prev.sourceMessageId !== next.sourceMessageId) return next;
2524
2546
  if (prev.kind !== next.kind) return next;
2547
+ if (next.kind === "OAUTH_REQUIRED" && prev.oauthAuthorizationUrl === next.oauthAuthorizationUrl) {
2548
+ return { ...oauthView(next, next.oauthAuthorizationUrl ?? "", disclosedLabel, oauthCopy(), prev.oauthPhase),
2549
+ notice: prev.notice, noticeHidden: prev.noticeHidden };
2550
+ }
2525
2551
  // Keep the latest service status while this exact job and transcript row
2526
2552
  // remain visible. Rebuilding from the envelope must not restart a terminal
2527
2553
  // job or replace progress with its initial status message.
@@ -2634,36 +2660,43 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
2634
2660
  const localized = (w: WidgetView): WidgetView =>
2635
2661
  w.kind === "QUESTIONNAIRE"
2636
2662
  ? questionnaireSynced(w, w.questionIndex, questionnaireCopy(), !w.answersTextHidden)
2637
- : w;
2638
-
2639
- const observed = (msgs: ConversationMessage[], prev?: WidgetView) => ({
2640
- _srvUsers: countTurns(msgs, "USER"),
2641
- _srvAssistants: countTurns(msgs, "ASSISTANT"),
2642
- // Derived HERE, with the counts, because this is the one expression every
2643
- // transcript rebuild already spreads — load, resume, tick and both newChat
2644
- // arms. That is what makes the widget impossible to leave stale: a rebuild
2645
- // that forgot to clear it would also have to have forgotten the counts,
2646
- // which the reply-detection depends on. `observed([])` (new chat) yields
2647
- // NO_WIDGET for free.
2648
- // Content is normalized HERE, not in the view: `messageText` decodes the
2649
- // `{ text: … }` shape the service also sends (treated as empty before,
2650
- // so those widgets never appeared at all), and `stripHidden` removes
2651
- // `<HIDDEN>` spans — which are transcript-only, and were promoting hidden
2652
- // envelopes into live interactive cards. The transcript path already did
2653
- // both; the widget path did neither.
2654
- widget: carrySelection(
2655
- localized(activeWidgetOf(
2656
- // A draft offers no controls: the agent has not finished asking, and
2657
- // an answer tapped now would start a second turn on top of this one.
2658
- // An empty newest row is NO_WIDGET — the placeholder rule.
2659
- msgs.map((m) => ({ id: m.id, role: m.role, content: stillWriting(m) ? "" : stripHidden(messageText(m)) })),
2660
- disclosedLabel,
2661
- o.subtree,
2662
- (url) => isWixMediaHost(hostOf(url)),
2663
- )),
2664
- prev,
2665
- ),
2666
- });
2663
+ : w.kind === "OAUTH_REQUIRED"
2664
+ ? oauthView(w, w.oauthAuthorizationUrl ?? "", disclosedLabel, oauthCopy(), w.oauthPhase)
2665
+ : w;
2666
+
2667
+ const observed = (msgs: ConversationMessage[], prev?: WidgetView) => {
2668
+ const result = {
2669
+ _srvUsers: countTurns(msgs, "USER"),
2670
+ _srvAssistants: countTurns(msgs, "ASSISTANT"),
2671
+ // Derived HERE, with the counts, because this is the one expression every
2672
+ // transcript rebuild already spreads — load, resume, tick and both newChat
2673
+ // arms. That is what makes the widget impossible to leave stale: a rebuild
2674
+ // that forgot to clear it would also have to have forgotten the counts,
2675
+ // which the reply-detection depends on. `observed([])` (new chat) yields
2676
+ // NO_WIDGET for free.
2677
+ // Content is normalized HERE, not in the view: `messageText` decodes the
2678
+ // `{ text: … }` shape the service also sends (treated as empty before,
2679
+ // so those widgets never appeared at all), and `stripHidden` removes
2680
+ // `<HIDDEN>` spans — which are transcript-only, and were promoting hidden
2681
+ // envelopes into live interactive cards. The transcript path already did
2682
+ // both; the widget path did neither.
2683
+ widget: carrySelection(
2684
+ localized(activeWidgetOf(
2685
+ // A draft offers no controls: the agent has not finished asking, and
2686
+ // an answer tapped now would start a second turn on top of this one.
2687
+ // An empty newest row is NO_WIDGET — the placeholder rule.
2688
+ msgs.map((m) => ({ id: m.id, role: m.role, content: stillWriting(m) ? "" : stripHidden(messageText(m)) })),
2689
+ disclosedLabel,
2690
+ o.subtree,
2691
+ (url) => isWixMediaHost(hostOf(url)),
2692
+ )),
2693
+ prev,
2694
+ ),
2695
+ };
2696
+ const key = oauthKeyOf(result.widget);
2697
+ if (key !== oauthKey) { oauthKey = key; oauthSeq++; }
2698
+ return result;
2699
+ };
2667
2700
 
2668
2701
  const greetingOnly = (): AriaBubble[] => [plainBubble(GREETING_ID, "ASSISTANT", assistant(), res(o.greeting))];
2669
2702
 
@@ -4028,12 +4061,38 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
4028
4061
  // The url wins when both are present: a button that names a destination
4029
4062
  // should go there, and `respondText` beside it is the fallback the
4030
4063
  // service sends for clients that cannot open one.
4031
- widgetPrimary: (s) => s.widget.primaryUrl
4032
- ? openWidgetUrl(s, s.widget.primaryUrl)
4033
- : impl.widgetRespond(s, { value: "primary" }),
4034
- widgetSecondary: (s) => s.widget.secondaryUrl
4035
- ? openWidgetUrl(s, s.widget.secondaryUrl)
4036
- : impl.widgetRespond(s, { value: "secondary" }),
4064
+ widgetPrimary: async (s) => {
4065
+ const w = s.widget;
4066
+ if (w.kind !== "OAUTH_REQUIRED") return w.primaryUrl
4067
+ ? openWidgetUrl(s, w.primaryUrl) : impl.widgetRespond(s, { value: "primary" });
4068
+ if (w.primaryHidden || !w.oauthAuthorizationUrl || s._pending) return s;
4069
+ if (w.oauthPhase === "authorizing") {
4070
+ oauthSeq++;
4071
+ return impl.widgetRespond(s, { value: "primary" });
4072
+ }
4073
+ // Key from the card itself: a worker rebuilt over persisted state restores
4074
+ // the card without a transcript rebuild, so the module-local key is still
4075
+ // empty and the in-flight guard below would swallow the first Authorize.
4076
+ const key = oauthKeyOf(w);
4077
+ if (key !== oauthKey) { oauthKey = key; oauthSeq++; }
4078
+ if (oauthOpening === key) return undefined;
4079
+ oauthOpening = key;
4080
+ const seq = ++oauthSeq, turn = turnSeq, draft = draftSeq;
4081
+ let opened = false;
4082
+ try { opened = !!(await o.openLink?.(w.oauthAuthorizationUrl)); } catch { /* shown below */ }
4083
+ finally { if (oauthOpening === key) oauthOpening = ""; }
4084
+ // Never merge an old action snapshot over a newer conversation, widget
4085
+ // or composer edit. An external browser opening can take arbitrarily long.
4086
+ if (seq !== oauthSeq || key !== oauthKey || turn !== turnSeq || draft !== draftSeq) return undefined;
4087
+ return opened
4088
+ ? { ...s, widget: oauthView(w, w.oauthAuthorizationUrl, disclosedLabel, oauthCopy(), "authorizing") }
4089
+ : { ...s, widget: { ...w, notice: oauthCopy().openFailed, noticeHidden: false } };
4090
+ },
4091
+ widgetSecondary: (s) => {
4092
+ if (s.widget.kind === "OAUTH_REQUIRED") oauthSeq++;
4093
+ return s.widget.secondaryUrl ? openWidgetUrl(s, s.widget.secondaryUrl)
4094
+ : impl.widgetRespond(s, { value: "secondary" });
4095
+ },
4037
4096
 
4038
4097
  dictate: (s) => {
4039
4098
  if (!o.dictation || s.listening) return s;
@@ -4478,7 +4537,7 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
4478
4537
  widgetAnswer: (s, arg) => gated(impl.widgetAnswer(s, arg)),
4479
4538
  widgetStep: (s, arg) => gated(impl.widgetStep(s, arg)),
4480
4539
  widgetRespond: (s, arg) => impl.widgetRespond(s, arg).then(gated),
4481
- widgetPrimary: (s) => impl.widgetPrimary(s).then(gated),
4540
+ widgetPrimary: (s) => impl.widgetPrimary(s).then((r) => r ? gated(r) : r),
4482
4541
  widgetSecondary: (s) => impl.widgetSecondary(s).then(gated),
4483
4542
  dictate: (s) => gated(impl.dictate(s)),
4484
4543
  finishDictation: (s) => gated(impl.finishDictation(s)),
@@ -0,0 +1,42 @@
1
+ import type { Disclose, WidgetView } from "./aria-widget-view.js";
2
+ import { isWebUrl } from "./aria-widget-model.js";
3
+
4
+ export interface OAuthCopy {
5
+ title: string; body: string; pending: string; authorize: string; decline: string;
6
+ done: string; authorized: string; declined: string; openFailed: string;
7
+ }
8
+
9
+ export const DEFAULT_OAUTH_COPY: OAuthCopy = {
10
+ title: "Connect an account", body: "Authorize access to continue this task.",
11
+ pending: "Finish authorization in your browser, then return and choose Done.",
12
+ authorize: "Authorize", decline: "Decline", done: "Done",
13
+ authorized: "Authorized", declined: "Declined",
14
+ openFailed: "Couldn't open authorization. Try again or decline.",
15
+ };
16
+
17
+ // These instructions are wire content from the native Aria client, not copy.
18
+ export const OAUTH_AUTHORIZED_NOTE = "The user completed the OAuth authorization flow. Please retry the previous tool call.";
19
+ export const OAUTH_DECLINED_NOTE = "The user declined OAuth authorization. Do not retry the tool.";
20
+
21
+ /** A browser-open result is not an OAuth callback. Only the owner's subsequent
22
+ * Done action sends completion. The destination is disclosed by the same helper
23
+ * as every other widget URL; no guessed server callback is invoked. */
24
+ export function oauthView(
25
+ view: WidgetView, rawUrl: string, disclose: Disclose,
26
+ copy: OAuthCopy = DEFAULT_OAUTH_COPY, phase: "pending" | "authorizing" = "pending",
27
+ ): WidgetView {
28
+ const url = isWebUrl(rawUrl.trim()) ? rawUrl.trim() : "";
29
+ const authorizing = phase === "authorizing" && !!url;
30
+ return {
31
+ ...view, notice: "", noticeHidden: true, hidden: false, oauthPhase: authorizing ? "authorizing" : "pending",
32
+ oauthAuthorizationUrl: url,
33
+ title: copy.title, titleHidden: !copy.title,
34
+ text: authorizing ? copy.pending : copy.body, textHidden: false,
35
+ primaryLabel: authorizing ? copy.done : disclose({ label: copy.authorize, url }),
36
+ primaryUrl: authorizing ? "" : url,
37
+ primaryHidden: !url, primaryDisabled: false, primaryEnabled: true,
38
+ primaryRespondText: authorizing ? `${copy.authorized}\n<HIDDEN>${OAUTH_AUTHORIZED_NOTE}</HIDDEN>` : "",
39
+ secondaryLabel: copy.decline, secondaryHidden: false, secondaryUrl: "",
40
+ secondaryRespondText: `${copy.declined}\n<HIDDEN>${OAUTH_DECLINED_NOTE}</HIDDEN>`,
41
+ };
42
+ }
@@ -14,6 +14,7 @@
14
14
 
15
15
  import type { NormalizedWidget, WidgetKind, WidgetOption } from "./aria-widget-model.js";
16
16
  import { SELECTED_TOKEN, VALUES_TOKEN, isWebUrl, stripMarkdown } from "./aria-widget-model.js";
17
+ import { oauthView } from "./aria-widget-oauth.js";
17
18
  import { composeGenericCard } from "./aria-generic-widget.js";
18
19
  import { normalizeWidget } from "./aria-widget-kinds.js";
19
20
  import { scanEnvelopes, widgetsOfParts } from "./aria-widgets.js";
@@ -127,6 +128,8 @@ export interface WidgetStep {
127
128
  /** The active widget, as the screen reads it. */
128
129
  export interface WidgetView {
129
130
  kind: WidgetCase;
131
+ oauthPhase?: "pending" | "authorizing";
132
+ oauthAuthorizationUrl?: string;
130
133
  /** Transcript row that owns this widget; prevents state carrying into a later
131
134
  * identical-looking ask. */
132
135
  sourceMessageId?: string;
@@ -1021,6 +1024,9 @@ export function viewOf(
1021
1024
  // A questionnaire is shown one question at a time; its on-screen fields are
1022
1025
  // derived, never stored, so they start from the same function every later
1023
1026
  // change goes through. The worker re-derives with its own copy.
1027
+ if (w.kind === "OAUTH_REQUIRED") {
1028
+ return oauthView(view, typeof extra.authorizationUrl === "string" ? extra.authorizationUrl : "", disclose);
1029
+ }
1024
1030
  return w.kind === "QUESTIONNAIRE"
1025
1031
  ? questionnaireSynced(view, 0, DEFAULT_QUESTIONNAIRE_COPY, false)
1026
1032
  : view;
@@ -248,6 +248,17 @@ const core = createAriaChat({
248
248
  // sentence around it is localized.
249
249
  mentionItemsFailed: (category: string) =>
250
250
  copyTemplate("ownerAria.mention.itemsFailed", "Couldn't load {category}.", { category }),
251
+ oauth: {
252
+ title: () => copyParam("ownerAria.oauth.title", "Connect an account"),
253
+ body: () => copyParam("ownerAria.oauth.body", "Authorize access to continue this task."),
254
+ pending: () => copyParam("ownerAria.oauth.pending", "Finish authorization in your browser, then return and choose Done."),
255
+ authorize: () => copyParam("ownerAria.oauth.authorize", "Authorize"),
256
+ decline: () => copyParam("ownerAria.oauth.decline", "Decline"),
257
+ done: () => copyParam("ownerAria.oauth.done", "Done"),
258
+ authorized: () => copyParam("ownerAria.oauth.authorized", "Authorized"),
259
+ declined: () => copyParam("ownerAria.oauth.declined", "Declined"),
260
+ openFailed: () => copyParam("ownerAria.oauth.openFailed", "Couldn't open authorization. Try again or decline."),
261
+ },
251
262
  widgetItemsFailed: () => copyParam("ownerAria.widget.itemsFailed", "Couldn't load these items."),
252
263
  widgetItemsUnavailable: () => copyParam("ownerAria.widget.itemsUnavailable", "Items aren't available here."),
253
264
  attachUploading: () => copyParam("ownerAria.attach.uploading", "Uploading…"),
@@ -432,7 +443,7 @@ const svc = defineService<AriaChatState, {
432
443
  // moved on must not commit its pre-await snapshot over the new one.
433
444
  copyMessage: (s: AriaChatState, arg?: AriaActionArg) => Promise<AriaChatState | undefined>;
434
445
  regenerate: (s: AriaChatState) => Promise<AriaChatState>;
435
- widgetPrimary: (s: AriaChatState) => Promise<AriaChatState>;
446
+ widgetPrimary: (s: AriaChatState) => Promise<AriaChatState | undefined>;
436
447
  widgetSecondary: (s: AriaChatState) => Promise<AriaChatState>;
437
448
  widgetToggle: (s: AriaChatState, arg?: AriaActionArg) => AriaChatState;
438
449
  widgetSelectOne: (s: AriaChatState, arg?: AriaActionArg) => AriaChatState;
@@ -155,6 +155,29 @@ export default defineApp({
155
155
  "parentScreenId": "himi_orders",
156
156
  "tabId": "profile"
157
157
  },
158
+ {
159
+ "screenId": "himi_addresses",
160
+ "isPublic": false,
161
+ "paramKeys": [],
162
+ "parentScreenId": "himi_account",
163
+ "tabId": "profile"
164
+ },
165
+ {
166
+ "screenId": "himi_address",
167
+ "isPublic": false,
168
+ "paramKeys": [
169
+ "id"
170
+ ],
171
+ "parentScreenId": "himi_addresses",
172
+ "tabId": "profile"
173
+ },
174
+ {
175
+ "screenId": "himi_wallet",
176
+ "isPublic": false,
177
+ "paramKeys": [],
178
+ "parentScreenId": "himi_account",
179
+ "tabId": "profile"
180
+ },
158
181
  {
159
182
  "screenId": "himi_services",
160
183
  "isPublic": true,