@vellumai/assistant 0.11.4-dev.202608202009.ccce214 → 0.11.4-dev.202608202110.0dbb88d

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.
@@ -179,16 +179,6 @@ export const ChannelReplyPayloadSchema = z.object({
179
179
  messageTs: z.string().optional(),
180
180
  /** When true, the daemon generates Block Kit blocks from the text before delivery. */
181
181
  useBlocks: z.boolean().optional(),
182
- /** When provided, set or clear the Slack Assistants API thread status. */
183
- assistantThreadStatus: z
184
- .object({
185
- channel: z.string(),
186
- threadTs: z.string(),
187
- status: z.string(),
188
- /** Serialized to Slack as `loading_messages`. */
189
- loadingMessages: z.array(z.string()).optional(),
190
- })
191
- .optional(),
192
182
  /** When provided, perform one Slack streaming operation (start/append/stop). */
193
183
  slackStream: SlackStreamOpSchema.optional(),
194
184
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.11.4-dev.202608202009.ccce214",
3
+ "version": "0.11.4-dev.202608202110.0dbb88d",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -388,6 +388,14 @@
388
388
  "description": "Multivariate experiment on the model the managed Balanced inference profile resolves to. control = gpt-5.6-luna (the shipped pin); terra = gpt-5.6-terra; glm-5p2 = accounts/fireworks/models/glm-5p2. Only the managed (vellum) implementation moves: ChatGPT-subscription and BYOK installs run the provider the user chose and are outside the experiment. Rollout and targeting are managed in the LaunchDarkly dashboard; any value that is not an arm name resolves to control.",
389
389
  "defaultEnabled": "control",
390
390
  "values": ["control", "terra", "glm-5p2"]
391
+ },
392
+ {
393
+ "id": "obscure-credits",
394
+ "scope": "client",
395
+ "key": "obscure-credits",
396
+ "label": "Obscure Credits",
397
+ "description": "Replaces the dollar amounts on the billing Plan section with a usage-relative view: the current-plan tile trades its price footer for a Usage Balance bar (managed spend this billing cycle against the package's included credits) and the credits spec chip reads \"<Package> usage, reset monthly\" instead of naming a dollar bundle. Spec chips wrap horizontally to fit the shorter labels. Off leaves the Plan section exactly as it ships today.",
398
+ "defaultEnabled": false
391
399
  }
392
400
  ]
393
401
  }
