@butlerbot/sdk 0.0.11 → 0.0.13

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.
@@ -102,8 +102,11 @@ export declare class Conversation {
102
102
  fetchState(): Promise<ConversationStateResponse>;
103
103
  /** Fetches the conversation progress stream from the server */
104
104
  fetchProgressStream(cb: (chunk: RequestResponse) => any): EventSource;
105
- /** Fetches the conversation progress from the server */
106
- fetchProgress(): Promise<RequestResponse[]>;
105
+ /**
106
+ * Fetches the conversation progress from the server
107
+ * Returns undefined if no active turn progress
108
+ */
109
+ fetchProgress(): Promise<RequestResponse[] | undefined>;
107
110
  /** Sends a message into the conversation */
108
111
  send(message: string, cb: (chunk: RequestResponse) => any, options?: DialogueRequestOptions): EventSource;
109
112
  }
@@ -170,17 +170,22 @@ class Conversation {
170
170
  const url = (0, url_formatter_1.formatURL)(this.endpoints.progressStream, { chatId: this.convoId }, { apiKey: this.apiKey, debug: this.debug });
171
171
  return this.handleSSE(url, cb);
172
172
  }
173
- /** Fetches the conversation progress from the server */
173
+ /**
174
+ * Fetches the conversation progress from the server
175
+ * Returns undefined if no active turn progress
176
+ */
174
177
  fetchProgress() {
175
178
  return __awaiter(this, void 0, void 0, function* () {
176
179
  if (!this.convoId)
177
180
  throw new Error("Conversation ID is not set");
178
181
  const url = (0, url_formatter_1.formatURL)(this.endpoints.progress, { chatId: this.convoId }, { apiKey: this.apiKey, debug: this.debug });
179
- const response = yield fetch(url, { headers: { "Authorization": `Bearer ${this.apiKey}` } });
182
+ const response = yield fetch(url);
180
183
  if (!response.ok) {
181
184
  const errorText = yield response.text();
182
185
  throw new Error(`Failed to fetch conversation progress: ${response.status} ${response.statusText} - ${errorText}`);
183
186
  }
187
+ if (response.status === 204)
188
+ return undefined; // No content
184
189
  const data = yield response.json();
185
190
  return data.events;
186
191
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@butlerbot/sdk",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "The official ButlerBot SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",