import { BinaryData } from '@character-foundry/core'; import { CCv3Data, CCv3CharacterBook, NormalizedCard } from '@character-foundry/schemas'; /** * Voxta Types * * Type definitions for Voxta package format. */ /** * Valid compression levels */ type CompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; /** * Voxta resource kind enumeration * Used in EntryResource, ThumbnailResource, and Collection references */ declare enum VoxtaResourceKind { Character = 1, Book = 2, Scenario = 3 } /** * Voxta resource reference */ interface VoxtaResourceRef { Kind: VoxtaResourceKind | number; Id: string; } /** * Voxta package metadata */ interface VoxtaPackage { $type: 'package'; Id: string; Name: string; Version: string; Description?: string; Creator?: string; ExplicitContent?: boolean; EntryResource?: VoxtaResourceRef; ThumbnailResource?: VoxtaResourceRef; DateCreated?: string; DateModified?: string; } /** * Voxta TTS configuration */ interface VoxtaTtsConfig { Voice: { parameters: { VoiceBackend?: string; VoiceId?: string; Gender?: string; Filename?: string; FinetuneVoice?: string; [key: string]: unknown; }; label: string; }; Service: { ServiceName: string; ServiceId: string; }; } /** * Voxta script */ interface VoxtaScript { Name: string; Content: string; } /** * Voxta character */ interface VoxtaCharacter { $type: 'character'; Id: string; Name: string; Label?: string; Version?: string; PackageId?: string; Description?: string; Personality?: string; Profile?: string; Scenario?: string; FirstMessage?: string; AlternativeFirstMessages?: string[]; MessageExamples?: string; SystemPrompt?: string; PostHistoryInstructions?: string; Context?: string; Instructions?: string; UserNameOverride?: string; UserDescriptionOverride?: string; Creator?: string; CreatorNotes?: string; Tags?: string[]; ExplicitContent?: boolean; Culture?: string; ImportedFrom?: string; MemoryBooks?: string[]; DefaultScenarios?: string[]; TextToSpeech?: VoxtaTtsConfig[]; ChatStyle?: number; EnableThinkingSpeech?: boolean; NotifyUserAwayReturn?: boolean; TimeAware?: boolean; UseMemory?: boolean; MaxTokens?: number; MaxSentences?: number; SystemPromptOverrideType?: number; ClimaxSensitivity?: number; PleasureDecay?: number; Scripts?: VoxtaScript[]; Augmentations?: unknown[]; Thumbnail?: { RandomizedETag?: string; ContentType?: string; }; DateCreated?: string; DateModified?: string; } /** * Voxta book item */ interface VoxtaBookItem { Id: string; Keywords: string[]; Text: string; Weight?: number; Deleted?: boolean; CreatedAt?: string; LastUpdated?: string; DeletedAt?: string; } /** * Voxta book (lorebook) */ interface VoxtaBook { $type: 'book'; Id: string; Name: string; Version?: string; PackageId?: string; Description?: string; ExplicitContent?: boolean; Creator?: string; Items: VoxtaBookItem[]; DateCreated?: string; DateModified?: string; } /** * Voxta collection item (reference to a resource) */ interface VoxtaCollectionItem { Resource: VoxtaResourceRef; } /** * Voxta collection folder (organizational grouping) */ interface VoxtaCollectionFolder { Name: string; Description?: string; /** Kind of resources in this folder (1=Character, 2=Book, 3=Scenario) */ Kind: VoxtaResourceKind | number; Items: VoxtaCollectionItem[]; /** Nested folders (if any) */ Folders?: VoxtaCollectionFolder[]; } /** * Voxta collection root structure */ interface VoxtaCollectionRoot { Folders: VoxtaCollectionFolder[]; } /** * Voxta collection - organizes resources into themed groups */ interface VoxtaCollection { $type: 'collection'; Id: string; Name: string; Version?: string; PackageId?: string; ExplicitContent?: boolean; Root: VoxtaCollectionRoot; Thumbnail?: { RandomizedETag?: string; ContentType?: string; }; DateCreated?: string; DateModified?: string; } /** * Voxta scenario action */ interface VoxtaAction { Name: string; Layer?: string; Arguments?: unknown[]; FinalLayer?: boolean; Timing?: number; Description?: string; Disabled?: boolean; Once?: boolean; FlagsFilter?: string; EvaluateNextEvent?: boolean; Effect?: { SetFlags?: string[]; Script?: string; Event?: string; Story?: string; Secret?: string; Instructions?: string; MaxSentences?: number; MaxTokens?: number; [key: string]: unknown; }; } /** * Voxta scenario event (similar to action but for event triggers) */ interface VoxtaEvent { Id?: string; Name: string; Layer?: string; Timing?: number; Description?: string; Arguments?: unknown[]; Disabled?: boolean; FinalLayer?: boolean; Once?: boolean; FlagsFilter?: string; EvaluateNextEvent?: boolean; Effect?: { SetFlags?: string[]; Script?: string; Event?: string; Story?: string; Secret?: string; Instructions?: string; MaxSentences?: number; MaxTokens?: number; [key: string]: unknown; }; } /** * Voxta scenario context (conditional context blocks) */ interface VoxtaContext { Name: string; Text: string; FlagsFilter?: string; Disabled?: boolean; } /** * Voxta scenario role - maps characters to scenario slots */ interface VoxtaRole { Name: string; Description?: string; DefaultCharacterId: string; EnabledOnStart?: boolean; } /** * Voxta impersonation (user persona override) */ interface VoxtaImpersonation { Name: string; Description?: string; } /** * Voxta scenario */ interface VoxtaScenario { $type: 'scenario'; Id: string; Name: string; Version?: string; ParentId?: string; PackageId?: string; Client?: string; Creator?: string; Description?: string; Template?: string; Messages?: string; SystemPrompt?: string; SystemPromptOverrideType?: number; Roles?: VoxtaRole[]; NarratorCharacterId?: string; Impersonation?: VoxtaImpersonation; SharedScripts?: VoxtaScript[]; Actions?: VoxtaAction[]; Events?: VoxtaEvent[]; Contexts?: VoxtaContext[]; ExplicitContent?: boolean; ChatFlow?: number; ChatStyle?: number; MemoryBooks?: string[]; Thumbnail?: { ETag?: number; RandomizedETag?: string; ContentType?: string; }; DateCreated?: string; DateModified?: string; UserId?: string; AppControlled?: boolean; Locked?: boolean; } /** * Extracted Voxta asset */ interface ExtractedVoxtaAsset { path: string; buffer: BinaryData; characterId?: string; } /** * Extracted Voxta character with assets */ interface ExtractedVoxtaCharacter { id: string; data: VoxtaCharacter; thumbnail?: BinaryData; assets: ExtractedVoxtaAsset[]; } /** * Extracted Voxta scenario */ interface ExtractedVoxtaScenario { id: string; data: VoxtaScenario; thumbnail?: BinaryData; } /** * Extracted Voxta book */ interface ExtractedVoxtaBook { id: string; data: VoxtaBook; } /** * Extracted Voxta collection with assets */ interface ExtractedVoxtaCollection { id: string; data: VoxtaCollection; thumbnail?: BinaryData; } /** * Voxta export type * - 'package': Has package.json with full metadata * - 'scenario': Has Scenarios/ folder but no package.json (scenario export) * - 'character': Only has Characters/ folder (single/multi character export) * - 'collection': Has Collections/ folder (bundled content with organization) */ type VoxtaExportType = 'package' | 'scenario' | 'character' | 'collection'; /** * Complete extracted Voxta data */ interface VoxtaData { package?: VoxtaPackage; characters: ExtractedVoxtaCharacter[]; scenarios: ExtractedVoxtaScenario[]; books: ExtractedVoxtaBook[]; collections: ExtractedVoxtaCollection[]; /** * Type of export detected: * - 'package': Has package.json * - 'scenario': Has Scenarios/ but no package.json * - 'character': Only Characters/ (no package.json or Scenarios/) * - 'collection': Has Collections/ folder */ exportType: VoxtaExportType; } /** * Options for Voxta extraction */ interface VoxtaReadOptions { maxFileSize?: number; maxAssetSize?: number; maxTotalSize?: number; } /** * Asset to include in Voxta export */ interface VoxtaWriteAsset { type: string; name: string; ext: string; data: BinaryData; tags?: string[]; isMain?: boolean; } /** * Options for building Voxta package */ interface VoxtaWriteOptions { compressionLevel?: CompressionLevel; includePackageJson?: boolean; characterId?: string; packageId?: string; /** Scenario to include - uses scenario.Id as the key */ scenario?: VoxtaScenario; /** Scenario thumbnail */ scenarioThumbnail?: BinaryData; } /** * Result of building a Voxta package */ interface VoxtaBuildResult { buffer: BinaryData; assetCount: number; totalSize: number; characterId: string; /** Scenario ID if a scenario was included */ scenarioId?: string; } /** * Voxta extension data stored in CCv3 extensions */ interface VoxtaExtensionData { id: string; version?: string; packageId?: string; label?: string; textToSpeech?: VoxtaTtsConfig[]; appearance?: string; context?: string; instructions?: string; userNameOverride?: string; userDescriptionOverride?: string; culture?: string; importedFrom?: string; chatSettings?: { chatStyle?: number; enableThinkingSpeech?: boolean; notifyUserAwayReturn?: boolean; timeAware?: boolean; useMemory?: boolean; maxTokens?: number; maxSentences?: number; systemPromptOverrideType?: number; }; simulationSettings?: { climaxSensitivity?: number; pleasureDecay?: number; }; scripts?: VoxtaScript[]; augmentations?: unknown[]; scenario?: { actions?: VoxtaAction[]; sharedScripts?: VoxtaScript[]; }; original?: Partial; } /** * Loss report for Voxta export */ interface VoxtaLossReport { lostFields: string[]; lostAssets: string[]; warnings: string[]; reason: string; } /** * Voxta Reader * * Extracts and parses .voxpkg files. */ /** * Check if data is a Voxta package */ declare function isVoxta(data: BinaryData): boolean; /** * Extract and parse a Voxta package */ declare function readVoxta(data: BinaryData, options?: VoxtaReadOptions): VoxtaData; /** * Async version of readVoxta */ declare function readVoxtaAsync(data: BinaryData, options?: VoxtaReadOptions): Promise; /** * Voxta Writer * * Creates .voxpkg files from CCv3 card data. */ /** * Build a Voxta package from CCv3 card data */ declare function writeVoxta(card: CCv3Data, assets: VoxtaWriteAsset[], options?: VoxtaWriteOptions): VoxtaBuildResult; /** * Async version of writeVoxta */ declare function writeVoxtaAsync(card: CCv3Data, assets: VoxtaWriteAsset[], options?: VoxtaWriteOptions): Promise; /** * Voxta <-> CCv3 Mapping * * Conversion utilities between Voxta format and CCv3 format. */ /** * Convert a Voxta character to CCv3 format */ declare function voxtaToCCv3(character: VoxtaCharacter, books?: VoxtaBook[]): CCv3Data; /** * Convert CCv3 card to Voxta character format */ declare function ccv3ToVoxta(card: CCv3Data): VoxtaCharacter; /** * Convert CCv3 lorebook to Voxta book format */ declare function ccv3LorebookToVoxtaBook(card: CCv3Data): VoxtaBook | null; /** * Macro Conversion * * Converts between Voxta-style macros (with spaces) and standard macros. * * Voxta uses: {{ user }}, {{ char }} * Standard uses: {{user}}, {{char}} */ /** * Convert Voxta-style macros to standard format (no spaces) */ declare function voxtaToStandard(text: string): string; /** * Convert standard macros to Voxta-style format (with spaces) */ declare function standardToVoxta(text: string): string; /** * Editable CCv3 fields (subset that can be changed in editors) */ type CCv3Edits = Partial; /** * Merge partial CCv3 edits into an existing Voxta character. * * This function applies only the fields present in `edits` to the original * character, preserving Voxta-specific fields like Scripts, TTS, and * Augmentations that CCv3 cannot represent. * * @param original - The original extracted Voxta character * @param edits - Partial CCv3 data fields to apply * @returns Updated VoxtaCharacter with edits merged */ declare function mergeCharacterEdits(original: ExtractedVoxtaCharacter | VoxtaCharacter, edits: CCv3Edits): VoxtaCharacter; /** * Merge partial CCv3 lorebook edits into an existing Voxta book. * * @param original - The original extracted Voxta book * @param edits - CCv3 character_book to merge * @returns Updated VoxtaBook with edits merged */ declare function mergeBookEdits(original: ExtractedVoxtaBook | VoxtaBook, edits: CCv3CharacterBook): VoxtaBook; /** * Delta changes to apply to a Voxta package */ interface VoxtaDeltas { /** Updated characters by ID */ characters?: Map; /** Updated books by ID */ books?: Map; /** Updated package metadata (optional) */ package?: Partial; } /** * Options for applying deltas */ interface ApplyDeltaOptions { compressionLevel?: CompressionLevel; } /** * Apply delta changes to an existing Voxta package. * * This performs a minimal update - only files that have changed are rewritten. * All other files (assets, scenarios, unchanged characters/books) are preserved * exactly as they were in the original package. * * @param originalBuffer - The original .voxpkg file buffer * @param deltas - Changes to apply * @param options - Compression options * @returns New package buffer with changes applied */ declare function applyVoxtaDeltas(originalBuffer: BinaryData, deltas: VoxtaDeltas, options?: ApplyDeltaOptions): Uint8Array; /** * Async version of applyVoxtaDeltas */ declare function applyVoxtaDeltasAsync(originalBuffer: BinaryData, deltas: VoxtaDeltas, options?: ApplyDeltaOptions): Promise; /** * Character info in package manifest */ interface ManifestCharacter { id: string; name: string; } /** * Book info in package manifest */ interface ManifestBook { id: string; name: string; /** Character IDs that reference this book */ usedBy: string[]; } /** * Scenario info in package manifest */ interface ManifestScenario { id: string; name: string; } /** * Package manifest for UI display */ interface PackageManifest { packageId?: string; packageName?: string; characters: ManifestCharacter[]; books: ManifestBook[]; scenarios: ManifestScenario[]; } /** * Get a manifest summary of a Voxta package for UI display. * * This provides a quick overview of package contents with relationship * information (which characters use which books). * * @param data - Extracted Voxta data from readVoxta() * @returns Package manifest for UI display */ declare function getPackageManifest(data: VoxtaData): PackageManifest; /** * Options for extracting a character package */ interface ExtractCharacterOptions { compressionLevel?: CompressionLevel; /** Include books referenced by the character */ includeBooks?: boolean; /** New package name (defaults to character name) */ packageName?: string; } /** * Extract a single character from a multi-character package. * * Creates a new standalone .voxpkg containing just the specified character, * their assets, and optionally their referenced books. * * NOTE: Scenarios are NOT extracted since they may contain scripts that * reference other characters in the package. * * @param originalBuffer - The original .voxpkg file buffer * @param characterId - ID of the character to extract * @param options - Extraction options * @returns New package buffer with just the specified character */ declare function extractCharacterPackage(originalBuffer: BinaryData, characterId: string, options?: ExtractCharacterOptions): Uint8Array; /** * Options for adding a character to a package */ interface AddCharacterOptions { compressionLevel?: CompressionLevel; /** Books to include with the character */ books?: VoxtaBook[]; /** Assets to include (path relative to character dir -> data) */ assets?: Map; /** Thumbnail image */ thumbnail?: BinaryData; } /** * Add a character to an existing Voxta package. * * @param originalBuffer - The original .voxpkg file buffer * @param character - The character to add * @param options - Options including books and assets * @returns New package buffer with the character added */ declare function addCharacterToPackage(originalBuffer: BinaryData, character: VoxtaCharacter, options?: AddCharacterOptions): Uint8Array; /** * Voxta Loss Reporting * * Documents what data is lost when exporting to Voxta format. */ /** * Check what would be lost when exporting a card to Voxta format */ declare function checkVoxtaLoss(card: NormalizedCard): VoxtaLossReport; /** * Check if export would be lossless */ declare function isVoxtaExportLossless(card: NormalizedCard): boolean; /** * Format loss report as human-readable string */ declare function formatVoxtaLossReport(report: VoxtaLossReport): string; /** * Voxta Asset Enricher * * Analyzes Voxta asset paths to extract semantic tags and types. * e.g. "Avatars/Default/happy_idle_01.webp" -> tags: [emotion:happy, state:idle, variant:01] */ interface EnrichedAssetMetadata { type: 'icon' | 'sound' | 'custom'; tags: string[]; } /** * Extract metadata from a Voxta asset path/filename */ declare function enrichVoxtaAsset(asset: ExtractedVoxtaAsset): EnrichedAssetMetadata; export { type AddCharacterOptions, type ApplyDeltaOptions, type CCv3Edits, type CompressionLevel, type EnrichedAssetMetadata, type ExtractCharacterOptions, type ExtractedVoxtaAsset, type ExtractedVoxtaBook, type ExtractedVoxtaCharacter, type ExtractedVoxtaCollection, type ExtractedVoxtaScenario, type ManifestBook, type ManifestCharacter, type ManifestScenario, type PackageManifest, type VoxtaAction, type VoxtaBook, type VoxtaBookItem, type VoxtaBuildResult, type VoxtaCharacter, type VoxtaCollection, type VoxtaCollectionFolder, type VoxtaCollectionItem, type VoxtaCollectionRoot, type VoxtaData, type VoxtaDeltas, type VoxtaExportType, type VoxtaExtensionData, type VoxtaLossReport, type VoxtaPackage, type VoxtaReadOptions, VoxtaResourceKind, type VoxtaResourceRef, type VoxtaScenario, type VoxtaScript, type VoxtaTtsConfig, type VoxtaWriteAsset, type VoxtaWriteOptions, addCharacterToPackage, applyVoxtaDeltas, applyVoxtaDeltasAsync, ccv3LorebookToVoxtaBook, ccv3ToVoxta, checkVoxtaLoss, enrichVoxtaAsset, extractCharacterPackage, formatVoxtaLossReport, getPackageManifest, isVoxta, isVoxtaExportLossless, mergeBookEdits, mergeCharacterEdits, readVoxta, readVoxtaAsync, standardToVoxta, voxtaToCCv3, voxtaToStandard, writeVoxta, writeVoxtaAsync };