@escapeaihq/client-core 0.12.0 → 0.49.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 (242) hide show
  1. package/README.md +32 -7
  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 +323 -0
  31. package/dist/admin.d.ts.map +1 -0
  32. package/dist/admin.js +198 -0
  33. package/dist/admin.js.map +1 -0
  34. package/dist/api.d.ts +1512 -4
  35. package/dist/api.d.ts.map +1 -1
  36. package/dist/api.js +820 -52
  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 +77 -0
  47. package/dist/conversation/binding.d.ts.map +1 -0
  48. package/dist/conversation/binding.js +57 -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 +350 -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 +201 -13
  103. package/dist/graphSchema.d.ts.map +1 -1
  104. package/dist/graphSchema.js +258 -9
  105. package/dist/graphSchema.js.map +1 -1
  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 +6 -0
  111. package/dist/index.d.ts.map +1 -1
  112. package/dist/index.js +9 -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/chunkDistribution.d.ts +43 -0
  119. package/dist/reactor/chunkDistribution.d.ts.map +1 -0
  120. package/dist/reactor/chunkDistribution.js +85 -0
  121. package/dist/reactor/chunkDistribution.js.map +1 -0
  122. package/dist/reactor/index.d.ts +2 -0
  123. package/dist/reactor/index.d.ts.map +1 -1
  124. package/dist/reactor/index.js +5 -0
  125. package/dist/reactor/index.js.map +1 -1
  126. package/dist/reactor/longLiveCommandDispatcher.d.ts +103 -0
  127. package/dist/reactor/longLiveCommandDispatcher.d.ts.map +1 -0
  128. package/dist/reactor/longLiveCommandDispatcher.js +87 -0
  129. package/dist/reactor/longLiveCommandDispatcher.js.map +1 -0
  130. package/dist/reactor/scenesFromEnrichment.d.ts.map +1 -1
  131. package/dist/reactor/scenesFromEnrichment.js +2 -66
  132. package/dist/reactor/scenesFromEnrichment.js.map +1 -1
  133. package/dist/reactor/seedImageOrchestrator.d.ts +6 -9
  134. package/dist/reactor/seedImageOrchestrator.d.ts.map +1 -1
  135. package/dist/reactor/seedImageOrchestrator.js +12 -13
  136. package/dist/reactor/seedImageOrchestrator.js.map +1 -1
  137. package/dist/reactor/storyTimeline.d.ts +44 -0
  138. package/dist/reactor/storyTimeline.d.ts.map +1 -0
  139. package/dist/reactor/storyTimeline.js +95 -0
  140. package/dist/reactor/storyTimeline.js.map +1 -0
  141. package/dist/storyGraph.d.ts +70 -0
  142. package/dist/storyGraph.d.ts.map +1 -0
  143. package/dist/storyGraph.js +178 -0
  144. package/dist/storyGraph.js.map +1 -0
  145. package/dist/vision/VisionSourceController.d.ts +127 -0
  146. package/dist/vision/VisionSourceController.d.ts.map +1 -0
  147. package/dist/vision/VisionSourceController.js +284 -0
  148. package/dist/vision/VisionSourceController.js.map +1 -0
  149. package/dist/vision/index.d.ts +4 -0
  150. package/dist/vision/index.d.ts.map +1 -1
  151. package/dist/vision/index.js +2 -0
  152. package/dist/vision/index.js.map +1 -1
  153. package/dist/vision/sourceKinds.d.ts +65 -0
  154. package/dist/vision/sourceKinds.d.ts.map +1 -0
  155. package/dist/vision/sourceKinds.js +26 -0
  156. package/dist/vision/sourceKinds.js.map +1 -0
  157. package/dist/websocket.d.ts +92 -0
  158. package/dist/websocket.d.ts.map +1 -1
  159. package/dist/websocket.js.map +1 -1
  160. package/package.json +1 -1
  161. package/src/__tests__/adapters-capabilities.test.ts +46 -0
  162. package/src/__tests__/adapters-chat.test.ts +172 -0
  163. package/src/__tests__/adapters-director.test.ts +95 -0
  164. package/src/__tests__/adapters-image.test.ts +133 -0
  165. package/src/__tests__/adapters-platform.test.ts +95 -0
  166. package/src/__tests__/adapters-registry.test.ts +189 -0
  167. package/src/__tests__/adapters-world.test.ts +296 -0
  168. package/src/__tests__/admin.test.ts +312 -0
  169. package/src/__tests__/adventures-party.test.ts +219 -0
  170. package/src/__tests__/adventures.test.ts +282 -0
  171. package/src/__tests__/api-pollers.test.ts +4 -0
  172. package/src/__tests__/api.clip-lookup.test.ts +64 -0
  173. package/src/__tests__/api.list-images-filters.test.ts +103 -0
  174. package/src/__tests__/api.test.ts +553 -0
  175. package/src/__tests__/audio.test.ts +65 -0
  176. package/src/__tests__/cast.test.ts +95 -0
  177. package/src/__tests__/castProjection.test.ts +167 -0
  178. package/src/__tests__/conversation/binding.test.ts +62 -0
  179. package/src/__tests__/conversation/controller.test.ts +732 -0
  180. package/src/__tests__/conversation/effectiveModel.test.ts +169 -0
  181. package/src/__tests__/conversation/headlessRenderer.ts +46 -0
  182. package/src/__tests__/conversation/presenceBus.test.ts +236 -0
  183. package/src/__tests__/conversation/presenceRegistry.test.ts +73 -0
  184. package/src/__tests__/conversation/roster.test.ts +100 -0
  185. package/src/__tests__/conversation/rosterProjection.test.ts +142 -0
  186. package/src/__tests__/conversation/router.test.ts +81 -0
  187. package/src/__tests__/conversation/runtime.test.ts +206 -0
  188. package/src/__tests__/conversation/voice.test.ts +440 -0
  189. package/src/__tests__/documents.test.ts +360 -0
  190. package/src/__tests__/graphSchema.test.ts +218 -9
  191. package/src/__tests__/longLiveCommandDispatcher.test.ts +185 -0
  192. package/src/__tests__/monitoring.test.ts +162 -0
  193. package/src/__tests__/persona-generation.test.ts +352 -0
  194. package/src/__tests__/platformAssistant.test.ts +484 -0
  195. package/src/__tests__/reactor/storyTimeline.test.ts +186 -0
  196. package/src/__tests__/regeneration.test.ts +486 -0
  197. package/src/__tests__/stories.test.ts +171 -0
  198. package/src/__tests__/storyGraph.test.ts +134 -0
  199. package/src/__tests__/tools-wrappers.test.ts +272 -0
  200. package/src/__tests__/videoGraph.test.ts +94 -0
  201. package/src/__tests__/websocket.test.ts +263 -0
  202. package/src/adapters/capabilities.ts +24 -0
  203. package/src/adapters/chatAdapter.ts +114 -0
  204. package/src/adapters/directorAdapter.ts +126 -0
  205. package/src/adapters/imageAdapter.ts +100 -0
  206. package/src/adapters/index.ts +67 -0
  207. package/src/adapters/registry.ts +159 -0
  208. package/src/adapters/worldAdapter.ts +272 -0
  209. package/src/admin.ts +517 -0
  210. package/src/api.ts +2215 -95
  211. package/src/audio.ts +35 -0
  212. package/src/castProjection.ts +95 -0
  213. package/src/conversation/binding.ts +100 -0
  214. package/src/conversation/controller.ts +447 -0
  215. package/src/conversation/effectiveModel.ts +111 -0
  216. package/src/conversation/index.ts +27 -0
  217. package/src/conversation/participant.ts +71 -0
  218. package/src/conversation/presence.ts +60 -0
  219. package/src/conversation/presenceBus.ts +109 -0
  220. package/src/conversation/presenceRegistry.ts +83 -0
  221. package/src/conversation/roster.ts +111 -0
  222. package/src/conversation/rosterProjection.ts +98 -0
  223. package/src/conversation/router.ts +96 -0
  224. package/src/conversation/runtime.ts +188 -0
  225. package/src/conversation/types.ts +100 -0
  226. package/src/conversation/voice.ts +402 -0
  227. package/src/graphSchema.ts +396 -13
  228. package/src/http.ts +72 -0
  229. package/src/index.ts +9 -0
  230. package/src/platformAssistant.ts +347 -0
  231. package/src/reactor/chunkDistribution.ts +98 -0
  232. package/src/reactor/index.ts +5 -0
  233. package/src/reactor/longLiveCommandDispatcher.ts +156 -0
  234. package/src/reactor/scenesFromEnrichment.ts +11 -76
  235. package/src/reactor/seedImageOrchestrator.ts +12 -13
  236. package/src/reactor/storyTimeline.ts +127 -0
  237. package/src/storyGraph.ts +298 -0
  238. package/src/vision/VisionSourceController.ts +354 -0
  239. package/src/vision/__tests__/VisionSourceController.test.ts +719 -0
  240. package/src/vision/index.ts +13 -0
  241. package/src/vision/sourceKinds.ts +75 -0
  242. package/src/websocket.ts +99 -3
