@superatomai/sdk-web 0.0.8 → 0.0.9
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/README.md +128 -3
- package/dist/index.cjs +30 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.js +30 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -300,6 +300,10 @@ declare const UserPromptRequestPayloadSchema: z.ZodObject<{
|
|
|
300
300
|
threadId: z.ZodString;
|
|
301
301
|
uiBlockId: z.ZodString;
|
|
302
302
|
}, z.core.$strip>>;
|
|
303
|
+
responseMode: z.ZodOptional<z.ZodEnum<{
|
|
304
|
+
component: "component";
|
|
305
|
+
text: "text";
|
|
306
|
+
}>>;
|
|
303
307
|
}, z.core.$strip>;
|
|
304
308
|
type UserPromptRequestPayload = z.infer<typeof UserPromptRequestPayloadSchema>;
|
|
305
309
|
/**
|
|
@@ -323,6 +327,10 @@ declare const UserPromptRequestMessageSchema: z.ZodObject<{
|
|
|
323
327
|
threadId: z.ZodString;
|
|
324
328
|
uiBlockId: z.ZodString;
|
|
325
329
|
}, z.core.$strip>>;
|
|
330
|
+
responseMode: z.ZodOptional<z.ZodEnum<{
|
|
331
|
+
component: "component";
|
|
332
|
+
text: "text";
|
|
333
|
+
}>>;
|
|
326
334
|
}, z.core.$strip>;
|
|
327
335
|
}, z.core.$strip>;
|
|
328
336
|
type UserPromptRequestMessage = z.infer<typeof UserPromptRequestMessageSchema>;
|
|
@@ -868,10 +876,12 @@ declare function sendAuthVerifyRequest(client: SuperatomClient, token: string, t
|
|
|
868
876
|
* @param prompt - User's prompt text
|
|
869
877
|
* @param threadId - Thread ID for conversation context
|
|
870
878
|
* @param uiBlockId - UI block ID for context
|
|
879
|
+
* @param responseMode - 'component' for component response (default), 'text' for text streaming
|
|
880
|
+
* @param onStream - Optional callback for streaming text chunks (only for text mode)
|
|
871
881
|
* @param timeout - Request timeout in milliseconds
|
|
872
882
|
* @returns Server response message
|
|
873
883
|
*/
|
|
874
|
-
declare function sendUserPromptRequest(client: SuperatomClient, prompt: string, threadId: string, uiBlockId: string, timeout?: number): Promise<Message>;
|
|
884
|
+
declare function sendUserPromptRequest(client: SuperatomClient, prompt: string, threadId: string, uiBlockId: string, responseMode?: 'component' | 'text', onStream?: (chunk: string) => void, timeout?: number): Promise<Message>;
|
|
875
885
|
/**
|
|
876
886
|
* Send a user prompt suggestions request
|
|
877
887
|
* @param client - SuperatomClient instance
|
|
@@ -1403,8 +1413,10 @@ declare class SuperatomClient {
|
|
|
1403
1413
|
/**
|
|
1404
1414
|
* Send a user prompt request
|
|
1405
1415
|
* Delegates to user prompt service
|
|
1416
|
+
* @param responseMode - 'component' for component response (default), 'text' for text streaming
|
|
1417
|
+
* @param onStream - Optional callback for streaming text chunks (only for text mode)
|
|
1406
1418
|
*/
|
|
1407
|
-
sendUserPromptRequest(prompt: string, threadId: string, uiBlockId: string, timeout?: number): Promise<Message>;
|
|
1419
|
+
sendUserPromptRequest(prompt: string, threadId: string, uiBlockId: string, responseMode?: 'component' | 'text', onStream?: (chunk: string) => void, timeout?: number): Promise<Message>;
|
|
1408
1420
|
/**
|
|
1409
1421
|
* Send a user prompt suggestions request
|
|
1410
1422
|
* Delegates to user prompt service
|
package/dist/index.d.ts
CHANGED
|
@@ -300,6 +300,10 @@ declare const UserPromptRequestPayloadSchema: z.ZodObject<{
|
|
|
300
300
|
threadId: z.ZodString;
|
|
301
301
|
uiBlockId: z.ZodString;
|
|
302
302
|
}, z.core.$strip>>;
|
|
303
|
+
responseMode: z.ZodOptional<z.ZodEnum<{
|
|
304
|
+
component: "component";
|
|
305
|
+
text: "text";
|
|
306
|
+
}>>;
|
|
303
307
|
}, z.core.$strip>;
|
|
304
308
|
type UserPromptRequestPayload = z.infer<typeof UserPromptRequestPayloadSchema>;
|
|
305
309
|
/**
|
|
@@ -323,6 +327,10 @@ declare const UserPromptRequestMessageSchema: z.ZodObject<{
|
|
|
323
327
|
threadId: z.ZodString;
|
|
324
328
|
uiBlockId: z.ZodString;
|
|
325
329
|
}, z.core.$strip>>;
|
|
330
|
+
responseMode: z.ZodOptional<z.ZodEnum<{
|
|
331
|
+
component: "component";
|
|
332
|
+
text: "text";
|
|
333
|
+
}>>;
|
|
326
334
|
}, z.core.$strip>;
|
|
327
335
|
}, z.core.$strip>;
|
|
328
336
|
type UserPromptRequestMessage = z.infer<typeof UserPromptRequestMessageSchema>;
|
|
@@ -868,10 +876,12 @@ declare function sendAuthVerifyRequest(client: SuperatomClient, token: string, t
|
|
|
868
876
|
* @param prompt - User's prompt text
|
|
869
877
|
* @param threadId - Thread ID for conversation context
|
|
870
878
|
* @param uiBlockId - UI block ID for context
|
|
879
|
+
* @param responseMode - 'component' for component response (default), 'text' for text streaming
|
|
880
|
+
* @param onStream - Optional callback for streaming text chunks (only for text mode)
|
|
871
881
|
* @param timeout - Request timeout in milliseconds
|
|
872
882
|
* @returns Server response message
|
|
873
883
|
*/
|
|
874
|
-
declare function sendUserPromptRequest(client: SuperatomClient, prompt: string, threadId: string, uiBlockId: string, timeout?: number): Promise<Message>;
|
|
884
|
+
declare function sendUserPromptRequest(client: SuperatomClient, prompt: string, threadId: string, uiBlockId: string, responseMode?: 'component' | 'text', onStream?: (chunk: string) => void, timeout?: number): Promise<Message>;
|
|
875
885
|
/**
|
|
876
886
|
* Send a user prompt suggestions request
|
|
877
887
|
* @param client - SuperatomClient instance
|
|
@@ -1403,8 +1413,10 @@ declare class SuperatomClient {
|
|
|
1403
1413
|
/**
|
|
1404
1414
|
* Send a user prompt request
|
|
1405
1415
|
* Delegates to user prompt service
|
|
1416
|
+
* @param responseMode - 'component' for component response (default), 'text' for text streaming
|
|
1417
|
+
* @param onStream - Optional callback for streaming text chunks (only for text mode)
|
|
1406
1418
|
*/
|
|
1407
|
-
sendUserPromptRequest(prompt: string, threadId: string, uiBlockId: string, timeout?: number): Promise<Message>;
|
|
1419
|
+
sendUserPromptRequest(prompt: string, threadId: string, uiBlockId: string, responseMode?: 'component' | 'text', onStream?: (chunk: string) => void, timeout?: number): Promise<Message>;
|
|
1408
1420
|
/**
|
|
1409
1421
|
* Send a user prompt suggestions request
|
|
1410
1422
|
* Delegates to user prompt service
|
package/dist/index.js
CHANGED
|
@@ -250,7 +250,8 @@ var UserPromptRequestPayloadSchema = z.object({
|
|
|
250
250
|
SA_RUNTIME: z.object({
|
|
251
251
|
threadId: z.string(),
|
|
252
252
|
uiBlockId: z.string()
|
|
253
|
-
}).optional()
|
|
253
|
+
}).optional(),
|
|
254
|
+
responseMode: z.enum(["component", "text"]).optional()
|
|
254
255
|
});
|
|
255
256
|
var UserPromptRequestMessageSchema = z.object({
|
|
256
257
|
id: z.string(),
|
|
@@ -636,8 +637,8 @@ async function sendAuthVerifyRequest(client, token, timeout) {
|
|
|
636
637
|
}
|
|
637
638
|
|
|
638
639
|
// src/services/userPrompt.ts
|
|
639
|
-
async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, timeout) {
|
|
640
|
-
const messageId = `
|
|
640
|
+
async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, responseMode, onStream, timeout) {
|
|
641
|
+
const messageId = `user_prompt_req_msg_${Date.now()}`;
|
|
641
642
|
const message = UserPromptRequestMessageSchema.parse({
|
|
642
643
|
id: messageId,
|
|
643
644
|
type: "USER_PROMPT_REQ",
|
|
@@ -652,11 +653,29 @@ async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, timeou
|
|
|
652
653
|
SA_RUNTIME: {
|
|
653
654
|
threadId,
|
|
654
655
|
uiBlockId
|
|
655
|
-
}
|
|
656
|
+
},
|
|
657
|
+
responseMode
|
|
656
658
|
}
|
|
657
659
|
});
|
|
658
|
-
|
|
659
|
-
|
|
660
|
+
let streamUnsubscribe = null;
|
|
661
|
+
if (responseMode === "text" && onStream) {
|
|
662
|
+
streamUnsubscribe = client.onMessage((msg) => {
|
|
663
|
+
if (msg.type === "USER_PROMPT_STREAM" && msg.id === `stream_${uiBlockId}`) {
|
|
664
|
+
const chunk = msg.payload?.chunk;
|
|
665
|
+
if (chunk) {
|
|
666
|
+
onStream(chunk);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
try {
|
|
672
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
673
|
+
return response;
|
|
674
|
+
} finally {
|
|
675
|
+
if (streamUnsubscribe) {
|
|
676
|
+
streamUnsubscribe();
|
|
677
|
+
}
|
|
678
|
+
}
|
|
660
679
|
}
|
|
661
680
|
async function sendUserPromptSuggestionsRequest(client, prompt, limit = 5, timeout) {
|
|
662
681
|
if (!prompt || prompt.trim().length === 0) {
|
|
@@ -1463,10 +1482,12 @@ var SuperatomClient = class {
|
|
|
1463
1482
|
/**
|
|
1464
1483
|
* Send a user prompt request
|
|
1465
1484
|
* Delegates to user prompt service
|
|
1485
|
+
* @param responseMode - 'component' for component response (default), 'text' for text streaming
|
|
1486
|
+
* @param onStream - Optional callback for streaming text chunks (only for text mode)
|
|
1466
1487
|
*/
|
|
1467
|
-
async sendUserPromptRequest(prompt, threadId, uiBlockId, timeout) {
|
|
1468
|
-
this.log("info", "Sending user prompt request");
|
|
1469
|
-
return sendUserPromptRequest(this, prompt, threadId, uiBlockId, timeout);
|
|
1488
|
+
async sendUserPromptRequest(prompt, threadId, uiBlockId, responseMode, onStream, timeout) {
|
|
1489
|
+
this.log("info", "Sending user prompt request with streaming support");
|
|
1490
|
+
return sendUserPromptRequest(this, prompt, threadId, uiBlockId, responseMode, onStream, timeout);
|
|
1470
1491
|
}
|
|
1471
1492
|
/**
|
|
1472
1493
|
* Send a user prompt suggestions request
|