@butlerbot/sdk 0.0.43 → 0.0.45

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.
@@ -120,6 +120,8 @@ export type LinkClientPayloads = {
120
120
  model?: string;
121
121
  instructions?: string;
122
122
  personality?: string;
123
+ /** Why Alfred is speaking on this one turn: a line for its system prompt, at most 500 characters. */
124
+ wake?: string;
123
125
  };
124
126
  "conversation.end": {
125
127
  sessionId: string;
@@ -27,6 +27,14 @@ export type DialogueRequestParams = {
27
27
  address?: ConversationAddress;
28
28
  /** Custom personality configuration for the AI */
29
29
  personality?: string;
30
+ /**
31
+ * Why Alfred is speaking on this turn, when something other than the message is the
32
+ * reason — for example "You are joining because a rule of the user's matched: ...".
33
+ * A line added to this one turn's system prompt and never written to the conversation,
34
+ * so it is passed per `send()`/`ask()` rather than set on the conversation. At most
35
+ * 500 characters; the server refuses a longer one. Left off when blank.
36
+ */
37
+ wake?: string;
30
38
  };
31
39
  export type DialogueRequestOptions = Omit<Omit<DialogueRequestParams, "message">, "chatId">;
32
40
  export interface RequestResponseByVersion {
@@ -58,6 +58,8 @@ export type TransportTurnRequest = {
58
58
  /** Where on the platform the conversation is: on Discord, the channel and thread. */
59
59
  address?: ConversationAddress;
60
60
  personality?: string;
61
+ /** Why Alfred is speaking on this one turn: a line for its system prompt, at most 500 characters. */
62
+ wake?: string;
61
63
  };
62
64
  export type TransportHandlers = {
63
65
  /** One payload of the stream, already in the shape callers expect. */
@@ -184,6 +184,8 @@ class LinkConversationTransport {
184
184
  ...(request.model ? { model: request.model } : {}),
185
185
  ...(request.instructions ? { instructions: request.instructions } : {}),
186
186
  ...(request.personality ? { personality: request.personality } : {}),
187
+ // Per turn, never on the session: it says why Alfred was woken for this one.
188
+ ...(request.wake?.trim() ? { wake: request.wake.trim() } : {}),
187
189
  }, {
188
190
  // A turn takes as long as it takes; only the transport dying ends it early.
189
191
  timeoutMs: 0,
@@ -120,5 +120,8 @@ function asQuery(request) {
120
120
  query.address = JSON.stringify(request.address);
121
121
  if (request.personality)
122
122
  query.personality = request.personality;
123
+ const wake = request.wake?.trim();
124
+ if (wake)
125
+ query.wake = wake;
123
126
  return query;
124
127
  }
@@ -21,4 +21,12 @@ export type DiscordAddress = {
21
21
  platform: "discord";
22
22
  channelId: string;
23
23
  threadId?: string;
24
+ /**
25
+ * The message the conversation was last held at — the user's most recent message in it.
26
+ *
27
+ * Anything Alfred says on the conversation outside a turn is posted as a reply to it, so a
28
+ * background task reporting back an hour later still says what it is answering, in a
29
+ * channel that has moved on since.
30
+ */
31
+ messageId?: string;
24
32
  };
@@ -1,3 +1,4 @@
1
+ import type { ConversationAddress } from "../conversation/address";
1
2
  /**
2
3
  * Outreach: what Alfred has told or asked this user outside a chat, and their answers.
3
4
  *
@@ -18,8 +19,13 @@ export type DeliverySurfaceStatus = typeof DELIVERY_SURFACE_STATUSES[number];
18
19
  export type DeliverySurface = {
19
20
  surface: DeliverySurfaceName;
20
21
  status: DeliverySurfaceStatus;
21
- /** Where on the surface it went: a Discord channel id, or "DM". */
22
- channelId?: string | null;
22
+ /**
23
+ * Where on the surface it was addressed, whole, as the conversation named it.
24
+ *
25
+ * Null when the conversation named none, in which case it went wherever the surface
26
+ * reaches its user by default: on Discord, their direct messages.
27
+ */
28
+ address?: ConversationAddress | null;
23
29
  /** What the channel called the message it sent. */
24
30
  messageId?: string | null;
25
31
  /** Why the last attempt failed. */
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DELIVERY_SOURCES = exports.DELIVERY_CLOSED_REASONS = exports.DELIVERY_ANSWER_VIA = exports.DELIVERY_SURFACE_STATUSES = exports.DELIVERY_SURFACES = exports.ANSWERABLE_DELIVERY_INTENTS = exports.DELIVERY_INTENTS = void 0;
4
+ exports.isDeliveryOpen = isDeliveryOpen;
2
5
  /**
3
6
  * Outreach: what Alfred has told or asked this user outside a chat, and their answers.
4
7
  *
@@ -6,9 +9,6 @@
6
9
  * notification about one. Answering closes it, and when it belongs to a job the answer is put
7
10
  * on that job's inbox.
8
11
  */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.DELIVERY_SOURCES = exports.DELIVERY_CLOSED_REASONS = exports.DELIVERY_ANSWER_VIA = exports.DELIVERY_SURFACE_STATUSES = exports.DELIVERY_SURFACES = exports.ANSWERABLE_DELIVERY_INTENTS = exports.DELIVERY_INTENTS = void 0;
11
- exports.isDeliveryOpen = isDeliveryOpen;
12
12
  exports.DELIVERY_INTENTS = ["question", "update", "approval", "statement"];
13
13
  /** The intents that leave something outstanding until the user answers. */
14
14
  exports.ANSWERABLE_DELIVERY_INTENTS = ["question", "approval"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@butlerbot/sdk",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "description": "The official ButlerBot SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",