@paymanai/payman-typescript-ask-sdk 1.2.9 → 1.2.10
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.mts +52 -1
- package/dist/index.d.ts +52 -1
- package/dist/index.js +988 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +985 -5
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +988 -4
- package/dist/index.native.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -126,6 +126,8 @@ type MessageDisplay = {
|
|
|
126
126
|
activeThinkingText?: string;
|
|
127
127
|
/** All thinking accumulated across blocks (for post-stream display) */
|
|
128
128
|
allThinkingText?: string;
|
|
129
|
+
/** Pre-formatted thinking text built from steps + allThinkingText (v2 streaming format, matches demo) */
|
|
130
|
+
formattedThinkingText?: string;
|
|
129
131
|
/** True while RAG image URLs are being resolved after the final response is shown */
|
|
130
132
|
isResolvingImages?: boolean;
|
|
131
133
|
};
|
|
@@ -254,6 +256,24 @@ type UseChatReturn = {
|
|
|
254
256
|
};
|
|
255
257
|
declare function useChat(config: ChatConfig, callbacks?: ChatCallbacks): UseChatReturn;
|
|
256
258
|
|
|
259
|
+
type UseChatV2Return = {
|
|
260
|
+
messages: MessageDisplay[];
|
|
261
|
+
sendMessage: (userMessage: string) => Promise<void>;
|
|
262
|
+
clearMessages: () => void;
|
|
263
|
+
prependMessages: (messages: MessageDisplay[]) => void;
|
|
264
|
+
cancelStream: () => void;
|
|
265
|
+
resetSession: () => void;
|
|
266
|
+
getSessionId: () => string | undefined;
|
|
267
|
+
getMessages: () => MessageDisplay[];
|
|
268
|
+
isWaitingForResponse: boolean;
|
|
269
|
+
sessionId: string | undefined;
|
|
270
|
+
userActionState: UserActionState;
|
|
271
|
+
approveUserAction: (otp: string) => Promise<void>;
|
|
272
|
+
rejectUserAction: () => Promise<void>;
|
|
273
|
+
resendOtp: () => Promise<void>;
|
|
274
|
+
};
|
|
275
|
+
declare function useChatV2(config: ChatConfig, callbacks?: ChatCallbacks): UseChatV2Return;
|
|
276
|
+
|
|
257
277
|
interface SpeechRecognitionEvent extends Event {
|
|
258
278
|
results: SpeechRecognitionResultList;
|
|
259
279
|
resultIndex: number;
|
|
@@ -326,6 +346,37 @@ type StreamOptions = {
|
|
|
326
346
|
*/
|
|
327
347
|
declare function streamWorkflowEvents(url: string, body: Record<string, unknown>, headers: Record<string, string>, options?: StreamOptions): Promise<void>;
|
|
328
348
|
|
|
349
|
+
/**
|
|
350
|
+
* Build a richly-formatted thinking string from the SDK's `steps` array
|
|
351
|
+
* and raw `allThinkingText`. This matches the demo's streaming format
|
|
352
|
+
* so both the SDK and demo produce identical thinking output.
|
|
353
|
+
*
|
|
354
|
+
* The SDK's `allThinkingText` only contains raw `INTENT_THINKING_CONT`
|
|
355
|
+
* deltas — no phase headers. This function reconstructs the full format
|
|
356
|
+
* from the steps array, which stores every event the SDK processes.
|
|
357
|
+
*/
|
|
358
|
+
declare function buildFormattedThinking(steps: StreamingStep[] | undefined, allThinkingText: string): string;
|
|
359
|
+
|
|
360
|
+
type V2EventProcessorState = {
|
|
361
|
+
formattedThinkingText: string;
|
|
362
|
+
finalResponse: string;
|
|
363
|
+
currentWorker: string;
|
|
364
|
+
lastEventType: string;
|
|
365
|
+
sessionId?: string;
|
|
366
|
+
executionId?: string;
|
|
367
|
+
hasError: boolean;
|
|
368
|
+
errorMessage: string;
|
|
369
|
+
userActionRequest?: UserActionRequest;
|
|
370
|
+
userActionPending: boolean;
|
|
371
|
+
userActionResult?: UserActionResult;
|
|
372
|
+
finalData?: unknown;
|
|
373
|
+
steps: StreamingStep[];
|
|
374
|
+
stepCounter: number;
|
|
375
|
+
currentExecutingStepId?: string;
|
|
376
|
+
};
|
|
377
|
+
declare function createInitialV2State(): V2EventProcessorState;
|
|
378
|
+
declare function processStreamEventV2(event: StreamEvent, state: V2EventProcessorState): V2EventProcessorState;
|
|
379
|
+
|
|
329
380
|
type UserActionResponse = {
|
|
330
381
|
success: boolean;
|
|
331
382
|
message: string;
|
|
@@ -343,4 +394,4 @@ declare function cancelUserAction(config: ChatConfig, userActionId: string): Pro
|
|
|
343
394
|
*/
|
|
344
395
|
declare function resendUserAction(config: ChatConfig, userActionId: string): Promise<UserActionResponse>;
|
|
345
396
|
|
|
346
|
-
export { type APIConfig, type ChatCallbacks, type ChatConfig, type ChunkDisplay, type MessageDisplay, type MessageRole, type SessionParams, type StreamEvent, type StreamOptions, type StreamProgress, type StreamingStep, type UseChatReturn, type UseVoiceReturn, type UserActionRequest, type UserActionResult, type UserActionState, type UserActionType, type VoiceCallbacks, type VoiceConfig, type VoicePermissions, type VoiceResult, type VoiceState, type WorkflowStage, cancelUserAction, generateId, resendUserAction, streamWorkflowEvents, submitUserAction, useChat, useVoice };
|
|
397
|
+
export { type APIConfig, type ChatCallbacks, type ChatConfig, type ChunkDisplay, type MessageDisplay, type MessageRole, type SessionParams, type StreamEvent, type StreamOptions, type StreamProgress, type StreamingStep, type UseChatReturn, type UseChatV2Return, type UseVoiceReturn, type UserActionRequest, type UserActionResult, type UserActionState, type UserActionType, type V2EventProcessorState, type VoiceCallbacks, type VoiceConfig, type VoicePermissions, type VoiceResult, type VoiceState, type WorkflowStage, buildFormattedThinking, cancelUserAction, createInitialV2State, generateId, processStreamEventV2, resendUserAction, streamWorkflowEvents, submitUserAction, useChat, useChatV2, useVoice };
|
package/dist/index.d.ts
CHANGED
|
@@ -126,6 +126,8 @@ type MessageDisplay = {
|
|
|
126
126
|
activeThinkingText?: string;
|
|
127
127
|
/** All thinking accumulated across blocks (for post-stream display) */
|
|
128
128
|
allThinkingText?: string;
|
|
129
|
+
/** Pre-formatted thinking text built from steps + allThinkingText (v2 streaming format, matches demo) */
|
|
130
|
+
formattedThinkingText?: string;
|
|
129
131
|
/** True while RAG image URLs are being resolved after the final response is shown */
|
|
130
132
|
isResolvingImages?: boolean;
|
|
131
133
|
};
|
|
@@ -254,6 +256,24 @@ type UseChatReturn = {
|
|
|
254
256
|
};
|
|
255
257
|
declare function useChat(config: ChatConfig, callbacks?: ChatCallbacks): UseChatReturn;
|
|
256
258
|
|
|
259
|
+
type UseChatV2Return = {
|
|
260
|
+
messages: MessageDisplay[];
|
|
261
|
+
sendMessage: (userMessage: string) => Promise<void>;
|
|
262
|
+
clearMessages: () => void;
|
|
263
|
+
prependMessages: (messages: MessageDisplay[]) => void;
|
|
264
|
+
cancelStream: () => void;
|
|
265
|
+
resetSession: () => void;
|
|
266
|
+
getSessionId: () => string | undefined;
|
|
267
|
+
getMessages: () => MessageDisplay[];
|
|
268
|
+
isWaitingForResponse: boolean;
|
|
269
|
+
sessionId: string | undefined;
|
|
270
|
+
userActionState: UserActionState;
|
|
271
|
+
approveUserAction: (otp: string) => Promise<void>;
|
|
272
|
+
rejectUserAction: () => Promise<void>;
|
|
273
|
+
resendOtp: () => Promise<void>;
|
|
274
|
+
};
|
|
275
|
+
declare function useChatV2(config: ChatConfig, callbacks?: ChatCallbacks): UseChatV2Return;
|
|
276
|
+
|
|
257
277
|
interface SpeechRecognitionEvent extends Event {
|
|
258
278
|
results: SpeechRecognitionResultList;
|
|
259
279
|
resultIndex: number;
|
|
@@ -326,6 +346,37 @@ type StreamOptions = {
|
|
|
326
346
|
*/
|
|
327
347
|
declare function streamWorkflowEvents(url: string, body: Record<string, unknown>, headers: Record<string, string>, options?: StreamOptions): Promise<void>;
|
|
328
348
|
|
|
349
|
+
/**
|
|
350
|
+
* Build a richly-formatted thinking string from the SDK's `steps` array
|
|
351
|
+
* and raw `allThinkingText`. This matches the demo's streaming format
|
|
352
|
+
* so both the SDK and demo produce identical thinking output.
|
|
353
|
+
*
|
|
354
|
+
* The SDK's `allThinkingText` only contains raw `INTENT_THINKING_CONT`
|
|
355
|
+
* deltas — no phase headers. This function reconstructs the full format
|
|
356
|
+
* from the steps array, which stores every event the SDK processes.
|
|
357
|
+
*/
|
|
358
|
+
declare function buildFormattedThinking(steps: StreamingStep[] | undefined, allThinkingText: string): string;
|
|
359
|
+
|
|
360
|
+
type V2EventProcessorState = {
|
|
361
|
+
formattedThinkingText: string;
|
|
362
|
+
finalResponse: string;
|
|
363
|
+
currentWorker: string;
|
|
364
|
+
lastEventType: string;
|
|
365
|
+
sessionId?: string;
|
|
366
|
+
executionId?: string;
|
|
367
|
+
hasError: boolean;
|
|
368
|
+
errorMessage: string;
|
|
369
|
+
userActionRequest?: UserActionRequest;
|
|
370
|
+
userActionPending: boolean;
|
|
371
|
+
userActionResult?: UserActionResult;
|
|
372
|
+
finalData?: unknown;
|
|
373
|
+
steps: StreamingStep[];
|
|
374
|
+
stepCounter: number;
|
|
375
|
+
currentExecutingStepId?: string;
|
|
376
|
+
};
|
|
377
|
+
declare function createInitialV2State(): V2EventProcessorState;
|
|
378
|
+
declare function processStreamEventV2(event: StreamEvent, state: V2EventProcessorState): V2EventProcessorState;
|
|
379
|
+
|
|
329
380
|
type UserActionResponse = {
|
|
330
381
|
success: boolean;
|
|
331
382
|
message: string;
|
|
@@ -343,4 +394,4 @@ declare function cancelUserAction(config: ChatConfig, userActionId: string): Pro
|
|
|
343
394
|
*/
|
|
344
395
|
declare function resendUserAction(config: ChatConfig, userActionId: string): Promise<UserActionResponse>;
|
|
345
396
|
|
|
346
|
-
export { type APIConfig, type ChatCallbacks, type ChatConfig, type ChunkDisplay, type MessageDisplay, type MessageRole, type SessionParams, type StreamEvent, type StreamOptions, type StreamProgress, type StreamingStep, type UseChatReturn, type UseVoiceReturn, type UserActionRequest, type UserActionResult, type UserActionState, type UserActionType, type VoiceCallbacks, type VoiceConfig, type VoicePermissions, type VoiceResult, type VoiceState, type WorkflowStage, cancelUserAction, generateId, resendUserAction, streamWorkflowEvents, submitUserAction, useChat, useVoice };
|
|
397
|
+
export { type APIConfig, type ChatCallbacks, type ChatConfig, type ChunkDisplay, type MessageDisplay, type MessageRole, type SessionParams, type StreamEvent, type StreamOptions, type StreamProgress, type StreamingStep, type UseChatReturn, type UseChatV2Return, type UseVoiceReturn, type UserActionRequest, type UserActionResult, type UserActionState, type UserActionType, type V2EventProcessorState, type VoiceCallbacks, type VoiceConfig, type VoicePermissions, type VoiceResult, type VoiceState, type WorkflowStage, buildFormattedThinking, cancelUserAction, createInitialV2State, generateId, processStreamEventV2, resendUserAction, streamWorkflowEvents, submitUserAction, useChat, useChatV2, useVoice };
|