@8wave/ai-elements 0.121.0-beta.16 → 0.121.0-beta.18

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 (140) hide show
  1. package/README.md +125 -54
  2. package/dist/_chunks/{Agent-7rbrjWzu.js → Agent-wt8Vi99H.js} +7 -5
  3. package/dist/_chunks/Agent-wt8Vi99H.js.map +1 -0
  4. package/dist/_chunks/{PkStreamingMarkdown-BnClGp-3.js → PkStreamingMarkdown-Br7Z60Vm.js} +787 -777
  5. package/dist/_chunks/PkStreamingMarkdown-Br7Z60Vm.js.map +1 -0
  6. package/dist/_chunks/{PkToolEditSpreadsheet-D4M6BUKx.js → PkToolEditSpreadsheet-Di9czFTy.js} +2 -2
  7. package/dist/_chunks/{PkToolEditSpreadsheet-D4M6BUKx.js.map → PkToolEditSpreadsheet-Di9czFTy.js.map} +1 -1
  8. package/dist/_chunks/{PkToolRequestGeolocation-DmOoFghZ.js → PkToolRequestGeolocation-dUTqHsV-.js} +2 -2
  9. package/dist/_chunks/{PkToolRequestGeolocation-DmOoFghZ.js.map → PkToolRequestGeolocation-dUTqHsV-.js.map} +1 -1
  10. package/dist/_chunks/{PkToolRequestOAuthConnection-DV0sfojC.js → PkToolRequestOAuthConnection-cNDld72U.js} +2 -2
  11. package/dist/_chunks/{PkToolRequestOAuthConnection-DV0sfojC.js.map → PkToolRequestOAuthConnection-cNDld72U.js.map} +1 -1
  12. package/dist/_chunks/{PkToolShowArtifact-V0a8zhdO.js → PkToolShowArtifact-DtstlRsL.js} +2 -2
  13. package/dist/_chunks/{PkToolShowArtifact-V0a8zhdO.js.map → PkToolShowArtifact-DtstlRsL.js.map} +1 -1
  14. package/dist/_chunks/{PkToolShowContactForm-sLhBxf9e.js → PkToolShowContactForm-BKaKlYGJ.js} +2 -2
  15. package/dist/_chunks/{PkToolShowContactForm-sLhBxf9e.js.map → PkToolShowContactForm-BKaKlYGJ.js.map} +1 -1
  16. package/dist/_chunks/{PkToolShowForm-Dl2k9jqk.js → PkToolShowForm-OxANKx0g.js} +3 -3
  17. package/dist/_chunks/{PkToolShowForm-Dl2k9jqk.js.map → PkToolShowForm-OxANKx0g.js.map} +1 -1
  18. package/dist/_chunks/{PkToolShowImageGallery-CTsq_DPb.js → PkToolShowImageGallery-DRePOmUx.js} +2 -2
  19. package/dist/_chunks/{PkToolShowImageGallery-CTsq_DPb.js.map → PkToolShowImageGallery-DRePOmUx.js.map} +1 -1
  20. package/dist/_chunks/{PkToolShowProductList-CpdKWQkP.js → PkToolShowProductList-Y9HR_RJ4.js} +2 -2
  21. package/dist/_chunks/{PkToolShowProductList-CpdKWQkP.js.map → PkToolShowProductList-Y9HR_RJ4.js.map} +1 -1
  22. package/dist/_chunks/{PkToolShowSources-WFm2JF0r.js → PkToolShowSources-BQnaaL2a.js} +3 -3
  23. package/dist/_chunks/{PkToolShowSources-WFm2JF0r.js.map → PkToolShowSources-BQnaaL2a.js.map} +1 -1
  24. package/dist/_chunks/{PkToolShowSuggestedReply-RcL_3RAz.js → PkToolShowSuggestedReply-ghiXQuDz.js} +2 -2
  25. package/dist/_chunks/{PkToolShowSuggestedReply-RcL_3RAz.js.map → PkToolShowSuggestedReply-ghiXQuDz.js.map} +1 -1
  26. package/dist/_chunks/{PkToolShowVideo-Ua5heyl1.js → PkToolShowVideo-BcNWgJD7.js} +2 -2
  27. package/dist/_chunks/{PkToolShowVideo-Ua5heyl1.js.map → PkToolShowVideo-BcNWgJD7.js.map} +1 -1
  28. package/dist/_chunks/{PkToolShowWebPages-STOCnsKm.js → PkToolShowWebPages-Ba6DkV0V.js} +2 -2
  29. package/dist/_chunks/{PkToolShowWebPages-STOCnsKm.js.map → PkToolShowWebPages-Ba6DkV0V.js.map} +1 -1
  30. package/dist/_chunks/{chatImagePolicy-C8X_GMnS.js → chatImagePolicy-P0TZW1on.js} +2 -2
  31. package/dist/_chunks/{chatImagePolicy-C8X_GMnS.js.map → chatImagePolicy-P0TZW1on.js.map} +1 -1
  32. package/dist/_chunks/{markdown-EqEd3eyd.js → markdown-DLplFIBU.js} +2 -2
  33. package/dist/_chunks/{markdown-EqEd3eyd.js.map → markdown-DLplFIBU.js.map} +1 -1
  34. package/dist/ai-elements.es.js +4053 -3494
  35. package/dist/ai-elements.es.js.map +1 -1
  36. package/dist-vue/PkChatbot.js +1 -1
  37. package/dist-vue/PkChatbotEmptyState.js +1 -1
  38. package/dist-vue/PkChatbotInput.js +1 -1
  39. package/dist-vue/PkChatbotMessages.js +1 -1
  40. package/dist-vue/PkChatbotStepPayload.js +1 -1
  41. package/dist-vue/PkChatbotStepToolDetail.js +1 -1
  42. package/dist-vue/PkChatbotSteps.js +1 -1
  43. package/dist-vue/PkChatbotViewChat.js +1 -1
  44. package/dist-vue/PkChatbotViewConversations.js +1 -1
  45. package/dist-vue/PkChatbotViewFiles.js +1 -1
  46. package/dist-vue/PkChatbotViewProfile.js +1 -1
  47. package/dist-vue/_chunks/{Agent-SH2vEFKs.js → Agent-DcoF75y8.js} +7 -5
  48. package/dist-vue/_chunks/Agent-DcoF75y8.js.map +1 -0
  49. package/dist-vue/_chunks/{Document-fmCxsccF.js → Document-C1bD6VNU.js} +2 -2
  50. package/dist-vue/_chunks/{Document-fmCxsccF.js.map → Document-C1bD6VNU.js.map} +1 -1
  51. package/dist-vue/_chunks/{PkChatbot-DlIEIjKJ.js → PkChatbot-wyaH2IgV.js} +9 -9
  52. package/dist-vue/_chunks/PkChatbot-wyaH2IgV.js.map +1 -0
  53. package/dist-vue/_chunks/{PkChatbotEmptyState-Bcozn56E.js → PkChatbotEmptyState-h2qZ0JOD.js} +2 -2
  54. package/dist-vue/_chunks/{PkChatbotEmptyState-Bcozn56E.js.map → PkChatbotEmptyState-h2qZ0JOD.js.map} +1 -1
  55. package/dist-vue/_chunks/{PkChatbotInput-DQVpDLNp.js → PkChatbotInput-C-bMNHC-.js} +87 -80
  56. package/dist-vue/_chunks/PkChatbotInput-C-bMNHC-.js.map +1 -0
  57. package/dist-vue/_chunks/{PkChatbotMessages-BYFozlwC.js → PkChatbotMessages-DU8qnlVX.js} +17 -17
  58. package/dist-vue/_chunks/{PkChatbotMessages-BYFozlwC.js.map → PkChatbotMessages-DU8qnlVX.js.map} +1 -1
  59. package/dist-vue/_chunks/{PkChatbotStepPayload-DjntsSlX.js → PkChatbotStepPayload-BOxfKD1b.js} +2 -2
  60. package/dist-vue/_chunks/{PkChatbotStepPayload-DjntsSlX.js.map → PkChatbotStepPayload-BOxfKD1b.js.map} +1 -1
  61. package/dist-vue/_chunks/{PkChatbotStepToolDetail-If9goNdY.js → PkChatbotStepToolDetail-Df6EOYxj.js} +3 -3
  62. package/dist-vue/_chunks/{PkChatbotStepToolDetail-If9goNdY.js.map → PkChatbotStepToolDetail-Df6EOYxj.js.map} +1 -1
  63. package/dist-vue/_chunks/{PkChatbotSteps-DUFfniZn.js → PkChatbotSteps-DnDtN4Q7.js} +5 -5
  64. package/dist-vue/_chunks/{PkChatbotSteps-DUFfniZn.js.map → PkChatbotSteps-DnDtN4Q7.js.map} +1 -1
  65. package/dist-vue/_chunks/{PkChatbotViewChat-BGoltDr9.js → PkChatbotViewChat-D4iupq1A.js} +7 -7
  66. package/dist-vue/_chunks/{PkChatbotViewChat-BGoltDr9.js.map → PkChatbotViewChat-D4iupq1A.js.map} +1 -1
  67. package/dist-vue/_chunks/{PkChatbotViewConversations-WUpRm6GG.js → PkChatbotViewConversations-dKZScKD9.js} +3 -3
  68. package/dist-vue/_chunks/{PkChatbotViewConversations-WUpRm6GG.js.map → PkChatbotViewConversations-dKZScKD9.js.map} +1 -1
  69. package/dist-vue/_chunks/{PkChatbotViewFiles-CpG_LRg6.js → PkChatbotViewFiles-CQC3rInD.js} +3 -3
  70. package/dist-vue/_chunks/{PkChatbotViewFiles-CpG_LRg6.js.map → PkChatbotViewFiles-CQC3rInD.js.map} +1 -1
  71. package/dist-vue/_chunks/{PkChatbotViewProfile-DetQJa7E.js → PkChatbotViewProfile-CkZyWh4V.js} +2 -2
  72. package/dist-vue/_chunks/{PkChatbotViewProfile-DetQJa7E.js.map → PkChatbotViewProfile-CkZyWh4V.js.map} +1 -1
  73. package/dist-vue/_chunks/{PkStreamingMarkdown-DLKEIMcZ.js → PkStreamingMarkdown-BYV68skc.js} +3 -3
  74. package/dist-vue/_chunks/{PkStreamingMarkdown-DLKEIMcZ.js.map → PkStreamingMarkdown-BYV68skc.js.map} +1 -1
  75. package/dist-vue/_chunks/{PkToolEditSpreadsheet-D2JtjXef.js → PkToolEditSpreadsheet-DQxJQIY0.js} +2 -2
  76. package/dist-vue/_chunks/{PkToolEditSpreadsheet-D2JtjXef.js.map → PkToolEditSpreadsheet-DQxJQIY0.js.map} +1 -1
  77. package/dist-vue/_chunks/{PkToolRequestGeolocation--MTT__Vu.js → PkToolRequestGeolocation-BpjglRbg.js} +2 -2
  78. package/dist-vue/_chunks/{PkToolRequestGeolocation--MTT__Vu.js.map → PkToolRequestGeolocation-BpjglRbg.js.map} +1 -1
  79. package/dist-vue/_chunks/{PkToolRequestOAuthConnection-Gb_qfvlN.js → PkToolRequestOAuthConnection-CD3M5DWj.js} +2 -2
  80. package/dist-vue/_chunks/{PkToolRequestOAuthConnection-Gb_qfvlN.js.map → PkToolRequestOAuthConnection-CD3M5DWj.js.map} +1 -1
  81. package/dist-vue/_chunks/{PkToolShowArtifact-BWVntj9H.js → PkToolShowArtifact-Bm5VBF_n.js} +2 -2
  82. package/dist-vue/_chunks/{PkToolShowArtifact-BWVntj9H.js.map → PkToolShowArtifact-Bm5VBF_n.js.map} +1 -1
  83. package/dist-vue/_chunks/{PkToolShowContactForm-BbBt3ha0.js → PkToolShowContactForm-CMQTQsU-.js} +2 -2
  84. package/dist-vue/_chunks/{PkToolShowContactForm-BbBt3ha0.js.map → PkToolShowContactForm-CMQTQsU-.js.map} +1 -1
  85. package/dist-vue/_chunks/{PkToolShowDiagram-CE6KHz1M.js → PkToolShowDiagram-adGuj4AF.js} +2 -2
  86. package/dist-vue/_chunks/{PkToolShowDiagram-CE6KHz1M.js.map → PkToolShowDiagram-adGuj4AF.js.map} +1 -1
  87. package/dist-vue/_chunks/{PkToolShowForm-CNm8HSUW.js → PkToolShowForm-Cx5KdTlZ.js} +4 -4
  88. package/dist-vue/_chunks/{PkToolShowForm-CNm8HSUW.js.map → PkToolShowForm-Cx5KdTlZ.js.map} +1 -1
  89. package/dist-vue/_chunks/{PkToolShowImageGallery-6k3ituoi.js → PkToolShowImageGallery-BtQ0gnGB.js} +2 -2
  90. package/dist-vue/_chunks/{PkToolShowImageGallery-6k3ituoi.js.map → PkToolShowImageGallery-BtQ0gnGB.js.map} +1 -1
  91. package/dist-vue/_chunks/{PkToolShowProductList-Bu-pUg5d.js → PkToolShowProductList-Dvatk6p-.js} +2 -2
  92. package/dist-vue/_chunks/{PkToolShowProductList-Bu-pUg5d.js.map → PkToolShowProductList-Dvatk6p-.js.map} +1 -1
  93. package/dist-vue/_chunks/{PkToolShowSources-DTWNZqWu.js → PkToolShowSources-DKkIYQ9r.js} +3 -3
  94. package/dist-vue/_chunks/{PkToolShowSources-DTWNZqWu.js.map → PkToolShowSources-DKkIYQ9r.js.map} +1 -1
  95. package/dist-vue/_chunks/{PkToolShowSuggestedReply-DSXhqWhx.js → PkToolShowSuggestedReply-BbAfjJP9.js} +2 -2
  96. package/dist-vue/_chunks/{PkToolShowSuggestedReply-DSXhqWhx.js.map → PkToolShowSuggestedReply-BbAfjJP9.js.map} +1 -1
  97. package/dist-vue/_chunks/{PkToolShowVideo-C0ycBiOI.js → PkToolShowVideo-DTNszfdU.js} +2 -2
  98. package/dist-vue/_chunks/{PkToolShowVideo-C0ycBiOI.js.map → PkToolShowVideo-DTNszfdU.js.map} +1 -1
  99. package/dist-vue/_chunks/{PkToolShowWebPages-CWWv1tr5.js → PkToolShowWebPages-euov57FB.js} +2 -2
  100. package/dist-vue/_chunks/{PkToolShowWebPages-CWWv1tr5.js.map → PkToolShowWebPages-euov57FB.js.map} +1 -1
  101. package/dist-vue/_chunks/{createChatbotApiClient-MbfcTdwY.js → createChatbotApiClient-qHjpFqPL.js} +8 -8
  102. package/dist-vue/_chunks/{createChatbotApiClient-MbfcTdwY.js.map → createChatbotApiClient-qHjpFqPL.js.map} +1 -1
  103. package/dist-vue/_chunks/{useChatbotStore-DDSgrRzg.js → useChatbotStore-CBjfSN69.js} +3 -3
  104. package/dist-vue/_chunks/{useChatbotStore-DDSgrRzg.js.map → useChatbotStore-CBjfSN69.js.map} +1 -1
  105. package/dist-vue/_chunks/{utils-B9-Vt10H.js → utils-BCGK2AFl.js} +2 -2
  106. package/dist-vue/_chunks/utils-BCGK2AFl.js.map +1 -0
  107. package/dist-vue/api.js +1 -1
  108. package/dist-vue/apps/web-component/src/components/EmbeddedChatWidget.ce.d.ts +12 -4
  109. package/dist-vue/apps/web-component/src/components/FloatingChatWidget.ce.d.ts +4 -3
  110. package/dist-vue/apps/web-component/src/composables/useChatbotAgent.d.ts +11 -5
  111. package/dist-vue/apps/web-component/src/composables/useChatbotProfileProvider.d.ts +3 -2
  112. package/dist-vue/apps/web-component/src/composables/useCopilotPageCss.d.ts +12 -4
  113. package/dist-vue/apps/web-component/src/composables/usePageModal.d.ts +19 -0
  114. package/dist-vue/apps/web-component/src/lib.d.ts +10 -3
  115. package/dist-vue/apps/web-component/src/pageTools/actions.d.ts +33 -0
  116. package/dist-vue/apps/web-component/src/pageTools/navigation.d.ts +27 -0
  117. package/dist-vue/apps/web-component/src/pageTools/snapshot.d.ts +18 -2
  118. package/dist-vue/apps/web-component/src/utils/emitWidgetEvent.d.ts +8 -0
  119. package/dist-vue/apps/web-component/src/utils/layout.d.ts +3 -3
  120. package/dist-vue/composables.js +43 -21
  121. package/dist-vue/composables.js.map +1 -1
  122. package/dist-vue/index.js +340 -321
  123. package/dist-vue/index.js.map +1 -1
  124. package/dist-vue/locales.js +44 -18
  125. package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +8 -5
  126. package/dist-vue/packages/components/src/chat/PkHostCallConfirmDialog.d.ts +19 -0
  127. package/dist-vue/packages/components/src/chat/utils.d.ts +5 -0
  128. package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +13 -7
  129. package/dist-vue/packages/models/src/schema/Agent.d.ts +31 -18
  130. package/dist-vue/packages/models/src/schema/ReasoningChat.d.ts +5 -3
  131. package/dist-vue/packages/models/src/schema/SubAgent.d.ts +5 -3
  132. package/dist-vue/style.css +1 -1
  133. package/package.json +1 -1
  134. package/dist/_chunks/Agent-7rbrjWzu.js.map +0 -1
  135. package/dist/_chunks/PkStreamingMarkdown-BnClGp-3.js.map +0 -1
  136. package/dist-vue/_chunks/Agent-SH2vEFKs.js.map +0 -1
  137. package/dist-vue/_chunks/PkChatbot-DlIEIjKJ.js.map +0 -1
  138. package/dist-vue/_chunks/PkChatbotInput-DQVpDLNp.js.map +0 -1
  139. package/dist-vue/_chunks/utils-B9-Vt10H.js.map +0 -1
  140. package/dist-vue/apps/web-component/src/composables/useCopilotPush.d.ts +0 -25
