@reactor-models/lingbot 0.2.18 → 0.2.20
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 +26 -26
- package/dist/chunk-5PONKO72.mjs +226 -0
- package/dist/chunk-5PONKO72.mjs.map +1 -0
- package/dist/chunk-G4UFL3VC.mjs +194 -0
- package/dist/chunk-G4UFL3VC.mjs.map +1 -0
- package/dist/core.d.mts +326 -0
- package/dist/core.d.ts +326 -0
- package/dist/core.js +254 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +15 -0
- package/dist/core.mjs.map +1 -0
- package/dist/index.d.mts +3 -450
- package/dist/index.d.ts +3 -450
- package/dist/index.js +190 -194
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -393
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +143 -0
- package/dist/react.d.ts +143 -0
- package/dist/react.js +233 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +39 -0
- package/dist/react.mjs.map +1 -0
- package/package.json +11 -1
package/dist/core.js
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/core.ts
|
|
21
|
+
var core_exports = {};
|
|
22
|
+
__export(core_exports, {
|
|
23
|
+
FileRef: () => import_js_sdk.FileRef,
|
|
24
|
+
LingbotModel: () => LingbotModel,
|
|
25
|
+
LingbotTracks: () => LingbotTracks,
|
|
26
|
+
MODEL_NAME: () => MODEL_NAME,
|
|
27
|
+
MODEL_VERSION: () => MODEL_VERSION
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(core_exports);
|
|
30
|
+
var import_js_sdk = require("@reactor-team/js-sdk");
|
|
31
|
+
var MODEL_NAME = "lingbot";
|
|
32
|
+
var MODEL_VERSION = "v0.2.20";
|
|
33
|
+
var LingbotTracks = [
|
|
34
|
+
{ name: "main_video", kind: "video", direction: "recvonly" }
|
|
35
|
+
];
|
|
36
|
+
function _unwrapMessage(raw) {
|
|
37
|
+
const env = raw;
|
|
38
|
+
if (env && typeof env === "object" && env.data && typeof env.data === "object") {
|
|
39
|
+
return { ...env.data, type: env.type };
|
|
40
|
+
}
|
|
41
|
+
return raw;
|
|
42
|
+
}
|
|
43
|
+
var LingbotModel = class extends import_js_sdk.Reactor {
|
|
44
|
+
constructor(options) {
|
|
45
|
+
super({
|
|
46
|
+
...options,
|
|
47
|
+
modelName: MODEL_NAME,
|
|
48
|
+
modelTracks: [...LingbotTracks]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** @deprecated The model client now extends `Reactor` directly — call methods on `this` instead. This accessor returns `this` for backwards compatibility and will be removed in a future major release. */
|
|
52
|
+
get reactor() {
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
/** Pause generation after the current chunk finishes. Frames stop streaming on `main_video` until `resume` is called. Requires generation to be active. Emits `generation_paused` and `state` on success, or `command_error` if not generating or already paused. */
|
|
56
|
+
async pause() {
|
|
57
|
+
await this.sendCommand("pause", {});
|
|
58
|
+
}
|
|
59
|
+
/** Abort the current run, clear the active prompt and reference image, and return to the waiting state. Valid at any time. After `reset`, call `set_prompt` and `set_image` again before `start` to begin a new session. Emits `generation_reset` and `state`. */
|
|
60
|
+
async reset() {
|
|
61
|
+
await this.sendCommand("reset", {});
|
|
62
|
+
}
|
|
63
|
+
/** Begin generating video on `main_video`. Requires both a prompt (via `set_prompt`) and a reference image (via `set_image`). Emits `generation_started` and `state` on success, or `command_error` if a precondition is missing. Has no effect while already generating. */
|
|
64
|
+
async start() {
|
|
65
|
+
await this.sendCommand("start", {});
|
|
66
|
+
}
|
|
67
|
+
/** Resume generation from a previous `pause`. Requires the session to be paused. Emits `generation_resumed` and `state` on success, or `command_error` if not paused. */
|
|
68
|
+
async resume() {
|
|
69
|
+
await this.sendCommand("resume", {});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Set seed
|
|
73
|
+
* @param params - Set seed
|
|
74
|
+
*/
|
|
75
|
+
async setSeed(params) {
|
|
76
|
+
await this.sendCommand("set_seed", params);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Provide a reference image that anchors generation (image-to-video). Call before `start`; the image is required for generation to begin. Changes during generation have no effect until `reset` is issued and `start` is called again. Emits `image_accepted`, `conditions_ready`, and `state` on success, or `command_error` if the file is missing, not an image, or cannot be decoded.
|
|
80
|
+
* @param params - Provide a reference image that anchors generation (image-to-video). Call before `start`; the image is required for generation to begin. Changes during generation have no effect until `reset` is issued and `start` is called again. Emits `image_accepted`, `conditions_ready`, and `state` on success, or `command_error` if the file is missing, not an image, or cannot be decoded.
|
|
81
|
+
*/
|
|
82
|
+
async setImage(params) {
|
|
83
|
+
await this.sendCommand("set_image", params);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Set the scene prompt. Valid at any time — call before `start` to arm generation, or hot-swap during generation to steer the next chunk. Emits `prompt_accepted`, `conditions_ready`, and `state` on success.
|
|
87
|
+
* @param params - Set the scene prompt. Valid at any time — call before `start` to arm generation, or hot-swap during generation to steer the next chunk. Emits `prompt_accepted`, `conditions_ready`, and `state` on success.
|
|
88
|
+
*/
|
|
89
|
+
async setPrompt(params) {
|
|
90
|
+
await this.sendCommand("set_prompt", params);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Set movement
|
|
94
|
+
* @param params - Set movement
|
|
95
|
+
*/
|
|
96
|
+
async setMovement(params) {
|
|
97
|
+
await this.sendCommand("set_movement", params);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Set look_vertical
|
|
101
|
+
* @param params - Set look_vertical
|
|
102
|
+
*/
|
|
103
|
+
async setLookVertical(params) {
|
|
104
|
+
await this.sendCommand("set_look_vertical", params);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Set look_horizontal
|
|
108
|
+
* @param params - Set look_horizontal
|
|
109
|
+
*/
|
|
110
|
+
async setLookHorizontal(params) {
|
|
111
|
+
await this.sendCommand("set_look_horizontal", params);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Set rotation_speed_deg
|
|
115
|
+
* @param params - Set rotation_speed_deg
|
|
116
|
+
*/
|
|
117
|
+
async setRotationSpeedDeg(params) {
|
|
118
|
+
await this.sendCommand("set_rotation_speed_deg", params);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Subscribe to typed model messages.
|
|
122
|
+
* @param handler - Called with a discriminated LingbotMessage
|
|
123
|
+
* @returns Unsubscribe function
|
|
124
|
+
*/
|
|
125
|
+
onMessage(handler) {
|
|
126
|
+
const wrappedHandler = (raw) => {
|
|
127
|
+
handler(_unwrapMessage(raw));
|
|
128
|
+
};
|
|
129
|
+
this.on("message", wrappedHandler);
|
|
130
|
+
return () => this.off("message", wrappedHandler);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Subscribe to "state" messages only.
|
|
134
|
+
* @returns Unsubscribe function
|
|
135
|
+
*/
|
|
136
|
+
onState(handler) {
|
|
137
|
+
return this.onMessage((msg) => {
|
|
138
|
+
if (msg.type === "state") handler(msg);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Subscribe to "command_error" messages only.
|
|
143
|
+
* @returns Unsubscribe function
|
|
144
|
+
*/
|
|
145
|
+
onCommandError(handler) {
|
|
146
|
+
return this.onMessage((msg) => {
|
|
147
|
+
if (msg.type === "command_error") handler(msg);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Subscribe to "chunk_complete" messages only.
|
|
152
|
+
* @returns Unsubscribe function
|
|
153
|
+
*/
|
|
154
|
+
onChunkComplete(handler) {
|
|
155
|
+
return this.onMessage((msg) => {
|
|
156
|
+
if (msg.type === "chunk_complete") handler(msg);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Subscribe to "image_accepted" messages only.
|
|
161
|
+
* @returns Unsubscribe function
|
|
162
|
+
*/
|
|
163
|
+
onImageAccepted(handler) {
|
|
164
|
+
return this.onMessage((msg) => {
|
|
165
|
+
if (msg.type === "image_accepted") handler(msg);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Subscribe to "prompt_accepted" messages only.
|
|
170
|
+
* @returns Unsubscribe function
|
|
171
|
+
*/
|
|
172
|
+
onPromptAccepted(handler) {
|
|
173
|
+
return this.onMessage((msg) => {
|
|
174
|
+
if (msg.type === "prompt_accepted") handler(msg);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Subscribe to "conditions_ready" messages only.
|
|
179
|
+
* @returns Unsubscribe function
|
|
180
|
+
*/
|
|
181
|
+
onConditionsReady(handler) {
|
|
182
|
+
return this.onMessage((msg) => {
|
|
183
|
+
if (msg.type === "conditions_ready") handler(msg);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Subscribe to "generation_reset" messages only.
|
|
188
|
+
* @returns Unsubscribe function
|
|
189
|
+
*/
|
|
190
|
+
onGenerationReset(handler) {
|
|
191
|
+
return this.onMessage((msg) => {
|
|
192
|
+
if (msg.type === "generation_reset") handler(msg);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Subscribe to "generation_paused" messages only.
|
|
197
|
+
* @returns Unsubscribe function
|
|
198
|
+
*/
|
|
199
|
+
onGenerationPaused(handler) {
|
|
200
|
+
return this.onMessage((msg) => {
|
|
201
|
+
if (msg.type === "generation_paused") handler(msg);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Subscribe to "generation_resumed" messages only.
|
|
206
|
+
* @returns Unsubscribe function
|
|
207
|
+
*/
|
|
208
|
+
onGenerationResumed(handler) {
|
|
209
|
+
return this.onMessage((msg) => {
|
|
210
|
+
if (msg.type === "generation_resumed") handler(msg);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Subscribe to "generation_started" messages only.
|
|
215
|
+
* @returns Unsubscribe function
|
|
216
|
+
*/
|
|
217
|
+
onGenerationStarted(handler) {
|
|
218
|
+
return this.onMessage((msg) => {
|
|
219
|
+
if (msg.type === "generation_started") handler(msg);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Subscribe to "generation_complete" messages only.
|
|
224
|
+
* @returns Unsubscribe function
|
|
225
|
+
*/
|
|
226
|
+
onGenerationComplete(handler) {
|
|
227
|
+
return this.onMessage((msg) => {
|
|
228
|
+
if (msg.type === "generation_complete") handler(msg);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Subscribe to the "main_video" recvonly video track the model publishes.
|
|
233
|
+
*
|
|
234
|
+
* The handler fires once the model starts publishing this track; it receives the live MediaStreamTrack and the parent MediaStream (useful for attaching to a `<video>` / `<audio>` element via `srcObject`).
|
|
235
|
+
* @param handler - Called with the received track and its stream
|
|
236
|
+
* @returns Unsubscribe function
|
|
237
|
+
*/
|
|
238
|
+
onMainVideo(handler) {
|
|
239
|
+
const wrapped = (name, t, s) => {
|
|
240
|
+
if (name === "main_video") handler(t, s);
|
|
241
|
+
};
|
|
242
|
+
this.on("trackReceived", wrapped);
|
|
243
|
+
return () => this.off("trackReceived", wrapped);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
247
|
+
0 && (module.exports = {
|
|
248
|
+
FileRef,
|
|
249
|
+
LingbotModel,
|
|
250
|
+
LingbotTracks,
|
|
251
|
+
MODEL_NAME,
|
|
252
|
+
MODEL_VERSION
|
|
253
|
+
});
|
|
254
|
+
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core.ts"],"sourcesContent":["// Copyright (c) 2026 Reactor Technologies, Inc. All rights reserved.\n\n// Auto-generated by @reactor-team/codegen — DO NOT EDIT\n// Model: lingbot v0.2.20\n\nimport { Reactor, FileRef } from \"@reactor-team/js-sdk\";\nexport { FileRef };\n\nexport const MODEL_NAME = \"lingbot\" as const;\nexport const MODEL_VERSION = \"v0.2.20\" as const;\n\n/**\n * Preset media tracks for the Lingbot model.\n *\n * Declared in the model's OpenAPI schema and passed to the SDK as\n * `modelTracks` so the transport can prepare the SDP offer in\n * parallel with session polling (faster first-frame latency).\n */\nexport const LingbotTracks = [\n { name: \"main_video\", kind: \"video\", direction: \"recvonly\" },\n] as const;\n\n/** Track names the client can subscribe to (recvonly, from the client's perspective). */\nexport type LingbotRecvTrackName =\n \"main_video\";\n\n/** Set seed */\nexport interface LingbotSetSeedParams {\n /**\n * Seed for the random generator used to sample the initial noise. Must be a non-negative integer; the model never draws its own random seed — pick one explicitly (or keep the default) for reproducible runs. Read once when `start` fires; later changes take effect only after `reset` followed by a new `start`.\n * @minimum 0\n * @default 42\n */\n\n seed?: number;\n}\n\n/** Provide a reference image that anchors generation (image-to-video). Call before `start`; the image is required for generation to begin. Changes during generation have no effect until `reset` is issued and `start` is called again. Emits `image_accepted`, `conditions_ready`, and `state` on success, or `command_error` if the file is missing, not an image, or cannot be decoded. */\nexport interface LingbotSetImageParams {\n /**\n * Reference to a file uploaded via the Reactor presigned-URL protocol.\n * @default null\n */\n\n image?: FileRef;\n}\n\n/** Set the scene prompt. Valid at any time — call before `start` to arm generation, or hot-swap during generation to steer the next chunk. Emits `prompt_accepted`, `conditions_ready`, and `state` on success. */\nexport interface LingbotSetPromptParams {\n /**\n * Natural-language description of the scene to generate. Replaces the previously active prompt. Applied on the next chunk when generating; otherwise takes effect when `start` fires.\n * @default \"\"\n */\n\n prompt?: string;\n}\n\n/** Set movement */\nexport interface LingbotSetMovementParams {\n /**\n * Character movement in the generated scene. `idle` holds the character stationary; `forward` / `back` translate along the look axis; `strafe_left` / `strafe_right` translate sideways. Can be changed at any time; the new value applies to the next chunk.\n * @default \"idle\"\n */\n\n movement?: \"idle\" | \"forward\" | \"back\" | \"strafe_left\" | \"strafe_right\";\n}\n\n/** Set look_vertical */\nexport interface LingbotSetLookVerticalParams {\n /**\n * Vertical (pitch) camera rotation. `idle` holds pitch steady; `up` / `down` rotate the camera at the rate given by `rotation_speed_deg`. Can be changed at any time; the new value applies to the next chunk.\n * @default \"idle\"\n */\n\n look_vertical?: \"idle\" | \"up\" | \"down\";\n}\n\n/** Set look_horizontal */\nexport interface LingbotSetLookHorizontalParams {\n /**\n * Horizontal (yaw) camera rotation. `idle` holds yaw steady; `left` / `right` rotate the camera at the rate given by `rotation_speed_deg`. Can be changed at any time; the new value applies to the next chunk.\n * @default \"idle\"\n */\n\n look_horizontal?: \"idle\" | \"left\" | \"right\";\n}\n\n/** Set rotation_speed_deg */\nexport interface LingbotSetRotationSpeedDegParams {\n /**\n * Camera rotation speed in degrees per latent frame, applied when `look_horizontal` or `look_vertical` is not `idle`. Range 0.0 – 30.0. Ignored when both look axes are `idle`. Can be changed at any time; the new value applies to the next chunk.\n * @minimum 0\n * @maximum 30\n * @default 5\n */\n\n rotation_speed_deg?: number;\n}\n\n/**\n * Snapshot of the session's observable state.\n *\n * Emitted on connect, after every command that mutates session state (`set_prompt`, `set_image`, `start`, `pause`, `resume`, `reset`, and the auto-generated `set_<field>` setters), and after each `chunk_complete`. Clients can treat this as the single source of truth for driving UI, without having to track every individual command and message themselves.\n */\nexport interface LingbotStateMessage {\n type: \"state\";\n /** Current value of the `seed` input field. The seed that was actually used by the running generation was captured when `start` fired — later changes to `seed` only take effect after `reset` and a new `start`. */\n\n seed: number;\n /** True while generation is paused via `pause`. */\n\n paused: boolean;\n /** True while the chunk loop is actively producing frames — equivalent to `started and not paused`. `False` both before `start` and while paused; read `started` to disambiguate. */\n\n running: boolean;\n /** True once `start` has been accepted. Remains true while paused; reset to false by `reset` or after `generation_complete` when the session is not auto-restarting. */\n\n started: boolean;\n /** Current value of the `movement` input field. */\n\n movement: string;\n /** True once a reference image has been set for the session. */\n\n has_image: boolean;\n /** True once a prompt has been set for the session. */\n\n has_prompt: boolean;\n /** Zero-based index of the last completed chunk. `0` before the first chunk has completed, and resets to `0` on `reset`. */\n\n current_chunk: number;\n /** Current value of the `look_vertical` input field. */\n\n look_vertical: string;\n /** Composite action string derived from `movement`, `look_horizontal`, and `look_vertical` — a `+`-joined combination of `w`/`s`/`a`/`d` and `left`/`right`/`up`/`down`, or `still` when idle. */\n\n current_action: string;\n /** The prompt currently driving generation, or `null` if no prompt has been set for the session. */\n\n current_prompt: unknown;\n /** Current value of the `look_horizontal` input field. */\n\n look_horizontal: string;\n /** Current value of the `rotation_speed_deg` input field (0.0 – 30.0). */\n\n rotation_speed_deg: number;\n}\n\n/** Emitted when a command is rejected because preconditions are not met or its arguments could not be processed. */\nexport interface LingbotCommandErrorMessage {\n type: \"command_error\";\n /** Human-readable explanation of why the command was rejected. */\n\n reason: string;\n /** Name of the command that was rejected. */\n\n command: string;\n}\n\n/** Emitted once per completed chunk of `main_video`. */\nexport interface LingbotChunkCompleteMessage {\n type: \"chunk_complete\";\n /** Zero-based index of the chunk that just completed. */\n\n chunk_index: number;\n /** The composite action string used to drive this chunk — a `+`-joined combination of movement (`w`/`s`/`a`/`d`) and look directions (`left`/`right`/`up`/`down`), or `still` when the character is idle with no camera rotation. */\n\n active_action: string;\n /** The prompt that was active while this chunk was generated. */\n\n active_prompt: string;\n /** Number of pixel frames emitted by this chunk. */\n\n frames_emitted: number;\n}\n\n/** Emitted after `set_image` successfully decodes the uploaded file. */\nexport interface LingbotImageAcceptedMessage {\n type: \"image_accepted\";\n /** Width in pixels of the decoded reference image. */\n\n width: number;\n /** Height in pixels of the decoded reference image. */\n\n height: number;\n}\n\n/** Emitted after `set_prompt` is accepted. */\nexport interface LingbotPromptAcceptedMessage {\n type: \"prompt_accepted\";\n /** The prompt text that was accepted. */\n\n prompt: string;\n}\n\n/** Emitted after `set_prompt` or `set_image` so the client can tell at a glance whether `start` will succeed. */\nexport interface LingbotConditionsReadyMessage {\n type: \"conditions_ready\";\n /** True once a reference image has been set for the session. */\n\n has_image: boolean;\n /** True once a prompt has been set for the session. */\n\n has_prompt: boolean;\n}\n\n/** Emitted after `reset` clears session state and returns to the waiting state. */\nexport interface LingbotGenerationResetMessage {\n type: \"generation_reset\";\n /** Short human-readable reason the reset was issued. */\n\n reason: string;\n}\n\n/** Emitted in response to `pause`, once the current chunk finishes. */\nexport interface LingbotGenerationPausedMessage {\n type: \"generation_paused\";\n /** Index of the last completed chunk before pausing. */\n\n chunk_index: number;\n}\n\n/** Emitted in response to `resume` when leaving the paused state. */\nexport interface LingbotGenerationResumedMessage {\n type: \"generation_resumed\";\n /** Index of the last completed chunk before resuming. */\n\n chunk_index: number;\n}\n\n/** Emitted once when `start` succeeds and frames begin streaming. */\nexport interface LingbotGenerationStartedMessage {\n type: \"generation_started\";\n /** The prompt active at the start of generation. */\n\n prompt: string;\n /** Total number of chunks the run will produce before `generation_complete` fires. */\n\n chunk_num: number;\n /** Total number of pixel frames the run will emit on `main_video` before `generation_complete`. */\n\n frame_num: number;\n}\n\n/** Emitted when all `chunk_num` chunks of a run have streamed. If the session is still `started`, a new run kicks off immediately with the same prompt and image; call `reset` to stop. */\nexport interface LingbotGenerationCompleteMessage {\n type: \"generation_complete\";\n /** Total number of chunks produced by the run. */\n\n total_chunks: number;\n}\n\nexport type LingbotMessage =\n | LingbotStateMessage\n | LingbotCommandErrorMessage\n | LingbotChunkCompleteMessage\n | LingbotImageAcceptedMessage\n | LingbotPromptAcceptedMessage\n | LingbotConditionsReadyMessage\n | LingbotGenerationResetMessage\n | LingbotGenerationPausedMessage\n | LingbotGenerationResumedMessage\n | LingbotGenerationStartedMessage\n | LingbotGenerationCompleteMessage;\n\n/**\n * Options for creating a LingbotModel (model name is set automatically).\n *\n * Derived from `Reactor`'s own constructor options with `modelName`\n * and `modelTracks` removed — those are supplied by this class.\n * Any new option the SDK adds appears here automatically on the\n * next `defaultSdkVersion` bump.\n */\nexport type LingbotOptions = Omit<\n ConstructorParameters<typeof Reactor>[0],\n \"modelName\" | \"modelTracks\"\n>;\n\n/**\n * @internal Flatten the `{ type, data, uploads? }` envelope the SDK\n * hands to `reactor.on(\"message\", …)` so a field the model schema\n * declares on a message is reachable at `msg.<field>` — matching the\n * shape the exported message interfaces promise.\n */\nfunction _unwrapMessage<T>(raw: unknown): T {\n const env = raw as { type?: string; data?: Record<string, unknown> };\n if (\n env &&\n typeof env === \"object\" &&\n env.data &&\n typeof env.data === \"object\"\n ) {\n return { ...env.data, type: env.type } as T;\n }\n return raw as T;\n}\n\n/**\n * Strongly-typed client for the Lingbot model.\n *\n * Extends {@link Reactor} with the model name (and modelTracks) baked into the\n * constructor, so every public method on Reactor — `connect`, `disconnect`,\n * `sendCommand`, `on`/`off`, `getStats`, `publishTrack`/`unpublishTrack`,\n * etc. — is reachable directly on the instance. The schema-derived sugar\n * below adds typed wrappers for every declared event, message, and track.\n */\n\nexport class LingbotModel extends Reactor {\n constructor(options?: LingbotOptions) {\n super({\n ...options,\n modelName: MODEL_NAME,\n modelTracks: [...LingbotTracks],\n });\n }\n\n /** @deprecated The model client now extends `Reactor` directly — call methods on `this` instead. This accessor returns `this` for backwards compatibility and will be removed in a future major release. */\n\n get reactor(): this {\n return this;\n }\n\n /** Pause generation after the current chunk finishes. Frames stop streaming on `main_video` until `resume` is called. Requires generation to be active. Emits `generation_paused` and `state` on success, or `command_error` if not generating or already paused. */\n\n async pause(): Promise<void> {\n await this.sendCommand(\"pause\", {});\n }\n\n /** Abort the current run, clear the active prompt and reference image, and return to the waiting state. Valid at any time. After `reset`, call `set_prompt` and `set_image` again before `start` to begin a new session. Emits `generation_reset` and `state`. */\n\n async reset(): Promise<void> {\n await this.sendCommand(\"reset\", {});\n }\n\n /** Begin generating video on `main_video`. Requires both a prompt (via `set_prompt`) and a reference image (via `set_image`). Emits `generation_started` and `state` on success, or `command_error` if a precondition is missing. Has no effect while already generating. */\n\n async start(): Promise<void> {\n await this.sendCommand(\"start\", {});\n }\n\n /** Resume generation from a previous `pause`. Requires the session to be paused. Emits `generation_resumed` and `state` on success, or `command_error` if not paused. */\n\n async resume(): Promise<void> {\n await this.sendCommand(\"resume\", {});\n }\n\n /**\n * Set seed\n * @param params - Set seed\n */\n\n async setSeed(params: LingbotSetSeedParams): Promise<void> {\n await this.sendCommand(\"set_seed\", params);\n }\n\n /**\n * Provide a reference image that anchors generation (image-to-video). Call before `start`; the image is required for generation to begin. Changes during generation have no effect until `reset` is issued and `start` is called again. Emits `image_accepted`, `conditions_ready`, and `state` on success, or `command_error` if the file is missing, not an image, or cannot be decoded.\n * @param params - Provide a reference image that anchors generation (image-to-video). Call before `start`; the image is required for generation to begin. Changes during generation have no effect until `reset` is issued and `start` is called again. Emits `image_accepted`, `conditions_ready`, and `state` on success, or `command_error` if the file is missing, not an image, or cannot be decoded.\n */\n\n async setImage(params: LingbotSetImageParams): Promise<void> {\n await this.sendCommand(\"set_image\", params);\n }\n\n /**\n * Set the scene prompt. Valid at any time — call before `start` to arm generation, or hot-swap during generation to steer the next chunk. Emits `prompt_accepted`, `conditions_ready`, and `state` on success.\n * @param params - Set the scene prompt. Valid at any time — call before `start` to arm generation, or hot-swap during generation to steer the next chunk. Emits `prompt_accepted`, `conditions_ready`, and `state` on success.\n */\n\n async setPrompt(params: LingbotSetPromptParams): Promise<void> {\n await this.sendCommand(\"set_prompt\", params);\n }\n\n /**\n * Set movement\n * @param params - Set movement\n */\n\n async setMovement(params: LingbotSetMovementParams): Promise<void> {\n await this.sendCommand(\"set_movement\", params);\n }\n\n /**\n * Set look_vertical\n * @param params - Set look_vertical\n */\n\n async setLookVertical(params: LingbotSetLookVerticalParams): Promise<void> {\n await this.sendCommand(\"set_look_vertical\", params);\n }\n\n /**\n * Set look_horizontal\n * @param params - Set look_horizontal\n */\n\n async setLookHorizontal(params: LingbotSetLookHorizontalParams): Promise<void> {\n await this.sendCommand(\"set_look_horizontal\", params);\n }\n\n /**\n * Set rotation_speed_deg\n * @param params - Set rotation_speed_deg\n */\n\n async setRotationSpeedDeg(params: LingbotSetRotationSpeedDegParams): Promise<void> {\n await this.sendCommand(\"set_rotation_speed_deg\", params);\n }\n\n /**\n * Subscribe to typed model messages.\n * @param handler - Called with a discriminated LingbotMessage\n * @returns Unsubscribe function\n */\n\n onMessage(handler: (message: LingbotMessage) => void): () => void {\n const wrappedHandler = (raw: unknown) => {\n handler(_unwrapMessage<LingbotMessage>(raw));\n };\n this.on(\"message\", wrappedHandler);\n return () => this.off(\"message\", wrappedHandler);\n }\n\n /**\n * Subscribe to \"state\" messages only.\n * @returns Unsubscribe function\n */\n\n onState(handler: (message: LingbotStateMessage) => void): () => void {\n return this.onMessage((msg) => {\n if (msg.type === \"state\") handler(msg as LingbotStateMessage);\n });\n }\n\n /**\n * Subscribe to \"command_error\" messages only.\n * @returns Unsubscribe function\n */\n\n onCommandError(handler: (message: LingbotCommandErrorMessage) => void): () => void {\n return this.onMessage((msg) => {\n if (msg.type === \"command_error\") handler(msg as LingbotCommandErrorMessage);\n });\n }\n\n /**\n * Subscribe to \"chunk_complete\" messages only.\n * @returns Unsubscribe function\n */\n\n onChunkComplete(handler: (message: LingbotChunkCompleteMessage) => void): () => void {\n return this.onMessage((msg) => {\n if (msg.type === \"chunk_complete\") handler(msg as LingbotChunkCompleteMessage);\n });\n }\n\n /**\n * Subscribe to \"image_accepted\" messages only.\n * @returns Unsubscribe function\n */\n\n onImageAccepted(handler: (message: LingbotImageAcceptedMessage) => void): () => void {\n return this.onMessage((msg) => {\n if (msg.type === \"image_accepted\") handler(msg as LingbotImageAcceptedMessage);\n });\n }\n\n /**\n * Subscribe to \"prompt_accepted\" messages only.\n * @returns Unsubscribe function\n */\n\n onPromptAccepted(handler: (message: LingbotPromptAcceptedMessage) => void): () => void {\n return this.onMessage((msg) => {\n if (msg.type === \"prompt_accepted\") handler(msg as LingbotPromptAcceptedMessage);\n });\n }\n\n /**\n * Subscribe to \"conditions_ready\" messages only.\n * @returns Unsubscribe function\n */\n\n onConditionsReady(handler: (message: LingbotConditionsReadyMessage) => void): () => void {\n return this.onMessage((msg) => {\n if (msg.type === \"conditions_ready\") handler(msg as LingbotConditionsReadyMessage);\n });\n }\n\n /**\n * Subscribe to \"generation_reset\" messages only.\n * @returns Unsubscribe function\n */\n\n onGenerationReset(handler: (message: LingbotGenerationResetMessage) => void): () => void {\n return this.onMessage((msg) => {\n if (msg.type === \"generation_reset\") handler(msg as LingbotGenerationResetMessage);\n });\n }\n\n /**\n * Subscribe to \"generation_paused\" messages only.\n * @returns Unsubscribe function\n */\n\n onGenerationPaused(handler: (message: LingbotGenerationPausedMessage) => void): () => void {\n return this.onMessage((msg) => {\n if (msg.type === \"generation_paused\") handler(msg as LingbotGenerationPausedMessage);\n });\n }\n\n /**\n * Subscribe to \"generation_resumed\" messages only.\n * @returns Unsubscribe function\n */\n\n onGenerationResumed(handler: (message: LingbotGenerationResumedMessage) => void): () => void {\n return this.onMessage((msg) => {\n if (msg.type === \"generation_resumed\") handler(msg as LingbotGenerationResumedMessage);\n });\n }\n\n /**\n * Subscribe to \"generation_started\" messages only.\n * @returns Unsubscribe function\n */\n\n onGenerationStarted(handler: (message: LingbotGenerationStartedMessage) => void): () => void {\n return this.onMessage((msg) => {\n if (msg.type === \"generation_started\") handler(msg as LingbotGenerationStartedMessage);\n });\n }\n\n /**\n * Subscribe to \"generation_complete\" messages only.\n * @returns Unsubscribe function\n */\n\n onGenerationComplete(handler: (message: LingbotGenerationCompleteMessage) => void): () => void {\n return this.onMessage((msg) => {\n if (msg.type === \"generation_complete\") handler(msg as LingbotGenerationCompleteMessage);\n });\n }\n\n /**\n * Subscribe to the \"main_video\" recvonly video track the model publishes.\n *\n * The handler fires once the model starts publishing this track; it receives the live MediaStreamTrack and the parent MediaStream (useful for attaching to a `<video>` / `<audio>` element via `srcObject`).\n * @param handler - Called with the received track and its stream\n * @returns Unsubscribe function\n */\n\n onMainVideo(\n handler: (track: MediaStreamTrack, stream: MediaStream) => void,\n ): () => void {\n const wrapped = (name: string, t: MediaStreamTrack, s: MediaStream) => {\n if (name === \"main_video\") handler(t, s);\n };\n this.on(\"trackReceived\", wrapped);\n return () => this.off(\"trackReceived\", wrapped);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,oBAAiC;AAG1B,IAAM,aAAa;AACnB,IAAM,gBAAgB;AAStB,IAAM,gBAAgB;AAAA,EAC3B,EAAE,MAAM,cAAc,MAAM,SAAS,WAAW,WAAW;AAC7D;AAuQA,SAAS,eAAkB,KAAiB;AAC1C,QAAM,MAAM;AACZ,MACE,OACA,OAAO,QAAQ,YACf,IAAI,QACJ,OAAO,IAAI,SAAS,UACpB;AACA,WAAO,EAAE,GAAG,IAAI,MAAM,MAAM,IAAI,KAAK;AAAA,EACvC;AACA,SAAO;AACT;AAYO,IAAM,eAAN,cAA2B,sBAAQ;AAAA,EACxC,YAAY,SAA0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