11import type {
2- AssistantThreadsSetStatusArguments ,
3- AssistantThreadsSetStatusResponse ,
42 AssistantThreadsSetSuggestedPromptsResponse ,
53 AssistantThreadsSetTitleResponse ,
64 ChatPostMessageArguments ,
@@ -11,8 +9,9 @@ import {
119 type AssistantThreadContextStore ,
1210 DefaultThreadContextStore ,
1311} from './AssistantThreadContextStore' ;
14- import { createSayStream } from './context' ;
12+ import { createSayStream , createSetStatus } from './context' ;
1513import type { SayStreamFn } from './context' ;
14+ import type { SetStatusFn } from './context' ;
1615import { AssistantInitializationError , AssistantMissingPropertyError } from './errors' ;
1716import { extractEventChannelId , extractEventThreadTs , isRecord } from './helpers' ;
1817import processMiddleware from './middleware/process' ;
@@ -43,9 +42,6 @@ interface AssistantUtilityArgs {
4342
4443type GetThreadContextUtilFn = ( ) => Promise < AssistantThreadContext > ;
4544type SaveThreadContextUtilFn = ( ) => Promise < void > ;
46- type SetStatusFn = (
47- status : string | Omit < AssistantThreadsSetStatusArguments , 'channel_id' | 'thread_ts' > ,
48- ) => Promise < AssistantThreadsSetStatusResponse > ;
4945
5046type SetSuggestedPromptsFn = (
5147 params : SetSuggestedPromptsArguments ,
@@ -186,7 +182,7 @@ export function enrichAssistantArgs(
186182
187183 preparedArgs . say = createSay ( preparedArgs ) ;
188184 preparedArgs . sayStream = createAssistantSayStream ( preparedArgs ) ;
189- preparedArgs . setStatus = createSetStatus ( preparedArgs ) ;
185+ preparedArgs . setStatus = createAssistantSetStatus ( preparedArgs ) ;
190186 preparedArgs . setSuggestedPrompts = createSetSuggestedPrompts ( preparedArgs ) ;
191187 preparedArgs . setTitle = createSetTitle ( preparedArgs ) ;
192188 return preparedArgs ;
@@ -350,24 +346,10 @@ function createAssistantSayStream(args: AllAssistantMiddlewareArgs): SayStreamFn
350346 * Creates utility `setStatus()` to set the status and indicate active processing.
351347 * https://api.slack.com/methods/assistant.threads.setStatus
352348 */
353- function createSetStatus ( args : AllAssistantMiddlewareArgs ) : SetStatusFn {
349+ function createAssistantSetStatus ( args : AllAssistantMiddlewareArgs ) : SetStatusFn {
354350 const { client, payload } = args ;
355- const { channelId : channel_id , threadTs : thread_ts } = extractThreadInfo ( payload ) ;
356-
357- return ( status : Parameters < SetStatusFn > [ 0 ] ) : Promise < AssistantThreadsSetStatusResponse > => {
358- if ( typeof status === 'string' ) {
359- return client . assistant . threads . setStatus ( {
360- channel_id,
361- thread_ts,
362- status,
363- } ) ;
364- }
365- return client . assistant . threads . setStatus ( {
366- channel_id,
367- thread_ts,
368- ...status ,
369- } ) ;
370- } ;
351+ const { channelId, threadTs } = extractThreadInfo ( payload ) ;
352+ return createSetStatus ( client , channelId , threadTs ) ;
371353}
372354
373355/**
0 commit comments