@escapeaihq/client-core 0.8.0 → 0.42.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 (307) hide show
  1. package/README.md +48 -4
  2. package/dist/adapters/capabilities.d.ts +10 -0
  3. package/dist/adapters/capabilities.d.ts.map +1 -0
  4. package/dist/adapters/capabilities.js +2 -0
  5. package/dist/adapters/capabilities.js.map +1 -0
  6. package/dist/adapters/chatAdapter.d.ts +38 -0
  7. package/dist/adapters/chatAdapter.d.ts.map +1 -0
  8. package/dist/adapters/chatAdapter.js +88 -0
  9. package/dist/adapters/chatAdapter.js.map +1 -0
  10. package/dist/adapters/directorAdapter.d.ts +62 -0
  11. package/dist/adapters/directorAdapter.d.ts.map +1 -0
  12. package/dist/adapters/directorAdapter.js +71 -0
  13. package/dist/adapters/directorAdapter.js.map +1 -0
  14. package/dist/adapters/imageAdapter.d.ts +44 -0
  15. package/dist/adapters/imageAdapter.d.ts.map +1 -0
  16. package/dist/adapters/imageAdapter.js +73 -0
  17. package/dist/adapters/imageAdapter.js.map +1 -0
  18. package/dist/adapters/index.d.ts +47 -0
  19. package/dist/adapters/index.d.ts.map +1 -0
  20. package/dist/adapters/index.js +41 -0
  21. package/dist/adapters/index.js.map +1 -0
  22. package/dist/adapters/registry.d.ts +98 -0
  23. package/dist/adapters/registry.d.ts.map +1 -0
  24. package/dist/adapters/registry.js +106 -0
  25. package/dist/adapters/registry.js.map +1 -0
  26. package/dist/adapters/worldAdapter.d.ts +142 -0
  27. package/dist/adapters/worldAdapter.d.ts.map +1 -0
  28. package/dist/adapters/worldAdapter.js +164 -0
  29. package/dist/adapters/worldAdapter.js.map +1 -0
  30. package/dist/admin.d.ts +200 -0
  31. package/dist/admin.d.ts.map +1 -0
  32. package/dist/admin.js +124 -0
  33. package/dist/admin.js.map +1 -0
  34. package/dist/api.d.ts +1299 -3
  35. package/dist/api.d.ts.map +1 -1
  36. package/dist/api.js +683 -95
  37. package/dist/api.js.map +1 -1
  38. package/dist/audio.d.ts +33 -1
  39. package/dist/audio.d.ts.map +1 -1
  40. package/dist/audio.js +4 -1
  41. package/dist/audio.js.map +1 -1
  42. package/dist/castProjection.d.ts +35 -0
  43. package/dist/castProjection.d.ts.map +1 -0
  44. package/dist/castProjection.js +80 -0
  45. package/dist/castProjection.js.map +1 -0
  46. package/dist/conversation/binding.d.ts +62 -0
  47. package/dist/conversation/binding.d.ts.map +1 -0
  48. package/dist/conversation/binding.js +51 -0
  49. package/dist/conversation/binding.js.map +1 -0
  50. package/dist/conversation/controller.d.ts +209 -0
  51. package/dist/conversation/controller.d.ts.map +1 -0
  52. package/dist/conversation/controller.js +342 -0
  53. package/dist/conversation/controller.js.map +1 -0
  54. package/dist/conversation/effectiveModel.d.ts +62 -0
  55. package/dist/conversation/effectiveModel.d.ts.map +1 -0
  56. package/dist/conversation/effectiveModel.js +73 -0
  57. package/dist/conversation/effectiveModel.js.map +1 -0
  58. package/dist/conversation/index.d.ts +27 -0
  59. package/dist/conversation/index.d.ts.map +1 -0
  60. package/dist/conversation/index.js +27 -0
  61. package/dist/conversation/index.js.map +1 -0
  62. package/dist/conversation/participant.d.ts +66 -0
  63. package/dist/conversation/participant.d.ts.map +1 -0
  64. package/dist/conversation/participant.js +36 -0
  65. package/dist/conversation/participant.js.map +1 -0
  66. package/dist/conversation/presence.d.ts +56 -0
  67. package/dist/conversation/presence.d.ts.map +1 -0
  68. package/dist/conversation/presence.js +34 -0
  69. package/dist/conversation/presence.js.map +1 -0
  70. package/dist/conversation/presenceBus.d.ts +42 -0
  71. package/dist/conversation/presenceBus.d.ts.map +1 -0
  72. package/dist/conversation/presenceBus.js +81 -0
  73. package/dist/conversation/presenceBus.js.map +1 -0
  74. package/dist/conversation/presenceRegistry.d.ts +49 -0
  75. package/dist/conversation/presenceRegistry.d.ts.map +1 -0
  76. package/dist/conversation/presenceRegistry.js +59 -0
  77. package/dist/conversation/presenceRegistry.js.map +1 -0
  78. package/dist/conversation/roster.d.ts +72 -0
  79. package/dist/conversation/roster.d.ts.map +1 -0
  80. package/dist/conversation/roster.js +69 -0
  81. package/dist/conversation/roster.js.map +1 -0
  82. package/dist/conversation/rosterProjection.d.ts +52 -0
  83. package/dist/conversation/rosterProjection.d.ts.map +1 -0
  84. package/dist/conversation/rosterProjection.js +74 -0
  85. package/dist/conversation/rosterProjection.js.map +1 -0
  86. package/dist/conversation/router.d.ts +74 -0
  87. package/dist/conversation/router.d.ts.map +1 -0
  88. package/dist/conversation/router.js +58 -0
  89. package/dist/conversation/router.js.map +1 -0
  90. package/dist/conversation/runtime.d.ts +64 -0
  91. package/dist/conversation/runtime.d.ts.map +1 -0
  92. package/dist/conversation/runtime.js +172 -0
  93. package/dist/conversation/runtime.js.map +1 -0
  94. package/dist/conversation/types.d.ts +99 -0
  95. package/dist/conversation/types.d.ts.map +1 -0
  96. package/dist/conversation/types.js +13 -0
  97. package/dist/conversation/types.js.map +1 -0
  98. package/dist/conversation/voice.d.ts +185 -0
  99. package/dist/conversation/voice.d.ts.map +1 -0
  100. package/dist/conversation/voice.js +307 -0
  101. package/dist/conversation/voice.js.map +1 -0
  102. package/dist/graphSchema.d.ts +260 -0
  103. package/dist/graphSchema.d.ts.map +1 -0
  104. package/dist/graphSchema.js +354 -0
  105. package/dist/graphSchema.js.map +1 -0
  106. package/dist/http.d.ts +20 -0
  107. package/dist/http.d.ts.map +1 -0
  108. package/dist/http.js +57 -0
  109. package/dist/http.js.map +1 -0
  110. package/dist/index.d.ts +9 -0
  111. package/dist/index.d.ts.map +1 -1
  112. package/dist/index.js +12 -0
  113. package/dist/index.js.map +1 -1
  114. package/dist/platformAssistant.d.ts +155 -0
  115. package/dist/platformAssistant.d.ts.map +1 -0
  116. package/dist/platformAssistant.js +256 -0
  117. package/dist/platformAssistant.js.map +1 -0
  118. package/dist/reactor/abortUtils.d.ts +16 -0
  119. package/dist/reactor/abortUtils.d.ts.map +1 -0
  120. package/dist/reactor/abortUtils.js +26 -0
  121. package/dist/reactor/abortUtils.js.map +1 -0
  122. package/dist/reactor/applyScenePrompt.d.ts +75 -0
  123. package/dist/reactor/applyScenePrompt.d.ts.map +1 -0
  124. package/dist/reactor/applyScenePrompt.js +60 -0
  125. package/dist/reactor/applyScenePrompt.js.map +1 -0
  126. package/dist/reactor/chunkDistribution.d.ts +43 -0
  127. package/dist/reactor/chunkDistribution.d.ts.map +1 -0
  128. package/dist/reactor/chunkDistribution.js +85 -0
  129. package/dist/reactor/chunkDistribution.js.map +1 -0
  130. package/dist/reactor/heliosCommandDispatcher.d.ts.map +1 -1
  131. package/dist/reactor/heliosCommandDispatcher.js +10 -15
  132. package/dist/reactor/heliosCommandDispatcher.js.map +1 -1
  133. package/dist/reactor/index.d.ts +4 -0
  134. package/dist/reactor/index.d.ts.map +1 -1
  135. package/dist/reactor/index.js +7 -0
  136. package/dist/reactor/index.js.map +1 -1
  137. package/dist/reactor/longLiveCommandDispatcher.d.ts +103 -0
  138. package/dist/reactor/longLiveCommandDispatcher.d.ts.map +1 -0
  139. package/dist/reactor/longLiveCommandDispatcher.js +87 -0
  140. package/dist/reactor/longLiveCommandDispatcher.js.map +1 -0
  141. package/dist/reactor/sceneEntry.d.ts +40 -6
  142. package/dist/reactor/sceneEntry.d.ts.map +1 -1
  143. package/dist/reactor/sceneEntry.js +63 -24
  144. package/dist/reactor/sceneEntry.js.map +1 -1
  145. package/dist/reactor/scenesFromEnrichment.d.ts.map +1 -1
  146. package/dist/reactor/scenesFromEnrichment.js +2 -66
  147. package/dist/reactor/scenesFromEnrichment.js.map +1 -1
  148. package/dist/reactor/seedImageOrchestrator.d.ts +42 -2
  149. package/dist/reactor/seedImageOrchestrator.d.ts.map +1 -1
  150. package/dist/reactor/seedImageOrchestrator.js +173 -4
  151. package/dist/reactor/seedImageOrchestrator.js.map +1 -1
  152. package/dist/reactor/storyTimeline.d.ts +44 -0
  153. package/dist/reactor/storyTimeline.d.ts.map +1 -0
  154. package/dist/reactor/storyTimeline.js +95 -0
  155. package/dist/reactor/storyTimeline.js.map +1 -0
  156. package/dist/storyGraph.d.ts +70 -0
  157. package/dist/storyGraph.d.ts.map +1 -0
  158. package/dist/storyGraph.js +178 -0
  159. package/dist/storyGraph.js.map +1 -0
  160. package/dist/timeFormat.d.ts +10 -0
  161. package/dist/timeFormat.d.ts.map +1 -1
  162. package/dist/timeFormat.js +12 -0
  163. package/dist/timeFormat.js.map +1 -1
  164. package/dist/toolSchemas.d.ts +370 -0
  165. package/dist/toolSchemas.d.ts.map +1 -0
  166. package/dist/toolSchemas.js +182 -0
  167. package/dist/toolSchemas.js.map +1 -0
  168. package/dist/vision/VisionPublisher.d.ts +115 -0
  169. package/dist/vision/VisionPublisher.d.ts.map +1 -0
  170. package/dist/vision/VisionPublisher.js +475 -0
  171. package/dist/vision/VisionPublisher.js.map +1 -0
  172. package/dist/vision/VisionSourceController.d.ts +127 -0
  173. package/dist/vision/VisionSourceController.d.ts.map +1 -0
  174. package/dist/vision/VisionSourceController.js +284 -0
  175. package/dist/vision/VisionSourceController.js.map +1 -0
  176. package/dist/vision/credentials.d.ts +22 -0
  177. package/dist/vision/credentials.d.ts.map +1 -0
  178. package/dist/vision/credentials.js +34 -0
  179. package/dist/vision/credentials.js.map +1 -0
  180. package/dist/vision/index.d.ts +18 -0
  181. package/dist/vision/index.d.ts.map +1 -0
  182. package/dist/vision/index.js +13 -0
  183. package/dist/vision/index.js.map +1 -0
  184. package/dist/vision/sourceKinds.d.ts +65 -0
  185. package/dist/vision/sourceKinds.d.ts.map +1 -0
  186. package/dist/vision/sourceKinds.js +26 -0
  187. package/dist/vision/sourceKinds.js.map +1 -0
  188. package/dist/vision/startVisionPublisher.d.ts +38 -0
  189. package/dist/vision/startVisionPublisher.d.ts.map +1 -0
  190. package/dist/vision/startVisionPublisher.js +44 -0
  191. package/dist/vision/startVisionPublisher.js.map +1 -0
  192. package/dist/vision/types.d.ts +95 -0
  193. package/dist/vision/types.d.ts.map +1 -0
  194. package/dist/vision/types.js +12 -0
  195. package/dist/vision/types.js.map +1 -0
  196. package/dist/vision/visionScheduler.d.ts +63 -0
  197. package/dist/vision/visionScheduler.d.ts.map +1 -0
  198. package/dist/vision/visionScheduler.js +67 -0
  199. package/dist/vision/visionScheduler.js.map +1 -0
  200. package/dist/websocket.d.ts +195 -0
  201. package/dist/websocket.d.ts.map +1 -1
  202. package/dist/websocket.js +179 -1
  203. package/dist/websocket.js.map +1 -1
  204. package/package.json +11 -1
  205. package/src/__tests__/adapters-capabilities.test.ts +46 -0
  206. package/src/__tests__/adapters-chat.test.ts +172 -0
  207. package/src/__tests__/adapters-director.test.ts +95 -0
  208. package/src/__tests__/adapters-image.test.ts +133 -0
  209. package/src/__tests__/adapters-platform.test.ts +95 -0
  210. package/src/__tests__/adapters-registry.test.ts +189 -0
  211. package/src/__tests__/adapters-world.test.ts +296 -0
  212. package/src/__tests__/admin.test.ts +312 -0
  213. package/src/__tests__/adventures-party.test.ts +219 -0
  214. package/src/__tests__/adventures.test.ts +282 -0
  215. package/src/__tests__/api-pollers.test.ts +104 -0
  216. package/src/__tests__/api.clip-lookup.test.ts +64 -0
  217. package/src/__tests__/api.list-images-filters.test.ts +103 -0
  218. package/src/__tests__/api.test.ts +470 -0
  219. package/src/__tests__/audio.test.ts +65 -0
  220. package/src/__tests__/cast.test.ts +95 -0
  221. package/src/__tests__/castProjection.test.ts +167 -0
  222. package/src/__tests__/chat-auth.test.ts +91 -0
  223. package/src/__tests__/conversation/controller.test.ts +697 -0
  224. package/src/__tests__/conversation/effectiveModel.test.ts +169 -0
  225. package/src/__tests__/conversation/headlessRenderer.ts +46 -0
  226. package/src/__tests__/conversation/presenceBus.test.ts +236 -0
  227. package/src/__tests__/conversation/presenceRegistry.test.ts +73 -0
  228. package/src/__tests__/conversation/roster.test.ts +100 -0
  229. package/src/__tests__/conversation/rosterProjection.test.ts +142 -0
  230. package/src/__tests__/conversation/router.test.ts +81 -0
  231. package/src/__tests__/conversation/runtime.test.ts +206 -0
  232. package/src/__tests__/conversation/voice.test.ts +440 -0
  233. package/src/__tests__/documents.test.ts +360 -0
  234. package/src/__tests__/graphSchema.test.ts +326 -0
  235. package/src/__tests__/longLiveCommandDispatcher.test.ts +185 -0
  236. package/src/__tests__/platformAssistant.test.ts +484 -0
  237. package/src/__tests__/reactor/applyScenePrompt.test.ts +192 -0
  238. package/src/__tests__/reactor/heliosCommandDispatcher.test.ts +4 -3
  239. package/src/__tests__/reactor/sceneEntry.test.ts +134 -10
  240. package/src/__tests__/reactor/seedImageOrchestrator.test.ts +51 -16
  241. package/src/__tests__/reactor/storyTimeline.test.ts +186 -0
  242. package/src/__tests__/regeneration.test.ts +486 -0
  243. package/src/__tests__/stories.test.ts +171 -0
  244. package/src/__tests__/storyGraph.test.ts +134 -0
  245. package/src/__tests__/timeFormat.test.ts +22 -1
  246. package/src/__tests__/toolSchemas.test.ts +57 -0
  247. package/src/__tests__/tools-wrappers.test.ts +272 -0
  248. package/src/__tests__/videoGraph.test.ts +94 -0
  249. package/src/__tests__/websocket-vision.test.ts +265 -0
  250. package/src/__tests__/websocket.test.ts +213 -0
  251. package/src/adapters/capabilities.ts +24 -0
  252. package/src/adapters/chatAdapter.ts +114 -0
  253. package/src/adapters/directorAdapter.ts +126 -0
  254. package/src/adapters/imageAdapter.ts +100 -0
  255. package/src/adapters/index.ts +67 -0
  256. package/src/adapters/registry.ts +159 -0
  257. package/src/adapters/worldAdapter.ts +272 -0
  258. package/src/admin.ts +310 -0
  259. package/src/api.ts +1890 -162
  260. package/src/audio.ts +35 -0
  261. package/src/castProjection.ts +95 -0
  262. package/src/conversation/binding.ts +81 -0
  263. package/src/conversation/controller.ts +439 -0
  264. package/src/conversation/effectiveModel.ts +111 -0
  265. package/src/conversation/index.ts +27 -0
  266. package/src/conversation/participant.ts +71 -0
  267. package/src/conversation/presence.ts +60 -0
  268. package/src/conversation/presenceBus.ts +109 -0
  269. package/src/conversation/presenceRegistry.ts +83 -0
  270. package/src/conversation/roster.ts +111 -0
  271. package/src/conversation/rosterProjection.ts +98 -0
  272. package/src/conversation/router.ts +96 -0
  273. package/src/conversation/runtime.ts +188 -0
  274. package/src/conversation/types.ts +100 -0
  275. package/src/conversation/voice.ts +402 -0
  276. package/src/graphSchema.ts +532 -0
  277. package/src/http.ts +72 -0
  278. package/src/index.ts +12 -0
  279. package/src/platformAssistant.ts +347 -0
  280. package/src/reactor/abortUtils.ts +22 -0
  281. package/src/reactor/applyScenePrompt.ts +136 -0
  282. package/src/reactor/chunkDistribution.ts +98 -0
  283. package/src/reactor/heliosCommandDispatcher.ts +10 -18
  284. package/src/reactor/index.ts +7 -0
  285. package/src/reactor/longLiveCommandDispatcher.ts +156 -0
  286. package/src/reactor/sceneEntry.ts +104 -33
  287. package/src/reactor/scenesFromEnrichment.ts +11 -76
  288. package/src/reactor/seedImageOrchestrator.ts +200 -4
  289. package/src/reactor/storyTimeline.ts +127 -0
  290. package/src/storyGraph.ts +298 -0
  291. package/src/timeFormat.ts +13 -0
  292. package/src/toolSchemas.ts +225 -0
  293. package/src/vision/VisionPublisher.ts +553 -0
  294. package/src/vision/VisionSourceController.ts +354 -0
  295. package/src/vision/__tests__/VisionPublisher.kvs.test.ts +244 -0
  296. package/src/vision/__tests__/VisionPublisher.test.ts +301 -0
  297. package/src/vision/__tests__/VisionSourceController.test.ts +719 -0
  298. package/src/vision/__tests__/startVisionPublisher.test.ts +251 -0
  299. package/src/vision/__tests__/toVisionRtcCredentials.test.ts +113 -0
  300. package/src/vision/__tests__/visionScheduler.test.ts +149 -0
  301. package/src/vision/credentials.ts +39 -0
  302. package/src/vision/index.ts +44 -0
  303. package/src/vision/sourceKinds.ts +75 -0
  304. package/src/vision/startVisionPublisher.ts +64 -0
  305. package/src/vision/types.ts +101 -0
  306. package/src/vision/visionScheduler.ts +102 -0
  307. package/src/websocket.ts +334 -4
