@decartai/sdk 0.0.36 → 0.0.38

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.
@@ -54,7 +54,10 @@ type RealTimeClient = {
54
54
  on: <K extends keyof Events>(event: K, listener: (data: Events[K]) => void) => void;
55
55
  off: <K extends keyof Events>(event: K, listener: (data: Events[K]) => void) => void;
56
56
  sessionId: string;
57
- setImage: (image: Blob | File | string) => Promise<void>;
57
+ setImage: (image: Blob | File | string | null, options?: {
58
+ prompt?: string;
59
+ enhance?: boolean;
60
+ }) => Promise<void>;
58
61
  playAudio?: (audio: Blob | File | ArrayBuffer) => Promise<void>;
59
62
  };
60
63
  //#endregion
@@ -99,7 +99,8 @@ const createRealTimeClient = (opts) => {
99
99
  on: eventEmitter.on,
100
100
  off: eventEmitter.off,
101
101
  sessionId,
102
- setImage: async (image) => {
102
+ setImage: async (image, options$1) => {
103
+ if (image === null) return webrtcManager.setImage(null, options$1);
103
104
  let imageBase64;
104
105
  if (typeof image === "string") {
105
106
  let url = null;
@@ -110,7 +111,7 @@ const createRealTimeClient = (opts) => {
110
111
  else if (url?.protocol === "http:" || url?.protocol === "https:") imageBase64 = await blobToBase64(await (await fetch(image)).blob());
111
112
  else imageBase64 = image;
112
113
  } else imageBase64 = await blobToBase64(image);
113
- return webrtcManager.setImage(imageBase64);
114
+ return webrtcManager.setImage(imageBase64, options$1);
114
115
  }
115
116
  };
116
117
  if (isAvatarLive && audioStreamManager) {
@@ -132,8 +132,10 @@ var WebRTCConnection = class {
132
132
  /**
133
133
  * Send an image to the server (e.g., as a reference for inference).
134
134
  * Can be called after connection is established.
135
+ * Pass null to clear the reference image or use a placeholder.
136
+ * Optionally include a prompt to send with the image.
135
137
  */
136
- async setImageBase64(imageBase64) {
138
+ async setImageBase64(imageBase64, options) {
137
139
  return new Promise((resolve, reject) => {
138
140
  const timeoutId = setTimeout(() => {
139
141
  this.websocketMessagesEmitter.off("setImageAck", listener);
@@ -146,10 +148,13 @@ var WebRTCConnection = class {
146
148
  else reject(new Error(msg.error ?? "Failed to send image"));
147
149
  };
148
150
  this.websocketMessagesEmitter.on("setImageAck", listener);
149
- this.send({
151
+ const message = {
150
152
  type: "set_image",
151
153
  image_data: imageBase64
152
- });
154
+ };
155
+ if (options?.prompt !== void 0) message.prompt = options.prompt;
156
+ if (options?.enhance !== void 0) message.enhance_prompt = options.enhance;
157
+ this.send(message);
153
158
  });
154
159
  }
155
160
  /**
@@ -61,8 +61,8 @@ var WebRTCManager = class {
61
61
  getWebsocketMessageEmitter() {
62
62
  return this.connection.websocketMessagesEmitter;
63
63
  }
64
- setImage(imageBase64) {
65
- return this.connection.setImageBase64(imageBase64);
64
+ setImage(imageBase64, options) {
65
+ return this.connection.setImageBase64(imageBase64, options);
66
66
  }
67
67
  };
68
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decartai/sdk",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "description": "Decart's JavaScript SDK",
5
5
  "type": "module",
6
6
  "license": "MIT",