@escapeaihq/client-core 0.139.0 → 0.140.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.
@@ -0,0 +1,111 @@
1
+ /**
2
+ * External-runtime event intake — the client half (§Q RUNTIME.3).
3
+ *
4
+ * An external runtime (whatever renders or simulates a scene outside Seer — a
5
+ * game, an XR app, an installation, a simulator) reports physical/gameplay
6
+ * FACTS into a running adventure session's quest ledger; Seer derives the
7
+ * narrative consequences. Two doors, one server ingress:
8
+ *
9
+ * - REST: `POST /api/v1/runtime/sessions/{sessionId}/events` (batched) —
10
+ * {@link RuntimeEventBatchRequest} → {@link RuntimeEventBatchResponse};
11
+ * - WebSocket: the chat socket's `runtime_event` action (one event per frame) —
12
+ * {@link RuntimeEventActionPayload} → a `runtime_event_ack` frame
13
+ * ({@link RuntimeEventAckFrame}).
14
+ *
15
+ * Mirrors `shared/runtime_events.py`. Seer-native, platform-neutral names; no
16
+ * engine or cross-platform-protocol import, by rule.
17
+ *
18
+ * **The clientToken contract.** Unique per genuine event across the session,
19
+ * stable across retries of that event (e.g. `${runtimeTick}:${ordinal}`). A
20
+ * retry with the same token answers `duplicate: true` and changes nothing; a
21
+ * batch naming one token twice is refused whole (HTTP 422).
22
+ */
23
+ /** The WebSocket action name. */
24
+ export declare const RUNTIME_EVENT_ACTION: "runtime_event";
25
+ /** The WebSocket acknowledgement frame type. */
26
+ export declare const RUNTIME_EVENT_ACK_FRAME: "runtime_event_ack";
27
+ /** Most events one REST batch may carry (`RUNTIME_EVENT_BATCH_MAX`). */
28
+ export declare const RUNTIME_EVENT_BATCH_MAX = 50;
29
+ /** The charset and bound a `clientToken` must satisfy. */
30
+ export declare const RUNTIME_CLIENT_TOKEN_PATTERN: RegExp;
31
+ /**
32
+ * The event types the server accepts from an external runtime
33
+ * (`EXTERNAL_RUNTIME_COMMANDABLE_EVENT_TYPES`): facts, never outcomes. Any
34
+ * other type is answered `accepted: false` with a reason.
35
+ */
36
+ export declare const RUNTIME_COMMANDABLE_EVENT_TYPES: readonly ["REACHED_SCENE", "FOUND_OBJECT", "GAMESTATE_SET", "MAP_AREA_UNLOCKED"];
37
+ export type RuntimeCommandableEventType = (typeof RUNTIME_COMMANDABLE_EVENT_TYPES)[number];
38
+ /** One fact the external runtime reports (the quest event vocabulary's camelCase wire). */
39
+ export type RuntimeQuestEvent = {
40
+ type: 'REACHED_SCENE';
41
+ sceneId: string;
42
+ beatId?: string;
43
+ } | {
44
+ type: 'FOUND_OBJECT';
45
+ entityId: string;
46
+ sceneId?: string;
47
+ } | {
48
+ type: 'GAMESTATE_SET';
49
+ key: string;
50
+ value: string;
51
+ } | {
52
+ type: 'MAP_AREA_UNLOCKED';
53
+ locationId: string;
54
+ };
55
+ /** One event of a submission: its token and its fact. */
56
+ export interface RuntimeEventInput {
57
+ clientToken: string;
58
+ event: RuntimeQuestEvent;
59
+ }
60
+ /**
61
+ * What the runtime says is physically present in its scene. Authoritative for
62
+ * `FOUND_OBJECT`: a found object must be listed (an empty list means nothing
63
+ * is present). Omit it and the runtime's own report of the pickup stands.
64
+ */
65
+ export interface RuntimePresence {
66
+ presentEntityIds: string[];
67
+ }
68
+ /** `POST /api/v1/runtime/sessions/{sessionId}/events` body. */
69
+ export interface RuntimeEventBatchRequest {
70
+ events: RuntimeEventInput[];
71
+ presence?: RuntimePresence;
72
+ }
73
+ /** What the server did with one event. */
74
+ export interface RuntimeEventResult {
75
+ clientToken: string;
76
+ eventType: string | null;
77
+ accepted: boolean;
78
+ /** The event replayed an already-recorded one (same token): nothing changed. */
79
+ duplicate: boolean;
80
+ rejectedReason: string | null;
81
+ transitions: Array<Record<string, unknown>>;
82
+ }
83
+ /** The REST door's answer: one result per event, in request order. */
84
+ export interface RuntimeEventBatchResponse {
85
+ traceId: string;
86
+ sessionId: string;
87
+ results: RuntimeEventResult[];
88
+ /** The quest ledger's last seq after the batch. */
89
+ lastSeq: number;
90
+ }
91
+ /** The WebSocket `runtime_event` action (one event per frame). */
92
+ export interface RuntimeEventActionPayload {
93
+ adventureSessionId: string;
94
+ clientToken: string;
95
+ event: RuntimeQuestEvent;
96
+ /** Optional {@link RuntimePresence} for this event. */
97
+ presentEntityIds?: string[];
98
+ }
99
+ /** The WebSocket door's answer to one `runtime_event` action. */
100
+ export interface RuntimeEventAckFrame {
101
+ type: typeof RUNTIME_EVENT_ACK_FRAME;
102
+ traceId: string;
103
+ sessionId: string;
104
+ result: RuntimeEventResult;
105
+ lastSeq: number;
106
+ }
107
+ /** Narrow a parsed chat frame to a {@link RuntimeEventAckFrame}. */
108
+ export declare function isRuntimeEventAck(frame: unknown): frame is RuntimeEventAckFrame;
109
+ /** Whether `token` satisfies the server's `clientToken` charset and bound. */
110
+ export declare function isValidRuntimeClientToken(token: unknown): token is string;
111
+ //# sourceMappingURL=runtimeEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeEvents.d.ts","sourceRoot":"","sources":["../src/runtimeEvents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,iCAAiC;AACjC,eAAO,MAAM,oBAAoB,EAAG,eAAwB,CAAC;AAC7D,gDAAgD;AAChD,eAAO,MAAM,uBAAuB,EAAG,mBAA4B,CAAC;AACpE,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,0DAA0D;AAC1D,eAAO,MAAM,4BAA4B,QAA8B,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,kFAKlC,CAAC;AAEX,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,+BAA+B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3F,2FAA2F;AAC3F,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ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gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,iEAAiE;AACjE,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,OAAO,uBAAuB,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,oEAAoE;AACpE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAQ/E;AAED,8EAA8E;AAC9E,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEzE"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * External-runtime event intake — the client half (§Q RUNTIME.3).
3
+ *
4
+ * An external runtime (whatever renders or simulates a scene outside Seer — a
5
+ * game, an XR app, an installation, a simulator) reports physical/gameplay
6
+ * FACTS into a running adventure session's quest ledger; Seer derives the
7
+ * narrative consequences. Two doors, one server ingress:
8
+ *
9
+ * - REST: `POST /api/v1/runtime/sessions/{sessionId}/events` (batched) —
10
+ * {@link RuntimeEventBatchRequest} → {@link RuntimeEventBatchResponse};
11
+ * - WebSocket: the chat socket's `runtime_event` action (one event per frame) —
12
+ * {@link RuntimeEventActionPayload} → a `runtime_event_ack` frame
13
+ * ({@link RuntimeEventAckFrame}).
14
+ *
15
+ * Mirrors `shared/runtime_events.py`. Seer-native, platform-neutral names; no
16
+ * engine or cross-platform-protocol import, by rule.
17
+ *
18
+ * **The clientToken contract.** Unique per genuine event across the session,
19
+ * stable across retries of that event (e.g. `${runtimeTick}:${ordinal}`). A
20
+ * retry with the same token answers `duplicate: true` and changes nothing; a
21
+ * batch naming one token twice is refused whole (HTTP 422).
22
+ */
23
+ /** The WebSocket action name. */
24
+ export const RUNTIME_EVENT_ACTION = 'runtime_event';
25
+ /** The WebSocket acknowledgement frame type. */
26
+ export const RUNTIME_EVENT_ACK_FRAME = 'runtime_event_ack';
27
+ /** Most events one REST batch may carry (`RUNTIME_EVENT_BATCH_MAX`). */
28
+ export const RUNTIME_EVENT_BATCH_MAX = 50;
29
+ /** The charset and bound a `clientToken` must satisfy. */
30
+ export const RUNTIME_CLIENT_TOKEN_PATTERN = /^[A-Za-z0-9_.:#-]{1,128}$/;
31
+ /**
32
+ * The event types the server accepts from an external runtime
33
+ * (`EXTERNAL_RUNTIME_COMMANDABLE_EVENT_TYPES`): facts, never outcomes. Any
34
+ * other type is answered `accepted: false` with a reason.
35
+ */
36
+ export const RUNTIME_COMMANDABLE_EVENT_TYPES = [
37
+ 'REACHED_SCENE',
38
+ 'FOUND_OBJECT',
39
+ 'GAMESTATE_SET',
40
+ 'MAP_AREA_UNLOCKED',
41
+ ];
42
+ /** Narrow a parsed chat frame to a {@link RuntimeEventAckFrame}. */
43
+ export function isRuntimeEventAck(frame) {
44
+ if (typeof frame !== 'object' || frame === null)
45
+ return false;
46
+ const candidate = frame;
47
+ return (candidate.type === RUNTIME_EVENT_ACK_FRAME &&
48
+ typeof candidate.result === 'object' &&
49
+ candidate.result !== null);
50
+ }
51
+ /** Whether `token` satisfies the server's `clientToken` charset and bound. */
52
+ export function isValidRuntimeClientToken(token) {
53
+ return typeof token === 'string' && RUNTIME_CLIENT_TOKEN_PATTERN.test(token);
54
+ }
55
+ //# sourceMappingURL=runtimeEvents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeEvents.js","sourceRoot":"","sources":["../src/runtimeEvents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,iCAAiC;AACjC,MAAM,CAAC,MAAM,oBAAoB,GAAG,eAAwB,CAAC;AAC7D,gDAAgD;AAChD,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAA4B,CAAC;AACpE,wEAAwE;AACxE,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAC1C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,4BAA4B,GAAG,2BAA2B,CAAC;AAExE;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,eAAe;IACf,cAAc;IACd,eAAe;IACf,mBAAmB;CACX,CAAC;AAsEX,oEAAoE;AACpE,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,SAAS,GAAG,KAA6C,CAAC;IAChE,OAAO,CACL,SAAS,CAAC,IAAI,KAAK,uBAAuB;QAC1C,OAAO,SAAS,CAAC,MAAM,KAAK,QAAQ;QACpC,SAAS,CAAC,MAAM,KAAK,IAAI,CAC1B,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,yBAAyB,CAAC,KAAc;IACtD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,4BAA4B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC/E,CAAC"}
@@ -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,yBAAyB,EAC9B,KAAK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