@loadmill/droid-cua 2.2.1 → 2.2.2
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.
|
@@ -96,9 +96,6 @@ function mapCuaError(err, cuaModel) {
|
|
|
96
96
|
}
|
|
97
97
|
return err;
|
|
98
98
|
}
|
|
99
|
-
export function isNonRetryableCuaError(err) {
|
|
100
|
-
return err?.status === 400 && err?.type === "invalid_request_error";
|
|
101
|
-
}
|
|
102
99
|
function getOpenAI() {
|
|
103
100
|
if (!openai) {
|
|
104
101
|
openai = new OpenAI({
|
|
@@ -177,6 +174,15 @@ export async function sendCUARequest({ messages, screenshotBase64, previousRespo
|
|
|
177
174
|
}
|
|
178
175
|
catch (err) {
|
|
179
176
|
cuaDebugTracer.onError(trace, err);
|
|
177
|
+
const responseError = err?.error && typeof err.error === "object" ? err.error : null;
|
|
178
|
+
const requestIdFromHeaders = err?.headers && typeof err.headers === "object"
|
|
179
|
+
? err.headers["x-request-id"] || err.headers["request-id"] || null
|
|
180
|
+
: null;
|
|
181
|
+
err.localRequestId = trace.localRequestId;
|
|
182
|
+
err.request_id = err?.request_id || responseError?.request_id || requestIdFromHeaders || null;
|
|
183
|
+
err.previous_response_id = previousResponseId || null;
|
|
184
|
+
err.last_response_output_types = trace.lastResponseMeta?.outputTypes ?? [];
|
|
185
|
+
err.request_config_hash = trace.requestConfigHash;
|
|
180
186
|
throw mapCuaError(err, cuaModel);
|
|
181
187
|
}
|
|
182
188
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getScreenshotAsBase64, connectToDevice, getDeviceInfo, getCurrentPlatform } from "../device/connection.js";
|
|
2
|
-
import {
|
|
2
|
+
import { sendCUARequest } from "../device/openai.js";
|
|
3
3
|
import { isAssertion, extractAssertionPrompt, buildAssertionSystemPrompt, checkAssertionResult, handleAssertionFailure, handleAssertionSuccess, } from "../device/assertions.js";
|
|
4
4
|
import { isLoadmillInstruction, extractLoadmillCommand, executeLoadmillInstruction, } from "../device/loadmill.js";
|
|
5
5
|
import { logger } from "../utils/logger.js";
|
|
@@ -308,18 +308,6 @@ export class ExecutionMode {
|
|
|
308
308
|
stack: err.stack
|
|
309
309
|
});
|
|
310
310
|
const addOutput = context.addOutput || ((item) => console.log(item.text || item));
|
|
311
|
-
if (isNonRetryableCuaError(err)) {
|
|
312
|
-
const message = `CUA request was rejected by the API: ${err.message}`;
|
|
313
|
-
this.emit(addOutput, 'error', message, context, stepContext, {
|
|
314
|
-
eventType: 'error',
|
|
315
|
-
payload: {
|
|
316
|
-
message: err.message,
|
|
317
|
-
status: err.status,
|
|
318
|
-
type: err.type
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
return { success: false, error: message };
|
|
322
|
-
}
|
|
323
311
|
// Check if we've exceeded max retries
|
|
324
312
|
if (retryCount >= MAX_RETRIES) {
|
|
325
313
|
emitDesktopDebug("reconnect.attempt", "device", {
|