chat 4.22.0 → 4.23.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.
package/dist/index.d.ts CHANGED
@@ -42,6 +42,7 @@ declare class MessageHistoryCache {
42
42
  interface SerializedChannel {
43
43
  _type: "chat:Channel";
44
44
  adapterName: string;
45
+ channelVisibility?: ChannelVisibility;
45
46
  id: string;
46
47
  isDM: boolean;
47
48
  }
@@ -50,6 +51,7 @@ interface SerializedChannel {
50
51
  */
51
52
  interface ChannelImplConfigWithAdapter {
52
53
  adapter: Adapter;
54
+ channelVisibility?: ChannelVisibility;
53
55
  id: string;
54
56
  isDM?: boolean;
55
57
  messageHistory?: MessageHistoryCache;
@@ -60,6 +62,7 @@ interface ChannelImplConfigWithAdapter {
60
62
  */
61
63
  interface ChannelImplConfigLazy {
62
64
  adapterName: string;
65
+ channelVisibility?: ChannelVisibility;
63
66
  id: string;
64
67
  isDM?: boolean;
65
68
  }
@@ -67,6 +70,7 @@ type ChannelImplConfig = ChannelImplConfigWithAdapter | ChannelImplConfigLazy;
67
70
  declare class ChannelImpl<TState = Record<string, unknown>> implements Channel<TState> {
68
71
  readonly id: string;
69
72
  readonly isDM: boolean;
73
+ readonly channelVisibility: ChannelVisibility;
70
74
  private _adapter?;
71
75
  private readonly _adapterName?;
72
76
  private _stateAdapterInstance?;
@@ -144,6 +148,7 @@ interface SerializedThread {
144
148
  _type: "chat:Thread";
145
149
  adapterName: string;
146
150
  channelId: string;
151
+ channelVisibility?: ChannelVisibility;
147
152
  currentMessage?: SerializedMessage;
148
153
  id: string;
149
154
  isDM: boolean;
@@ -154,6 +159,7 @@ interface SerializedThread {
154
159
  interface ThreadImplConfigWithAdapter {
155
160
  adapter: Adapter;
156
161
  channelId: string;
162
+ channelVisibility?: ChannelVisibility;
157
163
  currentMessage?: Message;
158
164
  fallbackStreamingPlaceholderText?: string | null;
159
165
  id: string;
@@ -172,6 +178,7 @@ interface ThreadImplConfigWithAdapter {
172
178
  interface ThreadImplConfigLazy {
173
179
  adapterName: string;
174
180
  channelId: string;
181
+ channelVisibility?: ChannelVisibility;
175
182
  currentMessage?: Message;
176
183
  fallbackStreamingPlaceholderText?: string | null;
177
184
  id: string;
@@ -186,6 +193,7 @@ declare class ThreadImpl<TState = Record<string, unknown>> implements Thread<TSt
186
193
  readonly id: string;
187
194
  readonly channelId: string;
188
195
  readonly isDM: boolean;
196
+ readonly channelVisibility: ChannelVisibility;
189
197
  /** Direct adapter instance (if provided) */
190
198
  private _adapter?;
191
199
  /** Adapter name for lazy resolution */
@@ -329,6 +337,16 @@ declare class NotImplementedError extends ChatError {
329
337
  constructor(message: string, feature?: string, cause?: unknown);
330
338
  }
331
339
 
340
+ /**
341
+ * Represents the visibility scope of a channel.
342
+ *
343
+ * - `private`: Channel is only visible to invited members (e.g., private Slack channels)
344
+ * - `workspace`: Channel is visible to all workspace members (e.g., public Slack channels)
345
+ * - `external`: Channel is shared with external organizations (e.g., Slack Connect)
346
+ * - `unknown`: Visibility cannot be determined
347
+ */
348
+ type ChannelVisibility = "private" | "workspace" | "external" | "unknown";
349
+
332
350
  /**
333
351
  * Chat configuration with type-safe adapter inference.
334
352
  * @template TAdapters - Record of adapter name to adapter instance
@@ -513,6 +531,16 @@ interface Adapter<TThreadId = unknown, TRawMessage = unknown> {
513
531
  fetchMessages(threadId: string, options?: FetchOptions): Promise<FetchResult<TRawMessage>>;
514
532
  /** Fetch thread metadata */
515
533
  fetchThread(threadId: string): Promise<ThreadInfo>;
534
+ /**
535
+ * Get the visibility scope of a channel containing the thread.
536
+ *
537
+ * This distinguishes between private channels, workspace-visible channels,
538
+ * and externally shared channels (e.g., Slack Connect).
539
+ *
540
+ * @param threadId - The thread ID to check
541
+ * @returns The channel visibility scope
542
+ */
543
+ getChannelVisibility?(threadId: string): ChannelVisibility;
516
544
  /** Handle incoming webhook request */
517
545
  handleWebhook(request: Request, options?: WebhookOptions): Promise<Response>;
518
546
  /** Called when Chat instance is created (internal use) */
@@ -862,6 +890,8 @@ interface Lock {
862
890
  interface Postable<TState = Record<string, unknown>, TRawMessage = unknown> {
863
891
  /** The adapter this entity belongs to */
864
892
  readonly adapter: Adapter;
893
+ /** The visibility scope of this channel */
894
+ readonly channelVisibility: ChannelVisibility;
865
895
  /** Unique ID */
866
896
  readonly id: string;
867
897
  /** Whether this is a direct message conversation */
@@ -961,6 +991,8 @@ interface ThreadSummary<TRawMessage = unknown> {
961
991
  * Channel metadata returned by fetchInfo().
962
992
  */
963
993
  interface ChannelInfo {
994
+ /** The visibility scope of this channel */
995
+ channelVisibility?: ChannelVisibility;
964
996
  id: string;
965
997
  isDM?: boolean;
966
998
  memberCount?: number;
@@ -1130,6 +1162,8 @@ interface Thread<TState = Record<string, unknown>, TRawMessage = unknown> extend
1130
1162
  interface ThreadInfo {
1131
1163
  channelId: string;
1132
1164
  channelName?: string;
1165
+ /** The visibility scope of this channel */
1166
+ channelVisibility?: ChannelVisibility;
1133
1167
  id: string;
1134
1168
  /** Whether this is a direct message conversation */
1135
1169
  isDM?: boolean;
@@ -3136,4 +3170,4 @@ declare const Select: SelectComponent;
3136
3170
  declare const SelectOption: SelectOptionComponent;
3137
3171
  declare const TextInput: TextInputComponent;
3138
3172
 
3139
- export { type ActionEvent, type ActionHandler, Actions, ActionsComponent, type Adapter, type AdapterPostableMessage, type AiAssistantMessage, type AiFilePart, type AiImagePart, type AiMessage, type AiMessagePart, type AiTextPart, type AiUserMessage, type AppHomeOpenedEvent, type AppHomeOpenedHandler, type AssistantContextChangedEvent, type AssistantContextChangedHandler, type AssistantThreadStartedEvent, type AssistantThreadStartedHandler, type Attachment, type Author, BaseFormatConverter, Button, ButtonComponent, Card, CardChild, CardComponent, CardElement, CardLink, CardLinkComponent, CardText, type Channel, ChannelImpl, type ChannelInfo, Chat, type ChatConfig, ChatElement, ChatError, type ChatInstance, type ConcurrencyConfig, type ConcurrencyStrategy, ConsoleLogger, type CustomEmojiMap, DEFAULT_EMOJI_MAP, type DirectMessageHandler, Divider, DividerComponent, type Emoji, type EmojiFormats, type EmojiMapConfig, EmojiResolver, type EmojiValue, type EphemeralMessage, type FetchDirection, type FetchOptions, type FetchResult, Field, FieldComponent, Fields, FieldsComponent, type FileUpload, type FormatConverter, type FormattedContent, Image, ImageComponent, LinkButton, LinkButtonComponent, type LinkPreview, type ListThreadsOptions, type ListThreadsResult, type Lock, LockError, type LockScope, type LockScopeContext, type LogLevel, type Logger, type MarkdownConverter, type MarkdownTextChunk, type MemberJoinedChannelEvent, type MemberJoinedChannelHandler, type MentionHandler, Message, type MessageContext, type MessageData, type MessageHandler, MessageHistoryCache, type MessageHistoryConfig, type MessageMetadata, Modal, type ModalCloseEvent, type ModalCloseHandler, type ModalCloseResponse, ModalComponent, ModalElement, type ModalErrorsResponse, type ModalPushResponse, type ModalResponse, type ModalSubmitEvent, type ModalSubmitHandler, type ModalUpdateResponse, NotImplementedError, type PlanUpdateChunk, type PostEphemeralOptions, type Postable, type PostableAst, type PostableCard, type PostableMarkdown, type PostableMessage, type PostableRaw, type QueueEntry, RadioSelect, RadioSelectComponent, RateLimitError, type RawMessage, type ReactionEvent, type ReactionHandler, type ScheduledMessage, Section, SectionComponent, Select, SelectComponent, SelectOption, SelectOptionComponent, type SentMessage, type SerializedChannel, type SerializedMessage, type SerializedThread, type SlashCommandEvent, type SlashCommandHandler, type StateAdapter, type StreamChunk, type StreamEvent, type StreamOptions, StreamingMarkdownRenderer, type SubscribedMessageHandler, THREAD_STATE_TTL_MS, Table, type TaskUpdateChunk, TextComponent, TextInput, TextInputComponent, type Thread, ThreadImpl, type ThreadInfo, type ThreadSummary, type WebhookOptions, type WellKnownEmoji, blockquote, cardChildToFallbackText, codeBlock, convertEmojiPlaceholders, createEmoji, defaultEmojiResolver, deriveChannelId, emoji, emphasis, fromFullStream, fromReactElement, fromReactModalElement, getEmoji, getNodeChildren, getNodeValue, inlineCode, isBlockquoteNode, isCardElement, isCodeNode, isDeleteNode, isEmphasisNode, isInlineCodeNode, isJSX, isLinkNode, isListItemNode, isListNode, isModalElement, isParagraphNode, isStrongNode, isTableCellNode, isTableNode, isTableRowNode, isTextNode, link, markdownToPlainText, paragraph, parseMarkdown, root, strikethrough, stringifyMarkdown, strong, tableElementToAscii, tableToAscii, text, toAiMessages, toCardElement, toModalElement, toPlainText, walkAst };
3173
+ export { type ActionEvent, type ActionHandler, Actions, ActionsComponent, type Adapter, type AdapterPostableMessage, type AiAssistantMessage, type AiFilePart, type AiImagePart, type AiMessage, type AiMessagePart, type AiTextPart, type AiUserMessage, type AppHomeOpenedEvent, type AppHomeOpenedHandler, type AssistantContextChangedEvent, type AssistantContextChangedHandler, type AssistantThreadStartedEvent, type AssistantThreadStartedHandler, type Attachment, type Author, BaseFormatConverter, Button, ButtonComponent, Card, CardChild, CardComponent, CardElement, CardLink, CardLinkComponent, CardText, type Channel, ChannelImpl, type ChannelInfo, type ChannelVisibility, Chat, type ChatConfig, ChatElement, ChatError, type ChatInstance, type ConcurrencyConfig, type ConcurrencyStrategy, ConsoleLogger, type CustomEmojiMap, DEFAULT_EMOJI_MAP, type DirectMessageHandler, Divider, DividerComponent, type Emoji, type EmojiFormats, type EmojiMapConfig, EmojiResolver, type EmojiValue, type EphemeralMessage, type FetchDirection, type FetchOptions, type FetchResult, Field, FieldComponent, Fields, FieldsComponent, type FileUpload, type FormatConverter, type FormattedContent, Image, ImageComponent, LinkButton, LinkButtonComponent, type LinkPreview, type ListThreadsOptions, type ListThreadsResult, type Lock, LockError, type LockScope, type LockScopeContext, type LogLevel, type Logger, type MarkdownConverter, type MarkdownTextChunk, type MemberJoinedChannelEvent, type MemberJoinedChannelHandler, type MentionHandler, Message, type MessageContext, type MessageData, type MessageHandler, MessageHistoryCache, type MessageHistoryConfig, type MessageMetadata, Modal, type ModalCloseEvent, type ModalCloseHandler, type ModalCloseResponse, ModalComponent, ModalElement, type ModalErrorsResponse, type ModalPushResponse, type ModalResponse, type ModalSubmitEvent, type ModalSubmitHandler, type ModalUpdateResponse, NotImplementedError, type PlanUpdateChunk, type PostEphemeralOptions, type Postable, type PostableAst, type PostableCard, type PostableMarkdown, type PostableMessage, type PostableRaw, type QueueEntry, RadioSelect, RadioSelectComponent, RateLimitError, type RawMessage, type ReactionEvent, type ReactionHandler, type ScheduledMessage, Section, SectionComponent, Select, SelectComponent, SelectOption, SelectOptionComponent, type SentMessage, type SerializedChannel, type SerializedMessage, type SerializedThread, type SlashCommandEvent, type SlashCommandHandler, type StateAdapter, type StreamChunk, type StreamEvent, type StreamOptions, StreamingMarkdownRenderer, type SubscribedMessageHandler, THREAD_STATE_TTL_MS, Table, type TaskUpdateChunk, TextComponent, TextInput, TextInputComponent, type Thread, ThreadImpl, type ThreadInfo, type ThreadSummary, type WebhookOptions, type WellKnownEmoji, blockquote, cardChildToFallbackText, codeBlock, convertEmojiPlaceholders, createEmoji, defaultEmojiResolver, deriveChannelId, emoji, emphasis, fromFullStream, fromReactElement, fromReactModalElement, getEmoji, getNodeChildren, getNodeValue, inlineCode, isBlockquoteNode, isCardElement, isCodeNode, isDeleteNode, isEmphasisNode, isInlineCodeNode, isJSX, isLinkNode, isListItemNode, isListNode, isModalElement, isParagraphNode, isStrongNode, isTableCellNode, isTableNode, isTableRowNode, isTextNode, link, markdownToPlainText, paragraph, parseMarkdown, root, strikethrough, stringifyMarkdown, strong, tableElementToAscii, tableToAscii, text, toAiMessages, toCardElement, toModalElement, toPlainText, walkAst };
package/dist/index.js CHANGED
@@ -469,6 +469,7 @@ function isAsyncIterable(value) {
469
469
  var ChannelImpl = class _ChannelImpl {
470
470
  id;
471
471
  isDM;
472
+ channelVisibility;
472
473
  _adapter;
473
474
  _adapterName;
474
475
  _stateAdapterInstance;
@@ -477,6 +478,7 @@ var ChannelImpl = class _ChannelImpl {
477
478
  constructor(config) {
478
479
  this.id = config.id;
479
480
  this.isDM = config.isDM ?? false;
481
+ this.channelVisibility = config.channelVisibility ?? "unknown";
480
482
  if (isLazyConfig(config)) {
481
483
  this._adapterName = config.adapterName;
482
484
  } else {
@@ -695,6 +697,7 @@ var ChannelImpl = class _ChannelImpl {
695
697
  _type: "chat:Channel",
696
698
  id: this.id,
697
699
  adapterName: this.adapter.name,
700
+ channelVisibility: this.channelVisibility,
698
701
  isDM: this.isDM
699
702
  };
700
703
  }
@@ -702,6 +705,7 @@ var ChannelImpl = class _ChannelImpl {
702
705
  const channel = new _ChannelImpl({
703
706
  id: json.id,
704
707
  adapterName: json.adapterName,
708
+ channelVisibility: json.channelVisibility,
705
709
  isDM: json.isDM
706
710
  });
707
711
  if (adapter) {
@@ -1099,6 +1103,7 @@ var ThreadImpl = class _ThreadImpl {
1099
1103
  id;
1100
1104
  channelId;
1101
1105
  isDM;
1106
+ channelVisibility;
1102
1107
  /** Direct adapter instance (if provided) */
1103
1108
  _adapter;
1104
1109
  /** Adapter name for lazy resolution */
@@ -1122,6 +1127,7 @@ var ThreadImpl = class _ThreadImpl {
1122
1127
  this.id = config.id;
1123
1128
  this.channelId = config.channelId;
1124
1129
  this.isDM = config.isDM ?? false;
1130
+ this.channelVisibility = config.channelVisibility ?? "unknown";
1125
1131
  this._isSubscribedContext = config.isSubscribedContext ?? false;
1126
1132
  this._currentMessage = config.currentMessage;
1127
1133
  this._logger = config.logger;
@@ -1212,6 +1218,7 @@ var ThreadImpl = class _ThreadImpl {
1212
1218
  adapter: this.adapter,
1213
1219
  stateAdapter: this._stateAdapter,
1214
1220
  isDM: this.isDM,
1221
+ channelVisibility: this.channelVisibility,
1215
1222
  messageHistory: this._messageHistory
1216
1223
  });
1217
1224
  }
@@ -1573,6 +1580,7 @@ var ThreadImpl = class _ThreadImpl {
1573
1580
  _type: "chat:Thread",
1574
1581
  id: this.id,
1575
1582
  channelId: this.channelId,
1583
+ channelVisibility: this.channelVisibility,
1576
1584
  currentMessage: this._currentMessage?.toJSON(),
1577
1585
  isDM: this.isDM,
1578
1586
  adapterName: this.adapter.name
@@ -1597,6 +1605,7 @@ var ThreadImpl = class _ThreadImpl {
1597
1605
  id: json.id,
1598
1606
  adapterName: json.adapterName,
1599
1607
  channelId: json.channelId,
1608
+ channelVisibility: json.channelVisibility,
1600
1609
  currentMessage: json.currentMessage ? Message.fromJSON(json.currentMessage) : void 0,
1601
1610
  isDM: json.isDM
1602
1611
  });
@@ -3192,6 +3201,7 @@ var Chat = class {
3192
3201
  const parts = threadId.split(":");
3193
3202
  const channelId = parts[1] || "";
3194
3203
  const isDM = adapter.isDM?.(threadId) ?? false;
3204
+ const channelVisibility = adapter.getChannelVisibility?.(threadId) ?? "unknown";
3195
3205
  return new ThreadImpl({
3196
3206
  id: threadId,
3197
3207
  adapter,
@@ -3200,6 +3210,7 @@ var Chat = class {
3200
3210
  initialMessage,
3201
3211
  isSubscribedContext,
3202
3212
  isDM,
3213
+ channelVisibility,
3203
3214
  currentMessage: initialMessage,
3204
3215
  logger: this.logger,
3205
3216
  streamingUpdateIntervalMs: this._streamingUpdateIntervalMs,