@@ -1,4 +1,4 @@
1
- import { J as e, O as t, P as n, b as r, n as i, w as a } from "./Agent-SH2vEFKs.js";
1
+ import { J as e, O as t, P as n, b as r, n as i, w as a } from "./Agent-DcoF75y8.js";
2
2
  import "./src-BZRiAJsH.js";
3
3
  import { c as o, i as s, l as c, u as l } from "./message-DZvfzt9j.js";
4
4
  //#region ../../packages/utils/src/text.ts
@@ -302,4 +302,4 @@ function se(e, t) {
302
302
  //#endregion
303
303
  export { R as A, I as C, m as D, oe as E, f as F, ee as I, $ as M, p as N, v as O, d as P, w as S, M as T, se as _, g as a, q as b, W as c, b as d, O as f, P as g, re as h, z as i, B as j, ae as k, U as l, F as m, E as n, y as o, Z as p, G as r, H as s, j as t, te as u, X as v, T as w, N as x, V as y };
304
304
 
305
- //# sourceMappingURL=utils-B9-Vt10H.js.map
305
+ //# sourceMappingURL=utils-BCGK2AFl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-BCGK2AFl.js","names":["isHostToolPart","WEB_SEARCH_TOOL_KEYS","isPresentationTool","MCP_TOOL_PREFIX","API_TOOL_PREFIX","SUBAGENT_TOOL_PREFIX","isReasoningPart","getToolPartName","isTextPart","isToolPart","removeAccents","str","fromAnyCase","toKebabCase","toSnakeCase","capitalizeFirstLetter","mergeConsecutiveTextParts","merged","part","parts","prev","isWidgetPart","dropCorrectedWidgetErrors","lastDrawn","index","isStreamingPart","FILE_OUTPUT_PARTS","moveFileOutputsLast","files","feedPartKey","toolCallId","getHostCallPart","PAGE_TOOL_STEPS","FORM_TOOL_STEP","pageToolStep","host","isHostActionPart","LIVE_REASONING_TAIL_LENGTH","FENCE_LINE","getMarkdownTail","markdown","maxLength","from","limit","boundary","length","cut","openFence","match","marker","rest","TOOL_APPROVAL_STATES","isToolApprovalPart","CONFIRM_TOOL_NAME","isToolConfirmPart","isConfirmationCardPart","getToolApprovalId","getPartState","isLoadingState","state","getContrast","hex","hexcolor","char","r","g","b","linearize","c","resolveContrastColor","textColor","mainColor","agentThemeStyle","contrastColor","formatDuration","ms","$n","stringifyPayload","value","json","hasPayload","formAnswerAsSpoken","input","answer","question","questionById","step","said","id","formStepOptions","option","formAnswerSlots","slots","output","steps","assign","list","WEB_SEARCH_TOOL_TYPES","key","RICH_DETAIL_TOOL_TYPES","hasRichToolDetail","asRecord","pickString","keys","record","getToolPartSummary","queries","valid","query","sheet","range","getPartIcon","TOOL_KEY_PREFIXES","toolLabel","te","name","prefix","p","PART_TYPE_LABELS","t","getPartTypeLabel","translator","label","PROVIDER_NAMES","providerLabel","slug","localizeSummaryLabels","summary","labels","colon","getToolPartLabel","page","$t"],"sources":["../../../../packages/utils/src/text.ts","../../../../packages/components/src/chat/utils.ts"],"sourcesContent":["export const removeAccents = (str: string) =>\n str.normalize('NFD').replace(/[\\u0300-\\u036f]/g, '')\n\nexport const toCamelCase = <T extends string>(str?: string): T => {\n if (!str) {\n return '' as unknown as T\n }\n return removeAccents(str)\n .replace(/[^a-zA-Z0-9]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))\n .replace(/^(.)/, (match) => match.toLowerCase()) as unknown as T\n}\n\nexport const fromCamelCase = (str?: string): string => {\n if (!str) {\n return ''\n }\n return str.replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n}\n\nexport const fromAnyCase = (str?: string): string => {\n if (!str) {\n return ''\n }\n return str\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/[-_]+/g, ' ')\n}\n\nexport const toPascalCase = <T extends string>(str?: string): T => {\n if (!str) {\n return '' as unknown as T\n }\n return removeAccents(str)\n .replace(/[^a-zA-Z0-9]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))\n .replace(/^(.)/, (match) => match.toUpperCase()) as unknown as T\n}\n\nexport const toKebabCase = <T extends string>(str?: string): T => {\n if (!str) {\n return '' as unknown as T\n }\n return removeAccents(str)\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/[^a-zA-Z0-9]+/g, '-')\n .toLowerCase() as unknown as T\n}\n\nexport const fromKebabCase = (str?: string): string => {\n if (!str) {\n return ''\n }\n return str.replace(/-/g, ' ')\n}\n\nexport const toSnakeCase = <T extends string>(str?: string): T => {\n if (!str) {\n return '' as unknown as T\n }\n return removeAccents(str)\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .replace(/[^a-zA-Z0-9]+/g, '_')\n .toLowerCase() as unknown as T\n}\n\nexport const capitalizeFirstLetter = (str?: string) => {\n if (!str) {\n return ''\n }\n return str.charAt(0).toUpperCase() + str.slice(1)\n}\n\nexport const lowercaseFirstLetter = (str?: string) => {\n if (!str) {\n return ''\n }\n return str.charAt(0).toLowerCase() + str.slice(1)\n}\n","import type { UIMessage } from 'ai'\nimport {\n API_TOOL_PREFIX,\n MCP_TOOL_PREFIX,\n SUBAGENT_TOOL_PREFIX,\n WEB_SEARCH_TOOL_KEYS,\n isHostToolPart,\n isPresentationTool,\n} from 'models'\nimport {\n isTextPart,\n isFilePart,\n isToolPart,\n isReasoningPart,\n hasPartText,\n hasTextPart,\n getTextPart,\n getMessageText,\n getToolPartName,\n capitalizeFirstLetter,\n fromAnyCase,\n} from 'utils'\n\nexport {\n isTextPart,\n isFilePart,\n isToolPart,\n isReasoningPart,\n hasPartText,\n hasTextPart,\n getTextPart,\n getMessageText,\n}\n\n/**\n * Merges consecutive text parts into a single text part.\n * Claude (and other models) often produce multiple text parts during streaming\n * that should logically be a single block of text.\n */\nexport function mergeConsecutiveTextParts(\n parts: UIMessage['parts'],\n): UIMessage['parts'] {\n const merged: UIMessage['parts'] = []\n for (const part of parts) {\n if (!isTextPart(part)) {\n merged.push(part)\n continue\n }\n const prev = merged[merged.length - 1]\n if (prev && isTextPart(prev)) {\n merged[merged.length - 1] = { ...prev, text: prev.text + part.text }\n } else {\n merged.push(part)\n }\n }\n return merged\n}\n\nconst isWidgetPart = (\n part: UIMessage['parts'][number],\n): part is Extract<UIMessage['parts'][number], { type: `tool-${string}` }> =>\n isToolPart(part) && isPresentationTool(getToolPartName(part))\n\n/**\n * Drops a widget call refused for its arguments when a later call of the same\n * widget in the message was drawn: the turn corrected it (the backend's\n * `correctableInputRefusals`), and the refusal would sit next to the working\n * widget, `showForm` drawing its render error above the form. A refusal with\n * nothing drawn after it stays. Only the feed reads this: the steps timeline\n * keeps every call, the refused one included.\n */\nexport function dropCorrectedWidgetErrors(\n parts: UIMessage['parts'],\n): UIMessage['parts'] {\n const lastDrawn = new Map<string, number>()\n for (const [index, part] of parts.entries()) {\n if (\n isWidgetPart(part) &&\n part.state !== 'output-error' &&\n !isStreamingPart(part)\n ) {\n lastDrawn.set(part.type, index)\n }\n }\n return parts.filter(\n (part, index) =>\n !(\n isWidgetPart(part) &&\n part.state === 'output-error' &&\n (lastDrawn.get(part.type) ?? -1) > index\n ),\n )\n}\n\n/**\n * Tool calls whose output is a file for the user to download. The feed draws\n * them after the answer, where the reader arrives, wherever in the message the\n * model made the call: a version written before a long answer sat above it,\n * out of sight.\n */\nconst FILE_OUTPUT_PARTS: ReadonlySet<string> = new Set(['tool-editSpreadsheet'])\n\n/** The parts with the file outputs moved last, in their own order. */\nexport function moveFileOutputsLast(\n parts: UIMessage['parts'],\n): UIMessage['parts'] {\n const files = parts.filter((part) => FILE_OUTPUT_PARTS.has(part.type))\n return files.length > 0\n ? [\n ...parts.filter((part) => !FILE_OUTPUT_PARTS.has(part.type)),\n ...files,\n ]\n : parts\n}\n\n/**\n * The key of a part in the feed. Its position, except for a file output: that\n * one is always last, so its position moves as the answer grows, and keyed by\n * it the card would be redrawn at every new part.\n */\nexport function feedPartKey(\n part: UIMessage['parts'][number],\n index: number,\n): string | number {\n const toolCallId = (part as { toolCallId?: string }).toolCallId\n return FILE_OUTPUT_PARTS.has(part.type) && toolCallId\n ? `file-${toolCallId}`\n : index\n}\n\n/** A call the embedding page runs, as the backend stamped it (spec `host-tools.md`). */\ninterface HostCallPart {\n toolName: string\n title?: string\n state?: string\n errorText?: string\n toolMetadata?: { readOnly?: boolean; provider?: 'app' | 'page' }\n}\n\nexport function getHostCallPart(\n part: UIMessage['parts'][number] | null | undefined,\n): HostCallPart | undefined {\n return isHostToolPart(part) ? (part as unknown as HostCallPart) : undefined\n}\n\n/**\n * The page tools of the widget (spec `page-tools.md`): defined by the backend,\n * so their step is ours to name, in the user's language. A tool the app\n * registered is named by its own `title`.\n */\nconst PAGE_TOOL_STEPS: Record<string, { icon: string; label: string }> = {\n page_snapshot: {\n icon: 'ri:pages-line',\n label: 'messagePart.pageTool.snapshot',\n },\n page_read: {\n icon: 'ri:file-text-line',\n label: 'messagePart.pageTool.read',\n },\n page_click: { icon: 'ri:cursor-line', label: 'messagePart.pageTool.click' },\n page_fill: { icon: 'ri:edit-line', label: 'messagePart.pageTool.fill' },\n page_scroll: {\n icon: 'ri:arrow-up-down-line',\n label: 'messagePart.pageTool.scroll',\n },\n}\n\n/** A form the site annotated for agents: its tool is named `form_<toolname>`. */\nconst FORM_TOOL_STEP = {\n icon: 'ri:survey-line',\n label: 'messagePart.pageTool.form',\n}\n\nconst pageToolStep = (host: HostCallPart) =>\n host.toolMetadata?.provider === 'page'\n ? (PAGE_TOOL_STEPS[host.toolName] ??\n (host.toolName.startsWith('form_') ? FORM_TOOL_STEP : undefined))\n : undefined\n\n/**\n * A host call that changes something in the app or on the page: the feed\n * shows it even without the steps timeline, because what it did stays done.\n */\nexport function isHostActionPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n return getHostCallPart(part)?.toolMetadata?.readOnly === false\n}\n\nexport function isStreamingPart(\n part: UIMessage['parts'][number] | null | undefined,\n): part is Extract<UIMessage['parts'][number], { streaming?: boolean }> {\n if (!part) {\n return false\n }\n if ('state' in part) {\n return part.state === 'streaming' || part.state === 'input-streaming'\n }\n return false\n}\n\n/**\n * How much of a reasoning still being written its live box renders. The box is\n * a few lines tall and follows the bottom, while the reasoning of one turn runs\n * to tens of kilobytes: chat `st0Eg8iG0zUX0HQN` wrote 92KB, and parsing all of\n * it at every delta froze the tab. Four thousand characters leave a few screens\n * to scroll back through, and a finished step renders all of it.\n */\nexport const LIVE_REASONING_TAIL_LENGTH = 4000\n\n// A fence opener or closer, also inside a list item or a quote, whose markers\n// and indentation are skipped. The rest of the line tells them apart: a\n// closing fence carries no info string.\nconst FENCE_LINE =\n /^[ \\t]*(?:(?:[-*+]|\\d{1,9}[.)])[ \\t]+|>[ \\t]?)*(`{3,}|~{3,})(.*)$/gm\n\n/**\n * The end of a markdown text, at most `maxLength` characters long, cut on a\n * blank line (a line break when there is none) so it does not open on half a\n * paragraph. A table or a formula can still be cut in two. An ellipsis marks\n * the cut. A cut inside a fenced code block reopens the fence, or the rest of\n * the text would render as code and the code as prose.\n */\nexport function getMarkdownTail(markdown: string, maxLength: number): string {\n if (markdown.length <= maxLength) {\n return markdown\n }\n const from = markdown.length - maxLength\n // The boundary is looked for in the first half of the window only: the one\n // blank line of the window can be the last thing written, and cutting there\n // would leave nothing to render.\n const limit = from + maxLength / 2\n const boundary = (index: number, length: number) =>\n index !== -1 && index < limit ? index + length : undefined\n const cut =\n boundary(markdown.indexOf('\\n\\n', from), 2) ??\n boundary(markdown.indexOf('\\n', from), 1) ??\n from\n let openFence: string | undefined\n for (const match of markdown.matchAll(FENCE_LINE)) {\n if (match.index >= cut) {\n break\n }\n const [, marker, rest] = match\n if (!openFence) {\n // A backtick in a backtick fence's info string makes it inline\n // code, not a fence.\n if (marker[0] === '`' && rest.includes('`')) {\n continue\n }\n openFence = marker\n } else if (\n marker[0] === openFence[0] &&\n marker.length >= openFence.length &&\n !rest.trim()\n ) {\n openFence = undefined\n }\n }\n const reopen = openFence ? `${openFence}\\n` : ''\n return `…\\n\\n${reopen}${markdown.slice(cut)}`\n}\n\n/**\n * States a tool part goes through when it needs the user's approval. They are\n * rendered by `PkToolApprovalCard` whatever the tool is, so the decision (and\n * its outcome) stays visible in the transcript.\n */\nconst TOOL_APPROVAL_STATES = new Set([\n 'approval-requested',\n 'approval-responded',\n 'output-denied',\n])\n\nexport function isToolApprovalPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n if (!isToolPart(part)) {\n return false\n }\n if (TOOL_APPROVAL_STATES.has(part.state)) {\n return true\n }\n // An executed (or errored) call that went through the gate keeps its\n // verdict in `approval`: the card stays in the transcript, so the user's\n // decision remains visible in the chat and in the log viewers (parity\n // with requestConfirm, whose 'confirmed' output is persisted).\n return (part as { approval?: unknown }).approval != null\n}\n\n/**\n * The client-side tool the model uses to have an action it described approved.\n * It predates the SDK's approval gate and keeps its own round-trip (it resolves\n * through `addToolOutput`), but it asks the user the very same question, so it\n * shares `PkToolApprovalCard` instead of having a card of its own.\n */\nexport const CONFIRM_TOOL_NAME = 'requestConfirm'\n\nexport function isToolConfirmPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n return isToolPart(part) && part.type === `tool-${CONFIRM_TOOL_NAME}`\n}\n\n/** True for any part the confirmation card is responsible for. */\nexport function isConfirmationCardPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n return isToolApprovalPart(part) || isToolConfirmPart(part)\n}\n\n/** The id of the pending approval request on a tool part, if any. */\nexport function getToolApprovalId(\n part: UIMessage['parts'][number] | null | undefined,\n): string | undefined {\n if (!isToolPart(part)) {\n return undefined\n }\n return (part as { approval?: { id?: string } }).approval?.id\n}\n\nexport function getPartState(\n part: UIMessage['parts'][number] | null | undefined,\n): string | undefined {\n if (!part) {\n return undefined\n }\n if ('state' in part) {\n return part.state\n }\n return undefined\n}\n\nexport function isLoadingState(state?: string): boolean {\n if (!state) {\n return false\n }\n return ['streaming'].includes(state)\n}\n\nexport function getContrast(hexcolor: string = '000000'): 'black' | 'white' {\n let hex = hexcolor.replace('#', '')\n\n // Expand 3-character hex to 6-character (e.g., #ccc -> #cccccc)\n if (hex.length === 3) {\n hex = hex\n .split('')\n .map((char) => char + char)\n .join('')\n }\n\n // WCAG relative luminance\n const r = parseInt(hex.substring(0, 2), 16) / 255\n const g = parseInt(hex.substring(2, 4), 16) / 255\n const b = parseInt(hex.substring(4, 6), 16) / 255\n\n const linearize = (c: number) =>\n c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n\n const luminance =\n 0.2126 * linearize(r) + 0.7152 * linearize(g) + 0.0722 * linearize(b)\n\n return luminance > 0.179 ? 'black' : 'white'\n}\n\n/**\n * True for a hex color with almost no hue: black, white and the grays between.\n * Anything else, a color the function cannot read included, counts as colored.\n */\nexport function isAchromaticColor(hexcolor: string | undefined): boolean {\n let hex = hexcolor?.trim().replace('#', '') ?? ''\n if (/^[0-9a-f]{3}$/i.test(hex)) {\n hex = hex\n .split('')\n .map((char) => char + char)\n .join('')\n }\n if (!/^[0-9a-f]{6}$/i.test(hex)) {\n return false\n }\n const channels = [0, 2, 4].map((at) =>\n parseInt(hex.substring(at, at + 2), 16),\n )\n return Math.max(...channels) - Math.min(...channels) < 32\n}\n\n/**\n * Resolves the contrast color based on the user's `textColor` preference.\n * Falls back to WCAG auto-detection via `getContrast` when set to `'auto'` or `undefined`.\n */\nexport function resolveContrastColor(\n textColor: 'auto' | 'white' | 'black' | undefined,\n mainColor: string | undefined,\n): 'black' | 'white' {\n if (textColor === 'white' || textColor === 'black') {\n return textColor\n }\n return getContrast(mainColor)\n}\n\n/**\n * The style of a chat root (PkChatbot, the widget's shell): the agent's color\n * as the brand. Volver derives every role of the brand (graphic, readable,\n * contrast, tinted surface) on any element with `.theme`, which both roots\n * carry, so the focus ring, the primary buttons, the links and the checkboxes\n * take the agent's color with the contrast each theme needs, instead of the\n * platform's purple. The fields' focus takes the brand's graphic role in both\n * themes, since the dark theme's accent is the platform's too.\n */\nexport function agentThemeStyle(\n mainColor: string | undefined,\n contrastColor: 'black' | 'white',\n): Record<string, string> | undefined {\n if (!mainColor) {\n return undefined\n }\n return {\n '--chatbot-main-color': mainColor,\n '--chatbot-contrast-color': contrastColor,\n '--color-brand': mainColor,\n '--color-brand-contrast': contrastColor,\n '--input-focus-color': 'var(--color-brand-graphic)',\n }\n}\n\n/**\n * Formats a duration in milliseconds using the i18n `seconds` number format\n * (e.g. \"12,4 secondi\" / \"12.4 seconds\"). Returns undefined for durations\n * that would render as \"0 seconds\" (less than 0.05s).\n */\nexport function formatDuration(\n $n: (value: number, format: string) => string,\n ms?: number,\n): string | undefined {\n if (ms === undefined || ms < 50) {\n return undefined\n }\n return $n(ms / 1000, 'seconds')\n}\n\n/**\n * Stringifies a tool payload for the raw fallback view. Returns undefined for\n * empty values so the caller can skip rendering the block entirely.\n */\nexport function stringifyPayload(value: unknown): string | undefined {\n if (value === undefined) {\n return undefined\n }\n if (typeof value === 'string') {\n return value.trim() || undefined\n }\n try {\n const json = JSON.stringify(value, null, 2)\n return json === '{}' || json === '[]' ? undefined : json\n } catch {\n return undefined\n }\n}\n\n/**\n * True when a tool payload carries something worth rendering, so a caller can\n * skip the block without stringifying the value twice.\n */\nexport function hasPayload(value: unknown): boolean {\n return stringifyPayload(value) !== undefined\n}\n\n/**\n * Turns the answers of a form into the sentence the caller would have said.\n *\n * On a call the tool loop is over by the time the form is on screen, so the\n * answers go back to the agent as a user message (see `sendUserMessage` in\n * `useVoiceSession`). Each answer is paired with its question, because that is\n * how a person would say it and because the agent hears it with no widget\n * attached.\n */\nexport function formAnswerAsSpoken(\n part: unknown,\n answer: string | { answers: { id: string; value: unknown }[] },\n): string {\n const input = (\n part as {\n input?: {\n steps?: { id: string; question?: string }[]\n question?: string\n }\n }\n )?.input\n\n if (typeof answer === 'string') {\n const question = input?.question ?? input?.steps?.[0]?.question\n return question ? `${question} ${answer}` : answer\n }\n\n const questionById = new Map(\n (input?.steps ?? []).map((step) => [step.id, step.question]),\n )\n const lines = answer.answers\n .filter(\n ({ value }) =>\n value !== null &&\n value !== '' &&\n !(Array.isArray(value) && !value.length),\n )\n .map(({ id, value }) => {\n const said = Array.isArray(value) ? value.join(', ') : String(value)\n const question = questionById.get(id)\n return question ? `${question} ${said}` : said\n })\n\n return lines.join('. ')\n}\n\n/**\n * The choices of a form step, as the radio and checkbox editors take them.\n *\n * The `value` is the LABEL and not the position, because it is what travels\n * back to the model as the answer: it reads the words it wrote, not an index.\n * Nothing here caps the list, and nothing should: the number of options an\n * agent configures is advice to the model, so a step can legitimately carry\n * more (see `showForm.tool.ts`).\n */\nexport function formStepOptions(\n step: { options?: { label: string; description?: string }[] } | undefined,\n): { label: string; value: string; description?: string }[] {\n if (!step?.options) {\n return []\n }\n return step.options.map((option) => ({\n label: option.label,\n value: option.label,\n description: option.description,\n }))\n}\n\n/**\n * Spreads the answers a form comes back with onto one slot PER STEP.\n *\n * A form's answers travel paired with step ids, and the tool schema does not\n * enforce that those ids are unique: a `.refine()` there would refuse the whole\n * form over a duplicate, which is the failure the schema was just cured of (see\n * the gotchas entry \"A configurable cap does not belong in an inputSchema\").\n * So the duplicate has to be survivable here. Keyed by id, two steps sharing\n * one collapsed onto a single answer: the second question showed the first\n * one's reply, and submitting sent that reply twice. Keyed by position, each\n * step keeps its own.\n *\n * A duplicated id restores the same incoming value to every step claiming it,\n * which is as much as the payload allows: the ids are all it says.\n */\nexport function formAnswerSlots(\n steps: { id: string }[],\n output: unknown,\n): Record<number, unknown> {\n const slots: Record<number, unknown> = {}\n if (output === undefined || output === null) {\n return slots\n }\n // A legacy single-choice answer is the plain string, and it can only\n // belong to a single-step form.\n if (typeof output === 'string') {\n if (steps.length === 1) {\n slots[0] = output\n }\n return slots\n }\n const assign = (id: string, value: unknown) => {\n steps.forEach((step, index) => {\n if (step.id === id) {\n slots[index] = value\n }\n })\n }\n const list = (output as { answers?: unknown }).answers\n if (Array.isArray(list)) {\n for (const answer of list as { id?: unknown; value?: unknown }[]) {\n if (typeof answer?.id === 'string') {\n assign(answer.id, answer.value)\n }\n }\n return slots\n }\n // Forms answered on a platform channel (the Teams modal) come back as a\n // flat record keyed by step id.\n for (const [id, value] of Object.entries(\n output as Record<string, unknown>,\n )) {\n if (value !== undefined) {\n assign(id, value)\n }\n }\n return slots\n}\n\n// Web search tool part types, gateway and provider-native\nexport const WEB_SEARCH_TOOL_TYPES: string[] = WEB_SEARCH_TOOL_KEYS.map(\n (key) => `tool-${key}`,\n)\n\n// Tool part types with a dedicated rich rendering in PkChatbotStepToolDetail\nconst RICH_DETAIL_TOOL_TYPES = new Set([\n 'tool-searchInKnowledgeBase',\n 'tool-retrieveRevisedAnswers',\n 'tool-expandChunkContext',\n 'tool-readDocumentFile',\n 'tool-getWeather',\n 'tool-geocode',\n 'tool-recallUserMemory',\n 'tool-saveUserMemory',\n ...WEB_SEARCH_TOOL_TYPES,\n])\n\nexport function hasRichToolDetail(\n part?: UIMessage['parts'][number] | null,\n): boolean {\n return isToolPart(part) && RICH_DETAIL_TOOL_TYPES.has(part.type)\n}\n\nconst asRecord = (value: unknown): Record<string, unknown> | undefined =>\n value && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined\n\nconst pickString = (\n record: Record<string, unknown> | undefined,\n ...keys: string[]\n): string | undefined => {\n for (const key of keys) {\n const value = record?.[key]\n if (typeof value === 'string' && value.trim()) {\n return value\n }\n }\n return undefined\n}\n\n/**\n * Returns a short inline summary for a tool part (search queries, location,\n * document name, ...) to be shown next to the step label without expanding\n * the step body.\n */\nexport function getToolPartSummary(\n part?: UIMessage['parts'][number] | null,\n): string | undefined {\n if (!isToolPart(part)) {\n return undefined\n }\n const input = asRecord('input' in part ? part.input : undefined)\n const output = asRecord('output' in part ? part.output : undefined)\n if (\n part.type === 'tool-searchInKnowledgeBase' ||\n WEB_SEARCH_TOOL_TYPES.includes(part.type)\n ) {\n const queries = input?.queries\n if (Array.isArray(queries)) {\n const valid = queries.filter(\n (query): query is string =>\n typeof query === 'string' && Boolean(query.trim()),\n )\n return valid.length ? valid.join(' · ') : undefined\n }\n return pickString(input, 'query', 'objective')\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return pickString(input, 'query')\n }\n if (part.type === 'tool-getWeather') {\n return (\n pickString(output, 'location') ?? pickString(input, 'locationName')\n )\n }\n if (part.type === 'tool-geocode') {\n return pickString(input, 'locationName')\n }\n if (part.type === 'tool-expandChunkContext') {\n return pickString(output, 'documentName')\n }\n if (\n part.type === 'tool-readDocumentFile' ||\n part.type === 'tool-readChatAttachment'\n ) {\n return pickString(output, 'name')\n }\n if (part.type === 'tool-readSpreadsheet') {\n const sheet = pickString(input, 'sheet')\n const range = pickString(input, 'range')\n return sheet && range ? `${sheet}!${range}` : sheet\n }\n if (part.type === 'tool-editSpreadsheet') {\n return pickString(output, 'filename')\n }\n if (part.type === 'tool-querySpreadsheet') {\n // The file when the step asked for the schema; a query has no name.\n return pickString(output, 'file')\n }\n if (part.type === 'tool-recallUserMemory') {\n return pickString(input, 'query')\n }\n if (part.type === 'tool-saveUserMemory') {\n return pickString(input, 'content', 'query')\n }\n return undefined\n}\n\n// Get part icon\nexport function getPartIcon(\n part?: UIMessage['parts'][number] | null,\n): string | undefined {\n const host = getHostCallPart(part)\n if (host) {\n return pageToolStep(host)?.icon ?? 'ri:apps-line'\n }\n if (isToolPart(part)) {\n if (part.type.includes('tool-subagent')) {\n return 'ri:robot-2-line'\n }\n if (part.type === 'tool-runWorker') {\n return 'ri:flow-chart'\n }\n if (part.type === 'tool-scheduleWakeup') {\n return 'ri:alarm-line'\n }\n if (part.type === 'tool-fetchTeamsChannelHistory') {\n return 'ri:chat-history-line'\n }\n if (part.type === 'tool-readEarlierMessages') {\n return 'ri:history-line'\n }\n if (part.type === 'tool-readChatAttachment') {\n return 'ri:attachment-line'\n }\n if (part.type === 'tool-enableTools') {\n return 'ri:toggle-line'\n }\n if (part.type.includes('tool-mcp')) {\n return 'mcp'\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return 'ri:file-edit-line'\n }\n if (part.type === 'tool-searchInKnowledgeBase') {\n return 'ri:search-line'\n }\n if (part.type === 'tool-expandChunkContext') {\n return 'ri:file-search-line'\n }\n if (part.type === 'tool-readDocumentFile') {\n return 'ri:file-text-line'\n }\n if (part.type === 'tool-readSpreadsheet') {\n return 'ri:table-line'\n }\n if (part.type === 'tool-editSpreadsheet') {\n return 'ri:file-excel-2-line'\n }\n if (part.type === 'tool-querySpreadsheet') {\n return 'ri:database-2-line'\n }\n if (part.type === 'tool-geocode') {\n return 'ri:map-2-line'\n }\n if (part.type === 'tool-getWeather') {\n return 'ri:sun-cloudy-line'\n }\n if (part.type === 'tool-recallUserMemory') {\n return 'ri:brain-line'\n }\n if (part.type === 'tool-saveUserMemory') {\n return 'ri:save-3-line'\n }\n if (part.type === 'tool-showWeather') {\n return 'ri:sun-line'\n }\n if (part.type === 'tool-showDiagram') {\n return 'ri:flow-chart'\n }\n if (part.type === 'tool-showSources') {\n return 'ri:book-2-line'\n }\n if (part.type === 'tool-showForm') {\n return 'ri:survey-line'\n }\n if (part.type === 'tool-showMultipleChoice') {\n return 'ri:checkbox-multiple-line'\n }\n if (part.type === 'tool-showArtifact') {\n return 'ri:file-code-line'\n }\n if (part.type === 'tool-showEmail') {\n return 'ri:mail-line'\n }\n if (part.type === 'tool-showMessage') {\n return 'ri:chat-1-line'\n }\n if (part.type === 'tool-showWebPages') {\n return 'ri:pages-line'\n }\n if (part.type === 'tool-showProductList') {\n return 'ri:shopping-bag-line'\n }\n if (part.type === 'tool-showContactForm') {\n return 'ri:send-plane-2-line'\n }\n if (part.type === 'tool-showCalendarEvent') {\n return 'ri:calendar-event-line'\n }\n if (part.type === 'tool-showComparison') {\n return 'ri:scales-line'\n }\n if (part.type === 'tool-showLocation') {\n return 'ri:map-pin-line'\n }\n if (part.type === 'tool-showQrCode') {\n return 'ri:qr-code-line'\n }\n if (part.type === 'tool-showImageGallery') {\n return 'ri:image-line'\n }\n if (part.type === 'tool-showVideo') {\n return 'ri:film-line'\n }\n if (part.type === 'tool-showSuggestedReply') {\n return 'ri:corner-down-right-line'\n }\n if (part.type === 'tool-requestGeolocation') {\n return 'ri:map-pin-user-line'\n }\n if (part.type === 'tool-disconnectOAuthConnection') {\n return 'ri:link-unlink'\n }\n if (part.type === 'tool-requestAccountLink') {\n return 'ri:link'\n }\n if (part.type === 'tool-unlinkAccount') {\n return 'ri:link-unlink'\n }\n if (WEB_SEARCH_TOOL_TYPES.includes(part.type)) {\n return 'ri:global-line'\n }\n return 'ri:tools-line'\n }\n if (isReasoningPart(part)) {\n return 'ri:lightbulb-line'\n }\n if (isTextPart(part)) {\n return 'ri:double-quotes-r'\n }\n return undefined\n}\n\n/** What `toolLabel` and `getPartTypeLabel` need from vue-i18n. */\nexport interface LabelTranslator {\n t: (key: string) => string\n te: (key: string) => boolean\n}\n\nconst TOOL_KEY_PREFIXES = [\n API_TOOL_PREFIX,\n MCP_TOOL_PREFIX,\n SUBAGENT_TOOL_PREFIX,\n] as const\n\n/**\n * The name a person reads for a tool of the turn: the translated label of a\n * built-in tool, otherwise the name the agent configured, without its\n * tool-set prefix and in words (`api-festivita_nazionali` reads \"Festivita\n * nazionali\"). Never the raw key, and never an i18n key with no translation,\n * which vue-i18n would print as the key itself.\n */\nexport function toolLabel(name: string, { t, te }: LabelTranslator): string {\n if (te(`agent.tool.${name}`)) {\n return t(`agent.tool.${name}`)\n }\n const prefix = TOOL_KEY_PREFIXES.find((p) => name.startsWith(p))\n const bare = prefix ? name.slice(prefix.length) : name\n return capitalizeFirstLetter(fromAnyCase(bare).trim().toLowerCase())\n}\n\n/**\n * The kinds of message part a person can meet, each with its label. Written\n * as literal keys so the widget's library build, which keeps only the keys it\n * finds written out (apps/web-component/vite-plugins/chatLocales.ts), ships\n * them too.\n */\nconst PART_TYPE_LABELS: Record<string, (t: LabelTranslator['t']) => string> = {\n custom: (t) => t('messagePart.type.custom'),\n data: (t) => t('messagePart.type.data'),\n file: (t) => t('messagePart.type.file'),\n reasoning: (t) => t('messagePart.type.reasoning'),\n 'source-document': (t) => t('messagePart.type.sourceDocument'),\n 'source-url': (t) => t('messagePart.type.sourceUrl'),\n 'step-start': (t) => t('messagePart.type.stepStart'),\n text: (t) => t('messagePart.type.text'),\n}\n\n/**\n * The label of a message part in the message details: the tool for a tool\n * call, the translated kind otherwise (text, reasoning, provider data...),\n * and the kind in words for one the catalog does not know yet.\n */\nexport function getPartTypeLabel(\n part: UIMessage['parts'][number],\n translator: LabelTranslator,\n): string {\n if (isToolPart(part)) {\n return toolLabel(getToolPartName(part), translator)\n }\n if (part.type === 'dynamic-tool') {\n return toolLabel(part.toolName, translator)\n }\n const kind = part.type.startsWith('data-') ? 'data' : part.type\n const label = PART_TYPE_LABELS[kind]\n return label\n ? label(translator.t)\n : capitalizeFirstLetter(fromAnyCase(part.type))\n}\n\n/**\n * The commercial name of a provider the gateway routed a turn through, from\n * its slug (`anthropic`, `bedrock`): proper nouns, so no translation. A slug\n * not listed here shows with a capital, never as the bare id.\n */\nconst PROVIDER_NAMES: Record<string, string> = {\n alibaba: 'Alibaba Cloud',\n anthropic: 'Anthropic',\n azure: 'Microsoft Azure',\n baseten: 'Baseten',\n bedrock: 'Amazon Bedrock',\n cerebras: 'Cerebras',\n cohere: 'Cohere',\n deepinfra: 'DeepInfra',\n deepseek: 'DeepSeek',\n fireworks: 'Fireworks AI',\n google: 'Google',\n groq: 'Groq',\n mistral: 'Mistral AI',\n moonshotai: 'Moonshot AI',\n openai: 'OpenAI',\n perplexity: 'Perplexity',\n togetherai: 'Together AI',\n vertex: 'Google Vertex AI',\n xai: 'xAI',\n zai: 'Z.ai',\n}\n\n/** The name of a provider slug, see `PROVIDER_NAMES`. */\nexport function providerLabel(slug: string): string {\n return (\n PROVIDER_NAMES[slug.toLowerCase()] ??\n capitalizeFirstLetter(fromAnyCase(slug))\n )\n}\n\n/**\n * The conversation summary in the reader's language. The analysis asks the\n * model for four bold labels (`SUMMARY_FORMAT` in\n * apps/backend/src/prompts/analysis.prompt.ts) and the model copies them in\n * English whatever the conversation's language, so every stored summary\n * holds them: they are translated where a summary is read. An empty summary\n * comes back as it is, so a `??` fallback after it still works.\n */\nexport function localizeSummaryLabels<T extends string | null | undefined>(\n summary: T,\n t: (key: string) => string,\n): T {\n if (!summary) {\n return summary\n }\n const labels: Record<string, string> = {\n Intent: t('conversationSummary.intent'),\n 'Topics covered': t('conversationSummary.topicsCovered'),\n 'Key facts': t('conversationSummary.keyFacts'),\n 'Open questions': t('conversationSummary.openQuestions'),\n }\n return summary.replace(\n /\\*\\*(Intent|Topics covered|Key facts|Open questions)(:?)\\*\\*/g,\n (_, label: string, colon: string) => `**${labels[label]}${colon}**`,\n ) as T\n}\n\n// Get part label\nexport function getToolPartLabel(\n $t: (key: string) => string,\n part?: UIMessage['parts'][number] | null,\n): string | undefined {\n const host = getHostCallPart(part)\n if (host) {\n const page = pageToolStep(host)\n return page ? $t(page.label) : host.title || host.toolName\n }\n if (isToolPart(part)) {\n if (part.type.includes('tool-subagent')) {\n return $t(`messagePart.runSubagent`)\n }\n if (part.type === 'tool-runWorker') {\n return $t(`messagePart.runWorker`)\n }\n if (part.type === 'tool-scheduleWakeup') {\n return $t(`messagePart.scheduleWakeup`)\n }\n if (part.type === 'tool-fetchTeamsChannelHistory') {\n return $t(`messagePart.fetchTeamsChannelHistory`)\n }\n if (part.type === 'tool-readEarlierMessages') {\n return $t(`messagePart.readEarlierMessages`)\n }\n if (part.type === 'tool-readChatAttachment') {\n return $t(`messagePart.readChatAttachment`)\n }\n if (part.type === 'tool-enableTools') {\n return $t(`messagePart.enableTools`)\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return $t(`messagePart.revisedAnswers`)\n }\n if (part.type === 'tool-searchInKnowledgeBase') {\n return $t(`messagePart.searchingDocuments`)\n }\n if (part.type === 'tool-expandChunkContext') {\n return $t(`messagePart.expandChunkContext`)\n }\n if (part.type === 'tool-readDocumentFile') {\n return $t(`messagePart.readDocumentFile`)\n }\n if (part.type === 'tool-readSpreadsheet') {\n return $t(`messagePart.readSpreadsheet`)\n }\n if (part.type === 'tool-editSpreadsheet') {\n return $t(`messagePart.editSpreadsheet`)\n }\n if (part.type === 'tool-querySpreadsheet') {\n return $t(`messagePart.querySpreadsheet`)\n }\n if (part.type === 'tool-geocode') {\n return $t(`messagePart.geocode`)\n }\n if (part.type === 'tool-getWeather') {\n return $t(`messagePart.getWeather`)\n }\n if (part.type === 'tool-recallUserMemory') {\n return $t(`messagePart.recallUserMemory`)\n }\n if (part.type === 'tool-saveUserMemory') {\n return $t(`messagePart.saveUserMemory`)\n }\n if (part.type === 'tool-showWeather') {\n return $t(`messagePart.showWeather`)\n }\n if (part.type === 'tool-showForm') {\n return $t(`messagePart.showForm`)\n }\n if (part.type === 'tool-showDiagram') {\n return $t(`messagePart.showDiagram`)\n }\n if (part.type === 'tool-showSources') {\n return $t(`messagePart.showSources`)\n }\n if (part.type === 'tool-showMultipleChoice') {\n return $t(`messagePart.showMultipleChoice`)\n }\n if (part.type === 'tool-showArtifact') {\n return $t(`messagePart.showArtifact`)\n }\n if (part.type === 'tool-showEmail') {\n return $t(`messagePart.showEmail`)\n }\n if (part.type === 'tool-showMessage') {\n return $t(`messagePart.showMessage`)\n }\n if (part.type === 'tool-showWebPages') {\n return $t(`messagePart.showWebPages`)\n }\n if (part.type === 'tool-showProducts') {\n return $t(`messagePart.showProducts`)\n }\n if (part.type === 'tool-showContactForm') {\n return $t(`messagePart.showContactForm`)\n }\n if (part.type === 'tool-showCalendarEvent') {\n return $t(`messagePart.showCalendarEvent`)\n }\n if (part.type === 'tool-showComparison') {\n return $t(`messagePart.showComparison`)\n }\n if (part.type === 'tool-showLocation') {\n return $t(`messagePart.showLocation`)\n }\n if (part.type === 'tool-showQrCode') {\n return $t(`messagePart.showQrCode`)\n }\n if (part.type === 'tool-showImageGallery') {\n return $t(`messagePart.showImageGallery`)\n }\n if (part.type === 'tool-showVideo') {\n return $t(`messagePart.showVideo`)\n }\n if (part.type === 'tool-showSuggestedReply') {\n return $t(`messagePart.showSuggestedReply`)\n }\n if (part.type === 'tool-requestGeolocation') {\n return $t(`messagePart.requestGeolocation`)\n }\n if (part.type === 'tool-disconnectOAuthConnection') {\n return $t(`messagePart.disconnectOAuthConnection`)\n }\n if (part.type === 'tool-requestAccountLink') {\n return $t(`messagePart.requestAccountLink`)\n }\n if (part.type === 'tool-unlinkAccount') {\n return $t(`messagePart.unlinkAccount`)\n }\n if (WEB_SEARCH_TOOL_TYPES.includes(part.type)) {\n return $t(`messagePart.webSearch`)\n }\n return $t(`messagePart.tool`)\n }\n if (isReasoningPart(part)) {\n return $t(`messagePart.reasoning`)\n }\n return $t(`messagePart.streaming`)\n}\n"],"mappings":";;;;AAAA,IAAaU,KAAiB,MAC1BC,EAAI,UAAU,KAAK,CAAC,CAAC,QAAQ,oBAAoB,EAAE,GAkB1CC,KAAe,MACnBD,IAGEA,EACF,QAAQ,sBAAsB,OAAO,CAAC,CACtC,QAAQ,yBAAyB,OAAO,CAAC,CACzC,QAAQ,UAAU,GAAG,IALf,IAiBFE,KAAiC,MACrCF,IAGED,EAAcC,CAAG,CAAC,CACpB,QAAQ,sBAAsB,OAAO,CAAC,CACtC,QAAQ,kBAAkB,GAAG,CAAC,CAC9B,YAAY,IALN,IAeFG,MAAiC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,gCAAgC,IAE1ClH,EAAK,SAAS,sBACPkH,EAAG,0BAA0B,IAEpClH,EAAK,SAAS,mBACPkH,EAAG,uBAAuB,IAEjClH,EAAK,SAAS,qBACPkH,EAAG,yBAAyB,IAEnClH,EAAK,SAAS,sBACPkH,EAAG,0BAA0B,IAEpClH,EAAK,SAAS,sBACPkH,EAAG,0BAA0B,IAEpClH,EAAK,SAAS,yBACPkH,EAAG,6BAA6B,IAEvClH,EAAK,SAAS,2BACPkH,EAAG,+BAA+B,IAEzClH,EAAK,SAAS,wBACPkH,EAAG,4BAA4B,IAEtClH,EAAK,SAAS,sBACPkH,EAAG,0BAA0B,IAEpClH,EAAK,SAAS,oBACPkH,EAAG,wBAAwB,IAElClH,EAAK,SAAS,0BACPkH,EAAG,8BAA8B,IAExClH,EAAK,SAAS,mBACPkH,EAAG,uBAAuB,IAEjClH,EAAK,SAAS,4BACPkH,EAAG,gCAAgC,IAE1ClH,EAAK,SAAS,4BACPkH,EAAG,gCAAgC,IAE1ClH,EAAK,SAAS,mCACPkH,EAAG,uCAAuC,IAEjDlH,EAAK,SAAS,4BACPkH,EAAG,gCAAgC,IAE1ClH,EAAK,SAAS,uBACPkH,EAAG,2BAA2B,IAErCnC,EAAsB,SAAS/E,EAAK,IAAI,IACjCkH,EAAG,uBAAuB,IAE9BA,EAAG,kBAAkB,IAE5B9H,EAAgBY,CAAI,IACbkH,EAAG,uBAAuB,IAE9BA,EAAG,uBAAuB;AACrC"}
package/dist-vue/api.js CHANGED
@@ -1 +1 @@
1
- export { t as createChatbotApiClient } from "./_chunks/createChatbotApiClient-MbfcTdwY.js";
1
+ export { t as createChatbotApiClient } from "./_chunks/createChatbotApiClient-qHjpFqPL.js";
@@ -26,14 +26,20 @@ type __VLS_Props = {
26
26
  * `prefers-color-scheme`. Let a host app hand down its own theme.
27
27
  */
28
28
  systemTheme?: 'light' | 'dark';
29
+ /**
30
+ * The chat's color scheme, over the agent's own setting too: a
31
+ * host that switches between light and dark around the chat
32
+ * (Agent Studio's assistant) keeps the chat in step with it.
33
+ */
34
+ theme?: 'light' | 'dark';
29
35
  };
30
- declare var __VLS_67: {}, __VLS_70: {}, __VLS_88: string, __VLS_89: {};
36
+ declare var __VLS_74: {}, __VLS_77: {}, __VLS_95: string, __VLS_96: {};
31
37
  type __VLS_Slots = {} & {
32
- [K in NonNullable<typeof __VLS_88>]?: (props: typeof __VLS_89) => any;
38
+ [K in NonNullable<typeof __VLS_95>]?: (props: typeof __VLS_96) => any;
33
39
  } & {
34
- 'header-actions'?: (props: typeof __VLS_67) => any;
40
+ 'header-actions'?: (props: typeof __VLS_74) => any;
35
41
  } & {
36
- actions?: (props: typeof __VLS_70) => any;
42
+ actions?: (props: typeof __VLS_77) => any;
37
43
  };
38
44
  declare const __VLS_base: DefineComponent<__VLS_Props, {
39
45
  sendMessage(text: string): void;
@@ -45,7 +51,9 @@ declare const __VLS_base: DefineComponent<__VLS_Props, {
45
51
  signIn: (newExternalToken: string) => Promise<void>;
46
52
  signOut: () => Promise<void>;
47
53
  readonly isWorking: boolean;
54
+ readonly isControllingPage: boolean;
48
55
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
56
+ theme: "light" | "dark";
49
57
  customCss: string;
50
58
  baseUrl: string;
51
59
  systemTheme: "light" | "dark";
@@ -17,8 +17,8 @@ type __VLS_Props = {
17
17
  floatingButtonPosition?: 'left' | 'right';
18
18
  /** `floating` or `copilot`: wins over the agent's setting (spec widget-copilot.md). */
19
19
  layout?: string;
20
- /** Copilot layout only, `overlay` or `push`: wins over the agent's setting. */
21
- copilotFrame?: string;
20
+ /** Floating layout only, `solid` or `glass`: wins over the agent's setting. */
21
+ appearance?: string;
22
22
  customCss?: string;
23
23
  /** Override the session/anonymous cookie name (defaults to 'eight-wave-ai'). */
24
24
  cookieName?: string;
@@ -43,10 +43,11 @@ declare const __VLS_export: DefineComponent<__VLS_Props, {
43
43
  signOut: () => Promise<void>;
44
44
  readonly isOpen: boolean;
45
45
  readonly isWorking: boolean;
46
+ readonly isControllingPage: boolean;
46
47
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
47
48
  floatingButtonPosition: "left" | "right";
48
49
  layout: string;
49
- copilotFrame: string;
50
+ appearance: string;
50
51
  customCss: string;
51
52
  baseUrl: string;
52
53
  systemTheme: "light" | "dark";
@@ -1,5 +1,5 @@
1
1
  import { MaybeRefOrGetter } from 'vue';
2
- import { AgentStatus, AgentVisibility, AgentWidgetLayout, AgentCopilotFrame, AgentLoaderStrategy, StoragePolicy, PageAccessLevel, AgentChannel } from '../../../../packages/models/src';
2
+ import { AgentStatus, AgentVisibility, AgentWidgetLayout, AgentWidgetAppearance, AgentLoaderStrategy, StoragePolicy, PageAccessLevel, AgentChannel } from '../../../../packages/models/src';
3
3
  export declare function useChatbotAgent(options: {
4
4
  baseUrl?: string;
5
5
  basePath?: string;
@@ -12,6 +12,8 @@ export declare function useChatbotAgent(options: {
12
12
  * then this override, then the OS `prefers-color-scheme`.
13
13
  */
14
14
  systemTheme?: MaybeRefOrGetter<'light' | 'dark' | undefined>;
15
+ /** Host-provided color scheme that wins over the agent theme too. */
16
+ theme?: MaybeRefOrGetter<'light' | 'dark' | undefined>;
15
17
  }): {
16
18
  agent: globalThis.Ref<{
17
19
  id: string;
@@ -28,7 +30,8 @@ export declare function useChatbotAgent(options: {
28
30
  welcomePopup: boolean;
29
31
  floatingButtonPosition: "left" | "right";
30
32
  layout: AgentWidgetLayout;
31
- copilotFrame: AgentCopilotFrame;
33
+ appearance: AgentWidgetAppearance;
34
+ hideFloatingButton: boolean;
32
35
  workingGlow: boolean;
33
36
  widgetUrl: string;
34
37
  loadDelay: number;
@@ -162,7 +165,8 @@ export declare function useChatbotAgent(options: {
162
165
  welcomePopup: boolean;
163
166
  floatingButtonPosition: "left" | "right";
164
167
  layout: AgentWidgetLayout;
165
- copilotFrame: AgentCopilotFrame;
168
+ appearance: AgentWidgetAppearance;
169
+ hideFloatingButton: boolean;
166
170
  workingGlow: boolean;
167
171
  widgetUrl: string;
168
172
  loadDelay: number;
@@ -292,7 +296,8 @@ export declare function useChatbotAgent(options: {
292
296
  textColor: "auto" | "white" | "black";
293
297
  floatingButtonPosition: "left" | "right";
294
298
  layout: AgentWidgetLayout;
295
- copilotFrame: AgentCopilotFrame;
299
+ appearance: AgentWidgetAppearance;
300
+ hideFloatingButton: boolean;
296
301
  logo?: string | undefined;
297
302
  copilotPageCss?: string | undefined;
298
303
  customCss?: string | undefined;
@@ -307,7 +312,8 @@ export declare function useChatbotAgent(options: {
307
312
  textColor: "auto" | "white" | "black";
308
313
  floatingButtonPosition: "left" | "right";
309
314
  layout: AgentWidgetLayout;
310
- copilotFrame: AgentCopilotFrame;
315
+ appearance: AgentWidgetAppearance;
316
+ hideFloatingButton: boolean;
311
317
  logo?: string | undefined;
312
318
  copilotPageCss?: string | undefined;
313
319
  customCss?: string | undefined;
@@ -1,5 +1,5 @@
1
1
  import { MaybeRefOrGetter, Ref } from 'vue';
2
- import { AgentBranding, AgentPublic, AuthMethods, AgentWidgetLayout, AgentCopilotFrame } from '../../../../packages/models/src';
2
+ import { AgentBranding, AgentPublic, AuthMethods, AgentWidgetLayout, AgentWidgetAppearance } from '../../../../packages/models/src';
3
3
  interface ProfileSessionValue {
4
4
  data: {
5
5
  user: {
@@ -47,7 +47,8 @@ export declare function useChatbotProfileProvider(deps: {
47
47
  textColor: "auto" | "white" | "black";
48
48
  floatingButtonPosition: "left" | "right";
49
49
  layout: AgentWidgetLayout;
50
- copilotFrame: AgentCopilotFrame;
50
+ appearance: AgentWidgetAppearance;
51
+ hideFloatingButton: boolean;
51
52
  logo?: string | undefined;
52
53
  copilotPageCss?: string | undefined;
53
54
  customCss?: string | undefined;
@@ -1,9 +1,17 @@
1
+ /** From here the copilot docks: `xl` of @volverjs/style, as in the widget's own styles. */
2
+ export declare const COPILOT_DOCKED_QUERY = "(min-width: 1280px)";
3
+ /**
4
+ * The room the docked panel takes: its width, `clamp(320px, 24vw, 406px)` in
5
+ * the widget's styles, plus the frame's margin (`--spacing-12`) on either
6
+ * side of it. In `rem` like the frame, so the two agree on a site with
7
+ * another root font size.
8
+ */
9
+ export declare const COPILOT_PANEL_ROOM = "calc(clamp(320px, 24vw, 406px) + 1.5rem)";
1
10
  /**
2
11
  * The agent's page CSS (spec `widget-copilot.md`, D7): a stylesheet in the
3
- * host page's `<head>` while the copilot panel is open and docked, with
4
- * either frame, and nothing otherwise. It is how a site moves its own
5
- * elements aside without a change to its code, with
6
- * `var(--chatbot-copilot-width)` in both frames. The text goes in as text,
12
+ * host page's `<head>` while the copilot panel is open and docked, and
13
+ * nothing otherwise. It is how a site moves its own elements aside without a
14
+ * change to its code, with `var(--chatbot-copilot-width)`. The text goes in as text,
7
15
  * never as markup, and the widget removes only its own sheet.
8
16
  */
9
17
  export declare function useCopilotPageCss(options: {
@@ -0,0 +1,19 @@
1
+ import { MaybeRefOrGetter, ShallowRef } from 'vue';
2
+ /**
3
+ * The page's open modal dialog, looked for while `watching` is true (a card
4
+ * waits, or the agent acts on the page) and `null` the rest of the time. A
5
+ * page does not say when it opens one, so it is polled.
6
+ */
7
+ export declare function usePageModal(watching: MaybeRefOrGetter<boolean>): ShallowRef<HTMLDialogElement | null>;
8
+ /**
9
+ * The stop of the control bar inside the page's modal dialog, while the agent
10
+ * acts on the page: the bar itself is inert behind that dialog, and the user
11
+ * must be able to stop the agent at any moment. Only the dialog's own content
12
+ * takes clicks, so the button goes in it, in a shadow root the page's styles
13
+ * do not reach. The page snapshot skips it, as it skips the widget.
14
+ */
15
+ export declare function usePageModalStop(modal: ShallowRef<HTMLDialogElement | null>, active: MaybeRefOrGetter<boolean>, options: {
16
+ text: () => string;
17
+ stopLabel: () => string;
18
+ onStop: () => void;
19
+ }): void;
@@ -10,7 +10,7 @@ export declare const FloatingChatWidgetCe: VueElementConstructor<{
10
10
  useHostSession?: boolean | string;
11
11
  floatingButtonPosition?: "left" | "right";
12
12
  layout?: string;
13
- copilotFrame?: string;
13
+ appearance?: string;
14
14
  customCss?: string;
15
15
  cookieName?: string;
16
16
  systemTheme?: "light" | "dark";
@@ -27,6 +27,7 @@ export declare const EmbeddedChatWidgetCe: VueElementConstructor<{
27
27
  cookieName?: string;
28
28
  displayMode?: "widget" | "fullscreen" | "panel";
29
29
  systemTheme?: "light" | "dark";
30
+ theme?: "light" | "dark";
30
31
  }>;
31
32
  declare module 'vue' {
32
33
  interface GlobalComponents {
@@ -75,8 +76,8 @@ export interface FloatingChatWidgetElement extends HTMLElement {
75
76
  floatingButtonPosition?: 'left' | 'right';
76
77
  /** `copilot` docks the chat on one side with the site framed beside it; wins over the agent's setting (spec `widget-copilot.md`). */
77
78
  layout?: 'floating' | 'copilot';
78
- /** Copilot layout only: `push` narrows the page beside the panel, `overlay` lays the panel over it; wins over the agent's setting. */
79
- copilotFrame?: 'overlay' | 'push';
79
+ /** Floating layout only: `glass` makes the card frosted glass over the page; wins over the agent's setting. */
80
+ appearance?: 'solid' | 'glass';
80
81
  customCss?: string;
81
82
  open(): void;
82
83
  close(): void;
@@ -94,6 +95,8 @@ export interface FloatingChatWidgetElement extends HTMLElement {
94
95
  readonly isOpen: boolean;
95
96
  /** The agent is answering or running a tool; false while it waits on the user (spec `widget-copilot.md`). */
96
97
  readonly isWorking: boolean;
98
+ /** The agent is acting on the page: the control bar and its stop show (spec `page-tools.md`). */
99
+ readonly isControllingPage: boolean;
97
100
  }
98
101
  export interface EmbeddedChatWidgetElement extends HTMLElement {
99
102
  organizationSlug: string;
@@ -106,6 +109,8 @@ export interface EmbeddedChatWidgetElement extends HTMLElement {
106
109
  useHostSession?: boolean;
107
110
  /** Layout mode: `widget` (default), `fullscreen` (full-page app layout) or `panel` (compact chrome for a docked side panel; the host owns background, border and open/close). */
108
111
  displayMode?: 'widget' | 'fullscreen' | 'panel';
112
+ /** The color scheme, over the agent's own setting too (`systemTheme` applies only to an agent set to automatic). */
113
+ theme?: 'light' | 'dark';
109
114
  forwardedSlots?: string;
110
115
  customCss?: string;
111
116
  sendMessage(text: string): void;
@@ -120,6 +125,8 @@ export interface EmbeddedChatWidgetElement extends HTMLElement {
120
125
  signOut(): Promise<void>;
121
126
  /** The agent is answering or running a tool; false while it waits on the user (spec `widget-copilot.md`). */
122
127
  readonly isWorking: boolean;
128
+ /** The agent is acting on the page: the control bar and its stop show (spec `page-tools.md`). */
129
+ readonly isControllingPage: boolean;
123
130
  }
124
131
  declare global {
125
132
  interface HTMLElementTagNameMap {
@@ -11,9 +11,42 @@ export declare function fill(element: Element, value: unknown, rules: PageRules)
11
11
  * popups and fullscreen stay out of reach.
12
12
  */
13
13
  export declare function click(element: Element): string;
14
+ /**
15
+ * The pointer moving onto `element`: a menu or a tooltip that opens on hover
16
+ * listens to these. A style that only `:hover` applies stays off, since no
17
+ * real pointer is there.
18
+ */
19
+ export declare function hover(element: Element): string;
20
+ /** The keys `page_press` takes: the ones a page handles itself, never a browser shortcut. */
21
+ export declare const PAGE_KEYS: readonly ["Enter", "Escape", "Tab", "Space", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight", "Home", "End", "PageDown", "PageUp", "Backspace", "Delete"];
22
+ /**
23
+ * `keydown` then `keyup` on `element`. True when the page handled the key
24
+ * (it prevented the default): a key pressed by script has no default action,
25
+ * so the caller does the one that matters when the page did not.
26
+ */
27
+ export declare function press(element: Element, key: string): boolean;
28
+ /**
29
+ * The form Enter in `element` submits, as the browser decides it: a field
30
+ * that takes a line of text, in a form whose first submit button is enabled,
31
+ * or with that field alone and no button.
32
+ */
33
+ export declare function formSubmittedByEnter(element: Element): HTMLFormElement | null;
34
+ /**
35
+ * Enter's submission, as the browser does it: a click on the default button,
36
+ * so the form is sent with it and its own handlers run, or the form alone
37
+ * when it has no button.
38
+ */
39
+ export declare function submitByEnter(form: HTMLFormElement): void;
40
+ /**
41
+ * What Escape does in a dialog when the page leaves it to the browser: the
42
+ * dialog's `cancel`, which the site may refuse, then its closing.
43
+ */
44
+ export declare function cancelDialogOf(element: Element): boolean;
14
45
  export declare function bringIntoView(element: Element): void;
15
46
  /** The form a click on `element` would submit, if any. */
16
47
  export declare function formSubmittedBy(element: Element): HTMLFormElement | null;
48
+ /** True for a link to another site: the user leaves the one they had open. */
49
+ export declare function leavesSite(element: Element): boolean;
17
50
  /**
18
51
  * True when a click on `element` would load another document: a link to
19
52
  * another path in the same tab. A link within the page (`#...`) or one a
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The page change an action of the agent may start (a link, a submit), seen
3
+ * from the page it starts on (spec `page-tools.md`). The answer that clicked
4
+ * goes on while this page is still on screen, and its next call, a
5
+ * `page_snapshot` most of the time, would read the page that is leaving: the
6
+ * model takes the click for one that did nothing, and clicks again. The page
7
+ * tools wait here first. On a page that unloads they never answer, and the
8
+ * new page runs the call (`resumeAfterPageNavigation` in the chat store); on
9
+ * a page that stays (a client-side route, a link within the page) they run
10
+ * once it has settled.
11
+ */
12
+ /** Resolves once the page has gone `QUIET_MS` without a change, or after `QUIET_MAX_MS`. */
13
+ export declare function pageQuiet(): Promise<void>;
14
+ /** Called right before the action that may load another document. */
15
+ export declare function startPageChange(): void;
16
+ /**
17
+ * Opens `url`, an address of this site, the way the site's own links do in a
18
+ * single-page app: a history entry and a `popstate`, which Vue Router, React
19
+ * Router and most routers follow without loading the page again. Loaded
20
+ * again, the page would drop the call the answer makes next. When within a
21
+ * moment neither a view changes (`ROUTE_MIN_ELEMENTS`) nor the title, no
22
+ * router took the address: it then loads as typed in the address bar. The
23
+ * page tools wait meanwhile, as after a click that may load another page.
24
+ */
25
+ export declare function openAddress(url: string): void;
26
+ /** What every page tool awaits before it reads or acts. */
27
+ export declare function pageChangeSettled(): Promise<void>;
@@ -1,3 +1,6 @@
1
+ /** The widget and its page control bar are not part of the page the agent works on. */
2
+ /** The widget, and the stop it puts inside a modal dialog of the page (`usePageModalStop`). */
3
+ export declare const STOP_IN_MODAL_TAG = "agent-studio-stop";
1
4
  /** Stable ids for elements across snapshots, without holding removed elements in memory. */
2
5
  export declare class PageRefs {
3
6
  private next;
@@ -24,6 +27,18 @@ export declare function filteredText(root: Element, rules: PageRules, max: numbe
24
27
  export declare function roleOf(element: Element): string | undefined;
25
28
  /** The accessible name, in the order the accessibility tree computes it, never from an excluded element. */
26
29
  export declare function nameOf(element: Element, rules: PageRules): string;
30
+ /**
31
+ * The question of the site's own confirmation dialog when `element` answers
32
+ * it: one of its buttons, or with `anyElement` any element in it (a key goes
33
+ * to the dialog's own handler as well). An `alertdialog`, or a modal dialog
34
+ * that only asks ("Delete the agent? This cannot be undone."). The site asks
35
+ * it of the user, so the user answers it, with the question in view, whatever
36
+ * the confirmation settings. Its text without the buttons, never from an
37
+ * excluded element.
38
+ */
39
+ export declare function confirmationQuestion(element: Element, rules: PageRules, { anyElement }?: {
40
+ anyElement?: boolean;
41
+ }): string | undefined;
27
42
  /** The options of a select the agent may see and pick: not the excluded ones. */
28
43
  export declare const allowedOptions: (select: HTMLSelectElement, rules: PageRules) => HTMLOptionElement[];
29
44
  /** One line for an element with a role: `[12] button "Invia" disabled`. */
@@ -35,8 +50,9 @@ export type SnapshotResult = {
35
50
  /**
36
51
  * Walks `root` in reading order, through open shadow roots and slots. An
37
52
  * element with a role becomes one line and is not descended (its text is its
38
- * name); any other element contributes its own text nodes. Stops at
39
- * `maxChars`, or past the node and time budget.
53
+ * name), but for a container, whose content follows its line, and a role of
54
+ * structure, read as text; any other element contributes its own text nodes.
55
+ * Stops at `maxChars`, or past the node and time budget.
40
56
  */
41
57
  export declare function snapshot(root: Element, refs: PageRefs, rules: PageRules, { maxChars, withRefs }: {
42
58
  maxChars: number;
@@ -23,3 +23,11 @@ export declare function useWidgetEvents(): {
23
23
  * signal, or a page waiting for `working-ended` would wait for ever.
24
24
  */
25
25
  export declare function useWorkingSignal(isWorking: () => boolean): void;
26
+ /**
27
+ * Mirrors the agent acting on the page (spec `page-tools.md`) the same way:
28
+ * the `controlling` attribute while the control bar and its stop show, and
29
+ * `page-control-started` and `page-control-ended`. It is what lights an
30
+ * effect around the page, where `working` also covers an answer that only
31
+ * thinks and writes.
32
+ */
33
+ export declare function usePageControlSignal(isControlling: () => boolean): void;
@@ -1,9 +1,9 @@
1
- import { AgentCopilotFrame, AgentWidgetLayout } from '../../../../packages/models/src';
1
+ import { AgentWidgetAppearance, AgentWidgetLayout } from '../../../../packages/models/src';
2
2
  /**
3
3
  * The layout the floating element shows (spec `widget-copilot.md`, D1): its
4
4
  * `layout` attribute wins over the agent's setting, and an attribute that
5
5
  * names no layout counts as absent.
6
6
  */
7
7
  export declare function resolveWidgetLayout(attribute: string | undefined, setting: AgentWidgetLayout | undefined): AgentWidgetLayout;
8
- /** How the site makes room for the copilot panel (D3), with the same rule as the layout. */
9
- export declare function resolveCopilotFrame(attribute: string | undefined, setting: AgentCopilotFrame | undefined): AgentCopilotFrame;
8
+ /** How the floating card looks over the site, with the same rule as the layout. */
9
+ export declare function resolveWidgetAppearance(attribute: string | undefined, setting: AgentWidgetAppearance | undefined): AgentWidgetAppearance;