@butlerbot/sdk 0.0.10-alpha.3 → 0.0.11

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/dist/config.d.ts CHANGED
@@ -22,9 +22,10 @@ export declare const CONFIG: {
22
22
  };
23
23
  };
24
24
  };
25
- stream: {
25
+ progress: {
26
26
  v4: {
27
27
  base: string;
28
+ stream: string;
28
29
  };
29
30
  };
30
31
  usage: {
package/dist/config.js CHANGED
@@ -17,8 +17,11 @@ exports.CONFIG = {
17
17
  v1: { base: "/api/convo/get/history" }
18
18
  }
19
19
  },
20
- stream: {
21
- v4: { base: "/api/alfred/v4/chat/stream" }
20
+ progress: {
21
+ v4: {
22
+ base: "/api/alfred/v4/chat/progress",
23
+ stream: "/api/alfred/v4/chat/progress/stream",
24
+ }
22
25
  },
23
26
  usage: {
24
27
  policy: {
@@ -34,8 +34,10 @@ export type ConversationOptions = {
34
34
  convoPath?: string;
35
35
  /** The path to append to the server URL specifying the history API endpoint to use */
36
36
  historyPath?: string;
37
- /** The path to append to the server URL specifying the stream API endpoint to use */
38
- streamPath?: string;
37
+ /** The path to append to the server URL specifying the progress API endpoint to use */
38
+ progressPath?: string;
39
+ /** The path to append to the server URL specifying the progress stream API endpoint to use */
40
+ progressStreamPath?: string;
39
41
  /** Whether to enable debug logs */
40
42
  debug?: boolean;
41
43
  /** The API version to use */
@@ -58,8 +60,10 @@ export declare class Conversation {
58
60
  setConversationEndpoint(conversationEndpoint: string): this;
59
61
  /** Sets the history endpoint where the quest is sent to, appended to server URL */
60
62
  setHistoryEndpoint(historyEndpoint: string): this;
61
- /** Sets the stream endpoint where the request is sent to, appended to server URL */
62
- setStreamEndpoint(streamEndpoint: string): this;
63
+ /** Sets the progress stream endpoint where the request is sent to, appended to server URL */
64
+ setProgressStreamEndpoint(progressStreamEndpoint: string): this;
65
+ /** Sets the progress endpoint where the request is sent to, appended to server URL */
66
+ setProgressEndpoint(progressEndpoint: string): this;
63
67
  /** Sets the conversation ID, has to be an existing conversation ID, undefined otherwise */
64
68
  setConvoId(convoId: string | undefined): this;
65
69
  /** Sets the AI model used for the next interaction, e.g Claude-Sonnet, GPT-4 */
@@ -81,8 +85,10 @@ export declare class Conversation {
81
85
  getConversationEndpoint(): string;
82
86
  /** Gets the current history endpoint */
83
87
  getHistoryEndpoint(): string;
84
- /** Gets the current stream endpoint */
85
- getStreamEndpoint(): string;
88
+ /** Gets the current progress stream endpoint */
89
+ getProgressStreamEndpoint(): string;
90
+ /** Gets the current progress endpoint */
91
+ getProgressEndpoint(): string;
86
92
  /** Gets the current options object */
87
93
  getModel(): string | undefined;
88
94
  /** Gets the current location-specific instructions */
@@ -94,8 +100,10 @@ export declare class Conversation {
94
100
  private handleSSE;
95
101
  /** Fetches the conversation state from the server, including message history and metadata */
96
102
  fetchState(): Promise<ConversationStateResponse>;
97
- /** Fetches the conversation stream from the server */
98
- fetchStream(cb: (chunk: RequestResponse) => any): EventSource;
103
+ /** Fetches the conversation progress stream from the server */
104
+ fetchProgressStream(cb: (chunk: RequestResponse) => any): EventSource;
105
+ /** Fetches the conversation progress from the server */
106
+ fetchProgress(): Promise<RequestResponse[]>;
99
107
  /** Sends a message into the conversation */
100
108
  send(message: string, cb: (chunk: RequestResponse) => any, options?: DialogueRequestOptions): EventSource;
101
109
  }
@@ -21,7 +21,8 @@ class Conversation {
21
21
  this.endpoints = {
22
22
  conversation: serverUrl + (config.convoPath || config.path || config_1.CONFIG.paths.conversation[config.chatApiV || DEFAULT_CONVO_API_V].base),
23
23
  history: serverUrl + (config.historyPath || config_1.CONFIG.paths.history.chat.v1.base),
24
- stream: serverUrl + (config.streamPath || config_1.CONFIG.paths.stream.v4.base),
24
+ progressStream: serverUrl + (config.progressStreamPath || config_1.CONFIG.paths.progress.v4.stream),
25
+ progress: serverUrl + (config.progressPath || config_1.CONFIG.paths.progress.v4.base),
25
26
  };
26
27
  this.apiKey = config.apiKey;
27
28
  this.debug = config.debug || false;
@@ -45,9 +46,14 @@ class Conversation {
45
46
  this.endpoints.history = historyEndpoint;
46
47
  return this;
47
48
  }
48
- /** Sets the stream endpoint where the request is sent to, appended to server URL */
49
- setStreamEndpoint(streamEndpoint) {
50
- this.endpoints.stream = streamEndpoint;
49
+ /** Sets the progress stream endpoint where the request is sent to, appended to server URL */
50
+ setProgressStreamEndpoint(progressStreamEndpoint) {
51
+ this.endpoints.progressStream = progressStreamEndpoint;
52
+ return this;
53
+ }
54
+ /** Sets the progress endpoint where the request is sent to, appended to server URL */
55
+ setProgressEndpoint(progressEndpoint) {
56
+ this.endpoints.progress = progressEndpoint;
51
57
  return this;
52
58
  }
53
59
  /** Sets the conversation ID, has to be an existing conversation ID, undefined otherwise */
@@ -95,9 +101,13 @@ class Conversation {
95
101
  getHistoryEndpoint() {
96
102
  return this.endpoints.history;
97
103
  }
98
- /** Gets the current stream endpoint */
99
- getStreamEndpoint() {
100
- return this.endpoints.stream;
104
+ /** Gets the current progress stream endpoint */
105
+ getProgressStreamEndpoint() {
106
+ return this.endpoints.progressStream;
107
+ }
108
+ /** Gets the current progress endpoint */
109
+ getProgressEndpoint() {
110
+ return this.endpoints.progress;
101
111
  }
102
112
  /** Gets the current options object */
103
113
  getModel() {
@@ -153,13 +163,28 @@ class Conversation {
153
163
  return data;
154
164
  });
155
165
  }
156
- /** Fetches the conversation stream from the server */
157
- fetchStream(cb) {
166
+ /** Fetches the conversation progress stream from the server */
167
+ fetchProgressStream(cb) {
158
168
  if (!this.convoId)
159
169
  throw new Error("Conversation ID is not set");
160
- const url = (0, url_formatter_1.formatURL)(this.endpoints.stream, { chatId: this.convoId }, { apiKey: this.apiKey, debug: this.debug });
170
+ const url = (0, url_formatter_1.formatURL)(this.endpoints.progressStream, { chatId: this.convoId }, { apiKey: this.apiKey, debug: this.debug });
161
171
  return this.handleSSE(url, cb);
162
172
  }
173
+ /** Fetches the conversation progress from the server */
174
+ fetchProgress() {
175
+ return __awaiter(this, void 0, void 0, function* () {
176
+ if (!this.convoId)
177
+ throw new Error("Conversation ID is not set");
178
+ 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}` } });
180
+ if (!response.ok) {
181
+ const errorText = yield response.text();
182
+ throw new Error(`Failed to fetch conversation progress: ${response.status} ${response.statusText} - ${errorText}`);
183
+ }
184
+ const data = yield response.json();
185
+ return data.events;
186
+ });
187
+ }
163
188
  // LIFE CYCLE
164
189
  /** Sends a message into the conversation */
165
190
  send(message, cb, options) {
@@ -170,11 +170,12 @@ export type ToolPayload = {
170
170
  status: ToolStatus;
171
171
  };
172
172
  export type ConvoStatusPayload = {
173
- /** Whether the entire AI convo has been disabled, a disabled convo cannot be restarted */
174
- disabled?: boolean;
175
- /** Whether the AI convo has been stopped, a stopped convo can be restarted
176
- * although just because it's not stopped does not necasserily mean it's an ongoing conversation */
177
- stopped?: boolean;
173
+ /** The state of the conversation.
174
+ * - `disabled`: The conversation has been permanently disabled and cannot be restarted.
175
+ * - `stopped`: The conversation has been stopped but can be restarted.
176
+ * - `started`: The conversation has been started/restarted.
177
+ */
178
+ state?: "disabled" | "stopped" | "started";
178
179
  /** Short summary generated for this conversation */
179
180
  shortSummary?: string;
180
181
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@butlerbot/sdk",
3
- "version": "0.0.10-alpha.3",
3
+ "version": "0.0.11",
4
4
  "description": "The official ButlerBot SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",