@escapeaihq/client-core 0.52.0 → 0.139.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.
Files changed (782) hide show
  1. package/README.md +445 -153
  2. package/dist/adapters/capabilities.d.ts +20 -3
  3. package/dist/adapters/capabilities.d.ts.map +1 -1
  4. package/dist/adapters/directorAdapter.d.ts +5 -4
  5. package/dist/adapters/directorAdapter.d.ts.map +1 -1
  6. package/dist/adapters/directorAdapter.js +5 -4
  7. package/dist/adapters/directorAdapter.js.map +1 -1
  8. package/dist/adapters/experienceModelCatalog.d.ts +382 -0
  9. package/dist/adapters/experienceModelCatalog.d.ts.map +1 -0
  10. package/dist/adapters/experienceModelCatalog.js +401 -0
  11. package/dist/adapters/experienceModelCatalog.js.map +1 -0
  12. package/dist/adapters/extractionAdapter.d.ts +81 -0
  13. package/dist/adapters/extractionAdapter.d.ts.map +1 -0
  14. package/dist/adapters/extractionAdapter.js +98 -0
  15. package/dist/adapters/extractionAdapter.js.map +1 -0
  16. package/dist/adapters/imageAdapter.d.ts +5 -1
  17. package/dist/adapters/imageAdapter.d.ts.map +1 -1
  18. package/dist/adapters/imageAdapter.js +5 -1
  19. package/dist/adapters/imageAdapter.js.map +1 -1
  20. package/dist/adapters/index.d.ts +54 -16
  21. package/dist/adapters/index.d.ts.map +1 -1
  22. package/dist/adapters/index.js +62 -11
  23. package/dist/adapters/index.js.map +1 -1
  24. package/dist/adapters/momentDirective.d.ts +66 -0
  25. package/dist/adapters/momentDirective.d.ts.map +1 -0
  26. package/dist/adapters/momentDirective.js +78 -0
  27. package/dist/adapters/momentDirective.js.map +1 -0
  28. package/dist/adapters/momentPolicy.d.ts +132 -0
  29. package/dist/adapters/momentPolicy.d.ts.map +1 -0
  30. package/dist/adapters/momentPolicy.js +165 -0
  31. package/dist/adapters/momentPolicy.js.map +1 -0
  32. package/dist/adapters/registry.d.ts +1 -1
  33. package/dist/adapters/registry.d.ts.map +1 -1
  34. package/dist/adapters/videoGenAdapter.d.ts +55 -0
  35. package/dist/adapters/videoGenAdapter.d.ts.map +1 -0
  36. package/dist/adapters/videoGenAdapter.js +78 -0
  37. package/dist/adapters/videoGenAdapter.js.map +1 -0
  38. package/dist/adapters/worldAdapter.d.ts +132 -11
  39. package/dist/adapters/worldAdapter.d.ts.map +1 -1
  40. package/dist/adapters/worldAdapter.js +127 -11
  41. package/dist/adapters/worldAdapter.js.map +1 -1
  42. package/dist/adapters/worldModelPreference.d.ts +173 -0
  43. package/dist/adapters/worldModelPreference.d.ts.map +1 -0
  44. package/dist/adapters/worldModelPreference.js +209 -0
  45. package/dist/adapters/worldModelPreference.js.map +1 -0
  46. package/dist/adapters/worldModelTradeoffs.d.ts +120 -0
  47. package/dist/adapters/worldModelTradeoffs.d.ts.map +1 -0
  48. package/dist/adapters/worldModelTradeoffs.js +154 -0
  49. package/dist/adapters/worldModelTradeoffs.js.map +1 -0
  50. package/dist/admin.d.ts +545 -0
  51. package/dist/admin.d.ts.map +1 -1
  52. package/dist/admin.js +230 -16
  53. package/dist/admin.js.map +1 -1
  54. package/dist/api.d.ts +10295 -2216
  55. package/dist/api.d.ts.map +1 -1
  56. package/dist/api.js +4187 -1240
  57. package/dist/api.js.map +1 -1
  58. package/dist/arcBoardJoin.d.ts +38 -0
  59. package/dist/arcBoardJoin.d.ts.map +1 -0
  60. package/dist/arcBoardJoin.js +37 -0
  61. package/dist/arcBoardJoin.js.map +1 -0
  62. package/dist/arcPreview.d.ts +49 -0
  63. package/dist/arcPreview.d.ts.map +1 -0
  64. package/dist/arcPreview.js +65 -0
  65. package/dist/arcPreview.js.map +1 -0
  66. package/dist/audio.d.ts +259 -16
  67. package/dist/audio.d.ts.map +1 -1
  68. package/dist/audio.js +605 -114
  69. package/dist/audio.js.map +1 -1
  70. package/dist/audioDsp.d.ts +45 -0
  71. package/dist/audioDsp.d.ts.map +1 -0
  72. package/dist/audioDsp.js +108 -0
  73. package/dist/audioDsp.js.map +1 -0
  74. package/dist/audioProtocol.d.ts +160 -0
  75. package/dist/audioProtocol.d.ts.map +1 -1
  76. package/dist/audioProtocol.js +99 -0
  77. package/dist/audioProtocol.js.map +1 -1
  78. package/dist/beatTitles.d.ts +33 -0
  79. package/dist/beatTitles.d.ts.map +1 -0
  80. package/dist/beatTitles.js +39 -0
  81. package/dist/beatTitles.js.map +1 -0
  82. package/dist/castProjection.d.ts +204 -1
  83. package/dist/castProjection.d.ts.map +1 -1
  84. package/dist/castProjection.js +202 -0
  85. package/dist/castProjection.js.map +1 -1
  86. package/dist/characterGrounding.d.ts +369 -0
  87. package/dist/characterGrounding.d.ts.map +1 -0
  88. package/dist/characterGrounding.js +408 -0
  89. package/dist/characterGrounding.js.map +1 -0
  90. package/dist/conversation/binding.d.ts +13 -0
  91. package/dist/conversation/binding.d.ts.map +1 -1
  92. package/dist/conversation/binding.js.map +1 -1
  93. package/dist/conversation/chatSessionStore.d.ts +178 -0
  94. package/dist/conversation/chatSessionStore.d.ts.map +1 -0
  95. package/dist/conversation/chatSessionStore.js +196 -0
  96. package/dist/conversation/chatSessionStore.js.map +1 -0
  97. package/dist/conversation/controller.d.ts +44 -0
  98. package/dist/conversation/controller.d.ts.map +1 -1
  99. package/dist/conversation/controller.js +82 -3
  100. package/dist/conversation/controller.js.map +1 -1
  101. package/dist/conversation/index.d.ts +2 -0
  102. package/dist/conversation/index.d.ts.map +1 -1
  103. package/dist/conversation/index.js +2 -0
  104. package/dist/conversation/index.js.map +1 -1
  105. package/dist/conversation/participant.d.ts +16 -0
  106. package/dist/conversation/participant.d.ts.map +1 -1
  107. package/dist/conversation/readSequencer.d.ts +38 -0
  108. package/dist/conversation/readSequencer.d.ts.map +1 -0
  109. package/dist/conversation/readSequencer.js +42 -0
  110. package/dist/conversation/readSequencer.js.map +1 -0
  111. package/dist/conversation/roster.d.ts +5 -1
  112. package/dist/conversation/roster.d.ts.map +1 -1
  113. package/dist/conversation/roster.js.map +1 -1
  114. package/dist/conversation/rosterProjection.d.ts +74 -1
  115. package/dist/conversation/rosterProjection.d.ts.map +1 -1
  116. package/dist/conversation/rosterProjection.js +135 -1
  117. package/dist/conversation/rosterProjection.js.map +1 -1
  118. package/dist/conversation/runtime.d.ts +20 -3
  119. package/dist/conversation/runtime.d.ts.map +1 -1
  120. package/dist/conversation/runtime.js +66 -7
  121. package/dist/conversation/runtime.js.map +1 -1
  122. package/dist/conversation/types.d.ts +43 -4
  123. package/dist/conversation/types.d.ts.map +1 -1
  124. package/dist/conversation/voice.d.ts +290 -13
  125. package/dist/conversation/voice.d.ts.map +1 -1
  126. package/dist/conversation/voice.js +565 -42
  127. package/dist/conversation/voice.js.map +1 -1
  128. package/dist/creatorCuration.d.ts +134 -0
  129. package/dist/creatorCuration.d.ts.map +1 -0
  130. package/dist/creatorCuration.js +228 -0
  131. package/dist/creatorCuration.js.map +1 -0
  132. package/dist/creatorDashboard.d.ts +155 -0
  133. package/dist/creatorDashboard.d.ts.map +1 -0
  134. package/dist/creatorDashboard.js +237 -0
  135. package/dist/creatorDashboard.js.map +1 -0
  136. package/dist/creatorUniverse.d.ts +95 -0
  137. package/dist/creatorUniverse.d.ts.map +1 -0
  138. package/dist/creatorUniverse.js +136 -0
  139. package/dist/creatorUniverse.js.map +1 -0
  140. package/dist/curationWrite.d.ts +76 -0
  141. package/dist/curationWrite.d.ts.map +1 -0
  142. package/dist/curationWrite.js +106 -0
  143. package/dist/curationWrite.js.map +1 -0
  144. package/dist/designTokens.d.ts +64 -0
  145. package/dist/designTokens.d.ts.map +1 -0
  146. package/dist/designTokens.js +117 -0
  147. package/dist/designTokens.js.map +1 -0
  148. package/dist/dialogAttribution.d.ts +79 -0
  149. package/dist/dialogAttribution.d.ts.map +1 -0
  150. package/dist/dialogAttribution.js +144 -0
  151. package/dist/dialogAttribution.js.map +1 -0
  152. package/dist/dmRunWorldReadiness.d.ts +605 -0
  153. package/dist/dmRunWorldReadiness.d.ts.map +1 -0
  154. package/dist/dmRunWorldReadiness.js +775 -0
  155. package/dist/dmRunWorldReadiness.js.map +1 -0
  156. package/dist/domains/access.d.ts +32 -0
  157. package/dist/domains/access.d.ts.map +1 -0
  158. package/dist/domains/access.js +43 -0
  159. package/dist/domains/access.js.map +1 -0
  160. package/dist/domains/adventureDefinitions.d.ts +159 -0
  161. package/dist/domains/adventureDefinitions.d.ts.map +1 -0
  162. package/dist/domains/adventureDefinitions.js +168 -0
  163. package/dist/domains/adventureDefinitions.js.map +1 -0
  164. package/dist/domains/adventures.d.ts +329 -0
  165. package/dist/domains/adventures.d.ts.map +1 -0
  166. package/dist/domains/adventures.js +359 -0
  167. package/dist/domains/adventures.js.map +1 -0
  168. package/dist/domains/arcs.d.ts +146 -0
  169. package/dist/domains/arcs.d.ts.map +1 -0
  170. package/dist/domains/arcs.js +202 -0
  171. package/dist/domains/arcs.js.map +1 -0
  172. package/dist/domains/artifacts.d.ts +259 -0
  173. package/dist/domains/artifacts.d.ts.map +1 -0
  174. package/dist/domains/artifacts.js +125 -0
  175. package/dist/domains/artifacts.js.map +1 -0
  176. package/dist/domains/chat.d.ts +158 -0
  177. package/dist/domains/chat.d.ts.map +1 -0
  178. package/dist/domains/chat.js +224 -0
  179. package/dist/domains/chat.js.map +1 -0
  180. package/dist/domains/decisions.d.ts +31 -0
  181. package/dist/domains/decisions.d.ts.map +1 -0
  182. package/dist/domains/decisions.js +42 -0
  183. package/dist/domains/decisions.js.map +1 -0
  184. package/dist/domains/documents.d.ts +218 -0
  185. package/dist/domains/documents.d.ts.map +1 -0
  186. package/dist/domains/documents.js +252 -0
  187. package/dist/domains/documents.js.map +1 -0
  188. package/dist/domains/enhancements.d.ts +106 -0
  189. package/dist/domains/enhancements.d.ts.map +1 -0
  190. package/dist/domains/enhancements.js +160 -0
  191. package/dist/domains/enhancements.js.map +1 -0
  192. package/dist/domains/graph.d.ts +454 -0
  193. package/dist/domains/graph.d.ts.map +1 -0
  194. package/dist/domains/graph.js +648 -0
  195. package/dist/domains/graph.js.map +1 -0
  196. package/dist/domains/images.d.ts +220 -0
  197. package/dist/domains/images.d.ts.map +1 -0
  198. package/dist/domains/images.js +307 -0
  199. package/dist/domains/images.js.map +1 -0
  200. package/dist/domains/ingestion.d.ts +312 -0
  201. package/dist/domains/ingestion.d.ts.map +1 -0
  202. package/dist/domains/ingestion.js +495 -0
  203. package/dist/domains/ingestion.js.map +1 -0
  204. package/dist/domains/me.d.ts +21 -0
  205. package/dist/domains/me.d.ts.map +1 -0
  206. package/dist/domains/me.js +23 -0
  207. package/dist/domains/me.js.map +1 -0
  208. package/dist/domains/orgs.d.ts +47 -0
  209. package/dist/domains/orgs.d.ts.map +1 -0
  210. package/dist/domains/orgs.js +75 -0
  211. package/dist/domains/orgs.js.map +1 -0
  212. package/dist/domains/personas.d.ts +138 -0
  213. package/dist/domains/personas.d.ts.map +1 -0
  214. package/dist/domains/personas.js +322 -0
  215. package/dist/domains/personas.js.map +1 -0
  216. package/dist/domains/projects.d.ts +53 -0
  217. package/dist/domains/projects.d.ts.map +1 -0
  218. package/dist/domains/projects.js +94 -0
  219. package/dist/domains/projects.js.map +1 -0
  220. package/dist/domains/quests.d.ts +431 -0
  221. package/dist/domains/quests.d.ts.map +1 -0
  222. package/dist/domains/quests.js +61 -0
  223. package/dist/domains/quests.js.map +1 -0
  224. package/dist/domains/reactor.d.ts +98 -0
  225. package/dist/domains/reactor.d.ts.map +1 -0
  226. package/dist/domains/reactor.js +131 -0
  227. package/dist/domains/reactor.js.map +1 -0
  228. package/dist/domains/showcase.d.ts +28 -0
  229. package/dist/domains/showcase.d.ts.map +1 -0
  230. package/dist/domains/showcase.js +28 -0
  231. package/dist/domains/showcase.js.map +1 -0
  232. package/dist/domains/storyboards.d.ts +1253 -0
  233. package/dist/domains/storyboards.d.ts.map +1 -0
  234. package/dist/domains/storyboards.js +781 -0
  235. package/dist/domains/storyboards.js.map +1 -0
  236. package/dist/domains/studioSettings.d.ts +39 -0
  237. package/dist/domains/studioSettings.d.ts.map +1 -0
  238. package/dist/domains/studioSettings.js +80 -0
  239. package/dist/domains/studioSettings.js.map +1 -0
  240. package/dist/domains/universes.d.ts +191 -0
  241. package/dist/domains/universes.d.ts.map +1 -0
  242. package/dist/domains/universes.js +276 -0
  243. package/dist/domains/universes.js.map +1 -0
  244. package/dist/domains/userDefaults.d.ts +18 -0
  245. package/dist/domains/userDefaults.d.ts.map +1 -0
  246. package/dist/domains/userDefaults.js +27 -0
  247. package/dist/domains/userDefaults.js.map +1 -0
  248. package/dist/domains/visemeBundles.d.ts +262 -0
  249. package/dist/domains/visemeBundles.d.ts.map +1 -0
  250. package/dist/domains/visemeBundles.js +373 -0
  251. package/dist/domains/visemeBundles.js.map +1 -0
  252. package/dist/domains/workflows.d.ts +142 -0
  253. package/dist/domains/workflows.d.ts.map +1 -0
  254. package/dist/domains/workflows.js +245 -0
  255. package/dist/domains/workflows.js.map +1 -0
  256. package/dist/enhancementDiff.d.ts +56 -0
  257. package/dist/enhancementDiff.d.ts.map +1 -0
  258. package/dist/enhancementDiff.js +110 -0
  259. package/dist/enhancementDiff.js.map +1 -0
  260. package/dist/generated/contract.d.ts +372 -0
  261. package/dist/generated/contract.d.ts.map +1 -0
  262. package/dist/generated/contract.js +395 -0
  263. package/dist/generated/contract.js.map +1 -0
  264. package/dist/graphSchema.d.ts +36 -5
  265. package/dist/graphSchema.d.ts.map +1 -1
  266. package/dist/graphSchema.js +88 -2
  267. package/dist/graphSchema.js.map +1 -1
  268. package/dist/http.d.ts +70 -1
  269. package/dist/http.d.ts.map +1 -1
  270. package/dist/http.js +263 -11
  271. package/dist/http.js.map +1 -1
  272. package/dist/identity.d.ts +81 -0
  273. package/dist/identity.d.ts.map +1 -0
  274. package/dist/identity.js +65 -0
  275. package/dist/identity.js.map +1 -0
  276. package/dist/index.d.ts +35 -0
  277. package/dist/index.d.ts.map +1 -1
  278. package/dist/index.js +118 -0
  279. package/dist/index.js.map +1 -1
  280. package/dist/messageContent.d.ts +174 -0
  281. package/dist/messageContent.d.ts.map +1 -0
  282. package/dist/messageContent.js +405 -0
  283. package/dist/messageContent.js.map +1 -0
  284. package/dist/mutationEpoch.d.ts +83 -0
  285. package/dist/mutationEpoch.d.ts.map +1 -0
  286. package/dist/mutationEpoch.js +109 -0
  287. package/dist/mutationEpoch.js.map +1 -0
  288. package/dist/obo.d.ts +144 -0
  289. package/dist/obo.d.ts.map +1 -0
  290. package/dist/obo.js +135 -0
  291. package/dist/obo.js.map +1 -0
  292. package/dist/opusTransport.d.ts +113 -0
  293. package/dist/opusTransport.d.ts.map +1 -0
  294. package/dist/opusTransport.js +170 -0
  295. package/dist/opusTransport.js.map +1 -0
  296. package/dist/pagination.d.ts +18 -0
  297. package/dist/pagination.d.ts.map +1 -0
  298. package/dist/pagination.js +26 -0
  299. package/dist/pagination.js.map +1 -0
  300. package/dist/platformAssistant.d.ts +55 -1
  301. package/dist/platformAssistant.d.ts.map +1 -1
  302. package/dist/platformAssistant.js +39 -1
  303. package/dist/platformAssistant.js.map +1 -1
  304. package/dist/pollUtils.d.ts +19 -0
  305. package/dist/pollUtils.d.ts.map +1 -0
  306. package/dist/pollUtils.js +35 -0
  307. package/dist/pollUtils.js.map +1 -0
  308. package/dist/questLog.d.ts +232 -0
  309. package/dist/questLog.d.ts.map +1 -0
  310. package/dist/questLog.js +522 -0
  311. package/dist/questLog.js.map +1 -0
  312. package/dist/reactor/dmDirectiveToExperience.d.ts +300 -0
  313. package/dist/reactor/dmDirectiveToExperience.d.ts.map +1 -0
  314. package/dist/reactor/dmDirectiveToExperience.js +401 -0
  315. package/dist/reactor/dmDirectiveToExperience.js.map +1 -0
  316. package/dist/reactor/dmSceneControlPrompt.d.ts.map +1 -1
  317. package/dist/reactor/dmSceneControlPrompt.js +64 -2
  318. package/dist/reactor/dmSceneControlPrompt.js.map +1 -1
  319. package/dist/reactor/dmWorldEntry.d.ts +1278 -0
  320. package/dist/reactor/dmWorldEntry.d.ts.map +1 -0
  321. package/dist/reactor/dmWorldEntry.js +1396 -0
  322. package/dist/reactor/dmWorldEntry.js.map +1 -0
  323. package/dist/reactor/framePromptCompaction.d.ts +223 -0
  324. package/dist/reactor/framePromptCompaction.d.ts.map +1 -0
  325. package/dist/reactor/framePromptCompaction.js +393 -0
  326. package/dist/reactor/framePromptCompaction.js.map +1 -0
  327. package/dist/reactor/frameWorldBind.d.ts +86 -0
  328. package/dist/reactor/frameWorldBind.d.ts.map +1 -0
  329. package/dist/reactor/frameWorldBind.js +79 -0
  330. package/dist/reactor/frameWorldBind.js.map +1 -0
  331. package/dist/reactor/happyOysterSeed.d.ts +166 -0
  332. package/dist/reactor/happyOysterSeed.d.ts.map +1 -0
  333. package/dist/reactor/happyOysterSeed.js +233 -0
  334. package/dist/reactor/happyOysterSeed.js.map +1 -0
  335. package/dist/reactor/happyOysterWalk.d.ts +274 -0
  336. package/dist/reactor/happyOysterWalk.d.ts.map +1 -0
  337. package/dist/reactor/happyOysterWalk.js +407 -0
  338. package/dist/reactor/happyOysterWalk.js.map +1 -0
  339. package/dist/reactor/happyOysterWorld.d.ts +718 -0
  340. package/dist/reactor/happyOysterWorld.d.ts.map +1 -0
  341. package/dist/reactor/happyOysterWorld.js +826 -0
  342. package/dist/reactor/happyOysterWorld.js.map +1 -0
  343. package/dist/reactor/heliosCommandDispatcher.d.ts.map +1 -1
  344. package/dist/reactor/heliosCommandDispatcher.js +5 -2
  345. package/dist/reactor/heliosCommandDispatcher.js.map +1 -1
  346. package/dist/reactor/hiddenWorldLifecycle.d.ts +101 -0
  347. package/dist/reactor/hiddenWorldLifecycle.d.ts.map +1 -0
  348. package/dist/reactor/hiddenWorldLifecycle.js +119 -0
  349. package/dist/reactor/hiddenWorldLifecycle.js.map +1 -0
  350. package/dist/reactor/imageCanvas.d.ts +15 -0
  351. package/dist/reactor/imageCanvas.d.ts.map +1 -0
  352. package/dist/reactor/imageCanvas.js +33 -0
  353. package/dist/reactor/imageCanvas.js.map +1 -0
  354. package/dist/reactor/index.d.ts +19 -0
  355. package/dist/reactor/index.d.ts.map +1 -1
  356. package/dist/reactor/index.js +78 -0
  357. package/dist/reactor/index.js.map +1 -1
  358. package/dist/reactor/longLiveCommandDispatcher.d.ts +23 -8
  359. package/dist/reactor/longLiveCommandDispatcher.d.ts.map +1 -1
  360. package/dist/reactor/longLiveCommandDispatcher.js +16 -4
  361. package/dist/reactor/longLiveCommandDispatcher.js.map +1 -1
  362. package/dist/reactor/longLiveSceneEntry.d.ts +203 -0
  363. package/dist/reactor/longLiveSceneEntry.d.ts.map +1 -0
  364. package/dist/reactor/longLiveSceneEntry.js +280 -0
  365. package/dist/reactor/longLiveSceneEntry.js.map +1 -0
  366. package/dist/reactor/momentCut.d.ts +153 -0
  367. package/dist/reactor/momentCut.d.ts.map +1 -0
  368. package/dist/reactor/momentCut.js +142 -0
  369. package/dist/reactor/momentCut.js.map +1 -0
  370. package/dist/reactor/promptAddonRegistry.d.ts +39 -3
  371. package/dist/reactor/promptAddonRegistry.d.ts.map +1 -1
  372. package/dist/reactor/promptAddonRegistry.js +42 -3
  373. package/dist/reactor/promptAddonRegistry.js.map +1 -1
  374. package/dist/reactor/promptTemplatePreview.d.ts +97 -0
  375. package/dist/reactor/promptTemplatePreview.d.ts.map +1 -0
  376. package/dist/reactor/promptTemplatePreview.js +185 -0
  377. package/dist/reactor/promptTemplatePreview.js.map +1 -0
  378. package/dist/reactor/reactorAvailability.d.ts +80 -0
  379. package/dist/reactor/reactorAvailability.d.ts.map +1 -0
  380. package/dist/reactor/reactorAvailability.js +121 -0
  381. package/dist/reactor/reactorAvailability.js.map +1 -0
  382. package/dist/reactor/reactorSessionRefusal.d.ts +125 -0
  383. package/dist/reactor/reactorSessionRefusal.d.ts.map +1 -0
  384. package/dist/reactor/reactorSessionRefusal.js +197 -0
  385. package/dist/reactor/reactorSessionRefusal.js.map +1 -0
  386. package/dist/reactor/reactorTokenScope.d.ts +47 -0
  387. package/dist/reactor/reactorTokenScope.d.ts.map +1 -0
  388. package/dist/reactor/reactorTokenScope.js +64 -0
  389. package/dist/reactor/reactorTokenScope.js.map +1 -0
  390. package/dist/reactor/resolveDirectorBeats.d.ts +65 -0
  391. package/dist/reactor/resolveDirectorBeats.d.ts.map +1 -0
  392. package/dist/reactor/resolveDirectorBeats.js +86 -0
  393. package/dist/reactor/resolveDirectorBeats.js.map +1 -0
  394. package/dist/reactor/sanaLiveEdit.d.ts +117 -0
  395. package/dist/reactor/sanaLiveEdit.d.ts.map +1 -0
  396. package/dist/reactor/sanaLiveEdit.js +105 -0
  397. package/dist/reactor/sanaLiveEdit.js.map +1 -0
  398. package/dist/reactor/sceneEntry.d.ts +66 -9
  399. package/dist/reactor/sceneEntry.d.ts.map +1 -1
  400. package/dist/reactor/sceneEntry.js +59 -66
  401. package/dist/reactor/sceneEntry.js.map +1 -1
  402. package/dist/reactor/sceneSeedImage.d.ts +199 -0
  403. package/dist/reactor/sceneSeedImage.d.ts.map +1 -0
  404. package/dist/reactor/sceneSeedImage.js +239 -0
  405. package/dist/reactor/sceneSeedImage.js.map +1 -0
  406. package/dist/reactor/seedImageOrchestrator.d.ts +70 -3
  407. package/dist/reactor/seedImageOrchestrator.d.ts.map +1 -1
  408. package/dist/reactor/seedImageOrchestrator.js +92 -28
  409. package/dist/reactor/seedImageOrchestrator.js.map +1 -1
  410. package/dist/reactor/toolPromptAddon.d.ts.map +1 -1
  411. package/dist/reactor/toolPromptAddon.js +16 -2
  412. package/dist/reactor/toolPromptAddon.js.map +1 -1
  413. package/dist/reactor/worldMintLoop.d.ts +286 -0
  414. package/dist/reactor/worldMintLoop.d.ts.map +1 -0
  415. package/dist/reactor/worldMintLoop.js +381 -0
  416. package/dist/reactor/worldMintLoop.js.map +1 -0
  417. package/dist/reactor/worldSteerOutcome.d.ts +98 -0
  418. package/dist/reactor/worldSteerOutcome.d.ts.map +1 -0
  419. package/dist/reactor/worldSteerOutcome.js +81 -0
  420. package/dist/reactor/worldSteerOutcome.js.map +1 -0
  421. package/dist/retryAfter.d.ts +15 -0
  422. package/dist/retryAfter.d.ts.map +1 -0
  423. package/dist/retryAfter.js +75 -0
  424. package/dist/retryAfter.js.map +1 -0
  425. package/dist/seriesKey.d.ts +31 -0
  426. package/dist/seriesKey.d.ts.map +1 -0
  427. package/dist/seriesKey.js +33 -0
  428. package/dist/seriesKey.js.map +1 -0
  429. package/dist/sessionRefresh.d.ts +135 -0
  430. package/dist/sessionRefresh.d.ts.map +1 -0
  431. package/dist/sessionRefresh.js +215 -0
  432. package/dist/sessionRefresh.js.map +1 -0
  433. package/dist/sharedAudioContext.d.ts +39 -0
  434. package/dist/sharedAudioContext.d.ts.map +1 -0
  435. package/dist/sharedAudioContext.js +63 -0
  436. package/dist/sharedAudioContext.js.map +1 -0
  437. package/dist/singleFlight.d.ts +51 -0
  438. package/dist/singleFlight.d.ts.map +1 -0
  439. package/dist/singleFlight.js +87 -0
  440. package/dist/singleFlight.js.map +1 -0
  441. package/dist/storyGraph.d.ts +83 -0
  442. package/dist/storyGraph.d.ts.map +1 -1
  443. package/dist/storyGraph.js +169 -4
  444. package/dist/storyGraph.js.map +1 -1
  445. package/dist/storyboardMask.d.ts +343 -0
  446. package/dist/storyboardMask.d.ts.map +1 -0
  447. package/dist/storyboardMask.js +505 -0
  448. package/dist/storyboardMask.js.map +1 -0
  449. package/dist/storyboardTimeline.d.ts +93 -0
  450. package/dist/storyboardTimeline.d.ts.map +1 -0
  451. package/dist/storyboardTimeline.js +131 -0
  452. package/dist/storyboardTimeline.js.map +1 -0
  453. package/dist/studioAutomation.d.ts +104 -0
  454. package/dist/studioAutomation.d.ts.map +1 -0
  455. package/dist/studioAutomation.js +178 -0
  456. package/dist/studioAutomation.js.map +1 -0
  457. package/dist/tenantClaim.d.ts +86 -0
  458. package/dist/tenantClaim.d.ts.map +1 -0
  459. package/dist/tenantClaim.js +164 -0
  460. package/dist/tenantClaim.js.map +1 -0
  461. package/dist/timeFormat.d.ts +25 -0
  462. package/dist/timeFormat.d.ts.map +1 -1
  463. package/dist/timeFormat.js +56 -0
  464. package/dist/timeFormat.js.map +1 -1
  465. package/dist/toolSchemas.d.ts +58 -10
  466. package/dist/toolSchemas.d.ts.map +1 -1
  467. package/dist/toolSchemas.js +37 -9
  468. package/dist/toolSchemas.js.map +1 -1
  469. package/dist/transport.d.ts +120 -0
  470. package/dist/transport.d.ts.map +1 -0
  471. package/dist/transport.js +282 -0
  472. package/dist/transport.js.map +1 -0
  473. package/dist/videoGenFacade.d.ts +63 -0
  474. package/dist/videoGenFacade.d.ts.map +1 -0
  475. package/dist/videoGenFacade.js +49 -0
  476. package/dist/videoGenFacade.js.map +1 -0
  477. package/dist/visemeScheduler.d.ts +24 -2
  478. package/dist/visemeScheduler.d.ts.map +1 -1
  479. package/dist/visemeScheduler.js +31 -2
  480. package/dist/visemeScheduler.js.map +1 -1
  481. package/dist/vision/VisionPublisher.d.ts +88 -0
  482. package/dist/vision/VisionPublisher.d.ts.map +1 -1
  483. package/dist/vision/VisionPublisher.js +196 -13
  484. package/dist/vision/VisionPublisher.js.map +1 -1
  485. package/dist/vision/VisionSourceController.d.ts +67 -1
  486. package/dist/vision/VisionSourceController.d.ts.map +1 -1
  487. package/dist/vision/VisionSourceController.js +147 -5
  488. package/dist/vision/VisionSourceController.js.map +1 -1
  489. package/dist/vision/index.d.ts +2 -1
  490. package/dist/vision/index.d.ts.map +1 -1
  491. package/dist/vision/index.js +2 -1
  492. package/dist/vision/index.js.map +1 -1
  493. package/dist/vision/sourceKinds.d.ts +18 -5
  494. package/dist/vision/sourceKinds.d.ts.map +1 -1
  495. package/dist/vision/sourceKinds.js +15 -2
  496. package/dist/vision/sourceKinds.js.map +1 -1
  497. package/dist/vision/types.d.ts +7 -4
  498. package/dist/vision/types.d.ts.map +1 -1
  499. package/dist/vision/visionErrors.d.ts +45 -0
  500. package/dist/vision/visionErrors.d.ts.map +1 -0
  501. package/dist/vision/visionErrors.js +66 -0
  502. package/dist/vision/visionErrors.js.map +1 -0
  503. package/dist/voiceCloneCaption.d.ts +33 -0
  504. package/dist/voiceCloneCaption.d.ts.map +1 -0
  505. package/dist/voiceCloneCaption.js +69 -0
  506. package/dist/voiceCloneCaption.js.map +1 -0
  507. package/dist/websocket.d.ts +273 -10
  508. package/dist/websocket.d.ts.map +1 -1
  509. package/dist/websocket.js +79 -0
  510. package/dist/websocket.js.map +1 -1
  511. package/dist/workflowAuthoring.d.ts +139 -0
  512. package/dist/workflowAuthoring.d.ts.map +1 -0
  513. package/dist/workflowAuthoring.js +557 -0
  514. package/dist/workflowAuthoring.js.map +1 -0
  515. package/package.json +15 -5
  516. package/src/__tests__/adapters-director.test.ts +9 -6
  517. package/src/__tests__/adapters-extraction.test.ts +175 -0
  518. package/src/__tests__/adapters-image.test.ts +66 -0
  519. package/src/__tests__/adapters-momentPolicy.test.ts +218 -0
  520. package/src/__tests__/adapters-platform.test.ts +110 -4
  521. package/src/__tests__/adapters-videogen.test.ts +53 -0
  522. package/src/__tests__/adapters-world.test.ts +117 -7
  523. package/src/__tests__/admin.enhancement-defaults.test.ts +115 -0
  524. package/src/__tests__/admin.test.ts +282 -0
  525. package/src/__tests__/adventures-world-state.test.ts +156 -0
  526. package/src/__tests__/adventures.test.ts +111 -1
  527. package/src/__tests__/api-pollers.test.ts +113 -23
  528. package/src/__tests__/api.adventure-definitions.test.ts +312 -0
  529. package/src/__tests__/api.anchor-beat.test.ts +75 -0
  530. package/src/__tests__/api.arc-approval.test.ts +171 -0
  531. package/src/__tests__/api.arc-beats-floor.test.ts +56 -0
  532. package/src/__tests__/api.arc-generation.test.ts +168 -0
  533. package/src/__tests__/api.arc-templates.test.ts +78 -0
  534. package/src/__tests__/api.assignVideoSeries.test.ts +81 -0
  535. package/src/__tests__/api.cast-frame-choices.test.ts +141 -0
  536. package/src/__tests__/api.cutscene-registry.test.ts +148 -0
  537. package/src/__tests__/api.enhancement-addition-actions.test.ts +137 -0
  538. package/src/__tests__/api.enrichVideo-serialization.test.ts +116 -0
  539. package/src/__tests__/api.extraction-base.test.ts +87 -0
  540. package/src/__tests__/api.generateVideo-cutscene.test.ts +148 -0
  541. package/src/__tests__/api.job-pipeline-stages.test.ts +128 -0
  542. package/src/__tests__/api.list-images-filters.test.ts +6 -3
  543. package/src/__tests__/api.quest-curation.test.ts +169 -0
  544. package/src/__tests__/api.reprocessVideo.test.ts +71 -0
  545. package/src/__tests__/api.scene-split-merge.test.ts +129 -0
  546. package/src/__tests__/api.session-quests.test.ts +184 -0
  547. package/src/__tests__/api.test.ts +122 -0
  548. package/src/__tests__/api.transferSeries.test.ts +114 -0
  549. package/src/__tests__/api.unknown-clusters.test.ts +225 -0
  550. package/src/__tests__/api.uploadVideo-options.test.ts +156 -0
  551. package/src/__tests__/arcPreview.test.ts +71 -0
  552. package/src/__tests__/arcStyleProfile.test.ts +204 -0
  553. package/src/__tests__/artifacts-delete.test.ts +109 -0
  554. package/src/__tests__/audio.test.ts +864 -5
  555. package/src/__tests__/audioDsp.test.ts +196 -0
  556. package/src/__tests__/audioUnavailable.test.ts +43 -0
  557. package/src/__tests__/cast.test.ts +10 -1
  558. package/src/__tests__/castCurationProjection.test.ts +84 -0
  559. package/src/__tests__/castFramePipelinePending.test.ts +171 -0
  560. package/src/__tests__/castProjection.test.ts +497 -5
  561. package/src/__tests__/characterGrounding.test.ts +357 -0
  562. package/src/__tests__/contract.test.ts +97 -0
  563. package/src/__tests__/conversation/chatSessionStore.test.ts +243 -0
  564. package/src/__tests__/conversation/controller.test.ts +211 -0
  565. package/src/__tests__/conversation/readSequencer.test.ts +52 -0
  566. package/src/__tests__/conversation/rosterProjection.test.ts +204 -3
  567. package/src/__tests__/conversation/runtime.test.ts +118 -1
  568. package/src/__tests__/conversation/voice.test.ts +741 -7
  569. package/src/__tests__/creatorCuration.test.ts +256 -0
  570. package/src/__tests__/creatorDashboard.test.ts +444 -0
  571. package/src/__tests__/creatorUniverse.test.ts +138 -0
  572. package/src/__tests__/curationWrite.test.ts +179 -0
  573. package/src/__tests__/decisions.test.ts +89 -0
  574. package/src/__tests__/designTokens.test.ts +72 -0
  575. package/src/__tests__/dialogAttribution.test.ts +187 -0
  576. package/src/__tests__/dmDirectiveToExperience.test.ts +198 -0
  577. package/src/__tests__/dmWorldEntry.test.ts +2102 -0
  578. package/src/__tests__/enhancementDiff.test.ts +132 -0
  579. package/src/__tests__/experienceModelCatalog.test.ts +292 -0
  580. package/src/__tests__/extractionStageState.test.ts +67 -0
  581. package/src/__tests__/getVideo.test.ts +95 -0
  582. package/src/__tests__/graphReadAfterWrite.test.ts +211 -0
  583. package/src/__tests__/graphSchema.test.ts +55 -4
  584. package/src/__tests__/happyOysterSeed.test.ts +208 -0
  585. package/src/__tests__/happyOysterWorld.test.ts +1241 -0
  586. package/src/__tests__/happyOysterWorldRefusal.test.ts +224 -0
  587. package/src/__tests__/hiddenWorldLifecycle.test.ts +203 -0
  588. package/src/__tests__/http.session-refresh.test.ts +424 -0
  589. package/src/__tests__/http.test.ts +316 -0
  590. package/src/__tests__/identity.test.ts +132 -0
  591. package/src/__tests__/loadBundleManifest.test.ts +192 -22
  592. package/src/__tests__/longLiveSceneEntry.test.ts +371 -0
  593. package/src/__tests__/me.test.ts +74 -0
  594. package/src/__tests__/messageContent.test.ts +395 -0
  595. package/src/__tests__/momentCut.test.ts +229 -0
  596. package/src/__tests__/mutationEpoch.test.ts +218 -0
  597. package/src/__tests__/obo.test.ts +159 -0
  598. package/src/__tests__/opusTransport.test.ts +182 -0
  599. package/src/__tests__/opusTransportLibopus.test.ts +125 -0
  600. package/src/__tests__/orgs.test.ts +229 -0
  601. package/src/__tests__/persona-generation.test.ts +208 -1
  602. package/src/__tests__/platformAssistant.test.ts +140 -0
  603. package/src/__tests__/projects.test.ts +338 -0
  604. package/src/__tests__/promptTemplatePreview.test.ts +160 -0
  605. package/src/__tests__/reactor/__fixtures__/realFramePromptText.ts +23 -0
  606. package/src/__tests__/reactor/api-reactor.test.ts +60 -21
  607. package/src/__tests__/reactor/framePromptCompaction.test.ts +300 -0
  608. package/src/__tests__/reactor/promptAddonRegistry.test.ts +79 -0
  609. package/src/__tests__/reactor/reactorTokenScope.test.ts +50 -0
  610. package/src/__tests__/reactor/resolveDirectorBeats.test.ts +156 -0
  611. package/src/__tests__/reactor/sceneEntry.test.ts +3 -0
  612. package/src/__tests__/reactor/sceneSeedImage.test.ts +361 -0
  613. package/src/__tests__/reactor/seedImageOrchestrator.test.ts +43 -5
  614. package/src/__tests__/reactor-happyOysterWalk.test.ts +294 -0
  615. package/src/__tests__/reactorAvailability.test.ts +217 -0
  616. package/src/__tests__/reactorSessionRefusal.test.ts +189 -0
  617. package/src/__tests__/regeneration.test.ts +9 -9
  618. package/src/__tests__/reprocessBlockedReason.test.ts +30 -0
  619. package/src/__tests__/retryAfter.test.ts +65 -0
  620. package/src/__tests__/roleClaim.test.ts +102 -0
  621. package/src/__tests__/sanaLiveEdit.test.ts +84 -0
  622. package/src/__tests__/seriesKey.test.ts +24 -0
  623. package/src/__tests__/settings-set9.test.ts +238 -0
  624. package/src/__tests__/singleFlight.test.ts +348 -0
  625. package/src/__tests__/storyGraph.test.ts +111 -1
  626. package/src/__tests__/storyboardFrameCutscene.test.ts +115 -0
  627. package/src/__tests__/storyboardMask.test.ts +527 -0
  628. package/src/__tests__/storyboardTimeline.test.ts +228 -0
  629. package/src/__tests__/storyboards.test.ts +639 -0
  630. package/src/__tests__/studioAutomation.test.ts +325 -0
  631. package/src/__tests__/toolSchemas.test.ts +11 -18
  632. package/src/__tests__/transport.test.ts +312 -0
  633. package/src/__tests__/videoGenFacade.test.ts +141 -0
  634. package/src/__tests__/videoGraph.test.ts +43 -1
  635. package/src/__tests__/visemeScheduler.test.ts +55 -1
  636. package/src/__tests__/visibility.test.ts +143 -0
  637. package/src/__tests__/voiceCloneCaption.test.ts +80 -0
  638. package/src/__tests__/voiceFallback.test.ts +55 -0
  639. package/src/__tests__/websocket-error-turn-ended.test.ts +49 -0
  640. package/src/__tests__/websocket-vision.test.ts +141 -0
  641. package/src/__tests__/websocket.test.ts +75 -1
  642. package/src/__tests__/workflowAuthoring.test.ts +187 -0
  643. package/src/__tests__/workflows.test.ts +640 -0
  644. package/src/__tests__/worldMintLoop.test.ts +448 -0
  645. package/src/__tests__/worldModelPreference.test.ts +302 -0
  646. package/src/__tests__/worldModelTradeoffs.test.ts +89 -0
  647. package/src/__tests__/worldSteerOutcome.test.ts +62 -0
  648. package/src/adapters/capabilities.ts +39 -3
  649. package/src/adapters/directorAdapter.ts +5 -4
  650. package/src/adapters/experienceModelCatalog.ts +538 -0
  651. package/src/adapters/extractionAdapter.ts +150 -0
  652. package/src/adapters/imageAdapter.ts +5 -1
  653. package/src/adapters/index.ts +104 -17
  654. package/src/adapters/momentDirective.ts +109 -0
  655. package/src/adapters/momentPolicy.ts +209 -0
  656. package/src/adapters/registry.ts +1 -1
  657. package/src/adapters/videoGenAdapter.ts +124 -0
  658. package/src/adapters/worldAdapter.ts +221 -16
  659. package/src/adapters/worldModelPreference.ts +247 -0
  660. package/src/adapters/worldModelTradeoffs.ts +247 -0
  661. package/src/admin.ts +842 -16
  662. package/src/api.ts +12687 -3446
  663. package/src/arcBoardJoin.ts +46 -0
  664. package/src/arcPreview.ts +103 -0
  665. package/src/audio.ts +691 -130
  666. package/src/audioDsp.ts +132 -0
  667. package/src/audioProtocol.ts +235 -0
  668. package/src/beatTitles.ts +51 -0
  669. package/src/castProjection.ts +311 -0
  670. package/src/characterGrounding.ts +491 -0
  671. package/src/conversation/binding.ts +13 -0
  672. package/src/conversation/chatSessionStore.ts +281 -0
  673. package/src/conversation/controller.ts +96 -3
  674. package/src/conversation/index.ts +2 -0
  675. package/src/conversation/participant.ts +16 -0
  676. package/src/conversation/readSequencer.ts +55 -0
  677. package/src/conversation/roster.ts +5 -1
  678. package/src/conversation/rosterProjection.ts +166 -2
  679. package/src/conversation/runtime.ts +66 -7
  680. package/src/conversation/types.ts +43 -4
  681. package/src/conversation/voice.ts +655 -51
  682. package/src/creatorCuration.ts +316 -0
  683. package/src/creatorDashboard.ts +344 -0
  684. package/src/creatorUniverse.ts +222 -0
  685. package/src/curationWrite.ts +108 -0
  686. package/src/designTokens.ts +157 -0
  687. package/src/dialogAttribution.ts +182 -0
  688. package/src/dmRunWorldReadiness.ts +1168 -0
  689. package/src/domains/access.ts +92 -0
  690. package/src/domains/adventureDefinitions.ts +313 -0
  691. package/src/domains/adventures.ts +557 -0
  692. package/src/domains/arcs.ts +350 -0
  693. package/src/domains/artifacts.ts +349 -0
  694. package/src/domains/chat.ts +338 -0
  695. package/src/domains/decisions.ts +62 -0
  696. package/src/domains/documents.ts +389 -0
  697. package/src/domains/enhancements.ts +259 -0
  698. package/src/domains/graph.ts +959 -0
  699. package/src/domains/images.ts +451 -0
  700. package/src/domains/ingestion.ts +695 -0
  701. package/src/domains/me.ts +27 -0
  702. package/src/domains/orgs.ts +168 -0
  703. package/src/domains/personas.ts +440 -0
  704. package/src/domains/projects.ts +177 -0
  705. package/src/domains/quests.ts +587 -0
  706. package/src/domains/reactor.ts +163 -0
  707. package/src/domains/showcase.ts +35 -0
  708. package/src/domains/storyboards.ts +1698 -0
  709. package/src/domains/studioSettings.ts +149 -0
  710. package/src/domains/universes.ts +433 -0
  711. package/src/domains/userDefaults.ts +37 -0
  712. package/src/domains/visemeBundles.ts +541 -0
  713. package/src/domains/workflows.ts +376 -0
  714. package/src/enhancementDiff.ts +171 -0
  715. package/src/generated/contract.ts +1016 -0
  716. package/src/graphSchema.ts +154 -6
  717. package/src/http.ts +295 -11
  718. package/src/identity.ts +123 -0
  719. package/src/index.ts +131 -0
  720. package/src/messageContent.ts +500 -0
  721. package/src/mutationEpoch.ts +107 -0
  722. package/src/obo.ts +201 -0
  723. package/src/opusTransport.ts +268 -0
  724. package/src/pagination.ts +29 -0
  725. package/src/platformAssistant.ts +97 -1
  726. package/src/pollUtils.ts +35 -0
  727. package/src/questLog.ts +704 -0
  728. package/src/reactor/dmDirectiveToExperience.ts +636 -0
  729. package/src/reactor/dmSceneControlPrompt.ts +69 -2
  730. package/src/reactor/dmWorldEntry.ts +2226 -0
  731. package/src/reactor/framePromptCompaction.ts +544 -0
  732. package/src/reactor/frameWorldBind.ts +133 -0
  733. package/src/reactor/happyOysterSeed.ts +329 -0
  734. package/src/reactor/happyOysterWalk.ts +541 -0
  735. package/src/reactor/happyOysterWorld.ts +1270 -0
  736. package/src/reactor/heliosCommandDispatcher.ts +5 -1
  737. package/src/reactor/hiddenWorldLifecycle.ts +182 -0
  738. package/src/reactor/imageCanvas.ts +38 -0
  739. package/src/reactor/index.ts +78 -0
  740. package/src/reactor/longLiveCommandDispatcher.ts +23 -8
  741. package/src/reactor/longLiveSceneEntry.ts +409 -0
  742. package/src/reactor/momentCut.ts +219 -0
  743. package/src/reactor/promptAddonRegistry.ts +81 -3
  744. package/src/reactor/promptTemplatePreview.ts +240 -0
  745. package/src/reactor/reactorAvailability.ts +155 -0
  746. package/src/reactor/reactorSessionRefusal.ts +260 -0
  747. package/src/reactor/reactorTokenScope.ts +69 -0
  748. package/src/reactor/resolveDirectorBeats.ts +140 -0
  749. package/src/reactor/sanaLiveEdit.ts +158 -0
  750. package/src/reactor/sceneEntry.ts +106 -88
  751. package/src/reactor/sceneSeedImage.ts +338 -0
  752. package/src/reactor/seedImageOrchestrator.ts +116 -34
  753. package/src/reactor/toolPromptAddon.ts +16 -2
  754. package/src/reactor/worldMintLoop.ts +545 -0
  755. package/src/reactor/worldSteerOutcome.ts +132 -0
  756. package/src/retryAfter.ts +71 -0
  757. package/src/seriesKey.ts +42 -0
  758. package/src/sessionRefresh.ts +237 -0
  759. package/src/sharedAudioContext.ts +67 -0
  760. package/src/singleFlight.ts +91 -0
  761. package/src/storyGraph.ts +247 -4
  762. package/src/storyboardMask.ts +756 -0
  763. package/src/storyboardTimeline.ts +220 -0
  764. package/src/studioAutomation.ts +208 -0
  765. package/src/tenantClaim.ts +170 -0
  766. package/src/timeFormat.ts +51 -0
  767. package/src/toolSchemas.ts +40 -10
  768. package/src/transport.ts +327 -0
  769. package/src/videoGenFacade.ts +90 -0
  770. package/src/visemeScheduler.ts +36 -3
  771. package/src/vision/VisionPublisher.ts +204 -14
  772. package/src/vision/VisionSourceController.ts +187 -6
  773. package/src/vision/__tests__/VisionPublisher.kvs.test.ts +50 -0
  774. package/src/vision/__tests__/VisionPublisher.test.ts +291 -0
  775. package/src/vision/__tests__/VisionSourceController.test.ts +376 -6
  776. package/src/vision/index.ts +5 -1
  777. package/src/vision/sourceKinds.ts +19 -5
  778. package/src/vision/types.ts +7 -4
  779. package/src/vision/visionErrors.ts +70 -0
  780. package/src/voiceCloneCaption.ts +77 -0
  781. package/src/websocket.ts +361 -12
  782. package/src/workflowAuthoring.ts +664 -0
