Skip to content

MediaStore

Defined in: gadgets/media-store.ts:87

Session-scoped media storage with ID abstraction.

Each MediaStore instance manages media for a single agent session. Media files are stored in a temporary directory and referenced by short, unique IDs rather than file paths.

new MediaStore(sessionId?): MediaStore

Defined in: gadgets/media-store.ts:99

Create a new MediaStore.

string

Optional session ID for the output directory. If not provided, a random ID is generated.

MediaStore

get size(): number

Defined in: gadgets/media-store.ts:232

Get the count of stored media items.

number

cleanup(): Promise<void>

Defined in: gadgets/media-store.ts:256

Delete all stored files and clear memory. Removes the entire session directory.

Promise<void>


clear(): void

Defined in: gadgets/media-store.ts:247

Clear in-memory store without deleting files. Resets the counter but leaves files on disk.

void


get(id): StoredMedia | undefined

Defined in: gadgets/media-store.ts:200

Get stored media by ID.

string

The media ID (e.g., “media_a1b2c3”)

StoredMedia | undefined

The stored media or undefined if not found


getOutputDir(): string

Defined in: gadgets/media-store.ts:107

Get the output directory path.

string


getPath(id): string | undefined

Defined in: gadgets/media-store.ts:211

Get the actual file path for a media ID. Convenience method for gadgets that need the raw path.

string

The media ID

string | undefined

The file path or undefined if not found


has(id): boolean

Defined in: gadgets/media-store.ts:239

Check if a media ID exists.

string

boolean


list(kind?): StoredMedia[]

Defined in: gadgets/media-store.ts:221

List all stored media, optionally filtered by kind.

MediaKind

Optional media kind to filter by

StoredMedia[]

Array of stored media items


store(media, gadgetName): Promise<StoredMedia>

Defined in: gadgets/media-store.ts:157

Store media and return stored metadata with ID.

GadgetMediaOutput

The media output from a gadget

string

Name of the gadget that created this media

Promise<StoredMedia>

Stored media information including generated ID

Error if file write fails