@escapeaihq/client-core 0.12.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/README.md +31 -6
  2. package/dist/adapters/capabilities.d.ts +10 -0
  3. package/dist/adapters/capabilities.d.ts.map +1 -0
  4. package/dist/adapters/capabilities.js +2 -0
  5. package/dist/adapters/capabilities.js.map +1 -0
  6. package/dist/adapters/chatAdapter.d.ts +38 -0
  7. package/dist/adapters/chatAdapter.d.ts.map +1 -0
  8. package/dist/adapters/chatAdapter.js +88 -0
  9. package/dist/adapters/chatAdapter.js.map +1 -0
  10. package/dist/adapters/directorAdapter.d.ts +62 -0
  11. package/dist/adapters/directorAdapter.d.ts.map +1 -0
  12. package/dist/adapters/directorAdapter.js +71 -0
  13. package/dist/adapters/directorAdapter.js.map +1 -0
  14. package/dist/adapters/imageAdapter.d.ts +44 -0
  15. package/dist/adapters/imageAdapter.d.ts.map +1 -0
  16. package/dist/adapters/imageAdapter.js +73 -0
  17. package/dist/adapters/imageAdapter.js.map +1 -0
  18. package/dist/adapters/index.d.ts +47 -0
  19. package/dist/adapters/index.d.ts.map +1 -0
  20. package/dist/adapters/index.js +41 -0
  21. package/dist/adapters/index.js.map +1 -0
  22. package/dist/adapters/registry.d.ts +98 -0
  23. package/dist/adapters/registry.d.ts.map +1 -0
  24. package/dist/adapters/registry.js +106 -0
  25. package/dist/adapters/registry.js.map +1 -0
  26. package/dist/adapters/worldAdapter.d.ts +142 -0
  27. package/dist/adapters/worldAdapter.d.ts.map +1 -0
  28. package/dist/adapters/worldAdapter.js +164 -0
  29. package/dist/adapters/worldAdapter.js.map +1 -0
  30. package/dist/admin.d.ts +200 -0
  31. package/dist/admin.d.ts.map +1 -0
  32. package/dist/admin.js +124 -0
  33. package/dist/admin.js.map +1 -0
  34. package/dist/api.d.ts +1185 -3
  35. package/dist/api.d.ts.map +1 -1
  36. package/dist/api.js +624 -51
  37. package/dist/api.js.map +1 -1
  38. package/dist/audio.d.ts +33 -1
  39. package/dist/audio.d.ts.map +1 -1
  40. package/dist/audio.js +4 -1
  41. package/dist/audio.js.map +1 -1
  42. package/dist/castProjection.d.ts +35 -0
  43. package/dist/castProjection.d.ts.map +1 -0
  44. package/dist/castProjection.js +80 -0
  45. package/dist/castProjection.js.map +1 -0
  46. package/dist/conversation/binding.d.ts +62 -0
  47. package/dist/conversation/binding.d.ts.map +1 -0
  48. package/dist/conversation/binding.js +51 -0
  49. package/dist/conversation/binding.js.map +1 -0
  50. package/dist/conversation/controller.d.ts +209 -0
  51. package/dist/conversation/controller.d.ts.map +1 -0
  52. package/dist/conversation/controller.js +342 -0
  53. package/dist/conversation/controller.js.map +1 -0
  54. package/dist/conversation/effectiveModel.d.ts +62 -0
  55. package/dist/conversation/effectiveModel.d.ts.map +1 -0
  56. package/dist/conversation/effectiveModel.js +73 -0
  57. package/dist/conversation/effectiveModel.js.map +1 -0
  58. package/dist/conversation/index.d.ts +27 -0
  59. package/dist/conversation/index.d.ts.map +1 -0
  60. package/dist/conversation/index.js +27 -0
  61. package/dist/conversation/index.js.map +1 -0
  62. package/dist/conversation/participant.d.ts +66 -0
  63. package/dist/conversation/participant.d.ts.map +1 -0
  64. package/dist/conversation/participant.js +36 -0
  65. package/dist/conversation/participant.js.map +1 -0
  66. package/dist/conversation/presence.d.ts +56 -0
  67. package/dist/conversation/presence.d.ts.map +1 -0
  68. package/dist/conversation/presence.js +34 -0
  69. package/dist/conversation/presence.js.map +1 -0
  70. package/dist/conversation/presenceBus.d.ts +42 -0
  71. package/dist/conversation/presenceBus.d.ts.map +1 -0
  72. package/dist/conversation/presenceBus.js +81 -0
  73. package/dist/conversation/presenceBus.js.map +1 -0
  74. package/dist/conversation/presenceRegistry.d.ts +49 -0
  75. package/dist/conversation/presenceRegistry.d.ts.map +1 -0
  76. package/dist/conversation/presenceRegistry.js +59 -0
  77. package/dist/conversation/presenceRegistry.js.map +1 -0
  78. package/dist/conversation/roster.d.ts +72 -0
  79. package/dist/conversation/roster.d.ts.map +1 -0
  80. package/dist/conversation/roster.js +69 -0
  81. package/dist/conversation/roster.js.map +1 -0
  82. package/dist/conversation/rosterProjection.d.ts +52 -0
  83. package/dist/conversation/rosterProjection.d.ts.map +1 -0
  84. package/dist/conversation/rosterProjection.js +74 -0
  85. package/dist/conversation/rosterProjection.js.map +1 -0
  86. package/dist/conversation/router.d.ts +74 -0
  87. package/dist/conversation/router.d.ts.map +1 -0
  88. package/dist/conversation/router.js +58 -0
  89. package/dist/conversation/router.js.map +1 -0
  90. package/dist/conversation/runtime.d.ts +64 -0
  91. package/dist/conversation/runtime.d.ts.map +1 -0
  92. package/dist/conversation/runtime.js +172 -0
  93. package/dist/conversation/runtime.js.map +1 -0
  94. package/dist/conversation/types.d.ts +99 -0
  95. package/dist/conversation/types.d.ts.map +1 -0
  96. package/dist/conversation/types.js +13 -0
  97. package/dist/conversation/types.js.map +1 -0
  98. package/dist/conversation/voice.d.ts +185 -0
  99. package/dist/conversation/voice.d.ts.map +1 -0
  100. package/dist/conversation/voice.js +307 -0
  101. package/dist/conversation/voice.js.map +1 -0
  102. package/dist/graphSchema.d.ts +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 +73 -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 +470 -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/controller.test.ts +697 -0
  179. package/src/__tests__/conversation/effectiveModel.test.ts +169 -0
  180. package/src/__tests__/conversation/headlessRenderer.ts +46 -0
  181. package/src/__tests__/conversation/presenceBus.test.ts +236 -0
  182. package/src/__tests__/conversation/presenceRegistry.test.ts +73 -0
  183. package/src/__tests__/conversation/roster.test.ts +100 -0
  184. package/src/__tests__/conversation/rosterProjection.test.ts +142 -0
  185. package/src/__tests__/conversation/router.test.ts +81 -0
  186. package/src/__tests__/conversation/runtime.test.ts +206 -0
  187. package/src/__tests__/conversation/voice.test.ts +440 -0
  188. package/src/__tests__/documents.test.ts +360 -0
  189. package/src/__tests__/graphSchema.test.ts +218 -9
  190. package/src/__tests__/longLiveCommandDispatcher.test.ts +185 -0
  191. package/src/__tests__/platformAssistant.test.ts +484 -0
  192. package/src/__tests__/reactor/storyTimeline.test.ts +186 -0
  193. package/src/__tests__/regeneration.test.ts +486 -0
  194. package/src/__tests__/stories.test.ts +171 -0
  195. package/src/__tests__/storyGraph.test.ts +134 -0
  196. package/src/__tests__/tools-wrappers.test.ts +272 -0
  197. package/src/__tests__/videoGraph.test.ts +94 -0
  198. package/src/__tests__/websocket.test.ts +213 -0
  199. package/src/adapters/capabilities.ts +24 -0
  200. package/src/adapters/chatAdapter.ts +114 -0
  201. package/src/adapters/directorAdapter.ts +126 -0
  202. package/src/adapters/imageAdapter.ts +100 -0
  203. package/src/adapters/index.ts +67 -0
  204. package/src/adapters/registry.ts +159 -0
  205. package/src/adapters/worldAdapter.ts +272 -0
  206. package/src/admin.ts +310 -0
  207. package/src/api.ts +1731 -116
  208. package/src/audio.ts +35 -0
  209. package/src/castProjection.ts +95 -0
  210. package/src/conversation/binding.ts +81 -0
  211. package/src/conversation/controller.ts +439 -0
  212. package/src/conversation/effectiveModel.ts +111 -0
  213. package/src/conversation/index.ts +27 -0
  214. package/src/conversation/participant.ts +71 -0
  215. package/src/conversation/presence.ts +60 -0
  216. package/src/conversation/presenceBus.ts +109 -0
  217. package/src/conversation/presenceRegistry.ts +83 -0
  218. package/src/conversation/roster.ts +111 -0
  219. package/src/conversation/rosterProjection.ts +98 -0
  220. package/src/conversation/router.ts +96 -0
  221. package/src/conversation/runtime.ts +188 -0
  222. package/src/conversation/types.ts +100 -0
  223. package/src/conversation/voice.ts +402 -0
  224. package/src/graphSchema.ts +396 -13
  225. package/src/http.ts +72 -0
  226. package/src/index.ts +9 -0
  227. package/src/platformAssistant.ts +347 -0
  228. package/src/reactor/chunkDistribution.ts +98 -0
  229. package/src/reactor/index.ts +5 -0
  230. package/src/reactor/longLiveCommandDispatcher.ts +156 -0
  231. package/src/reactor/scenesFromEnrichment.ts +11 -76
  232. package/src/reactor/seedImageOrchestrator.ts +12 -13
  233. package/src/reactor/storyTimeline.ts +127 -0
  234. package/src/storyGraph.ts +298 -0
  235. package/src/vision/VisionSourceController.ts +354 -0
  236. package/src/vision/__tests__/VisionSourceController.test.ts +719 -0
  237. package/src/vision/index.ts +13 -0
  238. package/src/vision/sourceKinds.ts +75 -0
  239. package/src/websocket.ts +75 -3
