diff --git a/packages/client/src/api/hermes/sessions.ts b/packages/client/src/api/hermes/sessions.ts index ffb27d1..95ef7ce 100644 --- a/packages/client/src/api/hermes/sessions.ts +++ b/packages/client/src/api/hermes/sessions.ts @@ -1,4 +1,4 @@ -import { request } from '../client' +import { request, getApiKey, getBaseUrlValue } from '../client' export interface SessionSummary { id: string @@ -147,6 +147,24 @@ export async function setSessionWorkspace(id: string, workspace: string | null): } } +export async function exportSession(id: string, mode: 'full' | 'compressed' = 'full', ext: 'json' | 'txt' = 'json'): Promise { + const baseUrl = getBaseUrlValue() + const token = getApiKey() + const url = `${baseUrl}/api/hermes/sessions/${id}/export?mode=${mode}&ext=${ext}&token=${encodeURIComponent(token)}` + const res = await fetch(url) + if (!res.ok) throw new Error('Export failed') + const blob = await res.blob() + const contentDisposition = res.headers.get('Content-Disposition') || '' + let filename = `session_${id}.${ext}` + const match = contentDisposition.match(/filename\*?=(?:UTF-8'')?([^;\n]+)/i) + if (match) filename = decodeURIComponent(match[1].replace(/"/g, '')) + const a = document.createElement('a') + a.href = URL.createObjectURL(blob) + a.download = filename + a.click() + URL.revokeObjectURL(a.href) +} + export interface UsageStatsResponse { total_input_tokens: number total_output_tokens: number diff --git a/packages/client/src/components/hermes/chat/ChatPanel.vue b/packages/client/src/components/hermes/chat/ChatPanel.vue index afd71f4..783c3ef 100644 --- a/packages/client/src/components/hermes/chat/ChatPanel.vue +++ b/packages/client/src/components/hermes/chat/ChatPanel.vue @@ -1,5 +1,5 @@