chat 4.23.0 → 4.25.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/{chunk-JW7GYSMH.js → chunk-OPV5U4WG.js} +8 -4
- package/dist/index.d.ts +225 -14
- package/dist/index.js +323 -34
- package/dist/{jsx-runtime-DraWieqP.d.ts → jsx-runtime-DxATbnrP.d.ts} +6 -0
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +1 -2
- package/docs/adapters.mdx +3 -3
- package/docs/getting-started.mdx +3 -1
- package/docs/guides/slack-nextjs.mdx +2 -0
- package/docs/index.mdx +3 -3
- package/docs/state.mdx +1 -1
- package/docs/usage.mdx +3 -3
- package/package.json +1 -1
- package/dist/chunk-JW7GYSMH.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jsx-runtime.js.map +0 -1
|
@@ -353,7 +353,8 @@ function Button(options) {
|
|
|
353
353
|
label: options.label,
|
|
354
354
|
style: options.style,
|
|
355
355
|
value: options.value,
|
|
356
|
-
disabled: options.disabled
|
|
356
|
+
disabled: options.disabled,
|
|
357
|
+
actionType: options.actionType
|
|
357
358
|
};
|
|
358
359
|
}
|
|
359
360
|
function LinkButton(options) {
|
|
@@ -475,7 +476,9 @@ function fromReactElement(element) {
|
|
|
475
476
|
id: props.id,
|
|
476
477
|
label: props.label ?? label,
|
|
477
478
|
style: props.style,
|
|
478
|
-
value: props.value
|
|
479
|
+
value: props.value,
|
|
480
|
+
actionType: props.actionType,
|
|
481
|
+
disabled: props.disabled
|
|
479
482
|
});
|
|
480
483
|
}
|
|
481
484
|
case "LinkButton": {
|
|
@@ -851,7 +854,9 @@ function resolveJSXElement(element) {
|
|
|
851
854
|
id: props.id,
|
|
852
855
|
label,
|
|
853
856
|
style: props.style,
|
|
854
|
-
value: props.value
|
|
857
|
+
value: props.value,
|
|
858
|
+
actionType: props.actionType,
|
|
859
|
+
disabled: props.disabled
|
|
855
860
|
});
|
|
856
861
|
}
|
|
857
862
|
if (type === LinkButton) {
|
|
@@ -1103,4 +1108,3 @@ export {
|
|
|
1103
1108
|
toModalElement,
|
|
1104
1109
|
isJSX
|
|
1105
1110
|
};
|
|
1106
|
-
//# sourceMappingURL=chunk-JW7GYSMH.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
|
|
2
2
|
import { Root, List, Content, Blockquote, Code, Emphasis, InlineCode, Delete, Link, ListItem, Paragraph, Strong, TableCell, Table as Table$1, TableRow, Text } from 'mdast';
|
|
3
3
|
export { Blockquote, Code, Content, Delete, Emphasis, InlineCode, Link, List, ListItem, Table as MdastTable, Paragraph, Root, Strong, TableCell, TableRow, Text } from 'mdast';
|
|
4
|
-
import { C as ChatElement, a as CardElement, M as ModalElement, 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-
|
|
5
|
-
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-
|
|
4
|
+
import { C as ChatElement, a as CardElement, M as ModalElement, 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-DxATbnrP.js';
|
|
5
|
+
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-DxATbnrP.js';
|
|
6
6
|
|
|
7
7
|
interface MessageHistoryConfig {
|
|
8
8
|
/** Maximum messages to keep per thread (default: 100) */
|
|
@@ -95,7 +95,9 @@ declare class ChannelImpl<TState = Record<string, unknown>> implements Channel<T
|
|
|
95
95
|
*/
|
|
96
96
|
threads(): AsyncIterable<ThreadSummary>;
|
|
97
97
|
fetchMetadata(): Promise<ChannelInfo>;
|
|
98
|
-
post(message:
|
|
98
|
+
post<T extends PostableObject>(message: T): Promise<T>;
|
|
99
|
+
post(message: string | AdapterPostableMessage | AsyncIterable<string> | ChatElement): Promise<SentMessage>;
|
|
100
|
+
private handlePostableObject;
|
|
99
101
|
private postSingleMessage;
|
|
100
102
|
postEphemeral(user: string | Author, message: AdapterPostableMessage | ChatElement, options: PostEphemeralOptions): Promise<EphemeralMessage | null>;
|
|
101
103
|
schedule(message: AdapterPostableMessage | ChatElement, options: {
|
|
@@ -141,6 +143,43 @@ declare class ConsoleLogger implements Logger {
|
|
|
141
143
|
error(message: string, ...args: unknown[]): void;
|
|
142
144
|
}
|
|
143
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Context provided to a PostableObject after it has been posted.
|
|
148
|
+
*/
|
|
149
|
+
interface PostableObjectContext {
|
|
150
|
+
adapter: Adapter;
|
|
151
|
+
logger?: Logger;
|
|
152
|
+
messageId: string;
|
|
153
|
+
threadId: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Base interface for objects that can be posted to threads/channels.
|
|
157
|
+
* Examples: Plan, Poll, etc.
|
|
158
|
+
*
|
|
159
|
+
* @template TData - The data type returned by getPostData()
|
|
160
|
+
*/
|
|
161
|
+
interface PostableObject<TData = unknown> {
|
|
162
|
+
/** Symbol identifying this as a postable object */
|
|
163
|
+
readonly $$typeof: symbol;
|
|
164
|
+
/**
|
|
165
|
+
* Get a fallback text representation for adapters that don't support this object type.
|
|
166
|
+
* This should return a human-readable string representation.
|
|
167
|
+
*/
|
|
168
|
+
getFallbackText(): string;
|
|
169
|
+
/** Get the data to send to the adapter */
|
|
170
|
+
getPostData(): TData;
|
|
171
|
+
/** Check if the adapter supports this object type */
|
|
172
|
+
isSupported(adapter: Adapter): boolean;
|
|
173
|
+
/** The kind of object - used by adapters to dispatch */
|
|
174
|
+
readonly kind: string;
|
|
175
|
+
/** Called after successful posting to bind the object to the thread */
|
|
176
|
+
onPosted(context: PostableObjectContext): void;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Type guard to check if a value is a PostableObject.
|
|
180
|
+
*/
|
|
181
|
+
declare function isPostableObject(value: unknown): value is PostableObject;
|
|
182
|
+
|
|
144
183
|
/**
|
|
145
184
|
* Serialized thread data for passing to external systems (e.g., workflow engines).
|
|
146
185
|
*/
|
|
@@ -252,7 +291,9 @@ declare class ThreadImpl<TState = Record<string, unknown>> implements Thread<TSt
|
|
|
252
291
|
isSubscribed(): Promise<boolean>;
|
|
253
292
|
subscribe(): Promise<void>;
|
|
254
293
|
unsubscribe(): Promise<void>;
|
|
255
|
-
post(message:
|
|
294
|
+
post<T extends PostableObject>(message: T): Promise<T>;
|
|
295
|
+
post(message: string | AdapterPostableMessage | AsyncIterable<string> | ChatElement): Promise<SentMessage>;
|
|
296
|
+
private handlePostableObject;
|
|
256
297
|
postEphemeral(user: string | Author, message: AdapterPostableMessage | ChatElement, options: PostEphemeralOptions): Promise<EphemeralMessage | null>;
|
|
257
298
|
schedule(message: AdapterPostableMessage | ChatElement, options: {
|
|
258
299
|
postAt: Date;
|
|
@@ -337,6 +378,85 @@ declare class NotImplementedError extends ChatError {
|
|
|
337
378
|
constructor(message: string, feature?: string, cause?: unknown);
|
|
338
379
|
}
|
|
339
380
|
|
|
381
|
+
type PlanTaskStatus = "pending" | "in_progress" | "complete" | "error";
|
|
382
|
+
interface PlanTask {
|
|
383
|
+
id: string;
|
|
384
|
+
status: PlanTaskStatus;
|
|
385
|
+
title: string;
|
|
386
|
+
}
|
|
387
|
+
interface PlanModel {
|
|
388
|
+
tasks: PlanModelTask[];
|
|
389
|
+
title: string;
|
|
390
|
+
}
|
|
391
|
+
interface PlanModelTask {
|
|
392
|
+
details?: PlanContent;
|
|
393
|
+
id: string;
|
|
394
|
+
output?: PlanContent;
|
|
395
|
+
status: PlanTaskStatus;
|
|
396
|
+
title: string;
|
|
397
|
+
}
|
|
398
|
+
type PlanContent = string | string[] | {
|
|
399
|
+
markdown: string;
|
|
400
|
+
} | {
|
|
401
|
+
ast: Root;
|
|
402
|
+
};
|
|
403
|
+
interface StartPlanOptions {
|
|
404
|
+
/** Initial plan title and first task title */
|
|
405
|
+
initialMessage: PlanContent;
|
|
406
|
+
}
|
|
407
|
+
interface AddTaskOptions {
|
|
408
|
+
/** Task details/substeps. */
|
|
409
|
+
children?: PlanContent;
|
|
410
|
+
title: PlanContent;
|
|
411
|
+
}
|
|
412
|
+
type UpdateTaskInput = PlanContent | {
|
|
413
|
+
/** Task output/results. */
|
|
414
|
+
output?: PlanContent;
|
|
415
|
+
/** Optional status override. */
|
|
416
|
+
status?: PlanTaskStatus;
|
|
417
|
+
};
|
|
418
|
+
interface CompletePlanOptions {
|
|
419
|
+
/** Final plan title shown when completed */
|
|
420
|
+
completeMessage: PlanContent;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* A Plan represents a task list that can be posted to a thread.
|
|
424
|
+
*
|
|
425
|
+
* Create a plan with `new Plan({ initialMessage: "..." })` and post it with `thread.post(plan)`.
|
|
426
|
+
* After posting, use methods like `addTask()`, `updateTask()`, and `complete()` to update it.
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* ```typescript
|
|
430
|
+
* const plan = new Plan({ initialMessage: "Starting task..." });
|
|
431
|
+
* await thread.post(plan);
|
|
432
|
+
* await plan.addTask({ title: "Fetch data" });
|
|
433
|
+
* await plan.updateTask("Got 42 results");
|
|
434
|
+
* await plan.complete({ completeMessage: "Done!" });
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
declare class Plan implements PostableObject<PlanModel> {
|
|
438
|
+
readonly $$typeof: symbol;
|
|
439
|
+
readonly kind = "plan";
|
|
440
|
+
private _model;
|
|
441
|
+
private _bound;
|
|
442
|
+
constructor(options: StartPlanOptions);
|
|
443
|
+
isSupported(adapter: Adapter): boolean;
|
|
444
|
+
getPostData(): PlanModel;
|
|
445
|
+
getFallbackText(): string;
|
|
446
|
+
onPosted(context: PostableObjectContext): void;
|
|
447
|
+
get id(): string;
|
|
448
|
+
get threadId(): string;
|
|
449
|
+
get title(): string;
|
|
450
|
+
get tasks(): readonly PlanTask[];
|
|
451
|
+
get currentTask(): PlanTask | null;
|
|
452
|
+
addTask(options: AddTaskOptions): Promise<PlanTask | null>;
|
|
453
|
+
updateTask(update?: UpdateTaskInput): Promise<PlanTask | null>;
|
|
454
|
+
reset(options: StartPlanOptions): Promise<PlanTask | null>;
|
|
455
|
+
complete(options: CompletePlanOptions): Promise<void>;
|
|
456
|
+
private canMutate;
|
|
457
|
+
private enqueueEdit;
|
|
458
|
+
}
|
|
459
|
+
|
|
340
460
|
/**
|
|
341
461
|
* Represents the visibility scope of a channel.
|
|
342
462
|
*
|
|
@@ -436,6 +556,18 @@ interface ChatConfig<TAdapters extends Record<string, Adapter> = Record<string,
|
|
|
436
556
|
* Options for webhook handling.
|
|
437
557
|
*/
|
|
438
558
|
interface WebhookOptions {
|
|
559
|
+
/**
|
|
560
|
+
* Override the default modal-opening behavior to handle it inline
|
|
561
|
+
* within the current webhook response cycle.
|
|
562
|
+
* When provided, called instead of adapter.openModal().
|
|
563
|
+
* Used by Teams to return modal content in the HTTP invoke response.
|
|
564
|
+
*
|
|
565
|
+
* The returned `viewId` is platform-specific (e.g. Slack's view ID).
|
|
566
|
+
* Adapters that don't produce a view ID may return void.
|
|
567
|
+
*/
|
|
568
|
+
onOpenModal?: (modal: ModalElement, contextId: string) => Promise<{
|
|
569
|
+
viewId: string;
|
|
570
|
+
} | undefined>;
|
|
439
571
|
/**
|
|
440
572
|
* Function to run message handling in the background.
|
|
441
573
|
* Use this to ensure fast webhook responses while processing continues.
|
|
@@ -476,6 +608,16 @@ interface Adapter<TThreadId = unknown, TRawMessage = unknown> {
|
|
|
476
608
|
disconnect?(): Promise<void>;
|
|
477
609
|
/** Edit an existing message */
|
|
478
610
|
editMessage(threadId: string, messageId: string, message: AdapterPostableMessage): Promise<RawMessage<TRawMessage>>;
|
|
611
|
+
/**
|
|
612
|
+
* Edit a previously posted object (Plan, Poll, etc.).
|
|
613
|
+
* If not implemented, object updates will throw PlanNotSupportedError.
|
|
614
|
+
*
|
|
615
|
+
* @param threadId - The thread containing the message
|
|
616
|
+
* @param messageId - The message ID to edit
|
|
617
|
+
* @param kind - The object kind (e.g., "plan")
|
|
618
|
+
* @param data - The object data (type depends on kind)
|
|
619
|
+
*/
|
|
620
|
+
editObject?(threadId: string, messageId: string, kind: string, data: unknown): Promise<RawMessage<TRawMessage>>;
|
|
479
621
|
/** Encode platform-specific data into a thread ID string */
|
|
480
622
|
encodeThreadId(platformData: TThreadId): string;
|
|
481
623
|
/**
|
|
@@ -621,6 +763,15 @@ interface Adapter<TThreadId = unknown, TRawMessage = unknown> {
|
|
|
621
763
|
postEphemeral?(threadId: string, userId: string, message: AdapterPostableMessage): Promise<EphemeralMessage<TRawMessage>>;
|
|
622
764
|
/** Post a message to a thread */
|
|
623
765
|
postMessage(threadId: string, message: AdapterPostableMessage): Promise<RawMessage<TRawMessage>>;
|
|
766
|
+
/**
|
|
767
|
+
* Post a special object (Plan, Poll, etc.) as a single message.
|
|
768
|
+
* If not implemented, posting such objects will throw PlanNotSupportedError.
|
|
769
|
+
*
|
|
770
|
+
* @param threadId - The thread to post to
|
|
771
|
+
* @param kind - The object kind (e.g., "plan")
|
|
772
|
+
* @param data - The object data (type depends on kind)
|
|
773
|
+
*/
|
|
774
|
+
postObject?(threadId: string, kind: string, data: unknown): Promise<RawMessage<TRawMessage>>;
|
|
624
775
|
/** Remove a reaction from a message */
|
|
625
776
|
removeReaction(threadId: string, messageId: string, emoji: EmojiValue | string): Promise<void>;
|
|
626
777
|
/** Render formatted content to platform-specific string */
|
|
@@ -726,7 +877,7 @@ interface ChatInstance {
|
|
|
726
877
|
*/
|
|
727
878
|
processAction(event: Omit<ActionEvent, "thread" | "openModal"> & {
|
|
728
879
|
adapter: Adapter;
|
|
729
|
-
}, options
|
|
880
|
+
}, options: WebhookOptions | undefined): Promise<void>;
|
|
730
881
|
processAppHomeOpened(event: AppHomeOpenedEvent, options?: WebhookOptions): void;
|
|
731
882
|
processAssistantContextChanged(event: AssistantContextChangedEvent, options?: WebhookOptions): void;
|
|
732
883
|
processAssistantThreadStarted(event: AssistantThreadStartedEvent, options?: WebhookOptions): void;
|
|
@@ -777,7 +928,7 @@ interface ChatInstance {
|
|
|
777
928
|
processSlashCommand(event: Omit<SlashCommandEvent, "channel" | "openModal"> & {
|
|
778
929
|
adapter: Adapter;
|
|
779
930
|
channelId: string;
|
|
780
|
-
}, options
|
|
931
|
+
}, options: WebhookOptions | undefined): void;
|
|
781
932
|
}
|
|
782
933
|
/** Lock scope determines which messages contend for the same lock. */
|
|
783
934
|
type LockScope = "thread" | "channel";
|
|
@@ -908,6 +1059,7 @@ interface Postable<TState = Record<string, unknown>, TRawMessage = unknown> {
|
|
|
908
1059
|
/**
|
|
909
1060
|
* Post a message.
|
|
910
1061
|
*/
|
|
1062
|
+
post<T extends PostableObject>(message: T): Promise<T>;
|
|
911
1063
|
post(message: string | PostableMessage | ChatElement): Promise<SentMessage<TRawMessage>>;
|
|
912
1064
|
/**
|
|
913
1065
|
* Post an ephemeral message visible only to a specific user.
|
|
@@ -1085,8 +1237,15 @@ interface Thread<TState = Record<string, unknown>, TRawMessage = unknown> extend
|
|
|
1085
1237
|
* // Stream from AI SDK
|
|
1086
1238
|
* const result = await agent.stream({ prompt: message.text });
|
|
1087
1239
|
* await thread.post(result.textStream);
|
|
1240
|
+
*
|
|
1241
|
+
* // Plan with live updates
|
|
1242
|
+
* const plan = new Plan({ initialMessage: "Working..." });
|
|
1243
|
+
* await thread.post(plan);
|
|
1244
|
+
* await plan.addTask({ title: "Step 1" });
|
|
1245
|
+
* await plan.complete({ completeMessage: "Done!" });
|
|
1088
1246
|
* ```
|
|
1089
1247
|
*/
|
|
1248
|
+
post<T extends PostableObject>(message: T): Promise<T>;
|
|
1090
1249
|
post(message: string | PostableMessage | ChatElement): Promise<SentMessage<TRawMessage>>;
|
|
1091
1250
|
/**
|
|
1092
1251
|
* Post an ephemeral message visible only to a specific user.
|
|
@@ -1159,6 +1318,7 @@ interface Thread<TState = Record<string, unknown>, TRawMessage = unknown> extend
|
|
|
1159
1318
|
*/
|
|
1160
1319
|
unsubscribe(): Promise<void>;
|
|
1161
1320
|
}
|
|
1321
|
+
|
|
1162
1322
|
interface ThreadInfo {
|
|
1163
1323
|
channelId: string;
|
|
1164
1324
|
channelName?: string;
|
|
@@ -1346,7 +1506,7 @@ type AdapterPostableMessage = string | PostableRaw | PostableMarkdown | Postable
|
|
|
1346
1506
|
* - `AsyncIterable<string>` - Streaming text (e.g., from AI SDK's textStream)
|
|
1347
1507
|
* - `AsyncIterable<string | StreamEvent>` - AI SDK fullStream (auto-detected, extracts text with step separators)
|
|
1348
1508
|
*/
|
|
1349
|
-
type PostableMessage = AdapterPostableMessage | AsyncIterable<string | StreamChunk | StreamEvent
|
|
1509
|
+
type PostableMessage = AdapterPostableMessage | AsyncIterable<string | StreamChunk | StreamEvent> | PostableObject;
|
|
1350
1510
|
/**
|
|
1351
1511
|
* Duck-typed stream event compatible with AI SDK's `fullStream`.
|
|
1352
1512
|
* - `text-delta` events are extracted as text output.
|
|
@@ -1787,7 +1947,7 @@ interface ModalCloseResponse {
|
|
|
1787
1947
|
action: "close";
|
|
1788
1948
|
}
|
|
1789
1949
|
type ModalResponse = ModalCloseResponse | ModalErrorsResponse | ModalUpdateResponse | ModalPushResponse;
|
|
1790
|
-
type ModalSubmitHandler = (event: ModalSubmitEvent) => void | Promise<ModalResponse | undefined>;
|
|
1950
|
+
type ModalSubmitHandler = (event: ModalSubmitEvent) => void | Promise<ModalResponse | void | undefined>;
|
|
1791
1951
|
type ModalCloseHandler = (event: ModalCloseEvent) => void | Promise<void>;
|
|
1792
1952
|
/**
|
|
1793
1953
|
* Event emitted when a user invokes a slash command.
|
|
@@ -2411,8 +2571,48 @@ declare class Chat<TAdapters extends Record<string, Adapter> = Record<string, Ad
|
|
|
2411
2571
|
*/
|
|
2412
2572
|
onAction(handler: ActionHandler): void;
|
|
2413
2573
|
onAction(actionIds: string[] | string, handler: ActionHandler): void;
|
|
2574
|
+
/**
|
|
2575
|
+
* Register a handler for modal form submissions.
|
|
2576
|
+
*
|
|
2577
|
+
* @example
|
|
2578
|
+
* ```typescript
|
|
2579
|
+
* // Handle specific modal
|
|
2580
|
+
* chat.onModalSubmit("settings-modal", async (event) => {
|
|
2581
|
+
* const name = event.values["name"];
|
|
2582
|
+
* await event.relatedThread?.post(`Updated name to ${name}`);
|
|
2583
|
+
* });
|
|
2584
|
+
*
|
|
2585
|
+
* // Handle all modal submissions
|
|
2586
|
+
* chat.onModalSubmit(async (event) => {
|
|
2587
|
+
* console.log(`Modal ${event.callbackId} submitted`);
|
|
2588
|
+
* });
|
|
2589
|
+
* ```
|
|
2590
|
+
*
|
|
2591
|
+
* @param callbackIdOrHandler - Either a callback ID, array of callback IDs, or the handler
|
|
2592
|
+
* @param handler - The handler (if callback ID filter is provided)
|
|
2593
|
+
*/
|
|
2414
2594
|
onModalSubmit(handler: ModalSubmitHandler): void;
|
|
2415
2595
|
onModalSubmit(callbackIds: string[] | string, handler: ModalSubmitHandler): void;
|
|
2596
|
+
/**
|
|
2597
|
+
* Register a handler for modal close/cancel events.
|
|
2598
|
+
* Only fires when the modal was created with `notifyOnClose: true`.
|
|
2599
|
+
*
|
|
2600
|
+
* @example
|
|
2601
|
+
* ```typescript
|
|
2602
|
+
* // Handle specific modal close
|
|
2603
|
+
* chat.onModalClose("settings-modal", async (event) => {
|
|
2604
|
+
* console.log("User cancelled settings");
|
|
2605
|
+
* });
|
|
2606
|
+
*
|
|
2607
|
+
* // Handle all modal close events
|
|
2608
|
+
* chat.onModalClose(async (event) => {
|
|
2609
|
+
* console.log(`Modal ${event.callbackId} closed`);
|
|
2610
|
+
* });
|
|
2611
|
+
* ```
|
|
2612
|
+
*
|
|
2613
|
+
* @param callbackIdOrHandler - Either a callback ID, array of callback IDs, or the handler
|
|
2614
|
+
* @param handler - The handler (if callback ID filter is provided)
|
|
2615
|
+
*/
|
|
2416
2616
|
onModalClose(handler: ModalCloseHandler): void;
|
|
2417
2617
|
onModalClose(callbackIds: string[] | string, handler: ModalCloseHandler): void;
|
|
2418
2618
|
/**
|
|
@@ -2500,7 +2700,7 @@ declare class Chat<TAdapters extends Record<string, Adapter> = Record<string, Ad
|
|
|
2500
2700
|
*/
|
|
2501
2701
|
processAction(event: Omit<ActionEvent, "thread" | "openModal"> & {
|
|
2502
2702
|
adapter: Adapter;
|
|
2503
|
-
}, options
|
|
2703
|
+
}, options: WebhookOptions | undefined): Promise<void>;
|
|
2504
2704
|
processModalSubmit(event: Omit<ModalSubmitEvent, "relatedThread" | "relatedMessage" | "relatedChannel">, contextId?: string, _options?: WebhookOptions): Promise<ModalResponse | undefined>;
|
|
2505
2705
|
processModalClose(event: Omit<ModalCloseEvent, "relatedThread" | "relatedMessage" | "relatedChannel">, contextId?: string, options?: WebhookOptions): void;
|
|
2506
2706
|
/**
|
|
@@ -2510,7 +2710,7 @@ declare class Chat<TAdapters extends Record<string, Adapter> = Record<string, Ad
|
|
|
2510
2710
|
processSlashCommand(event: Omit<SlashCommandEvent, "channel" | "openModal"> & {
|
|
2511
2711
|
adapter: Adapter;
|
|
2512
2712
|
channelId: string;
|
|
2513
|
-
}, options
|
|
2713
|
+
}, options: WebhookOptions | undefined): void;
|
|
2514
2714
|
processAssistantThreadStarted(event: AssistantThreadStartedEvent, options?: WebhookOptions): void;
|
|
2515
2715
|
processAssistantContextChanged(event: AssistantContextChangedEvent, options?: WebhookOptions): void;
|
|
2516
2716
|
processAppHomeOpened(event: AppHomeOpenedEvent, options?: WebhookOptions): void;
|
|
@@ -2681,6 +2881,13 @@ declare class Chat<TAdapters extends Record<string, Adapter> = Record<string, Ad
|
|
|
2681
2881
|
*/
|
|
2682
2882
|
declare function fromFullStream(stream: AsyncIterable<unknown>): AsyncIterable<string | StreamChunk>;
|
|
2683
2883
|
|
|
2884
|
+
interface StreamingMarkdownRendererOptions {
|
|
2885
|
+
/**
|
|
2886
|
+
* Wrap confirmed table blocks in code fences for append-only consumers that
|
|
2887
|
+
* cannot render markdown tables while a stream is in flight.
|
|
2888
|
+
*/
|
|
2889
|
+
wrapTablesForAppend?: boolean;
|
|
2890
|
+
}
|
|
2684
2891
|
/**
|
|
2685
2892
|
* A streaming markdown renderer that buffers potential table headers
|
|
2686
2893
|
* until confirmed by a separator line, preventing tables from flashing
|
|
@@ -2698,6 +2905,8 @@ declare class StreamingMarkdownRenderer {
|
|
|
2698
2905
|
private fenceToggles;
|
|
2699
2906
|
/** Incomplete trailing line buffer for incremental fence tracking. */
|
|
2700
2907
|
private incompleteLine;
|
|
2908
|
+
private readonly options;
|
|
2909
|
+
constructor(options?: StreamingMarkdownRendererOptions);
|
|
2701
2910
|
/** Append a chunk from the LLM stream. */
|
|
2702
2911
|
push(chunk: string): void;
|
|
2703
2912
|
/** O(1) check if accumulated text is inside an unclosed code fence. */
|
|
@@ -2714,9 +2923,10 @@ declare class StreamingMarkdownRenderer {
|
|
|
2714
2923
|
* Get text safe for append-only streaming (e.g. Slack native streaming).
|
|
2715
2924
|
*
|
|
2716
2925
|
* - Holds back unconfirmed table headers until separator arrives.
|
|
2717
|
-
* -
|
|
2718
|
-
* text
|
|
2719
|
-
* the table is still streaming,
|
|
2926
|
+
* - Optionally wraps confirmed tables in code fences so pipes render as
|
|
2927
|
+
* literal text on append-only surfaces that lack native table support.
|
|
2928
|
+
* The code fence is left OPEN while the table is still streaming,
|
|
2929
|
+
* keeping output monotonic for deltas.
|
|
2720
2930
|
* - Holds back unclosed inline markers (**, *, ~~, `, [).
|
|
2721
2931
|
* - The final editMessage replaces everything with properly formatted text.
|
|
2722
2932
|
*/
|
|
@@ -2725,6 +2935,7 @@ declare class StreamingMarkdownRenderer {
|
|
|
2725
2935
|
getText(): string;
|
|
2726
2936
|
/** Signal stream end. Flushes held-back lines. Returns final render. */
|
|
2727
2937
|
finish(): string;
|
|
2938
|
+
private formatAppendOnlyText;
|
|
2728
2939
|
}
|
|
2729
2940
|
|
|
2730
2941
|
/**
|
|
@@ -3170,4 +3381,4 @@ declare const Select: SelectComponent;
|
|
|
3170
3381
|
declare const SelectOption: SelectOptionComponent;
|
|
3171
3382
|
declare const TextInput: TextInputComponent;
|
|
3172
3383
|
|
|
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 };
|
|
3384
|
+
export { type ActionEvent, type ActionHandler, Actions, ActionsComponent, type Adapter, type AdapterPostableMessage, type AddTaskOptions, 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 CompletePlanOptions, 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, Plan, type PlanContent, type PlanModel, type PlanModelTask, type PlanTask, type PlanTaskStatus, type PlanUpdateChunk, type PostEphemeralOptions, type Postable, type PostableAst, type PostableCard, type PostableMarkdown, type PostableMessage, type PostableObject, type PostableObjectContext, 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 StartPlanOptions, 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 UpdateTaskInput, 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, isPostableObject, isStrongNode, isTableCellNode, isTableNode, isTableRowNode, isTextNode, link, markdownToPlainText, paragraph, parseMarkdown, root, strikethrough, stringifyMarkdown, strong, tableElementToAscii, tableToAscii, text, toAiMessages, toCardElement, toModalElement, toPlainText, walkAst };
|