chat 4.31.0 → 4.33.0

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.
@@ -784,4 +784,4 @@ declare namespace JSX {
784
784
  }
785
785
  }
786
786
 
787
- export { type SelectOptionElement as $, type ActionsComponent as A, type ButtonComponent as B, type CardChild as C, type DividerComponent as D, type ExternalSelectComponent as E, type FieldComponent as F, type ImageProps as G, type LinkButtonElement as H, type ImageComponent as I, JSX as J, type LinkButtonOptions as K, type LinkButtonComponent as L, type LinkButtonProps as M, type LinkElement as N, type ModalChild as O, type ModalComponent as P, type ModalElement as Q, type ModalOptions as R, type ModalProps as S, type RadioSelectComponent as T, type RadioSelectElement as U, type RadioSelectOptions as V, type SectionComponent as W, type SectionElement as X, type SelectComponent as Y, type SelectElement as Z, type SelectOptionComponent as _, type ActionsElement as a, type SelectOptionProps as a0, type SelectOptions as a1, type SelectProps as a2, Table as a3, type TableAlignment as a4, type TableComponent as a5, type TableElement as a6, type TableOptions as a7, type TableProps as a8, type TextComponent as a9, type TextElement as aa, type TextInputComponent as ab, type TextInputElement as ac, type TextInputOptions as ad, type TextInputProps as ae, type TextProps as af, type TextStyle as ag, cardChildToFallbackText as ah, fromReactElement as ai, fromReactModalElement as aj, isCardElement as ak, isCardLinkProps as al, isJSX as am, isModalElement as an, jsx as ao, jsxDEV as ap, jsxs as aq, toCardElement as ar, toModalElement as as, type ButtonElement as b, type ButtonOptions as c, type ButtonProps as d, type ButtonStyle as e, type CardComponent as f, type CardElement as g, type CardJSXElement as h, type CardJSXProps as i, type CardLinkComponent as j, type CardLinkProps as k, type CardOptions as l, type CardProps as m, type ChatElement as n, type ContainerProps as o, type DividerElement as p, type DividerProps as q, type ExternalSelectElement as r, type ExternalSelectOptions as s, type ExternalSelectProps as t, type FieldElement as u, type FieldProps as v, type FieldsComponent as w, type FieldsElement as x, Fragment as y, type ImageElement as z };
787
+ export { type LinkElement as $, type ActionsComponent as A, type ButtonComponent as B, type CardElement as C, type DividerComponent as D, type ExternalSelectComponent as E, type FieldComponent as F, type ChatElement as G, type ContainerProps as H, type ImageComponent as I, type DividerElement as J, type DividerProps as K, type LinkButtonComponent as L, type ModalComponent as M, type ExternalSelectElement as N, type ExternalSelectOptions as O, type ExternalSelectProps as P, type FieldElement as Q, type RadioSelectComponent as R, type SectionComponent as S, type TextComponent as T, type FieldProps as U, type FieldsElement as V, type ImageElement as W, type ImageProps as X, type LinkButtonElement as Y, type LinkButtonOptions as Z, type LinkButtonProps as _, type CardChild as a, type ModalChild as a0, type ModalElement as a1, type ModalOptions as a2, type ModalProps as a3, type RadioSelectElement as a4, type RadioSelectOptions as a5, type SectionElement as a6, type SelectElement as a7, type SelectOptionElement as a8, type SelectOptionProps as a9, type SelectOptions as aa, type SelectProps as ab, type TableAlignment as ac, type TableElement as ad, type TableOptions as ae, type TextElement as af, type TextInputElement as ag, type TextInputOptions as ah, type TextInputProps as ai, type TextProps as aj, type TextStyle as ak, Fragment as al, JSX as am, type TableComponent as an, type TableProps as ao, isCardLinkProps as ap, jsx as aq, jsxDEV as ar, jsxs as as, type CardComponent as b, type CardLinkComponent as c, type FieldsComponent as d, type SelectComponent as e, type SelectOptionComponent as f, Table as g, type TextInputComponent as h, cardChildToFallbackText as i, fromReactElement as j, fromReactModalElement as k, isCardElement as l, isJSX as m, isModalElement as n, toModalElement as o, type ActionsElement as p, type ButtonElement as q, type ButtonOptions as r, type ButtonProps as s, toCardElement as t, type ButtonStyle as u, type CardJSXElement as v, type CardJSXProps as w, type CardLinkProps as x, type CardOptions as y, type CardProps as z };
@@ -1 +1 @@
1
- export { A as ActionsComponent, B as ButtonComponent, d as ButtonProps, f as CardComponent, h as CardJSXElement, i as CardJSXProps, j as CardLinkComponent, k as CardLinkProps, m as CardProps, n as ChatElement, o as ContainerProps, D as DividerComponent, q as DividerProps, E as ExternalSelectComponent, t as ExternalSelectProps, F as FieldComponent, v as FieldProps, w as FieldsComponent, y as Fragment, I as ImageComponent, G as ImageProps, J as JSX, L as LinkButtonComponent, M as LinkButtonProps, P as ModalComponent, S as ModalProps, T as RadioSelectComponent, W as SectionComponent, Y as SelectComponent, _ as SelectOptionComponent, a0 as SelectOptionProps, a2 as SelectProps, a5 as TableComponent, a8 as TableProps, a9 as TextComponent, ab as TextInputComponent, ae as TextInputProps, af as TextProps, al as isCardLinkProps, am as isJSX, ao as jsx, ap as jsxDEV, aq as jsxs, ar as toCardElement, as as toModalElement } from './jsx-runtime-CzthIo1o.js';
1
+ export { A as ActionsComponent, B as ButtonComponent, s as ButtonProps, b as CardComponent, v as CardJSXElement, w as CardJSXProps, c as CardLinkComponent, x as CardLinkProps, z as CardProps, G as ChatElement, H as ContainerProps, D as DividerComponent, K as DividerProps, E as ExternalSelectComponent, P as ExternalSelectProps, F as FieldComponent, U as FieldProps, d as FieldsComponent, al as Fragment, I as ImageComponent, X as ImageProps, am as JSX, L as LinkButtonComponent, _ as LinkButtonProps, M as ModalComponent, a3 as ModalProps, R as RadioSelectComponent, S as SectionComponent, e as SelectComponent, f as SelectOptionComponent, a9 as SelectOptionProps, ab as SelectProps, an as TableComponent, ao as TableProps, T as TextComponent, h as TextInputComponent, ai as TextInputProps, aj as TextProps, ap as isCardLinkProps, m as isJSX, aq as jsx, ar as jsxDEV, as as jsxs, t as toCardElement, o as toModalElement } from './jsx-runtime-LBOLBP4o.js';
@@ -1,6 +1,177 @@
1
1
  import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
