@escapeaihq/client-core 0.6.1 → 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 +102 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +92 -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/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/api.ts +170 -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
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System-prompt addon that teaches a chat model to emit Helios
|
|
3
|
+
* world-steering markers.
|
|
4
|
+
*
|
|
5
|
+
* Phase 3 hooks this addon up via `PersonaConfig.prompt_addon_ids`: when
|
|
6
|
+
* a persona declares `prompt_addon_ids: ['helios-world-steering']`, the
|
|
7
|
+
* browser-side `/interactive/chat` page looks up the addon text via
|
|
8
|
+
* `getHeliosSteeringAddonText()` and concatenates it onto the persona's
|
|
9
|
+
* `custom_system_prompt` before sending each chat turn via the WS
|
|
10
|
+
* `systemPrompt` field.
|
|
11
|
+
*
|
|
12
|
+
* The backend has no awareness of the addon ID's semantics — the field
|
|
13
|
+
* is just metadata on `PersonaConfig`. See
|
|
14
|
+
* `shared/persona_addon_ids.py` for the matching Python constant.
|
|
15
|
+
*/
|
|
16
|
+
export { HELIOS_WORLD_STEERING_ADDON_ID } from './toolPromptAddonId.js';
|
|
17
|
+
/**
|
|
18
|
+
* Marker the addon uses to verify idempotent reapplication. The build
|
|
19
|
+
* function looks for this string in the base prompt before appending,
|
|
20
|
+
* so calling `buildHeliosSteeringSystemPrompt(buildHeliosSteeringSystemPrompt(p))`
|
|
21
|
+
* returns the same value as a single application. Choose something
|
|
22
|
+
* unique enough that a normal persona prompt would never include it
|
|
23
|
+
* verbatim.
|
|
24
|
+
*/
|
|
25
|
+
const ADDON_SENTINEL = '<!-- helios-world-steering-addon:v1 -->';
|
|
26
|
+
/**
|
|
27
|
+
* Stable, model-friendly addon text that teaches the marker grammar
|
|
28
|
+
* and the rules around when to emit each marker. Kept as a function
|
|
29
|
+
* (not a const) so callers don't accidentally share-and-mutate the
|
|
30
|
+
* underlying string.
|
|
31
|
+
*
|
|
32
|
+
* Update the version sentinel inside the function if the addon
|
|
33
|
+
* semantics change in a way the model needs to relearn — `prompt_addon_ids`
|
|
34
|
+
* is a stable identifier, but cached upstream chat history may have
|
|
35
|
+
* trained the model against the OLD prose. The sentinel doubles as a
|
|
36
|
+
* "did the LLM see the new version?" diagnostic.
|
|
37
|
+
*/
|
|
38
|
+
export function getHeliosSteeringAddonText() {
|
|
39
|
+
return [
|
|
40
|
+
ADDON_SENTINEL,
|
|
41
|
+
'## World Steering Capability',
|
|
42
|
+
'',
|
|
43
|
+
'This conversation is running alongside a live Helios video stream that ' +
|
|
44
|
+
"you can steer directly. When the user asks you to change the visible " +
|
|
45
|
+
'world — scene changes, atmospheric shifts, character swaps, pausing, ' +
|
|
46
|
+
'resetting — emit ONE of the following bracket-style markers at the ' +
|
|
47
|
+
'VERY END of your response, after your natural-language reply.',
|
|
48
|
+
'',
|
|
49
|
+
'### Markers',
|
|
50
|
+
'',
|
|
51
|
+
'- `[SET_SCENE: "<80-120 word Helios-quality scene prompt>"]` — change ' +
|
|
52
|
+
'the live world to a new scene. The prompt MUST follow the Helios ' +
|
|
53
|
+
"prompt-guide style: name the subject, the environment, the lighting, " +
|
|
54
|
+
'the camera framing (wide / medium / medium close-up / close-up), and ' +
|
|
55
|
+
'the mood. Target 80-120 words. Example argument: "wide cinematic ' +
|
|
56
|
+
'shot, a man in a red coat walks across a snowy bridge at dusk, soft ' +
|
|
57
|
+
"golden hour light streaming through wrought-iron railings, medium " +
|
|
58
|
+
'tracking shot following him from the right, his breath visible in the ' +
|
|
59
|
+
'cold air, distant city lights glowing behind him, mood: contemplative ' +
|
|
60
|
+
'and quietly hopeful, 35mm film grain, cinematic depth of field."',
|
|
61
|
+
'- `[SWAP_SEED: "<entity name>"]` — replace the active seed image ' +
|
|
62
|
+
'with a different entity from the current video. The entity name must ' +
|
|
63
|
+
'match one of the entities the user has shown you (matching is ' +
|
|
64
|
+
"case-insensitive). If you're not sure of the name, don't emit this " +
|
|
65
|
+
'marker — ask the user to clarify instead.',
|
|
66
|
+
'- `[PAUSE_WORLD]` — pause the live stream at the current frame. Use ' +
|
|
67
|
+
'when the user wants to freeze the action.',
|
|
68
|
+
'- `[RESUME_WORLD]` — resume a paused stream.',
|
|
69
|
+
'- `[RESET_WORLD]` — reset the stream to frame 0 and clear pending ' +
|
|
70
|
+
'prompts. Use only when the user explicitly asks to start over.',
|
|
71
|
+
'',
|
|
72
|
+
'### Critical Rules',
|
|
73
|
+
'',
|
|
74
|
+
'1. Emit AT MOST ONE marker per turn. If the user asks for a sequence ' +
|
|
75
|
+
'(e.g. "pause then change the scene"), pick the first action and tell ' +
|
|
76
|
+
'them you\'ll do the next one when they ask.',
|
|
77
|
+
'2. Markers go at the END of your response, after a blank line, never ' +
|
|
78
|
+
'mixed into the middle of prose.',
|
|
79
|
+
'3. SET_SCENE prompts must be detailed and ground in the established ' +
|
|
80
|
+
'world. Bland three-word prompts produce bland output.',
|
|
81
|
+
'4. For SET_SCENE, weave the existing entity / character continuity into ' +
|
|
82
|
+
"the prompt so identity is preserved across the cut. Don't invent a " +
|
|
83
|
+
'brand-new protagonist mid-scene unless the user explicitly asks for ' +
|
|
84
|
+
'one.',
|
|
85
|
+
'5. If the user asks something you can answer in words alone — describe ' +
|
|
86
|
+
"the world, recall a past moment, plan a beat — DON'T emit a marker. " +
|
|
87
|
+
'Markers are for actions, not exposition.',
|
|
88
|
+
'',
|
|
89
|
+
'### Example',
|
|
90
|
+
'',
|
|
91
|
+
'User: "Make it start raining and feel a bit lonelier."',
|
|
92
|
+
'',
|
|
93
|
+
'Assistant: Pulling the warmth out of the light and adding a slow grey ' +
|
|
94
|
+
'rain — give it a beat to settle in.',
|
|
95
|
+
'',
|
|
96
|
+
'[SET_SCENE: "wide cinematic shot, a man in a long coat stands alone on ' +
|
|
97
|
+
'a deserted cobblestone bridge in a slow grey downpour, single sodium ' +
|
|
98
|
+
"streetlamp casting a cone of amber light onto wet stone, distant city " +
|
|
99
|
+
'reflections rippling in puddles, medium tracking shot pulling back ' +
|
|
100
|
+
'slightly, his breath fogging in the cold air, mood: melancholy and ' +
|
|
101
|
+
'introspective, 35mm film grain, shallow depth of field, muted blue and ' +
|
|
102
|
+
'amber color palette, soft falling rain catching the lamp light."]',
|
|
103
|
+
'',
|
|
104
|
+
].join('\n');
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Concatenate the Helios steering addon onto an arbitrary base system
|
|
108
|
+
* prompt. Idempotent: a prompt that already contains the addon sentinel
|
|
109
|
+
* is returned unchanged.
|
|
110
|
+
*
|
|
111
|
+
* An empty base prompt is allowed — the addon stands on its own and
|
|
112
|
+
* works without a persona backstory (the test suite covers this).
|
|
113
|
+
*
|
|
114
|
+
* @param baseSystemPrompt - persona's `custom_system_prompt` (may be
|
|
115
|
+
* empty string or whitespace).
|
|
116
|
+
* @returns concatenated prompt: `<base>\n\n<addon>` when the base is
|
|
117
|
+
* non-empty, just `<addon>` otherwise.
|
|
118
|
+
*/
|
|
119
|
+
export function buildHeliosSteeringSystemPrompt(baseSystemPrompt) {
|
|
120
|
+
if (baseSystemPrompt && baseSystemPrompt.includes(ADDON_SENTINEL)) {
|
|
121
|
+
return baseSystemPrompt;
|
|
122
|
+
}
|
|
123
|
+
const addon = getHeliosSteeringAddonText();
|
|
124
|
+
const trimmed = (baseSystemPrompt ?? '').trim();
|
|
125
|
+
if (!trimmed)
|
|
126
|
+
return addon;
|
|
127
|
+
return `${trimmed}\n\n${addon}`;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=toolPromptAddon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolPromptAddon.js","sourceRoot":"","sources":["../../src/reactor/toolPromptAddon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,cAAc,GAAG,yCAAyC,CAAC;AAEjE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO;QACL,cAAc;QACd,8BAA8B;QAC9B,EAAE;QACF,yEAAyE;YACvE,uEAAuE;YACvE,uEAAuE;YACvE,qEAAqE;YACrE,+DAA+D;QACjE,EAAE;QACF,aAAa;QACb,EAAE;QACF,wEAAwE;YACtE,mEAAmE;YACnE,uEAAuE;YACvE,uEAAuE;YACvE,mEAAmE;YACnE,sEAAsE;YACtE,oEAAoE;YACpE,wEAAwE;YACxE,wEAAwE;YACxE,kEAAkE;QACpE,mEAAmE;YACjE,uEAAuE;YACvE,gEAAgE;YAChE,qEAAqE;YACrE,2CAA2C;QAC7C,sEAAsE;YACpE,2CAA2C;QAC7C,8CAA8C;QAC9C,oEAAoE;YAClE,gEAAgE;QAClE,EAAE;QACF,oBAAoB;QACpB,EAAE;QACF,uEAAuE;YACrE,uEAAuE;YACvE,6CAA6C;QAC/C,uEAAuE;YACrE,iCAAiC;QACnC,sEAAsE;YACpE,uDAAuD;QACzD,0EAA0E;YACxE,qEAAqE;YACrE,sEAAsE;YACtE,MAAM;QACR,yEAAyE;YACvE,sEAAsE;YACtE,0CAA0C;QAC5C,EAAE;QACF,aAAa;QACb,EAAE;QACF,wDAAwD;QACxD,EAAE;QACF,wEAAwE;YACtE,qCAAqC;QACvC,EAAE;QACF,yEAAyE;YACvE,uEAAuE;YACvE,wEAAwE;YACxE,qEAAqE;YACrE,qEAAqE;YACrE,yEAAyE;YACzE,mEAAmE;QACrE,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,+BAA+B,CAC7C,gBAAwB;IAExB,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QAClE,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD,MAAM,KAAK,GAAG,0BAA0B,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAChD,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,OAAO,GAAG,OAAO,OAAO,KAAK,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable string ID for the Helios world-steering prompt addon.
|
|
3
|
+
*
|
|
4
|
+
* Lives in its own module so consumers that only need the ID (e.g. UI
|
|
5
|
+
* code that checks whether a persona has the addon enabled) don't pull
|
|
6
|
+
* in the entire addon-text module. Match the Python constant in
|
|
7
|
+
* `shared/persona_addon_ids.py` exactly.
|
|
8
|
+
*/
|
|
9
|
+
export declare const HELIOS_WORLD_STEERING_ADDON_ID = "helios-world-steering";
|
|
10
|
+
//# sourceMappingURL=toolPromptAddonId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolPromptAddonId.d.ts","sourceRoot":"","sources":["../../src/reactor/toolPromptAddonId.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable string ID for the Helios world-steering prompt addon.
|
|
3
|
+
*
|
|
4
|
+
* Lives in its own module so consumers that only need the ID (e.g. UI
|
|
5
|
+
* code that checks whether a persona has the addon enabled) don't pull
|
|
6
|
+
* in the entire addon-text module. Match the Python constant in
|
|
7
|
+
* `shared/persona_addon_ids.py` exactly.
|
|
8
|
+
*/
|
|
9
|
+
export const HELIOS_WORLD_STEERING_ADDON_ID = 'helios-world-steering';
|
|
10
|
+
//# sourceMappingURL=toolPromptAddonId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolPromptAddonId.js","sourceRoot":"","sources":["../../src/reactor/toolPromptAddonId.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the Reactor / Helios integration layer.
|
|
3
|
+
*
|
|
4
|
+
* These are the framework-agnostic shapes consumed by both seer-agent's
|
|
5
|
+
* React `web/` app and the Vue sibling repo. They describe the inputs
|
|
6
|
+
* and outputs of the pure-function builders in this `reactor/` submodule:
|
|
7
|
+
*
|
|
8
|
+
* - `EntityContext` / `PersonaContext` — knowledge-graph grounding the
|
|
9
|
+
* Seer side aggregates from `ImageRecord` + `EnrichmentRecord` +
|
|
10
|
+
* `PersonaConfig`. Both are LLM-agnostic.
|
|
11
|
+
* - `RegenTemplateInput` — structured form-state for the Gemini Flash
|
|
12
|
+
* Image regen step (consumed by `buildRegenPrompt`). 16:9 is locked
|
|
13
|
+
* at the type level — Helios's reference image must be 16:9, so we
|
|
14
|
+
* enforce it everywhere upstream.
|
|
15
|
+
* - `UpsampleInput` / `UpsampleResult` — input/output for the
|
|
16
|
+
* LLM-agnostic message-pair builder (`buildUpsamplePrompt`). The
|
|
17
|
+
* Seer route translates these into Bedrock Converse messages; the
|
|
18
|
+
* Web-App can route them through a different provider.
|
|
19
|
+
*
|
|
20
|
+
* No runtime exports — type definitions only.
|
|
21
|
+
*
|
|
22
|
+
* `TimelineBeat` and `MapEnrichmentOptions` live in their own
|
|
23
|
+
* module (`./scenesFromEnrichment`) because they're tightly coupled to
|
|
24
|
+
* the mapper's algorithm doc-comments; we re-export them from here so
|
|
25
|
+
* callers importing from `reactor/types` get a single named-type
|
|
26
|
+
* surface.
|
|
27
|
+
*/
|
|
28
|
+
export type { TimelineBeat, MapEnrichmentOptions } from './scenesFromEnrichment';
|
|
29
|
+
export type { HeliosCommand } from './heliosTools';
|
|
30
|
+
/**
|
|
31
|
+
* Knowledge-graph grounding for a single entity from a source video.
|
|
32
|
+
* Aggregated by `aggregateEntityContext` from an `ImageRecord` plus the
|
|
33
|
+
* matching `EnrichmentRecord` for the source video.
|
|
34
|
+
*/
|
|
35
|
+
export interface EntityContext {
|
|
36
|
+
/** Display name of the entity, e.g. "Leo". */
|
|
37
|
+
name: string;
|
|
38
|
+
/** Free-text 1-2 sentence summary of where this entity appears in the
|
|
39
|
+
* source video. Derived from the Pegasus enrichment for the source
|
|
40
|
+
* video. May be undefined when the source video has no enrichment yet,
|
|
41
|
+
* or when the timestamp doesn't match any captured scene. */
|
|
42
|
+
sceneContext?: string;
|
|
43
|
+
/** Source video the image was extracted from. Informational only. */
|
|
44
|
+
sourceVideoId?: string;
|
|
45
|
+
/** Timestamp in the source video (seconds). Informational. */
|
|
46
|
+
sourceTimestamp?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Persona grounding pulled from a `PersonaConfig`. The backstory is the
|
|
50
|
+
* canonical `custom_system_prompt`, truncated to a snippet length sane
|
|
51
|
+
* for prompt injection (~400 chars by convention).
|
|
52
|
+
*/
|
|
53
|
+
export interface PersonaContext {
|
|
54
|
+
/** Persona display name. */
|
|
55
|
+
name: string;
|
|
56
|
+
/** PersonaConfig.custom_system_prompt — the canonical backstory.
|
|
57
|
+
* Truncated to a snippet length so prompts stay within budget. */
|
|
58
|
+
backstory: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Structured form-state for the optional Gemini Flash Image regen step.
|
|
62
|
+
*
|
|
63
|
+
* The `aspectRatio` is a literal `'16:9'` because Helios's reference image
|
|
64
|
+
* must be 16:9 — locking it in the type prevents accidentally generating
|
|
65
|
+
* an image Helios will reject.
|
|
66
|
+
*
|
|
67
|
+
* `styleFamily: 'custom'` requires a non-empty `customStyle`. We can't
|
|
68
|
+
* express that cleanly at the type level without discriminated unions
|
|
69
|
+
* that would explode the call sites, so `buildRegenPrompt` performs the
|
|
70
|
+
* runtime check and throws.
|
|
71
|
+
*/
|
|
72
|
+
export interface RegenTemplateInput {
|
|
73
|
+
/** Locked 16:9 — Helios reference images must be 16:9. */
|
|
74
|
+
aspectRatio: '16:9';
|
|
75
|
+
/** When true (default for the UI), the prompt instructs the model to
|
|
76
|
+
* preserve the source entity's identity. When false, the model is
|
|
77
|
+
* allowed to reinterpret freely. */
|
|
78
|
+
preserveIdentity: boolean;
|
|
79
|
+
/** Camera framing keyword. */
|
|
80
|
+
framing: 'wide' | 'medium' | 'medium-close-up' | 'close-up';
|
|
81
|
+
/** Lighting style keyword. */
|
|
82
|
+
lighting: 'cinematic' | 'golden-hour' | 'noir' | 'natural' | 'studio';
|
|
83
|
+
/** Style-family preset, or `'custom'` to provide a free-text style. */
|
|
84
|
+
styleFamily: 'photoreal' | 'anime' | 'watercolor' | 'pixar' | 'film-35mm' | 'custom';
|
|
85
|
+
/** Required when `styleFamily === 'custom'`. Free-text style descriptor
|
|
86
|
+
* appended in place of the preset. Runtime-validated by
|
|
87
|
+
* `buildRegenPrompt`. */
|
|
88
|
+
customStyle?: string;
|
|
89
|
+
/** Entity grounding — required because regenerated images are entity-anchored. */
|
|
90
|
+
entity: EntityContext;
|
|
91
|
+
/** Optional persona context. When present, the persona backstory is woven
|
|
92
|
+
* into the prompt as character grounding. */
|
|
93
|
+
persona?: PersonaContext;
|
|
94
|
+
/** Free-form creative direction appended verbatim to the prompt. */
|
|
95
|
+
creativeDirection?: string;
|
|
96
|
+
/** Optional structured override — describes what the subject should wear. */
|
|
97
|
+
clothingOverride?: string;
|
|
98
|
+
/** Optional structured override — describes pose/action. */
|
|
99
|
+
poseOverride?: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Input shape for `buildUpsamplePrompt`. All fields except `userPrompt`
|
|
103
|
+
* are optional — the builder includes a section only when its input is
|
|
104
|
+
* present, so callers can pass exactly what they have without padding.
|
|
105
|
+
*/
|
|
106
|
+
export interface UpsampleInput {
|
|
107
|
+
/** Short prompt the user typed. */
|
|
108
|
+
userPrompt: string;
|
|
109
|
+
/** Previous prompt in the same Helios session, if any — used for
|
|
110
|
+
* continuity in follow-up beats. */
|
|
111
|
+
previousPrompt?: string;
|
|
112
|
+
/** Entity grounding — name + scene context from the knowledge graph. */
|
|
113
|
+
entity?: EntityContext;
|
|
114
|
+
/** Persona grounding — backstory from `custom_system_prompt`. */
|
|
115
|
+
persona?: PersonaContext;
|
|
116
|
+
/** Optional small base64 thumbnail (≤ 64KB recommended) of the seed
|
|
117
|
+
* image. When present, it becomes the first content block in the
|
|
118
|
+
* user message so the LLM has a visual reference. */
|
|
119
|
+
thumbnailBase64?: string;
|
|
120
|
+
/** Media type for the thumbnail. Defaults to `'image/jpeg'`. */
|
|
121
|
+
thumbnailMediaType?: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* LLM-agnostic message pair returned by `buildUpsamplePrompt`. The
|
|
125
|
+
* caller translates these into whichever provider's request shape
|
|
126
|
+
* they're using (Bedrock Converse, Anthropic Messages, OpenAI Chat,
|
|
127
|
+
* etc.).
|
|
128
|
+
*
|
|
129
|
+
* `user` is a `ReadonlyArray` of content blocks rather than a plain
|
|
130
|
+
* string because the upsampler can attach an image reference. Even
|
|
131
|
+
* text-only callers receive an array (with a single `text` block) for
|
|
132
|
+
* shape consistency.
|
|
133
|
+
*/
|
|
134
|
+
export interface UpsampleResult {
|
|
135
|
+
/** System message: encodes the Helios prompt-engineering rules and
|
|
136
|
+
* the 80-120 word target. Provider-agnostic prose. */
|
|
137
|
+
system: string;
|
|
138
|
+
/** User message content blocks. Image blocks (when present) precede
|
|
139
|
+
* the text block so the LLM grounds its response on the image. */
|
|
140
|
+
user: ReadonlyArray<{
|
|
141
|
+
type: 'text';
|
|
142
|
+
text: string;
|
|
143
|
+
} | {
|
|
144
|
+
type: 'image';
|
|
145
|
+
mediaType: string;
|
|
146
|
+
base64: string;
|
|
147
|
+
}>;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/reactor/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACjF,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb;;;kEAG8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IAC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E;IACnE,IAAI,EAAE,aAAa,CACf;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAC9B;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CACvD,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/reactor/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `buildUpsamplePrompt` — LLM-agnostic system/user message-pair builder
|
|
3
|
+
* for the knowledge-grounded prompt-upsample step that turns a short
|
|
4
|
+
* user prompt into a Helios-quality dense paragraph.
|
|
5
|
+
*
|
|
6
|
+
* Returns `{system, user}` where `user` is a content-block array so
|
|
7
|
+
* thumbnails can sit alongside text. The caller (web app's Bedrock
|
|
8
|
+
* upsample route, or the Vue sibling) translates this into the
|
|
9
|
+
* provider-specific request shape.
|
|
10
|
+
*
|
|
11
|
+
* The system prompt encodes the Helios prompt-engineering rules
|
|
12
|
+
* (`ai_docs/reference/reactor/helios-prompt-guide.md`):
|
|
13
|
+
* - Detailed scene description with subject + environment + lighting +
|
|
14
|
+
* mood + camera framing
|
|
15
|
+
* - Exactly one new beat per follow-up
|
|
16
|
+
* - Re-anchor the subject with a short identifying phrase
|
|
17
|
+
* - Always specify camera framing
|
|
18
|
+
* - Describe light by its effect on surfaces
|
|
19
|
+
* - Show emotion through behavior, not abstract labels
|
|
20
|
+
* - Be physically specific (textures, materials, spatial relations)
|
|
21
|
+
* - 80-120 word target, ending with a complete sentence
|
|
22
|
+
* - Output only — no preamble or commentary
|
|
23
|
+
*
|
|
24
|
+
* User-message-block ordering: when a thumbnail is present, the image
|
|
25
|
+
* block comes first so the LLM grounds its description on the visual
|
|
26
|
+
* reference before reading the text instructions.
|
|
27
|
+
*/
|
|
28
|
+
import type { UpsampleInput, UpsampleResult } from './types';
|
|
29
|
+
export declare function buildUpsamplePrompt(input: UpsampleInput): UpsampleResult;
|
|
30
|
+
//# sourceMappingURL=upsamplePrompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upsamplePrompt.d.ts","sourceRoot":"","sources":["../../src/reactor/upsamplePrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAGV,aAAa,EACb,cAAc,EACf,MAAM,SAAS,CAAC;AAmEjB,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,cAAc,CAqDxE"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `buildUpsamplePrompt` — LLM-agnostic system/user message-pair builder
|
|
3
|
+
* for the knowledge-grounded prompt-upsample step that turns a short
|
|
4
|
+
* user prompt into a Helios-quality dense paragraph.
|
|
5
|
+
*
|
|
6
|
+
* Returns `{system, user}` where `user` is a content-block array so
|
|
7
|
+
* thumbnails can sit alongside text. The caller (web app's Bedrock
|
|
8
|
+
* upsample route, or the Vue sibling) translates this into the
|
|
9
|
+
* provider-specific request shape.
|
|
10
|
+
*
|
|
11
|
+
* The system prompt encodes the Helios prompt-engineering rules
|
|
12
|
+
* (`ai_docs/reference/reactor/helios-prompt-guide.md`):
|
|
13
|
+
* - Detailed scene description with subject + environment + lighting +
|
|
14
|
+
* mood + camera framing
|
|
15
|
+
* - Exactly one new beat per follow-up
|
|
16
|
+
* - Re-anchor the subject with a short identifying phrase
|
|
17
|
+
* - Always specify camera framing
|
|
18
|
+
* - Describe light by its effect on surfaces
|
|
19
|
+
* - Show emotion through behavior, not abstract labels
|
|
20
|
+
* - Be physically specific (textures, materials, spatial relations)
|
|
21
|
+
* - 80-120 word target, ending with a complete sentence
|
|
22
|
+
* - Output only — no preamble or commentary
|
|
23
|
+
*
|
|
24
|
+
* User-message-block ordering: when a thumbnail is present, the image
|
|
25
|
+
* block comes first so the LLM grounds its description on the visual
|
|
26
|
+
* reference before reading the text instructions.
|
|
27
|
+
*/
|
|
28
|
+
// The Python twin of this builder is
|
|
29
|
+
// `api/reactor/app.py::_build_system_prompt(has_previous)`. Both encode
|
|
30
|
+
// the same Helios prompt-guide rules and BOTH gate the continuity
|
|
31
|
+
// section on whether a previous prompt is provided — this keeps
|
|
32
|
+
// cold-start prompts tighter (fewer rules = less noise) and matches
|
|
33
|
+
// the Python behavior. Keep the two in sync when prompt-engineering
|
|
34
|
+
// changes land.
|
|
35
|
+
const BASE_SYSTEM_RULES = `You expand short user prompts into detailed scene descriptions for a real-time interactive video generation model (Helios). Write a single dense paragraph of strictly 80–120 words. You MUST finish with a complete sentence — never cut off mid-sentence. Output only the expanded prompt, with no preamble, no commentary, and no quotation marks.
|
|
36
|
+
|
|
37
|
+
Follow these rules, drawn from the Helios prompt guide:
|
|
38
|
+
|
|
39
|
+
1. **Scene bible on the first prompt.** When no previous prompt is provided, establish subject + environment + lighting + mood + camera framing in one pass.
|
|
40
|
+
2. **Re-anchor the subject.** Each prompt opens with a short identifying phrase for the main character (e.g. "Leo maintains his regal position", not the full re-description).
|
|
41
|
+
3. **Always specify camera framing.** Every prompt names the shot type (close-up, medium close-up, medium shot, wide shot, tracking shot, static shot) and optionally the motion (slow pullback, smooth tracking).
|
|
42
|
+
4. **Describe light by its effect.** Never say "good lighting" or "bright". Say what the light does to surfaces — "dappled sunlight filtering through the canopy", "neon signs blur across the hood".
|
|
43
|
+
5. **Show emotion through behavior.** Convey feelings through physical actions, posture, and body language. Not "she was curious" but "her eyes momentarily softened as she lowered her head to sniff".
|
|
44
|
+
6. **Be physically specific.** Describe textures, materials, spatial relationships, weight, and motion concretely.
|
|
45
|
+
|
|
46
|
+
If grounding context is provided (entity name, source-scene description, persona backstory, a reference image), incorporate it. Use the entity's real name. Echo specifics from the source scene where they fit. Carry persona traits through into physical behavior. If a reference image is attached, ground the visual description on what you see.`;
|
|
47
|
+
const CONTINUITY_RULES = `A previous prompt from the same Helios session is provided. Maintain visual continuity: keep the same character identity, environment, palette, and camera style. Re-anchor the subject with a short identifying phrase rather than re-describing them in full.
|
|
48
|
+
|
|
49
|
+
Introduce exactly one new narrative beat — a new action, object, or event — and let everything else evolve naturally. Do not introduce multiple changes at once.`;
|
|
50
|
+
function buildSystemPrompt(hasPrevious) {
|
|
51
|
+
return hasPrevious
|
|
52
|
+
? `${BASE_SYSTEM_RULES}\n\n${CONTINUITY_RULES}`
|
|
53
|
+
: BASE_SYSTEM_RULES;
|
|
54
|
+
}
|
|
55
|
+
function buildContextSection(opts) {
|
|
56
|
+
// Structure mirrors `api/reactor/app.py::_build_user_text` — including
|
|
57
|
+
// the source-video + timestamp anchors when present so the LLM has the
|
|
58
|
+
// same temporal grounding from either transport. Format chosen as a
|
|
59
|
+
// light key/value block (rather than free prose) so the model can
|
|
60
|
+
// parse it reliably even when several context fields are populated.
|
|
61
|
+
const lines = [];
|
|
62
|
+
if (opts.entity) {
|
|
63
|
+
if (opts.entity.sceneContext) {
|
|
64
|
+
lines.push(`This is ${opts.entity.name}, who in the source video appears in a scene where ${opts.entity.sceneContext}`);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
lines.push(`This is ${opts.entity.name}.`);
|
|
68
|
+
}
|
|
69
|
+
if (opts.entity.sourceVideoId) {
|
|
70
|
+
lines.push(`Source video: ${opts.entity.sourceVideoId}`);
|
|
71
|
+
}
|
|
72
|
+
if (typeof opts.entity.sourceTimestamp === 'number') {
|
|
73
|
+
lines.push(`Source timestamp: ${opts.entity.sourceTimestamp.toFixed(2)}s`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (opts.persona) {
|
|
77
|
+
lines.push(`Persona backstory for ${opts.persona.name}: ${opts.persona.backstory}`);
|
|
78
|
+
}
|
|
79
|
+
return lines.length > 0 ? lines.join('\n\n') : undefined;
|
|
80
|
+
}
|
|
81
|
+
export function buildUpsamplePrompt(input) {
|
|
82
|
+
const userBlocks = [];
|
|
83
|
+
// Image block first — give the LLM the visual reference before the
|
|
84
|
+
// instructions, so it grounds the description on what it actually sees.
|
|
85
|
+
if (input.thumbnailBase64) {
|
|
86
|
+
const mediaType = input.thumbnailMediaType ?? 'image/jpeg';
|
|
87
|
+
// Strip a data-URL prefix if the caller passed a raw data URL.
|
|
88
|
+
const base64 = input.thumbnailBase64.replace(/^data:image\/\w+;base64,/, '');
|
|
89
|
+
userBlocks.push({ type: 'image', mediaType, base64 });
|
|
90
|
+
}
|
|
91
|
+
// Build the text block. Sections are joined with double newlines so the
|
|
92
|
+
// LLM perceives them as distinct context fields, not a run-on sentence.
|
|
93
|
+
const textParts = [];
|
|
94
|
+
const contextSection = buildContextSection({
|
|
95
|
+
entity: input.entity,
|
|
96
|
+
persona: input.persona,
|
|
97
|
+
});
|
|
98
|
+
if (contextSection) {
|
|
99
|
+
textParts.push(contextSection);
|
|
100
|
+
}
|
|
101
|
+
if (input.previousPrompt) {
|
|
102
|
+
textParts.push(`The previous scene was:\n"${input.previousPrompt}"\n\nIntroduce exactly one new beat (a new action, object, or event). Keep the world, lighting, and camera stable. Re-anchor the subject with a short identifying phrase.`);
|
|
103
|
+
}
|
|
104
|
+
// Hint that the thumbnail is a reference image, but only when we actually
|
|
105
|
+
// attached one — keeps the text instructions truthful.
|
|
106
|
+
if (input.thumbnailBase64) {
|
|
107
|
+
textParts.push('The attached image is a visual reference for the subject and setting. Ground the scene description on what you see.');
|
|
108
|
+
}
|
|
109
|
+
// The user's short prompt always goes last — it's the most-recent-tokens
|
|
110
|
+
// anchor that the model expands.
|
|
111
|
+
textParts.push(`Expand this prompt into a Helios-quality 80–120 word paragraph: "${input.userPrompt}"`);
|
|
112
|
+
userBlocks.push({ type: 'text', text: textParts.join('\n\n') });
|
|
113
|
+
return {
|
|
114
|
+
system: buildSystemPrompt(Boolean(input.previousPrompt)),
|
|
115
|
+
user: userBlocks,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=upsamplePrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upsamplePrompt.js","sourceRoot":"","sources":["../../src/reactor/upsamplePrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AASH,qCAAqC;AACrC,wEAAwE;AACxE,kEAAkE;AAClE,gEAAgE;AAChE,oEAAoE;AACpE,oEAAoE;AACpE,gBAAgB;AAChB,MAAM,iBAAiB,GAAG;;;;;;;;;;;uVAW6T,CAAC;AAExV,MAAM,gBAAgB,GAAG;;iKAEwI,CAAC;AAElK,SAAS,iBAAiB,CAAC,WAAoB;IAC7C,OAAO,WAAW;QAChB,CAAC,CAAC,GAAG,iBAAiB,OAAO,gBAAgB,EAAE;QAC/C,CAAC,CAAC,iBAAiB,CAAC;AACxB,CAAC;AAED,SAAS,mBAAmB,CAAC,IAG5B;IACC,uEAAuE;IACvE,uEAAuE;IACvE,oEAAoE;IACpE,kEAAkE;IAClE,oEAAoE;IACpE,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAC7B,KAAK,CAAC,IAAI,CACR,WAAW,IAAI,CAAC,MAAM,CAAC,IAAI,sDAAsD,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAC5G,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;YAC9B,KAAK,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;QAC3D,CAAC;QACD,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,KAAK,QAA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,CAAC,IAAI,CACZ,6BAA6B,KAAK,CAAC,cAAc,2KAA2K,CAC7N,CAAC;IACJ,CAAC;IAED,0EAA0E;IAC1E,uDAAuD;IACvD,IAAI,KAAK,CAAC,eAAe,EAAE,CAAC;QAC1B,SAAS,CAAC,IAAI,CACZ,qHAAqH,CACtH,CAAC;IACJ,CAAC;IAED,yEAAyE;IACzE,iCAAiC;IACjC,SAAS,CAAC,IAAI,CACZ,oEAAoE,KAAK,CAAC,UAAU,GAAG,CACxF,CAAC;IAEF,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAEhE,OAAO;QACL,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QACxD,IAAI,EAAE,UAAU;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format a duration in seconds as a human-readable time string.
|
|
3
|
+
*
|
|
4
|
+
* Unifies the five inline implementations that lived in
|
|
5
|
+
* `web/app/{chat,chat-ws,jobs,videos,watch}/*` before this lift. Each
|
|
6
|
+
* call site had a slightly different shape:
|
|
7
|
+
* - `m:ss` (jobs page, watch page, videos durations)
|
|
8
|
+
* - `m:ss.cc` with sub-second centiseconds (chat / chat-ws citations)
|
|
9
|
+
* - `m:ss` returning `"-"` for null inputs (videos table)
|
|
10
|
+
* - None supported `h:mm:ss` so 90-minute videos rendered as `90:00`
|
|
11
|
+
*
|
|
12
|
+
* Defaults to `m:ss`, auto-extends to `h:mm:ss` when `seconds >= 3600`,
|
|
13
|
+
* opts into centiseconds via `centiseconds: true`, and returns
|
|
14
|
+
* `fallback` (default `"0:00"`) on null/undefined/NaN/±Infinity/negative
|
|
15
|
+
* inputs so call sites can render gracefully without input guards.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* formatTimestamp(65) // "1:05"
|
|
19
|
+
* formatTimestamp(3725) // "1:02:05" (auto h:mm:ss past 60 min)
|
|
20
|
+
* formatTimestamp(42.34, { centiseconds: true }) // "0:42.34"
|
|
21
|
+
* formatTimestamp(null) // "0:00"
|
|
22
|
+
* formatTimestamp(null, { fallback: '-' }) // "-"
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatTimestamp(seconds: number | null | undefined, options?: {
|
|
25
|
+
centiseconds?: boolean;
|
|
26
|
+
fallback?: string;
|
|
27
|
+
}): string;
|
|
28
|
+
//# sourceMappingURL=timeFormat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeFormat.d.ts","sourceRoot":"","sources":["../src/timeFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAClC,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAC1D,MAAM,CA8BR"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format a duration in seconds as a human-readable time string.
|
|
3
|
+
*
|
|
4
|
+
* Unifies the five inline implementations that lived in
|
|
5
|
+
* `web/app/{chat,chat-ws,jobs,videos,watch}/*` before this lift. Each
|
|
6
|
+
* call site had a slightly different shape:
|
|
7
|
+
* - `m:ss` (jobs page, watch page, videos durations)
|
|
8
|
+
* - `m:ss.cc` with sub-second centiseconds (chat / chat-ws citations)
|
|
9
|
+
* - `m:ss` returning `"-"` for null inputs (videos table)
|
|
10
|
+
* - None supported `h:mm:ss` so 90-minute videos rendered as `90:00`
|
|
11
|
+
*
|
|
12
|
+
* Defaults to `m:ss`, auto-extends to `h:mm:ss` when `seconds >= 3600`,
|
|
13
|
+
* opts into centiseconds via `centiseconds: true`, and returns
|
|
14
|
+
* `fallback` (default `"0:00"`) on null/undefined/NaN/±Infinity/negative
|
|
15
|
+
* inputs so call sites can render gracefully without input guards.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* formatTimestamp(65) // "1:05"
|
|
19
|
+
* formatTimestamp(3725) // "1:02:05" (auto h:mm:ss past 60 min)
|
|
20
|
+
* formatTimestamp(42.34, { centiseconds: true }) // "0:42.34"
|
|
21
|
+
* formatTimestamp(null) // "0:00"
|
|
22
|
+
* formatTimestamp(null, { fallback: '-' }) // "-"
|
|
23
|
+
*/
|
|
24
|
+
export function formatTimestamp(seconds, options = {}) {
|
|
25
|
+
const fallback = options.fallback ?? '0:00';
|
|
26
|
+
if (seconds === null ||
|
|
27
|
+
seconds === undefined ||
|
|
28
|
+
!Number.isFinite(seconds) ||
|
|
29
|
+
seconds < 0) {
|
|
30
|
+
return fallback;
|
|
31
|
+
}
|
|
32
|
+
const total = Math.floor(seconds);
|
|
33
|
+
const h = Math.floor(total / 3600);
|
|
34
|
+
const m = Math.floor((total % 3600) / 60);
|
|
35
|
+
const s = total % 60;
|
|
36
|
+
const pad2 = (n) => n.toString().padStart(2, '0');
|
|
37
|
+
const base = h > 0 ? `${h}:${pad2(m)}:${pad2(s)}` : `${m}:${pad2(s)}`;
|
|
38
|
+
if (options.centiseconds) {
|
|
39
|
+
// 1/100 of a second precision — sufficient for chat citation
|
|
40
|
+
// boundaries and avoids a third trailing digit that adds noise
|
|
41
|
+
// without precision. (Previously called "ms" in chat-ws code; the
|
|
42
|
+
// name was misleading — it's always been centiseconds.)
|
|
43
|
+
const cs = Math.floor((seconds - total) * 100);
|
|
44
|
+
return `${base}.${pad2(cs)}`;
|
|
45
|
+
}
|
|
46
|
+
return base;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=timeFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeFormat.js","sourceRoot":"","sources":["../src/timeFormat.ts"],"names":[],"mappings":"AAAA;;;;;;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C/B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@escapeaihq/client-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Framework-agnostic Seer client library: audio I/O, viseme lip-sync, WebSocket framing, REST. Consumed by both seer-agent's React web/ and the Vue Escape web-app.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`buildRegenPrompt snapshot — full prompt with persona, overrides, creative direction 1`] = `"Reframe Leo as a wide 16:9 cinematic shot while preserving their distinctive features, proportions, and identity from the reference image. 16:9 framing required — the output must be a landscape composition. Use a medium close-up framing the face and upper body. Light the scene with warm golden-hour light, low sun raking across the subject, long soft shadows. Render in 35mm film stock aesthetic, subtle grain, organic colour science, slight halation. Character context: Leo is grounded in the source scene — standing on a rocky outcrop in the jungle. Persona backstory for Leo: A noble jungle king who lost his pride to poachers years ago. Wardrobe: weathered leather mantle. Lean into wistful melancholy."`;
|
|
4
|
+
|
|
5
|
+
exports[`buildRegenPrompt snapshot — minimal input (no persona, no overrides) 1`] = `"Reframe Leo as a wide 16:9 cinematic shot while preserving their distinctive features, proportions, and identity from the reference image. 16:9 framing required — the output must be a landscape composition. Use a medium shot framing the full figure. Light the scene with cinematic lighting with deep shadows, sculpted key light, and a soft cool fill. Render in photorealistic style, naturalistic textures and skin, lifelike depth of field. Character context: Leo is grounded in the source scene — standing on a rocky outcrop in the jungle."`;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`mapEnrichmentToTimeline — shape A (scenes array, timed) maps a representative happy-path enrichment (snapshot) 1`] = `
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
|
+
"chunk": 0,
|
|
7
|
+
"label": "Sunrise",
|
|
8
|
+
"prompt": "A lion surveys the savanna at dawn",
|
|
9
|
+
"sourceEnd": 10,
|
|
10
|
+
"sourceStart": 0,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"chunk": 3,
|
|
14
|
+
"label": "Scene 2",
|
|
15
|
+
"prompt": "The lion descends from his rocky outcrop",
|
|
16
|
+
"sourceEnd": 30,
|
|
17
|
+
"sourceStart": 10,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"chunk": 10,
|
|
21
|
+
"label": "Scene 3",
|
|
22
|
+
"prompt": "A butterfly catches his eye and he gives chase",
|
|
23
|
+
"sourceEnd": 60,
|
|
24
|
+
"sourceStart": 30,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"chunk": 19,
|
|
28
|
+
"label": "Scene 4",
|
|
29
|
+
"prompt": "He returns to the pride at sunset",
|
|
30
|
+
"sourceEnd": 90,
|
|
31
|
+
"sourceStart": 60,
|
|
32
|
+
},
|
|
33
|
+
]
|
|
34
|
+
`;
|