UNPKG

@microsoft/teams.apps

Version:

<p> <a href="https://www.npmjs.com/package/@microsoft/teams.apps" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.apps/latest" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.apps?activeTab=code

109 lines (108 loc) • 4.02 kB
import { AxiosError } from 'axios'; import { IMessageActivity, IMessageActivityInput, ITypingActivity, ITypingActivityInput, SentActivity, TextFormat } from '@microsoft/teams.api'; import { IEventEmitter } from '@microsoft/teams.common'; /** * @deprecated Teams no longer supports stopping a stream. */ export declare class StreamCancelledError extends Error { constructor(message?: string); } /** * Base class for terminal streaming errors that should not be retried. */ export declare class TerminalStreamError extends Error { constructor(message?: string); } /** * Raised when the service reports that streaming exceeded ten minutes from the * first informative or content chunk. * A buffered Plan completion cannot use the ordinary PUT fallback. Resolve it * explicitly through Plan.complete() rather than retrying the same stream close. */ export declare class StreamTimedOutError extends TerminalStreamError { constructor(message?: string); } /** * Raised when streaming is not allowed for this user or bot. */ export declare class StreamNotAllowedError extends TerminalStreamError { constructor(message?: string); } /** * Raised for HTTP 409 PlanConflict streaming failures without retrying. * Preserves the original HTTP request, response, and cause. * This is a service lifecycle conflict, not a timeout; resolve the Plan state * explicitly instead of retrying the same stream close. * * @experimental This API is in preview and may change in the future. * Diagnostic: ExperimentalTeamsPlan */ export declare class PlanConflictStreamError extends AxiosError { /** @param error The original HTTP 409 PlanConflict failure. */ constructor(error: AxiosError); } /** * the minimum events a streamer * should support */ export interface IStreamerEvents { /** * emitted for each chunk sent */ readonly chunk: SentActivity; /** * emitted once on stream close */ readonly close: SentActivity; } /** * component that can send streamed chunks of an activity */ export interface IStreamer { readonly events: Omit<IEventEmitter<IStreamerEvents>, 'emit'>; /** * @deprecated Teams no longer supports stopping a stream. HttpStream always returns false. */ readonly canceled: boolean; /** * whether the current streamed message has been finalized. * * Closing is idempotent until the next emit or update. Emitting or * updating after close starts a new streamed message using the same * stream instance. */ readonly closed: boolean; /** * emit an activity chunk * @param activity the activity to send */ /** * @deprecated Use {@link IMessageActivityInput} or {@link ITypingActivityInput} instead. */ emit(activity: IMessageActivity | ITypingActivity): void; emit(activity: IMessageActivityInput | ITypingActivityInput | string): void; /** * send status updates before emitting (ex. "Thinking...") * @param text the status text to send * @param textFormat format of `text` (ex. `'extendedmarkdown'`); omit or pass `null` * to use the Teams default (`'markdown'`) */ update(text: string, textFormat?: TextFormat | null): void; /** * Discard accumulated streamed text and any pending text deltas, so the * final message sent by `close()` doesn't include them. Useful when a * mid-turn decision (e.g. a tool call producing a card) means the * buffered text should not appear in the final activity. Typing chunks * already shipped to Teams are not undone, but the final message updates * the same activity to reflect the cleared state. */ clearText(): void; /** * Finalize the current streamed message. * * Closing is idempotent until the next emit or update. Emitting or * updating after close starts a new streamed message using the same * stream instance. */ close(): SentActivity | undefined | Promise<SentActivity | undefined>; }