@8wave/ai-elements 0.118.0 → 0.119.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{PkStreamingMarkdown--CcBvs19.js → PkStreamingMarkdown-kpEBZA4d.js} +789 -780
- package/dist/_chunks/PkStreamingMarkdown-kpEBZA4d.js.map +1 -0
- package/dist/_chunks/{PkToolShowArtifact-BVGN7hV2.js → PkToolShowArtifact-B8TOTS6A.js} +2 -2
- package/dist/_chunks/{PkToolShowArtifact-BVGN7hV2.js.map → PkToolShowArtifact-B8TOTS6A.js.map} +1 -1
- package/dist/_chunks/{PkToolShowContactForm-Blrwqpl0.js → PkToolShowContactForm-B89p05XM.js} +2 -2
- package/dist/_chunks/{PkToolShowContactForm-Blrwqpl0.js.map → PkToolShowContactForm-B89p05XM.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-BpGHaN6x.js → PkToolShowForm-DTKQtFij.js} +4 -4
- package/dist/_chunks/{PkToolShowForm-BpGHaN6x.js.map → PkToolShowForm-DTKQtFij.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-8c9RvGV1.js → PkToolShowSources-CbwixpOb.js} +2 -2
- package/dist/_chunks/{PkToolShowSources-8c9RvGV1.js.map → PkToolShowSources-CbwixpOb.js.map} +1 -1
- package/dist/ai-elements.es.js +1888 -1863
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotEmptyState.js +1 -1
- package/dist-vue/PkChatbotInput.js +1 -1
- package/dist-vue/PkChatbotMessages.js +1 -1
- package/dist-vue/PkChatbotStepPayload.js +1 -1
- package/dist-vue/PkChatbotStepToolDetail.js +1 -1
- package/dist-vue/PkChatbotSteps.js +1 -1
- package/dist-vue/PkChatbotViewChat.js +1 -1
- package/dist-vue/PkChatbotViewProfile.js +1 -1
- package/dist-vue/_chunks/PkAvatar-BTqu8tn9.js +44 -0
- package/dist-vue/_chunks/PkAvatar-BTqu8tn9.js.map +1 -0
- package/dist-vue/_chunks/PkChatbot-C_OzxC0s.js +276 -0
- package/dist-vue/_chunks/PkChatbot-C_OzxC0s.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotEmptyState-D2dhInfG.js → PkChatbotEmptyState-BEQCnqui.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotEmptyState-D2dhInfG.js.map → PkChatbotEmptyState-BEQCnqui.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotInput-CQdxFbBR.js → PkChatbotInput-KJxWrDIT.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotInput-CQdxFbBR.js.map → PkChatbotInput-KJxWrDIT.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotMessages-coscJcpy.js → PkChatbotMessages-Zhuxom46.js} +283 -283
- package/dist-vue/_chunks/{PkChatbotMessages-coscJcpy.js.map → PkChatbotMessages-Zhuxom46.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepPayload-DnqFluQZ.js → PkChatbotStepPayload-Da4N5CKa.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotStepPayload-DnqFluQZ.js.map → PkChatbotStepPayload-Da4N5CKa.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-BMslY_BG.js → PkChatbotStepToolDetail-rrtImvq5.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-BMslY_BG.js.map → PkChatbotStepToolDetail-rrtImvq5.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotSteps-7FT6Ju6_.js → PkChatbotSteps-LEfOolAc.js} +38 -38
- package/dist-vue/_chunks/{PkChatbotSteps-7FT6Ju6_.js.map → PkChatbotSteps-LEfOolAc.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-Cko-Cw6c.js → PkChatbotViewChat-BJ0YHCvA.js} +7 -7
- package/dist-vue/_chunks/PkChatbotViewChat-BJ0YHCvA.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotViewProfile-B57VRVaO.js → PkChatbotViewProfile-CyzRxE3D.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewProfile-B57VRVaO.js.map → PkChatbotViewProfile-CyzRxE3D.js.map} +1 -1
- package/dist-vue/_chunks/{PkStreamingMarkdown-BtyWXY2k.js → PkStreamingMarkdown-BWEvuFZm.js} +2 -2
- package/dist-vue/_chunks/{PkStreamingMarkdown-BtyWXY2k.js.map → PkStreamingMarkdown-BWEvuFZm.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowArtifact-Ritx54_X.js → PkToolShowArtifact-tNEG6-r_.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowArtifact-Ritx54_X.js.map → PkToolShowArtifact-tNEG6-r_.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowContactForm-D30IsZGy.js → PkToolShowContactForm-DBC6f9gR.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowContactForm-D30IsZGy.js.map → PkToolShowContactForm-DBC6f9gR.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-PEozSAqU.js → PkToolShowDiagram-Bbq0ETt1.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-PEozSAqU.js.map → PkToolShowDiagram-Bbq0ETt1.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-ZmdM9J9x.js → PkToolShowForm-BG-8aTHy.js} +5 -5
- package/dist-vue/_chunks/{PkToolShowForm-ZmdM9J9x.js.map → PkToolShowForm-BG-8aTHy.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowImageGallery-Dkjf7Tw_.js → PkToolShowImageGallery-DXn-bxHv.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowImageGallery-Dkjf7Tw_.js.map → PkToolShowImageGallery-DXn-bxHv.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowProductList-CsHYM8vl.js → PkToolShowProductList-BZ_fDRCq.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowProductList-CsHYM8vl.js.map → PkToolShowProductList-BZ_fDRCq.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-CKZkcPLA.js → PkToolShowSources-CUURb0PG.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSources-CKZkcPLA.js.map → PkToolShowSources-CUURb0PG.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowVideo-CKm1fVQs.js → PkToolShowVideo-FNlPjswi.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowVideo-CKm1fVQs.js.map → PkToolShowVideo-FNlPjswi.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowWebPages-DLEC9cuh.js → PkToolShowWebPages-CWV79tsb.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowWebPages-DLEC9cuh.js.map → PkToolShowWebPages-CWV79tsb.js.map} +1 -1
- package/dist-vue/_chunks/{utils-fxHiCnzf.js → utils-Dk2jFXR_.js} +40 -31
- package/dist-vue/_chunks/utils-Dk2jFXR_.js.map +1 -0
- package/dist-vue/apps/web-component/src/composables/useChatbotAgent.d.ts +1 -4
- package/dist-vue/composables.js +132 -113
- package/dist-vue/composables.js.map +1 -1
- package/dist-vue/index.js +23 -23
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/packages/components/src/chat/PkAvatar.d.ts +7 -0
- package/dist-vue/packages/components/src/chat/utils.d.ts +10 -0
- package/dist-vue/style.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/PkStreamingMarkdown--CcBvs19.js.map +0 -1
- package/dist-vue/_chunks/PkAvatar-ZgCsoO-p.js +0 -42
- package/dist-vue/_chunks/PkAvatar-ZgCsoO-p.js.map +0 -1
- package/dist-vue/_chunks/PkChatbot-Cm45hwYw.js +0 -275
- package/dist-vue/_chunks/PkChatbot-Cm45hwYw.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotViewChat-Cko-Cw6c.js.map +0 -1
- package/dist-vue/_chunks/utils-fxHiCnzf.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-Dk2jFXR_.js","names":["isPresentationTool","isTextPart","getToolPartName","isToolPart","isReasoningPart","mergeConsecutiveTextParts","merged","part","parts","prev","isWidgetPart","dropCorrectedWidgetErrors","lastDrawn","index","isStreamingPart","FILE_OUTPUT_PARTS","moveFileOutputsLast","files","feedPartKey","toolCallId","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","RICH_DETAIL_TOOL_TYPES","hasRichToolDetail","asRecord","pickString","keys","key","record","getToolPartSummary","queries","valid","query","sheet","range","getPartIcon","getToolPartLabel","$t"],"sources":["../../../../packages/components/src/chat/utils.ts"],"sourcesContent":["import type { UIMessage } from 'ai'\nimport { isPresentationTool } from 'models'\nimport {\n isTextPart,\n isFilePart,\n isToolPart,\n isReasoningPart,\n hasPartText,\n hasTextPart,\n getTextPart,\n getMessageText,\n getToolPartName,\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\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 * 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// Provider-native web search tool part types\nexport const WEB_SEARCH_TOOL_TYPES = [\n 'tool-perplexity_search',\n 'tool-parallel_search',\n 'tool-web_search',\n 'tool-google_search',\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 (part.type === 'tool-readDocumentFile') {\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 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-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 (\n part.type === 'tool-perplexity_search' ||\n part.type === 'tool-parallel_search' ||\n part.type === 'tool-web_search' ||\n part.type === 'tool-google_search'\n ) {\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// Get part label\nexport function getToolPartLabel(\n $t: (key: string) => string,\n part?: UIMessage['parts'][number] | null,\n): string | undefined {\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-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 (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":";;;;AA8BA,SAAgBK,EACZ,GACkB;CAClB,IAAMC,IAA6B,CAAC;CACpC,KAAK,IAAMC,KAAQC,GAAO;EACtB,IAAI,CAACP,EAAWM,CAAI,GAAG;GACnB,EAAO,KAAKA,CAAI;GAChB;EACJ;EACA,IA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F,EAAG,8BAA8B,IAExCzF,EAAK,SAAS,mBACPyF,EAAG,uBAAuB,IAEjCzF,EAAK,SAAS,4BACPyF,EAAG,gCAAgC,IAE1CzF,EAAK,SAAS,4BACPyF,EAAG,gCAAgC,IAE1CzF,EAAK,SAAS,mCACPyF,EAAG,uCAAuC,IAEjDhB,EAAsB,SAASzE,EAAK,IAAI,IACjCyF,EAAG,uBAAuB,IAE9BA,EAAG,kBAAkB,IAE5B5F,EAAgBG,CAAI,IACbyF,EAAG,uBAAuB,IAE9BA,EAAG,uBAAuB;AACrC"}
|
|
@@ -288,8 +288,5 @@ export declare function useChatbotAgent(options: {
|
|
|
288
288
|
contrastColor: globalThis.ComputedRef<"white" | "black">;
|
|
289
289
|
mainColor: globalThis.ComputedRef<string | undefined>;
|
|
290
290
|
themeClass: globalThis.ComputedRef<string[]>;
|
|
291
|
-
themeStyle: globalThis.ComputedRef<
|
|
292
|
-
'--chatbot-main-color': string | undefined;
|
|
293
|
-
'--chatbot-contrast-color': "white" | "black";
|
|
294
|
-
} | undefined>;
|
|
291
|
+
themeStyle: globalThis.ComputedRef<Record<string, string> | undefined>;
|
|
295
292
|
};
|
package/dist-vue/composables.js
CHANGED
|
@@ -2,21 +2,21 @@ import { t as e } from "./_chunks/createChatbotApiClient-DSLxswr4.js";
|
|
|
2
2
|
import { n as t } from "./_chunks/useChatbotStore-rtl-oKqU.js";
|
|
3
3
|
import { t as n } from "./_chunks/src-DCfvejyT.js";
|
|
4
4
|
import { t as r } from "./_chunks/useLocalizedString-PfaKjIQY.js";
|
|
5
|
-
import {
|
|
6
|
-
import { computed as
|
|
7
|
-
import { createI18n as
|
|
8
|
-
import { createAuthClient as
|
|
9
|
-
import { anonymousClient as
|
|
5
|
+
import { T as i, i as a } from "./_chunks/utils-Dk2jFXR_.js";
|
|
6
|
+
import { computed as o, getCurrentInstance as s, onBeforeUnmount as c, onMounted as l, ref as u, toValue as d, watch as f } from "vue";
|
|
7
|
+
import { createI18n as p } from "vue-i18n";
|
|
8
|
+
import { createAuthClient as m } from "better-auth/vue";
|
|
9
|
+
import { anonymousClient as h, inferAdditionalFields as g } from "better-auth/client/plugins";
|
|
10
10
|
//#region src/utils/cookie.ts
|
|
11
|
-
var
|
|
12
|
-
function
|
|
11
|
+
var _ = "eight-wave-ai", v = "-uid", y = 31536e3;
|
|
12
|
+
function b(e, t, r) {
|
|
13
13
|
try {
|
|
14
14
|
document.cookie = `${e}=${t}; path=/; max-age=${r}${r > 0 ? "" : "; expires=Thu, 01 Jan 1970 00:00:00 GMT"}; SameSite=Lax; Secure`;
|
|
15
15
|
} catch (e) {
|
|
16
16
|
n.warn("[cookie] setCookie blocked (cross-origin/tracking protection)", e);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function x(e) {
|
|
20
20
|
try {
|
|
21
21
|
let t = `${e}=`, n = document.cookie.split("; ").find((e) => e.startsWith(t));
|
|
22
22
|
return n ? n.slice(t.length) : "";
|
|
@@ -24,76 +24,73 @@ function b(e) {
|
|
|
24
24
|
return n.warn("[cookie] getCookie blocked (cross-origin/tracking protection)", e), "";
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
27
|
+
function S(e, t = _) {
|
|
28
|
+
b(t, e, e ? y : 0);
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
return
|
|
30
|
+
function C(e = _) {
|
|
31
|
+
return x(e);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
33
|
+
function w(e, t = _) {
|
|
34
|
+
b(`${t}${v}`, e, y);
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
36
|
+
function T(e = _) {
|
|
37
|
+
return x(`${e}${v}`);
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
39
|
+
function E(e = _) {
|
|
40
|
+
b(`${e}${v}`, "", 0);
|
|
41
41
|
}
|
|
42
42
|
//#endregion
|
|
43
43
|
//#region src/utils/index.ts
|
|
44
|
-
var
|
|
44
|
+
var D = void 0, O = void 0, k = "auth";
|
|
45
45
|
//#endregion
|
|
46
46
|
//#region src/composables/useChatbotAgent.ts
|
|
47
|
-
function
|
|
48
|
-
let n =
|
|
49
|
-
async function
|
|
50
|
-
let i =
|
|
47
|
+
function A(t) {
|
|
48
|
+
let n = u(), r = u(), s = u(), c = u(), l = u(!1), p = u(!1), m = u(!1);
|
|
49
|
+
async function h() {
|
|
50
|
+
let i = d(t.organizationSlug), a = d(t.agentId);
|
|
51
51
|
if (!i || !a) return;
|
|
52
|
-
let
|
|
52
|
+
let o = e({
|
|
53
53
|
baseUrl: t.baseUrl ?? void 0,
|
|
54
54
|
basePath: t.basePath,
|
|
55
|
-
headers: () =>
|
|
55
|
+
headers: () => d(t.headers)
|
|
56
56
|
});
|
|
57
|
-
|
|
57
|
+
m.value = !0;
|
|
58
58
|
try {
|
|
59
|
-
let e = await
|
|
60
|
-
|
|
59
|
+
let e = await o.getAgentAccess(i, a);
|
|
60
|
+
s.value = e.authMethods, c.value = e.deploymentBranding?.css, e.requiresAuth ? (l.value = !0, r.value = e.branding ?? void 0, n.value = void 0) : (l.value = !1, r.value = void 0, n.value = e.agent ?? void 0), p.value = !1;
|
|
61
61
|
} catch {
|
|
62
|
-
|
|
62
|
+
p.value = !0, c.value = void 0, n.value = void 0, r.value = void 0, l.value = !1;
|
|
63
63
|
} finally {
|
|
64
|
-
|
|
64
|
+
m.value = !1;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}, { immediate: !0 }),
|
|
70
|
-
|
|
67
|
+
f([() => d(t.organizationSlug), () => d(t.agentId)], () => {
|
|
68
|
+
h();
|
|
69
|
+
}, { immediate: !0 }), f(() => d(t.headers), () => {
|
|
70
|
+
l.value && h();
|
|
71
71
|
});
|
|
72
|
-
let
|
|
72
|
+
let g = o(() => n.value?.interface ?? r.value?.interface), _ = o(() => i(g.value?.textColor, g.value?.mainColor)), v = o(() => g.value?.mainColor);
|
|
73
73
|
return {
|
|
74
74
|
agent: n,
|
|
75
75
|
branding: r,
|
|
76
|
-
authMethods:
|
|
77
|
-
deploymentCss:
|
|
78
|
-
requiresAuth:
|
|
79
|
-
notFound:
|
|
80
|
-
isLoading:
|
|
81
|
-
reload:
|
|
82
|
-
contrastColor:
|
|
83
|
-
mainColor:
|
|
84
|
-
themeClass:
|
|
85
|
-
let e =
|
|
76
|
+
authMethods: s,
|
|
77
|
+
deploymentCss: c,
|
|
78
|
+
requiresAuth: l,
|
|
79
|
+
notFound: p,
|
|
80
|
+
isLoading: m,
|
|
81
|
+
reload: h,
|
|
82
|
+
contrastColor: _,
|
|
83
|
+
mainColor: v,
|
|
84
|
+
themeClass: o(() => {
|
|
85
|
+
let e = g.value?.theme;
|
|
86
86
|
if (e && e !== "auto") return ["theme", `theme--${e}`];
|
|
87
|
-
let n =
|
|
87
|
+
let n = d(t.systemTheme);
|
|
88
88
|
return n ? ["theme", `theme--${n}`] : ["theme"];
|
|
89
89
|
}),
|
|
90
|
-
themeStyle:
|
|
91
|
-
"--chatbot-main-color": _.value,
|
|
92
|
-
"--chatbot-contrast-color": g.value
|
|
93
|
-
} : void 0)
|
|
90
|
+
themeStyle: o(() => a(v.value, _.value))
|
|
94
91
|
};
|
|
95
92
|
}
|
|
96
|
-
var
|
|
93
|
+
var j = {
|
|
97
94
|
action: {
|
|
98
95
|
accept: "Accetto",
|
|
99
96
|
acceptRedundancy: "Conferma ridondante",
|
|
@@ -1364,6 +1361,17 @@ var A = {
|
|
|
1364
1361
|
owner: "Proprietario",
|
|
1365
1362
|
user: "Utente"
|
|
1366
1363
|
},
|
|
1364
|
+
nav: {
|
|
1365
|
+
organization: "Organizzazione",
|
|
1366
|
+
configure: "Configura",
|
|
1367
|
+
monitor: "Monitora",
|
|
1368
|
+
allAgents: "Tutti gli agenti",
|
|
1369
|
+
agentSettings: "Impostazioni",
|
|
1370
|
+
agentTry: "Prova",
|
|
1371
|
+
searchAgent: "Cerca un agente",
|
|
1372
|
+
searchOrganization: "Cerca un'organizzazione",
|
|
1373
|
+
allOrganizations: "Tutte le organizzazioni"
|
|
1374
|
+
},
|
|
1367
1375
|
route: {
|
|
1368
1376
|
agentEndpoints: "API endpoints",
|
|
1369
1377
|
agents: "Agenti",
|
|
@@ -1696,7 +1704,7 @@ var A = {
|
|
|
1696
1704
|
invalidMessage: "Questo link non vale più. Puoi spegnere le mail dal tuo profilo, nella sezione Notifiche.",
|
|
1697
1705
|
openSettings: "Apri le preferenze di notifica"
|
|
1698
1706
|
}
|
|
1699
|
-
},
|
|
1707
|
+
}, M = {
|
|
1700
1708
|
action: {
|
|
1701
1709
|
accept: "Accept",
|
|
1702
1710
|
acceptRedundancy: "Confirm redundant",
|
|
@@ -2967,6 +2975,17 @@ var A = {
|
|
|
2967
2975
|
owner: "Owner",
|
|
2968
2976
|
user: "User"
|
|
2969
2977
|
},
|
|
2978
|
+
nav: {
|
|
2979
|
+
organization: "Organization",
|
|
2980
|
+
configure: "Configure",
|
|
2981
|
+
monitor: "Monitor",
|
|
2982
|
+
allAgents: "All agents",
|
|
2983
|
+
agentSettings: "Settings",
|
|
2984
|
+
agentTry: "Try",
|
|
2985
|
+
searchAgent: "Search an agent",
|
|
2986
|
+
searchOrganization: "Search an organization",
|
|
2987
|
+
allOrganizations: "All organizations"
|
|
2988
|
+
},
|
|
2970
2989
|
route: {
|
|
2971
2990
|
agentEndpoints: "API endpoints",
|
|
2972
2991
|
agents: "Agents",
|
|
@@ -3299,7 +3318,7 @@ var A = {
|
|
|
3299
3318
|
invalidMessage: "This link no longer works. You can turn the emails off from your profile, in the Notifications section.",
|
|
3300
3319
|
openSettings: "Open notification settings"
|
|
3301
3320
|
}
|
|
3302
|
-
},
|
|
3321
|
+
}, N = {
|
|
3303
3322
|
invalidType: "Expected {expected}, received {received}",
|
|
3304
3323
|
invalidTypeReceivedUndefined: "Required",
|
|
3305
3324
|
invalidTypeReceivedNull: "Required",
|
|
@@ -3431,7 +3450,7 @@ var A = {
|
|
|
3431
3450
|
jwt: "JWT",
|
|
3432
3451
|
template_literal: "input"
|
|
3433
3452
|
}
|
|
3434
|
-
},
|
|
3453
|
+
}, P = {
|
|
3435
3454
|
invalidType: "Previsto {expected}, ricevuto {received}",
|
|
3436
3455
|
invalidTypeReceivedUndefined: "Obbligatorio",
|
|
3437
3456
|
invalidTypeReceivedNull: "Obbligatorio",
|
|
@@ -3563,29 +3582,29 @@ var A = {
|
|
|
3563
3582
|
jwt: "JWT",
|
|
3564
3583
|
template_literal: "input"
|
|
3565
3584
|
}
|
|
3566
|
-
},
|
|
3567
|
-
function
|
|
3585
|
+
}, F = ["it", "en"];
|
|
3586
|
+
function I() {
|
|
3568
3587
|
let e = navigator.language.split("-")[0];
|
|
3569
|
-
return
|
|
3588
|
+
return F.includes(e) ? e : "en";
|
|
3570
3589
|
}
|
|
3571
|
-
var
|
|
3572
|
-
locale:
|
|
3590
|
+
var L = p({
|
|
3591
|
+
locale: I(),
|
|
3573
3592
|
legacy: !1,
|
|
3574
3593
|
globalInjection: !0,
|
|
3575
3594
|
fallbackWarn: !1,
|
|
3576
3595
|
messages: {
|
|
3577
3596
|
it: {
|
|
3578
|
-
...
|
|
3597
|
+
...j,
|
|
3579
3598
|
errors: {
|
|
3580
|
-
...
|
|
3581
|
-
...
|
|
3599
|
+
...P,
|
|
3600
|
+
...j.errors
|
|
3582
3601
|
}
|
|
3583
3602
|
},
|
|
3584
3603
|
en: {
|
|
3585
|
-
...
|
|
3604
|
+
...M,
|
|
3586
3605
|
errors: {
|
|
3587
|
-
...
|
|
3588
|
-
...
|
|
3606
|
+
...N,
|
|
3607
|
+
...M.errors
|
|
3589
3608
|
}
|
|
3590
3609
|
}
|
|
3591
3610
|
},
|
|
@@ -3750,7 +3769,7 @@ var I = f({
|
|
|
3750
3769
|
}
|
|
3751
3770
|
}
|
|
3752
3771
|
});
|
|
3753
|
-
async function
|
|
3772
|
+
async function R({ response: e }) {
|
|
3754
3773
|
if (!e.ok) try {
|
|
3755
3774
|
let t;
|
|
3756
3775
|
try {
|
|
@@ -3760,9 +3779,9 @@ async function L({ response: e }) {
|
|
|
3760
3779
|
t = void 0;
|
|
3761
3780
|
}
|
|
3762
3781
|
let n = typeof t?.code == "string" ? t.code : void 0, r = `errors.${n}`;
|
|
3763
|
-
return e.status === 429 ? r = "errors.TOO_MANY_REQUESTS" : n?.startsWith("YOU_ARE_NOT_ALLOWED_TO_") ? r = "errors.NOT_ALLOWED" : t || (r = "auth.genericError"),
|
|
3782
|
+
return e.status === 429 ? r = "errors.TOO_MANY_REQUESTS" : n?.startsWith("YOU_ARE_NOT_ALLOWED_TO_") ? r = "errors.NOT_ALLOWED" : t || (r = "auth.genericError"), L.global.te(r) ? new Response(JSON.stringify({
|
|
3764
3783
|
...t,
|
|
3765
|
-
message:
|
|
3784
|
+
message: L.global.t(r)
|
|
3766
3785
|
}), {
|
|
3767
3786
|
status: e.status,
|
|
3768
3787
|
statusText: e.statusText,
|
|
@@ -3774,7 +3793,7 @@ async function L({ response: e }) {
|
|
|
3774
3793
|
}
|
|
3775
3794
|
//#endregion
|
|
3776
3795
|
//#region src/composables/useChatbotAuth.ts
|
|
3777
|
-
function
|
|
3796
|
+
function z() {
|
|
3778
3797
|
return {
|
|
3779
3798
|
id: "anonymous-reauth",
|
|
3780
3799
|
getActions: (e) => ({ signIn: { anonymousReauth: async (t) => e("/sign-in/anonymous-reauth", {
|
|
@@ -3784,7 +3803,7 @@ function R() {
|
|
|
3784
3803
|
pathMethods: { "/sign-in/anonymous-reauth": "POST" }
|
|
3785
3804
|
};
|
|
3786
3805
|
}
|
|
3787
|
-
function
|
|
3806
|
+
function B() {
|
|
3788
3807
|
return {
|
|
3789
3808
|
id: "external-auth",
|
|
3790
3809
|
getActions: (e) => ({ signIn: { externalToken: async (t) => e("/sign-in/external-token", {
|
|
@@ -3798,25 +3817,25 @@ function z() {
|
|
|
3798
3817
|
}]
|
|
3799
3818
|
};
|
|
3800
3819
|
}
|
|
3801
|
-
var
|
|
3802
|
-
function
|
|
3820
|
+
var V = "better-auth:oauth-popup";
|
|
3821
|
+
function H() {
|
|
3803
3822
|
let e = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));
|
|
3804
3823
|
return Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
3805
3824
|
}
|
|
3806
|
-
function
|
|
3807
|
-
let t =
|
|
3825
|
+
function U(e = {}) {
|
|
3826
|
+
let t = u(C(e.cookieName)), n = o(() => d(e.useHostSession) ?? !1), r = o({
|
|
3808
3827
|
get: () => t.value,
|
|
3809
3828
|
set: (n) => {
|
|
3810
|
-
|
|
3829
|
+
S(n, e.cookieName), t.value = n;
|
|
3811
3830
|
}
|
|
3812
|
-
}), i =
|
|
3831
|
+
}), i = o(() => !n.value && r.value ? { Authorization: `Bearer ${r.value}` } : void 0), a = m({
|
|
3813
3832
|
baseURL: e.baseUrl ?? void 0,
|
|
3814
3833
|
basePath: e.basePath ?? "auth",
|
|
3815
3834
|
plugins: [
|
|
3835
|
+
g(),
|
|
3816
3836
|
h(),
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
z()
|
|
3837
|
+
z(),
|
|
3838
|
+
B()
|
|
3820
3839
|
],
|
|
3821
3840
|
fetchOptions: {
|
|
3822
3841
|
onSuccess: (e) => {
|
|
@@ -3824,7 +3843,7 @@ function H(e = {}) {
|
|
|
3824
3843
|
let t = e.response.headers.get("set-auth-token");
|
|
3825
3844
|
t && (r.value = t);
|
|
3826
3845
|
},
|
|
3827
|
-
onResponse:
|
|
3846
|
+
onResponse: R,
|
|
3828
3847
|
auth: {
|
|
3829
3848
|
type: "Bearer",
|
|
3830
3849
|
token: () => n.value ? "" : r.value
|
|
@@ -3834,32 +3853,32 @@ function H(e = {}) {
|
|
|
3834
3853
|
credentials: n.value ? "include" : t?.credentials
|
|
3835
3854
|
})
|
|
3836
3855
|
}
|
|
3837
|
-
}), s =
|
|
3856
|
+
}), s = a.useSession(), c = u(!1), l = o(() => d(e.externalToken)), p = o(() => d(e.isActive) ?? !0), _ = u(l.value), v = o(() => !!l.value || !!e.awaitExternalToken || !!_.value || n.value), y = Promise.resolve();
|
|
3838
3857
|
function b(e) {
|
|
3839
3858
|
let t = y.then(e, e);
|
|
3840
3859
|
return y = t, t;
|
|
3841
3860
|
}
|
|
3842
|
-
|
|
3861
|
+
f(() => s.value.data?.user, (t, n) => {
|
|
3843
3862
|
t && t.id !== n?.id && e.onSignedIn?.({
|
|
3844
3863
|
userId: t.id,
|
|
3845
3864
|
isAnonymous: !!t.isAnonymous
|
|
3846
3865
|
}), !t && n && e.onSignedOut?.();
|
|
3847
3866
|
});
|
|
3848
|
-
async function
|
|
3849
|
-
let { data: t } = await
|
|
3850
|
-
t?.token && (r.value = t.token, t.user?.id &&
|
|
3867
|
+
async function x() {
|
|
3868
|
+
let { data: t } = await a.signIn.anonymous();
|
|
3869
|
+
t?.token && (r.value = t.token, t.user?.id && w(t.user.id, e.cookieName));
|
|
3851
3870
|
}
|
|
3852
3871
|
async function D() {
|
|
3853
|
-
let t =
|
|
3872
|
+
let t = T(e.cookieName);
|
|
3854
3873
|
if (!t) return !1;
|
|
3855
3874
|
try {
|
|
3856
|
-
let { data: e } = await
|
|
3875
|
+
let { data: e } = await a.signIn.anonymousReauth({ userId: t });
|
|
3857
3876
|
if (e?.token) return r.value = e.token, await s.value.refetch(), !0;
|
|
3858
3877
|
} catch {}
|
|
3859
3878
|
return !1;
|
|
3860
3879
|
}
|
|
3861
3880
|
async function O() {
|
|
3862
|
-
await D() || await
|
|
3881
|
+
await D() || await x();
|
|
3863
3882
|
}
|
|
3864
3883
|
async function k(t) {
|
|
3865
3884
|
_.value === t && (e.onExternalAuthExpired?.(), !e.awaitExternalToken && await O());
|
|
@@ -3867,7 +3886,7 @@ function H(e = {}) {
|
|
|
3867
3886
|
async function A(e) {
|
|
3868
3887
|
c.value = !0;
|
|
3869
3888
|
try {
|
|
3870
|
-
let { data: t } = await
|
|
3889
|
+
let { data: t } = await a.signIn.externalToken({ token: e });
|
|
3871
3890
|
if (_.value !== e) return;
|
|
3872
3891
|
if (t?.token) {
|
|
3873
3892
|
r.value = t.token, await s.value.refetch();
|
|
@@ -3905,7 +3924,7 @@ function H(e = {}) {
|
|
|
3905
3924
|
}
|
|
3906
3925
|
});
|
|
3907
3926
|
}
|
|
3908
|
-
|
|
3927
|
+
f([p, s], ([t, r]) => {
|
|
3909
3928
|
if (!t) return;
|
|
3910
3929
|
if (!r.isPending && !r.isRefetching && !c.value && !r.data) {
|
|
3911
3930
|
if (n.value) return;
|
|
@@ -3929,27 +3948,27 @@ function H(e = {}) {
|
|
|
3929
3948
|
return;
|
|
3930
3949
|
}
|
|
3931
3950
|
}
|
|
3932
|
-
i?.isAnonymous && _.value && M !== _.value ? P(_.value) : i?.isAnonymous && i.id && !
|
|
3951
|
+
i?.isAnonymous && _.value && M !== _.value ? P(_.value) : i?.isAnonymous && i.id && !T(e.cookieName) && w(i.id, e.cookieName);
|
|
3933
3952
|
}
|
|
3934
|
-
}, { immediate: !0 }),
|
|
3953
|
+
}, { immediate: !0 }), f(n, () => {
|
|
3935
3954
|
s.value.refetch();
|
|
3936
|
-
}),
|
|
3937
|
-
e ? (_.value = e,
|
|
3955
|
+
}), f(l, (e, t) => {
|
|
3956
|
+
e ? (_.value = e, p.value && P(e)) : t && _.value === t && $();
|
|
3938
3957
|
});
|
|
3939
3958
|
function I(t) {
|
|
3940
3959
|
t.status === 401 && (n.value ? s.value.refetch() : _.value ? P(_.value) : e.awaitExternalToken || F());
|
|
3941
3960
|
}
|
|
3942
|
-
let
|
|
3961
|
+
let L = o(() => s.value.data?.user?.id), U = u();
|
|
3943
3962
|
async function W(t, n, i) {
|
|
3944
|
-
let
|
|
3963
|
+
let o = await a.signIn.email({
|
|
3945
3964
|
email: t,
|
|
3946
3965
|
password: n,
|
|
3947
3966
|
rememberMe: i
|
|
3948
|
-
}), s =
|
|
3967
|
+
}), s = o.data;
|
|
3949
3968
|
return s?.twoFactorRedirect ? (U.value = s.twoFactorToken ? {
|
|
3950
3969
|
token: s.twoFactorToken,
|
|
3951
3970
|
methods: s.twoFactorMethods ?? []
|
|
3952
|
-
} : void 0,
|
|
3971
|
+
} : void 0, E(e.cookieName), o) : (o.data?.token && (r.value = o.data.token, E(e.cookieName)), o);
|
|
3953
3972
|
}
|
|
3954
3973
|
let G = {
|
|
3955
3974
|
totp: "/two-factor/verify-totp",
|
|
@@ -3976,7 +3995,7 @@ function H(e = {}) {
|
|
|
3976
3995
|
async function J(e, t) {
|
|
3977
3996
|
let n = U.value;
|
|
3978
3997
|
if (!n) return q;
|
|
3979
|
-
let i = await
|
|
3998
|
+
let i = await a.$fetch(G[e], {
|
|
3980
3999
|
...K(n),
|
|
3981
4000
|
body: { code: t }
|
|
3982
4001
|
});
|
|
@@ -3984,22 +4003,22 @@ function H(e = {}) {
|
|
|
3984
4003
|
}
|
|
3985
4004
|
async function Y() {
|
|
3986
4005
|
let e = U.value;
|
|
3987
|
-
return e ?
|
|
4006
|
+
return e ? a.$fetch("/two-factor/send-otp", K(e)) : q;
|
|
3988
4007
|
}
|
|
3989
4008
|
function X() {
|
|
3990
4009
|
U.value = void 0;
|
|
3991
4010
|
}
|
|
3992
4011
|
function Z(e) {
|
|
3993
|
-
return
|
|
4012
|
+
return a.signUp.email(e);
|
|
3994
4013
|
}
|
|
3995
4014
|
function Q(e, t) {
|
|
3996
|
-
return
|
|
4015
|
+
return a.requestPasswordReset({
|
|
3997
4016
|
email: e,
|
|
3998
4017
|
redirectTo: t
|
|
3999
4018
|
});
|
|
4000
4019
|
}
|
|
4001
4020
|
async function ee(t, n) {
|
|
4002
|
-
let i = e.baseUrl ?? void 0, a = e.basePath ?? "auth", o =
|
|
4021
|
+
let i = e.baseUrl ?? void 0, a = e.basePath ?? "auth", o = H(), c = new URL(`${i}/${a}/oauth-popup/start`);
|
|
4003
4022
|
c.searchParams.set("provider", t), c.searchParams.set("popupOrigin", window.location.origin), c.searchParams.set("popupNonce", o);
|
|
4004
4023
|
let l = window.open(c.toString(), "eightwave-oauth", "width=600,height=700,menubar=no,toolbar=no");
|
|
4005
4024
|
return l ? new Promise((t) => {
|
|
@@ -4010,7 +4029,7 @@ function H(e = {}) {
|
|
|
4010
4029
|
window.removeEventListener("message", d), clearInterval(c), t({ popupBlocked: !1 });
|
|
4011
4030
|
}
|
|
4012
4031
|
function d(t) {
|
|
4013
|
-
t.origin === a && t.source === l && t.data?.type ===
|
|
4032
|
+
t.origin === a && t.source === l && t.data?.type === V && t.data.nonce === o && (l?.close(), typeof t.data.token == "string" && t.data.token && (r.value = t.data.token, E(e.cookieName), s.value.refetch().then(() => n?.())), u());
|
|
4014
4033
|
}
|
|
4015
4034
|
window.addEventListener("message", d);
|
|
4016
4035
|
}) : { popupBlocked: !0 };
|
|
@@ -4020,20 +4039,20 @@ function H(e = {}) {
|
|
|
4020
4039
|
_.value = void 0;
|
|
4021
4040
|
let e = r.value;
|
|
4022
4041
|
try {
|
|
4023
|
-
await
|
|
4042
|
+
await a.signOut();
|
|
4024
4043
|
} finally {
|
|
4025
4044
|
r.value === e && (r.value = ""), await s.value.refetch();
|
|
4026
4045
|
}
|
|
4027
4046
|
}
|
|
4028
4047
|
return {
|
|
4029
|
-
client:
|
|
4048
|
+
client: a,
|
|
4030
4049
|
session: s,
|
|
4031
4050
|
isAuthenticating: c,
|
|
4032
4051
|
isExternalAuth: v,
|
|
4033
4052
|
token: r,
|
|
4034
4053
|
headers: i,
|
|
4035
4054
|
onError: I,
|
|
4036
|
-
userId:
|
|
4055
|
+
userId: L,
|
|
4037
4056
|
signInWithEmail: W,
|
|
4038
4057
|
twoFactorChallenge: U,
|
|
4039
4058
|
verifyTwoFactor: J,
|
|
@@ -4041,7 +4060,7 @@ function H(e = {}) {
|
|
|
4041
4060
|
cancelTwoFactor: X,
|
|
4042
4061
|
signUpWithEmail: Z,
|
|
4043
4062
|
requestPasswordReset: Q,
|
|
4044
|
-
signInSocial:
|
|
4063
|
+
signInSocial: a.signIn.social,
|
|
4045
4064
|
signInWithSocialPopup: ee,
|
|
4046
4065
|
signInWithExternalToken: P,
|
|
4047
4066
|
signOut: $
|
|
@@ -4049,18 +4068,18 @@ function H(e = {}) {
|
|
|
4049
4068
|
}
|
|
4050
4069
|
//#endregion
|
|
4051
4070
|
//#region src/composables/useFocusTrapBypass.ts
|
|
4052
|
-
function
|
|
4071
|
+
function W() {
|
|
4053
4072
|
let e = null, t = (e) => {
|
|
4054
4073
|
e.stopPropagation();
|
|
4055
4074
|
};
|
|
4056
|
-
|
|
4057
|
-
let n =
|
|
4075
|
+
l(() => {
|
|
4076
|
+
let n = s()?.proxy?.$el?.getRootNode();
|
|
4058
4077
|
n instanceof ShadowRoot && (e = n, e.addEventListener("focusin", t));
|
|
4059
|
-
}),
|
|
4078
|
+
}), c(() => {
|
|
4060
4079
|
e &&= (e.removeEventListener("focusin", t), null);
|
|
4061
4080
|
});
|
|
4062
4081
|
}
|
|
4063
4082
|
//#endregion
|
|
4064
|
-
export {
|
|
4083
|
+
export { k as AUTH_BASE_PATH, D as BACKEND_URL, O as FRONTEND_URL, E as clearAnonymousUserIdCookie, T as getAnonymousUserIdCookie, C as getSessionCookie, w as setAnonymousUserIdCookie, S as setSessionCookie, A as useChatbotAgent, U as useChatbotAuth, t as useChatbotStore, W as useFocusTrapBypass, r as useLocalizedString };
|
|
4065
4084
|
|
|
4066
4085
|
//# sourceMappingURL=composables.js.map
|