@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.
- package/README.md +31 -6
- 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 +1185 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +624 -51
- 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 +201 -13
- package/dist/graphSchema.d.ts.map +1 -1
- package/dist/graphSchema.js +258 -9
- package/dist/graphSchema.js.map +1 -1
- 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 +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -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/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/index.d.ts +2 -0
- package/dist/reactor/index.d.ts.map +1 -1
- package/dist/reactor/index.js +5 -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/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 +6 -9
- package/dist/reactor/seedImageOrchestrator.d.ts.map +1 -1
- package/dist/reactor/seedImageOrchestrator.js +12 -13
- 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/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/index.d.ts +4 -0
- package/dist/vision/index.d.ts.map +1 -1
- package/dist/vision/index.js +2 -0
- package/dist/vision/index.js.map +1 -1
- 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/websocket.d.ts +73 -0
- package/dist/websocket.d.ts.map +1 -1
- package/dist/websocket.js.map +1 -1
- package/package.json +1 -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 +4 -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__/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 +218 -9
- package/src/__tests__/longLiveCommandDispatcher.test.ts +185 -0
- package/src/__tests__/platformAssistant.test.ts +484 -0
- 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__/tools-wrappers.test.ts +272 -0
- package/src/__tests__/videoGraph.test.ts +94 -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 +1731 -116
- 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 +396 -13
- package/src/http.ts +72 -0
- package/src/index.ts +9 -0
- package/src/platformAssistant.ts +347 -0
- package/src/reactor/chunkDistribution.ts +98 -0
- package/src/reactor/index.ts +5 -0
- package/src/reactor/longLiveCommandDispatcher.ts +156 -0
- package/src/reactor/scenesFromEnrichment.ts +11 -76
- package/src/reactor/seedImageOrchestrator.ts +12 -13
- package/src/reactor/storyTimeline.ts +127 -0
- package/src/storyGraph.ts +298 -0
- package/src/vision/VisionSourceController.ts +354 -0
- package/src/vision/__tests__/VisionSourceController.test.ts +719 -0
- package/src/vision/index.ts +13 -0
- package/src/vision/sourceKinds.ts +75 -0
- package/src/websocket.ts +75 -3
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { Capability } from './capabilities';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Framework-agnostic model-adapter registry contract (R1a).
|
|
5
|
+
*
|
|
6
|
+
* The primitive every later R1 adapter (image / world / director domains)
|
|
7
|
+
* registers into. Deliberately free of React, DOM, and provider-SDK imports —
|
|
8
|
+
* mirror the discipline of the `reactor/` and `vision/` submodules. It carries
|
|
9
|
+
* descriptors and resolves named routes; it never invokes a model.
|
|
10
|
+
*
|
|
11
|
+
* The route/fallback semantics mirror the backend chat router
|
|
12
|
+
* (`shared/model_router.py:344-360`): a route whose adapter is unregistered
|
|
13
|
+
* degrades to the configured fallback route rather than throwing, keeping the
|
|
14
|
+
* resolution path crash-proof.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Named-route constants — the `ROUTE_*` analogue of
|
|
19
|
+
* `shared/model_router.py:56-59`. Use these at call sites instead of inline
|
|
20
|
+
* string literals so a route name can never be a raw string.
|
|
21
|
+
*/
|
|
22
|
+
export const ROUTE_DEFAULT = 'default' as const;
|
|
23
|
+
export const ROUTE_FALLBACK = 'fallback' as const;
|
|
24
|
+
export const ROUTE_HIGH_QUALITY = 'high_quality' as const;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A single registered adapter. `id` is the stable lookup key; `capabilities`
|
|
28
|
+
* is the advertised {@link Capability} vocabulary. `metadata` is opaque and
|
|
29
|
+
* forward-compatible — the registry carries it untouched, never interpreting
|
|
30
|
+
* it, so adapters can stamp cost tier / cache policy / etc. without a contract
|
|
31
|
+
* change here.
|
|
32
|
+
*/
|
|
33
|
+
export interface ModelAdapterDescriptor {
|
|
34
|
+
/** Stable lookup key, e.g. `'helios'`, `'gemini-3.1-flash-image-preview'`. */
|
|
35
|
+
id: string;
|
|
36
|
+
displayName: string;
|
|
37
|
+
/** Provider family, e.g. `'reactor' | 'gemini' | 'bedrock' | 'ollama'`. */
|
|
38
|
+
provider: string;
|
|
39
|
+
capabilities: readonly Capability[];
|
|
40
|
+
/** Opaque, forward-compat metadata (cost tier, cache policy) — carried, not interpreted. */
|
|
41
|
+
metadata?: Readonly<Record<string, unknown>>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A named route binding — the `ROUTE_*` → adapter mapping. `name` is always a
|
|
46
|
+
* named-route constant, never a raw string at call sites.
|
|
47
|
+
*/
|
|
48
|
+
export interface NamedRoute {
|
|
49
|
+
/**
|
|
50
|
+
* `ROUTE_*` analogue, never a raw string at call sites. Deliberately typed
|
|
51
|
+
* `string` (not a literal union of the known `ROUTE_*`) so downstream R1b–R1d
|
|
52
|
+
* PRs can register new routes without widening it back; `resolveRoute`
|
|
53
|
+
* degrades on an unknown name rather than rejecting it.
|
|
54
|
+
*/
|
|
55
|
+
name: string;
|
|
56
|
+
adapterId: string;
|
|
57
|
+
reason: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Additive registry of {@link ModelAdapterDescriptor}s for a single domain.
|
|
62
|
+
*
|
|
63
|
+
* - {@link register} is additive and THROWS on a duplicate id (no silent
|
|
64
|
+
* overwrite).
|
|
65
|
+
* - {@link resolveRoute} degrades to the fallback route rather than throwing.
|
|
66
|
+
*/
|
|
67
|
+
export class AdapterRegistry<TDescriptor extends ModelAdapterDescriptor> {
|
|
68
|
+
private readonly domain: string;
|
|
69
|
+
private readonly routes: ReadonlyMap<string, NamedRoute>;
|
|
70
|
+
private readonly fallbackRouteName: string;
|
|
71
|
+
private readonly descriptors = new Map<string, TDescriptor>();
|
|
72
|
+
|
|
73
|
+
constructor(opts: {
|
|
74
|
+
domain: string;
|
|
75
|
+
routes: readonly NamedRoute[];
|
|
76
|
+
fallbackRouteName: string;
|
|
77
|
+
}) {
|
|
78
|
+
// Eager guard: a fallbackRouteName absent from `routes` would make EVERY
|
|
79
|
+
// degrade silently return undefined (resolveRoute never throws). Fail at
|
|
80
|
+
// construction — the only place the misconfiguration is detectable.
|
|
81
|
+
if (!opts.routes.some((route) => route.name === opts.fallbackRouteName)) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`AdapterRegistry(${opts.domain}): fallbackRouteName "${opts.fallbackRouteName}" ` +
|
|
84
|
+
'is not present in the routes array — configure a fallback route.',
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
this.domain = opts.domain;
|
|
88
|
+
this.fallbackRouteName = opts.fallbackRouteName;
|
|
89
|
+
this.routes = new Map(opts.routes.map((route) => [route.name, route]));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Register a descriptor. Additive — THROWS if `descriptor.id` already exists. */
|
|
93
|
+
register(descriptor: TDescriptor): void {
|
|
94
|
+
if (this.descriptors.has(descriptor.id)) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
`AdapterRegistry(${this.domain}): duplicate adapter id "${descriptor.id}" — ` +
|
|
97
|
+
'registration is additive and must not silently overwrite an existing adapter.',
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
this.descriptors.set(descriptor.id, descriptor);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Look up a descriptor by id, or `undefined` if unregistered. */
|
|
104
|
+
get(id: string): TDescriptor | undefined {
|
|
105
|
+
return this.descriptors.get(id);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** All registered descriptors (registration order). */
|
|
109
|
+
list(): readonly TDescriptor[] {
|
|
110
|
+
return [...this.descriptors.values()];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Descriptors whose `capabilities` include `cap`. */
|
|
114
|
+
listWithCapability(cap: Capability): readonly TDescriptor[] {
|
|
115
|
+
return this.list().filter((descriptor) => descriptor.capabilities.includes(cap));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Resolve a named route to its adapter. If the route's `adapterId` is
|
|
120
|
+
* registered, return it. Otherwise (route unknown, or its adapter
|
|
121
|
+
* unregistered) degrade to the configured fallback route and return ITS
|
|
122
|
+
* adapter if registered. If even the fallback adapter is missing, return
|
|
123
|
+
* `undefined`. NEVER throws.
|
|
124
|
+
*
|
|
125
|
+
* Parity with `shared/model_router.py:344-360`.
|
|
126
|
+
*/
|
|
127
|
+
resolveRoute(routeName: string): TDescriptor | undefined {
|
|
128
|
+
const direct = this.adapterForRoute(routeName);
|
|
129
|
+
if (direct !== undefined) {
|
|
130
|
+
return direct;
|
|
131
|
+
}
|
|
132
|
+
// Already tried the fallback route directly above — skip the second lookup.
|
|
133
|
+
if (routeName === this.fallbackRouteName) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
return this.adapterForRoute(this.fallbackRouteName);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* True iff `id` is registered AND its descriptor advertises EVERY member of
|
|
141
|
+
* `required`. False for an unregistered id.
|
|
142
|
+
*/
|
|
143
|
+
satisfies(id: string, required: readonly Capability[]): boolean {
|
|
144
|
+
const descriptor = this.descriptors.get(id);
|
|
145
|
+
if (descriptor === undefined) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
return required.every((cap) => descriptor.capabilities.includes(cap));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Resolve a route name to its REGISTERED adapter, or `undefined`. No fallback. */
|
|
152
|
+
private adapterForRoute(routeName: string): TDescriptor | undefined {
|
|
153
|
+
const route = this.routes.get(routeName);
|
|
154
|
+
if (route === undefined) {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
return this.descriptors.get(route.adapterId);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -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
|
+
}
|