2
2
  import { Root } from 'mdast';
3
- import { n as ChatElement, g as CardElement, Q as ModalElement, $ as SelectOptionElement } from './jsx-runtime-CzthIo1o.js';
3
+ import { G as ChatElement, C as CardElement, a1 as ModalElement, a8 as SelectOptionElement } from './jsx-runtime-LBOLBP4o.js';
4
+
5
+ /**
6
+ * Message class with serialization support for workflow engines.
7
+ */
8
+
9
+ /**
10
+ * Input data for creating a Message instance.
11
+ * Use this interface when constructing Message objects.
12
+ */
13
+ interface MessageData<TRawMessage = unknown> {
14
+ /** Attachments */
15
+ attachments: Attachment[];
16
+ /** Message author */
17
+ author: Author;
18
+ /** Structured formatting as an AST (mdast Root) */
19
+ formatted: FormattedContent;
20
+ /** Unique message ID */
21
+ id: string;
22
+ /** Whether the bot is @-mentioned in this message */
23
+ isMention?: boolean;
24
+ /** Links found in the message */
25
+ links?: LinkPreview[];
26
+ /** Message metadata */
27
+ metadata: MessageMetadata;
28
+ /** Platform-specific raw payload (escape hatch) */
29
+ raw: TRawMessage;
30
+ /** Plain text content (all formatting stripped) */
31
+ text: string;
32
+ /** Thread this message belongs to */
33
+ threadId: string;
34
+ }
35
+ /**
36
+ * Serialized message data for passing to external systems (e.g., workflow engines).
37
+ * Dates are converted to ISO strings, and non-serializable fields are omitted.
38
+ */
39
+ interface SerializedMessage {
40
+ _type: "chat:Message";
41
+ attachments: Array<{
42
+ type: "image" | "file" | "video" | "audio";
43
+ url?: string;
44
+ name?: string;
45
+ mimeType?: string;
46
+ size?: number;
47
+ width?: number;
48
+ height?: number;
49
+ fetchMetadata?: Record<string, string>;
50
+ }>;
51
+ author: {
52
+ userId: string;
53
+ userName: string;
54
+ fullName: string;
55
+ isBot: boolean | "unknown";
56
+ isMe: boolean;
57
+ };
58
+ formatted: Root;
59
+ id: string;
60
+ isMention?: boolean;
61
+ links?: Array<{
62
+ url: string;
63
+ title?: string;
64
+ description?: string;
65
+ imageUrl?: string;
66
+ siteName?: string;
67
+ }>;
68
+ metadata: {
69
+ dateSent: string;
70
+ edited: boolean;
71
+ editedAt?: string;
72
+ };
73
+ raw: unknown;
74
+ text: string;
75
+ threadId: string;
76
+ }
77
+ /**
78
+ * A chat message with serialization support for workflow engines.
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * // Create a message
83
+ * const message = new Message({
84
+ * id: "msg-1",
85
+ * threadId: "slack:C123:1234.5678",
86
+ * text: "Hello world",
87
+ * formatted: parseMarkdown("Hello world"),
88
+ * raw: {},
89
+ * author: { userId: "U123", userName: "user", fullName: "User", isBot: false, isMe: false },
90
+ * metadata: { dateSent: new Date(), edited: false },
91
+ * attachments: [],
92
+ * });
93
+ *
94
+ * // Serialize for workflow
95
+ * const serialized = message.toJSON();
96
+ * ```
97
+ */
98
+ declare class Message<TRawMessage = unknown> {
99
+ /** Unique message ID */
100
+ readonly id: string;
101
+ /** Thread this message belongs to */
102
+ readonly threadId: string;
103
+ /** Plain text content (all formatting stripped) */
104
+ text: string;
105
+ /**
106
+ * Structured formatting as an AST (mdast Root).
107
+ * This is the canonical representation - use this for processing.
108
+ * Use `stringifyMarkdown(message.formatted)` to get markdown string.
109
+ */
110
+ formatted: FormattedContent;
111
+ /** Platform-specific raw payload (escape hatch) */
112
+ raw: TRawMessage;
113
+ /** Message author */
114
+ author: Author;
115
+ /** Message metadata */
116
+ metadata: MessageMetadata;
117
+ /** Attachments */
118
+ attachments: Attachment[];
119
+ /**
120
+ * Whether the bot is @-mentioned in this message.
121
+ *
122
+ * This is set by the Chat SDK before passing the message to handlers.
123
+ * It checks for `@username` in the message text using the adapter's
124
+ * configured `userName` and optional `botUserId`.
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * chat.onSubscribedMessage(async (thread, message) => {
129
+ * if (message.isMention) {
130
+ * await thread.post("You mentioned me!");
131
+ * }
132
+ * });
133
+ * ```
134
+ */
135
+ isMention?: boolean;
136
+ /**
137
+ * Cross-platform user key for this message's author.
138
+ *
139
+ * Set by the Chat SDK before passing the message to handlers, when
140
+ * `ChatConfig.identity` is configured. `undefined` if no resolver is
141
+ * configured; `undefined` (i.e. absent) when the resolver returned null.
142
+ *
143
+ * Used by the Transcripts API to look up / append per-user transcripts.
144
+ */
145
+ userKey?: string;
146
+ /** Links found in the message */
147
+ links: LinkPreview[];
148
+ private _subjectPromise?;
149
+ get subject(): Promise<MessageSubject | null>;
150
+ constructor(data: MessageData<TRawMessage>);
151
+ /**
152
+ * Serialize the message to a plain JSON object.
153
+ * Use this to pass message data to external systems like workflow engines.
154
+ *
155
+ * Note: Attachment `data` (Buffer) and `fetchData` (function) are omitted
156
+ * as they're not serializable.
157
+ */
158
+ toJSON(): SerializedMessage;
159
+ /**
160
+ * Reconstruct a Message from serialized JSON data.
161
+ * Converts ISO date strings back to Date objects.
162
+ */
163
+ static fromJSON<TRawMessage = unknown>(json: SerializedMessage): Message<TRawMessage>;
164
+ /**
165
+ * Serialize a Message instance for @workflow/serde.
166
+ * This static method is automatically called by workflow serialization.
167
+ */
168
+ static [WORKFLOW_SERIALIZE](instance: Message): SerializedMessage;
169
+ /**
170
+ * Deserialize a Message from @workflow/serde.
171
+ * This static method is automatically called by workflow deserialization.
172
+ */
173
+ static [WORKFLOW_DESERIALIZE](data: SerializedMessage): Message;
174
+ }
4
175
 
