@butlerbot/sdk 0.0.1-alpha2 → 0.0.1-alpha4

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/index.d.ts CHANGED
@@ -22,3 +22,7 @@ export declare class ButlerBotClient {
22
22
  createConversation(config?: OptionalApiKey<ConversationOptions>): Conversation;
23
23
  }
24
24
  export { Conversation, ConversationOptions };
25
+ export * from "./types/ai_response_v3";
26
+ export * from "./types/dialogue_response_v3";
27
+ export * from "./types/error";
28
+ export * from "./types/ai_tools_v3";
package/dist/index.js CHANGED
@@ -1,4 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
17
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
18
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -40,3 +54,8 @@ class ButlerBotClient {
40
54
  }
41
55
  }
42
56
  exports.ButlerBotClient = ButlerBotClient;
57
+ // Expose types from /types
58
+ __exportStar(require("./types/ai_response_v3"), exports); // ai_response_v3.ts
59
+ __exportStar(require("./types/dialogue_response_v3"), exports); // dialogue_response_v3.ts
60
+ __exportStar(require("./types/error"), exports); // error.ts
61
+ __exportStar(require("./types/ai_tools_v3"), exports); // ai_tools_v3.ts
@@ -42,6 +42,9 @@ class Conversation {
42
42
  const sse = new eventsource_1.EventSource(url);
43
43
  sse.addEventListener("message", (event) => {
44
44
  const data = JSON.parse(event.data);
45
+ const convoId = data.success ? data.data.convoId : undefined;
46
+ if (convoId)
47
+ this.convoId = convoId; // update convo id from response
45
48
  cb(data);
46
49
  if (data.data.quitStream)
47
50
  sse.close();
@@ -1,16 +1,16 @@
1
1
  import { AIToolStatusData } from "./ai_tools_v3";
2
2
  import { ErrorCode } from "./error";
3
- type AIChatResultFail = {
3
+ export type AIChatResultFail = {
4
4
  success: false;
5
5
  errorcode: ErrorCode;
6
6
  };
7
- type AIChatResultSuccess = {
7
+ export type AIChatResultSuccess = {
8
8
  success: true;
9
9
  response: AIResponse[];
10
10
  usage: any;
11
11
  };
12
12
  export type AIChatResult = AIChatResultFail | AIChatResultSuccess;
13
- type BaseAIResponseMetadata = {
13
+ export type BaseAIResponseMetadata = {
14
14
  /** The model that generated this message */
15
15
  model: string;
16
16
  /** The actual model ID that generated this message */
@@ -18,7 +18,7 @@ type BaseAIResponseMetadata = {
18
18
  /** Epoch time for when this happened */
19
19
  timestamp: number;
20
20
  };
21
- type AIMessageResponse = {
21
+ export type AIMessageResponse = {
22
22
  /** Specifies type to be a message */
23
23
  type: "message";
24
24
  payload: {
@@ -31,7 +31,7 @@ type AIMessageResponse = {
31
31
  };
32
32
  metadata: BaseAIResponseMetadata & {};
33
33
  };
34
- type AIResponseStatusResponse = {
34
+ export type AIResponseStatusResponse = {
35
35
  /** Specifies type to be a status update for the response */
36
36
  type: "response_status";
37
37
  payload: {
@@ -39,7 +39,7 @@ type AIResponseStatusResponse = {
39
39
  completed: boolean;
40
40
  };
41
41
  };
42
- type AIConvoStatusResponse = {
42
+ export type AIConvoStatusResponse = {
43
43
  /** Specifies type to be a status update for the conversation */
44
44
  type: "convo_status";
45
45
  payload: {
@@ -50,7 +50,7 @@ type AIConvoStatusResponse = {
50
50
  stopped: boolean;
51
51
  };
52
52
  };
53
- type AIToolResponse = {
53
+ export type AIToolResponse = {
54
54
  /** Specifies type to be a tool use status update */
55
55
  type: "tool";
56
56
  payload: {
@@ -60,4 +60,3 @@ type AIToolResponse = {
60
60
  metadata: BaseAIResponseMetadata & {};
61
61
  };
62
62
  export type AIResponse = AIMessageResponse | AIToolResponse | AIConvoStatusResponse | AIResponseStatusResponse;
63
- export {};
@@ -1,6 +1,6 @@
1
1
  import { AIResponse } from "./ai_response_v3";
2
2
  import { ErrorCode } from "./error";
3
- type RequestBaseResponsePayload = {
3
+ export type RequestBaseResponsePayload = {
4
4
  /** Whether the conversation's ending */
5
5
  end?: boolean;
6
6
  /** Whether the stream is ending */
@@ -22,7 +22,8 @@ export type RequestSucessResponse = {
22
22
  data: {
23
23
  /** The AI's response */
24
24
  response: AIResponse;
25
+ /** The convoId, passed in most responses */
26
+ convoId?: string;
25
27
  } & RequestBaseResponsePayload;
26
28
  };
27
29
  export type RequestResponse = RequestFailResponse | RequestSucessResponse;
28
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@butlerbot/sdk",
3
- "version": "0.0.1-alpha2",
3
+ "version": "0.0.1-alpha4",
4
4
  "description": "The official ButlerBot SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",