@escapeaihq/client-core 0.49.0 → 0.52.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 +4 -4
- package/dist/adapters/worldAdapter.js +1 -1
- package/dist/conversation/binding.d.ts +28 -1
- package/dist/conversation/binding.d.ts.map +1 -1
- package/dist/conversation/binding.js +12 -0
- package/dist/conversation/binding.js.map +1 -1
- package/dist/conversation/controller.d.ts +16 -0
- package/dist/conversation/controller.d.ts.map +1 -1
- package/dist/conversation/controller.js +22 -0
- package/dist/conversation/controller.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/reactor/dmSceneControlPrompt.d.ts +40 -0
- package/dist/reactor/dmSceneControlPrompt.d.ts.map +1 -0
- package/dist/reactor/dmSceneControlPrompt.js +83 -0
- package/dist/reactor/dmSceneControlPrompt.js.map +1 -0
- package/dist/reactor/index.d.ts +1 -0
- package/dist/reactor/index.d.ts.map +1 -1
- package/dist/reactor/index.js +3 -0
- package/dist/reactor/index.js.map +1 -1
- package/dist/reactor/promptAddonRegistry.js +2 -2
- package/dist/reactor/promptAddonRegistry.js.map +1 -1
- package/dist/reactor/toolPromptAddon.d.ts +37 -28
- package/dist/reactor/toolPromptAddon.d.ts.map +1 -1
- package/dist/reactor/toolPromptAddon.js +48 -100
- package/dist/reactor/toolPromptAddon.js.map +1 -1
- package/dist/websocket.d.ts +119 -2
- package/dist/websocket.d.ts.map +1 -1
- package/dist/websocket.js +73 -0
- package/dist/websocket.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/conversation/binding.test.ts +53 -0
- package/src/__tests__/conversation/controller.test.ts +117 -0
- package/src/__tests__/reactor/promptAddonRegistry.test.ts +3 -1
- package/src/__tests__/reactor/toolPromptAddon.test.ts +34 -42
- package/src/__tests__/websocket-session-attach.test.ts +288 -0
- package/src/conversation/binding.ts +40 -1
- package/src/conversation/controller.ts +39 -0
- package/src/index.ts +10 -4
- package/src/reactor/dmSceneControlPrompt.ts +85 -0
- package/src/reactor/index.ts +3 -0
- package/src/reactor/promptAddonRegistry.ts +2 -2
- package/src/reactor/toolPromptAddon.ts +51 -101
- package/src/websocket.ts +186 -2
|
@@ -57,6 +57,27 @@ export interface ConversationContextBinding {
|
|
|
57
57
|
entityId?: string;
|
|
58
58
|
adventureSessionId?: string;
|
|
59
59
|
partyPersonaIds?: string[];
|
|
60
|
+
/**
|
|
61
|
+
* The persona's system prompt to carry on this conversation (SP1). The `text`
|
|
62
|
+
* send path does NOT load the persona server-side — it reads the prompt from
|
|
63
|
+
* the frame (`api/chat/ws.py` `SendActionMessage.systemPrompt`), unlike the
|
|
64
|
+
* `tts_stt` hello which `_merge_persona_into_hello` resolves server-side. So a
|
|
65
|
+
* standalone persona-face chat must carry the persona's `custom_system_prompt`
|
|
66
|
+
* on the binding for a TYPED turn to speak in-character. Like the other fields
|
|
67
|
+
* it is a `buildHelloPayload` arg, so the binding cannot drift from the wire.
|
|
68
|
+
* Falsy ⇒ dropped (no prompt → the backend uses the default assistant voice;
|
|
69
|
+
* land-dark for non-persona bindings).
|
|
70
|
+
*/
|
|
71
|
+
systemPrompt?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Whether `systemPrompt` REPLACES the default system prompt (`true`) or is
|
|
74
|
+
* appended to it (`false`/omitted). Mirrors `PersonaConfig.system_prompt_override`
|
|
75
|
+
* and `_merge_persona_into_hello`'s `systemPromptOverride` contract. Only sent
|
|
76
|
+
* when `systemPrompt` is present — the `buildHelloPayload` falsy-drop on
|
|
77
|
+
* `systemPrompt` gates both together (audio.ts:453), so an override flag with no
|
|
78
|
+
* prompt is a no-op.
|
|
79
|
+
*/
|
|
80
|
+
systemPromptOverride?: boolean;
|
|
60
81
|
}
|
|
61
82
|
|
|
62
83
|
/**
|
|
@@ -79,12 +100,24 @@ export type HelloArgs = Parameters<typeof buildHelloPayload>[0];
|
|
|
79
100
|
* fields too: an empty-string id is treated as "unset" (ids are real
|
|
80
101
|
* UUIDs/handles — an `''` is a caller mistake, not a value to send), keeping the
|
|
81
102
|
* hello free of meaningless empty fields.
|
|
103
|
+
*
|
|
104
|
+
* `systemPrompt`/`systemPromptOverride` (SP1) follow the SAME falsy-drop: an
|
|
105
|
+
* empty/absent prompt drops BOTH so the wire is byte-identical when unset, and
|
|
106
|
+
* the override flag only rides when a prompt is present (matching
|
|
107
|
+
* `buildHelloPayload`'s `...(systemPrompt ? { systemPrompt, systemPromptOverride } : {})`
|
|
108
|
+
* gate, audio.ts:453).
|
|
82
109
|
*/
|
|
83
110
|
export function toHelloArgs(
|
|
84
111
|
binding: ConversationContextBinding,
|
|
85
112
|
): Pick<
|
|
86
113
|
HelloArgs,
|
|
87
|
-
|
|
114
|
+
| 'videoId'
|
|
115
|
+
| 'personaId'
|
|
116
|
+
| 'entityId'
|
|
117
|
+
| 'adventureSessionId'
|
|
118
|
+
| 'partyPersonaIds'
|
|
119
|
+
| 'systemPrompt'
|
|
120
|
+
| 'systemPromptOverride'
|
|
88
121
|
> {
|
|
89
122
|
return {
|
|
90
123
|
...(binding.videoId ? { videoId: binding.videoId } : {}),
|
|
@@ -96,5 +129,11 @@ export function toHelloArgs(
|
|
|
96
129
|
...(binding.partyPersonaIds && binding.partyPersonaIds.length > 0
|
|
97
130
|
? { partyPersonaIds: [...binding.partyPersonaIds] }
|
|
98
131
|
: {}),
|
|
132
|
+
...(binding.systemPrompt
|
|
133
|
+
? {
|
|
134
|
+
systemPrompt: binding.systemPrompt,
|
|
135
|
+
systemPromptOverride: binding.systemPromptOverride ?? false,
|
|
136
|
+
}
|
|
137
|
+
: {}),
|
|
99
138
|
};
|
|
100
139
|
}
|
|
@@ -60,6 +60,22 @@ export interface ConversationSendOptions {
|
|
|
60
60
|
* passes its prior turns here per send, exactly like the chat-ws page does.
|
|
61
61
|
*/
|
|
62
62
|
messages?: ConversationHistoryMessage[];
|
|
63
|
+
/**
|
|
64
|
+
* A per-send system-prompt override (SP1). When provided, it WINS over the
|
|
65
|
+
* binding's `systemPrompt` — matching `_merge_persona_into_hello`'s
|
|
66
|
+
* client-override-wins contract (a field the client explicitly sends is
|
|
67
|
+
* preserved over the persona's). Omit it and the binding's persona prompt
|
|
68
|
+
* (if any) rides instead; omit both and no prompt is sent (the backend uses
|
|
69
|
+
* the default assistant prompt — land-dark for non-persona conversations).
|
|
70
|
+
*/
|
|
71
|
+
systemPrompt?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Whether `opts.systemPrompt` REPLACES (`true`) or appends to (`false`/omitted)
|
|
74
|
+
* the default prompt. Only meaningful alongside an explicit `opts.systemPrompt`
|
|
75
|
+
* — it is NOT applied to the binding's prompt (the binding carries its own
|
|
76
|
+
* `systemPromptOverride`).
|
|
77
|
+
*/
|
|
78
|
+
systemPromptOverride?: boolean;
|
|
63
79
|
}
|
|
64
80
|
|
|
65
81
|
export interface ConversationControllerOptions {
|
|
@@ -215,6 +231,24 @@ export class ConversationController {
|
|
|
215
231
|
const active = this.activeParticipant();
|
|
216
232
|
const args = this.toHelloArgs();
|
|
217
233
|
const modelId = this.modelOverride ?? active?.modelId;
|
|
234
|
+
// Persona system-prompt (SP1): the `text` send path reads the prompt from
|
|
235
|
+
// THIS frame (it does NOT load the persona server-side — only the `tts_stt`
|
|
236
|
+
// hello does, via `_merge_persona_into_hello`), so a standalone persona chat
|
|
237
|
+
// must thread its prompt on every typed turn or the reply comes back in the
|
|
238
|
+
// default assistant voice. CLIENT-OVERRIDE-WINS, by PRESENCE not truthiness:
|
|
239
|
+
// an explicitly provided `opts.systemPrompt` beats the binding's prompt
|
|
240
|
+
// (mirrors `_merge_persona_into_hello`: a field the client sends is preserved
|
|
241
|
+
// over the persona's). A nullish check (not `||`) means an explicit EMPTY
|
|
242
|
+
// STRING still wins — it clears the bound prompt for this send (the falsy-drop
|
|
243
|
+
// gate below then emits no prompt key), which `||` could not express (it would
|
|
244
|
+
// fall back to the binding). Both nullish on opts ⇒ the binding's prompt rides;
|
|
245
|
+
// falsy on the resolved value ⇒ no prompt key (byte-identical, land-dark for
|
|
246
|
+
// non-persona conversations).
|
|
247
|
+
const systemPrompt = opts?.systemPrompt ?? args.systemPrompt;
|
|
248
|
+
const systemPromptOverride =
|
|
249
|
+
opts?.systemPrompt != null
|
|
250
|
+
? (opts.systemPromptOverride ?? false)
|
|
251
|
+
: (args.systemPromptOverride ?? false);
|
|
218
252
|
this.socket.send(text, {
|
|
219
253
|
...(args.videoId ? { videoId: args.videoId } : {}),
|
|
220
254
|
...(args.entityId ? { entityId: args.entityId } : {}),
|
|
@@ -232,6 +266,11 @@ export class ConversationController {
|
|
|
232
266
|
...(args.personaId ? { personaId: args.personaId } : {}),
|
|
233
267
|
...(active?.personaId ? { personaId: active.personaId } : {}),
|
|
234
268
|
...(modelId ? { modelId } : {}),
|
|
269
|
+
// Persona prompt rides every typed turn (SP1) so the reply is in-character.
|
|
270
|
+
// Both keys travel together (gated on the resolved prompt), matching the
|
|
271
|
+
// `buildHelloPayload`/`SendActionMessage` shape where `systemPromptOverride`
|
|
272
|
+
// is meaningless without `systemPrompt`.
|
|
273
|
+
...(systemPrompt ? { systemPrompt, systemPromptOverride } : {}),
|
|
235
274
|
// Omitted when empty so a zero-history send stays byte-identical to the
|
|
236
275
|
// pre-0.30.0 wire (the backend defaults a missing `messages` to []).
|
|
237
276
|
...(opts?.messages?.length ? { messages: opts.messages } : {}),
|
package/src/index.ts
CHANGED
|
@@ -28,15 +28,21 @@ export * from './websocket';
|
|
|
28
28
|
export * from './api';
|
|
29
29
|
export * from './castProjection';
|
|
30
30
|
export * from './admin';
|
|
31
|
-
export
|
|
31
|
+
// Directory modules MUST re-export their barrel as `./<dir>/index` (not the bare
|
|
32
|
+
// `./<dir>`). Under strict-ESM resolvers (Nuxt/Rollup in the ../Web-App sibling),
|
|
33
|
+
// the published `dist/<dir>` has no `package.json` "main", so `from './<dir>.js'`
|
|
34
|
+
// (what a bare specifier compiles to) fails to resolve. The explicit `/index`
|
|
35
|
+
// makes tsc emit `./<dir>/index.js`, which resolves directly to the real file.
|
|
36
|
+
// See specs/technical-debt.md (client-core ESM barrel directory re-export bug).
|
|
37
|
+
export * from './reactor/index';
|
|
32
38
|
export * from './timeFormat';
|
|
33
39
|
export * from './toolSchemas';
|
|
34
|
-
export * from './vision';
|
|
40
|
+
export * from './vision/index';
|
|
35
41
|
export * from './graphSchema';
|
|
36
42
|
// R8.1 — pure story-graph projections (deriveScenes/deriveCast + SceneView/
|
|
37
43
|
// CharacterView). Grepped src/ for these names first per the collision warning
|
|
38
44
|
// above: no existing export owns them. The web studio module re-exports these.
|
|
39
45
|
export * from './storyGraph';
|
|
40
|
-
export * from './adapters';
|
|
41
|
-
export * from './conversation';
|
|
46
|
+
export * from './adapters/index';
|
|
47
|
+
export * from './conversation/index';
|
|
42
48
|
export * from './platformAssistant';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical DM scene-control prompt vocabulary (Dashboard Spec A §10A.6,
|
|
3
|
+
* Block B) — the SINGLE SOURCE of the world-/scene-steering instruction text on
|
|
4
|
+
* the client side.
|
|
5
|
+
*
|
|
6
|
+
* This mirrors the backend constant
|
|
7
|
+
* `shared/adventure_prompts.py::DM_SCENE_CONTROL_INSTRUCTIONS`. The two live in
|
|
8
|
+
* different runtimes (Python dispatcher vs TS client), so they cannot literally
|
|
9
|
+
* `import` one another; keep them in lock-step (the directive grammar is the
|
|
10
|
+
* contract the backend `DM_SCENE_TAG_PATTERN` parses).
|
|
11
|
+
*
|
|
12
|
+
* A-DM2 RETIRES the legacy Helios world-steering addon text (the divergent
|
|
13
|
+
* `[SET_SCENE]` / `[SWAP_SEED]` marker prose that used to live in
|
|
14
|
+
* `toolPromptAddon.ts`). That prototype vocabulary was a SECOND, drifting
|
|
15
|
+
* scene-steering instruction set (tech-debt #113); it is replaced by this one
|
|
16
|
+
* `[SCENE:...]` grammar so there is exactly one place that teaches a model how to
|
|
17
|
+
* drive the experience surface. `toolPromptAddon.ts::getHeliosSteeringAddonText`
|
|
18
|
+
* now returns THIS text, so any persona that still carries the
|
|
19
|
+
* `helios-world-steering` addon id gets the current vocabulary.
|
|
20
|
+
*
|
|
21
|
+
* NOTE on the runtime command layer: the `HeliosCommand` union +
|
|
22
|
+
* `dispatchHeliosCommand` (the world-ADAPTER capability layer that actually
|
|
23
|
+
* drives the Reactor SDK) are a separate, live concern and are unchanged — they
|
|
24
|
+
* are runtime command dispatch, not model-facing steering PROSE.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Version sentinel embedded in the addon text. Used by
|
|
29
|
+
* `buildHeliosSteeringSystemPrompt` for idempotent reapplication. Bumped from
|
|
30
|
+
* `v1` (the retired `[SET_SCENE]` prose) to `v2` (this `[SCENE:...]` vocabulary)
|
|
31
|
+
* so a cached upstream prompt built against the old prose is detectably stale.
|
|
32
|
+
*/
|
|
33
|
+
export const DM_SCENE_CONTROL_ADDON_SENTINEL =
|
|
34
|
+
'<!-- helios-world-steering-addon:v2 -->';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The canonical `[SCENE:...]` scene-control instruction text. Mirrors the
|
|
38
|
+
* backend `DM_SCENE_CONTROL_INSTRUCTIONS` grammar (same directive kinds, same
|
|
39
|
+
* one-tag-per-own-line rule). Kept as a function (not a const) so callers don't
|
|
40
|
+
* accidentally share-and-mutate the underlying string.
|
|
41
|
+
*/
|
|
42
|
+
export function getDmSceneControlPromptText(): string {
|
|
43
|
+
return [
|
|
44
|
+
DM_SCENE_CONTROL_ADDON_SENTINEL,
|
|
45
|
+
'## Scene Control',
|
|
46
|
+
'',
|
|
47
|
+
'You can control the viewer’s experience surface using scene tags. ' +
|
|
48
|
+
'Emit at most ONE tag per turn, each on its OWN line, after your ' +
|
|
49
|
+
'natural-language reply. The tag is parsed and acted on; it is stripped ' +
|
|
50
|
+
'from what the viewer reads.',
|
|
51
|
+
'',
|
|
52
|
+
'### Tags',
|
|
53
|
+
'',
|
|
54
|
+
'- `[SCENE:enter_world prompt="<optional atmosphere or directive>"]` — ' +
|
|
55
|
+
'transport the viewer into the interactive world model. The optional ' +
|
|
56
|
+
'prompt grounds the world in the established scene (subject, environment, ' +
|
|
57
|
+
'lighting, mood); weave existing character continuity in so identity is ' +
|
|
58
|
+
'preserved across the transition.',
|
|
59
|
+
'- `[SCENE:exit_world]` — return the viewer to the video.',
|
|
60
|
+
'- `[SCENE:seek_video t=<seconds>]` — jump the video to a specific ' +
|
|
61
|
+
'moment (e.g. `t=142.5`).',
|
|
62
|
+
'',
|
|
63
|
+
'### Rules',
|
|
64
|
+
'',
|
|
65
|
+
'1. Use these sparingly and purposefully, as a director would: to ' +
|
|
66
|
+
'punctuate a narrative beat, reveal a hidden moment, or immerse the ' +
|
|
67
|
+
'viewer at a climax.',
|
|
68
|
+
'2. One tag per turn, on its own line, at the END of your response.',
|
|
69
|
+
'3. If you can answer in words alone — describe the world, recall a ' +
|
|
70
|
+
'past moment, plan a beat — do NOT emit a tag. Tags are for actions, ' +
|
|
71
|
+
'not exposition.',
|
|
72
|
+
'',
|
|
73
|
+
'### Example',
|
|
74
|
+
'',
|
|
75
|
+
'User: “Take me into that forest.”',
|
|
76
|
+
'',
|
|
77
|
+
'Assistant: The trees pull close and the air goes green and still — ' +
|
|
78
|
+
'step through.',
|
|
79
|
+
'',
|
|
80
|
+
'[SCENE:enter_world prompt="a hushed old-growth forest at dusk, shafts of ' +
|
|
81
|
+
'green light through the canopy, mist low between the trunks, the path ' +
|
|
82
|
+
'ahead barely visible, mood: hushed and expectant"]',
|
|
83
|
+
'',
|
|
84
|
+
].join('\n');
|
|
85
|
+
}
|
package/src/reactor/index.ts
CHANGED
|
@@ -13,6 +13,9 @@ export * from './scenesFromEnrichment';
|
|
|
13
13
|
// (imported by both mappers); they are deliberately NOT re-exported here.
|
|
14
14
|
export * from './storyTimeline';
|
|
15
15
|
export * from './heliosTools';
|
|
16
|
+
// A-DM2 — canonical [SCENE:...] scene-control vocabulary (single source; the
|
|
17
|
+
// retired-`[SET_SCENE]`-prose replacement, tech-debt #113).
|
|
18
|
+
export * from './dmSceneControlPrompt';
|
|
16
19
|
export * from './toolPromptAddon';
|
|
17
20
|
export * from './entitySearch';
|
|
18
21
|
export * from './heliosCommandDispatcher';
|
|
@@ -37,9 +37,9 @@ export interface PromptAddonDescriptor {
|
|
|
37
37
|
export const KNOWN_PROMPT_ADDONS: readonly PromptAddonDescriptor[] = [
|
|
38
38
|
{
|
|
39
39
|
id: HELIOS_WORLD_STEERING_ADDON_ID,
|
|
40
|
-
label: '
|
|
40
|
+
label: 'Scene control',
|
|
41
41
|
description:
|
|
42
|
-
'Lets this persona drive
|
|
42
|
+
'Lets this persona drive the viewer’s experience surface with scene-control tags ([SCENE:enter_world], [SCENE:seek_video], [SCENE:exit_world]) — transport into the world model, seek the video, or return to it. Auto-enabled when the persona is bound to a source video or character image.',
|
|
43
43
|
},
|
|
44
44
|
];
|
|
45
45
|
|
|
@@ -1,126 +1,76 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* System-prompt addon that teaches a chat model to
|
|
3
|
-
*
|
|
2
|
+
* System-prompt addon that teaches a chat model to drive the viewer's
|
|
3
|
+
* experience surface with scene-control tags.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* `
|
|
9
|
-
*
|
|
10
|
-
* `
|
|
5
|
+
* A-DM2 RETIREMENT (tech-debt #113): this addon used to teach a SECOND,
|
|
6
|
+
* divergent world-steering vocabulary — the legacy `[SET_SCENE]` / `[SWAP_SEED]`
|
|
7
|
+
* / `[PAUSE_WORLD]` marker prose (the Phase-3 Helios prototype, whose only live
|
|
8
|
+
* web consumer `/interactive/chat` was removed in R0-4). That duplicate steering
|
|
9
|
+
* text is GONE. `getHeliosSteeringAddonText()` now delegates to the single
|
|
10
|
+
* canonical scene-control vocabulary in `dmSceneControlPrompt.ts` (the
|
|
11
|
+
* `[SCENE:...]` grammar that mirrors the backend
|
|
12
|
+
* `shared/adventure_prompts.py::DM_SCENE_CONTROL_INSTRUCTIONS` and is parsed by
|
|
13
|
+
* the dispatcher's `DM_SCENE_TAG_PATTERN`). There is now exactly ONE place that
|
|
14
|
+
* teaches a model how to steer the scene.
|
|
11
15
|
*
|
|
12
|
-
* The
|
|
13
|
-
*
|
|
14
|
-
* `
|
|
16
|
+
* The function name + the addon id (`helios-world-steering`) are kept for
|
|
17
|
+
* backward compatibility — `PersonaConfig.prompt_addon_ids` rows, the persona
|
|
18
|
+
* UI, and the pinned `../Web-App` consumer all reference them. Only the TEXT the
|
|
19
|
+
* addon produces changed (now the current `[SCENE:...]` vocabulary).
|
|
20
|
+
*
|
|
21
|
+
* The backend has no awareness of the addon ID's semantics — the field is just
|
|
22
|
+
* metadata on `PersonaConfig`. See `shared/persona_addon_ids.py` for the matching
|
|
23
|
+
* Python constant.
|
|
15
24
|
*/
|
|
16
25
|
|
|
17
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
DM_SCENE_CONTROL_ADDON_SENTINEL,
|
|
28
|
+
getDmSceneControlPromptText,
|
|
29
|
+
} from './dmSceneControlPrompt';
|
|
18
30
|
|
|
19
31
|
export { HELIOS_WORLD_STEERING_ADDON_ID } from './toolPromptAddonId';
|
|
32
|
+
// NOTE: the canonical `getDmSceneControlPromptText` + `DM_SCENE_CONTROL_ADDON_SENTINEL`
|
|
33
|
+
// are exported once from the barrel via `export * from './dmSceneControlPrompt'`
|
|
34
|
+
// (reactor/index.ts) — not re-exported here, to avoid an ambiguous double export.
|
|
20
35
|
|
|
21
36
|
/**
|
|
22
37
|
* Marker the addon uses to verify idempotent reapplication. The build
|
|
23
|
-
* function looks for this string in the base prompt before appending,
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
38
|
+
* function looks for this string in the base prompt before appending, so calling
|
|
39
|
+
* `buildHeliosSteeringSystemPrompt(buildHeliosSteeringSystemPrompt(p))` returns
|
|
40
|
+
* the same value as a single application. Single-sourced from the canonical
|
|
41
|
+
* scene-control module (bumped to `v2` for the retired-prose migration) so the
|
|
42
|
+
* sentinel can't drift from the text it guards.
|
|
28
43
|
*/
|
|
29
|
-
const ADDON_SENTINEL =
|
|
44
|
+
const ADDON_SENTINEL = DM_SCENE_CONTROL_ADDON_SENTINEL;
|
|
30
45
|
|
|
31
46
|
/**
|
|
32
|
-
* Stable, model-friendly addon text that teaches the
|
|
33
|
-
*
|
|
34
|
-
*
|
|
47
|
+
* Stable, model-friendly addon text that teaches the scene-control grammar.
|
|
48
|
+
*
|
|
49
|
+
* RETIRED: the legacy `[SET_SCENE]` marker prose. RETURNS: the single canonical
|
|
50
|
+
* `[SCENE:...]` scene-control vocabulary (`getDmSceneControlPromptText`). Kept as
|
|
51
|
+
* a function (not a const) so callers don't accidentally share-and-mutate the
|
|
35
52
|
* underlying string.
|
|
36
53
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* trained the model against the OLD prose. The sentinel doubles as a
|
|
41
|
-
* "did the LLM see the new version?" diagnostic.
|
|
54
|
+
* @deprecated Prefer {@link getDmSceneControlPromptText} directly — this alias
|
|
55
|
+
* is retained only so existing `helios-world-steering` callers keep working; it
|
|
56
|
+
* now returns the same canonical scene-control text.
|
|
42
57
|
*/
|
|
43
58
|
export function getHeliosSteeringAddonText(): string {
|
|
44
|
-
return
|
|
45
|
-
ADDON_SENTINEL,
|
|
46
|
-
'## World Steering Capability',
|
|
47
|
-
'',
|
|
48
|
-
'This conversation is running alongside a live Helios video stream that ' +
|
|
49
|
-
"you can steer directly. When the user asks you to change the visible " +
|
|
50
|
-
'world — scene changes, atmospheric shifts, character swaps, pausing, ' +
|
|
51
|
-
'resetting — emit ONE of the following bracket-style markers at the ' +
|
|
52
|
-
'VERY END of your response, after your natural-language reply.',
|
|
53
|
-
'',
|
|
54
|
-
'### Markers',
|
|
55
|
-
'',
|
|
56
|
-
'- `[SET_SCENE: "<80-120 word Helios-quality scene prompt>"]` — change ' +
|
|
57
|
-
'the live world to a new scene. The prompt MUST follow the Helios ' +
|
|
58
|
-
"prompt-guide style: name the subject, the environment, the lighting, " +
|
|
59
|
-
'the camera framing (wide / medium / medium close-up / close-up), and ' +
|
|
60
|
-
'the mood. Target 80-120 words. Example argument: "wide cinematic ' +
|
|
61
|
-
'shot, a man in a red coat walks across a snowy bridge at dusk, soft ' +
|
|
62
|
-
"golden hour light streaming through wrought-iron railings, medium " +
|
|
63
|
-
'tracking shot following him from the right, his breath visible in the ' +
|
|
64
|
-
'cold air, distant city lights glowing behind him, mood: contemplative ' +
|
|
65
|
-
'and quietly hopeful, 35mm film grain, cinematic depth of field."',
|
|
66
|
-
'- `[SWAP_SEED: "<entity name>"]` — replace the active seed image ' +
|
|
67
|
-
'with a different entity from the current video. The entity name must ' +
|
|
68
|
-
'match one of the entities the user has shown you (matching is ' +
|
|
69
|
-
"case-insensitive). If you're not sure of the name, don't emit this " +
|
|
70
|
-
'marker — ask the user to clarify instead.',
|
|
71
|
-
'- `[PAUSE_WORLD]` — pause the live stream at the current frame. Use ' +
|
|
72
|
-
'when the user wants to freeze the action.',
|
|
73
|
-
'- `[RESUME_WORLD]` — resume a paused stream.',
|
|
74
|
-
'- `[RESET_WORLD]` — reset the stream to frame 0 and clear pending ' +
|
|
75
|
-
'prompts. Use only when the user explicitly asks to start over.',
|
|
76
|
-
'',
|
|
77
|
-
'### Critical Rules',
|
|
78
|
-
'',
|
|
79
|
-
'1. Emit AT MOST ONE marker per turn. If the user asks for a sequence ' +
|
|
80
|
-
'(e.g. "pause then change the scene"), pick the first action and tell ' +
|
|
81
|
-
'them you\'ll do the next one when they ask.',
|
|
82
|
-
'2. Markers go at the END of your response, after a blank line, never ' +
|
|
83
|
-
'mixed into the middle of prose.',
|
|
84
|
-
'3. SET_SCENE prompts must be detailed and ground in the established ' +
|
|
85
|
-
'world. Bland three-word prompts produce bland output.',
|
|
86
|
-
'4. For SET_SCENE, weave the existing entity / character continuity into ' +
|
|
87
|
-
"the prompt so identity is preserved across the cut. Don't invent a " +
|
|
88
|
-
'brand-new protagonist mid-scene unless the user explicitly asks for ' +
|
|
89
|
-
'one.',
|
|
90
|
-
'5. If the user asks something you can answer in words alone — describe ' +
|
|
91
|
-
"the world, recall a past moment, plan a beat — DON'T emit a marker. " +
|
|
92
|
-
'Markers are for actions, not exposition.',
|
|
93
|
-
'',
|
|
94
|
-
'### Example',
|
|
95
|
-
'',
|
|
96
|
-
'User: "Make it start raining and feel a bit lonelier."',
|
|
97
|
-
'',
|
|
98
|
-
'Assistant: Pulling the warmth out of the light and adding a slow grey ' +
|
|
99
|
-
'rain — give it a beat to settle in.',
|
|
100
|
-
'',
|
|
101
|
-
'[SET_SCENE: "wide cinematic shot, a man in a long coat stands alone on ' +
|
|
102
|
-
'a deserted cobblestone bridge in a slow grey downpour, single sodium ' +
|
|
103
|
-
"streetlamp casting a cone of amber light onto wet stone, distant city " +
|
|
104
|
-
'reflections rippling in puddles, medium tracking shot pulling back ' +
|
|
105
|
-
'slightly, his breath fogging in the cold air, mood: melancholy and ' +
|
|
106
|
-
'introspective, 35mm film grain, shallow depth of field, muted blue and ' +
|
|
107
|
-
'amber color palette, soft falling rain catching the lamp light."]',
|
|
108
|
-
'',
|
|
109
|
-
].join('\n');
|
|
59
|
+
return getDmSceneControlPromptText();
|
|
110
60
|
}
|
|
111
61
|
|
|
112
62
|
/**
|
|
113
|
-
* Concatenate the
|
|
114
|
-
*
|
|
115
|
-
*
|
|
63
|
+
* Concatenate the scene-control addon onto an arbitrary base system prompt.
|
|
64
|
+
* Idempotent: a prompt that already contains the addon sentinel is returned
|
|
65
|
+
* unchanged.
|
|
116
66
|
*
|
|
117
|
-
* An empty base prompt is allowed — the addon stands on its own and
|
|
118
|
-
*
|
|
67
|
+
* An empty base prompt is allowed — the addon stands on its own and works
|
|
68
|
+
* without a persona backstory (the test suite covers this).
|
|
119
69
|
*
|
|
120
|
-
* @param baseSystemPrompt - persona's `custom_system_prompt` (may be
|
|
121
|
-
*
|
|
122
|
-
* @returns concatenated prompt: `<base>\n\n<addon>` when the base is
|
|
123
|
-
*
|
|
70
|
+
* @param baseSystemPrompt - persona's `custom_system_prompt` (may be empty
|
|
71
|
+
* string or whitespace).
|
|
72
|
+
* @returns concatenated prompt: `<base>\n\n<addon>` when the base is non-empty,
|
|
73
|
+
* just `<addon>` otherwise.
|
|
124
74
|
*/
|
|
125
75
|
export function buildHeliosSteeringSystemPrompt(
|
|
126
76
|
baseSystemPrompt: string,
|