@butlerbot/sdk 0.0.14 → 0.0.16

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.
@@ -2,6 +2,7 @@ import { EventSource } from "eventsource";
2
2
  import { CONFIG } from "../config";
3
3
  import { RequestResponseV4 } from "../types/type_registry";
4
4
  import { ConversationStateResponse } from "../types/state/convo_state_response";
5
+ import { TurnProgressEntry } from "../types/response/v4/turn_registry_v4";
5
6
  export type DialogueRequestParams = {
6
7
  /** Unique identifier for the chat session */
7
8
  chatId?: string;
@@ -125,7 +126,10 @@ export declare class Conversation {
125
126
  * Fetches the conversation progress from the server
126
127
  * Returns undefined if no active turn progress
127
128
  */
128
- fetchProgress(): Promise<RequestResponse[] | undefined>;
129
+ fetchProgress(options?: {
130
+ lastEventId?: string;
131
+ includeCompleted?: boolean;
132
+ }): Promise<TurnProgressEntry[] | undefined>;
129
133
  /** Sends a message into the conversation */
130
134
  send(message: string, cb: (chunk: RequestResponse) => any, options?: DialogueRequestOptions): EventSource;
131
135
  }
@@ -232,12 +232,12 @@ class Conversation {
232
232
  * Fetches the conversation progress from the server
233
233
  * Returns undefined if no active turn progress
234
234
  */
235
- fetchProgress() {
235
+ fetchProgress(options) {
236
236
  return __awaiter(this, void 0, void 0, function* () {
237
237
  if (!this.convoId)
238
238
  throw new Error("Conversation ID is not set");
239
- const url = (0, url_formatter_1.formatURL)(this.endpoints.progress, { chatId: this.convoId }, { apiKey: this.apiKey, debug: this.debug });
240
- const response = yield fetch(url);
239
+ const url = (0, url_formatter_1.formatURL)(this.endpoints.progress, { chatId: this.convoId, includeCompleted: options === null || options === void 0 ? void 0 : options.includeCompleted }, { apiKey: this.apiKey, debug: this.debug });
240
+ const response = yield fetch(url, { headers: (options === null || options === void 0 ? void 0 : options.lastEventId) ? { "last-event-id": options.lastEventId } : undefined });
241
241
  if (!response.ok) {
242
242
  const errorText = yield response.text();
243
243
  throw new Error(`Failed to fetch conversation progress: ${response.status} ${response.statusText} - ${errorText}`);
@@ -0,0 +1,7 @@
1
+ import { RequestResponseV4 } from "./dialogue_response_v4";
2
+ export type TurnProgressEntry = {
3
+ /** The ID of the buffered event */
4
+ eventId: string;
5
+ /** The actual event payload */
6
+ event: RequestResponseV4;
7
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@butlerbot/sdk",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "The official ButlerBot SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",