Skip to content

Commit 160cfb7

Browse files
committed
fix: make markdown text optional and add missing chunk type
1 parent 2601199 commit 160cfb7

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

packages/types/src/chunk.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ export interface URLSource {
2525
icon_url?: string;
2626
}
2727

28+
/**
29+
* An updated title of plans for task and tool calls.
30+
* https://docs.slack.dev/messaging/sending-and-scheduling-messages#text-streaming
31+
*/
32+
export interface PlanUpdateChunk extends Chunk {
33+
type: 'plan_update';
34+
title: string;
35+
}
36+
2837
/**
2938
* Used for displaying tool execution progress in a timeline-style UI.
3039
* https://docs.slack.dev/messaging/sending-and-scheduling-messages#text-streaming
@@ -42,7 +51,7 @@ export interface TaskUpdateChunk extends Chunk {
4251
/**
4352
* Union type of all possible chunk types
4453
*/
45-
export type AnyChunk = MarkdownTextChunk | TaskUpdateChunk;
54+
export type AnyChunk = MarkdownTextChunk | PlanUpdateChunk | TaskUpdateChunk;
4655

4756
/**
4857
* Parse a chunk object and return the appropriate typed chunk.
@@ -70,6 +79,14 @@ export function parseChunk(chunk: unknown): AnyChunk | null {
7079
return null;
7180
}
7281

82+
if(type === 'plan_update') {
83+
if (typeof chunkObj.title === 'string') {
84+
return chunkObj as unknown as PlanUpdateChunk;
85+
}
86+
console.warn('Invalid PlanUpdateChunk (missing title property)', chunk);
87+
return null;
88+
}
89+
7390
if (type === 'task_update') {
7491
const taskChunk = chunkObj as Partial<TaskUpdateChunk>;
7592
if (

packages/web-api/src/types/request/chat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export interface Unfurls {
169169
unfurl_media?: boolean;
170170
}
171171

172-
export interface ChatAppendStreamArguments extends TokenOverridable, ChannelAndTS, MarkdownText {
172+
export interface ChatAppendStreamArguments extends TokenOverridable, ChannelAndTS, Partial<MarkdownText> {
173173
/**
174174
* @description An array of {@link https://docs.slack.dev/messaging/sending-and-scheduling-messages#text-streaming chunk objects} to append to the stream.
175175
* Either `markdown_text` or `chunks` is required.

0 commit comments

Comments
 (0)