package/README.md CHANGED
@@ -1,194 +1,486 @@
1
1
  # @escapeaihq/client-core
2
2
 
3
- Framework-agnostic Seer client building blocks. Vanilla TypeScript, no React or Vue dependencies. Imported by both seer-agent's React `web/` app (this monorepo) and the Vue Escape `web-app` (sibling repo).
3
+ Framework-agnostic client building blocks for the Seer video-reasoning platform: a typed REST
4
+ client, a reconnecting chat WebSocket, browser audio I/O with viseme lip-sync, WebRTC vision
5
+ publishing, and pure projections over the story graph.
4
6
 
5
- ## Module format
7
+ Vanilla TypeScript — no React or Vue dependency, and no DOM work beyond the Web Audio, WebSocket
8
+ and WebRTC APIs it exists to wrap. The same source backs a React (Next.js) app and a Vue (Nuxt)
9
+ app.
6
10
 
7
- ESM-only. The published `package.json` points `exports[".".import]` at `./dist/index.js` and `exports[".".types]` at `./dist/index.d.ts` — there's no CJS `require` path. Both current consumers are ESM-default (Next.js 15 + React, Nuxt 3 + Vue + Vite), so this is fine. If a future CJS consumer (older Jest config, Node CLI script) appears, add a CJS bundle to the build (`tsup` or similar dual-output) before it bites.
11
+ ## Install
8
12
 
