@escapeaihq/client-core 0.6.0 → 0.7.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 +27 -2
- package/dist/api.d.ts +180 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +134 -0
- package/dist/api.js.map +1 -1
- package/dist/audio.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/reactor/entityContext.d.ts +34 -0
- package/dist/reactor/entityContext.d.ts.map +1 -0
- package/dist/reactor/entityContext.js +119 -0
- package/dist/reactor/entityContext.js.map +1 -0
- package/dist/reactor/entitySearch.d.ts +71 -0
- package/dist/reactor/entitySearch.d.ts.map +1 -0
- package/dist/reactor/entitySearch.js +93 -0
- package/dist/reactor/entitySearch.js.map +1 -0
- package/dist/reactor/heliosCommandDispatcher.d.ts +98 -0
- package/dist/reactor/heliosCommandDispatcher.d.ts.map +1 -0
- package/dist/reactor/heliosCommandDispatcher.js +181 -0
- package/dist/reactor/heliosCommandDispatcher.js.map +1 -0
- package/dist/reactor/heliosTools.d.ts +156 -0
- package/dist/reactor/heliosTools.d.ts.map +1 -0
- package/dist/reactor/heliosTools.js +241 -0
- package/dist/reactor/heliosTools.js.map +1 -0
- package/dist/reactor/index.d.ts +17 -0
- package/dist/reactor/index.d.ts.map +1 -0
- package/dist/reactor/index.js +17 -0
- package/dist/reactor/index.js.map +1 -0
- package/dist/reactor/promptAddonRegistry.d.ts +37 -0
- package/dist/reactor/promptAddonRegistry.d.ts.map +1 -0
- package/dist/reactor/promptAddonRegistry.js +38 -0
- package/dist/reactor/promptAddonRegistry.js.map +1 -0
- package/dist/reactor/regenTemplate.d.ts +23 -0
- package/dist/reactor/regenTemplate.d.ts.map +1 -0
- package/dist/reactor/regenTemplate.js +103 -0
- package/dist/reactor/regenTemplate.js.map +1 -0
- package/dist/reactor/sceneEntry.d.ts +79 -0
- package/dist/reactor/sceneEntry.d.ts.map +1 -0
- package/dist/reactor/sceneEntry.js +177 -0
- package/dist/reactor/sceneEntry.js.map +1 -0
- package/dist/reactor/scenesFromEnrichment.d.ts +67 -0
- package/dist/reactor/scenesFromEnrichment.d.ts.map +1 -0
- package/dist/reactor/scenesFromEnrichment.js +344 -0
- package/dist/reactor/scenesFromEnrichment.js.map +1 -0
- package/dist/reactor/seedImageOrchestrator.d.ts +81 -0
- package/dist/reactor/seedImageOrchestrator.d.ts.map +1 -0
- package/dist/reactor/seedImageOrchestrator.js +79 -0
- package/dist/reactor/seedImageOrchestrator.js.map +1 -0
- package/dist/reactor/toolPromptAddon.d.ts +44 -0
- package/dist/reactor/toolPromptAddon.d.ts.map +1 -0
- package/dist/reactor/toolPromptAddon.js +129 -0
- package/dist/reactor/toolPromptAddon.js.map +1 -0
- package/dist/reactor/toolPromptAddonId.d.ts +10 -0
- package/dist/reactor/toolPromptAddonId.d.ts.map +1 -0
- package/dist/reactor/toolPromptAddonId.js +10 -0
- package/dist/reactor/toolPromptAddonId.js.map +1 -0
- package/dist/reactor/types.d.ts +149 -0
- package/dist/reactor/types.d.ts.map +1 -0
- package/dist/reactor/types.js +2 -0
- package/dist/reactor/types.js.map +1 -0
- package/dist/reactor/upsamplePrompt.d.ts +30 -0
- package/dist/reactor/upsamplePrompt.d.ts.map +1 -0
- package/dist/reactor/upsamplePrompt.js +118 -0
- package/dist/reactor/upsamplePrompt.js.map +1 -0
- package/dist/timeFormat.d.ts +28 -0
- package/dist/timeFormat.d.ts.map +1 -0
- package/dist/timeFormat.js +48 -0
- package/dist/timeFormat.js.map +1 -0
- package/dist/visemeGeometry.d.ts +15 -0
- package/dist/visemeGeometry.d.ts.map +1 -1
- package/dist/visemeGeometry.js +26 -0
- package/dist/visemeGeometry.js.map +1 -1
- package/dist/visemeScheduler.d.ts +12 -0
- package/dist/visemeScheduler.d.ts.map +1 -1
- package/dist/visemeScheduler.js +24 -0
- package/dist/visemeScheduler.js.map +1 -1
- package/dist/websocket.d.ts +51 -3
- package/dist/websocket.d.ts.map +1 -1
- package/dist/websocket.js +52 -7
- package/dist/websocket.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/reactor/__snapshots__/regenTemplate.test.ts.snap +5 -0
- package/src/__tests__/reactor/__snapshots__/scenesFromEnrichment.test.ts.snap +34 -0
- package/src/__tests__/reactor/api-reactor.test.ts +253 -0
- package/src/__tests__/reactor/entityContext.test.ts +237 -0
- package/src/__tests__/reactor/entitySearch.test.ts +223 -0
- package/src/__tests__/reactor/heliosCommandDispatcher.test.ts +438 -0
- package/src/__tests__/reactor/heliosTools.test.ts +164 -0
- package/src/__tests__/reactor/promptAddonRegistry.test.ts +40 -0
- package/src/__tests__/reactor/regenTemplate.test.ts +156 -0
- package/src/__tests__/reactor/sceneEntry.test.ts +342 -0
- package/src/__tests__/reactor/scenesFromEnrichment.test.ts +760 -0
- package/src/__tests__/reactor/seedImageOrchestrator.test.ts +139 -0
- package/src/__tests__/reactor/toolPromptAddon.test.ts +104 -0
- package/src/__tests__/reactor/upsamplePrompt.test.ts +245 -0
- package/src/__tests__/timeFormat.test.ts +80 -0
- package/src/__tests__/tools-wrappers.test.ts +219 -0
- package/src/__tests__/websocket.test.ts +278 -0
- package/src/api.ts +279 -2
- package/src/index.ts +2 -0
- package/src/reactor/entityContext.ts +147 -0
- package/src/reactor/entitySearch.ts +139 -0
- package/src/reactor/heliosCommandDispatcher.ts +293 -0
- package/src/reactor/heliosTools.ts +260 -0
- package/src/reactor/index.ts +17 -0
- package/src/reactor/promptAddonRegistry.ts +52 -0
- package/src/reactor/regenTemplate.ts +142 -0
- package/src/reactor/sceneEntry.ts +267 -0
- package/src/reactor/scenesFromEnrichment.ts +393 -0
- package/src/reactor/seedImageOrchestrator.ts +132 -0
- package/src/reactor/toolPromptAddon.ts +135 -0
- package/src/reactor/toolPromptAddonId.ts +9 -0
- package/src/reactor/types.ts +158 -0
- package/src/reactor/upsamplePrompt.ts +154 -0
- package/src/timeFormat.ts +57 -0
- package/src/visemeGeometry.ts +30 -0
- package/src/visemeScheduler.ts +25 -0
- package/src/websocket.ts +86 -7
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translate parsed Helios commands into `reactor.sendCommand` calls.
|
|
3
|
+
*
|
|
4
|
+
* Pure framework-agnostic helper: no React imports, no DOM globals
|
|
5
|
+
* beyond `Blob` / `File` (which Vue, Node 22+, and React all expose).
|
|
6
|
+
* Originally lived in `web/app/interactive/chat/heliosToolHandler.ts`
|
|
7
|
+
* for Phase 3; lifted to client-core so the Vue web-app and any other
|
|
8
|
+
* consumer can reuse the same dispatcher.
|
|
9
|
+
*
|
|
10
|
+
* Failure policy: every command is wrapped in a try/catch. A bad
|
|
11
|
+
* command (e.g. SWAP_SEED for an entity the user never showed) is
|
|
12
|
+
* logged and skipped — never propagates back to the chat loop. The
|
|
13
|
+
* chat session must keep working even if the world stream is
|
|
14
|
+
* unreachable or the entity catalogue doesn't match.
|
|
15
|
+
*/
|
|
16
|
+
import { findEntityImageBySeedName } from './entitySearch.js';
|
|
17
|
+
import { loadSeedImageFile, sendSeedFileToReactor, } from './seedImageOrchestrator.js';
|
|
18
|
+
/**
|
|
19
|
+
* Dispatch a single `HeliosCommand` to the live Reactor session.
|
|
20
|
+
* Resolves with no value on both success and failure — the caller
|
|
21
|
+
* just awaits the dispatch and continues to the next command.
|
|
22
|
+
*/
|
|
23
|
+
/** True when `err` is an `AbortError` (or carries that name). Browsers
|
|
24
|
+
* emit `DOMException('AbortError')`; fetch + apiClient already pass
|
|
25
|
+
* this through unchanged. The `code === 'ABORT_ERR'` branch covers
|
|
26
|
+
* custom error classes some libraries use; the `name` check handles
|
|
27
|
+
* every browser DOMException + standard polyfill. */
|
|
28
|
+
function isAbortError(err) {
|
|
29
|
+
return (err instanceof Error &&
|
|
30
|
+
(err.name === 'AbortError' || err.code === 'ABORT_ERR'));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Dispatch a single `HeliosCommand` to the live Reactor session.
|
|
34
|
+
* Resolves with no value on both success and failure — the caller
|
|
35
|
+
* just awaits the dispatch and continues to the next command.
|
|
36
|
+
*
|
|
37
|
+
* When `ctx.signal` is provided and gets aborted (before or during
|
|
38
|
+
* dispatch), the function returns silently without invoking any further
|
|
39
|
+
* `apiClient` / `sendCommand` calls. Callers don't need to inspect the
|
|
40
|
+
* return value to distinguish abort from completion.
|
|
41
|
+
*/
|
|
42
|
+
export async function dispatchHeliosCommand(cmd, ctx) {
|
|
43
|
+
if (ctx.signal?.aborted)
|
|
44
|
+
return;
|
|
45
|
+
try {
|
|
46
|
+
switch (cmd.type) {
|
|
47
|
+
case 'set_scene':
|
|
48
|
+
await handleSetScene(cmd.prompt, ctx);
|
|
49
|
+
return;
|
|
50
|
+
case 'swap_seed':
|
|
51
|
+
await handleSwapSeed(cmd.entityName, ctx);
|
|
52
|
+
return;
|
|
53
|
+
case 'pause_world':
|
|
54
|
+
await ctx.reactor.sendCommand('pause', {});
|
|
55
|
+
return;
|
|
56
|
+
case 'resume_world':
|
|
57
|
+
await ctx.reactor.sendCommand('resume', {});
|
|
58
|
+
return;
|
|
59
|
+
case 'reset_world':
|
|
60
|
+
await ctx.reactor.sendCommand('reset', {});
|
|
61
|
+
return;
|
|
62
|
+
default: {
|
|
63
|
+
// Exhaustiveness check — TS will complain at compile time if a
|
|
64
|
+
// new HeliosCommand variant is added without updating this
|
|
65
|
+
// switch. The runtime branch is unreachable but keeps the
|
|
66
|
+
// narrowing honest.
|
|
67
|
+
const _exhaustive = cmd;
|
|
68
|
+
console.warn('[heliosCommandDispatcher] unknown command type', _exhaustive);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
// Abort is a clean signal — silent and stop here.
|
|
75
|
+
if (isAbortError(err))
|
|
76
|
+
return;
|
|
77
|
+
console.warn('[heliosCommandDispatcher] command failed; skipping', cmd, err);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* SET_SCENE: knowledge-grounded upsample then a prompt change.
|
|
82
|
+
*
|
|
83
|
+
* Mirrors `InteractiveController.handleSubmit`:
|
|
84
|
+
* - chunk 0 (no frames rendered yet) → `set_prompt`
|
|
85
|
+
* - mid-stream → `schedule_prompt` at `currentChunk + 2`
|
|
86
|
+
*
|
|
87
|
+
* Upsample failure falls back to the raw model-emitted prompt rather
|
|
88
|
+
* than aborting — the model is already doing the Helios prompt-guide
|
|
89
|
+
* shaping; upsample just adds knowledge-graph grounding.
|
|
90
|
+
*/
|
|
91
|
+
async function handleSetScene(modelPrompt, ctx) {
|
|
92
|
+
let prompt = modelPrompt;
|
|
93
|
+
try {
|
|
94
|
+
const res = await ctx.apiClient.upsampleReactorPrompt({
|
|
95
|
+
prompt: modelPrompt,
|
|
96
|
+
imageId: ctx.imageId,
|
|
97
|
+
entityContext: ctx.entityContext,
|
|
98
|
+
personaContext: ctx.personaContext,
|
|
99
|
+
}, { signal: ctx.signal });
|
|
100
|
+
if (res?.upsampledPrompt)
|
|
101
|
+
prompt = res.upsampledPrompt;
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
// Non-fatal: the model's prompt is already 80-120 word Helios-quality
|
|
105
|
+
// per the addon prose, so falling back is safe. Abort is also routed
|
|
106
|
+
// through this branch — that's intentional, we want abort to skip the
|
|
107
|
+
// rest of the dispatch.
|
|
108
|
+
if (isAbortError(err)) {
|
|
109
|
+
// Silent on abort — the caller asked for cancellation.
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
console.warn('[heliosCommandDispatcher] set_scene upsample failed; using raw prompt', err);
|
|
113
|
+
}
|
|
114
|
+
if (ctx.signal?.aborted)
|
|
115
|
+
return;
|
|
116
|
+
const chunk = ctx.currentChunk ?? 0;
|
|
117
|
+
if (chunk === 0) {
|
|
118
|
+
await ctx.reactor.sendCommand('set_prompt', { prompt });
|
|
119
|
+
// Only emit `start` when the page hasn't fired it yet — re-emitting
|
|
120
|
+
// start while the model is already running is undocumented Reactor
|
|
121
|
+
// behavior and could in theory restart the stream from frame 0.
|
|
122
|
+
// Defensive guard: when ctx.hasStarted is true, we just refresh the
|
|
123
|
+
// prompt without a fresh start.
|
|
124
|
+
if (!ctx.hasStarted) {
|
|
125
|
+
await ctx.reactor.sendCommand('start', {});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
await ctx.reactor.sendCommand('schedule_prompt', {
|
|
130
|
+
prompt,
|
|
131
|
+
chunk: chunk + 2,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* SWAP_SEED: replace the active seed image with a different entity
|
|
137
|
+
* from the current video. Entity resolution is delegated to
|
|
138
|
+
* `findEntityImageBySeedName` (also in client-core) so the lookup
|
|
139
|
+
* logic is reusable on its own.
|
|
140
|
+
*
|
|
141
|
+
* If nothing matches: log a warning + invoke `onUserWarning` and exit.
|
|
142
|
+
* The chat keeps working; the user can ask the assistant for an exact
|
|
143
|
+
* entity name.
|
|
144
|
+
*/
|
|
145
|
+
async function handleSwapSeed(entityName, ctx) {
|
|
146
|
+
if (!ctx.videoId) {
|
|
147
|
+
console.warn('[heliosCommandDispatcher] swap_seed requested but no video selected');
|
|
148
|
+
ctx.onUserWarning?.('Cannot swap seed — no video selected. Pick a video first.');
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const trimmed = entityName.trim();
|
|
152
|
+
if (!trimmed) {
|
|
153
|
+
console.warn('[heliosCommandDispatcher] swap_seed has empty entity name');
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const match = await findEntityImageBySeedName(ctx.apiClient, ctx.videoId, trimmed);
|
|
157
|
+
if (!match) {
|
|
158
|
+
console.warn(`[heliosCommandDispatcher] swap_seed: no entity matching "${entityName}" ` +
|
|
159
|
+
`in video ${ctx.videoId}`);
|
|
160
|
+
ctx.onUserWarning?.(`Couldn't find an entity named "${entityName}" in this video. ` +
|
|
161
|
+
'Try the exact name from the entity picker.');
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
// Use the shared orchestrator (#116) so PNG/JPEG extension handling
|
|
165
|
+
// and the upload→set_image sequence stay in one place. `swap-seed`
|
|
166
|
+
// stem distinguishes SWAP_SEED uploads from initial-seed uploads in
|
|
167
|
+
// server logs.
|
|
168
|
+
const file = await loadSeedImageFile(match.image_id, ctx.apiClient, {
|
|
169
|
+
signal: ctx.signal,
|
|
170
|
+
filenameStem: 'swap-seed',
|
|
171
|
+
});
|
|
172
|
+
if (ctx.signal?.aborted)
|
|
173
|
+
return;
|
|
174
|
+
await sendSeedFileToReactor(file, ctx.reactor, { transition: 'blend' });
|
|
175
|
+
// Tell the page so subsequent SET_SCENE upsample calls see the
|
|
176
|
+
// RIGHT entity's context. Without this, the Helios stream visually
|
|
177
|
+
// swaps but the model continues grounding prompts on the previous
|
|
178
|
+
// entity.
|
|
179
|
+
ctx.onSeedSwapped?.(match);
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=heliosCommandDispatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heliosCommandDispatcher.js","sourceRoot":"","sources":["../../src/reactor/heliosCommandDispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AA0EjC;;;;GAIG;AACH;;;;sDAIsD;AACtD,SAAS,YAAY,CAAC,GAAY;IAChC,OAAO,CACL,GAAG,YAAY,KAAK;QACpB,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY,IAAK,GAAiC,CAAC,IAAI,KAAK,WAAW,CAAC,CACvF,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MA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CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helios world-steering command vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* Phase 3 ships an "inline markers" implementation: the chat model emits
|
|
5
|
+
* bracket-style commands like `[SET_SCENE: "wide cinematic shot…"]`
|
|
6
|
+
* inline in its assistant turn, and the browser intercepts them with
|
|
7
|
+
* `parseHeliosCommands()` and dispatches `reactor.sendCommand(...)` for
|
|
8
|
+
* each one. `stripHeliosCommands()` then removes the markers from the
|
|
9
|
+
* user-facing transcript so the user only sees natural-language reply
|
|
10
|
+
* text.
|
|
11
|
+
*
|
|
12
|
+
* Why markers and not real Bedrock tool-use today? `shared/chat_dispatcher.py`
|
|
13
|
+
* and `agents/strands/tool_schemas.py` only register SERVER-SIDE tools
|
|
14
|
+
* (executed inline by the agent) — there is no per-request browser-tools
|
|
15
|
+
* pipe through the WS yet. Adding that is a substantial refactor that
|
|
16
|
+
* would dwarf the Phase 3 scope. Markers are a pragmatic bridge.
|
|
17
|
+
*
|
|
18
|
+
* Future Phase 3b: migrate to real Bedrock tool-use by threading
|
|
19
|
+
* browser-defined tools through the WS payload. The
|
|
20
|
+
* {@link BEDROCK_TOOL_SCHEMAS} export below already encodes the same
|
|
21
|
+
* vocabulary in Converse-tool-spec form, so the migration is mostly
|
|
22
|
+
* delete-marker-parser + add-toolUse-handler. Tracked in
|
|
23
|
+
* `specs/technical-debt.md` Issue #113.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Discriminated union of every world-steering action the chat model can
|
|
27
|
+
* trigger. Keep this in sync with both {@link parseHeliosCommands} (the
|
|
28
|
+
* marker grammar) and {@link BEDROCK_TOOL_SCHEMAS} (the future-tool-use
|
|
29
|
+
* grammar).
|
|
30
|
+
*/
|
|
31
|
+
export type HeliosCommand = {
|
|
32
|
+
type: 'set_scene';
|
|
33
|
+
prompt: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'swap_seed';
|
|
36
|
+
entityName: string;
|
|
37
|
+
} | {
|
|
38
|
+
type: 'pause_world';
|
|
39
|
+
} | {
|
|
40
|
+
type: 'resume_world';
|
|
41
|
+
} | {
|
|
42
|
+
type: 'reset_world';
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Extract Helios commands from a streamed model response. Unknown
|
|
46
|
+
* marker names are silently dropped. Malformed markers (unclosed
|
|
47
|
+
* brackets, missing quotes when an arg is expected) are also dropped —
|
|
48
|
+
* tolerance over strictness because the model is the source of truth
|
|
49
|
+
* for whether a marker was intended.
|
|
50
|
+
*
|
|
51
|
+
* Returned commands preserve source order.
|
|
52
|
+
*/
|
|
53
|
+
export declare function parseHeliosCommands(text: string): HeliosCommand[];
|
|
54
|
+
/**
|
|
55
|
+
* Remove every Helios marker from a text fragment so the user-facing
|
|
56
|
+
* transcript reads cleanly. The function:
|
|
57
|
+
* - Drops markers regardless of whether the name is recognised (the
|
|
58
|
+
* user shouldn't see `[FOO: "bar"]` either way).
|
|
59
|
+
* - Collapses runs of horizontal whitespace introduced by the
|
|
60
|
+
* deletion (so `Hello [PAUSE_WORLD] world` becomes `Hello world`,
|
|
61
|
+
* not `Hello world`).
|
|
62
|
+
* - Collapses 3+ consecutive newlines down to 2 (preserves paragraph
|
|
63
|
+
* breaks but doesn't leave huge gaps where markers used to sit).
|
|
64
|
+
* - Leaves the input's leading/trailing whitespace untouched. Streaming
|
|
65
|
+
* callers concatenate chunks, so trimming boundary whitespace would
|
|
66
|
+
* corrupt seams.
|
|
67
|
+
*/
|
|
68
|
+
export declare function stripHeliosCommands(text: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Bedrock Converse tool specs for the same vocabulary as the markers
|
|
71
|
+
* above. **NOT USED IN PHASE 3** — the chat dispatcher doesn't accept
|
|
72
|
+
* browser-defined tools yet (see Issue #113 in
|
|
73
|
+
* `specs/technical-debt.md`). Kept here so the future migration to real
|
|
74
|
+
* tool-use only needs to delete the marker parser and wire these into
|
|
75
|
+
* the WS send payload.
|
|
76
|
+
*
|
|
77
|
+
* Schema shape matches the AWS Bedrock Converse API:
|
|
78
|
+
* { toolSpec: { name, description, inputSchema: { json: {...} } } }
|
|
79
|
+
*
|
|
80
|
+
* NAMING NOTE: schemas use `snake_case` property names (`entity_name`,
|
|
81
|
+
* not `entityName`) because that's the convention Bedrock Converse
|
|
82
|
+
* tool-use expects in the inputSchema, and the LLM emits arguments
|
|
83
|
+
* keyed to the schema. The Phase 3b migration handler will need to
|
|
84
|
+
* translate snake_case tool-use args → camelCase `HeliosCommand`
|
|
85
|
+
* fields (e.g. `entity_name` → `entityName`). The marker parser does
|
|
86
|
+
* the same translation for the inline-marker path today.
|
|
87
|
+
*/
|
|
88
|
+
export declare const BEDROCK_TOOL_SCHEMAS: readonly [{
|
|
89
|
+
readonly toolSpec: {
|
|
90
|
+
readonly name: "set_scene";
|
|
91
|
+
readonly description: string;
|
|
92
|
+
readonly inputSchema: {
|
|
93
|
+
readonly json: {
|
|
94
|
+
readonly type: "object";
|
|
95
|
+
readonly properties: {
|
|
96
|
+
readonly prompt: {
|
|
97
|
+
readonly type: "string";
|
|
98
|
+
readonly description: "Detailed 80-120 word scene description for Helios.";
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
readonly required: readonly ["prompt"];
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
}, {
|
|
106
|
+
readonly toolSpec: {
|
|
107
|
+
readonly name: "swap_seed";
|
|
108
|
+
readonly description: string;
|
|
109
|
+
readonly inputSchema: {
|
|
110
|
+
readonly json: {
|
|
111
|
+
readonly type: "object";
|
|
112
|
+
readonly properties: {
|
|
113
|
+
readonly entity_name: {
|
|
114
|
+
readonly type: "string";
|
|
115
|
+
readonly description: "Exact display name of the target entity (e.g. \"Leo\").";
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
readonly required: readonly ["entity_name"];
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
}, {
|
|
123
|
+
readonly toolSpec: {
|
|
124
|
+
readonly name: "pause_world";
|
|
125
|
+
readonly description: string;
|
|
126
|
+
readonly inputSchema: {
|
|
127
|
+
readonly json: {
|
|
128
|
+
readonly type: "object";
|
|
129
|
+
readonly properties: {};
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
}, {
|
|
134
|
+
readonly toolSpec: {
|
|
135
|
+
readonly name: "resume_world";
|
|
136
|
+
readonly description: "Resume a paused Helios stream from the current frame.";
|
|
137
|
+
readonly inputSchema: {
|
|
138
|
+
readonly json: {
|
|
139
|
+
readonly type: "object";
|
|
140
|
+
readonly properties: {};
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
}, {
|
|
145
|
+
readonly toolSpec: {
|
|
146
|
+
readonly name: "reset_world";
|
|
147
|
+
readonly description: string;
|
|
148
|
+
readonly inputSchema: {
|
|
149
|
+
readonly json: {
|
|
150
|
+
readonly type: "object";
|
|
151
|
+
readonly properties: {};
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
}];
|
|
156
|
+
//# sourceMappingURL=heliosTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heliosTools.d.ts","sourceRoot":"","sources":["../../src/reactor/heliosTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GACvB;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAgD5B;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CA4BjE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAwBxD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6EvB,CAAC"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helios world-steering command vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* Phase 3 ships an "inline markers" implementation: the chat model emits
|
|
5
|
+
* bracket-style commands like `[SET_SCENE: "wide cinematic shot…"]`
|
|
6
|
+
* inline in its assistant turn, and the browser intercepts them with
|
|
7
|
+
* `parseHeliosCommands()` and dispatches `reactor.sendCommand(...)` for
|
|
8
|
+
* each one. `stripHeliosCommands()` then removes the markers from the
|
|
9
|
+
* user-facing transcript so the user only sees natural-language reply
|
|
10
|
+
* text.
|
|
11
|
+
*
|
|
12
|
+
* Why markers and not real Bedrock tool-use today? `shared/chat_dispatcher.py`
|
|
13
|
+
* and `agents/strands/tool_schemas.py` only register SERVER-SIDE tools
|
|
14
|
+
* (executed inline by the agent) — there is no per-request browser-tools
|
|
15
|
+
* pipe through the WS yet. Adding that is a substantial refactor that
|
|
16
|
+
* would dwarf the Phase 3 scope. Markers are a pragmatic bridge.
|
|
17
|
+
*
|
|
18
|
+
* Future Phase 3b: migrate to real Bedrock tool-use by threading
|
|
19
|
+
* browser-defined tools through the WS payload. The
|
|
20
|
+
* {@link BEDROCK_TOOL_SCHEMAS} export below already encodes the same
|
|
21
|
+
* vocabulary in Converse-tool-spec form, so the migration is mostly
|
|
22
|
+
* delete-marker-parser + add-toolUse-handler. Tracked in
|
|
23
|
+
* `specs/technical-debt.md` Issue #113.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Marker names recognised by {@link parseHeliosCommands}. Matched
|
|
27
|
+
* case-insensitively. Anything else is silently dropped — the model
|
|
28
|
+
* regularly invents marker names, and throwing would break the chat
|
|
29
|
+
* session for every typo.
|
|
30
|
+
*/
|
|
31
|
+
const KNOWN_MARKERS = {
|
|
32
|
+
set_scene: 'set_scene',
|
|
33
|
+
swap_seed: 'swap_seed',
|
|
34
|
+
pause_world: 'pause_world',
|
|
35
|
+
resume_world: 'resume_world',
|
|
36
|
+
reset_world: 'reset_world',
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Markers that REQUIRE a string argument. The argument is captured from
|
|
40
|
+
* the `"…"` group in the grammar; missing-arg variants are dropped.
|
|
41
|
+
*/
|
|
42
|
+
const MARKERS_REQUIRING_ARG = new Set(['set_scene', 'swap_seed']);
|
|
43
|
+
/**
|
|
44
|
+
* Grammar (loose):
|
|
45
|
+
* - `[ NAME ]`
|
|
46
|
+
* - `[ NAME : "argument" ]`
|
|
47
|
+
*
|
|
48
|
+
* Whitespace around the name/colon is tolerated; the name is matched
|
|
49
|
+
* case-insensitively. Markers that look syntactically valid but don't
|
|
50
|
+
* match a known name are dropped (so the model can hallucinate
|
|
51
|
+
* `[ENGAGE_HYPERDRIVE: "warp 9"]` without crashing).
|
|
52
|
+
*
|
|
53
|
+
* The regex is non-greedy on the argument to handle multiple markers
|
|
54
|
+
* on one line, and forbids embedded brackets inside the name to avoid
|
|
55
|
+
* catastrophic backtracking on malformed input.
|
|
56
|
+
*
|
|
57
|
+
* Only the regex SOURCE + FLAGS are kept at module scope. Each call
|
|
58
|
+
* to `parseHeliosCommands` constructs a fresh `RegExp` instance from
|
|
59
|
+
* those constants so the `g`-flag's `lastIndex` state is never shared
|
|
60
|
+
* across calls. Browser is single-threaded so the difference is mostly
|
|
61
|
+
* theoretical, but it eliminates the shared-state concern for SSR or
|
|
62
|
+
* concurrent test workers and lets us drop a defensive reset line.
|
|
63
|
+
*/
|
|
64
|
+
const MARKER_PATTERN = /\[\s*([A-Za-z_][A-Za-z0-9_]*)\s*(?::\s*"((?:[^"\\]|\\.)*)"\s*)?\]/g;
|
|
65
|
+
const MARKER_PATTERN_SOURCE = MARKER_PATTERN.source;
|
|
66
|
+
const MARKER_PATTERN_FLAGS = MARKER_PATTERN.flags;
|
|
67
|
+
/**
|
|
68
|
+
* Extract Helios commands from a streamed model response. Unknown
|
|
69
|
+
* marker names are silently dropped. Malformed markers (unclosed
|
|
70
|
+
* brackets, missing quotes when an arg is expected) are also dropped —
|
|
71
|
+
* tolerance over strictness because the model is the source of truth
|
|
72
|
+
* for whether a marker was intended.
|
|
73
|
+
*
|
|
74
|
+
* Returned commands preserve source order.
|
|
75
|
+
*/
|
|
76
|
+
export function parseHeliosCommands(text) {
|
|
77
|
+
if (!text)
|
|
78
|
+
return [];
|
|
79
|
+
const commands = [];
|
|
80
|
+
// Fresh regex per call — no shared lastIndex state to worry about.
|
|
81
|
+
const regex = new RegExp(MARKER_PATTERN_SOURCE, MARKER_PATTERN_FLAGS);
|
|
82
|
+
for (const match of text.matchAll(regex)) {
|
|
83
|
+
const rawName = match[1]?.toLowerCase();
|
|
84
|
+
const arg = match[2]; // string | undefined
|
|
85
|
+
if (!rawName)
|
|
86
|
+
continue;
|
|
87
|
+
const type = KNOWN_MARKERS[rawName];
|
|
88
|
+
if (!type)
|
|
89
|
+
continue;
|
|
90
|
+
if (MARKERS_REQUIRING_ARG.has(type)) {
|
|
91
|
+
// Argument is required and must be a non-empty trimmed string.
|
|
92
|
+
const trimmed = arg?.trim();
|
|
93
|
+
if (!trimmed)
|
|
94
|
+
continue;
|
|
95
|
+
if (type === 'set_scene') {
|
|
96
|
+
commands.push({ type: 'set_scene', prompt: trimmed });
|
|
97
|
+
}
|
|
98
|
+
else if (type === 'swap_seed') {
|
|
99
|
+
commands.push({ type: 'swap_seed', entityName: trimmed });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// Zero-arg markers; any included arg is ignored.
|
|
104
|
+
if (type === 'pause_world')
|
|
105
|
+
commands.push({ type: 'pause_world' });
|
|
106
|
+
else if (type === 'resume_world')
|
|
107
|
+
commands.push({ type: 'resume_world' });
|
|
108
|
+
else if (type === 'reset_world')
|
|
109
|
+
commands.push({ type: 'reset_world' });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return commands;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Remove every Helios marker from a text fragment so the user-facing
|
|
116
|
+
* transcript reads cleanly. The function:
|
|
117
|
+
* - Drops markers regardless of whether the name is recognised (the
|
|
118
|
+
* user shouldn't see `[FOO: "bar"]` either way).
|
|
119
|
+
* - Collapses runs of horizontal whitespace introduced by the
|
|
120
|
+
* deletion (so `Hello [PAUSE_WORLD] world` becomes `Hello world`,
|
|
121
|
+
* not `Hello world`).
|
|
122
|
+
* - Collapses 3+ consecutive newlines down to 2 (preserves paragraph
|
|
123
|
+
* breaks but doesn't leave huge gaps where markers used to sit).
|
|
124
|
+
* - Leaves the input's leading/trailing whitespace untouched. Streaming
|
|
125
|
+
* callers concatenate chunks, so trimming boundary whitespace would
|
|
126
|
+
* corrupt seams.
|
|
127
|
+
*/
|
|
128
|
+
export function stripHeliosCommands(text) {
|
|
129
|
+
if (!text)
|
|
130
|
+
return text;
|
|
131
|
+
// Reuse the parser's grammar via MARKER_PATTERN_SOURCE so any future
|
|
132
|
+
// change to the marker syntax automatically applies here too. Fresh
|
|
133
|
+
// RegExp instance — no `lastIndex` state shared with the parser.
|
|
134
|
+
// (Stripping doesn't capture so we don't need the parentheses, but
|
|
135
|
+
// keeping the same source is cheaper than maintaining two regexes.)
|
|
136
|
+
const stripRegex = new RegExp(MARKER_PATTERN_SOURCE, MARKER_PATTERN_FLAGS);
|
|
137
|
+
const stripped = text.replace(stripRegex, '');
|
|
138
|
+
// Collapse whitespace introduced by deletion (multiple spaces, tabs,
|
|
139
|
+
// newlines that became adjacent). Preserve single newlines for
|
|
140
|
+
// paragraph structure: collapse runs of horizontal whitespace, then
|
|
141
|
+
// dedupe consecutive blank lines.
|
|
142
|
+
const collapsed = stripped
|
|
143
|
+
// Collapse runs of spaces/tabs.
|
|
144
|
+
.replace(/[ \t]{2,}/g, ' ')
|
|
145
|
+
// Remove trailing spaces before newlines.
|
|
146
|
+
.replace(/[ \t]+\n/g, '\n')
|
|
147
|
+
// Collapse 3+ newlines down to 2.
|
|
148
|
+
.replace(/\n{3,}/g, '\n\n');
|
|
149
|
+
return collapsed;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Bedrock Converse tool specs for the same vocabulary as the markers
|
|
153
|
+
* above. **NOT USED IN PHASE 3** — the chat dispatcher doesn't accept
|
|
154
|
+
* browser-defined tools yet (see Issue #113 in
|
|
155
|
+
* `specs/technical-debt.md`). Kept here so the future migration to real
|
|
156
|
+
* tool-use only needs to delete the marker parser and wire these into
|
|
157
|
+
* the WS send payload.
|
|
158
|
+
*
|
|
159
|
+
* Schema shape matches the AWS Bedrock Converse API:
|
|
160
|
+
* { toolSpec: { name, description, inputSchema: { json: {...} } } }
|
|
161
|
+
*
|
|
162
|
+
* NAMING NOTE: schemas use `snake_case` property names (`entity_name`,
|
|
163
|
+
* not `entityName`) because that's the convention Bedrock Converse
|
|
164
|
+
* tool-use expects in the inputSchema, and the LLM emits arguments
|
|
165
|
+
* keyed to the schema. The Phase 3b migration handler will need to
|
|
166
|
+
* translate snake_case tool-use args → camelCase `HeliosCommand`
|
|
167
|
+
* fields (e.g. `entity_name` → `entityName`). The marker parser does
|
|
168
|
+
* the same translation for the inline-marker path today.
|
|
169
|
+
*/
|
|
170
|
+
export const BEDROCK_TOOL_SCHEMAS = [
|
|
171
|
+
{
|
|
172
|
+
toolSpec: {
|
|
173
|
+
name: 'set_scene',
|
|
174
|
+
description: 'Change the live Helios scene to a new prompt. The prompt should ' +
|
|
175
|
+
'be a detailed 80-120 word scene description following the Helios ' +
|
|
176
|
+
'prompt-guide style: subject, environment, lighting, camera framing, ' +
|
|
177
|
+
'mood. Use this when the user asks to change the world, the weather, ' +
|
|
178
|
+
'the time of day, or the mood. The change applies on the next chunk.',
|
|
179
|
+
inputSchema: {
|
|
180
|
+
json: {
|
|
181
|
+
type: 'object',
|
|
182
|
+
properties: {
|
|
183
|
+
prompt: {
|
|
184
|
+
type: 'string',
|
|
185
|
+
description: 'Detailed 80-120 word scene description for Helios.',
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
required: ['prompt'],
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
toolSpec: {
|
|
195
|
+
name: 'swap_seed',
|
|
196
|
+
description: 'Replace the active seed image with a different entity from the ' +
|
|
197
|
+
'current video. The entity name should match one of the ' +
|
|
198
|
+
"extracted entities (matching is case-insensitive on whitespace-trimmed " +
|
|
199
|
+
"names — `Leo`, `leo`, `LEO` all resolve to the same entity). Use when " +
|
|
200
|
+
'the user asks to ' +
|
|
201
|
+
"swap or focus on a different character. Triggers a blended " +
|
|
202
|
+
'transition rather than a hard cut.',
|
|
203
|
+
inputSchema: {
|
|
204
|
+
json: {
|
|
205
|
+
type: 'object',
|
|
206
|
+
properties: {
|
|
207
|
+
entity_name: {
|
|
208
|
+
type: 'string',
|
|
209
|
+
description: 'Exact display name of the target entity (e.g. "Leo").',
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
required: ['entity_name'],
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
toolSpec: {
|
|
219
|
+
name: 'pause_world',
|
|
220
|
+
description: 'Pause the live Helios stream at the current frame. Use when the ' +
|
|
221
|
+
'user wants to freeze the action.',
|
|
222
|
+
inputSchema: { json: { type: 'object', properties: {} } },
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
toolSpec: {
|
|
227
|
+
name: 'resume_world',
|
|
228
|
+
description: 'Resume a paused Helios stream from the current frame.',
|
|
229
|
+
inputSchema: { json: { type: 'object', properties: {} } },
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
toolSpec: {
|
|
234
|
+
name: 'reset_world',
|
|
235
|
+
description: 'Reset the Helios stream back to frame 0 and clear the scheduled ' +
|
|
236
|
+
'prompt buffer. Use when the user wants to start over.',
|
|
237
|
+
inputSchema: { json: { type: 'object', properties: {} } },
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
];
|
|
241
|
+
//# sourceMappingURL=heliosTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heliosTools.js","sourceRoot":"","sources":["../../src/reactor/heliosTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAeH;;;;;GAKG;AACH,MAAM,aAAa,GAA+F;IAChH,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,cAAc;IAC5B,WAAW,EAAE,aAAa;CAC3B,CAAC;AAEF;;;GAGG;AACH,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAS,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,cAAc,GAClB,oEAAoE,CAAC;AACvE,MAAM,qBAAqB,GAAG,cAAc,CAAC,MAAM,CAAC;AACpD,MAAM,oBAAoB,GAAG,cAAc,CAAC,KAAK,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,MAAM,QAAQ,GAAoB,EAAE,CAAC;IACrC,mEAAmE;IACnE,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,qB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E;gBACxE,mBAAmB;gBACnB,6DAA6D;gBAC7D,oCAAoC;YACtC,WAAW,EAAE;gBACX,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,WAAW,EAAE;4BACX,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,uDAAuD;yBAC1D;qBACF;oBACD,QAAQ,EAAE,CAAC,aAAa,CAAC;iBAC1B;aACF;SACF;KACF;IACD;QACE,QAAQ,EAAE;YACR,IAAI,EAAE,aAAa;YACnB,WAAW,EACT,kEAAkE;gBAClE,kCAAkC;YACpC,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE;SAC1D;KACF;IACD;QACE,QAAQ,EAAE;YACR,IAAI,EAAE,cAAc;YACpB,WAAW,EACT,uDAAuD;YACzD,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE;SAC1D;KACF;IACD;QACE,QAAQ,EAAE;YACR,IAAI,EAAE,aAAa;YACnB,WAAW,EACT,kEAAkE;gBAClE,uDAAuD;YACzD,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE;SAC1D;KACF;CACO,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Barrel re-export for the framework-agnostic Reactor / Helios layer.
|
|
3
|
+
* Consumed from `src/index.ts` via `export * from './reactor'`.
|
|
4
|
+
*/
|
|
5
|
+
export * from './types';
|
|
6
|
+
export * from './regenTemplate';
|
|
7
|
+
export * from './upsamplePrompt';
|
|
8
|
+
export * from './entityContext';
|
|
9
|
+
export * from './scenesFromEnrichment';
|
|
10
|
+
export * from './heliosTools';
|
|
11
|
+
export * from './toolPromptAddon';
|
|
12
|
+
export * from './entitySearch';
|
|
13
|
+
export * from './heliosCommandDispatcher';
|
|
14
|
+
export * from './seedImageOrchestrator';
|
|
15
|
+
export * from './promptAddonRegistry';
|
|
16
|
+
export * from './sceneEntry';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reactor/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Barrel re-export for the framework-agnostic Reactor / Helios layer.
|
|
3
|
+
* Consumed from `src/index.ts` via `export * from './reactor.js'`.
|
|
4
|
+
*/
|
|
5
|
+
export * from './types.js';
|
|
6
|
+
export * from './regenTemplate.js';
|
|
7
|
+
export * from './upsamplePrompt.js';
|
|
8
|
+
export * from './entityContext.js';
|
|
9
|
+
export * from './scenesFromEnrichment.js';
|
|
10
|
+
export * from './heliosTools.js';
|
|
11
|
+
export * from './toolPromptAddon.js';
|
|
12
|
+
export * from './entitySearch.js';
|
|
13
|
+
export * from './heliosCommandDispatcher.js';
|
|
14
|
+
export * from './seedImageOrchestrator.js';
|
|
15
|
+
export * from './promptAddonRegistry.js';
|
|
16
|
+
export * from './sceneEntry.js';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reactor/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC"}
|