chat 4.16.1 → 4.17.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
@@ -1,6 +1,6 @@
1
- import { C as CardElement, M as ModalElement, a as CardJSXElement, b as CardChild, A as Actions$1, B as Button$1, c as Card$1, d as cardChildToFallbackText$1, e as CardLink$1, T as Text$1, D as Divider$1, F as Field$1, f as Fields$1, g as fromReactElement$1, I as Image$1, i as isCardElement$1, h as isJSX$1, L as LinkButton$1, S as Section$1, j as Table$2, t as toCardElement$1, k as toModalElement$1, l as fromReactModalElement$1, m as isModalElement$1, n as Modal$1, R as RadioSelect$1, o as Select$1, p as SelectOption$1, q as TextInput$1 } from './jsx-runtime-Bokk9xw5.js';
2
- export { r as ActionsElement, s as ButtonElement, u as ButtonOptions, V as ButtonProps, v as ButtonStyle, W as CardJSXProps, X as CardLinkProps, w as CardOptions, Y as CardProps, Z as ContainerProps, x as DividerElement, _ as DividerProps, y as FieldElement, $ as FieldProps, z as FieldsElement, E as ImageElement, a0 as ImageProps, G as LinkButtonElement, H as LinkButtonOptions, a1 as LinkButtonProps, J as LinkElement, a3 as ModalChild, a4 as ModalOptions, a5 as RadioSelectElement, a6 as RadioSelectOptions, K as SectionElement, a7 as SelectElement, a8 as SelectOptionElement, a9 as SelectOptions, N as TableAlignment, O as TableElement, P as TableOptions, Q as TextElement, aa as TextInputElement, ab as TextInputOptions, a2 as TextProps, U as TextStyle } from './jsx-runtime-Bokk9xw5.js';
3
1
  import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
2
+ import { C as CardElement, M as ModalElement, a as ChatElement, b as CardChild, A as ActionsComponent, B as ButtonComponent, c as CardComponent, d as cardChildToFallbackText$1, e as CardLinkComponent, T as TextComponent, D as DividerComponent, F as FieldComponent, f as FieldsComponent, g as fromReactElement$1, I as ImageComponent, i as isCardElement$1, h as isJSX$1, L as LinkButtonComponent, S as SectionComponent, j as Table$2, t as toCardElement$1, k as toModalElement$1, l as fromReactModalElement$1, m as isModalElement$1, n as ModalComponent, R as RadioSelectComponent, o as SelectComponent, p as SelectOptionComponent, q as TextInputComponent } from './jsx-runtime-BJENDuXl.js';
3
+ export { r as ActionsElement, s as ButtonElement, u as ButtonOptions, V as ButtonProps, v as ButtonStyle, W as CardJSXElement, X as CardJSXProps, Y as CardLinkProps, w as CardOptions, Z as CardProps, _ as ContainerProps, x as DividerElement, $ as DividerProps, y as FieldElement, a0 as FieldProps, z as FieldsElement, E as ImageElement, a1 as ImageProps, G as LinkButtonElement, H as LinkButtonOptions, a2 as LinkButtonProps, J as LinkElement, a8 as ModalChild, a9 as ModalOptions, a3 as ModalProps, aa as RadioSelectElement, ab as RadioSelectOptions, K as SectionElement, ac as SelectElement, ad as SelectOptionElement, a4 as SelectOptionProps, ae as SelectOptions, a5 as SelectProps, N as TableAlignment, O as TableElement, P as TableOptions, Q as TextElement, af as TextInputElement, ag as TextInputOptions, a6 as TextInputProps, a7 as TextProps, U as TextStyle } from './jsx-runtime-BJENDuXl.js';
4
4
  import { Root, List, Content, Blockquote, Code, Emphasis, InlineCode, Delete, Link, ListItem, Paragraph, Strong, TableCell, Table as Table$1, TableRow, Text } from 'mdast';
5
5
  export { Blockquote, Code, Content, Delete, Emphasis, InlineCode, Link, List, ListItem, Table as MdastTable, Paragraph, Root, Strong, TableCell, TableRow, Text } from 'mdast';
6
6
 