@@ -0,0 +1,532 @@
1
+ /**
2
+ * Graph-schema vocabulary mirrored from the backend single source of truth
3
+ * (`shared/graph_schema.py` + `shared/provenance.py`).
4
+ *
5
+ * These are framework-agnostic TypeScript string-literal unions and constant
6
+ * tuples. They let consumers (the React `web/` graph editor's `PropertyPanel`
7
+ * and the Vue Web-App) drop their hand-maintained whitelist mirrors and type
8
+ * against the same vocabulary the backend validates against.
9
+ *
10
+ * Scope discipline (mirrors the backend "no god-module" rule): this file
11
+ * describes the **graph schema only** — node labels, relationship types, the
12
+ * user-creation whitelists (M7 P3a: {@link userCreatableLabels} /
13
+ * {@link userCreatableEdges} / {@link allowedPairs}), and the two provenance
14
+ * vocabularies. It must NOT grow tool/MCP schemas or request/response DTOs.
15
+ *
16
+ * Keep this in lockstep with the Python module. The Python `NARRATIVE_NODE_LABELS`
17
+ * static extension point (for Story-Engine narrative nodes like `Act` /
18
+ * `Scene` / `PlotBeat` / `CharacterArc`) has no runtime equivalent here — a
19
+ * phase that adds a narrative label widens these unions in the same change.
20
+ * M7 P3a added `Scene` / `PlotBeat` / `CharacterArc` to the node vocabulary and
21
+ * the six story edges to the relationship vocabulary.
22
+ *
23
+ * Read-surface vs create-surface (mirrors the backend split): the `GRAPH_*`
24
+ * unions/tuples are the READ-SURFACE — the full vocabulary a viewer can
25
+ * encounter (every node label, every edge type on `getVideoGraph` edges). The
26
+ * `userCreatable*` exports are the strict CREATE-SURFACE subset authorized by
27
+ * `POST /graph/{nodes,edges}`. Widening the read-surface is additive — the
28
+ * public exports are pinned by the sibling Vue Web-App and must never shrink.
29
+ */
30
+
31
+ // ---------------------------------------------------------------------------
32
+ // Node + relationship vocabulary (the graph that exists today)
33
+ // ---------------------------------------------------------------------------
34
+
35
+ /**
36
+ * Every node label in the video + story graph. The first five exist in the
37
+ * pipeline-produced video graph; `Scene` / `PlotBeat` / `CharacterArc` are the
38
+ * Story-Engine narrative labels added in M7 Phase 3a (creatable via
39
+ * `POST /graph/nodes` — see {@link userCreatableLabels}).
40
+ */
41
+ export type GraphNodeLabel =
42
+ | 'Video'
43
+ | 'Shot'
44
+ | 'Entity'
45
+ | 'Event'
46
+ | 'DialogLine'
47
+ // M7 Phase 1b: pipeline-written narrative Act node (read/validate-able +
48
+ // regeneratable; not user-creatable).
49
+ | 'Act'
50
+ | 'Scene'
51
+ | 'PlotBeat'
52
+ | 'CharacterArc'
53
+ // M7 Phase 4: pipeline-written SourceDoc node (document ingestion). Only its
54
+ // `title` is editable; processor-owned provenance fields are immutable.
55
+ | 'SourceDoc'
56
+ // M7 Phase 5: pipeline-only Persona node (persona <-> character binding).
57
+ // Read/validate-able vocabulary only; never user-creatable.
58
+ | 'Persona';
59
+
60
+ /**
61
+ * READ-SURFACE: every relationship type a viewer can encounter on edges
62
+ * returned by `getVideoGraph`. This is the full graph vocabulary — the original
63
+ * pipeline edges (`HAS_SHOT` / `MENTIONS` / `HAS_EVENT` / `HAS_DIALOG` /
64
+ * `SPOKEN_BY` / `NEXT`), the M7 narrative-structural edges (`HAS_ACT` /
65
+ * `IN_ACT` / `CONTAINS` / `INCLUDES`), and the six M7 P3a user-creatable story
66
+ * edges (`RELATES_TO` / `CAUSES` / `SET_IN` / `FEATURES` / `ON_ARC` /
67
+ * `LEADS_TO`).
68
+ *
69
+ * This is a SUPERSET of the original pipeline union (additive, no removal — the
70
+ * frozen public contract pinned by the sibling Vue Web-App stays valid).
71
+ *
72
+ * The CREATE-SURFACE is the strict subset {@link userCreatableEdges} (the six
73
+ * story edges only); `POST /graph/edges` rejects everything else (422). Mirror
74
+ * of the backend split: `shared/graph_schema.py` widens the `RelationshipType`
75
+ * read vocabulary while `VALID_RELATIONSHIP_TYPES` / `user_creatable_edges`
76
+ * stay the six.
77
+ */
78
+ export type GraphRelationshipType =
79
+ | 'HAS_SHOT'
80
+ | 'MENTIONS'
81
+ | 'HAS_EVENT'
82
+ | 'HAS_DIALOG'
83
+ | 'SPOKEN_BY'
84
+ | 'NEXT'
85
+ | 'HAS_ACT'
86
+ | 'IN_ACT'
87
+ | 'CONTAINS'
88
+ | 'INCLUDES'
89
+ | 'RELATES_TO'
90
+ | 'CAUSES'
91
+ | 'SET_IN'
92
+ | 'FEATURES'
93
+ | 'ON_ARC'
94
+ | 'LEADS_TO'
95
+ // M7 Phase 4: pipeline-written SourceDoc-[:ANNOTATES]->(Entity|Scene) edge
96
+ // (document ingestion). Read-surface only; NOT in the create-surface subset.
97
+ | 'ANNOTATES'
98
+ // M7 Phase 5: pipeline-only Persona-[:PORTRAYS]->Entity binding edge.
99
+ // Read/validate-able vocabulary only; NOT in the create-surface subset.
100
+ | 'PORTRAYS';
101
+
102
+ /** Runtime tuple of all node labels (mirrors `VALID_NODE_LABELS`). */
103
+ export const GRAPH_NODE_LABELS: readonly GraphNodeLabel[] = [
104
+ 'Video',
105
+ 'Shot',
106
+ 'Entity',
107
+ 'Event',
108
+ 'DialogLine',
109
+ 'Act',
110
+ 'Scene',
111
+ 'PlotBeat',
112
+ 'CharacterArc',
113
+ 'SourceDoc',
114
+ 'Persona',
115
+ ] as const;
116
+
117
+ /**
118
+ * Runtime tuple of the READ-SURFACE relationship vocabulary — every edge type a
119
+ * viewer can encounter on `getVideoGraph` edges. SUPERSET of the original
120
+ * pipeline edges (additive). The create-surface subset is {@link userCreatableEdges}.
121
+ */
122
+ export const GRAPH_RELATIONSHIP_TYPES: readonly GraphRelationshipType[] = [
123
+ 'HAS_SHOT',
124
+ 'MENTIONS',
125
+ 'HAS_EVENT',
126
+ 'HAS_DIALOG',
127
+ 'SPOKEN_BY',
128
+ 'NEXT',
129
+ 'HAS_ACT',
130
+ 'IN_ACT',
131
+ 'CONTAINS',
132
+ 'INCLUDES',
133
+ 'RELATES_TO',
134
+ 'CAUSES',
135
+ 'SET_IN',
136
+ 'FEATURES',
137
+ 'ON_ARC',
138
+ 'LEADS_TO',
139
+ // M7 Phase 4: pipeline-written SourceDoc-[:ANNOTATES]->(Entity|Scene) edge
140
+ // (read-surface only; NOT in the user-creatable subset).
141
+ 'ANNOTATES',
142
+ // M7 Phase 5: pipeline-only Persona-[:PORTRAYS]->Entity edge (read-surface
143
+ // only; NOT in the user-creatable subset).
144
+ 'PORTRAYS',
145
+ ] as const;
146
+
147
+ /**
148
+ * Primary-key property per node label (mirrors `PRIMARY_KEY`).
149
+ *
150
+ * NOTE: keyed on the CLOSED `GraphNodeLabel` union, unlike the Python
151
+ * `dict[str, str]`. A Story-Engine phase that adds a narrative label (e.g.
152
+ * `Act`) must widen BOTH `GraphNodeLabel` AND this `Record` key here, in the
153
+ * same change — TS will flag the gap as a type error until both are updated.
154
+ */
155
+ export const GRAPH_PRIMARY_KEY: Readonly<Record<GraphNodeLabel, string>> = {
156
+ Video: 'videoId',
157
+ Shot: 'shotId',
158
+ Entity: 'entityId',
159
+ Event: 'eventId',
160
+ DialogLine: 'dialogId',
161
+ Act: 'actId',
162
+ Scene: 'sceneId',
163
+ PlotBeat: 'beatId',
164
+ CharacterArc: 'arcId',
165
+ SourceDoc: 'docId',
166
+ Persona: 'personaId',
167
+ } as const;
168
+
169
+ /**
170
+ * Story Engine Phase 5 — the node label for graph entities. Single source for
171
+ * the ``'Entity'`` label string so call sites (e.g. the persona↔character
172
+ * binding affordance) don't hardcode it. Mirrors
173
+ * ``shared/neo4j_queries.py:LABEL_ENTITY``.
174
+ */
175
+ export const GRAPH_ENTITY_LABEL: GraphNodeLabel = 'Entity';
176
+
177
+ /**
178
+ * Story Engine Phase 5 — the ``Entity.type`` property value identifying a
179
+ * character (vs. location / object / organization). Mirrors backend
180
+ * ``shared/models.py:EntityType.CHARACTER``. Used to gate character-only UI
181
+ * without hardcoding the literal at call sites.
182
+ */
183
+ export const ENTITY_TYPE_CHARACTER = 'character' as const;
184
+
185
+ // ---------------------------------------------------------------------------
186
+ // Studio read-surface vocabulary — the node-label, edge-type, and node-property
187
+ // string constants the pure `storyGraph` projection (and the studio Scene
188
+ // inspector / Cast grid) match against when filtering a `get_video_graph`
189
+ // payload. Lifted into client-core (Platform Restructure R8.1) so the
190
+ // framework-agnostic `storyGraph` projection — now consumed by BOTH Studio
191
+ // (`web/app/components/studio/`) and the Director timeline mapper — has a single
192
+ // source for this vocabulary. The web `graphVocabulary.ts` module re-exports
193
+ // these (keeping its web-only `GRAPH_DETAIL_QUERY_PARAM` URL concern local).
194
+ //
195
+ // These mirror the backend (`shared/neo4j_queries.py`, `shared/graph_schema.py`)
196
+ // and the graph editor. `ACT`/`SHOT`/`CHARACTER_ARC` are read-only at runtime —
197
+ // `Act` is intentionally absent from the {@link GraphNodeLabel} create-surface
198
+ // union but DOES appear at read time, so these are plain string literals (the
199
+ // read-surface is wider than the typed create-surface union).
200
+ // ---------------------------------------------------------------------------
201
+
202
+ /** Node labels the studio read-surface (and `storyGraph`) match. */
203
+ export const STUDIO_NODE_LABELS = {
204
+ /** 'Act' — read-only at runtime; not in the create-surface union. */
205
+ ACT: 'Act',
206
+ SCENE: 'Scene',
207
+ SHOT: 'Shot',
208
+ ENTITY: GRAPH_ENTITY_LABEL,
209
+ CHARACTER_ARC: 'CharacterArc',
210
+ } as const;
211
+
212
+ /** Edge (relationship) types the studio read-surface (and `storyGraph`) traverse. */
213
+ export const STUDIO_EDGE_TYPES = {
214
+ /** Structural containment: Act→Scene and Scene→Shot. */
215
+ CONTAINS: 'CONTAINS',
216
+ /** Alternate structural containment used by some pipeline writers. */
217
+ INCLUDES: 'INCLUDES',
218
+ /** Scene⇄character feature edge. */
219
+ FEATURES: 'FEATURES',
220
+ /** Scene→location edge (the location an entity is set in). */
221
+ SET_IN: 'SET_IN',
222
+ /** Character→CharacterArc edge. */
223
+ ON_ARC: 'ON_ARC',
224
+ /** Character⇄character relationship edge. */
225
+ RELATES_TO: 'RELATES_TO',
226
+ } as const;
227
+
228
+ /**
229
+ * Node `properties` keys as they appear in the `get_video_graph` payload's
230
+ * `properties` map (mirrors the backend MERGE_* SET clauses).
231
+ */
232
+ export const STUDIO_NODE_PROPERTIES = {
233
+ TITLE: 'title',
234
+ INDEX: 'index',
235
+ SUMMARY: 'summary',
236
+ DESCRIPTION: 'description',
237
+ /** Scene/Shot time bounds (numeric seconds) — MERGE_SCENE / MERGE_SHOT. */
238
+ START_TIME: 'startTime',
239
+ END_TIME: 'endTime',
240
+ /** Act time bounds (numeric seconds) — MERGE_ACT uses t0/t1, not start/endTime. */
241
+ T0: 't0',
242
+ T1: 't1',
243
+ NAME: 'name',
244
+ ENTITY_TYPE: 'type',
245
+ ALIASES: 'aliases',
246
+ ENTITY_ID: 'entityId',
247
+ SCENE_ID: 'sceneId',
248
+ SHOT_ID: 'shotId',
249
+ ARC_ID: 'arcId',
250
+ CAPTION: 'caption',
251
+ } as const;
252
+
253
+ /** The `Entity.type` value identifying a character (single source). */
254
+ export const STUDIO_CHARACTER_TYPE = ENTITY_TYPE_CHARACTER;
255
+
256
+ /**
257
+ * User-editable properties per node label (mirrors `EDITABLE_NODE_PROPERTIES`).
258
+ *
259
+ * RUNTIME SOURCE OF TRUTH: the graph editor's live editable-property /
260
+ * primary-key whitelists now come from the fetched `GET /graph/schema` payload
261
+ * (see {@link fetchGraphSchema} and `web/app/jobs/[videoId]/graph/page.tsx`), so
262
+ * a backend whitelist change auto-propagates with no TS edit. These static
263
+ * `GRAPH_*` constants remain as the COMPILE-TIME typed vocabulary and a
264
+ * back-compat fallback (used while the schema is in flight, and imported by the
265
+ * sibling Vue Web-App). Keep them mirrored with the backend; do not treat them
266
+ * as the runtime authority for the editor.
267
+ */
268
+ export const GRAPH_EDITABLE_NODE_PROPERTIES: Readonly<
269
+ Record<GraphNodeLabel, readonly string[]>
270
+ > = {
271
+ // M7 Phase 1b added `themes` to the editable Video narrative props.
272
+ Video: ['fileName', 'episodeTitle', 'themes'],
273
+ Shot: ['caption'],
274
+ Entity: ['name', 'type'],
275
+ Event: ['label', 'category'],
276
+ DialogLine: ['text', 'speaker'],
277
+ // M7 Phase 1b: Act title/summary are creator-editable (the narrative is
278
+ // regeneratable, so only the human-authored fields are exposed).
279
+ Act: ['title', 'summary'],
280
+ Scene: ['title', 'summary'],
281
+ PlotBeat: ['label', 'summary'],
282
+ CharacterArc: ['label', 'summary'],
283
+ // M7 Phase 4: only the human-readable SourceDoc title is editable; the
284
+ // processor-owned provenance (kind/s3Key/contentHash/pageCount) is immutable.
285
+ SourceDoc: ['title'],
286
+ // M7 Phase 5: Persona is pipeline-only (graph_sync writer manages it) and is
287
+ // never editable through the graph editor — so it has no editable props.
288
+ Persona: [],
289
+ } as const;
290
+
291
+ /**
292
+ * Editable relationship properties (mirrors `EDITABLE_RELATIONSHIP_PROPERTIES`).
293
+ * NOTE: the Python source is a `frozenset` (unordered, unique) — this array
294
+ * carries no ordering contract; treat it as a set (membership), not a sequence.
295
+ */
296
+ export const GRAPH_EDITABLE_RELATIONSHIP_PROPERTIES: readonly string[] = [
297
+ 'confidence',
298
+ ] as const;
299
+
300
+ // ---------------------------------------------------------------------------
301
+ // User-creatable vocabulary — M7 Phase 3a (POST /graph/nodes + /graph/edges)
302
+ // ---------------------------------------------------------------------------
303
+ //
304
+ // COMPILE-TIME MIRROR of the backend `shared/graph_schema.py` creation
305
+ // whitelists: `user_creatable_labels`, `user_creatable_edges`, and
306
+ // `_VALID_EDGE_PAIRS`. Unlike the editable-property whitelist (which the
307
+ // frontend reads live from `GET /graph/schema` — see {@link fetchGraphSchema}),
308
+ // the `GET /graph/schema` payload does NOT yet serialize these creation sets
309
+ // (`GraphSchemaResponse` carries only `labels`/`edges`). So — exactly as the
310
+ // `GRAPH_*` constants above mirror the read whitelists — these are authored
311
+ // here as the compile-time mirror for the Phase-3b creation UI. Keep them in
312
+ // lockstep with the Python source; if a later phase extends the wire payload
313
+ // with creation sets, switch the UI to the fetched copy and demote these to a
314
+ // fallback (same pattern as the editable-property migration).
315
+
316
+ /**
317
+ * Node labels a creator may instantiate via `POST /graph/nodes`
318
+ * (mirrors `user_creatable_labels`). `Act` is pipeline-only (creators edit but
319
+ * do not create it); `Video`/`Shot`/`Entity`/`Event`/`DialogLine` are never
320
+ * user-creatable.
321
+ */
322
+ export const userCreatableLabels: readonly GraphNodeLabel[] = [
323
+ 'Scene',
324
+ 'PlotBeat',
325
+ 'CharacterArc',
326
+ ] as const;
327
+
328
+ /**
329
+ * CREATE-SURFACE relationship type — the strict subset of
330
+ * {@link GraphRelationshipType} a creator may instantiate via
331
+ * `POST /graph/edges`. Mirrors the backend `VALID_RELATIONSHIP_TYPES` /
332
+ * `user_creatable_edges`. The read-only pipeline / narrative-structural edges
333
+ * (`MENTIONS` / `HAS_*` / `CONTAINS` / `INCLUDES`, etc.) are part of the
334
+ * read-surface but NOT this create-surface.
335
+ */
336
+ export type UserCreatableEdge =
337
+ | 'RELATES_TO'
338
+ | 'CAUSES'
339
+ | 'SET_IN'
340
+ | 'FEATURES'
341
+ | 'ON_ARC'
342
+ | 'LEADS_TO';
343
+
344
+ /**
345
+ * CREATE-SURFACE: relationship types a creator may instantiate via
346
+ * `POST /graph/edges` (mirrors `user_creatable_edges`, identical to the
347
+ * backend's `VALID_RELATIONSHIP_TYPES`). A strict subset of the read-surface
348
+ * {@link GRAPH_RELATIONSHIP_TYPES}: the read-only pipeline / narrative-structural
349
+ * edges (`MENTIONS` / `HAS_*` / `CONTAINS` / `INCLUDES`, etc.) are encounterable
350
+ * on `getVideoGraph` but NOT creatable — the backend 422s them.
351
+ */
352
+ export const userCreatableEdges: readonly UserCreatableEdge[] = [
353
+ 'RELATES_TO',
354
+ 'CAUSES',
355
+ 'SET_IN',
356
+ 'FEATURES',
357
+ 'ON_ARC',
358
+ 'LEADS_TO',
359
+ ] as const;
360
+
361
+ /**
362
+ * Allowed `(sourceLabel, targetLabel)` endpoint pairs per user-creatable edge
363
+ * type (mirrors `_VALID_EDGE_PAIRS`). The backend rejects any edge whose
364
+ * endpoint labels are not listed here (422); for `SET_IN` / `FEATURES` the
365
+ * target `Entity.type` (location / character) is validated separately by a
366
+ * server-side read. Keyed by {@link UserCreatableEdge} (the create-surface only,
367
+ * not the full read-surface), valued by readonly `[GraphNodeLabel, GraphNodeLabel]`
368
+ * pairs.
369
+ */
370
+ export const allowedPairs: Readonly<
371
+ Record<UserCreatableEdge, readonly (readonly [GraphNodeLabel, GraphNodeLabel])[]>
372
+ > = {
373
+ RELATES_TO: [['Entity', 'Entity']],
374
+ CAUSES: [['Event', 'Event']],
375
+ SET_IN: [['Scene', 'Entity']],
376
+ FEATURES: [['Scene', 'Entity']],
377
+ ON_ARC: [['PlotBeat', 'CharacterArc']],
378
+ LEADS_TO: [['PlotBeat', 'PlotBeat']],
379
+ } as const;
380
+
381
+ /**
382
+ * Allowed `kind` values for a user-created `RELATES_TO` edge — mirrors the
383
+ * backend single source of truth (`shared/models.py:RelationshipKind`
384
+ * StrEnum: `ally|rival|family|romantic|mentor|custom`). Exposed so the M7 P3b
385
+ * CreateEdgePopover `kind` dropdown does not hand-roll the string list (DRY):
386
+ * the create-surface UI imports this rather than re-declaring it.
387
+ *
388
+ * Additive (M7 P3b): widens the create-surface mirror only; no existing export
389
+ * is removed or renamed, so the frozen public contract (pinned by the sibling
390
+ * Vue Web-App) stays valid.
391
+ */
392
+ export type RelationshipKindValue =
393
+ | 'ally'
394
+ | 'rival'
395
+ | 'family'
396
+ | 'romantic'
397
+ | 'mentor'
398
+ | 'custom';
399
+
400
+ /** Runtime tuple of {@link RelationshipKindValue} (mirrors `RelationshipKind`). */
401
+ export const RELATIONSHIP_KIND_VALUES: readonly RelationshipKindValue[] = [
402
+ 'ally',
403
+ 'rival',
404
+ 'family',
405
+ 'romantic',
406
+ 'mentor',
407
+ 'custom',
408
+ ] as const;
409
+
410
+ // ---------------------------------------------------------------------------
411
+ // Provenance — TWO SEPARATE unions (mirrors shared/provenance.py)
412
+ // ---------------------------------------------------------------------------
413
+
414
+ /**
415
+ * How a story-graph node/edge entered the graph. Separate from
416
+ * {@link MemoryFactProvenance} — do not merge them.
417
+ */
418
+ export type StoryGraphProvenance = 'pegasus' | 'user' | 'document' | 'regenerated';
419
+
420
+ /**
421
+ * How an agent-memory fact entered the `:Memory` plane. Separate from
422
+ * {@link StoryGraphProvenance} — do not merge them.
423
+ */
424
+ export type MemoryFactProvenance = 'chat' | 'document' | 'system' | 'regenerated';
425
+
426
+ /** Runtime tuple of story-graph provenance values. */
427
+ export const STORY_GRAPH_PROVENANCE_VALUES: readonly StoryGraphProvenance[] = [
428
+ 'pegasus',
429
+ 'user',
430
+ 'document',
431
+ 'regenerated',
432
+ ] as const;
433
+
434
+ /** Runtime tuple of memory-fact provenance values. */
435
+ export const MEMORY_FACT_PROVENANCE_VALUES: readonly MemoryFactProvenance[] = [
436
+ 'chat',
437
+ 'document',
438
+ 'system',
439
+ 'regenerated',
440
+ ] as const;
441
+
442
+ /**
443
+ * Authored-canon provenance — facts that chat extraction must NOT overwrite.
444
+ * Mirrors `AUTHORED_STORY_PROVENANCE` / `AUTHORED_MEMORY_PROVENANCE` in
445
+ * `shared/provenance.py`. Phase 6 (persona memory) is the first consumer; keep
446
+ * these mirrored so the frontend never re-declares the canon set or compares
447
+ * raw strings.
448
+ */
449
+ export const AUTHORED_STORY_PROVENANCE: ReadonlySet<StoryGraphProvenance> = new Set([
450
+ 'user',
451
+ 'document',
452
+ ]);
453
+
454
+ export const AUTHORED_MEMORY_PROVENANCE: ReadonlySet<MemoryFactProvenance> = new Set([
455
+ 'system',
456
+ 'document',
457
+ ]);
458
+
459
+ /** Type guard mirroring `is_story_graph_provenance` in `shared/provenance.py`. */
460
+ export function isStoryGraphProvenance(value: string): value is StoryGraphProvenance {
461
+ return (STORY_GRAPH_PROVENANCE_VALUES as readonly string[]).includes(value);
462
+ }
463
+
464
+ /** Type guard mirroring `is_memory_fact_provenance` in `shared/provenance.py`. */
465
+ export function isMemoryFactProvenance(value: string): value is MemoryFactProvenance {
466
+ return (MEMORY_FACT_PROVENANCE_VALUES as readonly string[]).includes(value);
467
+ }
468
+
469
+ // ---------------------------------------------------------------------------
470
+ // Live schema fetch — session-scoped memoization
471
+ // ---------------------------------------------------------------------------
472
+ //
473
+ // The static unions/constants above are the COMPILE-TIME vocabulary
474
+ // (PropertyPanel types against them, ../Web-App may import them). The runtime
475
+ // editable-property whitelist that drives the editor UI comes from the LIVE
476
+ // backend payload below, so the frontend never re-declares the whitelist and
477
+ // the #45 drift the PR closes cannot creep back. The static lists stay as
478
+ // types only; the fetched payload is the single runtime source of truth.
479
+
480
+ import type { GraphSchemaResponse } from './api';
481
+
482
+ /** Re-export the wire type so consumers import it from one module. */
483
+ export type { GraphSchemaResponse } from './api';
484
+
485
+ /**
486
+ * Minimal client surface `fetchGraphSchema` depends on. Keeps this module
487
+ * framework-agnostic and decoupled from the concrete `ApiClient` class — any
488
+ * object exposing `getGraphSchema()` works (real client or a test fake).
489
+ */
490
+ export interface GraphSchemaClient {
491
+ getGraphSchema(): Promise<GraphSchemaResponse>;
492
+ }
493
+
494
+ /**
495
+ * Module-scoped memoization slot. Holds the in-flight OR resolved promise so
496
+ * concurrent callers and re-renders share one network round-trip per session.
497
+ * Reset to `null` on rejection so a failed fetch can be retried.
498
+ */
499
+ let _graphSchemaPromise: Promise<GraphSchemaResponse> | null = null;
500
+
501
+ /**
502
+ * Session-scoped memoized fetch of `GET /graph/schema`. The first call kicks
503
+ * off the request; every subsequent call (concurrent or later) awaits the same
504
+ * cached promise — so `client.getGraphSchema()` runs exactly once per session.
505
+ *
506
+ * On rejection the cache is cleared so the next call retries rather than
507
+ * permanently surfacing a stale error (a transient network blip must not brick
508
+ * the editor for the rest of the session).
509
+ *
510
+ * Call `__resetGraphSchemaCache()` in tests (or on logout) to drop the cache.
511
+ */
512
+ export function fetchGraphSchema(
513
+ client: GraphSchemaClient,
514
+ ): Promise<GraphSchemaResponse> {
515
+ if (_graphSchemaPromise === null) {
516
+ _graphSchemaPromise = client.getGraphSchema().catch((err) => {
517
+ // Clear the slot so a subsequent call refetches instead of replaying the
518
+ // rejection forever. Re-throw so the awaiting caller still sees the error.
519
+ _graphSchemaPromise = null;
520
+ throw err;
521
+ });
522
+ }
523
+ return _graphSchemaPromise;
524
+ }
525
+
526
+ /**
527
+ * Test hook: drop the memoized schema promise so the next `fetchGraphSchema`
528
+ * starts fresh. Also usable on logout / session reset.
529
+ */
530
+ export function __resetGraphSchemaCache(): void {
531
+ _graphSchemaPromise = null;
532
+ }
package/src/http.ts ADDED
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Shared JSON fetch helper for the Seer API clients.
3
+ *
4
+ * Single source for the bearer-auth + FastAPI-error-shaping fetch wrapper used
5
+ * by both `ApiClient` (which delegates `makeRequest` here) and the additive
6
+ * `AdminClient`. Kept internal (not re-exported from `index.ts`) so the public
7
+ * package surface is unchanged — it is an implementation detail shared across
8
+ * the client classes, not a new export.
9
+ */
10
+
11
+ /** FastAPI error body: `detail` is a string, or an array of validation errors. */
12
+ interface ApiErrorBody {
13
+ detail?: string | Array<{ msg?: string; loc?: string[] }>;
14
+ }
15
+
16
+ /**
17
+ * Issue a JSON request, injecting the bearer token and shaping FastAPI errors.
18
+ *
19
+ * - Adds `Authorization: Bearer <token>` when `sessionToken` is set (anonymous
20
+ * otherwise, for land-dark endpoints).
21
+ * - On a non-2xx response, throws an `Error` whose message is the FastAPI
22
+ * `detail` (validation arrays are flattened to `loc: msg; …`).
23
+ * - A `204 No Content` resolves to `undefined`.
24
+ */
25
+ export async function requestJson<T>(
26
+ baseUrl: string,
27
+ endpoint: string,
28
+ sessionToken: string | undefined,
29
+ options: RequestInit = {},
30
+ ): Promise<T> {
31
+ const url = `${baseUrl}${endpoint}`;
32
+
33
+ const headers: Record<string, string> = {
34
+ 'Content-Type': 'application/json',
35
+ ...(options.headers as Record<string, string>),
36
+ };
37
+ if (sessionToken) {
38
+ headers['Authorization'] = `Bearer ${sessionToken}`;
39
+ }
40
+
41
+ try {
42
+ const response = await fetch(url, { ...options, headers });
43
+
44
+ if (!response.ok) {
45
+ const error: ApiErrorBody = await response.json().catch(() => ({
46
+ detail: `HTTP ${response.status}: ${response.statusText}`,
47
+ }));
48
+ const detail = error.detail;
49
+ let message: string;
50
+ if (Array.isArray(detail)) {
51
+ message = detail
52
+ .map((e) =>
53
+ e.msg ? `${(e.loc || []).slice(-1).join('.')}: ${e.msg}` : String(e),
54
+ )
55
+ .join('; ');
56
+ } else {
57
+ message = detail || `Request failed: ${response.status}`;
58
+ }
59
+ throw new Error(message);
60
+ }
61
+
62
+ // 204 No Content returns no body.
63
+ if (response.status === 204) {
64
+ return undefined as T;
65
+ }
66
+
67
+ return (await response.json()) as T;
68
+ } catch (error) {
69
+ console.error('API request failed:', error);
70
+ throw error;
71
+ }
72
+ }
package/src/index.ts CHANGED
@@ -26,5 +26,17 @@ export * from './visemeScheduler';
26
26
  export * from './visemeGeometry';
27
27
  export * from './websocket';
28
28
  export * from './api';
29
+ export * from './castProjection';
30
+ export * from './admin';
29
31
  export * from './reactor';
30
32
  export * from './timeFormat';
33
+ export * from './toolSchemas';
34
+ export * from './vision';
35
+ export * from './graphSchema';
36
+ // R8.1 — pure story-graph projections (deriveScenes/deriveCast + SceneView/
37
+ // CharacterView). Grepped src/ for these names first per the collision warning
38
+ // above: no existing export owns them. The web studio module re-exports these.
39
+ export * from './storyGraph';
40
+ export * from './adapters';
41
+ export * from './conversation';
42
+ export * from './platformAssistant';