@butlerbot/sdk 0.0.6-alpha.2 → 0.0.6-alpha.4

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.
Files changed (43) hide show
  1. package/dist/config.d.ts +12 -0
  2. package/dist/config.js +8 -0
  3. package/dist/modules/conversation.d.ts +30 -5
  4. package/dist/modules/conversation.js +68 -21
  5. package/dist/types/conversation/index.d.ts +3 -0
  6. package/dist/types/conversation/index.js +19 -0
  7. package/dist/types/conversation/v1/conversation_v1.d.ts +7 -0
  8. package/dist/types/conversation/v1/conversation_v1.js +2 -0
  9. package/dist/types/conversation/v1/index.d.ts +1 -0
  10. package/dist/types/conversation/v1/index.js +17 -0
  11. package/dist/types/conversation/v2/aisdk_types.d.ts +431 -0
  12. package/dist/types/conversation/v2/aisdk_types.js +2 -0
  13. package/dist/types/conversation/v2/conversation_v2.d.ts +74 -0
  14. package/dist/types/conversation/v2/conversation_v2.js +2 -0
  15. package/dist/types/conversation/v2/index.d.ts +1 -0
  16. package/dist/types/conversation/v2/index.js +17 -0
  17. package/dist/types/conversation/v3/aisdk_types.d.ts +431 -0
  18. package/dist/types/conversation/v3/aisdk_types.js +2 -0
  19. package/dist/types/conversation/v3/conversation_v3.d.ts +344 -0
  20. package/dist/types/conversation/v3/conversation_v3.js +2 -0
  21. package/dist/types/conversation/v3/index.d.ts +1 -0
  22. package/dist/types/conversation/v3/index.js +17 -0
  23. package/dist/types/model.d.ts +1 -0
  24. package/dist/types/model.js +2 -0
  25. package/dist/types/response/v3/ai_response_v3.d.ts +98 -0
  26. package/dist/types/response/v3/ai_response_v3.js +2 -0
  27. package/dist/types/response/v3/ai_tools_v3.d.ts +7 -0
  28. package/dist/types/response/v3/ai_tools_v3.js +2 -0
  29. package/dist/types/response/v3/dialogue_response_v3.d.ts +29 -0
  30. package/dist/types/response/v3/dialogue_response_v3.js +2 -0
  31. package/dist/types/response/v3/index.d.ts +3 -0
  32. package/dist/types/response/v3/index.js +19 -0
  33. package/dist/types/response/v4/ai_response_v4.d.ts +22 -0
  34. package/dist/types/response/v4/ai_response_v4.js +2 -0
  35. package/dist/types/response/v4/dialogue_response_v4.d.ts +29 -0
  36. package/dist/types/response/v4/dialogue_response_v4.js +2 -0
  37. package/dist/types/response/v4/index.d.ts +2 -0
  38. package/dist/types/response/v4/index.js +18 -0
  39. package/dist/types/state/convo_state_response.d.ts +11 -0
  40. package/dist/types/state/convo_state_response.js +2 -0
  41. package/dist/types/type_registry.d.ts +2 -2
  42. package/dist/types/type_registry.js +2 -2
  43. package/package.json +1 -1
