@8wave/ai-elements 0.125.0-beta.41 → 0.125.0-beta.42
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/{Agent-CeZ3bgZ3.js → Agent-DMvYDpLa.js} +123 -122
- package/dist/_chunks/Agent-DMvYDpLa.js.map +1 -0
- package/dist/_chunks/{PkFilePreview-D_1ZgiiA.js → PkFilePreview-DC4iX7Yc.js} +234 -209
- package/dist/_chunks/PkFilePreview-DC4iX7Yc.js.map +1 -0
- package/dist/_chunks/{PkFilePreviewDialog-CI22huzK.js → PkFilePreviewDialog-bcTkTcYk.js} +12 -7
- package/dist/_chunks/PkFilePreviewDialog-bcTkTcYk.js.map +1 -0
- package/dist/_chunks/{PkImageEditorDialog-CAEninFi.js → PkImageEditorDialog-FpbyhV3t.js} +2 -2
- package/dist/_chunks/{PkImageEditorDialog-CAEninFi.js.map → PkImageEditorDialog-FpbyhV3t.js.map} +1 -1
- package/dist/_chunks/{PkSelectionActions-BriGyWCi.js → PkSelectionActions-BbfVZY0R.js} +140 -13
- package/dist/_chunks/PkSelectionActions-BbfVZY0R.js.map +1 -0
- package/dist/_chunks/{PkStreamingMarkdown--9i0feuM.js → PkStreamingMarkdown-COSOOhCg.js} +3 -3
- package/dist/_chunks/{PkStreamingMarkdown--9i0feuM.js.map → PkStreamingMarkdown-COSOOhCg.js.map} +1 -1
- package/dist/_chunks/{PkToolChatFile-BKGUnWrj.js → PkToolChatFile-C_gS0X1j.js} +3 -3
- package/dist/_chunks/{PkToolChatFile-BKGUnWrj.js.map → PkToolChatFile-C_gS0X1j.js.map} +1 -1
- package/dist/_chunks/{PkToolRequestGeolocation-DktrQJvA.js → PkToolRequestGeolocation-CwDQnr7u.js} +2 -2
- package/dist/_chunks/{PkToolRequestGeolocation-DktrQJvA.js.map → PkToolRequestGeolocation-CwDQnr7u.js.map} +1 -1
- package/dist/_chunks/{PkToolRequestOAuthConnection-DkcLwFWl.js → PkToolRequestOAuthConnection-DkrnVowp.js} +2 -2
- package/dist/_chunks/{PkToolRequestOAuthConnection-DkcLwFWl.js.map → PkToolRequestOAuthConnection-DkrnVowp.js.map} +1 -1
- package/dist/_chunks/{PkToolShowArtifact-BfLpz2-W.js → PkToolShowArtifact-fpFtKrZo.js} +2 -2
- package/dist/_chunks/{PkToolShowArtifact-BfLpz2-W.js.map → PkToolShowArtifact-fpFtKrZo.js.map} +1 -1
- package/dist/_chunks/{PkToolShowContactForm-BsF6DFzV.js → PkToolShowContactForm-BAM772bm.js} +2 -2
- package/dist/_chunks/{PkToolShowContactForm-BsF6DFzV.js.map → PkToolShowContactForm-BAM772bm.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-w6RvbKEB.js → PkToolShowForm-DJcL0bgw.js} +4 -4
- package/dist/_chunks/{PkToolShowForm-w6RvbKEB.js.map → PkToolShowForm-DJcL0bgw.js.map} +1 -1
- package/dist/_chunks/{PkToolShowImageGallery-BEddh4He.js → PkToolShowImageGallery-DhB_ucYe.js} +2 -2
- package/dist/_chunks/{PkToolShowImageGallery-BEddh4He.js.map → PkToolShowImageGallery-DhB_ucYe.js.map} +1 -1
- package/dist/_chunks/{PkToolShowProductList-k-VB4pUB.js → PkToolShowProductList-DfcJJrOC.js} +2 -2
- package/dist/_chunks/{PkToolShowProductList-k-VB4pUB.js.map → PkToolShowProductList-DfcJJrOC.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-CGESvGrm.js → PkToolShowSources-GeWAMHYC.js} +3 -3
- package/dist/_chunks/{PkToolShowSources-CGESvGrm.js.map → PkToolShowSources-GeWAMHYC.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSuggestedReply-DTAq41wP.js → PkToolShowSuggestedReply-gpuWzpoh.js} +2 -2
- package/dist/_chunks/{PkToolShowSuggestedReply-DTAq41wP.js.map → PkToolShowSuggestedReply-gpuWzpoh.js.map} +1 -1
- package/dist/_chunks/{PkToolShowVideo-DeexblEL.js → PkToolShowVideo-CikqhGpT.js} +2 -2
- package/dist/_chunks/{PkToolShowVideo-DeexblEL.js.map → PkToolShowVideo-CikqhGpT.js.map} +1 -1
- package/dist/_chunks/{PkToolShowWebPages-C42FNo8K.js → PkToolShowWebPages-B-LuiAtg.js} +2 -2
- package/dist/_chunks/{PkToolShowWebPages-C42FNo8K.js.map → PkToolShowWebPages-B-LuiAtg.js.map} +1 -1
- package/dist/_chunks/{chatImagePolicy-DlZPHhW-.js → chatImagePolicy-Dv_WHhDs.js} +2 -2
- package/dist/_chunks/{chatImagePolicy-DlZPHhW-.js.map → chatImagePolicy-Dv_WHhDs.js.map} +1 -1
- package/dist/_chunks/{markdown-DNPhTO5l.js → markdown-BYpvcbWH.js} +2 -2
- package/dist/_chunks/{markdown-DNPhTO5l.js.map → markdown-BYpvcbWH.js.map} +1 -1
- package/dist/_chunks/{utils-zkq8kMz-.js → utils-DMvy5QRR.js} +2 -2
- package/dist/_chunks/{utils-zkq8kMz-.js.map → utils-DMvy5QRR.js.map} +1 -1
- package/dist/ai-elements.es.js +405 -135
- 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/PkChatbotViewConversations.js +1 -1
- package/dist-vue/PkChatbotViewFiles.js +1 -1
- package/dist-vue/PkChatbotViewProfile.js +1 -1
- package/dist-vue/_chunks/{Agent-ldDZiq6E.js → Agent-B9iJ1WvR.js} +131 -130
- package/dist-vue/_chunks/Agent-B9iJ1WvR.js.map +1 -0
- package/dist-vue/_chunks/{Document-BfjAfogy.js → Document-DnsOE7s6.js} +2 -2
- package/dist-vue/_chunks/{Document-BfjAfogy.js.map → Document-DnsOE7s6.js.map} +1 -1
- package/dist-vue/_chunks/{PkChart-DyyBXkd3.js → PkChart-D-K7nc0g.js} +2 -2
- package/dist-vue/_chunks/{PkChart-DyyBXkd3.js.map → PkChart-D-K7nc0g.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbot-wsqj3EpU.js → PkChatbot-DVQ-Bb7n.js} +8 -8
- package/dist-vue/_chunks/{PkChatbot-wsqj3EpU.js.map → PkChatbot-DVQ-Bb7n.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotEmptyState-DcgIfNkX.js → PkChatbotEmptyState-OlgewA4_.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotEmptyState-DcgIfNkX.js.map → PkChatbotEmptyState-OlgewA4_.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotInput-CN4rmNgu.js → PkChatbotInput-D_I0Gf_u.js} +4 -4
- package/dist-vue/_chunks/{PkChatbotInput-CN4rmNgu.js.map → PkChatbotInput-D_I0Gf_u.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotMessages-BlF4Xp0_.js → PkChatbotMessages-CAXnEfXK.js} +18 -18
- package/dist-vue/_chunks/{PkChatbotMessages-BlF4Xp0_.js.map → PkChatbotMessages-CAXnEfXK.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepPayload-q9uXE5mr.js → PkChatbotStepPayload-EBri1L10.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotStepPayload-q9uXE5mr.js.map → PkChatbotStepPayload-EBri1L10.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-BJz6Qwh3.js → PkChatbotStepToolDetail-DiQEa0UV.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-BJz6Qwh3.js.map → PkChatbotStepToolDetail-DiQEa0UV.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotSteps-DvJYNl_k.js → PkChatbotSteps-BgLnv2J1.js} +5 -5
- package/dist-vue/_chunks/{PkChatbotSteps-DvJYNl_k.js.map → PkChatbotSteps-BgLnv2J1.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-tmHyxxT3.js → PkChatbotViewChat-CmjD1IXf.js} +360 -355
- package/dist-vue/_chunks/PkChatbotViewChat-CmjD1IXf.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotViewConversations-DOzUh_A7.js → PkChatbotViewConversations-CVZH5dXx.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotViewConversations-DOzUh_A7.js.map → PkChatbotViewConversations-CVZH5dXx.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewFiles-CsL8OhcA.js → PkChatbotViewFiles-CO4gv9nd.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotViewFiles-CsL8OhcA.js.map → PkChatbotViewFiles-CO4gv9nd.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewProfile-CFqxCK2f.js → PkChatbotViewProfile-CriJtak0.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewProfile-CFqxCK2f.js.map → PkChatbotViewProfile-CriJtak0.js.map} +1 -1
- package/dist-vue/_chunks/{PkFilePreview-Bp5-Pl54.js → PkFilePreview-k5gEl3n8.js} +586 -434
- package/dist-vue/_chunks/PkFilePreview-k5gEl3n8.js.map +1 -0
- package/dist-vue/_chunks/{PkFilePreviewDialog-CS885vBR.js → PkFilePreviewDialog-DUwZPErE.js} +12 -7
- package/dist-vue/_chunks/PkFilePreviewDialog-DUwZPErE.js.map +1 -0
- package/dist-vue/_chunks/{PkImageEditorDialog-BhfdnsmX.js → PkImageEditorDialog-DQPXePae.js} +2 -2
- package/dist-vue/_chunks/{PkImageEditorDialog-BhfdnsmX.js.map → PkImageEditorDialog-DQPXePae.js.map} +1 -1
- package/dist-vue/_chunks/{PkStreamingMarkdown-NgrJUZPI.js → PkStreamingMarkdown-ZasabxE0.js} +3 -3
- package/dist-vue/_chunks/{PkStreamingMarkdown-NgrJUZPI.js.map → PkStreamingMarkdown-ZasabxE0.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolChatFile-DnmiNGF4.js → PkToolChatFile-CD26Q2xp.js} +3 -3
- package/dist-vue/_chunks/{PkToolChatFile-DnmiNGF4.js.map → PkToolChatFile-CD26Q2xp.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolRequestGeolocation-D1XNCvdr.js → PkToolRequestGeolocation-Bhh7UomV.js} +2 -2
- package/dist-vue/_chunks/{PkToolRequestGeolocation-D1XNCvdr.js.map → PkToolRequestGeolocation-Bhh7UomV.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolRequestOAuthConnection-OTvMRYaL.js → PkToolRequestOAuthConnection-8GJlt5G1.js} +2 -2
- package/dist-vue/_chunks/{PkToolRequestOAuthConnection-OTvMRYaL.js.map → PkToolRequestOAuthConnection-8GJlt5G1.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowArtifact-C8ueuIGQ.js → PkToolShowArtifact-BhVd_ZQ8.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowArtifact-C8ueuIGQ.js.map → PkToolShowArtifact-BhVd_ZQ8.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowChart-BWO6Hzlq.js → PkToolShowChart-BQXxaPIO.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowChart-BWO6Hzlq.js.map → PkToolShowChart-BQXxaPIO.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowContactForm-BBcDsLEO.js → PkToolShowContactForm-CackCDGD.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowContactForm-BBcDsLEO.js.map → PkToolShowContactForm-CackCDGD.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-BzUcxOKy.js → PkToolShowDiagram-CABPsFi8.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-BzUcxOKy.js.map → PkToolShowDiagram-CABPsFi8.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-B6uhHzJ8.js → PkToolShowForm-BStbk4Iu.js} +4 -4
- package/dist-vue/_chunks/{PkToolShowForm-B6uhHzJ8.js.map → PkToolShowForm-BStbk4Iu.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowImageGallery-C39nlJrJ.js → PkToolShowImageGallery-BeeHsdTp.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowImageGallery-C39nlJrJ.js.map → PkToolShowImageGallery-BeeHsdTp.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowProductList-FLLkRCnm.js → PkToolShowProductList-BfUiap9U.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowProductList-FLLkRCnm.js.map → PkToolShowProductList-BfUiap9U.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-Cb7r5jrX.js → PkToolShowSources-CgEkcyRg.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowSources-Cb7r5jrX.js.map → PkToolShowSources-CgEkcyRg.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSuggestedReply-BVLCX5Sm.js → PkToolShowSuggestedReply-DxlGhMvE.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSuggestedReply-BVLCX5Sm.js.map → PkToolShowSuggestedReply-DxlGhMvE.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowVideo-QDLhVlau.js → PkToolShowVideo-CqSRnDNC.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowVideo-QDLhVlau.js.map → PkToolShowVideo-CqSRnDNC.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowWebPages-P6PdJTEE.js → PkToolShowWebPages-B-qIS8qY.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowWebPages-P6PdJTEE.js.map → PkToolShowWebPages-B-qIS8qY.js.map} +1 -1
- package/dist-vue/_chunks/{createChatbotApiClient-CGeNprai.js → createChatbotApiClient-DmPcjwB3.js} +7 -7
- package/dist-vue/_chunks/{createChatbotApiClient-CGeNprai.js.map → createChatbotApiClient-DmPcjwB3.js.map} +1 -1
- package/dist-vue/_chunks/{useChatbotStore-KXAltGz3.js → useChatbotStore-B6ILfm5Z.js} +17 -17
- package/dist-vue/_chunks/{useChatbotStore-KXAltGz3.js.map → useChatbotStore-B6ILfm5Z.js.map} +1 -1
- package/dist-vue/_chunks/{utils-D4B1FVGF.js → utils-KBB6SDPn.js} +2 -2
- package/dist-vue/_chunks/{utils-D4B1FVGF.js.map → utils-KBB6SDPn.js.map} +1 -1
- package/dist-vue/api.js +1 -1
- package/dist-vue/apps/web-component/src/composables/useChatbotAgent.d.ts +6 -0
- package/dist-vue/composables.js +270 -6
- package/dist-vue/composables.js.map +1 -1
- package/dist-vue/index.js +5325 -5232
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/locales.js +12 -0
- package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +6 -0
- package/dist-vue/packages/components/src/chat/PkFilePreview.d.ts +8 -0
- package/dist-vue/packages/components/src/chat/PkFilePreviewDialog.d.ts +4 -0
- package/dist-vue/packages/components/src/chat/PkSelectionActionIconPicker.d.ts +19 -0
- package/dist-vue/packages/components/src/chat/PkSelectionActions.d.ts +3 -0
- package/dist-vue/packages/components/src/chat/selectionActionEdits.d.ts +1 -0
- package/dist-vue/packages/components/src/chat/selectionActionIcons.d.ts +9 -0
- package/dist-vue/packages/components/src/chat/useChatFilePreview.d.ts +12 -12
- package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +18 -0
- package/dist-vue/packages/models/src/schema/Agent.d.ts +2688 -0
- package/dist-vue/packages/models/src/schema/Chart.d.ts +4 -4
- package/dist-vue/packages/models/src/schema/Lead.d.ts +6 -6
- package/dist-vue/packages/models/src/schema/ReasoningChat.d.ts +768 -0
- package/dist-vue/packages/models/src/schema/SelectionAction.d.ts +1415 -0
- package/dist-vue/packages/models/src/schema/SelectionActionPreview.d.ts +38 -0
- package/dist-vue/packages/models/src/schema/SpreadsheetPreview.d.ts +6 -6
- package/dist-vue/packages/models/src/schema/SubAgent.d.ts +768 -0
- package/dist-vue/packages/models/src/schema/WordPreview.d.ts +13 -13
- package/dist-vue/packages/models/src/schema/index.d.ts +1 -0
- package/dist-vue/style.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/Agent-CeZ3bgZ3.js.map +0 -1
- package/dist/_chunks/PkFilePreview-D_1ZgiiA.js.map +0 -1
- package/dist/_chunks/PkFilePreviewDialog-CI22huzK.js.map +0 -1
- package/dist/_chunks/PkSelectionActions-BriGyWCi.js.map +0 -1
- package/dist-vue/_chunks/Agent-ldDZiq6E.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotViewChat-tmHyxxT3.js.map +0 -1
- package/dist-vue/_chunks/PkFilePreview-Bp5-Pl54.js.map +0 -1
- package/dist-vue/_chunks/PkFilePreviewDialog-CS885vBR.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolRequestOAuthConnection-OTvMRYaL.js","names":["__unplugin_components_0","__unplugin_components_1","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_createBlock","_createCommentVNode","_Fragment","_sfc_main","isVoiceRenderAck","isMcpOAuthReport","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","POLL_INTERVAL_MS","POLL_TIMEOUT_MS","PkToolRequestOAuthConnection_default","defineComponent","__emit","props","__props","emit","$t","useI18n","toolPart","computed","state","serverName","isRenderAck","isConnectedByOutput","isAwaitingConnection","mcpServerId","ref","hasConnected","isSigningIn","oauthError","isDone","canConnect","isConnectedNow","status","pollTimer","signInAttempt","signInWindow","stopWatching","settleConnected","connectedServerId","watchForConnection","attempt","popup","deadline","tick","connected","onMessage","event","reportedServerId","openAuthWindow","connection","err","onMounted","onUnmounted","_component_VvIcon","VvIcon","_component_VvButton","VvButtonLocalized","openBlock","createElementBlock","createElementVNode","createVNode","toDisplayString","unref","createBlock","createCommentVNode","Fragment"],"sources":["../../../../packages/components/src/chat/PkToolRequestOAuthConnection.vue","../../../../packages/components/src/chat/PkToolRequestOAuthConnection.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, onMounted, onUnmounted, ref } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { isVoiceRenderAck } from 'models'\n import { isMcpOAuthReport } from './mcpOAuthReport'\n\n const props = defineProps<{\n part: unknown\n /**\n * The backend the chat talks to, where the sign-in's callback page\n * runs. Without it the card hears no report and relies on its poll.\n */\n backendUrl?: string\n resolveConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; authorizeUrl: string }>\n checkConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; connected: boolean }>\n }>()\n\n const emit = defineEmits<{\n connected: [mcpServerId: string]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n /** How often the connection is re-read while the sign-in window is out. */\n const POLL_INTERVAL_MS = 2000\n /**\n * How long we keep asking. The only end to a sign-in nobody finishes:\n * `popup.closed` cannot be that signal, because the browser disowns the\n * handle when the provider severs the opener (that is what\n * `Cross-Origin-Opener-Policy` does), so it reads as closed from the first\n * check of the very flow this watch exists for. Long enough for a password\n * manager and a second factor.\n */\n const POLL_TIMEOUT_MS = 5 * 60 * 1000\n\n const toolPart = computed(() => {\n return props.part as {\n state?: string\n toolCallId?: string\n input?: { serverName: string }\n output?: unknown\n }\n })\n\n const state = computed(() => toolPart.value.state ?? 'unknown')\n const serverName = computed(() => toolPart.value.input?.serverName)\n\n /**\n * A card drawn during a CALL arrives already \"answered\": the turn could\n * not wait for the connection, so the backend closed the tool with a note\n * saying the card was drawn (see `isVoiceRenderAck`, same rule as the\n * forms). That note is not a connection, and without this the card\n * rendered its inert fallback: the caller was told to connect the account\n * and given nothing to click (measured 2026-08-07).\n */\n const isRenderAck = computed(() => isVoiceRenderAck(toolPart.value.output))\n\n /** The output this card wrote itself once the connection went through. */\n const isConnectedByOutput = computed(\n () =>\n (toolPart.value.output as { connected?: unknown } | undefined)\n ?.connected === true,\n )\n\n const isAwaitingConnection = computed(\n () => state.value === 'input-available' || isRenderAck.value,\n )\n\n const mcpServerId = ref<string | null>(null)\n /**\n * Set once THIS card's sign-in went through, and never from a plain read of\n * the connection: a card still asking is the turn saying it could not use\n * that integration, and a token row can outlive its usefulness (a refresh\n * that failed transiently keeps the row, so the turn sees no usable token\n * while a status read still sees one). Trusting the read there would have\n * left the card claiming success, with no button, on a turn still waiting.\n * It doubles as the guard that resumes the turn exactly once, whichever\n * channel got there first.\n */\n const hasConnected = ref(false)\n /** A sign-in window we opened is still out there. */\n const isSigningIn = ref(false)\n const oauthError = ref<string | null>(null)\n\n const isDone = computed(\n () => hasConnected.value || isConnectedByOutput.value,\n )\n const canConnect = computed(\n () => Boolean(serverName.value) && Boolean(props.resolveConnection),\n )\n\n /**\n * Whether the server says this user has connected, asked without minting\n * anything: no OAuth `state` is burned by looking.\n */\n async function isConnectedNow(): Promise<boolean> {\n if (!serverName.value || !props.checkConnection) {\n return false\n }\n try {\n const status = await props.checkConnection(serverName.value)\n mcpServerId.value = status.mcpServerId\n return status.connected\n } catch {\n // Not knowing is not an error to show: the sign-in window is still\n // out there and the next read may well answer.\n return false\n }\n }\n\n let pollTimer: ReturnType<typeof setTimeout> | undefined\n /**\n * Which sign-in a running tick belongs to. A tick suspended on its read\n * outlives the attempt that scheduled it: without this it woke up inside\n * the NEXT attempt, restarted its own chain over that one's timer and then\n * stopped it on its own older deadline.\n */\n let signInAttempt = 0\n /** The window this attempt opened, the only sender we accept a report from. */\n let signInWindow: Window | null = null\n\n function stopWatching() {\n if (pollTimer !== undefined) {\n clearTimeout(pollTimer)\n pollTimer = undefined\n }\n signInAttempt += 1\n signInWindow = null\n isSigningIn.value = false\n }\n\n function settleConnected(connectedServerId: string) {\n stopWatching()\n if (hasConnected.value) {\n return\n }\n hasConnected.value = true\n mcpServerId.value = connectedServerId\n oauthError.value = null\n emit('connected', connectedServerId)\n }\n\n /**\n * Watches the connection from THIS window while the sign-in window is away.\n *\n * The callback page reports through `window.opener`, and a provider that\n * sends `Cross-Origin-Opener-Policy` anywhere in its redirect chain takes\n * that opener away: the connection then succeeds with nobody listening, the\n * card stays on its button and the suspended turn is never resumed\n * (reported 2026-08-27). This channel never goes through that window, so it\n * survives whatever the provider does to it. Chained rather than periodic:\n * a read slower than the interval would otherwise overlap the next one.\n */\n function watchForConnection(popup: Window) {\n stopWatching()\n const attempt = signInAttempt\n signInWindow = popup\n isSigningIn.value = true\n const deadline = Date.now() + POLL_TIMEOUT_MS\n const tick = async () => {\n if (attempt !== signInAttempt || Date.now() > deadline) {\n if (attempt === signInAttempt) {\n stopWatching()\n }\n return\n }\n const connected = await isConnectedNow()\n if (attempt !== signInAttempt) {\n return\n }\n if (connected && mcpServerId.value) {\n settleConnected(mcpServerId.value)\n return\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n\n /**\n * The callback page's own report, when the browser let it through: faster\n * than the poll, and the only channel carrying the failure reason.\n *\n * Accepted only as {@link isMcpOAuthReport} says, and only while that\n * sign-in is out: the listener stays up for as long as the card is on\n * screen, and nothing else with a handle on this page may resume a turn by\n * posting a message at it.\n */\n function onMessage(event: MessageEvent) {\n if (\n !isSigningIn.value ||\n !isMcpOAuthReport(event, signInWindow, props.backendUrl)\n ) {\n return\n }\n const reportedServerId = event.data.mcpServerId as string | undefined\n if (\n reportedServerId &&\n mcpServerId.value &&\n reportedServerId !== mcpServerId.value\n ) {\n return\n }\n if (!event.data.success) {\n // A failure carries no server id: the callback never got that far.\n stopWatching()\n oauthError.value = event.data.error ?? 'Unknown error'\n return\n }\n const connectedServerId = reportedServerId ?? mcpServerId.value\n if (connectedServerId) {\n settleConnected(connectedServerId)\n }\n }\n\n /**\n * Opens the provider's sign-in, on an authorize URL minted NOW.\n *\n * The URL carries an OAuth `state` that lives ten minutes server-side.\n * Minted when the card rendered, it was routinely expired by the time\n * anyone clicked, and the callback then failed on a sign-in the user had\n * just completed. The window is opened blank first, synchronously, or the\n * popup blocker kills it while we wait for the URL.\n */\n async function openAuthWindow() {\n if (\n !serverName.value ||\n !props.resolveConnection ||\n isSigningIn.value\n ) {\n return\n }\n oauthError.value = null\n const popup = window.open(\n '',\n 'mcp_oauth',\n 'width=600,height=700,menubar=no,toolbar=no',\n )\n if (!popup) {\n oauthError.value = $t('auth.popupBlocked')\n return\n }\n watchForConnection(popup)\n try {\n const connection = await props.resolveConnection(serverName.value)\n mcpServerId.value = connection.mcpServerId\n popup.location.href = connection.authorizeUrl\n } catch (err) {\n stopWatching()\n popup.close()\n oauthError.value =\n err instanceof Error ? err.message : 'Failed to resolve OAuth'\n }\n }\n\n // For the card's whole life, not just between the click and the answer: a\n // card that re-renders while the sign-in window is away used to lose the\n // listener with it, and the completion landed on nobody.\n onMounted(() => window.addEventListener('message', onMessage))\n onUnmounted(() => {\n window.removeEventListener('message', onMessage)\n stopWatching()\n })\n</script>\n\n<template>\n <!-- The same frame and header as the other tool cards: this was the only\n one drawing itself as a tinted box (DESIGN.md). -->\n <div\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface text-12\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon name=\"ri:link\" class=\"text-16 shrink-0\" />\n <strong class=\"truncate\">{{ serverName }}</strong>\n </div>\n <div class=\"p-sm\">\n <!-- Connected: just now, or by this card on an earlier visit -->\n <template v-if=\"isDone\">\n <div class=\"flex items-center gap-8\">\n <VvIcon name=\"ri:check-line\" class=\"text-16 text-success\" />\n <strong class=\"font-medium text-word-1\">\n {{\n $t('messagePart.requestOAuthConnectionSuccess', {\n name: serverName,\n })\n }}\n </strong>\n </div>\n </template>\n\n <!-- Signing in: the window is out and we are watching for it -->\n <template v-else-if=\"isSigningIn\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"loading-loop\" />\n <span class=\"text-10\">{{\n $t('messagePart.requestOAuthConnection')\n }}</span>\n </div>\n </template>\n\n <!-- OAuth error -->\n <template v-else-if=\"oauthError\">\n <div class=\"flex flex-col gap-xs\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:close-line\" class=\"text-danger\" />\n <strong class=\"text-10\">\n {{ oauthError }}\n </strong>\n </div>\n <VvButton\n v-if=\"canConnect\"\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </div>\n </template>\n\n <!-- Waiting on the user: show the connect button -->\n <template v-else-if=\"isAwaitingConnection && canConnect\">\n <div class=\"flex items-center gap-6 text-word-3 mb-xs\">\n <span>\n {{\n $t('messagePart.requestOAuthConnectionPrompt', {\n name: serverName,\n })\n }}\n </span>\n </div>\n <VvButton\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </template>\n <!-- Fallback for unknown state -->\n <template v-else>\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:link\" />\n <span class=\"text-10\">\n {{\n $t('messagePart.requestOAuthConnectionInfo', {\n name: serverName,\n })\n }}\n </span>\n </div>\n </template>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed, onMounted, onUnmounted, ref } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { isVoiceRenderAck } from 'models'\n import { isMcpOAuthReport } from './mcpOAuthReport'\n\n const props = defineProps<{\n part: unknown\n /**\n * The backend the chat talks to, where the sign-in's callback page\n * runs. Without it the card hears no report and relies on its poll.\n */\n backendUrl?: string\n resolveConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; authorizeUrl: string }>\n checkConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; connected: boolean }>\n }>()\n\n const emit = defineEmits<{\n connected: [mcpServerId: string]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n /** How often the connection is re-read while the sign-in window is out. */\n const POLL_INTERVAL_MS = 2000\n /**\n * How long we keep asking. The only end to a sign-in nobody finishes:\n * `popup.closed` cannot be that signal, because the browser disowns the\n * handle when the provider severs the opener (that is what\n * `Cross-Origin-Opener-Policy` does), so it reads as closed from the first\n * check of the very flow this watch exists for. Long enough for a password\n * manager and a second factor.\n */\n const POLL_TIMEOUT_MS = 5 * 60 * 1000\n\n const toolPart = computed(() => {\n return props.part as {\n state?: string\n toolCallId?: string\n input?: { serverName: string }\n output?: unknown\n }\n })\n\n const state = computed(() => toolPart.value.state ?? 'unknown')\n const serverName = computed(() => toolPart.value.input?.serverName)\n\n /**\n * A card drawn during a CALL arrives already \"answered\": the turn could\n * not wait for the connection, so the backend closed the tool with a note\n * saying the card was drawn (see `isVoiceRenderAck`, same rule as the\n * forms). That note is not a connection, and without this the card\n * rendered its inert fallback: the caller was told to connect the account\n * and given nothing to click (measured 2026-08-07).\n */\n const isRenderAck = computed(() => isVoiceRenderAck(toolPart.value.output))\n\n /** The output this card wrote itself once the connection went through. */\n const isConnectedByOutput = computed(\n () =>\n (toolPart.value.output as { connected?: unknown } | undefined)\n ?.connected === true,\n )\n\n const isAwaitingConnection = computed(\n () => state.value === 'input-available' || isRenderAck.value,\n )\n\n const mcpServerId = ref<string | null>(null)\n /**\n * Set once THIS card's sign-in went through, and never from a plain read of\n * the connection: a card still asking is the turn saying it could not use\n * that integration, and a token row can outlive its usefulness (a refresh\n * that failed transiently keeps the row, so the turn sees no usable token\n * while a status read still sees one). Trusting the read there would have\n * left the card claiming success, with no button, on a turn still waiting.\n * It doubles as the guard that resumes the turn exactly once, whichever\n * channel got there first.\n */\n const hasConnected = ref(false)\n /** A sign-in window we opened is still out there. */\n const isSigningIn = ref(false)\n const oauthError = ref<string | null>(null)\n\n const isDone = computed(\n () => hasConnected.value || isConnectedByOutput.value,\n )\n const canConnect = computed(\n () => Boolean(serverName.value) && Boolean(props.resolveConnection),\n )\n\n /**\n * Whether the server says this user has connected, asked without minting\n * anything: no OAuth `state` is burned by looking.\n */\n async function isConnectedNow(): Promise<boolean> {\n if (!serverName.value || !props.checkConnection) {\n return false\n }\n try {\n const status = await props.checkConnection(serverName.value)\n mcpServerId.value = status.mcpServerId\n return status.connected\n } catch {\n // Not knowing is not an error to show: the sign-in window is still\n // out there and the next read may well answer.\n return false\n }\n }\n\n let pollTimer: ReturnType<typeof setTimeout> | undefined\n /**\n * Which sign-in a running tick belongs to. A tick suspended on its read\n * outlives the attempt that scheduled it: without this it woke up inside\n * the NEXT attempt, restarted its own chain over that one's timer and then\n * stopped it on its own older deadline.\n */\n let signInAttempt = 0\n /** The window this attempt opened, the only sender we accept a report from. */\n let signInWindow: Window | null = null\n\n function stopWatching() {\n if (pollTimer !== undefined) {\n clearTimeout(pollTimer)\n pollTimer = undefined\n }\n signInAttempt += 1\n signInWindow = null\n isSigningIn.value = false\n }\n\n function settleConnected(connectedServerId: string) {\n stopWatching()\n if (hasConnected.value) {\n return\n }\n hasConnected.value = true\n mcpServerId.value = connectedServerId\n oauthError.value = null\n emit('connected', connectedServerId)\n }\n\n /**\n * Watches the connection from THIS window while the sign-in window is away.\n *\n * The callback page reports through `window.opener`, and a provider that\n * sends `Cross-Origin-Opener-Policy` anywhere in its redirect chain takes\n * that opener away: the connection then succeeds with nobody listening, the\n * card stays on its button and the suspended turn is never resumed\n * (reported 2026-08-27). This channel never goes through that window, so it\n * survives whatever the provider does to it. Chained rather than periodic:\n * a read slower than the interval would otherwise overlap the next one.\n */\n function watchForConnection(popup: Window) {\n stopWatching()\n const attempt = signInAttempt\n signInWindow = popup\n isSigningIn.value = true\n const deadline = Date.now() + POLL_TIMEOUT_MS\n const tick = async () => {\n if (attempt !== signInAttempt || Date.now() > deadline) {\n if (attempt === signInAttempt) {\n stopWatching()\n }\n return\n }\n const connected = await isConnectedNow()\n if (attempt !== signInAttempt) {\n return\n }\n if (connected && mcpServerId.value) {\n settleConnected(mcpServerId.value)\n return\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n\n /**\n * The callback page's own report, when the browser let it through: faster\n * than the poll, and the only channel carrying the failure reason.\n *\n * Accepted only as {@link isMcpOAuthReport} says, and only while that\n * sign-in is out: the listener stays up for as long as the card is on\n * screen, and nothing else with a handle on this page may resume a turn by\n * posting a message at it.\n */\n function onMessage(event: MessageEvent) {\n if (\n !isSigningIn.value ||\n !isMcpOAuthReport(event, signInWindow, props.backendUrl)\n ) {\n return\n }\n const reportedServerId = event.data.mcpServerId as string | undefined\n if (\n reportedServerId &&\n mcpServerId.value &&\n reportedServerId !== mcpServerId.value\n ) {\n return\n }\n if (!event.data.success) {\n // A failure carries no server id: the callback never got that far.\n stopWatching()\n oauthError.value = event.data.error ?? 'Unknown error'\n return\n }\n const connectedServerId = reportedServerId ?? mcpServerId.value\n if (connectedServerId) {\n settleConnected(connectedServerId)\n }\n }\n\n /**\n * Opens the provider's sign-in, on an authorize URL minted NOW.\n *\n * The URL carries an OAuth `state` that lives ten minutes server-side.\n * Minted when the card rendered, it was routinely expired by the time\n * anyone clicked, and the callback then failed on a sign-in the user had\n * just completed. The window is opened blank first, synchronously, or the\n * popup blocker kills it while we wait for the URL.\n */\n async function openAuthWindow() {\n if (\n !serverName.value ||\n !props.resolveConnection ||\n isSigningIn.value\n ) {\n return\n }\n oauthError.value = null\n const popup = window.open(\n '',\n 'mcp_oauth',\n 'width=600,height=700,menubar=no,toolbar=no',\n )\n if (!popup) {\n oauthError.value = $t('auth.popupBlocked')\n return\n }\n watchForConnection(popup)\n try {\n const connection = await props.resolveConnection(serverName.value)\n mcpServerId.value = connection.mcpServerId\n popup.location.href = connection.authorizeUrl\n } catch (err) {\n stopWatching()\n popup.close()\n oauthError.value =\n err instanceof Error ? err.message : 'Failed to resolve OAuth'\n }\n }\n\n // For the card's whole life, not just between the click and the answer: a\n // card that re-renders while the sign-in window is away used to lose the\n // listener with it, and the completion landed on nobody.\n onMounted(() => window.addEventListener('message', onMessage))\n onUnmounted(() => {\n window.removeEventListener('message', onMessage)\n stopWatching()\n })\n</script>\n\n<template>\n <!-- The same frame and header as the other tool cards: this was the only\n one drawing itself as a tinted box (DESIGN.md). -->\n <div\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface text-12\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon name=\"ri:link\" class=\"text-16 shrink-0\" />\n <strong class=\"truncate\">{{ serverName }}</strong>\n </div>\n <div class=\"p-sm\">\n <!-- Connected: just now, or by this card on an earlier visit -->\n <template v-if=\"isDone\">\n <div class=\"flex items-center gap-8\">\n <VvIcon name=\"ri:check-line\" class=\"text-16 text-success\" />\n <strong class=\"font-medium text-word-1\">\n {{\n $t('messagePart.requestOAuthConnectionSuccess', {\n name: serverName,\n })\n }}\n </strong>\n </div>\n </template>\n\n <!-- Signing in: the window is out and we are watching for it -->\n <template v-else-if=\"isSigningIn\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"loading-loop\" />\n <span class=\"text-10\">{{\n $t('messagePart.requestOAuthConnection')\n }}</span>\n </div>\n </template>\n\n <!-- OAuth error -->\n <template v-else-if=\"oauthError\">\n <div class=\"flex flex-col gap-xs\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:close-line\" class=\"text-danger\" />\n <strong class=\"text-10\">\n {{ oauthError }}\n </strong>\n </div>\n <VvButton\n v-if=\"canConnect\"\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </div>\n </template>\n\n <!-- Waiting on the user: show the connect button -->\n <template v-else-if=\"isAwaitingConnection && canConnect\">\n <div class=\"flex items-center gap-6 text-word-3 mb-xs\">\n <span>\n {{\n $t('messagePart.requestOAuthConnectionPrompt', {\n name: serverName,\n })\n }}\n </span>\n </div>\n <VvButton\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </template>\n <!-- Fallback for unknown state -->\n <template v-else>\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:link\" />\n <span class=\"text-10\">\n {{\n $t('messagePart.requestOAuthConnectionInfo', {\n name: serverName,\n })\n }}\n </span>\n </div>\n </template>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;A,6BA4BU4B,IAAmB,KASnBC,IAAkB,K;;;;;;;;;;EA/BxB,IAAMI,IAAQC,GAeRC,IAAOH,GAIP,EAAE,GAAGI,MAAOC,EAAQ,EAAE,UAAU,SAAS,CAAC,GAc1CC,IAAWC,QACNN,EAAM,IAMhB,GAEKO,IAAQD,QAAeD,EAAS,MAAM,SAAS,SAAS,GACxDG,IAAaF,QAAeD,EAAS,MAAM,OAAO,UAAU,GAU5DI,IAAcH,QAAe3B,EAAiB0B,EAAS,MAAM,MAAM,CAAC,GAGpEK,IAAsBJ,QAEnBD,EAAS,MAAM,QACV,cAAc,EAC5B,GAEMM,IAAuBL,QACnBC,EAAM,UAAU,qBAAqBE,EAAY,KAC3D,GAEMG,IAAcC,EAAmB,IAAI,GAWrCC,IAAeD,EAAI,EAAK,GAExBE,IAAcF,EAAI,EAAK,GACvBG,IAAaH,EAAmB,IAAI,GAEpCI,IAASX,QACLQ,EAAa,SAASJ,EAAoB,KACpD,GACMQ,IAAaZ,QACT,EAAQE,EAAW,SAAU,EAAQR,EAAM,iBACrD;EAMA,eAAemB,IAAmC;GAC9C,IAAI,CAACX,EAAW,SAAS,CAACR,EAAM,iBAC5B,OAAO;GAEX,IAAI;IACA,IAAMoB,IAAS,MAAMpB,EAAM,gBAAgBQ,EAAW,KAAK;IAE3D,OADA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SACjB/C,EAAA,GAAAC,EAiBM,OAjBNmB,IAiBM,CAhBFlB,EAKM,OALNmB,IAKM,CAJFlB,EAAmDqE,GAAA;IAA3C,MAAK;IAAgB,OAAM;G,IACnCtE,EAES,UAFToB,IAESlB,EADF2C,EAAA,KAAU,GAAA,CAAA,C,IAIXE,EAAA,SADVjD,EAAA,GAAAM,EAS8BoE,GAAA;;IAP1B,WAAU;IACV,MAAK;IACJ,OAAoCrE,EAAA6B,CAAA,CAAE,CAAA,4CAAA,EAAqF,MAAAK,EAAA,M;IAK3H,SAAO4B;G,yCAKCzB,EAAA,SAAwBO,EAAA,SAA7CjD,EAAA,GAAAC,EAmBWO,GAAA,EAAA,KAAA,EAAA,GAAA,CAlBPN,EAQM,OARNqB,IAQM,CAPFrB,EAMO,QAAA,MAAAE,EAJCC,EAAA6B,CAAA,CAAE,CAAA,4CAAA,EAAqF,MAAAK,EAAA,M,WAMnGpC,EAQ8BuE,GAAA;IAP1B,WAAU;IACV,MAAK;IACJ,OAAgCrE,EAAA6B,CAAA,CAAE,CAAA,4CAAA,EAAiF,MAAAK,EAAA,M;IAKnH,SAAO4B;G,iCAIZnE,EAAA,GAAAC,EASM,OATNuB,IASM,CARFrB,EAAyBqE,GAAA,EAAjB,MAAK,UAAS,CAAA,GACtBtE,EAMO,QANPuB,GAMOrB,EAJCC,EAAA6B,CAAA,CAAE,CAAA,0CAAA,EAAmF,MAAAK,EAAA,M"}
|
|
1
|
+
{"version":3,"file":"PkToolRequestOAuthConnection-8GJlt5G1.js","names":["__unplugin_components_0","__unplugin_components_1","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_createBlock","_createCommentVNode","_Fragment","_sfc_main","isVoiceRenderAck","isMcpOAuthReport","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","POLL_INTERVAL_MS","POLL_TIMEOUT_MS","PkToolRequestOAuthConnection_default","defineComponent","__emit","props","__props","emit","$t","useI18n","toolPart","computed","state","serverName","isRenderAck","isConnectedByOutput","isAwaitingConnection","mcpServerId","ref","hasConnected","isSigningIn","oauthError","isDone","canConnect","isConnectedNow","status","pollTimer","signInAttempt","signInWindow","stopWatching","settleConnected","connectedServerId","watchForConnection","attempt","popup","deadline","tick","connected","onMessage","event","reportedServerId","openAuthWindow","connection","err","onMounted","onUnmounted","_component_VvIcon","VvIcon","_component_VvButton","VvButtonLocalized","openBlock","createElementBlock","createElementVNode","createVNode","toDisplayString","unref","createBlock","createCommentVNode","Fragment"],"sources":["../../../../packages/components/src/chat/PkToolRequestOAuthConnection.vue","../../../../packages/components/src/chat/PkToolRequestOAuthConnection.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, onMounted, onUnmounted, ref } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { isVoiceRenderAck } from 'models'\n import { isMcpOAuthReport } from './mcpOAuthReport'\n\n const props = defineProps<{\n part: unknown\n /**\n * The backend the chat talks to, where the sign-in's callback page\n * runs. Without it the card hears no report and relies on its poll.\n */\n backendUrl?: string\n resolveConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; authorizeUrl: string }>\n checkConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; connected: boolean }>\n }>()\n\n const emit = defineEmits<{\n connected: [mcpServerId: string]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n /** How often the connection is re-read while the sign-in window is out. */\n const POLL_INTERVAL_MS = 2000\n /**\n * How long we keep asking. The only end to a sign-in nobody finishes:\n * `popup.closed` cannot be that signal, because the browser disowns the\n * handle when the provider severs the opener (that is what\n * `Cross-Origin-Opener-Policy` does), so it reads as closed from the first\n * check of the very flow this watch exists for. Long enough for a password\n * manager and a second factor.\n */\n const POLL_TIMEOUT_MS = 5 * 60 * 1000\n\n const toolPart = computed(() => {\n return props.part as {\n state?: string\n toolCallId?: string\n input?: { serverName: string }\n output?: unknown\n }\n })\n\n const state = computed(() => toolPart.value.state ?? 'unknown')\n const serverName = computed(() => toolPart.value.input?.serverName)\n\n /**\n * A card drawn during a CALL arrives already \"answered\": the turn could\n * not wait for the connection, so the backend closed the tool with a note\n * saying the card was drawn (see `isVoiceRenderAck`, same rule as the\n * forms). That note is not a connection, and without this the card\n * rendered its inert fallback: the caller was told to connect the account\n * and given nothing to click (measured 2026-08-07).\n */\n const isRenderAck = computed(() => isVoiceRenderAck(toolPart.value.output))\n\n /** The output this card wrote itself once the connection went through. */\n const isConnectedByOutput = computed(\n () =>\n (toolPart.value.output as { connected?: unknown } | undefined)\n ?.connected === true,\n )\n\n const isAwaitingConnection = computed(\n () => state.value === 'input-available' || isRenderAck.value,\n )\n\n const mcpServerId = ref<string | null>(null)\n /**\n * Set once THIS card's sign-in went through, and never from a plain read of\n * the connection: a card still asking is the turn saying it could not use\n * that integration, and a token row can outlive its usefulness (a refresh\n * that failed transiently keeps the row, so the turn sees no usable token\n * while a status read still sees one). Trusting the read there would have\n * left the card claiming success, with no button, on a turn still waiting.\n * It doubles as the guard that resumes the turn exactly once, whichever\n * channel got there first.\n */\n const hasConnected = ref(false)\n /** A sign-in window we opened is still out there. */\n const isSigningIn = ref(false)\n const oauthError = ref<string | null>(null)\n\n const isDone = computed(\n () => hasConnected.value || isConnectedByOutput.value,\n )\n const canConnect = computed(\n () => Boolean(serverName.value) && Boolean(props.resolveConnection),\n )\n\n /**\n * Whether the server says this user has connected, asked without minting\n * anything: no OAuth `state` is burned by looking.\n */\n async function isConnectedNow(): Promise<boolean> {\n if (!serverName.value || !props.checkConnection) {\n return false\n }\n try {\n const status = await props.checkConnection(serverName.value)\n mcpServerId.value = status.mcpServerId\n return status.connected\n } catch {\n // Not knowing is not an error to show: the sign-in window is still\n // out there and the next read may well answer.\n return false\n }\n }\n\n let pollTimer: ReturnType<typeof setTimeout> | undefined\n /**\n * Which sign-in a running tick belongs to. A tick suspended on its read\n * outlives the attempt that scheduled it: without this it woke up inside\n * the NEXT attempt, restarted its own chain over that one's timer and then\n * stopped it on its own older deadline.\n */\n let signInAttempt = 0\n /** The window this attempt opened, the only sender we accept a report from. */\n let signInWindow: Window | null = null\n\n function stopWatching() {\n if (pollTimer !== undefined) {\n clearTimeout(pollTimer)\n pollTimer = undefined\n }\n signInAttempt += 1\n signInWindow = null\n isSigningIn.value = false\n }\n\n function settleConnected(connectedServerId: string) {\n stopWatching()\n if (hasConnected.value) {\n return\n }\n hasConnected.value = true\n mcpServerId.value = connectedServerId\n oauthError.value = null\n emit('connected', connectedServerId)\n }\n\n /**\n * Watches the connection from THIS window while the sign-in window is away.\n *\n * The callback page reports through `window.opener`, and a provider that\n * sends `Cross-Origin-Opener-Policy` anywhere in its redirect chain takes\n * that opener away: the connection then succeeds with nobody listening, the\n * card stays on its button and the suspended turn is never resumed\n * (reported 2026-08-27). This channel never goes through that window, so it\n * survives whatever the provider does to it. Chained rather than periodic:\n * a read slower than the interval would otherwise overlap the next one.\n */\n function watchForConnection(popup: Window) {\n stopWatching()\n const attempt = signInAttempt\n signInWindow = popup\n isSigningIn.value = true\n const deadline = Date.now() + POLL_TIMEOUT_MS\n const tick = async () => {\n if (attempt !== signInAttempt || Date.now() > deadline) {\n if (attempt === signInAttempt) {\n stopWatching()\n }\n return\n }\n const connected = await isConnectedNow()\n if (attempt !== signInAttempt) {\n return\n }\n if (connected && mcpServerId.value) {\n settleConnected(mcpServerId.value)\n return\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n\n /**\n * The callback page's own report, when the browser let it through: faster\n * than the poll, and the only channel carrying the failure reason.\n *\n * Accepted only as {@link isMcpOAuthReport} says, and only while that\n * sign-in is out: the listener stays up for as long as the card is on\n * screen, and nothing else with a handle on this page may resume a turn by\n * posting a message at it.\n */\n function onMessage(event: MessageEvent) {\n if (\n !isSigningIn.value ||\n !isMcpOAuthReport(event, signInWindow, props.backendUrl)\n ) {\n return\n }\n const reportedServerId = event.data.mcpServerId as string | undefined\n if (\n reportedServerId &&\n mcpServerId.value &&\n reportedServerId !== mcpServerId.value\n ) {\n return\n }\n if (!event.data.success) {\n // A failure carries no server id: the callback never got that far.\n stopWatching()\n oauthError.value = event.data.error ?? 'Unknown error'\n return\n }\n const connectedServerId = reportedServerId ?? mcpServerId.value\n if (connectedServerId) {\n settleConnected(connectedServerId)\n }\n }\n\n /**\n * Opens the provider's sign-in, on an authorize URL minted NOW.\n *\n * The URL carries an OAuth `state` that lives ten minutes server-side.\n * Minted when the card rendered, it was routinely expired by the time\n * anyone clicked, and the callback then failed on a sign-in the user had\n * just completed. The window is opened blank first, synchronously, or the\n * popup blocker kills it while we wait for the URL.\n */\n async function openAuthWindow() {\n if (\n !serverName.value ||\n !props.resolveConnection ||\n isSigningIn.value\n ) {\n return\n }\n oauthError.value = null\n const popup = window.open(\n '',\n 'mcp_oauth',\n 'width=600,height=700,menubar=no,toolbar=no',\n )\n if (!popup) {\n oauthError.value = $t('auth.popupBlocked')\n return\n }\n watchForConnection(popup)\n try {\n const connection = await props.resolveConnection(serverName.value)\n mcpServerId.value = connection.mcpServerId\n popup.location.href = connection.authorizeUrl\n } catch (err) {\n stopWatching()\n popup.close()\n oauthError.value =\n err instanceof Error ? err.message : 'Failed to resolve OAuth'\n }\n }\n\n // For the card's whole life, not just between the click and the answer: a\n // card that re-renders while the sign-in window is away used to lose the\n // listener with it, and the completion landed on nobody.\n onMounted(() => window.addEventListener('message', onMessage))\n onUnmounted(() => {\n window.removeEventListener('message', onMessage)\n stopWatching()\n })\n</script>\n\n<template>\n <!-- The same frame and header as the other tool cards: this was the only\n one drawing itself as a tinted box (DESIGN.md). -->\n <div\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface text-12\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon name=\"ri:link\" class=\"text-16 shrink-0\" />\n <strong class=\"truncate\">{{ serverName }}</strong>\n </div>\n <div class=\"p-sm\">\n <!-- Connected: just now, or by this card on an earlier visit -->\n <template v-if=\"isDone\">\n <div class=\"flex items-center gap-8\">\n <VvIcon name=\"ri:check-line\" class=\"text-16 text-success\" />\n <strong class=\"font-medium text-word-1\">\n {{\n $t('messagePart.requestOAuthConnectionSuccess', {\n name: serverName,\n })\n }}\n </strong>\n </div>\n </template>\n\n <!-- Signing in: the window is out and we are watching for it -->\n <template v-else-if=\"isSigningIn\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"loading-loop\" />\n <span class=\"text-10\">{{\n $t('messagePart.requestOAuthConnection')\n }}</span>\n </div>\n </template>\n\n <!-- OAuth error -->\n <template v-else-if=\"oauthError\">\n <div class=\"flex flex-col gap-xs\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:close-line\" class=\"text-danger\" />\n <strong class=\"text-10\">\n {{ oauthError }}\n </strong>\n </div>\n <VvButton\n v-if=\"canConnect\"\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </div>\n </template>\n\n <!-- Waiting on the user: show the connect button -->\n <template v-else-if=\"isAwaitingConnection && canConnect\">\n <div class=\"flex items-center gap-6 text-word-3 mb-xs\">\n <span>\n {{\n $t('messagePart.requestOAuthConnectionPrompt', {\n name: serverName,\n })\n }}\n </span>\n </div>\n <VvButton\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </template>\n <!-- Fallback for unknown state -->\n <template v-else>\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:link\" />\n <span class=\"text-10\">\n {{\n $t('messagePart.requestOAuthConnectionInfo', {\n name: serverName,\n })\n }}\n </span>\n </div>\n </template>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed, onMounted, onUnmounted, ref } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { isVoiceRenderAck } from 'models'\n import { isMcpOAuthReport } from './mcpOAuthReport'\n\n const props = defineProps<{\n part: unknown\n /**\n * The backend the chat talks to, where the sign-in's callback page\n * runs. Without it the card hears no report and relies on its poll.\n */\n backendUrl?: string\n resolveConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; authorizeUrl: string }>\n checkConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; connected: boolean }>\n }>()\n\n const emit = defineEmits<{\n connected: [mcpServerId: string]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n /** How often the connection is re-read while the sign-in window is out. */\n const POLL_INTERVAL_MS = 2000\n /**\n * How long we keep asking. The only end to a sign-in nobody finishes:\n * `popup.closed` cannot be that signal, because the browser disowns the\n * handle when the provider severs the opener (that is what\n * `Cross-Origin-Opener-Policy` does), so it reads as closed from the first\n * check of the very flow this watch exists for. Long enough for a password\n * manager and a second factor.\n */\n const POLL_TIMEOUT_MS = 5 * 60 * 1000\n\n const toolPart = computed(() => {\n return props.part as {\n state?: string\n toolCallId?: string\n input?: { serverName: string }\n output?: unknown\n }\n })\n\n const state = computed(() => toolPart.value.state ?? 'unknown')\n const serverName = computed(() => toolPart.value.input?.serverName)\n\n /**\n * A card drawn during a CALL arrives already \"answered\": the turn could\n * not wait for the connection, so the backend closed the tool with a note\n * saying the card was drawn (see `isVoiceRenderAck`, same rule as the\n * forms). That note is not a connection, and without this the card\n * rendered its inert fallback: the caller was told to connect the account\n * and given nothing to click (measured 2026-08-07).\n */\n const isRenderAck = computed(() => isVoiceRenderAck(toolPart.value.output))\n\n /** The output this card wrote itself once the connection went through. */\n const isConnectedByOutput = computed(\n () =>\n (toolPart.value.output as { connected?: unknown } | undefined)\n ?.connected === true,\n )\n\n const isAwaitingConnection = computed(\n () => state.value === 'input-available' || isRenderAck.value,\n )\n\n const mcpServerId = ref<string | null>(null)\n /**\n * Set once THIS card's sign-in went through, and never from a plain read of\n * the connection: a card still asking is the turn saying it could not use\n * that integration, and a token row can outlive its usefulness (a refresh\n * that failed transiently keeps the row, so the turn sees no usable token\n * while a status read still sees one). Trusting the read there would have\n * left the card claiming success, with no button, on a turn still waiting.\n * It doubles as the guard that resumes the turn exactly once, whichever\n * channel got there first.\n */\n const hasConnected = ref(false)\n /** A sign-in window we opened is still out there. */\n const isSigningIn = ref(false)\n const oauthError = ref<string | null>(null)\n\n const isDone = computed(\n () => hasConnected.value || isConnectedByOutput.value,\n )\n const canConnect = computed(\n () => Boolean(serverName.value) && Boolean(props.resolveConnection),\n )\n\n /**\n * Whether the server says this user has connected, asked without minting\n * anything: no OAuth `state` is burned by looking.\n */\n async function isConnectedNow(): Promise<boolean> {\n if (!serverName.value || !props.checkConnection) {\n return false\n }\n try {\n const status = await props.checkConnection(serverName.value)\n mcpServerId.value = status.mcpServerId\n return status.connected\n } catch {\n // Not knowing is not an error to show: the sign-in window is still\n // out there and the next read may well answer.\n return false\n }\n }\n\n let pollTimer: ReturnType<typeof setTimeout> | undefined\n /**\n * Which sign-in a running tick belongs to. A tick suspended on its read\n * outlives the attempt that scheduled it: without this it woke up inside\n * the NEXT attempt, restarted its own chain over that one's timer and then\n * stopped it on its own older deadline.\n */\n let signInAttempt = 0\n /** The window this attempt opened, the only sender we accept a report from. */\n let signInWindow: Window | null = null\n\n function stopWatching() {\n if (pollTimer !== undefined) {\n clearTimeout(pollTimer)\n pollTimer = undefined\n }\n signInAttempt += 1\n signInWindow = null\n isSigningIn.value = false\n }\n\n function settleConnected(connectedServerId: string) {\n stopWatching()\n if (hasConnected.value) {\n return\n }\n hasConnected.value = true\n mcpServerId.value = connectedServerId\n oauthError.value = null\n emit('connected', connectedServerId)\n }\n\n /**\n * Watches the connection from THIS window while the sign-in window is away.\n *\n * The callback page reports through `window.opener`, and a provider that\n * sends `Cross-Origin-Opener-Policy` anywhere in its redirect chain takes\n * that opener away: the connection then succeeds with nobody listening, the\n * card stays on its button and the suspended turn is never resumed\n * (reported 2026-08-27). This channel never goes through that window, so it\n * survives whatever the provider does to it. Chained rather than periodic:\n * a read slower than the interval would otherwise overlap the next one.\n */\n function watchForConnection(popup: Window) {\n stopWatching()\n const attempt = signInAttempt\n signInWindow = popup\n isSigningIn.value = true\n const deadline = Date.now() + POLL_TIMEOUT_MS\n const tick = async () => {\n if (attempt !== signInAttempt || Date.now() > deadline) {\n if (attempt === signInAttempt) {\n stopWatching()\n }\n return\n }\n const connected = await isConnectedNow()\n if (attempt !== signInAttempt) {\n return\n }\n if (connected && mcpServerId.value) {\n settleConnected(mcpServerId.value)\n return\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n\n /**\n * The callback page's own report, when the browser let it through: faster\n * than the poll, and the only channel carrying the failure reason.\n *\n * Accepted only as {@link isMcpOAuthReport} says, and only while that\n * sign-in is out: the listener stays up for as long as the card is on\n * screen, and nothing else with a handle on this page may resume a turn by\n * posting a message at it.\n */\n function onMessage(event: MessageEvent) {\n if (\n !isSigningIn.value ||\n !isMcpOAuthReport(event, signInWindow, props.backendUrl)\n ) {\n return\n }\n const reportedServerId = event.data.mcpServerId as string | undefined\n if (\n reportedServerId &&\n mcpServerId.value &&\n reportedServerId !== mcpServerId.value\n ) {\n return\n }\n if (!event.data.success) {\n // A failure carries no server id: the callback never got that far.\n stopWatching()\n oauthError.value = event.data.error ?? 'Unknown error'\n return\n }\n const connectedServerId = reportedServerId ?? mcpServerId.value\n if (connectedServerId) {\n settleConnected(connectedServerId)\n }\n }\n\n /**\n * Opens the provider's sign-in, on an authorize URL minted NOW.\n *\n * The URL carries an OAuth `state` that lives ten minutes server-side.\n * Minted when the card rendered, it was routinely expired by the time\n * anyone clicked, and the callback then failed on a sign-in the user had\n * just completed. The window is opened blank first, synchronously, or the\n * popup blocker kills it while we wait for the URL.\n */\n async function openAuthWindow() {\n if (\n !serverName.value ||\n !props.resolveConnection ||\n isSigningIn.value\n ) {\n return\n }\n oauthError.value = null\n const popup = window.open(\n '',\n 'mcp_oauth',\n 'width=600,height=700,menubar=no,toolbar=no',\n )\n if (!popup) {\n oauthError.value = $t('auth.popupBlocked')\n return\n }\n watchForConnection(popup)\n try {\n const connection = await props.resolveConnection(serverName.value)\n mcpServerId.value = connection.mcpServerId\n popup.location.href = connection.authorizeUrl\n } catch (err) {\n stopWatching()\n popup.close()\n oauthError.value =\n err instanceof Error ? err.message : 'Failed to resolve OAuth'\n }\n }\n\n // For the card's whole life, not just between the click and the answer: a\n // card that re-renders while the sign-in window is away used to lose the\n // listener with it, and the completion landed on nobody.\n onMounted(() => window.addEventListener('message', onMessage))\n onUnmounted(() => {\n window.removeEventListener('message', onMessage)\n stopWatching()\n })\n</script>\n\n<template>\n <!-- The same frame and header as the other tool cards: this was the only\n one drawing itself as a tinted box (DESIGN.md). -->\n <div\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface text-12\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon name=\"ri:link\" class=\"text-16 shrink-0\" />\n <strong class=\"truncate\">{{ serverName }}</strong>\n </div>\n <div class=\"p-sm\">\n <!-- Connected: just now, or by this card on an earlier visit -->\n <template v-if=\"isDone\">\n <div class=\"flex items-center gap-8\">\n <VvIcon name=\"ri:check-line\" class=\"text-16 text-success\" />\n <strong class=\"font-medium text-word-1\">\n {{\n $t('messagePart.requestOAuthConnectionSuccess', {\n name: serverName,\n })\n }}\n </strong>\n </div>\n </template>\n\n <!-- Signing in: the window is out and we are watching for it -->\n <template v-else-if=\"isSigningIn\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"loading-loop\" />\n <span class=\"text-10\">{{\n $t('messagePart.requestOAuthConnection')\n }}</span>\n </div>\n </template>\n\n <!-- OAuth error -->\n <template v-else-if=\"oauthError\">\n <div class=\"flex flex-col gap-xs\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:close-line\" class=\"text-danger\" />\n <strong class=\"text-10\">\n {{ oauthError }}\n </strong>\n </div>\n <VvButton\n v-if=\"canConnect\"\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </div>\n </template>\n\n <!-- Waiting on the user: show the connect button -->\n <template v-else-if=\"isAwaitingConnection && canConnect\">\n <div class=\"flex items-center gap-6 text-word-3 mb-xs\">\n <span>\n {{\n $t('messagePart.requestOAuthConnectionPrompt', {\n name: serverName,\n })\n }}\n </span>\n </div>\n <VvButton\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </template>\n <!-- Fallback for unknown state -->\n <template v-else>\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:link\" />\n <span class=\"text-10\">\n {{\n $t('messagePart.requestOAuthConnectionInfo', {\n name: serverName,\n })\n }}\n </span>\n </div>\n </template>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;A,6BA4BU4B,IAAmB,KASnBC,IAAkB,K;;;;;;;;;;EA/BxB,IAAMI,IAAQC,GAeRC,IAAOH,GAIP,EAAE,GAAGI,MAAOC,EAAQ,EAAE,UAAU,SAAS,CAAC,GAc1CC,IAAWC,QACNN,EAAM,IAMhB,GAEKO,IAAQD,QAAeD,EAAS,MAAM,SAAS,SAAS,GACxDG,IAAaF,QAAeD,EAAS,MAAM,OAAO,UAAU,GAU5DI,IAAcH,QAAe3B,EAAiB0B,EAAS,MAAM,MAAM,CAAC,GAGpEK,IAAsBJ,QAEnBD,EAAS,MAAM,QACV,cAAc,EAC5B,GAEMM,IAAuBL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,GAMOrB,EAJCC,EAAA6B,CAAA,CAAE,CAAA,0CAAA,EAAmF,MAAAK,EAAA,M"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-CGnMp29N.js";
|
|
2
2
|
import { t } from "./VvButtonLocalized-C-vx25u4.js";
|
|
3
|
-
import { t as n } from "./PkStreamingMarkdown-
|
|
3
|
+
import { t as n } from "./PkStreamingMarkdown-ZasabxE0.js";
|
|
4
4
|
import { computed as r, createBlock as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, normalizeClass as u, openBlock as d, ref as f, toDisplayString as p, unref as m, watch as h } from "vue";
|
|
5
5
|
import { useClipboard as g } from "@vueuse/core";
|
|
6
6
|
// ../../packages/components/src/chat/PkCode.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -88,4 +88,4 @@ var _ = ["innerHTML"], v = /* @__PURE__ */ l({
|
|
|
88
88
|
}), T = /* @__PURE__ */ e({ default: () => E }), E = w;
|
|
89
89
|
export { T as n, v as r, E as t };
|
|
90
90
|
|
|
91
|
-
//# sourceMappingURL=PkToolShowArtifact-
|
|
91
|
+
//# sourceMappingURL=PkToolShowArtifact-BhVd_ZQ8.js.map
|
package/dist-vue/_chunks/{PkToolShowArtifact-C8ueuIGQ.js.map → PkToolShowArtifact-BhVd_ZQ8.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolShowArtifact-C8ueuIGQ.js","names":["$attrs","_hoisted_1","_openBlock","_createElementBlock","_normalizeClass","_createTextVNode","_createElementVNode","_sfc_main","$t","__unplugin_components_0","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","_unref","_createBlock","PkCode","PkStreamingMarkdown","_normalizeClass","_sfc_main","__exportAll","PkStreamingMarkdown_default","_hoisted_1$1","PkCode_default","defineComponent","props","__props","highlightedHtml","ref","hasCode","computed","highlight","hljs","result","watch","openBlock","createElementBlock","normalizeClass","_ctx","_cache","createTextVNode","createElementVNode","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","PkToolShowArtifact_vue_vue_type_script_setup_true_lang_default","useClipboard","toolPart","artifactTypeLabel","languageLabel","isCodeType","isMarkdownType","codeLanguage","_component_VvButton","VvButtonLocalized","toDisplayString","createVNode","unref","copied","copy","createBlock","PkToolShowArtifact_exports","PkToolShowArtifact_default"],"sources":["../../../../packages/components/src/chat/PkCode.vue","../../../../packages/components/src/chat/PkCode.vue","../../../../packages/components/src/chat/PkToolShowArtifact.vue","../../../../packages/components/src/chat/PkToolShowArtifact.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref, watch } from 'vue'\n\n defineOptions({\n inheritAttrs: false,\n })\n\n const props = defineProps<{\n code: unknown\n language: string\n line?: boolean\n }>()\n\n const highlightedHtml = ref('')\n\n const hasCode = computed(() => {\n if (typeof props.code === 'string') {\n return props.code\n }\n return JSON.stringify(props.code, null, 2)\n })\n\n async function highlight() {\n const hljs = (await import('highlight.js/lib/common')).default\n try {\n const result = props.language\n ? hljs.highlight(hasCode.value, { language: props.language })\n : hljs.highlightAuto(hasCode.value)\n highlightedHtml.value = result.value\n } catch {\n highlightedHtml.value = hasCode.value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n }\n }\n\n watch(hasCode, highlight, { immediate: true })\n</script>\n\n<template>\n <pre\n :class=\"\n $attrs.class\n ? $attrs.class\n : 'font-mono leading-snug text-smaller bg-surface-1'\n \">\n <code :class=\"['hljs', line ? 'whitespace-pre-line' : 'whitespace-pre', language]\" v-html=\"highlightedHtml\"></code>\n </pre>\n</template>\n","<script setup lang=\"ts\">\n import { computed, ref, watch } from 'vue'\n\n defineOptions({\n inheritAttrs: false,\n })\n\n const props = defineProps<{\n code: unknown\n language: string\n line?: boolean\n }>()\n\n const highlightedHtml = ref('')\n\n const hasCode = computed(() => {\n if (typeof props.code === 'string') {\n return props.code\n }\n return JSON.stringify(props.code, null, 2)\n })\n\n async function highlight() {\n const hljs = (await import('highlight.js/lib/common')).default\n try {\n const result = props.language\n ? hljs.highlight(hasCode.value, { language: props.language })\n : hljs.highlightAuto(hasCode.value)\n highlightedHtml.value = result.value\n } catch {\n highlightedHtml.value = hasCode.value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n }\n }\n\n watch(hasCode, highlight, { immediate: true })\n</script>\n\n<template>\n <pre\n :class=\"\n $attrs.class\n ? $attrs.class\n : 'font-mono leading-snug text-smaller bg-surface-1'\n \">\n <code :class=\"['hljs', line ? 'whitespace-pre-line' : 'whitespace-pre', language]\" v-html=\"highlightedHtml\"></code>\n </pre>\n</template>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import PkCode from './PkCode.vue'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n\n const { copy, copied } = useClipboard()\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n title: string\n content: string\n artifactType: string\n language?: string\n }\n }\n return part\n })\n\n const artifactTypeLabel = computed(() => {\n const labels: Record<string, string> = {\n code: 'Code',\n document: 'Document',\n markdown: 'Markdown',\n json: 'JSON',\n xml: 'XML',\n csv: 'CSV',\n html: 'HTML',\n yaml: 'YAML',\n sql: 'SQL',\n text: 'Text',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'Artifact'\n }\n return labels[toolPart.value.input.artifactType] || 'Artifact'\n })\n\n const languageLabel = computed(() => {\n if (!toolPart.value.input?.language) {\n return ''\n }\n return ` (${toolPart.value.input.language})`\n })\n\n const isCodeType = computed(() => {\n return (\n toolPart.value.input?.artifactType === 'code' ||\n toolPart.value.input?.artifactType === 'json' ||\n toolPart.value.input?.artifactType === 'xml' ||\n toolPart.value.input?.artifactType === 'yaml' ||\n toolPart.value.input?.artifactType === 'html' ||\n toolPart.value.input?.artifactType === 'sql'\n )\n })\n\n const isMarkdownType = computed(() => {\n return toolPart.value.input?.artifactType === 'markdown'\n })\n\n const codeLanguage = computed(() => {\n if (toolPart.value.input?.language) {\n return toolPart.value.input.language\n }\n // Map artifact types to highlight.js languages\n const languageMap: Record<string, string> = {\n json: 'json',\n xml: 'xml',\n yaml: 'yaml',\n html: 'html',\n sql: 'sql',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'plaintext'\n }\n return languageMap[toolPart.value.input.artifactType] || 'plaintext'\n })\n</script>\n\n<template>\n <div class=\"border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 font-bold bg-surface-1 text-12 border-b border-surface-3 text-word-3 flex justify-between items-center\">\n <div class=\"flex flex-col items-start gap-4\">\n <span>{{ toolPart?.input?.title }}</span>\n <span class=\"text-10 opacity-60 font-normal\">\n {{ artifactTypeLabel }}{{ languageLabel }}\n </span>\n </div>\n <VvButton\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n modifiers=\"action-quiet-small\"\n :title=\"$t('action.copy')\"\n class=\"shrink-0\"\n @click=\"copy(toolPart?.input?.content || '')\" />\n </div>\n <div class=\"px-sm py-10 bg-surface\">\n <PkCode\n v-if=\"isCodeType\"\n :code=\"toolPart?.input?.content\"\n :language=\"codeLanguage\" />\n <PkStreamingMarkdown\n v-else-if=\"isMarkdownType\"\n :markdown=\"toolPart?.input?.content\"\n class=\"wysiwyg text-word-2\" />\n <pre\n v-else\n class=\"text-word-2 whitespace-pre-wrap break-words\"\n :class=\"{\n italic:\n toolPart?.input?.artifactType === 'document' ||\n toolPart?.input?.artifactType === 'text',\n }\"\n >{{ toolPart?.input?.content }}</pre>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import PkCode from './PkCode.vue'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n\n const { copy, copied } = useClipboard()\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n title: string\n content: string\n artifactType: string\n language?: string\n }\n }\n return part\n })\n\n const artifactTypeLabel = computed(() => {\n const labels: Record<string, string> = {\n code: 'Code',\n document: 'Document',\n markdown: 'Markdown',\n json: 'JSON',\n xml: 'XML',\n csv: 'CSV',\n html: 'HTML',\n yaml: 'YAML',\n sql: 'SQL',\n text: 'Text',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'Artifact'\n }\n return labels[toolPart.value.input.artifactType] || 'Artifact'\n })\n\n const languageLabel = computed(() => {\n if (!toolPart.value.input?.language) {\n return ''\n }\n return ` (${toolPart.value.input.language})`\n })\n\n const isCodeType = computed(() => {\n return (\n toolPart.value.input?.artifactType === 'code' ||\n toolPart.value.input?.artifactType === 'json' ||\n toolPart.value.input?.artifactType === 'xml' ||\n toolPart.value.input?.artifactType === 'yaml' ||\n toolPart.value.input?.artifactType === 'html' ||\n toolPart.value.input?.artifactType === 'sql'\n )\n })\n\n const isMarkdownType = computed(() => {\n return toolPart.value.input?.artifactType === 'markdown'\n })\n\n const codeLanguage = computed(() => {\n if (toolPart.value.input?.language) {\n return toolPart.value.input.language\n }\n // Map artifact types to highlight.js languages\n const languageMap: Record<string, string> = {\n json: 'json',\n xml: 'xml',\n yaml: 'yaml',\n html: 'html',\n sql: 'sql',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'plaintext'\n }\n return languageMap[toolPart.value.input.artifactType] || 'plaintext'\n })\n</script>\n\n<template>\n <div class=\"border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 font-bold bg-surface-1 text-12 border-b border-surface-3 text-word-3 flex justify-between items-center\">\n <div class=\"flex flex-col items-start gap-4\">\n <span>{{ toolPart?.input?.title }}</span>\n <span class=\"text-10 opacity-60 font-normal\">\n {{ artifactTypeLabel }}{{ languageLabel }}\n </span>\n </div>\n <VvButton\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n modifiers=\"action-quiet-small\"\n :title=\"$t('action.copy')\"\n class=\"shrink-0\"\n @click=\"copy(toolPart?.input?.content || '')\" />\n </div>\n <div class=\"px-sm py-10 bg-surface\">\n <PkCode\n v-if=\"isCodeType\"\n :code=\"toolPart?.input?.content\"\n :language=\"codeLanguage\" />\n <PkStreamingMarkdown\n v-else-if=\"isMarkdownType\"\n :markdown=\"toolPart?.input?.content\"\n class=\"wysiwyg text-word-2\" />\n <pre\n v-else\n class=\"text-word-2 whitespace-pre-wrap break-words\"\n :class=\"{\n italic:\n toolPart?.input?.artifactType === 'document' ||\n toolPart?.input?.artifactType === 'text',\n }\"\n >{{ toolPart?.input?.content }}</pre>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;EAOI,IAAM0B,IAAQC,GAMRC,IAAkBC,EAAI,EAAE,GAExBC,IAAUC,QACR,OAAOL,EAAM,QAAS,WACfA,EAAM,OAEV,KAAK,UAAUA,EAAM,MAAM,MAAM,CAAC,CAC5C;EAED,eAAeM,IAAY;GACvB,IAAMC,KAAQ,MAAM,OAAO,2BAAA,CAA4B;GACvD,IAAI;IACA,IAAMC,IAASR,EAAM,WACfO,EAAK,UAAUH,EAAQ,OAAO,EAAE,UAAUJ,EAAM,SAAS,CAAC,IAC1DO,EAAK,cAAcH,EAAQ,KAAK;IACtC,EAAgB,QAAQI,EAAO;GACnC,QAAQ;IACJ,EAAgB,QAAQJ,EAAQ,MAC3B,QAAQ,MAAM,OAAO,CAAA,CACrB,QAAQ,MAAM,MAAM,CAAA,CACpB,QAAQ,MAAM,MAAM;GAC7B;EACJ;E,OAEAK,EAAML,GAASE,GAAW,EAAE,WAAW,GAAK,CAAC,I,UAI7C9B,EAAA,GAAAC,EAOM,OAAA,EAND,OAAKC,EAAeJ,EAAAA,OAAO,QAAwBA,EAAAA,OAAO,Q;GAIzD,AAAAwC,EAAA,OAAAnC,EAAA,YACF,EAAA;GAAAC,EAAmH,QAAA;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AFPkC,GAEOjC,EADAsC,EAAA,KAAiB,IAAAtC,EAAMuC,EAAA,KAAa,GAAA,CAAA,C,IAG/CtC,EAMoD0C,GAAA;IAL/C,MAAMzC,EAAA8C,CAAA,IAAM,kBAAA;IACZ,OAAO9C,EAAA8C,CAAA,IAASrD,EAAAA,GAAE,eAAA,IAAoBA,EAAAA,GAAE,aAAA;IACzC,WAAU;IACT,OAAOA,EAAAA,GAAE,aAAA;IACV,OAAM;IACL,SAAK,AAAAgC,EAAA,QAAA,MAAEzB,EAAA+C,CAAA,CAAI,CAACZ,EAAA,OAAU,OAAO,WAAO,EAAA;;;;;G,MAE7CtC,EAkBM,OAlBNmC,GAkBM,CAhBQM,EAAA,SADV3C,EAAA,GAAAM,EAG+BC,GAAA;;IAD1B,MAAMiC,EAAA,OAAU,OAAO;IACvB,UAAUK,EAAA;G,qCAEAD,EAAA,SADf5C,EAAA,GAAAM,EAGkCE,GAAA;;IAD7B,UAAUgC,EAAA,OAAU,OAAO;IAC5B,OAAM;G,8BACVxC,EAAA,GAAAC,EAQyC,OAAA;;IANrC,OAAKQ,EAAA,CAAC,+CAA6C,E,QACW+B,EAAA,OAAU,OAAO,iBAAY,cAA2CA,EAAA,OAAU,OAAO,iBAAY,O;GAK/J,GAAArC,EAAAqC,EAAA,OAAU,OAAO,OAAO,GAAA,CAAA,E"}
|
|
1
|
+
{"version":3,"file":"PkToolShowArtifact-BhVd_ZQ8.js","names":["$attrs","_hoisted_1","_openBlock","_createElementBlock","_normalizeClass","_createTextVNode","_createElementVNode","_sfc_main","$t","__unplugin_components_0","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","_unref","_createBlock","PkCode","PkStreamingMarkdown","_normalizeClass","_sfc_main","__exportAll","PkStreamingMarkdown_default","_hoisted_1$1","PkCode_default","defineComponent","props","__props","highlightedHtml","ref","hasCode","computed","highlight","hljs","result","watch","openBlock","createElementBlock","normalizeClass","_ctx","_cache","createTextVNode","createElementVNode","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","PkToolShowArtifact_vue_vue_type_script_setup_true_lang_default","useClipboard","toolPart","artifactTypeLabel","languageLabel","isCodeType","isMarkdownType","codeLanguage","_component_VvButton","VvButtonLocalized","toDisplayString","createVNode","unref","copied","copy","createBlock","PkToolShowArtifact_exports","PkToolShowArtifact_default"],"sources":["../../../../packages/components/src/chat/PkCode.vue","../../../../packages/components/src/chat/PkCode.vue","../../../../packages/components/src/chat/PkToolShowArtifact.vue","../../../../packages/components/src/chat/PkToolShowArtifact.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref, watch } from 'vue'\n\n defineOptions({\n inheritAttrs: false,\n })\n\n const props = defineProps<{\n code: unknown\n language: string\n line?: boolean\n }>()\n\n const highlightedHtml = ref('')\n\n const hasCode = computed(() => {\n if (typeof props.code === 'string') {\n return props.code\n }\n return JSON.stringify(props.code, null, 2)\n })\n\n async function highlight() {\n const hljs = (await import('highlight.js/lib/common')).default\n try {\n const result = props.language\n ? hljs.highlight(hasCode.value, { language: props.language })\n : hljs.highlightAuto(hasCode.value)\n highlightedHtml.value = result.value\n } catch {\n highlightedHtml.value = hasCode.value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n }\n }\n\n watch(hasCode, highlight, { immediate: true })\n</script>\n\n<template>\n <pre\n :class=\"\n $attrs.class\n ? $attrs.class\n : 'font-mono leading-snug text-smaller bg-surface-1'\n \">\n <code :class=\"['hljs', line ? 'whitespace-pre-line' : 'whitespace-pre', language]\" v-html=\"highlightedHtml\"></code>\n </pre>\n</template>\n","<script setup lang=\"ts\">\n import { computed, ref, watch } from 'vue'\n\n defineOptions({\n inheritAttrs: false,\n })\n\n const props = defineProps<{\n code: unknown\n language: string\n line?: boolean\n }>()\n\n const highlightedHtml = ref('')\n\n const hasCode = computed(() => {\n if (typeof props.code === 'string') {\n return props.code\n }\n return JSON.stringify(props.code, null, 2)\n })\n\n async function highlight() {\n const hljs = (await import('highlight.js/lib/common')).default\n try {\n const result = props.language\n ? hljs.highlight(hasCode.value, { language: props.language })\n : hljs.highlightAuto(hasCode.value)\n highlightedHtml.value = result.value\n } catch {\n highlightedHtml.value = hasCode.value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n }\n }\n\n watch(hasCode, highlight, { immediate: true })\n</script>\n\n<template>\n <pre\n :class=\"\n $attrs.class\n ? $attrs.class\n : 'font-mono leading-snug text-smaller bg-surface-1'\n \">\n <code :class=\"['hljs', line ? 'whitespace-pre-line' : 'whitespace-pre', language]\" v-html=\"highlightedHtml\"></code>\n </pre>\n</template>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import PkCode from './PkCode.vue'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n\n const { copy, copied } = useClipboard()\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n title: string\n content: string\n artifactType: string\n language?: string\n }\n }\n return part\n })\n\n const artifactTypeLabel = computed(() => {\n const labels: Record<string, string> = {\n code: 'Code',\n document: 'Document',\n markdown: 'Markdown',\n json: 'JSON',\n xml: 'XML',\n csv: 'CSV',\n html: 'HTML',\n yaml: 'YAML',\n sql: 'SQL',\n text: 'Text',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'Artifact'\n }\n return labels[toolPart.value.input.artifactType] || 'Artifact'\n })\n\n const languageLabel = computed(() => {\n if (!toolPart.value.input?.language) {\n return ''\n }\n return ` (${toolPart.value.input.language})`\n })\n\n const isCodeType = computed(() => {\n return (\n toolPart.value.input?.artifactType === 'code' ||\n toolPart.value.input?.artifactType === 'json' ||\n toolPart.value.input?.artifactType === 'xml' ||\n toolPart.value.input?.artifactType === 'yaml' ||\n toolPart.value.input?.artifactType === 'html' ||\n toolPart.value.input?.artifactType === 'sql'\n )\n })\n\n const isMarkdownType = computed(() => {\n return toolPart.value.input?.artifactType === 'markdown'\n })\n\n const codeLanguage = computed(() => {\n if (toolPart.value.input?.language) {\n return toolPart.value.input.language\n }\n // Map artifact types to highlight.js languages\n const languageMap: Record<string, string> = {\n json: 'json',\n xml: 'xml',\n yaml: 'yaml',\n html: 'html',\n sql: 'sql',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'plaintext'\n }\n return languageMap[toolPart.value.input.artifactType] || 'plaintext'\n })\n</script>\n\n<template>\n <div class=\"border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 font-bold bg-surface-1 text-12 border-b border-surface-3 text-word-3 flex justify-between items-center\">\n <div class=\"flex flex-col items-start gap-4\">\n <span>{{ toolPart?.input?.title }}</span>\n <span class=\"text-10 opacity-60 font-normal\">\n {{ artifactTypeLabel }}{{ languageLabel }}\n </span>\n </div>\n <VvButton\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n modifiers=\"action-quiet-small\"\n :title=\"$t('action.copy')\"\n class=\"shrink-0\"\n @click=\"copy(toolPart?.input?.content || '')\" />\n </div>\n <div class=\"px-sm py-10 bg-surface\">\n <PkCode\n v-if=\"isCodeType\"\n :code=\"toolPart?.input?.content\"\n :language=\"codeLanguage\" />\n <PkStreamingMarkdown\n v-else-if=\"isMarkdownType\"\n :markdown=\"toolPart?.input?.content\"\n class=\"wysiwyg text-word-2\" />\n <pre\n v-else\n class=\"text-word-2 whitespace-pre-wrap break-words\"\n :class=\"{\n italic:\n toolPart?.input?.artifactType === 'document' ||\n toolPart?.input?.artifactType === 'text',\n }\"\n >{{ toolPart?.input?.content }}</pre>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import PkCode from './PkCode.vue'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n\n const { copy, copied } = useClipboard()\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n title: string\n content: string\n artifactType: string\n language?: string\n }\n }\n return part\n })\n\n const artifactTypeLabel = computed(() => {\n const labels: Record<string, string> = {\n code: 'Code',\n document: 'Document',\n markdown: 'Markdown',\n json: 'JSON',\n xml: 'XML',\n csv: 'CSV',\n html: 'HTML',\n yaml: 'YAML',\n sql: 'SQL',\n text: 'Text',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'Artifact'\n }\n return labels[toolPart.value.input.artifactType] || 'Artifact'\n })\n\n const languageLabel = computed(() => {\n if (!toolPart.value.input?.language) {\n return ''\n }\n return ` (${toolPart.value.input.language})`\n })\n\n const isCodeType = computed(() => {\n return (\n toolPart.value.input?.artifactType === 'code' ||\n toolPart.value.input?.artifactType === 'json' ||\n toolPart.value.input?.artifactType === 'xml' ||\n toolPart.value.input?.artifactType === 'yaml' ||\n toolPart.value.input?.artifactType === 'html' ||\n toolPart.value.input?.artifactType === 'sql'\n )\n })\n\n const isMarkdownType = computed(() => {\n return toolPart.value.input?.artifactType === 'markdown'\n })\n\n const codeLanguage = computed(() => {\n if (toolPart.value.input?.language) {\n return toolPart.value.input.language\n }\n // Map artifact types to highlight.js languages\n const languageMap: Record<string, string> = {\n json: 'json',\n xml: 'xml',\n yaml: 'yaml',\n html: 'html',\n sql: 'sql',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'plaintext'\n }\n return languageMap[toolPart.value.input.artifactType] || 'plaintext'\n })\n</script>\n\n<template>\n <div class=\"border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 font-bold bg-surface-1 text-12 border-b border-surface-3 text-word-3 flex justify-between items-center\">\n <div class=\"flex flex-col items-start gap-4\">\n <span>{{ toolPart?.input?.title }}</span>\n <span class=\"text-10 opacity-60 font-normal\">\n {{ artifactTypeLabel }}{{ languageLabel }}\n </span>\n </div>\n <VvButton\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n modifiers=\"action-quiet-small\"\n :title=\"$t('action.copy')\"\n class=\"shrink-0\"\n @click=\"copy(toolPart?.input?.content || '')\" />\n </div>\n <div class=\"px-sm py-10 bg-surface\">\n <PkCode\n v-if=\"isCodeType\"\n :code=\"toolPart?.input?.content\"\n :language=\"codeLanguage\" />\n <PkStreamingMarkdown\n v-else-if=\"isMarkdownType\"\n :markdown=\"toolPart?.input?.content\"\n class=\"wysiwyg text-word-2\" />\n <pre\n v-else\n class=\"text-word-2 whitespace-pre-wrap break-words\"\n :class=\"{\n italic:\n toolPart?.input?.artifactType === 'document' ||\n toolPart?.input?.artifactType === 'text',\n }\"\n >{{ toolPart?.input?.content }}</pre>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;EAOI,IAAM0B,IAAQC,GAMRC,IAAkBC,EAAI,EAAE,GAExBC,IAAUC,QACR,OAAOL,EAAM,QAAS,WACfA,EAAM,OAEV,KAAK,UAAUA,EAAM,MAAM,MAAM,CAAC,CAC5C;EAED,eAAeM,IAAY;GACvB,IAAMC,KAAQ,MAAM,OAAO,2BAAA,CAA4B;GACvD,IAAI;IACA,IAAMC,IAASR,EAAM,WACfO,EAAK,UAAUH,EAAQ,OAAO,EAAE,UAAUJ,EAAM,SAAS,CAAC,IAC1DO,EAAK,cAAcH,EAAQ,KAAK;IACtC,EAAgB,QAAQI,EAAO;GACnC,QAAQ;IACJ,EAAgB,QAAQJ,EAAQ,MAC3B,QAAQ,MAAM,OAAO,CAAA,CACrB,QAAQ,MAAM,MAAM,CAAA,CACpB,QAAQ,MAAM,MAAM;GAC7B;EACJ;E,OAEAK,EAAML,GAASE,GAAW,EAAE,WAAW,GAAK,CAAC,I,UAI7C9B,EAAA,GAAAC,EAOM,OAAA,EAND,OAAKC,EAAeJ,EAAAA,OAAO,QAAwBA,EAAAA,OAAO,Q;GAIzD,AAAAwC,EAAA,OAAAnC,EAAA,YACF,EAAA;GAAAC,EAAmH,QAAA;IAA5G,OAAKF,EAAA;KAAA;KAAWuB,E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IAAAtC,EAAMuC,EAAA,KAAa,GAAA,CAAA,C,IAG/CtC,EAMoD0C,GAAA;IAL/C,MAAMzC,EAAA8C,CAAA,IAAM,kBAAA;IACZ,OAAO9C,EAAA8C,CAAA,IAASrD,EAAAA,GAAE,eAAA,IAAoBA,EAAAA,GAAE,aAAA;IACzC,WAAU;IACT,OAAOA,EAAAA,GAAE,aAAA;IACV,OAAM;IACL,SAAK,AAAAgC,EAAA,QAAA,MAAEzB,EAAA+C,CAAA,CAAI,CAACZ,EAAA,OAAU,OAAO,WAAO,EAAA;;;;;G,MAE7CtC,EAkBM,OAlBNmC,GAkBM,CAhBQM,EAAA,SADV3C,EAAA,GAAAM,EAG+BC,GAAA;;IAD1B,MAAMiC,EAAA,OAAU,OAAO;IACvB,UAAUK,EAAA;G,qCAEAD,EAAA,SADf5C,EAAA,GAAAM,EAGkCE,GAAA;;IAD7B,UAAUgC,EAAA,OAAU,OAAO;IAC5B,OAAM;G,8BACVxC,EAAA,GAAAC,EAQyC,OAAA;;IANrC,OAAKQ,EAAA,CAAC,+CAA6C,E,QACW+B,EAAA,OAAU,OAAO,iBAAY,cAA2CA,EAAA,OAAU,OAAO,iBAAY,O;GAK/J,GAAArC,EAAAqC,EAAA,OAAU,OAAO,OAAO,GAAA,CAAA,E"}
|
|
@@ -2,7 +2,7 @@ import { t as e } from "./rolldown-runtime-CGnMp29N.js";
|
|
|
2
2
|
import { S as t, _ as n, o as r, r as i, s as a, v as o } from "./schemas-BO5QlXAp.js";
|
|
3
3
|
import { t as s } from "./VvButtonLocalized-C-vx25u4.js";
|
|
4
4
|
import "./src-nb8MU1sh.js";
|
|
5
|
-
import { et as c } from "./utils-
|
|
5
|
+
import { et as c } from "./utils-KBB6SDPn.js";
|
|
6
6
|
import { VvButtonGroup as l, VvIcon as u } from "@volverjs/ui-vue/components";
|
|
7
7
|
import { Fragment as d, computed as f, createBlock as p, createCommentVNode as m, createElementBlock as h, createElementVNode as g, createVNode as _, defineAsyncComponent as v, defineComponent as y, openBlock as b, ref as x, renderList as S, toDisplayString as C, unref as w, useTemplateRef as ee, withCtx as T } from "vue";
|
|
8
8
|
import { useI18n as E } from "vue-i18n";
|
|
@@ -109,7 +109,7 @@ var O = [
|
|
|
109
109
|
isDark: { type: Boolean }
|
|
110
110
|
},
|
|
111
111
|
setup(e) {
|
|
112
|
-
let t = v(() => import("./PkChart-
|
|
112
|
+
let t = v(() => import("./PkChart-D-K7nc0g.js")), n = e, { t: r, locale: i } = E({ useScope: "global" }), { copy: a, copied: o } = D(), y = f(() => {
|
|
113
113
|
switch (n.chart.type) {
|
|
114
114
|
case "line": return "ri:line-chart-line";
|
|
115
115
|
case "pie": return "ri:pie-chart-line";
|
|
@@ -214,4 +214,4 @@ var O = [
|
|
|
214
214
|
}), te = /* @__PURE__ */ e({ default: () => $ }), $ = Q;
|
|
215
215
|
export { $ as default, L as n, M as r, te as t };
|
|
216
216
|
|
|
217
|
-
//# sourceMappingURL=PkToolShowChart-
|
|
217
|
+
//# sourceMappingURL=PkToolShowChart-BQXxaPIO.js.map
|
package/dist-vue/_chunks/{PkToolShowChart-BWO6Hzlq.js.map → PkToolShowChart-BQXxaPIO.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolShowChart-BWO6Hzlq.js","names":["z.object","z.string","z.array","z.number","z.enum","z.boolean","_hoisted_1","_hoisted_2","_hoisted_3","__unplugin_components_0","__unplugin_components_1","__unplugin_components_2","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_withCtx","_createBlock","_createCommentVNode","_Fragment","_renderList","_sfc_main","$t","__unplugin_components_0","_openBlock","_createElementBlock","_Fragment","_renderList","_createBlock","PkChartCard","_createVNode","_toDisplayString","_createCommentVNode","_sfc_main","__exportAll","string","number","array","_enum","boolean","object","VvButtonLocalized","toSnakeCase","CHART_TYPES","CHART_TONES","CHART_FORMATS","CHART_LIMITS","isRoundChart","type","LABEL_MAX","ChartSeriesSchema","ChartSchema","chart","issue","ctx","series","s","categories","i","v","ShowChartInputSchema","chartValueFormatter","formatter","locale","format","cents","value","chartAsTsv","clean","text","category","row","_hoisted_1$1","_hoisted_2$1","_hoisted_3$1","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","PkChartCard_default","defineComponent","PkChart","defineAsyncComponent","props","__props","$t","useI18n","useClipboard","icon","computed","showTable","ref","chartRef","useTemplateRef","downloadPng","blob","url","anchor","_component_VvIcon","VvIcon","_component_VvButton","_component_VvButtonGroup","VvButtonGroup","openBlock","createElementBlock","createElementVNode","createVNode","toDisplayString","unref","withCtx","_cache","copied","copy","createCommentVNode","createBlock","Fragment","renderList","_hoisted_1","_hoisted_2","_hoisted_3","PkToolShowChart_vue_vue_type_script_setup_true_lang_default","toolPart","streaming","refused","input","parsed","_ctx","PkToolShowChart_exports","PkToolShowChart_default"],"sources":["../../../../packages/models/src/schema/Chart.ts","../../../../packages/components/src/chat/chartFormat.ts","../../../../packages/components/src/chat/PkChartCard.vue","../../../../packages/components/src/chat/PkChartCard.vue","../../../../packages/components/src/chat/PkToolShowChart.vue","../../../../packages/components/src/chat/PkToolShowChart.vue"],"sourcesContent":["import * as z from 'zod'\nimport { AgentBuiltInTool } from './Agent'\n\n// A chart as the model describes it (spec `chat-charts.md`): categories and\n// named series of numbers, no colors or code. `showChart` draws it in the\n// chat; the Excel and Word files the agent creates write the same shape as a\n// native Office chart.\n\nexport const CHART_TYPES = ['bar', 'line', 'pie', 'doughnut'] as const\nexport type ChartType = (typeof CHART_TYPES)[number]\n\n/** The meaning a series' color carries, drawn with the semantic colors. */\nexport const CHART_TONES = [\n 'positive',\n 'warning',\n 'negative',\n 'critical',\n 'neutral',\n] as const\nexport type ChartTone = (typeof CHART_TONES)[number]\n\nexport const CHART_FORMATS = ['number', 'percent', 'currency'] as const\nexport type ChartFormat = (typeof CHART_FORMATS)[number]\n\nexport const CHART_LIMITS = {\n maxCategories: 50,\n maxSeries: 8,\n /** Slices of a pie or a doughnut: more do not read. */\n maxSlices: 12,\n /** Charts in one `showChart` call. */\n maxCharts: 4,\n} as const\n\n/**\n * The agent can draw a chart in the chat: with `showChart`, or with the\n * Mermaid XY chart of `showDiagram` when it has not got the first. What the\n * \"Make a chart\" selection action needs.\n */\nexport const hasChatChartTool = (\n disabledTools: readonly AgentBuiltInTool[],\n): boolean =>\n !disabledTools.includes(AgentBuiltInTool.ShowChart) ||\n !disabledTools.includes(AgentBuiltInTool.ShowDiagram)\n\n/** A pie or a doughnut: one series, its values the slices. */\nexport const isRoundChart = (type: ChartType): boolean =>\n type === 'pie' || type === 'doughnut'\n\n/** Labels short enough for a legend, an axis and a slice. */\nconst LABEL_MAX = 120\n\nexport const ChartSeriesSchema = z.object({\n name: z\n .string()\n .min(1)\n .max(LABEL_MAX)\n .describe('Series name, shown in the legend'),\n values: z\n .array(z.number().nullable())\n .max(CHART_LIMITS.maxCategories)\n .describe('One number per category, in the same order; null for none'),\n tone: z\n .enum(CHART_TONES)\n .optional()\n .describe(\n 'Only when the series means a judgement (e.g. high risk = negative): it takes that color',\n ),\n})\nexport type ChartSeries = z.infer<typeof ChartSeriesSchema>\n\n/**\n * The fields of a chart, without the checks across them: the schema a tool\n * extends before {@link refineChart} adds those checks.\n */\nexport const ChartFieldsSchema = z.object({\n type: z\n .enum(CHART_TYPES)\n .describe(\n 'bar to compare amounts, line for a trend over time, pie or doughnut for the shares of one whole',\n ),\n title: z\n .string()\n .max(200)\n .optional()\n .describe('Short title above the chart'),\n horizontal: z\n .boolean()\n .optional()\n .describe('bar only: categories on the vertical axis, for long labels'),\n stacked: z\n .boolean()\n .optional()\n .describe('bar only: the series stacked into one bar per category'),\n // The limits in the schema, so the model reads them before it writes\n categories: z\n .array(z.string().max(LABEL_MAX))\n .min(1)\n .max(\n CHART_LIMITS.maxCategories,\n `At most ${CHART_LIMITS.maxCategories} categories: group the smallest ones.`,\n )\n .describe(\n 'The labels of the x axis (or of the slices), in display order',\n ),\n series: z\n .array(ChartSeriesSchema)\n .min(1)\n .max(\n CHART_LIMITS.maxSeries,\n `At most ${CHART_LIMITS.maxSeries} series.`,\n )\n .describe('One or more named series; exactly one for pie or doughnut'),\n valueLabel: z\n .string()\n .max(LABEL_MAX)\n .optional()\n .describe('What the numbers measure, with the unit (e.g. \"Clienti\")'),\n categoryLabel: z\n .string()\n .max(LABEL_MAX)\n .optional()\n .describe('What the categories are (e.g. \"Fascia di rating\")'),\n format: z\n .enum(CHART_FORMATS)\n .optional()\n .describe(\n 'How values read: percent means 0.25 is 25%, currency is in euro',\n ),\n})\n\n/**\n * The checks JSON Schema cannot state, worded for the model that wrote the\n * chart: it reads the message and calls again.\n */\nexport const refineChart = (\n chart: z.infer<typeof ChartFieldsSchema>,\n ctx: z.RefinementCtx,\n) => {\n const { type, categories, series } = chart\n const issue = (message: string, path: (string | number)[]) =>\n ctx.addIssue({ code: 'custom', message, path })\n series.forEach((s, i) => {\n if (s.values.length !== categories.length) {\n issue(\n `Series \"${s.name}\" has ${s.values.length} values for ${categories.length} categories: give one value per category.`,\n ['series', i, 'values'],\n )\n }\n if (s.values.every((v) => v === null)) {\n issue(\n `Series \"${s.name}\" has no values: leave it out, or give its numbers.`,\n ['series', i, 'values'],\n )\n }\n })\n if (isRoundChart(type)) {\n if (series.length !== 1) {\n issue(\n `A ${type} chart has exactly one series: ${series.length} given. Use a bar chart to compare several.`,\n ['series'],\n )\n }\n if (categories.length > CHART_LIMITS.maxSlices) {\n issue(\n `${categories.length} slices: at most ${CHART_LIMITS.maxSlices} in a ${type}. Group the smallest into one, or use a bar chart.`,\n ['categories'],\n )\n }\n if (series[0]?.values.some((v) => v !== null && v < 0)) {\n issue(`A ${type} chart cannot show negative values.`, [\n 'series',\n 0,\n 'values',\n ])\n } else if (\n series[0]?.values.some((v) => v !== null) &&\n !series[0].values.some((v) => v !== null && v > 0)\n ) {\n issue(\n `A ${type} chart needs at least one value above zero: every slice is empty.`,\n ['series', 0, 'values'],\n )\n }\n }\n}\n\nexport const ChartSchema = ChartFieldsSchema.superRefine(refineChart)\nexport type Chart = z.infer<typeof ChartSchema>\n\n/**\n * The input of `showChart`: every chart the user asked for in one call. A\n * presentation tool ends the turn, and a model that calls one chart at a\n * time (GPT-6.1 Sol, asked for a pie and a bar chart, drew the pie only)\n * would never draw the second.\n */\nexport const ShowChartInputSchema = z.object({\n charts: z\n .array(ChartSchema)\n .min(1)\n .max(CHART_LIMITS.maxCharts)\n .describe(\n 'Every chart the user asked for, one entry each (e.g. a pie and a bar chart of the same numbers)',\n ),\n caption: z\n .string()\n .max(500)\n .optional()\n .describe('Optional note below the charts, e.g. the source'),\n})\nexport type ShowChartInput = z.infer<typeof ShowChartInputSchema>\n","import type { ChartFormat } from 'models'\n\n/**\n * How the values of a chart read, on its axis, in its tooltip and in its\n * table: `percent` takes 0.25 as 25%, `currency` is in euro, as the model is\n * told (spec `chat-charts.md`).\n */\nexport const chartValueFormatter = (\n locale: string,\n format: ChartFormat = 'number',\n): ((value: number | null) => string) => {\n const formatter = new Intl.NumberFormat(\n locale,\n format === 'percent'\n ? { style: 'percent', maximumFractionDigits: 1 }\n : format === 'currency'\n ? { style: 'currency', currency: 'EUR', maximumFractionDigits: 0 }\n : { maximumFractionDigits: 2 },\n )\n // 160.000 € on an axis, 12,50 € where there are cents\n const cents =\n format === 'currency'\n ? new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: 'EUR',\n })\n : formatter\n return (value) =>\n value === null || !Number.isFinite(value)\n ? ''\n : (Number.isInteger(value) ? formatter : cents).format(value)\n}\n\n/**\n * The chart as tab-separated text: pasted in Excel or Sheets it lands in\n * cells, one row per category and one column per series. The numbers are\n * written in the reader's locale without grouping: an Italian Excel reads\n * \"12.5\" as text or a date, \"12,5\" as the number.\n */\nexport const chartAsTsv = (\n chart: {\n categories: string[]\n series: { name: string; values: (number | null)[] }[]\n categoryLabel?: string\n },\n locale: string,\n): string => {\n const number = new Intl.NumberFormat(locale, {\n useGrouping: false,\n maximumFractionDigits: 10,\n })\n const clean = (text: string) => text.replace(/[\\t\\r\\n]+/g, ' ')\n const rows = [\n [chart.categoryLabel ?? '', ...chart.series.map((s) => s.name)],\n ...chart.categories.map((category, i) => [\n category,\n ...chart.series.map((s) => {\n const value = s.values[i]\n return value === null || value === undefined\n ? ''\n : number.format(value)\n }),\n ]),\n ]\n return rows.map((row) => row.map(clean).join('\\t')).join('\\n')\n}\n","<script setup lang=\"ts\">\n import { computed, defineAsyncComponent, ref, useTemplateRef } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import type { Chart } from 'models'\n import { toSnakeCase } from 'utils'\n import { chartAsTsv, chartValueFormatter } from './chartFormat'\n\n // Chart.js comes with it: a separate chunk, loaded with the first chart\n const PkChart = defineAsyncComponent(() => import('./PkChart.vue'))\n\n /**\n * One chart of `showChart` (spec `chat-charts.md`) in its card: the chart,\n * the same numbers as a table, \"Copy data\" for a sheet and the chart as a\n * PNG.\n */\n const props = defineProps<{\n chart: Chart\n /** A note below the chart, e.g. the source of the numbers. */\n caption?: string\n isDark?: boolean\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n const { copy, copied } = useClipboard()\n\n const icon = computed(() => {\n switch (props.chart.type) {\n case 'line':\n return 'ri:line-chart-line'\n case 'pie':\n return 'ri:pie-chart-line'\n case 'doughnut':\n return 'ri:donut-chart-line'\n default:\n return props.chart.horizontal\n ? 'ri:bar-chart-horizontal-line'\n : 'ri:bar-chart-2-line'\n }\n })\n\n const showTable = ref(false)\n const format = computed(() =>\n chartValueFormatter(locale.value, props.chart.format),\n )\n\n const chartRef = useTemplateRef<{ toBlob: () => Promise<Blob | null> }>(\n 'chartRef',\n )\n const downloadPng = async () => {\n const blob = await chartRef.value?.toBlob()\n if (!blob) {\n return\n }\n const url = URL.createObjectURL(blob)\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.download = `${toSnakeCase(props.chart.title || 'chart')}.png`\n document.body.appendChild(anchor)\n anchor.click()\n document.body.removeChild(anchor)\n URL.revokeObjectURL(url)\n }\n</script>\n\n<template>\n <div\n class=\"pk-chart-card border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon :name=\"icon\" class=\"text-16 shrink-0\" />\n <strong class=\"font-bold truncate\">\n {{ chart.title || $t('label.chart') }}\n </strong>\n <VvButtonGroup\n modifiers=\"compact\"\n class=\"pk-chart-card__actions ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"showTable ? icon : 'ri:table-line'\"\n :label=\"\n showTable\n ? $t('chart.showChart')\n : $t('chart.showTable')\n \"\n @click=\"showTable = !showTable\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('chart.copyData')\"\n @click=\"copy(chartAsTsv(chart, locale))\" />\n <VvButton\n v-if=\"!showTable\"\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n :title=\"$t('chart.downloadPng')\"\n @click=\"downloadPng\" />\n </VvButtonGroup>\n </div>\n <div v-if=\"showTable\" class=\"pk-chart-card__table-wrap\">\n <table class=\"pk-chart-card__table text-12\">\n <thead>\n <tr>\n <th scope=\"col\">{{ chart.categoryLabel ?? '' }}</th>\n <th\n v-for=\"series in chart.series\"\n :key=\"series.name\"\n scope=\"col\">\n {{ series.name }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"(category, i) in chart.categories\" :key=\"i\">\n <th scope=\"row\">{{ category }}</th>\n <td v-for=\"series in chart.series\" :key=\"series.name\">\n {{ format(series.values[i] ?? null) }}\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n <div v-else class=\"pk-chart-card__stage px-sm py-sm\">\n <PkChart ref=\"chartRef\" :chart :is-dark />\n </div>\n <div\n v-if=\"caption\"\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3\">\n {{ caption }}\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-chart-card {\n // A container for the narrow card below. It is also the containing\n // block of any `position: fixed` inside it, so a menu added here\n // must open in the top layer (docs/agents/gotchas/frontend.md, \"The\n // chat measures its own width\"): today the card has none.\n container-type: inline-size;\n\n // On a narrow card the actions keep their icon and lose the word on\n // screen, still read by a screen reader: the title keeps the room\n // (at 390px it was cut to \"Fattori di ...\")\n @container (width < 30rem) {\n &__actions .vv-button__label {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n }\n\n // A fixed stage, as the diagram's: the chart loads in a chunk of its\n // own, and loader and chart must take the same room or the chat's\n // scroll jumps\n &__stage {\n height: 320px;\n }\n\n &__table-wrap {\n max-height: 320px;\n overflow: auto;\n }\n\n &__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-6) var(--spacing-sm);\n border-bottom: 1px solid var(--color-surface-3);\n text-align: right;\n white-space: nowrap;\n }\n\n th:first-child {\n text-align: left;\n white-space: normal;\n }\n\n thead th {\n color: var(--color-word-3);\n font-weight: 600;\n }\n\n tbody th {\n color: var(--color-word-2);\n font-weight: 400;\n }\n\n td {\n color: var(--color-word);\n font-variant-numeric: tabular-nums;\n }\n\n tbody tr:last-child > * {\n border-bottom: 0;\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed, defineAsyncComponent, ref, useTemplateRef } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import type { Chart } from 'models'\n import { toSnakeCase } from 'utils'\n import { chartAsTsv, chartValueFormatter } from './chartFormat'\n\n // Chart.js comes with it: a separate chunk, loaded with the first chart\n const PkChart = defineAsyncComponent(() => import('./PkChart.vue'))\n\n /**\n * One chart of `showChart` (spec `chat-charts.md`) in its card: the chart,\n * the same numbers as a table, \"Copy data\" for a sheet and the chart as a\n * PNG.\n */\n const props = defineProps<{\n chart: Chart\n /** A note below the chart, e.g. the source of the numbers. */\n caption?: string\n isDark?: boolean\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n const { copy, copied } = useClipboard()\n\n const icon = computed(() => {\n switch (props.chart.type) {\n case 'line':\n return 'ri:line-chart-line'\n case 'pie':\n return 'ri:pie-chart-line'\n case 'doughnut':\n return 'ri:donut-chart-line'\n default:\n return props.chart.horizontal\n ? 'ri:bar-chart-horizontal-line'\n : 'ri:bar-chart-2-line'\n }\n })\n\n const showTable = ref(false)\n const format = computed(() =>\n chartValueFormatter(locale.value, props.chart.format),\n )\n\n const chartRef = useTemplateRef<{ toBlob: () => Promise<Blob | null> }>(\n 'chartRef',\n )\n const downloadPng = async () => {\n const blob = await chartRef.value?.toBlob()\n if (!blob) {\n return\n }\n const url = URL.createObjectURL(blob)\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.download = `${toSnakeCase(props.chart.title || 'chart')}.png`\n document.body.appendChild(anchor)\n anchor.click()\n document.body.removeChild(anchor)\n URL.revokeObjectURL(url)\n }\n</script>\n\n<template>\n <div\n class=\"pk-chart-card border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon :name=\"icon\" class=\"text-16 shrink-0\" />\n <strong class=\"font-bold truncate\">\n {{ chart.title || $t('label.chart') }}\n </strong>\n <VvButtonGroup\n modifiers=\"compact\"\n class=\"pk-chart-card__actions ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"showTable ? icon : 'ri:table-line'\"\n :label=\"\n showTable\n ? $t('chart.showChart')\n : $t('chart.showTable')\n \"\n @click=\"showTable = !showTable\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('chart.copyData')\"\n @click=\"copy(chartAsTsv(chart, locale))\" />\n <VvButton\n v-if=\"!showTable\"\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n :title=\"$t('chart.downloadPng')\"\n @click=\"downloadPng\" />\n </VvButtonGroup>\n </div>\n <div v-if=\"showTable\" class=\"pk-chart-card__table-wrap\">\n <table class=\"pk-chart-card__table text-12\">\n <thead>\n <tr>\n <th scope=\"col\">{{ chart.categoryLabel ?? '' }}</th>\n <th\n v-for=\"series in chart.series\"\n :key=\"series.name\"\n scope=\"col\">\n {{ series.name }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"(category, i) in chart.categories\" :key=\"i\">\n <th scope=\"row\">{{ category }}</th>\n <td v-for=\"series in chart.series\" :key=\"series.name\">\n {{ format(series.values[i] ?? null) }}\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n <div v-else class=\"pk-chart-card__stage px-sm py-sm\">\n <PkChart ref=\"chartRef\" :chart :is-dark />\n </div>\n <div\n v-if=\"caption\"\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3\">\n {{ caption }}\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-chart-card {\n // A container for the narrow card below. It is also the containing\n // block of any `position: fixed` inside it, so a menu added here\n // must open in the top layer (docs/agents/gotchas/frontend.md, \"The\n // chat measures its own width\"): today the card has none.\n container-type: inline-size;\n\n // On a narrow card the actions keep their icon and lose the word on\n // screen, still read by a screen reader: the title keeps the room\n // (at 390px it was cut to \"Fattori di ...\")\n @container (width < 30rem) {\n &__actions .vv-button__label {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n }\n\n // A fixed stage, as the diagram's: the chart loads in a chunk of its\n // own, and loader and chart must take the same room or the chat's\n // scroll jumps\n &__stage {\n height: 320px;\n }\n\n &__table-wrap {\n max-height: 320px;\n overflow: auto;\n }\n\n &__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-6) var(--spacing-sm);\n border-bottom: 1px solid var(--color-surface-3);\n text-align: right;\n white-space: nowrap;\n }\n\n th:first-child {\n text-align: left;\n white-space: normal;\n }\n\n thead th {\n color: var(--color-word-3);\n font-weight: 600;\n }\n\n tbody th {\n color: var(--color-word-2);\n font-weight: 400;\n }\n\n td {\n color: var(--color-word);\n font-variant-numeric: tabular-nums;\n }\n\n tbody tr:last-child > * {\n border-bottom: 0;\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { ShowChartInputSchema } from 'models'\n import PkChartCard from './PkChartCard.vue'\n\n /**\n * The cards of `showChart` (spec `chat-charts.md`): every chart of the\n * call in its own card, one under the other, the caption under the last.\n */\n const props = defineProps<{\n part: unknown\n isDark?: boolean\n }>()\n\n const toolPart = computed(\n () => props.part as { state?: string; input?: unknown },\n )\n // A half-written input has series shorter than the categories\n const streaming = computed(() => toolPart.value.state === 'input-streaming')\n // A call the tool refused for its input: the model reads why and calls\n // again, and the corrected chart follows it. Nothing to show here.\n const refused = computed(() => toolPart.value.state === 'output-error')\n /** The input as the tool validated it; a stored one that is not stays a message. */\n const input = computed(() => {\n if (streaming.value) {\n return undefined\n }\n const parsed = ShowChartInputSchema.safeParse(toolPart.value.input)\n return parsed.success ? parsed.data : undefined\n })\n</script>\n\n<template>\n <div v-if=\"input\" class=\"flex flex-col gap-sm w-full\">\n <PkChartCard\n v-for=\"(chart, i) in input.charts\"\n :key=\"i\"\n :chart\n :caption=\"i === input.charts.length - 1 ? input.caption : undefined\"\n :is-dark />\n </div>\n <div\n v-else-if=\"streaming\"\n class=\"pk-tool-show-chart__loading border border-surface-3 rounded-xl w-full flex justify-center items-center\">\n <VvIcon name=\"loading-loop\" class=\"w-24 h-24 text-word-5\" />\n </div>\n <div\n v-else-if=\"!refused\"\n class=\"border border-surface-3 rounded-xl w-full text-12 text-danger py-8 px-sm\">\n {{ $t('message.chartRenderError') }}\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-tool-show-chart {\n // The height of a card while the call is written: the card that\n // replaces it takes about as much, and the chat's scroll stays put\n &__loading {\n height: 360px;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { ShowChartInputSchema } from 'models'\n import PkChartCard from './PkChartCard.vue'\n\n /**\n * The cards of `showChart` (spec `chat-charts.md`): every chart of the\n * call in its own card, one under the other, the caption under the last.\n */\n const props = defineProps<{\n part: unknown\n isDark?: boolean\n }>()\n\n const toolPart = computed(\n () => props.part as { state?: string; input?: unknown },\n )\n // A half-written input has series shorter than the categories\n const streaming = computed(() => toolPart.value.state === 'input-streaming')\n // A call the tool refused for its input: the model reads why and calls\n // again, and the corrected chart follows it. Nothing to show here.\n const refused = computed(() => toolPart.value.state === 'output-error')\n /** The input as the tool validated it; a stored one that is not stays a message. */\n const input = computed(() => {\n if (streaming.value) {\n return undefined\n }\n const parsed = ShowChartInputSchema.safeParse(toolPart.value.input)\n return parsed.success ? parsed.data : undefined\n })\n</script>\n\n<template>\n <div v-if=\"input\" class=\"flex flex-col gap-sm w-full\">\n <PkChartCard\n v-for=\"(chart, i) in input.charts\"\n :key=\"i\"\n :chart\n :caption=\"i === input.charts.length - 1 ? input.caption : undefined\"\n :is-dark />\n </div>\n <div\n v-else-if=\"streaming\"\n class=\"pk-tool-show-chart__loading border border-surface-3 rounded-xl w-full flex justify-center items-center\">\n <VvIcon name=\"loading-loop\" class=\"w-24 h-24 text-word-5\" />\n </div>\n <div\n v-else-if=\"!refused\"\n class=\"border border-surface-3 rounded-xl w-full text-12 text-danger py-8 px-sm\">\n {{ $t('message.chartRenderError') }}\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-tool-show-chart {\n // The height of a card while the call is written: the card that\n // replaces it takes about as much, and the chat's scroll stays put\n &__loading {\n height: 360px;\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;AAQA,IAAa6C,IAAc;CAAC;CA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IAApD,MAAK;IAAe,OAAM;G,QAGtByB,EAAA,Q,aADhBrG,EAAA,GAAAC,EAIM,OAJNgG,GAIM1F,EADCT,EAAAA,GAAE,0BAAA,CAAA,GAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"PkToolShowChart-BQXxaPIO.js","names":["z.object","z.string","z.array","z.number","z.enum","z.boolean","_hoisted_1","_hoisted_2","_hoisted_3","__unplugin_components_0","__unplugin_components_1","__unplugin_components_2","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_withCtx","_createBlock","_createCommentVNode","_Fragment","_renderList","_sfc_main","$t","__unplugin_components_0","_openBlock","_createElementBlock","_Fragment","_renderList","_createBlock","PkChartCard","_createVNode","_toDisplayString","_createCommentVNode","_sfc_main","__exportAll","string","number","array","_enum","boolean","object","VvButtonLocalized","toSnakeCase","CHART_TYPES","CHART_TONES","CHART_FORMATS","CHART_LIMITS","isRoundChart","type","LABEL_MAX","ChartSeriesSchema","ChartSchema","chart","issue","ctx","series","s","categories","i","v","ShowChartInputSchema","chartValueFormatter","formatter","locale","format","cents","value","chartAsTsv","clean","text","category","row","_hoisted_1$1","_hoisted_2$1","_hoisted_3$1","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","PkChartCard_default","defineComponent","PkChart","defineAsyncComponent","props","__props","$t","useI18n","useClipboard","icon","computed","showTable","ref","chartRef","useTemplateRef","downloadPng","blob","url","anchor","_component_VvIcon","VvIcon","_component_VvButton","_component_VvButtonGroup","VvButtonGroup","openBlock","createElementBlock","createElementVNode","createVNode","toDisplayString","unref","withCtx","_cache","copied","copy","createCommentVNode","createBlock","Fragment","renderList","_hoisted_1","_hoisted_2","_hoisted_3","PkToolShowChart_vue_vue_type_script_setup_true_lang_default","toolPart","streaming","refused","input","parsed","_ctx","PkToolShowChart_exports","PkToolShowChart_default"],"sources":["../../../../packages/models/src/schema/Chart.ts","../../../../packages/components/src/chat/chartFormat.ts","../../../../packages/components/src/chat/PkChartCard.vue","../../../../packages/components/src/chat/PkChartCard.vue","../../../../packages/components/src/chat/PkToolShowChart.vue","../../../../packages/components/src/chat/PkToolShowChart.vue"],"sourcesContent":["import * as z from 'zod'\nimport { AgentBuiltInTool } from './Agent'\n\n// A chart as the model describes it (spec `chat-charts.md`): categories and\n// named series of numbers, no colors or code. `showChart` draws it in the\n// chat; the Excel and Word files the agent creates write the same shape as a\n// native Office chart.\n\nexport const CHART_TYPES = ['bar', 'line', 'pie', 'doughnut'] as const\nexport type ChartType = (typeof CHART_TYPES)[number]\n\n/** The meaning a series' color carries, drawn with the semantic colors. */\nexport const CHART_TONES = [\n 'positive',\n 'warning',\n 'negative',\n 'critical',\n 'neutral',\n] as const\nexport type ChartTone = (typeof CHART_TONES)[number]\n\nexport const CHART_FORMATS = ['number', 'percent', 'currency'] as const\nexport type ChartFormat = (typeof CHART_FORMATS)[number]\n\nexport const CHART_LIMITS = {\n maxCategories: 50,\n maxSeries: 8,\n /** Slices of a pie or a doughnut: more do not read. */\n maxSlices: 12,\n /** Charts in one `showChart` call. */\n maxCharts: 4,\n} as const\n\n/**\n * The agent can draw a chart in the chat: with `showChart`, or with the\n * Mermaid XY chart of `showDiagram` when it has not got the first. What the\n * \"Make a chart\" selection action needs.\n */\nexport const hasChatChartTool = (\n disabledTools: readonly AgentBuiltInTool[],\n): boolean =>\n !disabledTools.includes(AgentBuiltInTool.ShowChart) ||\n !disabledTools.includes(AgentBuiltInTool.ShowDiagram)\n\n/** A pie or a doughnut: one series, its values the slices. */\nexport const isRoundChart = (type: ChartType): boolean =>\n type === 'pie' || type === 'doughnut'\n\n/** Labels short enough for a legend, an axis and a slice. */\nconst LABEL_MAX = 120\n\nexport const ChartSeriesSchema = z.object({\n name: z\n .string()\n .min(1)\n .max(LABEL_MAX)\n .describe('Series name, shown in the legend'),\n values: z\n .array(z.number().nullable())\n .max(CHART_LIMITS.maxCategories)\n .describe('One number per category, in the same order; null for none'),\n tone: z\n .enum(CHART_TONES)\n .optional()\n .describe(\n 'Only when the series means a judgement (e.g. high risk = negative): it takes that color',\n ),\n})\nexport type ChartSeries = z.infer<typeof ChartSeriesSchema>\n\n/**\n * The fields of a chart, without the checks across them: the schema a tool\n * extends before {@link refineChart} adds those checks.\n */\nexport const ChartFieldsSchema = z.object({\n type: z\n .enum(CHART_TYPES)\n .describe(\n 'bar to compare amounts, line for a trend over time, pie or doughnut for the shares of one whole',\n ),\n title: z\n .string()\n .max(200)\n .optional()\n .describe('Short title above the chart'),\n horizontal: z\n .boolean()\n .optional()\n .describe('bar only: categories on the vertical axis, for long labels'),\n stacked: z\n .boolean()\n .optional()\n .describe('bar only: the series stacked into one bar per category'),\n // The limits in the schema, so the model reads them before it writes\n categories: z\n .array(z.string().max(LABEL_MAX))\n .min(1)\n .max(\n CHART_LIMITS.maxCategories,\n `At most ${CHART_LIMITS.maxCategories} categories: group the smallest ones.`,\n )\n .describe(\n 'The labels of the x axis (or of the slices), in display order',\n ),\n series: z\n .array(ChartSeriesSchema)\n .min(1)\n .max(\n CHART_LIMITS.maxSeries,\n `At most ${CHART_LIMITS.maxSeries} series.`,\n )\n .describe('One or more named series; exactly one for pie or doughnut'),\n valueLabel: z\n .string()\n .max(LABEL_MAX)\n .optional()\n .describe('What the numbers measure, with the unit (e.g. \"Clienti\")'),\n categoryLabel: z\n .string()\n .max(LABEL_MAX)\n .optional()\n .describe('What the categories are (e.g. \"Fascia di rating\")'),\n format: z\n .enum(CHART_FORMATS)\n .optional()\n .describe(\n 'How values read: percent means 0.25 is 25%, currency is in euro',\n ),\n})\n\n/**\n * The checks JSON Schema cannot state, worded for the model that wrote the\n * chart: it reads the message and calls again.\n */\nexport const refineChart = (\n chart: z.infer<typeof ChartFieldsSchema>,\n ctx: z.RefinementCtx,\n) => {\n const { type, categories, series } = chart\n const issue = (message: string, path: (string | number)[]) =>\n ctx.addIssue({ code: 'custom', message, path })\n series.forEach((s, i) => {\n if (s.values.length !== categories.length) {\n issue(\n `Series \"${s.name}\" has ${s.values.length} values for ${categories.length} categories: give one value per category.`,\n ['series', i, 'values'],\n )\n }\n if (s.values.every((v) => v === null)) {\n issue(\n `Series \"${s.name}\" has no values: leave it out, or give its numbers.`,\n ['series', i, 'values'],\n )\n }\n })\n if (isRoundChart(type)) {\n if (series.length !== 1) {\n issue(\n `A ${type} chart has exactly one series: ${series.length} given. Use a bar chart to compare several.`,\n ['series'],\n )\n }\n if (categories.length > CHART_LIMITS.maxSlices) {\n issue(\n `${categories.length} slices: at most ${CHART_LIMITS.maxSlices} in a ${type}. Group the smallest into one, or use a bar chart.`,\n ['categories'],\n )\n }\n if (series[0]?.values.some((v) => v !== null && v < 0)) {\n issue(`A ${type} chart cannot show negative values.`, [\n 'series',\n 0,\n 'values',\n ])\n } else if (\n series[0]?.values.some((v) => v !== null) &&\n !series[0].values.some((v) => v !== null && v > 0)\n ) {\n issue(\n `A ${type} chart needs at least one value above zero: every slice is empty.`,\n ['series', 0, 'values'],\n )\n }\n }\n}\n\nexport const ChartSchema = ChartFieldsSchema.superRefine(refineChart)\nexport type Chart = z.infer<typeof ChartSchema>\n\n/**\n * The input of `showChart`: every chart the user asked for in one call. A\n * presentation tool ends the turn, and a model that calls one chart at a\n * time (GPT-6.1 Sol, asked for a pie and a bar chart, drew the pie only)\n * would never draw the second.\n */\nexport const ShowChartInputSchema = z.object({\n charts: z\n .array(ChartSchema)\n .min(1)\n .max(CHART_LIMITS.maxCharts)\n .describe(\n 'Every chart the user asked for, one entry each (e.g. a pie and a bar chart of the same numbers)',\n ),\n caption: z\n .string()\n .max(500)\n .optional()\n .describe('Optional note below the charts, e.g. the source'),\n})\nexport type ShowChartInput = z.infer<typeof ShowChartInputSchema>\n","import type { ChartFormat } from 'models'\n\n/**\n * How the values of a chart read, on its axis, in its tooltip and in its\n * table: `percent` takes 0.25 as 25%, `currency` is in euro, as the model is\n * told (spec `chat-charts.md`).\n */\nexport const chartValueFormatter = (\n locale: string,\n format: ChartFormat = 'number',\n): ((value: number | null) => string) => {\n const formatter = new Intl.NumberFormat(\n locale,\n format === 'percent'\n ? { style: 'percent', maximumFractionDigits: 1 }\n : format === 'currency'\n ? { style: 'currency', currency: 'EUR', maximumFractionDigits: 0 }\n : { maximumFractionDigits: 2 },\n )\n // 160.000 € on an axis, 12,50 € where there are cents\n const cents =\n format === 'currency'\n ? new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: 'EUR',\n })\n : formatter\n return (value) =>\n value === null || !Number.isFinite(value)\n ? ''\n : (Number.isInteger(value) ? formatter : cents).format(value)\n}\n\n/**\n * The chart as tab-separated text: pasted in Excel or Sheets it lands in\n * cells, one row per category and one column per series. The numbers are\n * written in the reader's locale without grouping: an Italian Excel reads\n * \"12.5\" as text or a date, \"12,5\" as the number.\n */\nexport const chartAsTsv = (\n chart: {\n categories: string[]\n series: { name: string; values: (number | null)[] }[]\n categoryLabel?: string\n },\n locale: string,\n): string => {\n const number = new Intl.NumberFormat(locale, {\n useGrouping: false,\n maximumFractionDigits: 10,\n })\n const clean = (text: string) => text.replace(/[\\t\\r\\n]+/g, ' ')\n const rows = [\n [chart.categoryLabel ?? '', ...chart.series.map((s) => s.name)],\n ...chart.categories.map((category, i) => [\n category,\n ...chart.series.map((s) => {\n const value = s.values[i]\n return value === null || value === undefined\n ? ''\n : number.format(value)\n }),\n ]),\n ]\n return rows.map((row) => row.map(clean).join('\\t')).join('\\n')\n}\n","<script setup lang=\"ts\">\n import { computed, defineAsyncComponent, ref, useTemplateRef } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import type { Chart } from 'models'\n import { toSnakeCase } from 'utils'\n import { chartAsTsv, chartValueFormatter } from './chartFormat'\n\n // Chart.js comes with it: a separate chunk, loaded with the first chart\n const PkChart = defineAsyncComponent(() => import('./PkChart.vue'))\n\n /**\n * One chart of `showChart` (spec `chat-charts.md`) in its card: the chart,\n * the same numbers as a table, \"Copy data\" for a sheet and the chart as a\n * PNG.\n */\n const props = defineProps<{\n chart: Chart\n /** A note below the chart, e.g. the source of the numbers. */\n caption?: string\n isDark?: boolean\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n const { copy, copied } = useClipboard()\n\n const icon = computed(() => {\n switch (props.chart.type) {\n case 'line':\n return 'ri:line-chart-line'\n case 'pie':\n return 'ri:pie-chart-line'\n case 'doughnut':\n return 'ri:donut-chart-line'\n default:\n return props.chart.horizontal\n ? 'ri:bar-chart-horizontal-line'\n : 'ri:bar-chart-2-line'\n }\n })\n\n const showTable = ref(false)\n const format = computed(() =>\n chartValueFormatter(locale.value, props.chart.format),\n )\n\n const chartRef = useTemplateRef<{ toBlob: () => Promise<Blob | null> }>(\n 'chartRef',\n )\n const downloadPng = async () => {\n const blob = await chartRef.value?.toBlob()\n if (!blob) {\n return\n }\n const url = URL.createObjectURL(blob)\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.download = `${toSnakeCase(props.chart.title || 'chart')}.png`\n document.body.appendChild(anchor)\n anchor.click()\n document.body.removeChild(anchor)\n URL.revokeObjectURL(url)\n }\n</script>\n\n<template>\n <div\n class=\"pk-chart-card border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon :name=\"icon\" class=\"text-16 shrink-0\" />\n <strong class=\"font-bold truncate\">\n {{ chart.title || $t('label.chart') }}\n </strong>\n <VvButtonGroup\n modifiers=\"compact\"\n class=\"pk-chart-card__actions ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"showTable ? icon : 'ri:table-line'\"\n :label=\"\n showTable\n ? $t('chart.showChart')\n : $t('chart.showTable')\n \"\n @click=\"showTable = !showTable\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('chart.copyData')\"\n @click=\"copy(chartAsTsv(chart, locale))\" />\n <VvButton\n v-if=\"!showTable\"\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n :title=\"$t('chart.downloadPng')\"\n @click=\"downloadPng\" />\n </VvButtonGroup>\n </div>\n <div v-if=\"showTable\" class=\"pk-chart-card__table-wrap\">\n <table class=\"pk-chart-card__table text-12\">\n <thead>\n <tr>\n <th scope=\"col\">{{ chart.categoryLabel ?? '' }}</th>\n <th\n v-for=\"series in chart.series\"\n :key=\"series.name\"\n scope=\"col\">\n {{ series.name }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"(category, i) in chart.categories\" :key=\"i\">\n <th scope=\"row\">{{ category }}</th>\n <td v-for=\"series in chart.series\" :key=\"series.name\">\n {{ format(series.values[i] ?? null) }}\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n <div v-else class=\"pk-chart-card__stage px-sm py-sm\">\n <PkChart ref=\"chartRef\" :chart :is-dark />\n </div>\n <div\n v-if=\"caption\"\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3\">\n {{ caption }}\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-chart-card {\n // A container for the narrow card below. It is also the containing\n // block of any `position: fixed` inside it, so a menu added here\n // must open in the top layer (docs/agents/gotchas/frontend.md, \"The\n // chat measures its own width\"): today the card has none.\n container-type: inline-size;\n\n // On a narrow card the actions keep their icon and lose the word on\n // screen, still read by a screen reader: the title keeps the room\n // (at 390px it was cut to \"Fattori di ...\")\n @container (width < 30rem) {\n &__actions .vv-button__label {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n }\n\n // A fixed stage, as the diagram's: the chart loads in a chunk of its\n // own, and loader and chart must take the same room or the chat's\n // scroll jumps\n &__stage {\n height: 320px;\n }\n\n &__table-wrap {\n max-height: 320px;\n overflow: auto;\n }\n\n &__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-6) var(--spacing-sm);\n border-bottom: 1px solid var(--color-surface-3);\n text-align: right;\n white-space: nowrap;\n }\n\n th:first-child {\n text-align: left;\n white-space: normal;\n }\n\n thead th {\n color: var(--color-word-3);\n font-weight: 600;\n }\n\n tbody th {\n color: var(--color-word-2);\n font-weight: 400;\n }\n\n td {\n color: var(--color-word);\n font-variant-numeric: tabular-nums;\n }\n\n tbody tr:last-child > * {\n border-bottom: 0;\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed, defineAsyncComponent, ref, useTemplateRef } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import type { Chart } from 'models'\n import { toSnakeCase } from 'utils'\n import { chartAsTsv, chartValueFormatter } from './chartFormat'\n\n // Chart.js comes with it: a separate chunk, loaded with the first chart\n const PkChart = defineAsyncComponent(() => import('./PkChart.vue'))\n\n /**\n * One chart of `showChart` (spec `chat-charts.md`) in its card: the chart,\n * the same numbers as a table, \"Copy data\" for a sheet and the chart as a\n * PNG.\n */\n const props = defineProps<{\n chart: Chart\n /** A note below the chart, e.g. the source of the numbers. */\n caption?: string\n isDark?: boolean\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n const { copy, copied } = useClipboard()\n\n const icon = computed(() => {\n switch (props.chart.type) {\n case 'line':\n return 'ri:line-chart-line'\n case 'pie':\n return 'ri:pie-chart-line'\n case 'doughnut':\n return 'ri:donut-chart-line'\n default:\n return props.chart.horizontal\n ? 'ri:bar-chart-horizontal-line'\n : 'ri:bar-chart-2-line'\n }\n })\n\n const showTable = ref(false)\n const format = computed(() =>\n chartValueFormatter(locale.value, props.chart.format),\n )\n\n const chartRef = useTemplateRef<{ toBlob: () => Promise<Blob | null> }>(\n 'chartRef',\n )\n const downloadPng = async () => {\n const blob = await chartRef.value?.toBlob()\n if (!blob) {\n return\n }\n const url = URL.createObjectURL(blob)\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.download = `${toSnakeCase(props.chart.title || 'chart')}.png`\n document.body.appendChild(anchor)\n anchor.click()\n document.body.removeChild(anchor)\n URL.revokeObjectURL(url)\n }\n</script>\n\n<template>\n <div\n class=\"pk-chart-card border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon :name=\"icon\" class=\"text-16 shrink-0\" />\n <strong class=\"font-bold truncate\">\n {{ chart.title || $t('label.chart') }}\n </strong>\n <VvButtonGroup\n modifiers=\"compact\"\n class=\"pk-chart-card__actions ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"showTable ? icon : 'ri:table-line'\"\n :label=\"\n showTable\n ? $t('chart.showChart')\n : $t('chart.showTable')\n \"\n @click=\"showTable = !showTable\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('chart.copyData')\"\n @click=\"copy(chartAsTsv(chart, locale))\" />\n <VvButton\n v-if=\"!showTable\"\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n :title=\"$t('chart.downloadPng')\"\n @click=\"downloadPng\" />\n </VvButtonGroup>\n </div>\n <div v-if=\"showTable\" class=\"pk-chart-card__table-wrap\">\n <table class=\"pk-chart-card__table text-12\">\n <thead>\n <tr>\n <th scope=\"col\">{{ chart.categoryLabel ?? '' }}</th>\n <th\n v-for=\"series in chart.series\"\n :key=\"series.name\"\n scope=\"col\">\n {{ series.name }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"(category, i) in chart.categories\" :key=\"i\">\n <th scope=\"row\">{{ category }}</th>\n <td v-for=\"series in chart.series\" :key=\"series.name\">\n {{ format(series.values[i] ?? null) }}\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n <div v-else class=\"pk-chart-card__stage px-sm py-sm\">\n <PkChart ref=\"chartRef\" :chart :is-dark />\n </div>\n <div\n v-if=\"caption\"\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3\">\n {{ caption }}\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-chart-card {\n // A container for the narrow card below. It is also the containing\n // block of any `position: fixed` inside it, so a menu added here\n // must open in the top layer (docs/agents/gotchas/frontend.md, \"The\n // chat measures its own width\"): today the card has none.\n container-type: inline-size;\n\n // On a narrow card the actions keep their icon and lose the word on\n // screen, still read by a screen reader: the title keeps the room\n // (at 390px it was cut to \"Fattori di ...\")\n @container (width < 30rem) {\n &__actions .vv-button__label {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n }\n\n // A fixed stage, as the diagram's: the chart loads in a chunk of its\n // own, and loader and chart must take the same room or the chat's\n // scroll jumps\n &__stage {\n height: 320px;\n }\n\n &__table-wrap {\n max-height: 320px;\n overflow: auto;\n }\n\n &__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-6) var(--spacing-sm);\n border-bottom: 1px solid var(--color-surface-3);\n text-align: right;\n white-space: nowrap;\n }\n\n th:first-child {\n text-align: left;\n white-space: normal;\n }\n\n thead th {\n color: var(--color-word-3);\n font-weight: 600;\n }\n\n tbody th {\n color: var(--color-word-2);\n font-weight: 400;\n }\n\n td {\n color: var(--color-word);\n font-variant-numeric: tabular-nums;\n }\n\n tbody tr:last-child > * {\n border-bottom: 0;\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { ShowChartInputSchema } from 'models'\n import PkChartCard from './PkChartCard.vue'\n\n /**\n * The cards of `showChart` (spec `chat-charts.md`): every chart of the\n * call in its own card, one under the other, the caption under the last.\n */\n const props = defineProps<{\n part: unknown\n isDark?: boolean\n }>()\n\n const toolPart = computed(\n () => props.part as { state?: string; input?: unknown },\n )\n // A half-written input has series shorter than the categories\n const streaming = computed(() => toolPart.value.state === 'input-streaming')\n // A call the tool refused for its input: the model reads why and calls\n // again, and the corrected chart follows it. Nothing to show here.\n const refused = computed(() => toolPart.value.state === 'output-error')\n /** The input as the tool validated it; a stored one that is not stays a message. */\n const input = computed(() => {\n if (streaming.value) {\n return undefined\n }\n const parsed = ShowChartInputSchema.safeParse(toolPart.value.input)\n return parsed.success ? parsed.data : undefined\n })\n</script>\n\n<template>\n <div v-if=\"input\" class=\"flex flex-col gap-sm w-full\">\n <PkChartCard\n v-for=\"(chart, i) in input.charts\"\n :key=\"i\"\n :chart\n :caption=\"i === input.charts.length - 1 ? input.caption : undefined\"\n :is-dark />\n </div>\n <div\n v-else-if=\"streaming\"\n class=\"pk-tool-show-chart__loading border border-surface-3 rounded-xl w-full flex justify-center items-center\">\n <VvIcon name=\"loading-loop\" class=\"w-24 h-24 text-word-5\" />\n </div>\n <div\n v-else-if=\"!refused\"\n class=\"border border-surface-3 rounded-xl w-full text-12 text-danger py-8 px-sm\">\n {{ $t('message.chartRenderError') }}\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-tool-show-chart {\n // The height of a card while the call is written: the card that\n // replaces it takes about as much, and the chat's scroll stays put\n &__loading {\n height: 360px;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { ShowChartInputSchema } from 'models'\n import PkChartCard from './PkChartCard.vue'\n\n /**\n * The cards of `showChart` (spec `chat-charts.md`): every chart of the\n * call in its own card, one under the other, the caption under the last.\n */\n const props = defineProps<{\n part: unknown\n isDark?: boolean\n }>()\n\n const toolPart = computed(\n () => props.part as { state?: string; input?: unknown },\n )\n // A half-written input has series shorter than the categories\n const streaming = computed(() => toolPart.value.state === 'input-streaming')\n // A call the tool refused for its input: the model reads why and calls\n // again, and the corrected chart follows it. Nothing to show here.\n const refused = computed(() => toolPart.value.state === 'output-error')\n /** The input as the tool validated it; a stored one that is not stays a message. */\n const input = computed(() => {\n if (streaming.value) {\n return undefined\n }\n const parsed = ShowChartInputSchema.safeParse(toolPart.value.input)\n return parsed.success ? parsed.data : undefined\n })\n</script>\n\n<template>\n <div v-if=\"input\" class=\"flex flex-col gap-sm w-full\">\n <PkChartCard\n v-for=\"(chart, i) in input.charts\"\n :key=\"i\"\n :chart\n :caption=\"i === input.charts.length - 1 ? input.caption : undefined\"\n :is-dark />\n </div>\n <div\n v-else-if=\"streaming\"\n class=\"pk-tool-show-chart__loading border border-surface-3 rounded-xl w-full flex justify-center items-center\">\n <VvIcon name=\"loading-loop\" class=\"w-24 h-24 text-word-5\" />\n </div>\n <div\n v-else-if=\"!refused\"\n class=\"border border-surface-3 rounded-xl w-full text-12 text-danger py-8 px-sm\">\n {{ $t('message.chartRenderError') }}\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-tool-show-chart {\n // The height of a card while the call is written: the card that\n // replaces it takes about as much, and the chat's scroll stays put\n &__loading {\n height: 360px;\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;AAQA,IAAa6C,IAAc;CAAC;CAAO;CAAQ;CAAO;AAAU,GAI/CC,IAAc;CACvB;CACA;CACA;CACA;CACA;AACJ,GAGaC,IAAgB;CAAC;CAAU;CAAW;AAAU,GAGhDC,IAAe;CACxB,eAAe;CACf,WAAW;CAEX,WAAW;CAEX,WAAW;AACf,GAcaC,KAAgB,MACzBC,MAAS,SAASA,MAAS,YAGzBC,IAAY,KAELC,IAAoBpD,EAAS;CACtC,MAAMC,EACM,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAIkD,CAAS,CAAC,CACd,SAAS,kCAAkC;CAChD,QAAQjD,EACGC,EAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAC5B,IAAI6C,EAAa,aAAa,CAAC,CAC/B,SAAS,2DAA2D;CACzE,MAAM5C,EACI0C,CAAW,CAAC,CACjB,SAAS,CAAC,CACV,SACG,yFACJ;AACR,CAAC,GAuHYO,IAhHoBrD,EAAS;CACtC,MAAMI,EACIyC,CAAW,CAAC,CACjB,SACG,iGACJ;CACJ,OAAO5C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,MAAM,UAAU,iBAAiB,GAGrEE,IAAUlC,QAAegC,EAAS,MAAM,UAAU,cAAc,GAEhEG,IAAQnC,QAAe;GACzB,IAAIiC,EAAU,OACV;GAEJ,IAAMG,IAASnE,EAAqB,UAAU+D,EAAS,MAAM,KAAK;GAClE,OAAOI,EAAO,UAAUA,EAAO,OAAO,KAAA;EAC1C,CAAC;;;GAIU,OAAAD,EAAA,SAAXtG,EAAA,GAAAC,EAOM,OAPN8F,GAOM,EANF/F,EAAA,EAAA,GAAAC,EAKeC,GAAA,MAAAC,EAJUmG,EAAA,MAAM,SAAnB,GAAO,OADnBtG,EAAA,GAAAI,EAKeC,GAAA;IAHV,KAAK6B;IACL;IACA,SAASA,MAAMoE,EAAA,MAAM,OAAO,SAAM,IAAOA,EAAA,MAAM,UAAU,KAAA;IACzD,WAAAxC,EAAA;;;;;G,iBAGMsC,EAAA,SADfpG,EAAA,GAAAC,EAIM,OAJN+F,GAIM,CADF1F,EAA4DsE,GAAA;IAApD,MAAK;IAAe,OAAM;G,QAGtByB,EAAA,Q,aADhBrG,EAAA,GAAAC,EAIM,OAJNgG,GAIM1F,EADCT,EAAAA,GAAE,0BAAA,CAAA,GAAA,CAAA"}
|
package/dist-vue/_chunks/{PkToolShowContactForm-BBcDsLEO.js → PkToolShowContactForm-CackCDGD.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-CGnMp29N.js";
|
|
2
2
|
import { S as t, d as n, v as r } from "./schemas-BO5QlXAp.js";
|
|
3
3
|
import { t as i } from "./VvButtonLocalized-C-vx25u4.js";
|
|
4
|
-
import { t as a } from "./PkStreamingMarkdown-
|
|
4
|
+
import { t as a } from "./PkStreamingMarkdown-ZasabxE0.js";
|
|
5
5
|
import { t as o } from "./src-nb8MU1sh.js";
|
|
6
6
|
import { t as s } from "./useSafeLocalStorage-Bn4SsL8C.js";
|
|
7
7
|
import { t as ee } from "./useLocalizedString-Dmn92nix.js";
|
|
@@ -156,4 +156,4 @@ var k = { class: "border border-surface-3 rounded-xl w-full overflow-hidden bg-s
|
|
|
156
156
|
}), W = /* @__PURE__ */ e({ default: () => G }), G = U;
|
|
157
157
|
export { W as n, G as t };
|
|
158
158
|
|
|
159
|
-
//# sourceMappingURL=PkToolShowContactForm-
|
|
159
|
+
//# sourceMappingURL=PkToolShowContactForm-CackCDGD.js.map
|