9
- ## What's in here
13
+ ```bash
14
+ npm install @escapeaihq/client-core
15
+ ```
10
16
 
11
- | Module | What it does |
12
- |---|---|
13
- | `timeFormat` | `formatTimestamp(seconds, opts?)` — locale-aware `M:SS` / `M:SS.cs` formatter. `formatCitationTimestamp(seconds)` (`src/timeFormat.ts:68`) is a preset with `centiseconds: true`, used by chat surfaces for sub-second word/turn citations (renders as `"1:23.45"`). |
14
- | `graphSchema` | **0.12.0:** Graph-schema vocabulary mirrored from the backend single source of truth (`shared/graph_schema.py` + `shared/provenance.py`). Types `GraphNodeLabel`, `GraphRelationshipType`; two **separate** provenance unions `StoryGraphProvenance` (`'pegasus' \| 'user' \| 'document' \| 'regenerated'`) and `MemoryFactProvenance` (`'chat' \| 'document' \| 'system' \| 'regenerated'`) — never merged. Runtime constants `GRAPH_NODE_LABELS`, `GRAPH_RELATIONSHIP_TYPES`, `GRAPH_PRIMARY_KEY`, `GRAPH_EDITABLE_NODE_PROPERTIES`, `GRAPH_EDITABLE_RELATIONSHIP_PROPERTIES`, `STORY_GRAPH_PROVENANCE_VALUES`, `MEMORY_FACT_PROVENANCE_VALUES`; authored-canon sets `AUTHORED_STORY_PROVENANCE` / `AUTHORED_MEMORY_PROVENANCE` + guards `isStoryGraphProvenance` / `isMemoryFactProvenance`. **0.13.0:** adds a session-scoped memoized `fetchGraphSchema(client)` that fetches the live `GET /graph/schema` payload once per session (resets its cache on rejection so a failed fetch retries; `__resetGraphSchemaCache()` test hook). The graph-editor `PropertyPanel` now sources its **runtime** editable/PK lists from this fetched payload (backend = single runtime source of truth), dropping its hand-maintained literal whitelist. The static `GRAPH_*` unions/constants are **retained** as the typed compile-time vocabulary and a back-compat fallback — they are **not** removed (eliminating the TS copy entirely needs build-time codegen; tech-debt #205). Resolves tech-debt #45 for the graph editor (M7 Phase 1a). **0.15.0 (M7 Phase 3a):** widens `GraphNodeLabel` + `GRAPH_NODE_LABELS` with `Scene`/`PlotBeat`/`CharacterArc` and `GraphRelationshipType` + `GRAPH_RELATIONSHIP_TYPES` with the six user-creatable edges (`RELATES_TO`/`CAUSES`/`SET_IN`/`FEATURES`/`ON_ARC`/`LEADS_TO`); adds `GRAPH_PRIMARY_KEY` (`Scene→sceneId`, `PlotBeat→beatId`, `CharacterArc→arcId`) + `GRAPH_EDITABLE_NODE_PROPERTIES` entries. New exports consumed by the 3b creation UI: `userCreatableLabels` (`['Scene','PlotBeat','CharacterArc']`), `userCreatableEdges` (the six edges), and `allowedPairs` (the TS mirror of the backend `_VALID_EDGE_PAIRS`: `RELATES_TO→[[Entity,Entity]]`, `SET_IN`/`FEATURES→[[Scene,Entity]]`, `ON_ARC→[[PlotBeat,CharacterArc]]`, `LEADS_TO→[[PlotBeat,PlotBeat]]`, `CAUSES→[[Event,Event]]`) — all **additive**. Graph schema only — no tool/MCP schemas. **0.39.0 (R8.1):** adds the studio **read-surface** vocabulary `STUDIO_NODE_LABELS` / `STUDIO_EDGE_TYPES` / `STUDIO_NODE_PROPERTIES` / `STUDIO_CHARACTER_TYPE` (lifted from web `graphVocabulary.ts`, which now re-exports them) so the lifted `storyGraph` projection resolves its vocabulary in one place. |
15
- | `storyGraph` | **0.39.0 (R8.1):** the pure get_video_graph projection lifted from `web/app/components/studio/storyGraph.ts` (the web module is now a thin re-export shim). `deriveScenes(graph): SceneView[]` (collapsed scenes with featured characters, location, shots, parent act — sorted by act.index then scene.index) and `deriveCast(graph): CharacterView[]` (character entities with aliases, scene memberships, arcs, related characters). Edge-direction-agnostic traversal (CONTAINS/INCLUDES/FEATURES/SET_IN/ON_ARC/RELATES_TO matched by EITHER endpoint). The **single source** of the collapsed-story projection both Studio read-views AND the Director story-timeline mapper (`reactor/storyTimeline.ts`) consume — two copies would drift. Plus view-model types `SceneView`/`CharacterView`/`ArcView`/`ShotView`/`CharacterRef`/`LocationRef`. |
16
- | `toolSchemas` | **0.11.0:** `AGENT_TOOL_SCHEMAS`, `AGENT_TOOL_NAMES`, `getAgentToolSchema(name)` + types `AgentToolSchema` / `AgentToolName` / `ToolRequestField` / `ToolFieldType` (`src/toolSchemas.ts`). Framework-agnostic TS mirror of the backend's 12 SERVER-SIDE RAG tools whose canonical source is `shared/tool_schemas.py`. Exposes each tool's name, description, endpoint, HTTP method, and request field shapes so clients can introspect the agent's tool surface without copy-pasting strings. Keep in sync when the backend tool list changes (no codegen yet). **Distinct from** the Helios browser-side `BEDROCK_TOOL_SCHEMAS` in `reactor/heliosTools.ts` — different vocabulary, do not converge. |
17
- | `audioProtocol` | Binary audio frame codec (1-byte tag + 320 samples PCM16); type defs for phoneme/word/barge-in messages |
18
- | `audio` | `MicrophoneRecorder`, `AudioFramePlayer`, `PlaybackTracker`, `AudioSessionClient`, `AudioPipeline`. Web Audio API based. Clean barge-in via `GainNode` + tracked `activeSources`. Sentence-boundary viseme scheduling. |
19
- | `visemeScheduler` | Maps Inworld TTS 1.5 phoneme timing to mouth shape changes via `requestAnimationFrame`, locked to `AudioContext.currentTime`. Stops the loop when idle. |
20
- | `visemeGeometry` | Pure path math: derive inner-lip donut, mouth clip ellipse, teeth/tongue geometry from existing `mouth_paths` data |
21
- | `websocket` | `ChatWebSocket` — auto-reconnecting wrapper around native WebSocket with text/binary multiplexing. `sendPlaybackState(state: PlaybackState)` publishes `{ action: 'playback_state', videoId, currentTime, shotId?, paused, clientTs }` for cross-device video↔chat sync (`src/websocket.ts:493` `sendPlaybackState` + `src/websocket.ts:69` `PlaybackState`). Fire-and-forget: drops silently when the socket isn't OPEN. See `specs/2026-05-17-cross-device-playback-sync.md`. **Phase 2 vision signaling:** `sendVisionOffer({ sdp, fps })` (`src/websocket.ts:578`), `sendVisionIce({ candidate, sdpMid, sdpMLineIndex })` (`src/websocket.ts:594`), and `sendVisionClose()` (`src/websocket.ts:614`) forward SDP/ICE over the existing chat-ws WebSocket; inbound `vision_answer`, `vision_ice`, and `vision_status` events are surfaced via typed event handlers. **0.49.0 (dashboard A-DM0):** the `ChatWsEvent` union gains a `dm_directive` member `{ type, timestamp?, directive: DmDirectiveKind, params }` (mirrors `ChatEventType.DM_DIRECTIVE` in `shared/chat_dispatcher.py`) — a DM-issued scene-control directive (`enter_world`/`exit_world`/`seek_video`/`set_experience_source`). Additive; `ConversationRuntime.applyFrame` drops it via its default arm (no consumer wired yet — A-DM0 is dark). **0.51.0 (dashboard B5 — server-anchored session):** `sendSessionAttach({ action:'session_attach', videoId, connectionId })` joins a server-anchored chat session (anchor `(userId,videoId)`, matching `SessionAttachMessage` + the `PlaybackStateStore` row) — best-effort like the vision sends. `sendSessionDetach()` leaves it WITHOUT closing the socket (mirrors `sendVisionDetach`; backend `session_detach` action) so a long-lived adopted socket can rebind away from a video session without leaving a stale peer. Inbound `session_attached` (ack with the replayed cross-device `anchoredState` + the `peers` list) and `presence` (`attached`/`detached` fan-out) ride the SAME typed-event dispatcher as the vision events (`on('session_attached'|'presence', …)`), with payload types `SessionAttachedEvent` / `PresenceEvent` / `SessionAnchoredState`. The `ChatWsEvent` union also gains `session_attached` + `presence` variants (exhaustive-switch arms). All additive; a client that never calls `sendSessionAttach` is byte-identical. Mirrors `api/chat/ws.py::_handle_session_attach` / `_detach_session`. |
22
- | `vision/` | **Phase 2:** `VisionPublisher` (`src/vision/VisionPublisher.ts:1`) — framework-agnostic class taking any `MediaStreamTrack` + `ChatWebSocket` + optional `VisionRtcCredentials` and managing the `RTCPeerConnection` lifecycle (SDP offer/answer, ICE trickle, restart-on-disconnect). **Dual-mode signaling**: `credentials.mode === 'kvs'` dynamically imports the optional `amazon-kinesis-video-streams-webrtc` peer dep and connects via Amazon KVS WebRTC against a backend-minted SigV4-presigned wss:// URL; otherwise (or when no credentials passed) uses the existing chat-WS `vision_offer`/`vision_ice`/`vision_close` protocol. `ChatWebSocket.sendVisionAttach({clientId})` (KVS mode only) binds the chat session to the KVS viewer ClientId so the backend dispatcher can find the FrameBuffer. `visionScheduler.ts` adjusts published fps from backend `vision_status` back-pressure (pure helper). `types.ts` exports `VisionPublisherConfig`, `VisionPublisherOptions`, `VisionRtcCredentials`, `VisionStatus`, `VisionStatusListener`, `VisionErrorListener`. Source-agnostic by design — consumers wire `<video>.captureStream()`, `getUserMedia()`, or future Reactor/Helios/PlayCanvas surfaces (Issue #150). **0.10.0 additions:** `toVisionRtcCredentials(response)` (`src/vision/credentials.ts:23`) — pure mapping helper that converts a `ChatVisionRtcCredentialsResponse` API wire shape into `VisionRtcCredentials`, coercing `null` ICE fields to `undefined`. `startVisionPublisher(opts)` (`src/vision/startVisionPublisher.ts:42`) — framework-agnostic factory: construct→subscribe→start→cleanup in one call, returning `VisionPublisherHandle { publisher, stop() }`. Used by both `/watch` and `/chat-ws` React hooks so the construct/teardown sequence has exactly one implementation. **0.31.0 (R3a — vision-source picker):** `sourceKinds.ts` — `VISION_SOURCE_KINDS` (`webcam`/`playing-video`/`server-render`, the frozen constant + `VisionSourceKind` union) and the `VisionSourceDescriptor` tagged union (`{kind:'webcam',constraints?}` vs `{kind:'playing-video'|'server-render', element, waitForFrame?}`) so the controller never queries the DOM. `VisionSourceController.ts` (`src/vision/VisionSourceController.ts:89`) — the framework-agnostic owner of "turn a chosen local source into a published feed": `start(descriptor)` acquires (getUserMedia vs `element.captureStream()`, with the `waitForFrame` black-frame gate lifted from the watch hook), mints credentials AFTER acquisition, then DELEGATES to `startVisionPublisher`; `switchSource()` tears the previous publisher + tracks down BEFORE acquiring the next; `stop()` is idempotent, leaves zero live tracks, and epoch-guards in-flight starts (a racing stop/switch releases the late stream, no error); `currentKind` + `isStarting` expose the published source and the in-flight phase. Environmental failures → `onError` (restartable); misuse (`start()` while active) throws. `ws` must be the SAME authenticated `ChatWebSocket` as the chat turns (frames are keyed to the WS session server-side). Land-dark until R3b–R3d wire the surfaces; sources are LOCAL only (cross-device vision deferred). |
23
- | `api` | `ApiClient` REST client + all backend response/request type definitions. Constructor takes `baseURL` and `chatBaseUrl` from the caller (no env-var coupling). Image-tool wrappers since 0.3.0: `extractImage`, `regenerateImage`, `pollVisemeBundleUntilDone`. Bundle resolution since 0.5.0: `loadBundleManifest` (handles the inline-vs-S3 body_svg split internally) + canonical `VisemeBundleManifest` type. Reactor/Helios wrappers: `getReactorToken`, `getSeedImageBlob`, `upsampleReactorPrompt`. Chat-model registry (since the LLM-provider phase): `listChatModels()` returns `ChatModelsResponse` with `ChatModelInfo` entries (`id`, `provider`, `capabilities: ChatModelCapability[]`, context window, etc.) — public endpoint so it works before login. **0.10.0 additions:** `getSystemPrompt()` returns `SystemPromptComponents` (`src/api.ts:205,2132`) with `{ film_qa, guardrails, audio_markup, full_default }` — calls `GET /api/v1/chat/system-prompt`. **0.13.0 additions (M7 Phase 1a):** `getGraphSchema()` returns `GraphSchemaResponse` (`{ traceId, labels: Record<string,{pk,editable[]}>, edges: Record<string,{editable[]}> }`) — calls `GET /api/v1/tools/graph/schema`. **Graph-editor signature changes:** `deleteGraphNode` / `deleteGraphEdge` now send **query params** (no request body — tech-debt #42), and `UpdateNodeRequest` / `DeleteNodeRequest` input types **dropped `idProperty`** (backend derives the PK — tech-debt #44). These are input-type narrowings (callers pass less); additive otherwise. **0.14.0 additions (M7 Phase 1b):** `NarrativeAct` (`src/api.ts:751`) gains **optional** `actId` / `index` / `title` / `summary` / `t0` / `t1` — **additive only**; the existing `act` / `timeRange` / `description` fields are retained (per the client-core API-is-a-contract rule, no public export removed/renamed). Acts and `themes` / `mainCharacterNames` are now read **from the graph** — `Act`-labelled `GraphNode`s and the `Video` node properties returned by `getVideoGraph()` — rather than parsed from `getEnrichments()`; `GraphNode` / `VideoGraphResponse` carry `Act` nodes with no schema change. **0.15.0 additions (M7 Phase 3a):** `createGraphNode(data: CreateNodeRequest): Promise<CreateNodeResponse>` (`POST /api/v1/tools/graph/nodes`) and `createGraphEdge(data: CreateEdgeRequest): Promise<CreateEdgeResponse>` (`POST /api/v1/tools/graph/edges`) — both **additive** (no public export removed/renamed, per the API-is-a-contract rule). New request/response types `CreateNodeRequest` `{ videoId, label, properties }` / `CreateNodeResponse` `{ traceId, nodeId, properties }` and `CreateEdgeRequest` `{ videoId, sourceId, targetId, type, properties? }` / `CreateEdgeResponse` `{ traceId, edgeId, properties }`. The 201 JSON body is parsed by the existing `makeRequest` path (only 204 is special-cased); a 422 surfaces the FastAPI `detail` message unchanged. **Source-document CRUD (M7 Phase 4, package version 0.14.0):** shapes mirror the **authoritative backend Pydantic models** (`api/tools/schemas.py`). `uploadDocument(file, meta, onProgress?)` (multipart XHR mirroring `uploadVideo`; file sent under the multipart field **`upload`**; `POST /api/v1/ingestion/documents` → `{ traceId, document }`, HTTP 202 new / 200 idempotent dedupe), `listDocuments({ videoId?, seriesId?, limit?, nextToken? })`, `getDocument(docId)` (→ `{ traceId, document }` — suggestions are **nested** in `document.suggestions`, no top-level field), `acceptSuggestion(docId, sid)` (201 `{ traceId, suggestionId, graphId }`, writes graph node/edge with provenance `document`), `rejectSuggestion(docId, sid)` (204), `deleteDocument(docId)` (204) — all on the tools/ingestion base URL, not chat. New types/constants: `DocumentKind`, `DocumentStatus` + `DOC_STATUS_*`, `SuggestionStatus` + `SUGGESTION_STATUS_*`, `Suggestion`, `DocumentRecord` (mirrors `DocumentResponse`: `suggestions` always present; no `ownerUserId`/`s3Key`/`contentHash`), `UploadDocumentMeta`, `UploadDocumentResponse` `{ traceId, document }`, `ListDocumentsResponse`, `GetDocumentResponse` `{ traceId, document }`, `AcceptSuggestionResponse` `{ traceId, suggestionId, graphId }`. **0.16.0 additions (M7 Phase 6 — narrative regeneration):** `startRegeneration(videoId, request: RegenerateRequest): Promise<RegenerationRunResponse>` (`POST /api/v1/tools/graph/{videoId}/regenerate` → 202; `statusUrl`/`Location` to the run's poll URL; a 409 lock / 429 cap / 422 bad-scope surfaces the FastAPI `detail`), `listRegenerations(videoId, { limit?, cursor? }?)` (`GET .../regenerations` → `RegenerationListResponse` newest-first + `nextCursor`), `getRegeneration(videoId, runId, { signal? }?)` (`GET .../regenerations/{runId}`, 404 absent), and `pollRegenerationUntilDone(videoId, runId, { intervalMs?, timeoutMs?, signal? }?)` (5s cadence, abortable — resolves on `complete`/`cancelled`, throws on `failed`, mirrors `pollVisemeBundleUntilDone`). New types/constants `RegenerationRunStatus` + `REGENERATION_STATUS` const map + `REGENERATION_TERMINAL_STATUSES`, `RegenerationScopeKind` + `REGEN_SCOPE_BARE_KINDS`/`REGEN_SCOPE_TARGETED_KINDS`/`REGEN_SCOPE_SEPARATOR` + `buildRegenerationScope(kind, targetId?)` (builds `acts`/`characters`/`scene:<id>`/`arc:<id>`; throws on a bare+target or targeted-without-id contract violation), `RegenerateRequest` `{ scope, promptAddon? }`, `RegenerationRunResponse` `{ traceId, runId, videoId, scope, status, statusUrl, createdAt, promptAddon?, startedAt?, completedAt?, delta, error? }`, `RegenerationListResponse` `{ traceId, videoId, runs, nextCursor }`. **0.21.0 additions (M9 Story Engine Phase 8a — Adventure Runtime):** `startAdventure(request: StartAdventureRequest, { signal? }?): Promise<AdventureResponse>` (`POST /api/v1/adventures` → 201, `Location` to the session GET URL; a 422 `Persona is not a Dungeon Master` / 404 / 403 surfaces the FastAPI `detail`), `getAdventure(sessionId, { signal? }?): Promise<GetAdventureResponse>` (`GET /api/v1/adventures/{sessionId}`, 404 absent/not-owned), `deleteAdventure(sessionId, { signal? }?): Promise<void>` (`DELETE .../{sessionId}` → 204). New camelCase-wire types `TurnRecord` `{ turn, beatId, summary }`, `AdventureState` `{ sessionId, ownerUserId, storyId, videoId, dmPersonaId, partyPersonaIds, currentBeatId?, visitedBeatIds, flags, inventory, turnHistory, createdAt, updatedAt }`, `StartAdventureRequest` `{ storyId, videoId, dmPersonaId, initialBeatId? }`, `AdventureResponse` `{ traceId, sessionId, state }`, `GetAdventureResponse` `{ traceId, state }`. `PersonaConfig` / `CreatePersonaRequest` / `UpdatePersonaRequest` gain optional snake_case `is_dungeon_master` (read defaults `false`). `ChatWebSocket.send()` options + `buildHelloPayload()` gain optional `adventureSessionId` (spread only when set → land-dark). **0.22.0 additions:** `listAdventures(storyId?, { signal? }?): Promise<ListAdventuresResponse>` (`GET /api/v1/adventures`, owner-scoped newest-first, optional `storyId` filter) + `ListAdventuresResponse` `{ traceId, adventures }`. **0.23.0 additions (M10 Story Engine Phase 9a — multi-persona scene orchestrator):** `addPartyMember(sessionId, personaId, { signal? }?): Promise<GetAdventureResponse>` and `removePartyMember(sessionId, personaId, { signal? }?): Promise<GetAdventureResponse>` — both `PATCH /api/v1/adventures/{sessionId}/party` with `{ action, personaId }` (add: 422 for a DM / non-character / unowned persona; remove: idempotent 200 no-op; 404 for a missing adventure). New types/constants `PARTY_ACTION` (`{ ADD:'add', REMOVE:'remove' }`) + `PartyAction` + `PartyUpdateRequest` `{ action, personaId }`; `StartAdventureRequest` gains optional `partyPersonaIds?: string[]`. `ChatWebSocket.send()` options + `buildHelloPayload()` gain optional `partyPersonaIds?: string[]` (spread only when non-empty → land-dark; advisory — the server's `AdventureState.party_persona_ids` is authoritative). `ChatWsEvent` gains a `turn_changed` member `{ type, timestamp?, personaId, previousPersonaId? }` (mirrors `ChatEventType.TURN_CHANGED`) and an optional `personaId?` on the `token`/`done`/`citation`/`image`/`audio_chunk` members (orchestrator-stamped; undefined elsewhere → land-dark; per-turn TTS voice swap on audio deferred). **R1c additions (Platform Experience Restructure — image adapter registry, no version bump, release is R1e):** `listImageModels(): Promise<ImageModelsResponse>` (`GET /api/v1/images/models`, **authenticated** — unlike chat/models it is NOT in `DEFAULT_PUBLIC_PATHS`; served on the **chat** base URL via `chatRequest`) + `ImageModelInfo` `{ id, displayName, provider, capabilities: string[], isDefault, isFallback }` / `ImageModelsResponse` `{ models }`. **Additive only** (no public export removed/renamed). **0.32.0 additions (Platform Experience Restructure R5a+R5c — cast-with-persona projection):** `getCast(videoId): Promise<CastWithPersonaResponse>` (`GET /api/v1/tools/videos/{videoId}/cast`, tools base URL) — one call returns the character cast pre-joined to bound-persona display fields (the server resolves the PORTRAYS binding; replaces the CastGrid `getVideoGraph`+`listPersonas` client-side `entity_id` join since R5c). New types `CastArc`/`CastScene`/`CastCharacter`/`CastPersonaSummary`/`CastEntry`/`CastWithPersonaResponse` (`CastCharacter.scenes: CastScene[]` carries `{sceneId, title}` so a Cast drawer renders scene titles without the graph payload). New `castWithPersona(response): CastEntry[]` (`src/castProjection.ts`) — the framework-agnostic pure normalizer (deterministic ordering, list coalescing, title/name fallbacks, input never mutated) every Cast consumer shares. **0.32.0 additions (R5b — story-detail graph read):** `getVideoGraph(videoId, detail?)` gains an optional `detail` arg — `GRAPH_DETAIL.STORY` requests the server-collapsed story view (Acts/Scenes/cast/narrative edges; Shots collapsed to per-Scene `shotCount` properties; DialogLine/Event/MENTIONS omitted), `GRAPH_DETAIL.RAW` the full graph; omitting it sends NO query param (byte-identical pre-R5b request). New exports `GRAPH_DETAIL` + `GraphDetail` (mirror of `shared/graph_schema.py`). **0.33.0 additions (Platform Experience Restructure R6b — image filtering params):** `listImages(params)` gains optional `model?: string` + `status?: ImageStatus` filters, mirroring the new `GET /api/v1/images` query params. `model` ids come from R1's image-model registry (discoverable via `listImageModels()`); the backend rejects an unregistered id with 400 — **no client-core image-model descriptor is added** (R1's `imageAdapter.ts` stays the sole catalogue owner). `status` reuses the existing `ImageStatus` union (`ImageRecord['status']`) — no parallel status enum. Omitting both leaves the request byte-identical to 0.32.0 (additive only). **0.44.0 additions (C3a persona-generation, spec Step 11 — auto-generate trigger + job tracking):** `getPersonaGenSettings(): Promise<PersonaGenerationSettings|null>` (`GET /api/v1/personas/settings/generation`, null when unsaved), `updatePersonaGenSettings(body): Promise<PersonaGenerationSettings>` (`PUT` partial merge — `UpdatePersonaGenSettingsRequest` all-optional), `generatePersonasForVideo(videoId): Promise<GeneratePersonasJobResponse>` (`POST /api/v1/videos/{videoId}/personas/generate`, 202 envelope, idempotent on the active `(user,video)` job), `getPersonaJob(jobId): Promise<AutoGenerationJob>` (`GET /api/v1/persona-jobs/{jobId}`, owner-scoped poll — all in `src/api.ts`), and `listPersonasByVideo(sourceVideoId)` + a new optional `sourceVideoId` on `listPersonas({ sourceVideoId })` (→ the `source_video_id` query param). New exported types `PersonaGenerationSettings`, `UpdatePersonaGenSettingsRequest`, `AutoGenerationJob`, `PersonaJobProgress`, `PersonaJobError`, `GeneratePersonasJobResponse`, `PersonaJobStatus`, `PersonaJobErrorStage`; `PersonaConfig` (+`CreatePersonaRequest`/`UpdatePersonaRequest` for the first four) gain optional snake_case `entity_name`/`is_auto_generated`/`source_video_id`/`available_clip_indices`/`clips_used`. **camelCase wire keys** (`jobId`/`traceId`) on `GeneratePersonasJobResponse` ONLY — the backend serializes that model with aliases; `AutoGenerationJob`/`PersonaGenerationSettings` are snake_case (no backend aliases). **0.45.0 additions (C3a persona-generation, spec Step 13 — review/audition page):** `auditionPersona(personaId, body?, { signal? }?): Promise<Blob>` (`POST /api/v1/personas/{id}/audition` — renders a short TTS sample in the persona's current voice; returns the `audio/wav` blob the review page plays via `URL.createObjectURL`+`<audio>`; an omitted body uses the backend default sample text; bypasses the JSON wrapper since the response is binary, same pattern as `getSeedImageBlob`) and `reclonePersona(personaId): Promise<ReclonedPersonaResponse>` (`POST /api/v1/personas/{id}/reclone` — re-clones the voice from a different subset of the cached `persona-clips` WITHOUT re-downloading video; swaps `voice_id`, appends to `clips_used`). New exported types `AuditionRequest`, `ReclonedPersonaResponse` (**camelCase** wire — `personaId`/`voiceId`/`clipsUsed`), `RecloneConflictCode`, and a `RecloneConflictError` class — `reclonePersona` bypasses the generic JSON error path to raise this typed error on a `409` (whose `detail` is a structured object the flattener would render as `[object Object]`) so the review UI can branch on `voice_clone_max_retries_exhausted` vs `no_candidate_clips_remaining` and disable the Reclone control. Additive only; no public export removed/renamed (`../Web-App` pins this package). The persona-gen *pages* (settings/review/list — spec Steps 12–14) consume these. **0.46.0 additions (C3a-f1 — persona-gen trigger relocated to Studio Cast):** `generatePersonasForVideo(videoId, opts?: { entityIds?: string[] })` gains an OPTIONAL second arg — a non-empty `entityIds` sends a snake_case `{ entity_ids: [...] }` body (mirrors the new `GeneratePersonasRequest` backend model) restricting generation to a character subset (Cast per-member "Generate persona"); omitting it (or `entityIds: []`) sends NO body — byte-identical to the prior 1-arg call (whole-video). The prior signature still type-checks (additive). **0.49.0 additions (dashboard A-DM0 — DM scene control):** `DmDirectiveKind` (`'enter_world'|'exit_world'|'seek_video'|'set_experience_source'` — single-sourced with the backend `DM_DIRECTIVE_KINDS`) + `DmDirectiveEvent` `{ type:'dm_directive'; timestamp?; directive: DmDirectiveKind; params: Record<string,unknown> }`. Additive type exports only; no public export removed/renamed. See [CHANGELOG.md](./CHANGELOG.md). |
24
- | `admin` | **0.19.0 (GitHub #215 Phase 2):** `AdminClient` — the prompt-defaults editor surface. Constructed with the **chat** base URL + session token (the admin router is mounted in `api/chat/app.py`). Methods: `listPromptDefaults()` → `PromptDefaultsListResponse`; `getPromptDefault(key)` / `updatePromptDefault(key, {value})` / `revertPromptDefault(key)` → `PromptDefaultDetail`. Types: `PromptDefaultSource` (`'db'|'code'`), `PromptDefaultSummary`, `PromptDefaultDetail`, `UpdatePromptDefaultRequest`. **0.24.0 (M12 Slice 5 — eval-observability reader):** added `listEvalRuns(params, {signal})` → `EvalRunsListResponse` (one cursor page) and `listAllEvalRuns(params, {signal})` → `AllEvalRunsResult` (`{runs, truncated}`; follows `nextCursor` until null, capped at `MAX_EVAL_RUN_PAGES = 50` — stops not throws, and sets `truncated: true` when the cap is hit with pages still pending so the page warns rather than presenting a partial series as complete). `params` carries the XOR selector `benchmarkId` **or** `promptVersion` (server returns 422 on neither/both) + optional `limit`/`cursor`. Types: `EvalRunSummary`, `EvalRunsListResponse`, `ListEvalRunsParams`, `AllEvalRunsResult` (mirror `api/admin/schemas.py` exactly). The `/observability` web page is the consumer (charts metric scores per `promptVersion`, one line per `modelId`, grouped client-side). **Additive only** — no `ApiClient` export changed. Shares the internal `http.ts` `requestJson` helper that `ApiClient.makeRequest` now also delegates to (DRY, private — not re-exported). The server enforces the editable-key carve-out (extraction keys are not editable → 404 → thrown `Error`). **R6d (read-only regen base prompts):** added `listRegenBasePrompts()` → `RegenBasePromptsResponse` (`GET /api/v1/admin/regen-prompts`; types `RegenBasePrompt`/`RegenBasePromptsResponse` mirror `api/admin/schemas.py`; `editable` always `false`, no write method exists). Also additive on `api.ts`: `RegenerateRequest.appliedDocumentIds?: string[] | null` (cap 20; server silently dedups + drops unknown ids) and `RegenerationRunResponse.appliedDocumentIds?: string[]` mirror the R6c backend fields. **0.47.0 (C4 Phase 3 — admin monitoring tools, data layer):** added a separate read-only `MonitoringClient` (also chat-base + session token) wrapping `/api/v1/admin/monitoring/*`: `listMetrics()` → `MonitoringMetricCatalogResponse` (the allowlist; pick a `metricId` — no raw namespace/name pass-through), `getMetricSeries(metricId, {rangeSeconds, periodSeconds}, {signal})` → `MonitoringMetricSeriesResponse` (CloudWatch GetMetricData; unknown id → 404 → thrown `Error`), `listTraces({jobId, videoId, rangeSeconds}, {signal})` → `MonitoringTraceSummariesResponse` (X-Ray; bad annotation id → 422), `getTraceDetail(xrayTraceId, {signal})` → `MonitoringTraceDetailResponse` (`found=false` when X-Ray has no such trace). Types mirror `api/admin/schemas.py` exactly. **Additive only** — no `ApiClient` export changed. |
25
- | `reactor/` | Pure builders for the `/interactive` page in seer-agent (and reusable by the Vue Web-App). `buildRegenPrompt(input)` produces deterministic Gemini Flash Image prompts with locked 16:9 + identity guarantees plus a creative-direction escape hatch. `buildUpsamplePrompt(input)` returns `{system, user}` message blocks for any LLM transport, encoding the Helios prompt-guide rules and weaving in entity/persona/previous-prompt context. `aggregateEntityContext` and `aggregatePersonaContext` adapt our existing `ImageRecord` / `EnrichmentRecord` / `PersonaConfig` types into the canonical context shapes. **Phase 2:** `mapEnrichmentToTimeline(enrichment, opts)` consumes a `EnrichmentRecord` and returns a `TimelineBeat[]` (chunk-pinned prompts) for the `/interactive/director` timeline UI. Defensively probes multiple Pegasus result shapes. **Phase 3:** `heliosTools.ts` — `HeliosCommand` (discriminated union), `parseHeliosCommands(text)` (extracts `[SET_SCENE: "…"]`-style inline markers from streamed chat output), `stripHeliosCommands(text)` (removes markers from the displayed transcript), and the future-use `BEDROCK_TOOL_SCHEMAS` Converse-tool-spec export. `dmSceneControlPrompt.ts` (**A-DM2, 0.50.0**) — the SINGLE canonical `[SCENE:...]` scene-control vocabulary (`getDmSceneControlPromptText()` + `DM_SCENE_CONTROL_ADDON_SENTINEL`), mirroring the backend `shared/adventure_prompts.py::DM_SCENE_CONTROL_INSTRUCTIONS` (parsed by `DM_SCENE_TAG_PATTERN`). `toolPromptAddon.ts` — `HELIOS_WORLD_STEERING_ADDON_ID`, `getHeliosSteeringAddonText()` (now **delegates** to `getDmSceneControlPromptText()` — the legacy `[SET_SCENE]` world-steering prose is RETIRED, tech-debt #113; the export + addon id are kept for the pinned consumer), idempotent `buildHeliosSteeringSystemPrompt(base)` for personas with `prompt_addon_ids: ['helios-world-steering']`. NOTE: the `heliosTools.ts` runtime command layer above (`HeliosCommand`/`parseHeliosCommands`/`BEDROCK_TOOL_SCHEMAS`) is a SEPARATE, unchanged concern (world-adapter command dispatch, not model-facing steering prose). `entitySearch.ts` — `findEntityImageBySeedName(apiClient, videoId, name)` resolves an entity name to its `ImageRecord` (searches `extracted` then `character`, case-insensitive). Per-`(videoId, category)` in-process cache so repeat SWAP_SEED commands skip the API round-trip; `forceRefresh: true` and `clearEntitySearchCache()` bypass it. `heliosCommandDispatcher.ts` — `dispatchHeliosCommand(cmd, ctx)` executes a `HeliosCommand` against a structural Reactor bridge (`sendCommand` + `uploadFile`); pure async function, no React. `HeliosToolContext.signal?: AbortSignal` cancels in-flight upsample + seed-image work on unmount. `seedImageOrchestrator.ts` — `loadSeedImageFile(imageId, apiClient)` + `sendSeedFileToReactor(file, reactor, opts)` + convenience `loadAndApplySeedImage`. Used by all three `/interactive` React pages AND by the SWAP_SEED branch of the dispatcher, so the load → upload → set_image sequence has exactly one implementation. No `@reactor-team/js-sdk` dependency — that stays in the consuming app. `applyScenePrompt.ts` — `applyScenePrompt({prompt, apiClient, reactor, currentChunk, isRunning, ...})`: shared submit policy for a live Helios session. `!isRunning` → `set_prompt` + `start`; running → `schedule_prompt` at `currentChunk + 2`. Upsample failure falls back to the raw prompt; abort propagates. Used by both `InteractiveController` and the watch-page `HeliosWorldControls` so the two pages cannot diverge. **LongLive-v2 director initiative (Step 2, additive, land-dark — no version bump, R1e releases):** `longLiveCommandDispatcher.ts` — `dispatchLongLiveCommand(cmd, ctx)`, the `dispatchHeliosCommand` analogue for the Reactor **LongLive-v2** world model over the **SAME Reactor transport** (only the `modelName` differs). `LongLiveCommand` is its OWN discriminated union (`set_shot`/`scene_cut`/`schedule_shot`/`schedule_scene_cut`/`pause`/`resume`/`reset`/`set_seed`) — NOT a `HeliosCommand`. Mappings to `reactor.sendCommand`: `set_shot{prompt}` → `set_shot` then `start` **only when `!ctx.hasStarted`** (the opening-shot-then-start guard, mirroring Helios `set_scene` chunk-0); `scene_cut{prompt}` → `scene_cut` (a HARD, memory-purging transition Helios lacks); `schedule_shot`/`schedule_scene_cut` use the snake_case `at_session_chunk` wire field; `pause`/`resume`/`reset` → `{}`; `set_seed{seed}` → `set_seed`. `LongLiveToolContext` is NARROWER than `HeliosToolContext`: `reactor: Pick<HeliosReactorBridge, 'sendCommand'>` (reuses the structural bridge — **no rename, no `uploadFile`**: LongLive is text-to-video with NO image conditioning, hence **NO `swap_seed`**), `hasStarted?`, `signal?`, `onUserWarning?`. Same failure policy: clean abort silent (reuses `isAbortError`), other failures logged + skipped. **SDK-free** (no `@reactor-team/js-sdk` import). **R8.1 (0.39.0):** `storyTimeline.ts` — `deriveStoryTimeline(scenes: SceneView[], options?)` maps the collapsed R5 `detail=story` projection (one `SceneView` per scene) to `TimelineBeat[]`: one beat per scene, prompt grounded in the scene summary + featured-character names + location label, scene-id provenance in the `label`. The **story-graph-driven sibling** of `mapEnrichmentToTimeline` (which stays the labelled FALLBACK for graph-less videos). `chunkDistribution.ts` (internal — NOT barrel-exported) holds the shared `computeChunkIndices`/`enforceSpacing` so BOTH mappers share ONE chunk-distribution algorithm (extracted from `scenesFromEnrichment.ts`; DRY — one place can break). `StoryTimelineOptions` mirrors `MapEnrichmentOptions`. Spec: [`specs/interactive-helios-prototype.md`](../../specs/interactive-helios-prototype.md). |
26
- | `adapters/` | **R1a (Platform Experience Restructure):** the framework-agnostic model-adapter registry primitive every later R1 adapter (image / world / director domains) registers into. **Zero React / DOM / provider-SDK imports** — same discipline as `reactor/` and `vision/`. `capabilities.ts` — `Capability` is the single capability union, formed by **extending** the existing `ChatModelCapability` (`api.ts:499`, the source of truth that mirrors `shared/model_config.py:CAPABILITY_*`) with the net-new TS-only domains `ImageCapability` (`'image_gen'|'image_edit'|'identity_preserve'`), `WorldCapability` (`'world_stream'|'set_scene'|'swap_seed'|'pause_resume'`), `DirectorCapability` (`'timeline_schedule'|'enrichment_driven'`). There is **no parallel `CAPABILITY` const map** — extend the union, don't re-spell the four chat strings. `registry.ts` — `AdapterRegistry<TDescriptor extends ModelAdapterDescriptor>` ({ `domain`, `routes`, `fallbackRouteName` }): `register()` is additive and **throws on a duplicate id** (no silent overwrite); `get`/`list`/`listWithCapability(cap)`; `resolveRoute(name)` returns the named route's adapter and **degrades to the fallback route's adapter when the route's adapterId is unregistered — NEVER throws** (parity with `shared/model_router.py:344-360`); `satisfies(id, required)` is true iff the id is registered and advertises every required cap. Route names are the exported `ROUTE_DEFAULT`/`ROUTE_FALLBACK`/`ROUTE_HIGH_QUALITY` string constants (the `ROUTE_*` analogue of `shared/model_router.py:56-59`), never inline literals. `ModelAdapterDescriptor.metadata` is opaque/forward-compat — carried, not interpreted. **R1b** adds `chatAdapter.ts` — `loadChatAdapterRegistry(client)` hydrates an `AdapterRegistry<ChatAdapterDescriptor>` from `GET /api/v1/chat/models` and is a **FACADE over the backend**: model selection stays server-side in `shared/model_router.py`, so there is **no `route()` / client-side selection table** here — it only mirrors the catalogue (one descriptor per model, `capabilities` copied VERBATIM) so the UI can list / `listWithCapability` / auto-switch. `ROUTE_DEFAULT`/`ROUTE_FALLBACK` both mirror the resolved default id (parity with `api/chat/app.py:686-697`: `defaultModelId` when present in models, else the first model by `(provider, id)`; empty models → `''` sentinel so the constructor guard still passes and `resolveRoute` degrades to `undefined`, never throws). **R1c** adds `imageAdapter.ts` — `loadImageAdapterRegistry(client)` hydrates an `AdapterRegistry<ImageAdapterDescriptor>` from `GET /api/v1/images/models` (via `ApiClient.listImageModels()`, served on the **chat** base URL since the images API is mounted on the chat app). Same FACADE discipline as the chat adapter — image generation still resolves to Gemini in the pipeline unchanged (R1c is land-dark); this only mirrors the catalogue so a future UI (R6) can list / `listWithCapability('identity_preserve')`. `ROUTE_DEFAULT` mirrors the `isDefault`-flagged model id (else first by id), and `ROUTE_FALLBACK` the `isFallback`-flagged model (the registry's real fallback; mirrors default when none flagged) — empty models → `''` sentinel so the constructor guard still passes and `resolveRoute` degrades to `undefined`. `ImageModelInfo`/`ImageModelsResponse` wire types live in `api.ts` (`capabilities: string[]` — cast to `Capability[]` only inside the adapter to avoid an `api.ts`↔`capabilities.ts` cycle). **R1d** adds `worldAdapter.ts` + `directorAdapter.ts` — the net-new WORLD (step-into-video) and DIRECTOR registries, seeded with the one model that exists today: **Helios**. `worldAdapter.ts` — `WorldAdapterDescriptor` extends `ModelAdapterDescriptor` with `supportedCommands: readonly string[]` (**model-agnostic** — the registry holds heterogeneous world models; a sibling such as a Reactor LongLive adapter has its OWN command vocabulary `set_shot`/`scene_cut`/… that is not a `HeliosCommand`); `heliosWorldAdapter` (`id:'helios'`, provider `'reactor'`, caps `['world_stream','set_scene','swap_seed','pause_resume']`, `supportedCommands` = the EXACT `HeliosCommand` variant set from `reactor/heliosTools.ts:32-37`) **CENTRALIZES the `'helios'` model-name literal** so the R8 page rewire stops hard-coding it; `createWorldRegistry()` pre-registers it with `ROUTE_DEFAULT`+`ROUTE_FALLBACK` both → its id; `requiredCapabilityForCommand(cmd)` is the pure exhaustive-switch mapping (`set_scene`→`'set_scene'`, `swap_seed`→`'swap_seed'`, `pause_world`/`resume_world`→`'pause_resume'`, `reset_world`→`'world_stream'`). `dispatchWorldCommand(adapterId, cmd, ctx)` routes **in FRONT of the existing `dispatchHeliosCommand`** (NOT a rewrite): the Helios branch delegates with **IDENTICAL args** — the live Helios path is UNCHANGED (LAND-DARK) — and an unknown id throws the typed `UnsupportedWorldAdapterError` WITHOUT touching the bridge. It reuses the structural `HeliosReactorBridge` via `HeliosToolContext` — **no `@reactor-team/js-sdk` import**, the adapters/ submodule stays SDK-free. `directorAdapter.ts` — `DirectorAdapterDescriptor` extends `ModelAdapterDescriptor` with `worldAdapterId`; `heliosDirectorAdapter` (`id:'helios-director'`) backs onto `heliosWorldAdapter` and its `capabilities` are the director members `['timeline_schedule','enrichment_driven']` **plus the four world caps it inherits via `worldAdapterId`** (deduped); `createDirectorRegistry()` pre-registers it. **LongLive-v2 director initiative (Step 2 — additive, land-dark, no version bump):** `worldAdapter.ts` adds `longLiveWorldAdapter` (`id:'longlive-v2'`, displayName `'LongLive 2.0'`, provider `'reactor'`, caps `['world_stream','set_scene','scene_cut','pause_resume']`, `supportedCommands` = its 8 LongLive command strings). The **ASYMMETRIC capability matrix** holds via `registry.satisfies`: Helios HAS `swap_seed` and NOT `scene_cut`; LongLive HAS `scene_cut` (a hard memory-purging transition) and NOT `swap_seed` (text-to-video, no image conditioning). `createWorldRegistry()` now registers **both** adapters; **world `ROUTE_DEFAULT`+`ROUTE_FALLBACK` STAY Helios** (plain `/interactive` unchanged — LongLive is resolvable by id + `listWithCapability('scene_cut')` but is NOT the world default). `dispatchWorldCommand` is **widened via FUNCTION OVERLOADS** that keep exact `(adapterId, cmd, ctx)` typing per adapter — `'helios'` → `dispatchHeliosCommand` (BYTE-IDENTICAL to R1d), `'longlive-v2'` → `dispatchLongLiveCommand`, unknown → throw. **No per-command runtime capability gate** (the R1d review removed the unreachable `satisfies` scaffolding): the overloads enforce the cmd/adapter match at compile time, and the asymmetric-matrix INFO is consumed via `registry.satisfies()` by the Step-3 director UI (to hide the seed-image control for LongLive), not a dispatch gate (resolves tech-debt #414). `directorAdapter.ts` adds `longLiveDirectorAdapter` (`id:'longlive-director'`, backs onto `longLiveWorldAdapter`, inherits `scene_cut` + the director members, NOT `swap_seed`). **THE DIRECTOR-DEFAULT FLIP:** `createDirectorRegistry()` registers both directors and points `ROUTE_DEFAULT` → `'longlive-director'`, `ROUTE_FALLBACK` → `'helios-director'` (the world default stays Helios; only the DIRECTOR default flips). LAND-DARK — nothing reads the director route until **Step 3 wires the web director page**; the live `/interactive` and `/interactive/director` pages are UNCHANGED (their `modelName="helios"` literals stay; **R8 migrates the pages**). **Purely additive to client-core** — no existing public export removed/renamed (the sibling Vue Web-App pins this package); Steps 1–2 carried no version bump (the release is R1e). **R1e (0.25.0 — R1's release):** `index.ts` adds the aggregator `createPlatformRegistries(client): Promise<PlatformRegistries>` — the **single entry** every downstream wave imports to get all four registries pre-wired. `world` + `director` are synchronous seeds (Helios world default; LongLive-v2 director default); `chat` + `image` load from their backend catalogues via the existing facades in parallel. It makes NO selection decision — it only composes `loadChatAdapterRegistry`/`loadImageAdapterRegistry`/`createWorldRegistry`/`createDirectorRegistry` (DRY). `PlatformRegistries` = `{ chat, image, world, director }`. The `seer-agent` `web/` `/admin/adapters` showroom inspector is the first consumer; additive-only (no export removed/renamed). |
27
- | `conversation/` | **R2.1 (0.26.0 — Conversation panel core):** the framework-agnostic, headless **conversation state** primitive that lets React (R2.2) and a game engine (PlayCanvas, R7) render the **same** controller. **Zero DOM** — same discipline as `reactor/`/`adapters/`. `participant.ts` — `ConversationParticipant` `{ participantId; personaId?; role; presence; modelId?; capabilities? }` + the frozen constant objects `ParticipantRole` (`persona`/`dm`/`user`) and `PresenceKind` (`PRESENCE_NONE`/`PRESENCE_FACE_2D`/`PRESENCE_AVATAR_3D`) — constants, never inline literals. `presenceRegistry.ts` — `PresenceRendererRegistry` (mirrors `reactor/promptAddonRegistry.ts`): `register(kind, factory)`/`resolve(kind)`/`has(kind)`; a factory returns an opaque `PresenceHandle` (`mount`/`update`/`destroy`) so React and a game engine register their own renderer; **THROWS on duplicate register** (fail-loud) and **returns the `PRESENCE_NONE` no-op for any unregistered kind** (fail-soft — this is what lets the reserved `PRESENCE_AVATAR_3D` stub render nothing until R7; tech-debt #421). `binding.ts` — `ConversationContextBinding` `{ kind: 'video'|'studio_session'|'persona'|'none'; videoId?; personaId?; entityId?; adventureSessionId?; partyPersonaIds?; systemPrompt?; systemPromptOverride? }` + the `ConversationContextKind` constant + a single `toHelloArgs(binding)` mapper that maps **1:1 onto `buildHelloPayload`** so there is exactly one hello-builder (DRY). **0.48.0 (dashboard B1):** the `PERSONA` kind + the `personaId` field make a standalone persona-face chat a DISTINCT binding so the floater's switch-persona path rebinds (`conversationBindingKey` keys on `personaId`) instead of colliding on a shared `NONE` key; `personaId` is also a `buildHelloPayload` arg (same falsy-drop land-dark contract as the other id fields), and the controller still overlays the active participant's `personaId` on top. `effectiveModel.ts` — `resolveEffectiveModel({ boundModelId, capabilities, needed, override, registry })` is the **single, pure** capability auto-switch (no I/O; R3's vision picker CONSUMES it — there is no parallel `resolveVisionCapability`): returns `{ modelId; reason: 'bound'|'override'|'auto_switch'; switchedFrom?; needed }`. Capability facts come ONLY from the injected R1 chat registry (`listWithCapability`/`satisfies`, typed as a narrow `Pick<>` so the helper depends on just those two methods) — R2 never hardcodes which models are vision-capable, and **fails SOFT to `bound`** when no model advertises the needed capability (a config state the panel surfaces, not a crash). `controller.ts` — `ConversationController`, a **thin state+reducer over the existing `ChatWebSocket`** (it does NOT reimplement transport/reconnect/protocol): holds participants/activeParticipant/`contextBinding`/`modelOverride?` + a reference to the R1 chat registry; `connect()`/`send(text)`/`setModelOverride`/`clearModelOverride`/`addParticipant`/`removeParticipant`/`setActiveParticipant`/`dispose()`; emits a typed `onState(snapshot)` callback (no framework events); the sole `buildHello()` builds the hello once via `buildHelloPayload(toHelloArgs(binding))`; re-derives advisory `partyPersonaIds` (matching `chat-ws/adventureMode.ts`) on participant changes. **Socket adoption:** the constructor takes an optional `existingSocket?: ChatWebSocket` — when supplied it ADOPTS that socket (opens none) and `dispose()` does **NOT** close it (the owner does) — the Watch shared-socket invariant (R2.4) so the dispatcher reads one `FrameBuffer`. **ADDITIVE-ONLY:** `Citation`/`PlaybackState`/`ChatModelCapability` are IMPORTED from `websocket.ts`/`api.ts`, never re-declared (avoids the ambiguous-export trap). **R2.3 (0.30.0):** the controller's hello is **`mode:'text'`, always** (it previously inherited `buildHelloPayload`'s `tts_stt` default, which would have routed the first self-driving `connect()` into the backend voice pipeline — the controller owns TEXT conversations; the voice hello stays page-owned per the R2.2 finding), `onMessage(handler): () => void` is the additive reply-event seam (a passthrough to `ChatWebSocket.onMessage`/`offMessage`) so a renderer can consume `token`/`citation`/`done`/`error`/`turn_changed` frames without reaching into a privately-owned socket, and `send(text, opts?)` gains additive `opts.messages` (`ConversationSendOptions`/`ConversationHistoryMessage`) — the transcript-owning renderer passes prior turns per send because the backend builds `conversation_history` solely from each send's `messages` field (omitted/empty ⇒ wire unchanged). **R7.1 (0.35.0 — portable conversation runtime):** the multi-persona runtime joins the subsystem. `router.ts` — advisory routing helpers lifted verbatim from `web/app/chat-ws/adventureMode.ts` (`MultiPersonaFrameFields`, `turnChangedSpeakerId`, `resolvePersonaPill`+`PillPersona`, `advisoryPartyPersonaIds`); **ADVISORY ONLY** — the server `agents/orchestrator/persona_router.py` `resolve_addressed_persona` is authoritative, the client never routes a turn, it only renders the server's `turn_changed`. `roster.ts` — `ADVENTURE_MUTATION_TOOLS` (the SINGLE copy of the four DM mutation tool names, mirroring `shared/tool_schemas.py`), `isAdventureMutationTool`, `shouldRefreshAdventureRail` (the one land-dark gate on adventure-state refresh), `filterPartyCandidates`+`PartyCandidatePersona`. `runtime.ts` — `ConversationRuntime` (`src/conversation/runtime.ts:33`): a pure reducer/observer over the existing `ChatWsEvent` union — `applyFrame(event)` / `getState(): ConversationRuntimeState` / `subscribe(listener)` (fault-isolated, returns unsubscribe) / `acknowledgeAdventureState()` / `releaseTurn(personaId)` (R7.2, additive: the host removed the persona holding the turn — `activePersonaId` returns to null; the only host-driven speaker transition, `turn_changed` remains the only way the speaker MOVES to a persona). The speaker ONLY moves on a server `turn_changed` while an adventure is active; `done` finalizes the per-message persona pill; a DM-mutation `tool_result` sets `staleAdventureState` for the host to re-fetch+ack. Immutable state-per-transition, listeners fire only on actual change. `types.ts` — `RosterParticipant`/`ConversationRuntimeState`/`ConversationRuntimeOptions` (REUSES the R2.1 `PresenceKind` constants — never re-declared, per the ambiguous-export trap). **PlayCanvas portability:** the runtime has zero React/DOM imports and runs in plain node — a 3D host feeds it the same frames and renders `ConversationRuntimeState` directly; the renderer seam (`PresenceAdapter`) lands in R7.3. Caveat for any engine host: client routing stays advisory — never promote the router helpers to a turn decision. **R7.3 (0.36.0 — `PresenceAdapter` seam, the portability contract):** `presence.ts` — `PresenceAdapter`, the renderer-agnostic interface the runtime drives: `mount(participant)`/`unmount(personaId)`/`setActiveParticipant(personaId|null)`/`setSpeaking(personaId, speaking)`/`applyViseme(personaId, viseme: VisemeSymbol)` — every method keyed by `personaId` (N participants → N presence slots, renderer-independent); `applyViseme` takes the *scheduled viseme value* from the existing `visemeScheduler` pipeline, NEVER a DOM node (the React adapter applies it to SVG, a PlayCanvas adapter to morph targets); `presenceKindHasStage(kind)` is the single text-only gate (a `PRESENCE_NONE` seat receives nothing beyond `mount`/`unmount`). Adapter *selection* stays on the R2.1 `PresenceRendererRegistry` — no parallel kind→factory map. `presenceBus.ts` — `bindPresence(runtime, adapter): PresenceBinding`, pure glue (no renderer dependency): bind mounts the roster + stages the initial speaker; a speaker swap emits `setActiveParticipant(next)` + `setSpeaking(prev,false)` + `setSpeaking(next,true)`; an unstaged/unknown speaker clears the stage to `null`; `PresenceBinding.applyViseme` is the SINGLE viseme delivery path (R7.5's voice module consumes it — never instantiate a second path); `dispose()` is idempotent. **Headless conformance harness:** `src/__tests__/conversation/headlessRenderer.ts` (`RecordingPresenceAdapter`) + `presenceBus.test.ts` pin the exact call sequence a real renderer receives for a 3-participant cue chain, in plain node — the executable proof of PlayCanvas-portability; an engine implements `PresenceAdapter` against that sequence with zero client-core changes. **R7.4 (0.37.0 — Studio cast roster projection):** `rosterProjection.ts` — `castToRoster({ cast, dmPersona, partyPersonaIds })` (`src/conversation/rosterProjection.ts:55`): the single DRY projection turning R5's one-call cast-with-persona response (`getCast` → `CastEntry[]`) + the active `AdventureState` into `RosterParticipant[]` (DM seat first, then party members in party order; de-duplicated, DM never doubled; every server-party member gets a seat even when absent from the cast so a `turn_changed` speaker can always be staged). This is the one place the renderer-facing roster is built — it replaces the pre-R7.4 client-side `entity_id ∈ storyCharacterEntityIds` join across two stores. Pure (no I/O/DOM/React). **R7.5 (0.38.0 — overlay voice parity):** `voice.ts` — `VoiceSession` (`src/conversation/voice.ts`): the framework-agnostic voice pipeline driving a full STT/TTS/mic/viseme round-trip over the SAME `ChatWebSocket` the controller owns/adopts. A THIN composition (not a re-implementation): it composes the existing `AudioPipeline` (player + `VisemeScheduler` + `AudioSessionClient` barge-in + sentence anchoring) + `MicrophoneRecorder`, and builds the voice (`tts_stt`) hello through the SINGLE `buildHelloPayload` — **no second viseme scheduler, no second hello-construction site**. `buildHello()` is fixture-diffed against the page's `startVoiceChat()` payload (the parity oracle, `voice.test.ts`); `start()` mirrors the page's iOS user-gesture priming order EXACTLY (player + `recorder.prime()` in the synchronous prefix — callers MUST invoke it from a click handler's sync prefix); `interrupt()` = barge-in; `dispose()` NEVER closes the socket (the Watch shared-socket invariant). Visemes flow through one `onViseme` callback the renderer routes onto R7.3's `PresenceAdapter.applyViseme` (the single delivery path). `ConversationController` gains additive `voiceSocket()` (hands the shared socket to a `VoiceSession`) + `voiceHelloArgs()` (the single hello-args input: context + active persona/model). The text-only overlay default is unchanged (`mode:'text'`; voice is per-conversation opt-in); `/chat-ws` stays the page-owned parity oracle (its collapse onto `VoiceSession` is tech-debt #470). **SP1 (0.52.0 — persona system-prompt on the binding):** `binding.ts` gains optional `systemPrompt?`/`systemPromptOverride?` (both already valid `buildHelloPayload`/`HelloArgs` fields), and `toHelloArgs` maps them with the same falsy-drop as the id fields — an empty/absent prompt drops **both** keys, the override flag only rides when a prompt is present (mirrors `buildHelloPayload`'s `systemPrompt ? {…} : {}` gate). The fix: the `text` send path reads the prompt from the frame (`api/chat/ws.py` `SendActionMessage.systemPrompt`) and does NOT load the persona server-side (only the `tts_stt` hello does, via `_merge_persona_into_hello`), so a standalone persona chat that carried only `personaId` replied in the **default** assistant voice. `controller.send(text, opts?)` now threads `systemPrompt`/`systemPromptOverride` onto the frame with **client-override-wins** (an explicit `opts.systemPrompt` beats the binding's prompt — matching `_merge_persona_into_hello`'s contract), and `buildHello()` carries the prompt automatically (it already spreads `toHelloArgs()`). The web floater passes `persona.custom_system_prompt`/`system_prompt_override` into the `open()` binding so a TYPED turn replies in-character. Land-dark: a persona with no custom prompt is byte-identical on the wire. |
28
-
29
- ## Layout
17
+ Two peer dependencies are **optional** — install them only if you use the feature that loads them.
18
+ Both are dynamically imported at the point of use, so a consumer that skips them never resolves
19
+ them.
30
20
 
31
- ```
32
- src/
33
- audioProtocol.ts
34
- audio.ts
35
- visemeScheduler.ts
36
- visemeGeometry.ts
37
- timeFormat.ts ← 0.10.0: formatTimestamp + formatCitationTimestamp
38
- graphSchema.ts ← 0.12.0: graph whitelists + 2 provenance unions; 0.13.0: session-cached fetchGraphSchema(); 0.15.0: Scene/PlotBeat/CharacterArc + userCreatableLabels/userCreatableEdges/allowedPairs (M7 P3a); 0.39.0: STUDIO_NODE_LABELS/STUDIO_EDGE_TYPES/STUDIO_NODE_PROPERTIES/STUDIO_CHARACTER_TYPE read-surface vocab (R8.1)
39
- storyGraph.ts ← 0.39.0: deriveScenes/deriveCast + SceneView/CharacterView/ArcView (lifted from web studio; the single story projection Studio + Director share) (R8.1)
40
- toolSchemas.ts ← 0.11.0: AGENT_TOOL_SCHEMAS (mirror of shared/tool_schemas.py)
41
- websocket.ts
42
- api.ts
43
- vision/ ← Phase 2 vision publisher
44
- VisionPublisher.ts ← RTCPeerConnection lifecycle + SDP/ICE
45
- visionScheduler.ts ← fps back-pressure (pure helper)
46
- types.ts ← VisionPublisherConfig, VisionStatus, …
47
- credentials.ts ← 0.10.0: toVisionRtcCredentials()
48
- startVisionPublisher.ts ← 0.10.0: startVisionPublisher() + types
49
- sourceKinds.ts ← 0.31.0 (R3a): VISION_SOURCE_KINDS + descriptors
50
- VisionSourceController.ts ← 0.31.0 (R3a): source acquisition + lifecycle
51
- index.ts ← submodule re-exports
52
- __tests__/
53
- VisionPublisher.test.ts
54
- visionScheduler.test.ts
55
- reactor/
56
- types.ts
57
- regenTemplate.ts
58
- upsamplePrompt.ts
59
- entityContext.ts
60
- scenesFromEnrichment.ts ← Phase 2 timeline mapper (raw Pegasus enrichment → beats; the labelled fallback)
61
- chunkDistribution.ts ← R8.1: shared computeChunkIndices/enforceSpacing (BOTH mappers; internal, not barrel-exported)
62
- storyTimeline.ts ← R8.1: deriveStoryTimeline (collapsed R5 story projection → beats; sibling of scenesFromEnrichment)
63
- heliosTools.ts ← Phase 3 marker grammar
64
- toolPromptAddon.ts ← Phase 3 system-prompt addon
65
- toolPromptAddonId.ts ← Phase 3 addon ID constant
66
- entitySearch.ts ← Phase 3 SWAP_SEED lookup (cached)
67
- heliosCommandDispatcher.ts ← Phase 3 HeliosCommand executor (abort-aware)
68
- longLiveCommandDispatcher.ts ← LongLive-v2: dispatchLongLiveCommand (set_shot/scene_cut/schedule_*/set_seed; SAME Reactor bridge, text-only, abort-aware)
69
- seedImageOrchestrator.ts ← Phase 3+ load → upload → set_image
70
- sceneEntry.ts ← Step-Into-Scene orchestrator (extract + upsample + bootstrap)
71
- applyScenePrompt.ts ← Shared upsample + chunk-0-vs-running submit policy
72
- index.ts ← submodule re-exports
73
- adapters/ ← R1a: framework-agnostic model-adapter registry (no React/DOM/SDK)
74
- capabilities.ts ← Capability union = ChatModelCapability (api.ts) + image/world/director caps
75
- registry.ts ← AdapterRegistry + ModelAdapterDescriptor/NamedRoute + ROUTE_* constants
76
- chatAdapter.ts ← R1b: loadChatAdapterRegistry — FACADE over /chat/models (selection stays server-side)
77
- imageAdapter.ts ← R1c: loadImageAdapterRegistry — FACADE over /images/models (catalogue; R1 owns registry, R6 consumes)
78
- worldAdapter.ts ← R1d + LongLive: helios/longLiveWorldAdapter + createWorldRegistry (both; world default stays helios) + dispatchWorldCommand (per-adapter overloads → dispatchHelios/LongLiveCommand; SDK-free)
79
- directorAdapter.ts ← R1d + LongLive: helios/longLiveDirectorAdapter + createDirectorRegistry (both; DIRECTOR default FLIPPED to longlive-director, fallback helios-director)
80
- index.ts ← submodule re-exports
81
- index.ts ← top-level re-exports
82
- __tests__/
83
- api-pollers.test.ts
84
- audio.test.ts
85
- loadBundleManifest.test.ts
86
- visemeGeometry.test.ts
87
- visemeScheduler.test.ts
88
- adapters-capabilities.test.ts ← R1a: Capability ↔ imported ChatModelCapability assignability
89
- adapters-registry.test.ts ← R1a: register/get/list/listWithCapability/resolveRoute/satisfies
90
- adapters-chat.test.ts ← R1b: loadChatAdapterRegistry facade (verbatim caps, default tiebreak, empty-safe)
91
- adapters-image.test.ts ← R1c: loadImageAdapterRegistry facade (verbatim caps, isDefault route seed, identity_preserve filter, empty-safe)
92
- adapters-world.test.ts ← R1d + LongLive: createWorldRegistry seeds, supportedCommands↔HeliosCommand parity, asymmetric matrix via satisfies, dispatchWorldCommand helios delegation + longlive routing + unsupported-adapter throw
93
- adapters-director.test.ts ← R1d + LongLive: createDirectorRegistry seeds, inherited world caps via worldAdapterId, DIRECTOR default flip (longlive-director) + fallback helios-director
94
- longLiveCommandDispatcher.test.ts ← LongLive: each LongLiveCommand → correct sendCommand call(s) (set_shot+start guard, snake_case at_session_chunk, abort no-op)
95
- reactor/
96
- api-reactor.test.ts
97
- entityContext.test.ts
98
- regenTemplate.test.ts
99
- upsamplePrompt.test.ts
100
- scenesFromEnrichment.test.ts
101
- heliosTools.test.ts
102
- toolPromptAddon.test.ts
103
- entitySearch.test.ts
104
- heliosCommandDispatcher.test.ts
105
- seedImageOrchestrator.test.ts
106
- ```
21
+ | Optional peer | Version | Needed when |
22
+ |---|---|---|
23
+ | `amazon-kinesis-video-streams-webrtc` | `^2.1.0` | `VisionPublisher` runs in Amazon KVS signalling mode (the backend's vision-RTC credentials endpoint returns `mode: 'kvs'`). Local signalling mode never loads it. |
24
+ | `libopus-wasm` | `^0.2.0` | A `VoiceSession` opts into `offerOpus`. PCM16-only consumers never load it. |
107
25
 
108
- ## Consumption — locally in this repo
26
+ ### Module format
109
27
 
110
- The repo root is an npm workspace covering `packages/*` (client-core's own dev tooling). `web/` is **not** a workspace member — it depends on this package via `"@escapeaihq/client-core": "file:../packages/client-core"`, which makes npm create a symlink in `web/node_modules/@escapeaihq/client-core`. Edits here show up in `web/` immediately. Next.js compiles the TS source through `transpilePackages: ['@escapeaihq/client-core']`, so no build step is required during dev.
28
+ ESM only. The published package exposes a single entry point with `types` and `import`
29
+ conditions — there is no CommonJS `require` path. Type declarations ship with the package,
30
+ alongside the TypeScript sources.
111
31
 
112
- Web was deliberately moved out of the root workspace: npm's workspace lockfiles strict-filter platform-specific optional deps, and a lockfile generated on macOS would break `next build` on Vercel/Linux when it couldn't resolve `lightningcss-linux-x64-gnu`. The `file:` symlink gives the same dev experience without polluting web's lockfile.
32
+ ## Quick start
113
33
 
114
- ## Consumption — sibling repo (web-app)
34
+ ```ts
35
+ import { ApiClient, formatCitationTimestamp } from '@escapeaihq/client-core';
115
36
 
116
- For the sibling Vue `web-app`, `@escapeaihq/client-core` is a regular dep pulled from the **public npmjs.com registry** (MIT). No auth required. `package.json` declares `"@escapeaihq/client-core": "0.5.0"` (pinned exact while pre-1.0). Plain `npm install` / `npm ci` fetches the compiled `dist/` artifact — Nuxt dev SSR and production builds both consume that.
37
+ const api = new ApiClient(
38
+ 'https://api.example.com', // tools / ingestion base URL
39
+ sessionToken, // bearer token, or `undefined` before login
40
+ 'https://chat.example.com', // chat base URL
41
+ );
117
42
 
118
- **Optional: local live edits** via `npm link`, for when you want to iterate here and see changes in `web-app` without re-publishing:
43
+ // Public endpoint — works before login.
44
+ const { models } = await api.listChatModels();
119
45
 
120
- ```bash
121
- # one-time setup, after both repos are cloned side-by-side
122
- cd ~/projects/seer-agent/packages/client-core && npm link
123
- cd ~/projects/web-app && npm link @escapeaihq/client-core
46
+ api.setSessionToken(freshToken); // swap the bearer at any time
47
+
48
+ formatCitationTimestamp(83.45); // "1:23.45"
124
49
  ```
125
50
 
126
- Unlink with `npm unlink @escapeaihq/client-core` to fall back to the registry version. The symlink path used to be the default historic workflow (when the package was on auth-required GitHub Packages); since the move to public npm, the registry path works directly and the symlink is only needed for active cross-repo development.
51
+ Base URLs and tokens are always passed in. The package reads no environment variables and holds
52
+ no application config.
127
53
 
128
- ## Where to run `npm install` when adding/upgrading deps
54
+ ## Module map
129
55
 
130
- The repo deliberately runs three install lifecycles, one per consumer:
56
+ | Area | What it gives you |
57
+ |---|---|
58
+ | REST | `ApiClient` (the whole backend surface behind one facade) plus every request/response type |
59
+ | Admin & identity | `AdminClient`, `MonitoringClient`, `IdentityClient` |
60
+ | Realtime chat | `ChatWebSocket`, the `ChatWsEvent` frame union, typed event subscriptions |
61
+ | Audio & voice | `AudioPipeline`, `MicrophoneRecorder`, `AudioFramePlayer`, `PlaybackTracker`, `AudioSessionClient`, `VoiceSession`, the binary frame codec, optional Opus transport |
62
+ | Lip-sync | `VisemeScheduler` (phoneme timing → mouth shapes) plus pure mouth-geometry path math |
63
+ | Vision | `VisionPublisher`, `VisionSourceController`, `startVisionPublisher`, fps back-pressure scheduling |
64
+ | Conversation runtime | `ConversationController`, `ConversationRuntime`, `PresenceAdapter` + `bindPresence`, roster projections, `ChatSessionStore` |
65
+ | Model adapters | `AdapterRegistry`, `createPlatformRegistries`, per-domain registries and the experience-model catalog |
66
+ | Story graph | The graph-schema vocabulary, `deriveScenes` / `deriveCast`, arc and timeline projections |
67
+ | Creator surfaces | Dashboard, universe, curation and cast projections; visibility filters |
68
+ | Storyboards | Wire types + `StoryboardsApi`, the mask/camera core, the timeline projection |
69
+ | Prompt building | Reactor/Helios prompt builders, world-model orchestrators, prompt compaction |
70
+ | Presentation | Design tokens (`LIGHT_TOKENS` / `DARK_TOKENS`), `parseSeerMessage`, `formatTimestamp` |
71
+
72
+ Everything below is exported from the package root.
73
+
74
+ ## REST — `ApiClient`
75
+
76
+ ```ts
77
+ new ApiClient(baseURL: string, sessionToken: string | undefined, chatBaseUrl: string)
78
+ ```
131
79
 
132
- | Goal | Command | Lockfile that gets updated |
133
- |---|---|---|
134
- | Add/upgrade a dep used by `@escapeaihq/client-core` (jest, ts-jest, typescript, etc.) | `npm install <pkg> --workspace=@escapeaihq/client-core` (from repo root) | repo-root `package-lock.json` |
135
- | Add/upgrade a dep used by `web/` (Next.js, React, Tailwind, etc.) | `cd web && npm install <pkg>` | `web/package-lock.json` |
136
- | Pull in remote changes after a branch update | `npm ci` from repo root, then `cd web && npm ci` | both — neither lockfile is rewritten |
80
+ Two base URLs because the backend runs two apps: the tools/ingestion API and the chat API (which
81
+ also hosts images, videos, orgs, admin and identity routes). `ApiClient` picks the right one per
82
+ method — you never choose.
83
+
84
+ `setSessionToken(token)` swaps the bearer in place. `setOboAssertion(assertion)` attaches a
85
+ server-minted on-behalf-of assertion, carried as the `X-Seer-OBO-Assertion` header on every JSON
86
+ request; the assertion is opaque here (minting and verification stay server-side) and is **sticky**
87
+ on the instance until cleared, so a server that mints per request must use a per-request client or
88
+ clear it after each call.
89
+
90
+ The surface is broad — videos and ingestion jobs, enrichment, transcripts and dialog search, the
91
+ graph editor, personas and voices, projects and orgs, adventures and quests, arcs, enhancements,
92
+ workflows, images and video generation, storyboards, artifacts, universes. Every method is typed
93
+ and every response type is exported; browse the shipped declarations for the full list.
94
+
95
+ Common patterns worth knowing:
96
+
97
+ - Poll helpers wrap the 202-and-poll endpoints: `pollVisemeBundleUntilDone`,
98
+ `pollRegenerationUntilDone`, `pollWorkflowStepUntilDone`. They take `{ intervalMs?, timeoutMs?,
99
+ signal? }`, resolve on a terminal status and throw on failure.
100
+ - Terminal-status sets are exported rather than re-spelled at call sites —
101
+ `REGENERATION_TERMINAL_STATUSES`, `WORKFLOW_TERMINAL_RUN_STATUSES`,
102
+ `ARC_PROPOSAL_TERMINAL_STATUSES` (+ `isArcProposalTerminal`), `RESTORE_TERMINAL_STATUSES`
103
+ (+ `isTerminalRestoreStatus`), `BRANCH_TERMINAL_STATUSES` (+ `isTerminalBranchStatus`),
104
+ `TERMINAL_VIDEO_GEN_STATUSES` (+ `isTerminalVideoGenStatus`), `SERIES_TRANSFER_TERMINAL_STATUSES`.
105
+ Hand-rolled status lists silently miss members such as `'cancelled'` and poll forever.
106
+ - Uploads (`uploadVideo`, `uploadDocument`) use multipart XHR and accept an `onProgress` callback.
107
+ - Binary responses (`auditionPersona`, `getSeedImageBlob`) resolve to a `Blob`.
108
+
109
+ `AdminClient` and `MonitoringClient` are separate, read-mostly clients over the admin routes; both
110
+ take `(chatBaseUrl, sessionToken?)`. `IdentityClient` (same signature) is session-gated rather than
111
+ admin-gated and covers self-service account linking.
112
+
113
+ ## Realtime chat — `ChatWebSocket`
114
+
115
+ An auto-reconnecting wrapper around the native WebSocket with text/binary multiplexing.
116
+
117
+ ```ts
118
+ import { ChatWebSocket } from '@escapeaihq/client-core';
119
+
120
+ const ws = new ChatWebSocket({
121
+ url: 'wss://chat.example.com/api/chat/ws',
122
+ // Prefer fetchToken over a static authToken for short-lived tokens: it is
123
+ // invoked once per connect attempt, including every reconnect.
124
+ fetchToken: () => api.getChatWsToken().then((r) => r.wsToken),
125
+ });
126
+
127
+ await ws.connect();
128
+ ws.onMessage((frame) => { /* frame: WebSocketMessage */ });
129
+ ws.send('who is in this scene?', { videoId });
130
+ ws.disconnect();
131
+ ```
137
132
 
138
- `web/` is not a workspace member (the cross-platform optional-deps issue described above), so `npm install` at the repo root will *not* refresh `web/node_modules`. Always run installs in `web/` separately.
133
+ Inbound frames come in two typings. `ChatWsEvent` is the discriminated union — tokens, citations,
134
+ images, audio chunks, tool results, turn changes, quest-state changes, roster changes, DM
135
+ directives, asides, errors — and is what new code should switch on, because TypeScript narrows each
136
+ case to exactly the fields it carries. `onMessage` handlers are still typed against the legacy flat
137
+ `WebSocketMessage` interface for back-compat; narrow to `ChatWsEvent` in the handler body. Either
138
+ way, a consumer that ignores unknown `type` values degrades safely: new frame kinds are added as new
139
+ members, never by widening an existing one.
140
+
141
+ Some frames also dispatch as typed events via `ws.on(name, handler)` / `ws.off(...)`: the vision
142
+ signalling events, `session_attached` and `presence`.
143
+
144
+ Fire-and-forget publishers (they drop silently when the socket isn't open):
145
+ `sendPlaybackState` for cross-device video↔chat sync, `sendVisionOffer` / `sendVisionIce` /
146
+ `sendVisionClose` / `sendVisionAttach` / `sendVisionDetach` for vision signalling, and
147
+ `sendSessionAttach` / `sendSessionDetach` for server-anchored sessions.
148
+
149
+ Vision refusals arrive in two wire shapes from the same backend handler. `classifyVisionError(raw)`
150
+ normalizes both into one `VisionErrorEvent` (or `null`) with a `VisionErrorReason` of `'rejected'`,
151
+ `'throttled'` or `'failed'`;
152
+ `isVisionScopedChatError(frame)` and `VISION_SCOPED_ERROR_ACTIONS` let a chat surface skip a vision
153
+ refusal rather than render it as a failed turn.
154
+
155
+ ## Audio, voice and lip-sync
156
+
157
+ The binary frame codec is the wire format — a 1-byte tag plus 320 PCM16 samples — with the message
158
+ types for phoneme, word and barge-in metadata, plus the `audio_unavailable` and `voice_fallback`
159
+ frames (a sentence that produced no audio, and a persona speaking in the session voice) and their
160
+ label maps.
161
+
162
+ Audio I/O is built from `MicrophoneRecorder`, `AudioFramePlayer`, `PlaybackTracker`,
163
+ `AudioSessionClient`, and `AudioPipeline` composing them. Barge-in is clean (gain node plus tracked
164
+ active sources), mic and player share one refcounted page-singleton `AudioContext`, the player runs
165
+ an adaptive jitter buffer and an `AudioBuffer` pool, and `setDuck(gain)` / `clearDuck()` lower the
166
+ master gain while another surface is speaking.
167
+
168
+ `VisemeScheduler` maps TTS phoneme timing to mouth-shape changes on `requestAnimationFrame`, locked
169
+ to `AudioContext.currentTime`, and stops the loop when idle. The mouth-geometry helpers are pure path math — inner-lip donut,
170
+ mouth clip ellipse, teeth and tongue geometry.
171
+
172
+ Optional Opus legs ride the same framing. `createOpusTransportCodecs()`
173
+ dynamically imports `libopus-wasm` at a pinned 16 kHz mono VoIP profile; the mic leg encodes to
174
+ `TAG_MIC_OPUS` and the TTS leg decodes `TAG_AI_OPUS` back to legacy PCM16 frames, so the rest of the
175
+ pipeline stays codec-agnostic. `VoiceSession` owns the lifecycle: with `offerOpus` it preloads
176
+ before the hello, offers `['opus', 'pcm16']` only on success and switches both legs when the server
177
+ acknowledges Opus. The default hello is byte-identical PCM16, and a corrupt packet drops the packet,
178
+ never the session.
179
+
180
+ ## Vision publishing
181
+
182
+ `VisionPublisher` takes any `MediaStreamTrack` plus a `ChatWebSocket` and manages the
183
+ `RTCPeerConnection` lifecycle — SDP offer/answer, ICE trickle, restart on disconnect. Signalling is
184
+ dual-mode: Amazon KVS when the backend mints KVS credentials (this is the path that needs the
185
+ optional peer dependency), otherwise the chat-WebSocket protocol. `setFps(target)` retargets the
186
+ sender's `maxFramerate` at runtime, and the initial cap is baked into the first negotiation.
187
+
188
+ `VisionSourceController` owns "turn a chosen local source into a published feed": acquire (camera
189
+ via `getUserMedia`, or a `<video>` element's captured stream with a first-frame gate), mint
190
+ credentials, delegate to `startVisionPublisher`. `switchSource()` tears the previous publisher down
191
+ before acquiring the next; `stop()` is idempotent and leaves zero live tracks. It also honours the
192
+ server's retry budget — inside a throttle window `start()` refuses locally without touching the
193
+ camera and reports the remaining seconds.
194
+
195
+ `createVisionScheduler` is the pure fps back-pressure helper: it halves the publish rate under the
196
+ server's pause signal and eases back up as the buffer drains, clamped to `[minFps, fps]` with
197
+ `VISION_MIN_FPS` = `0.5` as the floor default.
198
+
199
+ Refusals surface as `VisionRefusedError` (`reason`, `retryAfterSeconds`, `traceId`, `recoverable`),
200
+ with `formatVisionErrorMessage` as the single wording.
201
+
202
+ ## Headless conversation runtime
203
+
204
+ Zero DOM. The same controller drives a React panel and a game engine.
205
+
206
+ `ConversationController` is a thin state and reducer layer over `ChatWebSocket` — participants,
207
+ active participant, context binding, model override. It can **adopt** an existing socket
208
+ (`existingSocket`), in which case `dispose()` does not close it. `resolveEffectiveModel` is the one
209
+ pure capability auto-switch: it consults an injected chat registry and fails soft to the bound model
210
+ when nothing advertises the needed capability.
211
+
212
+ `ConversationRuntime` is a pure reducer over the `ChatWsEvent` union: `applyFrame(event)`,
213
+ `getState()`, `subscribe(listener)`. The speaker only moves on a server `turn_changed`; the client
214
+ never routes a turn itself. `adventureStateEpoch` is a monotonic counter of gated DM mutations and
215
+ `acknowledgeAdventureState(epoch)` acknowledges by value, so a second mutation arriving mid-refetch
216
+ is not lost.
217
+
218
+ `PresenceAdapter` is the renderer-agnostic seam — `mount`, `unmount`, `setActiveParticipant`,
219
+ `setSpeaking`, `applyViseme`, all keyed by persona id. `bindPresence(runtime, adapter)` is the pure
220
+ glue, and `PresenceRendererRegistry` maps a presence kind to a renderer factory (fail-loud on a
221
+ duplicate registration, no-op for an unregistered kind).
222
+
223
+ `VoiceSession` is a full STT/TTS/mic/viseme round trip over the same socket, composed from
224
+ `AudioPipeline` and `MicrophoneRecorder` rather than reimplemented. `start()` must be called from
225
+ the synchronous prefix of a click handler (iOS gesture priming). `synthesizeReply(text)` arms the
226
+ output half without the mic so a typed turn is still spoken. `handleReconnect()` re-primes after a
227
+ socket reconnect; `dispose()` never closes the socket.
228
+
229
+ `ChatSessionStore` wraps session CRUD with the orchestration a chat surface needs, and
230
+ `ConversationTranscriptCache` is a generic, storage-injectable transcript cache (omit the storage
231
+ and it is an SSR no-op).
232
+
233
+ ## Model adapter registries
234
+
235
+ `AdapterRegistry` is the primitive: `register()` (additive, throws on a duplicate id), `get`,
236
+ `list`, `listWithCapability(cap)`, `resolveRoute(name)` — which degrades to the fallback route
237
+ rather than throwing — and `satisfies(id, required)`. Route names are the exported `ROUTE_DEFAULT`,
238
+ `ROUTE_FALLBACK` and `ROUTE_HIGH_QUALITY` constants.
239
+
240
+ `createPlatformRegistries(client)` composes all seven — `chat`, `image`, `world`, `director`,
241
+ `extraction`, `embedding`, `videoGen`. Chat, image and extraction hydrate from their backend
242
+ catalogues; world, director and video-gen are synchronous seeds. The registries **mirror** the
243
+ backend catalogue; model selection stays server-side, so there is no client-side routing table.
244
+
245
+ For world models the descriptor carries four independent axes, each with its own resolver:
246
+ `capabilities` (the abstract gate), `supportedCommands` (advisory metadata),
247
+ `seedImageCommand` — resolved by `resolveWorldSeedImageCommand` — for handing a model an uploaded
248
+ seed image, and `resolveWorldSteerCommand` for re-aiming a world that is already running. An unknown
249
+ id resolves to `null`, which means *do not send*; never fall back to another model's verb.
250
+ `dispatchWorldCommand(adapterId, cmd, ctx)` routes to the right dispatcher with per-adapter
251
+ overloads, and throws `UnsupportedWorldAdapterError` for an unknown id without touching the bridge.
252
+ `worldModelTradeoff(registry, id)` answers what picking a model commits you to — seed timing, world
253
+ lifetime, vendor listing, scene-change cost.
254
+
255
+ `experienceModelCatalog(registry, options?)` is the single projection a model switcher renders,
256
+ combining registry world rows with the off-registry live-edit and video-generation seams. Each row
257
+ carries capability flags and a `wired` selectability gate;
258
+ `isExperienceModelWired(registry, modelId, options?)` is the matching host gate — pass it the
259
+ **same** options you passed the catalog or the two can disagree.
260
+
261
+ ## Story graph and creator projections
262
+
263
+ The graph-schema vocabulary mirrors the backend: the `GraphNodeLabel` / `GraphRelationshipType`
264
+ unions with their runtime tuples `GRAPH_NODE_LABELS` / `GRAPH_RELATIONSHIP_TYPES`, plus
265
+ `GRAPH_PRIMARY_KEY`, `GRAPH_EDITABLE_NODE_PROPERTIES`, `GRAPH_EDITABLE_RELATIONSHIP_PROPERTIES`, the
266
+ user-creatable subsets `userCreatableLabels` / `userCreatableEdges` / `allowedPairs`, and the studio
267
+ read-surface vocabulary. Provenance is deliberately **two** unions that are never merged —
268
+ `StoryGraphProvenance` and `MemoryFactProvenance` — each with its own value tuple, authored-canon
269
+ set and type guard. `fetchGraphSchema(client)` fetches the live schema once per session and is the
270
+ runtime source of truth; the static constants are the compile-time vocabulary and fallback.
271
+
272
+ The story-graph module holds the collapsed projection both the studio read views and the director
273
+ timeline consume: `deriveScenes(graph)` and `deriveCast(graph)`, plus the `SceneView` / `CharacterView` /
274
+ `ArcView` / `ShotView` view-model types. Traversal is edge-direction-agnostic.
275
+
276
+ `deriveArcGhostLane(variant, knownSceneIds)` projects an arc proposal onto a scene board
277
+ as a read-only ghost swimlane, with anchors validated against real scenes.
278
+
279
+ Creator-surface projections are pure functions over API responses: `deriveNeedsYou`,
280
+ `deriveProjectConsole`, `filterProjectsByCategory` and friends for a dashboard;
281
+ `confidenceQueue`, `seriesCurationGroups`, `resolveSuggestionEntity` for a curation queue;
282
+ `castWithPersona` for a cast grid; `mergeGraphRelations` for a universe view.
283
+ `isFabricatedDefaultConfidence(v)` and `FABRICATED_DEFAULT_CONFIDENCE` (`0.75`) flag a confidence
284
+ that is the backend's write-time default rather than a measured signal, so a surface can render
285
+ "unverified" instead of a fabricated percentage.
286
+
287
+ Visibility filtering has one predicate family so the halves cannot drift: `isBlessed(row)`,
288
+ `onlyBlessed(rows)` for a showcase catalog, `withoutBlessed(rows)`, and
289
+ `withoutForeignBlessed(rows, ownedVideoIds)` for creator surfaces — build the ownership set with
290
+ `loadOwnedVideoIds(client)` (returns `null` rather than throwing, so a listing blip degrades the
291
+ rule instead of blanking a feed) or `ownedVideoIdSet(listings)`.
292
+
293
+ Other single-source helpers: `extractionStageState(job)` for the extraction stage of an ingestion
294
+ job; `parseReprocessBlockedReason(error)` + `REPROCESS_BLOCKED_REASON` for the stable reprocess
295
+ conflict tokens; `buildRegenerationScope(kind, targetId?)`; `seriesDisplaySlug(seriesId)`
296
+ (render-only — never use the output for equality, grouping or as a key, and never send it back);
297
+ `absentBundleFallbackReason(persona)` + `FACE_FALLBACK_LABELS` for why a renderer is painting the
298
+ generic face.
299
+
300
+ ## Storyboards
301
+
302
+ `StoryboardsApi` (also facade-delegated on `ApiClient`) plus the wire types mirror the backend
303
+ storyboard models. Three rules the module enforces and no consumer should re-derive:
304
+
305
+ - **Ordering lives only in `Storyboard.frameIds`.** There is no per-frame order field; a reorder is
306
+ one idempotent list patch, and `orderStoryboardFrames(frameIds, frames)` is the only resolver.
307
+ - **Frame status is derived,** never sent. `deriveFrameStatus(variants)` mirrors the server rule for
308
+ the optimistic window between a write and the next read.
309
+ - **The master frame is `STORYBOARD_MASTER_FRAME_WIDTH` × `STORYBOARD_MASTER_FRAME_HEIGHT`
310
+ (1664 × 936) at `STORYBOARD_MASTER_ASPECT_RATIO` (`'16:9'`).**
311
+
312
+ `txnVer` is store-owned: read it off a frame and echo it back on a patch or the version guard is
313
+ dead — never mint one.
314
+
315
+ Reading a frame splits by purpose. `displayFrameVariant(frame)` is succeeded-only (what to *show*),
316
+ `frameImageUrl(frame)` its presigned URL; `promptFrameVariant(frame)` is the prompt accessor and
317
+ falls back to the newest variant of any status carrying prompt text, so a refused frame stays
318
+ distinguishable from one that does not exist. `frameRenderFailed(frame)` /
319
+ `frameRenderFailure(frame)` tell "refused and never coming back" apart from "still generating".
320
+ `storyboardFrameBudget(variant)` gives `{ nodeCount, frameCount, capped }` — a count-only spend
321
+ preview, capped at `MAX_FRAMES_PER_BOARD` (24).
322
+
323
+ The region-edit core has zero extra dependencies: normalized brush strokes
324
+ (radius normalized against the longer edge, so the brush stays round on a 16:9 frame), a pure
325
+ `planMaskRender` returning an assertable op list, and a structural `rasterizeMaskPlan` that accepts
326
+ anything shaped like a 2D context. **White (`MASK_PAINT_COLOR`) edits, black (`MASK_KEEP_COLOR`)
327
+ keeps.** Only `renderMaskToCanvas` / `strokesToMaskPngBlob` / `strokesToMaskBase64` need a real
328
+ canvas, and they throw in a canvas-less environment rather than silently posting a mask that edits
329
+ the wrong pixels. The camera half is a dual encoding: `CameraPose` ⇄ tuple ⇄ annotation, plus
330
+ `cameraPoseToProse` for the deterministic prose leg.
331
+
332
+ The board's timeline projection is in **seconds only** — the app applies its own
333
+ pixels-per-second. `buildStoryboardTimeline(frameIds, frames)` returns cumulative clips, bands of
334
+ consecutive clips sharing a sequence, a total, and `missingFrameIds` (normal mid-run: the ordering
335
+ is written before the frames exist). `clipAtTime(timeline, seconds)` hit-tests the playhead;
336
+ `storyboardFrameProgress(timeline)` counts by derived status over the whole timeline, and its
337
+ `fraction` is settled/total — a board whose last frame failed is finished.
338
+
339
+ ## Prompt building and world entry
340
+
341
+ The Reactor modules hold deterministic prompt builders and world-model orchestrators, all free of
342
+ any vendor SDK import — the consuming app owns the SDK. `buildRegenPrompt(input)` produces image-regen
343
+ prompts with locked aspect ratio and identity guarantees; `buildUpsamplePrompt(input)` returns
344
+ `{ system, user }` blocks for any LLM transport; `aggregateEntityContext` and
345
+ `aggregatePersonaContext` adapt existing records into the canonical context shapes.
346
+ `mapEnrichmentToTimeline` and `deriveStoryTimeline` are the two timeline mappers (raw enrichment,
347
+ and the collapsed story projection) sharing one chunk-distribution algorithm.
348
+
349
+ `parseHeliosCommands(text)` extracts inline `[SET_SCENE: "…"]`-style markers from streamed chat
350
+ output and `stripHeliosCommands(text)` removes them from the displayed transcript.
351
+ `dispatchHeliosCommand` / `dispatchLongLiveCommand` execute a parsed command against a structural
352
+ bridge — pure async functions, abort-aware.
353
+
354
+ `launchHappyOysterWorld` is a create-or-reopen orchestrator over a structural bridge, with the
355
+ prompt cap the vendor SDK does not enforce, a `{ encryptedWorldId, mode }` handle, and a failure
356
+ vocabulary. Seed preparation crops rather than merely compressing, because the vendor rejects an
357
+ out-of-band seed only after a permanent, already-billed world exists.
358
+
359
+ `compactFramePromptText(text, maxChars)` fits a compiled frame prompt inside a target's cap
360
+ **without truncating**: it sheds whole semantic units along the prompt's own boundaries in a fixed
361
+ ceremony-first order and stops the instant the text fits. It never touches the action line, so a
362
+ frame whose action alone exceeds the cap comes back still over it and the caller's cap check blocks
363
+ loudly instead of launching half a beat.
364
+
365
+ ## Presentation helpers
366
+
367
+ The shared design-token palette is `LIGHT_TOKENS` and `DARK_TOKENS` (a complete map over every
368
+ token key), `cssVarName(key)` and `toCssVars(map)`. It is a TypeScript map rather than a stylesheet
369
+ so it ships through the tsc-only build (a stylesheet in the source tree would not reach the
370
+ emitted output); each app owns its own CSS emission.
371
+
372
+ `parseSeerMessage(content)` is the one parser for persona/assistant chat output,
373
+ returning a **token stream** (`text`, `bold`, `italic`, `cue`, `imageRef`, `linebreak`) so consumers
374
+ never build raw HTML. It extracts deduped emotion badges, preserves non-verbal cues, and collects
375
+ control tags. `splitSeerInternalBlocks(content)` runs first and is streaming-safe: reasoning blocks
376
+ are captured for an optional disclosure and tool scaffolding is dropped, with a tag split across
377
+ streamed tokens held back rather than flashed. Do not add a per-surface strip.
378
+
379
+ `formatTimestamp(seconds, options?)` is the locale-aware `M:SS` / `M:SS.cs` formatter;
380
+ `formatCitationTimestamp(seconds)` is the centisecond preset used for sub-second citations.
381
+
382
+ The tool-schema mirror exposes the server-side RAG tool surface — `AGENT_TOOL_SCHEMAS` (14 tools),
383
+ `AGENT_TOOL_NAMES`, `getAgentToolSchema(name)` — so a client can introspect each tool's name,
384
+ description, endpoint, method and request fields without copy-pasting strings. It is CI-diffed
385
+ against a generated backend contract.
386
+
387
+ The workflow-authoring catalog and pre-publish lint back a workflow composer:
388
+ `WORKFLOW_DRIVER_AUTHORING` (a total record over the driver union, so catalog completeness is a
389
+ compile-time guarantee), `WORKFLOW_DRIVER_GROUPS`, `workflowDriversByGroup()`,
390
+ `authoredStepFromDriver(driver, stepId)` and `validateAuthoredSteps(steps)` returning
391
+ `{ errors, warnings }`.
392
+
393
+ ## Errors
394
+
395
+ Non-2xx JSON responses throw an `Error` whose `message` is the server's shaped detail. Two
396
+ additive runtime properties ride along for callers that need to branch. They are **not** on the
397
+ declared `Error` type, so read them through a narrow-and-cast
398
+ (`(err as Error & { status?: number }).status`):
399
+
400
+ - `.status` — the HTTP status code. Branch on it instead of pattern-matching the message.
401
+ - `.detail` — the structured detail object when the server sent one (a string detail invents
402
+ nothing). Some routes answer with fields you need: a frame-world conflict returns the id of the
403
+ world the frame already owns.
404
+
405
+ Typed error classes, for the cases where a status code isn't enough:
406
+
407
+ | Class | Thrown by |
408
+ |---|---|
409
+ | `RecloneConflictError` | Persona voice re-clone conflict; carries a `RecloneConflictCode` so a UI can distinguish exhausted retries from no remaining candidate clips |
410
+ | `RestoreConflictError` | Universe restore; `code: 'stale_plan' \| 'already_active'` disambiguates two causes behind one status |
411
+ | `RestoreInvalidTargetError` | Universe restore against an invalid target version |
412
+ | `VisionRefusedError` | A backend vision refusal; carries `reason`, `retryAfterSeconds`, `traceId`, `recoverable` |
413
+ | `UnsupportedWorldAdapterError` | `dispatchWorldCommand` with an unregistered adapter id |
414
+ | `HappyOysterLaunchError` | World launch failure; carries `reason` and `retryable`, and **the `handle` when a world was created but never streamed — that world is already billed and this handle is the only way back to it** |
139
415
 
140
- ## Build & publish
416
+ ## Host integration seams
141
417
 
142
- The repo-checked-in `package.json` points `main`/`types`/`exports` at `./src/index.ts` so in-monorepo consumers (`web/`) can `import` TypeScript source directly through Next.js's `transpilePackages`. The published artifact needs to point at `./dist/index.js` instead — the publish workflow rewrites these in place via `npm pkg set` before running `npm publish`. (npm does not honor `publishConfig.main`/`.types`/`.exports` overrides the way pnpm/yarn-berry do, hence the rewrite.) The on-disk file is never committed with the rewritten paths.
418
+ **Session refresh.** Every client here snapshots its bearer at construction, so a surface a user
419
+ lingers on will 401 on its next call. Install one refresher for the whole page:
143
420
 
144
- A second post-build step (`scripts/add-ext.mjs`) appends the correct suffix to extension-less relative imports in `dist/*.js`. TypeScript's emitter doesn't add them, and Node strict ESM (used by Nuxt/Rollup in the sibling repo) refuses to resolve `from './foo'` without an explicit extension. The script is **directory-aware**: a specifier whose target is a directory on disk gets `/index.js` (`./reactor` → `./reactor/index.js`), a file target gets `.js`. This matters for the four **directory** modules re-exported from `src/index.ts` (`reactor`, `vision`, `adapters`, `conversation`) — those source re-exports use explicit `/index` (`export * from './reactor/index'`) so `tsc` emits the directory form. (A bare `.js` on a directory specifier was the v0.42.0–0.49.0 packaging bug that broke the sibling Nuxt build; fixed in v0.49.1, tech-debt #486.) After rewriting, the script runs a **build-time guard** that fails the build if any real relative import/export specifier in `dist` doesn't resolve on disk under strict ESM — so a broken barrel can never be published again. **When adding a new directory module to the barrel, always re-export it as `./<dir>/index`, not `./<dir>`.**
421
+ ```ts
422
+ import { setSessionRefresher, hasSessionRefresher } from '@escapeaihq/client-core';
145
423
 
146
- ```bash
147
- # from the package directory
148
- npm run typecheck # tsc -p tsconfig.json --noEmit
149
- npm test # jest (jsdom)
150
- npm run build # tsc -p tsconfig.build.json && node scripts/add-ext.mjs → dist/
424
+ setSessionRefresher(async (staleToken) => refreshWithYourAuthProvider(staleToken));
425
+
426
+ hasSessionRefresher(); // true — pass `undefined` to setSessionRefresher to clear it
151
427
  ```
152
428
 
153
- Direct `npm publish` from a dev machine is not part of the flow — releases go through CI; see below.
429
+ The JSON request path then replays a bearer 401 exactly once, and only when the refresh yields a
430
+ *different* token. Registration is module-level on purpose: one registration covers every client
431
+ instance — including a stale one held in a long-running closure — and concurrent 401s collapse onto
432
+ a single refresh. A host that installs nothing behaves exactly as before. The replay rides the JSON
433
+ path only; raw/blob fetches, SSE streams and multipart uploads are not replayed.
154
434
 
155
- ### Cutting a release
435
+ **On-behalf-of.** The OBO helpers carry the assertion header constant (`OBO_ASSERTION_HEADER`),
436
+ federated-id helpers and the `OboAssertionClaims` type. Minting and verification stay server-side —
437
+ the package holds no secrets.
156
438
 
157
- CI publishes to **public npm (npmjs.com)** on every push of a `client-core-v*` tag (`.github/workflows/publish-client-core.yml`). The package ships as MIT, installable without auth. The flow:
439
+ **Tenant and role claims.** The claim readers pull the active-tenant and role claims out of a
440
+ session JWT for **display only** (`getActiveOrgIdFromJwt`, `getDctClaim`, `getJwtClaims`, `getRolesFromJwt`,
441
+ `hasPlatformAdminRole`, `PLATFORM_ADMIN_ROLE_NAME`). It is unverified by design; the backend
442
+ independently verifies membership.
158
443
 
159
- ```bash
160
- # 1. bump version in packages/client-core/package.json (semver)
161
- # 2. commit the bump on main
162
- git commit -am "client-core: release v0.4.2"
163
- # 3. tag and push — the tag triggers the publish workflow
164
- git tag client-core-v0.4.2
165
- git push origin main client-core-v0.4.2
166
- ```
444
+ ## Stability and versioning
167
445
 
168
- The workflow runs `npm ci` at the repo root, then `npm --workspace=@escapeaihq/client-core run typecheck`, `test`, and `build`, then `npm publish --workspace=@escapeaihq/client-core`. Auth uses an `NPM_TOKEN` secret — a granular access token with **bypass 2FA** enabled, scoped to the `@escapeaihq` org's packages. Provenance attestations (`--provenance`) are **deliberately disabled**: npm rejects them for packages whose source repo is private (seer-agent is private by design), and the rejection happens *after* the attestation is signed to the public sigstore log, which would leak commit references on every release. Supply-chain guarantees are instead SHA-pinned action versions + `npm audit --audit-level=high` gating publish.
446
+ The package is a published, **additive-only** contract with more than one consumer: exported symbols
447
+ are not removed or renamed, and new fields arrive optional. Practical consequences:
169
448
 
170
- **Semver policy (manual bumps):**
449
+ - Switch exhaustively on unions you consume, but treat an unknown member as ignorable — new
450
+ frame kinds, new statuses and new capabilities are added, not substituted.
451
+ - Optional fields are optional because a client may deploy ahead of the API. Degrade on absence.
452
+
453
+ While the package is `0.x` it is pre-stable and constructor signatures may still change. Pin an
454
+ exact version (no caret) until `1.0`.
171
455
 
172
456
  | Bump | When |
173
457
  |---|---|
174
- | **Patch** (0.x.Z) | Bug fix in an existing function; new internal helper; documentation; tests; non-API-visible refactor. |
175
- | **Minor** (0.Y.0) | New exported function/class/type; new optional parameter; new module under `src/`. |
176
- | **Major** (X.0.0 — pre-1.0 still bumps the leading 0.) | Renamed/removed exported symbol; required argument added or order changed (e.g. `ApiClient` constructor in 1a.1); changed return type or thrown errors that consumers branch on. |
177
-
178
- While this is `0.x`, the package is pre-stable: any release may include breaking changes in the constructor signatures of `ApiClient`, `AudioPipeline`, etc. — consumers should pin to an exact version (`"@escapeaihq/client-core": "0.1.0"`, no caret) until `1.0`.
458
+ | Patch | Bug fix in an existing function; internal helper; docs; tests; non-API-visible refactor |
459
+ | Minor | New exported function, class or type; new optional parameter; new module |
460
+ | Major | Renamed or removed export; a required argument added or reordered; a changed return type or thrown error consumers branch on |
179
461
 
180
- ## What does NOT belong here
462
+ ## Not in scope
181
463
 
182
- - React or Vue components, hooks, or composables — those live with their consumer
183
- - App-specific config (env vars, base URLs) — pass them in via constructor args
184
- - Any DOM rendering beyond what's needed for Web Audio / Web Animations / WebSocket APIs
464
+ - React or Vue components, hooks or composables — those live with their consumer.
465
+ - Application config (environment variables, base URLs) — pass it in via constructor arguments.
466
+ - DOM rendering beyond what the Web Audio, WebRTC and WebSocket APIs require.
185
467
 
186
- ## Testing
468
+ ## Development
187
469
 
188
- Jest with `ts-jest/presets/default-esm` and `jsdom` environment. Tests live next to source under `src/__tests__/`. Run from this directory:
470
+ From the package directory:
189
471
 
190
472
  ```bash
191
- npm test
192
- # or from monorepo root
193
- npm run test:client-core
473
+ npm run typecheck # tsc --noEmit
474
+ npm test # jest (jsdom)
475
+ npm run build # emit dist/
476
+ npm run api-report:check # diff the emitted declaration surface against the committed snapshot
477
+ npm run api-report:update # regenerate that snapshot after an intentional additive change
194
478
  ```
479
+
480
+ The declaration surface is a committed, CI-diffed artifact. If the check fails: an additive change
481
+ means regenerating and committing the snapshot so reviewers see the delta; a removal or rename is
482
+ forbidden — fix the code instead.
483
+
484
+ ## License
485
+
486
+ MIT.