5
176
  interface ThreadHistoryConfig {
6
177
  /** Maximum messages to keep per thread (default: 100) */
@@ -2298,259 +2469,6 @@ interface TranscriptsApi {
2298
2469
  list(query: ListQuery): Promise<TranscriptEntry[]>;
2299
2470
  }
2300
2471
 
2301
- /**
2302
- * Message class with serialization support for workflow engines.
2303
- */
2304
-
2305
- /**
2306
- * Input data for creating a Message instance.
2307
- * Use this interface when constructing Message objects.
2308
- */
2309
- interface MessageData<TRawMessage = unknown> {
2310
- /** Attachments */
2311
- attachments: Attachment[];
2312
- /** Message author */
2313
- author: Author;
2314
- /** Structured formatting as an AST (mdast Root) */
2315
- formatted: FormattedContent;
2316
- /** Unique message ID */
2317
- id: string;
2318
- /** Whether the bot is @-mentioned in this message */
2319
- isMention?: boolean;
2320
- /** Links found in the message */
2321
- links?: LinkPreview[];
2322
- /** Message metadata */
2323
- metadata: MessageMetadata;
2324
- /** Platform-specific raw payload (escape hatch) */
2325
- raw: TRawMessage;
2326
- /** Plain text content (all formatting stripped) */
2327
- text: string;
2328
- /** Thread this message belongs to */
2329
- threadId: string;
2330
- }
2331
- /**
2332
- * Serialized message data for passing to external systems (e.g., workflow engines).
2333
- * Dates are converted to ISO strings, and non-serializable fields are omitted.
2334
- */
2335
- interface SerializedMessage {
2336
- _type: "chat:Message";
2337
- attachments: Array<{
2338
- type: "image" | "file" | "video" | "audio";
2339
- url?: string;
2340
- name?: string;
2341
- mimeType?: string;
2342
- size?: number;
2343
- width?: number;
2344
- height?: number;
2345
- fetchMetadata?: Record<string, string>;
2346
- }>;
2347
- author: {
2348
- userId: string;
2349
- userName: string;
2350
- fullName: string;
2351
- isBot: boolean | "unknown";
2352
- isMe: boolean;
2353
- };
2354
- formatted: Root;
2355
- id: string;
2356
- isMention?: boolean;
2357
- links?: Array<{
2358
- url: string;
2359
- title?: string;
2360
- description?: string;
2361
- imageUrl?: string;
2362
- siteName?: string;
2363
- }>;
2364
- metadata: {
2365
- dateSent: string;
2366
- edited: boolean;
2367
- editedAt?: string;
2368
- };
2369
- raw: unknown;
2370
- text: string;
2371
- threadId: string;
2372
- }
2373
- /**
2374
- * A chat message with serialization support for workflow engines.
2375
- *
2376
- * @example
2377
- * ```typescript
2378
- * // Create a message
2379
- * const message = new Message({
2380
- * id: "msg-1",
2381
- * threadId: "slack:C123:1234.5678",
2382
- * text: "Hello world",
2383
- * formatted: parseMarkdown("Hello world"),
2384
- * raw: {},
2385
- * author: { userId: "U123", userName: "user", fullName: "User", isBot: false, isMe: false },
2386
- * metadata: { dateSent: new Date(), edited: false },
2387
- * attachments: [],
2388
- * });
2389
- *
2390
- * // Serialize for workflow
2391
- * const serialized = message.toJSON();
2392
- * ```
2393
- */
2394
- declare class Message<TRawMessage = unknown> {
2395
- /** Unique message ID */
2396
- readonly id: string;
2397
- /** Thread this message belongs to */
2398
- readonly threadId: string;
2399
- /** Plain text content (all formatting stripped) */
2400
- text: string;
2401
- /**
2402
- * Structured formatting as an AST (mdast Root).
2403
- * This is the canonical representation - use this for processing.
2404
- * Use `stringifyMarkdown(message.formatted)` to get markdown string.
2405
- */
2406
- formatted: FormattedContent;
2407
- /** Platform-specific raw payload (escape hatch) */
2408
- raw: TRawMessage;
2409
- /** Message author */
2410
- author: Author;
2411
- /** Message metadata */
2412
- metadata: MessageMetadata;
2413
- /** Attachments */
2414
- attachments: Attachment[];
2415
- /**
2416
- * Whether the bot is @-mentioned in this message.
2417
- *
2418
- * This is set by the Chat SDK before passing the message to handlers.
2419
- * It checks for `@username` in the message text using the adapter's
2420
- * configured `userName` and optional `botUserId`.
2421
- *
2422
- * @example
2423
- * ```typescript
2424
- * chat.onSubscribedMessage(async (thread, message) => {
2425
- * if (message.isMention) {
2426
- * await thread.post("You mentioned me!");
2427
- * }
2428
- * });
2429
- * ```
2430
- */
2431
- isMention?: boolean;
2432
- /**
2433
- * Cross-platform user key for this message's author.
2434
- *
2435
- * Set by the Chat SDK before passing the message to handlers, when
2436
- * `ChatConfig.identity` is configured. `undefined` if no resolver is
2437
- * configured; `undefined` (i.e. absent) when the resolver returned null.
2438
- *
2439
- * Used by the Transcripts API to look up / append per-user transcripts.
2440
- */
2441
- userKey?: string;
2442
- /** Links found in the message */
2443
- links: LinkPreview[];
2444
- private _subjectPromise?;
2445
- get subject(): Promise<MessageSubject | null>;
2446
- constructor(data: MessageData<TRawMessage>);
2447
- /**
2448
- * Serialize the message to a plain JSON object.
2449
- * Use this to pass message data to external systems like workflow engines.
2450
- *
2451
- * Note: Attachment `data` (Buffer) and `fetchData` (function) are omitted
2452
- * as they're not serializable.
2453
- */
2454
- toJSON(): SerializedMessage;
2455
- /**
2456
- * Reconstruct a Message from serialized JSON data.
2457
- * Converts ISO date strings back to Date objects.
2458
- */
2459
- static fromJSON<TRawMessage = unknown>(json: SerializedMessage): Message<TRawMessage>;
2460
- /**
2461
- * Serialize a Message instance for @workflow/serde.
2462
- * This static method is automatically called by workflow serialization.
2463
- */
2464
- static [WORKFLOW_SERIALIZE](instance: Message): SerializedMessage;
2465
- /**
2466
- * Deserialize a Message from @workflow/serde.
2467
- * This static method is automatically called by workflow deserialization.
2468
- */
2469
- static [WORKFLOW_DESERIALIZE](data: SerializedMessage): Message;
2470
- }
2471
-
2472
- /**
2473
- * Content part types structurally identical to AI SDK's TextPart, ImagePart,
2474
- * FilePart so that AiMessage[] is directly assignable to ModelMessage[].
2475
- * @see https://ai-sdk.dev/docs/reference/ai-sdk-core/model-message
2476
- */
2477
- /** Matches AI SDK's DataContent */
2478
- type DataContent = string | Uint8Array | ArrayBuffer | Buffer;
2479
- interface AiTextPart {
2480
- text: string;
2481
- type: "text";
2482
- }
2483
- interface AiImagePart {
2484
- image: DataContent | URL;
2485
- mediaType?: string;
2486
- type: "image";
2487
- }
2488
- interface AiFilePart {
2489
- data: DataContent | URL;
2490
- filename?: string;
2491
- mediaType: string;
2492
- type: "file";
2493
- }
2494
- type AiMessagePart = AiTextPart | AiImagePart | AiFilePart;
2495
- /**
2496
- * A message formatted for AI SDK consumption.
2497
- *
2498
- * This is a discriminated union matching AI SDK's ModelMessage type:
2499
- * - User messages can have text, image, and file parts
2500
- * - Assistant messages have string content only
2501
- */
2502
- type AiMessage = AiUserMessage | AiAssistantMessage;
2503
- interface AiUserMessage {
2504
- content: string | AiMessagePart[];
2505
- role: "user";
2506
- }
2507
- interface AiAssistantMessage {
2508
- content: string;
2509
- role: "assistant";
2510
- }
2511
- /**
2512
- * Options for converting messages to AI SDK format.
2513
- */
2514
- interface ToAiMessagesOptions {
2515
- /** When true, prefixes user messages with "[username]: " for multi-user context */
2516
- includeNames?: boolean;
2517
- /**
2518
- * Called when an attachment type is not supported (video, audio).
2519
- * Defaults to `console.warn`.
2520
- */
2521
- onUnsupportedAttachment?: (attachment: Attachment, message: Message) => void;
2522
- /**
2523
- * Called for each message after default processing (text, links, attachments).
2524
- * Return the message (modified or as-is) to include it, or `null` to skip it.
2525
- *
2526
- * @param aiMessage - The processed AI message
2527
- * @param source - The original chat Message
2528
- * @returns The message to include, or null to skip
2529
- */
2530
- transformMessage?: (aiMessage: AiMessage, source: Message) => AiMessage | null | Promise<AiMessage | null>;
2531
- }
2532
- /**
2533
- * Convert chat SDK messages to AI SDK conversation format.
2534
- *
2535
- * - Filters out messages with empty/whitespace-only text
2536
- * - Maps `author.isMe === true` to `"assistant"`, otherwise `"user"`
2537
- * - Uses `message.text` for content
2538
- * - Appends link metadata when available
2539
- * - Includes image attachments and text files as `FilePart`
2540
- * - Uses `fetchData()` when available to include attachment data inline (base64)
2541
- * - Warns on unsupported attachment types (video, audio)
2542
- *
2543
- * Works with `FetchResult.messages`, `thread.recentMessages`, or collected iterables.
2544
- *
2545
- * @example
2546
- * ```typescript
2547
- * const result = await thread.adapter.fetchMessages(thread.id, { limit: 20 });
2548
- * const history = await toAiMessages(result.messages);
2549
- * const response = await agent.stream({ prompt: history });
2550
- * ```
2551
- */
2552
- declare function toAiMessages(messages: Message[], options?: ToAiMessagesOptions): Promise<AiMessage[]>;
2553
-
2554
2472
  /** Filter can be EmojiValue objects, emoji names, or raw emoji formats */
2555
2473
  type EmojiFilter = EmojiValue | string;
2556
2474
  /**
@@ -3138,6 +3056,7 @@ declare class Chat<TAdapters extends Record<string, Adapter> = Record<string, Ad
3138
3056
  * subscription status, mention detection, and pattern matching.
3139
3057
  */
3140
3058
  private dispatchToHandlers;
3059
+ private setMentionFlags;
3141
3060
  private createThread;
3142
3061
  /**
3143
3062
  * Detect if the bot was mentioned in the message.
@@ -3155,4 +3074,86 @@ declare class Chat<TAdapters extends Record<string, Adapter> = Record<string, Ad
3155
3074
  private runHandlers;
3156
3075
  }
3157
3076
 
3158
- export { type LockScope as $, type ActionEvent as A, type ConcurrencyConfig as B, type Channel as C, type ConcurrencyStrategy as D, ConsoleLogger as E, type CountQuery as F, type CustomEmojiMap as G, type DeleteTarget as H, type DirectMessageHandler as I, type DurationString as J, type Emoji as K, type EmojiFormats as L, type EmojiMapConfig as M, type EmojiValue as N, type EphemeralMessage as O, type FetchDirection as P, type FetchOptions as Q, type FetchResult as R, type FileUpload as S, type FormattedContent as T, type IdentityContext as U, type IdentityResolver as V, type LinkPreview as W, type ListQuery as X, type ListThreadsOptions as Y, type ListThreadsResult as Z, type Lock as _, type ActionHandler as a, type TranscriptRole as a$, type LockScopeContext as a0, type LogLevel as a1, type Logger as a2, type MarkdownTextChunk as a3, type MemberJoinedChannelEvent as a4, type MemberJoinedChannelHandler as a5, type MentionHandler as a6, Message as a7, type MessageContext as a8, type MessageData as a9, type PostableRaw as aA, type QueueEntry as aB, type RawMessage as aC, type ReactionEvent as aD, type ReactionHandler as aE, type ScheduledMessage as aF, type SentMessage as aG, type SerializedChannel as aH, type SerializedMessage as aI, type SerializedThread as aJ, type SlashCommandEvent as aK, type SlashCommandHandler as aL, type StateAdapter as aM, type StreamChunk as aN, type StreamEvent as aO, type StreamOptions as aP, type SubscribedMessageHandler as aQ, THREAD_STATE_TTL_MS as aR, type TaskUpdateChunk as aS, type Thread as aT, ThreadHistoryCache as aU, type ThreadHistoryConfig as aV, ThreadImpl as aW, type ThreadInfo as aX, type ThreadSummary as aY, type ToAiMessagesOptions as aZ, type TranscriptEntry as a_, type MessageHandler as aa, type MessageMetadata as ab, type MessageSubject as ac, type ModalClearResponse as ad, type ModalCloseEvent as ae, type ModalCloseHandler as af, type ModalCloseResponse as ag, type ModalErrorsResponse as ah, type ModalPushResponse as ai, type ModalResponse as aj, type ModalSubmitEvent as ak, type ModalSubmitHandler as al, type ModalUpdateResponse as am, type OptionsLoadEvent as an, type OptionsLoadGroup as ao, type OptionsLoadHandler as ap, type OptionsLoadResult as aq, type PlanUpdateChunk as ar, type PostEphemeralOptions as as, type Postable as at, type PostableAst as au, type PostableCard as av, type PostableMarkdown as aw, type PostableMessage as ax, type PostableObject as ay, type PostableObjectContext as az, type Adapter as b, type TranscriptsApi as b0, type TranscriptsConfig as b1, type UserInfo as b2, type WebhookOptions as b3, type WellKnownEmoji as b4, deriveChannelId as b5, isPostableObject as b6, toAiMessages as b7, type AdapterPostableMessage as c, type AiAssistantMessage as d, type AiFilePart as e, type AiImagePart as f, type AiMessage as g, type AiMessagePart as h, type AiTextPart as i, type AiUserMessage as j, type AppHomeOpenedEvent as k, type AppHomeOpenedHandler as l, type AppendInput as m, type AppendOptions as n, type AssistantContextChangedEvent as o, type AssistantContextChangedHandler as p, type AssistantThreadStartedEvent as q, type AssistantThreadStartedHandler as r, type Attachment as s, type Author as t, ChannelImpl as u, type ChannelInfo as v, type ChannelVisibility as w, Chat as x, type ChatConfig as y, type ChatInstance as z };
3077
+ /**
3078
+ * Content part types structurally identical to AI SDK's TextPart, ImagePart,
3079
+ * FilePart so that AiMessage[] is directly assignable to ModelMessage[].
3080
+ * @see https://ai-sdk.dev/docs/reference/ai-sdk-core/model-message
3081
+ */
3082
+ /** Matches AI SDK's DataContent */
3083
+ type DataContent = string | Uint8Array | ArrayBuffer | Buffer;
3084
+ interface AiTextPart {
3085
+ text: string;
3086
+ type: "text";
3087
+ }
3088
+ interface AiImagePart {
3089
+ image: DataContent | URL;
3090
+ mediaType?: string;
3091
+ type: "image";
3092
+ }
3093
+ interface AiFilePart {
3094
+ data: DataContent | URL;
3095
+ filename?: string;
3096
+ mediaType: string;
3097
+ type: "file";
3098
+ }
3099
+ type AiMessagePart = AiTextPart | AiImagePart | AiFilePart;
3100
+ /**
3101
+ * A message formatted for AI SDK consumption.
3102
+ *
3103
+ * This is a discriminated union matching AI SDK's ModelMessage type:
3104
+ * - User messages can have text, image, and file parts
3105
+ * - Assistant messages have string content only
3106
+ */
3107
+ type AiMessage = AiUserMessage | AiAssistantMessage;
3108
+ interface AiUserMessage {
3109
+ content: string | AiMessagePart[];
3110
+ role: "user";
3111
+ }
3112
+ interface AiAssistantMessage {
3113
+ content: string;
3114
+ role: "assistant";
3115
+ }
3116
+ /**
3117
+ * Options for converting messages to AI SDK format.
3118
+ */
3119
+ interface ToAiMessagesOptions {
3120
+ /** When true, prefixes user messages with "[username]: " for multi-user context */
3121
+ includeNames?: boolean;
3122
+ /**
3123
+ * Called when an attachment type is not supported (video, audio).
3124
+ * Defaults to `console.warn`.
3125
+ */
3126
+ onUnsupportedAttachment?: (attachment: Attachment, message: Message) => void;
3127
+ /**
3128
+ * Called for each message after default processing (text, links, attachments).
3129
+ * Return the message (modified or as-is) to include it, or `null` to skip it.
3130
+ *
3131
+ * @param aiMessage - The processed AI message
3132
+ * @param source - The original chat Message
3133
+ * @returns The message to include, or null to skip
3134
+ */
3135
+ transformMessage?: (aiMessage: AiMessage, source: Message) => AiMessage | null | Promise<AiMessage | null>;
3136
+ }
3137
+ /**
3138
+ * Convert chat SDK messages to AI SDK conversation format.
3139
+ *
3140
+ * - Filters out messages with empty/whitespace-only text
3141
+ * - Maps `author.isMe === true` to `"assistant"`, otherwise `"user"`
3142
+ * - Uses `message.text` for content
3143
+ * - Appends link metadata when available
3144
+ * - Includes image attachments and text files as `FilePart`
3145
+ * - Uses `fetchData()` when available to include attachment data inline (base64)
3146
+ * - Warns on unsupported attachment types (video, audio)
3147
+ *
3148
+ * Works with `FetchResult.messages`, `thread.recentMessages`, or collected iterables.
3149
+ *
3150
+ * @example
3151
+ * ```typescript
3152
+ * const result = await thread.adapter.fetchMessages(thread.id, { limit: 20 });
3153
+ * const history = await toAiMessages(result.messages);
3154
+ * const response = await agent.stream({ prompt: history });
3155
+ * ```
3156
+ */
3157
+ declare function toAiMessages(messages: Message[], options?: ToAiMessagesOptions): Promise<AiMessage[]>;
3158
+
3159
+ export { type FileUpload as $, type AiAssistantMessage as A, type AssistantThreadStartedHandler as B, Chat as C, type Attachment as D, type EmojiFormats as E, type Author as F, type Channel as G, ChannelImpl as H, type ChannelInfo as I, type ChatConfig as J, type ChatInstance as K, type ConcurrencyConfig as L, type ConcurrencyStrategy as M, ConsoleLogger as N, type CountQuery as O, type PostableObject as P, type DeleteTarget as Q, type DirectMessageHandler as R, type StreamChunk as S, type ToAiMessagesOptions as T, type DurationString as U, type Emoji as V, type WellKnownEmoji as W, type EphemeralMessage as X, type FetchDirection as Y, type FetchOptions as Z, type FetchResult as _, type ChannelVisibility as a, type ThreadSummary as a$, type FormattedContent as a0, type IdentityContext as a1, type IdentityResolver as a2, type LinkPreview as a3, type ListQuery as a4, type ListThreadsOptions as a5, type ListThreadsResult as a6, type Lock as a7, type LockScope as a8, type LockScopeContext as a9, type PlanUpdateChunk as aA, type PostEphemeralOptions as aB, type Postable as aC, type PostableAst as aD, type PostableCard as aE, type PostableMarkdown as aF, type PostableMessage as aG, type PostableRaw as aH, type QueueEntry as aI, type RawMessage as aJ, type ReactionEvent as aK, type ReactionHandler as aL, type ScheduledMessage as aM, type SentMessage as aN, type SerializedChannel as aO, type SerializedMessage as aP, type SerializedThread as aQ, type SlashCommandEvent as aR, type SlashCommandHandler as aS, type StateAdapter as aT, type StreamOptions as aU, type SubscribedMessageHandler as aV, THREAD_STATE_TTL_MS as aW, type TaskUpdateChunk as aX, type Thread as aY, ThreadImpl as aZ, type ThreadInfo as a_, type LogLevel as aa, type Logger as ab, type MarkdownTextChunk as ac, type MemberJoinedChannelEvent as ad, type MemberJoinedChannelHandler as ae, type MentionHandler as af, Message as ag, type MessageContext as ah, type MessageData as ai, type MessageHandler as aj, type MessageMetadata as ak, type MessageSubject as al, type ModalClearResponse as am, type ModalCloseEvent as an, type ModalCloseHandler as ao, type ModalCloseResponse as ap, type ModalErrorsResponse as aq, type ModalPushResponse as ar, type ModalResponse as as, type ModalSubmitEvent as at, type ModalSubmitHandler as au, type ModalUpdateResponse as av, type OptionsLoadEvent as aw, type OptionsLoadGroup as ax, type OptionsLoadHandler as ay, type OptionsLoadResult as az, type AiFilePart as b, type TranscriptEntry as b0, type TranscriptRole as b1, type TranscriptsApi as b2, type TranscriptsConfig as b3, type UserInfo as b4, type WebhookOptions as b5, deriveChannelId as b6, isPostableObject as b7, type AiImagePart as c, type AiMessage as d, type AiMessagePart as e, type AiTextPart as f, type AiUserMessage as g, type Adapter as h, type PostableObjectContext as i, ThreadHistoryCache as j, type ThreadHistoryConfig as k, type StreamEvent as l, type EmojiMapConfig as m, type EmojiValue as n, type CustomEmojiMap as o, type AdapterPostableMessage as p, type ActionEvent as q, type ActionHandler as r, type AppHomeOpenedEvent as s, toAiMessages as t, type AppHomeOpenedHandler as u, type AppendInput as v, type AppendOptions as w, type AssistantContextChangedEvent as x, type AssistantContextChangedHandler as y, type AssistantThreadStartedEvent as z };
package/docs/api/chat.mdx CHANGED
@@ -27,9 +27,9 @@ const bot = new Chat(config);
27
27
  type: 'Record<string, Adapter>',
28
28
  },
