@superatomai/sdk-node 0.0.6-mds → 0.0.7-mds
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 +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +36 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6777,6 +6777,7 @@ ${formatted}`;
|
|
|
6777
6777
|
Analyze the error and try again with a corrected query.`;
|
|
6778
6778
|
}
|
|
6779
6779
|
};
|
|
6780
|
+
const maxIterations = this.config.maxRetries + 2;
|
|
6780
6781
|
await LLM.streamWithTools(
|
|
6781
6782
|
{ sys: prompts.system, user: prompts.user },
|
|
6782
6783
|
[llmTool],
|
|
@@ -6787,7 +6788,7 @@ Analyze the error and try again with a corrected query.`;
|
|
|
6787
6788
|
temperature: 0,
|
|
6788
6789
|
apiKey: this.config.apiKey
|
|
6789
6790
|
},
|
|
6790
|
-
|
|
6791
|
+
maxIterations
|
|
6791
6792
|
);
|
|
6792
6793
|
const executionTimeMs = Date.now() - startTime;
|
|
6793
6794
|
if (!executedTool) {
|
|
@@ -10170,21 +10171,25 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
|
|
|
10170
10171
|
if (responseMode === "text") {
|
|
10171
10172
|
streamCallback = (chunk) => {
|
|
10172
10173
|
accumulatedStreamResponse += chunk;
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
|
|
10174
|
+
try {
|
|
10175
|
+
const streamMessage = {
|
|
10176
|
+
id: `stream_${existingUiBlockId}`,
|
|
10177
|
+
// Different ID pattern for streaming
|
|
10178
|
+
type: "USER_PROMPT_STREAM",
|
|
10179
|
+
from: { type: "data-agent" },
|
|
10180
|
+
to: {
|
|
10181
|
+
type: "runtime",
|
|
10182
|
+
id: wsId
|
|
10183
|
+
},
|
|
10184
|
+
payload: {
|
|
10185
|
+
uiBlockId: existingUiBlockId,
|
|
10186
|
+
chunk
|
|
10187
|
+
}
|
|
10188
|
+
};
|
|
10189
|
+
sendMessage(streamMessage);
|
|
10190
|
+
} catch (err) {
|
|
10191
|
+
logger.warn(`[UserPromptRequest] Stream send failed (WebSocket may be closed): ${err instanceof Error ? err.message : String(err)}`);
|
|
10192
|
+
}
|
|
10188
10193
|
};
|
|
10189
10194
|
}
|
|
10190
10195
|
const userResponse = await get_agent_user_response(
|
|
@@ -15419,17 +15424,27 @@ var SuperatomSDK = class {
|
|
|
15419
15424
|
}
|
|
15420
15425
|
}
|
|
15421
15426
|
/**
|
|
15422
|
-
* Send a message to the Superatom service
|
|
15427
|
+
* Send a message to the Superatom service.
|
|
15428
|
+
* Returns true if the message was sent, false if the WebSocket is not connected.
|
|
15429
|
+
* Does NOT throw on closed connections — callers can check the return value if needed.
|
|
15423
15430
|
*/
|
|
15424
15431
|
send(message) {
|
|
15425
15432
|
if (!this.ws || !this.connected) {
|
|
15426
|
-
|
|
15433
|
+
logger.warn("WebSocket is not connected, message not sent:", message.type);
|
|
15434
|
+
return false;
|
|
15427
15435
|
}
|
|
15428
15436
|
if (this.ws.readyState !== this.ws.OPEN) {
|
|
15429
|
-
|
|
15437
|
+
logger.warn("WebSocket is not in OPEN state, message not sent:", message.type);
|
|
15438
|
+
return false;
|
|
15439
|
+
}
|
|
15440
|
+
try {
|
|
15441
|
+
const payload = JSON.stringify(message);
|
|
15442
|
+
this.ws.send(payload);
|
|
15443
|
+
return true;
|
|
15444
|
+
} catch (error) {
|
|
15445
|
+
logger.warn(`Failed to send WebSocket message (${message.type}):`, error instanceof Error ? error.message : String(error));
|
|
15446
|
+
return false;
|
|
15430
15447
|
}
|
|
15431
|
-
const payload = JSON.stringify(message);
|
|
15432
|
-
this.ws.send(payload);
|
|
15433
15448
|
}
|
|
15434
15449
|
/**
|
|
15435
15450
|
* Register a message handler to receive all messages
|