Skip to main content
Glama
export.ts1.64 kB
/** * Session Export Module * * Handles exporting reasoning sessions to the filesystem as linked JSON structures. * Export location: ~/.thoughtbox/exports/ */ import * as fs from 'fs'; import * as path from 'path'; import * as os from 'os'; import type { SessionExport } from './types.js'; /** * Exports reasoning sessions to the filesystem */ export class SessionExporter { private defaultDir: string; constructor() { this.defaultDir = path.join(os.homedir(), '.thoughtbox', 'exports'); } /** * Ensure export directory exists */ async ensureExportDir(dir?: string): Promise<string> { const targetDir = dir || this.defaultDir; await fs.promises.mkdir(targetDir, { recursive: true }); return targetDir; } /** * Generate export filename with timestamp * Format: {sessionId}-{timestamp}.json */ generateFilename(sessionId: string): string { const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); return `${sessionId}-${timestamp}.json`; } /** * Export session data to filesystem * @returns The full path to the exported file */ async export( data: SessionExport, sessionId: string, destination?: string ): Promise<string> { const dir = await this.ensureExportDir(destination); const filename = this.generateFilename(sessionId); const filepath = path.join(dir, filename); await fs.promises.writeFile( filepath, JSON.stringify(data, null, 2), 'utf-8' ); return filepath; } /** * Get the default export directory path */ getDefaultDir(): string { return this.defaultDir; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/glassBead-tc/Thoughtbox'

If you have feedback or need assistance with the MCP directory API, please join our Discord server