@butlerbot/sdk 0.0.41 → 0.0.43

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.
@@ -1,4 +1,5 @@
1
1
  import { ConversationEvent } from "../types/response/v5";
2
+ import type { ConversationAddress } from "../types/conversation/address";
2
3
  /**
3
4
  * LINK WIRE PROTOCOL (client side)
4
5
  * ===============================
@@ -110,6 +111,8 @@ export type LinkClientPayloads = {
110
111
  personality?: string;
111
112
  instructions?: string;
112
113
  platform?: string;
114
+ /** Where on the platform the conversation is: on Discord, the channel and thread. */
115
+ address?: ConversationAddress;
113
116
  };
114
117
  "conversation.chat": {
115
118
  sessionId: string;
@@ -5,6 +5,7 @@ import { ConversationStream, SteerResult, TurnStopMode, TurnStopped } from "./tr
5
5
  import { RequestResponseV3, RequestResponseV4 } from "../types/type_registry";
6
6
  import { RequestResponseV5 } from "../types/response/v5/dialogue_response_v5";
7
7
  import { ConversationStateResponse } from "../types/state/convo_state_response";
8
+ import { ConversationAddress } from "../types/conversation/address";
8
9
  import { TurnProgressEntry } from "../types/response/v4/turn_registry_v4";
9
10
  import { TurnProgressEntryV5 } from "../types/response/v5/turn_registry_v5";
10
11
  export type DialogueRequestParams = {
@@ -18,6 +19,12 @@ export type DialogueRequestParams = {
18
19
  instructions?: string;
19
20
  /** Platform where the chat is occurring */
20
21
  platform?: string;
22
+ /**
23
+ * Where on the platform the conversation is — on Discord, the channel and the thread
24
+ * inside it. Anything Alfred has to say on this conversation outside a turn is delivered
25
+ * there. An address is whole: a new one replaces the old rather than merging into it.
26
+ */
27
+ address?: ConversationAddress;
21
28
  /** Custom personality configuration for the AI */
22
29
  personality?: string;
23
30
  };
@@ -111,6 +118,13 @@ export declare class Conversation<V extends APIPath = "v4"> {
111
118
  setInstructions(instructions: string): this;
112
119
  /** Sets the platform where the chat is occurring, used internally for logging - ignore in most contexts */
113
120
  setPlatform(platform: string): this;
121
+ /**
122
+ * Sets where on the platform the conversation is — on Discord, the channel and the thread
123
+ * inside it. Anything Alfred has to say on this conversation outside a turn is delivered
124
+ * there. The address is whole: this replaces whatever the conversation named before rather
125
+ * than merging into it, so a conversation that left a thread stops naming one.
126
+ */
127
+ setAddress(address: ConversationAddress): this;
114
128
  /** Sets a custom personality configuration for the AI */
115
129
  setPersonality(personality: string): this;
116
130
  /** Gets the current conversation ID */
@@ -134,6 +148,8 @@ export declare class Conversation<V extends APIPath = "v4"> {
134
148
  getInstructions(): string | undefined;
135
149
  /** Gets the current platform */
136
150
  getPlatform(): string | undefined;
151
+ /** Gets where on the platform the conversation is */
152
+ getAddress(): import("../types/type_registry").DiscordAddress | undefined;
137
153
  /** Gets the current personality configuration */
138
154
  getPersonality(): string | undefined;
139
155
  /**
@@ -34,6 +34,7 @@ class Conversation {
34
34
  personality: this.options?.personality,
35
35
  instructions: this.options?.instructions,
36
36
  platform: this.options?.platform,
37
+ address: this.options?.address,
37
38
  }));
38
39
  }
39
40
  else {
@@ -95,6 +96,16 @@ class Conversation {
95
96
  this.options = { ...this.options, platform };
96
97
  return this;
97
98
  }
99
+ /**
100
+ * Sets where on the platform the conversation is — on Discord, the channel and the thread
101
+ * inside it. Anything Alfred has to say on this conversation outside a turn is delivered
102
+ * there. The address is whole: this replaces whatever the conversation named before rather
103
+ * than merging into it, so a conversation that left a thread stops naming one.
104
+ */
105
+ setAddress(address) {
106
+ this.options = { ...this.options, address };
107
+ return this;
108
+ }
98
109
  /** Sets a custom personality configuration for the AI */
99
110
  setPersonality(personality) {
100
111
  this.options = { ...this.options, personality };
@@ -140,6 +151,10 @@ class Conversation {
140
151
  getPlatform() {
141
152
  return this.options?.platform;
142
153
  }
154
+ /** Gets where on the platform the conversation is */
155
+ getAddress() {
156
+ return this.options?.address;
157
+ }
143
158
  /** Gets the current personality configuration */
144
159
  getPersonality() {
145
160
  return this.options?.personality;
@@ -6,6 +6,7 @@
6
6
  * only decides how a turn is sent and how its stream comes back — everything a
7
7
  * caller sees, including the payload shape, is identical either way.
8
8
  */
9
+ import type { ConversationAddress } from "../types/conversation/address";
9
10
  /** A turn in progress. */
10
11
  export type ConversationStream = {
11
12
  /**
@@ -54,6 +55,8 @@ export type TransportTurnRequest = {
54
55
  model?: string;
55
56
  instructions?: string;
56
57
  platform?: string;
58
+ /** Where on the platform the conversation is: on Discord, the channel and thread. */
59
+ address?: ConversationAddress;
57
60
  personality?: string;
58
61
  };
59
62
  export type TransportHandlers = {
@@ -1,10 +1,13 @@
1
1
  import type { Link } from "../link/link";
2
+ import type { ConversationAddress } from "../types/conversation/address";
2
3
  import { ConversationStream, ConversationTransport, SteerResult, TransportAttachRequest, TransportHandlers, TransportSteerRequest, TransportStopRequest, TransportTurnRequest, TurnStopped } from "./transport";
3
4
  export type LinkSessionConfig = {
4
5
  model?: string;
5
6
  personality?: string;
6
7
  instructions?: string;
7
8
  platform?: string;
9
+ /** Where on the platform the conversation is: on Discord, the channel and thread. */
10
+ address?: ConversationAddress;
8
11
  };
9
12
  /**
10
13
  * Carries a turn over an existing Link connection.
@@ -396,6 +396,7 @@ class LinkConversationTransport {
396
396
  ...(request.personality ?? config.personality ? { personality: request.personality ?? config.personality } : {}),
397
397
  ...(request.instructions ?? config.instructions ? { instructions: request.instructions ?? config.instructions } : {}),
398
398
  ...(request.platform ?? config.platform ? { platform: request.platform ?? config.platform } : {}),
399
+ ...(request.address ?? config.address ? { address: request.address ?? config.address } : {}),
399
400
  }, {
400
401
  isDone: (frame) => frame.type === "conversation.open",
401
402
  });
@@ -114,6 +114,10 @@ function asQuery(request) {
114
114
  query.instructions = request.instructions;
115
115
  if (request.platform)
116
116
  query.platform = request.platform;
117
+ // An address is a small object, and a query parameter is a string: it travels JSON-encoded
118
+ // rather than as a field per part, so the server reads one whole address or none at all.
119
+ if (request.address)
120
+ query.address = JSON.stringify(request.address);
117
121
  if (request.personality)
118
122
  query.personality = request.personality;
119
123
  return query;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Where a conversation lives on the platform it is being held on.
3
+ *
4
+ * Anything Alfred has to say on a conversation outside a turn — a background task reporting
5
+ * what it found — is delivered to the address the conversation named. A conversation that
6
+ * names none is answered wherever the platform's own default is, which on Discord is the
7
+ * user's direct messages.
8
+ *
9
+ * An address is whole: a new one replaces the old outright rather than being merged into it,
10
+ * so a conversation that moves out of a thread stops naming the thread it was in.
11
+ */
12
+ export type ConversationAddress = DiscordAddress;
13
+ /**
14
+ * A place on Discord.
15
+ *
16
+ * `channelId` is the guild text or forum channel, or the literal `"DM"` for the user's direct
17
+ * messages. `threadId` is the thread or forum post inside that channel, when the conversation
18
+ * is in one — a forum post being a thread whose channel is the forum.
19
+ */
20
+ export type DiscordAddress = {
21
+ platform: "discord";
22
+ channelId: string;
23
+ threadId?: string;
24
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,7 +5,7 @@ import type { Delivery } from "../outreach/delivery";
5
5
  * These are the shapes the jobs routes answer with. The server flattens a job row into a
6
6
  * `JobView` before it leaves, and this is that view rather than the row.
7
7
  */
8
- export declare const JOB_STATUSES: readonly ["queued", "running", "blocked", "waiting_user", "waiting_approval", "waiting_child", "waiting_budget", "review", "done", "failed", "cancelled"];
8
+ export declare const JOB_STATUSES: readonly ["queued", "running", "blocked", "waiting_user", "waiting_approval", "waiting_child", "waiting_task", "waiting_budget", "review", "done", "failed", "cancelled"];
9
9
  export type JobStatus = typeof JOB_STATUSES[number];
10
10
  /** The statuses a job never leaves. */
11
11
  export declare const TERMINAL_JOB_STATUSES: readonly JobStatus[];
@@ -15,6 +15,11 @@ exports.JOB_STATUSES = [
15
15
  "waiting_user",
16
16
  "waiting_approval",
17
17
  "waiting_child",
18
+ /**
19
+ * Parked with no wake time, on a tool call one of its shifts started that is still
20
+ * running in the background as a task; the task settling re-queues the job.
21
+ */
22
+ "waiting_task",
18
23
  "waiting_budget",
19
24
  "review",
20
25
  "done",
@@ -3,6 +3,7 @@ export * from "./response/v4";
3
3
  export * from "./response/v5";
4
4
  export * from "./state/convo_state_response";
5
5
  export * from "./conversation/v4/conversation_v4";
6
+ export * from "./conversation/address";
6
7
  export * from "./jobs";
7
8
  export * from "./outreach";
8
9
  export * from "./error";
@@ -19,6 +19,7 @@ __exportStar(require("./response/v4"), exports);
19
19
  __exportStar(require("./response/v5"), exports);
20
20
  __exportStar(require("./state/convo_state_response"), exports);
21
21
  __exportStar(require("./conversation/v4/conversation_v4"), exports);
22
+ __exportStar(require("./conversation/address"), exports);
22
23
  __exportStar(require("./jobs"), exports);
23
24
  __exportStar(require("./outreach"), exports);
24
25
  __exportStar(require("./error"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@butlerbot/sdk",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "description": "The official ButlerBot SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",