@uipath/eval-tool 1.203.0-preview.205 → 1.204.0-preview.206
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.js
CHANGED
|
@@ -2,11 +2,14 @@ import {
|
|
|
2
2
|
OutputFormatter,
|
|
3
3
|
Pagination,
|
|
4
4
|
RESULTS,
|
|
5
|
+
carriedInstructions,
|
|
5
6
|
catchError,
|
|
7
|
+
extractErrorDetails,
|
|
6
8
|
extractErrorMessage,
|
|
7
9
|
getAuthContext,
|
|
10
|
+
instructionsFor,
|
|
8
11
|
processContext
|
|
9
|
-
} from "./tool-
|
|
12
|
+
} from "./tool-jpgd82xt.js";
|
|
10
13
|
import {
|
|
11
14
|
__require
|
|
12
15
|
} from "./tool-1de529jm.js";
|
|
@@ -15,7 +18,7 @@ var package_default = {
|
|
|
15
18
|
name: "@uipath/eval-tool",
|
|
16
19
|
author: "UiPath",
|
|
17
20
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
18
|
-
version: "1.
|
|
21
|
+
version: "1.204.0-preview.206",
|
|
19
22
|
description: "Manage runtime evaluations, evaluators, eval sets, evaluations, and schedules.",
|
|
20
23
|
private: false,
|
|
21
24
|
repository: {
|
|
@@ -79,6 +82,31 @@ async function resolveEvalAuth(tenant) {
|
|
|
79
82
|
tenantId: ctx.tenantId ?? ""
|
|
80
83
|
};
|
|
81
84
|
}
|
|
85
|
+
|
|
86
|
+
class EvalApiError extends Error {
|
|
87
|
+
status;
|
|
88
|
+
response;
|
|
89
|
+
constructor(method, url, status, statusText, body, headers) {
|
|
90
|
+
super(`${method} ${url} returned ${status}`);
|
|
91
|
+
this.name = "EvalApiError";
|
|
92
|
+
this.status = status;
|
|
93
|
+
this.response = {
|
|
94
|
+
status,
|
|
95
|
+
statusText,
|
|
96
|
+
headers,
|
|
97
|
+
text: () => Promise.resolve(body)
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
class EvalResponseError extends Error {
|
|
103
|
+
instructions;
|
|
104
|
+
constructor(message, instructions) {
|
|
105
|
+
super(message);
|
|
106
|
+
this.name = "EvalResponseError";
|
|
107
|
+
this.instructions = instructions;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
82
110
|
async function evalApiRequest(url, headers, method, body) {
|
|
83
111
|
const response = await fetch(url, {
|
|
84
112
|
method,
|
|
@@ -87,15 +115,14 @@ async function evalApiRequest(url, headers, method, body) {
|
|
|
87
115
|
});
|
|
88
116
|
const text = await response.text();
|
|
89
117
|
if (!response.ok) {
|
|
90
|
-
|
|
91
|
-
throw new Error(`${method} ${url.split("?")[0]} returned ${response.status}: ${text}${hint}`);
|
|
118
|
+
throw new EvalApiError(method, url.split("?")[0] ?? url, response.status, response.statusText, text, response.headers);
|
|
92
119
|
}
|
|
93
120
|
if (!text)
|
|
94
121
|
return {};
|
|
95
122
|
try {
|
|
96
123
|
return JSON.parse(text);
|
|
97
124
|
} catch {
|
|
98
|
-
throw new
|
|
125
|
+
throw new EvalResponseError(`API returned non-JSON response (${response.status}): ${text.slice(0, 200)}`, "The endpoint answered with something other than JSON — check the base URL in use with 'uip whoami' and the service status, then retry.");
|
|
99
126
|
}
|
|
100
127
|
}
|
|
101
128
|
async function resolveEvalAuthOrFail(tenant) {
|
|
@@ -111,19 +138,41 @@ async function resolveEvalAuthOrFail(tenant) {
|
|
|
111
138
|
}
|
|
112
139
|
return auth;
|
|
113
140
|
}
|
|
141
|
+
function evalFailureInstructions(details, fallback, error) {
|
|
142
|
+
if (details.parsedErrors) {
|
|
143
|
+
const flagged = Object.entries(details.parsedErrors).map(([field, messages]) => field === "$" ? messages.join(" ") : `${field}: ${messages.join(" ")}`).join(" ");
|
|
144
|
+
return `The service rejected the request body: ${flagged} Fix the request and retry; Errors carries the same map per field.`;
|
|
145
|
+
}
|
|
146
|
+
const carried = carriedInstructions(error);
|
|
147
|
+
if (carried) {
|
|
148
|
+
return carried;
|
|
149
|
+
}
|
|
150
|
+
if (details.context?.httpStatus === 404) {
|
|
151
|
+
return fallback;
|
|
152
|
+
}
|
|
153
|
+
return instructionsFor("backend", error);
|
|
154
|
+
}
|
|
114
155
|
async function evalApiRequestOrFail(url, headers, method, instructions, body) {
|
|
115
156
|
const [err, data] = await catchError(evalApiRequest(url, headers, method, body));
|
|
116
157
|
if (err) {
|
|
117
|
-
OutputFormatter.error(
|
|
118
|
-
Result: RESULTS.Failure,
|
|
119
|
-
Message: err.message,
|
|
120
|
-
Instructions: instructions
|
|
121
|
-
});
|
|
158
|
+
OutputFormatter.error(await evalFailureEnvelope(err, instructions));
|
|
122
159
|
processContext.exit(1);
|
|
123
160
|
return null;
|
|
124
161
|
}
|
|
125
162
|
return data;
|
|
126
163
|
}
|
|
164
|
+
async function evalFailureEnvelope(error, fallbackInstructions) {
|
|
165
|
+
const details = await extractErrorDetails(error);
|
|
166
|
+
return {
|
|
167
|
+
Result: details.result,
|
|
168
|
+
ErrorCode: details.errorCode,
|
|
169
|
+
Message: details.message,
|
|
170
|
+
Instructions: evalFailureInstructions(details, fallbackInstructions, error),
|
|
171
|
+
Retry: details.retry,
|
|
172
|
+
...details.parsedErrors ? { Errors: details.parsedErrors } : {},
|
|
173
|
+
...details.context ? { Context: details.context } : {}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
127
176
|
function parseIntOrFail(value, flag, min = 0) {
|
|
128
177
|
const n = Number.parseInt(value, 10);
|
|
129
178
|
if (Number.isNaN(n) || n < min) {
|
|
@@ -861,7 +910,7 @@ async function submitRun(evalSetId, items, evaluators, batchSize, agentsApiBase,
|
|
|
861
910
|
};
|
|
862
911
|
const raw = await evalApiRequest(`${agentsApiBase}/unifiedEvals/workloads/executeAndEvaluate`, authHeaders, "POST", body);
|
|
863
912
|
if (raw === null || typeof raw !== "object" || !("evalSetRunId" in raw)) {
|
|
864
|
-
throw new
|
|
913
|
+
throw new EvalResponseError("API response did not contain evalSetRunId. The run may not have been created.", "List the process's runs with 'uip eval run list --process-key <process-key>' to see whether the run was created before submitting it again.");
|
|
865
914
|
}
|
|
866
915
|
return String(raw.evalSetRunId);
|
|
867
916
|
}
|
|
@@ -965,11 +1014,7 @@ async function resolveFromEvalSet(options) {
|
|
|
965
1014
|
const folderKey = options.folderKey ?? evalSet.folderKey;
|
|
966
1015
|
const [submitErr, evalSetRunId] = await catchError(submitRun(evalSetId, items, evaluatorConfigs, batchSize, auth.agentsApiBase, auth.authHeaders, folderKey, auth.tenantId, options.processKey, evalSet.workloadId));
|
|
967
1016
|
if (submitErr) {
|
|
968
|
-
OutputFormatter.error(
|
|
969
|
-
Result: RESULTS.Failure,
|
|
970
|
-
Message: submitErr.message,
|
|
971
|
-
Instructions: "Check that the package is published and the eval set is configured correctly."
|
|
972
|
-
});
|
|
1017
|
+
OutputFormatter.error(await evalFailureEnvelope(submitErr, "Check that the package is published and the eval set is configured correctly."));
|
|
973
1018
|
processContext.exit(1);
|
|
974
1019
|
return;
|
|
975
1020
|
}
|
|
@@ -1023,7 +1068,7 @@ async function resolveInline(options) {
|
|
|
1023
1068
|
folderKey = options.folderKey;
|
|
1024
1069
|
folderLabel = folderKey;
|
|
1025
1070
|
} else {
|
|
1026
|
-
const { createApiClient, PersonalWorkspacesApi } = await import("./index-
|
|
1071
|
+
const { createApiClient, PersonalWorkspacesApi } = await import("./index-ynehe0js.js");
|
|
1027
1072
|
const [wsApiErr, wsApi] = await catchError(createApiClient(PersonalWorkspacesApi, {
|
|
1028
1073
|
tenant: options.tenant
|
|
1029
1074
|
}));
|
|
@@ -1059,11 +1104,7 @@ async function resolveInline(options) {
|
|
|
1059
1104
|
const evalSetId = options.evalSetId ?? ZERO_GUID;
|
|
1060
1105
|
const [submitErr, evalSetRunId] = await catchError(submitRun(evalSetId, items, evaluators, batchSize, auth.agentsApiBase, auth.authHeaders, folderKey, auth.tenantId, options.processKey, options.workloadId));
|
|
1061
1106
|
if (submitErr) {
|
|
1062
|
-
OutputFormatter.error(
|
|
1063
|
-
Result: RESULTS.Failure,
|
|
1064
|
-
Message: submitErr.message,
|
|
1065
|
-
Instructions: "Check that the package is published and the eval set ID is correct."
|
|
1066
|
-
});
|
|
1107
|
+
OutputFormatter.error(await evalFailureEnvelope(submitErr, "Check that the package is published and the eval set ID is correct."));
|
|
1067
1108
|
processContext.exit(1);
|
|
1068
1109
|
return;
|
|
1069
1110
|
}
|
|
@@ -1326,6 +1367,7 @@ function formatEvalSet(es) {
|
|
|
1326
1367
|
Description: es.description ?? "",
|
|
1327
1368
|
Version: es.version ?? "-",
|
|
1328
1369
|
BatchSize: es.batchSize ?? "-",
|
|
1370
|
+
TimeoutMinutes: es.timeoutMinutes ?? "-",
|
|
1329
1371
|
EvaluatorRefs: es.evaluatorRefs,
|
|
1330
1372
|
CreatedAt: es.createdAt,
|
|
1331
1373
|
...es.updatedAt ? { UpdatedAt: es.updatedAt } : {}
|
|
@@ -1593,4 +1635,4 @@ var registerCommands = async (program) => {
|
|
|
1593
1635
|
|
|
1594
1636
|
export { metadata, registerCommands };
|
|
1595
1637
|
|
|
1596
|
-
//# debugId=
|
|
1638
|
+
//# debugId=3A36BD658832390564756E2164756E21
|