@paymanai/payman-typescript-ask-sdk 1.0.1 → 1.1.0
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 -2
- package/dist/index.d.ts +52 -2
- package/dist/index.js +305 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +304 -26
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +305 -24
- package/dist/index.native.js.map +1 -1
- package/package.json +5 -4
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,17 @@ import React from 'react';
|
|
|
3
3
|
type MessageRole = "user" | "assistant" | "system";
|
|
4
4
|
type StreamProgress = "started" | "processing" | "completed" | "error";
|
|
5
5
|
type WorkflowStage = "DEV" | "SANDBOX" | "PROD" | "ARCHIVED";
|
|
6
|
+
type UserActionRequest = {
|
|
7
|
+
userActionId: string;
|
|
8
|
+
message: string;
|
|
9
|
+
requestedSchema: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
type UserActionResult = "approved" | "rejected";
|
|
12
|
+
type UserActionState = {
|
|
13
|
+
request: UserActionRequest | null;
|
|
14
|
+
result: UserActionResult | null;
|
|
15
|
+
clearOtpTrigger: number;
|
|
16
|
+
};
|
|
6
17
|
type StreamingStep = {
|
|
7
18
|
id: string;
|
|
8
19
|
eventType: string;
|
|
@@ -36,6 +47,8 @@ type MessageDisplay = {
|
|
|
36
47
|
steps?: StreamingStep[];
|
|
37
48
|
isCancelled?: boolean;
|
|
38
49
|
currentExecutingStepId?: string;
|
|
50
|
+
/** Result of user action (OTP approval/rejection) */
|
|
51
|
+
userActionResult?: UserActionResult;
|
|
39
52
|
};
|
|
40
53
|
type SessionParams = {
|
|
41
54
|
id?: string;
|
|
@@ -61,6 +74,8 @@ type ChatConfig = {
|
|
|
61
74
|
workflowVersion?: number;
|
|
62
75
|
/** Stage/Environment */
|
|
63
76
|
stage?: WorkflowStage;
|
|
77
|
+
/** Query param name for stage (default: "stage"). Use e.g. "workflowStage" if the API expects that name. */
|
|
78
|
+
stageQueryParam?: string;
|
|
64
79
|
/** Session params */
|
|
65
80
|
sessionParams?: SessionParams;
|
|
66
81
|
/** Custom placeholder text */
|
|
@@ -123,9 +138,13 @@ type ChatCallbacks = {
|
|
|
123
138
|
}) => void;
|
|
124
139
|
/** Called when session ID changes */
|
|
125
140
|
onSessionIdChange?: (sessionId: string) => void;
|
|
141
|
+
/** Called when a user action (e.g. OTP) is required */
|
|
142
|
+
onUserActionRequired?: (request: UserActionRequest) => void;
|
|
143
|
+
/** Called on user action events (SUCCESS, INVALID, EXPIRED, REJECTED, RESENT, FAILED) */
|
|
144
|
+
onUserActionEvent?: (eventType: string, message: string) => void;
|
|
126
145
|
};
|
|
127
146
|
|
|
128
|
-
|
|
147
|
+
type UseChatReturn = {
|
|
129
148
|
messages: MessageDisplay[];
|
|
130
149
|
sendMessage: (userMessage: string) => Promise<void>;
|
|
131
150
|
clearMessages: () => void;
|
|
@@ -135,7 +154,16 @@ declare function useChat(config: ChatConfig, callbacks?: ChatCallbacks): {
|
|
|
135
154
|
getMessages: () => MessageDisplay[];
|
|
136
155
|
isWaitingForResponse: boolean;
|
|
137
156
|
sessionId: string | undefined;
|
|
157
|
+
/** User action (OTP) state — always present, inert when workflow has no user actions */
|
|
158
|
+
userActionState: UserActionState;
|
|
159
|
+
/** Submit OTP for approval */
|
|
160
|
+
approveUserAction: (otp: string) => Promise<void>;
|
|
161
|
+
/** Reject / cancel a user action */
|
|
162
|
+
rejectUserAction: () => Promise<void>;
|
|
163
|
+
/** Resend OTP code */
|
|
164
|
+
resendOtp: () => Promise<void>;
|
|
138
165
|
};
|
|
166
|
+
declare function useChat(config: ChatConfig, callbacks?: ChatCallbacks): UseChatReturn;
|
|
139
167
|
|
|
140
168
|
/**
|
|
141
169
|
* Cross-platform UUID v4 generator
|
|
@@ -157,6 +185,11 @@ type StreamEvent = {
|
|
|
157
185
|
inputTokens?: number;
|
|
158
186
|
outputTokens?: number;
|
|
159
187
|
elapsedMs?: number;
|
|
188
|
+
userActionRequest?: {
|
|
189
|
+
userActionId: string;
|
|
190
|
+
message: string;
|
|
191
|
+
requestedSchema: Record<string, unknown>;
|
|
192
|
+
};
|
|
160
193
|
[key: string]: unknown;
|
|
161
194
|
};
|
|
162
195
|
type StreamOptions = {
|
|
@@ -170,4 +203,21 @@ type StreamOptions = {
|
|
|
170
203
|
*/
|
|
171
204
|
declare function streamWorkflowEvents(url: string, body: Record<string, unknown>, headers: Record<string, string>, options?: StreamOptions): Promise<void>;
|
|
172
205
|
|
|
173
|
-
|
|
206
|
+
type UserActionResponse = {
|
|
207
|
+
success: boolean;
|
|
208
|
+
message: string;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Submit a user action (e.g. OTP verification)
|
|
212
|
+
*/
|
|
213
|
+
declare function submitUserAction(config: ChatConfig, userActionId: string, data?: Record<string, unknown>): Promise<UserActionResponse>;
|
|
214
|
+
/**
|
|
215
|
+
* Cancel / reject a user action
|
|
216
|
+
*/
|
|
217
|
+
declare function cancelUserAction(config: ChatConfig, userActionId: string): Promise<UserActionResponse>;
|
|
218
|
+
/**
|
|
219
|
+
* Resend a user action (e.g. request a new OTP)
|
|
220
|
+
*/
|
|
221
|
+
declare function resendUserAction(config: ChatConfig, userActionId: string): Promise<UserActionResponse>;
|
|
222
|
+
|
|
223
|
+
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 UserActionRequest, type UserActionResult, type UserActionState, type WorkflowStage, cancelUserAction, generateId, resendUserAction, streamWorkflowEvents, submitUserAction, useChat };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,17 @@ import React from 'react';
|
|
|
3
3
|
type MessageRole = "user" | "assistant" | "system";
|
|
4
4
|
type StreamProgress = "started" | "processing" | "completed" | "error";
|
|
5
5
|
type WorkflowStage = "DEV" | "SANDBOX" | "PROD" | "ARCHIVED";
|
|
6
|
+
type UserActionRequest = {
|
|
7
|
+
userActionId: string;
|
|
8
|
+
message: string;
|
|
9
|
+
requestedSchema: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
type UserActionResult = "approved" | "rejected";
|
|
12
|
+
type UserActionState = {
|
|
13
|
+
request: UserActionRequest | null;
|
|
14
|
+
result: UserActionResult | null;
|
|
15
|
+
clearOtpTrigger: number;
|
|
16
|
+
};
|
|
6
17
|
type StreamingStep = {
|
|
7
18
|
id: string;
|
|
8
19
|
eventType: string;
|
|
@@ -36,6 +47,8 @@ type MessageDisplay = {
|
|
|
36
47
|
steps?: StreamingStep[];
|
|
37
48
|
isCancelled?: boolean;
|
|
38
49
|
currentExecutingStepId?: string;
|
|
50
|
+
/** Result of user action (OTP approval/rejection) */
|
|
51
|
+
userActionResult?: UserActionResult;
|
|
39
52
|
};
|
|
40
53
|
type SessionParams = {
|
|
41
54
|
id?: string;
|
|
@@ -61,6 +74,8 @@ type ChatConfig = {
|
|
|
61
74
|
workflowVersion?: number;
|
|
62
75
|
/** Stage/Environment */
|
|
63
76
|
stage?: WorkflowStage;
|
|
77
|
+
/** Query param name for stage (default: "stage"). Use e.g. "workflowStage" if the API expects that name. */
|
|
78
|
+
stageQueryParam?: string;
|
|
64
79
|
/** Session params */
|
|
65
80
|
sessionParams?: SessionParams;
|
|
66
81
|
/** Custom placeholder text */
|
|
@@ -123,9 +138,13 @@ type ChatCallbacks = {
|
|
|
123
138
|
}) => void;
|
|
124
139
|
/** Called when session ID changes */
|
|
125
140
|
onSessionIdChange?: (sessionId: string) => void;
|
|
141
|
+
/** Called when a user action (e.g. OTP) is required */
|
|
142
|
+
onUserActionRequired?: (request: UserActionRequest) => void;
|
|
143
|
+
/** Called on user action events (SUCCESS, INVALID, EXPIRED, REJECTED, RESENT, FAILED) */
|
|
144
|
+
onUserActionEvent?: (eventType: string, message: string) => void;
|
|
126
145
|
};
|
|
127
146
|
|
|
128
|
-
|
|
147
|
+
type UseChatReturn = {
|
|
129
148
|
messages: MessageDisplay[];
|
|
130
149
|
sendMessage: (userMessage: string) => Promise<void>;
|
|
131
150
|
clearMessages: () => void;
|
|
@@ -135,7 +154,16 @@ declare function useChat(config: ChatConfig, callbacks?: ChatCallbacks): {
|
|
|
135
154
|
getMessages: () => MessageDisplay[];
|
|
136
155
|
isWaitingForResponse: boolean;
|
|
137
156
|
sessionId: string | undefined;
|
|
157
|
+
/** User action (OTP) state — always present, inert when workflow has no user actions */
|
|
158
|
+
userActionState: UserActionState;
|
|
159
|
+
/** Submit OTP for approval */
|
|
160
|
+
approveUserAction: (otp: string) => Promise<void>;
|
|
161
|
+
/** Reject / cancel a user action */
|
|
162
|
+
rejectUserAction: () => Promise<void>;
|
|
163
|
+
/** Resend OTP code */
|
|
164
|
+
resendOtp: () => Promise<void>;
|
|
138
165
|
};
|
|
166
|
+
declare function useChat(config: ChatConfig, callbacks?: ChatCallbacks): UseChatReturn;
|
|
139
167
|
|
|
140
168
|
/**
|
|
141
169
|
* Cross-platform UUID v4 generator
|
|
@@ -157,6 +185,11 @@ type StreamEvent = {
|
|
|
157
185
|
inputTokens?: number;
|
|
158
186
|
outputTokens?: number;
|
|
159
187
|
elapsedMs?: number;
|
|
188
|
+
userActionRequest?: {
|
|
189
|
+
userActionId: string;
|
|
190
|
+
message: string;
|
|
191
|
+
requestedSchema: Record<string, unknown>;
|
|
192
|
+
};
|
|
160
193
|
[key: string]: unknown;
|
|
161
194
|
};
|
|
162
195
|
type StreamOptions = {
|
|
@@ -170,4 +203,21 @@ type StreamOptions = {
|
|
|
170
203
|
*/
|
|
171
204
|
declare function streamWorkflowEvents(url: string, body: Record<string, unknown>, headers: Record<string, string>, options?: StreamOptions): Promise<void>;
|
|
172
205
|
|
|
173
|
-
|
|
206
|
+
type UserActionResponse = {
|
|
207
|
+
success: boolean;
|
|
208
|
+
message: string;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Submit a user action (e.g. OTP verification)
|
|
212
|
+
*/
|
|
213
|
+
declare function submitUserAction(config: ChatConfig, userActionId: string, data?: Record<string, unknown>): Promise<UserActionResponse>;
|
|
214
|
+
/**
|
|
215
|
+
* Cancel / reject a user action
|
|
216
|
+
*/
|
|
217
|
+
declare function cancelUserAction(config: ChatConfig, userActionId: string): Promise<UserActionResponse>;
|
|
218
|
+
/**
|
|
219
|
+
* Resend a user action (e.g. request a new OTP)
|
|
220
|
+
*/
|
|
221
|
+
declare function resendUserAction(config: ChatConfig, userActionId: string): Promise<UserActionResponse>;
|
|
222
|
+
|
|
223
|
+
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 UserActionRequest, type UserActionResult, type UserActionState, type WorkflowStage, cancelUserAction, generateId, resendUserAction, streamWorkflowEvents, submitUserAction, useChat };
|