@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
package/dist/api.d.ts CHANGED
@@ -115,6 +115,254 @@ export interface VideoDeletionResponse {
115
115
  deleted: VideoDeletionStats;
116
116
  errors?: string[] | null;
117
117
  }
118
+ /**
119
+ * Lifecycle status of a regeneration run. Mirrors
120
+ * `shared/models.py::RegenerationRunStatus` (a Python StrEnum) — the worker
121
+ * walks QUEUED → RUNNING → MERGING → COMPLETE, or terminates in FAILED /
122
+ * CANCELLED. Exposed as a const map (not bare literals) so call sites compare
123
+ * against `REGENERATION_STATUS.COMPLETE` rather than `'complete'`.
124
+ */
125
+ export type RegenerationRunStatus = 'queued' | 'running' | 'merging' | 'complete' | 'failed' | 'cancelled';
126
+ /** Const map of every {@link RegenerationRunStatus} value (mirrors the backend StrEnum). */
127
+ export declare const REGENERATION_STATUS: {
128
+ readonly QUEUED: "queued";
129
+ readonly RUNNING: "running";
130
+ readonly MERGING: "merging";
131
+ readonly COMPLETE: "complete";
132
+ readonly FAILED: "failed";
133
+ readonly CANCELLED: "cancelled";
134
+ };
135
+ /**
136
+ * Terminal statuses: a run in one of these will never transition again.
137
+ * Mirrors `shared/models.py::REGENERATION_TERMINAL_STATUSES`. The poller
138
+ * resolves on COMPLETE / CANCELLED and throws on FAILED — but a consumer
139
+ * rendering history can use this set to gate "in-flight" affordances.
140
+ */
141
+ export declare const REGENERATION_TERMINAL_STATUSES: readonly RegenerationRunStatus[];
142
+ /**
143
+ * The regeneration scope kind. Mirrors the backend scope grammar
144
+ * (`shared/models.py::parse_regeneration_scope`): `acts` / `characters` are
145
+ * BARE (whole-narrative), `scene` / `arc` are TARGETED (carry an `<id>`).
146
+ */
147
+ export type RegenerationScopeKind = 'acts' | 'characters' | 'scene' | 'arc';
148
+ /** Scope kinds that regenerate a whole narrative dimension (no target id). */
149
+ export declare const REGEN_SCOPE_BARE_KINDS: readonly RegenerationScopeKind[];
150
+ /** Scope kinds that target a single node by id (`<kind>:<id>`). */
151
+ export declare const REGEN_SCOPE_TARGETED_KINDS: readonly RegenerationScopeKind[];
152
+ /** Separator between a targeted scope's kind and its id (mirrors `REGEN_SCOPE_SEPARATOR`). */
153
+ export declare const REGEN_SCOPE_SEPARATOR = ":";
154
+ /**
155
+ * Build a wire-format scope string from a kind + optional target id, mirroring
156
+ * the backend grammar so callers never hand-roll `'scene:' + id`. A bare kind
157
+ * (`acts` / `characters`) MUST NOT carry a target; a targeted kind
158
+ * (`scene` / `arc`) MUST. Throws on a contract violation so a UI bug surfaces
159
+ * locally rather than as a server-side 422.
160
+ */
161
+ export declare function buildRegenerationScope(kind: RegenerationScopeKind, targetId?: string): string;
162
+ /**
163
+ * Request body for `POST .../graph/{videoId}/regenerate`. Mirrors
164
+ * `api/tools/schemas.py::RegenerateRequest` (`extra="forbid"`). `scope` is
165
+ * validated server-side against the grammar (422 on malformed); use
166
+ * {@link buildRegenerationScope} to construct it. `promptAddon` is optional
167
+ * creator-steering text appended to the Pegasus prompt (server caps the length).
168
+ */
169
+ export interface RegenerateRequest {
170
+ scope: string;
171
+ promptAddon?: string | null;
172
+ /**
173
+ * Optional docIds of accepted documents whose knowledge is folded into this
174
+ * re-run ADDITIVELY — the base prompts are never replaced (R6c). Mirrors the
175
+ * backend field: max 20 ids; summaries are resolved read-only server-side;
176
+ * unknown/foreign docIds are silently ignored and duplicates de-duplicated
177
+ * (first occurrence wins), so the response's `appliedDocumentIds` may be
178
+ * shorter than this list. NOT nullable: the backend model is `list[str]`
179
+ * (non-nullable, defaults to `[]` when omitted), so a JSON `null` would 422 —
180
+ * omit the field instead.
181
+ */
182
+ appliedDocumentIds?: string[];
183
+ }
184
+ /**
185
+ * A single regeneration run. Mirrors
186
+ * `api/tools/schemas.py::RegenerationRunResponse` — the POST 202 body, the GET
187
+ * detail body, and each entry in {@link RegenerationListResponse.runs}.
188
+ * `delta` is empty (`{}`) until the run merges; once merged it carries
189
+ * `{ nodes: { added, updated, preservedUser, removed }, edges: { ... } }`.
190
+ */
191
+ export interface RegenerationRunResponse {
192
+ traceId: string;
193
+ runId: string;
194
+ videoId: string;
195
+ scope: string;
196
+ status: RegenerationRunStatus;
197
+ statusUrl: string;
198
+ createdAt: string;
199
+ promptAddon?: string | null;
200
+ startedAt?: string | null;
201
+ completedAt?: string | null;
202
+ delta: Record<string, unknown>;
203
+ error?: string | null;
204
+ /**
205
+ * docIds of the accepted documents actually applied to this run (R6c) —
206
+ * de-duplicated, unknown/foreign ids dropped server-side. Optional so this
207
+ * client stays compatible with pre-R6c backends that omit the field; current
208
+ * backends always send it (`[]` when none were applied).
209
+ */
210
+ appliedDocumentIds?: string[];
211
+ }
212
+ /**
213
+ * Count buckets a merged run reports under {@link RegenerationRunResponse.delta}
214
+ * `.nodes`. Mirrors the backend delta keys (`shared/regeneration_merge.py::
215
+ * DELTA_*`), the single source of truth for these names crossing the store/API
216
+ * boundary. Every key is always present once a run merges (the backend seeds
217
+ * them all to 0), so a UI summarizing the delta never has to guard for absence.
218
+ */
219
+ export interface RegenerationNodeCounts {
220
+ added: number;
221
+ updated: number;
222
+ preservedUser: number;
223
+ removed: number;
224
+ }
225
+ /**
226
+ * Delta bucket key strings, mirroring `shared/regeneration_merge.py::DELTA_*`.
227
+ * Exposed as a const map so call sites read `delta[REGEN_DELTA_KEYS.nodes]`
228
+ * rather than re-typing the literals (single source of truth on the wire names).
229
+ */
230
+ export declare const REGEN_DELTA_KEYS: {
231
+ readonly nodes: "nodes";
232
+ readonly edges: "edges";
233
+ readonly added: "added";
234
+ readonly updated: "updated";
235
+ readonly preservedUser: "preservedUser";
236
+ readonly removed: "removed";
237
+ };
238
+ /**
239
+ * Extract the `nodes` count buckets from a run's {@link RegenerationRunResponse.delta}.
240
+ *
241
+ * `delta` is typed `Record<string, unknown>` (it carries `nodes` + `edges`
242
+ * sub-objects once merged, and is `{}` before merge), so a UI that wants the
243
+ * "N updated · M preserved · K added · R removed" summary needs a single,
244
+ * tested narrowing rather than ad-hoc casts at each call site. Returns all-zero
245
+ * counts when the delta is empty/malformed (an unmerged or failed run), and
246
+ * coerces any non-numeric / negative bucket to 0 so the summary line is always
247
+ * safe to render.
248
+ */
249
+ export declare function parseRegenerationNodeCounts(delta: Record<string, unknown> | null | undefined): RegenerationNodeCounts;
250
+ /**
251
+ * Response listing a video's regeneration runs (newest-first). Mirrors
252
+ * `api/tools/schemas.py::RegenerationListResponse`. `nextCursor` is an opaque
253
+ * pagination cursor (null when there is no further page).
254
+ */
255
+ export interface RegenerationListResponse {
256
+ traceId: string;
257
+ videoId: string;
258
+ runs: RegenerationRunResponse[];
259
+ nextCursor: string | null;
260
+ }
261
+ /**
262
+ * Mirrors `shared/models.py::DocumentKind` (a Python StrEnum). The classifier
263
+ * tags each uploaded source document with one of these kinds; the chat
264
+ * `document_search` tool can filter by it.
265
+ */
266
+ export type DocumentKind = 'script' | 'notes' | 'bible' | 'transcript' | 'other';
267
+ /**
268
+ * Mirrors `shared/models.py::DOC_STATUS_*` (a Literal + Final-constant set,
269
+ * NOT a StrEnum — same pattern as {@link EnrichmentStatus}). The
270
+ * document-processing pipeline advances a doc through these states; narrowing
271
+ * here lets callers compare against the exported constants below instead of
272
+ * bare string literals.
273
+ */
274
+ export type DocumentStatus = 'pending' | 'parsing' | 'extracting' | 'ready' | 'failed';
275
+ export declare const DOC_STATUS_PENDING: DocumentStatus;
276
+ export declare const DOC_STATUS_PARSING: DocumentStatus;
277
+ export declare const DOC_STATUS_EXTRACTING: DocumentStatus;
278
+ export declare const DOC_STATUS_READY: DocumentStatus;
279
+ export declare const DOC_STATUS_FAILED: DocumentStatus;
280
+ /**
281
+ * Mirrors `shared/models.py::SuggestionStatus` (Literal + Final constants).
282
+ * A pipeline-extracted graph suggestion is `pending` until a user accepts or
283
+ * rejects it via the document-detail endpoints.
284
+ */
285
+ export type SuggestionStatus = 'pending' | 'accepted' | 'rejected';
286
+ export declare const SUGGESTION_STATUS_PENDING: SuggestionStatus;
287
+ export declare const SUGGESTION_STATUS_ACCEPTED: SuggestionStatus;
288
+ export declare const SUGGESTION_STATUS_REJECTED: SuggestionStatus;
289
+ /**
290
+ * A pipeline-proposed graph mutation awaiting user review. `kind` says whether
291
+ * `payload` is a proposed node or edge; `payload` carries the proposed
292
+ * node/edge contents (label/properties for a node, endpoints/type/properties
293
+ * for an edge). Accepting it writes the node/edge with provenance `document`.
294
+ */
295
+ export interface Suggestion {
296
+ suggestionId: string;
297
+ status: SuggestionStatus;
298
+ kind: 'node' | 'edge';
299
+ payload: Record<string, unknown>;
300
+ }
301
+ /**
302
+ * The wire shape for a single source document — mirrors the backend
303
+ * `api/tools/schemas.py::DocumentResponse` (built from `SourceDocRecord` via
304
+ * `DocumentResponse.from_record`). The backend intentionally OMITS the record's
305
+ * `ownerUserId`/`s3Key`/`contentHash`, so they are absent here too. `videoId`/
306
+ * `seriesId` are optional links; `parseError`/`parseWarning` are populated when
307
+ * parsing fails or partially succeeds. `suggestions` is always present (the
308
+ * detail endpoint populates it; list endpoints return an empty array).
309
+ */
310
+ export interface DocumentRecord {
311
+ docId: string;
312
+ status: DocumentStatus;
313
+ videoId?: string | null;
314
+ seriesId?: string | null;
315
+ kind: DocumentKind;
316
+ title: string;
317
+ pageCount: number;
318
+ parseError?: string | null;
319
+ parseWarning?: string | null;
320
+ suggestions: Suggestion[];
321
+ createdAt?: string | null;
322
+ updatedAt?: string | null;
323
+ }
324
+ /**
325
+ * Response from `POST /api/v1/ingestion/documents` (multipart upload). Mirrors
326
+ * the backend `DocumentUploadResponse` — 202 for a freshly-staged document, 200
327
+ * when an identical upload by the same owner dedupes to an existing `document`.
328
+ */
329
+ export interface UploadDocumentResponse {
330
+ traceId: string;
331
+ document: DocumentRecord;
332
+ }
333
+ /** Optional metadata attached to a document upload. */
334
+ export interface UploadDocumentMeta {
335
+ videoId?: string;
336
+ seriesId?: string;
337
+ episodeNumber?: number;
338
+ kind: DocumentKind;
339
+ title: string;
340
+ }
341
+ export interface ListDocumentsResponse {
342
+ traceId: string;
343
+ results: DocumentRecord[];
344
+ nextToken?: string | null;
345
+ }
346
+ /**
347
+ * `GET /api/v1/ingestion/documents/{docId}` — mirrors the backend
348
+ * `DocumentDetailResponse`. There is NO top-level `suggestions` field: the
349
+ * suggestion list is nested inside `document.suggestions` (the detail endpoint
350
+ * calls `DocumentResponse.from_record(..., include_suggestions=True)`).
351
+ */
352
+ export interface GetDocumentResponse {
353
+ traceId: string;
354
+ document: DocumentRecord;
355
+ }
356
+ /**
357
+ * 201 response from accepting a suggestion — mirrors the backend
358
+ * `AcceptSuggestionResponse`. `graphId` is the composite id of the created
359
+ * graph node or edge (the backend returns one field regardless of `kind`).
360
+ */
361
+ export interface AcceptSuggestionResponse {
362
+ traceId: string;
363
+ suggestionId: string;
364
+ graphId: string;
365
+ }
118
366
  export interface ChatMessage {
119
367
  role: 'user' | 'assistant';
120
368
  content: string;
@@ -126,6 +374,277 @@ export interface ChatStreamRequest {
126
374
  systemPrompt?: string;
127
375
  modelId?: string;
128
376
  }
377
+ /**
378
+ * Route the Platform Assistant (R4) is summoned on, so the server-side
379
+ * assistant can scope its `propose_form_fields` suggestions to the
380
+ * current surface + form. Mirrors `api/assistant/schemas.py:RouteContext`.
381
+ */
382
+ export interface AssistantRouteContext {
383
+ /** The UI surface, e.g. `'studio/cast'` or `'settings/defaults'`. */
384
+ surface: string;
385
+ /** The form the user is editing, e.g. `'persona'` (optional). */
386
+ formId?: string;
387
+ /** The entity/story the form is bound to, if any (optional). */
388
+ entityId?: string;
389
+ }
390
+ /**
391
+ * Request body for `POST /api/v1/assistant/stream` — the R4 Platform
392
+ * Assistant SSE copilot. Mirrors {@link ChatStreamRequest} but:
393
+ * - DROPS `videoId` — the assistant is out-of-world (not video-scoped);
394
+ * it answers tooling questions + proposes form-field values.
395
+ * - ADDS `routeContext` so the assistant knows which surface/form the
396
+ * user is on.
397
+ *
398
+ * There is intentionally NO `systemPrompt` override (unlike chat): the
399
+ * assistant has no prompt-injection escape hatch (see the R4a spec
400
+ * "Prompt-injection surface" risk). Model resolution flows server-side
401
+ * through the SAME `resolve_model_id` → `shared/model_router.py` seam the
402
+ * chat endpoint uses — `modelId` is an optional explicit pin only.
403
+ *
404
+ * `documentContext` (R11.2) is a SEPARATE, larger-capped field for an
405
+ * "operate on this document" draft (e.g. a long prompt the user wants
406
+ * refined). It is DISTINCT from the deliberately-small `prompt`
407
+ * user-message field: the server places it in MODEL CONTEXT (the system
408
+ * prompt), never the user turn, so the small `prompt` cap keeps its
409
+ * prompt-injection floor while a full-length draft still round-trips.
410
+ */
411
+ export interface AssistantStreamRequest {
412
+ prompt: string;
413
+ messages?: ChatMessage[];
414
+ modelId?: string;
415
+ routeContext?: AssistantRouteContext;
416
+ /**
417
+ * Optional large document/draft for the assistant to operate ON (R11.2).
418
+ * Placed in model context server-side, NOT the user turn. Capped at the
419
+ * admin prompt editor's max so a full-length "Improve with assistant"
420
+ * draft round-trips (the small 2 KB `prompt` cap stays for injection
421
+ * mitigation).
422
+ */
423
+ documentContext?: string;
424
+ }
425
+ /**
426
+ * Discriminated union of the SSE events the chat / assistant stream
427
+ * endpoints emit (decoded from each `data: {…}` line). Mirrors the
428
+ * transport-agnostic `ChatEventType` values in
429
+ * `shared/chat_dispatcher.py` that survive onto the SSE wire.
430
+ *
431
+ * The R4 Platform Assistant ADDS the `'suggestion'` variant ALONGSIDE the
432
+ * existing token / tool_use / tool_result / citation / error / done variants —
433
+ * it never replaces one. The assistant's `propose_form_fields` tool result is
434
+ * converted by the dispatcher into a `suggestion` event the host UI maps
435
+ * onto its own form fields (it mutates nothing server-side). Consumers
436
+ * `switch` on `type` to narrow.
437
+ */
438
+ export type AssistantStreamEvent = {
439
+ type: 'token';
440
+ timestamp?: number;
441
+ content: string;
442
+ } | {
443
+ type: 'tool_use';
444
+ timestamp?: number;
445
+ tool: string;
446
+ toolUseId: string;
447
+ } | {
448
+ /**
449
+ * The structured `tool_result` frame the dispatcher emits after EVERY
450
+ * assistant tool call (parity with the chat executor path): for
451
+ * `propose_form_fields` it follows the `suggestion` event; for the
452
+ * reference tools (`describe_tool` / `list_platform_capabilities`) it is
453
+ * the only structured result. Wire contract shared with `api/assistant`
454
+ * (the Python dispatcher emits this exact `{tool, toolUseId, result}`
455
+ * shape) — included here so an exhaustive `switch` handles it.
456
+ */
457
+ type: 'tool_result';
458
+ timestamp?: number;
459
+ tool: string;
460
+ toolUseId: string;
461
+ result: Record<string, unknown>;
462
+ } | {
463
+ type: 'citation';
464
+ timestamp?: number;
465
+ citation: Citation;
466
+ span?: string;
467
+ } | {
468
+ type: 'error';
469
+ timestamp?: number;
470
+ message: string;
471
+ } | {
472
+ type: 'done';
473
+ timestamp?: number;
474
+ reason?: string;
475
+ } | {
476
+ /**
477
+ * A `propose_form_fields` tool call surfaced as a structured
478
+ * suggestion the host page reviews + applies. Carries the target
479
+ * form id, the proposed `{fieldName: value}` map, and an optional
480
+ * rationale. Wire contract shared with `api/assistant` (the Python
481
+ * dispatcher emits this exact shape).
482
+ */
483
+ type: 'suggestion';
484
+ timestamp?: number;
485
+ targetForm: string;
486
+ fields: Record<string, string>;
487
+ rationale?: string;
488
+ };
489
+ /**
490
+ * One field of a creator/admin form, as returned by the R4b form-schema
491
+ * reference endpoint (`GET /api/v1/schema/{form}`). The backend DERIVES each
492
+ * field from the form's PUBLIC Pydantic request model via `model_json_schema()`
493
+ * (single source of truth — it can never drift from the real endpoint contract).
494
+ * The assistant consults this so `propose_form_fields` only proposes VALID
495
+ * field names. Mirrors `api/assistant/schemas.py:FormField`.
496
+ */
497
+ export interface FormSchemaField {
498
+ /** The wire field name (e.g. `name`, `systemPrompt`, `voiceId`). */
499
+ name: string;
500
+ /** JSON-schema type token (`string` / `integer` / `boolean` / `object` / …). */
501
+ type: string;
502
+ /** Whether the source model marks this field required. */
503
+ required: boolean;
504
+ /**
505
+ * Human-readable field description (from the Pydantic `Field(description=…)`).
506
+ * `null` when the source field declares no description (backend `str | None`).
507
+ */
508
+ description: string | null;
509
+ /**
510
+ * Optional JSON-schema constraints carried through from the source model
511
+ * (e.g. `{ maxLength, minLength, enum }`). Absent when the field has none.
512
+ */
513
+ constraints?: Record<string, unknown>;
514
+ /** Optional example values for the field, when the source model supplies them. */
515
+ examples?: unknown[];
516
+ }
517
+ /**
518
+ * Response of `GET /api/v1/schema/{form}` (R4b) — the queryable, drift-proof
519
+ * description of a named creator/admin form's fields. `form` is the requested
520
+ * form id (`personas` / `documents` / `adventures` / `images` / `scenes` — an
521
+ * explicit allow-list; `scenes` returns the editable Scene fields {title,
522
+ * summary} since R11.3 added the public `UpdateSceneRequest` model; NEVER an
523
+ * extraction-prompt form, per the graph-corruption carve-out, tech-debt #336).
524
+ * Mirrors `api/assistant/schemas.py:FormSchemaResponse`.
525
+ */
526
+ export interface FormSchemaResponse {
527
+ /** The form id this schema describes. */
528
+ form: string;
529
+ /** The form's fields, derived from its public Pydantic request model. */
530
+ fields: FormSchemaField[];
531
+ /** Trace id for log correlation. */
532
+ traceId: string;
533
+ }
534
+ /**
535
+ * One tool's human-readable reference, as returned by the R4b tool-reference
536
+ * endpoints. DERIVED from the full `shared/tool_schemas` registry
537
+ * (`iter_all_tool_schemas` — chat + adventure + assistant; the same source the
538
+ * executor resolves from — the catalogue and the runtime tool surface cannot
539
+ * diverge). `params` is the per-parameter descriptor map keyed by parameter
540
+ * name. Mirrors `api/assistant/schemas.py:ToolReference`.
541
+ */
542
+ export interface ToolReference {
543
+ /** The tool name (e.g. `propose_form_fields`, `semantic_search`). */
544
+ name: string;
545
+ /** Human-readable description of what the tool does. */
546
+ description: string;
547
+ /** Per-parameter descriptors keyed by parameter name. */
548
+ params: Record<string, unknown>;
549
+ }
550
+ /**
551
+ * Response of `GET /api/v1/tools/reference` (R4b) — every executor-resolvable
552
+ * tool, derived from the full `shared/tool_schemas` registry
553
+ * (`iter_all_tool_schemas` — chat + adventure + assistant) so the catalogue
554
+ * cannot drift from the live tool list. Mirrors
555
+ * `api/assistant/schemas.py:ToolReferenceListResponse`.
556
+ */
557
+ export interface ToolReferenceListResponse {
558
+ /** Every platform tool's reference. */
559
+ tools: ToolReference[];
560
+ /** Trace id for log correlation. */
561
+ traceId: string;
562
+ }
563
+ /**
564
+ * Response of `GET /api/v1/tools/reference/{name}` (R4b) — one tool's reference
565
+ * NESTED under `tool` (matching the backend `ToolReferenceDetailResponse`, which
566
+ * keeps `traceId` at the top level alongside the `tool` object, mirroring the
567
+ * `{ tools, traceId }` list shape). 404 when the tool is unknown. Mirrors
568
+ * `api/assistant/schemas.py:ToolReferenceDetailResponse`.
569
+ */
570
+ export interface ToolReferenceResponse {
571
+ /** The requested tool's reference. */
572
+ tool: ToolReference;
573
+ /** Trace id for log correlation. */
574
+ traceId: string;
575
+ }
576
+ /**
577
+ * Capability flags advertised by a chat model. Mirrors
578
+ * ``shared/model_config.py:CAPABILITY_*`` so frontends can decide which
579
+ * UI affordances (image upload, audio chat, tool selection) to enable
580
+ * per model.
581
+ */
582
+ export type ChatModelCapability = 'tools' | 'vision' | 'audio' | 'thinking';
583
+ /**
584
+ * Single entry from ``GET /api/v1/chat/models``. The ``provider`` field
585
+ * tells consumers whether the backend will route via Bedrock or an
586
+ * OpenAI-compatible local endpoint — affects only diagnostics; the chat
587
+ * WebSocket protocol is identical for both.
588
+ */
589
+ export interface ChatModelInfo {
590
+ id: string;
591
+ name: string;
592
+ displayName: string;
593
+ provider: 'bedrock' | 'ollama' | string;
594
+ contextWindow: number;
595
+ maxOutputTokens: number;
596
+ capabilities: ChatModelCapability[];
597
+ }
598
+ export interface ChatModelsResponse {
599
+ models: ChatModelInfo[];
600
+ defaultModelId?: string | null;
601
+ }
602
+ /**
603
+ * Single entry returned by `GET /api/v1/images/models` (R1c).
604
+ *
605
+ * Mirrors `ChatModelInfo` for the read-only image-model catalogue. `capabilities`
606
+ * is the raw wire type (`string[]`) — NOT the adapter `Capability[]` union — so
607
+ * api.ts has no import cycle with `adapters/capabilities.ts`. The image adapter
608
+ * (`adapters/imageAdapter.ts`) casts it to `Capability[]` when building a
609
+ * descriptor.
610
+ */
611
+ export interface ImageModelInfo {
612
+ id: string;
613
+ displayName: string;
614
+ provider: string;
615
+ capabilities: string[];
616
+ isDefault: boolean;
617
+ isFallback: boolean;
618
+ }
619
+ export interface ImageModelsResponse {
620
+ models: ImageModelInfo[];
621
+ }
622
+ /**
623
+ * Default system prompt components returned by `GET /api/v1/chat/system-prompt`.
624
+ *
625
+ * @property film_qa - Base film analyst persona and instructions
626
+ * @property guardrails - Developer guidance and safety constraints
627
+ * @property audio_markup - Instructions for TTS-optimized responses
628
+ * @property full_default - Combined default prompt as used in chat sessions
629
+ */
630
+ export interface SystemPromptComponents {
631
+ film_qa: string;
632
+ guardrails: string;
633
+ audio_markup: string;
634
+ full_default: string;
635
+ }
636
+ /**
637
+ * Story Engine Phase 5 — outcome of syncing a persona's character binding
638
+ * to the knowledge graph (the (Persona)-[:PORTRAYS]->(Entity) edge).
639
+ * Mirrors backend ``shared/models.py:GraphSyncStatus``. Derived per-request
640
+ * by the persona router after the graph write; never persisted to DynamoDB.
641
+ *
642
+ * - ``'synced'`` — ``entity_id`` is set and the graph write succeeded.
643
+ * - ``'pending'`` — ``entity_id`` is set but the graph write failed (logged;
644
+ * reconciliation is tracked as tech-debt).
645
+ * - ``'none'`` — ``entity_id`` is null (no binding).
646
+ */
647
+ export type GraphSyncStatus = 'synced' | 'pending' | 'none';
129
648
  export interface PersonaConfig {
130
649
  persona_id: string;
131
650
  user_id: string;
@@ -167,6 +686,37 @@ export interface PersonaConfig {
167
686
  status: 'pending' | 'approved';
168
687
  created_at: string;
169
688
  updated_at: string;
689
+ /** Phase 2: opt into live-vision frame attachment on chat turns. Default
690
+ * false. When true and the persona's ``chat_model_id`` supports the
691
+ * ``vision`` capability, the backend attaches the latest browser-side
692
+ * captured frame to each user message. */
693
+ vision_enabled?: boolean;
694
+ /** Phase 2: requested vision frame cadence in frames-per-second (0.5–3.0).
695
+ * Client-side preference for the publisher's encode rate; backend
696
+ * does not currently enforce this server-side (see specs/technical-debt.md
697
+ * Issue #161). */
698
+ vision_fps?: number;
699
+ /** Story Engine Phase 5: bound character Entity ID. When set, the backend
700
+ * auto-manages a (Persona)-[:PORTRAYS]->(Entity) graph edge. Accepted on
701
+ * create/update; snake_case on the wire (matches sibling fields). Always
702
+ * present on persona responses — serialized as ``null`` when no binding.
703
+ * Typed optional only as a defensive superset for older cached payloads. */
704
+ entity_id?: string | null;
705
+ /** Story Engine Phase 5: outcome of the most recent PORTRAYS sync. Derived
706
+ * per-request by the persona router; not persisted to DynamoDB. The backend
707
+ * field is required + defaulted to ``'none'``, so it is ALWAYS present on
708
+ * every persona response (``'none'`` when there is no binding) — never
709
+ * absent. Typed optional only as a defensive superset for older cached
710
+ * payloads; treat a missing value as ``'none'``. */
711
+ graph_sync_status?: GraphSyncStatus;
712
+ /** Story Engine Phase 8a (M9 Adventure Runtime): when true this persona may
713
+ * drive an interactive adventure as the Dungeon Master (it is accepted as the
714
+ * ``dmPersonaId`` for ``POST /api/v1/adventures``). Accepted on create/update;
715
+ * snake_case on the wire (matches sibling fields). The backend field is
716
+ * required + defaults to ``false``, so it is ALWAYS present on persona
717
+ * responses — typed optional only as a defensive superset for older cached
718
+ * payloads; treat a missing value as ``false``. */
719
+ is_dungeon_master?: boolean;
170
720
  }
171
721
  export type VisemeBundleStatus = 'pending' | 'complete' | 'failed';
172
722
  export type VisemeRegenStatusValue = 'pending' | 'complete' | 'failed';
@@ -311,6 +861,13 @@ export interface RegenerateImageRequest {
311
861
  }
312
862
  export interface RegenerateImageResponse {
313
863
  traceId: string;
864
+ /** Tracked `image_id` of the new `ImageRecord` the regeneration wrote.
865
+ * `null`/absent when the S3 upload succeeded but the metadata write
866
+ * didn't (best-effort tracking) — the caller still has
867
+ * `imageUrl`/`imageS3Key` in that case. When present, the caller can
868
+ * `getImage(imageId)` the new row to auto-select it (closes
869
+ * tech-debt #110). */
870
+ imageId?: string | null;
314
871
  /** Presigned S3 URL for immediate display only. The URL has a short
315
872
  * TTL (typically 1h) and will 403 once expired — persist `imageS3Key`
316
873
  * if you need a stable handle and re-presign on read. */
@@ -392,6 +949,18 @@ export interface CreatePersonaRequest {
392
949
  prompt_addon_ids?: string[];
393
950
  is_default?: boolean;
394
951
  status?: 'pending' | 'approved';
952
+ /** Phase 2: opt into live-vision frame attachment on chat turns. */
953
+ vision_enabled?: boolean;
954
+ /** Phase 2: requested vision frame cadence in fps (0.5–3.0). */
955
+ vision_fps?: number;
956
+ /** Story Engine Phase 5: bind this persona to a character Entity. The
957
+ * backend creates a (Persona)-[:PORTRAYS]->(Entity) edge and returns
958
+ * ``graph_sync_status`` on the response. */
959
+ entity_id?: string | null;
960
+ /** Story Engine Phase 8a (M9): mark this persona as a Dungeon Master so it
961
+ * can drive interactive adventures. Optional; defaults to ``false``
962
+ * server-side. snake_case on the wire (matches sibling fields). */
963
+ is_dungeon_master?: boolean;
395
964
  }
396
965
  export interface UpdatePersonaRequest {
397
966
  name?: string | null;
@@ -419,12 +988,122 @@ export interface UpdatePersonaRequest {
419
988
  prompt_addon_ids?: string[] | null;
420
989
  is_default?: boolean | null;
421
990
  status?: 'pending' | 'approved';
991
+ /** Phase 2: opt into / out of live-vision frame attachment. */
992
+ vision_enabled?: boolean | null;
993
+ /** Phase 2: vision frame cadence in fps (0.5–3.0). */
994
+ vision_fps?: number | null;
995
+ /** Story Engine Phase 5: change the persona↔character binding. Set to a
996
+ * character Entity ID to (re)bind, or ``null`` to clear it. The backend
997
+ * reconciles the (Persona)-[:PORTRAYS]->(Entity) edge and returns
998
+ * ``graph_sync_status`` on the response. */
999
+ entity_id?: string | null;
1000
+ /** Story Engine Phase 8a (M9): toggle Dungeon-Master capability. Optional;
1001
+ * ``null``/``undefined`` skips the field (no change). snake_case on the wire
1002
+ * (matches sibling fields). */
1003
+ is_dungeon_master?: boolean | null;
422
1004
  }
423
1005
  export interface PersonaListResponse {
424
1006
  personas: PersonaConfig[];
425
1007
  total: number;
426
1008
  next_token?: string | null;
427
1009
  }
1010
+ /**
1011
+ * Story Engine Phase 5 — a single character Entity for a video, as returned
1012
+ * by ``GET /api/v1/tools/videos/{videoId}/characters``. Mirrors the backend
1013
+ * ``api/tools/schemas.py:CharacterItem`` (camelCase wire fields). ``type`` is
1014
+ * always ``'character'`` because the endpoint surfaces only character Entities.
1015
+ */
1016
+ export interface CharacterItem {
1017
+ entityId: string;
1018
+ name: string;
1019
+ type: 'character';
1020
+ aliases: string[];
1021
+ }
1022
+ /**
1023
+ * Story Engine Phase 5 — response of
1024
+ * ``GET /api/v1/tools/videos/{videoId}/characters``. Lists only ``Entity``
1025
+ * nodes with ``type === 'character'`` for the given video. Mirrors the
1026
+ * backend ``api/tools/schemas.py:CharacterListResponse``.
1027
+ */
1028
+ export interface CharacterListResponse {
1029
+ traceId: string;
1030
+ videoId: string;
1031
+ characters: CharacterItem[];
1032
+ }
1033
+ /**
1034
+ * Platform Restructure R5a — one CharacterArc attached to a cast character.
1035
+ * Mirrors the backend ``api/tools/schemas.py:CastArc``.
1036
+ */
1037
+ export interface CastArc {
1038
+ arcId: string;
1039
+ /** Display title — the server falls back to the arc label, then arcId. */
1040
+ title: string;
1041
+ summary: string | null;
1042
+ index: number;
1043
+ }
1044
+ /**
1045
+ * Platform Restructure R5c — one Scene featuring a cast character, with the
1046
+ * display ``title`` riding alongside the id (the studio character drawer
1047
+ * renders titles; pre-R5c they came from a client-side lookup over the full
1048
+ * graph payload). Mirrors the backend ``api/tools/schemas.py:CastScene``.
1049
+ */
1050
+ export interface CastScene {
1051
+ sceneId: string;
1052
+ /** Display title — the server falls back to the sceneId when untitled. */
1053
+ title: string;
1054
+ }
1055
+ /**
1056
+ * Platform Restructure R5a/R5c — a character Entity as projected for the
1057
+ * studio Cast view. Carries everything the character drawer renders
1058
+ * (aliases/scenes/arcs/relatedCharacterIds), so the R5c CastGrid rewire is a
1059
+ * drop-in. Mirrors the backend ``api/tools/schemas.py:CastCharacter``. R5c
1060
+ * (the first consumer, shipped before this type was ever published) reshaped
1061
+ * R5a's ``sceneIds: string[]`` into ``scenes: CastScene[]``.
1062
+ */
1063
+ export interface CastCharacter {
1064
+ entityId: string;
1065
+ name: string;
1066
+ aliases: string[];
1067
+ scenes: CastScene[];
1068
+ arcs: CastArc[];
1069
+ /** RELATES_TO character neighbours, filtered to ids within this cast. */
1070
+ relatedCharacterIds: string[];
1071
+ }
1072
+ /**
1073
+ * Platform Restructure R5a — display fields of the persona bound to a cast
1074
+ * character, hydrated server-side from the persona store (the binding is
1075
+ * resolved via the graph PORTRAYS edge + the authoritative
1076
+ * ``PersonaConfig.entity_id``, NOT by client-side string equality). camelCase
1077
+ * wire fields per the tools-API convention. Mirrors the backend
1078
+ * ``api/tools/schemas.py:CastPersonaSummary``.
1079
+ */
1080
+ export interface CastPersonaSummary {
1081
+ personaId: string;
1082
+ name: string;
1083
+ chatModelId: string;
1084
+ characterImageId: string | null;
1085
+ isDungeonMaster: boolean;
1086
+ }
1087
+ /**
1088
+ * Platform Restructure R5a — one cast row: a character pre-joined to its
1089
+ * bound persona (``null`` when unbound). Mirrors the backend
1090
+ * ``api/tools/schemas.py:CastEntry``.
1091
+ */
1092
+ export interface CastEntry {
1093
+ character: CastCharacter;
1094
+ persona: CastPersonaSummary | null;
1095
+ }
1096
+ /**
1097
+ * Platform Restructure R5a — response of
1098
+ * ``GET /api/v1/tools/videos/{videoId}/cast``: the one-call server-side
1099
+ * replacement for the studio CastGrid's two-call client-side ``entity_id``
1100
+ * join. Mirrors the backend ``api/tools/schemas.py:CastWithPersonaResponse``.
1101
+ */
1102
+ export interface CastWithPersonaResponse {
1103
+ traceId: string;
1104
+ videoId: string;
1105
+ cast: CastEntry[];
1106
+ }
428
1107
  export interface SynthesizedPersona {
429
1108
  name: string;
430
1109
  description: string;
@@ -477,6 +1156,34 @@ export interface ChatWsTokenResponse {
477
1156
  /** Seconds until expiry. Mirrors `WS_TOKEN_TTL_SECONDS` server-side. */
478
1157
  expiresIn: number;
479
1158
  }
1159
+ /**
1160
+ * Response from `POST /api/v1/chat/vision-rtc/credentials` — mirrors
1161
+ * the Pydantic `VisionRtcCredentialsResponse` on the backend. `mode`
1162
+ * tells the publisher whether to use the chat-WS signaling protocol
1163
+ * (`local`) or the KVS WebRTC SDK (`kvs`); the rest of the fields are
1164
+ * the connection-establishment material for the chosen mode.
1165
+ *
1166
+ * Re-exported as `VisionRtcCredentials` from
1167
+ * `@escapeaihq/client-core/vision` for convenience at the
1168
+ * `VisionPublisher` callsite.
1169
+ */
1170
+ export interface ChatVisionRtcCredentialsResponse {
1171
+ mode: 'local' | 'kvs';
1172
+ iceServers: Array<{
1173
+ urls: string[];
1174
+ username?: string | null;
1175
+ credential?: string | null;
1176
+ }>;
1177
+ signedSignalingUrl: string | null;
1178
+ channelArn: string | null;
1179
+ clientId: string | null;
1180
+ /** kvs mode only: AWS region for SigV4-signing follow-up ICE
1181
+ * candidate messages. Null in local mode. */
1182
+ region: string | null;
1183
+ expiresIn: number;
1184
+ /** Opaque request id for log correlation — matches chat-API logs. */
1185
+ traceId: string;
1186
+ }
480
1187
  export interface SessionMessage {
481
1188
  role: string;
482
1189
  content: string;
@@ -585,9 +1292,106 @@ export interface VideoGraphResponse {
585
1292
  nodes: GraphNode[];
586
1293
  edges: GraphEdge[];
587
1294
  }
1295
+ /**
1296
+ * Detail level for the video-graph read (Platform Restructure R5b). Mirrors
1297
+ * `shared/graph_schema.py`'s `GraphDetail` — the single source of the
1298
+ * `story`/`raw` mode literals (constants over bare strings; consumers compare
1299
+ * against `GRAPH_DETAIL.*`, never a raw literal).
1300
+ *
1301
+ * - `RAW` (the server default — omitting the `detail` arg keeps the request
1302
+ * byte-identical to the pre-R5b call): the full extraction subgraph.
1303
+ * - `STORY`: the curated story view — Acts, Scenes (each Scene node's
1304
+ * `properties` carries a read-time `shotCount`), the character cast,
1305
+ * document contributions, and narrative edges; Shot/DialogLine/Event nodes
1306
+ * and MENTIONS edges are collapsed server-side.
1307
+ */
1308
+ export declare const GRAPH_DETAIL: {
1309
+ readonly STORY: "story";
1310
+ readonly RAW: "raw";
1311
+ };
1312
+ export type GraphDetail = (typeof GRAPH_DETAIL)[keyof typeof GRAPH_DETAIL];
1313
+ /**
1314
+ * Per-story aggregate counts surfaced on the Creator Studio overview. Derived
1315
+ * server-side from the existing graph + document readers (no new graph
1316
+ * machinery): acts/scenes/characters come from `GET /api/v1/tools/graph`
1317
+ * node labels (characters = `Entity` with `type === 'character'`), documents
1318
+ * from the P4 document store.
1319
+ */
1320
+ export interface StoryCounts {
1321
+ acts: number;
1322
+ scenes: number;
1323
+ characters: number;
1324
+ documents: number;
1325
+ }
1326
+ /**
1327
+ * Summary item returned by `GET /api/v1/stories`. The Story resource is a
1328
+ * thin, read-only view over the existing Video — `storyId === videoId` (1:1)
1329
+ * in M7 P7. Both fields are present and equal so consumers can read whichever
1330
+ * they prefer; a future real-ULID Story milestone can diverge them without a
1331
+ * breaking shape change.
1332
+ */
1333
+ export interface StorySummary {
1334
+ storyId: string;
1335
+ videoId: string;
1336
+ title: string;
1337
+ updatedAt: string;
1338
+ /** Always `null` in P7 (no poster source); reserved for future population. */
1339
+ posterUrl?: string | null;
1340
+ }
1341
+ /** Detail returned by `GET /api/v1/stories/{storyId}` — summary fields + counts. */
1342
+ export interface StoryDetail {
1343
+ storyId: string;
1344
+ videoId: string;
1345
+ title: string;
1346
+ updatedAt: string;
1347
+ posterUrl?: string | null;
1348
+ counts: StoryCounts;
1349
+ }
1350
+ export interface ListStoriesResponse {
1351
+ traceId: string;
1352
+ stories: StorySummary[];
1353
+ }
1354
+ export interface GetStoryResponse {
1355
+ traceId: string;
1356
+ story: StoryDetail;
1357
+ }
1358
+ /**
1359
+ * Request params for {@link ApiClient.clipLookup}. Mirrors the backend
1360
+ * `ClipLookupRequest` (`shared/tool_request_models.py`). `BaseSchema` has NO
1361
+ * alias generator and the model declares `videoId` literally (camelCase,
1362
+ * `# noqa: N815`), so the wire keys are camelCase verbatim — the client does
1363
+ * not remap.
1364
+ */
1365
+ export interface ClipLookupParams {
1366
+ videoId: string;
1367
+ /** Clip start time in seconds (>= 0). */
1368
+ t0: number;
1369
+ /** Clip end time in seconds (> 0). */
1370
+ t1: number;
1371
+ }
1372
+ /**
1373
+ * Response from `POST /api/v1/tools/clip-lookup`. Mirrors the backend
1374
+ * `ClipLookupResponse` (`api/tools/schemas.py`) — camelCase keys verbatim.
1375
+ * `url` is a presigned (or local-stub) playable URL for the [t0,t1] span;
1376
+ * `citation` carries the time-coded span.
1377
+ */
1378
+ export interface ClipLookupResponse {
1379
+ traceId: string;
1380
+ url: string;
1381
+ expiresIn: number;
1382
+ citation: {
1383
+ videoId: string;
1384
+ t0: number;
1385
+ t1: number;
1386
+ shotId?: string | null;
1387
+ };
1388
+ source: {
1389
+ system: string;
1390
+ details?: Record<string, unknown> | null;
1391
+ };
1392
+ }
588
1393
  export interface UpdateNodeRequest {
589
1394
  nodeLabel: string;
590
- idProperty: string;
591
1395
  idValue: string;
592
1396
  properties: Record<string, unknown>;
593
1397
  }
@@ -597,7 +1401,6 @@ export interface UpdateNodeResponse {
597
1401
  }
598
1402
  export interface DeleteNodeRequest {
599
1403
  nodeLabel: string;
600
- idProperty: string;
601
1404
  idValue: string;
602
1405
  }
603
1406
  export interface DeleteNodeResponse {
@@ -623,6 +1426,71 @@ export interface DeleteRelationshipResponse {
623
1426
  traceId: string;
624
1427
  deleted: number;
625
1428
  }
1429
+ /**
1430
+ * Per-label schema entry returned by `GET /api/v1/tools/graph/schema`.
1431
+ * `pk` is the primary-key property name; `editable` is the user-editable
1432
+ * property whitelist. Both are derived server-side from the canonical
1433
+ * `shared/graph_schema.py` single source of truth.
1434
+ */
1435
+ export interface GraphLabelSchema {
1436
+ pk: string;
1437
+ editable: string[];
1438
+ }
1439
+ /** Per-relationship-type schema entry: the editable property whitelist. */
1440
+ export interface GraphEdgeSchema {
1441
+ editable: string[];
1442
+ }
1443
+ /**
1444
+ * Response from `GET /api/v1/tools/graph/schema` (M7 P1a). The live wire copy
1445
+ * of the graph whitelists — lets the web/ `PropertyPanel` drop its
1446
+ * hand-maintained mirror (tech-debt #45) and consume the same vocabulary the
1447
+ * backend validates against. No auth required (pure metadata).
1448
+ */
1449
+ export interface GraphSchemaResponse {
1450
+ traceId: string;
1451
+ labels: Record<string, GraphLabelSchema>;
1452
+ edges: Record<string, GraphEdgeSchema>;
1453
+ }
1454
+ /**
1455
+ * Body for `POST /api/v1/tools/graph/nodes` (M7 P3a). Creates a user-authored
1456
+ * narrative node (Scene / PlotBeat / CharacterArc — see {@link userCreatableLabels}
1457
+ * in `graphSchema.ts`). `videoId` IS a legitimate field here: the node does not
1458
+ * exist yet, so ownership is asserted directly from `videoId` (the documented
1459
+ * POST-carries-videoId exception to derive-ownership-from-object). The backend
1460
+ * stamps `provenance='user'`, `versionId`, and `createdAt`/`updatedAt`.
1461
+ */
1462
+ export interface CreateNodeRequest {
1463
+ videoId: string;
1464
+ label: string;
1465
+ properties: Record<string, unknown>;
1466
+ }
1467
+ /** 201 response from `POST /api/v1/tools/graph/nodes` (composite `nodeId`). */
1468
+ export interface CreateNodeResponse {
1469
+ traceId: string;
1470
+ nodeId: string;
1471
+ properties: Record<string, unknown>;
1472
+ }
1473
+ /**
1474
+ * Body for `POST /api/v1/tools/graph/edges` (M7 P3a). Creates a user-authored
1475
+ * relationship (one of {@link userCreatableEdges}). `sourceId`/`targetId` are
1476
+ * composite ids (`Label:pk:value`); both endpoints must belong to `videoId`.
1477
+ * `type` must be a user-creatable edge whose `(sourceLabel, targetLabel)` pair
1478
+ * is in {@link allowedPairs}; `properties` carries edge-specific fields (e.g.
1479
+ * `kind` for RELATES_TO, `confidence` for FEATURES, `condition` for LEADS_TO).
1480
+ */
1481
+ export interface CreateEdgeRequest {
1482
+ videoId: string;
1483
+ sourceId: string;
1484
+ targetId: string;
1485
+ type: string;
1486
+ properties?: Record<string, unknown>;
1487
+ }
1488
+ /** 201 response from `POST /api/v1/tools/graph/edges` (composite `edgeId`). */
1489
+ export interface CreateEdgeResponse {
1490
+ traceId: string;
1491
+ edgeId: string;
1492
+ properties: Record<string, unknown>;
1493
+ }
626
1494
  /**
627
1495
  * Response shape from the Reactor `/tokens` exchange, returned by the
628
1496
  * Next.js server-side broker at `/api/reactor/token`. The broker forwards
@@ -652,11 +1520,127 @@ export interface UpsampleReactorPromptRequest {
652
1520
  entityContext?: ReactorEntityContext;
653
1521
  /** Persona grounding (name + truncated backstory). */
654
1522
  personaContext?: ReactorPersonaContext;
1523
+ /**
1524
+ * Optional chat-model id to run the upsample on (R8.3). When set, it MUST be
1525
+ * one the backend chat router knows (`shared/model_config.py` — the same set
1526
+ * `GET /api/v1/chat/models` lists); an unknown id is rejected with a 422.
1527
+ * Omitted ⇒ the backend's configured default upsample model — so existing
1528
+ * callers keep their behavior (additive-only). The Director surfaces this via
1529
+ * the R1 CHAT adapter picker so the steering LLM is operator-swappable.
1530
+ */
1531
+ model?: string;
655
1532
  }
656
1533
  export interface UpsampleReactorPromptResponse {
657
1534
  traceId: string;
658
1535
  upsampledPrompt: string;
659
1536
  }
1537
+ /**
1538
+ * One entry in an adventure's turn log. Mirrors
1539
+ * `shared/adventure_models.py::TurnRecord` — the backend serializes it
1540
+ * camelCase (`{turn, beatId, summary}`) inside {@link AdventureState.turnHistory}.
1541
+ * `turn` is 1-based and monotonically increasing; the backend keeps only the
1542
+ * last `TURN_HISTORY_MAX_ENTRIES` (30) records.
1543
+ */
1544
+ export interface TurnRecord {
1545
+ turn: number;
1546
+ beatId: string;
1547
+ summary: string;
1548
+ }
1549
+ /**
1550
+ * Server-authoritative state for an in-progress interactive adventure. Mirrors
1551
+ * `shared/adventure_models.py::AdventureState` (a camelCase-on-the-wire pydantic
1552
+ * model). Returned by `POST /api/v1/adventures` and `GET
1553
+ * /api/v1/adventures/{sessionId}`. The Dungeon-Master persona mutates this via
1554
+ * the `/api/v1/tools/adventure/*` endpoints; the runtime threads `sessionId`
1555
+ * into chat turns so the DM tools resolve the active adventure.
1556
+ */
1557
+ export interface AdventureState {
1558
+ sessionId: string;
1559
+ ownerUserId: string;
1560
+ storyId: string;
1561
+ videoId: string;
1562
+ dmPersonaId: string;
1563
+ partyPersonaIds: string[];
1564
+ /** Current PlotBeat id. `null` before the first `advance_story` move. */
1565
+ currentBeatId?: string | null;
1566
+ visitedBeatIds: string[];
1567
+ flags: Record<string, string>;
1568
+ inventory: string[];
1569
+ turnHistory: TurnRecord[];
1570
+ createdAt: string;
1571
+ updatedAt: string;
1572
+ }
1573
+ /**
1574
+ * Request body for `POST /api/v1/adventures` (start an adventure). Mirrors the
1575
+ * backend `api/adventures/schemas.py::StartAdventureRequest` (`extra="forbid"`,
1576
+ * camelCase keys verbatim). `dmPersonaId` MUST reference a persona whose
1577
+ * `is_dungeon_master` is true (the backend 422s otherwise). `initialBeatId`
1578
+ * optionally seeds the starting PlotBeat; omit to start before any beat.
1579
+ */
1580
+ export interface StartAdventureRequest {
1581
+ storyId: string;
1582
+ videoId: string;
1583
+ dmPersonaId: string;
1584
+ initialBeatId?: string | null;
1585
+ /**
1586
+ * Initial party of character personas for a multi-persona adventure (M10
1587
+ * Story Engine Phase 9a). Each id must reference an owned persona that is
1588
+ * bound to a character entity and is NOT a Dungeon Master (the backend 422s
1589
+ * otherwise). Optional; omit / `[]` for an M9 single-DM adventure — the wire
1590
+ * stays unchanged (land-dark). Mirrors the additive `partyPersonaIds` field
1591
+ * on the backend `StartAdventureRequest`.
1592
+ */
1593
+ partyPersonaIds?: string[];
1594
+ }
1595
+ /**
1596
+ * The two `action` values accepted by `PATCH /api/v1/adventures/{sessionId}/party`
1597
+ * (M10 Story Engine Phase 9a). `add` appends a character persona to the party
1598
+ * (validated + deduped server-side); `remove` is an idempotent no-op when the
1599
+ * persona is absent. Named constant so call sites never hard-code the literals.
1600
+ */
1601
+ export declare const PARTY_ACTION: {
1602
+ readonly ADD: "add";
1603
+ readonly REMOVE: "remove";
1604
+ };
1605
+ /** Union of the {@link PARTY_ACTION} values. */
1606
+ export type PartyAction = (typeof PARTY_ACTION)[keyof typeof PARTY_ACTION];
1607
+ /**
1608
+ * Request body for `PATCH /api/v1/adventures/{sessionId}/party` (M10 Story
1609
+ * Engine Phase 9a). Mirrors the backend `PartyUpdateRequest` (`extra="forbid"`,
1610
+ * camelCase keys verbatim). The PATCH returns the updated
1611
+ * {@link GetAdventureResponse} (the same 200 shape as `GET adventure`).
1612
+ */
1613
+ export interface PartyUpdateRequest {
1614
+ action: PartyAction;
1615
+ personaId: string;
1616
+ }
1617
+ /**
1618
+ * 201 response from `POST /api/v1/adventures`. Mirrors the backend
1619
+ * `AdventureResponse` — carries the new `sessionId` (also in `state.sessionId`)
1620
+ * plus the full initial {@link AdventureState}. The `Location` header points at
1621
+ * `/api/v1/adventures/{sessionId}`.
1622
+ */
1623
+ export interface AdventureResponse {
1624
+ traceId: string;
1625
+ sessionId: string;
1626
+ state: AdventureState;
1627
+ }
1628
+ /** `GET /api/v1/adventures/{sessionId}` — mirrors the backend `GetAdventureResponse`. */
1629
+ export interface GetAdventureResponse {
1630
+ traceId: string;
1631
+ state: AdventureState;
1632
+ }
1633
+ /**
1634
+ * `GET /api/v1/adventures` — mirrors the backend `ListAdventuresResponse`.
1635
+ * Owner-scoped list of the caller's adventures (soft-deleted ones excluded),
1636
+ * newest-first by `createdAt`, optionally narrowed to a single `storyId`. Each
1637
+ * entry is the same camelCase {@link AdventureState} returned by
1638
+ * `GET /api/v1/adventures/{sessionId}`.
1639
+ */
1640
+ export interface ListAdventuresResponse {
1641
+ traceId: string;
1642
+ adventures: AdventureState[];
1643
+ }
660
1644
  export declare class ApiClient {
661
1645
  private baseURL;
662
1646
  private sessionToken?;
@@ -688,6 +1672,23 @@ export declare class ApiClient {
688
1672
  limit?: number;
689
1673
  nextToken?: string;
690
1674
  }): Promise<ListJobsResponse>;
1675
+ /**
1676
+ * Story Engine Phase 5 — list character entities for a video. Backs the
1677
+ * persona↔character binding selector. Returns only ``Entity`` nodes with
1678
+ * ``type === 'character'`` for the given video. Auth + video ownership are
1679
+ * enforced server-side (caller must own the video). Uses the main API base
1680
+ * (the tools routes use ``request``, not ``chatRequest``).
1681
+ */
1682
+ listVideoCharacters(videoId: string): Promise<CharacterListResponse>;
1683
+ /**
1684
+ * Platform Restructure R5a — fetch a video's character cast pre-joined to
1685
+ * each character's bound persona in ONE round-trip (the server resolves the
1686
+ * PORTRAYS binding + hydrates persona display fields). The one-call
1687
+ * replacement for the CastGrid's `getVideoGraph` + `listPersonas` client-side
1688
+ * `entity_id` join (the R5c rewire consumes this). Auth + video ownership are
1689
+ * enforced server-side. Tools API base (`request`, not `chatRequest`).
1690
+ */
1691
+ getCast(videoId: string): Promise<CastWithPersonaResponse>;
691
1692
  /**
692
1693
  * List staged videos in the ingestion bucket
693
1694
  */
@@ -716,11 +1717,150 @@ export declare class ApiClient {
716
1717
  * Delete a video and all associated data across all systems
717
1718
  */
718
1719
  deleteVideo(videoId: string, s3Key?: string): Promise<VideoDeletionResponse>;
1720
+ /**
1721
+ * Start an async narrative regeneration run for a video scope.
1722
+ * `POST /api/v1/tools/graph/{videoId}/regenerate` → 202 with the QUEUED run
1723
+ * (and a `Location` header to the run's poll URL, exposed as `statusUrl`).
1724
+ *
1725
+ * Auth + ownership are enforced server-side. A malformed `scope` is a 422,
1726
+ * an in-flight run is a 409, over-cap is a 429 — all surface as a thrown
1727
+ * `Error` carrying the FastAPI detail. Build `request.scope` with
1728
+ * {@link buildRegenerationScope}. Pair with {@link pollRegenerationUntilDone}.
1729
+ */
1730
+ startRegeneration(videoId: string, request: RegenerateRequest): Promise<RegenerationRunResponse>;
1731
+ /**
1732
+ * List a video's regeneration runs, newest-first.
1733
+ * `GET /api/v1/tools/graph/{videoId}/regenerations`. `limit` (1–100) and
1734
+ * `cursor` (opaque pagination token from a prior `nextCursor`) are optional.
1735
+ */
1736
+ listRegenerations(videoId: string, params?: {
1737
+ limit?: number;
1738
+ cursor?: string;
1739
+ }): Promise<RegenerationListResponse>;
1740
+ /**
1741
+ * Fetch a single regeneration run by id.
1742
+ * `GET /api/v1/tools/graph/{videoId}/regenerations/{runId}` (404 if absent).
1743
+ * `signal` aborts the in-flight fetch — {@link pollRegenerationUntilDone}
1744
+ * threads its poll signal through so a page unmount cancels cleanly.
1745
+ */
1746
+ getRegeneration(videoId: string, runId: string, options?: {
1747
+ signal?: AbortSignal;
1748
+ }): Promise<RegenerationRunResponse>;
1749
+ /**
1750
+ * Poll {@link getRegeneration} until the run reaches a terminal status.
1751
+ * COMPLETE / CANCELLED resolve with the final run; FAILED throws
1752
+ * (`record.error` ?? a generic message). Mirrors
1753
+ * {@link pollVisemeBundleUntilDone}: 5s cadence, abortable via `signal`,
1754
+ * and a wall-clock timeout (regeneration re-invokes Pegasus, so the default
1755
+ * matches bundle assembly — generous but bounded).
1756
+ */
1757
+ pollRegenerationUntilDone(videoId: string, runId: string, options?: {
1758
+ intervalMs?: number;
1759
+ timeoutMs?: number;
1760
+ signal?: AbortSignal;
1761
+ }): Promise<RegenerationRunResponse>;
1762
+ /**
1763
+ * Upload a source document (script / notes / bible / transcript) with
1764
+ * progress tracking. Mirrors {@link uploadVideo}: multipart XHR so the
1765
+ * browser reports upload progress (fetch cannot). The `meta` fields ride
1766
+ * alongside the file as a JSON `payload` part. Returns 201 with
1767
+ * `{ traceId, docId, statusUrl }`; the backend enqueues
1768
+ * `document-processing-queue` to parse + extract suggestions.
1769
+ */
1770
+ uploadDocument(file: File, meta: UploadDocumentMeta, onProgress?: UploadProgressCallback): Promise<UploadDocumentResponse>;
1771
+ /**
1772
+ * List source documents, optionally scoped to a video or series. Mirrors
1773
+ * {@link listJobs} query-param handling. GET `/api/v1/ingestion/documents`.
1774
+ */
1775
+ listDocuments(params?: {
1776
+ videoId?: string;
1777
+ seriesId?: string;
1778
+ limit?: number;
1779
+ nextToken?: string;
1780
+ }): Promise<ListDocumentsResponse>;
1781
+ /**
1782
+ * Fetch a single document plus its pending/resolved graph suggestions.
1783
+ * GET `/api/v1/ingestion/documents/{docId}`.
1784
+ */
1785
+ getDocument(docId: string): Promise<GetDocumentResponse>;
1786
+ /**
1787
+ * Accept a pipeline-extracted graph suggestion — writes the proposed
1788
+ * node/edge with provenance `document`. POST returns 201 with
1789
+ * `{ traceId, suggestionId, graphId }` (`graphId` is the composite id of the
1790
+ * created node/edge); a 422 (e.g. already resolved, or the payload fails
1791
+ * graph validation) surfaces the FastAPI detail as a thrown `Error`. POST
1792
+ * `.../documents/{docId}/suggestions/{sid}/accept`.
1793
+ */
1794
+ acceptSuggestion(docId: string, suggestionId: string): Promise<AcceptSuggestionResponse>;
1795
+ /**
1796
+ * Reject a pipeline-extracted graph suggestion (marks it `rejected`, writes
1797
+ * nothing to the graph). Returns 204 (no body). POST
1798
+ * `.../documents/{docId}/suggestions/{sid}/reject`.
1799
+ */
1800
+ rejectSuggestion(docId: string, suggestionId: string): Promise<void>;
1801
+ /**
1802
+ * Delete a source document and its associated data. Returns 204 (no body).
1803
+ * DELETE `/api/v1/ingestion/documents/{docId}`.
1804
+ */
1805
+ deleteDocument(docId: string): Promise<void>;
1806
+ /**
1807
+ * Shared SSE body-reader for the chat + assistant stream endpoints.
1808
+ * POSTs the JSON `body` to `url` (with the auth header when a session
1809
+ * token is set) and returns the response's `ReadableStreamDefaultReader`
1810
+ * for the caller to decode. `streamChat` and `streamAssistant` differ
1811
+ * ONLY by URL + body, so they both route through here — there is exactly
1812
+ * one fetch/reader/decoder plumbing (DRY; R4a reviewer flag).
1813
+ *
1814
+ * `errorPrefix` only shapes the fallback message when the backend
1815
+ * returns a non-2xx without a `detail` field.
1816
+ */
1817
+ private readSseStream;
719
1818
  /**
720
1819
  * Stream chat responses with Server-Sent Events
721
1820
  * Returns a ReadableStreamDefaultReader for processing SSE events
722
1821
  */
723
1822
  streamChat(request: ChatStreamRequest, signal?: AbortSignal): Promise<ReadableStreamDefaultReader<Uint8Array>>;
1823
+ /**
1824
+ * Stream Platform Assistant (R4) responses with Server-Sent Events.
1825
+ * Sibling of {@link streamChat} hitting `POST /api/v1/assistant/stream`
1826
+ * — reuses the exact same SSE reader/decoder plumbing via
1827
+ * {@link readSseStream}. Decode each `data: {…}` line into an
1828
+ * {@link AssistantStreamEvent} (the stream may carry the additive
1829
+ * `suggestion` variant). The assistant is out-of-world: the request
1830
+ * carries `routeContext` instead of `videoId`.
1831
+ */
1832
+ streamAssistant(request: AssistantStreamRequest, signal?: AbortSignal): Promise<ReadableStreamDefaultReader<Uint8Array>>;
1833
+ /**
1834
+ * Fetch the chat-model registry from the backend. Returns Bedrock entries
1835
+ * plus any locally-discovered Ollama models. Public endpoint — works
1836
+ * before the user is authenticated.
1837
+ */
1838
+ listChatModels(): Promise<ChatModelsResponse>;
1839
+ /**
1840
+ * Fetch the drift-proof field schema for a named creator/admin form
1841
+ * (`GET /api/v1/schema/{form}`). The backend derives every field from the
1842
+ * form's PUBLIC Pydantic request model (`model_json_schema()`) so it can
1843
+ * never drift from the real endpoint contract. The host UI uses this to
1844
+ * validate which `propose_form_fields` suggestions are applicable; the
1845
+ * assistant uses it to propose VALID field names. `form` is one of the
1846
+ * registered ids (`personas` / `documents` / `adventures` / `images`);
1847
+ * `scenes` is intentionally omitted and any unknown form returns 404
1848
+ * (surfaced as a thrown Error).
1849
+ */
1850
+ getFormSchema(form: string): Promise<FormSchemaResponse>;
1851
+ /**
1852
+ * List every platform tool's human-readable reference
1853
+ * (`GET /api/v1/tools/reference`). Derived server-side from the full
1854
+ * `shared/tool_schemas` registry (`iter_all_tool_schemas` — chat + adventure
1855
+ * + assistant), so the catalogue cannot drift from the live tool list.
1856
+ */
1857
+ listToolReferences(): Promise<ToolReferenceListResponse>;
1858
+ /**
1859
+ * Fetch one tool's reference by name
1860
+ * (`GET /api/v1/tools/reference/{name}`). 404 (thrown Error) when the tool
1861
+ * is unknown.
1862
+ */
1863
+ getToolReference(name: string): Promise<ToolReferenceResponse>;
724
1864
  /**
725
1865
  * Create a new persona
726
1866
  */
@@ -754,9 +1894,25 @@ export declare class ApiClient {
754
1894
  * Does NOT persist — returns suggestions to create individually.
755
1895
  */
756
1896
  synthesizePersonas(videoId: string, enrichmentData: Record<string, unknown>, maxPersonas?: number): Promise<SynthesizePersonasResponse>;
1897
+ /**
1898
+ * Fetch the image-model catalogue from the backend (R1c). Read-only.
1899
+ * Unlike {@link listChatModels}, this endpoint is **authenticated** (its
1900
+ * consumers — Studio Images, the Admin adapter inspector — are post-auth, so
1901
+ * it is not a public pre-auth path); call it with a valid session. Served via
1902
+ * the CHAT base URL (the images API is mounted on the chat app), so this uses
1903
+ * `chatRequest`, NOT `toolsRequest`.
1904
+ */
1905
+ listImageModels(): Promise<ImageModelsResponse>;
757
1906
  listImages(params?: {
758
1907
  category?: ImageCategory;
759
1908
  videoId?: string;
1909
+ /** Filter by generation model. Valid ids come from `listImageModels()`
1910
+ * (R1's `GET /api/v1/images/models`); the backend rejects an
1911
+ * unregistered id with 400. */
1912
+ model?: string;
1913
+ /** Filter by lifecycle status. Reuses the `ImageStatus` union
1914
+ * (`ImageRecord['status']`) — no parallel status enum (R6b). */
1915
+ status?: ImageStatus;
760
1916
  limit?: number;
761
1917
  nextToken?: string;
762
1918
  }): Promise<ImageListResponse>;
@@ -850,6 +2006,19 @@ export declare class ApiClient {
850
2006
  * by `POST /api/v1/chat/ws-token` in `api/chat/app.py`.
851
2007
  */
852
2008
  getChatWsToken(): Promise<ChatWsTokenResponse>;
2009
+ /**
2010
+ * Mint WebRTC signaling credentials for a vision-publisher session.
2011
+ *
2012
+ * Returns either `local`-mode config (STUN-only; existing chat-WS
2013
+ * signaling protocol) or `kvs`-mode config (SigV4-presigned wss://
2014
+ * URL + short-term STUN/TURN). The publisher branches on `mode` —
2015
+ * raw AWS credentials never reach the browser.
2016
+ *
2017
+ * Token TTL is short (~300s); callers running long-lived sessions
2018
+ * should re-call this method before `expiresIn` elapses. The current
2019
+ * VisionPublisher does NOT auto-refresh.
2020
+ */
2021
+ getVisionRtcCredentials(): Promise<ChatVisionRtcCredentialsResponse>;
853
2022
  /**
854
2023
  * List available TTS voices. Backed by `GET /api/voices` — server
855
2024
  * caches Inworld results for 5 min; pass `refresh: true` to bypass.
@@ -909,11 +2078,59 @@ export declare class ApiClient {
909
2078
  t0?: number;
910
2079
  t1?: number;
911
2080
  }): Promise<EntityTimelineResponse>;
912
- getVideoGraph(videoId: string): Promise<VideoGraphResponse>;
2081
+ /**
2082
+ * Fetch a video's subgraph. R5b: the optional `detail` arg selects the
2083
+ * server-side view — `GRAPH_DETAIL.STORY` for the collapsed story view,
2084
+ * `GRAPH_DETAIL.RAW` for the full extraction graph. Omitting it sends NO
2085
+ * query param (byte-identical to the pre-R5b request — the server defaults
2086
+ * to raw), so every existing caller is untouched.
2087
+ */
2088
+ getVideoGraph(videoId: string, detail?: GraphDetail): Promise<VideoGraphResponse>;
2089
+ /**
2090
+ * List all stories (videos) visible to the caller. `storyId === videoId`
2091
+ * (1:1) in M7 P7 — the Story resource is a thin, read-only view over the
2092
+ * existing Video. No pagination/filter parameters in P7.
2093
+ */
2094
+ listStories(): Promise<ListStoriesResponse>;
2095
+ /**
2096
+ * Fetch a single story's metadata + aggregate counts. Throws (404) when the
2097
+ * id resolves to no Video node.
2098
+ */
2099
+ getStory(storyId: string): Promise<GetStoryResponse>;
2100
+ /**
2101
+ * Resolve a playable (presigned or local-stub) URL for a clip span via the
2102
+ * existing `POST /api/v1/tools/clip-lookup` tool endpoint. Used by the studio
2103
+ * Scene inspector to scope the player to a scene's `[t0, t1]`. Additive — never
2104
+ * remove/rename. Wire keys are camelCase (backend `BaseSchema`, no aliasing).
2105
+ */
2106
+ clipLookup(params: ClipLookupParams): Promise<ClipLookupResponse>;
2107
+ /**
2108
+ * Fetch the live graph whitelist (node PKs + editable properties per label
2109
+ * and edge type). No auth required — pure metadata. Prefer the memoized
2110
+ * `fetchGraphSchema()` wrapper in `graphSchema.ts` over calling this per
2111
+ * render; the raw method exists for that wrapper and one-off callers.
2112
+ */
2113
+ getGraphSchema(): Promise<GraphSchemaResponse>;
913
2114
  updateGraphNode(data: UpdateNodeRequest): Promise<UpdateNodeResponse>;
914
2115
  deleteGraphNode(data: DeleteNodeRequest): Promise<DeleteNodeResponse>;
915
2116
  updateGraphEdge(data: UpdateRelationshipRequest): Promise<UpdateRelationshipResponse>;
916
2117
  deleteGraphEdge(data: DeleteRelationshipRequest): Promise<DeleteRelationshipResponse>;
2118
+ /**
2119
+ * Create a user-authored narrative node (Scene / PlotBeat / CharacterArc).
2120
+ * POST returns 201 with `{traceId, nodeId, properties}`; `makeRequest` parses
2121
+ * the body (only 204 is bodyless) and surfaces a 422 (e.g. label not
2122
+ * user-creatable, missing actId/index for a Scene) as a thrown `Error` with
2123
+ * the FastAPI detail. The backend stamps provenance/versionId/timestamps.
2124
+ */
2125
+ createGraphNode(data: CreateNodeRequest): Promise<CreateNodeResponse>;
2126
+ /**
2127
+ * Create a user-authored relationship (RELATES_TO / CAUSES / SET_IN /
2128
+ * FEATURES / ON_ARC / LEADS_TO). POST returns 201 with
2129
+ * `{traceId, edgeId, properties}`; a 422 (invalid endpoint-label pair,
2130
+ * pipeline-only type, cross-video endpoints, or SET_IN/FEATURES Entity.type
2131
+ * mismatch) surfaces as a thrown `Error` with the FastAPI detail.
2132
+ */
2133
+ createGraphEdge(data: CreateEdgeRequest): Promise<CreateEdgeResponse>;
917
2134
  /**
918
2135
  * Fetch a persona's viseme bundle by ID. Returns the full record including
919
2136
  * inline body_svg and mouth_paths when status === 'complete'.
@@ -1091,6 +2308,15 @@ export declare class ApiClient {
1091
2308
  getSeedImageBlob(imageId: string, options?: {
1092
2309
  signal?: AbortSignal;
1093
2310
  }): Promise<Blob>;
2311
+ /**
2312
+ * Fetch the default system prompt components from the Chat API.
2313
+ * Backed by `GET /api/v1/chat/system-prompt`.
2314
+ *
2315
+ * Authentication is required — the client must have a session token set.
2316
+ * Callers that need caching should wrap this in their own layer (see
2317
+ * `web/lib/systemPrompt.ts` which keeps a 5-minute in-memory cache).
2318
+ */
2319
+ getSystemPrompt(): Promise<SystemPromptComponents>;
1094
2320
  /**
1095
2321
  * Knowledge-grounded prompt upsample — expands a short user prompt
1096
2322
  * into a Helios-quality 80-120 word paragraph using Bedrock. Routes
@@ -1104,5 +2330,75 @@ export declare class ApiClient {
1104
2330
  upsampleReactorPrompt(input: UpsampleReactorPromptRequest, options?: {
1105
2331
  signal?: AbortSignal;
1106
2332
  }): Promise<UpsampleReactorPromptResponse>;
2333
+ /**
2334
+ * Start an interactive adventure for a story/video, driven by a
2335
+ * Dungeon-Master persona. `POST /api/v1/adventures` → 201 with the initial
2336
+ * {@link AdventureState} (and a `Location` header to the session's GET URL).
2337
+ *
2338
+ * Auth + video ownership are enforced server-side. `dmPersonaId` must
2339
+ * reference an owned persona whose `is_dungeon_master` is true (422 otherwise),
2340
+ * and a missing/unowned persona is a 404/403 — all surface as a thrown `Error`
2341
+ * carrying the FastAPI detail. Additive — never remove/rename.
2342
+ */
2343
+ startAdventure(request: StartAdventureRequest, options?: {
2344
+ signal?: AbortSignal;
2345
+ }): Promise<AdventureResponse>;
2346
+ /**
2347
+ * Fetch the current {@link AdventureState} for a session.
2348
+ * `GET /api/v1/adventures/{sessionId}` (404 when absent or not owned by the
2349
+ * caller — the store hides cross-tenant and soft-deleted sessions).
2350
+ */
2351
+ getAdventure(sessionId: string, options?: {
2352
+ signal?: AbortSignal;
2353
+ }): Promise<GetAdventureResponse>;
2354
+ /**
2355
+ * List the caller's adventures, newest-first. `GET /api/v1/adventures` →
2356
+ * {@link ListAdventuresResponse}. Owner-scoped server-side (soft-deleted
2357
+ * sessions excluded); pass `storyId` to narrow to a single story. Additive —
2358
+ * never remove/rename.
2359
+ */
2360
+ listAdventures(storyId?: string, options?: {
2361
+ signal?: AbortSignal;
2362
+ }): Promise<ListAdventuresResponse>;
2363
+ /**
2364
+ * Soft-delete an adventure session. `DELETE /api/v1/adventures/{sessionId}`
2365
+ * → 204 (resolves to `void`). A missing/unowned session is a 404 surfaced as
2366
+ * a thrown `Error`.
2367
+ */
2368
+ deleteAdventure(sessionId: string, options?: {
2369
+ signal?: AbortSignal;
2370
+ }): Promise<void>;
2371
+ /**
2372
+ * Mutate an adventure's party (M10 Story Engine Phase 9a).
2373
+ * `PATCH /api/v1/adventures/{sessionId}/party` with
2374
+ * `{ action, personaId }` → the updated {@link GetAdventureResponse}.
2375
+ * Shared by {@link addPartyMember} / {@link removePartyMember}; not exported
2376
+ * directly so call sites go through the action-specific wrappers. Additive —
2377
+ * never remove/rename.
2378
+ */
2379
+ private patchParty;
2380
+ /**
2381
+ * Add a character persona to an adventure's party (M10 Story Engine Phase
2382
+ * 9a). `PATCH /api/v1/adventures/{sessionId}/party` with `action='add'` →
2383
+ * the updated {@link GetAdventureResponse}. The persona must be owned by the
2384
+ * caller, bound to a character entity, and NOT a Dungeon Master (422
2385
+ * otherwise); a missing/unowned adventure is a 404 — all surface as a thrown
2386
+ * `Error` carrying the FastAPI detail. Server-side dedupe makes a repeat add
2387
+ * a no-op. Additive — never remove/rename.
2388
+ */
2389
+ addPartyMember(sessionId: string, personaId: string, options?: {
2390
+ signal?: AbortSignal;
2391
+ }): Promise<GetAdventureResponse>;
2392
+ /**
2393
+ * Remove a character persona from an adventure's party (M10 Story Engine
2394
+ * Phase 9a). `PATCH /api/v1/adventures/{sessionId}/party` with
2395
+ * `action='remove'` → the updated {@link GetAdventureResponse}. Idempotent:
2396
+ * removing an absent member is a 200 no-op that returns the current state. A
2397
+ * missing/unowned adventure is a 404 surfaced as a thrown `Error`. Additive —
2398
+ * never remove/rename.
2399
+ */
2400
+ removePartyMember(sessionId: string, personaId: string, options?: {
2401
+ signal?: AbortSignal;
2402
+ }): Promise<GetAdventureResponse>;
1107
2403
  }
1108
2404
  //# sourceMappingURL=api.d.ts.map