Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
feat(docs): load VikingBot from the shared embed widget (#3939)
t0saki88f338f78f98
diff --git a/docs/.vitepress/theme/VikingBotAssistant.vue b/docs/.vitepress/theme/VikingBotAssistant.vueindex 95cf71990..f33c5f996 100644--- a/docs/.vitepress/theme/VikingBotAssistant.vue+++ b/docs/.vitepress/theme/VikingBotAssistant.vue@@ -1,357 +1,140 @@<script setup lang="ts">-import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'-import { useData, withBase } from 'vitepress'-import { chatWithVikingBot, VikingBotApiError } from './vikingbot-api'-import { renderVikingBotMarkdown } from './vikingbot-markdown'--type ChatMessage = {- id: string- role: 'user' | 'assistant'- content: string+import { computed, ref } from 'vue'+import { useData } from 'vitepress'++type VikingBotWidgetLocale = 'en' | 'zh'++type VikingBotWidgetMountOptions = {+ site: string+ locale?: VikingBotWidgetLocale+ /**+ * 'none' keeps the widget from rendering its own floating launcher AND from+ * binding a click handler of its own — this component owns the trigger, so a+ * widget-side listener would toggle the panel a second time per click and+ * desync `aria-expanded`.+ */+ trigger?: 'none' | 'floating'+ open?: boolean+ onEvent?: (name: string, payload?: unknown) => void+}++type VikingBotWidgetApi = {+ mount: (options: VikingBotWidgetMountOptions) => void+ open: () => void+ toggle: () => void+}++declare global {+ interface Window {+ VikingBotWidget?: VikingBotWidgetApi+ }}+const WIDGET_URL =+ import.meta.env.VITE_VIKINGBOT_WIDGET_URL ||+ 'https://openviking.net/studio/embed-widget/vikingbot-widget.js'+const WIDGET_SITE = 'vikingbot'++let widgetScriptPromise: Promise<void> | null = null+let widgetMounted = false+const { lang } = useData()const isOpen = ref(false)-const input = ref('')-const loading = ref(false)-const messages = ref<ChatMessage[]>([])-const copiedMessageId = ref('')-const scrollArea = ref<HTMLElement>()-const inputArea = ref<HTMLTextAreaElement>()-const triggerArea = ref<HTMLButtonElement>()-const logoUrl = withBase('/ov-logo.png')-const panelWidth = ref(368)-const preferredPanelWidth = ref(368)-const panelMaxWidth = ref(640)-const isResizing = ref(false)-const PANEL_WIDTH_KEY = 'openviking-vikingbot-panel-width'-const MIN_PANEL_WIDTH = 320-const MAX_PANEL_WIDTH = 640-const MIN_COMPACT_DOC_WIDTH = 400-const MIN_FULL_DOC_WIDTH = 760-const RESIZE_STEP = 16+const isLoading = ref(false)+const hasError = ref(false)const isZh = computed(() => lang.value.startsWith('zh'))+const locale = computed<VikingBotWidgetLocale>(() => (isZh.value ? 'zh' : 'en'))const copy = computed(() => isZh.value ? {trigger: '问问 VikingBot',- title: 'VikingBot',- subtitle: 'OpenViking 文档助手',- welcome: '你好!我是 VikingBot。你可以问我 OpenViking 的使用方式、核心概念或 API 集成问题。',- placeholder: '输入你的问题…',- send: '发送',- copy: '复制',- copied: '已复制',- thinking: '正在查找答案…',- close: '关闭 VikingBot',- empty: '请输入问题',- tooLong: '问题不能超过 500 个字符',- timeout: '请求超时,请稍后重试。',- invalid: 'VikingBot 返回了无法识别的响应。',- failed: '暂时无法连接 VikingBot,请稍后重试。',- resize: '调整 VikingBot 面板宽度'+ failed: 'VikingBot 暂时无法加载,请稍后重试。'} : {trigger: 'Ask VikingBot',- title: 'VikingBot',- subtitle: 'OpenViking docs assistant',- welcome: 'Hi! I’m VikingBot. Ask me about OpenViking concepts, usage, or API integration.',- placeholder: 'Ask a question…',- send: 'Send',- copy: 'Copy',- copied: 'Copied',- thinking: 'Looking for an answer…',- close: 'Close VikingBot',- empty: 'Please enter a question',- tooLong: 'Questions cannot exceed 500 characters',- timeout: 'The request timed out. Please try again.',- invalid: 'VikingBot returned an invalid response.',- failed: 'VikingBot is unavailable right now. Please try again later.',- resize: 'Resize VikingBot panel'+ failed: 'VikingBot failed to load. Please try again later.'})-function openPanel() {- isOpen.value = true- nextTick(() => inputArea.value?.focus())-}--function closePanel() {- const shouldRestoreFocus = isOpen.value- isOpen.value = false- if (shouldRestoreFocus) nextTick(() => triggerArea.value?.focus())-}--function maxPanelWidthForViewport() {- if (window.innerWidth < 768) return MAX_PANEL_WIDTH- const reservedWidth = window.innerWidth < 1280 ? MIN_COMPACT_DOC_WIDTH : MIN_FULL_DOC_WIDTH- return Math.max(MIN_PANEL_WIDTH, Math.min(MAX_PANEL_WIDTH, window.innerWidth - reservedWidth))-}--function applyPanelWidth(width: number, remember = true) {- panelMaxWidth.value = maxPanelWidthForViewport()- panelWidth.value = Math.min(Math.max(width, MIN_PANEL_WIDTH), panelMaxWidth.value)- if (remember) preferredPanelWidth.value = panelWidth.value- document.documentElement.style.setProperty('--vikingbot-panel-width', `${panelWidth.value}px`)-}--function onResizeMove(event: PointerEvent) {- if (!isResizing.value) return- applyPanelWidth(window.innerWidth - event.clientX)-}--function stopResize() {- if (!isResizing.value) return- isResizing.value = false- document.documentElement.classList.remove('vikingbot-assistant-resizing')- window.removeEventListener('pointermove', onResizeMove)- window.removeEventListener('pointercancel', stopResize)- window.removeEventListener('blur', stopResize)- localStorage.setItem(PANEL_WIDTH_KEY, String(preferredPanelWidth.value))-}--function startResize(event: PointerEvent) {- if (window.innerWidth < 768) return- event.preventDefault()- isResizing.value = true- document.documentElement.classList.add('vikingbot-assistant-resizing')- window.addEventListener('pointermove', onResizeMove)- window.addEventListener('pointerup', stopResize, { once: true })- window.addEventListener('pointercancel', stopResize, { once: true })- window.addEventListener('blur', stopResize, { once: true })-}--function onResizeKeydown(event: KeyboardEvent) {- let nextWidth: number | undefined- if (event.key === 'ArrowLeft') nextWidth = panelWidth.value + RESIZE_STEP- if (event.key === 'ArrowRight') nextWidth = panelWidth.value - RESIZE_STEP- if (event.key === 'Home') nextWidth = MIN_PANEL_WIDTH- if (event.key === 'End') nextWidth = panelMaxWidth.value- if (nextWidth === undefined) return-- event.preventDefault()- applyPanelWidth(nextWidth)- localStorage.setItem(PANEL_WIDTH_KEY, String(preferredPanelWidth.value))-}--function onWindowResize() {- if (window.innerWidth >= 768) applyPanelWidth(preferredPanelWidth.value, false)-}--function errorMessage(error: unknown) {- if (!(error instanceof VikingBotApiError)) return copy.value.failed- if (error.code === 'empty_query') return copy.value.empty- if (error.code === 'query_too_long') return copy.value.tooLong- if (error.code === 'request_timeout') return copy.value.timeout- if (error.code === 'invalid_response') return copy.value.invalid- return copy.value.failed-}--async function copyAnswer(message: ChatMessage) {- try {- await navigator.clipboard.writeText(message.content)- } catch {- const textarea = document.createElement('textarea')- textarea.value = message.content- textarea.style.position = 'fixed'- textarea.style.opacity = '0'- document.body.appendChild(textarea)- textarea.select()- document.execCommand('copy')- textarea.remove()+function loadWidgetScript() {+ if (!widgetScriptPromise) {+ widgetScriptPromise = new Promise<void>((resolve, reject) => {+ const script = document.createElement('script')+ script.src = WIDGET_URL+ script.async = true+ script.dataset.vikingbotWidget = ''+ script.addEventListener('load', () => resolve(), { once: true })+ script.addEventListener(+ 'error',+ () => {+ script.remove()+ reject(new Error(`Failed to load the VikingBot widget from ${WIDGET_URL}`))+ },+ { once: true }+ )+ document.head.appendChild(script)+ })}- copiedMessageId.value = message.id- window.setTimeout(() => {- if (copiedMessageId.value === message.id) copiedMessageId.value = ''- }, 1600)+ return widgetScriptPromise.catch((error: unknown) => {+ // Let the next click retry a failed load instead of caching the rejection.+ widgetScriptPromise = null+ throw error+ })}-async function scrollToBottom() {- await nextTick()- scrollArea.value?.scrollTo({ top: scrollArea.value.scrollHeight, behavior: 'smooth' })+function onWidgetEvent(name: string) {+ if (name === 'open') isOpen.value = true+ if (name === 'close') isOpen.value = false}-async function sendMessage() {- if (loading.value) return- const query = input.value.trim()- if (!query) return+async function onTriggerClick() {+ if (isLoading.value) return- const userMessage: ChatMessage = {- id: `${Date.now()}-user`,- role: 'user',- content: query- }- messages.value.push(userMessage)- input.value = ''- loading.value = true- await scrollToBottom()+ hasError.value = false+ isLoading.value = truetry {- const result = await chatWithVikingBot(query)- messages.value.push({- id: `${Date.now()}-assistant`,- role: 'assistant',- content: result.text+ await loadWidgetScript()++ const widget = window.VikingBotWidget+ if (!widget) throw new Error('The VikingBot widget script did not register window.VikingBotWidget')++ if (widgetMounted) {+ // No local state update here: toggle() emits open/close synchronously and+ // onWidgetEvent is the single writer of isOpen. Flipping it here too+ // would invert aria-expanded on every click.+ widget.toggle()+ return+ }++ widget.mount({+ site: WIDGET_SITE,+ locale: locale.value,+ trigger: 'none',+ open: true,+ onEvent: onWidgetEvent})+ widgetMounted = true} catch (error) {- messages.value.push({- id: `${Date.now()}-error`,- role: 'assistant',- content: errorMessage(error)- })+ console.error(error)+ hasError.value = true} finally {- loading.value = false- await scrollToBottom()- inputArea.value?.focus()+ isLoading.value = false}}--function onInputKeydown(event: KeyboardEvent) {- if (event.key !== 'Enter' || event.shiftKey || event.isComposing) return- event.preventDefault()- void sendMessage()-}--function onEscape(event: KeyboardEvent) {- if (event.key !== 'Escape' || event.defaultPrevented || !isOpen.value) return- event.preventDefault()- closePanel()-}--watch(isOpen, (open) => {- document.documentElement.classList.toggle('vikingbot-assistant-open', open)-})--onMounted(() => {- const storedWidth = Number(localStorage.getItem(PANEL_WIDTH_KEY))- preferredPanelWidth.value = Number.isFinite(storedWidth) && storedWidth > 0 ? storedWidth : 368- applyPanelWidth(preferredPanelWidth.value, false)- window.addEventListener('keydown', onEscape)- window.addEventListener('resize', onWindowResize)-})--onBeforeUnmount(() => {- document.documentElement.classList.remove('vikingbot-assistant-open')- document.documentElement.classList.remove('vikingbot-assistant-resizing')- document.documentElement.style.removeProperty('--vikingbot-panel-width')- window.removeEventListener('keydown', onEscape)- window.removeEventListener('resize', onWindowResize)- window.removeEventListener('pointermove', onResizeMove)- window.removeEventListener('pointerup', stopResize)- window.removeEventListener('pointercancel', stopResize)- window.removeEventListener('blur', stopResize)-})</script><template>- <button- ref="triggerArea"- class="vikingbot-trigger"- type="button"- :aria-label="copy.trigger"- :aria-expanded="isOpen"- aria-controls="vikingbot-assistant-panel"- @click="isOpen ? closePanel() : openPanel()"- >- <span class="vikingbot-spark" aria-hidden="true">✦</span>- <span class="vikingbot-trigger-label">{{ copy.trigger }}</span>- </button>-- <Teleport to="body">- <Transition name="vikingbot-panel">- <aside- v-if="isOpen"- id="vikingbot-assistant-panel"- class="vikingbot-panel"- aria-label="VikingBot"- >- <div- class="vikingbot-resize-handle"- role="separator"- tabindex="0"- aria-orientation="vertical"- :aria-label="copy.resize"- :aria-valuemin="MIN_PANEL_WIDTH"- :aria-valuemax="panelMaxWidth"- :aria-valuenow="panelWidth"- @keydown="onResizeKeydown"- @pointerdown="startResize"- />- <header class="vikingbot-panel-header">- <div class="vikingbot-identity">- <span class="vikingbot-avatar" aria-hidden="true">- <img :src="logoUrl" alt="" />- </span>- <span>- <strong>{{ copy.title }}</strong>- <small>{{ copy.subtitle }}</small>- </span>- </div>- <button class="vikingbot-close" type="button" :aria-label="copy.close" @click="closePanel">- <span aria-hidden="true">×</span>- </button>- </header>-- <div ref="scrollArea" class="vikingbot-messages" aria-live="polite">- <div class="vikingbot-message is-assistant">- <span class="vikingbot-message-mark" aria-hidden="true">- <img :src="logoUrl" alt="" />- </span>- <div class="vikingbot-markdown" v-html="renderVikingBotMarkdown(copy.welcome)" />- </div>- <div- v-for="message in messages"- :key="message.id"- class="vikingbot-message"- :class="`is-${message.role}`"- >- <span v-if="message.role === 'assistant'" class="vikingbot-message-mark" aria-hidden="true">- <img :src="logoUrl" alt="" />- </span>- <p v-if="message.role === 'user'">{{ message.content }}</p>- <div v-else class="vikingbot-answer">- <div- class="vikingbot-markdown"- v-html="renderVikingBotMarkdown(message.content)"- />- <button- class="vikingbot-copy-answer"- type="button"- @click="copyAnswer(message)"- >- <svg viewBox="0 0 24 24" aria-hidden="true">- <path d="M8 8h10v11H8z" />- <path d="M6 16H4V5h10v2" />- </svg>- {{ copiedMessageId === message.id ? copy.copied : copy.copy }}- </button>- </div>- </div>- <div- v-if="loading"- class="vikingbot-message is-loading"- role="status"- :aria-label="copy.thinking"- >- <span class="vikingbot-dots" aria-hidden="true"><i /><i /><i /></span>- </div>- </div>-- <form class="vikingbot-composer" @submit.prevent="sendMessage">- <div class="vikingbot-input-shell">- <textarea- ref="inputArea"- v-model="input"- :placeholder="copy.placeholder"- :disabled="loading"- maxlength="500"- rows="3"- @keydown="onInputKeydown"- />- <button type="submit" :disabled="loading || !input.trim()" :aria-label="copy.send">- <svg viewBox="0 0 24 24" aria-hidden="true"><path d="m5 12 14-7-4.7 14-2.8-5.5L5 12Zm6.5 1.5 3-3" /></svg>- </button>- </div>- </form>- </aside>- </Transition>- </Teleport>+ <span class="vikingbot-launcher">+ <button+ class="vikingbot-trigger"+ type="button"+ :aria-label="copy.trigger"+ :aria-expanded="isOpen"+ :aria-busy="isLoading"+ @click="onTriggerClick"+ >+ <span class="vikingbot-spark" aria-hidden="true">✦</span>+ <span class="vikingbot-trigger-label">{{ copy.trigger }}</span>+ </button>+ <span v-if="hasError" class="vikingbot-trigger-error" role="alert">{{ copy.failed }}</span>+ </span></template>diff --git a/docs/.vitepress/theme/custom.css b/docs/.vitepress/theme/custom.cssindex 3914e693e..7fe41961c 100644--- a/docs/.vitepress/theme/custom.css+++ b/docs/.vitepress/theme/custom.css@@ -1,5 +1,4 @@:root {- --vikingbot-panel-width: 368px;--vp-layout-max-width: 100vw;--vp-c-brand-1: #0f766e;--vp-c-brand-2: #115e59;@@ -121,7 +120,13 @@margin-right: 12px;}-/* VikingBot docs assistant */+/* VikingBot docs assistant (shared embed widget launcher) */+.vikingbot-launcher {+ position: relative;+ display: inline-flex;+ align-items: center;+}+.vikingbot-trigger {display: inline-flex;height: 40px;@@ -152,518 +157,20 @@line-height: 1;}-.vikingbot-panel {- position: fixed;- z-index: 90;- top: 0;- right: 0;- bottom: 0;- display: flex;- width: min(var(--vikingbot-panel-width), 100vw);- flex-direction: column;- border-left: 1px solid var(--vp-c-divider);- background:- radial-gradient(circle at 90% 0, color-mix(in srgb, var(--vp-c-brand-soft) 55%, transparent), transparent 230px),- var(--vp-c-bg);-}--.vikingbot-resize-handle {+.vikingbot-trigger-error {position: absolute;- z-index: 2;- top: 0;- bottom: 0;- left: -6px;- width: 12px;- padding: 0;- border: 0;- background: transparent;- cursor: col-resize;- touch-action: none;-}--.vikingbot-resize-handle::before {- position: absolute;- top: 0;- bottom: 0;- left: 5px;- width: 1px;- background: var(--vp-c-divider);- content: '';- transition: width 0.15s, background-color 0.15s;-}--.vikingbot-resize-handle:hover::before,-.vikingbot-resize-handle:focus-visible::before,-.vikingbot-assistant-resizing .vikingbot-resize-handle::before {- width: 2px;- background: color-mix(in srgb, var(--vp-c-brand-1) 72%, var(--vp-c-divider));-}--.vikingbot-resize-handle:focus-visible {- outline: 0;-}--html.vikingbot-assistant-resizing,-html.vikingbot-assistant-resizing * {- cursor: col-resize !important;- user-select: none !important;-}--.vikingbot-panel-header {- display: flex;- height: calc(var(--vp-nav-height) + 1px);- min-height: calc(var(--vp-nav-height) + 1px);- align-items: center;- justify-content: space-between;- padding: 7px 16px;- border-bottom: 1px solid var(--vp-c-divider);-}--.vikingbot-identity {- display: flex;- align-items: center;- gap: 11px;-}--.vikingbot-identity > span:last-child {- display: flex;- flex-direction: column;-}--.vikingbot-identity strong {- color: var(--vp-c-text-1);- font-size: 15px;- line-height: 20px;-}--.vikingbot-identity small {- color: var(--vp-c-text-3);- font-size: 11px;- line-height: 16px;-}--.vikingbot-avatar,-.vikingbot-message-mark {- display: block;- flex: 0 0 auto;- overflow: hidden;- border-radius: 8px;- background: var(--vp-c-bg-soft);-}--.vikingbot-avatar img,-.vikingbot-message-mark img {- display: block;- width: 100%;- height: 100%;- object-fit: cover;-}--.vikingbot-avatar {- width: 36px;- height: 36px;-}--.vikingbot-close {- display: grid;- width: 34px;- height: 34px;- place-items: center;- border: 0;- border-radius: 8px;- background: transparent;- color: var(--vp-c-text-2);- font-size: 24px;- cursor: pointer;-}--.vikingbot-close:hover {- background: var(--vp-c-bg-soft);- color: var(--vp-c-text-1);-}--.vikingbot-messages {- flex: 1 1 auto;- overflow-y: auto;- padding: 22px 16px;- overscroll-behavior: contain;-}--.vikingbot-message {- display: flex;- align-items: flex-start;- gap: 9px;- margin-bottom: 18px;-}--.vikingbot-message.is-user {- justify-content: flex-end;-}--.vikingbot-message-mark {- width: 25px;- height: 25px;- margin-top: 2px;- border-radius: 7px;- font-size: 11px;-}--.vikingbot-message > p,-.vikingbot-markdown {- max-width: calc(100% - 36px);- margin: 0;- padding: 10px 12px;+ z-index: 90;+ top: calc(100% + 6px);+ right: 12px;+ max-width: 260px;+ padding: 6px 10px;border: 1px solid var(--vp-c-divider);- border-radius: 4px 14px 14px 14px;- background: var(--vp-c-bg-elv);- color: var(--vp-c-text-1);- font-size: 13px;- line-height: 1.65;- overflow-wrap: anywhere;-}--.vikingbot-answer {- display: flex;- width: calc(100% - 36px);- max-width: calc(100% - 36px);- flex-direction: column;- align-items: flex-end;-}--.vikingbot-answer .vikingbot-markdown {- width: 100%;- max-width: none;-}--.vikingbot-copy-answer {- display: inline-flex;- height: 28px;- align-items: center;- gap: 5px;- margin-top: 7px;- padding: 0 8px;- border: 0;border-radius: 6px;- background: transparent;- color: var(--vp-c-text-3);- font: inherit;- font-size: 11px;- cursor: pointer;-}--.vikingbot-copy-answer:hover {- background: var(--vp-c-bg-soft);- color: var(--vp-c-text-1);-}--.vikingbot-copy-answer svg {- width: 14px;- height: 14px;- fill: none;- stroke: currentColor;- stroke-linecap: round;- stroke-linejoin: round;- stroke-width: 1.7;-}--.vikingbot-message > p { white-space: pre-wrap; }-.vikingbot-markdown { white-space: normal; }--.vikingbot-message.is-user > p {- border-color: transparent;- border-radius: 14px 4px 14px 14px;- background: var(--vp-c-brand-soft);-}--.vikingbot-message.is-loading {- align-items: center;- min-height: 24px;- margin: 2px 0 18px 3px;-}--.vikingbot-markdown > :first-child { margin-top: 0; }-.vikingbot-markdown > :last-child { margin-bottom: 0; }--.vikingbot-markdown p,-.vikingbot-markdown ul,-.vikingbot-markdown ol,-.vikingbot-markdown pre,-.vikingbot-markdown blockquote,-.vikingbot-markdown table {- margin: 0 0 10px;-}--.vikingbot-markdown ul,-.vikingbot-markdown ol {- padding-left: 18px;-}--.vikingbot-markdown li + li { margin-top: 4px; }--.vikingbot-markdown h1,-.vikingbot-markdown h2,-.vikingbot-markdown h3,-.vikingbot-markdown h4 {- margin: 14px 0 7px;- color: var(--vp-c-text-1);- font-weight: 750;- line-height: 1.35;-}--.vikingbot-markdown h1 { font-size: 17px; }-.vikingbot-markdown h2 { font-size: 15px; }-.vikingbot-markdown h3,-.vikingbot-markdown h4 { font-size: 14px; }--.vikingbot-markdown a {- color: var(--vp-c-brand-1);- font-weight: 600;- text-decoration: underline;- text-underline-offset: 2px;-}--.vikingbot-markdown code {- padding: 2px 4px;- border-radius: 4px;- background: var(--vp-c-bg-soft);- color: var(--vp-c-brand-1);- font-family: var(--vp-font-family-mono);- font-size: 0.9em;-}--.vikingbot-markdown pre {- overflow-x: auto;- padding: 10px;- border-radius: 8px;- background: var(--vp-code-block-bg);-}--.vikingbot-markdown pre code {- padding: 0;- background: transparent;- color: var(--vp-code-block-color);- white-space: pre;-}--.vikingbot-markdown blockquote {- padding-left: 10px;- border-left: 3px solid var(--vp-c-brand-1);+ background: var(--vp-c-bg-elv);color: var(--vp-c-text-2);-}--.vikingbot-markdown table {- display: block;- width: 100%;- overflow-x: auto;- border-collapse: collapse;font-size: 12px;-}--.vikingbot-markdown th,-.vikingbot-markdown td {- padding: 6px 8px;- border: 1px solid var(--vp-c-divider);- text-align: left;-}--.vikingbot-markdown th { background: var(--vp-c-bg-soft); }--.vikingbot-composer {- flex: 0 0 auto;- padding: 12px 14px 14px;- border-top: 1px solid var(--vp-c-divider);- background: color-mix(in srgb, var(--vp-c-bg) 94%, transparent);-}--.vikingbot-input-shell {- position: relative;- border: 1px solid var(--vp-c-divider);- border-radius: 12px;- background: var(--vp-c-bg-elv);- transition: border-color 0.2s, box-shadow 0.2s;-}--.vikingbot-input-shell:focus-within {- border-color: var(--vp-c-brand-1);- box-shadow: 0 0 0 3px var(--vp-c-brand-soft);-}--.vikingbot-input-shell textarea {- display: block;- width: 100%;- min-height: 86px;- resize: none;- border: 0;- outline: 0;- padding: 12px 48px 12px 12px;- background: transparent;- color: var(--vp-c-text-1);- font: inherit;- font-size: 13px;- line-height: 1.5;-}--.vikingbot-input-shell button {- position: absolute;- right: 9px;- bottom: 9px;- display: grid;- width: 32px;- height: 32px;- place-items: center;- border: 0;- border-radius: 8px;- background: var(--vp-c-brand-1);- color: var(--vp-c-bg);- cursor: pointer;-}--.vikingbot-input-shell button:disabled {- opacity: 0.35;- cursor: not-allowed;-}--.vikingbot-input-shell svg {- width: 17px;- fill: none;- stroke: currentColor;- stroke-linecap: round;- stroke-linejoin: round;- stroke-width: 1.8;-}--.vikingbot-dots {- display: inline-flex;- gap: 3px;-}--.vikingbot-dots i {- width: 4px;- height: 4px;- border-radius: 50%;- background: var(--vp-c-brand-1);- animation: vikingbot-pulse 1.1s infinite ease-in-out;-}--.vikingbot-dots i:nth-child(2) { animation-delay: 0.15s; }-.vikingbot-dots i:nth-child(3) { animation-delay: 0.3s; }--.vikingbot-panel-enter-active,-.vikingbot-panel-leave-active { transition: transform 0.24s ease, opacity 0.2s ease; }-.vikingbot-panel-enter-from,-.vikingbot-panel-leave-to { opacity: 0; transform: translateX(24px); }--@keyframes vikingbot-pulse {- 0%, 60%, 100% { opacity: 0.28; transform: translateY(0); }- 30% { opacity: 1; transform: translateY(-2px); }-}--@media (min-width: 768px) {- html.vikingbot-assistant-open {- --vp-layout-max-width: 100vw;- }-- html.vikingbot-assistant-open .Layout,- html.vikingbot-assistant-open .VPNav {- padding-right: var(--vikingbot-panel-width);- }-- html.vikingbot-assistant-open .VPNavBar.has-sidebar .wrapper {- padding-right: 16px;- padding-left: 16px;- }-- html.vikingbot-assistant-open .VPNavBar.has-sidebar .container > .title {- position: relative;- top: auto;- left: auto;- width: auto;- flex: 0 0 auto;- padding: 0;- }-- html.vikingbot-assistant-open .VPNavBar.has-sidebar .container > .content {- padding-right: 0;- padding-left: 24px;- }-- html.vikingbot-assistant-open .VPNavBarTitle .logo {- display: block;- width: 28px;- height: 28px;- flex: 0 0 28px;- object-fit: cover;- }-- html.vikingbot-assistant-open .VPContent .VPDoc {- padding-right: 60px;- padding-left: 60px;- }-- html.vikingbot-assistant-open .VPContent .VPDoc.has-aside > .container > .content {- padding-right: 0;- padding-left: 0;- }-- html.vikingbot-assistant-open .Layout,- html.vikingbot-assistant-open .VPNav,- html.vikingbot-assistant-open .VPSidebar {- transition: padding-right 0.24s ease, right 0.24s ease;- }-}--@media (min-width: 768px) and (max-width: 1279px) {- html.vikingbot-assistant-open .VPSidebar {- display: none;- }-- html.vikingbot-assistant-open .VPContent.has-sidebar {- padding-left: 0;- }-- html.vikingbot-assistant-open .VPContent .VPDoc > .container > .aside,- html.vikingbot-assistant-open .VPNavBar .menu,- html.vikingbot-assistant-open .VPNavBar .translations,- html.vikingbot-assistant-open .VPNavBar .appearance,- html.vikingbot-assistant-open .VPNavBar .social-links,- html.vikingbot-assistant-open .VPNavBar .extra {- display: none !important;- }-- html.vikingbot-assistant-open .ov-docs-search-trigger {- width: 40px;- min-width: 40px;- justify-content: center;- padding: 0;- }-- html.vikingbot-assistant-open .ov-docs-search-trigger-label,- html.vikingbot-assistant-open .ov-docs-search-trigger kbd {- display: none;- }-- html.vikingbot-assistant-open .ov-docs-search-trigger-compact {- display: block;- }-}--@media (min-width: 768px) and (max-width: 1599px) {- html.vikingbot-assistant-open .VPContent .VPDoc {- padding-right: 32px;- padding-left: 32px;- }-}--@media (min-width: 1280px) {- html.vikingbot-assistant-open .VPSidebar {- width: var(--vp-sidebar-width);- padding-left: 60px;- }-- html.vikingbot-assistant-open .VPContent .VPDoc > .container > .aside {- max-width: 240px;- padding-left: 16px;- }+ line-height: 1.4;+ box-shadow: var(--vp-shadow-2);}@media (max-width: 1279px) {@@ -673,15 +180,11 @@ html.vikingbot-assistant-resizing * {@media (max-width: 767px) {.vikingbot-trigger { margin-right: 8px; }- .vikingbot-panel { z-index: 200; width: 100vw; }- .vikingbot-resize-handle { display: none; }+ .vikingbot-trigger-error { max-width: 200px; }}@media (prefers-reduced-motion: reduce) {- .vikingbot-trigger,- .vikingbot-panel-enter-active,- .vikingbot-panel-leave-active { transition: none; }- .vikingbot-dots i { animation: none; }+ .vikingbot-trigger { transition: none; }}.ov-docs-search-trigger {diff --git a/docs/.vitepress/theme/vikingbot-api.test.ts b/docs/.vitepress/theme/vikingbot-api.test.tsdeleted file mode 100644index b80498fc4..000000000--- a/docs/.vitepress/theme/vikingbot-api.test.ts+++ /dev/null@@ -1,31 +0,0 @@-import assert from 'node:assert/strict'-import test from 'node:test'-import { getVikingBotUserId, normalizeVikingBotQuery, VikingBotApiError } from './vikingbot-api.ts'--test('normalizes VikingBot queries and enforces the UI limit', () => {- assert.equal(normalizeVikingBotQuery(' How does memory work? '), 'How does memory work?')-- assert.throws(- () => normalizeVikingBotQuery(' '),- (error) => error instanceof VikingBotApiError && error.code === 'empty_query'- )- assert.throws(- () => normalizeVikingBotQuery('x'.repeat(501)),- (error) => error instanceof VikingBotApiError && error.code === 'query_too_long'- )-})--test('reuses the stable VikingBot user id from storage', () => {- const values = new Map<string, string>([['client_id', 'existing-user']])- const storage = {- getItem(key: string) {- return values.get(key) ?? null- },- setItem(key: string, value: string) {- values.set(key, value)- }- }-- assert.equal(getVikingBotUserId(storage), 'existing-user')- assert.equal(values.size, 1)-})diff --git a/docs/.vitepress/theme/vikingbot-api.ts b/docs/.vitepress/theme/vikingbot-api.tsdeleted file mode 100644index 9c94f9792..000000000--- a/docs/.vitepress/theme/vikingbot-api.ts+++ /dev/null@@ -1,122 +0,0 @@-const DEFAULT_API_BASE_URL =- 'https://sd7aepg2caqr3a7a3g870.apigateway-cn-shanghai.volceapi.com/api/v1'-const VIKINGBOT_API_KEY = 'kjWSxIHxa0hRk9C/0gSFvA=='-const REQUEST_TIMEOUT_MS = 60_000-const CLIENT_ID_KEY = 'client_id'--type ApiResponse<T> = {- status: string- err_code: string- err_msg: string- result: T-}--export type VikingBotApiErrorCode =- | 'api_error'- | 'empty_query'- | 'http_error'- | 'invalid_response'- | 'network_error'- | 'query_too_long'- | 'request_timeout'--export type VikingBotChatResult = {- text: string-}--export class VikingBotApiError extends Error {- readonly code: VikingBotApiErrorCode- readonly apiCode: string- readonly httpStatus?: number-- constructor(- code: VikingBotApiErrorCode,- apiCode = '',- httpStatus?: number- ) {- super(code)- this.name = 'VikingBotApiError'- this.code = code- this.apiCode = apiCode- this.httpStatus = httpStatus- }-}--export function getVikingBotUserId(storage: Pick<Storage, 'getItem' | 'setItem'> = localStorage) {- let id = storage.getItem(CLIENT_ID_KEY)- if (!id) {- id = crypto.randomUUID()- storage.setItem(CLIENT_ID_KEY, id)- }- return id-}--export function normalizeVikingBotQuery(query: string) {- const normalized = query.trim()- if (!normalized) throw new VikingBotApiError('empty_query')- if (normalized.length > 500) throw new VikingBotApiError('query_too_long')- return normalized-}--export async function chatWithVikingBot(query: string): Promise<VikingBotChatResult> {- const normalizedQuery = normalizeVikingBotQuery(query)-- const controller = new AbortController()- const timeout = window.setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS)-- try {- const response = await fetch(`${DEFAULT_API_BASE_URL}/bot/chat`, {- method: 'POST',- headers: {- 'Content-Type': 'application/json',- 'X-OpenViking-Bot-Key': VIKINGBOT_API_KEY- },- body: JSON.stringify({- user_id: getVikingBotUserId(),- query: normalizedQuery- }),- signal: controller.signal- })-- let data: ApiResponse<VikingBotChatResult>- try {- data = (await response.json()) as ApiResponse<VikingBotChatResult>- } catch {- throw new VikingBotApiError(- response.ok ? 'invalid_response' : 'http_error',- '',- response.status- )- }-- if (!response.ok) {- throw new VikingBotApiError(- 'http_error',- data.err_code,- response.status- )- }-- if (data.status !== 'ok') {- throw new VikingBotApiError(- 'api_error',- data.err_code,- response.status- )- }-- if (!data.result || typeof data.result.text !== 'string') {- throw new VikingBotApiError('invalid_response', '', response.status)- }-- return data.result- } catch (error) {- if (error instanceof DOMException && error.name === 'AbortError') {- throw new VikingBotApiError('request_timeout')- }- if (error instanceof VikingBotApiError) throw error- throw new VikingBotApiError('network_error')- } finally {- window.clearTimeout(timeout)- }-}diff --git a/docs/.vitepress/theme/vikingbot-markdown.test.ts b/docs/.vitepress/theme/vikingbot-markdown.test.tsdeleted file mode 100644index 86e4e0235..000000000--- a/docs/.vitepress/theme/vikingbot-markdown.test.ts+++ /dev/null@@ -1,24 +0,0 @@-import assert from 'node:assert/strict'-import test from 'node:test'-import { renderVikingBotMarkdown } from './vikingbot-markdown.ts'--test('renders supported VikingBot Markdown', () => {- const result = renderVikingBotMarkdown('## Install\n\n```bash\nnpm install openviking\n```')-- assert.match(result, /<h2>Install<\/h2>/)- assert.match(result, /<code class="language-bash">/)-})--test('sanitizes VikingBot Markdown output', () => {- const result = renderVikingBotMarkdown([- '<img src=x onerror=alert(1)>',- '[unsafe](javascript:alert(1))',- '[safe](https://openviking.ai)'- ].join('\n\n'))-- assert.doesNotMatch(result, /<img/i)- assert.doesNotMatch(result, /href="javascript:/i)- assert.match(result, /href="https:\/\/openviking\.ai"/)- assert.match(result, /target="_blank"/)- assert.match(result, /rel="noopener noreferrer"/)-})diff --git a/docs/.vitepress/theme/vikingbot-markdown.ts b/docs/.vitepress/theme/vikingbot-markdown.tsdeleted file mode 100644index 9b275d500..000000000--- a/docs/.vitepress/theme/vikingbot-markdown.ts+++ /dev/null@@ -1,50 +0,0 @@-import MarkdownIt from 'markdown-it'-import { FilterXSS } from 'xss'--const markdown = new MarkdownIt({- html: false,- breaks: true,- linkify: true,- typographer: true-})--const defaultLinkOpen = markdown.renderer.rules.link_open-markdown.renderer.rules.link_open = (tokens, index, options, env, self) => {- tokens[index].attrSet('target', '_blank')- tokens[index].attrSet('rel', 'noopener noreferrer')- return defaultLinkOpen- ? defaultLinkOpen(tokens, index, options, env, self)- : self.renderToken(tokens, index, options)-}--const sanitizer = new FilterXSS({- whiteList: {- a: ['href', 'title', 'target', 'rel'],- blockquote: [],- br: [],- code: ['class'],- em: [],- h1: [],- h2: [],- h3: [],- h4: [],- li: [],- ol: [],- p: [],- pre: [],- strong: [],- table: [],- tbody: [],- td: [],- th: [],- thead: [],- tr: [],- ul: []- },- stripIgnoreTag: true,- stripIgnoreTagBody: ['script', 'style']-})--export function renderVikingBotMarkdown(content: string) {- return sanitizer.process(markdown.render(content))-}diff --git a/docs/package-lock.json b/docs/package-lock.jsonindex 1ec087404..baae2367e 100644--- a/docs/package-lock.json+++ b/docs/package-lock.json@@ -8,9 +8,7 @@"name": "openviking-docs","version": "0.0.0","devDependencies": {- "markdown-it": "^14.3.0",- "vitepress": "1.6.4",- "xss": "^1.0.15"+ "vitepress": "1.6.4"}},"node_modules/@algolia/abtesting": {@@ -1588,13 +1586,6 @@"node": ">= 14.0.0"}},- "node_modules/argparse": {- "version": "2.0.1",- "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",- "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",- "dev": true,- "license": "Python-2.0"- },"node_modules/birpc": {"version": "2.9.0","resolved": "https://registry.npmjs.org/birpc/-/birpc-2.9.0.tgz",@@ -1649,13 +1640,6 @@"url": "https://github.com/sponsors/wooorm"}},- "node_modules/commander": {- "version": "2.20.3",- "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",- "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",- "dev": true,- "license": "MIT"- },"node_modules/copy-anything": {"version": "4.0.5","resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-4.0.5.tgz",@@ -1672,13 +1656,6 @@"url": "https://github.com/sponsors/mesqueeb"}},- "node_modules/cssfilter": {- "version": "0.0.10",- "resolved": "https://registry.npmjs.org/cssfilter/-/cssfilter-0.0.10.tgz",- "integrity": "sha512-FAaLDaplstoRsDR8XGYH51znUN0UY7nMc6Z9/fvE8EXGwvJE9hu7W2vHwx1+bd6gCYnln9nLbzxFTrcO9YQDZw==",- "dev": true,- "license": "MIT"- },"node_modules/csstype": {"version": "3.2.3","resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",@@ -1870,26 +1847,6 @@"url": "https://github.com/sponsors/mesqueeb"}},- "node_modules/linkify-it": {- "version": "5.0.2",- "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.2.tgz",- "integrity": "sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==",- "dev": true,- "funding": [- {- "type": "github",- "url": "https://github.com/sponsors/puzrin"- },- {- "type": "github",- "url": "https://github.com/sponsors/markdown-it"- }- ],- "license": "MIT",- "dependencies": {- "uc.micro": "^2.0.0"- }- },"node_modules/magic-string": {"version": "0.30.21","resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",@@ -1907,47 +1864,6 @@"dev": true,"license": "MIT"},- "node_modules/markdown-it": {- "version": "14.3.0",- "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.3.0.tgz",- "integrity": "sha512-RCEsPjR+sr0x+AuYp601tKTkgFG4YEPLCzHST3cQ/fhlJkqAkz1L2/Qbp1j9qw5SBwQHFBoW8+hoN5xssOF0Tw==",- "dev": true,- "funding": [- {- "type": "github",- "url": "https://github.com/sponsors/puzrin"- },- {- "type": "github",- "url": "https://github.com/sponsors/markdown-it"- }- ],- "license": "MIT",- "dependencies": {- "argparse": "^2.0.1",- "entities": "^4.5.0",- "linkify-it": "^5.0.2",- "mdurl": "^2.0.0",- "punycode.js": "^2.3.1",- "uc.micro": "^2.1.0"- },- "bin": {- "markdown-it": "bin/markdown-it.mjs"- }- },- "node_modules/markdown-it/node_modules/entities": {- "version": "4.5.0",- "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",- "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",- "dev": true,- "license": "BSD-2-Clause",- "engines": {- "node": ">=0.12"- },- "funding": {- "url": "https://github.com/fb55/entities?sponsor=1"- }- },"node_modules/mdast-util-to-hast": {"version": "13.2.1","resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.1.tgz",@@ -1970,13 +1886,6 @@"url": "https://opencollective.com/unified"}},- "node_modules/mdurl": {- "version": "2.0.0",- "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz",- "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==",- "dev": true,- "license": "MIT"- },"node_modules/micromark-util-character": {"version": "2.1.1","resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz",@@ -2181,16 +2090,6 @@"url": "https://github.com/sponsors/wooorm"}},- "node_modules/punycode.js": {- "version": "2.3.1",- "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz",- "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==",- "dev": true,- "license": "MIT",- "engines": {- "node": ">=6"- }- },"node_modules/regex": {"version": "6.1.0","resolved": "https://registry.npmjs.org/regex/-/regex-6.1.0.tgz",@@ -2372,13 +2271,6 @@"url": "https://github.com/sponsors/wooorm"}},- "node_modules/uc.micro": {- "version": "2.1.0",- "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz",- "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==",- "dev": true,- "license": "MIT"- },"node_modules/unist-util-is": {"version": "6.0.1","resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.1.tgz",@@ -2606,23 +2498,6 @@}}},- "node_modules/xss": {- "version": "1.0.15",- "resolved": "https://registry.npmjs.org/xss/-/xss-1.0.15.tgz",- "integrity": "sha512-FVdlVVC67WOIPvfOwhoMETV72f6GbW7aOabBC3WxN/oUdoEMDyLz4OgRv5/gck2ZeNqEQu+Tb0kloovXOfpYVg==",- "dev": true,- "license": "MIT",- "dependencies": {- "commander": "^2.20.3",- "cssfilter": "0.0.10"- },- "bin": {- "xss": "bin/xss"- },- "engines": {- "node": ">= 0.10.0"- }- },"node_modules/zwitch": {"version": "2.0.4","resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",diff --git a/docs/package.json b/docs/package.jsonindex bb0d78671..3ca1b3e32 100644--- a/docs/package.json+++ b/docs/package.json@@ -12,8 +12,6 @@"test:search": "node --experimental-strip-types --test .vitepress/theme/openviking-search-*.test.ts"},"devDependencies": {- "markdown-it": "^14.3.0",- "vitepress": "1.6.4",- "xss": "^1.0.15"+ "vitepress": "1.6.4"}}