okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
0b3299a01
main
1import type { Session } from './types' ; 2 3export function sessionLog ( session :Session ) { 4return JSON . stringify ({ schema :'strata.session-log/1' , exportedAt :new Date (). toISOString (), session}, null , 2 ); 5} 6 7export function downloadSessionLog ( session :Session ) { 8const url = URL . createObjectURL ( new Blob ([ sessionLog ( session )], { type :'application/json' })); 9const link = document . createElement ( 'a' ); 10const name = session . title . replace ( / [^\p{L}\p{N}._-]+ / gu , '-' ). slice ( 0 , 80 ) || 'chat' ; 11link . href = url ; link . download = ` ${ name } -session-log.json` ; 12document . body . appendChild ( link ); link . click (); link . remove (); 13setTimeout (() => URL . revokeObjectURL ( url ), 1000 ); 14}