@@ -61,6 +61,7 @@ const {
61
61
  deliverDirect,
62
62
  sendChannelReaction,
63
63
  sendChannelTyping,
64
+ setChannelThreadStatus,
64
65
  supportsChannelTyping,
65
66
  isDirectDelivery,
66
67
  getTransportForCallback,
@@ -152,21 +153,28 @@ describe("Slack sub-operation selection", () => {
152
153
  expect(slack.sendSlackReply).not.toHaveBeenCalled();
153
154
  });
154
155
 
155
- test("assistantThreadStatus routes to sendSlackAssistantThreadStatus", async () => {
156
- await deliverDirect(
157
- `${BASE}/deliver/slack`,
158
- payload({
159
- assistantThreadStatus: {
160
- channel: "C1",
161
- threadTs: "1700.5",
162
- status: "is thinking",
163
- },
164
- }),
165
- );
156
+ test("setChannelThreadStatus reaches Slack without touching the text path", async () => {
157
+ await setChannelThreadStatus(`${BASE}/deliver/slack`, {
158
+ chatId: "C1",
159
+ threadTs: "1700.5",
160
+ status: "is thinking",
161
+ });
162
+
166
163
  expect(slack.sendSlackAssistantThreadStatus).toHaveBeenCalledTimes(1);
167
164
  expect(slack.sendSlackReply).not.toHaveBeenCalled();
168
165
  });
169
166
 
167
+ test("a channel with no status surface resolves quietly", async () => {
168
+ const result = await setChannelThreadStatus(`${BASE}/deliver/telegram`, {
169
+ chatId: "123",
170
+ threadTs: "1700.5",
171
+ status: "is thinking",
172
+ });
173
+
174
+ expect(result).toEqual({ ok: true });
175
+ expect(telegram.sendTelegramReply).not.toHaveBeenCalled();
176
+ });
177
+
170
178
  test("sendChannelTyping resolves quietly for a channel with no typing capability", async () => {
171
179
  const result = await sendChannelTyping(`${BASE}/deliver/slack`, "C1");
172
180
 
@@ -24,15 +24,28 @@ export interface ReactionTarget {
24
24
  readonly action: "add" | "remove";
25
25
  }
26
26
 
27
+ /**
28
+ * A status surface update. `chatId` is the room, spelled the way every other
29
+ * method on this interface spells it.
30
+ */
31
+ export interface ThreadStatus {
32
+ readonly chatId: string;
33
+ readonly threadTs: string;
34
+ readonly status: string;
35
+ /** Rotating hints shown under the status while it holds. */
36
+ readonly loadingMessages?: readonly string[];
37
+ }
38
+
27
39
  /**
28
40
  * Direct outbound delivery for one channel, wrapping the channel's provider-API
29
41
  * send functions behind a uniform surface. Transports are registered statically
30
42
  * (delivery runs in non-daemon contexts) and dispatched by channel, resolved
31
43
  * from the gateway callback URL via `callback-routing.ts`.
32
44
  *
33
- * The dispatcher routes a payload to the optional sub-operation methods when the
34
- * matching payload field is set and the method exists; otherwise it calls
35
- * `deliver`. A transport only implements the sub-operations it supports.
45
+ * Each operation takes its own parameters and is reached through its own entry
46
+ * point; a transport implements only the operations its channel supports, so
47
+ * an absent method is an absent capability. `streamReply` is the last one the
48
+ * dispatcher still selects by inspecting a payload field.
36
49
  */
37
50
  export interface ChannelTransport {
38
51
  /** Canonical source channel id, e.g. `"slack"`. */
@@ -66,10 +79,16 @@ export interface ChannelTransport {
66
79
  target: ReactionTarget,
67
80
  ): Promise<ChannelDeliveryResult>;
68
81
 
69
- /** Update an assistant-thread status surface. Routed when `payload.assistantThreadStatus` is set. */
82
+ /**
83
+ * Set or clear the channel's own "working on it" surface.
84
+ *
85
+ * Distinct from `typing`: an indicator a channel refreshes on a timer versus
86
+ * a status a channel holds until it is changed. Slack has both and uses this
87
+ * one; a channel with only the first implements only `typing`.
88
+ */
70
89
  setThreadStatus?(
71
90
  ctx: CallbackContext,
72
- payload: ChannelReplyPayload,
91
+ status: ThreadStatus,
73
92
  ): Promise<ChannelDeliveryResult>;
74
93
 
75
94
  /** Perform one streaming operation. Routed when `payload.slackStream` is set. */
@@ -20,6 +20,7 @@ import type {
20
20
  CallbackContext,
21
21
  ChannelTransport,
22
22
  ReactionTarget,
23
+ ThreadStatus,
23
24
  } from "./channel-transport.js";
24
25
  import { discordTransport } from "./discord/transport.js";
25
26
  import { slackTransport } from "./slack/transport.js";
@@ -95,6 +96,23 @@ export async function sendChannelReaction(
95
96
  return transport.react(callbackContext(callbackUrl), target);
96
97
  }
97
98
 
99
+ /**
100
+ * Set or clear the channel's status surface.
101
+ *
102
+ * Resolves to nothing when the channel holds none, so a caller does not have
103
+ * to know which channels do.
104
+ */
105
+ export async function setChannelThreadStatus(
106
+ callbackUrl: string,
107
+ status: ThreadStatus,
108
+ ): Promise<ChannelDeliveryResult> {
109
+ const transport = getTransportForCallback(callbackUrl);
110
+ if (!transport?.setThreadStatus) {
111
+ return { ok: true };
112
+ }
113
+ return transport.setThreadStatus(callbackContext(callbackUrl), status);
114
+ }
115
+
98
116
  function callbackContext(callbackUrl: string): CallbackContext {
99
117
  const params: Record<string, string> = {};
100
118
  try {
@@ -143,8 +161,5 @@ export async function deliverDirect(
143
161
  if (payload.slackStream && transport.streamReply) {
144
162
  return transport.streamReply(ctx, payload);
145
163
  }
146
- if (payload.assistantThreadStatus && transport.setThreadStatus) {
147
- return transport.setThreadStatus(ctx, payload);
148
- }
149
164
  return transport.deliver(ctx, payload);
150
165
  }
@@ -372,7 +372,7 @@ export async function sendSlackAssistantThreadStatus(
372
372
  channel: string,
373
373
  threadTs: string,
374
374
  status: string,
375
- loadingMessages?: string[],
375
+ loadingMessages?: readonly string[],
376
376
  ): Promise<void> {
377
377
  try {
378
378
  const body: Record<string, unknown> = {
@@ -64,13 +64,9 @@ export const slackTransport: ChannelTransport = {
64
64
  return { ok: true };
65
65
  },
66
66
 
67
- async setThreadStatus(_ctx, payload) {
68
- const status = payload.assistantThreadStatus;
69
- if (!status) {
70
- return { ok: true };
71
- }
67
+ async setThreadStatus(_ctx, status) {
72
68
  await sendSlackAssistantThreadStatus(
73
- status.channel,
69
+ status.chatId,
74
70
  status.threadTs,
75
71
  status.status,
76
72
  status.loadingMessages,
@@ -92,9 +92,17 @@ const sentReactions: Array<{
92
92
  callbackUrl: string;
93
93
  target: Record<string, unknown>;
94
94
  }> = [];
95
+ const sentThreadStatuses: Array<Record<string, unknown>> = [];
95
96
  mock.module("../../../messaging/providers/index.js", () => ({
96
97
  sendChannelTyping: async () => ({ ok: true }),
97
98
  supportsChannelTyping: () => false,
99
+ setChannelThreadStatus: async (
100
+ _callbackUrl: string,
101
+ status: Record<string, unknown>,
102
+ ) => {
103
+ sentThreadStatuses.push(status);
104
+ return { ok: true };
105
+ },
98
106
  sendChannelReaction: async (
99
107
  callbackUrl: string,
100
108
  target: Record<string, unknown>,
@@ -144,6 +152,7 @@ beforeEach(() => {
144
152
  clearConversations();
145
153
  deliveredChannelReplies.length = 0;
146
154
  sentReactions.length = 0;
155
+ sentThreadStatuses.length = 0;
147
156
  markedProcessedEvents.length = 0;
148
157
  processingFailureEvents.length = 0;
149
158
  retryableFailureEvents.length = 0;
@@ -985,17 +994,14 @@ describe("Slack thinking status timing", () => {
985
994
  const threadTs = "1700000000.000011";
986
995
 
987
996
  const processMessage: MessageProcessor = async () => {
988
- expect(deliveredChannelReplies).toHaveLength(1);
989
- expect(deliveredChannelReplies[0]!.payload.assistantThreadStatus).toEqual(
990
- {
991
- channel: channelId,
992
- threadTs,
993
- status: expect.any(String),
994
- loadingMessages: ["Thinking\u2026"],
995
- },
996
- );
997
- const threadStatus = deliveredChannelReplies[0]!.payload
998
- .assistantThreadStatus as { status: string };
997
+ expect(sentThreadStatuses).toHaveLength(1);
998
+ expect(sentThreadStatuses[0]).toEqual({
999
+ chatId: channelId,
1000
+ threadTs,
1001
+ status: expect.any(String),
1002
+ loadingMessages: ["Thinking\u2026"],
1003
+ });
1004
+ const threadStatus = sentThreadStatuses[0] as { status: string };
999
1005
  expect(slackStatusLabels).toContain(threadStatus.status);
1000
1006
  return { messageId: "user-msg-mention-immediate" };
1001
1007
  };
@@ -1016,12 +1022,9 @@ describe("Slack thinking status timing", () => {
1016
1022
 
1017
1023
  await flush();
1018
1024
 
1019
- const statuses = deliveredChannelReplies.map((entry) => {
1020
- const status = entry.payload.assistantThreadStatus as
1021
- | { status?: string }
1022
- | undefined;
1023
- return status?.status;
1024
- });
1025
+ const statuses = sentThreadStatuses.map(
1026
+ (entry) => (entry as { status?: string }).status,
1027
+ );
1025
1028
  expect(slackStatusLabels).toContain(statuses[0]!);
1026
1029
  expect(statuses[1]).toBe("");
1027
1030
  });
@@ -1102,12 +1105,9 @@ describe("Slack thinking status timing", () => {
1102
1105
 
1103
1106
  await flush();
1104
1107
 
1105
- const statuses = deliveredChannelReplies.map((entry) => {
1106
- const status = entry.payload.assistantThreadStatus as
1107
- | { status?: string }
1108
- | undefined;
1109
- return status?.status;
1110
- });
1108
+ const statuses = sentThreadStatuses.map(
1109
+ (entry) => (entry as { status?: string }).status,
1110
+ );
1111
1111
  expect(slackStatusLabels).toContain(statuses[0]!);
1112
1112
  expect(statuses[1]).toBe("");
1113
1113
  });
@@ -1164,18 +1164,16 @@ describe("Slack thinking status timing", () => {
1164
1164
 
1165
1165
  await flush();
1166
1166
 
1167
- const statuses = deliveredChannelReplies.map(
1168
- (entry) => entry.payload.assistantThreadStatus,
1169
- );
1167
+ const statuses = sentThreadStatuses;
1170
1168
  expect(statuses).toEqual([
1171
1169
  {
1172
- channel: channelId,
1170
+ chatId: channelId,
1173
1171
  threadTs,
1174
1172
  status: expect.any(String),
1175
1173
  loadingMessages: ["In progress (1/2): Search docs"],
1176
1174
  },
1177
1175
  {
1178
- channel: channelId,
1176
+ chatId: channelId,
1179
1177
  threadTs,
1180
1178
  status: "",
1181
1179
  },
@@ -1298,24 +1296,22 @@ describe("Slack thinking status timing", () => {
1298
1296
 
1299
1297
  await flush();
1300
1298
 
1301
- const statuses = deliveredChannelReplies.map(
1302
- (entry) => entry.payload.assistantThreadStatus,
1303
- );
1299
+ const statuses = sentThreadStatuses;
1304
1300
  expect(statuses).toEqual([
1305
1301
  {
1306
- channel: channelId,
1302
+ chatId: channelId,
1307
1303
  threadTs,
1308
1304
  status: expect.any(String),
1309
1305
  loadingMessages: ["In progress (1/2): Read request"],
1310
1306
  },
1311
1307
  {
1312
- channel: channelId,
1308
+ chatId: channelId,
1313
1309
  threadTs,
1314
1310
  status: expect.any(String),
1315
1311
  loadingMessages: ["In progress (2/2): Write answer"],
1316
1312
  },
1317
1313
  {
1318
- channel: channelId,
1314
+ chatId: channelId,
1319
1315
  threadTs,
1320
1316
  status: "",
1321
1317
  },
@@ -20,9 +20,10 @@ import {
20
20
  } from "../../../contacts/guardian-delivery-reader.js";
21
21
  import { isConversationBusyError } from "../../../daemon/conversation-messaging.js";
22
22
  import type { TrustContext } from "../../../daemon/trust-context-types.js";
23
- import { sendChannelReaction } from "../../../messaging/providers/index.js";
24
23
  import {
24
+ sendChannelReaction,
25
25
  sendChannelTyping,
26
+ setChannelThreadStatus,
26
27
  supportsChannelTyping,
27
28
  } from "../../../messaging/providers/index.js";
28
29
  import {
@@ -175,7 +176,6 @@ export function processChannelMessageInBackground(
175
176
  sourceChannel,
176
177
  replyCallbackUrl,
177
178
  chatId: externalChatId,
178
- assistantId,
179
179
  startImmediately: shouldStartSlackThinkingStatusImmediately({
180
180
  sourceChannel,
181
181
  chatType,
@@ -473,16 +473,9 @@ function createSlackThinkingStatusController(params: {
473
473
  sourceChannel: ChannelId;
474
474
  replyCallbackUrl?: string;
475
475
  chatId: string;
476
- assistantId?: string;
477
476
  startImmediately?: boolean;
478
477
  }): SlackThinkingStatusController | undefined {
479
- const {
480
- sourceChannel,
481
- replyCallbackUrl,
482
- chatId,
483
- assistantId,
484
- startImmediately,
485
- } = params;
478
+ const { sourceChannel, replyCallbackUrl, chatId, startImmediately } = params;
486
479
  if (
487
480
  !replyCallbackUrl ||
488
481
  !shouldEmitSlackThinkingStatus(sourceChannel, replyCallbackUrl)
@@ -507,7 +500,6 @@ function createSlackThinkingStatusController(params: {
507
500
  slackThinkingStatus = setSlackThinkingStatus(
508
501
  callbackUrl,
509
502
  chatId,
510
- assistantId,
511
503
  currentLoadingMessages,
512
504
  );
513
505
  lastSentLoadingMessageKey = getLoadingMessagesKey(currentLoadingMessages);
@@ -624,7 +616,6 @@ function getTaskProgressLoadingMessage(
624
616
  function setSlackThinkingStatus(
625
617
  callbackUrl: string,
626
618
  chatId: string,
627
- assistantId?: string,
628
619
  loadingMessages?: string[],
629
620
  ): SlackThinkingStatusHandle {
630
621
  let cleared = false;
@@ -687,15 +678,11 @@ function setSlackThinkingStatus(
687
678
 
688
679
  // Track the set promise so clear waits for it to settle first,
689
680
  // preventing a race where clear arrives at Slack before set.
690
- let statusPromise = deliverChannelReply(callbackUrl, {
681
+ let statusPromise = setChannelThreadStatus(callbackUrl, {
691
682
  chatId,
692
- assistantId,
693
- assistantThreadStatus: {
694
- channel: chatId,
695
- threadTs,
696
- status: getRandomSlackThinkingStatus(),
697
- ...(loadingMessages ? { loadingMessages } : {}),
698
- },
683
+ threadTs,
684
+ status: getRandomSlackThinkingStatus(),
685
+ ...(loadingMessages ? { loadingMessages } : {}),
699
686
  }).catch((err) => {
700
687
  log.debug({ err, chatId, threadTs }, "Failed to set Slack thinking status");
701
688
  });
@@ -705,17 +692,13 @@ function setSlackThinkingStatus(
705
692
  return;
706
693
  }
707
694
  statusPromise = statusPromise.then(() =>
708
- deliverChannelReply(callbackUrl, {
695
+ setChannelThreadStatus(callbackUrl, {
709
696
  chatId,
710
- assistantId,
711
- assistantThreadStatus: {
712
- channel: chatId,
713
- threadTs,
714
- status: getRandomSlackThinkingStatus(),
715
- ...(nextLoadingMessages
716
- ? { loadingMessages: nextLoadingMessages }
717
- : {}),
718
- },
697
+ threadTs,
698
+ status: getRandomSlackThinkingStatus(),
699
+ ...(nextLoadingMessages
700
+ ? { loadingMessages: nextLoadingMessages }
701
+ : {}),
719
702
  }).catch((err) => {
720
703
  log.debug(
721
704
  { err, chatId, threadTs },
@@ -732,14 +715,10 @@ function setSlackThinkingStatus(
732
715
  cleared = true;
733
716
  clearTimeout(safetyTimer);
734
717
  void statusPromise.then(() =>
735
- deliverChannelReply(callbackUrl, {
718
+ setChannelThreadStatus(callbackUrl, {
736
719
  chatId,
737
- assistantId,
738
- assistantThreadStatus: {
739
- channel: chatId,
740
- threadTs,
741
- status: "",
742
- },
720
+ threadTs,
721
+ status: "",
743
722
  }).catch((err) => {
744
723
  log.debug(
745
724
  { err, chatId, threadTs },