@paymanai/payman-typescript-ask-sdk 1.2.8 → 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 +56 -1
- package/dist/index.d.ts +56 -1
- package/dist/index.js +1078 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1075 -6
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +1078 -5
- package/dist/index.native.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -126,6 +126,10 @@ 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;
|
|
131
|
+
/** True while RAG image URLs are being resolved after the final response is shown */
|
|
132
|
+
isResolvingImages?: boolean;
|
|
129
133
|
};
|
|
130
134
|
type SessionParams = {
|
|
131
135
|
id?: string;
|
|
@@ -141,6 +145,8 @@ type APIConfig = {
|
|
|
141
145
|
headers?: Record<string, string>;
|
|
142
146
|
/** API endpoint for streaming (default: /api/workflows/ask/stream) */
|
|
143
147
|
streamEndpoint?: string;
|
|
148
|
+
/** API endpoint for resolving RAG image URLs (default: /api/playground/ask/resolve-image-urls) */
|
|
149
|
+
resolveImagesEndpoint?: string;
|
|
144
150
|
};
|
|
145
151
|
type ChatConfig = {
|
|
146
152
|
/** API configuration - required for the library to make calls */
|
|
@@ -250,6 +256,24 @@ type UseChatReturn = {
|
|
|
250
256
|
};
|
|
251
257
|
declare function useChat(config: ChatConfig, callbacks?: ChatCallbacks): UseChatReturn;
|
|
252
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
|
+
|
|
253
277
|
interface SpeechRecognitionEvent extends Event {
|
|
254
278
|
results: SpeechRecognitionResultList;
|
|
255
279
|
resultIndex: number;
|
|
@@ -322,6 +346,37 @@ type StreamOptions = {
|
|
|
322
346
|
*/
|
|
323
347
|
declare function streamWorkflowEvents(url: string, body: Record<string, unknown>, headers: Record<string, string>, options?: StreamOptions): Promise<void>;
|
|
324
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
|
+
|
|
325
380
|
type UserActionResponse = {
|
|
326
381
|
success: boolean;
|
|
327
382
|
message: string;
|
|
@@ -339,4 +394,4 @@ declare function cancelUserAction(config: ChatConfig, userActionId: string): Pro
|
|
|
339
394
|
*/
|
|
340
395
|
declare function resendUserAction(config: ChatConfig, userActionId: string): Promise<UserActionResponse>;
|
|
341
396
|
|
|
342
|
-
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,10 @@ 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;
|
|
131
|
+
/** True while RAG image URLs are being resolved after the final response is shown */
|
|
132
|
+
isResolvingImages?: boolean;
|
|
129
133
|
};
|
|
130
134
|
type SessionParams = {
|
|
131
135
|
id?: string;
|
|
@@ -141,6 +145,8 @@ type APIConfig = {
|
|
|
141
145
|
headers?: Record<string, string>;
|
|
142
146
|
/** API endpoint for streaming (default: /api/workflows/ask/stream) */
|
|
143
147
|
streamEndpoint?: string;
|
|
148
|
+
/** API endpoint for resolving RAG image URLs (default: /api/playground/ask/resolve-image-urls) */
|
|
149
|
+
resolveImagesEndpoint?: string;
|
|
144
150
|
};
|
|
145
151
|
type ChatConfig = {
|
|
146
152
|
/** API configuration - required for the library to make calls */
|
|
@@ -250,6 +256,24 @@ type UseChatReturn = {
|
|
|
250
256
|
};
|
|
251
257
|
declare function useChat(config: ChatConfig, callbacks?: ChatCallbacks): UseChatReturn;
|
|
252
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
|
+
|
|
253
277
|
interface SpeechRecognitionEvent extends Event {
|
|
254
278
|
results: SpeechRecognitionResultList;
|
|
255
279
|
resultIndex: number;
|
|
@@ -322,6 +346,37 @@ type StreamOptions = {
|
|
|
322
346
|
*/
|
|
323
347
|
declare function streamWorkflowEvents(url: string, body: Record<string, unknown>, headers: Record<string, string>, options?: StreamOptions): Promise<void>;
|
|
324
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
|
+
|
|
325
380
|
type UserActionResponse = {
|
|
326
381
|
success: boolean;
|
|
327
382
|
message: string;
|
|
@@ -339,4 +394,4 @@ declare function cancelUserAction(config: ChatConfig, userActionId: string): Pro
|
|
|
339
394
|
*/
|
|
340
395
|
declare function resendUserAction(config: ChatConfig, userActionId: string): Promise<UserActionResponse>;
|
|
341
396
|
|
|
342
|
-
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 };
|