package/dist/api.d.ts CHANGED
@@ -115,6 +115,271 @@ 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
+ }
366
+ /**
367
+ * 201 response from marking two entities distinct (R5d homonym override) —
368
+ * mirrors the backend `MarkEntitiesDistinctResponse`.
369
+ */
370
+ export interface MarkEntitiesDistinctResponse {
371
+ traceId: string;
372
+ docentId: string;
373
+ entityId: string;
374
+ }
375
+ /**
376
+ * Response from clearing a distinctness override (re-arms the de-dup oracle) —
377
+ * mirrors the backend `ClearEntitiesDistinctResponse`.
378
+ */
379
+ export interface ClearEntitiesDistinctResponse {
380
+ traceId: string;
381
+ cleared: boolean;
382
+ }
118
383
  export interface ChatMessage {
119
384
  role: 'user' | 'assistant';
120
385
  content: string;
@@ -126,6 +391,232 @@ export interface ChatStreamRequest {
126
391
  systemPrompt?: string;
127
392
  modelId?: string;
128
393
  }
394
+ /**
395
+ * Route the Platform Assistant (R4) is summoned on, so the server-side
396
+ * assistant can scope its `propose_form_fields` suggestions to the
397
+ * current surface + form. Mirrors `api/assistant/schemas.py:RouteContext`.
398
+ */
399
+ export interface AssistantRouteContext {
400
+ /** The UI surface, e.g. `'studio/cast'` or `'settings/defaults'`. */
401
+ surface: string;
402
+ /** The form the user is editing, e.g. `'persona'` (optional). */
403
+ formId?: string;
404
+ /** The entity/story the form is bound to, if any (optional). */
405
+ entityId?: string;
406
+ }
407
+ /**
408
+ * Request body for `POST /api/v1/assistant/stream` — the R4 Platform
409
+ * Assistant SSE copilot. Mirrors {@link ChatStreamRequest} but:
410
+ * - DROPS `videoId` — the assistant is out-of-world (not video-scoped);
411
+ * it answers tooling questions + proposes form-field values.
412
+ * - ADDS `routeContext` so the assistant knows which surface/form the
413
+ * user is on.
414
+ *
415
+ * There is intentionally NO `systemPrompt` override (unlike chat): the
416
+ * assistant has no prompt-injection escape hatch (see the R4a spec
417
+ * "Prompt-injection surface" risk). Model resolution flows server-side
418
+ * through the SAME `resolve_model_id` → `shared/model_router.py` seam the
419
+ * chat endpoint uses — `modelId` is an optional explicit pin only.
420
+ *
421
+ * `documentContext` (R11.2) is a SEPARATE, larger-capped field for an
422
+ * "operate on this document" draft (e.g. a long prompt the user wants
423
+ * refined). It is DISTINCT from the deliberately-small `prompt`
424
+ * user-message field: the server places it in MODEL CONTEXT (the system
425
+ * prompt), never the user turn, so the small `prompt` cap keeps its
426
+ * prompt-injection floor while a full-length draft still round-trips.
427
+ */
428
+ export interface AssistantStreamRequest {
429
+ prompt: string;
430
+ messages?: ChatMessage[];
431
+ modelId?: string;
432
+ routeContext?: AssistantRouteContext;
433
+ /**
434
+ * Optional large document/draft for the assistant to operate ON (R11.2).
435
+ * Placed in model context server-side, NOT the user turn. Capped at the
436
+ * admin prompt editor's max so a full-length "Improve with assistant"
437
+ * draft round-trips (the small 2 KB `prompt` cap stays for injection
438
+ * mitigation).
439
+ */
440
+ documentContext?: string;
441
+ }
442
+ /**
443
+ * Discriminated union of the SSE events the chat / assistant stream
444
+ * endpoints emit (decoded from each `data: {…}` line). Mirrors the
445
+ * transport-agnostic `ChatEventType` values in
446
+ * `shared/chat_dispatcher.py` that survive onto the SSE wire.
447
+ *
448
+ * The R4 Platform Assistant ADDS the `'suggestion'` variant ALONGSIDE the
449
+ * existing token / tool_use / tool_result / citation / error / done variants —
450
+ * it never replaces one. The assistant's `propose_form_fields` tool result is
451
+ * converted by the dispatcher into a `suggestion` event the host UI maps
452
+ * onto its own form fields (it mutates nothing server-side). Consumers
453
+ * `switch` on `type` to narrow.
454
+ */
455
+ export type AssistantStreamEvent = {
456
+ type: 'token';
457
+ timestamp?: number;
458
+ content: string;
459
+ } | {
460
+ type: 'tool_use';
461
+ timestamp?: number;
462
+ tool: string;
463
+ toolUseId: string;
464
+ } | {
465
+ /**
466
+ * The structured `tool_result` frame the dispatcher emits after EVERY
467
+ * assistant tool call (parity with the chat executor path): for
468
+ * `propose_form_fields` it follows the `suggestion` event; for the
469
+ * reference tools (`describe_tool` / `list_platform_capabilities`) it is
470
+ * the only structured result. Wire contract shared with `api/assistant`
471
+ * (the Python dispatcher emits this exact `{tool, toolUseId, result}`
472
+ * shape) — included here so an exhaustive `switch` handles it.
473
+ */
474
+ type: 'tool_result';
475
+ timestamp?: number;
476
+ tool: string;
477
+ toolUseId: string;
478
+ result: Record<string, unknown>;
479
+ } | {
480
+ type: 'citation';
481
+ timestamp?: number;
482
+ citation: Citation;
483
+ span?: string;
484
+ } | {
485
+ type: 'error';
486
+ timestamp?: number;
487
+ message: string;
488
+ } | {
489
+ type: 'done';
490
+ timestamp?: number;
491
+ reason?: string;
492
+ } | {
493
+ /**
494
+ * A `propose_form_fields` tool call surfaced as a structured
495
+ * suggestion the host page reviews + applies. Carries the target
496
+ * form id, the proposed `{fieldName: value}` map, and an optional
497
+ * rationale. Wire contract shared with `api/assistant` (the Python
498
+ * dispatcher emits this exact shape).
499
+ */
500
+ type: 'suggestion';
501
+ timestamp?: number;
502
+ targetForm: string;
503
+ fields: Record<string, string>;
504
+ rationale?: string;
505
+ };
506
+ /**
507
+ * Dashboard Spec A (§10A.5) — the kind of scene-control directive the DM may
508
+ * issue back to the viewer's experience surface. The allowlist is single-sourced
509
+ * with the backend `DM_DIRECTIVE_KINDS` set in `shared/chat_dispatcher.py` and
510
+ * the line-anchored `DM_SCENE_TAG_PATTERN` parser:
511
+ * - `enter_world` params: `{ prompt?: string; timestamp?: number }`
512
+ * - `exit_world` params: `{}`
513
+ * - `seek_video` params: `{ t?: number; timestamp?: number }`
514
+ * - `set_experience_source` params: `{ source: string }`
515
+ */
516
+ export type DmDirectiveKind = 'enter_world' | 'exit_world' | 'seek_video' | 'set_experience_source';
517
+ /**
518
+ * Dashboard Spec A (§10A.5) — a DM-issued scene-control directive, surfaced on
519
+ * the chat WebSocket / SSE stream as `{type:"dm_directive", directive, params}`.
520
+ * The backend `ChatDispatcher.emit_dm_directive` emits this AFTER stripping the
521
+ * inline `[SCENE:...]` tag from the streamed narration (the directive fires as
522
+ * the DM finishes speaking). `params` is an open bag keyed by the directive kind
523
+ * (see {@link DmDirectiveKind}); consumers narrow on `directive` then read the
524
+ * params they expect. ADDITIVE — no existing consumer is wired (A-DM0 ships
525
+ * dark); the full `useExperienceSource` wire lands in a later DV phase.
526
+ */
527
+ export type DmDirectiveEvent = {
528
+ type: 'dm_directive';
529
+ timestamp?: number;
530
+ directive: DmDirectiveKind;
531
+ params: Record<string, unknown>;
532
+ };
533
+ /**
534
+ * One field of a creator/admin form, as returned by the R4b form-schema
535
+ * reference endpoint (`GET /api/v1/schema/{form}`). The backend DERIVES each
536
+ * field from the form's PUBLIC Pydantic request model via `model_json_schema()`
537
+ * (single source of truth — it can never drift from the real endpoint contract).
538
+ * The assistant consults this so `propose_form_fields` only proposes VALID
539
+ * field names. Mirrors `api/assistant/schemas.py:FormField`.
540
+ */
541
+ export interface FormSchemaField {
542
+ /** The wire field name (e.g. `name`, `systemPrompt`, `voiceId`). */
543
+ name: string;
544
+ /** JSON-schema type token (`string` / `integer` / `boolean` / `object` / …). */
545
+ type: string;
546
+ /** Whether the source model marks this field required. */
547
+ required: boolean;
548
+ /**
549
+ * Human-readable field description (from the Pydantic `Field(description=…)`).
550
+ * `null` when the source field declares no description (backend `str | None`).
551
+ */
552
+ description: string | null;
553
+ /**
554
+ * Optional JSON-schema constraints carried through from the source model
555
+ * (e.g. `{ maxLength, minLength, enum }`). Absent when the field has none.
556
+ */
557
+ constraints?: Record<string, unknown>;
558
+ /** Optional example values for the field, when the source model supplies them. */
559
+ examples?: unknown[];
560
+ }
561
+ /**
562
+ * Response of `GET /api/v1/schema/{form}` (R4b) — the queryable, drift-proof
563
+ * description of a named creator/admin form's fields. `form` is the requested
564
+ * form id (`personas` / `documents` / `adventures` / `images` / `scenes` — an
565
+ * explicit allow-list; `scenes` returns the editable Scene fields {title,
566
+ * summary} since R11.3 added the public `UpdateSceneRequest` model; NEVER an
567
+ * extraction-prompt form, per the graph-corruption carve-out, tech-debt #336).
568
+ * Mirrors `api/assistant/schemas.py:FormSchemaResponse`.
569
+ */
570
+ export interface FormSchemaResponse {
571
+ /** The form id this schema describes. */
572
+ form: string;
573
+ /** The form's fields, derived from its public Pydantic request model. */
574
+ fields: FormSchemaField[];
575
+ /** Trace id for log correlation. */
576
+ traceId: string;
577
+ }
578
+ /**
579
+ * One tool's human-readable reference, as returned by the R4b tool-reference
580
+ * endpoints. DERIVED from the full `shared/tool_schemas` registry
581
+ * (`iter_all_tool_schemas` — chat + adventure + assistant; the same source the
582
+ * executor resolves from — the catalogue and the runtime tool surface cannot
583
+ * diverge). `params` is the per-parameter descriptor map keyed by parameter
584
+ * name. Mirrors `api/assistant/schemas.py:ToolReference`.
585
+ */
586
+ export interface ToolReference {
587
+ /** The tool name (e.g. `propose_form_fields`, `semantic_search`). */
588
+ name: string;
589
+ /** Human-readable description of what the tool does. */
590
+ description: string;
591
+ /** Per-parameter descriptors keyed by parameter name. */
592
+ params: Record<string, unknown>;
593
+ }
594
+ /**
595
+ * Response of `GET /api/v1/tools/reference` (R4b) — every executor-resolvable
596
+ * tool, derived from the full `shared/tool_schemas` registry
597
+ * (`iter_all_tool_schemas` — chat + adventure + assistant) so the catalogue
598
+ * cannot drift from the live tool list. Mirrors
599
+ * `api/assistant/schemas.py:ToolReferenceListResponse`.
600
+ */
601
+ export interface ToolReferenceListResponse {
602
+ /** Every platform tool's reference. */
603
+ tools: ToolReference[];
604
+ /** Trace id for log correlation. */
605
+ traceId: string;
606
+ }
607
+ /**
608
+ * Response of `GET /api/v1/tools/reference/{name}` (R4b) — one tool's reference
609
+ * NESTED under `tool` (matching the backend `ToolReferenceDetailResponse`, which
610
+ * keeps `traceId` at the top level alongside the `tool` object, mirroring the
611
+ * `{ tools, traceId }` list shape). 404 when the tool is unknown. Mirrors
612
+ * `api/assistant/schemas.py:ToolReferenceDetailResponse`.
613
+ */
614
+ export interface ToolReferenceResponse {
615
+ /** The requested tool's reference. */
616
+ tool: ToolReference;
617
+ /** Trace id for log correlation. */
618
+ traceId: string;
619
+ }
129
620
  /**
130
621
  * Capability flags advertised by a chat model. Mirrors
131
622
  * ``shared/model_config.py:CAPABILITY_*`` so frontends can decide which
@@ -152,6 +643,26 @@ export interface ChatModelsResponse {
152
643
  models: ChatModelInfo[];
153
644
  defaultModelId?: string | null;
154
645
  }
646
+ /**
647
+ * Single entry returned by `GET /api/v1/images/models` (R1c).
648
+ *
649
+ * Mirrors `ChatModelInfo` for the read-only image-model catalogue. `capabilities`
650
+ * is the raw wire type (`string[]`) — NOT the adapter `Capability[]` union — so
651
+ * api.ts has no import cycle with `adapters/capabilities.ts`. The image adapter
652
+ * (`adapters/imageAdapter.ts`) casts it to `Capability[]` when building a
653
+ * descriptor.
654
+ */
655
+ export interface ImageModelInfo {
656
+ id: string;
657
+ displayName: string;
658
+ provider: string;
659
+ capabilities: string[];
660
+ isDefault: boolean;
661
+ isFallback: boolean;
662
+ }
663
+ export interface ImageModelsResponse {
664
+ models: ImageModelInfo[];
665
+ }
155
666
  /**
156
667
  * Default system prompt components returned by `GET /api/v1/chat/system-prompt`.
157
668
  *
@@ -166,6 +677,18 @@ export interface SystemPromptComponents {
166
677
  audio_markup: string;
167
678
  full_default: string;
168
679
  }
680
+ /**
681
+ * Story Engine Phase 5 — outcome of syncing a persona's character binding
682
+ * to the knowledge graph (the (Persona)-[:PORTRAYS]->(Entity) edge).
683
+ * Mirrors backend ``shared/models.py:GraphSyncStatus``. Derived per-request
684
+ * by the persona router after the graph write; never persisted to DynamoDB.
685
+ *
686
+ * - ``'synced'`` — ``entity_id`` is set and the graph write succeeded.
687
+ * - ``'pending'`` — ``entity_id`` is set but the graph write failed (logged;
688
+ * reconciliation is tracked as tech-debt).
689
+ * - ``'none'`` — ``entity_id`` is null (no binding).
690
+ */
691
+ export type GraphSyncStatus = 'synced' | 'pending' | 'none';
169
692
  export interface PersonaConfig {
170
693
  persona_id: string;
171
694
  user_id: string;
@@ -217,6 +740,48 @@ export interface PersonaConfig {
217
740
  * does not currently enforce this server-side (see specs/technical-debt.md
218
741
  * Issue #161). */
219
742
  vision_fps?: number;
743
+ /** Story Engine Phase 5: bound character Entity ID. When set, the backend
744
+ * auto-manages a (Persona)-[:PORTRAYS]->(Entity) graph edge. Accepted on
745
+ * create/update; snake_case on the wire (matches sibling fields). Always
746
+ * present on persona responses — serialized as ``null`` when no binding.
747
+ * Typed optional only as a defensive superset for older cached payloads. */
748
+ entity_id?: string | null;
749
+ /** Story Engine Phase 5: outcome of the most recent PORTRAYS sync. Derived
750
+ * per-request by the persona router; not persisted to DynamoDB. The backend
751
+ * field is required + defaulted to ``'none'``, so it is ALWAYS present on
752
+ * every persona response (``'none'`` when there is no binding) — never
753
+ * absent. Typed optional only as a defensive superset for older cached
754
+ * payloads; treat a missing value as ``'none'``. */
755
+ graph_sync_status?: GraphSyncStatus;
756
+ /** Story Engine Phase 8a (M9 Adventure Runtime): when true this persona may
757
+ * drive an interactive adventure as the Dungeon Master (it is accepted as the
758
+ * ``dmPersonaId`` for ``POST /api/v1/adventures``). Accepted on create/update;
759
+ * snake_case on the wire (matches sibling fields). The backend field is
760
+ * required + defaults to ``false``, so it is ALWAYS present on persona
761
+ * responses — typed optional only as a defensive superset for older cached
762
+ * payloads; treat a missing value as ``false``. */
763
+ is_dungeon_master?: boolean;
764
+ /** C3a persona-generation provenance — character name from the source video.
765
+ * ``null`` for manually-created personas. snake_case on the wire (matches
766
+ * sibling fields). Mirrors ``shared/persona_models.py:PersonaConfig.entity_name``. */
767
+ entity_name?: string | null;
768
+ /** C3a: ``true`` when this persona was created by the persona-generation
769
+ * pipeline (drives the "Auto" badge on the personas list). The backend field
770
+ * is required + defaults to ``false``, so it is always present on responses;
771
+ * typed optional only as a defensive superset for older cached payloads. */
772
+ is_auto_generated?: boolean;
773
+ /** C3a: the video used as the source for synthesis + voice cloning. ``null``
774
+ * for manually-created personas. */
775
+ source_video_id?: string | null;
776
+ /** C3a reclone bookkeeping — all transcript-segment indices the worker
777
+ * uploaded to S3 as cached WAV clips at generation time. Empty for
778
+ * manually-created personas. Store-managed; surfaced for the audition/reclone
779
+ * UI's retries-left counter. */
780
+ available_clip_indices?: number[];
781
+ /** C3a reclone bookkeeping — the subset of ``available_clip_indices`` already
782
+ * consumed by the current ``voice_id`` (initial clone + each successful
783
+ * reclone appends). Survives page reload. Store-managed. */
784
+ clips_used?: number[];
220
785
  }
221
786
  export type VisemeBundleStatus = 'pending' | 'complete' | 'failed';
222
787
  export type VisemeRegenStatusValue = 'pending' | 'complete' | 'failed';
@@ -361,6 +926,13 @@ export interface RegenerateImageRequest {
361
926
  }
362
927
  export interface RegenerateImageResponse {
363
928
  traceId: string;
929
+ /** Tracked `image_id` of the new `ImageRecord` the regeneration wrote.
930
+ * `null`/absent when the S3 upload succeeded but the metadata write
931
+ * didn't (best-effort tracking) — the caller still has
932
+ * `imageUrl`/`imageS3Key` in that case. When present, the caller can
933
+ * `getImage(imageId)` the new row to auto-select it (closes
934
+ * tech-debt #110). */
935
+ imageId?: string | null;
364
936
  /** Presigned S3 URL for immediate display only. The URL has a short
365
937
  * TTL (typically 1h) and will 403 once expired — persist `imageS3Key`
366
938
  * if you need a stable handle and re-presign on read. */
@@ -446,6 +1018,24 @@ export interface CreatePersonaRequest {
446
1018
  vision_enabled?: boolean;
447
1019
  /** Phase 2: requested vision frame cadence in fps (0.5–3.0). */
448
1020
  vision_fps?: number;
1021
+ /** Story Engine Phase 5: bind this persona to a character Entity. The
1022
+ * backend creates a (Persona)-[:PORTRAYS]->(Entity) edge and returns
1023
+ * ``graph_sync_status`` on the response. */
1024
+ entity_id?: string | null;
1025
+ /** Story Engine Phase 8a (M9): mark this persona as a Dungeon Master so it
1026
+ * can drive interactive adventures. Optional; defaults to ``false``
1027
+ * server-side. snake_case on the wire (matches sibling fields). */
1028
+ is_dungeon_master?: boolean;
1029
+ /** C3a persona-generation provenance (set by the worker, but accepted on
1030
+ * create so a caller can stamp it). Character name from the source video. */
1031
+ entity_name?: string | null;
1032
+ /** C3a: flag a pipeline-created persona. Defaults to ``false`` server-side. */
1033
+ is_auto_generated?: boolean;
1034
+ /** C3a: the source video used for synthesis + voice cloning. */
1035
+ source_video_id?: string | null;
1036
+ /** C3a reclone bookkeeping: the full pool of cached-clip indices uploaded to
1037
+ * S3 at generation time. ``clips_used`` is store-managed, not client-settable. */
1038
+ available_clip_indices?: number[];
449
1039
  }
450
1040
  export interface UpdatePersonaRequest {
451
1041
  name?: string | null;
@@ -477,12 +1067,258 @@ export interface UpdatePersonaRequest {
477
1067
  vision_enabled?: boolean | null;
478
1068
  /** Phase 2: vision frame cadence in fps (0.5–3.0). */
479
1069
  vision_fps?: number | null;
1070
+ /** Story Engine Phase 5: change the persona↔character binding. Set to a
1071
+ * character Entity ID to (re)bind, or ``null`` to clear it. The backend
1072
+ * reconciles the (Persona)-[:PORTRAYS]->(Entity) edge and returns
1073
+ * ``graph_sync_status`` on the response. */
1074
+ entity_id?: string | null;
1075
+ /** Story Engine Phase 8a (M9): toggle Dungeon-Master capability. Optional;
1076
+ * ``null``/``undefined`` skips the field (no change). snake_case on the wire
1077
+ * (matches sibling fields). */
1078
+ is_dungeon_master?: boolean | null;
1079
+ /** C3a persona-generation provenance. ``null``/``undefined`` skips the field. */
1080
+ entity_name?: string | null;
1081
+ /** C3a: flag a pipeline-created persona. ``null``/``undefined`` skips. */
1082
+ is_auto_generated?: boolean | null;
1083
+ /** C3a: the source video used for synthesis + voice cloning. */
1084
+ source_video_id?: string | null;
1085
+ /** C3a reclone bookkeeping: the full pool of cached-clip indices. */
1086
+ available_clip_indices?: number[] | null;
480
1087
  }
481
1088
  export interface PersonaListResponse {
482
1089
  personas: PersonaConfig[];
483
1090
  total: number;
484
1091
  next_token?: string | null;
485
1092
  }
1093
+ /** Lifecycle of an async persona-generation job. Mirrors
1094
+ * ``shared/persona_models.py:PersonaJobStatus``. Non-terminal:
1095
+ * ``pending``/``synthesizing``/``cloning``; terminal:
1096
+ * ``complete``/``failed``/``partial``. */
1097
+ export type PersonaJobStatus = 'pending' | 'synthesizing' | 'cloning' | 'complete' | 'failed' | 'partial';
1098
+ /** The stage a per-persona failure occurred at. Mirrors
1099
+ * ``shared/persona_models.py:JobErrorStage``. */
1100
+ export type PersonaJobErrorStage = 'synthesis' | 'extraction' | 'cloning' | 'creation' | 'no_data' | 'cloning_skipped';
1101
+ /** Per-user defaults driving the persona-generation pipeline. The voice
1102
+ * defaults are a *fallback* used only when cloning is skipped or fails. Mirrors
1103
+ * ``shared/persona_models.py:PersonaGenerationSettings`` (snake_case wire). */
1104
+ export interface PersonaGenerationSettings {
1105
+ user_id: string;
1106
+ default_voice_id: string;
1107
+ default_tts_model_id: string;
1108
+ default_temperature: number;
1109
+ default_speaking_rate: number;
1110
+ default_audio_format: AudioFormat;
1111
+ default_enable_markups: boolean;
1112
+ default_chat_model_id: string;
1113
+ /** Supports ``{entity_name}`` and ``{video_title}`` placeholders. */
1114
+ default_system_prompt_template?: string | null;
1115
+ default_system_prompt_override: boolean;
1116
+ entity_type_filter: string[];
1117
+ min_dialog_lines: number;
1118
+ min_graph_speakers: number;
1119
+ max_personas: number;
1120
+ auto_generate_enabled: boolean;
1121
+ voice_clone_max_retries: number;
1122
+ voice_clone_min_clip_seconds: number;
1123
+ /** Store-managed; set on every upsert. Do not construct directly. */
1124
+ updated_at: string;
1125
+ }
1126
+ /** Partial body for ``PUT /api/v1/personas/settings/generation`` — every field
1127
+ * optional; an upsert merges supplied (non-null) fields over the stored (or
1128
+ * default) settings. ``user_id``/``updated_at`` are store-managed and rejected
1129
+ * from the client. Mirrors
1130
+ * ``shared/persona_models.py:UpdatePersonaGenSettingsRequest``. */
1131
+ export interface UpdatePersonaGenSettingsRequest {
1132
+ default_voice_id?: string | null;
1133
+ default_tts_model_id?: string | null;
1134
+ default_temperature?: number | null;
1135
+ default_speaking_rate?: number | null;
1136
+ default_audio_format?: AudioFormat | null;
1137
+ default_enable_markups?: boolean | null;
1138
+ default_chat_model_id?: string | null;
1139
+ default_system_prompt_template?: string | null;
1140
+ default_system_prompt_override?: boolean | null;
1141
+ entity_type_filter?: string[] | null;
1142
+ min_dialog_lines?: number | null;
1143
+ min_graph_speakers?: number | null;
1144
+ max_personas?: number | null;
1145
+ auto_generate_enabled?: boolean | null;
1146
+ voice_clone_max_retries?: number | null;
1147
+ voice_clone_min_clip_seconds?: number | null;
1148
+ }
1149
+ /** Live counters surfaced by the job-poll endpoint. Mirrors
1150
+ * ``shared/persona_models.py:JobProgress``. */
1151
+ export interface PersonaJobProgress {
1152
+ total_characters: number;
1153
+ synthesized: number;
1154
+ cloned: number;
1155
+ failed: number;
1156
+ }
1157
+ /** One per-persona failure recorded on the job without aborting the run.
1158
+ * Mirrors ``shared/persona_models.py:JobError``. */
1159
+ export interface PersonaJobError {
1160
+ persona_name?: string | null;
1161
+ stage: PersonaJobErrorStage;
1162
+ error: string;
1163
+ }
1164
+ /** Async persona-generation job record, as returned by
1165
+ * ``GET /api/v1/persona-jobs/{jobId}``. snake_case on the wire (the backend
1166
+ * model has no aliases). Mirrors
1167
+ * ``shared/persona_models.py:AutoGenerationJob``. */
1168
+ export interface AutoGenerationJob {
1169
+ job_id: string;
1170
+ user_id: string;
1171
+ video_id: string;
1172
+ status: PersonaJobStatus;
1173
+ created_at: string;
1174
+ updated_at: string;
1175
+ progress: PersonaJobProgress;
1176
+ persona_ids: string[];
1177
+ errors: PersonaJobError[];
1178
+ /** Used clip indices per persona id, so reclone can pick a different set. */
1179
+ clips_used: Record<string, number[]>;
1180
+ }
1181
+ /** 202 envelope from ``POST /api/v1/videos/{videoId}/personas/generate``.
1182
+ * **camelCase wire keys** (``jobId``/``traceId``) — the backend serializes this
1183
+ * model with aliases (unlike the snake_case ``AutoGenerationJob``). Mirrors
1184
+ * ``shared/persona_models.py:GeneratePersonasJobResponse``. */
1185
+ export interface GeneratePersonasJobResponse {
1186
+ jobId: string;
1187
+ status: PersonaJobStatus;
1188
+ /** Per-request correlation id (resource-creating-POST convention). */
1189
+ traceId?: string | null;
1190
+ }
1191
+ /** Body for ``POST /api/v1/personas/{personaId}/audition`` (C3a Step 9). All
1192
+ * fields optional — an omitted body renders the backend default sample text in
1193
+ * the persona's current voice. Mirrors ``shared/persona_models.py:AuditionRequest``
1194
+ * (snake_case wire; ``extra="forbid"`` server-side). */
1195
+ export interface AuditionRequest {
1196
+ /** Sample line to synthesize (1–500 chars). Default: the backend sample text. */
1197
+ text?: string;
1198
+ /** Requested format (PCM16 only; the response is always ``audio/wav``). */
1199
+ audio_format?: AudioFormat;
1200
+ }
1201
+ /** 200 body of ``POST /api/v1/personas/{personaId}/reclone`` (C3a Step 9).
1202
+ * **camelCase wire keys** (``personaId``/``voiceId``/``clipsUsed``) — the backend
1203
+ * serializes this model with aliases. Mirrors
1204
+ * ``shared/persona_models.py:ReclonedPersonaResponse``. */
1205
+ export interface ReclonedPersonaResponse {
1206
+ personaId: string;
1207
+ voiceId: string;
1208
+ /** The full set of clip indices the current ``voiceId`` was cloned from after
1209
+ * this reclone (initial clone + every successful reclone). */
1210
+ clipsUsed: number[];
1211
+ }
1212
+ /** Structured reason a reclone was refused with ``409 Conflict``. The backend
1213
+ * returns ``detail`` as an object (``{error, attempts?}``), which the generic
1214
+ * JSON error path can't surface, so {@link ApiClient.reclonePersona} raises a
1215
+ * {@link RecloneConflictError} carrying this code instead. */
1216
+ export type RecloneConflictCode = 'voice_clone_max_retries_exhausted' | 'no_candidate_clips_remaining';
1217
+ /** Thrown by {@link ApiClient.reclonePersona} on a ``409`` so the review UI can
1218
+ * distinguish "retries exhausted" from "no clips left" and disable the Reclone
1219
+ * control (instead of seeing an opaque ``[object Object]`` message). */
1220
+ export declare class RecloneConflictError extends Error {
1221
+ readonly code: RecloneConflictCode;
1222
+ readonly attempts?: number;
1223
+ constructor(code: RecloneConflictCode, attempts?: number);
1224
+ }
1225
+ /**
1226
+ * Story Engine Phase 5 — a single character Entity for a video, as returned
1227
+ * by ``GET /api/v1/tools/videos/{videoId}/characters``. Mirrors the backend
1228
+ * ``api/tools/schemas.py:CharacterItem`` (camelCase wire fields). ``type`` is
1229
+ * always ``'character'`` because the endpoint surfaces only character Entities.
1230
+ */
1231
+ export interface CharacterItem {
1232
+ entityId: string;
1233
+ name: string;
1234
+ type: 'character';
1235
+ aliases: string[];
1236
+ }
1237
+ /**
1238
+ * Story Engine Phase 5 — response of
1239
+ * ``GET /api/v1/tools/videos/{videoId}/characters``. Lists only ``Entity``
1240
+ * nodes with ``type === 'character'`` for the given video. Mirrors the
1241
+ * backend ``api/tools/schemas.py:CharacterListResponse``.
1242
+ */
1243
+ export interface CharacterListResponse {
1244
+ traceId: string;
1245
+ videoId: string;
1246
+ characters: CharacterItem[];
1247
+ }
1248
+ /**
1249
+ * Platform Restructure R5a — one CharacterArc attached to a cast character.
1250
+ * Mirrors the backend ``api/tools/schemas.py:CastArc``.
1251
+ */
1252
+ export interface CastArc {
1253
+ arcId: string;
1254
+ /** Display title — the server falls back to the arc label, then arcId. */
1255
+ title: string;
1256
+ summary: string | null;
1257
+ index: number;
1258
+ }
1259
+ /**
1260
+ * Platform Restructure R5c — one Scene featuring a cast character, with the
1261
+ * display ``title`` riding alongside the id (the studio character drawer
1262
+ * renders titles; pre-R5c they came from a client-side lookup over the full
1263
+ * graph payload). Mirrors the backend ``api/tools/schemas.py:CastScene``.
1264
+ */
1265
+ export interface CastScene {
1266
+ sceneId: string;
1267
+ /** Display title — the server falls back to the sceneId when untitled. */
1268
+ title: string;
1269
+ }
1270
+ /**
1271
+ * Platform Restructure R5a/R5c — a character Entity as projected for the
1272
+ * studio Cast view. Carries everything the character drawer renders
1273
+ * (aliases/scenes/arcs/relatedCharacterIds), so the R5c CastGrid rewire is a
1274
+ * drop-in. Mirrors the backend ``api/tools/schemas.py:CastCharacter``. R5c
1275
+ * (the first consumer, shipped before this type was ever published) reshaped
1276
+ * R5a's ``sceneIds: string[]`` into ``scenes: CastScene[]``.
1277
+ */
1278
+ export interface CastCharacter {
1279
+ entityId: string;
1280
+ name: string;
1281
+ aliases: string[];
1282
+ scenes: CastScene[];
1283
+ arcs: CastArc[];
1284
+ /** RELATES_TO character neighbours, filtered to ids within this cast. */
1285
+ relatedCharacterIds: string[];
1286
+ }
1287
+ /**
1288
+ * Platform Restructure R5a — display fields of the persona bound to a cast
1289
+ * character, hydrated server-side from the persona store (the binding is
1290
+ * resolved via the graph PORTRAYS edge + the authoritative
1291
+ * ``PersonaConfig.entity_id``, NOT by client-side string equality). camelCase
1292
+ * wire fields per the tools-API convention. Mirrors the backend
1293
+ * ``api/tools/schemas.py:CastPersonaSummary``.
1294
+ */
1295
+ export interface CastPersonaSummary {
1296
+ personaId: string;
1297
+ name: string;
1298
+ chatModelId: string;
1299
+ characterImageId: string | null;
1300
+ isDungeonMaster: boolean;
1301
+ }
1302
+ /**
1303
+ * Platform Restructure R5a — one cast row: a character pre-joined to its
1304
+ * bound persona (``null`` when unbound). Mirrors the backend
1305
+ * ``api/tools/schemas.py:CastEntry``.
1306
+ */
1307
+ export interface CastEntry {
1308
+ character: CastCharacter;
1309
+ persona: CastPersonaSummary | null;
1310
+ }
1311
+ /**
1312
+ * Platform Restructure R5a — response of
1313
+ * ``GET /api/v1/tools/videos/{videoId}/cast``: the one-call server-side
1314
+ * replacement for the studio CastGrid's two-call client-side ``entity_id``
1315
+ * join. Mirrors the backend ``api/tools/schemas.py:CastWithPersonaResponse``.
1316
+ */
1317
+ export interface CastWithPersonaResponse {
1318
+ traceId: string;
1319
+ videoId: string;
1320
+ cast: CastEntry[];
1321
+ }
486
1322
  export interface SynthesizedPersona {
487
1323
  name: string;
488
1324
  description: string;
@@ -671,9 +1507,106 @@ export interface VideoGraphResponse {
671
1507
  nodes: GraphNode[];
672
1508
  edges: GraphEdge[];
673
1509
  }
1510
+ /**
1511
+ * Detail level for the video-graph read (Platform Restructure R5b). Mirrors
1512
+ * `shared/graph_schema.py`'s `GraphDetail` — the single source of the
1513
+ * `story`/`raw` mode literals (constants over bare strings; consumers compare
1514
+ * against `GRAPH_DETAIL.*`, never a raw literal).
1515
+ *
1516
+ * - `RAW` (the server default — omitting the `detail` arg keeps the request
1517
+ * byte-identical to the pre-R5b call): the full extraction subgraph.
1518
+ * - `STORY`: the curated story view — Acts, Scenes (each Scene node's
1519
+ * `properties` carries a read-time `shotCount`), the character cast,
1520
+ * document contributions, and narrative edges; Shot/DialogLine/Event nodes
1521
+ * and MENTIONS edges are collapsed server-side.
1522
+ */
1523
+ export declare const GRAPH_DETAIL: {
1524
+ readonly STORY: "story";
1525
+ readonly RAW: "raw";
1526
+ };
1527
+ export type GraphDetail = (typeof GRAPH_DETAIL)[keyof typeof GRAPH_DETAIL];
1528
+ /**
1529
+ * Per-story aggregate counts surfaced on the Creator Studio overview. Derived
1530
+ * server-side from the existing graph + document readers (no new graph
1531
+ * machinery): acts/scenes/characters come from `GET /api/v1/tools/graph`
1532
+ * node labels (characters = `Entity` with `type === 'character'`), documents
1533
+ * from the P4 document store.
1534
+ */
1535
+ export interface StoryCounts {
1536
+ acts: number;
1537
+ scenes: number;
1538
+ characters: number;
1539
+ documents: number;
1540
+ }
1541
+ /**
1542
+ * Summary item returned by `GET /api/v1/stories`. The Story resource is a
1543
+ * thin, read-only view over the existing Video — `storyId === videoId` (1:1)
1544
+ * in M7 P7. Both fields are present and equal so consumers can read whichever
1545
+ * they prefer; a future real-ULID Story milestone can diverge them without a
1546
+ * breaking shape change.
1547
+ */
1548
+ export interface StorySummary {
1549
+ storyId: string;
1550
+ videoId: string;
1551
+ title: string;
1552
+ updatedAt: string;
1553
+ /** Always `null` in P7 (no poster source); reserved for future population. */
1554
+ posterUrl?: string | null;
1555
+ }
1556
+ /** Detail returned by `GET /api/v1/stories/{storyId}` — summary fields + counts. */
1557
+ export interface StoryDetail {
1558
+ storyId: string;
1559
+ videoId: string;
1560
+ title: string;
1561
+ updatedAt: string;
1562
+ posterUrl?: string | null;
1563
+ counts: StoryCounts;
1564
+ }
1565
+ export interface ListStoriesResponse {
1566
+ traceId: string;
1567
+ stories: StorySummary[];
1568
+ }
1569
+ export interface GetStoryResponse {
1570
+ traceId: string;
1571
+ story: StoryDetail;
1572
+ }
1573
+ /**
1574
+ * Request params for {@link ApiClient.clipLookup}. Mirrors the backend
1575
+ * `ClipLookupRequest` (`shared/tool_request_models.py`). `BaseSchema` has NO
1576
+ * alias generator and the model declares `videoId` literally (camelCase,
1577
+ * `# noqa: N815`), so the wire keys are camelCase verbatim — the client does
1578
+ * not remap.
1579
+ */
1580
+ export interface ClipLookupParams {
1581
+ videoId: string;
1582
+ /** Clip start time in seconds (>= 0). */
1583
+ t0: number;
1584
+ /** Clip end time in seconds (> 0). */
1585
+ t1: number;
1586
+ }
1587
+ /**
1588
+ * Response from `POST /api/v1/tools/clip-lookup`. Mirrors the backend
1589
+ * `ClipLookupResponse` (`api/tools/schemas.py`) — camelCase keys verbatim.
1590
+ * `url` is a presigned (or local-stub) playable URL for the [t0,t1] span;
1591
+ * `citation` carries the time-coded span.
1592
+ */
1593
+ export interface ClipLookupResponse {
1594
+ traceId: string;
1595
+ url: string;
1596
+ expiresIn: number;
1597
+ citation: {
1598
+ videoId: string;
1599
+ t0: number;
1600
+ t1: number;
1601
+ shotId?: string | null;
1602
+ };
1603
+ source: {
1604
+ system: string;
1605
+ details?: Record<string, unknown> | null;
1606
+ };
1607
+ }
674
1608
  export interface UpdateNodeRequest {
675
1609
  nodeLabel: string;
676
- idProperty: string;
677
1610
  idValue: string;
678
1611
  properties: Record<string, unknown>;
679
1612
  }
@@ -683,7 +1616,6 @@ export interface UpdateNodeResponse {
683
1616
  }
684
1617
  export interface DeleteNodeRequest {
685
1618
  nodeLabel: string;
686
- idProperty: string;
687
1619
  idValue: string;
688
1620
  }
689
1621
  export interface DeleteNodeResponse {
@@ -709,6 +1641,79 @@ export interface DeleteRelationshipResponse {
709
1641
  traceId: string;
710
1642
  deleted: number;
711
1643
  }
1644
+ /**
1645
+ * Per-label schema entry returned by `GET /api/v1/tools/graph/schema`.
1646
+ * `pk` is the primary-key property name; `editable` is the user-editable
1647
+ * property whitelist. Both are derived server-side from the canonical
1648
+ * `shared/graph_schema.py` single source of truth.
1649
+ */
1650
+ export interface GraphLabelSchema {
1651
+ pk: string;
1652
+ editable: string[];
1653
+ }
1654
+ /** Per-relationship-type schema entry: the editable property whitelist. */
1655
+ export interface GraphEdgeSchema {
1656
+ editable: string[];
1657
+ }
1658
+ /**
1659
+ * Response from `GET /api/v1/tools/graph/schema` (M7 P1a). The live wire copy
1660
+ * of the graph whitelists — lets the web/ `PropertyPanel` drop its
1661
+ * hand-maintained mirror (tech-debt #45) and consume the same vocabulary the
1662
+ * backend validates against. No auth required (pure metadata).
1663
+ */
1664
+ export interface GraphSchemaResponse {
1665
+ traceId: string;
1666
+ labels: Record<string, GraphLabelSchema>;
1667
+ edges: Record<string, GraphEdgeSchema>;
1668
+ /**
1669
+ * Whether `SEER_ENTITY_DEDUP_ENABLED` is on server-side (R5d #454). When
1670
+ * false, the de-dup oracle does not reconcile same-named characters and the
1671
+ * "Accept as new" homonym override is a no-op — so the UI hides that
1672
+ * affordance. Optional for backward compatibility with pre-0.43.0 servers
1673
+ * (treated as `false`).
1674
+ */
1675
+ entityDedupEnabled?: boolean;
1676
+ }
1677
+ /**
1678
+ * Body for `POST /api/v1/tools/graph/nodes` (M7 P3a). Creates a user-authored
1679
+ * narrative node (Scene / PlotBeat / CharacterArc — see {@link userCreatableLabels}
1680
+ * in `graphSchema.ts`). `videoId` IS a legitimate field here: the node does not
1681
+ * exist yet, so ownership is asserted directly from `videoId` (the documented
1682
+ * POST-carries-videoId exception to derive-ownership-from-object). The backend
1683
+ * stamps `provenance='user'`, `versionId`, and `createdAt`/`updatedAt`.
1684
+ */
1685
+ export interface CreateNodeRequest {
1686
+ videoId: string;
1687
+ label: string;
1688
+ properties: Record<string, unknown>;
1689
+ }
1690
+ /** 201 response from `POST /api/v1/tools/graph/nodes` (composite `nodeId`). */
1691
+ export interface CreateNodeResponse {
1692
+ traceId: string;
1693
+ nodeId: string;
1694
+ properties: Record<string, unknown>;
1695
+ }
1696
+ /**
1697
+ * Body for `POST /api/v1/tools/graph/edges` (M7 P3a). Creates a user-authored
1698
+ * relationship (one of {@link userCreatableEdges}). `sourceId`/`targetId` are
1699
+ * composite ids (`Label:pk:value`); both endpoints must belong to `videoId`.
1700
+ * `type` must be a user-creatable edge whose `(sourceLabel, targetLabel)` pair
1701
+ * is in {@link allowedPairs}; `properties` carries edge-specific fields (e.g.
1702
+ * `kind` for RELATES_TO, `confidence` for FEATURES, `condition` for LEADS_TO).
1703
+ */
1704
+ export interface CreateEdgeRequest {
1705
+ videoId: string;
1706
+ sourceId: string;
1707
+ targetId: string;
1708
+ type: string;
1709
+ properties?: Record<string, unknown>;
1710
+ }
1711
+ /** 201 response from `POST /api/v1/tools/graph/edges` (composite `edgeId`). */
1712
+ export interface CreateEdgeResponse {
1713
+ traceId: string;
1714
+ edgeId: string;
1715
+ properties: Record<string, unknown>;
1716
+ }
712
1717
  /**
713
1718
  * Response shape from the Reactor `/tokens` exchange, returned by the
714
1719
  * Next.js server-side broker at `/api/reactor/token`. The broker forwards
@@ -738,11 +1743,127 @@ export interface UpsampleReactorPromptRequest {
738
1743
  entityContext?: ReactorEntityContext;
739
1744
  /** Persona grounding (name + truncated backstory). */
740
1745
  personaContext?: ReactorPersonaContext;
1746
+ /**
1747
+ * Optional chat-model id to run the upsample on (R8.3). When set, it MUST be
1748
+ * one the backend chat router knows (`shared/model_config.py` — the same set
1749
+ * `GET /api/v1/chat/models` lists); an unknown id is rejected with a 422.
1750
+ * Omitted ⇒ the backend's configured default upsample model — so existing
1751
+ * callers keep their behavior (additive-only). The Director surfaces this via
1752
+ * the R1 CHAT adapter picker so the steering LLM is operator-swappable.
1753
+ */
1754
+ model?: string;
741
1755
  }
742
1756
  export interface UpsampleReactorPromptResponse {
743
1757
  traceId: string;
744
1758
  upsampledPrompt: string;
745
1759
  }
1760
+ /**
1761
+ * One entry in an adventure's turn log. Mirrors
1762
+ * `shared/adventure_models.py::TurnRecord` — the backend serializes it
1763
+ * camelCase (`{turn, beatId, summary}`) inside {@link AdventureState.turnHistory}.
1764
+ * `turn` is 1-based and monotonically increasing; the backend keeps only the
1765
+ * last `TURN_HISTORY_MAX_ENTRIES` (30) records.
1766
+ */
1767
+ export interface TurnRecord {
1768
+ turn: number;
1769
+ beatId: string;
1770
+ summary: string;
1771
+ }
1772
+ /**
1773
+ * Server-authoritative state for an in-progress interactive adventure. Mirrors
1774
+ * `shared/adventure_models.py::AdventureState` (a camelCase-on-the-wire pydantic
1775
+ * model). Returned by `POST /api/v1/adventures` and `GET
1776
+ * /api/v1/adventures/{sessionId}`. The Dungeon-Master persona mutates this via
1777
+ * the `/api/v1/tools/adventure/*` endpoints; the runtime threads `sessionId`
1778
+ * into chat turns so the DM tools resolve the active adventure.
1779
+ */
1780
+ export interface AdventureState {
1781
+ sessionId: string;
1782
+ ownerUserId: string;
1783
+ storyId: string;
1784
+ videoId: string;
1785
+ dmPersonaId: string;
1786
+ partyPersonaIds: string[];
1787
+ /** Current PlotBeat id. `null` before the first `advance_story` move. */
1788
+ currentBeatId?: string | null;
1789
+ visitedBeatIds: string[];
1790
+ flags: Record<string, string>;
1791
+ inventory: string[];
1792
+ turnHistory: TurnRecord[];
1793
+ createdAt: string;
1794
+ updatedAt: string;
1795
+ }
1796
+ /**
1797
+ * Request body for `POST /api/v1/adventures` (start an adventure). Mirrors the
1798
+ * backend `api/adventures/schemas.py::StartAdventureRequest` (`extra="forbid"`,
1799
+ * camelCase keys verbatim). `dmPersonaId` MUST reference a persona whose
1800
+ * `is_dungeon_master` is true (the backend 422s otherwise). `initialBeatId`
1801
+ * optionally seeds the starting PlotBeat; omit to start before any beat.
1802
+ */
1803
+ export interface StartAdventureRequest {
1804
+ storyId: string;
1805
+ videoId: string;
1806
+ dmPersonaId: string;
1807
+ initialBeatId?: string | null;
1808
+ /**
1809
+ * Initial party of character personas for a multi-persona adventure (M10
1810
+ * Story Engine Phase 9a). Each id must reference an owned persona that is
1811
+ * bound to a character entity and is NOT a Dungeon Master (the backend 422s
1812
+ * otherwise). Optional; omit / `[]` for an M9 single-DM adventure — the wire
1813
+ * stays unchanged (land-dark). Mirrors the additive `partyPersonaIds` field
1814
+ * on the backend `StartAdventureRequest`.
1815
+ */
1816
+ partyPersonaIds?: string[];
1817
+ }
1818
+ /**
1819
+ * The two `action` values accepted by `PATCH /api/v1/adventures/{sessionId}/party`
1820
+ * (M10 Story Engine Phase 9a). `add` appends a character persona to the party
1821
+ * (validated + deduped server-side); `remove` is an idempotent no-op when the
1822
+ * persona is absent. Named constant so call sites never hard-code the literals.
1823
+ */
1824
+ export declare const PARTY_ACTION: {
1825
+ readonly ADD: "add";
1826
+ readonly REMOVE: "remove";
1827
+ };
1828
+ /** Union of the {@link PARTY_ACTION} values. */
1829
+ export type PartyAction = (typeof PARTY_ACTION)[keyof typeof PARTY_ACTION];
1830
+ /**
1831
+ * Request body for `PATCH /api/v1/adventures/{sessionId}/party` (M10 Story
1832
+ * Engine Phase 9a). Mirrors the backend `PartyUpdateRequest` (`extra="forbid"`,
1833
+ * camelCase keys verbatim). The PATCH returns the updated
1834
+ * {@link GetAdventureResponse} (the same 200 shape as `GET adventure`).
1835
+ */
1836
+ export interface PartyUpdateRequest {
1837
+ action: PartyAction;
1838
+ personaId: string;
1839
+ }
1840
+ /**
1841
+ * 201 response from `POST /api/v1/adventures`. Mirrors the backend
1842
+ * `AdventureResponse` — carries the new `sessionId` (also in `state.sessionId`)
1843
+ * plus the full initial {@link AdventureState}. The `Location` header points at
1844
+ * `/api/v1/adventures/{sessionId}`.
1845
+ */
1846
+ export interface AdventureResponse {
1847
+ traceId: string;
1848
+ sessionId: string;
1849
+ state: AdventureState;
1850
+ }
1851
+ /** `GET /api/v1/adventures/{sessionId}` — mirrors the backend `GetAdventureResponse`. */
1852
+ export interface GetAdventureResponse {
1853
+ traceId: string;
1854
+ state: AdventureState;
1855
+ }
1856
+ /**
1857
+ * `GET /api/v1/adventures` — mirrors the backend `ListAdventuresResponse`.
1858
+ * Owner-scoped list of the caller's adventures (soft-deleted ones excluded),
1859
+ * newest-first by `createdAt`, optionally narrowed to a single `storyId`. Each
1860
+ * entry is the same camelCase {@link AdventureState} returned by
1861
+ * `GET /api/v1/adventures/{sessionId}`.
1862
+ */
1863
+ export interface ListAdventuresResponse {
1864
+ traceId: string;
1865
+ adventures: AdventureState[];
1866
+ }
746
1867
  export declare class ApiClient {
747
1868
  private baseURL;
748
1869
  private sessionToken?;
@@ -774,6 +1895,23 @@ export declare class ApiClient {
774
1895
  limit?: number;
775
1896
  nextToken?: string;
776
1897
  }): Promise<ListJobsResponse>;
1898
+ /**
1899
+ * Story Engine Phase 5 — list character entities for a video. Backs the
1900
+ * persona↔character binding selector. Returns only ``Entity`` nodes with
1901
+ * ``type === 'character'`` for the given video. Auth + video ownership are
1902
+ * enforced server-side (caller must own the video). Uses the main API base
1903
+ * (the tools routes use ``request``, not ``chatRequest``).
1904
+ */
1905
+ listVideoCharacters(videoId: string): Promise<CharacterListResponse>;
1906
+ /**
1907
+ * Platform Restructure R5a — fetch a video's character cast pre-joined to
1908
+ * each character's bound persona in ONE round-trip (the server resolves the
1909
+ * PORTRAYS binding + hydrates persona display fields). The one-call
1910
+ * replacement for the CastGrid's `getVideoGraph` + `listPersonas` client-side
1911
+ * `entity_id` join (the R5c rewire consumes this). Auth + video ownership are
1912
+ * enforced server-side. Tools API base (`request`, not `chatRequest`).
1913
+ */
1914
+ getCast(videoId: string): Promise<CastWithPersonaResponse>;
777
1915
  /**
778
1916
  * List staged videos in the ingestion bucket
779
1917
  */
@@ -802,29 +1940,203 @@ export declare class ApiClient {
802
1940
  * Delete a video and all associated data across all systems
803
1941
  */
804
1942
  deleteVideo(videoId: string, s3Key?: string): Promise<VideoDeletionResponse>;
1943
+ /**
1944
+ * Start an async narrative regeneration run for a video scope.
1945
+ * `POST /api/v1/tools/graph/{videoId}/regenerate` → 202 with the QUEUED run
1946
+ * (and a `Location` header to the run's poll URL, exposed as `statusUrl`).
1947
+ *
1948
+ * Auth + ownership are enforced server-side. A malformed `scope` is a 422,
1949
+ * an in-flight run is a 409, over-cap is a 429 — all surface as a thrown
1950
+ * `Error` carrying the FastAPI detail. Build `request.scope` with
1951
+ * {@link buildRegenerationScope}. Pair with {@link pollRegenerationUntilDone}.
1952
+ */
1953
+ startRegeneration(videoId: string, request: RegenerateRequest): Promise<RegenerationRunResponse>;
1954
+ /**
1955
+ * List a video's regeneration runs, newest-first.
1956
+ * `GET /api/v1/tools/graph/{videoId}/regenerations`. `limit` (1–100) and
1957
+ * `cursor` (opaque pagination token from a prior `nextCursor`) are optional.
1958
+ */
1959
+ listRegenerations(videoId: string, params?: {
1960
+ limit?: number;
1961
+ cursor?: string;
1962
+ }): Promise<RegenerationListResponse>;
1963
+ /**
1964
+ * Fetch a single regeneration run by id.
1965
+ * `GET /api/v1/tools/graph/{videoId}/regenerations/{runId}` (404 if absent).
1966
+ * `signal` aborts the in-flight fetch — {@link pollRegenerationUntilDone}
1967
+ * threads its poll signal through so a page unmount cancels cleanly.
1968
+ */
1969
+ getRegeneration(videoId: string, runId: string, options?: {
1970
+ signal?: AbortSignal;
1971
+ }): Promise<RegenerationRunResponse>;
1972
+ /**
1973
+ * Poll {@link getRegeneration} until the run reaches a terminal status.
1974
+ * COMPLETE / CANCELLED resolve with the final run; FAILED throws
1975
+ * (`record.error` ?? a generic message). Mirrors
1976
+ * {@link pollVisemeBundleUntilDone}: 5s cadence, abortable via `signal`,
1977
+ * and a wall-clock timeout (regeneration re-invokes Pegasus, so the default
1978
+ * matches bundle assembly — generous but bounded).
1979
+ */
1980
+ pollRegenerationUntilDone(videoId: string, runId: string, options?: {
1981
+ intervalMs?: number;
1982
+ timeoutMs?: number;
1983
+ signal?: AbortSignal;
1984
+ }): Promise<RegenerationRunResponse>;
1985
+ /**
1986
+ * Upload a source document (script / notes / bible / transcript) with
1987
+ * progress tracking. Mirrors {@link uploadVideo}: multipart XHR so the
1988
+ * browser reports upload progress (fetch cannot). The `meta` fields ride
1989
+ * alongside the file as a JSON `payload` part. Returns 201 with
1990
+ * `{ traceId, docId, statusUrl }`; the backend enqueues
1991
+ * `document-processing-queue` to parse + extract suggestions.
1992
+ */
1993
+ uploadDocument(file: File, meta: UploadDocumentMeta, onProgress?: UploadProgressCallback): Promise<UploadDocumentResponse>;
1994
+ /**
1995
+ * List source documents, optionally scoped to a video or series. Mirrors
1996
+ * {@link listJobs} query-param handling. GET `/api/v1/ingestion/documents`.
1997
+ */
1998
+ listDocuments(params?: {
1999
+ videoId?: string;
2000
+ seriesId?: string;
2001
+ limit?: number;
2002
+ nextToken?: string;
2003
+ }): Promise<ListDocumentsResponse>;
2004
+ /**
2005
+ * Fetch a single document plus its pending/resolved graph suggestions.
2006
+ * GET `/api/v1/ingestion/documents/{docId}`.
2007
+ */
2008
+ getDocument(docId: string): Promise<GetDocumentResponse>;
2009
+ /**
2010
+ * Accept a pipeline-extracted graph suggestion — writes the proposed
2011
+ * node/edge with provenance `document`. POST returns 201 with
2012
+ * `{ traceId, suggestionId, graphId }` (`graphId` is the composite id of the
2013
+ * created node/edge); a 422 (e.g. already resolved, or the payload fails
2014
+ * graph validation) surfaces the FastAPI detail as a thrown `Error`. POST
2015
+ * `.../documents/{docId}/suggestions/{sid}/accept`.
2016
+ *
2017
+ * `acceptAsNew` (R5d homonym override): accept a same-named character as a
2018
+ * DISTINCT character, skipping de-dup reconciliation and recording a "these
2019
+ * are different" override so the oracle never auto-merges the pair. Omitted
2020
+ * (the default) sends a body-less POST, byte-identical to the legacy accept.
2021
+ */
2022
+ acceptSuggestion(docId: string, suggestionId: string, options?: {
2023
+ acceptAsNew?: boolean;
2024
+ }): Promise<AcceptSuggestionResponse>;
2025
+ /**
2026
+ * Mark two entities as DIFFERENT characters (R5d homonym override) so the
2027
+ * de-dup oracle never reconciles them. `docentId` is the document-authored
2028
+ * (`docent-`) entity, `entityId` the Pegasus character to keep separate.
2029
+ * POST `/api/v1/tools/graph/entities/distinct` → 201.
2030
+ */
2031
+ markEntitiesDistinct(args: {
2032
+ videoId: string;
2033
+ docentId: string;
2034
+ entityId: string;
2035
+ }): Promise<MarkEntitiesDistinctResponse>;
2036
+ /**
2037
+ * Clear a distinctness override (re-arms the de-dup oracle for the pair).
2038
+ * Idempotent — `cleared` is `false` when no override existed. DELETE
2039
+ * `/api/v1/tools/graph/entities/distinct?videoId&docentId&entityId`.
2040
+ */
2041
+ clearEntitiesDistinct(args: {
2042
+ videoId: string;
2043
+ docentId: string;
2044
+ entityId: string;
2045
+ }): Promise<ClearEntitiesDistinctResponse>;
2046
+ /**
2047
+ * Reject a pipeline-extracted graph suggestion (marks it `rejected`, writes
2048
+ * nothing to the graph). Returns 204 (no body). POST
2049
+ * `.../documents/{docId}/suggestions/{sid}/reject`.
2050
+ */
2051
+ rejectSuggestion(docId: string, suggestionId: string): Promise<void>;
2052
+ /**
2053
+ * Delete a source document and its associated data. Returns 204 (no body).
2054
+ * DELETE `/api/v1/ingestion/documents/{docId}`.
2055
+ */
2056
+ deleteDocument(docId: string): Promise<void>;
2057
+ /**
2058
+ * Shared SSE body-reader for the chat + assistant stream endpoints.
2059
+ * POSTs the JSON `body` to `url` (with the auth header when a session
2060
+ * token is set) and returns the response's `ReadableStreamDefaultReader`
2061
+ * for the caller to decode. `streamChat` and `streamAssistant` differ
2062
+ * ONLY by URL + body, so they both route through here — there is exactly
2063
+ * one fetch/reader/decoder plumbing (DRY; R4a reviewer flag).
2064
+ *
2065
+ * `errorPrefix` only shapes the fallback message when the backend
2066
+ * returns a non-2xx without a `detail` field.
2067
+ */
2068
+ private readSseStream;
805
2069
  /**
806
2070
  * Stream chat responses with Server-Sent Events
807
2071
  * Returns a ReadableStreamDefaultReader for processing SSE events
808
2072
  */
809
2073
  streamChat(request: ChatStreamRequest, signal?: AbortSignal): Promise<ReadableStreamDefaultReader<Uint8Array>>;
2074
+ /**
2075
+ * Stream Platform Assistant (R4) responses with Server-Sent Events.
2076
+ * Sibling of {@link streamChat} hitting `POST /api/v1/assistant/stream`
2077
+ * — reuses the exact same SSE reader/decoder plumbing via
2078
+ * {@link readSseStream}. Decode each `data: {…}` line into an
2079
+ * {@link AssistantStreamEvent} (the stream may carry the additive
2080
+ * `suggestion` variant). The assistant is out-of-world: the request
2081
+ * carries `routeContext` instead of `videoId`.
2082
+ */
2083
+ streamAssistant(request: AssistantStreamRequest, signal?: AbortSignal): Promise<ReadableStreamDefaultReader<Uint8Array>>;
810
2084
  /**
811
2085
  * Fetch the chat-model registry from the backend. Returns Bedrock entries
812
2086
  * plus any locally-discovered Ollama models. Public endpoint — works
813
2087
  * before the user is authenticated.
814
2088
  */
815
2089
  listChatModels(): Promise<ChatModelsResponse>;
2090
+ /**
2091
+ * Fetch the drift-proof field schema for a named creator/admin form
2092
+ * (`GET /api/v1/schema/{form}`). The backend derives every field from the
2093
+ * form's PUBLIC Pydantic request model (`model_json_schema()`) so it can
2094
+ * never drift from the real endpoint contract. The host UI uses this to
2095
+ * validate which `propose_form_fields` suggestions are applicable; the
2096
+ * assistant uses it to propose VALID field names. `form` is one of the
2097
+ * registered ids (`personas` / `documents` / `adventures` / `images`);
2098
+ * `scenes` is intentionally omitted and any unknown form returns 404
2099
+ * (surfaced as a thrown Error).
2100
+ */
2101
+ getFormSchema(form: string): Promise<FormSchemaResponse>;
2102
+ /**
2103
+ * List every platform tool's human-readable reference
2104
+ * (`GET /api/v1/tools/reference`). Derived server-side from the full
2105
+ * `shared/tool_schemas` registry (`iter_all_tool_schemas` — chat + adventure
2106
+ * + assistant), so the catalogue cannot drift from the live tool list.
2107
+ */
2108
+ listToolReferences(): Promise<ToolReferenceListResponse>;
2109
+ /**
2110
+ * Fetch one tool's reference by name
2111
+ * (`GET /api/v1/tools/reference/{name}`). 404 (thrown Error) when the tool
2112
+ * is unknown.
2113
+ */
2114
+ getToolReference(name: string): Promise<ToolReferenceResponse>;
816
2115
  /**
817
2116
  * Create a new persona
818
2117
  */
819
2118
  createPersona(data: CreatePersonaRequest): Promise<PersonaConfig>;
820
2119
  /**
821
- * List all personas for the current user
2120
+ * List all personas for the current user.
2121
+ *
2122
+ * When ``sourceVideoId`` is set (C3a), the backend delegates to
2123
+ * ``PersonaStore.list_personas_by_video`` and returns ALL personas
2124
+ * auto-generated from that video in one shot (it paginates internally), so
2125
+ * ``limit`` / ``nextToken`` do not apply and the response ``next_token`` is
2126
+ * always ``null``. See {@link listPersonasByVideo} for the convenience wrapper.
822
2127
  */
823
2128
  listPersonas(params?: {
824
2129
  limit?: number;
825
2130
  nextToken?: string;
826
2131
  status?: 'pending' | 'approved';
2132
+ sourceVideoId?: string;
827
2133
  }): Promise<PersonaListResponse>;
2134
+ /**
2135
+ * C3a: list the personas auto-generated from a given source video. Thin
2136
+ * wrapper over {@link listPersonas} with ``sourceVideoId`` — backs the review
2137
+ * page's roster + the "Auto"/"Pending" badges on the personas list.
2138
+ */
2139
+ listPersonasByVideo(sourceVideoId: string): Promise<PersonaListResponse>;
828
2140
  /**
829
2141
  * Get the default persona for the current user
830
2142
  */
@@ -846,9 +2158,87 @@ export declare class ApiClient {
846
2158
  * Does NOT persist — returns suggestions to create individually.
847
2159
  */
848
2160
  synthesizePersonas(videoId: string, enrichmentData: Record<string, unknown>, maxPersonas?: number): Promise<SynthesizePersonasResponse>;
2161
+ /**
2162
+ * C3a: fetch the current user's persona-generation settings, or ``null`` when
2163
+ * never saved (the settings UI then falls back to its client-side defaults).
2164
+ * ``GET /api/v1/personas/settings/generation``.
2165
+ */
2166
+ getPersonaGenSettings(): Promise<PersonaGenerationSettings | null>;
2167
+ /**
2168
+ * C3a: upsert the user's persona-generation settings. The body is a partial —
2169
+ * supplied (non-null) fields merge over the stored (or default) settings; the
2170
+ * response is the persisted, fully-populated settings. ``user_id`` /
2171
+ * ``updated_at`` are store-managed. ``PUT /api/v1/personas/settings/generation``.
2172
+ */
2173
+ updatePersonaGenSettings(body: UpdatePersonaGenSettingsRequest): Promise<PersonaGenerationSettings>;
2174
+ /**
2175
+ * C3a: trigger auto-generation of personas for a video. Returns a ``202`` job
2176
+ * envelope (``{ jobId, status, traceId }`` — camelCase wire keys). Idempotent
2177
+ * on ``(user, video)``: a second call while a job is still active returns that
2178
+ * job's id instead of spawning a duplicate. Poll {@link getPersonaJob} with the
2179
+ * returned ``jobId``. ``POST /api/v1/videos/{videoId}/personas/generate``.
2180
+ *
2181
+ * C3a-f1 (Studio Cast): pass ``opts.entityIds`` to restrict generation to a
2182
+ * character-Entity-id subset — a per-cast-member "Generate persona" sends that
2183
+ * one id; the Cast "Generate all" sends the whole cast (or omits it). Omitting
2184
+ * ``entityIds`` (or passing an empty list) generates for every qualifying
2185
+ * speaking character — byte-identical to the original whole-video call, so the
2186
+ * body is only sent when a non-empty subset is supplied.
2187
+ */
2188
+ generatePersonasForVideo(videoId: string, opts?: {
2189
+ entityIds?: string[];
2190
+ }): Promise<GeneratePersonasJobResponse>;
2191
+ /**
2192
+ * C3a: poll a persona-generation job's status + progress + errors. Ownership
2193
+ * is enforced server-side by reconstructing the partition key from the auth
2194
+ * token (a foreign/unknown id 404s). ``GET /api/v1/persona-jobs/{jobId}``.
2195
+ */
2196
+ getPersonaJob(jobId: string): Promise<AutoGenerationJob>;
2197
+ /**
2198
+ * C3a (Step 9 / review page): render a short TTS sample in the persona's
2199
+ * current voice and return the ``audio/wav`` bytes as a ``Blob`` (the caller
2200
+ * plays it via ``URL.createObjectURL`` + ``<audio>``). Allowed for any persona
2201
+ * status so the review page can preview before approval.
2202
+ * ``POST /api/v1/personas/{personaId}/audition``.
2203
+ *
2204
+ * The response is binary, so this bypasses the JSON ``chatRequest`` wrapper and
2205
+ * attaches the bearer token directly (same pattern as {@link getSeedImageBlob}).
2206
+ * An omitted ``body`` renders the backend default sample text.
2207
+ */
2208
+ auditionPersona(personaId: string, body?: AuditionRequest, options?: {
2209
+ signal?: AbortSignal;
2210
+ }): Promise<Blob>;
2211
+ /**
2212
+ * C3a (Step 9 / review page): re-clone the persona's voice from a DIFFERENT
2213
+ * subset of its cached ``persona-clips`` (available minus already-used) without
2214
+ * re-downloading the video. Swaps ``voice_id`` and appends to ``clips_used``;
2215
+ * returns the new ``voiceId`` + the full ``clipsUsed`` set.
2216
+ * ``POST /api/v1/personas/{personaId}/reclone``.
2217
+ *
2218
+ * Bypasses ``chatRequest`` so a ``409`` (whose ``detail`` is a structured
2219
+ * object the generic JSON error path renders as ``[object Object]``) is raised
2220
+ * as a typed {@link RecloneConflictError} the review UI can branch on.
2221
+ */
2222
+ reclonePersona(personaId: string): Promise<ReclonedPersonaResponse>;
2223
+ /**
2224
+ * Fetch the image-model catalogue from the backend (R1c). Read-only.
2225
+ * Unlike {@link listChatModels}, this endpoint is **authenticated** (its
2226
+ * consumers — Studio Images, the Admin adapter inspector — are post-auth, so
2227
+ * it is not a public pre-auth path); call it with a valid session. Served via
2228
+ * the CHAT base URL (the images API is mounted on the chat app), so this uses
2229
+ * `chatRequest`, NOT `toolsRequest`.
2230
+ */
2231
+ listImageModels(): Promise<ImageModelsResponse>;
849
2232
  listImages(params?: {
850
2233
  category?: ImageCategory;
851
2234
  videoId?: string;
2235
+ /** Filter by generation model. Valid ids come from `listImageModels()`
2236
+ * (R1's `GET /api/v1/images/models`); the backend rejects an
2237
+ * unregistered id with 400. */
2238
+ model?: string;
2239
+ /** Filter by lifecycle status. Reuses the `ImageStatus` union
2240
+ * (`ImageRecord['status']`) — no parallel status enum (R6b). */
2241
+ status?: ImageStatus;
852
2242
  limit?: number;
853
2243
  nextToken?: string;
854
2244
  }): Promise<ImageListResponse>;
@@ -1014,11 +2404,59 @@ export declare class ApiClient {
1014
2404
  t0?: number;
1015
2405
  t1?: number;
1016
2406
  }): Promise<EntityTimelineResponse>;
1017
- getVideoGraph(videoId: string): Promise<VideoGraphResponse>;
2407
+ /**
2408
+ * Fetch a video's subgraph. R5b: the optional `detail` arg selects the
2409
+ * server-side view — `GRAPH_DETAIL.STORY` for the collapsed story view,
2410
+ * `GRAPH_DETAIL.RAW` for the full extraction graph. Omitting it sends NO
2411
+ * query param (byte-identical to the pre-R5b request — the server defaults
2412
+ * to raw), so every existing caller is untouched.
2413
+ */
2414
+ getVideoGraph(videoId: string, detail?: GraphDetail): Promise<VideoGraphResponse>;
2415
+ /**
2416
+ * List all stories (videos) visible to the caller. `storyId === videoId`
2417
+ * (1:1) in M7 P7 — the Story resource is a thin, read-only view over the
2418
+ * existing Video. No pagination/filter parameters in P7.
2419
+ */
2420
+ listStories(): Promise<ListStoriesResponse>;
2421
+ /**
2422
+ * Fetch a single story's metadata + aggregate counts. Throws (404) when the
2423
+ * id resolves to no Video node.
2424
+ */
2425
+ getStory(storyId: string): Promise<GetStoryResponse>;
2426
+ /**
2427
+ * Resolve a playable (presigned or local-stub) URL for a clip span via the
2428
+ * existing `POST /api/v1/tools/clip-lookup` tool endpoint. Used by the studio
2429
+ * Scene inspector to scope the player to a scene's `[t0, t1]`. Additive — never
2430
+ * remove/rename. Wire keys are camelCase (backend `BaseSchema`, no aliasing).
2431
+ */
2432
+ clipLookup(params: ClipLookupParams): Promise<ClipLookupResponse>;
2433
+ /**
2434
+ * Fetch the live graph whitelist (node PKs + editable properties per label
2435
+ * and edge type). No auth required — pure metadata. Prefer the memoized
2436
+ * `fetchGraphSchema()` wrapper in `graphSchema.ts` over calling this per
2437
+ * render; the raw method exists for that wrapper and one-off callers.
2438
+ */
2439
+ getGraphSchema(): Promise<GraphSchemaResponse>;
1018
2440
  updateGraphNode(data: UpdateNodeRequest): Promise<UpdateNodeResponse>;
1019
2441
  deleteGraphNode(data: DeleteNodeRequest): Promise<DeleteNodeResponse>;
1020
2442
  updateGraphEdge(data: UpdateRelationshipRequest): Promise<UpdateRelationshipResponse>;
1021
2443
  deleteGraphEdge(data: DeleteRelationshipRequest): Promise<DeleteRelationshipResponse>;
2444
+ /**
2445
+ * Create a user-authored narrative node (Scene / PlotBeat / CharacterArc).
2446
+ * POST returns 201 with `{traceId, nodeId, properties}`; `makeRequest` parses
2447
+ * the body (only 204 is bodyless) and surfaces a 422 (e.g. label not
2448
+ * user-creatable, missing actId/index for a Scene) as a thrown `Error` with
2449
+ * the FastAPI detail. The backend stamps provenance/versionId/timestamps.
2450
+ */
2451
+ createGraphNode(data: CreateNodeRequest): Promise<CreateNodeResponse>;
2452
+ /**
2453
+ * Create a user-authored relationship (RELATES_TO / CAUSES / SET_IN /
2454
+ * FEATURES / ON_ARC / LEADS_TO). POST returns 201 with
2455
+ * `{traceId, edgeId, properties}`; a 422 (invalid endpoint-label pair,
2456
+ * pipeline-only type, cross-video endpoints, or SET_IN/FEATURES Entity.type
2457
+ * mismatch) surfaces as a thrown `Error` with the FastAPI detail.
2458
+ */
2459
+ createGraphEdge(data: CreateEdgeRequest): Promise<CreateEdgeResponse>;
1022
2460
  /**
1023
2461
  * Fetch a persona's viseme bundle by ID. Returns the full record including
1024
2462
  * inline body_svg and mouth_paths when status === 'complete'.
@@ -1218,5 +2656,75 @@ export declare class ApiClient {
1218
2656
  upsampleReactorPrompt(input: UpsampleReactorPromptRequest, options?: {
1219
2657
  signal?: AbortSignal;
1220
2658
  }): Promise<UpsampleReactorPromptResponse>;
2659
+ /**
2660
+ * Start an interactive adventure for a story/video, driven by a
2661
+ * Dungeon-Master persona. `POST /api/v1/adventures` → 201 with the initial
2662
+ * {@link AdventureState} (and a `Location` header to the session's GET URL).
2663
+ *
2664
+ * Auth + video ownership are enforced server-side. `dmPersonaId` must
2665
+ * reference an owned persona whose `is_dungeon_master` is true (422 otherwise),
2666
+ * and a missing/unowned persona is a 404/403 — all surface as a thrown `Error`
2667
+ * carrying the FastAPI detail. Additive — never remove/rename.
2668
+ */
2669
+ startAdventure(request: StartAdventureRequest, options?: {
2670
+ signal?: AbortSignal;
2671
+ }): Promise<AdventureResponse>;
2672
+ /**
2673
+ * Fetch the current {@link AdventureState} for a session.
2674
+ * `GET /api/v1/adventures/{sessionId}` (404 when absent or not owned by the
2675
+ * caller — the store hides cross-tenant and soft-deleted sessions).
2676
+ */
2677
+ getAdventure(sessionId: string, options?: {
2678
+ signal?: AbortSignal;
2679
+ }): Promise<GetAdventureResponse>;
2680
+ /**
2681
+ * List the caller's adventures, newest-first. `GET /api/v1/adventures` →
2682
+ * {@link ListAdventuresResponse}. Owner-scoped server-side (soft-deleted
2683
+ * sessions excluded); pass `storyId` to narrow to a single story. Additive —
2684
+ * never remove/rename.
2685
+ */
2686
+ listAdventures(storyId?: string, options?: {
2687
+ signal?: AbortSignal;
2688
+ }): Promise<ListAdventuresResponse>;
2689
+ /**
2690
+ * Soft-delete an adventure session. `DELETE /api/v1/adventures/{sessionId}`
2691
+ * → 204 (resolves to `void`). A missing/unowned session is a 404 surfaced as
2692
+ * a thrown `Error`.
2693
+ */
2694
+ deleteAdventure(sessionId: string, options?: {
2695
+ signal?: AbortSignal;
2696
+ }): Promise<void>;
2697
+ /**
2698
+ * Mutate an adventure's party (M10 Story Engine Phase 9a).
2699
+ * `PATCH /api/v1/adventures/{sessionId}/party` with
2700
+ * `{ action, personaId }` → the updated {@link GetAdventureResponse}.
2701
+ * Shared by {@link addPartyMember} / {@link removePartyMember}; not exported
2702
+ * directly so call sites go through the action-specific wrappers. Additive —
2703
+ * never remove/rename.
2704
+ */
2705
+ private patchParty;
2706
+ /**
2707
+ * Add a character persona to an adventure's party (M10 Story Engine Phase
2708
+ * 9a). `PATCH /api/v1/adventures/{sessionId}/party` with `action='add'` →
2709
+ * the updated {@link GetAdventureResponse}. The persona must be owned by the
2710
+ * caller, bound to a character entity, and NOT a Dungeon Master (422
2711
+ * otherwise); a missing/unowned adventure is a 404 — all surface as a thrown
2712
+ * `Error` carrying the FastAPI detail. Server-side dedupe makes a repeat add
2713
+ * a no-op. Additive — never remove/rename.
2714
+ */
2715
+ addPartyMember(sessionId: string, personaId: string, options?: {
2716
+ signal?: AbortSignal;
2717
+ }): Promise<GetAdventureResponse>;
2718
+ /**
2719
+ * Remove a character persona from an adventure's party (M10 Story Engine
2720
+ * Phase 9a). `PATCH /api/v1/adventures/{sessionId}/party` with
2721
+ * `action='remove'` → the updated {@link GetAdventureResponse}. Idempotent:
2722
+ * removing an absent member is a 200 no-op that returns the current state. A
2723
+ * missing/unowned adventure is a 404 surfaced as a thrown `Error`. Additive —
2724
+ * never remove/rename.
2725
+ */
2726
+ removePartyMember(sessionId: string, personaId: string, options?: {
2727
+ signal?: AbortSignal;
2728
+ }): Promise<GetAdventureResponse>;
1221
2729
  }
1222
2730
  //# sourceMappingURL=api.d.ts.map