@@ -0,0 +1,431 @@
1
+ /**
2
+ * A message that can be used in the `messages` field of a prompt.
3
+ * It can be a user message, an assistant message, or a tool message.
4
+ */
5
+ export type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessage | ToolModelMessage;
6
+ type ProviderOptions = Object;
7
+ type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
8
+ type JSONObject = {
9
+ [key: string]: JSONValue | undefined;
10
+ };
11
+ type JSONArray = JSONValue[];
12
+ /**
13
+ * A tool message. It contains the result of one or more tool calls.
14
+ */
15
+ type ToolModelMessage = {
16
+ role: 'tool';
17
+ content: ToolContent;
18
+ /**
19
+ * Additional provider-specific metadata. They are passed through
20
+ * to the provider from the AI SDK and enable provider-specific
21
+ * functionality that can be fully encapsulated in the provider.
22
+ */
23
+ providerOptions?: ProviderOptions;
24
+ };
25
+ /**
26
+ * Content of a tool message. It is an array of tool result parts.
27
+ */
28
+ type ToolContent = Array<ToolResultPart | ToolApprovalResponse>;
29
+ /**
30
+ * Tool approval response prompt part.
31
+ */
32
+ type ToolApprovalResponse = {
33
+ type: 'tool-approval-response';
34
+ /**
35
+ * ID of the tool approval.
36
+ */
37
+ approvalId: string;
38
+ /**
39
+ * Flag indicating whether the approval was granted or denied.
40
+ */
41
+ approved: boolean;
42
+ /**
43
+ * Optional reason for the approval or denial.
44
+ */
45
+ reason?: string;
46
+ /**
47
+ * Flag indicating whether the tool call is provider-executed.
48
+ * Only provider-executed tool approval responses should be sent to the model.
49
+ */
50
+ providerExecuted?: boolean;
51
+ };
52
+ /**
53
+ * An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
54
+ */
55
+ type AssistantModelMessage = {
56
+ role: 'assistant';
57
+ content: AssistantContent;
58
+ /**
59
+ * Additional provider-specific metadata. They are passed through
60
+ * to the provider from the AI SDK and enable provider-specific
61
+ * functionality that can be fully encapsulated in the provider.
62
+ */
63
+ providerOptions?: ProviderOptions;
64
+ };
65
+ /**
66
+ * Content of an assistant message.
67
+ * It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
68
+ */
69
+ type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | ToolCallPart | ToolResultPart | ToolApprovalRequest>;
70
+ /**
71
+ * Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
72
+ */
73
+ interface ToolCallPart {
74
+ type: 'tool-call';
75
+ /**
76
+ * ID of the tool call. This ID is used to match the tool call with the tool result.
77
+ */
78
+ toolCallId: string;
79
+ /**
80
+ * Name of the tool that is being called.
81
+ */
82
+ toolName: string;
83
+ /**
84
+ * Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
85
+ */
86
+ input: unknown;
87
+ /**
88
+ * Additional provider-specific metadata. They are passed through
89
+ * to the provider from the AI SDK and enable provider-specific
90
+ * functionality that can be fully encapsulated in the provider.
91
+ */
92
+ providerOptions?: ProviderOptions;
93
+ /**
94
+ * Whether the tool call was executed by the provider.
95
+ */
96
+ providerExecuted?: boolean;
97
+ }
98
+ /**
99
+ * Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
100
+ */
101
+ interface ToolResultPart {
102
+ type: 'tool-result';
103
+ /**
104
+ * ID of the tool call that this result is associated with.
105
+ */
106
+ toolCallId: string;
107
+ /**
108
+ * Name of the tool that generated this result.
109
+ */
110
+ toolName: string;
111
+ /**
112
+ * Result of the tool call. This is a JSON-serializable object.
113
+ */
114
+ output: ToolResultOutput;
115
+ /**
116
+ * Additional provider-specific metadata. They are passed through
117
+ * to the provider from the AI SDK and enable provider-specific
118
+ * functionality that can be fully encapsulated in the provider.
119
+ */
120
+ providerOptions?: ProviderOptions;
121
+ }
122
+ /**
123
+ * Output of a tool result.
124
+ */
125
+ type ToolResultOutput = {
126
+ /**
127
+ * Text tool output that should be directly sent to the API.
128
+ */
129
+ type: 'text';
130
+ value: string;
131
+ /**
132
+ * Provider-specific options.
133
+ */
134
+ providerOptions?: ProviderOptions;
135
+ } | {
136
+ type: 'json';
137
+ value: JSONValue;
138
+ /**
139
+ * Provider-specific options.
140
+ */
141
+ providerOptions?: ProviderOptions;
142
+ } | {
143
+ /**
144
+ * Type when the user has denied the execution of the tool call.
145
+ */
146
+ type: 'execution-denied';
147
+ /**
148
+ * Optional reason for the execution denial.
149
+ */
150
+ reason?: string;
151
+ /**
152
+ * Provider-specific options.
153
+ */
154
+ providerOptions?: ProviderOptions;
155
+ } | {
156
+ type: 'error-text';
157
+ value: string;
158
+ /**
159
+ * Provider-specific options.
160
+ */
161
+ providerOptions?: ProviderOptions;
162
+ } | {
163
+ type: 'error-json';
164
+ value: JSONValue;
165
+ /**
166
+ * Provider-specific options.
167
+ */
168
+ providerOptions?: ProviderOptions;
169
+ } | {
170
+ type: 'content';
171
+ value: Array<{
172
+ type: 'text';
173
+ /**
174
+ * Text content.
175
+ */
176
+ text: string;
177
+ /**
178
+ * Provider-specific options.
179
+ */
180
+ providerOptions?: ProviderOptions;
181
+ } | {
182
+ /**
183
+ * @deprecated Use image-data or file-data instead.
184
+ */
185
+ type: 'media';
186
+ data: string;
187
+ mediaType: string;
188
+ } | {
189
+ type: 'file-data';
190
+ /**
191
+ * Base-64 encoded media data.
192
+ */
193
+ data: string;
194
+ /**
195
+ * IANA media type.
196
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
197
+ */
198
+ mediaType: string;
199
+ /**
200
+ * Optional filename of the file.
201
+ */
202
+ filename?: string;
203
+ /**
204
+ * Provider-specific options.
205
+ */
206
+ providerOptions?: ProviderOptions;
207
+ } | {
208
+ type: 'file-url';
209
+ /**
210
+ * URL of the file.
211
+ */
212
+ url: string;
213
+ /**
214
+ * Provider-specific options.
215
+ */
216
+ providerOptions?: ProviderOptions;
217
+ } | {
218
+ type: 'file-id';
219
+ /**
220
+ * ID of the file.
221
+ *
222
+ * If you use multiple providers, you need to
223
+ * specify the provider specific ids using
224
+ * the Record option. The key is the provider
225
+ * name, e.g. 'openai' or 'anthropic'.
226
+ */
227
+ fileId: string | Record<string, string>;
228
+ /**
229
+ * Provider-specific options.
230
+ */
231
+ providerOptions?: ProviderOptions;
232
+ } | {
233
+ /**
234
+ * Images that are referenced using base64 encoded data.
235
+ */
236
+ type: 'image-data';
237
+ /**
238
+ * Base-64 encoded image data.
239
+ */
240
+ data: string;
241
+ /**
242
+ * IANA media type.
243
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
244
+ */
245
+ mediaType: string;
246
+ /**
247
+ * Provider-specific options.
248
+ */
249
+ providerOptions?: ProviderOptions;
250
+ } | {
251
+ /**
252
+ * Images that are referenced using a URL.
253
+ */
254
+ type: 'image-url';
255
+ /**
256
+ * URL of the image.
257
+ */
258
+ url: string;
259
+ /**
260
+ * Provider-specific options.
261
+ */
262
+ providerOptions?: ProviderOptions;
263
+ } | {
264
+ /**
265
+ * Images that are referenced using a provider file id.
266
+ */
267
+ type: 'image-file-id';
268
+ /**
269
+ * Image that is referenced using a provider file id.
270
+ *
271
+ * If you use multiple providers, you need to
272
+ * specify the provider specific ids using
273
+ * the Record option. The key is the provider
274
+ * name, e.g. 'openai' or 'anthropic'.
275
+ */
276
+ fileId: string | Record<string, string>;
277
+ /**
278
+ * Provider-specific options.
279
+ */
280
+ providerOptions?: ProviderOptions;
281
+ } | {
282
+ /**
283
+ * Custom content part. This can be used to implement
284
+ * provider-specific content parts.
285
+ */
286
+ type: 'custom';
287
+ /**
288
+ * Provider-specific options.
289
+ */
290
+ providerOptions?: ProviderOptions;
291
+ }>;
292
+ };
293
+ /**
294
+ * Tool approval request prompt part.
295
+ */
296
+ type ToolApprovalRequest = {
297
+ type: 'tool-approval-request';
298
+ /**
299
+ * ID of the tool approval.
300
+ */
301
+ approvalId: string;
302
+ /**
303
+ * ID of the tool call that the approval request is for.
304
+ */
305
+ toolCallId: string;
306
+ };
307
+ /**
308
+ * Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
309
+ */
310
+ type DataContent = string | Uint8Array | ArrayBuffer | Buffer;
311
+ /**
312
+ * A system message. It can contain system information.
313
+ *
314
+ * Note: using the "system" part of the prompt is strongly preferred
315
+ * to increase the resilience against prompt injection attacks,
316
+ * and because not all providers support several system messages.
317
+ */
318
+ type SystemModelMessage = {
319
+ role: 'system';
320
+ content: string;
321
+ /**
322
+ * Additional provider-specific metadata. They are passed through
323
+ * to the provider from the AI SDK and enable provider-specific
324
+ * functionality that can be fully encapsulated in the provider.
325
+ */
326
+ providerOptions?: ProviderOptions;
327
+ };
328
+ /**
329
+ * Text content part of a prompt. It contains a string of text.
330
+ */
331
+ interface TextPart {
332
+ type: 'text';
333
+ /**
334
+ * The text content.
335
+ */
336
+ text: string;
337
+ /**
338
+ * Additional provider-specific metadata. They are passed through
339
+ * to the provider from the AI SDK and enable provider-specific
340
+ * functionality that can be fully encapsulated in the provider.
341
+ */
342
+ providerOptions?: ProviderOptions;
343
+ }
344
+ /**
345
+ * Image content part of a prompt. It contains an image.
346
+ */
347
+ interface ImagePart {
348
+ type: 'image';
349
+ /**
350
+ * Image data. Can either be:
351
+ *
352
+ * - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
353
+ * - URL: a URL that points to the image
354
+ */
355
+ image: DataContent | URL;
356
+ /**
357
+ * Optional IANA media type of the image.
358
+ *
359
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
360
+ */
361
+ mediaType?: string;
362
+ /**
363
+ * Additional provider-specific metadata. They are passed through
364
+ * to the provider from the AI SDK and enable provider-specific
365
+ * functionality that can be fully encapsulated in the provider.
366
+ */
367
+ providerOptions?: ProviderOptions;
368
+ }
369
+ /**
370
+ * File content part of a prompt. It contains a file.
371
+ */
372
+ interface FilePart {
373
+ type: 'file';
374
+ /**
375
+ * File data. Can either be:
376
+ *
377
+ * - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
378
+ * - URL: a URL that points to the image
379
+ */
380
+ data: DataContent | URL;
381
+ /**
382
+ * Optional filename of the file.
383
+ */
384
+ filename?: string;
385
+ /**
386
+ * IANA media type of the file.
387
+ *
388
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
389
+ */
390
+ mediaType: string;
391
+ /**
392
+ * Additional provider-specific metadata. They are passed through
393
+ * to the provider from the AI SDK and enable provider-specific
394
+ * functionality that can be fully encapsulated in the provider.
395
+ */
396
+ providerOptions?: ProviderOptions;
397
+ }
398
+ /**
399
+ * Reasoning content part of a prompt. It contains a reasoning.
400
+ */
401
+ interface ReasoningPart {
402
+ type: 'reasoning';
403
+ /**
404
+ * The reasoning text.
405
+ */
406
+ text: string;
407
+ /**
408
+ * Additional provider-specific metadata. They are passed through
409
+ * to the provider from the AI SDK and enable provider-specific
410
+ * functionality that can be fully encapsulated in the provider.
411
+ */
412
+ providerOptions?: ProviderOptions;
413
+ }
414
+ /**
415
+ * Content of a user message. It can be a string or an array of text and image parts.
416
+ */
417
+ type UserContent = string | Array<TextPart | ImagePart | FilePart>;
418
+ /**
419
+ * A user message. It can contain text or a combination of text and images.
420
+ */
421
+ type UserModelMessage = {
422
+ role: 'user';
423
+ content: UserContent;
424
+ /**
425
+ * Additional provider-specific metadata. They are passed through
426
+ * to the provider from the AI SDK and enable provider-specific
427
+ * functionality that can be fully encapsulated in the provider.
428
+ */
429
+ providerOptions?: ProviderOptions;
430
+ };
431
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,74 @@
1
+ import { AI_MODEL } from "../../model";
2
+ import { AIResponseV3 } from "../../type_registry";
3
+ import { ModelMessage } from "./aisdk_types";
4
+ export type AIChatProfileProcessedMessageData = {
5
+ /** A summarized version of this message */
6
+ summarized?: any;
7
+ };
8
+ export type RawAIChatProfileMessage = (ModelMessage & {
9
+ etc?: AIChatProfileProcessedMessageData;
10
+ });
11
+ export type AIChatProfileDisplayEntity = {
12
+ name?: string;
13
+ avatarUrl?: string;
14
+ };
15
+ export type BaseUserResponseMetadata = {
16
+ /** Epoch time for when this happened */
17
+ timestamp: number;
18
+ };
19
+ export type AIChatDialogueAdditional = {
20
+ from: "assistant" | "user";
21
+ } & AIChatProfileDisplayEntity;
22
+ export type AIChatDialogueMessage = ((AIResponseV3 & AIChatDialogueAdditional) | ({
23
+ type: "message";
24
+ payload: {
25
+ message: string;
26
+ };
27
+ metadata: BaseUserResponseMetadata;
28
+ } & AIChatDialogueAdditional));
29
+ export type AIChatProfile = {
30
+ settings: {
31
+ /** The AI model to use */
32
+ model?: AI_MODEL;
33
+ /** The profile's system prompt */
34
+ system?: string;
35
+ /** The location where this chat is taking place, e.g discord, brain, discord_agent, etc. Used for logging purposes */
36
+ location?: string;
37
+ /** The temperature of the AI, 0 to 1 */
38
+ temperature?: number;
39
+ /**
40
+ * The instructions that appears due to the current location, e.g website might have 'use markdown' while discord might have 'use discord formatting'
41
+ * It's simply appended to the system prompt later, the reason it's seperate is because the location instructions can change for the same chat over time
42
+ **/
43
+ locationInstructions?: string;
44
+ /** The chat's title */
45
+ title?: string;
46
+ /** Whether to disable auto title generation */
47
+ disableAutoTitle?: boolean;
48
+ /** Enable token-caching */
49
+ tokenCaching?: boolean;
50
+ };
51
+ /** Summary information for this conversation */
52
+ summary?: {
53
+ /** Very short summary, like a single sentence */
54
+ shortSummary?: string;
55
+ /** Longer summmary, few sentences */
56
+ longSummary?: string;
57
+ };
58
+ /** The raw dialogue messages */
59
+ messages: RawAIChatProfileMessage[];
60
+ /** The user's prompt and the responses generated by the AI model and sent to the user */
61
+ dialogue: AIChatDialogueMessage[];
62
+ /** Overwrite the default user's name and avatar, useful if the messages was sent on the user's behalf by a different entity */
63
+ defaultDisplayUser?: AIChatProfileDisplayEntity;
64
+ /** Overwrite the default AI's name and avatar, useful if the messages was sent on the AI's behalf by a different entity */
65
+ defaultDisplayAssistant?: AIChatProfileDisplayEntity;
66
+ };
67
+ export interface ConversationV2 {
68
+ version: "2.0";
69
+ conversationId: string;
70
+ ownerUserId: string;
71
+ /** Whether to disable the ability for the user to view this conversation */
72
+ disableView?: boolean;
73
+ profile: AIChatProfile;
74
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./conversation_v2";
@@ -0,0 +1,17 @@
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
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./conversation_v2"), exports);