@escapeaihq/client-core 0.49.1 → 0.138.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +445 -153
- package/dist/adapters/capabilities.d.ts +20 -3
- package/dist/adapters/capabilities.d.ts.map +1 -1
- package/dist/adapters/directorAdapter.d.ts +5 -4
- package/dist/adapters/directorAdapter.d.ts.map +1 -1
- package/dist/adapters/directorAdapter.js +5 -4
- package/dist/adapters/directorAdapter.js.map +1 -1
- package/dist/adapters/experienceModelCatalog.d.ts +382 -0
- package/dist/adapters/experienceModelCatalog.d.ts.map +1 -0
- package/dist/adapters/experienceModelCatalog.js +401 -0
- package/dist/adapters/experienceModelCatalog.js.map +1 -0
- package/dist/adapters/extractionAdapter.d.ts +81 -0
- package/dist/adapters/extractionAdapter.d.ts.map +1 -0
- package/dist/adapters/extractionAdapter.js +98 -0
- package/dist/adapters/extractionAdapter.js.map +1 -0
- package/dist/adapters/imageAdapter.d.ts +5 -1
- package/dist/adapters/imageAdapter.d.ts.map +1 -1
- package/dist/adapters/imageAdapter.js +5 -1
- package/dist/adapters/imageAdapter.js.map +1 -1
- package/dist/adapters/index.d.ts +54 -16
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +62 -11
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/momentDirective.d.ts +66 -0
- package/dist/adapters/momentDirective.d.ts.map +1 -0
- package/dist/adapters/momentDirective.js +78 -0
- package/dist/adapters/momentDirective.js.map +1 -0
- package/dist/adapters/momentPolicy.d.ts +132 -0
- package/dist/adapters/momentPolicy.d.ts.map +1 -0
- package/dist/adapters/momentPolicy.js +165 -0
- package/dist/adapters/momentPolicy.js.map +1 -0
- package/dist/adapters/registry.d.ts +1 -1
- package/dist/adapters/registry.d.ts.map +1 -1
- package/dist/adapters/videoGenAdapter.d.ts +55 -0
- package/dist/adapters/videoGenAdapter.d.ts.map +1 -0
- package/dist/adapters/videoGenAdapter.js +78 -0
- package/dist/adapters/videoGenAdapter.js.map +1 -0
- package/dist/adapters/worldAdapter.d.ts +132 -11
- package/dist/adapters/worldAdapter.d.ts.map +1 -1
- package/dist/adapters/worldAdapter.js +127 -11
- package/dist/adapters/worldAdapter.js.map +1 -1
- package/dist/adapters/worldModelPreference.d.ts +173 -0
- package/dist/adapters/worldModelPreference.d.ts.map +1 -0
- package/dist/adapters/worldModelPreference.js +209 -0
- package/dist/adapters/worldModelPreference.js.map +1 -0
- package/dist/adapters/worldModelTradeoffs.d.ts +120 -0
- package/dist/adapters/worldModelTradeoffs.d.ts.map +1 -0
- package/dist/adapters/worldModelTradeoffs.js +154 -0
- package/dist/adapters/worldModelTradeoffs.js.map +1 -0
- package/dist/admin.d.ts +545 -0
- package/dist/admin.d.ts.map +1 -1
- package/dist/admin.js +230 -16
- package/dist/admin.js.map +1 -1
- package/dist/api.d.ts +10281 -2216
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +4174 -1240
- package/dist/api.js.map +1 -1
- package/dist/arcBoardJoin.d.ts +38 -0
- package/dist/arcBoardJoin.d.ts.map +1 -0
- package/dist/arcBoardJoin.js +37 -0
- package/dist/arcBoardJoin.js.map +1 -0
- package/dist/arcPreview.d.ts +49 -0
- package/dist/arcPreview.d.ts.map +1 -0
- package/dist/arcPreview.js +65 -0
- package/dist/arcPreview.js.map +1 -0
- package/dist/audio.d.ts +259 -16
- package/dist/audio.d.ts.map +1 -1
- package/dist/audio.js +605 -114
- package/dist/audio.js.map +1 -1
- package/dist/audioDsp.d.ts +45 -0
- package/dist/audioDsp.d.ts.map +1 -0
- package/dist/audioDsp.js +108 -0
- package/dist/audioDsp.js.map +1 -0
- package/dist/audioProtocol.d.ts +160 -0
- package/dist/audioProtocol.d.ts.map +1 -1
- package/dist/audioProtocol.js +99 -0
- package/dist/audioProtocol.js.map +1 -1
- package/dist/beatTitles.d.ts +33 -0
- package/dist/beatTitles.d.ts.map +1 -0
- package/dist/beatTitles.js +39 -0
- package/dist/beatTitles.js.map +1 -0
- package/dist/castProjection.d.ts +204 -1
- package/dist/castProjection.d.ts.map +1 -1
- package/dist/castProjection.js +202 -0
- package/dist/castProjection.js.map +1 -1
- package/dist/characterGrounding.d.ts +369 -0
- package/dist/characterGrounding.d.ts.map +1 -0
- package/dist/characterGrounding.js +408 -0
- package/dist/characterGrounding.js.map +1 -0
- package/dist/conversation/binding.d.ts +41 -1
- package/dist/conversation/binding.d.ts.map +1 -1
- package/dist/conversation/binding.js +12 -0
- package/dist/conversation/binding.js.map +1 -1
- package/dist/conversation/chatSessionStore.d.ts +178 -0
- package/dist/conversation/chatSessionStore.d.ts.map +1 -0
- package/dist/conversation/chatSessionStore.js +196 -0
- package/dist/conversation/chatSessionStore.js.map +1 -0
- package/dist/conversation/controller.d.ts +60 -0
- package/dist/conversation/controller.d.ts.map +1 -1
- package/dist/conversation/controller.js +104 -3
- package/dist/conversation/controller.js.map +1 -1
- package/dist/conversation/index.d.ts +2 -0
- package/dist/conversation/index.d.ts.map +1 -1
- package/dist/conversation/index.js +2 -0
- package/dist/conversation/index.js.map +1 -1
- package/dist/conversation/participant.d.ts +16 -0
- package/dist/conversation/participant.d.ts.map +1 -1
- package/dist/conversation/readSequencer.d.ts +38 -0
- package/dist/conversation/readSequencer.d.ts.map +1 -0
- package/dist/conversation/readSequencer.js +42 -0
- package/dist/conversation/readSequencer.js.map +1 -0
- package/dist/conversation/roster.d.ts +5 -1
- package/dist/conversation/roster.d.ts.map +1 -1
- package/dist/conversation/roster.js.map +1 -1
- package/dist/conversation/rosterProjection.d.ts +74 -1
- package/dist/conversation/rosterProjection.d.ts.map +1 -1
- package/dist/conversation/rosterProjection.js +135 -1
- package/dist/conversation/rosterProjection.js.map +1 -1
- package/dist/conversation/runtime.d.ts +20 -3
- package/dist/conversation/runtime.d.ts.map +1 -1
- package/dist/conversation/runtime.js +66 -7
- package/dist/conversation/runtime.js.map +1 -1
- package/dist/conversation/types.d.ts +43 -4
- package/dist/conversation/types.d.ts.map +1 -1
- package/dist/conversation/voice.d.ts +290 -13
- package/dist/conversation/voice.d.ts.map +1 -1
- package/dist/conversation/voice.js +565 -42
- package/dist/conversation/voice.js.map +1 -1
- package/dist/creatorCuration.d.ts +134 -0
- package/dist/creatorCuration.d.ts.map +1 -0
- package/dist/creatorCuration.js +228 -0
- package/dist/creatorCuration.js.map +1 -0
- package/dist/creatorDashboard.d.ts +155 -0
- package/dist/creatorDashboard.d.ts.map +1 -0
- package/dist/creatorDashboard.js +237 -0
- package/dist/creatorDashboard.js.map +1 -0
- package/dist/creatorUniverse.d.ts +95 -0
- package/dist/creatorUniverse.d.ts.map +1 -0
- package/dist/creatorUniverse.js +136 -0
- package/dist/creatorUniverse.js.map +1 -0
- package/dist/curationWrite.d.ts +76 -0
- package/dist/curationWrite.d.ts.map +1 -0
- package/dist/curationWrite.js +106 -0
- package/dist/curationWrite.js.map +1 -0
- package/dist/designTokens.d.ts +64 -0
- package/dist/designTokens.d.ts.map +1 -0
- package/dist/designTokens.js +117 -0
- package/dist/designTokens.js.map +1 -0
- package/dist/dialogAttribution.d.ts +79 -0
- package/dist/dialogAttribution.d.ts.map +1 -0
- package/dist/dialogAttribution.js +144 -0
- package/dist/dialogAttribution.js.map +1 -0
- package/dist/dmRunWorldReadiness.d.ts +605 -0
- package/dist/dmRunWorldReadiness.d.ts.map +1 -0
- package/dist/dmRunWorldReadiness.js +775 -0
- package/dist/dmRunWorldReadiness.js.map +1 -0
- package/dist/domains/access.d.ts +32 -0
- package/dist/domains/access.d.ts.map +1 -0
- package/dist/domains/access.js +43 -0
- package/dist/domains/access.js.map +1 -0
- package/dist/domains/adventureDefinitions.d.ts +159 -0
- package/dist/domains/adventureDefinitions.d.ts.map +1 -0
- package/dist/domains/adventureDefinitions.js +168 -0
- package/dist/domains/adventureDefinitions.js.map +1 -0
- package/dist/domains/adventures.d.ts +329 -0
- package/dist/domains/adventures.d.ts.map +1 -0
- package/dist/domains/adventures.js +359 -0
- package/dist/domains/adventures.js.map +1 -0
- package/dist/domains/arcs.d.ts +146 -0
- package/dist/domains/arcs.d.ts.map +1 -0
- package/dist/domains/arcs.js +202 -0
- package/dist/domains/arcs.js.map +1 -0
- package/dist/domains/artifacts.d.ts +259 -0
- package/dist/domains/artifacts.d.ts.map +1 -0
- package/dist/domains/artifacts.js +125 -0
- package/dist/domains/artifacts.js.map +1 -0
- package/dist/domains/chat.d.ts +158 -0
- package/dist/domains/chat.d.ts.map +1 -0
- package/dist/domains/chat.js +224 -0
- package/dist/domains/chat.js.map +1 -0
- package/dist/domains/decisions.d.ts +31 -0
- package/dist/domains/decisions.d.ts.map +1 -0
- package/dist/domains/decisions.js +42 -0
- package/dist/domains/decisions.js.map +1 -0
- package/dist/domains/documents.d.ts +218 -0
- package/dist/domains/documents.d.ts.map +1 -0
- package/dist/domains/documents.js +252 -0
- package/dist/domains/documents.js.map +1 -0
- package/dist/domains/enhancements.d.ts +106 -0
- package/dist/domains/enhancements.d.ts.map +1 -0
- package/dist/domains/enhancements.js +160 -0
- package/dist/domains/enhancements.js.map +1 -0
- package/dist/domains/graph.d.ts +454 -0
- package/dist/domains/graph.d.ts.map +1 -0
- package/dist/domains/graph.js +648 -0
- package/dist/domains/graph.js.map +1 -0
- package/dist/domains/images.d.ts +220 -0
- package/dist/domains/images.d.ts.map +1 -0
- package/dist/domains/images.js +307 -0
- package/dist/domains/images.js.map +1 -0
- package/dist/domains/ingestion.d.ts +312 -0
- package/dist/domains/ingestion.d.ts.map +1 -0
- package/dist/domains/ingestion.js +495 -0
- package/dist/domains/ingestion.js.map +1 -0
- package/dist/domains/me.d.ts +21 -0
- package/dist/domains/me.d.ts.map +1 -0
- package/dist/domains/me.js +23 -0
- package/dist/domains/me.js.map +1 -0
- package/dist/domains/orgs.d.ts +47 -0
- package/dist/domains/orgs.d.ts.map +1 -0
- package/dist/domains/orgs.js +75 -0
- package/dist/domains/orgs.js.map +1 -0
- package/dist/domains/personas.d.ts +135 -0
- package/dist/domains/personas.d.ts.map +1 -0
- package/dist/domains/personas.js +316 -0
- package/dist/domains/personas.js.map +1 -0
- package/dist/domains/projects.d.ts +53 -0
- package/dist/domains/projects.d.ts.map +1 -0
- package/dist/domains/projects.js +94 -0
- package/dist/domains/projects.js.map +1 -0
- package/dist/domains/quests.d.ts +431 -0
- package/dist/domains/quests.d.ts.map +1 -0
- package/dist/domains/quests.js +61 -0
- package/dist/domains/quests.js.map +1 -0
- package/dist/domains/reactor.d.ts +98 -0
- package/dist/domains/reactor.d.ts.map +1 -0
- package/dist/domains/reactor.js +131 -0
- package/dist/domains/reactor.js.map +1 -0
- package/dist/domains/showcase.d.ts +28 -0
- package/dist/domains/showcase.d.ts.map +1 -0
- package/dist/domains/showcase.js +28 -0
- package/dist/domains/showcase.js.map +1 -0
- package/dist/domains/storyboards.d.ts +1253 -0
- package/dist/domains/storyboards.d.ts.map +1 -0
- package/dist/domains/storyboards.js +781 -0
- package/dist/domains/storyboards.js.map +1 -0
- package/dist/domains/studioSettings.d.ts +39 -0
- package/dist/domains/studioSettings.d.ts.map +1 -0
- package/dist/domains/studioSettings.js +80 -0
- package/dist/domains/studioSettings.js.map +1 -0
- package/dist/domains/universes.d.ts +191 -0
- package/dist/domains/universes.d.ts.map +1 -0
- package/dist/domains/universes.js +276 -0
- package/dist/domains/universes.js.map +1 -0
- package/dist/domains/userDefaults.d.ts +18 -0
- package/dist/domains/userDefaults.d.ts.map +1 -0
- package/dist/domains/userDefaults.js +27 -0
- package/dist/domains/userDefaults.js.map +1 -0
- package/dist/domains/visemeBundles.d.ts +262 -0
- package/dist/domains/visemeBundles.d.ts.map +1 -0
- package/dist/domains/visemeBundles.js +373 -0
- package/dist/domains/visemeBundles.js.map +1 -0
- package/dist/domains/workflows.d.ts +142 -0
- package/dist/domains/workflows.d.ts.map +1 -0
- package/dist/domains/workflows.js +245 -0
- package/dist/domains/workflows.js.map +1 -0
- package/dist/enhancementDiff.d.ts +56 -0
- package/dist/enhancementDiff.d.ts.map +1 -0
- package/dist/enhancementDiff.js +110 -0
- package/dist/enhancementDiff.js.map +1 -0
- package/dist/generated/contract.d.ts +372 -0
- package/dist/generated/contract.d.ts.map +1 -0
- package/dist/generated/contract.js +390 -0
- package/dist/generated/contract.js.map +1 -0
- package/dist/graphSchema.d.ts +36 -5
- package/dist/graphSchema.d.ts.map +1 -1
- package/dist/graphSchema.js +88 -2
- package/dist/graphSchema.js.map +1 -1
- package/dist/http.d.ts +70 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +263 -11
- package/dist/http.js.map +1 -1
- package/dist/identity.d.ts +81 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +65 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +118 -0
- package/dist/index.js.map +1 -1
- package/dist/messageContent.d.ts +174 -0
- package/dist/messageContent.d.ts.map +1 -0
- package/dist/messageContent.js +405 -0
- package/dist/messageContent.js.map +1 -0
- package/dist/mutationEpoch.d.ts +83 -0
- package/dist/mutationEpoch.d.ts.map +1 -0
- package/dist/mutationEpoch.js +109 -0
- package/dist/mutationEpoch.js.map +1 -0
- package/dist/obo.d.ts +144 -0
- package/dist/obo.d.ts.map +1 -0
- package/dist/obo.js +135 -0
- package/dist/obo.js.map +1 -0
- package/dist/opusTransport.d.ts +113 -0
- package/dist/opusTransport.d.ts.map +1 -0
- package/dist/opusTransport.js +170 -0
- package/dist/opusTransport.js.map +1 -0
- package/dist/pagination.d.ts +18 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +26 -0
- package/dist/pagination.js.map +1 -0
- package/dist/platformAssistant.d.ts +55 -1
- package/dist/platformAssistant.d.ts.map +1 -1
- package/dist/platformAssistant.js +39 -1
- package/dist/platformAssistant.js.map +1 -1
- package/dist/pollUtils.d.ts +19 -0
- package/dist/pollUtils.d.ts.map +1 -0
- package/dist/pollUtils.js +35 -0
- package/dist/pollUtils.js.map +1 -0
- package/dist/questLog.d.ts +232 -0
- package/dist/questLog.d.ts.map +1 -0
- package/dist/questLog.js +522 -0
- package/dist/questLog.js.map +1 -0
- package/dist/reactor/dmDirectiveToExperience.d.ts +300 -0
- package/dist/reactor/dmDirectiveToExperience.d.ts.map +1 -0
- package/dist/reactor/dmDirectiveToExperience.js +401 -0
- package/dist/reactor/dmDirectiveToExperience.js.map +1 -0
- package/dist/reactor/dmSceneControlPrompt.d.ts +40 -0
- package/dist/reactor/dmSceneControlPrompt.d.ts.map +1 -0
- package/dist/reactor/dmSceneControlPrompt.js +145 -0
- package/dist/reactor/dmSceneControlPrompt.js.map +1 -0
- package/dist/reactor/dmWorldEntry.d.ts +1278 -0
- package/dist/reactor/dmWorldEntry.d.ts.map +1 -0
- package/dist/reactor/dmWorldEntry.js +1396 -0
- package/dist/reactor/dmWorldEntry.js.map +1 -0
- package/dist/reactor/framePromptCompaction.d.ts +223 -0
- package/dist/reactor/framePromptCompaction.d.ts.map +1 -0
- package/dist/reactor/framePromptCompaction.js +393 -0
- package/dist/reactor/framePromptCompaction.js.map +1 -0
- package/dist/reactor/frameWorldBind.d.ts +86 -0
- package/dist/reactor/frameWorldBind.d.ts.map +1 -0
- package/dist/reactor/frameWorldBind.js +79 -0
- package/dist/reactor/frameWorldBind.js.map +1 -0
- package/dist/reactor/happyOysterSeed.d.ts +166 -0
- package/dist/reactor/happyOysterSeed.d.ts.map +1 -0
- package/dist/reactor/happyOysterSeed.js +233 -0
- package/dist/reactor/happyOysterSeed.js.map +1 -0
- package/dist/reactor/happyOysterWalk.d.ts +274 -0
- package/dist/reactor/happyOysterWalk.d.ts.map +1 -0
- package/dist/reactor/happyOysterWalk.js +407 -0
- package/dist/reactor/happyOysterWalk.js.map +1 -0
- package/dist/reactor/happyOysterWorld.d.ts +718 -0
- package/dist/reactor/happyOysterWorld.d.ts.map +1 -0
- package/dist/reactor/happyOysterWorld.js +826 -0
- package/dist/reactor/happyOysterWorld.js.map +1 -0
- package/dist/reactor/heliosCommandDispatcher.d.ts.map +1 -1
- package/dist/reactor/heliosCommandDispatcher.js +5 -2
- package/dist/reactor/heliosCommandDispatcher.js.map +1 -1
- package/dist/reactor/hiddenWorldLifecycle.d.ts +101 -0
- package/dist/reactor/hiddenWorldLifecycle.d.ts.map +1 -0
- package/dist/reactor/hiddenWorldLifecycle.js +119 -0
- package/dist/reactor/hiddenWorldLifecycle.js.map +1 -0
- package/dist/reactor/imageCanvas.d.ts +15 -0
- package/dist/reactor/imageCanvas.d.ts.map +1 -0
- package/dist/reactor/imageCanvas.js +33 -0
- package/dist/reactor/imageCanvas.js.map +1 -0
- package/dist/reactor/index.d.ts +20 -0
- package/dist/reactor/index.d.ts.map +1 -1
- package/dist/reactor/index.js +81 -0
- package/dist/reactor/index.js.map +1 -1
- package/dist/reactor/longLiveCommandDispatcher.d.ts +23 -8
- package/dist/reactor/longLiveCommandDispatcher.d.ts.map +1 -1
- package/dist/reactor/longLiveCommandDispatcher.js +16 -4
- package/dist/reactor/longLiveCommandDispatcher.js.map +1 -1
- package/dist/reactor/longLiveSceneEntry.d.ts +203 -0
- package/dist/reactor/longLiveSceneEntry.d.ts.map +1 -0
- package/dist/reactor/longLiveSceneEntry.js +280 -0
- package/dist/reactor/longLiveSceneEntry.js.map +1 -0
- package/dist/reactor/momentCut.d.ts +153 -0
- package/dist/reactor/momentCut.d.ts.map +1 -0
- package/dist/reactor/momentCut.js +142 -0
- package/dist/reactor/momentCut.js.map +1 -0
- package/dist/reactor/promptAddonRegistry.d.ts +39 -3
- package/dist/reactor/promptAddonRegistry.d.ts.map +1 -1
- package/dist/reactor/promptAddonRegistry.js +44 -5
- package/dist/reactor/promptAddonRegistry.js.map +1 -1
- package/dist/reactor/promptTemplatePreview.d.ts +97 -0
- package/dist/reactor/promptTemplatePreview.d.ts.map +1 -0
- package/dist/reactor/promptTemplatePreview.js +185 -0
- package/dist/reactor/promptTemplatePreview.js.map +1 -0
- package/dist/reactor/reactorAvailability.d.ts +80 -0
- package/dist/reactor/reactorAvailability.d.ts.map +1 -0
- package/dist/reactor/reactorAvailability.js +121 -0
- package/dist/reactor/reactorAvailability.js.map +1 -0
- package/dist/reactor/reactorSessionRefusal.d.ts +125 -0
- package/dist/reactor/reactorSessionRefusal.d.ts.map +1 -0
- package/dist/reactor/reactorSessionRefusal.js +197 -0
- package/dist/reactor/reactorSessionRefusal.js.map +1 -0
- package/dist/reactor/reactorTokenScope.d.ts +47 -0
- package/dist/reactor/reactorTokenScope.d.ts.map +1 -0
- package/dist/reactor/reactorTokenScope.js +64 -0
- package/dist/reactor/reactorTokenScope.js.map +1 -0
- package/dist/reactor/resolveDirectorBeats.d.ts +65 -0
- package/dist/reactor/resolveDirectorBeats.d.ts.map +1 -0
- package/dist/reactor/resolveDirectorBeats.js +86 -0
- package/dist/reactor/resolveDirectorBeats.js.map +1 -0
- package/dist/reactor/sanaLiveEdit.d.ts +117 -0
- package/dist/reactor/sanaLiveEdit.d.ts.map +1 -0
- package/dist/reactor/sanaLiveEdit.js +105 -0
- package/dist/reactor/sanaLiveEdit.js.map +1 -0
- package/dist/reactor/sceneEntry.d.ts +66 -9
- package/dist/reactor/sceneEntry.d.ts.map +1 -1
- package/dist/reactor/sceneEntry.js +59 -66
- package/dist/reactor/sceneEntry.js.map +1 -1
- package/dist/reactor/sceneSeedImage.d.ts +199 -0
- package/dist/reactor/sceneSeedImage.d.ts.map +1 -0
- package/dist/reactor/sceneSeedImage.js +239 -0
- package/dist/reactor/sceneSeedImage.js.map +1 -0
- package/dist/reactor/seedImageOrchestrator.d.ts +70 -3
- package/dist/reactor/seedImageOrchestrator.d.ts.map +1 -1
- package/dist/reactor/seedImageOrchestrator.js +92 -28
- package/dist/reactor/seedImageOrchestrator.js.map +1 -1
- package/dist/reactor/toolPromptAddon.d.ts +37 -28
- package/dist/reactor/toolPromptAddon.d.ts.map +1 -1
- package/dist/reactor/toolPromptAddon.js +63 -101
- package/dist/reactor/toolPromptAddon.js.map +1 -1
- package/dist/reactor/worldMintLoop.d.ts +286 -0
- package/dist/reactor/worldMintLoop.d.ts.map +1 -0
- package/dist/reactor/worldMintLoop.js +381 -0
- package/dist/reactor/worldMintLoop.js.map +1 -0
- package/dist/reactor/worldSteerOutcome.d.ts +98 -0
- package/dist/reactor/worldSteerOutcome.d.ts.map +1 -0
- package/dist/reactor/worldSteerOutcome.js +81 -0
- package/dist/reactor/worldSteerOutcome.js.map +1 -0
- package/dist/retryAfter.d.ts +15 -0
- package/dist/retryAfter.d.ts.map +1 -0
- package/dist/retryAfter.js +75 -0
- package/dist/retryAfter.js.map +1 -0
- package/dist/seriesKey.d.ts +31 -0
- package/dist/seriesKey.d.ts.map +1 -0
- package/dist/seriesKey.js +33 -0
- package/dist/seriesKey.js.map +1 -0
- package/dist/sessionRefresh.d.ts +135 -0
- package/dist/sessionRefresh.d.ts.map +1 -0
- package/dist/sessionRefresh.js +215 -0
- package/dist/sessionRefresh.js.map +1 -0
- package/dist/sharedAudioContext.d.ts +39 -0
- package/dist/sharedAudioContext.d.ts.map +1 -0
- package/dist/sharedAudioContext.js +63 -0
- package/dist/sharedAudioContext.js.map +1 -0
- package/dist/singleFlight.d.ts +51 -0
- package/dist/singleFlight.d.ts.map +1 -0
- package/dist/singleFlight.js +87 -0
- package/dist/singleFlight.js.map +1 -0
- package/dist/storyGraph.d.ts +83 -0
- package/dist/storyGraph.d.ts.map +1 -1
- package/dist/storyGraph.js +169 -4
- package/dist/storyGraph.js.map +1 -1
- package/dist/storyboardMask.d.ts +343 -0
- package/dist/storyboardMask.d.ts.map +1 -0
- package/dist/storyboardMask.js +505 -0
- package/dist/storyboardMask.js.map +1 -0
- package/dist/storyboardTimeline.d.ts +93 -0
- package/dist/storyboardTimeline.d.ts.map +1 -0
- package/dist/storyboardTimeline.js +131 -0
- package/dist/storyboardTimeline.js.map +1 -0
- package/dist/studioAutomation.d.ts +104 -0
- package/dist/studioAutomation.d.ts.map +1 -0
- package/dist/studioAutomation.js +178 -0
- package/dist/studioAutomation.js.map +1 -0
- package/dist/tenantClaim.d.ts +86 -0
- package/dist/tenantClaim.d.ts.map +1 -0
- package/dist/tenantClaim.js +164 -0
- package/dist/tenantClaim.js.map +1 -0
- package/dist/timeFormat.d.ts +25 -0
- package/dist/timeFormat.d.ts.map +1 -1
- package/dist/timeFormat.js +56 -0
- package/dist/timeFormat.js.map +1 -1
- package/dist/toolSchemas.d.ts +53 -10
- package/dist/toolSchemas.d.ts.map +1 -1
- package/dist/toolSchemas.js +36 -9
- package/dist/toolSchemas.js.map +1 -1
- package/dist/transport.d.ts +120 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +282 -0
- package/dist/transport.js.map +1 -0
- package/dist/videoGenFacade.d.ts +63 -0
- package/dist/videoGenFacade.d.ts.map +1 -0
- package/dist/videoGenFacade.js +49 -0
- package/dist/videoGenFacade.js.map +1 -0
- package/dist/visemeScheduler.d.ts +24 -2
- package/dist/visemeScheduler.d.ts.map +1 -1
- package/dist/visemeScheduler.js +31 -2
- package/dist/visemeScheduler.js.map +1 -1
- package/dist/vision/VisionPublisher.d.ts +88 -0
- package/dist/vision/VisionPublisher.d.ts.map +1 -1
- package/dist/vision/VisionPublisher.js +196 -13
- package/dist/vision/VisionPublisher.js.map +1 -1
- package/dist/vision/VisionSourceController.d.ts +67 -1
- package/dist/vision/VisionSourceController.d.ts.map +1 -1
- package/dist/vision/VisionSourceController.js +147 -5
- package/dist/vision/VisionSourceController.js.map +1 -1
- package/dist/vision/index.d.ts +2 -1
- package/dist/vision/index.d.ts.map +1 -1
- package/dist/vision/index.js +2 -1
- package/dist/vision/index.js.map +1 -1
- package/dist/vision/sourceKinds.d.ts +18 -5
- package/dist/vision/sourceKinds.d.ts.map +1 -1
- package/dist/vision/sourceKinds.js +15 -2
- package/dist/vision/sourceKinds.js.map +1 -1
- package/dist/vision/types.d.ts +7 -4
- package/dist/vision/types.d.ts.map +1 -1
- package/dist/vision/visionErrors.d.ts +45 -0
- package/dist/vision/visionErrors.d.ts.map +1 -0
- package/dist/vision/visionErrors.js +66 -0
- package/dist/vision/visionErrors.js.map +1 -0
- package/dist/voiceCloneCaption.d.ts +33 -0
- package/dist/voiceCloneCaption.d.ts.map +1 -0
- package/dist/voiceCloneCaption.js +69 -0
- package/dist/voiceCloneCaption.js.map +1 -0
- package/dist/websocket.d.ts +390 -10
- package/dist/websocket.d.ts.map +1 -1
- package/dist/websocket.js +152 -0
- package/dist/websocket.js.map +1 -1
- package/dist/workflowAuthoring.d.ts +139 -0
- package/dist/workflowAuthoring.d.ts.map +1 -0
- package/dist/workflowAuthoring.js +557 -0
- package/dist/workflowAuthoring.js.map +1 -0
- package/package.json +15 -5
- package/src/__tests__/adapters-director.test.ts +9 -6
- package/src/__tests__/adapters-extraction.test.ts +175 -0
- package/src/__tests__/adapters-image.test.ts +66 -0
- package/src/__tests__/adapters-momentPolicy.test.ts +218 -0
- package/src/__tests__/adapters-platform.test.ts +110 -4
- package/src/__tests__/adapters-videogen.test.ts +53 -0
- package/src/__tests__/adapters-world.test.ts +117 -7
- package/src/__tests__/admin.enhancement-defaults.test.ts +115 -0
- package/src/__tests__/admin.test.ts +282 -0
- package/src/__tests__/adventures-world-state.test.ts +156 -0
- package/src/__tests__/adventures.test.ts +111 -1
- package/src/__tests__/api-pollers.test.ts +113 -23
- package/src/__tests__/api.adventure-definitions.test.ts +312 -0
- package/src/__tests__/api.anchor-beat.test.ts +75 -0
- package/src/__tests__/api.arc-approval.test.ts +171 -0
- package/src/__tests__/api.arc-beats-floor.test.ts +56 -0
- package/src/__tests__/api.arc-generation.test.ts +168 -0
- package/src/__tests__/api.arc-templates.test.ts +78 -0
- package/src/__tests__/api.assignVideoSeries.test.ts +81 -0
- package/src/__tests__/api.cast-frame-choices.test.ts +141 -0
- package/src/__tests__/api.cutscene-registry.test.ts +148 -0
- package/src/__tests__/api.enhancement-addition-actions.test.ts +137 -0
- package/src/__tests__/api.enrichVideo-serialization.test.ts +116 -0
- package/src/__tests__/api.extraction-base.test.ts +87 -0
- package/src/__tests__/api.generateVideo-cutscene.test.ts +148 -0
- package/src/__tests__/api.job-pipeline-stages.test.ts +128 -0
- package/src/__tests__/api.list-images-filters.test.ts +6 -3
- package/src/__tests__/api.quest-curation.test.ts +169 -0
- package/src/__tests__/api.reprocessVideo.test.ts +71 -0
- package/src/__tests__/api.scene-split-merge.test.ts +129 -0
- package/src/__tests__/api.session-quests.test.ts +184 -0
- package/src/__tests__/api.test.ts +122 -0
- package/src/__tests__/api.transferSeries.test.ts +114 -0
- package/src/__tests__/api.unknown-clusters.test.ts +225 -0
- package/src/__tests__/api.uploadVideo-options.test.ts +156 -0
- package/src/__tests__/arcPreview.test.ts +71 -0
- package/src/__tests__/arcStyleProfile.test.ts +204 -0
- package/src/__tests__/artifacts-delete.test.ts +109 -0
- package/src/__tests__/audio.test.ts +864 -5
- package/src/__tests__/audioDsp.test.ts +196 -0
- package/src/__tests__/audioUnavailable.test.ts +43 -0
- package/src/__tests__/cast.test.ts +10 -1
- package/src/__tests__/castCurationProjection.test.ts +84 -0
- package/src/__tests__/castFramePipelinePending.test.ts +171 -0
- package/src/__tests__/castProjection.test.ts +497 -5
- package/src/__tests__/characterGrounding.test.ts +357 -0
- package/src/__tests__/contract.test.ts +97 -0
- package/src/__tests__/conversation/binding.test.ts +53 -0
- package/src/__tests__/conversation/chatSessionStore.test.ts +243 -0
- package/src/__tests__/conversation/controller.test.ts +328 -0
- package/src/__tests__/conversation/readSequencer.test.ts +52 -0
- package/src/__tests__/conversation/rosterProjection.test.ts +204 -3
- package/src/__tests__/conversation/runtime.test.ts +118 -1
- package/src/__tests__/conversation/voice.test.ts +741 -7
- package/src/__tests__/creatorCuration.test.ts +256 -0
- package/src/__tests__/creatorDashboard.test.ts +444 -0
- package/src/__tests__/creatorUniverse.test.ts +138 -0
- package/src/__tests__/curationWrite.test.ts +179 -0
- package/src/__tests__/decisions.test.ts +89 -0
- package/src/__tests__/designTokens.test.ts +72 -0
- package/src/__tests__/dialogAttribution.test.ts +187 -0
- package/src/__tests__/dmDirectiveToExperience.test.ts +198 -0
- package/src/__tests__/dmWorldEntry.test.ts +2102 -0
- package/src/__tests__/enhancementDiff.test.ts +132 -0
- package/src/__tests__/experienceModelCatalog.test.ts +292 -0
- package/src/__tests__/extractionStageState.test.ts +67 -0
- package/src/__tests__/getVideo.test.ts +95 -0
- package/src/__tests__/graphReadAfterWrite.test.ts +211 -0
- package/src/__tests__/graphSchema.test.ts +55 -4
- package/src/__tests__/happyOysterSeed.test.ts +208 -0
- package/src/__tests__/happyOysterWorld.test.ts +1241 -0
- package/src/__tests__/happyOysterWorldRefusal.test.ts +224 -0
- package/src/__tests__/hiddenWorldLifecycle.test.ts +203 -0
- package/src/__tests__/http.session-refresh.test.ts +424 -0
- package/src/__tests__/http.test.ts +316 -0
- package/src/__tests__/identity.test.ts +132 -0
- package/src/__tests__/loadBundleManifest.test.ts +192 -22
- package/src/__tests__/longLiveSceneEntry.test.ts +371 -0
- package/src/__tests__/me.test.ts +74 -0
- package/src/__tests__/messageContent.test.ts +395 -0
- package/src/__tests__/momentCut.test.ts +229 -0
- package/src/__tests__/mutationEpoch.test.ts +218 -0
- package/src/__tests__/obo.test.ts +159 -0
- package/src/__tests__/opusTransport.test.ts +182 -0
- package/src/__tests__/opusTransportLibopus.test.ts +125 -0
- package/src/__tests__/orgs.test.ts +229 -0
- package/src/__tests__/persona-generation.test.ts +187 -1
- package/src/__tests__/platformAssistant.test.ts +140 -0
- package/src/__tests__/projects.test.ts +338 -0
- package/src/__tests__/promptTemplatePreview.test.ts +160 -0
- package/src/__tests__/reactor/__fixtures__/realFramePromptText.ts +23 -0
- package/src/__tests__/reactor/api-reactor.test.ts +60 -21
- package/src/__tests__/reactor/framePromptCompaction.test.ts +300 -0
- package/src/__tests__/reactor/promptAddonRegistry.test.ts +82 -1
- package/src/__tests__/reactor/reactorTokenScope.test.ts +50 -0
- package/src/__tests__/reactor/resolveDirectorBeats.test.ts +156 -0
- package/src/__tests__/reactor/sceneEntry.test.ts +3 -0
- package/src/__tests__/reactor/sceneSeedImage.test.ts +361 -0
- package/src/__tests__/reactor/seedImageOrchestrator.test.ts +43 -5
- package/src/__tests__/reactor/toolPromptAddon.test.ts +34 -42
- package/src/__tests__/reactor-happyOysterWalk.test.ts +294 -0
- package/src/__tests__/reactorAvailability.test.ts +217 -0
- package/src/__tests__/reactorSessionRefusal.test.ts +189 -0
- package/src/__tests__/regeneration.test.ts +9 -9
- package/src/__tests__/reprocessBlockedReason.test.ts +30 -0
- package/src/__tests__/retryAfter.test.ts +65 -0
- package/src/__tests__/roleClaim.test.ts +102 -0
- package/src/__tests__/sanaLiveEdit.test.ts +84 -0
- package/src/__tests__/seriesKey.test.ts +24 -0
- package/src/__tests__/settings-set9.test.ts +238 -0
- package/src/__tests__/singleFlight.test.ts +348 -0
- package/src/__tests__/storyGraph.test.ts +111 -1
- package/src/__tests__/storyboardFrameCutscene.test.ts +115 -0
- package/src/__tests__/storyboardMask.test.ts +527 -0
- package/src/__tests__/storyboardTimeline.test.ts +228 -0
- package/src/__tests__/storyboards.test.ts +639 -0
- package/src/__tests__/studioAutomation.test.ts +325 -0
- package/src/__tests__/toolSchemas.test.ts +11 -18
- package/src/__tests__/transport.test.ts +312 -0
- package/src/__tests__/videoGenFacade.test.ts +141 -0
- package/src/__tests__/videoGraph.test.ts +43 -1
- package/src/__tests__/visemeScheduler.test.ts +55 -1
- package/src/__tests__/visibility.test.ts +143 -0
- package/src/__tests__/voiceCloneCaption.test.ts +80 -0
- package/src/__tests__/voiceFallback.test.ts +55 -0
- package/src/__tests__/websocket-error-turn-ended.test.ts +49 -0
- package/src/__tests__/websocket-session-attach.test.ts +288 -0
- package/src/__tests__/websocket-vision.test.ts +141 -0
- package/src/__tests__/websocket.test.ts +75 -1
- package/src/__tests__/workflowAuthoring.test.ts +187 -0
- package/src/__tests__/workflows.test.ts +640 -0
- package/src/__tests__/worldMintLoop.test.ts +448 -0
- package/src/__tests__/worldModelPreference.test.ts +302 -0
- package/src/__tests__/worldModelTradeoffs.test.ts +89 -0
- package/src/__tests__/worldSteerOutcome.test.ts +62 -0
- package/src/adapters/capabilities.ts +39 -3
- package/src/adapters/directorAdapter.ts +5 -4
- package/src/adapters/experienceModelCatalog.ts +538 -0
- package/src/adapters/extractionAdapter.ts +150 -0
- package/src/adapters/imageAdapter.ts +5 -1
- package/src/adapters/index.ts +104 -17
- package/src/adapters/momentDirective.ts +109 -0
- package/src/adapters/momentPolicy.ts +209 -0
- package/src/adapters/registry.ts +1 -1
- package/src/adapters/videoGenAdapter.ts +124 -0
- package/src/adapters/worldAdapter.ts +221 -16
- package/src/adapters/worldModelPreference.ts +247 -0
- package/src/adapters/worldModelTradeoffs.ts +247 -0
- package/src/admin.ts +842 -16
- package/src/api.ts +12670 -3446
- package/src/arcBoardJoin.ts +46 -0
- package/src/arcPreview.ts +103 -0
- package/src/audio.ts +691 -130
- package/src/audioDsp.ts +132 -0
- package/src/audioProtocol.ts +235 -0
- package/src/beatTitles.ts +51 -0
- package/src/castProjection.ts +311 -0
- package/src/characterGrounding.ts +491 -0
- package/src/conversation/binding.ts +53 -1
- package/src/conversation/chatSessionStore.ts +281 -0
- package/src/conversation/controller.ts +135 -3
- package/src/conversation/index.ts +2 -0
- package/src/conversation/participant.ts +16 -0
- package/src/conversation/readSequencer.ts +55 -0
- package/src/conversation/roster.ts +5 -1
- package/src/conversation/rosterProjection.ts +166 -2
- package/src/conversation/runtime.ts +66 -7
- package/src/conversation/types.ts +43 -4
- package/src/conversation/voice.ts +655 -51
- package/src/creatorCuration.ts +316 -0
- package/src/creatorDashboard.ts +344 -0
- package/src/creatorUniverse.ts +222 -0
- package/src/curationWrite.ts +108 -0
- package/src/designTokens.ts +157 -0
- package/src/dialogAttribution.ts +182 -0
- package/src/dmRunWorldReadiness.ts +1168 -0
- package/src/domains/access.ts +92 -0
- package/src/domains/adventureDefinitions.ts +313 -0
- package/src/domains/adventures.ts +557 -0
- package/src/domains/arcs.ts +350 -0
- package/src/domains/artifacts.ts +349 -0
- package/src/domains/chat.ts +338 -0
- package/src/domains/decisions.ts +62 -0
- package/src/domains/documents.ts +389 -0
- package/src/domains/enhancements.ts +259 -0
- package/src/domains/graph.ts +959 -0
- package/src/domains/images.ts +451 -0
- package/src/domains/ingestion.ts +695 -0
- package/src/domains/me.ts +27 -0
- package/src/domains/orgs.ts +168 -0
- package/src/domains/personas.ts +433 -0
- package/src/domains/projects.ts +177 -0
- package/src/domains/quests.ts +587 -0
- package/src/domains/reactor.ts +163 -0
- package/src/domains/showcase.ts +35 -0
- package/src/domains/storyboards.ts +1698 -0
- package/src/domains/studioSettings.ts +149 -0
- package/src/domains/universes.ts +433 -0
- package/src/domains/userDefaults.ts +37 -0
- package/src/domains/visemeBundles.ts +541 -0
- package/src/domains/workflows.ts +376 -0
- package/src/enhancementDiff.ts +171 -0
- package/src/generated/contract.ts +1011 -0
- package/src/graphSchema.ts +154 -6
- package/src/http.ts +295 -11
- package/src/identity.ts +123 -0
- package/src/index.ts +131 -0
- package/src/messageContent.ts +500 -0
- package/src/mutationEpoch.ts +107 -0
- package/src/obo.ts +201 -0
- package/src/opusTransport.ts +268 -0
- package/src/pagination.ts +29 -0
- package/src/platformAssistant.ts +97 -1
- package/src/pollUtils.ts +35 -0
- package/src/questLog.ts +704 -0
- package/src/reactor/dmDirectiveToExperience.ts +636 -0
- package/src/reactor/dmSceneControlPrompt.ts +152 -0
- package/src/reactor/dmWorldEntry.ts +2226 -0
- package/src/reactor/framePromptCompaction.ts +544 -0
- package/src/reactor/frameWorldBind.ts +133 -0
- package/src/reactor/happyOysterSeed.ts +329 -0
- package/src/reactor/happyOysterWalk.ts +541 -0
- package/src/reactor/happyOysterWorld.ts +1270 -0
- package/src/reactor/heliosCommandDispatcher.ts +5 -1
- package/src/reactor/hiddenWorldLifecycle.ts +182 -0
- package/src/reactor/imageCanvas.ts +38 -0
- package/src/reactor/index.ts +81 -0
- package/src/reactor/longLiveCommandDispatcher.ts +23 -8
- package/src/reactor/longLiveSceneEntry.ts +409 -0
- package/src/reactor/momentCut.ts +219 -0
- package/src/reactor/promptAddonRegistry.ts +83 -5
- package/src/reactor/promptTemplatePreview.ts +240 -0
- package/src/reactor/reactorAvailability.ts +155 -0
- package/src/reactor/reactorSessionRefusal.ts +260 -0
- package/src/reactor/reactorTokenScope.ts +69 -0
- package/src/reactor/resolveDirectorBeats.ts +140 -0
- package/src/reactor/sanaLiveEdit.ts +158 -0
- package/src/reactor/sceneEntry.ts +106 -88
- package/src/reactor/sceneSeedImage.ts +338 -0
- package/src/reactor/seedImageOrchestrator.ts +116 -34
- package/src/reactor/toolPromptAddon.ts +66 -102
- package/src/reactor/worldMintLoop.ts +545 -0
- package/src/reactor/worldSteerOutcome.ts +132 -0
- package/src/retryAfter.ts +71 -0
- package/src/seriesKey.ts +42 -0
- package/src/sessionRefresh.ts +237 -0
- package/src/sharedAudioContext.ts +67 -0
- package/src/singleFlight.ts +91 -0
- package/src/storyGraph.ts +247 -4
- package/src/storyboardMask.ts +756 -0
- package/src/storyboardTimeline.ts +220 -0
- package/src/studioAutomation.ts +208 -0
- package/src/tenantClaim.ts +170 -0
- package/src/timeFormat.ts +51 -0
- package/src/toolSchemas.ts +39 -10
- package/src/transport.ts +327 -0
- package/src/videoGenFacade.ts +90 -0
- package/src/visemeScheduler.ts +36 -3
- package/src/vision/VisionPublisher.ts +204 -14
- package/src/vision/VisionSourceController.ts +187 -6
- package/src/vision/__tests__/VisionPublisher.kvs.test.ts +50 -0
- package/src/vision/__tests__/VisionPublisher.test.ts +291 -0
- package/src/vision/__tests__/VisionSourceController.test.ts +376 -6
- package/src/vision/index.ts +5 -1
- package/src/vision/sourceKinds.ts +19 -5
- package/src/vision/types.ts +7 -4
- package/src/vision/visionErrors.ts +70 -0
- package/src/voiceCloneCaption.ts +77 -0
- package/src/websocket.ts +542 -9
- package/src/workflowAuthoring.ts +664 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ChatSessionStore` + `ConversationTranscriptCache` (SP2 P1).
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic owners of the two pieces of conversation persistence that
|
|
5
|
+
* lived INLINE in `web/app/chat-ws/page.tsx` (the proven creator/debug
|
|
6
|
+
* reference) and so could not be reused by the dashboard persona floater or
|
|
7
|
+
* `../Web-App`:
|
|
8
|
+
*
|
|
9
|
+
* 1. **Backend `ChatSession` CRUD orchestration** — the create-on-first-send,
|
|
10
|
+
* list-for-persona, restore→normalized-turns, persist user/assistant
|
|
11
|
+
* sequencing that the page wired by hand around the raw `ApiClient` session
|
|
12
|
+
* methods. The raw HTTP calls already live on `ApiClient` (the single
|
|
13
|
+
* transport); this is the ORCHESTRATION (the order + the shape mapping)
|
|
14
|
+
* lifted into one place so every persona-chat surface gets identical
|
|
15
|
+
* session behavior. The store NEVER re-implements transport — it composes
|
|
16
|
+
* the existing `ApiClient` methods.
|
|
17
|
+
*
|
|
18
|
+
* 2. **`localStorage` transcript cache** — the `videoId`-keyed conversation
|
|
19
|
+
* map the page persisted under `seer-agent-ws-chat-conversations-v2`, with
|
|
20
|
+
* the same tail-pruning (`MAX_CONVERSATION_MESSAGES`). Generic over the
|
|
21
|
+
* renderer's own message shape so the React `Message`/Vue equivalents both
|
|
22
|
+
* reuse it; storage access is injected (so it is testable + SSR-safe) and
|
|
23
|
+
* defaults to `globalThis.localStorage`.
|
|
24
|
+
*
|
|
25
|
+
* DRY: this is the SINGLE source of truth for session-persistence orchestration
|
|
26
|
+
* and transcript caching. The chat-ws page (and the floater) CONSUME it; they no
|
|
27
|
+
* longer keep inline copies. Additive-only — published as a new minor; no public
|
|
28
|
+
* export is removed/renamed (`../Web-App` pins client-core).
|
|
29
|
+
*/
|
|
30
|
+
import type { AddMessageRequest, ChatSession, CreateSessionRequest } from '../api';
|
|
31
|
+
/**
|
|
32
|
+
* The subset of `ApiClient` the store composes. Declared structurally (not as
|
|
33
|
+
* `Pick<ApiClient, …>`) so the store stays framework-agnostic and trivially
|
|
34
|
+
* mockable in tests; the real `ApiClient` satisfies it.
|
|
35
|
+
*/
|
|
36
|
+
export interface ChatSessionApi {
|
|
37
|
+
createSession(data: CreateSessionRequest): Promise<ChatSession>;
|
|
38
|
+
listSessions(params?: {
|
|
39
|
+
limit?: number;
|
|
40
|
+
nextToken?: string;
|
|
41
|
+
personaId?: string;
|
|
42
|
+
}): Promise<{
|
|
43
|
+
sessions: ChatSession[];
|
|
44
|
+
}>;
|
|
45
|
+
getSession(sessionId: string): Promise<ChatSession>;
|
|
46
|
+
addMessageToSession(sessionId: string, data: AddMessageRequest): Promise<ChatSession>;
|
|
47
|
+
deleteSession(sessionId: string): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
/** Page default — list size for the persona-scoped session sidebar. */
|
|
50
|
+
export declare const DEFAULT_SESSION_LIST_LIMIT = 50;
|
|
51
|
+
/**
|
|
52
|
+
* A session message normalized into the minimal shape every renderer needs to
|
|
53
|
+
* rebuild its transcript. The renderer maps these into its own message type
|
|
54
|
+
* (adding presentation-only fields — citations, images, a model id, an id), so
|
|
55
|
+
* the store stays free of any renderer schema. Mirrors the chat-ws page's
|
|
56
|
+
* restore mapping (page.tsx:852-860): `role` is narrowed to the chat roles, the
|
|
57
|
+
* timestamp is resolved to epoch-ms (now() when the backend omitted it).
|
|
58
|
+
*/
|
|
59
|
+
export interface RestoredSessionMessage {
|
|
60
|
+
role: 'user' | 'assistant';
|
|
61
|
+
content: string;
|
|
62
|
+
/** Epoch ms — `new Date(msg.timestamp).getTime()`, or now() when absent. */
|
|
63
|
+
timestamp: number;
|
|
64
|
+
}
|
|
65
|
+
/** The result of restoring a session — the normalized turns plus the
|
|
66
|
+
* session-level context (video/persona) the renderer re-selects. */
|
|
67
|
+
export interface RestoredSession {
|
|
68
|
+
sessionId: string;
|
|
69
|
+
videoId: string | null;
|
|
70
|
+
personaId: string | null;
|
|
71
|
+
messages: RestoredSessionMessage[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Wraps the backend `ChatSession` CRUD with the chat-ws page's exact
|
|
75
|
+
* orchestration so any persona-chat surface persists sessions identically.
|
|
76
|
+
* Stateless beyond the injected `ApiClient` — the renderer still owns
|
|
77
|
+
* `currentSessionId` / the session list state (this only performs the calls +
|
|
78
|
+
* the shape mapping). Construct one per `ApiClient`.
|
|
79
|
+
*/
|
|
80
|
+
export declare class ChatSessionStore {
|
|
81
|
+
private readonly api;
|
|
82
|
+
constructor(api: ChatSessionApi);
|
|
83
|
+
/**
|
|
84
|
+
* Create a backend session for the given persona/video. Mirrors
|
|
85
|
+
* `handleCreateSession` (page.tsx:808-827): the title defaults to a localized
|
|
86
|
+
* `Chat <date>` when omitted, and `videoId` is sent as `null` when unset.
|
|
87
|
+
*/
|
|
88
|
+
createSession(args: {
|
|
89
|
+
personaId: string;
|
|
90
|
+
videoId?: string | null;
|
|
91
|
+
title?: string;
|
|
92
|
+
}): Promise<ChatSession>;
|
|
93
|
+
/**
|
|
94
|
+
* List the sessions for a persona (the sidebar source). Mirrors the page's
|
|
95
|
+
* `listSessions({ limit: 50, personaId })` calls — one place for the limit
|
|
96
|
+
* default + the persona scope. `personaId` is optional and only forwarded
|
|
97
|
+
* when truthy (mirrors the page's `personaId: selectedPersonaId || undefined`
|
|
98
|
+
* — an unset persona lists the user's sessions unscoped).
|
|
99
|
+
*/
|
|
100
|
+
listForPersona(personaId?: string, limit?: number): Promise<ChatSession[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Restore a session and normalize its messages. Mirrors
|
|
103
|
+
* `handleRestoreSession` (page.tsx:844-882) — the renderer maps the returned
|
|
104
|
+
* `RestoredSessionMessage[]` into its own message objects and re-selects the
|
|
105
|
+
* session's `videoId` / `personaId`.
|
|
106
|
+
*/
|
|
107
|
+
restore(sessionId: string): Promise<RestoredSession>;
|
|
108
|
+
/**
|
|
109
|
+
* Append one message (user or assistant) to a session. Mirrors
|
|
110
|
+
* `handleSaveMessageToBackend` (page.tsx:830-841) — the single backend-persist
|
|
111
|
+
* call. The renderer decides WHEN to persist (e.g. assistant on stream-end);
|
|
112
|
+
* this owns only the call shape.
|
|
113
|
+
*/
|
|
114
|
+
saveMessage(sessionId: string, role: 'user' | 'assistant', content: string): Promise<ChatSession>;
|
|
115
|
+
/** Delete a session (sidebar trash). Mirrors `handleDeleteSession`. */
|
|
116
|
+
delete(sessionId: string): Promise<void>;
|
|
117
|
+
}
|
|
118
|
+
/** Bump when the persisted shape changes (the page used `'v2'`). Kept here so
|
|
119
|
+
* the storage key is single-sourced across consumers. */
|
|
120
|
+
export declare const TRANSCRIPT_CACHE_VERSION = "v2";
|
|
121
|
+
/** The page's storage key (`seer-agent-ws-chat-conversations-v2`). Single
|
|
122
|
+
* source of truth so a consumer can never drift the key. */
|
|
123
|
+
export declare const TRANSCRIPT_CACHE_KEY = "seer-agent-ws-chat-conversations-v2";
|
|
124
|
+
/** Max persisted turns per conversation (the page's `MAX_CONVERSATION_MESSAGES`). */
|
|
125
|
+
export declare const MAX_CONVERSATION_MESSAGES = 50;
|
|
126
|
+
/** The minimal `Storage` surface the cache needs — `globalThis.localStorage`
|
|
127
|
+
* satisfies it; tests inject a fake; SSR injects nothing (the cache no-ops). */
|
|
128
|
+
export interface TranscriptStorage {
|
|
129
|
+
getItem(key: string): string | null;
|
|
130
|
+
setItem(key: string, value: string): void;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Tail-prune a transcript to at most `limit` messages — keep the most recent.
|
|
134
|
+
* Mirrors the page's `pruneMessages` (page.tsx:171-174). Pure; exported so a
|
|
135
|
+
* consumer can prune before render too.
|
|
136
|
+
*/
|
|
137
|
+
export declare function pruneMessages<T>(messages: readonly T[], limit?: number): T[];
|
|
138
|
+
/**
|
|
139
|
+
* The `videoId`-keyed localStorage transcript cache (`ConversationTranscriptCache`).
|
|
140
|
+
* Generic over the renderer's message type `M` (it persists whatever the
|
|
141
|
+
* renderer hands it). All access goes through the injected `TranscriptStorage`,
|
|
142
|
+
* so it is SSR-safe (omit storage ⇒ every method no-ops) and testable. Mirrors
|
|
143
|
+
* the page's load/save/clear localStorage effects (page.tsx:944-980, 1773-1783)
|
|
144
|
+
* EXACTLY: same key, same per-`videoId` map, same tail-pruning on save, same
|
|
145
|
+
* malformed-JSON tolerance.
|
|
146
|
+
*/
|
|
147
|
+
export declare class ConversationTranscriptCache<M> {
|
|
148
|
+
private readonly storage;
|
|
149
|
+
private readonly key;
|
|
150
|
+
private readonly limit;
|
|
151
|
+
constructor(opts?: {
|
|
152
|
+
/** Defaults to `globalThis.localStorage` when available, else undefined
|
|
153
|
+
* (no-op — SSR / tests without a fake). */
|
|
154
|
+
storage?: TranscriptStorage;
|
|
155
|
+
/** Override the storage key (defaults to {@link TRANSCRIPT_CACHE_KEY}). */
|
|
156
|
+
key?: string;
|
|
157
|
+
/** Override the per-conversation tail limit. */
|
|
158
|
+
limit?: number;
|
|
159
|
+
});
|
|
160
|
+
/** The whole `{ [videoId]: M[] }` map (or `{}` on absent/malformed JSON). */
|
|
161
|
+
private readAll;
|
|
162
|
+
/**
|
|
163
|
+
* Load the persisted transcript for one conversation. Returns `[]` for an
|
|
164
|
+
* absent/empty/malformed entry (mirrors page.tsx:945-968). An empty `videoId`
|
|
165
|
+
* also yields `[]` (the page treated falsy `selectedVideoId` as "no
|
|
166
|
+
* conversation").
|
|
167
|
+
*/
|
|
168
|
+
load(videoId: string): M[];
|
|
169
|
+
/**
|
|
170
|
+
* Persist a conversation's transcript (tail-pruned to the limit). No-op when
|
|
171
|
+
* `videoId` is empty or `messages` is empty — matching the page's save effect
|
|
172
|
+
* guard (page.tsx:972: `if (!selectedVideoId || messages.length === 0) return`).
|
|
173
|
+
*/
|
|
174
|
+
save(videoId: string, messages: readonly M[]): void;
|
|
175
|
+
/** Drop one conversation's transcript (the page's `clearConversation`). */
|
|
176
|
+
clear(videoId: string): void;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=chatSessionStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatSessionStore.d.ts","sourceRoot":"","sources":["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,QAAQ,CAAC,OAAO,CAAgC;IACxD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEnB,IAAI,CAAC,EAAE;QACjB;oDAC4C;QAC5C,OAAO,CAAC,EAAE,iBAAiB,CAAC;QAC5B,2EAA2E;QAC3E,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,gDAAgD;QAChD,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB;IAYD,6EAA6E;IAC7E,OAAO,CAAC,OAAO;IAYf;;;;;OAKG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,EAAE;IAM1B;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI;IAOnD,2EAA2E;IAC3E,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAO7B"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ChatSessionStore` + `ConversationTranscriptCache` (SP2 P1).
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic owners of the two pieces of conversation persistence that
|
|
5
|
+
* lived INLINE in `web/app/chat-ws/page.tsx` (the proven creator/debug
|
|
6
|
+
* reference) and so could not be reused by the dashboard persona floater or
|
|
7
|
+
* `../Web-App`:
|
|
8
|
+
*
|
|
9
|
+
* 1. **Backend `ChatSession` CRUD orchestration** — the create-on-first-send,
|
|
10
|
+
* list-for-persona, restore→normalized-turns, persist user/assistant
|
|
11
|
+
* sequencing that the page wired by hand around the raw `ApiClient` session
|
|
12
|
+
* methods. The raw HTTP calls already live on `ApiClient` (the single
|
|
13
|
+
* transport); this is the ORCHESTRATION (the order + the shape mapping)
|
|
14
|
+
* lifted into one place so every persona-chat surface gets identical
|
|
15
|
+
* session behavior. The store NEVER re-implements transport — it composes
|
|
16
|
+
* the existing `ApiClient` methods.
|
|
17
|
+
*
|
|
18
|
+
* 2. **`localStorage` transcript cache** — the `videoId`-keyed conversation
|
|
19
|
+
* map the page persisted under `seer-agent-ws-chat-conversations-v2`, with
|
|
20
|
+
* the same tail-pruning (`MAX_CONVERSATION_MESSAGES`). Generic over the
|
|
21
|
+
* renderer's own message shape so the React `Message`/Vue equivalents both
|
|
22
|
+
* reuse it; storage access is injected (so it is testable + SSR-safe) and
|
|
23
|
+
* defaults to `globalThis.localStorage`.
|
|
24
|
+
*
|
|
25
|
+
* DRY: this is the SINGLE source of truth for session-persistence orchestration
|
|
26
|
+
* and transcript caching. The chat-ws page (and the floater) CONSUME it; they no
|
|
27
|
+
* longer keep inline copies. Additive-only — published as a new minor; no public
|
|
28
|
+
* export is removed/renamed (`../Web-App` pins client-core).
|
|
29
|
+
*/
|
|
30
|
+
/** Page default — list size for the persona-scoped session sidebar. */
|
|
31
|
+
export const DEFAULT_SESSION_LIST_LIMIT = 50;
|
|
32
|
+
/**
|
|
33
|
+
* Wraps the backend `ChatSession` CRUD with the chat-ws page's exact
|
|
34
|
+
* orchestration so any persona-chat surface persists sessions identically.
|
|
35
|
+
* Stateless beyond the injected `ApiClient` — the renderer still owns
|
|
36
|
+
* `currentSessionId` / the session list state (this only performs the calls +
|
|
37
|
+
* the shape mapping). Construct one per `ApiClient`.
|
|
38
|
+
*/
|
|
39
|
+
export class ChatSessionStore {
|
|
40
|
+
api;
|
|
41
|
+
constructor(api) {
|
|
42
|
+
this.api = api;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create a backend session for the given persona/video. Mirrors
|
|
46
|
+
* `handleCreateSession` (page.tsx:808-827): the title defaults to a localized
|
|
47
|
+
* `Chat <date>` when omitted, and `videoId` is sent as `null` when unset.
|
|
48
|
+
*/
|
|
49
|
+
async createSession(args) {
|
|
50
|
+
return this.api.createSession({
|
|
51
|
+
persona_id: args.personaId,
|
|
52
|
+
video_id: args.videoId ?? null,
|
|
53
|
+
title: args.title ?? `Chat ${new Date().toLocaleDateString()}`,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* List the sessions for a persona (the sidebar source). Mirrors the page's
|
|
58
|
+
* `listSessions({ limit: 50, personaId })` calls — one place for the limit
|
|
59
|
+
* default + the persona scope. `personaId` is optional and only forwarded
|
|
60
|
+
* when truthy (mirrors the page's `personaId: selectedPersonaId || undefined`
|
|
61
|
+
* — an unset persona lists the user's sessions unscoped).
|
|
62
|
+
*/
|
|
63
|
+
async listForPersona(personaId, limit = DEFAULT_SESSION_LIST_LIMIT) {
|
|
64
|
+
const response = await this.api.listSessions({
|
|
65
|
+
limit,
|
|
66
|
+
...(personaId ? { personaId } : {}),
|
|
67
|
+
});
|
|
68
|
+
return response.sessions;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Restore a session and normalize its messages. Mirrors
|
|
72
|
+
* `handleRestoreSession` (page.tsx:844-882) — the renderer maps the returned
|
|
73
|
+
* `RestoredSessionMessage[]` into its own message objects and re-selects the
|
|
74
|
+
* session's `videoId` / `personaId`.
|
|
75
|
+
*/
|
|
76
|
+
async restore(sessionId) {
|
|
77
|
+
const session = await this.api.getSession(sessionId);
|
|
78
|
+
return {
|
|
79
|
+
sessionId: session.session_id,
|
|
80
|
+
videoId: session.video_id ?? null,
|
|
81
|
+
personaId: session.persona_id ?? null,
|
|
82
|
+
messages: session.messages.map((msg) => ({
|
|
83
|
+
role: msg.role,
|
|
84
|
+
content: msg.content,
|
|
85
|
+
timestamp: msg.timestamp ? new Date(msg.timestamp).getTime() : Date.now(),
|
|
86
|
+
})),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Append one message (user or assistant) to a session. Mirrors
|
|
91
|
+
* `handleSaveMessageToBackend` (page.tsx:830-841) — the single backend-persist
|
|
92
|
+
* call. The renderer decides WHEN to persist (e.g. assistant on stream-end);
|
|
93
|
+
* this owns only the call shape.
|
|
94
|
+
*/
|
|
95
|
+
async saveMessage(sessionId, role, content) {
|
|
96
|
+
return this.api.addMessageToSession(sessionId, { role, content });
|
|
97
|
+
}
|
|
98
|
+
/** Delete a session (sidebar trash). Mirrors `handleDeleteSession`. */
|
|
99
|
+
async delete(sessionId) {
|
|
100
|
+
await this.api.deleteSession(sessionId);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// ── localStorage transcript cache ───────────────────────────────────────────
|
|
104
|
+
/** Bump when the persisted shape changes (the page used `'v2'`). Kept here so
|
|
105
|
+
* the storage key is single-sourced across consumers. */
|
|
106
|
+
export const TRANSCRIPT_CACHE_VERSION = 'v2';
|
|
107
|
+
/** The page's storage key (`seer-agent-ws-chat-conversations-v2`). Single
|
|
108
|
+
* source of truth so a consumer can never drift the key. */
|
|
109
|
+
export const TRANSCRIPT_CACHE_KEY = `seer-agent-ws-chat-conversations-${TRANSCRIPT_CACHE_VERSION}`;
|
|
110
|
+
/** Max persisted turns per conversation (the page's `MAX_CONVERSATION_MESSAGES`). */
|
|
111
|
+
export const MAX_CONVERSATION_MESSAGES = 50;
|
|
112
|
+
/**
|
|
113
|
+
* Tail-prune a transcript to at most `limit` messages — keep the most recent.
|
|
114
|
+
* Mirrors the page's `pruneMessages` (page.tsx:171-174). Pure; exported so a
|
|
115
|
+
* consumer can prune before render too.
|
|
116
|
+
*/
|
|
117
|
+
export function pruneMessages(messages, limit = MAX_CONVERSATION_MESSAGES) {
|
|
118
|
+
if (messages.length <= limit)
|
|
119
|
+
return [...messages];
|
|
120
|
+
return messages.slice(-limit);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* The `videoId`-keyed localStorage transcript cache (`ConversationTranscriptCache`).
|
|
124
|
+
* Generic over the renderer's message type `M` (it persists whatever the
|
|
125
|
+
* renderer hands it). All access goes through the injected `TranscriptStorage`,
|
|
126
|
+
* so it is SSR-safe (omit storage ⇒ every method no-ops) and testable. Mirrors
|
|
127
|
+
* the page's load/save/clear localStorage effects (page.tsx:944-980, 1773-1783)
|
|
128
|
+
* EXACTLY: same key, same per-`videoId` map, same tail-pruning on save, same
|
|
129
|
+
* malformed-JSON tolerance.
|
|
130
|
+
*/
|
|
131
|
+
export class ConversationTranscriptCache {
|
|
132
|
+
storage;
|
|
133
|
+
key;
|
|
134
|
+
limit;
|
|
135
|
+
constructor(opts) {
|
|
136
|
+
this.storage =
|
|
137
|
+
opts?.storage ??
|
|
138
|
+
(typeof globalThis !== 'undefined' &&
|
|
139
|
+
globalThis.localStorage
|
|
140
|
+
? globalThis
|
|
141
|
+
.localStorage
|
|
142
|
+
: undefined);
|
|
143
|
+
this.key = opts?.key ?? TRANSCRIPT_CACHE_KEY;
|
|
144
|
+
this.limit = opts?.limit ?? MAX_CONVERSATION_MESSAGES;
|
|
145
|
+
}
|
|
146
|
+
/** The whole `{ [videoId]: M[] }` map (or `{}` on absent/malformed JSON). */
|
|
147
|
+
readAll() {
|
|
148
|
+
if (!this.storage)
|
|
149
|
+
return {};
|
|
150
|
+
const stored = this.storage.getItem(this.key);
|
|
151
|
+
if (!stored)
|
|
152
|
+
return {};
|
|
153
|
+
try {
|
|
154
|
+
const parsed = JSON.parse(stored);
|
|
155
|
+
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return {};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Load the persisted transcript for one conversation. Returns `[]` for an
|
|
163
|
+
* absent/empty/malformed entry (mirrors page.tsx:945-968). An empty `videoId`
|
|
164
|
+
* also yields `[]` (the page treated falsy `selectedVideoId` as "no
|
|
165
|
+
* conversation").
|
|
166
|
+
*/
|
|
167
|
+
load(videoId) {
|
|
168
|
+
if (!videoId)
|
|
169
|
+
return [];
|
|
170
|
+
const conversation = this.readAll()[videoId];
|
|
171
|
+
return Array.isArray(conversation) ? conversation : [];
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Persist a conversation's transcript (tail-pruned to the limit). No-op when
|
|
175
|
+
* `videoId` is empty or `messages` is empty — matching the page's save effect
|
|
176
|
+
* guard (page.tsx:972: `if (!selectedVideoId || messages.length === 0) return`).
|
|
177
|
+
*/
|
|
178
|
+
save(videoId, messages) {
|
|
179
|
+
if (!this.storage || !videoId || messages.length === 0)
|
|
180
|
+
return;
|
|
181
|
+
const all = this.readAll();
|
|
182
|
+
all[videoId] = pruneMessages(messages, this.limit);
|
|
183
|
+
this.storage.setItem(this.key, JSON.stringify(all));
|
|
184
|
+
}
|
|
185
|
+
/** Drop one conversation's transcript (the page's `clearConversation`). */
|
|
186
|
+
clear(videoId) {
|
|
187
|
+
if (!this.storage || !videoId)
|
|
188
|
+
return;
|
|
189
|
+
const all = this.readAll();
|
|
190
|
+
if (!(videoId in all))
|
|
191
|
+
return;
|
|
192
|
+
delete all[videoId];
|
|
193
|
+
this.storage.setItem(this.key, JSON.stringify(all));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=chatSessionStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatSessionStore.js","sourceRoot":"","sources":["../../src/conversation/chatSessionStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AA4BH,uEAAuE;AACvE,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AA0B7C;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IACE;IAA7B,YAA6B,GAAmB;QAAnB,QAAG,GAAH,GAAG,CAAgB;IAAG,CAAC;IAEpD;;;;OAIG;IACH,KAAK,CAAC,aAAa,CAAC,IAInB;QACC,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC;YAC5B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,QAAQ,EAAE,IAAI,CAAC,OAAO,IAAI,IAAI;YAC9B,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC,kBAAkB,EAAE,EAA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,CAAC,CAAC;QACpB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -48,6 +48,31 @@ export interface ConversationSendOptions {
|
|
|
48
48
|
* passes its prior turns here per send, exactly like the chat-ws page does.
|
|
49
49
|
*/
|
|
50
50
|
messages?: ConversationHistoryMessage[];
|
|
51
|
+
/**
|
|
52
|
+
* A per-send system-prompt override (SP1). When provided, it WINS over the
|
|
53
|
+
* binding's `systemPrompt` — matching `_merge_persona_into_hello`'s
|
|
54
|
+
* client-override-wins contract (a field the client explicitly sends is
|
|
55
|
+
* preserved over the persona's). Omit it and the binding's persona prompt
|
|
56
|
+
* (if any) rides instead; omit both and no prompt is sent (the backend uses
|
|
57
|
+
* the default assistant prompt — land-dark for non-persona conversations).
|
|
58
|
+
*/
|
|
59
|
+
systemPrompt?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Whether `opts.systemPrompt` REPLACES (`true`) or appends to (`false`/omitted)
|
|
62
|
+
* the default prompt. Only meaningful alongside an explicit `opts.systemPrompt`
|
|
63
|
+
* — it is NOT applied to the binding's prompt (the binding carries its own
|
|
64
|
+
* `systemPromptOverride`).
|
|
65
|
+
*/
|
|
66
|
+
systemPromptOverride?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* CHAT-U.3 — per-send keepalive overrides. Highest precedence in
|
|
69
|
+
* `composeSendOptions` (over the active participant's persona timings and the
|
|
70
|
+
* binding's), for a renderer that owns a keepalive control of its own — the
|
|
71
|
+
* `/chat-ws` shape, where the page holds the two values in state. Omit both
|
|
72
|
+
* (every caller today) and the participant/binding values ride instead.
|
|
73
|
+
*/
|
|
74
|
+
heartbeatInterval?: number;
|
|
75
|
+
idleTimeout?: number;
|
|
51
76
|
}
|
|
52
77
|
export interface ConversationControllerOptions {
|
|
53
78
|
binding: ConversationContextBinding;
|
|
@@ -87,6 +112,16 @@ export declare class ConversationController {
|
|
|
87
112
|
private readonly socket;
|
|
88
113
|
/** True iff the controller created `socket` (and must dispose it). */
|
|
89
114
|
private readonly ownsSocket;
|
|
115
|
+
/**
|
|
116
|
+
* Reconnect listeners (#471). Registered by a renderer that owns a
|
|
117
|
+
* `VoiceSession` over this controller's socket so it can re-prime voice after
|
|
118
|
+
* a socket reconnect. Fired AFTER the socket's own `onReconnected`, on an OWNED
|
|
119
|
+
* socket only — an ADOPTED socket's reconnect is the surface owner's concern
|
|
120
|
+
* (and the overlay decommissions an adopted session when that socket dies, so
|
|
121
|
+
* there is nothing to re-prime). A list so multiple listeners can register; each
|
|
122
|
+
* `onReconnected()` returns its own unsubscribe.
|
|
123
|
+
*/
|
|
124
|
+
private readonly reconnectListeners;
|
|
90
125
|
constructor(opts: ConversationControllerOptions);
|
|
91
126
|
/**
|
|
92
127
|
* Open the conversation: drive exactly ONE hello onto the socket, built only
|
|
@@ -121,6 +156,16 @@ export declare class ConversationController {
|
|
|
121
156
|
* `ChatWebSocket.send` — the controller never builds its own send frame.
|
|
122
157
|
*/
|
|
123
158
|
send(text: string, opts?: ConversationSendOptions): void;
|
|
159
|
+
/**
|
|
160
|
+
* Compose the per-turn `ChatWebSocket.send` options for the active binding +
|
|
161
|
+
* participant — the SINGLE place the send frame is shaped. Exposed so the SP1
|
|
162
|
+
* TTS-on-typed-input path (the panel's `VoiceSession.synthesizeReply`) sends a
|
|
163
|
+
* frame IDENTICAL to a normal text turn: same context scope, same persona
|
|
164
|
+
* prompt threading, same history — only the transport differs (the typed turn
|
|
165
|
+
* rides an already-armed `tts_stt` audio session so the reply is synthesized).
|
|
166
|
+
* No second composition site; `send()` and the synth path share this exactly.
|
|
167
|
+
*/
|
|
168
|
+
composeSendOptions(opts?: ConversationSendOptions): Parameters<ChatWebSocket['send']>[1];
|
|
124
169
|
/**
|
|
125
170
|
* Subscribe to the conversation socket's inbound JSON messages (`token`,
|
|
126
171
|
* `citation`, `done`, `error`, `turn_changed`, …) and return an unsubscribe
|
|
@@ -143,6 +188,21 @@ export declare class ConversationController {
|
|
|
143
188
|
* the transport). Works for both owned and adopted sockets.
|
|
144
189
|
*/
|
|
145
190
|
voiceSocket(): ChatWebSocket;
|
|
191
|
+
/**
|
|
192
|
+
* Register a listener fired after the controller's OWNED socket reconnects
|
|
193
|
+
* (#471). A renderer that drives a `VoiceSession` over `voiceSocket()` uses
|
|
194
|
+
* this to re-prime voice (`VoiceSession.handleReconnect()`) on a reconnect —
|
|
195
|
+
* the single re-prime path, mirroring the `/chat-ws` host's `onReconnected`
|
|
196
|
+
* wiring. Returns an unsubscribe.
|
|
197
|
+
*
|
|
198
|
+
* No-op registration on an ADOPTED socket (returns a no-op unsubscribe): the
|
|
199
|
+
* surface that constructed the adopted socket owns its reconnect callbacks, and
|
|
200
|
+
* the overlay decommissions an adopted session when that socket dies (#444), so
|
|
201
|
+
* the controller cannot (and need not) re-prime across an adopted reconnect.
|
|
202
|
+
*/
|
|
203
|
+
onReconnected(listener: () => void): () => void;
|
|
204
|
+
/** Fan the OWNED socket's reconnect out to registered listeners (#471). */
|
|
205
|
+
private emitReconnected;
|
|
146
206
|
/**
|
|
147
207
|
* The hello-args for the active binding + participant overlay — the SAME shape
|
|
148
208
|
* `buildHello()` spreads, exposed so a `VoiceSession` (R7.5) layers its voice
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/conversation/controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAEL,KAAK,uB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SAAS,EAAE,WAAW,GAAG,SAAS,CAAC;IAU1C,sEAAsE;IACtE,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKvC,+EAA+E;IAC/E,kBAAkB,IAAI,IAAI;IAK1B;;;;;;OAMG;IACH,qBAAqB,CACnB,MAAM,GAAE,SAAS,mBAAmB,EAAO,GAC1C,cAAc,GAAG,SAAS;IAa7B;;;;;OAKG;IACH,cAAc,CAAC,WAAW,EAAE,uBAAuB,GAAG,IAAI;IAc1D;;;;;OAKG;IACH,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAW9C;;;;;OAKG;IACH,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAUjD;;qFAEiF;IACjF,QAAQ,IAAI,oBAAoB;IAkBhC;;;;OAIG;IACH,OAAO,IAAI,IAAI;IAUf,OAAO,CAAC,iBAAiB;IAMzB;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAO7B,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,IAAI;CAGb"}
|
|
@@ -39,6 +39,16 @@ export class ConversationController {
|
|
|
39
39
|
socket;
|
|
40
40
|
/** True iff the controller created `socket` (and must dispose it). */
|
|
41
41
|
ownsSocket;
|
|
42
|
+
/**
|
|
43
|
+
* Reconnect listeners (#471). Registered by a renderer that owns a
|
|
44
|
+
* `VoiceSession` over this controller's socket so it can re-prime voice after
|
|
45
|
+
* a socket reconnect. Fired AFTER the socket's own `onReconnected`, on an OWNED
|
|
46
|
+
* socket only — an ADOPTED socket's reconnect is the surface owner's concern
|
|
47
|
+
* (and the overlay decommissions an adopted session when that socket dies, so
|
|
48
|
+
* there is nothing to re-prime). A list so multiple listeners can register; each
|
|
49
|
+
* `onReconnected()` returns its own unsubscribe.
|
|
50
|
+
*/
|
|
51
|
+
reconnectListeners = new Set();
|
|
42
52
|
constructor(opts) {
|
|
43
53
|
this.participants = [...(opts.participants ?? [])];
|
|
44
54
|
this.activeParticipantId = this.participants[0]?.participantId;
|
|
@@ -55,7 +65,18 @@ export class ConversationController {
|
|
|
55
65
|
if (!opts.socketOptions) {
|
|
56
66
|
throw new Error('ConversationController: socketOptions is required when no existingSocket is provided.');
|
|
57
67
|
}
|
|
58
|
-
|
|
68
|
+
// Compose the caller's `onReconnected` with the controller's reconnect
|
|
69
|
+
// fan-out (#471) so a renderer can register a `VoiceSession` re-prime
|
|
70
|
+
// listener without the caller threading a callback through socketOptions.
|
|
71
|
+
// The caller's hook (if any) still fires first; then the listeners.
|
|
72
|
+
const callerOnReconnected = opts.socketOptions.onReconnected;
|
|
73
|
+
this.socket = new ChatWebSocket({
|
|
74
|
+
...opts.socketOptions,
|
|
75
|
+
onReconnected: () => {
|
|
76
|
+
callerOnReconnected?.();
|
|
77
|
+
this.emitReconnected();
|
|
78
|
+
},
|
|
79
|
+
});
|
|
59
80
|
this.ownsSocket = true;
|
|
60
81
|
}
|
|
61
82
|
// Seed the binding with the party roster derived from the initial roster so
|
|
@@ -144,10 +165,43 @@ export class ConversationController {
|
|
|
144
165
|
if (!this.connected) {
|
|
145
166
|
throw new Error('ConversationController: call connect() before send().');
|
|
146
167
|
}
|
|
168
|
+
this.socket.send(text, this.composeSendOptions(opts));
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Compose the per-turn `ChatWebSocket.send` options for the active binding +
|
|
172
|
+
* participant — the SINGLE place the send frame is shaped. Exposed so the SP1
|
|
173
|
+
* TTS-on-typed-input path (the panel's `VoiceSession.synthesizeReply`) sends a
|
|
174
|
+
* frame IDENTICAL to a normal text turn: same context scope, same persona
|
|
175
|
+
* prompt threading, same history — only the transport differs (the typed turn
|
|
176
|
+
* rides an already-armed `tts_stt` audio session so the reply is synthesized).
|
|
177
|
+
* No second composition site; `send()` and the synth path share this exactly.
|
|
178
|
+
*/
|
|
179
|
+
composeSendOptions(opts) {
|
|
147
180
|
const active = this.activeParticipant();
|
|
148
181
|
const args = this.toHelloArgs();
|
|
149
182
|
const modelId = this.modelOverride ?? active?.modelId;
|
|
150
|
-
|
|
183
|
+
// Persona system-prompt (SP1): the `text` send path reads the prompt from
|
|
184
|
+
// THIS frame (it does NOT load the persona server-side — only the `tts_stt`
|
|
185
|
+
// hello does, via `_merge_persona_into_hello`), so a standalone persona chat
|
|
186
|
+
// must thread its prompt on every typed turn or the reply comes back in the
|
|
187
|
+
// default assistant voice. CLIENT-OVERRIDE-WINS, by PRESENCE not truthiness:
|
|
188
|
+
// an explicitly provided `opts.systemPrompt` beats the binding's prompt
|
|
189
|
+
// (mirrors `_merge_persona_into_hello`: a field the client sends is preserved
|
|
190
|
+
// over the persona's). A nullish check (not `||`) means an explicit EMPTY
|
|
191
|
+
// STRING still wins — it clears the bound prompt for this send (the falsy-drop
|
|
192
|
+
// gate below then emits no prompt key), which `||` could not express (it would
|
|
193
|
+
// fall back to the binding). Both nullish on opts ⇒ the binding's prompt rides;
|
|
194
|
+
// falsy on the resolved value ⇒ no prompt key (byte-identical, land-dark for
|
|
195
|
+
// non-persona conversations).
|
|
196
|
+
const systemPrompt = opts?.systemPrompt ?? args.systemPrompt;
|
|
197
|
+
const systemPromptOverride = opts?.systemPrompt != null
|
|
198
|
+
? (opts.systemPromptOverride ?? false)
|
|
199
|
+
: (args.systemPromptOverride ?? false);
|
|
200
|
+
const heartbeatInterval = opts?.heartbeatInterval ??
|
|
201
|
+
active?.heartbeatInterval ??
|
|
202
|
+
this.binding.heartbeatInterval;
|
|
203
|
+
const idleTimeout = opts?.idleTimeout ?? active?.idleTimeout ?? this.binding.idleTimeout;
|
|
204
|
+
return {
|
|
151
205
|
...(args.videoId ? { videoId: args.videoId } : {}),
|
|
152
206
|
...(args.entityId ? { entityId: args.entityId } : {}),
|
|
153
207
|
...(args.adventureSessionId
|
|
@@ -164,10 +218,27 @@ export class ConversationController {
|
|
|
164
218
|
...(args.personaId ? { personaId: args.personaId } : {}),
|
|
165
219
|
...(active?.personaId ? { personaId: active.personaId } : {}),
|
|
166
220
|
...(modelId ? { modelId } : {}),
|
|
221
|
+
// Persona prompt rides every typed turn (SP1) so the reply is in-character.
|
|
222
|
+
// Both keys travel together (gated on the resolved prompt), matching the
|
|
223
|
+
// `buildHelloPayload`/`SendActionMessage` shape where `systemPromptOverride`
|
|
224
|
+
// is meaningless without `systemPrompt`.
|
|
225
|
+
...(systemPrompt ? { systemPrompt, systemPromptOverride } : {}),
|
|
167
226
|
// Omitted when empty so a zero-history send stays byte-identical to the
|
|
168
227
|
// pre-0.30.0 wire (the backend defaults a missing `messages` to []).
|
|
169
228
|
...(opts?.messages?.length ? { messages: opts.messages } : {}),
|
|
170
|
-
|
|
229
|
+
// CHAT-U.3 — the keepalive pair `/chat-ws` has always sent from its
|
|
230
|
+
// selected persona (`page.tsx` `options.heartbeatInterval/idleTimeout`),
|
|
231
|
+
// which the self-driving panel omitted: a persona configured for a long
|
|
232
|
+
// idle timeout still got the server's 120s default and had its socket
|
|
233
|
+
// reaped mid-turn. PRECEDENCE, highest first: an explicit per-send
|
|
234
|
+
// `opts` value > the ACTIVE participant's persona timings > the
|
|
235
|
+
// conversation binding's. Nullish (not `||`) so an explicit `0`
|
|
236
|
+
// heartbeat — the documented "disable keepalive, I have my own" value —
|
|
237
|
+
// survives instead of falling back. All three absent ⇒ no key on the
|
|
238
|
+
// wire (byte-identical; the backend applies 30s/120s).
|
|
239
|
+
...(heartbeatInterval != null ? { heartbeatInterval } : {}),
|
|
240
|
+
...(idleTimeout != null ? { idleTimeout } : {}),
|
|
241
|
+
};
|
|
171
242
|
}
|
|
172
243
|
/**
|
|
173
244
|
* Subscribe to the conversation socket's inbound JSON messages (`token`,
|
|
@@ -196,6 +267,36 @@ export class ConversationController {
|
|
|
196
267
|
voiceSocket() {
|
|
197
268
|
return this.socket;
|
|
198
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Register a listener fired after the controller's OWNED socket reconnects
|
|
272
|
+
* (#471). A renderer that drives a `VoiceSession` over `voiceSocket()` uses
|
|
273
|
+
* this to re-prime voice (`VoiceSession.handleReconnect()`) on a reconnect —
|
|
274
|
+
* the single re-prime path, mirroring the `/chat-ws` host's `onReconnected`
|
|
275
|
+
* wiring. Returns an unsubscribe.
|
|
276
|
+
*
|
|
277
|
+
* No-op registration on an ADOPTED socket (returns a no-op unsubscribe): the
|
|
278
|
+
* surface that constructed the adopted socket owns its reconnect callbacks, and
|
|
279
|
+
* the overlay decommissions an adopted session when that socket dies (#444), so
|
|
280
|
+
* the controller cannot (and need not) re-prime across an adopted reconnect.
|
|
281
|
+
*/
|
|
282
|
+
onReconnected(listener) {
|
|
283
|
+
if (!this.ownsSocket)
|
|
284
|
+
return () => { };
|
|
285
|
+
this.reconnectListeners.add(listener);
|
|
286
|
+
return () => this.reconnectListeners.delete(listener);
|
|
287
|
+
}
|
|
288
|
+
/** Fan the OWNED socket's reconnect out to registered listeners (#471). */
|
|
289
|
+
emitReconnected() {
|
|
290
|
+
for (const listener of this.reconnectListeners) {
|
|
291
|
+
try {
|
|
292
|
+
listener();
|
|
293
|
+
}
|
|
294
|
+
catch (err) {
|
|
295
|
+
// A faulty listener must not break the others or the socket's reconnect.
|
|
296
|
+
console.error('ConversationController: onReconnected listener threw', err);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
199
300
|
/**
|
|
200
301
|
* The hello-args for the active binding + participant overlay — the SAME shape
|
|
201
302
|
* `buildHello()` spreads, exposed so a `VoiceSession` (R7.5) layers its voice
|