29
29
  dedupeTtlMs: {
30
- description: 'TTL for message deduplication entries in milliseconds. Increase if webhook cold starts cause platform retries after the default window.',
30
+ description: 'TTL for message deduplication entries in milliseconds. The default outlives the last Slack event retry (~5 minutes after original delivery); increase it if your platform redelivers later than that.',
31
31
  type: 'number',
32
- default: '300000',
32
+ default: '600000',
33
33
  },
34
34
  state: {
35
35
  description: 'State adapter for subscriptions, locking, and caching.',
@@ -98,6 +98,20 @@ When the [Web adapter](/adapters/official/web) is selected, the CLI also creates
98
98
 
99
99
  When the [Discord adapter](/adapters/official/discord) is selected, the CLI also creates a Gateway listener at `/api/discord/gateway` and a `vercel.json` cron that calls it. Discord delivers slash commands and button clicks to the webhook route, but regular messages and reactions only arrive over the Gateway WebSocket, so the cron keeps that connection alive and forwards events to `/api/webhooks/discord`. Set a `CRON_SECRET` environment variable to authenticate the cron requests. The generated serverless Gateway cron requires [Vercel Pro or Enterprise](https://vercel.com/docs/cron-jobs/usage-and-pricing) because it runs every nine minutes.
100
100
 
101
+ ## Vercel Connect
102
+
103
+ [Vercel Connect](/docs/vercel-connect) lets the Slack, GitHub, and Linear adapters authenticate with a connector instead of stored provider secrets. Pass `--connect` — or choose **Vercel Connect** at the interactive auth-mode prompt — to scaffold Connect wiring for any selected Slack, GitHub, or Linear adapter:
104
+
105
+ ```bash
106
+ npm create chat-sdk@latest -- my-bot --adapter slack --connect -y
107
+ ```
108
+
109
+ The generated `src/lib/bot.ts` spreads the matching helper from `@vercel/connect/chat` into the adapter factory, `@vercel/connect` is added to dependencies, and `.env.example` lists each connector UID (for example `SLACK_CONNECTOR`) in place of native secrets.
110
+
111
+ <Callout type="info">
112
+ Vercel Connect provides `VERCEL_OIDC_TOKEN` at runtime. For local development, run `vercel link` then `vercel env pull` to populate it. Connect forwards inbound webhooks only to deployed URLs, so test webhook delivery against a Vercel deployment (such as a preview) rather than localhost.
113
+ </Callout>
114
+
101
115
  ## Reference
102
116
 
103
117
  | Option | Description |
@@ -106,6 +120,7 @@ When the [Discord adapter](/adapters/official/discord) is selected, the CLI also
106
120
  | `-d, --description <text>` | Project description. |
107
121
  | `--adapter <values...>` | Platform or state adapters to include. |
108
122
  | `--vendor` | List only vendor-official adapters in the interactive prompt. |
123
+ | `--connect` | Authenticate Slack, GitHub, and Linear adapters with Vercel Connect. |
109
124
  | `--pm <manager>` | Package manager to use: `npm`, `yarn`, `pnpm`, or `bun`. |
110
125
  | `-y, --yes` | Skip prompts and accept defaults. |
111
126
  | `--interactive` | Always prompt, even when a coding agent environment is detected. |
@@ -32,6 +32,8 @@ The `fallbackToDM` option is required and controls behavior on platforms without
32
32
  | Discord | No | DM fallback | Persists in DM |
33
33
  | Teams | No | DM fallback | Persists in DM |
34
34
 
35
+ Discord slash command responses can be made ephemeral with the Discord adapter's [`interactionFlags` option](/adapters/official/discord#interaction-flags). Outside that interaction flow, `postEphemeral` still follows the fallback behavior.
36
+
35
37
  ## Check for fallback
36
38
 
37
39
  ```typescript title="lib/bot.ts" lineNumbers
package/docs/meta.json CHANGED
@@ -9,6 +9,7 @@
9
9
  "threads-messages-channels",
10
10
  "handling-events",
11
11
  "posting-messages",
12
+ "vercel-connect",
12
13
  "error-handling",
13
14
  "testing",
14
15
  "---AI---",
@@ -121,6 +121,8 @@ Telegram supports bot commands such as `/status` and `/status@mybot`. Register h
121
121
 
122
122
  Discord slash commands are received via [HTTP Interactions](/adapters/official/discord#http-interactions-vs-gateway) — no Gateway connection is needed. The adapter automatically sends a deferred response to Discord, then resolves it when your handler calls `event.channel.post()`.
123
123
 
124
+ To make selected Discord slash command responses ephemeral, return `DiscordInteractionResponseFlag.Ephemeral` from the Discord adapter's [`interactionFlags` option](/adapters/official/discord#interaction-flags).
125
+
124
126
  ### Subcommands
125
127
 
126
128
  Discord supports subcommand groups and subcommands. The adapter flattens these into the `event.command` path:
@@ -217,11 +217,14 @@ await plan.addTask({ title: "Summarize findings" });
217
217
  await plan.complete({ completeMessage: "Done!" });
218
218
  ```
219
219
 
220
- By default `updateTask()` mutates the most recent `in_progress` task. Pass `{ id }` to target a specific task — useful when work runs in parallel or out of order:
220
+ By default `updateTask()` mutates the most recent `in_progress` task. For parallel work, pass `autoCompletePrevious: false` to `addTask()` so earlier tasks stay in progress; then pass `{ id }` to `updateTask()` to target a specific task when updates run out of order:
221
221
 
222
222
  ```typescript
223
223
  const fetchTask = await plan.addTask({ title: "Fetch data" });
224
- const transformTask = await plan.addTask({ title: "Transform" });
224
+ const transformTask = await plan.addTask({
225
+ title: "Transform",
226
+ autoCompletePrevious: false,
227
+ });
225
228
 
226
229
  // Update a specific task by id, even if it isn't the most recent in_progress one.
227
230
  await plan.updateTask({ id: fetchTask.id, output: "Got 42 rows" });
@@ -232,7 +235,7 @@ Adapters that don't support PostableObject editing (e.g. WhatsApp) render the pl
232
235
 
233
236
  | Method | Description |
234
237
  |--------|-------------|
235
- | `addTask({ title, children? })` | Append a new task. The previous in-progress task is auto-completed |
238
+ | `addTask({ title, children?, autoCompletePrevious? })` | Append a new task. When `autoCompletePrevious` is true (default), existing in-progress tasks are marked complete first; pass `false` for parallel workflows |
236
239
  | `updateTask(input)` | Mutate the current (or `{ id }`-targeted) task's `output`, `status`, or `title` |
237
240
  | `complete({ completeMessage })` | Mark all in-progress tasks complete and update the plan title |
238
241
  | `reset({ initialMessage })` | Discard all tasks and start fresh with a new initial message — useful when re-using a plan handle for a new run |