@@ -414,6 +414,8 @@ interface StateAdapter {
414
414
  releaseLock(lock: Lock): Promise<void>;
415
415
  /** Set a cached value with optional TTL in milliseconds */
416
416
  set<T = unknown>(key: string, value: T, ttlMs?: number): Promise<void>;
417
+ /** Atomically set a value only if the key does not already exist. Returns true if set, false if key existed. */
418
+ setIfNotExists(key: string, value: unknown, ttlMs?: number): Promise<boolean>;
417
419
  /** Subscribe to a thread (persists across restarts) */
418
420
  subscribe(threadId: string): Promise<void>;
419
421
  /** Unsubscribe from a thread */
@@ -450,11 +452,11 @@ interface Postable<TState = Record<string, unknown>, TRawMessage = unknown> {
450
452
  /**
451
453
  * Post a message.
452
454
  */
453
- post(message: string | PostableMessage | CardJSXElement): Promise<SentMessage<TRawMessage>>;
455
+ post(message: string | PostableMessage | ChatElement): Promise<SentMessage<TRawMessage>>;
454
456
  /**
455
457
  * Post an ephemeral message visible only to a specific user.
456
458
  */
457
- postEphemeral(user: string | Author, message: AdapterPostableMessage | CardJSXElement, options: PostEphemeralOptions): Promise<EphemeralMessage | null>;
459
+ postEphemeral(user: string | Author, message: AdapterPostableMessage | ChatElement, options: PostEphemeralOptions): Promise<EphemeralMessage | null>;
458
460
  /**
459
461
  * Set the state. Merges with existing state by default.
460
462
  */
@@ -599,7 +601,7 @@ interface Thread<TState = Record<string, unknown>, TRawMessage = unknown> extend
599
601
  * await thread.post(result.textStream);
600
602
  * ```
601
603
  */
602
- post(message: string | PostableMessage | CardJSXElement): Promise<SentMessage<TRawMessage>>;
604
+ post(message: string | PostableMessage | ChatElement): Promise<SentMessage<TRawMessage>>;
603
605
  /**
604
606
  * Post an ephemeral message visible only to a specific user.
605
607
  *
@@ -628,7 +630,7 @@ interface Thread<TState = Record<string, unknown>, TRawMessage = unknown> extend
628
630
  * }
629
631
  * ```
630
632
  */
631
- postEphemeral(user: string | Author, message: AdapterPostableMessage | CardJSXElement, options: PostEphemeralOptions): Promise<EphemeralMessage | null>;
633
+ postEphemeral(user: string | Author, message: AdapterPostableMessage | ChatElement, options: PostEphemeralOptions): Promise<EphemeralMessage | null>;
632
634
  /** Recently fetched messages (cached) */
633
635
  recentMessages: Message<TRawMessage>[];
634
636
  /**
@@ -784,7 +786,7 @@ interface SentMessage<TRawMessage = unknown> extends Message<TRawMessage> {
784
786
  /** Delete this message */
785
787
  delete(): Promise<void>;
786
788
  /** Edit this message with text, a PostableMessage, or a JSX Card element */
787
- edit(newContent: string | PostableMessage | CardJSXElement): Promise<SentMessage<TRawMessage>>;
789
+ edit(newContent: string | PostableMessage | ChatElement): Promise<SentMessage<TRawMessage>>;
788
790
  /** Remove a reaction from this message */
789
791
  removeReaction(emoji: EmojiValue | string): Promise<void>;
790
792
  }
@@ -1114,7 +1116,7 @@ interface ActionEvent<TRawMessage = unknown> {
1114
1116
  * @param modal - The modal element to display (JSX or ModalElement)
1115
1117
  * @returns The view/dialog ID, or undefined if modals are not supported
1116
1118
  */
1117
- openModal(modal: ModalElement | CardJSXElement): Promise<{
1119
+ openModal(modal: ModalElement | ChatElement): Promise<{
1118
1120
  viewId: string;
1119
1121
  } | undefined>;
1120
1122
  /** Platform-specific raw event data */
@@ -1293,7 +1295,7 @@ interface SlashCommandEvent<TState = Record<string, unknown>> {
1293
1295
  * @param modal - The modal element to display (JSX or ModalElement)
1294
1296
  * @returns The view/dialog ID, or undefined if modals are not supported
1295
1297
  */
1296
- openModal(modal: ModalElement | CardJSXElement): Promise<{
1298
+ openModal(modal: ModalElement | ChatElement): Promise<{
1297
1299
  viewId: string;
1298
1300
  } | undefined>;
1299
1301
  /** Platform-specific raw payload */
@@ -1571,9 +1573,9 @@ declare class ChannelImpl<TState = Record<string, unknown>> implements Channel<T
1571
1573
  */
1572
1574
  threads(): AsyncIterable<ThreadSummary>;
1573
1575
  fetchMetadata(): Promise<ChannelInfo>;
1574
- post(message: string | PostableMessage | CardJSXElement): Promise<SentMessage>;
1576
+ post(message: string | PostableMessage | ChatElement): Promise<SentMessage>;
1575
1577
  private postSingleMessage;
1576
- postEphemeral(user: string | Author, message: AdapterPostableMessage | CardJSXElement, options: PostEphemeralOptions): Promise<EphemeralMessage | null>;
1578
+ postEphemeral(user: string | Author, message: AdapterPostableMessage | ChatElement, options: PostEphemeralOptions): Promise<EphemeralMessage | null>;
1577
1579
  startTyping(status?: string): Promise<void>;
1578
1580
  mentionUser(userId: string): string;
1579
1581
  toJSON(): SerializedChannel;
@@ -2199,8 +2201,8 @@ declare class ThreadImpl<TState = Record<string, unknown>> implements Thread<TSt
2199
2201
  isSubscribed(): Promise<boolean>;
2200
2202
  subscribe(): Promise<void>;
2201
2203
  unsubscribe(): Promise<void>;
2202
- post(message: string | PostableMessage | CardJSXElement): Promise<SentMessage>;
2203
- postEphemeral(user: string | Author, message: AdapterPostableMessage | CardJSXElement, options: PostEphemeralOptions): Promise<EphemeralMessage | null>;
2204
+ post(message: string | PostableMessage | ChatElement): Promise<SentMessage>;
2205
+ postEphemeral(user: string | Author, message: AdapterPostableMessage | ChatElement, options: PostEphemeralOptions): Promise<EphemeralMessage | null>;
2204
2206
  /**
2205
2207
  * Handle streaming from an AsyncIterable.
2206
2208
  * Normalizes the stream (supports both textStream and fullStream from AI SDK),
@@ -2668,31 +2670,31 @@ declare abstract class BaseFormatConverter implements FormatConverter {
2668
2670
  protected cardChildToFallbackText(child: CardChild): string | null;
2669
2671
  }
2670
2672
 
2671
- declare const Actions: typeof Actions$1;
2672
- declare const Button: typeof Button$1;
2673
- declare const Card: typeof Card$1;
2673
+ declare const Actions: ActionsComponent;
2674
+ declare const Button: ButtonComponent;
2675
+ declare const Card: CardComponent;
2674
2676
  declare const cardChildToFallbackText: typeof cardChildToFallbackText$1;
2675
- declare const CardLink: typeof CardLink$1;
2676
- declare const CardText: typeof Text$1;
2677
- declare const Divider: typeof Divider$1;
2678
- declare const Field: typeof Field$1;
2679
- declare const Fields: typeof Fields$1;
2677
+ declare const CardLink: CardLinkComponent;
2678
+ declare const CardText: TextComponent;
2679
+ declare const Divider: DividerComponent;
2680
+ declare const Field: FieldComponent;
2681
+ declare const Fields: FieldsComponent;
2680
2682
  declare const fromReactElement: typeof fromReactElement$1;
2681
- declare const Image: typeof Image$1;
2683
+ declare const Image: ImageComponent;
2682
2684
  declare const isCardElement: typeof isCardElement$1;
2683
2685
  declare const isJSX: typeof isJSX$1;
2684
- declare const LinkButton: typeof LinkButton$1;
2685
- declare const Section: typeof Section$1;
2686
+ declare const LinkButton: LinkButtonComponent;
2687
+ declare const Section: SectionComponent;
2686
2688
  declare const Table: typeof Table$2;
2687
2689
  declare const toCardElement: typeof toCardElement$1;
2688
2690
  declare const toModalElement: typeof toModalElement$1;
2689
2691
 
2690
2692
  declare const fromReactModalElement: typeof fromReactModalElement$1;
2691
2693
  declare const isModalElement: typeof isModalElement$1;
2692
- declare const Modal: typeof Modal$1;
2693
- declare const RadioSelect: typeof RadioSelect$1;
2694
- declare const Select: typeof Select$1;
2695
- declare const SelectOption: typeof SelectOption$1;
2696
- declare const TextInput: typeof TextInput$1;
2694
+ declare const Modal: ModalComponent;
2695
+ declare const RadioSelect: RadioSelectComponent;
2696
+ declare const Select: SelectComponent;
2697
+ declare const SelectOption: SelectOptionComponent;
2698
+ declare const TextInput: TextInputComponent;
2697
2699
 
2698
- export { type ActionEvent, type ActionHandler, Actions, type Adapter, type AdapterPostableMessage, type AppHomeOpenedEvent, type AppHomeOpenedHandler, type AssistantContextChangedEvent, type AssistantContextChangedHandler, type AssistantThreadStartedEvent, type AssistantThreadStartedHandler, type Attachment, type Author, BaseFormatConverter, Button, Card, CardChild, CardElement, CardJSXElement, CardLink, CardText, type Channel, ChannelImpl, type ChannelInfo, Chat, type ChatConfig, ChatError, type ChatInstance, ConsoleLogger, type CustomEmojiMap, DEFAULT_EMOJI_MAP, Divider, type Emoji, type EmojiFormats, type EmojiMapConfig, EmojiResolver, type EmojiValue, type EphemeralMessage, type FetchDirection, type FetchOptions, type FetchResult, Field, Fields, type FileUpload, type FormatConverter, type FormattedContent, Image, LinkButton, type ListThreadsOptions, type ListThreadsResult, type Lock, LockError, type LogLevel, type Logger, type MarkdownConverter, type MarkdownTextChunk, type MemberJoinedChannelEvent, type MemberJoinedChannelHandler, type MentionHandler, Message, type MessageData, type MessageHandler, type MessageMetadata, Modal, type ModalCloseEvent, type ModalCloseHandler, type ModalCloseResponse, 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, RadioSelect, RateLimitError, type RawMessage, type ReactionEvent, type ReactionHandler, Section, Select, SelectOption, 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, TextInput, 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, toCardElement, toModalElement, toPlainText, walkAst };
2700
+ export { type ActionEvent, type ActionHandler, Actions, ActionsComponent, type Adapter, type AdapterPostableMessage, 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, ConsoleLogger, type CustomEmojiMap, DEFAULT_EMOJI_MAP, 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 ListThreadsOptions, type ListThreadsResult, type Lock, LockError, type LogLevel, type Logger, type MarkdownConverter, type MarkdownTextChunk, type MemberJoinedChannelEvent, type MemberJoinedChannelHandler, type MentionHandler, Message, type MessageData, type MessageHandler, 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, RadioSelect, RadioSelectComponent, RateLimitError, type RawMessage, type ReactionEvent, type ReactionHandler, 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, toCardElement, toModalElement, toPlainText, walkAst };
package/dist/index.js CHANGED
@@ -59,7 +59,7 @@ import {
59
59
  toModalElement,
60
60
  toPlainText,
61
61
  walkAst
62
- } from "./chunk-A2J5CUHD.js";
62
+ } from "./chunk-Q32GJ2PR.js";
63
63
 
64
64
  // src/channel.ts
65
65
  import { WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2, WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2 } from "@workflow/serde";
@@ -2476,15 +2476,18 @@ var Chat = class {
2476
2476
  return;
2477
2477
  }
2478
2478
  const dedupeKey = `dedupe:${adapter.name}:${message.id}`;
2479
- const alreadyProcessed = await this._stateAdapter.get(dedupeKey);
2480
- if (alreadyProcessed) {
2479
+ const isFirstProcess = await this._stateAdapter.setIfNotExists(
2480
+ dedupeKey,
2481
+ true,
2482
+ this._dedupeTtlMs
2483
+ );
2484
+ if (!isFirstProcess) {
2481
2485
  this.logger.debug("Skipping duplicate message", {
2482
2486
  adapter: adapter.name,
2483
2487
  messageId: message.id
2484
2488
  });
2485
2489
  return;
2486
2490
  }
2487
- await this._stateAdapter.set(dedupeKey, true, this._dedupeTtlMs);
2488
2491
  const lock = await this._stateAdapter.acquireLock(
2489
2492
  threadId,
2490
2493
  DEFAULT_LOCK_TTL_MS