@@ -0,0 +1,164 @@
1
+ import { AdapterRegistry, ROUTE_DEFAULT, ROUTE_FALLBACK, } from './registry.js';
2
+ import { dispatchHeliosCommand, dispatchLongLiveCommand } from '../reactor.js';
3
+ /**
4
+ * The one world model that exists today. Helios drives the live
5
+ * step-into-video stream over the structural Reactor bridge. Its
6
+ * `supportedCommands` is the EXACT {@link HeliosCommand} variant set
7
+ * (`reactor/heliosTools.ts:32-37`).
8
+ *
9
+ * The 'helios' id is the single source of truth for the model name — the
10
+ * R8 rewire reads it from here instead of re-spelling the literal in the
11
+ * `/interactive` pages.
12
+ */
13
+ // `as const satisfies` (NOT a `: WorldAdapterDescriptor` annotation) so `.id`
14
+ // keeps its literal type `'helios'` — `dispatchWorldCommand`'s overloads key on
15
+ // `typeof heliosWorldAdapter.id`, which would widen to `string` (defeating the
16
+ // cmd/adapter discrimination) under a plain type annotation.
17
+ export const heliosWorldAdapter = {
18
+ id: 'helios',
19
+ displayName: 'Helios',
20
+ provider: 'reactor',
21
+ capabilities: ['world_stream', 'set_scene', 'swap_seed', 'pause_resume'],
22
+ supportedCommands: [
23
+ 'set_scene',
24
+ 'swap_seed',
25
+ 'pause_world',
26
+ 'resume_world',
27
+ 'reset_world',
28
+ ],
29
+ };
30
+ /**
31
+ * The second world model — Reactor LongLive-v2. SAME Reactor transport as
32
+ * Helios (only the `modelName` differs on the bridge); its OWN command
33
+ * vocabulary (`set_shot`/`scene_cut`/`schedule_shot`/… — the
34
+ * {@link LongLiveCommand} variant set, not a `HeliosCommand`).
35
+ *
36
+ * ASYMMETRIC capability matrix vs Helios: LongLive is text-to-video with NO
37
+ * image conditioning, so it LACKS `swap_seed`; but it ADDS `scene_cut` (a
38
+ * hard, memory-purging transition) which Helios — a continuous morph — lacks.
39
+ * That asymmetry is exactly what `registry.satisfies` lets the Step-3 director
40
+ * UI query (hide the seed-image UI when the resolved world is LongLive).
41
+ */
42
+ // `as const satisfies` (see heliosWorldAdapter) so `.id` stays `'longlive-v2'`
43
+ // for the dispatchWorldCommand overload discrimination.
44
+ export const longLiveWorldAdapter = {
45
+ id: 'longlive-v2',
46
+ displayName: 'LongLive 2.0',
47
+ provider: 'reactor',
48
+ // 'set_scene' here is the ABSTRACT scene-steering capability (not a 1:1
49
+ // command name) — LongLive fulfills it via its `set_shot` command, where
50
+ // Helios uses `set_scene`. So satisfies(id,['set_scene']) is true for both
51
+ // adapters even though their underlying commands differ.
52
+ // NO 'swap_seed' (no image conditioning); HAS 'scene_cut' (hard transition).
53
+ // 'set_seed' (numeric noise seed, read once at start) is in supportedCommands
54
+ // but is internal session tooling — NOT a surfaced capability like Helios's
55
+ // image-based swap_seed, so it intentionally has no WorldCapability entry.
56
+ capabilities: ['world_stream', 'set_scene', 'scene_cut', 'pause_resume'],
57
+ supportedCommands: [
58
+ 'set_shot',
59
+ 'scene_cut',
60
+ 'schedule_shot',
61
+ 'schedule_scene_cut',
62
+ 'pause',
63
+ 'resume',
64
+ 'reset',
65
+ 'set_seed',
66
+ ],
67
+ };
68
+ /**
69
+ * Build a world {@link AdapterRegistry} pre-registered with the Helios seed.
70
+ * Each call returns a FRESH instance (the factory is synchronous + free) —
71
+ * callers that dispatch repeatedly should memoize one registry rather than
72
+ * rebuild it per call.
73
+ *
74
+ * Both `ROUTE_DEFAULT` and `ROUTE_FALLBACK` STAY pointed at the Helios id —
75
+ * Helios remains the WORLD default (plain `/interactive` is unchanged). The
76
+ * LongLive adapter is registered + resolvable by id (`get('longlive-v2')`)
77
+ * and by capability (`listWithCapability('scene_cut')`), but it is NOT the
78
+ * world default. The DIRECTOR registry is where LongLive becomes the default
79
+ * (see `createDirectorRegistry`). The R1a constructor guard REQUIRES the
80
+ * `fallbackRouteName` to be present by name in `routes`.
81
+ */
82
+ export function createWorldRegistry() {
83
+ const routes = [
84
+ {
85
+ name: ROUTE_DEFAULT,
86
+ adapterId: heliosWorldAdapter.id,
87
+ reason: 'Helios stays the world default (plain /interactive unchanged)',
88
+ },
89
+ {
90
+ name: ROUTE_FALLBACK,
91
+ adapterId: heliosWorldAdapter.id,
92
+ reason: 'Helios is the world fallback',
93
+ },
94
+ ];
95
+ const registry = new AdapterRegistry({
96
+ domain: 'world',
97
+ routes,
98
+ fallbackRouteName: ROUTE_FALLBACK,
99
+ });
100
+ registry.register(heliosWorldAdapter);
101
+ registry.register(longLiveWorldAdapter);
102
+ return registry;
103
+ }
104
+ /**
105
+ * Pure mapping from a world command to the {@link WorldCapability} an
106
+ * adapter must advertise to accept it. Mirrors the dispatcher's
107
+ * exhaustive-switch idiom (`reactor/heliosCommandDispatcher.ts:114-142`) so
108
+ * a new {@link HeliosCommand} variant fails to compile until mapped here.
109
+ */
110
+ export function requiredCapabilityForCommand(cmd) {
111
+ switch (cmd.type) {
112
+ case 'set_scene':
113
+ return 'set_scene';
114
+ case 'swap_seed':
115
+ return 'swap_seed';
116
+ case 'pause_world':
117
+ case 'resume_world':
118
+ return 'pause_resume';
119
+ case 'reset_world':
120
+ // 'world_stream' is used as the base/lifecycle capability here — there is
121
+ // no reset-specific WorldCapability, and any adapter that can stream a
122
+ // world can reset it. A future replay-only adapter that omits
123
+ // 'world_stream' would (correctly) be gated out of reset_world.
124
+ return 'world_stream';
125
+ default: {
126
+ // Exhaustiveness check — TS complains at compile time if a new
127
+ // HeliosCommand variant is added without mapping it here.
128
+ const _exhaustive = cmd;
129
+ throw new Error(`requiredCapabilityForCommand: unmapped world command ${JSON.stringify(_exhaustive)}`);
130
+ }
131
+ }
132
+ }
133
+ /**
134
+ * Thrown by {@link dispatchWorldCommand} when an adapter id has no real world
135
+ * transport wired (anything other than the Helios or LongLive seeds). Typed
136
+ * so callers can distinguish "no transport for this adapter" from a transient
137
+ * Reactor failure (which the underlying dispatchers swallow). Carries the
138
+ * offending `adapterId`.
139
+ */
140
+ export class UnsupportedWorldAdapterError extends Error {
141
+ adapterId;
142
+ constructor(adapterId) {
143
+ // No class-name prefix in the message — `this.name` already supplies it,
144
+ // so `error.toString()` / stack traces don't render it twice. Generic
145
+ // (no enumeration of which adapters ARE wired) so it doesn't go stale as
146
+ // sibling adapters register.
147
+ super(`World adapter "${adapterId}" has no dispatch transport wired in dispatchWorldCommand.`);
148
+ this.name = 'UnsupportedWorldAdapterError';
149
+ this.adapterId = adapterId;
150
+ }
151
+ }
152
+ export async function dispatchWorldCommand(adapterId, cmd, ctx) {
153
+ if (adapterId === heliosWorldAdapter.id) {
154
+ // Delegate to the existing dispatcher — IDENTICAL args, no rewrite.
155
+ await dispatchHeliosCommand(cmd, ctx);
156
+ }
157
+ else if (adapterId === longLiveWorldAdapter.id) {
158
+ await dispatchLongLiveCommand(cmd, ctx);
159
+ }
160
+ else {
161
+ throw new UnsupportedWorldAdapterError(adapterId);
162
+ }
163
+ }
164
+ //# sourceMappingURL=worldAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worldAdapter.js","sourceRoot":"","sources":["../../src/adapters/worldAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,GAGf,MAAM,YAAY,CAAC;AAQpB,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AA+C5E;;;;;;;;;GASG;AACH,8EAA8E;AAC9E,gFAAgF;AAChF,+EAA+E;AAC/E,6DAA6D;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,EAAE,EAAE,QAAQ;IACZ,WAAW,EAAE,QAAQ;IACrB,QAAQ,EAAE,SAAS;IACnB,YAAY,EAAE,CAAC,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,CAAC;IACxE,iBAAiB,EAAE;QACjB,WAAW;QACX,WAAW;QACX,aAAa;QACb,cAAc;QACd,aAAa;KACd;CACwC,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,+EAA+E;AAC/E,wDAAwD;AACxD,MAAM,CAAC,MAAM,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YAChB,0EAA0E;YAC1E,uEAAuE;YACvE,8DAA8D;YAC9D,gEAAgE;YAChE,OAAO,cAAc,CAAC;QACxB,OAAO,CAAC,CAAC,CAAC;YACR,+DAA+D;YAC/D,0DAA0D;YAC1D,MAAM,WAAW,GAAU,GAAG,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,wDAAwD,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CACtF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IAC5C,SAAS,CAAS;IAE3B,YAAY,SAAiB;QAC3B,yEAAyE;QACzE,sEAAsE;QACtE,yEAAyE;QACzE,6BAA6B;QAC7B,KAAK,CACH,kBAAkB,SAAS,4DAA4D,CACxF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAoCD,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,SAAiB,EACjB,GAAoC,EACpC,GAA4C;IAE5C,IAAI,SAAS,KAAK,kBAAkB,CAAC,EAAE,EAAE,CAAC;QACxC,oEAAoE;QACpE,MAAM,qBAAqB,CAAC,GAAoB,EAAE,GAAwB,CAAC,CAAC;IAC9E,CAAC;SAAM,IAAI,SAAS,KAAK,oBAAoB,CAAC,EAAE,EAAE,CAAC;QACjD,MAAM,uBAAuB,CAC3B,GAAsB,EACtB,GAA0B,CAC3B,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,4BAA4B,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;AACH,CAAC"}
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Admin control-plane client (GitHub #215 Phase 2): the prompt-defaults editor.
3
+ *
4
+ * Additive surface — a new `AdminClient` class plus its `PromptDefault*` types.
5
+ * It does NOT touch `ApiClient`'s public API (the `^0.x`-pinned external
6
+ * consumer must keep working). The admin endpoints live on the CHAT API base
7
+ * (the router is mounted in `api/chat/app.py`), so `AdminClient` is constructed
8
+ * with the chat base URL + session token, mirroring how `ApiClient` routes
9
+ * persona/chat calls through `chatRequest`.
10
+ */
11
+ /** Where a prompt's effective value comes from. Mirrors the backend enum. */
12
+ export type PromptDefaultSource = 'db' | 'code';
13
+ /** One row in the editor list: identity + source + audit metadata (no body). */
14
+ export interface PromptDefaultSummary {
15
+ promptKey: string;
16
+ label: string;
17
+ group: string;
18
+ source: PromptDefaultSource;
19
+ updatedAt: string | null;
20
+ updatedBy: string | null;
21
+ editable: boolean;
22
+ }
23
+ /** Response for `GET /api/v1/admin/prompts`. */
24
+ export interface PromptDefaultsListResponse {
25
+ prompts: PromptDefaultSummary[];
26
+ traceId: string;
27
+ }
28
+ /** Single-key detail: effective value + in-code default (for diff) + metadata. */
29
+ export interface PromptDefaultDetail {
30
+ promptKey: string;
31
+ label: string;
32
+ group: string;
33
+ source: PromptDefaultSource;
34
+ value: string;
35
+ codeDefault: string;
36
+ previousValue: string | null;
37
+ updatedAt: string | null;
38
+ updatedBy: string | null;
39
+ editable: boolean;
40
+ traceId: string;
41
+ }
42
+ /** Body for `PUT /api/v1/admin/prompts/{key}`. */
43
+ export interface UpdatePromptDefaultRequest {
44
+ value: string;
45
+ }
46
+ /**
47
+ * One read-only regeneration base prompt from `GET /api/v1/admin/regen-prompts`
48
+ * (R6d). Mirrors the backend `RegenBasePrompt` (`api/admin/schemas.py`) EXACTLY.
49
+ * These prompts are eval-gated (tuned via observability/eval promotion,
50
+ * tech-debt #336) — `editable` is always `false` and the API exposes NO write
51
+ * path for them.
52
+ */
53
+ export interface RegenBasePrompt {
54
+ promptKey: string;
55
+ label: string;
56
+ group: string;
57
+ /** Regeneration scope kind: 'acts' | 'characters' | 'scene' | 'arc'. */
58
+ scopeKind: string;
59
+ /** The in-code base prompt text, verbatim. */
60
+ prompt: string;
61
+ editable: boolean;
62
+ }
63
+ /** Response for `GET /api/v1/admin/regen-prompts` (read-only list). */
64
+ export interface RegenBasePromptsResponse {
65
+ prompts: RegenBasePrompt[];
66
+ traceId: string;
67
+ }
68
+ /**
69
+ * One scored synthetic-eval run from `GET /api/v1/admin/eval-runs` (M12 S4/S5).
70
+ *
71
+ * Mirrors the backend `EvalRunSummary` (`api/admin/schemas.py`) EXACTLY —
72
+ * same camelCase field names + nullability. The internal PK/SK/gsi1pk/gsi1sk
73
+ * storage keys are dropped server-side, so they never appear here. `metrics`
74
+ * and the optional provenance fields are always sent by the endpoint (the
75
+ * Python model merely defaults them).
76
+ */
77
+ export interface EvalRunSummary {
78
+ evalRunId: string;
79
+ benchmarkId: string;
80
+ scenarioId: string;
81
+ status: string;
82
+ createdAt: string;
83
+ metrics: Record<string, number>;
84
+ scenarioSetId: string | null;
85
+ scenarioType: string | null;
86
+ promptVersion: string | null;
87
+ pipelineVersion: string | null;
88
+ modelId: string | null;
89
+ routeName: string | null;
90
+ costTier: string | null;
91
+ latencyMs: number | null;
92
+ estimatedCostUsd: number | null;
93
+ }
94
+ /** One cursor-paginated page from `GET /api/v1/admin/eval-runs`. */
95
+ export interface EvalRunsListResponse {
96
+ runs: EvalRunSummary[];
97
+ nextCursor: string | null;
98
+ traceId: string;
99
+ }
100
+ /**
101
+ * Query params for `listEvalRuns`.
102
+ *
103
+ * The server enforces an XOR contract: provide EXACTLY ONE of `benchmarkId`
104
+ * (base-table access path) or `promptVersion` (GSI1 access path) — neither or
105
+ * both yields a 422. The client does not pre-validate; it forwards whatever is
106
+ * given.
107
+ */
108
+ export interface ListEvalRunsParams {
109
+ benchmarkId?: string;
110
+ promptVersion?: string;
111
+ limit?: number;
112
+ cursor?: string;
113
+ }
114
+ /**
115
+ * Result of `listAllEvalRuns`: the accumulated runs plus whether the page cap
116
+ * was hit. `truncated` is `true` when {@link MAX_EVAL_RUN_PAGES} was reached
117
+ * with more pages still pending — `runs` is then a newest-first PREFIX, NOT the
118
+ * full series, so the caller must warn rather than present it as complete.
119
+ */
120
+ export interface AllEvalRunsResult {
121
+ runs: EvalRunSummary[];
122
+ truncated: boolean;
123
+ }
124
+ /**
125
+ * Safety cap on `listAllEvalRuns` pagination. A misbehaving server that always
126
+ * returns a non-null `nextCursor` would otherwise loop forever; 50 pages at the
127
+ * default page limit is plenty for an admin trend view, so we stop (not throw)
128
+ * at the cap and the page renders what it has.
129
+ */
130
+ export declare const MAX_EVAL_RUN_PAGES = 50;
131
+ /**
132
+ * Client for the admin prompt-defaults CRUD surface.
133
+ *
134
+ * The auth gate is the allow-all `get_user_id` floor today (any authenticated
135
+ * user); the per-user/admin gate is deferred to the future RBAC milestone. The
136
+ * server enforces the editable-key carve-out (extraction-template keys are not
137
+ * editable) regardless — a non-editable key yields a 404, surfaced here as a
138
+ * thrown `Error`.
139
+ */
140
+ export declare class AdminClient {
141
+ private chatBaseUrl;
142
+ private sessionToken?;
143
+ constructor(chatBaseUrl: string, sessionToken?: string);
144
+ /** Update the bearer token (e.g. after a Descope session refresh). */
145
+ setSessionToken(token: string | undefined): void;
146
+ /** List every editable prompt key with its source (db|code) + audit metadata. */
147
+ listPromptDefaults(options?: {
148
+ signal?: AbortSignal;
149
+ }): Promise<PromptDefaultsListResponse>;
150
+ /** Get one key's effective value, in-code default (for diff), and metadata. */
151
+ getPromptDefault(promptKey: string, options?: {
152
+ signal?: AbortSignal;
153
+ }): Promise<PromptDefaultDetail>;
154
+ /** Create or update an override (201 on create, 200 on update server-side). */
155
+ updatePromptDefault(promptKey: string, body: UpdatePromptDefaultRequest, options?: {
156
+ signal?: AbortSignal;
157
+ }): Promise<PromptDefaultDetail>;
158
+ /** One-step revert: restores the previous value, else the in-code default. */
159
+ revertPromptDefault(promptKey: string, options?: {
160
+ signal?: AbortSignal;
161
+ }): Promise<PromptDefaultDetail>;
162
+ /**
163
+ * List the AI-tuned regeneration base prompts (acts/characters/scene/arc),
164
+ * READ-ONLY (R6d). There is no corresponding write method — the backend
165
+ * exposes no PUT/POST for these prompts; they are tuned via the eval-gated
166
+ * promotion (tech-debt #336), never the admin editor.
167
+ */
168
+ listRegenBasePrompts(options?: {
169
+ signal?: AbortSignal;
170
+ }): Promise<RegenBasePromptsResponse>;
171
+ /**
172
+ * Fetch one cursor-paginated page of scored synthetic-eval runs (M12 S5).
173
+ *
174
+ * The server enforces the XOR contract — EXACTLY ONE of `benchmarkId` or
175
+ * `promptVersion` (neither/both → 422). This client does NOT pre-validate; it
176
+ * forwards the params as given and lets `requestJson` surface a 422 as a
177
+ * thrown `Error`. Only defined params are appended to the query string.
178
+ */
179
+ listEvalRuns(params: ListEvalRunsParams, options?: {
180
+ signal?: AbortSignal;
181
+ }): Promise<EvalRunsListResponse>;
182
+ /**
183
+ * Page through ALL eval runs for the given selector, newest-first.
184
+ *
185
+ * Follows `nextCursor` until it is `null`, accumulating runs. Stops (does NOT
186
+ * throw) at {@link MAX_EVAL_RUN_PAGES} so a misbehaving server — or simply a
187
+ * benchmark with more history than the cap covers — cannot spin forever. When
188
+ * the cap is hit with pages still pending, the returned `runs` is a
189
+ * newest-first PREFIX and `truncated` is `true`, so the caller can warn rather
190
+ * than present a partial series as complete (the `/observability` page does).
191
+ * The caller's `params` are never mutated (the cursor lives in a local). Any
192
+ * `params.cursor` is IGNORED — "list ALL" always starts from the newest page,
193
+ * so a stray cursor can't silently begin mid-series. Honors `options.signal`
194
+ * on every page request.
195
+ */
196
+ listAllEvalRuns(params: ListEvalRunsParams, options?: {
197
+ signal?: AbortSignal;
198
+ }): Promise<AllEvalRunsResult>;
199
+ }
200
+ //# sourceMappingURL=admin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,6EAA6E;AAC7E,MAAM,MAAM,mBAAmB,GAAG,IAAI,GAAG,MAAM,CAAC;AAEhD,gFAAgF;AAChF,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EA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
+ *
4
+ * Additive surface — a new `AdminClient` class plus its `PromptDefault*` types.
5
+ * It does NOT touch `ApiClient`'s public API (the `^0.x`-pinned external
6
+ * consumer must keep working). The admin endpoints live on the CHAT API base
7
+ * (the router is mounted in `api/chat/app.py`), so `AdminClient` is constructed
8
+ * with the chat base URL + session token, mirroring how `ApiClient` routes
9
+ * persona/chat calls through `chatRequest`.
10
+ */
11
+ import { requestJson } from './http.js';
12
+ const ADMIN_PROMPTS_PATH = '/api/v1/admin/prompts';
13
+ const ADMIN_EVAL_RUNS_PATH = '/api/v1/admin/eval-runs';
14
+ const ADMIN_REGEN_PROMPTS_PATH = '/api/v1/admin/regen-prompts';
15
+ /**
16
+ * Safety cap on `listAllEvalRuns` pagination. A misbehaving server that always
17
+ * returns a non-null `nextCursor` would otherwise loop forever; 50 pages at the
18
+ * default page limit is plenty for an admin trend view, so we stop (not throw)
19
+ * at the cap and the page renders what it has.
20
+ */
21
+ export const MAX_EVAL_RUN_PAGES = 50;
22
+ /**
23
+ * Client for the admin prompt-defaults CRUD surface.
24
+ *
25
+ * The auth gate is the allow-all `get_user_id` floor today (any authenticated
26
+ * user); the per-user/admin gate is deferred to the future RBAC milestone. The
27
+ * server enforces the editable-key carve-out (extraction-template keys are not
28
+ * editable) regardless — a non-editable key yields a 404, surfaced here as a
29
+ * thrown `Error`.
30
+ */
31
+ export class AdminClient {
32
+ chatBaseUrl;
33
+ sessionToken;
34
+ constructor(chatBaseUrl, sessionToken) {
35
+ this.chatBaseUrl = chatBaseUrl;
36
+ this.sessionToken = sessionToken;
37
+ }
38
+ /** Update the bearer token (e.g. after a Descope session refresh). */
39
+ setSessionToken(token) {
40
+ this.sessionToken = token;
41
+ }
42
+ /** List every editable prompt key with its source (db|code) + audit metadata. */
43
+ async listPromptDefaults(options = {}) {
44
+ return requestJson(this.chatBaseUrl, ADMIN_PROMPTS_PATH, this.sessionToken, { signal: options.signal });
45
+ }
46
+ /** Get one key's effective value, in-code default (for diff), and metadata. */
47
+ async getPromptDefault(promptKey, options = {}) {
48
+ return requestJson(this.chatBaseUrl, `${ADMIN_PROMPTS_PATH}/${encodeURIComponent(promptKey)}`, this.sessionToken, { signal: options.signal });
49
+ }
50
+ /** Create or update an override (201 on create, 200 on update server-side). */
51
+ async updatePromptDefault(promptKey, body, options = {}) {
52
+ return requestJson(this.chatBaseUrl, `${ADMIN_PROMPTS_PATH}/${encodeURIComponent(promptKey)}`, this.sessionToken, { method: 'PUT', body: JSON.stringify(body), signal: options.signal });
53
+ }
54
+ /** One-step revert: restores the previous value, else the in-code default. */
55
+ async revertPromptDefault(promptKey, options = {}) {
56
+ return requestJson(this.chatBaseUrl, `${ADMIN_PROMPTS_PATH}/${encodeURIComponent(promptKey)}/revert`, this.sessionToken, { method: 'POST', signal: options.signal });
57
+ }
58
+ /**
59
+ * List the AI-tuned regeneration base prompts (acts/characters/scene/arc),
60
+ * READ-ONLY (R6d). There is no corresponding write method — the backend
61
+ * exposes no PUT/POST for these prompts; they are tuned via the eval-gated
62
+ * promotion (tech-debt #336), never the admin editor.
63
+ */
64
+ async listRegenBasePrompts(options = {}) {
65
+ return requestJson(this.chatBaseUrl, ADMIN_REGEN_PROMPTS_PATH, this.sessionToken, { signal: options.signal });
66
+ }
67
+ /**
68
+ * Fetch one cursor-paginated page of scored synthetic-eval runs (M12 S5).
69
+ *
70
+ * The server enforces the XOR contract — EXACTLY ONE of `benchmarkId` or
71
+ * `promptVersion` (neither/both → 422). This client does NOT pre-validate; it
72
+ * forwards the params as given and lets `requestJson` surface a 422 as a
73
+ * thrown `Error`. Only defined params are appended to the query string.
74
+ */
75
+ async listEvalRuns(params, options = {}) {
76
+ const search = new URLSearchParams();
77
+ if (params.benchmarkId !== undefined) {
78
+ search.set('benchmarkId', params.benchmarkId);
79
+ }
80
+ if (params.promptVersion !== undefined) {
81
+ search.set('promptVersion', params.promptVersion);
82
+ }
83
+ if (params.limit !== undefined) {
84
+ search.set('limit', String(params.limit));
85
+ }
86
+ if (params.cursor !== undefined) {
87
+ search.set('cursor', params.cursor);
88
+ }
89
+ const qs = search.toString();
90
+ const path = qs ? `${ADMIN_EVAL_RUNS_PATH}?${qs}` : ADMIN_EVAL_RUNS_PATH;
91
+ return requestJson(this.chatBaseUrl, path, this.sessionToken, { signal: options.signal });
92
+ }
93
+ /**
94
+ * Page through ALL eval runs for the given selector, newest-first.
95
+ *
96
+ * Follows `nextCursor` until it is `null`, accumulating runs. Stops (does NOT
97
+ * throw) at {@link MAX_EVAL_RUN_PAGES} so a misbehaving server — or simply a
98
+ * benchmark with more history than the cap covers — cannot spin forever. When
99
+ * the cap is hit with pages still pending, the returned `runs` is a
100
+ * newest-first PREFIX and `truncated` is `true`, so the caller can warn rather
101
+ * than present a partial series as complete (the `/observability` page does).
102
+ * The caller's `params` are never mutated (the cursor lives in a local). Any
103
+ * `params.cursor` is IGNORED — "list ALL" always starts from the newest page,
104
+ * so a stray cursor can't silently begin mid-series. Honors `options.signal`
105
+ * on every page request.
106
+ */
107
+ async listAllEvalRuns(params, options = {}) {
108
+ const runs = [];
109
+ // Start at the newest page regardless of any caller-supplied params.cursor —
110
+ // mid-series start would silently return a truncated history.
111
+ let cursor = undefined;
112
+ for (let page = 0; page < MAX_EVAL_RUN_PAGES; page += 1) {
113
+ const response = await this.listEvalRuns({ ...params, cursor }, options);
114
+ runs.push(...response.runs);
115
+ if (response.nextCursor === null) {
116
+ return { runs, truncated: false };
117
+ }
118
+ cursor = response.nextCursor;
119
+ }
120
+ // Exhausted the page cap with a non-null cursor still pending — partial.
121
+ return { runs, truncated: true };
122
+ }
123
+ }
124
+ //# sourceMappingURL=admin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.js","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AA8HrC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AACnD,MAAM,oBAAoB,GAAG,yBAAyB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