@escapeaihq/client-core 0.139.0 → 0.141.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/dist/api.d.ts +122 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +71 -0
- package/dist/api.js.map +1 -1
- package/dist/domains/adventureDefinitions.d.ts +14 -4
- package/dist/domains/adventureDefinitions.d.ts.map +1 -1
- package/dist/domains/adventureDefinitions.js +14 -4
- package/dist/domains/adventureDefinitions.js.map +1 -1
- package/dist/domains/personas.d.ts +3 -0
- package/dist/domains/personas.d.ts.map +1 -1
- package/dist/domains/personas.js +6 -0
- package/dist/domains/personas.js.map +1 -1
- package/dist/domains/runtime.d.ts +25 -0
- package/dist/domains/runtime.d.ts.map +1 -0
- package/dist/domains/runtime.js +29 -0
- package/dist/domains/runtime.js.map +1 -0
- package/dist/domains/showcase.d.ts +16 -1
- package/dist/domains/showcase.d.ts.map +1 -1
- package/dist/domains/showcase.js +15 -0
- package/dist/domains/showcase.js.map +1 -1
- package/dist/generated/contract.d.ts +7 -1
- package/dist/generated/contract.d.ts.map +1 -1
- package/dist/generated/contract.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/runtimeEvents.d.ts +111 -0
- package/dist/runtimeEvents.d.ts.map +1 -0
- package/dist/runtimeEvents.js +55 -0
- package/dist/runtimeEvents.js.map +1 -0
- package/dist/sceneBridge.d.ts +193 -0
- package/dist/sceneBridge.d.ts.map +1 -0
- package/dist/sceneBridge.js +329 -0
- package/dist/sceneBridge.js.map +1 -0
- package/dist/voiceCloneCaption.d.ts +7 -1
- package/dist/voiceCloneCaption.d.ts.map +1 -1
- package/dist/voiceCloneCaption.js +26 -1
- package/dist/voiceCloneCaption.js.map +1 -1
- package/dist/websocket.d.ts +18 -1
- package/dist/websocket.d.ts.map +1 -1
- package/dist/websocket.js +16 -0
- package/dist/websocket.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/api.adventure-definitions.test.ts +16 -0
- package/src/__tests__/castFramePipelinePending.test.ts +56 -1
- package/src/__tests__/persona-generation.test.ts +26 -0
- package/src/__tests__/scene-bridge.test.ts +314 -0
- package/src/__tests__/voiceCloneCaption.test.ts +56 -0
- package/src/api.ts +156 -0
- package/src/domains/adventureDefinitions.ts +14 -4
- package/src/domains/personas.ts +7 -0
- package/src/domains/runtime.ts +38 -0
- package/src/domains/showcase.ts +24 -1
- package/src/generated/contract.ts +10 -0
- package/src/index.ts +3 -0
- package/src/runtimeEvents.ts +127 -0
- package/src/sceneBridge.ts +433 -0
- package/src/voiceCloneCaption.ts +36 -2
- package/src/websocket.ts +25 -1
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scene bridge — connect an embedded scene to a running adventure session
|
|
3
|
+
* (§Q RUNTIME.3, owner ruling R-D16).
|
|
4
|
+
*
|
|
5
|
+
* A transport-agnostic, DOM-free adapter between Seer's chat event stream and a
|
|
6
|
+
* scene (a rendered 3D world, an XR app, an installation — whatever the
|
|
7
|
+
* embedding host shows). The host owns the wire on both sides:
|
|
8
|
+
*
|
|
9
|
+
* - **Outbound** — the host feeds every chat frame to {@link SceneBridge.applyFrame}
|
|
10
|
+
* (and wires {@link SceneBridge.handleViseme} / {@link SceneBridge.createVisemeScheduler}
|
|
11
|
+
* into its audio playback); the bridge projects them into a small neutral
|
|
12
|
+
* vocabulary ({@link SceneOutboundMessage}) and hands each one to the host's
|
|
13
|
+
* `post(message)`: who is speaking, the mouth shape per speaker,
|
|
14
|
+
* emotion / cue / trigger tags, interaction end, quest state change, DM
|
|
15
|
+
* directive, and the result of each event the scene reported.
|
|
16
|
+
* - **Inbound** — the host passes each message the scene sends to
|
|
17
|
+
* {@link SceneBridge.receive}; a `runtime_event` message is submitted to Seer
|
|
18
|
+
* through the host's {@link SceneEventSubmitter} (the chat socket's
|
|
19
|
+
* `runtime_event` action or the REST door — see
|
|
20
|
+
* {@link chatSocketRuntimeEventSubmitter} / {@link restRuntimeEventSubmitter}).
|
|
21
|
+
*
|
|
22
|
+
* It re-derives nothing: speaker state and quest pushes come from
|
|
23
|
+
* {@link ConversationRuntime}; speaker staging and per-persona mouth delivery go
|
|
24
|
+
* through {@link bindPresence} onto a {@link PresenceAdapter} the bridge
|
|
25
|
+
* implements; mouth shapes come from {@link VisemeScheduler}; tags are parsed by
|
|
26
|
+
* {@link parseSeerMessage}, with a hold-back so a tag split across two streamed
|
|
27
|
+
* tokens (`[hap` + `py]`) is still read once ({@link SeerTagStream}).
|
|
28
|
+
*
|
|
29
|
+
* Platform-neutral by rule: no engine, device or cross-platform-protocol
|
|
30
|
+
* import, and no host's legacy message names — a host maps this vocabulary onto
|
|
31
|
+
* its own wire in a thin adapter.
|
|
32
|
+
*/
|
|
33
|
+
import { ConversationRuntime } from './conversation/runtime';
|
|
34
|
+
import type { RosterParticipant } from './conversation/types';
|
|
35
|
+
import { type ParsedSeerMessage, type SeerEmotion, type SeerNonverbalCue } from './messageContent';
|
|
36
|
+
import { RUNTIME_EVENT_ACTION, type RuntimeEventActionPayload, type RuntimeEventBatchRequest, type RuntimeEventBatchResponse, type RuntimeEventResult, type RuntimeQuestEvent } from './runtimeEvents';
|
|
37
|
+
import { VisemeScheduler, type VisemeSymbol } from './visemeScheduler';
|
|
38
|
+
import type { ChatWsEvent, QuestNewlyAvailable, QuestStateChange } from './websocket';
|
|
39
|
+
/** What the bridge posts to the scene. */
|
|
40
|
+
export type SceneOutboundMessage =
|
|
41
|
+
/** The persona now speaking (`null`: nobody holds the floor). */
|
|
42
|
+
{
|
|
43
|
+
type: 'speaker';
|
|
44
|
+
personaId: string | null;
|
|
45
|
+
}
|
|
46
|
+
/** One mouth shape for one speaker (`rest` when they stop). */
|
|
47
|
+
| {
|
|
48
|
+
type: 'mouth';
|
|
49
|
+
personaId: string;
|
|
50
|
+
viseme: VisemeSymbol;
|
|
51
|
+
} | {
|
|
52
|
+
type: 'emotion';
|
|
53
|
+
personaId: string | null;
|
|
54
|
+
emotion: SeerEmotion;
|
|
55
|
+
} | {
|
|
56
|
+
type: 'cue';
|
|
57
|
+
personaId: string | null;
|
|
58
|
+
cue: SeerNonverbalCue;
|
|
59
|
+
} | {
|
|
60
|
+
type: 'trigger';
|
|
61
|
+
personaId: string | null;
|
|
62
|
+
name: string;
|
|
63
|
+
}
|
|
64
|
+
/** The speaker ended the interaction: an `[INTERACTION_END]` tag, or the turn finished without one. */
|
|
65
|
+
| {
|
|
66
|
+
type: 'interaction_end';
|
|
67
|
+
personaId: string | null;
|
|
68
|
+
reason: 'tag' | 'turn_done';
|
|
69
|
+
}
|
|
70
|
+
/** The session's quest state moved (a `quest_state_changed` push for this session). */
|
|
71
|
+
| {
|
|
72
|
+
type: 'quest_state';
|
|
73
|
+
sessionId: string;
|
|
74
|
+
lastSeq: number;
|
|
75
|
+
changes: QuestStateChange[];
|
|
76
|
+
mapUnlocks: string[];
|
|
77
|
+
newlyAvailable: QuestNewlyAvailable;
|
|
78
|
+
}
|
|
79
|
+
/** A Dungeon-Master scene directive (`[SCENE:…]`, delivered server-side as `dm_directive`). */
|
|
80
|
+
| {
|
|
81
|
+
type: 'dm_directive';
|
|
82
|
+
directive: string;
|
|
83
|
+
params: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
/** What Seer did with one event the scene reported. */
|
|
86
|
+
| {
|
|
87
|
+
type: 'runtime_event_result';
|
|
88
|
+
result: RuntimeEventResult;
|
|
89
|
+
};
|
|
90
|
+
/** What a scene may send the bridge. */
|
|
91
|
+
export interface SceneRuntimeEventMessage {
|
|
92
|
+
type: typeof RUNTIME_EVENT_ACTION;
|
|
93
|
+
/** Unique per genuine event, stable across retries (the server's idempotency key). */
|
|
94
|
+
clientToken: string;
|
|
95
|
+
event: RuntimeQuestEvent;
|
|
96
|
+
/** What the scene says is physically present (authoritative for `FOUND_OBJECT`). */
|
|
97
|
+
presentEntityIds?: string[];
|
|
98
|
+
}
|
|
99
|
+
export type SceneInboundMessage = SceneRuntimeEventMessage;
|
|
100
|
+
/**
|
|
101
|
+
* Submit one scene event to Seer. Return the server's result (REST), or nothing
|
|
102
|
+
* when the result arrives later as a frame through {@link SceneBridge.applyFrame}
|
|
103
|
+
* (the chat socket's `runtime_event_ack`).
|
|
104
|
+
*/
|
|
105
|
+
export type SceneEventSubmitter = (message: SceneRuntimeEventMessage) => Promise<RuntimeEventResult | void> | RuntimeEventResult | void;
|
|
106
|
+
export interface SceneBridgeOptions {
|
|
107
|
+
/** The adventure session the scene is connected to. */
|
|
108
|
+
adventureSessionId: string;
|
|
109
|
+
/** The host's sink for outbound messages (e.g. a `postMessage` wrapper). */
|
|
110
|
+
post: (message: SceneOutboundMessage) => void;
|
|
111
|
+
/** How inbound scene events reach Seer. */
|
|
112
|
+
submit: SceneEventSubmitter;
|
|
113
|
+
/**
|
|
114
|
+
* The roster to stage. A participant whose `presence` is `PRESENCE_NONE`
|
|
115
|
+
* gets no speaker/mouth messages (the {@link bindPresence} stage gate).
|
|
116
|
+
* Ignored when `runtime` is given (its roster is used).
|
|
117
|
+
*/
|
|
118
|
+
participants?: readonly RosterParticipant[];
|
|
119
|
+
/**
|
|
120
|
+
* A runtime the host already drives. When given, the host keeps feeding it
|
|
121
|
+
* and {@link SceneBridge.applyFrame} does not forward frames to it; when
|
|
122
|
+
* omitted, the bridge owns a runtime and feeds it from `applyFrame`.
|
|
123
|
+
*/
|
|
124
|
+
runtime?: ConversationRuntime;
|
|
125
|
+
}
|
|
126
|
+
/** Longest unclosed `[…` the tag stream holds back before releasing it as text. */
|
|
127
|
+
export declare const SCENE_TAG_HOLD_MAX = 64;
|
|
128
|
+
/**
|
|
129
|
+
* Incremental {@link parseSeerMessage} over streamed tokens. Text is released
|
|
130
|
+
* up to (not including) the last `[` that has no `]` after it, so a tag split
|
|
131
|
+
* across tokens is parsed once, whole. An unclosed `[` longer than
|
|
132
|
+
* {@link SCENE_TAG_HOLD_MAX} is released as text (it is not a tag).
|
|
133
|
+
*/
|
|
134
|
+
export declare class SeerTagStream {
|
|
135
|
+
private pending;
|
|
136
|
+
/** Append streamed text; the parse of whatever is now safe to release (or `null`). */
|
|
137
|
+
push(text: string): ParsedSeerMessage | null;
|
|
138
|
+
/** Release whatever is held (end of turn). */
|
|
139
|
+
flush(): ParsedSeerMessage | null;
|
|
140
|
+
}
|
|
141
|
+
/** Connects one scene to one adventure session. See the module docs. */
|
|
142
|
+
export declare class SceneBridge {
|
|
143
|
+
private readonly opts;
|
|
144
|
+
/** The conversation runtime the bridge reads speaker and quest state from. */
|
|
145
|
+
readonly runtime: ConversationRuntime;
|
|
146
|
+
private readonly ownsRuntime;
|
|
147
|
+
private readonly binding;
|
|
148
|
+
private readonly unsubscribe;
|
|
149
|
+
private readonly streams;
|
|
150
|
+
private readonly endedByTag;
|
|
151
|
+
private readonly lastMouth;
|
|
152
|
+
private lastQuest;
|
|
153
|
+
private disposed;
|
|
154
|
+
constructor(opts: SceneBridgeOptions);
|
|
155
|
+
/** Feed one chat frame (every frame the host's chat socket delivers). */
|
|
156
|
+
applyFrame(frame: ChatWsEvent): void;
|
|
157
|
+
/**
|
|
158
|
+
* One scheduled mouth shape for the CURRENT speaker — pass this as the
|
|
159
|
+
* `onVisemeChange` callback of the host's {@link VisemeScheduler} (or of an
|
|
160
|
+
* `AudioPipeline`, which wraps one). Attributed to the persona whose turn is
|
|
161
|
+
* in flight, falling back to the floor holder.
|
|
162
|
+
*/
|
|
163
|
+
readonly handleViseme: (viseme: string) => void;
|
|
164
|
+
/** A {@link VisemeScheduler} on the host's audio clock that drives {@link handleViseme}. */
|
|
165
|
+
createVisemeScheduler(audioContext: AudioContext): VisemeScheduler;
|
|
166
|
+
/**
|
|
167
|
+
* Accept one message from the scene. Returns `true` when it was a message
|
|
168
|
+
* the bridge understands (a `runtime_event`), `false` otherwise (ignored —
|
|
169
|
+
* a newer scene's message kind never throws). A malformed `runtime_event` is
|
|
170
|
+
* answered with a refused `runtime_event_result` and never submitted.
|
|
171
|
+
*/
|
|
172
|
+
receive(message: unknown): boolean;
|
|
173
|
+
/** Stop posting and unstage every participant. Idempotent. */
|
|
174
|
+
dispose(): void;
|
|
175
|
+
private submit;
|
|
176
|
+
private post;
|
|
177
|
+
private speakingPersonaId;
|
|
178
|
+
private onRuntimeState;
|
|
179
|
+
private onText;
|
|
180
|
+
private endTurn;
|
|
181
|
+
private emitTags;
|
|
182
|
+
private presenceAdapter;
|
|
183
|
+
private postMouth;
|
|
184
|
+
}
|
|
185
|
+
/** Submit scene events over the chat socket's `runtime_event` action (results arrive as frames). */
|
|
186
|
+
export declare function chatSocketRuntimeEventSubmitter(socket: {
|
|
187
|
+
sendRuntimeEvent(payload: RuntimeEventActionPayload): void;
|
|
188
|
+
}, adventureSessionId: string): SceneEventSubmitter;
|
|
189
|
+
/** Submit scene events over `POST /api/v1/runtime/sessions/{id}/events`, one per request. */
|
|
190
|
+
export declare function restRuntimeEventSubmitter(api: {
|
|
191
|
+
submitRuntimeEvents(sessionId: string, request: RuntimeEventBatchRequest): Promise<RuntimeEventBatchResponse>;
|
|
192
|
+
}, adventureSessionId: string): SceneEventSubmitter;
|
|
193
|
+
//# sourceMappingURL=sceneBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sceneBridge.d.ts","sourceRoot":"","sources":["../src/sceneBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAA4B,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,yBA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CACvC,GAAG,EAAE;IACH,mBAAmB,CACjB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACvC,EACD,kBAAkB,EAAE,MAAM,GACzB,mBAAmB,CAUrB"}
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scene bridge — connect an embedded scene to a running adventure session
|
|
3
|
+
* (§Q RUNTIME.3, owner ruling R-D16).
|
|
4
|
+
*
|
|
5
|
+
* A transport-agnostic, DOM-free adapter between Seer's chat event stream and a
|
|
6
|
+
* scene (a rendered 3D world, an XR app, an installation — whatever the
|
|
7
|
+
* embedding host shows). The host owns the wire on both sides:
|
|
8
|
+
*
|
|
9
|
+
* - **Outbound** — the host feeds every chat frame to {@link SceneBridge.applyFrame}
|
|
10
|
+
* (and wires {@link SceneBridge.handleViseme} / {@link SceneBridge.createVisemeScheduler}
|
|
11
|
+
* into its audio playback); the bridge projects them into a small neutral
|
|
12
|
+
* vocabulary ({@link SceneOutboundMessage}) and hands each one to the host's
|
|
13
|
+
* `post(message)`: who is speaking, the mouth shape per speaker,
|
|
14
|
+
* emotion / cue / trigger tags, interaction end, quest state change, DM
|
|
15
|
+
* directive, and the result of each event the scene reported.
|
|
16
|
+
* - **Inbound** — the host passes each message the scene sends to
|
|
17
|
+
* {@link SceneBridge.receive}; a `runtime_event` message is submitted to Seer
|
|
18
|
+
* through the host's {@link SceneEventSubmitter} (the chat socket's
|
|
19
|
+
* `runtime_event` action or the REST door — see
|
|
20
|
+
* {@link chatSocketRuntimeEventSubmitter} / {@link restRuntimeEventSubmitter}).
|
|
21
|
+
*
|
|
22
|
+
* It re-derives nothing: speaker state and quest pushes come from
|
|
23
|
+
* {@link ConversationRuntime}; speaker staging and per-persona mouth delivery go
|
|
24
|
+
* through {@link bindPresence} onto a {@link PresenceAdapter} the bridge
|
|
25
|
+
* implements; mouth shapes come from {@link VisemeScheduler}; tags are parsed by
|
|
26
|
+
* {@link parseSeerMessage}, with a hold-back so a tag split across two streamed
|
|
27
|
+
* tokens (`[hap` + `py]`) is still read once ({@link SeerTagStream}).
|
|
28
|
+
*
|
|
29
|
+
* Platform-neutral by rule: no engine, device or cross-platform-protocol
|
|
30
|
+
* import, and no host's legacy message names — a host maps this vocabulary onto
|
|
31
|
+
* its own wire in a thin adapter.
|
|
32
|
+
*/
|
|
33
|
+
import { bindPresence } from './conversation/presenceBus.js';
|
|
34
|
+
import { ConversationRuntime } from './conversation/runtime.js';
|
|
35
|
+
import { parseSeerMessage, } from './messageContent.js';
|
|
36
|
+
import { isRuntimeEventAck, isValidRuntimeClientToken, RUNTIME_EVENT_ACTION, } from './runtimeEvents.js';
|
|
37
|
+
import { normalizeVisemeSymbol, VisemeScheduler } from './visemeScheduler.js';
|
|
38
|
+
/** Longest unclosed `[…` the tag stream holds back before releasing it as text. */
|
|
39
|
+
export const SCENE_TAG_HOLD_MAX = 64;
|
|
40
|
+
/**
|
|
41
|
+
* Incremental {@link parseSeerMessage} over streamed tokens. Text is released
|
|
42
|
+
* up to (not including) the last `[` that has no `]` after it, so a tag split
|
|
43
|
+
* across tokens is parsed once, whole. An unclosed `[` longer than
|
|
44
|
+
* {@link SCENE_TAG_HOLD_MAX} is released as text (it is not a tag).
|
|
45
|
+
*/
|
|
46
|
+
export class SeerTagStream {
|
|
47
|
+
pending = '';
|
|
48
|
+
/** Append streamed text; the parse of whatever is now safe to release (or `null`). */
|
|
49
|
+
push(text) {
|
|
50
|
+
this.pending += text;
|
|
51
|
+
const open = this.pending.lastIndexOf('[');
|
|
52
|
+
const held = open !== -1 &&
|
|
53
|
+
this.pending.indexOf(']', open) === -1 &&
|
|
54
|
+
this.pending.length - open <= SCENE_TAG_HOLD_MAX;
|
|
55
|
+
const cut = held ? open : this.pending.length;
|
|
56
|
+
const ready = this.pending.slice(0, cut);
|
|
57
|
+
this.pending = this.pending.slice(cut);
|
|
58
|
+
return ready ? parseSeerMessage(ready) : null;
|
|
59
|
+
}
|
|
60
|
+
/** Release whatever is held (end of turn). */
|
|
61
|
+
flush() {
|
|
62
|
+
const rest = this.pending;
|
|
63
|
+
this.pending = '';
|
|
64
|
+
return rest ? parseSeerMessage(rest) : null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const NO_PERSONA = '\u0000';
|
|
68
|
+
/** Connects one scene to one adventure session. See the module docs. */
|
|
69
|
+
export class SceneBridge {
|
|
70
|
+
opts;
|
|
71
|
+
/** The conversation runtime the bridge reads speaker and quest state from. */
|
|
72
|
+
runtime;
|
|
73
|
+
ownsRuntime;
|
|
74
|
+
binding;
|
|
75
|
+
unsubscribe;
|
|
76
|
+
streams = new Map();
|
|
77
|
+
endedByTag = new Set();
|
|
78
|
+
lastMouth = new Map();
|
|
79
|
+
lastQuest;
|
|
80
|
+
disposed = false;
|
|
81
|
+
constructor(opts) {
|
|
82
|
+
this.opts = opts;
|
|
83
|
+
this.ownsRuntime = opts.runtime === undefined;
|
|
84
|
+
this.runtime =
|
|
85
|
+
opts.runtime ??
|
|
86
|
+
new ConversationRuntime({
|
|
87
|
+
adventureSessionId: opts.adventureSessionId,
|
|
88
|
+
participants: opts.participants ?? [],
|
|
89
|
+
});
|
|
90
|
+
this.lastQuest = this.runtime.getState().latestQuestChange;
|
|
91
|
+
this.binding = bindPresence(this.runtime, this.presenceAdapter());
|
|
92
|
+
this.unsubscribe = this.runtime.subscribe((state) => this.onRuntimeState(state));
|
|
93
|
+
}
|
|
94
|
+
/** Feed one chat frame (every frame the host's chat socket delivers). */
|
|
95
|
+
applyFrame(frame) {
|
|
96
|
+
if (this.disposed)
|
|
97
|
+
return;
|
|
98
|
+
if (this.ownsRuntime)
|
|
99
|
+
this.runtime.applyFrame(frame);
|
|
100
|
+
if (isRuntimeEventAck(frame)) {
|
|
101
|
+
if (frame.sessionId === this.opts.adventureSessionId) {
|
|
102
|
+
this.post({ type: 'runtime_event_result', result: frame.result });
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
switch (frame.type) {
|
|
107
|
+
case 'token':
|
|
108
|
+
this.onText(frame.personaId ?? this.speakingPersonaId(), frame.content);
|
|
109
|
+
return;
|
|
110
|
+
case 'done':
|
|
111
|
+
this.endTurn(frame.personaId ?? null);
|
|
112
|
+
return;
|
|
113
|
+
case 'dm_directive':
|
|
114
|
+
this.post({ type: 'dm_directive', directive: frame.directive, params: frame.params });
|
|
115
|
+
return;
|
|
116
|
+
case 'error':
|
|
117
|
+
if (frame.action === RUNTIME_EVENT_ACTION && typeof frame.clientToken === 'string') {
|
|
118
|
+
this.post({
|
|
119
|
+
type: 'runtime_event_result',
|
|
120
|
+
result: refused(frame.clientToken, null, frame.message),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
124
|
+
default:
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* One scheduled mouth shape for the CURRENT speaker — pass this as the
|
|
130
|
+
* `onVisemeChange` callback of the host's {@link VisemeScheduler} (or of an
|
|
131
|
+
* `AudioPipeline`, which wraps one). Attributed to the persona whose turn is
|
|
132
|
+
* in flight, falling back to the floor holder.
|
|
133
|
+
*/
|
|
134
|
+
handleViseme = (viseme) => {
|
|
135
|
+
if (this.disposed)
|
|
136
|
+
return;
|
|
137
|
+
const personaId = this.speakingPersonaId();
|
|
138
|
+
if (personaId === null)
|
|
139
|
+
return;
|
|
140
|
+
this.binding.applyViseme(personaId, normalizeVisemeSymbol({ phoneSymbol: '', visemeSymbol: viseme }));
|
|
141
|
+
};
|
|
142
|
+
/** A {@link VisemeScheduler} on the host's audio clock that drives {@link handleViseme}. */
|
|
143
|
+
createVisemeScheduler(audioContext) {
|
|
144
|
+
return new VisemeScheduler(audioContext, this.handleViseme);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Accept one message from the scene. Returns `true` when it was a message
|
|
148
|
+
* the bridge understands (a `runtime_event`), `false` otherwise (ignored —
|
|
149
|
+
* a newer scene's message kind never throws). A malformed `runtime_event` is
|
|
150
|
+
* answered with a refused `runtime_event_result` and never submitted.
|
|
151
|
+
*/
|
|
152
|
+
receive(message) {
|
|
153
|
+
if (this.disposed || typeof message !== 'object' || message === null)
|
|
154
|
+
return false;
|
|
155
|
+
const candidate = message;
|
|
156
|
+
if (candidate.type !== RUNTIME_EVENT_ACTION)
|
|
157
|
+
return false;
|
|
158
|
+
const token = candidate.clientToken;
|
|
159
|
+
const event = candidate.event;
|
|
160
|
+
if (!isValidRuntimeClientToken(token)) {
|
|
161
|
+
this.post({
|
|
162
|
+
type: 'runtime_event_result',
|
|
163
|
+
result: refused(typeof token === 'string' ? token : '', null, 'clientToken is missing or malformed'),
|
|
164
|
+
});
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
if (typeof event !== 'object' || event === null || typeof event.type !== 'string') {
|
|
168
|
+
this.post({ type: 'runtime_event_result', result: refused(token, null, 'event.type is missing') });
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
const presence = candidate.presentEntityIds;
|
|
172
|
+
if (presence !== undefined && !(Array.isArray(presence) && presence.every((id) => typeof id === 'string'))) {
|
|
173
|
+
this.post({
|
|
174
|
+
type: 'runtime_event_result',
|
|
175
|
+
result: refused(token, event.type, 'presentEntityIds must be a list of strings'),
|
|
176
|
+
});
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
const submission = {
|
|
180
|
+
type: RUNTIME_EVENT_ACTION,
|
|
181
|
+
clientToken: token,
|
|
182
|
+
event: candidate.event,
|
|
183
|
+
...(presence !== undefined ? { presentEntityIds: presence } : {}),
|
|
184
|
+
};
|
|
185
|
+
void this.submit(submission);
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
/** Stop posting and unstage every participant. Idempotent. */
|
|
189
|
+
dispose() {
|
|
190
|
+
if (this.disposed)
|
|
191
|
+
return;
|
|
192
|
+
this.disposed = true;
|
|
193
|
+
this.unsubscribe();
|
|
194
|
+
this.binding.dispose();
|
|
195
|
+
}
|
|
196
|
+
async submit(message) {
|
|
197
|
+
try {
|
|
198
|
+
const result = await this.opts.submit(message);
|
|
199
|
+
if (result)
|
|
200
|
+
this.post({ type: 'runtime_event_result', result });
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
this.post({
|
|
204
|
+
type: 'runtime_event_result',
|
|
205
|
+
result: refused(message.clientToken, message.event.type, `submit failed: ${error instanceof Error ? error.message : String(error)}`),
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
post(message) {
|
|
210
|
+
if (!this.disposed)
|
|
211
|
+
this.opts.post(message);
|
|
212
|
+
}
|
|
213
|
+
speakingPersonaId() {
|
|
214
|
+
const state = this.runtime.getState();
|
|
215
|
+
return state.inFlightPersonaId ?? state.activePersonaId;
|
|
216
|
+
}
|
|
217
|
+
onRuntimeState(state) {
|
|
218
|
+
const change = state.latestQuestChange;
|
|
219
|
+
if (change !== null && change !== this.lastQuest) {
|
|
220
|
+
this.post({
|
|
221
|
+
type: 'quest_state',
|
|
222
|
+
sessionId: change.sessionId,
|
|
223
|
+
lastSeq: change.lastSeq,
|
|
224
|
+
changes: change.changes,
|
|
225
|
+
mapUnlocks: change.mapUnlocks,
|
|
226
|
+
newlyAvailable: change.newlyAvailable,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
this.lastQuest = change;
|
|
230
|
+
}
|
|
231
|
+
onText(personaId, text) {
|
|
232
|
+
const key = personaId ?? NO_PERSONA;
|
|
233
|
+
let stream = this.streams.get(key);
|
|
234
|
+
if (!stream) {
|
|
235
|
+
stream = new SeerTagStream();
|
|
236
|
+
this.streams.set(key, stream);
|
|
237
|
+
}
|
|
238
|
+
this.emitTags(personaId, stream.push(text));
|
|
239
|
+
}
|
|
240
|
+
endTurn(personaId) {
|
|
241
|
+
const keys = personaId === null ? [...this.streams.keys()] : [personaId];
|
|
242
|
+
if (keys.length === 0)
|
|
243
|
+
keys.push(this.speakingPersonaId() ?? NO_PERSONA);
|
|
244
|
+
for (const key of keys) {
|
|
245
|
+
const who = key === NO_PERSONA ? null : key;
|
|
246
|
+
const stream = this.streams.get(key);
|
|
247
|
+
if (stream)
|
|
248
|
+
this.emitTags(who, stream.flush());
|
|
249
|
+
if (!this.endedByTag.has(key)) {
|
|
250
|
+
this.post({ type: 'interaction_end', personaId: who, reason: 'turn_done' });
|
|
251
|
+
}
|
|
252
|
+
this.streams.delete(key);
|
|
253
|
+
this.endedByTag.delete(key);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
emitTags(personaId, parsed) {
|
|
257
|
+
if (parsed === null)
|
|
258
|
+
return;
|
|
259
|
+
for (const emotion of parsed.emotions)
|
|
260
|
+
this.post({ type: 'emotion', personaId, emotion });
|
|
261
|
+
for (const token of parsed.tokens) {
|
|
262
|
+
if (token.kind === 'cue')
|
|
263
|
+
this.post({ type: 'cue', personaId, cue: token.name });
|
|
264
|
+
}
|
|
265
|
+
for (const name of parsed.triggers)
|
|
266
|
+
this.post({ type: 'trigger', personaId, name });
|
|
267
|
+
if (parsed.interactionEnded) {
|
|
268
|
+
const key = personaId ?? NO_PERSONA;
|
|
269
|
+
if (!this.endedByTag.has(key)) {
|
|
270
|
+
this.endedByTag.add(key);
|
|
271
|
+
this.post({ type: 'interaction_end', personaId, reason: 'tag' });
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
presenceAdapter() {
|
|
276
|
+
return {
|
|
277
|
+
mount: () => undefined,
|
|
278
|
+
unmount: (personaId) => {
|
|
279
|
+
this.lastMouth.delete(personaId);
|
|
280
|
+
},
|
|
281
|
+
setActiveParticipant: (personaId) => this.post({ type: 'speaker', personaId }),
|
|
282
|
+
setSpeaking: (personaId, speaking) => {
|
|
283
|
+
if (!speaking)
|
|
284
|
+
this.postMouth(personaId, 'rest');
|
|
285
|
+
},
|
|
286
|
+
applyViseme: (personaId, viseme) => this.postMouth(personaId, viseme),
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
postMouth(personaId, viseme) {
|
|
290
|
+
if (this.lastMouth.get(personaId) === viseme)
|
|
291
|
+
return;
|
|
292
|
+
this.lastMouth.set(personaId, viseme);
|
|
293
|
+
this.post({ type: 'mouth', personaId, viseme });
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function refused(clientToken, eventType, reason) {
|
|
297
|
+
return {
|
|
298
|
+
clientToken,
|
|
299
|
+
eventType,
|
|
300
|
+
accepted: false,
|
|
301
|
+
duplicate: false,
|
|
302
|
+
rejectedReason: reason,
|
|
303
|
+
transitions: [],
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
/** Submit scene events over the chat socket's `runtime_event` action (results arrive as frames). */
|
|
307
|
+
export function chatSocketRuntimeEventSubmitter(socket, adventureSessionId) {
|
|
308
|
+
return (message) => {
|
|
309
|
+
socket.sendRuntimeEvent({
|
|
310
|
+
adventureSessionId,
|
|
311
|
+
clientToken: message.clientToken,
|
|
312
|
+
event: message.event,
|
|
313
|
+
...(message.presentEntityIds !== undefined ? { presentEntityIds: message.presentEntityIds } : {}),
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/** Submit scene events over `POST /api/v1/runtime/sessions/{id}/events`, one per request. */
|
|
318
|
+
export function restRuntimeEventSubmitter(api, adventureSessionId) {
|
|
319
|
+
return async (message) => {
|
|
320
|
+
const response = await api.submitRuntimeEvents(adventureSessionId, {
|
|
321
|
+
events: [{ clientToken: message.clientToken, event: message.event }],
|
|
322
|
+
...(message.presentEntityIds !== undefined
|
|
323
|
+
? { presence: { presentEntityIds: message.presentEntityIds } }
|
|
324
|
+
: {}),
|
|
325
|
+
});
|
|
326
|
+
return response.results[0];
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
//# sourceMappingURL=sceneBridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sceneBridge.js","s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AAC;AACJ,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,+BAA+B,CAC7C,MAAsE,EACtE,kBAA0B;IAE1B,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,CAAC,gBAAgB,CAAC;YACtB,kBAAkB;YAClB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,GAAG,CAAC,OAAO,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClG,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,yBAAyB,CACvC,GAKC,EACD,kBAA0B;IAE1B,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,mBAAmB,CAAC,kBAAkB,EAAE;YACjE,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;YACpE,GAAG,CAAC,OAAO,CAAC,gBAAgB,KAAK,SAAS;gBACxC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,EAAE,EAAE;gBAC9D,CAAC,CAAC,EAAE,CAAC;SACR,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -8,10 +8,16 @@
|
|
|
8
8
|
* whose creator chose a stock voice. Each caption states only what the
|
|
9
9
|
* persona's `voice_clone_outcome` record proves.
|
|
10
10
|
*/
|
|
11
|
-
import type { PersonaConfig, RecloneIneligibleReason, VoiceCloneStatus } from './api';
|
|
11
|
+
import type { PersonaConfig, RecloneIneligibleReason, VoiceCloneSkipCause, VoiceCloneStatus } from './api';
|
|
12
12
|
/** Statuses where the persona ended on the default voice although a clone was
|
|
13
13
|
* wanted — mirror of `shared/persona_models.py` `VOICE_CLONE_FALLBACK_STATUSES`. */
|
|
14
14
|
export declare const VOICE_CLONE_FALLBACK_STATUSES: ReadonlySet<VoiceCloneStatus>;
|
|
15
|
+
/**
|
|
16
|
+
* §Q PERS.130 — the plain reason shown for each `skipped_no_dialogue` cause
|
|
17
|
+
* (`VoiceCloneOutcome.cause`). Before this, every empty harvest read "no
|
|
18
|
+
* dialogue to clone", including the clone the speech-grounding gate refused.
|
|
19
|
+
*/
|
|
20
|
+
export declare const VOICE_CLONE_SKIP_CAPTIONS: Readonly<Record<VoiceCloneSkipCause, string>>;
|
|
15
21
|
/** The reason shown in a caption is shortened to this many characters. */
|
|
16
22
|
export declare const VOICE_CLONE_CAPTION_REASON_MAX_CHARS = 120;
|
|
17
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voiceCloneCaption.d.ts","sourceRoot":"","sources":["../src/voiceCloneCaption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"voiceCloneCaption.d.ts","sourceRoot":"","sources":["../src/voiceCloneCaption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EAEvB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,OAAO,CAAC;AAEf;qFACqF;AACrF,eAAO,MAAM,6BAA6B,EAAE,WAAW,CAAC,gBAAgB,CAKtE,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAUnF,CAAC;AAaF,0EAA0E;AAC1E,eAAO,MAAM,oCAAoC,MAAM,CAAC;AASxD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,qBAAqB,CAAC,GAAG,IAAI,GAAG,SAAS,GACrE,MAAM,GAAG,IAAI,CAgBf;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,MAAM,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAGzF,CAAC;AAEF;sFACsF;AACtF,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,2BAA2B,CAAC,GAAG,IAAI,GAAG,SAAS,GAC3E,MAAM,GAAG,IAAI,CAIf"}
|
|
@@ -16,6 +16,31 @@ export const VOICE_CLONE_FALLBACK_STATUSES = new Set([
|
|
|
16
16
|
'refused',
|
|
17
17
|
'failed',
|
|
18
18
|
]);
|
|
19
|
+
/**
|
|
20
|
+
* §Q PERS.130 — the plain reason shown for each `skipped_no_dialogue` cause
|
|
21
|
+
* (`VoiceCloneOutcome.cause`). Before this, every empty harvest read "no
|
|
22
|
+
* dialogue to clone", including the clone the speech-grounding gate refused.
|
|
23
|
+
*/
|
|
24
|
+
export const VOICE_CLONE_SKIP_CAPTIONS = {
|
|
25
|
+
no_character: 'not linked to a character in the video',
|
|
26
|
+
speech_unverified: 'their voice was not confirmed as theirs; pick their voice sample to allow a clone',
|
|
27
|
+
speech_untimed: 'their confirmed speech has no usable timing to sample',
|
|
28
|
+
lines_unusable: 'their lines have no usable timing to sample',
|
|
29
|
+
lines_too_short: 'each of their lines is too short to sample',
|
|
30
|
+
lines_unreadable: 'their lines could not be read back from the video',
|
|
31
|
+
audio_unusable: 'no usable audio could be cut from their lines',
|
|
32
|
+
no_speech_matched: 'no speech in this video is matched to a speaker yet',
|
|
33
|
+
no_lines_matched: 'no lines in this video are matched to them',
|
|
34
|
+
};
|
|
35
|
+
/** The caption for a `skipped_no_dialogue` row that names no cause this build
|
|
36
|
+
* knows (a row written before the field, or a newer backend's cause). */
|
|
37
|
+
const LEGACY_NO_DIALOGUE_REASON = 'no dialogue to clone';
|
|
38
|
+
function skipReason(cause) {
|
|
39
|
+
if (cause && Object.prototype.hasOwnProperty.call(VOICE_CLONE_SKIP_CAPTIONS, cause)) {
|
|
40
|
+
return VOICE_CLONE_SKIP_CAPTIONS[cause];
|
|
41
|
+
}
|
|
42
|
+
return LEGACY_NO_DIALOGUE_REASON;
|
|
43
|
+
}
|
|
19
44
|
/** The reason shown in a caption is shortened to this many characters. */
|
|
20
45
|
export const VOICE_CLONE_CAPTION_REASON_MAX_CHARS = 120;
|
|
21
46
|
function shortReason(reason) {
|
|
@@ -42,7 +67,7 @@ export function voiceCloneCaption(persona) {
|
|
|
42
67
|
case 'failed':
|
|
43
68
|
return `voice: stock (clone failed${reason ? `: ${reason}` : ''})`;
|
|
44
69
|
case 'skipped_no_dialogue':
|
|
45
|
-
return
|
|
70
|
+
return `voice: stock (${skipReason(outcome.cause)})`;
|
|
46
71
|
case 'skipped_insufficient_audio':
|
|
47
72
|
return 'voice: stock (too little dialogue audio to clone)';
|
|
48
73
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voiceCloneCaption.js","sourceRoot":"","sources":["../src/voiceCloneCaption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"voiceCloneCaption.js","sourceRoot":"","sources":["../src/voiceCloneCaption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAUH;qFACqF;AACrF,MAAM,CAAC,MAAM,6BAA6B,GAAkC,IAAI,GAAG,CAAmB;IACpG,qBAAqB;IACrB,4BAA4B;IAC5B,SAAS;IACT,QAAQ;CACT,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAkD;IACtF,YAAY,EAAE,wCAAwC;IACtD,iBAAiB,EAAE,mFAAmF;IACtG,cAAc,EAAE,uDAAuD;IACvE,cAAc,EAAE,6CAA6C;IAC7D,eAAe,EAAE,4CAA4C;IAC7D,gBAAgB,EAAE,mDAAmD;IACrE,cAAc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