feat(hub+web): include scratchlist in session export (#1235) (#1237)

Bump export schema to v2 with scratchlist text and attachment metadata
so operators keep notes when they export-then-delete. Markdown gets a
Scratchlist section; attachment bytes stay out of the JSON.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
HeavyGee
2026-07-30 23:21:08 +08:00
committed by GitHub
co-authored by Cursor
parent 99814e9668
commit a742fdf1a8
8 changed files with 174 additions and 18 deletions
+13 -3
View File
@@ -1,14 +1,24 @@
import { z } from 'zod'
import { DecryptedMessageSchema, SessionSchema } from './schemas'
import { DecryptedMessageSchema, ScratchlistEntrySchema, SessionSchema } from './schemas'
export const HAPI_SESSION_EXPORT_SCHEMA_VERSION = 1
/**
* Session export schema version.
*
* v1: session + messages only (#793 / #808)
* v2: adds scratchlist text + attachment metadata (#1235). Attachment
* bytes are intentionally omitted - metadata (id/filename/mime/size/path)
* is enough for cold archive; download URLs only work while the session
* still exists on the hub.
*/
export const HAPI_SESSION_EXPORT_SCHEMA_VERSION = 2
export const SESSION_EXPORT_MESSAGE_LIMIT = 20_000
export const HapiSessionExportSchema = z.object({
schemaVersion: z.literal(HAPI_SESSION_EXPORT_SCHEMA_VERSION),
exportedAt: z.number().int().nonnegative(),
session: SessionSchema,
messages: z.array(DecryptedMessageSchema)
messages: z.array(DecryptedMessageSchema),
scratchlist: z.array(ScratchlistEntrySchema)
})
export type HapiSessionExport = z.infer<typeof HapiSessionExportSchema>