@lsamien/yaoyao 0.4.78 → 0.4.80
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/README.md +5 -5
- package/THIRD_PARTY_NOTICES.md +4 -0
- package/build-info.json +11 -3
- package/dist/assets/{AboutDialog-jvhTP8-J.js → AboutDialog-on4AME1V.js} +2 -2
- package/dist/assets/{AboutDialog-jvhTP8-J.js.map → AboutDialog-on4AME1V.js.map} +1 -1
- package/dist/assets/{BotAutomationsView-ktoci79V.js → BotAutomationsView-Bmb14qI5.js} +2 -2
- package/dist/assets/{BotAutomationsView-ktoci79V.js.map → BotAutomationsView-Bmb14qI5.js.map} +1 -1
- package/dist/assets/BotPluginsDialog-6WPFFQnG.js +2 -0
- package/dist/assets/BotPluginsDialog-6WPFFQnG.js.map +1 -0
- package/dist/assets/BotPluginsDialog-B0iR4Jy2.css +1 -0
- package/dist/assets/{BotSettingsDialog-Ci_DZL4m.js → BotSettingsDialog-wWHnGtBg.js} +4 -4
- package/dist/assets/{BotSettingsDialog-Ci_DZL4m.js.map → BotSettingsDialog-wWHnGtBg.js.map} +1 -1
- package/dist/assets/ChatView-BKNyjhWf.js +2 -0
- package/dist/assets/ChatView-BKNyjhWf.js.map +1 -0
- package/dist/assets/ChatView-ClK12dmT.css +1 -0
- package/dist/assets/{ComputerPanel-Dbwgx5n8.js → ComputerPanel-DP9Sge1E.js} +2 -2
- package/dist/assets/{ComputerPanel-Dbwgx5n8.js.map → ComputerPanel-DP9Sge1E.js.map} +1 -1
- package/dist/assets/{ComputerViewerView-csnhRedK.js → ComputerViewerView-WjPHo035.js} +2 -2
- package/dist/assets/{ComputerViewerView-csnhRedK.js.map → ComputerViewerView-WjPHo035.js.map} +1 -1
- package/dist/assets/{ConversationsView-CEO2SVGT.js → ConversationsView-BRNIpK57.js} +4 -4
- package/dist/assets/{ConversationsView-CEO2SVGT.js.map → ConversationsView-BRNIpK57.js.map} +1 -1
- package/dist/assets/{ConversationsView-CHLGKsJt.css → ConversationsView-CbArO1v2.css} +1 -1
- package/dist/assets/{FilesView-t5jA-H2-.js → FilesView-ETwEkBC-.js} +2 -2
- package/dist/assets/{FilesView-t5jA-H2-.js.map → FilesView-ETwEkBC-.js.map} +1 -1
- package/dist/assets/{FloatingResourceSearch-BAYymuJV.js → FloatingResourceSearch-CxF6Ko17.js} +2 -2
- package/dist/assets/{FloatingResourceSearch-BAYymuJV.js.map → FloatingResourceSearch-CxF6Ko17.js.map} +1 -1
- package/dist/assets/{HistoryView-BqMSV9iC.js → HistoryView-uwkxvrTT.js} +2 -2
- package/dist/assets/{HistoryView-BqMSV9iC.js.map → HistoryView-uwkxvrTT.js.map} +1 -1
- package/dist/assets/{KanbanView-CWwrwH9S.js → KanbanView-BjiWhQiB.js} +2 -2
- package/dist/assets/{KanbanView-CWwrwH9S.js.map → KanbanView-BjiWhQiB.js.map} +1 -1
- package/dist/assets/{LocalVmSettingsPanel-BXvZwFQP.js → LocalVmSettingsPanel-BAVywgEJ.js} +2 -2
- package/dist/assets/{LocalVmSettingsPanel-BXvZwFQP.js.map → LocalVmSettingsPanel-BAVywgEJ.js.map} +1 -1
- package/dist/assets/{RunnerSettingsPanel-KkpIkkob.js → RunnerSettingsPanel-spsPiohB.js} +2 -2
- package/dist/assets/{RunnerSettingsPanel-KkpIkkob.js.map → RunnerSettingsPanel-spsPiohB.js.map} +1 -1
- package/dist/assets/{StandaloneDialog-D4BQqjpB.js → StandaloneDialog-Ctcd4omg.js} +2 -2
- package/dist/assets/{StandaloneDialog-D4BQqjpB.js.map → StandaloneDialog-Ctcd4omg.js.map} +1 -1
- package/dist/assets/{UpdateCheckDialog-Ct0bT6xU.js → UpdateCheckDialog-C43LDN1t.js} +2 -2
- package/dist/assets/{UpdateCheckDialog-Ct0bT6xU.js.map → UpdateCheckDialog-C43LDN1t.js.map} +1 -1
- package/dist/assets/{WorkspaceKnowledgePanel-WBcPB49x.js → WorkspaceKnowledgePanel-CDbdIzXZ.js} +2 -2
- package/dist/assets/{WorkspaceKnowledgePanel-WBcPB49x.js.map → WorkspaceKnowledgePanel-CDbdIzXZ.js.map} +1 -1
- package/dist/assets/{WorkspaceRoutinesPanel-JubUwGsV.js → WorkspaceRoutinesPanel-h7wcBTnK.js} +2 -2
- package/dist/assets/{WorkspaceRoutinesPanel-JubUwGsV.js.map → WorkspaceRoutinesPanel-h7wcBTnK.js.map} +1 -1
- package/dist/assets/WorkspaceShell-Bx8se0l7.js +44 -0
- package/dist/assets/WorkspaceShell-Bx8se0l7.js.map +1 -0
- package/dist/assets/WorkspaceShell-DXti6BpF.css +1 -0
- package/dist/assets/{WorkspaceView-DTanioWW.js → WorkspaceView-zDyCd5Ys.js} +2 -2
- package/dist/assets/{WorkspaceView-DTanioWW.js.map → WorkspaceView-zDyCd5Ys.js.map} +1 -1
- package/dist/assets/{docx-preview-B1SjJgD_.js → docx-preview-DOVGRYbk.js} +2 -2
- package/dist/assets/{docx-preview-B1SjJgD_.js.map → docx-preview-DOVGRYbk.js.map} +1 -1
- package/dist/assets/{index-CWamgtSb.js → index-CRBIQ5t6.js} +4 -4
- package/dist/assets/index-CRBIQ5t6.js.map +1 -0
- package/dist/assets/{pdf-DVDddcFC.js → pdf-CyfBRmEm.js} +2 -2
- package/dist/assets/{pdf-DVDddcFC.js.map → pdf-CyfBRmEm.js.map} +1 -1
- package/dist/assets/{sessionOwnership-0hdKcwOs.js → sessionOwnership-BhbWRxbS.js} +2 -2
- package/dist/assets/{sessionOwnership-0hdKcwOs.js.map → sessionOwnership-BhbWRxbS.js.map} +1 -1
- package/dist/assets/{viewModels-DKBqaDRg.js → viewModels-DNhmBuoz.js} +4 -4
- package/dist/assets/{viewModels-DKBqaDRg.js.map → viewModels-DNhmBuoz.js.map} +1 -1
- package/dist/index.html +1 -1
- package/dist/provider-logos/airtable.svg +13 -0
- package/dist/provider-logos/discord.svg +15 -0
- package/dist/provider-logos/github.svg +10 -0
- package/dist/provider-logos/gmail.svg +1 -0
- package/dist/provider-logos/googlecalendar.svg +148 -0
- package/dist/provider-logos/googledrive.svg +25 -0
- package/dist/provider-logos/linear.svg +5 -0
- package/dist/provider-logos/notion.svg +11 -0
- package/dist/provider-logos/outlook.svg +76 -0
- package/dist/provider-logos/slack.svg +22 -0
- package/dist/provider-logos/trello.svg +19 -0
- package/dist/provider-logos/twitter.svg +128 -0
- package/dist-server/server/app.js +2 -2
- package/dist-server/server/botPlugins/connectedApps.js +3 -2
- package/dist-server/server/credentialVault/coordinator.js +3 -1
- package/dist-server/server/credentialVault/localClient.js +70 -0
- package/dist-server/server/credentialVault/transport.js +1 -0
- package/dist-server/server/dashboardCommand.js +62 -0
- package/dist-server/server/dashboardController.js +117 -25
- package/dist-server/server/routes.js +5 -0
- package/dist-server/server/security.js +2 -1
- package/dist-server/shared/botProviderLogos.js +61 -0
- package/package.json +1 -1
- package/release.json +3 -3
- package/dist/assets/BotPluginsDialog-Db5dTqvg.css +0 -1
- package/dist/assets/BotPluginsDialog-H85RI-7P.js +0 -2
- package/dist/assets/BotPluginsDialog-H85RI-7P.js.map +0 -1
- package/dist/assets/ChatView-6cdLMsuy.js +0 -2
- package/dist/assets/ChatView-6cdLMsuy.js.map +0 -1
- package/dist/assets/ChatView-C_7_7olu.css +0 -1
- package/dist/assets/WorkspaceShell-0m4gg6AW.css +0 -1
- package/dist/assets/WorkspaceShell-Do2VAwIz.js +0 -44
- package/dist/assets/WorkspaceShell-Do2VAwIz.js.map +0 -1
- package/dist/assets/index-CWamgtSb.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatView-BKNyjhWf.js","names":[],"sources":["../../src/client/components/workspace/pendingComposer.ts","../../src/client/views/ChatView.vue","../../src/client/views/ChatView.vue"],"sourcesContent":["import type { UiLibraryItem } from '@/components/library/types'\n\nconst KEY = 'hermes-yaoyao:pending-composer-item'\n\ntype PendingItem = { name: string; url: string; mimeType?: string }\n\ntype ComposerFileSource = Pick<UiLibraryItem, 'name' | 'previewUrl' | 'downloadUrl' | 'mimeType'>\n\nexport function queueLibraryItemForComposer(item: UiLibraryItem): boolean {\n const url = item.downloadUrl || item.previewUrl\n if (!url) return false\n const pending: PendingItem = { name: item.name, url, mimeType: item.mimeType }\n sessionStorage.setItem(KEY, JSON.stringify(pending))\n return true\n}\n\nexport async function loadComposerFile(item: ComposerFileSource): Promise<File | null> {\n const url = item.downloadUrl || item.previewUrl\n if (!url || !item.name) return null\n try {\n const response = await fetch(url, { credentials: 'same-origin' })\n if (!response.ok) throw new Error(`下载文件失败(${response.status})`)\n const blob = await response.blob()\n return new File([blob], item.name, { type: item.mimeType || blob.type || 'application/octet-stream' })\n } catch {\n return null\n }\n}\n\nexport async function consumeLibraryItemForComposer(): Promise<File | null> {\n const raw = sessionStorage.getItem(KEY)\n if (!raw) return null\n sessionStorage.removeItem(KEY)\n try {\n const pending = JSON.parse(raw) as PendingItem\n return await loadComposerFile({ name: pending.name, downloadUrl: pending.url, mimeType: pending.mimeType })\n } catch {\n return null\n }\n}\n","<script setup lang=\"ts\">\nimport {useUnreadStore} from '@/stores/unread'\nimport { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useRoute, useRouter } from 'vue-router'\nimport AppIcon from '@/components/common/AppIcon.vue'\nimport YaoYaoSidebarIcon from '@/components/common/YaoYaoSidebarIcon.vue'\nimport StandaloneDialog from '@/components/common/StandaloneDialog.vue'\nimport type { SessionSummary } from '@shared/types'\nimport type { ChoiceOption } from '@/components/common/types'\nimport ComposerShell from '@/components/composer/ComposerShell.vue'\nimport ModelChoiceDialog from '@/components/composer/ModelChoiceDialog.vue'\nimport type { ComposerOption, ComposerReference, ComposerSubmit } from '@/components/composer/types'\nimport PreviewInspector from '@/components/library/PreviewInspector.vue'\nimport PreviewModal from '@/components/library/PreviewModal.vue'\nimport ImagePreviewLightbox from '@/components/library/ImagePreviewLightbox.vue'\nimport type { PreviewMedia } from '@/components/library/ImagePreviewLightbox.vue'\nimport type { UiLibraryItem } from '@/components/library/types'\nimport { mediaItemsFromMessages, mediaUrlIdentity, previewItemFromUrl } from '@/components/library/mediaSequence'\nimport MessageTimeline from '@/components/messages/MessageTimeline.vue'\nimport SessionOutline from '@/components/messages/SessionOutline.vue'\nimport type { UiMessage } from '@/components/messages/types'\nimport ResourceSidebar from '@/components/app/ResourceSidebar.vue'\nimport FloatingResourceSearch from '@/components/app/FloatingResourceSearch.vue'\nimport WorkspaceView from '@/components/workspace/WorkspaceView.vue'\nimport { chatInteraction, chatMessagesToUi, sessionSidebarItem } from '@/components/workspace/viewModels'\nimport { consumeLibraryItemForComposer, loadComposerFile } from '@/components/workspace/pendingComposer'\nimport { readAgentShowThinking, writeAgentShowThinking } from '@/utils/sessionPreferences'\nimport { modelChoiceId, modelForChoiceId } from '@/utils/sessionModel'\nimport { MODEL_CATALOG_CHANGED_EVENT, modelCatalogChangedProfile } from '@/utils/modelCatalogEvents'\nimport { isOwnedChatSession } from '@/utils/sessionOwnership'\nimport { useAuthStore } from '@/stores/auth'\nimport { useChatStore } from '@/stores/chat'\nimport { getSession } from '@/api/sessions'\n\nconst unread=useUnreadStore()\nconst auth = useAuthStore()\nconst chat = useChatStore()\nconst route = useRoute()\nconst router = useRouter()\nconst quoted = ref<UiMessage | null>(null)\nconst preview = ref<UiLibraryItem | null>(null)\nconst filePreview = ref<UiLibraryItem | null>(null)\nconst mediaPreviewIndex = ref<number | null>(null)\nconst outlineOpen = ref(false)\nconst modelDialog = ref(false)\nconst modelSwitching = ref(false)\nconst showThinking = ref(false)\nconst queueMode = ref(false)\nconst actionSessionId = ref('')\nconst renaming = ref(false)\nconst pendingDeleteSession = ref<Pick<SessionSummary, 'id' | 'profile' | 'title'> | null>(null)\nconst deletingSession = ref(false)\nconst deleteSessionError = ref('')\nconst renameValue = ref('')\nconst actionMenuPosition = ref({ x: 8, y: 8 })\nconst composer = ref<InstanceType<typeof ComposerShell> | null>(null)\nconst timeline = ref<InstanceType<typeof MessageTimeline> | null>(null)\nconst headerSessionMenuButton = ref<HTMLButtonElement | null>(null)\nconst restoringRouteProfile = ref('')\n\nfunction handleModelCatalogChanged(event: Event) {\n const profile = modelCatalogChangedProfile(event)\n if (profile && profile === auth.activeProfile?.name) void chat.loadModels(profile).catch(() => undefined)\n}\n\nconst sessions = computed(() => [...chat.sessions]\n .filter(isOwnedChatSession))\nconst agentNames = computed(() => new Map(auth.profiles.map(profile => [\n profile.name,\n profile.agentName || profile.displayName || profile.name,\n])))\nconst agentAvatars = computed(() => Object.fromEntries(auth.profiles.flatMap(profile =>\n profile.agentAvatar ? [[profile.name, profile.agentAvatar] as const] : []\n)))\nconst sidebarItems = computed(() => sessions.value.map(session => sessionSidebarItem(\n session,\n unread.snapshot.conversations.find(c=>c.mode==='chat'&&c.id===session.id&&c.profile===session.profile)?.count ?? 0,\n agentNames.value.get(session.profile || auth.activeProfile?.name || ''),\n)))\nconst messages = computed(() => chatMessagesToUi(chat.messages, profile => profile ? agentNames.value.get(profile) : undefined))\nconst conversationMediaItems = computed(() => mediaItemsFromMessages(messages.value))\nconst lightboxMedia = computed(() => conversationMediaItems.value.map(item => ({ url: item.previewUrl || item.downloadUrl || '', name: item.name, type: item.kind as 'image' | 'video' })).filter(item => item.url))\nconst activeSession = computed(() => chat.activeSession)\nconst actionSession = computed(() => chat.sessions.find(session => session.id === actionSessionId.value))\nconst connected = computed(() => ['connected', 'ready'].includes(chat.connectionState))\nconst interaction = computed(() => chatInteraction(chat.pendingApproval, chat.pendingClarification))\nconst reference = computed<ComposerReference | null>(() => quoted.value ? { id: quoted.value.id, content: quoted.value.content, author: quoted.value.author } : null)\nconst forkSourceTitle = computed(() => {\n const parentId = activeSession.value?.parentSessionId\n if (!parentId) return ''\n return chat.sessions.find(session => session.id === parentId && session.profile === activeSession.value?.profile)?.title || parentId\n})\nconst selectedModelId = computed(() => chat.selectedModel ? modelChoiceId(chat.selectedModel) : '')\nconst reasoningOptions: ChoiceOption[] = [\n { id: '', label: '默认', description: '使用模型或 Profile 的默认强度' },\n { id: 'none', label: '关闭', description: '不使用额外推理' },\n { id: 'low', label: '低', description: '更快的轻量推理' },\n { id: 'medium', label: '中', description: '速度与深度平衡' },\n { id: 'high', label: '高', description: '更深入地分析复杂问题' },\n { id: 'xhigh', label: '极高', description: '适用于最复杂的任务' },\n]\nconst reasoningComposerOptions = computed<ComposerOption[]>(() => reasoningOptions.map(option => ({\n id: option.id,\n label: option.label,\n detail: option.description,\n})))\nconst reasoningLabel = computed(() => reasoningOptions.find(option => option.id === (chat.reasoningEffort || ''))?.label || '默认')\nconst actionMenuStyle = computed(() => ({ left: `${actionMenuPosition.value.x}px`, top: `${actionMenuPosition.value.y}px` }))\n\nfunction routeProfile(): string {\n const value = typeof route.query.profile === 'string' ? route.query.profile : ''\n return auth.profiles.some(profile => profile.name === value) ? value : ''\n}\n\nfunction sessionLocation(id: string, profile: string) {\n return { path: `/chat/${encodeURIComponent(id)}`, query: { profile } }\n}\n\nasync function findLegacySessionProfile(sessionId: string): Promise<string> {\n for (const profile of auth.profiles) {\n try {\n const session = await getSession(sessionId, profile.name)\n if (session.id === sessionId) return profile.name\n } catch { /* Try the next profile: 9119 returns 404 for a foreign session. */ }\n }\n return auth.activeProfile?.name || ''\n}\n\nasync function ensureRouteProfile(profile: string): Promise<void> {\n if (!profile || auth.activeProfile?.name === profile) return\n chat.switchProfile(profile)\n restoringRouteProfile.value = profile\n auth.selectProfile(profile)\n await nextTick()\n}\n\nasync function refreshSessions() {\n const requestedId = typeof route.params.sessionId === 'string' ? route.params.sessionId : ''\n const profile = routeProfile() || (requestedId ? await findLegacySessionProfile(requestedId) : auth.activeProfile?.name || '')\n if (profile && auth.activeProfile?.name !== profile) {\n if (requestedId) await router.replace(sessionLocation(requestedId, profile))\n await ensureRouteProfile(profile)\n }\n // The session route is the authoritative navigation target. A secondary\n // unread-count request must never prevent its history from being restored.\n await chat.loadSessions(profile, 'chat')\n if (requestedId) {\n const target = await getSession(requestedId, profile).catch(() => undefined)\n if (target && !isOwnedChatSession(target)) {\n await router.replace({ path: `/history/${encodeURIComponent(requestedId)}`, query: { profile } })\n return\n }\n }\n if (requestedId && chat.activeSessionId !== requestedId) await chat.selectSession(requestedId, profile)\n if (requestedId && profile && routeProfile() !== profile) await router.replace(sessionLocation(requestedId, profile))\n void chat.loadUnread(profile).catch(() => undefined)\n if (!requestedId && chat.activeSession && !isOwnedChatSession(chat.activeSession)) {\n chat.clearSelection()\n }\n}\n\nconst readPending=new Set<string>()\nasync function markVisible(ids:string[]){\n if(preview.value||filePreview.value||outlineOpen.value||modelDialog.value||!chat.activeSessionId||typeof route.query.unread==='string')return\n const session=chat.activeSessionId,profile=chat.activeProfileName,key=`${profile}:${session}:${ids.join(',')}`\n if(readPending.has(key))return\n readPending.add(key);try{await unread.visible('chat',session,profile,ids)}catch{}finally{readPending.delete(key)}\n}\nlet unreadNavigation=0\nwatch(()=>[route.params.id,route.query.unread,chat.messages.length],async()=>{\n const id=route.query.unread;if(typeof id!=='string'||!chat.activeSessionId)return\n const own=++unreadNavigation\n for(let i=0;i<100&&own===unreadNavigation;i++){\n await nextTick();if(timeline.value?.scrollToMessage(id)){const query={...route.query};delete query.unread;await router.replace({query});return}\n if(!chat.hasMoreBefore)return\n const before=chat.messages.length;await chat.loadOlder();if(chat.messages.length===before)return\n }\n},{flush:'post'})\nasync function chooseSession(id: string) {\n outlineOpen.value = false\n preview.value = null\n const session = chat.sessions.find(item => item.id === id)\n const profile = session?.profile || auth.activeProfile?.name || 'default'\n await router.push(sessionLocation(id, profile))\n await ensureRouteProfile(profile)\n if (chat.activeProfileName !== profile) await chat.loadSessions(profile, 'chat')\n await chat.selectSession(id, profile)\n\n quoted.value = null\n}\n\nasync function createSession() {\n outlineOpen.value = false\n preview.value = null\n const id = chat.createSession(auth.activeProfile?.name)\n await router.push(sessionLocation(id, auth.activeProfile?.name || 'default'))\n}\n\nasync function send(payload: ComposerSubmit) {\n try {\n await chat.send(payload.text, payload.files, queueMode.value ? 'queue' : chat.isStreaming ? 'steer' : 'submit')\n composer.value?.clearAfterSend()\n } catch { /* store exposes the error and the composer keeps its draft */ }\n}\n\nfunction openAttachment(attachment: NonNullable<UiMessage['attachments']>[number]) {\n const item = previewItemFromUrl(attachment.name, attachment.url || '', attachment.id, attachment.kind)\n item.size = attachment.size\n if (item.kind === 'image' || item.kind === 'video') openMedia(item)\n else { outlineOpen.value = false; preview.value = null; filePreview.value = item }\n}\n\nfunction openMedia(item: UiLibraryItem) {\n const target = mediaUrlIdentity(item.previewUrl || item.downloadUrl || '')\n const index = lightboxMedia.value.findIndex(media => mediaUrlIdentity(media.url) === target)\n mediaPreviewIndex.value = index >= 0 ? index : null\n}\n\nfunction openLocalFile({ name, url }: { name: string; url: string }) {\n const item = previewItemFromUrl(name, url)\n if (item.kind === 'image' || item.kind === 'video') openMedia(item)\n else { outlineOpen.value = false; filePreview.value = item }\n}\n\nasync function addPreviewToComposer(item: UiLibraryItem) {\n const file = await loadComposerFile(item)\n if (!file || !composer.value) return\n composer.value.attachFiles([file])\n preview.value = null\n filePreview.value = null\n mediaPreviewIndex.value = null\n await nextTick()\n composer.value?.focus()\n}\n\nasync function addMediaToComposer(media: PreviewMedia) {\n await addPreviewToComposer(previewItemFromUrl(media.name, media.url, `preview:${media.url}`, media.type))\n}\n\nasync function selectModel(id: string) {\n if (id === selectedModelId.value) {\n modelDialog.value = false\n return\n }\n const model = modelForChoiceId(chat.models, id)\n if (!model || modelSwitching.value) return\n modelSwitching.value = true\n try {\n await chat.setModel(model)\n modelDialog.value = false\n } finally {\n modelSwitching.value = false\n }\n}\n\nfunction selectReasoning(id: string) {\n chat.reasoningEffort = id || undefined\n}\n\nasync function toggleFastMode(enabled: boolean) {\n try { await chat.setFastMode(enabled) } catch { /* store restores the acknowledged state */ }\n}\n\nfunction restoreShowThinking(profile = auth.activeProfile?.name || 'default') {\n showThinking.value = readAgentShowThinking(auth.user?.id ?? 'local', profile)\n}\n\nfunction toggleShowThinking() {\n showThinking.value = !showThinking.value\n writeAgentShowThinking(auth.user?.id ?? 'local', auth.activeProfile?.name || 'default', showThinking.value)\n}\n\nfunction openSessionActions(id: string, event?: MouseEvent) {\n actionSessionId.value = id\n const session = chat.sessions.find(item => item.id === id)\n renameValue.value = session?.title || ''\n renaming.value = false\n const menuWidth = 208\n const menuHeight = 210\n const inset = 8\n const anchor = event?.currentTarget instanceof HTMLElement ? event.currentTarget.getBoundingClientRect() : null\n const requestedX = event?.type === 'contextmenu' ? event.clientX : anchor ? anchor.right - menuWidth : window.innerWidth - menuWidth - 14\n const requestedY = event?.type === 'contextmenu' ? event.clientY : anchor ? anchor.bottom + 5 : 46\n actionMenuPosition.value = {\n x: Math.max(inset, Math.min(requestedX, window.innerWidth - menuWidth - inset)),\n y: Math.max(inset, Math.min(requestedY, window.innerHeight - menuHeight - inset)),\n }\n}\n\nfunction closeSessionActions() {\n actionSessionId.value = ''\n renaming.value = false\n}\n\nasync function forceRefreshHistory() {\n closeSessionActions()\n try { await chat.forceRefreshHistory() }\n catch { /* The chat store displays the refresh error without clearing messages. */ }\n}\n\nfunction handleSessionActionPointer(event: PointerEvent) {\n if (!actionSessionId.value || (event.target as HTMLElement).closest('.session-actions')) return\n closeSessionActions()\n}\n\nfunction handleSessionActionKey(event: KeyboardEvent) {\n if (event.key === 'Escape' && actionSessionId.value) closeSessionActions()\n}\n\nasync function saveRename() {\n const session = chat.sessions.find(item => item.id === actionSessionId.value)\n if (!session || !renameValue.value.trim()) return\n await chat.renameSession(session.id, renameValue.value.trim(), session.profile)\n closeSessionActions()\n}\n\nasync function toggleSessionPinned() {\n const session = actionSession.value\n if (!session) return\n await chat.setSessionPinned(session.id, !session.pinned, session.profile)\n closeSessionActions()\n}\n\nasync function openSessionOutline() {\n const session = actionSession.value\n if (!session) return\n closeSessionActions()\n if (session.id !== chat.activeSessionId || session.profile !== chat.activeProfileName) await chooseSession(session.id)\n preview.value = null\n outlineOpen.value = true\n}\n\nfunction closeInspector() {\n const restoreMenuFocus = outlineOpen.value\n preview.value = null\n outlineOpen.value = false\n if (restoreMenuFocus) void nextTick(() => headerSessionMenuButton.value?.focus())\n}\n\nfunction navigateOutline(target: { messageId: string; anchorId: string }) {\n timeline.value?.scrollToAnchor(target.messageId, target.anchorId)\n if (window.matchMedia('(max-width: 900px)').matches) closeInspector()\n}\n\nfunction confirmDeleteSession() {\n const session = actionSession.value\n if (!session) return\n pendingDeleteSession.value = { id: session.id, profile: session.profile, title: session.title }\n deleteSessionError.value = ''\n closeSessionActions()\n}\n\nfunction cancelDeleteSession() {\n if (deletingSession.value) return\n pendingDeleteSession.value = null\n deleteSessionError.value = ''\n void nextTick(() => headerSessionMenuButton.value?.focus())\n}\n\nasync function deleteSession() {\n const session = pendingDeleteSession.value\n if (!session || deletingSession.value) return\n deletingSession.value = true\n deleteSessionError.value = ''\n try {\n await chat.removeSession(session.id, session.profile)\n if (route.params.sessionId === session.id) await router.replace({ path: '/chat', query: { profile: session.profile } })\n pendingDeleteSession.value = null\n } catch (cause) {\n deleteSessionError.value = cause instanceof Error ? cause.message : '删除失败,请重试'\n } finally {\n deletingSession.value = false\n }\n}\n\nasync function branch() {\n const id = await chat.branchSession()\n if (id) await router.push(sessionLocation(id, chat.activeProfileName || auth.activeProfile?.name || 'default'))\n}\n\nasync function revealSourceMessage() {\n const messageId = typeof route.query.message === 'string' ? route.query.message : ''\n if (!messageId) return\n await nextTick()\n for (let attempt = 0; attempt < 10; attempt += 1) {\n if (timeline.value?.scrollToMessage(messageId)) return\n if (!chat.hasMoreBefore) return\n await chat.loadOlder()\n await nextTick()\n }\n}\n\nonMounted(async () => {\n restoreShowThinking()\n document.addEventListener('pointerdown', handleSessionActionPointer)\n document.addEventListener('keydown', handleSessionActionKey)\n window.addEventListener(MODEL_CATALOG_CHANGED_EVENT, handleModelCatalogChanged)\n await refreshSessions()\n await Promise.allSettled([chat.loadModels(auth.activeProfile?.name), chat.connect()])\n void chat.refreshActiveSessionModel().catch(() => undefined)\n await revealSourceMessage()\n const pendingFile = await consumeLibraryItemForComposer()\n if (pendingFile) composer.value?.attachFiles([pendingFile])\n})\n\nonBeforeUnmount(() => {\n document.removeEventListener('pointerdown', handleSessionActionPointer)\n document.removeEventListener('keydown', handleSessionActionKey)\n window.removeEventListener(MODEL_CATALOG_CHANGED_EVENT, handleModelCatalogChanged)\n})\n\nwatch(() => auth.activeProfile?.name, async (profile, previous) => {\n if (!profile || profile === previous) return\n restoreShowThinking(profile)\n outlineOpen.value = false\n preview.value = null\n if (restoringRouteProfile.value === profile) {\n restoringRouteProfile.value = ''\n return\n }\n chat.switchProfile(profile)\n const requestedId = typeof route.params.sessionId === 'string' ? route.params.sessionId : ''\n if (requestedId && routeProfile() === profile) {\n await Promise.allSettled([chat.loadSessions(profile, 'chat'), chat.loadModels(profile), chat.loadUnread(profile), chat.connect()])\n await chat.selectSession(requestedId, profile)\n return\n }\n await router.replace({ path: '/chat', query: { profile } })\n await Promise.allSettled([chat.loadSessions(profile, 'chat'), chat.loadModels(profile), chat.loadUnread(profile), chat.connect()])\n})\n\nwatch(() => chat.activeSessionId, async id => {\n const profile = chat.activeProfileName || auth.activeProfile?.name || ''\n if (id) void chat.refreshActiveSessionModel().catch(() => undefined)\n if (!id || (route.params.sessionId === id && routeProfile() === profile)) return\n await router.replace(sessionLocation(id, profile))\n})\n</script>\n\n<template>\n <WorkspaceView sidebar-title=\"对话\" :sidebar-subtitle=\"`${sessions.length} 个会话`\" :inspector-open=\"!!preview || outlineOpen\" :inspector-close-label=\"outlineOpen ? '关闭会话大纲' : '关闭预览'\" @close-inspector=\"closeInspector\">\n <template #sidebar-action>\n <button class=\"sidebar-primary-action\" type=\"button\" title=\"新建聊天\" aria-label=\"新建聊天\" @click=\"createSession\">\n <YaoYaoSidebarIcon name=\"add\" />\n <span>新建聊天</span>\n </button>\n </template>\n <template #sidebar>\n <ResourceSidebar\n :items=\"sidebarItems\"\n :active-id=\"chat.activeSessionId\"\n :loading=\"chat.isLoading\"\n external-search\n single-line\n :has-more=\"chat.hasMoreSessions\"\n :loading-more=\"chat.isLoadingMoreSessions\"\n search-placeholder=\"搜索会话\"\n empty-title=\"还没有会话\"\n empty-description=\"新建会话后,从输入框开始聊天。\"\n @load-more=\"chat.loadMoreSessions(auth.activeProfile?.name)\"\n @select=\"chooseSession\"\n @more=\"openSessionActions\"\n @context-menu=\"openSessionActions\"\n />\n </template>\n\n <div class=\"chat-workspace\">\n <MessageTimeline\n @visible-messages=\"markVisible\"\n ref=\"timeline\"\n :messages=\"messages\"\n :title=\"activeSession?.title || '新会话'\"\n :subtitle=\"activeSession ? `${activeSession.profile || auth.activeProfile?.name || ''} · ${activeSession.model || chat.selectedModel?.name || '默认模型'}` : '选择会话或直接开始输入'\"\n :loading=\"chat.activeRouteState?.isLoadingHistory\"\n :loading-older=\"chat.activeRouteState?.isLoadingHistory\"\n :has-older=\"chat.hasMoreBefore\"\n :connected=\"connected\"\n :synced=\"chat.historySynced\"\n :show-tools=\"showThinking\"\n :thinking=\"chat.isSending || chat.isStreaming\"\n :show-assistant-identity=\"false\"\n :agent-avatars=\"agentAvatars\"\n :interaction=\"interaction\"\n empty-logo\n transparent-header\n :fork-source-title=\"forkSourceTitle\"\n @load-older=\"chat.loadOlder\"\n @quote=\"quoted = $event\"\n @branch=\"branch\"\n @preview=\"openAttachment\"\n @preview-file=\"openLocalFile\"\n @approve=\"interaction && chat.respondToApproval(interaction.id, $event)\"\n @clarify=\"interaction && chat.respondToClarification(interaction.id, $event)\"\n >\n <template #header-actions>\n <button v-if=\"activeSession\" ref=\"headerSessionMenuButton\" class=\"icon-button header-session-menu\" type=\"button\" title=\"会话操作\" aria-label=\"会话操作\" @click=\"openSessionActions(activeSession.id, $event)\"><AppIcon name=\"dots\" :size=\"18\" /></button>\n </template>\n </MessageTimeline>\n <p v-if=\"chat.error\" class=\"chat-error\" role=\"alert\"><AppIcon name=\"alert\" :size=\"13\" />{{ chat.error }}</p>\n <ComposerShell\n ref=\"composer\"\n mode=\"chat\"\n :draft-key=\"`${auth.user?.id || 'local'}:${auth.activeProfile?.name || 'default'}:${chat.activeSessionId || 'new'}`\"\n :disabled=\"chat.connectionState === 'failed'\"\n :streaming=\"chat.isStreaming\"\n :sending=\"chat.isSending\"\n :model-label=\"chat.selectedModel?.name || '选择模型'\"\n :fast-mode=\"chat.fastMode\"\n :fast-mode-disabled=\"!chat.activeSessionId\"\n :reasoning-effort=\"reasoningLabel\"\n :reasoning-value=\"chat.reasoningEffort || ''\"\n :reasoning-options=\"reasoningComposerOptions\"\n show-context\n :context-used=\"chat.contextUsage?.contextTokens\"\n :context-limit=\"chat.contextUsage?.contextLimit\"\n :context-percent=\"chat.contextUsage?.percentUsed\"\n :queue-mode=\"queueMode || chat.isQueued\"\n :tool-trace-visible=\"showThinking\"\n :reference=\"reference\"\n :slash-commands=\"[\n { id: 'fork', label: 'fork', detail: '从当前会话创建分支' },\n { id: 'compact', label: 'compact', detail: '压缩当前会话上下文' },\n { id: 'model', label: 'model', detail: '切换模型' },\n ]\"\n @send=\"send\"\n @stop=\"chat.interrupt\"\n @model-click=\"modelDialog = true\"\n @fast-mode-toggle=\"toggleFastMode\"\n @reasoning-change=\"selectReasoning\"\n @settings-click=\"toggleShowThinking\"\n @queue-toggle=\"queueMode = !queueMode\"\n @clear-reference=\"quoted = null\"\n />\n </div>\n\n <template #inspector>\n <SessionOutline v-if=\"outlineOpen\" :messages=\"messages\" :has-older=\"chat.hasMoreBefore\" @navigate=\"navigateOutline\" />\n <PreviewInspector v-else-if=\"preview\" :item=\"preview\" @close=\"preview = null\" @add-to-composer=\"addPreviewToComposer\" />\n </template>\n </WorkspaceView>\n\n <FloatingResourceSearch section=\"chat\" label=\"搜索会话\" :items=\"sidebarItems\" @select=\"chooseSession\" />\n <PreviewModal v-if=\"filePreview\" :item=\"filePreview\" :items=\"conversationMediaItems\" @close=\"filePreview = null\" @add-to-composer=\"addPreviewToComposer\" @source=\"filePreview = null\" />\n <ImagePreviewLightbox v-model=\"mediaPreviewIndex\" :images=\"lightboxMedia\" @add=\"addMediaToComposer\" />\n\n <ModelChoiceDialog :open=\"modelDialog\" :options=\"chat.models\" :selected-id=\"selectedModelId\" :busy=\"modelSwitching\" @close=\"modelDialog = false\" @select=\"selectModel\" />\n\n <StandaloneDialog v-if=\"pendingDeleteSession\" title=\"删除会话\" compact :before-close=\"() => !deletingSession\" @close=\"cancelDeleteSession\">\n <div class=\"session-delete\" :aria-busy=\"deletingSession\">\n <p>确定删除「{{ pendingDeleteSession.title || '新会话' }}」吗?删除后无法恢复。</p>\n <p v-if=\"deleteSessionError\" class=\"session-delete-error\" role=\"alert\">{{ deleteSessionError }}</p>\n <div class=\"session-delete-actions\">\n <button class=\"quiet-button\" type=\"button\" :disabled=\"deletingSession\" @click=\"cancelDeleteSession\">取消</button>\n <button class=\"solid-button session-delete-confirm\" type=\"button\" :disabled=\"deletingSession\" @click=\"deleteSession\">{{ deletingSession ? '删除中…' : '删除' }}</button>\n </div>\n </div>\n </StandaloneDialog>\n\n <Teleport to=\"body\">\n <Transition name=\"session-menu\">\n <section v-if=\"actionSessionId\" class=\"session-actions\" :style=\"actionMenuStyle\" role=\"menu\" aria-label=\"会话操作\" @contextmenu.prevent>\n <template v-if=\"renaming\">\n <label>会话名称<input v-model=\"renameValue\" maxlength=\"120\" autofocus @keydown.enter=\"saveRename\" /></label>\n <div><button class=\"quiet-button\" type=\"button\" @click=\"renaming = false\">取消</button><button class=\"solid-button\" type=\"button\" @click=\"saveRename\">保存</button></div>\n </template>\n <template v-else>\n <button class=\"action-row\" role=\"menuitem\" type=\"button\" @click=\"openSessionOutline\"><AppIcon name=\"menu\" :size=\"14\" />会话大纲</button>\n <button v-if=\"actionSessionId === chat.activeSessionId\" class=\"action-row\" role=\"menuitem\" type=\"button\" :disabled=\"chat.isStreaming || chat.isQueued || chat.isSending || chat.activeRouteState?.isLoadingHistory\" @click=\"forceRefreshHistory\"><AppIcon name=\"refresh\" :size=\"14\" />强制刷新历史</button>\n <button class=\"action-row\" role=\"menuitem\" type=\"button\" @click=\"toggleSessionPinned\"><AppIcon :name=\"actionSession?.pinned ? 'pin-off' : 'pin'\" :size=\"14\" />{{ actionSession?.pinned ? '取消置顶' : '置顶会话' }}</button>\n <button class=\"action-row\" role=\"menuitem\" type=\"button\" @click=\"renaming = true\"><AppIcon name=\"edit\" :size=\"14\" />重命名</button>\n <button class=\"action-row danger\" role=\"menuitem\" type=\"button\" @click=\"confirmDeleteSession\"><AppIcon name=\"trash\" :size=\"14\" />删除会话</button>\n </template>\n </section>\n </Transition>\n </Teleport>\n</template>\n\n<style scoped>\n.chat-workspace { display: flex; min-width: 0; min-height: 0; flex: 1; flex-direction: column; }\n.session-delete p { margin: 0; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }\n.session-delete .session-delete-error { margin-top: 12px; color: var(--danger); }\n.session-delete-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }\n.session-delete-actions button { min-width: 80px; min-height: 44px; font-size: 14px; }\n.session-delete-confirm { border-color: var(--danger); background: var(--danger); color: var(--text-on-solid); }\n.session-delete-confirm:hover { transform: none; filter: brightness(.95); }\n.session-delete-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }\n.session-delete-actions button:disabled { opacity: .6; cursor: wait; }\n.sidebar-primary-action { display: flex; width: 100%; min-height: 40px; align-items: center; gap: 10px; padding: 0 11px; border: 0; border-radius: 9px; background: transparent; color: var(--text-primary); cursor: pointer; font-size: 12px; font-weight: 610; text-align: left; transition: background-color 120ms ease; }\n.sidebar-primary-action:hover, .sidebar-primary-action:focus-visible { background: var(--surface-hover); outline: 0; }\n.sidebar-primary-action:focus-visible { box-shadow: inset 0 0 0 1px var(--line-strong); }\n.header-session-menu { color: var(--text-muted); background: transparent; }.header-session-menu:hover { color: var(--text-primary); background: var(--surface-soft); }\n.chat-error { display: flex; width: min(760px, calc(100% - 32px)); margin: 0 auto 4px; align-items: center; gap: 6px; color: var(--danger); font-size: 9px; }\n.session-actions { position: fixed; z-index: 205; width: 208px; box-sizing: border-box; padding: 6px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-raised); box-shadow: 0 12px 34px rgba(0,0,0,.16); }.action-row { display: flex; width: 100%; min-height: 34px; align-items: center; gap: 8px; padding: 0 9px; border: 0; border-radius: 7px; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 11px; text-align: left; }.action-row:hover, .action-row:focus-visible { outline: 0; background: var(--surface-soft); color: var(--text-primary); }.action-row.danger { color: var(--danger); }.session-actions label { display: flex; flex-direction: column; gap: 6px; padding: 4px; color: var(--text-muted); font-size: 9px; }.session-actions input { width: 100%; height: 32px; box-sizing: border-box; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: var(--surface-soft); color: var(--text-primary); font-size: 11px; }.session-actions input:focus { border-color: var(--line-strong); box-shadow: 0 0 0 3px var(--focus-ring); }.session-actions > div { display: flex; justify-content: flex-end; gap: 5px; margin-top: 7px; padding: 0 4px 3px; }.session-actions :deep(.quiet-button), .session-actions :deep(.solid-button) { min-height: 29px; padding-inline: 10px; font-size: 10px; }\n.session-menu-enter-active, .session-menu-leave-active { transition: opacity 100ms ease, transform 120ms var(--ease-out); transform-origin: top right; }.session-menu-enter-from, .session-menu-leave-to { opacity: 0; transform: translateY(-3px) scale(.98); }\n@media (prefers-reduced-motion: reduce) { .sidebar-primary-action, .session-menu-enter-active, .session-menu-leave-active { transition: none; } }\n</style>\n","<script setup lang=\"ts\">\nimport {useUnreadStore} from '@/stores/unread'\nimport { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useRoute, useRouter } from 'vue-router'\nimport AppIcon from '@/components/common/AppIcon.vue'\nimport YaoYaoSidebarIcon from '@/components/common/YaoYaoSidebarIcon.vue'\nimport StandaloneDialog from '@/components/common/StandaloneDialog.vue'\nimport type { SessionSummary } from '@shared/types'\nimport type { ChoiceOption } from '@/components/common/types'\nimport ComposerShell from '@/components/composer/ComposerShell.vue'\nimport ModelChoiceDialog from '@/components/composer/ModelChoiceDialog.vue'\nimport type { ComposerOption, ComposerReference, ComposerSubmit } from '@/components/composer/types'\nimport PreviewInspector from '@/components/library/PreviewInspector.vue'\nimport PreviewModal from '@/components/library/PreviewModal.vue'\nimport ImagePreviewLightbox from '@/components/library/ImagePreviewLightbox.vue'\nimport type { PreviewMedia } from '@/components/library/ImagePreviewLightbox.vue'\nimport type { UiLibraryItem } from '@/components/library/types'\nimport { mediaItemsFromMessages, mediaUrlIdentity, previewItemFromUrl } from '@/components/library/mediaSequence'\nimport MessageTimeline from '@/components/messages/MessageTimeline.vue'\nimport SessionOutline from '@/components/messages/SessionOutline.vue'\nimport type { UiMessage } from '@/components/messages/types'\nimport ResourceSidebar from '@/components/app/ResourceSidebar.vue'\nimport FloatingResourceSearch from '@/components/app/FloatingResourceSearch.vue'\nimport WorkspaceView from '@/components/workspace/WorkspaceView.vue'\nimport { chatInteraction, chatMessagesToUi, sessionSidebarItem } from '@/components/workspace/viewModels'\nimport { consumeLibraryItemForComposer, loadComposerFile } from '@/components/workspace/pendingComposer'\nimport { readAgentShowThinking, writeAgentShowThinking } from '@/utils/sessionPreferences'\nimport { modelChoiceId, modelForChoiceId } from '@/utils/sessionModel'\nimport { MODEL_CATALOG_CHANGED_EVENT, modelCatalogChangedProfile } from '@/utils/modelCatalogEvents'\nimport { isOwnedChatSession } from '@/utils/sessionOwnership'\nimport { useAuthStore } from '@/stores/auth'\nimport { useChatStore } from '@/stores/chat'\nimport { getSession } from '@/api/sessions'\n\nconst unread=useUnreadStore()\nconst auth = useAuthStore()\nconst chat = useChatStore()\nconst route = useRoute()\nconst router = useRouter()\nconst quoted = ref<UiMessage | null>(null)\nconst preview = ref<UiLibraryItem | null>(null)\nconst filePreview = ref<UiLibraryItem | null>(null)\nconst mediaPreviewIndex = ref<number | null>(null)\nconst outlineOpen = ref(false)\nconst modelDialog = ref(false)\nconst modelSwitching = ref(false)\nconst showThinking = ref(false)\nconst queueMode = ref(false)\nconst actionSessionId = ref('')\nconst renaming = ref(false)\nconst pendingDeleteSession = ref<Pick<SessionSummary, 'id' | 'profile' | 'title'> | null>(null)\nconst deletingSession = ref(false)\nconst deleteSessionError = ref('')\nconst renameValue = ref('')\nconst actionMenuPosition = ref({ x: 8, y: 8 })\nconst composer = ref<InstanceType<typeof ComposerShell> | null>(null)\nconst timeline = ref<InstanceType<typeof MessageTimeline> | null>(null)\nconst headerSessionMenuButton = ref<HTMLButtonElement | null>(null)\nconst restoringRouteProfile = ref('')\n\nfunction handleModelCatalogChanged(event: Event) {\n const profile = modelCatalogChangedProfile(event)\n if (profile && profile === auth.activeProfile?.name) void chat.loadModels(profile).catch(() => undefined)\n}\n\nconst sessions = computed(() => [...chat.sessions]\n .filter(isOwnedChatSession))\nconst agentNames = computed(() => new Map(auth.profiles.map(profile => [\n profile.name,\n profile.agentName || profile.displayName || profile.name,\n])))\nconst agentAvatars = computed(() => Object.fromEntries(auth.profiles.flatMap(profile =>\n profile.agentAvatar ? [[profile.name, profile.agentAvatar] as const] : []\n)))\nconst sidebarItems = computed(() => sessions.value.map(session => sessionSidebarItem(\n session,\n unread.snapshot.conversations.find(c=>c.mode==='chat'&&c.id===session.id&&c.profile===session.profile)?.count ?? 0,\n agentNames.value.get(session.profile || auth.activeProfile?.name || ''),\n)))\nconst messages = computed(() => chatMessagesToUi(chat.messages, profile => profile ? agentNames.value.get(profile) : undefined))\nconst conversationMediaItems = computed(() => mediaItemsFromMessages(messages.value))\nconst lightboxMedia = computed(() => conversationMediaItems.value.map(item => ({ url: item.previewUrl || item.downloadUrl || '', name: item.name, type: item.kind as 'image' | 'video' })).filter(item => item.url))\nconst activeSession = computed(() => chat.activeSession)\nconst actionSession = computed(() => chat.sessions.find(session => session.id === actionSessionId.value))\nconst connected = computed(() => ['connected', 'ready'].includes(chat.connectionState))\nconst interaction = computed(() => chatInteraction(chat.pendingApproval, chat.pendingClarification))\nconst reference = computed<ComposerReference | null>(() => quoted.value ? { id: quoted.value.id, content: quoted.value.content, author: quoted.value.author } : null)\nconst forkSourceTitle = computed(() => {\n const parentId = activeSession.value?.parentSessionId\n if (!parentId) return ''\n return chat.sessions.find(session => session.id === parentId && session.profile === activeSession.value?.profile)?.title || parentId\n})\nconst selectedModelId = computed(() => chat.selectedModel ? modelChoiceId(chat.selectedModel) : '')\nconst reasoningOptions: ChoiceOption[] = [\n { id: '', label: '默认', description: '使用模型或 Profile 的默认强度' },\n { id: 'none', label: '关闭', description: '不使用额外推理' },\n { id: 'low', label: '低', description: '更快的轻量推理' },\n { id: 'medium', label: '中', description: '速度与深度平衡' },\n { id: 'high', label: '高', description: '更深入地分析复杂问题' },\n { id: 'xhigh', label: '极高', description: '适用于最复杂的任务' },\n]\nconst reasoningComposerOptions = computed<ComposerOption[]>(() => reasoningOptions.map(option => ({\n id: option.id,\n label: option.label,\n detail: option.description,\n})))\nconst reasoningLabel = computed(() => reasoningOptions.find(option => option.id === (chat.reasoningEffort || ''))?.label || '默认')\nconst actionMenuStyle = computed(() => ({ left: `${actionMenuPosition.value.x}px`, top: `${actionMenuPosition.value.y}px` }))\n\nfunction routeProfile(): string {\n const value = typeof route.query.profile === 'string' ? route.query.profile : ''\n return auth.profiles.some(profile => profile.name === value) ? value : ''\n}\n\nfunction sessionLocation(id: string, profile: string) {\n return { path: `/chat/${encodeURIComponent(id)}`, query: { profile } }\n}\n\nasync function findLegacySessionProfile(sessionId: string): Promise<string> {\n for (const profile of auth.profiles) {\n try {\n const session = await getSession(sessionId, profile.name)\n if (session.id === sessionId) return profile.name\n } catch { /* Try the next profile: 9119 returns 404 for a foreign session. */ }\n }\n return auth.activeProfile?.name || ''\n}\n\nasync function ensureRouteProfile(profile: string): Promise<void> {\n if (!profile || auth.activeProfile?.name === profile) return\n chat.switchProfile(profile)\n restoringRouteProfile.value = profile\n auth.selectProfile(profile)\n await nextTick()\n}\n\nasync function refreshSessions() {\n const requestedId = typeof route.params.sessionId === 'string' ? route.params.sessionId : ''\n const profile = routeProfile() || (requestedId ? await findLegacySessionProfile(requestedId) : auth.activeProfile?.name || '')\n if (profile && auth.activeProfile?.name !== profile) {\n if (requestedId) await router.replace(sessionLocation(requestedId, profile))\n await ensureRouteProfile(profile)\n }\n // The session route is the authoritative navigation target. A secondary\n // unread-count request must never prevent its history from being restored.\n await chat.loadSessions(profile, 'chat')\n if (requestedId) {\n const target = await getSession(requestedId, profile).catch(() => undefined)\n if (target && !isOwnedChatSession(target)) {\n await router.replace({ path: `/history/${encodeURIComponent(requestedId)}`, query: { profile } })\n return\n }\n }\n if (requestedId && chat.activeSessionId !== requestedId) await chat.selectSession(requestedId, profile)\n if (requestedId && profile && routeProfile() !== profile) await router.replace(sessionLocation(requestedId, profile))\n void chat.loadUnread(profile).catch(() => undefined)\n if (!requestedId && chat.activeSession && !isOwnedChatSession(chat.activeSession)) {\n chat.clearSelection()\n }\n}\n\nconst readPending=new Set<string>()\nasync function markVisible(ids:string[]){\n if(preview.value||filePreview.value||outlineOpen.value||modelDialog.value||!chat.activeSessionId||typeof route.query.unread==='string')return\n const session=chat.activeSessionId,profile=chat.activeProfileName,key=`${profile}:${session}:${ids.join(',')}`\n if(readPending.has(key))return\n readPending.add(key);try{await unread.visible('chat',session,profile,ids)}catch{}finally{readPending.delete(key)}\n}\nlet unreadNavigation=0\nwatch(()=>[route.params.id,route.query.unread,chat.messages.length],async()=>{\n const id=route.query.unread;if(typeof id!=='string'||!chat.activeSessionId)return\n const own=++unreadNavigation\n for(let i=0;i<100&&own===unreadNavigation;i++){\n await nextTick();if(timeline.value?.scrollToMessage(id)){const query={...route.query};delete query.unread;await router.replace({query});return}\n if(!chat.hasMoreBefore)return\n const before=chat.messages.length;await chat.loadOlder();if(chat.messages.length===before)return\n }\n},{flush:'post'})\nasync function chooseSession(id: string) {\n outlineOpen.value = false\n preview.value = null\n const session = chat.sessions.find(item => item.id === id)\n const profile = session?.profile || auth.activeProfile?.name || 'default'\n await router.push(sessionLocation(id, profile))\n await ensureRouteProfile(profile)\n if (chat.activeProfileName !== profile) await chat.loadSessions(profile, 'chat')\n await chat.selectSession(id, profile)\n\n quoted.value = null\n}\n\nasync function createSession() {\n outlineOpen.value = false\n preview.value = null\n const id = chat.createSession(auth.activeProfile?.name)\n await router.push(sessionLocation(id, auth.activeProfile?.name || 'default'))\n}\n\nasync function send(payload: ComposerSubmit) {\n try {\n await chat.send(payload.text, payload.files, queueMode.value ? 'queue' : chat.isStreaming ? 'steer' : 'submit')\n composer.value?.clearAfterSend()\n } catch { /* store exposes the error and the composer keeps its draft */ }\n}\n\nfunction openAttachment(attachment: NonNullable<UiMessage['attachments']>[number]) {\n const item = previewItemFromUrl(attachment.name, attachment.url || '', attachment.id, attachment.kind)\n item.size = attachment.size\n if (item.kind === 'image' || item.kind === 'video') openMedia(item)\n else { outlineOpen.value = false; preview.value = null; filePreview.value = item }\n}\n\nfunction openMedia(item: UiLibraryItem) {\n const target = mediaUrlIdentity(item.previewUrl || item.downloadUrl || '')\n const index = lightboxMedia.value.findIndex(media => mediaUrlIdentity(media.url) === target)\n mediaPreviewIndex.value = index >= 0 ? index : null\n}\n\nfunction openLocalFile({ name, url }: { name: string; url: string }) {\n const item = previewItemFromUrl(name, url)\n if (item.kind === 'image' || item.kind === 'video') openMedia(item)\n else { outlineOpen.value = false; filePreview.value = item }\n}\n\nasync function addPreviewToComposer(item: UiLibraryItem) {\n const file = await loadComposerFile(item)\n if (!file || !composer.value) return\n composer.value.attachFiles([file])\n preview.value = null\n filePreview.value = null\n mediaPreviewIndex.value = null\n await nextTick()\n composer.value?.focus()\n}\n\nasync function addMediaToComposer(media: PreviewMedia) {\n await addPreviewToComposer(previewItemFromUrl(media.name, media.url, `preview:${media.url}`, media.type))\n}\n\nasync function selectModel(id: string) {\n if (id === selectedModelId.value) {\n modelDialog.value = false\n return\n }\n const model = modelForChoiceId(chat.models, id)\n if (!model || modelSwitching.value) return\n modelSwitching.value = true\n try {\n await chat.setModel(model)\n modelDialog.value = false\n } finally {\n modelSwitching.value = false\n }\n}\n\nfunction selectReasoning(id: string) {\n chat.reasoningEffort = id || undefined\n}\n\nasync function toggleFastMode(enabled: boolean) {\n try { await chat.setFastMode(enabled) } catch { /* store restores the acknowledged state */ }\n}\n\nfunction restoreShowThinking(profile = auth.activeProfile?.name || 'default') {\n showThinking.value = readAgentShowThinking(auth.user?.id ?? 'local', profile)\n}\n\nfunction toggleShowThinking() {\n showThinking.value = !showThinking.value\n writeAgentShowThinking(auth.user?.id ?? 'local', auth.activeProfile?.name || 'default', showThinking.value)\n}\n\nfunction openSessionActions(id: string, event?: MouseEvent) {\n actionSessionId.value = id\n const session = chat.sessions.find(item => item.id === id)\n renameValue.value = session?.title || ''\n renaming.value = false\n const menuWidth = 208\n const menuHeight = 210\n const inset = 8\n const anchor = event?.currentTarget instanceof HTMLElement ? event.currentTarget.getBoundingClientRect() : null\n const requestedX = event?.type === 'contextmenu' ? event.clientX : anchor ? anchor.right - menuWidth : window.innerWidth - menuWidth - 14\n const requestedY = event?.type === 'contextmenu' ? event.clientY : anchor ? anchor.bottom + 5 : 46\n actionMenuPosition.value = {\n x: Math.max(inset, Math.min(requestedX, window.innerWidth - menuWidth - inset)),\n y: Math.max(inset, Math.min(requestedY, window.innerHeight - menuHeight - inset)),\n }\n}\n\nfunction closeSessionActions() {\n actionSessionId.value = ''\n renaming.value = false\n}\n\nasync function forceRefreshHistory() {\n closeSessionActions()\n try { await chat.forceRefreshHistory() }\n catch { /* The chat store displays the refresh error without clearing messages. */ }\n}\n\nfunction handleSessionActionPointer(event: PointerEvent) {\n if (!actionSessionId.value || (event.target as HTMLElement).closest('.session-actions')) return\n closeSessionActions()\n}\n\nfunction handleSessionActionKey(event: KeyboardEvent) {\n if (event.key === 'Escape' && actionSessionId.value) closeSessionActions()\n}\n\nasync function saveRename() {\n const session = chat.sessions.find(item => item.id === actionSessionId.value)\n if (!session || !renameValue.value.trim()) return\n await chat.renameSession(session.id, renameValue.value.trim(), session.profile)\n closeSessionActions()\n}\n\nasync function toggleSessionPinned() {\n const session = actionSession.value\n if (!session) return\n await chat.setSessionPinned(session.id, !session.pinned, session.profile)\n closeSessionActions()\n}\n\nasync function openSessionOutline() {\n const session = actionSession.value\n if (!session) return\n closeSessionActions()\n if (session.id !== chat.activeSessionId || session.profile !== chat.activeProfileName) await chooseSession(session.id)\n preview.value = null\n outlineOpen.value = true\n}\n\nfunction closeInspector() {\n const restoreMenuFocus = outlineOpen.value\n preview.value = null\n outlineOpen.value = false\n if (restoreMenuFocus) void nextTick(() => headerSessionMenuButton.value?.focus())\n}\n\nfunction navigateOutline(target: { messageId: string; anchorId: string }) {\n timeline.value?.scrollToAnchor(target.messageId, target.anchorId)\n if (window.matchMedia('(max-width: 900px)').matches) closeInspector()\n}\n\nfunction confirmDeleteSession() {\n const session = actionSession.value\n if (!session) return\n pendingDeleteSession.value = { id: session.id, profile: session.profile, title: session.title }\n deleteSessionError.value = ''\n closeSessionActions()\n}\n\nfunction cancelDeleteSession() {\n if (deletingSession.value) return\n pendingDeleteSession.value = null\n deleteSessionError.value = ''\n void nextTick(() => headerSessionMenuButton.value?.focus())\n}\n\nasync function deleteSession() {\n const session = pendingDeleteSession.value\n if (!session || deletingSession.value) return\n deletingSession.value = true\n deleteSessionError.value = ''\n try {\n await chat.removeSession(session.id, session.profile)\n if (route.params.sessionId === session.id) await router.replace({ path: '/chat', query: { profile: session.profile } })\n pendingDeleteSession.value = null\n } catch (cause) {\n deleteSessionError.value = cause instanceof Error ? cause.message : '删除失败,请重试'\n } finally {\n deletingSession.value = false\n }\n}\n\nasync function branch() {\n const id = await chat.branchSession()\n if (id) await router.push(sessionLocation(id, chat.activeProfileName || auth.activeProfile?.name || 'default'))\n}\n\nasync function revealSourceMessage() {\n const messageId = typeof route.query.message === 'string' ? route.query.message : ''\n if (!messageId) return\n await nextTick()\n for (let attempt = 0; attempt < 10; attempt += 1) {\n if (timeline.value?.scrollToMessage(messageId)) return\n if (!chat.hasMoreBefore) return\n await chat.loadOlder()\n await nextTick()\n }\n}\n\nonMounted(async () => {\n restoreShowThinking()\n document.addEventListener('pointerdown', handleSessionActionPointer)\n document.addEventListener('keydown', handleSessionActionKey)\n window.addEventListener(MODEL_CATALOG_CHANGED_EVENT, handleModelCatalogChanged)\n await refreshSessions()\n await Promise.allSettled([chat.loadModels(auth.activeProfile?.name), chat.connect()])\n void chat.refreshActiveSessionModel().catch(() => undefined)\n await revealSourceMessage()\n const pendingFile = await consumeLibraryItemForComposer()\n if (pendingFile) composer.value?.attachFiles([pendingFile])\n})\n\nonBeforeUnmount(() => {\n document.removeEventListener('pointerdown', handleSessionActionPointer)\n document.removeEventListener('keydown', handleSessionActionKey)\n window.removeEventListener(MODEL_CATALOG_CHANGED_EVENT, handleModelCatalogChanged)\n})\n\nwatch(() => auth.activeProfile?.name, async (profile, previous) => {\n if (!profile || profile === previous) return\n restoreShowThinking(profile)\n outlineOpen.value = false\n preview.value = null\n if (restoringRouteProfile.value === profile) {\n restoringRouteProfile.value = ''\n return\n }\n chat.switchProfile(profile)\n const requestedId = typeof route.params.sessionId === 'string' ? route.params.sessionId : ''\n if (requestedId && routeProfile() === profile) {\n await Promise.allSettled([chat.loadSessions(profile, 'chat'), chat.loadModels(profile), chat.loadUnread(profile), chat.connect()])\n await chat.selectSession(requestedId, profile)\n return\n }\n await router.replace({ path: '/chat', query: { profile } })\n await Promise.allSettled([chat.loadSessions(profile, 'chat'), chat.loadModels(profile), chat.loadUnread(profile), chat.connect()])\n})\n\nwatch(() => chat.activeSessionId, async id => {\n const profile = chat.activeProfileName || auth.activeProfile?.name || ''\n if (id) void chat.refreshActiveSessionModel().catch(() => undefined)\n if (!id || (route.params.sessionId === id && routeProfile() === profile)) return\n await router.replace(sessionLocation(id, profile))\n})\n</script>\n\n<template>\n <WorkspaceView sidebar-title=\"对话\" :sidebar-subtitle=\"`${sessions.length} 个会话`\" :inspector-open=\"!!preview || outlineOpen\" :inspector-close-label=\"outlineOpen ? '关闭会话大纲' : '关闭预览'\" @close-inspector=\"closeInspector\">\n <template #sidebar-action>\n <button class=\"sidebar-primary-action\" type=\"button\" title=\"新建聊天\" aria-label=\"新建聊天\" @click=\"createSession\">\n <YaoYaoSidebarIcon name=\"add\" />\n <span>新建聊天</span>\n </button>\n </template>\n <template #sidebar>\n <ResourceSidebar\n :items=\"sidebarItems\"\n :active-id=\"chat.activeSessionId\"\n :loading=\"chat.isLoading\"\n external-search\n single-line\n :has-more=\"chat.hasMoreSessions\"\n :loading-more=\"chat.isLoadingMoreSessions\"\n search-placeholder=\"搜索会话\"\n empty-title=\"还没有会话\"\n empty-description=\"新建会话后,从输入框开始聊天。\"\n @load-more=\"chat.loadMoreSessions(auth.activeProfile?.name)\"\n @select=\"chooseSession\"\n @more=\"openSessionActions\"\n @context-menu=\"openSessionActions\"\n />\n </template>\n\n <div class=\"chat-workspace\">\n <MessageTimeline\n @visible-messages=\"markVisible\"\n ref=\"timeline\"\n :messages=\"messages\"\n :title=\"activeSession?.title || '新会话'\"\n :subtitle=\"activeSession ? `${activeSession.profile || auth.activeProfile?.name || ''} · ${activeSession.model || chat.selectedModel?.name || '默认模型'}` : '选择会话或直接开始输入'\"\n :loading=\"chat.activeRouteState?.isLoadingHistory\"\n :loading-older=\"chat.activeRouteState?.isLoadingHistory\"\n :has-older=\"chat.hasMoreBefore\"\n :connected=\"connected\"\n :synced=\"chat.historySynced\"\n :show-tools=\"showThinking\"\n :thinking=\"chat.isSending || chat.isStreaming\"\n :show-assistant-identity=\"false\"\n :agent-avatars=\"agentAvatars\"\n :interaction=\"interaction\"\n empty-logo\n transparent-header\n :fork-source-title=\"forkSourceTitle\"\n @load-older=\"chat.loadOlder\"\n @quote=\"quoted = $event\"\n @branch=\"branch\"\n @preview=\"openAttachment\"\n @preview-file=\"openLocalFile\"\n @approve=\"interaction && chat.respondToApproval(interaction.id, $event)\"\n @clarify=\"interaction && chat.respondToClarification(interaction.id, $event)\"\n >\n <template #header-actions>\n <button v-if=\"activeSession\" ref=\"headerSessionMenuButton\" class=\"icon-button header-session-menu\" type=\"button\" title=\"会话操作\" aria-label=\"会话操作\" @click=\"openSessionActions(activeSession.id, $event)\"><AppIcon name=\"dots\" :size=\"18\" /></button>\n </template>\n </MessageTimeline>\n <p v-if=\"chat.error\" class=\"chat-error\" role=\"alert\"><AppIcon name=\"alert\" :size=\"13\" />{{ chat.error }}</p>\n <ComposerShell\n ref=\"composer\"\n mode=\"chat\"\n :draft-key=\"`${auth.user?.id || 'local'}:${auth.activeProfile?.name || 'default'}:${chat.activeSessionId || 'new'}`\"\n :disabled=\"chat.connectionState === 'failed'\"\n :streaming=\"chat.isStreaming\"\n :sending=\"chat.isSending\"\n :model-label=\"chat.selectedModel?.name || '选择模型'\"\n :fast-mode=\"chat.fastMode\"\n :fast-mode-disabled=\"!chat.activeSessionId\"\n :reasoning-effort=\"reasoningLabel\"\n :reasoning-value=\"chat.reasoningEffort || ''\"\n :reasoning-options=\"reasoningComposerOptions\"\n show-context\n :context-used=\"chat.contextUsage?.contextTokens\"\n :context-limit=\"chat.contextUsage?.contextLimit\"\n :context-percent=\"chat.contextUsage?.percentUsed\"\n :queue-mode=\"queueMode || chat.isQueued\"\n :tool-trace-visible=\"showThinking\"\n :reference=\"reference\"\n :slash-commands=\"[\n { id: 'fork', label: 'fork', detail: '从当前会话创建分支' },\n { id: 'compact', label: 'compact', detail: '压缩当前会话上下文' },\n { id: 'model', label: 'model', detail: '切换模型' },\n ]\"\n @send=\"send\"\n @stop=\"chat.interrupt\"\n @model-click=\"modelDialog = true\"\n @fast-mode-toggle=\"toggleFastMode\"\n @reasoning-change=\"selectReasoning\"\n @settings-click=\"toggleShowThinking\"\n @queue-toggle=\"queueMode = !queueMode\"\n @clear-reference=\"quoted = null\"\n />\n </div>\n\n <template #inspector>\n <SessionOutline v-if=\"outlineOpen\" :messages=\"messages\" :has-older=\"chat.hasMoreBefore\" @navigate=\"navigateOutline\" />\n <PreviewInspector v-else-if=\"preview\" :item=\"preview\" @close=\"preview = null\" @add-to-composer=\"addPreviewToComposer\" />\n </template>\n </WorkspaceView>\n\n <FloatingResourceSearch section=\"chat\" label=\"搜索会话\" :items=\"sidebarItems\" @select=\"chooseSession\" />\n <PreviewModal v-if=\"filePreview\" :item=\"filePreview\" :items=\"conversationMediaItems\" @close=\"filePreview = null\" @add-to-composer=\"addPreviewToComposer\" @source=\"filePreview = null\" />\n <ImagePreviewLightbox v-model=\"mediaPreviewIndex\" :images=\"lightboxMedia\" @add=\"addMediaToComposer\" />\n\n <ModelChoiceDialog :open=\"modelDialog\" :options=\"chat.models\" :selected-id=\"selectedModelId\" :busy=\"modelSwitching\" @close=\"modelDialog = false\" @select=\"selectModel\" />\n\n <StandaloneDialog v-if=\"pendingDeleteSession\" title=\"删除会话\" compact :before-close=\"() => !deletingSession\" @close=\"cancelDeleteSession\">\n <div class=\"session-delete\" :aria-busy=\"deletingSession\">\n <p>确定删除「{{ pendingDeleteSession.title || '新会话' }}」吗?删除后无法恢复。</p>\n <p v-if=\"deleteSessionError\" class=\"session-delete-error\" role=\"alert\">{{ deleteSessionError }}</p>\n <div class=\"session-delete-actions\">\n <button class=\"quiet-button\" type=\"button\" :disabled=\"deletingSession\" @click=\"cancelDeleteSession\">取消</button>\n <button class=\"solid-button session-delete-confirm\" type=\"button\" :disabled=\"deletingSession\" @click=\"deleteSession\">{{ deletingSession ? '删除中…' : '删除' }}</button>\n </div>\n </div>\n </StandaloneDialog>\n\n <Teleport to=\"body\">\n <Transition name=\"session-menu\">\n <section v-if=\"actionSessionId\" class=\"session-actions\" :style=\"actionMenuStyle\" role=\"menu\" aria-label=\"会话操作\" @contextmenu.prevent>\n <template v-if=\"renaming\">\n <label>会话名称<input v-model=\"renameValue\" maxlength=\"120\" autofocus @keydown.enter=\"saveRename\" /></label>\n <div><button class=\"quiet-button\" type=\"button\" @click=\"renaming = false\">取消</button><button class=\"solid-button\" type=\"button\" @click=\"saveRename\">保存</button></div>\n </template>\n <template v-else>\n <button class=\"action-row\" role=\"menuitem\" type=\"button\" @click=\"openSessionOutline\"><AppIcon name=\"menu\" :size=\"14\" />会话大纲</button>\n <button v-if=\"actionSessionId === chat.activeSessionId\" class=\"action-row\" role=\"menuitem\" type=\"button\" :disabled=\"chat.isStreaming || chat.isQueued || chat.isSending || chat.activeRouteState?.isLoadingHistory\" @click=\"forceRefreshHistory\"><AppIcon name=\"refresh\" :size=\"14\" />强制刷新历史</button>\n <button class=\"action-row\" role=\"menuitem\" type=\"button\" @click=\"toggleSessionPinned\"><AppIcon :name=\"actionSession?.pinned ? 'pin-off' : 'pin'\" :size=\"14\" />{{ actionSession?.pinned ? '取消置顶' : '置顶会话' }}</button>\n <button class=\"action-row\" role=\"menuitem\" type=\"button\" @click=\"renaming = true\"><AppIcon name=\"edit\" :size=\"14\" />重命名</button>\n <button class=\"action-row danger\" role=\"menuitem\" type=\"button\" @click=\"confirmDeleteSession\"><AppIcon name=\"trash\" :size=\"14\" />删除会话</button>\n </template>\n </section>\n </Transition>\n </Teleport>\n</template>\n\n<style scoped>\n.chat-workspace { display: flex; min-width: 0; min-height: 0; flex: 1; flex-direction: column; }\n.session-delete p { margin: 0; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }\n.session-delete .session-delete-error { margin-top: 12px; color: var(--danger); }\n.session-delete-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }\n.session-delete-actions button { min-width: 80px; min-height: 44px; font-size: 14px; }\n.session-delete-confirm { border-color: var(--danger); background: var(--danger); color: var(--text-on-solid); }\n.session-delete-confirm:hover { transform: none; filter: brightness(.95); }\n.session-delete-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }\n.session-delete-actions button:disabled { opacity: .6; cursor: wait; }\n.sidebar-primary-action { display: flex; width: 100%; min-height: 40px; align-items: center; gap: 10px; padding: 0 11px; border: 0; border-radius: 9px; background: transparent; color: var(--text-primary); cursor: pointer; font-size: 12px; font-weight: 610; text-align: left; transition: background-color 120ms ease; }\n.sidebar-primary-action:hover, .sidebar-primary-action:focus-visible { background: var(--surface-hover); outline: 0; }\n.sidebar-primary-action:focus-visible { box-shadow: inset 0 0 0 1px var(--line-strong); }\n.header-session-menu { color: var(--text-muted); background: transparent; }.header-session-menu:hover { color: var(--text-primary); background: var(--surface-soft); }\n.chat-error { display: flex; width: min(760px, calc(100% - 32px)); margin: 0 auto 4px; align-items: center; gap: 6px; color: var(--danger); font-size: 9px; }\n.session-actions { position: fixed; z-index: 205; width: 208px; box-sizing: border-box; padding: 6px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-raised); box-shadow: 0 12px 34px rgba(0,0,0,.16); }.action-row { display: flex; width: 100%; min-height: 34px; align-items: center; gap: 8px; padding: 0 9px; border: 0; border-radius: 7px; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 11px; text-align: left; }.action-row:hover, .action-row:focus-visible { outline: 0; background: var(--surface-soft); color: var(--text-primary); }.action-row.danger { color: var(--danger); }.session-actions label { display: flex; flex-direction: column; gap: 6px; padding: 4px; color: var(--text-muted); font-size: 9px; }.session-actions input { width: 100%; height: 32px; box-sizing: border-box; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: var(--surface-soft); color: var(--text-primary); font-size: 11px; }.session-actions input:focus { border-color: var(--line-strong); box-shadow: 0 0 0 3px var(--focus-ring); }.session-actions > div { display: flex; justify-content: flex-end; gap: 5px; margin-top: 7px; padding: 0 4px 3px; }.session-actions :deep(.quiet-button), .session-actions :deep(.solid-button) { min-height: 29px; padding-inline: 10px; font-size: 10px; }\n.session-menu-enter-active, .session-menu-leave-active { transition: opacity 100ms ease, transform 120ms var(--ease-out); transform-origin: top right; }.session-menu-enter-from, .session-menu-leave-to { opacity: 0; transform: translateY(-3px) scale(.98); }\n@media (prefers-reduced-motion: reduce) { .sidebar-primary-action, .session-menu-enter-active, .session-menu-leave-active { transition: none; } }\n</style>\n"],"mappings":"6wBAEA,IAAM,EAAM,sCAcZ,eAAsB,GAAiB,EAAgD,CACrF,IAAM,EAAM,EAAK,aAAe,EAAK,WACrC,GAAI,CAAC,GAAO,CAAC,EAAK,KAAM,OAAO,KAC/B,G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AA,EACtL,EAAgI,SAAA,CAAxH,MAAM,aAAa,KAAK,WAAW,KAAK,SAAU,QAAK,AAAA,EAAA,MAAA,GAAE,EAAA,MAAQ,EAAS,EAAA,CAAA,EAAkC,EAAA,CAAzB,KAAK,OAAQ,KAAM,EAAM,CAAA,EAAA,AAAA,EAAA,MAAA,EAAA,MAAG,EAAA,CAAA,CAAA,EACvH,EAA8I,SAAA,CAAtI,MAAM,oBAAoB,KAAK,WAAW,KAAK,SAAU,QAAO,EAAsB,EAAA,CAAA,EAAmC,EAAA,CAA1B,KAAK,QAAS,KAAM,EAAM,CAAA,EAAA,AAAA,EAAA,MAAA,EAAA,OAAI,EAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.chat-workspace[data-v-058ae687]{flex-direction:column;flex:1;min-width:0;min-height:0;display:flex}.session-delete p[data-v-058ae687]{overflow-wrap:anywhere;margin:0;font-size:14px;line-height:1.6}.session-delete .session-delete-error[data-v-058ae687]{color:var(--danger);margin-top:12px}.session-delete-actions[data-v-058ae687]{justify-content:flex-end;gap:12px;margin-top:24px;display:flex}.session-delete-actions button[data-v-058ae687]{min-width:80px;min-height:44px;font-size:14px}.session-delete-confirm[data-v-058ae687]{border-color:var(--danger);background:var(--danger);color:var(--text-on-solid)}.session-delete-confirm[data-v-058ae687]:hover{filter:brightness(.95);transform:none}.session-delete-actions button[data-v-058ae687]:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.session-delete-actions button[data-v-058ae687]:disabled{opacity:.6;cursor:wait}.sidebar-primary-action[data-v-058ae687]{width:100%;min-height:40px;color:var(--text-primary);cursor:pointer;text-align:left;background:0 0;border:0;border-radius:9px;align-items:center;gap:10px;padding:0 11px;font-size:12px;font-weight:610;transition:background-color .12s;display:flex}.sidebar-primary-action[data-v-058ae687]:hover,.sidebar-primary-action[data-v-058ae687]:focus-visible{background:var(--surface-hover);outline:0}.sidebar-primary-action[data-v-058ae687]:focus-visible{box-shadow:inset 0 0 0 1px var(--line-strong)}.header-session-menu[data-v-058ae687]{color:var(--text-muted);background:0 0}.header-session-menu[data-v-058ae687]:hover{color:var(--text-primary);background:var(--surface-soft)}.chat-error[data-v-058ae687]{width:min(760px,100% - 32px);color:var(--danger);align-items:center;gap:6px;margin:0 auto 4px;font-size:9px;display:flex}.session-actions[data-v-058ae687]{z-index:205;box-sizing:border-box;border:1px solid var(--line);background:var(--surface-raised);border-radius:11px;width:208px;padding:6px;position:fixed;box-shadow:0 12px 34px #00000029}.action-row[data-v-058ae687]{width:100%;min-height:34px;color:var(--text-secondary);cursor:pointer;text-align:left;background:0 0;border:0;border-radius:7px;align-items:center;gap:8px;padding:0 9px;font-size:11px;display:flex}.action-row[data-v-058ae687]:hover,.action-row[data-v-058ae687]:focus-visible{background:var(--surface-soft);color:var(--text-primary);outline:0}.action-row.danger[data-v-058ae687]{color:var(--danger)}.session-actions label[data-v-058ae687]{color:var(--text-muted);flex-direction:column;gap:6px;padding:4px;font-size:9px;display:flex}.session-actions input[data-v-058ae687]{box-sizing:border-box;border:1px solid var(--line);background:var(--surface-soft);width:100%;height:32px;color:var(--text-primary);border-radius:7px;outline:0;padding:0 8px;font-size:11px}.session-actions input[data-v-058ae687]:focus{border-color:var(--line-strong);box-shadow:0 0 0 3px var(--focus-ring)}.session-actions>div[data-v-058ae687]{justify-content:flex-end;gap:5px;margin-top:7px;padding:0 4px 3px;display:flex}.session-actions[data-v-058ae687] .quiet-button,.session-actions[data-v-058ae687] .solid-button{min-height:29px;padding-inline:10px;font-size:10px}.session-menu-enter-active[data-v-058ae687],.session-menu-leave-active[data-v-058ae687]{transition:opacity .1s ease, transform .12s var(--ease-out);transform-origin:100% 0}.session-menu-enter-from[data-v-058ae687],.session-menu-leave-to[data-v-058ae687]{opacity:0;transform:translateY(-3px)scale(.98)}@media (prefers-reduced-motion:reduce){.sidebar-primary-action[data-v-058ae687],.session-menu-enter-active[data-v-058ae687],.session-menu-leave-active[data-v-058ae687]{transition:none}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as e,B as t,F as n,G as r,H as i,L as a,M as o,W as s,_ as c,at as l,ct as u,d,et as f,f as ee,g as p,h as te,m,o as ne,ot as re,p as h,s as ie,t as g,u as ae,v as oe,x as se}from"./_plugin-vue_export-helper-CscYwSBt.js";import{F as _,j as v}from"./index-CWamgtSb.js";function ce(e){return!!e?.enabled&&(!!e.available||!!e.installation)}async function le(e,t,n,r){let i=`/api/app/agents/${encodeURIComponent(e)}/managed-browser`,a=t??await _(i,{signal:n});if(n.throwIfAborted(),!ce(a))throw Error(a.reason||`托管浏览器不可用,请检查执行节点与授权`);!a.available&&a.installation?.status!==`installing`&&(a=await _(i+`/prepare`,{method:`POST`,body:{retry:a.installation?.status===`failed`},signal:n}));let o=Date.now();for(;;){if(n.throwIfAborted(),r(a),a.available)return;if(a.installation?.status===`failed`)throw Error(a.installation.error||a.installation.message||`浏览器准备失败,请重试`);if(!ce(a))throw Error(a.reason||`执行节点已不可用,请重新连接后重试`);if(Date.now()-o>6e5)throw Error(`浏览器仍在准备中,可稍后重新接管查看进度`);await new Promise((e,t)=>{let r=()=>{clearTimeout(i),t(n.reason??new DOMException(`Aborted`,`AbortError`))},i=setTimeout(()=>{n.removeEventListener(`abort`,r),e()},1e3);n.addEventListener(`abort`,r,{once:!0}),n.aborted&&r()}),a=await _(i,{signal:n})}}var ue=class{send;failed;id=v();done;resolve;queue=[];running=!1;ending=!1;finished=!1;heartbeat;latest;constructor(e,t,n){this.send=t,this.failed=n,this.latest={x:e.x,y:e.y},this.done=new Promise(e=>{this.resolve=e}),this.heartbeat=setInterval(()=>{this.ending||this.move(this.latest)},1e3),this.enqueue(`start`,e)}move(e){this.ending||this.enqueue(`move`,e)}end(e){this.ending||(this.ending=!0,clearInterval(this.heartbeat),this.enqueue(`end`,e))}cancel(){return this.finished?this.done:(this.ending=!0,clearInterval(this.heartbeat),this.queue=[],this.enqueue(`cancel`,this.latest),this.done)}enqueue(e,t){this.latest={x:t.x,y:t.y};let n={kind:`pointer`,gestureId:this.id,phase:e,x:t.x,y:t.y};e===`move`&&this.queue.at(-1)?.phase===`move`?this.queue[this.queue.length-1]=n:this.queue.push(n),this.flush()}async flush(){if(!(this.running||this.finished)){this.running=!0;try{for(;this.queue.length;){let e=this.queue.shift();if(await this.send(e),e.phase===`end`||e.phase===`cancel`){this.finish();return}}}catch(e){this.ending=!0,this.queue=[],clearInterval(this.heartbeat);try{await this.send({kind:`pointer`,gestureId:this.id,phase:`cancel`,...this.latest})}catch{}this.failed(e),this.finish()}finally{this.running=!1}}}finish(){this.finished=!0,this.ending=!0,this.queue=[],clearInterval(this.heartbeat),this.resolve()}},de={class:`browser-toolbar`,"aria-label":`机器人浏览器`},y={class:`browser-tabs`,role:`tablist`,"aria-label":`浏览器标签页`},b=[`aria-selected`,`title`,`disabled`,`onClick`],x=[`aria-label`,`disabled`,`onClick`],fe=[`disabled`],S=[`disabled`],C=[`disabled`],w=[`disabled`],T=[`disabled`],E=[`disabled`],pe=g(se({__name:`BrowserToolbar`,props:{state:{},enabled:{type:Boolean}},emits:[`action`],setup(e,{emit:t}){let o=e,s=t,l=f(``),ee=f(!1),p=h(()=>o.state?.tabs.find(e=>e.active));i(()=>p.value?.url,e=>{ee.value||(l.value=e===`about:blank`?``:e??``)},{immediate:!0});function te(){let e=l.value.trim();e&&(/^https?:\/\//i.test(e)||(e=`https://`+e),ee.value=!1,s(`action`,{kind:`navigate`,url:e}))}return(t,i)=>(n(),c(`div`,de,[m(`div`,y,[(n(!0),c(d,null,a(e.state?.tabs,t=>(n(),c(`div`,{key:t.id,class:re([`tab`,{active:t.active}])},[m(`button`,{role:`tab`,"aria-selected":t.active,title:t.title,disabled:!e.enabled,onClick:e=>s(`action`,{kind:`select-tab`,tabId:t.id})},u(t.title),9,b),m(`button`,{class:`close-tab`,"aria-label":`关闭标签页 ${t.title}`,disabled:!e.enabled,onClick:e=>s(`action`,{kind:`close-tab`,tabId:t.id})},`×`,8,x)],2))),128)),m(`button`,{class:`new-tab`,"aria-label":`新建标签页`,disabled:!e.enabled,onClick:i[0]||=e=>s(`action`,{kind:`new-tab`,url:`https://www.google.com/`})},`+`,8,fe)]),m(`form`,{class:`navigation`,onSubmit:ae(te,[`prevent`])},[m(`button`,{type:`button`,"aria-label":`后退`,disabled:!e.enabled,onClick:i[1]||=e=>s(`action`,{kind:`back`})},`←`,8,S),m(`button`,{type:`button`,"aria-label":`前进`,disabled:!e.enabled,onClick:i[2]||=e=>s(`action`,{kind:`forward`})},`→`,8,C),m(`button`,{type:`button`,"aria-label":`重新加载页面`,disabled:!e.enabled,onClick:i[3]||=e=>s(`action`,{kind:`reload`})},`↻`,8,w),r(m(`input`,{"onUpdate:modelValue":i[4]||=e=>l.value=e,type:`text`,inputmode:`url`,autocomplete:`off`,spellcheck:`false`,"aria-label":`浏览器地址`,placeholder:`输入网址`,disabled:!e.enabled,onFocus:i[5]||=e=>ee.value=!0,onBlur:i[6]||=e=>ee.value=!1},null,40,T),[[ie,l.value]]),m(`button`,{type:`submit`,disabled:!e.enabled||!l.value.trim()},`前往`,8,E)],32)]))}}),[[`__scopeId`,`data-v-76ef2743`]]),me=[`value`,`disabled`],he=[`value`,`disabled`],ge=[`disabled`],_e=[`value`],ve={key:2},ye=[`disabled`],be=[`disabled`],xe=[`aria-expanded`],Se=[`aria-pressed`],Ce=[`disabled`],we=[`aria-busy`],Te={role:`status`},Ee=[`value`],De={key:1},Oe={key:2,role:`alert`},ke=[`aria-busy`],Ae={key:0,role:`status`},je=[`disabled`],Me=[`src`,`alt`],Ne={key:1},Pe={key:2,class:`view-label`},Fe={key:3,class:`computer-error`,role:`alert`},Ie={key:4},Le={key:0},Re={key:1},ze={key:2},Be={key:3},Ve={key:4,class:`browser-downloads`},He={key:5},Ue=[`disabled`],We=[`disabled`],Ge={key:0,class:`manual-input`},Ke={class:`key-row`},qe=[`disabled`,`onClick`],Je={class:`key-row`},Ye=[`disabled`],Xe=[`disabled`],Ze=[`disabled`],Qe=[`disabled`],$e=[`disabled`],et=[`disabled`],tt={key:1},nt={key:2},rt=[`aria-busy`],it=[`disabled`],D=g(se({__name:`ComputerPanel`,props:{agents:{},embedded:{type:Boolean},standalone:{type:Boolean},autoTake:{type:Boolean},backend:{},host:{}},emits:[`close`,`changed`,`controlRequest`,`targetChanged`],setup(g,{expose:se,emit:de}){let y=g,b=de,x=f(y.agents[0]?.id??``),fe=f(),S=f(y.backend),C=f(y.host??(y.backend===`desktop`?`local`:``)),w=f(),T=f({mode:`off`}),E=f(),D=f(),O=f(!1),at=f(!1),k=f(),ot=f(!1),A=f(),j=f(!1),st=f(!1),ct=f(!1),M,N=h(()=>S.value===`managed-browser`?A.value?.installation:void 0),lt=h(()=>y.agents.find(e=>e.id===x.value)),P=f(``),F=f(!1),ut=f(``),I=f(``),L=f(!1),R,dt,z=!1,ft=!1,pt=0,B=0,mt={off:`电脑未运行`,idle:`电脑空闲 · 仅查看`,agent:`机器人正在操作`,pausing:`正在等待当前操作结束`,human:`人工控制中`,resuming:`正在交还机器人`,error:`电脑需要检查`},V=h(()=>!!D.value&&D.value.controlId===T.value.controlId),ht=h(()=>S.value===`managed-browser`&&V.value&&T.value.mode===`human`&&!T.value.canResume),H=h(()=>L.value&&!!E.value&&V.value&&T.value.mode===`human`&&E.value?.generation===T.value.generation),U=h(()=>H.value&&!F.value&&!ot.value),W=f({vm:!0,cloud:!0,desktop:!0,managedBrowser:!1}),G=h(()=>{let e=W.value,t=w.value,n=[];if(e.desktop)for(let e of t?.hosts??[])n.push({key:`desktop:`+e.id,label:(e.id===`local`?`服务器`:`电脑`)+` · `+(e.name||`未命名`),backend:`desktop`,host:e.id,disabled:!e.online});if(e.cloud&&n.push({key:`cloud`,label:`云端 · Grok Bot`+(t?.cloudConfigured?``:` · 未连接`),backend:`cloud`,disabled:!t?.cloudConfigured}),e.vm&&n.push({key:`vm`,label:`本地虚拟机`+(t?.vmEnabled?``:` · 未启用`),backend:`vm`,disabled:!t?.vmEnabled}),e.managedBrowser){let e=t?.managedBrowser;n.push({key:`managed-browser`,label:`托管浏览器`+(e?.available?``:ce(e)?` · `+(e?.installation?.status===`failed`?`准备失败`:`待准备`):` · 不可用`),backend:`managed-browser`,disabled:!ce(e)})}return n}),gt=h(()=>G.value.find(e=>e.backend===S.value&&(e.host??``)===C.value)?.key??``),_t=h(()=>G.value.some(e=>e.key===gt.value&&!e.disabled));i([S,C],([e,t])=>{e&&b(`targetChanged`,e,t||void 0)},{immediate:!0});async function vt(){if(!x.value)return;let e=x.value,t=encodeURIComponent(e),n=await _(`/api/app/settings/host-tools`);if(z||e!==x.value)return;W.value={vm:n.vm,cloud:n.cloud,desktop:n.scriptMachine||n.serverComputer,managedBrowser:n.managedBrowser===!0};let[r,i,a,o]=await Promise.all([W.value.desktop?_(`/api/app/agents/${t}/desktop-environment`).catch(()=>void 0):Promise.resolve(void 0),W.value.cloud?_(`/api/app/agents/${t}/cloud-computer`).catch(()=>void 0):Promise.resolve(void 0),W.value.vm?_(`/api/app/agents/${t}/local-vm`).catch(()=>void 0):Promise.resolve(void 0),W.value.managedBrowser?_(`/api/app/agents/${t}/managed-browser`).catch(()=>void 0):Promise.resolve(void 0)]);z||e!==x.value||(w.value={hosts:(r?.hosts??[]).filter(e=>e.id===`local`?n.serverComputer:n.scriptMachine),cloudConfigured:!!i?.configured,vmEnabled:!!a?.enabled,managedBrowser:o},S.value===`managed-browser`&&(A.value=o,k.value=o))}async function yt(e){let t=G.value.find(t=>t.key===e);if(!(!t||t.disabled||e===gt.value)){if(await $(),D.value)try{await St(`/giveback`,{...D.value,notes:``})}catch(e){P.value=e instanceof Error?e.message:`请先交还当前电脑`;return}S.value=t.backend,C.value=t.host??``,M?.abort(),clearTimeout(Y),J=void 0,k.value=void 0,A.value=void 0,q.length=0,L.value=!1,B++,R=void 0,E.value=void 0,D.value=void 0,T.value={mode:`off`},P.value=``,await Ct()}}let bt=()=>`/api/app/agents/${encodeURIComponent(x.value)}/computer`,xt=()=>{let e=new URLSearchParams;S.value&&e.set(`backend`,S.value),S.value===`desktop`&&C.value&&e.set(`host`,C.value);let t=e.toString();return t?`?`+t:``};async function St(e,t){return _(bt()+e+xt(),{method:`POST`,body:t})}async function Ct(){if(ft||F.value||z||!x.value||document.hidden||!_t.value&&!(S.value===`managed-browser`&&W.value.managedBrowser))return;ft=!0;let e=++B,t=bt(),n=xt(),r=x.value;try{if(S.value===`managed-browser`){let t=await _(`/api/app/agents/${encodeURIComponent(r)}/managed-browser`).catch(t=>{throw e===B&&!z&&(A.value=void 0,k.value=void 0,w.value&&(w.value.managedBrowser=void 0),T.value={mode:`off`,backend:`managed-browser`}),t});if(e!==B||z)return;if(A.value=t,k.value=t,w.value&&(w.value.managedBrowser=t),!t.available){T.value={mode:`off`,backend:`managed-browser`},L.value=!1,E.value=void 0,P.value=``;return}}let i=await _(t+n);if(e!==B||z)return;if(T.value=i,L.value=!0,D.value&&i.controlId!==D.value.controlId&&i.mode!==`pausing`&&(D.value=void 0),V.value&&Date.now()-pt>8e3&&(await St(`/renew`,D.value),pt=Date.now()),i.backend===`browser`){let t=await _(`/api/app/agents/${encodeURIComponent(x.value)}/browser`);if(e!==B||z)return;k.value=t,A.value=void 0}else i.backend!==`managed-browser`&&(k.value=void 0,A.value=void 0);if(i.mode!==`off`&&(![`browser`,`managed-browser`].includes(i.backend??``)||k.value?.open)){let r=await _(t+`/frame`+n);e===B&&!z&&(E.value=r)}else E.value=void 0;P.value=``}catch(t){if(e===B&&!z){L.value=!1,E.value=void 0,q.length=0,P.value=t instanceof Error?t.message:`无法读取电脑状态`;{let e=Number(t.status);([401,410].includes(e)||e===403&&D.value)&&(D.value=void 0,E.value=void 0,T.value={mode:`off`})}}}finally{ft=!1}}async function K(e){if(F.value)return;B++,F.value=!0,P.value=``;let t=``;try{await e()}catch(e){t=e instanceof Error?e.message:`电脑操作失败`}finally{F.value=!1,z||(await Ct(),t&&(P.value=t),Dt())}}async function wt(){if(!F.value){st.value=!0;try{await K(vt)}finally{st.value=!1}}}function Tt(){return K(async()=>{if(!_t.value)throw Error(`所选电脑不可用,请重新选择`);let e=x.value,t=S.value,n=bt(),r=xt(),i=new AbortController;M=i;try{if(t===`managed-browser`&&(j.value=!A.value?.available,await le(e,A.value,i.signal,n=>{!z&&e===x.value&&t===S.value&&(A.value=n,k.value=n,w.value&&(w.value.managedBrowser=n))})),i.signal.throwIfAborted(),z||e!==x.value||t!==S.value)return;j.value=!1,R??=v();let a=await _(n+`/take`+r,{method:`POST`,body:{requestId:R}}),o={controlId:a.controlId,token:a.token};if(z||i.signal.aborted||e!==x.value||t!==S.value){await _(n+`/giveback`+r,{method:`POST`,body:{...o,notes:``}});return}D.value=o,T.value=a,pt=0}catch(e){if(!i.signal.aborted)throw e}finally{M===i&&(M=void 0,j.value=!1)}})}let q=[],Et=!1,J,Y;function X(e){if(!H.value||z||ot.value)return;J&&(q.push(J),J=void 0,clearTimeout(Y));let t=q.at(-1);if(e.kind===`text`&&t?.kind===`text`&&t.text.length+e.text.length<=16e3)t.text+=e.text;else if(q.length<64)q.push(e);else{P.value=`输入过快,请稍后再试`;return}Dt()}async function Dt(){if(Et||F.value||!q.length||z)return;if(!H.value||!E.value||!D.value){q.length=0;return}Et=!0;let e=q.shift(),t=E.value,n=D.value;try{await K(async()=>{await St(`/input`,{...n,requestId:v(),generation:t.generation,frameId:t.id,action:e})}),P.value&&(q.length=0)}finally{Et=!1,q.length&&setTimeout(()=>void Dt(),0)}}function Ot(e){if(!U.value||!E.value||!D.value)return;let t=E.value,n=D.value;K(async()=>{S.value===`managed-browser`?await _(`/api/app/agents/${encodeURIComponent(x.value)}/managed-browser/action`,{method:`POST`,body:{...n,requestId:v(),generation:t.generation,action:e}}):await St(`/browser`,{...n,requestId:v(),generation:t.generation,frameId:t.id,action:e})})}function kt(e,t=!1){let n=e.currentTarget.getBoundingClientRect(),r=E.value,i=Math.min(n.width/r.width,n.height/r.height),a=n.left+(n.width-r.width*i)/2,o=n.top+(n.height-r.height*i)/2,s=Math.floor((e.clientX-a)/i),c=Math.floor((e.clientY-o)/i);if(t)return{x:Math.max(0,Math.min(r.width-1,s)),y:Math.max(0,Math.min(r.height-1,c))};if(!(s<0||c<0||s>=r.width||c>=r.height))return{x:s,y:c}}let Z,At=!1,Q;function jt(e){if(!U.value||Z||e.button!==0||q.length)return;let t=e.currentTarget;t.focus({preventScroll:!0});let n=kt(e);n&&(At=!1,Z={...n,clientX:e.clientX,clientY:e.clientY,pointerId:e.pointerId,element:t},t.setPointerCapture(e.pointerId))}function Mt(e){let t=bt(),n=xt(),r=D.value,i=E.value.generation,a=E.value;clearTimeout(Y),J=void 0,P.value=``,ot.value=!0;let o=()=>!z&&bt()===t&&xt()===n&&D.value?.controlId===r.controlId&&T.value.generation===i,s=new ue(e,async e=>{if(e.phase!==`cancel`&&(!o()||!H.value))throw Error(`控制权已变化,请重新接管`);if(await _(t+`/input`+n,{method:`POST`,timeoutMs:5e3,body:{...r,requestId:v(),generation:i,frameId:a.id,action:{...e}}}),e.phase===`cancel`)return;let s=await _(t+`/frame`+n,{timeoutMs:5e3});if(!o()||s.generation!==i)throw Error(`控制权已变化,请重新接管`);a=s,E.value=s},e=>{o()&&(P.value=e instanceof Error?e.message:`拖动失败,请重新按下鼠标`)});Q=s,s.done.then(async()=>{if(Q===s){Q=void 0,ot.value=!1;let e=P.value;await Ct(),o()&&e&&(P.value=e)}})}function Nt(e){let t=Z;if(!t||e.pointerId!==t.pointerId||!H.value||S.value!==`managed-browser`)return;!Q&&Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY)>5&&(At=!0,Mt(t));let n=kt(e,!0);n&&Q?.move(n)}function Pt(){let e=Z;Z=void 0,e?.element.hasPointerCapture(e.pointerId)&&e.element.releasePointerCapture(e.pointerId)}function $(){return Pt(),Q?(At=!0,Q.cancel()):Promise.resolve()}function Ft(e){let t=Z;if(!t||e.pointerId!==t.pointerId)return;if(!H.value){$();return}Nt(e);let n=kt(e,!0);if(Pt(),Q){n?Q.end(n):$();return}n&&Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY)>5&&(At=!0,X({kind:`drag`,fromX:t.x,fromY:t.y,toX:n.x,toY:n.y}))}let It=()=>{$()},Lt=()=>{document.hidden&&$()};i(H,e=>{e||$()});function Rt(e){H.value&&(e.preventDefault(),X({kind:`scroll`,direction:Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX>0?`right`:`left`:e.deltaY>0?`down`:`up`,amount:Math.min(20,Math.max(1,Math.ceil(Math.abs(e.deltaY||e.deltaX)/80)))}))}function zt(e){if(!H.value)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){$(),e.currentTarget.blur();return}let t=[e.ctrlKey||S.value===`managed-browser`&&e.metaKey?`ctrl`:``,e.altKey?`alt`:``,e.shiftKey?`shift`:``,e.metaKey&&S.value!==`managed-browser`?`super`:``].filter(Boolean);e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey?X({kind:`text`,text:e.key}):[`Control`,`Alt`,`Shift`,`Meta`].includes(e.key)||X({kind:`key`,key:{Enter:`Return`,ArrowUp:`Up`,ArrowDown:`Down`,ArrowLeft:`Left`,ArrowRight:`Right`,Backspace:`BackSpace`}[e.key]??e.key,modifiers:t})}function Bt(e){if(At){At=!1;return}if(!H.value||!E.value)return;let t=kt(e);if(!t)return;let n={kind:`click`,...t,button:e.button===2?`right`:`left`,count:e.detail>1?2:1};if(e.button===2||e.detail>1)clearTimeout(Y),J=void 0,X(n);else{if(J){let e=J;J=void 0,clearTimeout(Y),X(e)}J=n,Y=setTimeout(()=>{let e=J;J=void 0,e&&X(e)},180)}}async function Vt(){await $(),D.value&&(await St(`/giveback`,{...D.value,notes:I.value}),D.value=void 0,R=void 0,I.value=``)}async function Ht(){if(F.value||!ht.value||!D.value)return;await $();let e=x.value,t=D.value;ct.value=!0;try{await K(async()=>{clearTimeout(Y),J=void 0,q.length=0;let n=await _(`/api/app/agents/${encodeURIComponent(e)}/managed-browser/close`,{method:`POST`,body:t});z||x.value!==e||S.value!==`managed-browser`||D.value!==t||(T.value=n,D.value=void 0,R=void 0,I.value=``,E.value=void 0,L.value=!1,O.value=!1,b(`changed`))})}finally{ct.value=!1}}async function Ut(){if(j.value){M?.abort(),z=!0,fe.value?.close?.(),b(`close`);return}F.value||(await K(Vt),D.value||(z=!0,!y.embedded&&!y.standalone&&fe.value?.close(),b(`close`)))}async function Wt(){try{document.fullscreenElement?await document.exitFullscreen():await fe.value?.requestFullscreen()}catch{P.value=`无法进入全屏,请使用窗口最大化`}}async function Gt(){await Ct(),z||(dt=setTimeout(()=>void Gt(),1200))}return i(x,()=>{$(),M?.abort(),clearTimeout(Y),J=void 0,k.value=void 0,A.value=void 0,q.length=0,L.value=!1,B++,R=void 0,E.value=void 0,D.value=void 0,T.value={mode:`off`},P.value=``,S.value=y.backend,C.value=y.host??(y.backend===`desktop`?`local`:``),w.value=void 0,vt().then(async()=>{if(!S.value){let e=G.value.find(e=>!e.disabled);e&&await yt(e.key)}await Ct()}).catch(e=>{P.value=e instanceof Error?e.message:`无法读取电脑列表`})}),o(async()=>{window.addEventListener(`blur`,It),document.addEventListener(`visibilitychange`,Lt),!y.embedded&&!y.standalone&&fe.value?.showModal();try{if(await vt(),z)return;if(!S.value){let e=G.value.find(e=>!e.disabled);e&&await yt(e.key)}if(!_t.value&&S.value!==`managed-browser`)throw Error(`所选电脑不可用,请重新选择;未打开其他电脑`);y.autoTake&&!z&&_t.value&&await Tt()}catch(e){P.value=e instanceof Error?e.message:`无法读取电脑列表`}z||Gt()}),e(()=>{$(),window.removeEventListener(`blur`,It),document.removeEventListener(`visibilitychange`,Lt),M?.abort(),D.value&&St(`/giveback`,{...D.value,notes:I.value}).catch(()=>{}),q.length=0,J=void 0,clearTimeout(Y),z=!0,B++,clearTimeout(dt)}),se({take:Tt,close:Ut,releaseControl:async()=>{if(j.value){M?.abort();return}if(F.value)throw Error(`请等待当前操作完成`);if(await K(Vt),D.value)throw Error(P.value||`请先交还控制权`)},hasControl:()=>!!D.value}),(e,i)=>(n(),te(ee,{to:`body`,disabled:g.embedded||g.standalone},[(n(),te(t(g.embedded||g.standalone?`section`:`dialog`),{ref_key:`dialog`,ref:fe,class:re([`computer-panel`,{embedded:g.embedded,standalone:g.standalone}]),"aria-label":G.value.find(e=>e.key===gt.value)?.label||`电脑桌面`,onCancel:ae(Ut,[`prevent`])},{default:s(()=>[m(`header`,null,[m(`div`,null,[m(`strong`,null,u(S.value===`managed-browser`?`托管浏览器`:T.value.backend===`grok`?`Grok Bot 云端电脑`:T.value.backend===`local`?T.value.hostName??`服务器桌面`:T.value.backend===`browser`?`浏览器 · `+T.value.hostName:`本地虚拟机`),1),m(`small`,null,u(j.value?`正在准备浏览器`:mt[T.value.mode]),1)]),G.value.length>1?(n(),c(`select`,{key:0,value:gt.value,"aria-label":`切换电脑环境`,disabled:!!D.value||F.value,onChange:i[0]||=e=>yt(e.target.value)},[(n(!0),c(d,null,a(G.value,e=>(n(),c(`option`,{key:e.key,value:e.key,disabled:e.disabled},u(e.label),9,he))),128))],40,me)):p(``,!0),g.agents.length>1?r((n(),c(`select`,{key:1,"onUpdate:modelValue":i[1]||=e=>x.value=e,"aria-label":`选择电脑`,disabled:!!D.value||F.value},[(n(!0),c(d,null,a(g.agents,e=>(n(),c(`option`,{key:e.id,value:e.id},u(e.name),9,_e))),128))],8,ge)),[[ne,x.value]]):g.embedded?p(``,!0):(n(),c(`span`,ve,u(g.agents[0]?.name),1)),g.embedded&&!D.value?(n(),c(`button`,{key:3,disabled:F.value||T.value.mode===`human`,onClick:i[2]||=e=>b(`controlRequest`)},`接管电脑`,8,ye)):p(``,!0),g.embedded&&V.value?(n(),c(`button`,{key:4,onClick:i[3]||=e=>O.value=!O.value},`键盘与操作`)):p(``,!0),g.embedded&&V.value?(n(),c(`button`,{key:5,disabled:F.value||T.value.mode!==`human`,onClick:i[4]||=e=>K(Vt)},`交还`,8,be)):p(``,!0),g.embedded?p(``,!0):(n(),c(d,{key:6},[V.value?(n(),c(`button`,{key:0,type:`button`,"aria-expanded":O.value,onClick:i[5]||=e=>O.value=!O.value},`键盘与操作`,8,xe)):p(``,!0),m(`button`,{type:`button`,"aria-pressed":at.value,onClick:i[6]||=e=>at.value=!at.value},u(at.value?`适应窗口`:`原始大小`),9,Se),m(`button`,{type:`button`,onClick:Wt},`全屏`)],64)),g.embedded?p(``,!0):(n(),c(`button`,{key:7,class:`return-control`,type:`button`,disabled:F.value&&!j.value,onClick:Ut},u(S.value===`managed-browser`?D.value?`交还并收起`:`收起窗口`:D.value?`交还并关闭`:`关闭`),9,Ce))]),T.value.backend===`browser`||T.value.backend===`managed-browser`?(n(),te(pe,{key:0,state:k.value,enabled:U.value,onAction:Ot},null,8,[`state`,`enabled`])):p(``,!0),N.value&&N.value.status!==`ready`?(n(),c(`section`,{key:1,class:`browser-installation`,"aria-busy":j.value},[m(`p`,Te,u(N.value.message),1),N.value.status===`installing`||N.value.status===`checking`?(n(),c(`progress`,{key:0,value:N.value.progress,max:`100`,"aria-label":`浏览器准备进度`},null,8,Ee)):p(``,!0),j.value?(n(),c(`small`,De,`关闭窗口后仍会继续准备。`)):p(``,!0),N.value.error?(n(),c(`p`,Oe,u(N.value.error),1)):p(``,!0)],8,we)):p(``,!0),S.value===`managed-browser`&&!A.value?.available?(n(),c(`section`,{key:2,class:`browser-availability`,"aria-busy":st.value},[N.value?p(``,!0):(n(),c(`p`,Ae,u(A.value?.reason||(W.value.managedBrowser?`执行节点暂时不可用,请检查连接后重新检测。`:`托管浏览器尚未开放,请在 Bot 设置中开启。`)),1)),m(`button`,{type:`button`,disabled:F.value,onClick:wt},u(st.value?`正在检测…`:`重新检测`),9,je)],8,ke)):p(``,!0),m(`div`,{class:re([`computer-screen`,{controlling:H.value,"actual-size":at.value}])},[E.value?(n(),c(`img`,{key:0,src:`data:image/png;base64,${E.value.data}`,alt:(G.value.find(e=>e.key===gt.value)?.label||`电脑`)+`当前画面`,draggable:`false`,tabindex:`0`,title:`点按后可使用键盘、滚轮和拖动;按 Esc 退出键盘控制`,onPointerdown:jt,onPointermove:Nt,onPointerup:Ft,onPointercancel:$,onLostpointercapture:i[7]||=e=>l(Z)&&$(),onBlur:$,onWheel:Rt,onKeydown:zt,onClick:Bt,onContextmenu:ae(Bt,[`prevent`])},null,40,Me)):(n(),c(`p`,Ne,u(j.value?`准备完成后会自动接管,无需再次点击。`:T.value.mode===`off`?S.value===`managed-browser`?`浏览器尚未打开。接管后可打开网页。`:`打开电脑后可查看桌面。`:`正在读取电脑画面…`),1)),E.value&&(!V.value||E.value.generation!==T.value.generation)?(n(),c(`span`,Pe,u(V.value?`正在同步画面`:T.value.mode===`off`?`上次画面`:`仅查看`),1)):p(``,!0)],2),P.value||T.value.error?(n(),c(`p`,Fe,u(P.value||T.value.error),1)):p(``,!0),O.value||!g.embedded&&!D.value?(n(),c(`footer`,Ie,[T.value.backend===`grok`?(n(),c(`p`,Le,`多个机器人共享同一台 Grok Bot 云端电脑、工作文件与浏览器资料。`)):T.value.backend===`local`?(n(),c(`p`,Re,`当前显示`+u(T.value.hostName||`所选电脑`)+`的桌面,点击、输入、按键和滚动都会发送到这台电脑。`,1)):p(``,!0),S.value===`vm`&<.value?.computerEnvironmentId?(n(),c(`p`,ze,`共享电脑:`+u(lt.value.computerEnvironmentName)+`。成员共用工作文件和浏览器资料,可同时执行命令与文件操作,桌面操作交替进行;人工接管时机器人暂停等待。`,1)):p(``,!0),T.value.backend===`managed-browser`?(n(),c(`p`,Be,`当前是托管浏览器,与电脑桌面和虚拟机分别管理;网页操作无需启动虚拟机。`)):p(``,!0),A.value?.downloads.length?(n(),c(`details`,Ve,[m(`summary`,null,`浏览器下载(`+u(A.value.downloads.length)+`)`,1),m(`ul`,null,[(n(!0),c(d,null,a(A.value.downloads,e=>(n(),c(`li`,{key:e.id},[m(`span`,null,u(e.name),1),m(`small`,null,u((e.size/1024).toFixed(1))+` KiB`,1)]))),128))])])):p(``,!0),D.value?p(``,!0):(n(),c(`p`,He,`查看不会输入任何内容。接管后机器人会暂停,已有操作结束后才允许人工操作。`)),!D.value&&!_t.value&&S.value!==`managed-browser`?(n(),c(`button`,{key:6,type:`button`,disabled:F.value,onClick:i[8]||=e=>K(vt)},`重新检查连接`,8,Ue)):p(``,!0),!D.value&&T.value.mode!==`human`?(n(),c(`button`,{key:7,type:`button`,disabled:F.value||!_t.value,onClick:i[9]||=e=>g.embedded?b(`controlRequest`):Tt()},u(j.value?`正在准备浏览器…`:N.value?.status===`failed`?`重试并接管浏览器`:T.value.mode===`off`?`打开并控制`:`接管电脑`),9,We)):p(``,!0),V.value?(n(),c(d,{key:8},[O.value?(n(),c(`section`,Ge,[m(`div`,Ke,[(n(),c(d,null,a([`Return`,`Tab`,`Escape`,`BackSpace`,`Up`,`Down`,`Left`,`Right`],e=>m(`button`,{key:e,type:`button`,disabled:!U.value,onClick:t=>X({kind:`key`,key:e})},u({Return:`回车`,Escape:`Esc`,BackSpace:`退格`,Up:`↑`,Down:`↓`,Left:`←`,Right:`→`}[e]||e),9,qe)),64))]),m(`div`,Je,[m(`button`,{disabled:!U.value,onClick:i[10]||=e=>X({kind:`key`,key:`a`,modifiers:[T.value.backend===`local`||T.value.backend===`browser`?`super`:`ctrl`]})},`全选`,8,Ye),m(`button`,{disabled:!U.value,onClick:i[11]||=e=>X({kind:`key`,key:`c`,modifiers:[T.value.backend===`local`||T.value.backend===`browser`?`super`:`ctrl`]})},`复制`,8,Xe),m(`button`,{disabled:!U.value,onClick:i[12]||=e=>X({kind:`key`,key:`v`,modifiers:[T.value.backend===`local`||T.value.backend===`browser`?`super`:`ctrl`]})},`粘贴`,8,Ze)]),m(`label`,null,[i[17]||=oe(`输入到电脑`,-1),r(m(`textarea`,{"onUpdate:modelValue":i[13]||=e=>ut.value=e,rows:`2`,maxlength:`16000`,placeholder:`输入文字后点击发送`,disabled:!U.value},null,8,Qe),[[ie,ut.value]])]),m(`button`,{type:`button`,disabled:!U.value||!ut.value,onClick:i[14]||=e=>{X({kind:`text`,text:ut.value}),ut.value=``}},`输入文字`,8,$e)])):p(``,!0),m(`label`,null,[i[18]||=oe(`交还说明`,-1),r(m(`textarea`,{"onUpdate:modelValue":i[15]||=e=>I.value=e,rows:`2`,maxlength:`4000`,placeholder:`告诉机器人你完成了什么,以及接下来需要做什么`},null,512),[[ie,I.value]])]),m(`button`,{type:`button`,disabled:F.value||T.value.mode!==`human`,onClick:i[16]||=e=>K(Vt)},u(T.value.canResume?`交还机器人并继续`:S.value===`managed-browser`?`结束接管`:`结束控制`),9,et),S.value===`managed-browser`?(n(),c(`small`,tt,u(A.value?.supportsRetention===!0?`交还或收起只会释放操作权,页面会保留;长时间空闲后可能回收。`:A.value?.supportsRetention===!1?`此节点需更新后才能跨任务保留页面;任务结束后浏览器会关闭。`:`交还或收起会结束当前接管。`),1)):(n(),c(`small`,nt,`控制只属于当前页面。页面断开后控制权会到期,任务不会自行恢复。`))],64)):p(``,!0)])):p(``,!0),ht.value?(n(),c(`section`,{key:5,class:`browser-session-actions`,"aria-busy":ct.value},[m(`button`,{type:`button`,disabled:F.value,onClick:Ht},u(ct.value?`正在关闭浏览器…`:`关闭浏览器`),9,it),i[19]||=m(`small`,null,`结束当前浏览器会话并关闭标签页。`,-1)],8,rt)):p(``,!0)]),_:1},40,[`class`,`aria-label`]))],8,[`disabled`]))}}),[[`__scopeId`,`data-v-a344d14e`]]);export{ce as n,D as t};
|
|
2
|
-
//# sourceMappingURL=ComputerPanel-
|
|
1
|
+
import{A as e,B as t,F as n,G as r,H as i,L as a,M as o,W as s,_ as c,at as l,ct as u,d,et as f,f as ee,g as p,h as te,m,o as ne,ot as re,p as h,s as ie,t as g,u as ae,v as oe,x as se}from"./_plugin-vue_export-helper-CscYwSBt.js";import{F as _,j as v}from"./index-CRBIQ5t6.js";function ce(e){return!!e?.enabled&&(!!e.available||!!e.installation)}async function le(e,t,n,r){let i=`/api/app/agents/${encodeURIComponent(e)}/managed-browser`,a=t??await _(i,{signal:n});if(n.throwIfAborted(),!ce(a))throw Error(a.reason||`托管浏览器不可用,请检查执行节点与授权`);!a.available&&a.installation?.status!==`installing`&&(a=await _(i+`/prepare`,{method:`POST`,body:{retry:a.installation?.status===`failed`},signal:n}));let o=Date.now();for(;;){if(n.throwIfAborted(),r(a),a.available)return;if(a.installation?.status===`failed`)throw Error(a.installation.error||a.installation.message||`浏览器准备失败,请重试`);if(!ce(a))throw Error(a.reason||`执行节点已不可用,请重新连接后重试`);if(Date.now()-o>6e5)throw Error(`浏览器仍在准备中,可稍后重新接管查看进度`);await new Promise((e,t)=>{let r=()=>{clearTimeout(i),t(n.reason??new DOMException(`Aborted`,`AbortError`))},i=setTimeout(()=>{n.removeEventListener(`abort`,r),e()},1e3);n.addEventListener(`abort`,r,{once:!0}),n.aborted&&r()}),a=await _(i,{signal:n})}}var ue=class{send;failed;id=v();done;resolve;queue=[];running=!1;ending=!1;finished=!1;heartbeat;latest;constructor(e,t,n){this.send=t,this.failed=n,this.latest={x:e.x,y:e.y},this.done=new Promise(e=>{this.resolve=e}),this.heartbeat=setInterval(()=>{this.ending||this.move(this.latest)},1e3),this.enqueue(`start`,e)}move(e){this.ending||this.enqueue(`move`,e)}end(e){this.ending||(this.ending=!0,clearInterval(this.heartbeat),this.enqueue(`end`,e))}cancel(){return this.finished?this.done:(this.ending=!0,clearInterval(this.heartbeat),this.queue=[],this.enqueue(`cancel`,this.latest),this.done)}enqueue(e,t){this.latest={x:t.x,y:t.y};let n={kind:`pointer`,gestureId:this.id,phase:e,x:t.x,y:t.y};e===`move`&&this.queue.at(-1)?.phase===`move`?this.queue[this.queue.length-1]=n:this.queue.push(n),this.flush()}async flush(){if(!(this.running||this.finished)){this.running=!0;try{for(;this.queue.length;){let e=this.queue.shift();if(await this.send(e),e.phase===`end`||e.phase===`cancel`){this.finish();return}}}catch(e){this.ending=!0,this.queue=[],clearInterval(this.heartbeat);try{await this.send({kind:`pointer`,gestureId:this.id,phase:`cancel`,...this.latest})}catch{}this.failed(e),this.finish()}finally{this.running=!1}}}finish(){this.finished=!0,this.ending=!0,this.queue=[],clearInterval(this.heartbeat),this.resolve()}},de={class:`browser-toolbar`,"aria-label":`机器人浏览器`},y={class:`browser-tabs`,role:`tablist`,"aria-label":`浏览器标签页`},b=[`aria-selected`,`title`,`disabled`,`onClick`],x=[`aria-label`,`disabled`,`onClick`],fe=[`disabled`],S=[`disabled`],C=[`disabled`],w=[`disabled`],T=[`disabled`],E=[`disabled`],pe=g(se({__name:`BrowserToolbar`,props:{state:{},enabled:{type:Boolean}},emits:[`action`],setup(e,{emit:t}){let o=e,s=t,l=f(``),ee=f(!1),p=h(()=>o.state?.tabs.find(e=>e.active));i(()=>p.value?.url,e=>{ee.value||(l.value=e===`about:blank`?``:e??``)},{immediate:!0});function te(){let e=l.value.trim();e&&(/^https?:\/\//i.test(e)||(e=`https://`+e),ee.value=!1,s(`action`,{kind:`navigate`,url:e}))}return(t,i)=>(n(),c(`div`,de,[m(`div`,y,[(n(!0),c(d,null,a(e.state?.tabs,t=>(n(),c(`div`,{key:t.id,class:re([`tab`,{active:t.active}])},[m(`button`,{role:`tab`,"aria-selected":t.active,title:t.title,disabled:!e.enabled,onClick:e=>s(`action`,{kind:`select-tab`,tabId:t.id})},u(t.title),9,b),m(`button`,{class:`close-tab`,"aria-label":`关闭标签页 ${t.title}`,disabled:!e.enabled,onClick:e=>s(`action`,{kind:`close-tab`,tabId:t.id})},`×`,8,x)],2))),128)),m(`button`,{class:`new-tab`,"aria-label":`新建标签页`,disabled:!e.enabled,onClick:i[0]||=e=>s(`action`,{kind:`new-tab`,url:`https://www.google.com/`})},`+`,8,fe)]),m(`form`,{class:`navigation`,onSubmit:ae(te,[`prevent`])},[m(`button`,{type:`button`,"aria-label":`后退`,disabled:!e.enabled,onClick:i[1]||=e=>s(`action`,{kind:`back`})},`←`,8,S),m(`button`,{type:`button`,"aria-label":`前进`,disabled:!e.enabled,onClick:i[2]||=e=>s(`action`,{kind:`forward`})},`→`,8,C),m(`button`,{type:`button`,"aria-label":`重新加载页面`,disabled:!e.enabled,onClick:i[3]||=e=>s(`action`,{kind:`reload`})},`↻`,8,w),r(m(`input`,{"onUpdate:modelValue":i[4]||=e=>l.value=e,type:`text`,inputmode:`url`,autocomplete:`off`,spellcheck:`false`,"aria-label":`浏览器地址`,placeholder:`输入网址`,disabled:!e.enabled,onFocus:i[5]||=e=>ee.value=!0,onBlur:i[6]||=e=>ee.value=!1},null,40,T),[[ie,l.value]]),m(`button`,{type:`submit`,disabled:!e.enabled||!l.value.trim()},`前往`,8,E)],32)]))}}),[[`__scopeId`,`data-v-76ef2743`]]),me=[`value`,`disabled`],he=[`value`,`disabled`],ge=[`disabled`],_e=[`value`],ve={key:2},ye=[`disabled`],be=[`disabled`],xe=[`aria-expanded`],Se=[`aria-pressed`],Ce=[`disabled`],we=[`aria-busy`],Te={role:`status`},Ee=[`value`],De={key:1},Oe={key:2,role:`alert`},ke=[`aria-busy`],Ae={key:0,role:`status`},je=[`disabled`],Me=[`src`,`alt`],Ne={key:1},Pe={key:2,class:`view-label`},Fe={key:3,class:`computer-error`,role:`alert`},Ie={key:4},Le={key:0},Re={key:1},ze={key:2},Be={key:3},Ve={key:4,class:`browser-downloads`},He={key:5},Ue=[`disabled`],We=[`disabled`],Ge={key:0,class:`manual-input`},Ke={class:`key-row`},qe=[`disabled`,`onClick`],Je={class:`key-row`},Ye=[`disabled`],Xe=[`disabled`],Ze=[`disabled`],Qe=[`disabled`],$e=[`disabled`],et=[`disabled`],tt={key:1},nt={key:2},rt=[`aria-busy`],it=[`disabled`],D=g(se({__name:`ComputerPanel`,props:{agents:{},embedded:{type:Boolean},standalone:{type:Boolean},autoTake:{type:Boolean},backend:{},host:{}},emits:[`close`,`changed`,`controlRequest`,`targetChanged`],setup(g,{expose:se,emit:de}){let y=g,b=de,x=f(y.agents[0]?.id??``),fe=f(),S=f(y.backend),C=f(y.host??(y.backend===`desktop`?`local`:``)),w=f(),T=f({mode:`off`}),E=f(),D=f(),O=f(!1),at=f(!1),k=f(),ot=f(!1),A=f(),j=f(!1),st=f(!1),ct=f(!1),M,N=h(()=>S.value===`managed-browser`?A.value?.installation:void 0),lt=h(()=>y.agents.find(e=>e.id===x.value)),P=f(``),F=f(!1),ut=f(``),I=f(``),L=f(!1),R,dt,z=!1,ft=!1,pt=0,B=0,mt={off:`电脑未运行`,idle:`电脑空闲 · 仅查看`,agent:`机器人正在操作`,pausing:`正在等待当前操作结束`,human:`人工控制中`,resuming:`正在交还机器人`,error:`电脑需要检查`},V=h(()=>!!D.value&&D.value.controlId===T.value.controlId),ht=h(()=>S.value===`managed-browser`&&V.value&&T.value.mode===`human`&&!T.value.canResume),H=h(()=>L.value&&!!E.value&&V.value&&T.value.mode===`human`&&E.value?.generation===T.value.generation),U=h(()=>H.value&&!F.value&&!ot.value),W=f({vm:!0,cloud:!0,desktop:!0,managedBrowser:!1}),G=h(()=>{let e=W.value,t=w.value,n=[];if(e.desktop)for(let e of t?.hosts??[])n.push({key:`desktop:`+e.id,label:(e.id===`local`?`服务器`:`电脑`)+` · `+(e.name||`未命名`),backend:`desktop`,host:e.id,disabled:!e.online});if(e.cloud&&n.push({key:`cloud`,label:`云端 · Grok Bot`+(t?.cloudConfigured?``:` · 未连接`),backend:`cloud`,disabled:!t?.cloudConfigured}),e.vm&&n.push({key:`vm`,label:`本地虚拟机`+(t?.vmEnabled?``:` · 未启用`),backend:`vm`,disabled:!t?.vmEnabled}),e.managedBrowser){let e=t?.managedBrowser;n.push({key:`managed-browser`,label:`托管浏览器`+(e?.available?``:ce(e)?` · `+(e?.installation?.status===`failed`?`准备失败`:`待准备`):` · 不可用`),backend:`managed-browser`,disabled:!ce(e)})}return n}),gt=h(()=>G.value.find(e=>e.backend===S.value&&(e.host??``)===C.value)?.key??``),_t=h(()=>G.value.some(e=>e.key===gt.value&&!e.disabled));i([S,C],([e,t])=>{e&&b(`targetChanged`,e,t||void 0)},{immediate:!0});async function vt(){if(!x.value)return;let e=x.value,t=encodeURIComponent(e),n=await _(`/api/app/settings/host-tools`);if(z||e!==x.value)return;W.value={vm:n.vm,cloud:n.cloud,desktop:n.scriptMachine||n.serverComputer,managedBrowser:n.managedBrowser===!0};let[r,i,a,o]=await Promise.all([W.value.desktop?_(`/api/app/agents/${t}/desktop-environment`).catch(()=>void 0):Promise.resolve(void 0),W.value.cloud?_(`/api/app/agents/${t}/cloud-computer`).catch(()=>void 0):Promise.resolve(void 0),W.value.vm?_(`/api/app/agents/${t}/local-vm`).catch(()=>void 0):Promise.resolve(void 0),W.value.managedBrowser?_(`/api/app/agents/${t}/managed-browser`).catch(()=>void 0):Promise.resolve(void 0)]);z||e!==x.value||(w.value={hosts:(r?.hosts??[]).filter(e=>e.id===`local`?n.serverComputer:n.scriptMachine),cloudConfigured:!!i?.configured,vmEnabled:!!a?.enabled,managedBrowser:o},S.value===`managed-browser`&&(A.value=o,k.value=o))}async function yt(e){let t=G.value.find(t=>t.key===e);if(!(!t||t.disabled||e===gt.value)){if(await $(),D.value)try{await St(`/giveback`,{...D.value,notes:``})}catch(e){P.value=e instanceof Error?e.message:`请先交还当前电脑`;return}S.value=t.backend,C.value=t.host??``,M?.abort(),clearTimeout(Y),J=void 0,k.value=void 0,A.value=void 0,q.length=0,L.value=!1,B++,R=void 0,E.value=void 0,D.value=void 0,T.value={mode:`off`},P.value=``,await Ct()}}let bt=()=>`/api/app/agents/${encodeURIComponent(x.value)}/computer`,xt=()=>{let e=new URLSearchParams;S.value&&e.set(`backend`,S.value),S.value===`desktop`&&C.value&&e.set(`host`,C.value);let t=e.toString();return t?`?`+t:``};async function St(e,t){return _(bt()+e+xt(),{method:`POST`,body:t})}async function Ct(){if(ft||F.value||z||!x.value||document.hidden||!_t.value&&!(S.value===`managed-browser`&&W.value.managedBrowser))return;ft=!0;let e=++B,t=bt(),n=xt(),r=x.value;try{if(S.value===`managed-browser`){let t=await _(`/api/app/agents/${encodeURIComponent(r)}/managed-browser`).catch(t=>{throw e===B&&!z&&(A.value=void 0,k.value=void 0,w.value&&(w.value.managedBrowser=void 0),T.value={mode:`off`,backend:`managed-browser`}),t});if(e!==B||z)return;if(A.value=t,k.value=t,w.value&&(w.value.managedBrowser=t),!t.available){T.value={mode:`off`,backend:`managed-browser`},L.value=!1,E.value=void 0,P.value=``;return}}let i=await _(t+n);if(e!==B||z)return;if(T.value=i,L.value=!0,D.value&&i.controlId!==D.value.controlId&&i.mode!==`pausing`&&(D.value=void 0),V.value&&Date.now()-pt>8e3&&(await St(`/renew`,D.value),pt=Date.now()),i.backend===`browser`){let t=await _(`/api/app/agents/${encodeURIComponent(x.value)}/browser`);if(e!==B||z)return;k.value=t,A.value=void 0}else i.backend!==`managed-browser`&&(k.value=void 0,A.value=void 0);if(i.mode!==`off`&&(![`browser`,`managed-browser`].includes(i.backend??``)||k.value?.open)){let r=await _(t+`/frame`+n);e===B&&!z&&(E.value=r)}else E.value=void 0;P.value=``}catch(t){if(e===B&&!z){L.value=!1,E.value=void 0,q.length=0,P.value=t instanceof Error?t.message:`无法读取电脑状态`;{let e=Number(t.status);([401,410].includes(e)||e===403&&D.value)&&(D.value=void 0,E.value=void 0,T.value={mode:`off`})}}}finally{ft=!1}}async function K(e){if(F.value)return;B++,F.value=!0,P.value=``;let t=``;try{await e()}catch(e){t=e instanceof Error?e.message:`电脑操作失败`}finally{F.value=!1,z||(await Ct(),t&&(P.value=t),Dt())}}async function wt(){if(!F.value){st.value=!0;try{await K(vt)}finally{st.value=!1}}}function Tt(){return K(async()=>{if(!_t.value)throw Error(`所选电脑不可用,请重新选择`);let e=x.value,t=S.value,n=bt(),r=xt(),i=new AbortController;M=i;try{if(t===`managed-browser`&&(j.value=!A.value?.available,await le(e,A.value,i.signal,n=>{!z&&e===x.value&&t===S.value&&(A.value=n,k.value=n,w.value&&(w.value.managedBrowser=n))})),i.signal.throwIfAborted(),z||e!==x.value||t!==S.value)return;j.value=!1,R??=v();let a=await _(n+`/take`+r,{method:`POST`,body:{requestId:R}}),o={controlId:a.controlId,token:a.token};if(z||i.signal.aborted||e!==x.value||t!==S.value){await _(n+`/giveback`+r,{method:`POST`,body:{...o,notes:``}});return}D.value=o,T.value=a,pt=0}catch(e){if(!i.signal.aborted)throw e}finally{M===i&&(M=void 0,j.value=!1)}})}let q=[],Et=!1,J,Y;function X(e){if(!H.value||z||ot.value)return;J&&(q.push(J),J=void 0,clearTimeout(Y));let t=q.at(-1);if(e.kind===`text`&&t?.kind===`text`&&t.text.length+e.text.length<=16e3)t.text+=e.text;else if(q.length<64)q.push(e);else{P.value=`输入过快,请稍后再试`;return}Dt()}async function Dt(){if(Et||F.value||!q.length||z)return;if(!H.value||!E.value||!D.value){q.length=0;return}Et=!0;let e=q.shift(),t=E.value,n=D.value;try{await K(async()=>{await St(`/input`,{...n,requestId:v(),generation:t.generation,frameId:t.id,action:e})}),P.value&&(q.length=0)}finally{Et=!1,q.length&&setTimeout(()=>void Dt(),0)}}function Ot(e){if(!U.value||!E.value||!D.value)return;let t=E.value,n=D.value;K(async()=>{S.value===`managed-browser`?await _(`/api/app/agents/${encodeURIComponent(x.value)}/managed-browser/action`,{method:`POST`,body:{...n,requestId:v(),generation:t.generation,action:e}}):await St(`/browser`,{...n,requestId:v(),generation:t.generation,frameId:t.id,action:e})})}function kt(e,t=!1){let n=e.currentTarget.getBoundingClientRect(),r=E.value,i=Math.min(n.width/r.width,n.height/r.height),a=n.left+(n.width-r.width*i)/2,o=n.top+(n.height-r.height*i)/2,s=Math.floor((e.clientX-a)/i),c=Math.floor((e.clientY-o)/i);if(t)return{x:Math.max(0,Math.min(r.width-1,s)),y:Math.max(0,Math.min(r.height-1,c))};if(!(s<0||c<0||s>=r.width||c>=r.height))return{x:s,y:c}}let Z,At=!1,Q;function jt(e){if(!U.value||Z||e.button!==0||q.length)return;let t=e.currentTarget;t.focus({preventScroll:!0});let n=kt(e);n&&(At=!1,Z={...n,clientX:e.clientX,clientY:e.clientY,pointerId:e.pointerId,element:t},t.setPointerCapture(e.pointerId))}function Mt(e){let t=bt(),n=xt(),r=D.value,i=E.value.generation,a=E.value;clearTimeout(Y),J=void 0,P.value=``,ot.value=!0;let o=()=>!z&&bt()===t&&xt()===n&&D.value?.controlId===r.controlId&&T.value.generation===i,s=new ue(e,async e=>{if(e.phase!==`cancel`&&(!o()||!H.value))throw Error(`控制权已变化,请重新接管`);if(await _(t+`/input`+n,{method:`POST`,timeoutMs:5e3,body:{...r,requestId:v(),generation:i,frameId:a.id,action:{...e}}}),e.phase===`cancel`)return;let s=await _(t+`/frame`+n,{timeoutMs:5e3});if(!o()||s.generation!==i)throw Error(`控制权已变化,请重新接管`);a=s,E.value=s},e=>{o()&&(P.value=e instanceof Error?e.message:`拖动失败,请重新按下鼠标`)});Q=s,s.done.then(async()=>{if(Q===s){Q=void 0,ot.value=!1;let e=P.value;await Ct(),o()&&e&&(P.value=e)}})}function Nt(e){let t=Z;if(!t||e.pointerId!==t.pointerId||!H.value||S.value!==`managed-browser`)return;!Q&&Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY)>5&&(At=!0,Mt(t));let n=kt(e,!0);n&&Q?.move(n)}function Pt(){let e=Z;Z=void 0,e?.element.hasPointerCapture(e.pointerId)&&e.element.releasePointerCapture(e.pointerId)}function $(){return Pt(),Q?(At=!0,Q.cancel()):Promise.resolve()}function Ft(e){let t=Z;if(!t||e.pointerId!==t.pointerId)return;if(!H.value){$();return}Nt(e);let n=kt(e,!0);if(Pt(),Q){n?Q.end(n):$();return}n&&Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY)>5&&(At=!0,X({kind:`drag`,fromX:t.x,fromY:t.y,toX:n.x,toY:n.y}))}let It=()=>{$()},Lt=()=>{document.hidden&&$()};i(H,e=>{e||$()});function Rt(e){H.value&&(e.preventDefault(),X({kind:`scroll`,direction:Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX>0?`right`:`left`:e.deltaY>0?`down`:`up`,amount:Math.min(20,Math.max(1,Math.ceil(Math.abs(e.deltaY||e.deltaX)/80)))}))}function zt(e){if(!H.value)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){$(),e.currentTarget.blur();return}let t=[e.ctrlKey||S.value===`managed-browser`&&e.metaKey?`ctrl`:``,e.altKey?`alt`:``,e.shiftKey?`shift`:``,e.metaKey&&S.value!==`managed-browser`?`super`:``].filter(Boolean);e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey?X({kind:`text`,text:e.key}):[`Control`,`Alt`,`Shift`,`Meta`].includes(e.key)||X({kind:`key`,key:{Enter:`Return`,ArrowUp:`Up`,ArrowDown:`Down`,ArrowLeft:`Left`,ArrowRight:`Right`,Backspace:`BackSpace`}[e.key]??e.key,modifiers:t})}function Bt(e){if(At){At=!1;return}if(!H.value||!E.value)return;let t=kt(e);if(!t)return;let n={kind:`click`,...t,button:e.button===2?`right`:`left`,count:e.detail>1?2:1};if(e.button===2||e.detail>1)clearTimeout(Y),J=void 0,X(n);else{if(J){let e=J;J=void 0,clearTimeout(Y),X(e)}J=n,Y=setTimeout(()=>{let e=J;J=void 0,e&&X(e)},180)}}async function Vt(){await $(),D.value&&(await St(`/giveback`,{...D.value,notes:I.value}),D.value=void 0,R=void 0,I.value=``)}async function Ht(){if(F.value||!ht.value||!D.value)return;await $();let e=x.value,t=D.value;ct.value=!0;try{await K(async()=>{clearTimeout(Y),J=void 0,q.length=0;let n=await _(`/api/app/agents/${encodeURIComponent(e)}/managed-browser/close`,{method:`POST`,body:t});z||x.value!==e||S.value!==`managed-browser`||D.value!==t||(T.value=n,D.value=void 0,R=void 0,I.value=``,E.value=void 0,L.value=!1,O.value=!1,b(`changed`))})}finally{ct.value=!1}}async function Ut(){if(j.value){M?.abort(),z=!0,fe.value?.close?.(),b(`close`);return}F.value||(await K(Vt),D.value||(z=!0,!y.embedded&&!y.standalone&&fe.value?.close(),b(`close`)))}async function Wt(){try{document.fullscreenElement?await document.exitFullscreen():await fe.value?.requestFullscreen()}catch{P.value=`无法进入全屏,请使用窗口最大化`}}async function Gt(){await Ct(),z||(dt=setTimeout(()=>void Gt(),1200))}return i(x,()=>{$(),M?.abort(),clearTimeout(Y),J=void 0,k.value=void 0,A.value=void 0,q.length=0,L.value=!1,B++,R=void 0,E.value=void 0,D.value=void 0,T.value={mode:`off`},P.value=``,S.value=y.backend,C.value=y.host??(y.backend===`desktop`?`local`:``),w.value=void 0,vt().then(async()=>{if(!S.value){let e=G.value.find(e=>!e.disabled);e&&await yt(e.key)}await Ct()}).catch(e=>{P.value=e instanceof Error?e.message:`无法读取电脑列表`})}),o(async()=>{window.addEventListener(`blur`,It),document.addEventListener(`visibilitychange`,Lt),!y.embedded&&!y.standalone&&fe.value?.showModal();try{if(await vt(),z)return;if(!S.value){let e=G.value.find(e=>!e.disabled);e&&await yt(e.key)}if(!_t.value&&S.value!==`managed-browser`)throw Error(`所选电脑不可用,请重新选择;未打开其他电脑`);y.autoTake&&!z&&_t.value&&await Tt()}catch(e){P.value=e instanceof Error?e.message:`无法读取电脑列表`}z||Gt()}),e(()=>{$(),window.removeEventListener(`blur`,It),document.removeEventListener(`visibilitychange`,Lt),M?.abort(),D.value&&St(`/giveback`,{...D.value,notes:I.value}).catch(()=>{}),q.length=0,J=void 0,clearTimeout(Y),z=!0,B++,clearTimeout(dt)}),se({take:Tt,close:Ut,releaseControl:async()=>{if(j.value){M?.abort();return}if(F.value)throw Error(`请等待当前操作完成`);if(await K(Vt),D.value)throw Error(P.value||`请先交还控制权`)},hasControl:()=>!!D.value}),(e,i)=>(n(),te(ee,{to:`body`,disabled:g.embedded||g.standalone},[(n(),te(t(g.embedded||g.standalone?`section`:`dialog`),{ref_key:`dialog`,ref:fe,class:re([`computer-panel`,{embedded:g.embedded,standalone:g.standalone}]),"aria-label":G.value.find(e=>e.key===gt.value)?.label||`电脑桌面`,onCancel:ae(Ut,[`prevent`])},{default:s(()=>[m(`header`,null,[m(`div`,null,[m(`strong`,null,u(S.value===`managed-browser`?`托管浏览器`:T.value.backend===`grok`?`Grok Bot 云端电脑`:T.value.backend===`local`?T.value.hostName??`服务器桌面`:T.value.backend===`browser`?`浏览器 · `+T.value.hostName:`本地虚拟机`),1),m(`small`,null,u(j.value?`正在准备浏览器`:mt[T.value.mode]),1)]),G.value.length>1?(n(),c(`select`,{key:0,value:gt.value,"aria-label":`切换电脑环境`,disabled:!!D.value||F.value,onChange:i[0]||=e=>yt(e.target.value)},[(n(!0),c(d,null,a(G.value,e=>(n(),c(`option`,{key:e.key,value:e.key,disabled:e.disabled},u(e.label),9,he))),128))],40,me)):p(``,!0),g.agents.length>1?r((n(),c(`select`,{key:1,"onUpdate:modelValue":i[1]||=e=>x.value=e,"aria-label":`选择电脑`,disabled:!!D.value||F.value},[(n(!0),c(d,null,a(g.agents,e=>(n(),c(`option`,{key:e.id,value:e.id},u(e.name),9,_e))),128))],8,ge)),[[ne,x.value]]):g.embedded?p(``,!0):(n(),c(`span`,ve,u(g.agents[0]?.name),1)),g.embedded&&!D.value?(n(),c(`button`,{key:3,disabled:F.value||T.value.mode===`human`,onClick:i[2]||=e=>b(`controlRequest`)},`接管电脑`,8,ye)):p(``,!0),g.embedded&&V.value?(n(),c(`button`,{key:4,onClick:i[3]||=e=>O.value=!O.value},`键盘与操作`)):p(``,!0),g.embedded&&V.value?(n(),c(`button`,{key:5,disabled:F.value||T.value.mode!==`human`,onClick:i[4]||=e=>K(Vt)},`交还`,8,be)):p(``,!0),g.embedded?p(``,!0):(n(),c(d,{key:6},[V.value?(n(),c(`button`,{key:0,type:`button`,"aria-expanded":O.value,onClick:i[5]||=e=>O.value=!O.value},`键盘与操作`,8,xe)):p(``,!0),m(`button`,{type:`button`,"aria-pressed":at.value,onClick:i[6]||=e=>at.value=!at.value},u(at.value?`适应窗口`:`原始大小`),9,Se),m(`button`,{type:`button`,onClick:Wt},`全屏`)],64)),g.embedded?p(``,!0):(n(),c(`button`,{key:7,class:`return-control`,type:`button`,disabled:F.value&&!j.value,onClick:Ut},u(S.value===`managed-browser`?D.value?`交还并收起`:`收起窗口`:D.value?`交还并关闭`:`关闭`),9,Ce))]),T.value.backend===`browser`||T.value.backend===`managed-browser`?(n(),te(pe,{key:0,state:k.value,enabled:U.value,onAction:Ot},null,8,[`state`,`enabled`])):p(``,!0),N.value&&N.value.status!==`ready`?(n(),c(`section`,{key:1,class:`browser-installation`,"aria-busy":j.value},[m(`p`,Te,u(N.value.message),1),N.value.status===`installing`||N.value.status===`checking`?(n(),c(`progress`,{key:0,value:N.value.progress,max:`100`,"aria-label":`浏览器准备进度`},null,8,Ee)):p(``,!0),j.value?(n(),c(`small`,De,`关闭窗口后仍会继续准备。`)):p(``,!0),N.value.error?(n(),c(`p`,Oe,u(N.value.error),1)):p(``,!0)],8,we)):p(``,!0),S.value===`managed-browser`&&!A.value?.available?(n(),c(`section`,{key:2,class:`browser-availability`,"aria-busy":st.value},[N.value?p(``,!0):(n(),c(`p`,Ae,u(A.value?.reason||(W.value.managedBrowser?`执行节点暂时不可用,请检查连接后重新检测。`:`托管浏览器尚未开放,请在 Bot 设置中开启。`)),1)),m(`button`,{type:`button`,disabled:F.value,onClick:wt},u(st.value?`正在检测…`:`重新检测`),9,je)],8,ke)):p(``,!0),m(`div`,{class:re([`computer-screen`,{controlling:H.value,"actual-size":at.value}])},[E.value?(n(),c(`img`,{key:0,src:`data:image/png;base64,${E.value.data}`,alt:(G.value.find(e=>e.key===gt.value)?.label||`电脑`)+`当前画面`,draggable:`false`,tabindex:`0`,title:`点按后可使用键盘、滚轮和拖动;按 Esc 退出键盘控制`,onPointerdown:jt,onPointermove:Nt,onPointerup:Ft,onPointercancel:$,onLostpointercapture:i[7]||=e=>l(Z)&&$(),onBlur:$,onWheel:Rt,onKeydown:zt,onClick:Bt,onContextmenu:ae(Bt,[`prevent`])},null,40,Me)):(n(),c(`p`,Ne,u(j.value?`准备完成后会自动接管,无需再次点击。`:T.value.mode===`off`?S.value===`managed-browser`?`浏览器尚未打开。接管后可打开网页。`:`打开电脑后可查看桌面。`:`正在读取电脑画面…`),1)),E.value&&(!V.value||E.value.generation!==T.value.generation)?(n(),c(`span`,Pe,u(V.value?`正在同步画面`:T.value.mode===`off`?`上次画面`:`仅查看`),1)):p(``,!0)],2),P.value||T.value.error?(n(),c(`p`,Fe,u(P.value||T.value.error),1)):p(``,!0),O.value||!g.embedded&&!D.value?(n(),c(`footer`,Ie,[T.value.backend===`grok`?(n(),c(`p`,Le,`多个机器人共享同一台 Grok Bot 云端电脑、工作文件与浏览器资料。`)):T.value.backend===`local`?(n(),c(`p`,Re,`当前显示`+u(T.value.hostName||`所选电脑`)+`的桌面,点击、输入、按键和滚动都会发送到这台电脑。`,1)):p(``,!0),S.value===`vm`&<.value?.computerEnvironmentId?(n(),c(`p`,ze,`共享电脑:`+u(lt.value.computerEnvironmentName)+`。成员共用工作文件和浏览器资料,可同时执行命令与文件操作,桌面操作交替进行;人工接管时机器人暂停等待。`,1)):p(``,!0),T.value.backend===`managed-browser`?(n(),c(`p`,Be,`当前是托管浏览器,与电脑桌面和虚拟机分别管理;网页操作无需启动虚拟机。`)):p(``,!0),A.value?.downloads.length?(n(),c(`details`,Ve,[m(`summary`,null,`浏览器下载(`+u(A.value.downloads.length)+`)`,1),m(`ul`,null,[(n(!0),c(d,null,a(A.value.downloads,e=>(n(),c(`li`,{key:e.id},[m(`span`,null,u(e.name),1),m(`small`,null,u((e.size/1024).toFixed(1))+` KiB`,1)]))),128))])])):p(``,!0),D.value?p(``,!0):(n(),c(`p`,He,`查看不会输入任何内容。接管后机器人会暂停,已有操作结束后才允许人工操作。`)),!D.value&&!_t.value&&S.value!==`managed-browser`?(n(),c(`button`,{key:6,type:`button`,disabled:F.value,onClick:i[8]||=e=>K(vt)},`重新检查连接`,8,Ue)):p(``,!0),!D.value&&T.value.mode!==`human`?(n(),c(`button`,{key:7,type:`button`,disabled:F.value||!_t.value,onClick:i[9]||=e=>g.embedded?b(`controlRequest`):Tt()},u(j.value?`正在准备浏览器…`:N.value?.status===`failed`?`重试并接管浏览器`:T.value.mode===`off`?`打开并控制`:`接管电脑`),9,We)):p(``,!0),V.value?(n(),c(d,{key:8},[O.value?(n(),c(`section`,Ge,[m(`div`,Ke,[(n(),c(d,null,a([`Return`,`Tab`,`Escape`,`BackSpace`,`Up`,`Down`,`Left`,`Right`],e=>m(`button`,{key:e,type:`button`,disabled:!U.value,onClick:t=>X({kind:`key`,key:e})},u({Return:`回车`,Escape:`Esc`,BackSpace:`退格`,Up:`↑`,Down:`↓`,Left:`←`,Right:`→`}[e]||e),9,qe)),64))]),m(`div`,Je,[m(`button`,{disabled:!U.value,onClick:i[10]||=e=>X({kind:`key`,key:`a`,modifiers:[T.value.backend===`local`||T.value.backend===`browser`?`super`:`ctrl`]})},`全选`,8,Ye),m(`button`,{disabled:!U.value,onClick:i[11]||=e=>X({kind:`key`,key:`c`,modifiers:[T.value.backend===`local`||T.value.backend===`browser`?`super`:`ctrl`]})},`复制`,8,Xe),m(`button`,{disabled:!U.value,onClick:i[12]||=e=>X({kind:`key`,key:`v`,modifiers:[T.value.backend===`local`||T.value.backend===`browser`?`super`:`ctrl`]})},`粘贴`,8,Ze)]),m(`label`,null,[i[17]||=oe(`输入到电脑`,-1),r(m(`textarea`,{"onUpdate:modelValue":i[13]||=e=>ut.value=e,rows:`2`,maxlength:`16000`,placeholder:`输入文字后点击发送`,disabled:!U.value},null,8,Qe),[[ie,ut.value]])]),m(`button`,{type:`button`,disabled:!U.value||!ut.value,onClick:i[14]||=e=>{X({kind:`text`,text:ut.value}),ut.value=``}},`输入文字`,8,$e)])):p(``,!0),m(`label`,null,[i[18]||=oe(`交还说明`,-1),r(m(`textarea`,{"onUpdate:modelValue":i[15]||=e=>I.value=e,rows:`2`,maxlength:`4000`,placeholder:`告诉机器人你完成了什么,以及接下来需要做什么`},null,512),[[ie,I.value]])]),m(`button`,{type:`button`,disabled:F.value||T.value.mode!==`human`,onClick:i[16]||=e=>K(Vt)},u(T.value.canResume?`交还机器人并继续`:S.value===`managed-browser`?`结束接管`:`结束控制`),9,et),S.value===`managed-browser`?(n(),c(`small`,tt,u(A.value?.supportsRetention===!0?`交还或收起只会释放操作权,页面会保留;长时间空闲后可能回收。`:A.value?.supportsRetention===!1?`此节点需更新后才能跨任务保留页面;任务结束后浏览器会关闭。`:`交还或收起会结束当前接管。`),1)):(n(),c(`small`,nt,`控制只属于当前页面。页面断开后控制权会到期,任务不会自行恢复。`))],64)):p(``,!0)])):p(``,!0),ht.value?(n(),c(`section`,{key:5,class:`browser-session-actions`,"aria-busy":ct.value},[m(`button`,{type:`button`,disabled:F.value,onClick:Ht},u(ct.value?`正在关闭浏览器…`:`关闭浏览器`),9,it),i[19]||=m(`small`,null,`结束当前浏览器会话并关闭标签页。`,-1)],8,rt)):p(``,!0)]),_:1},40,[`class`,`aria-label`]))],8,[`disabled`]))}}),[[`__scopeId`,`data-v-a344d14e`]]);export{ce as n,D as t};
|
|
2
|
+
//# sourceMappingURL=ComputerPanel-DP9Sge1E.js.map
|