@escapeaihq/client-core 0.8.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -4
- package/dist/adapters/capabilities.d.ts +10 -0
- package/dist/adapters/capabilities.d.ts.map +1 -0
- package/dist/adapters/capabilities.js +2 -0
- package/dist/adapters/capabilities.js.map +1 -0
- package/dist/adapters/chatAdapter.d.ts +38 -0
- package/dist/adapters/chatAdapter.d.ts.map +1 -0
- package/dist/adapters/chatAdapter.js +88 -0
- package/dist/adapters/chatAdapter.js.map +1 -0
- package/dist/adapters/directorAdapter.d.ts +62 -0
- package/dist/adapters/directorAdapter.d.ts.map +1 -0
- package/dist/adapters/directorAdapter.js +71 -0
- package/dist/adapters/directorAdapter.js.map +1 -0
- package/dist/adapters/imageAdapter.d.ts +44 -0
- package/dist/adapters/imageAdapter.d.ts.map +1 -0
- package/dist/adapters/imageAdapter.js +73 -0
- package/dist/adapters/imageAdapter.js.map +1 -0
- package/dist/adapters/index.d.ts +47 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +41 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/registry.d.ts +98 -0
- package/dist/adapters/registry.d.ts.map +1 -0
- package/dist/adapters/registry.js +106 -0
- package/dist/adapters/registry.js.map +1 -0
- package/dist/adapters/worldAdapter.d.ts +142 -0
- package/dist/adapters/worldAdapter.d.ts.map +1 -0
- package/dist/adapters/worldAdapter.js +164 -0
- package/dist/adapters/worldAdapter.js.map +1 -0
- package/dist/admin.d.ts +200 -0
- package/dist/admin.d.ts.map +1 -0
- package/dist/admin.js +124 -0
- package/dist/admin.js.map +1 -0
- package/dist/api.d.ts +1299 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +683 -95
- package/dist/api.js.map +1 -1
- package/dist/audio.d.ts +33 -1
- package/dist/audio.d.ts.map +1 -1
- package/dist/audio.js +4 -1
- package/dist/audio.js.map +1 -1
- package/dist/castProjection.d.ts +35 -0
- package/dist/castProjection.d.ts.map +1 -0
- package/dist/castProjection.js +80 -0
- package/dist/castProjection.js.map +1 -0
- package/dist/conversation/binding.d.ts +62 -0
- package/dist/conversation/binding.d.ts.map +1 -0
- package/dist/conversation/binding.js +51 -0
- package/dist/conversation/binding.js.map +1 -0
- package/dist/conversation/controller.d.ts +209 -0
- package/dist/conversation/controller.d.ts.map +1 -0
- package/dist/conversation/controller.js +342 -0
- package/dist/conversation/controller.js.map +1 -0
- package/dist/conversation/effectiveModel.d.ts +62 -0
- package/dist/conversation/effectiveModel.d.ts.map +1 -0
- package/dist/conversation/effectiveModel.js +73 -0
- package/dist/conversation/effectiveModel.js.map +1 -0
- package/dist/conversation/index.d.ts +27 -0
- package/dist/conversation/index.d.ts.map +1 -0
- package/dist/conversation/index.js +27 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/conversation/participant.d.ts +66 -0
- package/dist/conversation/participant.d.ts.map +1 -0
- package/dist/conversation/participant.js +36 -0
- package/dist/conversation/participant.js.map +1 -0
- package/dist/conversation/presence.d.ts +56 -0
- package/dist/conversation/presence.d.ts.map +1 -0
- package/dist/conversation/presence.js +34 -0
- package/dist/conversation/presence.js.map +1 -0
- package/dist/conversation/presenceBus.d.ts +42 -0
- package/dist/conversation/presenceBus.d.ts.map +1 -0
- package/dist/conversation/presenceBus.js +81 -0
- package/dist/conversation/presenceBus.js.map +1 -0
- package/dist/conversation/presenceRegistry.d.ts +49 -0
- package/dist/conversation/presenceRegistry.d.ts.map +1 -0
- package/dist/conversation/presenceRegistry.js +59 -0
- package/dist/conversation/presenceRegistry.js.map +1 -0
- package/dist/conversation/roster.d.ts +72 -0
- package/dist/conversation/roster.d.ts.map +1 -0
- package/dist/conversation/roster.js +69 -0
- package/dist/conversation/roster.js.map +1 -0
- package/dist/conversation/rosterProjection.d.ts +52 -0
- package/dist/conversation/rosterProjection.d.ts.map +1 -0
- package/dist/conversation/rosterProjection.js +74 -0
- package/dist/conversation/rosterProjection.js.map +1 -0
- package/dist/conversation/router.d.ts +74 -0
- package/dist/conversation/router.d.ts.map +1 -0
- package/dist/conversation/router.js +58 -0
- package/dist/conversation/router.js.map +1 -0
- package/dist/conversation/runtime.d.ts +64 -0
- package/dist/conversation/runtime.d.ts.map +1 -0
- package/dist/conversation/runtime.js +172 -0
- package/dist/conversation/runtime.js.map +1 -0
- package/dist/conversation/types.d.ts +99 -0
- package/dist/conversation/types.d.ts.map +1 -0
- package/dist/conversation/types.js +13 -0
- package/dist/conversation/types.js.map +1 -0
- package/dist/conversation/voice.d.ts +185 -0
- package/dist/conversation/voice.d.ts.map +1 -0
- package/dist/conversation/voice.js +307 -0
- package/dist/conversation/voice.js.map +1 -0
- package/dist/graphSchema.d.ts +260 -0
- package/dist/graphSchema.d.ts.map +1 -0
- package/dist/graphSchema.js +354 -0
- package/dist/graphSchema.js.map +1 -0
- package/dist/http.d.ts +20 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +57 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/platformAssistant.d.ts +155 -0
- package/dist/platformAssistant.d.ts.map +1 -0
- package/dist/platformAssistant.js +256 -0
- package/dist/platformAssistant.js.map +1 -0
- package/dist/reactor/abortUtils.d.ts +16 -0
- package/dist/reactor/abortUtils.d.ts.map +1 -0
- package/dist/reactor/abortUtils.js +26 -0
- package/dist/reactor/abortUtils.js.map +1 -0
- package/dist/reactor/applyScenePrompt.d.ts +75 -0
- package/dist/reactor/applyScenePrompt.d.ts.map +1 -0
- package/dist/reactor/applyScenePrompt.js +60 -0
- package/dist/reactor/applyScenePrompt.js.map +1 -0
- package/dist/reactor/chunkDistribution.d.ts +43 -0
- package/dist/reactor/chunkDistribution.d.ts.map +1 -0
- package/dist/reactor/chunkDistribution.js +85 -0
- package/dist/reactor/chunkDistribution.js.map +1 -0
- package/dist/reactor/heliosCommandDispatcher.d.ts.map +1 -1
- package/dist/reactor/heliosCommandDispatcher.js +10 -15
- package/dist/reactor/heliosCommandDispatcher.js.map +1 -1
- package/dist/reactor/index.d.ts +4 -0
- package/dist/reactor/index.d.ts.map +1 -1
- package/dist/reactor/index.js +7 -0
- package/dist/reactor/index.js.map +1 -1
- package/dist/reactor/longLiveCommandDispatcher.d.ts +103 -0
- package/dist/reactor/longLiveCommandDispatcher.d.ts.map +1 -0
- package/dist/reactor/longLiveCommandDispatcher.js +87 -0
- package/dist/reactor/longLiveCommandDispatcher.js.map +1 -0
- package/dist/reactor/sceneEntry.d.ts +40 -6
- package/dist/reactor/sceneEntry.d.ts.map +1 -1
- package/dist/reactor/sceneEntry.js +63 -24
- package/dist/reactor/sceneEntry.js.map +1 -1
- package/dist/reactor/scenesFromEnrichment.d.ts.map +1 -1
- package/dist/reactor/scenesFromEnrichment.js +2 -66
- package/dist/reactor/scenesFromEnrichment.js.map +1 -1
- package/dist/reactor/seedImageOrchestrator.d.ts +42 -2
- package/dist/reactor/seedImageOrchestrator.d.ts.map +1 -1
- package/dist/reactor/seedImageOrchestrator.js +173 -4
- package/dist/reactor/seedImageOrchestrator.js.map +1 -1
- package/dist/reactor/storyTimeline.d.ts +44 -0
- package/dist/reactor/storyTimeline.d.ts.map +1 -0
- package/dist/reactor/storyTimeline.js +95 -0
- package/dist/reactor/storyTimeline.js.map +1 -0
- package/dist/storyGraph.d.ts +70 -0
- package/dist/storyGraph.d.ts.map +1 -0
- package/dist/storyGraph.js +178 -0
- package/dist/storyGraph.js.map +1 -0
- package/dist/timeFormat.d.ts +10 -0
- package/dist/timeFormat.d.ts.map +1 -1
- package/dist/timeFormat.js +12 -0
- package/dist/timeFormat.js.map +1 -1
- package/dist/toolSchemas.d.ts +370 -0
- package/dist/toolSchemas.d.ts.map +1 -0
- package/dist/toolSchemas.js +182 -0
- package/dist/toolSchemas.js.map +1 -0
- package/dist/vision/VisionPublisher.d.ts +115 -0
- package/dist/vision/VisionPublisher.d.ts.map +1 -0
- package/dist/vision/VisionPublisher.js +475 -0
- package/dist/vision/VisionPublisher.js.map +1 -0
- package/dist/vision/VisionSourceController.d.ts +127 -0
- package/dist/vision/VisionSourceController.d.ts.map +1 -0
- package/dist/vision/VisionSourceController.js +284 -0
- package/dist/vision/VisionSourceController.js.map +1 -0
- package/dist/vision/credentials.d.ts +22 -0
- package/dist/vision/credentials.d.ts.map +1 -0
- package/dist/vision/credentials.js +34 -0
- package/dist/vision/credentials.js.map +1 -0
- package/dist/vision/index.d.ts +18 -0
- package/dist/vision/index.d.ts.map +1 -0
- package/dist/vision/index.js +13 -0
- package/dist/vision/index.js.map +1 -0
- package/dist/vision/sourceKinds.d.ts +65 -0
- package/dist/vision/sourceKinds.d.ts.map +1 -0
- package/dist/vision/sourceKinds.js +26 -0
- package/dist/vision/sourceKinds.js.map +1 -0
- package/dist/vision/startVisionPublisher.d.ts +38 -0
- package/dist/vision/startVisionPublisher.d.ts.map +1 -0
- package/dist/vision/startVisionPublisher.js +44 -0
- package/dist/vision/startVisionPublisher.js.map +1 -0
- package/dist/vision/types.d.ts +95 -0
- package/dist/vision/types.d.ts.map +1 -0
- package/dist/vision/types.js +12 -0
- package/dist/vision/types.js.map +1 -0
- package/dist/vision/visionScheduler.d.ts +63 -0
- package/dist/vision/visionScheduler.d.ts.map +1 -0
- package/dist/vision/visionScheduler.js +67 -0
- package/dist/vision/visionScheduler.js.map +1 -0
- package/dist/websocket.d.ts +195 -0
- package/dist/websocket.d.ts.map +1 -1
- package/dist/websocket.js +179 -1
- package/dist/websocket.js.map +1 -1
- package/package.json +11 -1
- package/src/__tests__/adapters-capabilities.test.ts +46 -0
- package/src/__tests__/adapters-chat.test.ts +172 -0
- package/src/__tests__/adapters-director.test.ts +95 -0
- package/src/__tests__/adapters-image.test.ts +133 -0
- package/src/__tests__/adapters-platform.test.ts +95 -0
- package/src/__tests__/adapters-registry.test.ts +189 -0
- package/src/__tests__/adapters-world.test.ts +296 -0
- package/src/__tests__/admin.test.ts +312 -0
- package/src/__tests__/adventures-party.test.ts +219 -0
- package/src/__tests__/adventures.test.ts +282 -0
- package/src/__tests__/api-pollers.test.ts +104 -0
- package/src/__tests__/api.clip-lookup.test.ts +64 -0
- package/src/__tests__/api.list-images-filters.test.ts +103 -0
- package/src/__tests__/api.test.ts +470 -0
- package/src/__tests__/audio.test.ts +65 -0
- package/src/__tests__/cast.test.ts +95 -0
- package/src/__tests__/castProjection.test.ts +167 -0
- package/src/__tests__/chat-auth.test.ts +91 -0
- package/src/__tests__/conversation/controller.test.ts +697 -0
- package/src/__tests__/conversation/effectiveModel.test.ts +169 -0
- package/src/__tests__/conversation/headlessRenderer.ts +46 -0
- package/src/__tests__/conversation/presenceBus.test.ts +236 -0
- package/src/__tests__/conversation/presenceRegistry.test.ts +73 -0
- package/src/__tests__/conversation/roster.test.ts +100 -0
- package/src/__tests__/conversation/rosterProjection.test.ts +142 -0
- package/src/__tests__/conversation/router.test.ts +81 -0
- package/src/__tests__/conversation/runtime.test.ts +206 -0
- package/src/__tests__/conversation/voice.test.ts +440 -0
- package/src/__tests__/documents.test.ts +360 -0
- package/src/__tests__/graphSchema.test.ts +326 -0
- package/src/__tests__/longLiveCommandDispatcher.test.ts +185 -0
- package/src/__tests__/platformAssistant.test.ts +484 -0
- package/src/__tests__/reactor/applyScenePrompt.test.ts +192 -0
- package/src/__tests__/reactor/heliosCommandDispatcher.test.ts +4 -3
- package/src/__tests__/reactor/sceneEntry.test.ts +134 -10
- package/src/__tests__/reactor/seedImageOrchestrator.test.ts +51 -16
- package/src/__tests__/reactor/storyTimeline.test.ts +186 -0
- package/src/__tests__/regeneration.test.ts +486 -0
- package/src/__tests__/stories.test.ts +171 -0
- package/src/__tests__/storyGraph.test.ts +134 -0
- package/src/__tests__/timeFormat.test.ts +22 -1
- package/src/__tests__/toolSchemas.test.ts +57 -0
- package/src/__tests__/tools-wrappers.test.ts +272 -0
- package/src/__tests__/videoGraph.test.ts +94 -0
- package/src/__tests__/websocket-vision.test.ts +265 -0
- package/src/__tests__/websocket.test.ts +213 -0
- package/src/adapters/capabilities.ts +24 -0
- package/src/adapters/chatAdapter.ts +114 -0
- package/src/adapters/directorAdapter.ts +126 -0
- package/src/adapters/imageAdapter.ts +100 -0
- package/src/adapters/index.ts +67 -0
- package/src/adapters/registry.ts +159 -0
- package/src/adapters/worldAdapter.ts +272 -0
- package/src/admin.ts +310 -0
- package/src/api.ts +1890 -162
- package/src/audio.ts +35 -0
- package/src/castProjection.ts +95 -0
- package/src/conversation/binding.ts +81 -0
- package/src/conversation/controller.ts +439 -0
- package/src/conversation/effectiveModel.ts +111 -0
- package/src/conversation/index.ts +27 -0
- package/src/conversation/participant.ts +71 -0
- package/src/conversation/presence.ts +60 -0
- package/src/conversation/presenceBus.ts +109 -0
- package/src/conversation/presenceRegistry.ts +83 -0
- package/src/conversation/roster.ts +111 -0
- package/src/conversation/rosterProjection.ts +98 -0
- package/src/conversation/router.ts +96 -0
- package/src/conversation/runtime.ts +188 -0
- package/src/conversation/types.ts +100 -0
- package/src/conversation/voice.ts +402 -0
- package/src/graphSchema.ts +532 -0
- package/src/http.ts +72 -0
- package/src/index.ts +12 -0
- package/src/platformAssistant.ts +347 -0
- package/src/reactor/abortUtils.ts +22 -0
- package/src/reactor/applyScenePrompt.ts +136 -0
- package/src/reactor/chunkDistribution.ts +98 -0
- package/src/reactor/heliosCommandDispatcher.ts +10 -18
- package/src/reactor/index.ts +7 -0
- package/src/reactor/longLiveCommandDispatcher.ts +156 -0
- package/src/reactor/sceneEntry.ts +104 -33
- package/src/reactor/scenesFromEnrichment.ts +11 -76
- package/src/reactor/seedImageOrchestrator.ts +200 -4
- package/src/reactor/storyTimeline.ts +127 -0
- package/src/storyGraph.ts +298 -0
- package/src/timeFormat.ts +13 -0
- package/src/toolSchemas.ts +225 -0
- package/src/vision/VisionPublisher.ts +553 -0
- package/src/vision/VisionSourceController.ts +354 -0
- package/src/vision/__tests__/VisionPublisher.kvs.test.ts +244 -0
- package/src/vision/__tests__/VisionPublisher.test.ts +301 -0
- package/src/vision/__tests__/VisionSourceController.test.ts +719 -0
- package/src/vision/__tests__/startVisionPublisher.test.ts +251 -0
- package/src/vision/__tests__/toVisionRtcCredentials.test.ts +113 -0
- package/src/vision/__tests__/visionScheduler.test.ts +149 -0
- package/src/vision/credentials.ts +39 -0
- package/src/vision/index.ts +44 -0
- package/src/vision/sourceKinds.ts +75 -0
- package/src/vision/startVisionPublisher.ts +64 -0
- package/src/vision/types.ts +101 -0
- package/src/vision/visionScheduler.ts +102 -0
- package/src/websocket.ts +334 -4
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AdapterRegistry,
|
|
3
|
+
ROUTE_DEFAULT,
|
|
4
|
+
ROUTE_FALLBACK,
|
|
5
|
+
type NamedRoute,
|
|
6
|
+
type ModelAdapterDescriptor,
|
|
7
|
+
} from './registry';
|
|
8
|
+
import type { WorldCapability } from './capabilities';
|
|
9
|
+
import type {
|
|
10
|
+
HeliosCommand,
|
|
11
|
+
HeliosToolContext,
|
|
12
|
+
LongLiveCommand,
|
|
13
|
+
LongLiveToolContext,
|
|
14
|
+
} from '../reactor';
|
|
15
|
+
import { dispatchHeliosCommand, dispatchLongLiveCommand } from '../reactor';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* World-domain (step-into-video) adapter registry — R1d, Helios seed.
|
|
19
|
+
*
|
|
20
|
+
* This is a capability GATE in FRONT of the existing, working Helios
|
|
21
|
+
* machinery, NOT a rewrite. Today the live `/interactive` pages dispatch
|
|
22
|
+
* through {@link dispatchHeliosCommand} against a structural
|
|
23
|
+
* `HeliosReactorBridge`; the `modelName="helios"` literal is hard-coded in
|
|
24
|
+
* those React pages. R1d wraps that one model behind a
|
|
25
|
+
* {@link WorldAdapterDescriptor} + {@link AdapterRegistry} so later waves
|
|
26
|
+
* (R7 flagship DM, R8 Director/Interactive rewire) can register sibling
|
|
27
|
+
* adapters and swap them. The 'helios' model-name literal is CENTRALIZED
|
|
28
|
+
* here so the R8 rewire stops hard-coding it in the pages.
|
|
29
|
+
*
|
|
30
|
+
* LAND-DARK: the live Helios path is UNCHANGED. {@link dispatchWorldCommand}
|
|
31
|
+
* only gates in front of {@link dispatchHeliosCommand} and delegates with
|
|
32
|
+
* IDENTICAL arguments. The adapters/ submodule stays SDK-free — it reuses
|
|
33
|
+
* the structural `HeliosReactorBridge` via {@link HeliosToolContext} and
|
|
34
|
+
* takes NO `@reactor-team/js-sdk` dependency.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A world adapter descriptor — a {@link ModelAdapterDescriptor} that also
|
|
39
|
+
* declares the world commands it accepts. `supportedCommands` is deliberately
|
|
40
|
+
* `readonly string[]` (model-agnostic), NOT locked to the {@link HeliosCommand}
|
|
41
|
+
* variant set: the registry's purpose is to hold heterogeneous world models,
|
|
42
|
+
* and a sibling model (e.g. a Reactor LongLive adapter) has its OWN command
|
|
43
|
+
* vocabulary (`set_shot`/`scene_cut`/`schedule_shot`/…) that is not a
|
|
44
|
+
* `HeliosCommand`. Each adapter declares its own command strings here; the
|
|
45
|
+
* Helios seed below declares the `HeliosCommand` variant names.
|
|
46
|
+
*/
|
|
47
|
+
export interface WorldAdapterDescriptor extends ModelAdapterDescriptor {
|
|
48
|
+
/**
|
|
49
|
+
* The world commands this adapter accepts (each model's own vocabulary).
|
|
50
|
+
*
|
|
51
|
+
* Distinct axis from the inherited `capabilities`: `capabilities` (e.g.
|
|
52
|
+
* `'world_stream'`/`'pause_resume'`) is the **registry** axis that
|
|
53
|
+
* `listWithCapability`/`satisfies` filter and gate on; `supportedCommands`
|
|
54
|
+
* (e.g. `'set_scene'`/`'reset_world'`) is **advisory metadata** naming the
|
|
55
|
+
* command strings the adapter's dispatcher understands. The dispatch gate
|
|
56
|
+
* routes on `id` + (when a 2nd adapter lands) `capabilities`, NOT on this
|
|
57
|
+
* array.
|
|
58
|
+
*/
|
|
59
|
+
supportedCommands: readonly string[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The one world model that exists today. Helios drives the live
|
|
64
|
+
* step-into-video stream over the structural Reactor bridge. Its
|
|
65
|
+
* `supportedCommands` is the EXACT {@link HeliosCommand} variant set
|
|
66
|
+
* (`reactor/heliosTools.ts:32-37`).
|
|
67
|
+
*
|
|
68
|
+
* The 'helios' id is the single source of truth for the model name — the
|
|
69
|
+
* R8 rewire reads it from here instead of re-spelling the literal in the
|
|
70
|
+
* `/interactive` pages.
|
|
71
|
+
*/
|
|
72
|
+
// `as const satisfies` (NOT a `: WorldAdapterDescriptor` annotation) so `.id`
|
|
73
|
+
// keeps its literal type `'helios'` — `dispatchWorldCommand`'s overloads key on
|
|
74
|
+
// `typeof heliosWorldAdapter.id`, which would widen to `string` (defeating the
|
|
75
|
+
// cmd/adapter discrimination) under a plain type annotation.
|
|
76
|
+
export const heliosWorldAdapter = {
|
|
77
|
+
id: 'helios',
|
|
78
|
+
displayName: 'Helios',
|
|
79
|
+
provider: 'reactor',
|
|
80
|
+
capabilities: ['world_stream', 'set_scene', 'swap_seed', 'pause_resume'],
|
|
81
|
+
supportedCommands: [
|
|
82
|
+
'set_scene',
|
|
83
|
+
'swap_seed',
|
|
84
|
+
'pause_world',
|
|
85
|
+
'resume_world',
|
|
86
|
+
'reset_world',
|
|
87
|
+
],
|
|
88
|
+
} as const satisfies WorldAdapterDescriptor;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The second world model — Reactor LongLive-v2. SAME Reactor transport as
|
|
92
|
+
* Helios (only the `modelName` differs on the bridge); its OWN command
|
|
93
|
+
* vocabulary (`set_shot`/`scene_cut`/`schedule_shot`/… — the
|
|
94
|
+
* {@link LongLiveCommand} variant set, not a `HeliosCommand`).
|
|
95
|
+
*
|
|
96
|
+
* ASYMMETRIC capability matrix vs Helios: LongLive is text-to-video with NO
|
|
97
|
+
* image conditioning, so it LACKS `swap_seed`; but it ADDS `scene_cut` (a
|
|
98
|
+
* hard, memory-purging transition) which Helios — a continuous morph — lacks.
|
|
99
|
+
* That asymmetry is exactly what `registry.satisfies` lets the Step-3 director
|
|
100
|
+
* UI query (hide the seed-image UI when the resolved world is LongLive).
|
|
101
|
+
*/
|
|
102
|
+
// `as const satisfies` (see heliosWorldAdapter) so `.id` stays `'longlive-v2'`
|
|
103
|
+
// for the dispatchWorldCommand overload discrimination.
|
|
104
|
+
export const longLiveWorldAdapter = {
|
|
105
|
+
id: 'longlive-v2',
|
|
106
|
+
displayName: 'LongLive 2.0',
|
|
107
|
+
provider: 'reactor',
|
|
108
|
+
// 'set_scene' here is the ABSTRACT scene-steering capability (not a 1:1
|
|
109
|
+
// command name) — LongLive fulfills it via its `set_shot` command, where
|
|
110
|
+
// Helios uses `set_scene`. So satisfies(id,['set_scene']) is true for both
|
|
111
|
+
// adapters even though their underlying commands differ.
|
|
112
|
+
// NO 'swap_seed' (no image conditioning); HAS 'scene_cut' (hard transition).
|
|
113
|
+
// 'set_seed' (numeric noise seed, read once at start) is in supportedCommands
|
|
114
|
+
// but is internal session tooling — NOT a surfaced capability like Helios's
|
|
115
|
+
// image-based swap_seed, so it intentionally has no WorldCapability entry.
|
|
116
|
+
capabilities: ['world_stream', 'set_scene', 'scene_cut', 'pause_resume'],
|
|
117
|
+
supportedCommands: [
|
|
118
|
+
'set_shot',
|
|
119
|
+
'scene_cut',
|
|
120
|
+
'schedule_shot',
|
|
121
|
+
'schedule_scene_cut',
|
|
122
|
+
'pause',
|
|
123
|
+
'resume',
|
|
124
|
+
'reset',
|
|
125
|
+
'set_seed',
|
|
126
|
+
],
|
|
127
|
+
} as const satisfies WorldAdapterDescriptor;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Build a world {@link AdapterRegistry} pre-registered with the Helios seed.
|
|
131
|
+
* Each call returns a FRESH instance (the factory is synchronous + free) —
|
|
132
|
+
* callers that dispatch repeatedly should memoize one registry rather than
|
|
133
|
+
* rebuild it per call.
|
|
134
|
+
*
|
|
135
|
+
* Both `ROUTE_DEFAULT` and `ROUTE_FALLBACK` STAY pointed at the Helios id —
|
|
136
|
+
* Helios remains the WORLD default (plain `/interactive` is unchanged). The
|
|
137
|
+
* LongLive adapter is registered + resolvable by id (`get('longlive-v2')`)
|
|
138
|
+
* and by capability (`listWithCapability('scene_cut')`), but it is NOT the
|
|
139
|
+
* world default. The DIRECTOR registry is where LongLive becomes the default
|
|
140
|
+
* (see `createDirectorRegistry`). The R1a constructor guard REQUIRES the
|
|
141
|
+
* `fallbackRouteName` to be present by name in `routes`.
|
|
142
|
+
*/
|
|
143
|
+
export function createWorldRegistry(): AdapterRegistry<WorldAdapterDescriptor> {
|
|
144
|
+
const routes: NamedRoute[] = [
|
|
145
|
+
{
|
|
146
|
+
name: ROUTE_DEFAULT,
|
|
147
|
+
adapterId: heliosWorldAdapter.id,
|
|
148
|
+
reason: 'Helios stays the world default (plain /interactive unchanged)',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: ROUTE_FALLBACK,
|
|
152
|
+
adapterId: heliosWorldAdapter.id,
|
|
153
|
+
reason: 'Helios is the world fallback',
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
|
|
157
|
+
const registry = new AdapterRegistry<WorldAdapterDescriptor>({
|
|
158
|
+
domain: 'world',
|
|
159
|
+
routes,
|
|
160
|
+
fallbackRouteName: ROUTE_FALLBACK,
|
|
161
|
+
});
|
|
162
|
+
registry.register(heliosWorldAdapter);
|
|
163
|
+
registry.register(longLiveWorldAdapter);
|
|
164
|
+
return registry;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Pure mapping from a world command to the {@link WorldCapability} an
|
|
169
|
+
* adapter must advertise to accept it. Mirrors the dispatcher's
|
|
170
|
+
* exhaustive-switch idiom (`reactor/heliosCommandDispatcher.ts:114-142`) so
|
|
171
|
+
* a new {@link HeliosCommand} variant fails to compile until mapped here.
|
|
172
|
+
*/
|
|
173
|
+
export function requiredCapabilityForCommand(cmd: HeliosCommand): WorldCapability {
|
|
174
|
+
switch (cmd.type) {
|
|
175
|
+
case 'set_scene':
|
|
176
|
+
return 'set_scene';
|
|
177
|
+
case 'swap_seed':
|
|
178
|
+
return 'swap_seed';
|
|
179
|
+
case 'pause_world':
|
|
180
|
+
case 'resume_world':
|
|
181
|
+
return 'pause_resume';
|
|
182
|
+
case 'reset_world':
|
|
183
|
+
// 'world_stream' is used as the base/lifecycle capability here — there is
|
|
184
|
+
// no reset-specific WorldCapability, and any adapter that can stream a
|
|
185
|
+
// world can reset it. A future replay-only adapter that omits
|
|
186
|
+
// 'world_stream' would (correctly) be gated out of reset_world.
|
|
187
|
+
return 'world_stream';
|
|
188
|
+
default: {
|
|
189
|
+
// Exhaustiveness check — TS complains at compile time if a new
|
|
190
|
+
// HeliosCommand variant is added without mapping it here.
|
|
191
|
+
const _exhaustive: never = cmd;
|
|
192
|
+
throw new Error(
|
|
193
|
+
`requiredCapabilityForCommand: unmapped world command ${JSON.stringify(_exhaustive)}`,
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Thrown by {@link dispatchWorldCommand} when an adapter id has no real world
|
|
201
|
+
* transport wired (anything other than the Helios or LongLive seeds). Typed
|
|
202
|
+
* so callers can distinguish "no transport for this adapter" from a transient
|
|
203
|
+
* Reactor failure (which the underlying dispatchers swallow). Carries the
|
|
204
|
+
* offending `adapterId`.
|
|
205
|
+
*/
|
|
206
|
+
export class UnsupportedWorldAdapterError extends Error {
|
|
207
|
+
readonly adapterId: string;
|
|
208
|
+
|
|
209
|
+
constructor(adapterId: string) {
|
|
210
|
+
// No class-name prefix in the message — `this.name` already supplies it,
|
|
211
|
+
// so `error.toString()` / stack traces don't render it twice. Generic
|
|
212
|
+
// (no enumeration of which adapters ARE wired) so it doesn't go stale as
|
|
213
|
+
// sibling adapters register.
|
|
214
|
+
super(
|
|
215
|
+
`World adapter "${adapterId}" has no dispatch transport wired in dispatchWorldCommand.`,
|
|
216
|
+
);
|
|
217
|
+
this.name = 'UnsupportedWorldAdapterError';
|
|
218
|
+
this.adapterId = adapterId;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Per-adapter dispatch of a single world command, routed by `adapterId`.
|
|
224
|
+
*
|
|
225
|
+
* (a) `heliosWorldAdapter.id` → delegate to the EXISTING
|
|
226
|
+
* {@link dispatchHeliosCommand} with IDENTICAL arguments. The Helios path
|
|
227
|
+
* is UNCHANGED — this only routes in front of it (LAND-DARK). This branch
|
|
228
|
+
* is BYTE-IDENTICAL to the R1d single-adapter body; the LongLive branch is
|
|
229
|
+
* purely ADDITIVE.
|
|
230
|
+
* (b) `longLiveWorldAdapter.id` → delegate to {@link dispatchLongLiveCommand}
|
|
231
|
+
* over the SAME structural Reactor bridge.
|
|
232
|
+
* (c) Any other id → throw a typed {@link UnsupportedWorldAdapterError}
|
|
233
|
+
* WITHOUT touching the bridge (no other adapter has a real transport).
|
|
234
|
+
*
|
|
235
|
+
* Compile-time safety is enforced by the FUNCTION OVERLOADS below — each
|
|
236
|
+
* `(adapterId, cmd, ctx)` triple must agree (a `LongLiveCommand` cannot be
|
|
237
|
+
* passed under the Helios id, and vice versa). So NO per-command runtime
|
|
238
|
+
* capability gate is added here (the R1d review removed the unreachable
|
|
239
|
+
* `satisfies` scaffolding): the overloads enforce the cmd/adapter match at the
|
|
240
|
+
* type level, and the capability INFO (the asymmetric matrix — helios
|
|
241
|
+
* `swap_seed` not `scene_cut`; longlive `scene_cut` not `swap_seed`) is
|
|
242
|
+
* consumed via `registry.satisfies()` by the Step-3 director UI (to hide the
|
|
243
|
+
* seed-image control for LongLive), NOT by a runtime dispatch gate. Resolves
|
|
244
|
+
* tech-debt #414.
|
|
245
|
+
*/
|
|
246
|
+
export async function dispatchWorldCommand(
|
|
247
|
+
adapterId: typeof heliosWorldAdapter.id,
|
|
248
|
+
cmd: HeliosCommand,
|
|
249
|
+
ctx: HeliosToolContext,
|
|
250
|
+
): Promise<void>;
|
|
251
|
+
export async function dispatchWorldCommand(
|
|
252
|
+
adapterId: typeof longLiveWorldAdapter.id,
|
|
253
|
+
cmd: LongLiveCommand,
|
|
254
|
+
ctx: LongLiveToolContext,
|
|
255
|
+
): Promise<void>;
|
|
256
|
+
export async function dispatchWorldCommand(
|
|
257
|
+
adapterId: string,
|
|
258
|
+
cmd: HeliosCommand | LongLiveCommand,
|
|
259
|
+
ctx: HeliosToolContext | LongLiveToolContext,
|
|
260
|
+
): Promise<void> {
|
|
261
|
+
if (adapterId === heliosWorldAdapter.id) {
|
|
262
|
+
// Delegate to the existing dispatcher — IDENTICAL args, no rewrite.
|
|
263
|
+
await dispatchHeliosCommand(cmd as HeliosCommand, ctx as HeliosToolContext);
|
|
264
|
+
} else if (adapterId === longLiveWorldAdapter.id) {
|
|
265
|
+
await dispatchLongLiveCommand(
|
|
266
|
+
cmd as LongLiveCommand,
|
|
267
|
+
ctx as LongLiveToolContext,
|
|
268
|
+
);
|
|
269
|
+
} else {
|
|
270
|
+
throw new UnsupportedWorldAdapterError(adapterId);
|
|
271
|
+
}
|
|
272
|
+
}
|
package/src/admin.ts
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
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
|
+
|
|
12
|
+
import { requestJson } from './http';
|
|
13
|
+
|
|
14
|
+
/** Where a prompt's effective value comes from. Mirrors the backend enum. */
|
|
15
|
+
export type PromptDefaultSource = 'db' | 'code';
|
|
16
|
+
|
|
17
|
+
/** One row in the editor list: identity + source + audit metadata (no body). */
|
|
18
|
+
export interface PromptDefaultSummary {
|
|
19
|
+
promptKey: string;
|
|
20
|
+
label: string;
|
|
21
|
+
group: string;
|
|
22
|
+
source: PromptDefaultSource;
|
|
23
|
+
updatedAt: string | null;
|
|
24
|
+
updatedBy: string | null;
|
|
25
|
+
editable: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Response for `GET /api/v1/admin/prompts`. */
|
|
29
|
+
export interface PromptDefaultsListResponse {
|
|
30
|
+
prompts: PromptDefaultSummary[];
|
|
31
|
+
traceId: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Single-key detail: effective value + in-code default (for diff) + metadata. */
|
|
35
|
+
export interface PromptDefaultDetail {
|
|
36
|
+
promptKey: string;
|
|
37
|
+
label: string;
|
|
38
|
+
group: string;
|
|
39
|
+
source: PromptDefaultSource;
|
|
40
|
+
value: string;
|
|
41
|
+
codeDefault: string;
|
|
42
|
+
previousValue: string | null;
|
|
43
|
+
updatedAt: string | null;
|
|
44
|
+
updatedBy: string | null;
|
|
45
|
+
editable: boolean;
|
|
46
|
+
traceId: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Body for `PUT /api/v1/admin/prompts/{key}`. */
|
|
50
|
+
export interface UpdatePromptDefaultRequest {
|
|
51
|
+
value: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* One read-only regeneration base prompt from `GET /api/v1/admin/regen-prompts`
|
|
56
|
+
* (R6d). Mirrors the backend `RegenBasePrompt` (`api/admin/schemas.py`) EXACTLY.
|
|
57
|
+
* These prompts are eval-gated (tuned via observability/eval promotion,
|
|
58
|
+
* tech-debt #336) — `editable` is always `false` and the API exposes NO write
|
|
59
|
+
* path for them.
|
|
60
|
+
*/
|
|
61
|
+
export interface RegenBasePrompt {
|
|
62
|
+
promptKey: string;
|
|
63
|
+
label: string;
|
|
64
|
+
group: string;
|
|
65
|
+
/** Regeneration scope kind: 'acts' | 'characters' | 'scene' | 'arc'. */
|
|
66
|
+
scopeKind: string;
|
|
67
|
+
/** The in-code base prompt text, verbatim. */
|
|
68
|
+
prompt: string;
|
|
69
|
+
editable: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Response for `GET /api/v1/admin/regen-prompts` (read-only list). */
|
|
73
|
+
export interface RegenBasePromptsResponse {
|
|
74
|
+
prompts: RegenBasePrompt[];
|
|
75
|
+
traceId: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* One scored synthetic-eval run from `GET /api/v1/admin/eval-runs` (M12 S4/S5).
|
|
80
|
+
*
|
|
81
|
+
* Mirrors the backend `EvalRunSummary` (`api/admin/schemas.py`) EXACTLY —
|
|
82
|
+
* same camelCase field names + nullability. The internal PK/SK/gsi1pk/gsi1sk
|
|
83
|
+
* storage keys are dropped server-side, so they never appear here. `metrics`
|
|
84
|
+
* and the optional provenance fields are always sent by the endpoint (the
|
|
85
|
+
* Python model merely defaults them).
|
|
86
|
+
*/
|
|
87
|
+
export interface EvalRunSummary {
|
|
88
|
+
evalRunId: string;
|
|
89
|
+
benchmarkId: string;
|
|
90
|
+
scenarioId: string;
|
|
91
|
+
status: string;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
metrics: Record<string, number>;
|
|
94
|
+
scenarioSetId: string | null;
|
|
95
|
+
scenarioType: string | null;
|
|
96
|
+
promptVersion: string | null;
|
|
97
|
+
pipelineVersion: string | null;
|
|
98
|
+
modelId: string | null;
|
|
99
|
+
routeName: string | null;
|
|
100
|
+
costTier: string | null;
|
|
101
|
+
latencyMs: number | null;
|
|
102
|
+
estimatedCostUsd: number | null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** One cursor-paginated page from `GET /api/v1/admin/eval-runs`. */
|
|
106
|
+
export interface EvalRunsListResponse {
|
|
107
|
+
runs: EvalRunSummary[];
|
|
108
|
+
nextCursor: string | null;
|
|
109
|
+
traceId: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Query params for `listEvalRuns`.
|
|
114
|
+
*
|
|
115
|
+
* The server enforces an XOR contract: provide EXACTLY ONE of `benchmarkId`
|
|
116
|
+
* (base-table access path) or `promptVersion` (GSI1 access path) — neither or
|
|
117
|
+
* both yields a 422. The client does not pre-validate; it forwards whatever is
|
|
118
|
+
* given.
|
|
119
|
+
*/
|
|
120
|
+
export interface ListEvalRunsParams {
|
|
121
|
+
benchmarkId?: string;
|
|
122
|
+
promptVersion?: string;
|
|
123
|
+
limit?: number;
|
|
124
|
+
cursor?: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Result of `listAllEvalRuns`: the accumulated runs plus whether the page cap
|
|
129
|
+
* was hit. `truncated` is `true` when {@link MAX_EVAL_RUN_PAGES} was reached
|
|
130
|
+
* with more pages still pending — `runs` is then a newest-first PREFIX, NOT the
|
|
131
|
+
* full series, so the caller must warn rather than present it as complete.
|
|
132
|
+
*/
|
|
133
|
+
export interface AllEvalRunsResult {
|
|
134
|
+
runs: EvalRunSummary[];
|
|
135
|
+
truncated: boolean;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const ADMIN_PROMPTS_PATH = '/api/v1/admin/prompts';
|
|
139
|
+
const ADMIN_EVAL_RUNS_PATH = '/api/v1/admin/eval-runs';
|
|
140
|
+
const ADMIN_REGEN_PROMPTS_PATH = '/api/v1/admin/regen-prompts';
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Safety cap on `listAllEvalRuns` pagination. A misbehaving server that always
|
|
144
|
+
* returns a non-null `nextCursor` would otherwise loop forever; 50 pages at the
|
|
145
|
+
* default page limit is plenty for an admin trend view, so we stop (not throw)
|
|
146
|
+
* at the cap and the page renders what it has.
|
|
147
|
+
*/
|
|
148
|
+
export const MAX_EVAL_RUN_PAGES = 50;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Client for the admin prompt-defaults CRUD surface.
|
|
152
|
+
*
|
|
153
|
+
* The auth gate is the allow-all `get_user_id` floor today (any authenticated
|
|
154
|
+
* user); the per-user/admin gate is deferred to the future RBAC milestone. The
|
|
155
|
+
* server enforces the editable-key carve-out (extraction-template keys are not
|
|
156
|
+
* editable) regardless — a non-editable key yields a 404, surfaced here as a
|
|
157
|
+
* thrown `Error`.
|
|
158
|
+
*/
|
|
159
|
+
export class AdminClient {
|
|
160
|
+
private chatBaseUrl: string;
|
|
161
|
+
private sessionToken?: string;
|
|
162
|
+
|
|
163
|
+
constructor(chatBaseUrl: string, sessionToken?: string) {
|
|
164
|
+
this.chatBaseUrl = chatBaseUrl;
|
|
165
|
+
this.sessionToken = sessionToken;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Update the bearer token (e.g. after a Descope session refresh). */
|
|
169
|
+
setSessionToken(token: string | undefined): void {
|
|
170
|
+
this.sessionToken = token;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** List every editable prompt key with its source (db|code) + audit metadata. */
|
|
174
|
+
async listPromptDefaults(
|
|
175
|
+
options: { signal?: AbortSignal } = {},
|
|
176
|
+
): Promise<PromptDefaultsListResponse> {
|
|
177
|
+
return requestJson<PromptDefaultsListResponse>(
|
|
178
|
+
this.chatBaseUrl,
|
|
179
|
+
ADMIN_PROMPTS_PATH,
|
|
180
|
+
this.sessionToken,
|
|
181
|
+
{ signal: options.signal },
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Get one key's effective value, in-code default (for diff), and metadata. */
|
|
186
|
+
async getPromptDefault(
|
|
187
|
+
promptKey: string,
|
|
188
|
+
options: { signal?: AbortSignal } = {},
|
|
189
|
+
): Promise<PromptDefaultDetail> {
|
|
190
|
+
return requestJson<PromptDefaultDetail>(
|
|
191
|
+
this.chatBaseUrl,
|
|
192
|
+
`${ADMIN_PROMPTS_PATH}/${encodeURIComponent(promptKey)}`,
|
|
193
|
+
this.sessionToken,
|
|
194
|
+
{ signal: options.signal },
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Create or update an override (201 on create, 200 on update server-side). */
|
|
199
|
+
async updatePromptDefault(
|
|
200
|
+
promptKey: string,
|
|
201
|
+
body: UpdatePromptDefaultRequest,
|
|
202
|
+
options: { signal?: AbortSignal } = {},
|
|
203
|
+
): Promise<PromptDefaultDetail> {
|
|
204
|
+
return requestJson<PromptDefaultDetail>(
|
|
205
|
+
this.chatBaseUrl,
|
|
206
|
+
`${ADMIN_PROMPTS_PATH}/${encodeURIComponent(promptKey)}`,
|
|
207
|
+
this.sessionToken,
|
|
208
|
+
{ method: 'PUT', body: JSON.stringify(body), signal: options.signal },
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** One-step revert: restores the previous value, else the in-code default. */
|
|
213
|
+
async revertPromptDefault(
|
|
214
|
+
promptKey: string,
|
|
215
|
+
options: { signal?: AbortSignal } = {},
|
|
216
|
+
): Promise<PromptDefaultDetail> {
|
|
217
|
+
return requestJson<PromptDefaultDetail>(
|
|
218
|
+
this.chatBaseUrl,
|
|
219
|
+
`${ADMIN_PROMPTS_PATH}/${encodeURIComponent(promptKey)}/revert`,
|
|
220
|
+
this.sessionToken,
|
|
221
|
+
{ method: 'POST', signal: options.signal },
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* List the AI-tuned regeneration base prompts (acts/characters/scene/arc),
|
|
227
|
+
* READ-ONLY (R6d). There is no corresponding write method — the backend
|
|
228
|
+
* exposes no PUT/POST for these prompts; they are tuned via the eval-gated
|
|
229
|
+
* promotion (tech-debt #336), never the admin editor.
|
|
230
|
+
*/
|
|
231
|
+
async listRegenBasePrompts(
|
|
232
|
+
options: { signal?: AbortSignal } = {},
|
|
233
|
+
): Promise<RegenBasePromptsResponse> {
|
|
234
|
+
return requestJson<RegenBasePromptsResponse>(
|
|
235
|
+
this.chatBaseUrl,
|
|
236
|
+
ADMIN_REGEN_PROMPTS_PATH,
|
|
237
|
+
this.sessionToken,
|
|
238
|
+
{ signal: options.signal },
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Fetch one cursor-paginated page of scored synthetic-eval runs (M12 S5).
|
|
244
|
+
*
|
|
245
|
+
* The server enforces the XOR contract — EXACTLY ONE of `benchmarkId` or
|
|
246
|
+
* `promptVersion` (neither/both → 422). This client does NOT pre-validate; it
|
|
247
|
+
* forwards the params as given and lets `requestJson` surface a 422 as a
|
|
248
|
+
* thrown `Error`. Only defined params are appended to the query string.
|
|
249
|
+
*/
|
|
250
|
+
async listEvalRuns(
|
|
251
|
+
params: ListEvalRunsParams,
|
|
252
|
+
options: { signal?: AbortSignal } = {},
|
|
253
|
+
): Promise<EvalRunsListResponse> {
|
|
254
|
+
const search = new URLSearchParams();
|
|
255
|
+
if (params.benchmarkId !== undefined) {
|
|
256
|
+
search.set('benchmarkId', params.benchmarkId);
|
|
257
|
+
}
|
|
258
|
+
if (params.promptVersion !== undefined) {
|
|
259
|
+
search.set('promptVersion', params.promptVersion);
|
|
260
|
+
}
|
|
261
|
+
if (params.limit !== undefined) {
|
|
262
|
+
search.set('limit', String(params.limit));
|
|
263
|
+
}
|
|
264
|
+
if (params.cursor !== undefined) {
|
|
265
|
+
search.set('cursor', params.cursor);
|
|
266
|
+
}
|
|
267
|
+
const qs = search.toString();
|
|
268
|
+
const path = qs ? `${ADMIN_EVAL_RUNS_PATH}?${qs}` : ADMIN_EVAL_RUNS_PATH;
|
|
269
|
+
return requestJson<EvalRunsListResponse>(
|
|
270
|
+
this.chatBaseUrl,
|
|
271
|
+
path,
|
|
272
|
+
this.sessionToken,
|
|
273
|
+
{ signal: options.signal },
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Page through ALL eval runs for the given selector, newest-first.
|
|
279
|
+
*
|
|
280
|
+
* Follows `nextCursor` until it is `null`, accumulating runs. Stops (does NOT
|
|
281
|
+
* throw) at {@link MAX_EVAL_RUN_PAGES} so a misbehaving server — or simply a
|
|
282
|
+
* benchmark with more history than the cap covers — cannot spin forever. When
|
|
283
|
+
* the cap is hit with pages still pending, the returned `runs` is a
|
|
284
|
+
* newest-first PREFIX and `truncated` is `true`, so the caller can warn rather
|
|
285
|
+
* than present a partial series as complete (the `/observability` page does).
|
|
286
|
+
* The caller's `params` are never mutated (the cursor lives in a local). Any
|
|
287
|
+
* `params.cursor` is IGNORED — "list ALL" always starts from the newest page,
|
|
288
|
+
* so a stray cursor can't silently begin mid-series. Honors `options.signal`
|
|
289
|
+
* on every page request.
|
|
290
|
+
*/
|
|
291
|
+
async listAllEvalRuns(
|
|
292
|
+
params: ListEvalRunsParams,
|
|
293
|
+
options: { signal?: AbortSignal } = {},
|
|
294
|
+
): Promise<AllEvalRunsResult> {
|
|
295
|
+
const runs: EvalRunSummary[] = [];
|
|
296
|
+
// Start at the newest page regardless of any caller-supplied params.cursor —
|
|
297
|
+
// mid-series start would silently return a truncated history.
|
|
298
|
+
let cursor: string | undefined = undefined;
|
|
299
|
+
for (let page = 0; page < MAX_EVAL_RUN_PAGES; page += 1) {
|
|
300
|
+
const response = await this.listEvalRuns({ ...params, cursor }, options);
|
|
301
|
+
runs.push(...response.runs);
|
|
302
|
+
if (response.nextCursor === null) {
|
|
303
|
+
return { runs, truncated: false };
|
|
304
|
+
}
|
|
305
|
+
cursor = response.nextCursor;
|
|
306
|
+
}
|
|
307
|
+
// Exhausted the page cap with a non-null cursor still pending — partial.
|
|
308
|
+
return { runs, truncated: true };
|
|
309
|
+
}
|
|
310
|
+
}
|