@uipath/codedagent-tool 1.205.0-preview.276 → 1.206.0-preview.279
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 +34 -6
- package/dist/{index-sby22td6.js → index-nzr4mx5p.js} +2 -22
- package/dist/index.js +8 -9
- package/dist/init.js +4 -5
- package/dist/{jmespath-231m3hyn.js → jmespath-ab6tdc42.js} +1 -1
- package/dist/{js-yaml-88tdqrtd.js → js-yaml-a2bk27p6.js} +1 -3
- package/dist/{tool-sdc09fzm.js → tool-6yj9cwz2.js} +38 -43
- package/dist/{tool-kh9ddkna.js → tool-dzz670n8.js} +1615 -586
- package/dist/{tool-1de529jm.js → tool-epsr41wx.js} +12 -3
- package/dist/tool.js +7 -8
- package/package.json +2 -2
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
__toESM,
|
|
2
3
|
__commonJS,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./tool-
|
|
4
|
+
__exportCjs,
|
|
5
|
+
__require
|
|
6
|
+
} from "./tool-epsr41wx.js";
|
|
6
7
|
|
|
7
8
|
// ../../node_modules/commander/lib/error.js
|
|
8
9
|
var require_error = __commonJS(function(exports) {
|
|
@@ -124,7 +125,7 @@ var require_help = __commonJS(function(exports) {
|
|
|
124
125
|
this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
|
|
125
126
|
}
|
|
126
127
|
visibleCommands(cmd) {
|
|
127
|
-
const visibleCommands = cmd.commands.filter((
|
|
128
|
+
const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);
|
|
128
129
|
const helpCommand = cmd._getHelpCommand();
|
|
129
130
|
if (helpCommand && !helpCommand._hidden) {
|
|
130
131
|
visibleCommands.push(helpCommand);
|
|
@@ -604,8 +605,8 @@ var require_option = __commonJS(function(exports) {
|
|
|
604
605
|
}
|
|
605
606
|
}
|
|
606
607
|
function camelcase(str) {
|
|
607
|
-
return str.split("-").reduce((
|
|
608
|
-
return
|
|
608
|
+
return str.split("-").reduce((str, word) => {
|
|
609
|
+
return str + word[0].toUpperCase() + word.slice(1);
|
|
609
610
|
});
|
|
610
611
|
}
|
|
611
612
|
function splitOptionFlags(flags) {
|
|
@@ -1176,44 +1177,44 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1176
1177
|
});
|
|
1177
1178
|
return source;
|
|
1178
1179
|
}
|
|
1179
|
-
_prepareUserArgs(
|
|
1180
|
-
if (
|
|
1180
|
+
_prepareUserArgs(argv2, parseOptions) {
|
|
1181
|
+
if (argv2 !== undefined && !Array.isArray(argv2)) {
|
|
1181
1182
|
throw new Error("first parameter to parse must be array or undefined");
|
|
1182
1183
|
}
|
|
1183
1184
|
parseOptions = parseOptions || {};
|
|
1184
|
-
if (
|
|
1185
|
+
if (argv2 === undefined && parseOptions.from === undefined) {
|
|
1185
1186
|
if (process2.versions?.electron) {
|
|
1186
1187
|
parseOptions.from = "electron";
|
|
1187
1188
|
}
|
|
1188
|
-
const
|
|
1189
|
-
if (
|
|
1189
|
+
const execArgv2 = process2.execArgv ?? [];
|
|
1190
|
+
if (execArgv2.includes("-e") || execArgv2.includes("--eval") || execArgv2.includes("-p") || execArgv2.includes("--print")) {
|
|
1190
1191
|
parseOptions.from = "eval";
|
|
1191
1192
|
}
|
|
1192
1193
|
}
|
|
1193
|
-
if (
|
|
1194
|
-
|
|
1194
|
+
if (argv2 === undefined) {
|
|
1195
|
+
argv2 = process2.argv;
|
|
1195
1196
|
}
|
|
1196
|
-
this.rawArgs =
|
|
1197
|
+
this.rawArgs = argv2.slice();
|
|
1197
1198
|
let userArgs;
|
|
1198
1199
|
switch (parseOptions.from) {
|
|
1199
1200
|
case undefined:
|
|
1200
1201
|
case "node":
|
|
1201
|
-
this._scriptPath =
|
|
1202
|
-
userArgs =
|
|
1202
|
+
this._scriptPath = argv2[1];
|
|
1203
|
+
userArgs = argv2.slice(2);
|
|
1203
1204
|
break;
|
|
1204
1205
|
case "electron":
|
|
1205
1206
|
if (process2.defaultApp) {
|
|
1206
|
-
this._scriptPath =
|
|
1207
|
-
userArgs =
|
|
1207
|
+
this._scriptPath = argv2[1];
|
|
1208
|
+
userArgs = argv2.slice(2);
|
|
1208
1209
|
} else {
|
|
1209
|
-
userArgs =
|
|
1210
|
+
userArgs = argv2.slice(1);
|
|
1210
1211
|
}
|
|
1211
1212
|
break;
|
|
1212
1213
|
case "user":
|
|
1213
|
-
userArgs =
|
|
1214
|
+
userArgs = argv2.slice(0);
|
|
1214
1215
|
break;
|
|
1215
1216
|
case "eval":
|
|
1216
|
-
userArgs =
|
|
1217
|
+
userArgs = argv2.slice(1);
|
|
1217
1218
|
break;
|
|
1218
1219
|
default:
|
|
1219
1220
|
throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
|
|
@@ -1736,18 +1737,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1736
1737
|
this.error(message, { code: "commander.missingMandatoryOptionValue" });
|
|
1737
1738
|
}
|
|
1738
1739
|
_conflictingOption(option, conflictingOption) {
|
|
1739
|
-
const findBestOptionFromValue = (
|
|
1740
|
-
const optionKey =
|
|
1740
|
+
const findBestOptionFromValue = (option) => {
|
|
1741
|
+
const optionKey = option.attributeName();
|
|
1741
1742
|
const optionValue = this.getOptionValue(optionKey);
|
|
1742
1743
|
const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
|
|
1743
1744
|
const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
|
|
1744
1745
|
if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
|
|
1745
1746
|
return negativeOption;
|
|
1746
1747
|
}
|
|
1747
|
-
return positiveOption ||
|
|
1748
|
+
return positiveOption || option;
|
|
1748
1749
|
};
|
|
1749
|
-
const getErrorMessage = (
|
|
1750
|
-
const bestOption = findBestOptionFromValue(
|
|
1750
|
+
const getErrorMessage = (option) => {
|
|
1751
|
+
const bestOption = findBestOptionFromValue(option);
|
|
1751
1752
|
const optionKey = bestOption.attributeName();
|
|
1752
1753
|
const source = this.getOptionValueSource(optionKey);
|
|
1753
1754
|
if (source === "env") {
|
|
@@ -1901,10 +1902,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1901
1902
|
this._name = path.basename(filename, path.extname(filename));
|
|
1902
1903
|
return this;
|
|
1903
1904
|
}
|
|
1904
|
-
executableDir(
|
|
1905
|
-
if (
|
|
1905
|
+
executableDir(path) {
|
|
1906
|
+
if (path === undefined)
|
|
1906
1907
|
return this._executableDir;
|
|
1907
|
-
this._executableDir =
|
|
1908
|
+
this._executableDir = path;
|
|
1908
1909
|
return this;
|
|
1909
1910
|
}
|
|
1910
1911
|
helpInformation(contextOptions) {
|
|
@@ -2001,11 +2002,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2001
2002
|
}
|
|
2002
2003
|
help(contextOptions) {
|
|
2003
2004
|
this.outputHelp(contextOptions);
|
|
2004
|
-
let
|
|
2005
|
-
if (
|
|
2006
|
-
|
|
2005
|
+
let exitCode2 = Number(process2.exitCode ?? 0);
|
|
2006
|
+
if (exitCode2 === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
2007
|
+
exitCode2 = 1;
|
|
2007
2008
|
}
|
|
2008
|
-
this._exit(
|
|
2009
|
+
this._exit(exitCode2, "commander.help", "(outputHelp)");
|
|
2009
2010
|
}
|
|
2010
2011
|
addHelpText(position, text) {
|
|
2011
2012
|
const allowedValues = ["beforeAll", "before", "after", "afterAll"];
|
|
@@ -2077,26 +2078,6 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2077
2078
|
exports.useColor = useColor;
|
|
2078
2079
|
});
|
|
2079
2080
|
|
|
2080
|
-
// ../../node_modules/commander/index.js
|
|
2081
|
-
var require_commander = __commonJS(function(exports) {
|
|
2082
|
-
var { Argument } = require_argument();
|
|
2083
|
-
var { Command } = require_command();
|
|
2084
|
-
var { CommanderError, InvalidArgumentError } = require_error();
|
|
2085
|
-
var { Help } = require_help();
|
|
2086
|
-
var { Option } = require_option();
|
|
2087
|
-
exports.program = new Command;
|
|
2088
|
-
exports.createCommand = (name) => new Command(name);
|
|
2089
|
-
exports.createOption = (flags, description) => new Option(flags, description);
|
|
2090
|
-
exports.createArgument = (name, description) => new Argument(name, description);
|
|
2091
|
-
exports.Command = Command;
|
|
2092
|
-
exports.Option = Option;
|
|
2093
|
-
exports.Argument = Argument;
|
|
2094
|
-
exports.Help = Help;
|
|
2095
|
-
exports.CommanderError = CommanderError;
|
|
2096
|
-
exports.InvalidArgumentError = InvalidArgumentError;
|
|
2097
|
-
exports.InvalidOptionArgumentError = InvalidArgumentError;
|
|
2098
|
-
});
|
|
2099
|
-
|
|
2100
2081
|
// ../common/src/telemetry/telemetry-dimensions.ts
|
|
2101
2082
|
var BaseDimensions = {
|
|
2102
2083
|
ApplicationName: "ApplicationName",
|
|
@@ -2132,6 +2113,21 @@ var CommandDimensions = {
|
|
|
2132
2113
|
ProductArea: "ProductArea",
|
|
2133
2114
|
Mode: "Mode"
|
|
2134
2115
|
};
|
|
2116
|
+
var ProjectDimensions = {
|
|
2117
|
+
ProjectKey: "ProjectKey",
|
|
2118
|
+
ProjectType: "ProjectType",
|
|
2119
|
+
ProjectIdentityStatus: "ProjectIdentityStatus",
|
|
2120
|
+
SolutionKey: "SolutionKey",
|
|
2121
|
+
SolutionProjectKey: "SolutionProjectKey",
|
|
2122
|
+
SolutionIdentityStatus: "SolutionIdentityStatus",
|
|
2123
|
+
PreviousSolutionKey: "PreviousSolutionKey"
|
|
2124
|
+
};
|
|
2125
|
+
var GUID_KEY_DIMENSIONS = new Set([
|
|
2126
|
+
ProjectDimensions.ProjectKey,
|
|
2127
|
+
ProjectDimensions.SolutionKey,
|
|
2128
|
+
ProjectDimensions.SolutionProjectKey,
|
|
2129
|
+
ProjectDimensions.PreviousSolutionKey
|
|
2130
|
+
]);
|
|
2135
2131
|
var ShipDimensions = {
|
|
2136
2132
|
ShipKind: "ShipKind",
|
|
2137
2133
|
Target: "Target",
|
|
@@ -2200,6 +2196,7 @@ var RESERVED_DIMENSION_NAMES = new Set([
|
|
|
2200
2196
|
...Object.values(BaseDimensions),
|
|
2201
2197
|
...Object.values(CommandDimensions),
|
|
2202
2198
|
...Object.values(ShipDimensions),
|
|
2199
|
+
...Object.values(ProjectDimensions),
|
|
2203
2200
|
...Object.values(ErrorDimensions),
|
|
2204
2201
|
...Object.values(AuthDimensions),
|
|
2205
2202
|
...Object.values(SkillsDimensions),
|
|
@@ -2225,7 +2222,8 @@ var CURATED_DIMENSIONS = new Set([
|
|
|
2225
2222
|
BaseDimensions.SessionIdSource,
|
|
2226
2223
|
BaseDimensions.SessionId,
|
|
2227
2224
|
...Object.values(CommandDimensions),
|
|
2228
|
-
...Object.values(ShipDimensions)
|
|
2225
|
+
...Object.values(ShipDimensions),
|
|
2226
|
+
...Object.values(ProjectDimensions)
|
|
2229
2227
|
]);
|
|
2230
2228
|
function lowercaseIdDimensionValues(properties) {
|
|
2231
2229
|
let changed = false;
|
|
@@ -2246,21 +2244,100 @@ function lowercaseIdDimensionValues(properties) {
|
|
|
2246
2244
|
return changed ? result : properties;
|
|
2247
2245
|
}
|
|
2248
2246
|
|
|
2247
|
+
// ../../node_modules/commander/index.js
|
|
2248
|
+
var exports_commander = {};
|
|
2249
|
+
__exportCjs(exports_commander, {
|
|
2250
|
+
program: () => $program,
|
|
2251
|
+
createCommand: () => $createCommand,
|
|
2252
|
+
createOption: () => $createOption,
|
|
2253
|
+
createArgument: () => $createArgument,
|
|
2254
|
+
Command: () => $Command,
|
|
2255
|
+
Option: () => $Option,
|
|
2256
|
+
Argument: () => $Argument,
|
|
2257
|
+
Help: () => $Help,
|
|
2258
|
+
CommanderError: () => $CommanderError,
|
|
2259
|
+
InvalidArgumentError: () => $InvalidArgumentError,
|
|
2260
|
+
InvalidOptionArgumentError: () => $InvalidOptionArgumentError
|
|
2261
|
+
}, {
|
|
2262
|
+
program: (value) => $program = value,
|
|
2263
|
+
createCommand: (value) => $createCommand = value,
|
|
2264
|
+
createOption: (value) => $createOption = value,
|
|
2265
|
+
createArgument: (value) => $createArgument = value,
|
|
2266
|
+
Command: (value) => $Command = value,
|
|
2267
|
+
Option: (value) => $Option = value,
|
|
2268
|
+
Argument: (value) => $Argument = value,
|
|
2269
|
+
Help: (value) => $Help = value,
|
|
2270
|
+
CommanderError: (value) => $CommanderError = value,
|
|
2271
|
+
InvalidArgumentError: (value) => $InvalidArgumentError = value,
|
|
2272
|
+
InvalidOptionArgumentError: (value) => $InvalidOptionArgumentError = value
|
|
2273
|
+
});
|
|
2274
|
+
var { Argument } = require_argument();
|
|
2275
|
+
var { Command: Command2 } = require_command();
|
|
2276
|
+
var { CommanderError, InvalidArgumentError } = require_error();
|
|
2277
|
+
var { Help } = require_help();
|
|
2278
|
+
var { Option } = require_option();
|
|
2279
|
+
var $program = new Command2;
|
|
2280
|
+
var $createCommand = (name) => new Command2(name);
|
|
2281
|
+
var $createOption = (flags, description) => new Option(flags, description);
|
|
2282
|
+
var $createArgument = (name, description) => new Argument(name, description);
|
|
2283
|
+
var $Command = Command2;
|
|
2284
|
+
var $Option = Option;
|
|
2285
|
+
var $Argument = Argument;
|
|
2286
|
+
var $Help = Help;
|
|
2287
|
+
var $CommanderError = CommanderError;
|
|
2288
|
+
var $InvalidArgumentError = InvalidArgumentError;
|
|
2289
|
+
var $InvalidOptionArgumentError = InvalidArgumentError;
|
|
2290
|
+
|
|
2249
2291
|
// ../../node_modules/commander/esm.mjs
|
|
2250
|
-
var import__ = __toESM(require_commander(), 1);
|
|
2251
2292
|
var {
|
|
2252
2293
|
program,
|
|
2253
2294
|
createCommand,
|
|
2254
2295
|
createArgument,
|
|
2255
2296
|
createOption,
|
|
2256
|
-
CommanderError,
|
|
2257
|
-
InvalidArgumentError,
|
|
2297
|
+
CommanderError: CommanderError2,
|
|
2298
|
+
InvalidArgumentError: InvalidArgumentError2,
|
|
2258
2299
|
InvalidOptionArgumentError,
|
|
2259
2300
|
Command,
|
|
2260
|
-
Argument,
|
|
2261
|
-
Option,
|
|
2262
|
-
Help
|
|
2263
|
-
} =
|
|
2301
|
+
Argument: Argument2,
|
|
2302
|
+
Option: Option2,
|
|
2303
|
+
Help: Help2
|
|
2304
|
+
} = exports_commander;
|
|
2305
|
+
|
|
2306
|
+
// ../common/src/telemetry/project-identity.ts
|
|
2307
|
+
function projectKey(id) {
|
|
2308
|
+
if (typeof id !== "string")
|
|
2309
|
+
return;
|
|
2310
|
+
const key = id.trim().toLowerCase().replaceAll("-", "");
|
|
2311
|
+
return /^[0-9a-f]{32}$/.test(key) ? key : undefined;
|
|
2312
|
+
}
|
|
2313
|
+
function projectIdentityProperties(identity) {
|
|
2314
|
+
const key = identity.id ? projectKey(identity.id) : undefined;
|
|
2315
|
+
return {
|
|
2316
|
+
[ProjectDimensions.ProjectIdentityStatus]: identity.status === "resolved" && !key ? "invalid" : identity.status,
|
|
2317
|
+
[ProjectDimensions.ProjectType]: identity.projectType,
|
|
2318
|
+
...identity.status === "resolved" && key ? {
|
|
2319
|
+
[ProjectDimensions.ProjectKey]: key
|
|
2320
|
+
} : {}
|
|
2321
|
+
};
|
|
2322
|
+
}
|
|
2323
|
+
var PROJECT_IDENTITY_LOOKUP_BUDGET_MS = 1000;
|
|
2324
|
+
async function withinProjectIdentityBudget(work, onTimeout) {
|
|
2325
|
+
work.catch(() => {
|
|
2326
|
+
return;
|
|
2327
|
+
});
|
|
2328
|
+
let timer;
|
|
2329
|
+
const expired = new Promise((resolve) => {
|
|
2330
|
+
timer = setTimeout(() => {
|
|
2331
|
+
onTimeout?.();
|
|
2332
|
+
resolve(undefined);
|
|
2333
|
+
}, PROJECT_IDENTITY_LOOKUP_BUDGET_MS);
|
|
2334
|
+
});
|
|
2335
|
+
try {
|
|
2336
|
+
return await Promise.race([work, expired]);
|
|
2337
|
+
} finally {
|
|
2338
|
+
clearTimeout(timer);
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2264
2341
|
|
|
2265
2342
|
// ../common/src/telemetry/pseudonymize.ts
|
|
2266
2343
|
var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
|
|
@@ -2725,6 +2802,8 @@ function redactProperty(name, value) {
|
|
|
2725
2802
|
if (isSensitiveName(name)) {
|
|
2726
2803
|
return REDACTED;
|
|
2727
2804
|
}
|
|
2805
|
+
if (GUID_KEY_DIMENSIONS.has(name))
|
|
2806
|
+
return projectKey(value);
|
|
2728
2807
|
if (typeof value === "boolean" || typeof value === "number") {
|
|
2729
2808
|
return value;
|
|
2730
2809
|
}
|
|
@@ -2799,9 +2878,139 @@ function settlePromiseLike(thenable) {
|
|
|
2799
2878
|
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
|
|
2800
2879
|
}
|
|
2801
2880
|
|
|
2802
|
-
// ../common/src/
|
|
2803
|
-
|
|
2804
|
-
|
|
2881
|
+
// ../common/src/error-codes.ts
|
|
2882
|
+
var CLI_ERROR_CODES = [
|
|
2883
|
+
"invalid_argument",
|
|
2884
|
+
"authentication_required",
|
|
2885
|
+
"permission_denied",
|
|
2886
|
+
"local_permission_denied",
|
|
2887
|
+
"not_found",
|
|
2888
|
+
"rate_limited",
|
|
2889
|
+
"network_error",
|
|
2890
|
+
"timeout",
|
|
2891
|
+
"server_error",
|
|
2892
|
+
"method_not_allowed",
|
|
2893
|
+
"not_supported",
|
|
2894
|
+
"configuration_error",
|
|
2895
|
+
"execution_failed",
|
|
2896
|
+
"unknown_error"
|
|
2897
|
+
];
|
|
2898
|
+
var RETRY_HINTS = [
|
|
2899
|
+
"RetryWillNotFix",
|
|
2900
|
+
"RetryLater",
|
|
2901
|
+
"RetryAfter1Second",
|
|
2902
|
+
"RetryAfter10Seconds",
|
|
2903
|
+
"RetryAfter30Seconds",
|
|
2904
|
+
"RetryAfter60Seconds"
|
|
2905
|
+
];
|
|
2906
|
+
var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
|
|
2907
|
+
var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
|
|
2908
|
+
function isCliErrorCode(value) {
|
|
2909
|
+
return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
|
|
2910
|
+
}
|
|
2911
|
+
function isRetryHint(value) {
|
|
2912
|
+
return typeof value === "string" && RETRY_HINT_VALUES.has(value);
|
|
2913
|
+
}
|
|
2914
|
+
function carriedErrorCode(error) {
|
|
2915
|
+
if (!error || typeof error !== "object")
|
|
2916
|
+
return;
|
|
2917
|
+
const code = error.errorCode;
|
|
2918
|
+
return isCliErrorCode(code) ? code : undefined;
|
|
2919
|
+
}
|
|
2920
|
+
function carriedRetry(error) {
|
|
2921
|
+
if (!error || typeof error !== "object")
|
|
2922
|
+
return;
|
|
2923
|
+
const retry = error.retry;
|
|
2924
|
+
return isRetryHint(retry) ? retry : undefined;
|
|
2925
|
+
}
|
|
2926
|
+
function defaultRetryForErrorCode(errorCode) {
|
|
2927
|
+
switch (errorCode) {
|
|
2928
|
+
case "network_error":
|
|
2929
|
+
case "rate_limited":
|
|
2930
|
+
case "server_error":
|
|
2931
|
+
case "timeout":
|
|
2932
|
+
return "RetryLater";
|
|
2933
|
+
default:
|
|
2934
|
+
return "RetryWillNotFix";
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
// ../common/src/error-graph.ts
|
|
2939
|
+
function* walkErrorGraph(error) {
|
|
2940
|
+
const queue = [error];
|
|
2941
|
+
const seen = new Set;
|
|
2942
|
+
for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
|
|
2943
|
+
const current = queue.shift();
|
|
2944
|
+
if (current === null || typeof current !== "object")
|
|
2945
|
+
continue;
|
|
2946
|
+
if (seen.has(current))
|
|
2947
|
+
continue;
|
|
2948
|
+
seen.add(current);
|
|
2949
|
+
const cur = current;
|
|
2950
|
+
yield cur;
|
|
2951
|
+
if (cur.cause !== undefined)
|
|
2952
|
+
queue.push(cur.cause);
|
|
2953
|
+
if (Array.isArray(cur.errors))
|
|
2954
|
+
queue.push(...cur.errors);
|
|
2955
|
+
}
|
|
2956
|
+
return;
|
|
2957
|
+
}
|
|
2958
|
+
function parseHttpStatusFromMessage(message) {
|
|
2959
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
2960
|
+
if (!match)
|
|
2961
|
+
return;
|
|
2962
|
+
const status = Number(match[1]);
|
|
2963
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
2964
|
+
}
|
|
2965
|
+
function findHttpStatusInGraph(error) {
|
|
2966
|
+
for (const node of walkErrorGraph(error)) {
|
|
2967
|
+
const response = node.response;
|
|
2968
|
+
const explicit = typeof node.status === "number" ? node.status : response?.status;
|
|
2969
|
+
if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
|
|
2970
|
+
return explicit;
|
|
2971
|
+
}
|
|
2972
|
+
if (typeof node.message === "string") {
|
|
2973
|
+
const parsed = parseHttpStatusFromMessage(node.message);
|
|
2974
|
+
if (parsed !== undefined && parsed >= 400) {
|
|
2975
|
+
return parsed;
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
return;
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2982
|
+
// ../common/src/http-status.ts
|
|
2983
|
+
function classifyHttpStatus(status) {
|
|
2984
|
+
if (status === undefined)
|
|
2985
|
+
return;
|
|
2986
|
+
if (status === 400 || status === 409 || status === 413 || status === 422) {
|
|
2987
|
+
return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
|
|
2988
|
+
}
|
|
2989
|
+
if (status === 401) {
|
|
2990
|
+
return {
|
|
2991
|
+
errorCode: "authentication_required",
|
|
2992
|
+
retry: "RetryWillNotFix"
|
|
2993
|
+
};
|
|
2994
|
+
}
|
|
2995
|
+
if (status === 403) {
|
|
2996
|
+
return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
|
|
2997
|
+
}
|
|
2998
|
+
if (status === 404) {
|
|
2999
|
+
return { errorCode: "not_found", retry: "RetryWillNotFix" };
|
|
3000
|
+
}
|
|
3001
|
+
if (status === 405) {
|
|
3002
|
+
return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
|
|
3003
|
+
}
|
|
3004
|
+
if (status === 408) {
|
|
3005
|
+
return { errorCode: "timeout", retry: "RetryLater" };
|
|
3006
|
+
}
|
|
3007
|
+
if (status === 429) {
|
|
3008
|
+
return { errorCode: "rate_limited", retry: "RetryLater" };
|
|
3009
|
+
}
|
|
3010
|
+
if (status >= 500 && status < 600) {
|
|
3011
|
+
return { errorCode: "server_error", retry: "RetryLater" };
|
|
3012
|
+
}
|
|
3013
|
+
return;
|
|
2805
3014
|
}
|
|
2806
3015
|
|
|
2807
3016
|
// ../common/src/local-permission-codes.ts
|
|
@@ -2811,8 +3020,371 @@ var LOCAL_PERMISSION_ERROR_CODES = new Set([
|
|
|
2811
3020
|
"EROFS"
|
|
2812
3021
|
]);
|
|
2813
3022
|
|
|
3023
|
+
// ../common/src/error-handler.ts
|
|
3024
|
+
var DEFAULT_401 = "Unauthorized (401). The session is missing or expired, or its token carries no scope for this API. Run `uip login status --detailed` to see the session and its scopes.";
|
|
3025
|
+
var DEFAULT_403 = "Forbidden (403). The account lacks permission for this operation, or the token carries no scope for this API. Run `uip login status --detailed` to see the token's scopes.";
|
|
3026
|
+
var DEFAULT_405 = "Method Not Allowed (405). The endpoint may not exist or the base URL may be incorrect.";
|
|
3027
|
+
var DEFAULT_413 = "Payload too large (413). The upload exceeded the server or CDN size limit. Reduce the package size — for example, exclude unused dependencies or remove large files from the project — and try again.";
|
|
3028
|
+
var CLOUDFLARE_BLOCK_403 = "Forbidden (403) by Cloudflare, in front of the service: the answer is a Cloudflare HTML page, not the service's JSON, so the service did not see the request and did not check the account's roles or the token's scopes. Cloudflare blocks a request when its content matches a firewall rule (text that looks like SQL or script code, for example) or when it comes from a network the firewall does not allow.";
|
|
3029
|
+
var CLOUDFLARE_BLOCK_403_INSTRUCTIONS = "If the request carries text that looks like code, change that text and try again. Otherwise send the time of the request and the Cloudflare Ray ID, when the message gives one, to the owner of the service or UiPath support.";
|
|
3030
|
+
var HTML_RESPONSE_MESSAGE = "Received HTML instead of the expected JSON response.";
|
|
3031
|
+
var NETWORK_ERROR_CODES = new Set([
|
|
3032
|
+
"ECONNREFUSED",
|
|
3033
|
+
"ECONNRESET",
|
|
3034
|
+
"ENOTFOUND",
|
|
3035
|
+
"EAI_AGAIN",
|
|
3036
|
+
"ETIMEDOUT",
|
|
3037
|
+
"EPIPE",
|
|
3038
|
+
"EHOSTUNREACH",
|
|
3039
|
+
"ENETUNREACH",
|
|
3040
|
+
"EAI_FAIL"
|
|
3041
|
+
]);
|
|
3042
|
+
var TLS_ERROR_CODES = new Set([
|
|
3043
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
3044
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
3045
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
3046
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
3047
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
3048
|
+
"CERT_HAS_EXPIRED",
|
|
3049
|
+
"CERT_UNTRUSTED",
|
|
3050
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
3051
|
+
]);
|
|
3052
|
+
var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
|
|
3053
|
+
var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
|
|
3054
|
+
var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
|
|
3055
|
+
function localPermissionInstructions(code, path) {
|
|
3056
|
+
const target = path !== undefined ? `'${path}'` : "a local file or resource";
|
|
3057
|
+
if (code === "EROFS") {
|
|
3058
|
+
return `The filesystem containing ${target} is read-only (EROFS), so the ` + "CLI could not write to it. This is a local environment problem, " + "not a UiPath service error — retrying will not help. Use a " + "writable location, or give this environment write access to the " + "path.";
|
|
3059
|
+
}
|
|
3060
|
+
const onWindows = typeof process !== "undefined" && process.platform === "win32";
|
|
3061
|
+
const remedy = onWindows ? "Re-run from an elevated terminal, close any program holding " + "the file open, or grant your user access to the path." : "Grant this user (or the sandbox the command runs in) access " + "to the path, or run the command outside the sandbox.";
|
|
3062
|
+
return `The operating system denied access to ${target} (${code}). This is ` + "a local permission problem, not a UiPath service error — retrying " + `without a permission change will not help. ${remedy}`;
|
|
3063
|
+
}
|
|
3064
|
+
function describeConnectivityError(error) {
|
|
3065
|
+
for (const cur of walkErrorGraph(error)) {
|
|
3066
|
+
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
3067
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
3068
|
+
if (code && TLS_ERROR_CODES.has(code)) {
|
|
3069
|
+
return {
|
|
3070
|
+
code,
|
|
3071
|
+
kind: "tls",
|
|
3072
|
+
message: message ?? code,
|
|
3073
|
+
instructions: TLS_INSTRUCTIONS
|
|
3074
|
+
};
|
|
3075
|
+
}
|
|
3076
|
+
if (code && NETWORK_ERROR_CODES.has(code)) {
|
|
3077
|
+
return {
|
|
3078
|
+
code,
|
|
3079
|
+
kind: "network",
|
|
3080
|
+
message: message ?? code,
|
|
3081
|
+
instructions: NETWORK_INSTRUCTIONS
|
|
3082
|
+
};
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
return;
|
|
3086
|
+
}
|
|
3087
|
+
function describePermissionError(error) {
|
|
3088
|
+
for (const cur of walkErrorGraph(error)) {
|
|
3089
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
3090
|
+
const code = matchLocalPermissionCode(cur.code, message);
|
|
3091
|
+
if (!code)
|
|
3092
|
+
continue;
|
|
3093
|
+
const path = localPermissionPath(cur.path, message);
|
|
3094
|
+
return {
|
|
3095
|
+
code,
|
|
3096
|
+
message: message ?? code,
|
|
3097
|
+
...path !== undefined ? { path } : {},
|
|
3098
|
+
instructions: localPermissionInstructions(code, path)
|
|
3099
|
+
};
|
|
3100
|
+
}
|
|
3101
|
+
return;
|
|
3102
|
+
}
|
|
3103
|
+
function matchLocalPermissionCode(code, message) {
|
|
3104
|
+
if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
|
|
3105
|
+
return code;
|
|
3106
|
+
}
|
|
3107
|
+
const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
|
|
3108
|
+
return match ? match[1] : undefined;
|
|
3109
|
+
}
|
|
3110
|
+
function localPermissionPath(path, message) {
|
|
3111
|
+
if (typeof path === "string")
|
|
3112
|
+
return path;
|
|
3113
|
+
return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
|
|
3114
|
+
}
|
|
3115
|
+
function readHeader(response, name) {
|
|
3116
|
+
const headers = response?.headers;
|
|
3117
|
+
if (!headers || typeof headers !== "object")
|
|
3118
|
+
return;
|
|
3119
|
+
if (typeof headers.get === "function") {
|
|
3120
|
+
const value = headers.get(name);
|
|
3121
|
+
if (value)
|
|
3122
|
+
return value;
|
|
3123
|
+
}
|
|
3124
|
+
const plain = headers;
|
|
3125
|
+
const key = Object.keys(plain).find((k) => k.toLowerCase() === name.toLowerCase());
|
|
3126
|
+
const value = key === undefined ? undefined : plain[key];
|
|
3127
|
+
return typeof value === "string" && value !== "" ? value : undefined;
|
|
3128
|
+
}
|
|
3129
|
+
function isHtmlDocument(body) {
|
|
3130
|
+
return /^\s*(<!doctype html|<html\b)/i.test(body);
|
|
3131
|
+
}
|
|
3132
|
+
function retryHintForRetryAfter(seconds) {
|
|
3133
|
+
if (seconds <= 1) {
|
|
3134
|
+
return "RetryAfter1Second";
|
|
3135
|
+
}
|
|
3136
|
+
if (seconds <= 10) {
|
|
3137
|
+
return "RetryAfter10Seconds";
|
|
3138
|
+
}
|
|
3139
|
+
if (seconds <= 30) {
|
|
3140
|
+
return "RetryAfter30Seconds";
|
|
3141
|
+
}
|
|
3142
|
+
return "RetryAfter60Seconds";
|
|
3143
|
+
}
|
|
3144
|
+
function classifyError(status, error) {
|
|
3145
|
+
const byStatus = classifyHttpStatus(status);
|
|
3146
|
+
if (byStatus)
|
|
3147
|
+
return byStatus;
|
|
3148
|
+
if (status === undefined && describePermissionError(error)) {
|
|
3149
|
+
return {
|
|
3150
|
+
errorCode: "local_permission_denied",
|
|
3151
|
+
retry: "RetryWillNotFix"
|
|
3152
|
+
};
|
|
3153
|
+
}
|
|
3154
|
+
const connectivity = describeConnectivityError(error);
|
|
3155
|
+
if (connectivity) {
|
|
3156
|
+
return {
|
|
3157
|
+
errorCode: "network_error",
|
|
3158
|
+
retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
|
|
3159
|
+
};
|
|
3160
|
+
}
|
|
3161
|
+
return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
|
|
3162
|
+
}
|
|
3163
|
+
function withCarriedClass(inferred, error) {
|
|
3164
|
+
const errorCode = carriedErrorCode(error);
|
|
3165
|
+
const retry = carriedRetry(error);
|
|
3166
|
+
if (errorCode === undefined || errorCode === inferred.errorCode) {
|
|
3167
|
+
return {
|
|
3168
|
+
errorCode: inferred.errorCode,
|
|
3169
|
+
retry: retry ?? inferred.retry
|
|
3170
|
+
};
|
|
3171
|
+
}
|
|
3172
|
+
return { errorCode, retry: retry ?? defaultRetryForErrorCode(errorCode) };
|
|
3173
|
+
}
|
|
3174
|
+
function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
|
|
3175
|
+
if (extractedMessage) {
|
|
3176
|
+
return `HTTP ${status}: ${extractedMessage}`;
|
|
3177
|
+
}
|
|
3178
|
+
return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
|
|
3179
|
+
}
|
|
3180
|
+
async function extractErrorDetails(error, options) {
|
|
3181
|
+
const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
|
|
3182
|
+
const response = err.response;
|
|
3183
|
+
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
3184
|
+
const explicitStatus = err.status ?? response?.status;
|
|
3185
|
+
const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
|
|
3186
|
+
const status = explicitStatus ?? inferredStatus;
|
|
3187
|
+
const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
|
|
3188
|
+
let rawBody;
|
|
3189
|
+
let extractedMessage;
|
|
3190
|
+
let parsedBody;
|
|
3191
|
+
const textFn = response?.text?.bind(response);
|
|
3192
|
+
if (textFn) {
|
|
3193
|
+
const [bodyError, body] = await catchError((async () => textFn())());
|
|
3194
|
+
if (!bodyError && body) {
|
|
3195
|
+
rawBody = body;
|
|
3196
|
+
const [parseError, parsed] = catchError(() => JSON.parse(body));
|
|
3197
|
+
if (!parseError && parsed && typeof parsed === "object") {
|
|
3198
|
+
parsedBody = parsed;
|
|
3199
|
+
if (parsedBody.errors && typeof parsedBody.errors === "object") {
|
|
3200
|
+
for (const field of Object.values(parsedBody.errors)) {
|
|
3201
|
+
if (Array.isArray(field) && field.length > 0) {
|
|
3202
|
+
const first = field[0];
|
|
3203
|
+
if (first && typeof first.message === "string") {
|
|
3204
|
+
extractedMessage = first.message;
|
|
3205
|
+
break;
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
if (!extractedMessage) {
|
|
3211
|
+
extractedMessage = typeof parsedBody.message === "string" ? parsedBody.message : typeof parsedBody.errorMessage === "string" ? parsedBody.errorMessage : typeof parsedBody.title === "string" ? parsedBody.title : undefined;
|
|
3212
|
+
}
|
|
3213
|
+
if (!extractedMessage) {
|
|
3214
|
+
extractedMessage = body;
|
|
3215
|
+
}
|
|
3216
|
+
if (extractedMessage && typeof parsedBody.detail === "string" && parsedBody.detail.length > 0 && !extractedMessage.includes(parsedBody.detail)) {
|
|
3217
|
+
extractedMessage = `${extractedMessage}: ${parsedBody.detail}`;
|
|
3218
|
+
}
|
|
3219
|
+
} else {
|
|
3220
|
+
extractedMessage = isHtmlDocument(body) ? HTML_RESPONSE_MESSAGE : body;
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
let message;
|
|
3225
|
+
let result = "Failure";
|
|
3226
|
+
const classificationStatus = status ?? findHttpStatusInGraph(error);
|
|
3227
|
+
const classification = classifyError(classificationStatus, error);
|
|
3228
|
+
let retry = classification.retry;
|
|
3229
|
+
const htmlForbidden = status === 403 && rawBody !== undefined && isHtmlDocument(rawBody);
|
|
3230
|
+
const rayId = htmlForbidden ? readHeader(response, "cf-ray") : undefined;
|
|
3231
|
+
const cloudflareBlock = htmlForbidden && (rayId !== undefined || /\bcloudflare\b/i.test(readHeader(response, "server") ?? ""));
|
|
3232
|
+
if (status === 401) {
|
|
3233
|
+
message = DEFAULT_401;
|
|
3234
|
+
result = "AuthenticationError";
|
|
3235
|
+
} else if (cloudflareBlock) {
|
|
3236
|
+
message = rayId ? `${CLOUDFLARE_BLOCK_403} Cloudflare Ray ID: ${rayId}.` : CLOUDFLARE_BLOCK_403;
|
|
3237
|
+
} else if (status === 403) {
|
|
3238
|
+
message = options?.forbiddenMessage ?? DEFAULT_403;
|
|
3239
|
+
result = "AuthenticationError";
|
|
3240
|
+
} else if (status === 405) {
|
|
3241
|
+
message = DEFAULT_405;
|
|
3242
|
+
} else if (status === 413) {
|
|
3243
|
+
message = DEFAULT_413;
|
|
3244
|
+
} else if (status === 400 || status === 422) {
|
|
3245
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
3246
|
+
result = "ValidationError";
|
|
3247
|
+
} else if (status === 429) {
|
|
3248
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
3249
|
+
} else if (extractedMessage) {
|
|
3250
|
+
if (isSuccessfulResponse && rawMessage !== "Unknown error") {
|
|
3251
|
+
message = rawMessage;
|
|
3252
|
+
} else {
|
|
3253
|
+
message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
|
|
3254
|
+
}
|
|
3255
|
+
} else if (status) {
|
|
3256
|
+
if (inferredStatus !== undefined) {
|
|
3257
|
+
message = rawMessage;
|
|
3258
|
+
} else if (rawMessage === "Unknown error" && response) {
|
|
3259
|
+
const statusText = response.statusText;
|
|
3260
|
+
message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
|
|
3261
|
+
} else {
|
|
3262
|
+
message = `HTTP ${status}: ${rawMessage}`;
|
|
3263
|
+
}
|
|
3264
|
+
} else {
|
|
3265
|
+
message = rawMessage;
|
|
3266
|
+
}
|
|
3267
|
+
if (status === undefined) {
|
|
3268
|
+
const connectivity = describeConnectivityError(error);
|
|
3269
|
+
if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
|
|
3270
|
+
message = `${message}: ${connectivity.message}`;
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
const permission = status === undefined ? describePermissionError(error) : undefined;
|
|
3274
|
+
if (permission) {
|
|
3275
|
+
if (permission.message !== message && !message.includes(permission.message)) {
|
|
3276
|
+
message = `${message}: ${permission.message}`;
|
|
3277
|
+
}
|
|
3278
|
+
if (!message.includes(permission.instructions)) {
|
|
3279
|
+
const punctuated = message.endsWith(".") ? message : `${message}.`;
|
|
3280
|
+
message = `${punctuated} ${permission.instructions}`;
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
let details = rawMessage;
|
|
3284
|
+
if (htmlForbidden) {
|
|
3285
|
+
details = cloudflareBlock ? CLOUDFLARE_BLOCK_403_INSTRUCTIONS : HTML_RESPONSE_MESSAGE;
|
|
3286
|
+
} else if (rawBody) {
|
|
3287
|
+
if (parsedBody) {
|
|
3288
|
+
const extra = {};
|
|
3289
|
+
if (parsedBody.errorCode)
|
|
3290
|
+
extra.errorCode = parsedBody.errorCode;
|
|
3291
|
+
if (parsedBody.detail)
|
|
3292
|
+
extra.detail = parsedBody.detail;
|
|
3293
|
+
if (parsedBody.details)
|
|
3294
|
+
extra.details = parsedBody.details;
|
|
3295
|
+
if (parsedBody.errors != null)
|
|
3296
|
+
extra.errors = parsedBody.errors;
|
|
3297
|
+
if (parsedBody.data && typeof parsedBody.data === "object" && Object.keys(parsedBody.data).length > 0) {
|
|
3298
|
+
extra.data = parsedBody.data;
|
|
3299
|
+
}
|
|
3300
|
+
details = Object.keys(extra).length > 0 ? JSON.stringify(extra) : rawBody;
|
|
3301
|
+
} else {
|
|
3302
|
+
details = rawBody;
|
|
3303
|
+
}
|
|
3304
|
+
} else if (typeof err.message === "string") {
|
|
3305
|
+
details = err.message;
|
|
3306
|
+
} else {
|
|
3307
|
+
details = describeThrownValue(error);
|
|
3308
|
+
}
|
|
3309
|
+
const context = {};
|
|
3310
|
+
if (classificationStatus) {
|
|
3311
|
+
context.httpStatus = classificationStatus;
|
|
3312
|
+
}
|
|
3313
|
+
if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
|
|
3314
|
+
context.errorCode = parsedBody.errorCode;
|
|
3315
|
+
} else if (parsedBody?.code && typeof parsedBody.code === "string") {
|
|
3316
|
+
context.errorCode = parsedBody.code;
|
|
3317
|
+
}
|
|
3318
|
+
if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
|
|
3319
|
+
context.requestId = parsedBody.requestId;
|
|
3320
|
+
} else if (cloudflareBlock && rayId) {
|
|
3321
|
+
context.requestId = rayId;
|
|
3322
|
+
}
|
|
3323
|
+
if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
|
|
3324
|
+
context.traceId = parsedBody.traceId;
|
|
3325
|
+
}
|
|
3326
|
+
if (permission?.path !== undefined) {
|
|
3327
|
+
context.path = permission.path;
|
|
3328
|
+
}
|
|
3329
|
+
if (status === 429) {
|
|
3330
|
+
const retryAfterValue = readHeader(response, "retry-after");
|
|
3331
|
+
if (retryAfterValue) {
|
|
3332
|
+
const seconds = Number(retryAfterValue);
|
|
3333
|
+
if (!Number.isNaN(seconds)) {
|
|
3334
|
+
context.retryAfter = seconds;
|
|
3335
|
+
retry = retryHintForRetryAfter(seconds);
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
const hasContext = Object.keys(context).length > 0;
|
|
3340
|
+
let parsedErrors;
|
|
3341
|
+
if (parsedBody?.errors && typeof parsedBody.errors === "object") {
|
|
3342
|
+
const errors = {};
|
|
3343
|
+
for (const [field, raw] of Object.entries(parsedBody.errors)) {
|
|
3344
|
+
if (Array.isArray(raw)) {
|
|
3345
|
+
const messages = raw.map((entry) => {
|
|
3346
|
+
if (typeof entry === "string")
|
|
3347
|
+
return entry;
|
|
3348
|
+
if (entry && typeof entry === "object" && typeof entry.message === "string") {
|
|
3349
|
+
return entry.message;
|
|
3350
|
+
}
|
|
3351
|
+
return String(entry);
|
|
3352
|
+
}).filter(Boolean);
|
|
3353
|
+
if (messages.length > 0)
|
|
3354
|
+
errors[field] = messages;
|
|
3355
|
+
} else if (typeof raw === "string") {
|
|
3356
|
+
errors[field] = [raw];
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
if (Object.keys(errors).length > 0)
|
|
3360
|
+
parsedErrors = errors;
|
|
3361
|
+
}
|
|
3362
|
+
return {
|
|
3363
|
+
result,
|
|
3364
|
+
...withCarriedClass({ errorCode: classification.errorCode, retry }, error),
|
|
3365
|
+
message,
|
|
3366
|
+
details,
|
|
3367
|
+
...hasContext ? { context } : {},
|
|
3368
|
+
...parsedErrors ? { parsedErrors } : {}
|
|
3369
|
+
};
|
|
3370
|
+
}
|
|
3371
|
+
function extractErrorMessageSync(error) {
|
|
3372
|
+
if (error instanceof Error) {
|
|
3373
|
+
return error.message;
|
|
3374
|
+
}
|
|
3375
|
+
if (typeof error === "object" && error !== null) {
|
|
3376
|
+
if ("status" in error && error.status === 401) {
|
|
3377
|
+
return DEFAULT_401;
|
|
3378
|
+
}
|
|
3379
|
+
if ("message" in error && typeof error.message === "string") {
|
|
3380
|
+
return error.message;
|
|
3381
|
+
}
|
|
3382
|
+
}
|
|
3383
|
+
return describeThrownValue(error);
|
|
3384
|
+
}
|
|
3385
|
+
|
|
2814
3386
|
// ../filesystem/src/node.ts
|
|
2815
|
-
import { randomUUID } from "node:crypto";
|
|
3387
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2816
3388
|
import { existsSync } from "node:fs";
|
|
2817
3389
|
import * as fs from "node:fs/promises";
|
|
2818
3390
|
import * as os from "node:os";
|
|
@@ -2823,6 +3395,9 @@ var LOCK_MAX_WAIT_MS = 20000;
|
|
|
2823
3395
|
var LOCK_MAX_HOLD_MS = 60000;
|
|
2824
3396
|
var LOCK_RETRY_MIN_MS = 100;
|
|
2825
3397
|
var LOCK_RETRY_JITTER_MS = 200;
|
|
3398
|
+
var HASH_CHUNK_BYTES = 256 * 1024;
|
|
3399
|
+
var hashBuffers = [];
|
|
3400
|
+
var HASH_BUFFERS_KEPT = 64;
|
|
2826
3401
|
|
|
2827
3402
|
class NodeFileSystem {
|
|
2828
3403
|
path = {
|
|
@@ -2841,7 +3416,7 @@ class NodeFileSystem {
|
|
|
2841
3416
|
};
|
|
2842
3417
|
utils = {
|
|
2843
3418
|
open: async (url) => {
|
|
2844
|
-
const { default: open } = await import("./index-
|
|
3419
|
+
const { default: open } = await import("./index-nzr4mx5p.js");
|
|
2845
3420
|
await open(url);
|
|
2846
3421
|
}
|
|
2847
3422
|
};
|
|
@@ -2880,6 +3455,15 @@ class NodeFileSystem {
|
|
|
2880
3455
|
throw error;
|
|
2881
3456
|
}
|
|
2882
3457
|
}
|
|
3458
|
+
async readdirEntries(dirPath) {
|
|
3459
|
+
try {
|
|
3460
|
+
return await fs.readdir(dirPath, { withFileTypes: true });
|
|
3461
|
+
} catch (error) {
|
|
3462
|
+
if (this.isEnoent(error))
|
|
3463
|
+
return [];
|
|
3464
|
+
throw error;
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
2883
3467
|
async stat(filePath) {
|
|
2884
3468
|
try {
|
|
2885
3469
|
const stats = await fs.stat(filePath);
|
|
@@ -2887,7 +3471,8 @@ class NodeFileSystem {
|
|
|
2887
3471
|
isFile: () => stats.isFile(),
|
|
2888
3472
|
isDirectory: () => stats.isDirectory(),
|
|
2889
3473
|
size: stats.size,
|
|
2890
|
-
mtimeMs: stats.mtimeMs
|
|
3474
|
+
mtimeMs: stats.mtimeMs,
|
|
3475
|
+
ctimeMs: stats.ctimeMs
|
|
2891
3476
|
};
|
|
2892
3477
|
} catch (error) {
|
|
2893
3478
|
if (this.isEnoent(error))
|
|
@@ -3001,6 +3586,42 @@ class NodeFileSystem {
|
|
|
3001
3586
|
throw error;
|
|
3002
3587
|
}
|
|
3003
3588
|
}
|
|
3589
|
+
async hashFile(filePath) {
|
|
3590
|
+
let handle;
|
|
3591
|
+
try {
|
|
3592
|
+
handle = await fs.open(filePath, "r");
|
|
3593
|
+
} catch (error) {
|
|
3594
|
+
if (this.isEnoent(error))
|
|
3595
|
+
return null;
|
|
3596
|
+
throw error;
|
|
3597
|
+
}
|
|
3598
|
+
const buffer = hashBuffers.pop() ?? Buffer.allocUnsafe(HASH_CHUNK_BYTES);
|
|
3599
|
+
try {
|
|
3600
|
+
const opened = await handle.stat();
|
|
3601
|
+
const stats = {
|
|
3602
|
+
isFile: () => opened.isFile(),
|
|
3603
|
+
isDirectory: () => opened.isDirectory(),
|
|
3604
|
+
size: opened.size,
|
|
3605
|
+
mtimeMs: opened.mtimeMs,
|
|
3606
|
+
ctimeMs: opened.ctimeMs
|
|
3607
|
+
};
|
|
3608
|
+
const hash = createHash("sha256");
|
|
3609
|
+
let size = 0;
|
|
3610
|
+
for (;; ) {
|
|
3611
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.byteLength, null);
|
|
3612
|
+
if (bytesRead === 0)
|
|
3613
|
+
break;
|
|
3614
|
+
hash.update(buffer.subarray(0, bytesRead));
|
|
3615
|
+
size += bytesRead;
|
|
3616
|
+
}
|
|
3617
|
+
return { sha256: hash.digest("hex"), size, stats };
|
|
3618
|
+
} finally {
|
|
3619
|
+
if (hashBuffers.length < HASH_BUFFERS_KEPT) {
|
|
3620
|
+
hashBuffers.push(buffer);
|
|
3621
|
+
}
|
|
3622
|
+
await handle.close();
|
|
3623
|
+
}
|
|
3624
|
+
}
|
|
3004
3625
|
async realpath(filePath) {
|
|
3005
3626
|
try {
|
|
3006
3627
|
return await fs.realpath(filePath);
|
|
@@ -3084,8 +3705,8 @@ function getOutputSink() {
|
|
|
3084
3705
|
|
|
3085
3706
|
// ../common/src/logger.ts
|
|
3086
3707
|
var logFilePathSlot = singleton("logFilePath");
|
|
3087
|
-
function setGlobalLogFilePath(
|
|
3088
|
-
logFilePathSlot.set(
|
|
3708
|
+
function setGlobalLogFilePath(path) {
|
|
3709
|
+
logFilePathSlot.set(path);
|
|
3089
3710
|
}
|
|
3090
3711
|
function getGlobalLogFilePath() {
|
|
3091
3712
|
return logFilePathSlot.get("");
|
|
@@ -3153,14 +3774,14 @@ class SimpleLogger {
|
|
|
3153
3774
|
return this.fileLoggingEnabled || !!getGlobalLogFilePath();
|
|
3154
3775
|
}
|
|
3155
3776
|
writeToFile(formatted) {
|
|
3156
|
-
const
|
|
3157
|
-
if (!
|
|
3777
|
+
const path = this.logFilePath || getGlobalLogFilePath();
|
|
3778
|
+
if (!path)
|
|
3158
3779
|
return;
|
|
3159
3780
|
const timestamp = new Date().toISOString();
|
|
3160
3781
|
this.pendingWrites = Promise.all([
|
|
3161
3782
|
this.pendingWrites,
|
|
3162
3783
|
this.pendingInit
|
|
3163
|
-
]).then(() => getFileSystem().appendFile(
|
|
3784
|
+
]).then(() => getFileSystem().appendFile(path, `${timestamp} ${formatted}`).catch(() => {}));
|
|
3164
3785
|
}
|
|
3165
3786
|
write(formatted) {
|
|
3166
3787
|
if (this.isFileLoggingActive()) {
|
|
@@ -3210,17 +3831,17 @@ class SimpleLogger {
|
|
|
3210
3831
|
setGlobalLogFilePath("");
|
|
3211
3832
|
}
|
|
3212
3833
|
}
|
|
3213
|
-
setLogFile(
|
|
3214
|
-
this.logFilePath =
|
|
3215
|
-
setGlobalLogFilePath(
|
|
3216
|
-
if (!
|
|
3834
|
+
setLogFile(path) {
|
|
3835
|
+
this.logFilePath = path;
|
|
3836
|
+
setGlobalLogFilePath(path);
|
|
3837
|
+
if (!path)
|
|
3217
3838
|
return;
|
|
3218
3839
|
this.fileLoggingEnabled = true;
|
|
3219
|
-
const
|
|
3840
|
+
const fs = getFileSystem();
|
|
3220
3841
|
this.pendingInit = (async () => {
|
|
3221
3842
|
const [error] = await catchError((async () => {
|
|
3222
|
-
await
|
|
3223
|
-
await
|
|
3843
|
+
await fs.mkdir(fs.path.dirname(path));
|
|
3844
|
+
await fs.writeFile(path, "");
|
|
3224
3845
|
})());
|
|
3225
3846
|
if (error)
|
|
3226
3847
|
this.fileLoggingEnabled = false;
|
|
@@ -3268,18 +3889,111 @@ function getLogFilePath() {
|
|
|
3268
3889
|
return logger.getLogFilePath();
|
|
3269
3890
|
}
|
|
3270
3891
|
|
|
3892
|
+
// ../common/src/timings.ts
|
|
3893
|
+
var TIMINGS_ENV_VAR = "UIP_TIMINGS";
|
|
3894
|
+
function createStorage2() {
|
|
3895
|
+
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
3896
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
3897
|
+
return {
|
|
3898
|
+
getStore: () => {
|
|
3899
|
+
return;
|
|
3900
|
+
},
|
|
3901
|
+
run: (_store, fn) => fn()
|
|
3902
|
+
};
|
|
3903
|
+
}
|
|
3904
|
+
return new mod.AsyncLocalStorage;
|
|
3905
|
+
}
|
|
3906
|
+
var storageSlot = singleton("TimingStorage");
|
|
3907
|
+
var stateSlot = singleton("Timings");
|
|
3908
|
+
var rootStartedSlot = singleton("TimingsRootStarted");
|
|
3909
|
+
var longLivedHostSlot = singleton("TimingsLongLivedHost");
|
|
3910
|
+
var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
|
|
3911
|
+
function newState(baseline) {
|
|
3912
|
+
return { baseline, httpMs: 0, httpCalls: 0 };
|
|
3913
|
+
}
|
|
3914
|
+
function getState() {
|
|
3915
|
+
const scoped = storage.getStore();
|
|
3916
|
+
if (scoped) {
|
|
3917
|
+
return scoped;
|
|
3918
|
+
}
|
|
3919
|
+
const pinned = livePinnedState();
|
|
3920
|
+
if (pinned !== undefined) {
|
|
3921
|
+
return pinned;
|
|
3922
|
+
}
|
|
3923
|
+
return newState(processStartIsInvocationStart() ? 0 : performance.now());
|
|
3924
|
+
}
|
|
3925
|
+
function livePinnedState() {
|
|
3926
|
+
const pinned = stateSlot.get();
|
|
3927
|
+
return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
|
|
3928
|
+
}
|
|
3929
|
+
function processStartIsInvocationStart() {
|
|
3930
|
+
return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
|
|
3931
|
+
}
|
|
3932
|
+
function timingsEnabled() {
|
|
3933
|
+
if (typeof process === "undefined") {
|
|
3934
|
+
return false;
|
|
3935
|
+
}
|
|
3936
|
+
const value = process.env?.[TIMINGS_ENV_VAR];
|
|
3937
|
+
if (value === undefined) {
|
|
3938
|
+
return false;
|
|
3939
|
+
}
|
|
3940
|
+
const normalized = value.trim().toLowerCase();
|
|
3941
|
+
return normalized === "1" || normalized === "true";
|
|
3942
|
+
}
|
|
3943
|
+
function recordExitCode(exitCode) {
|
|
3944
|
+
if (!timingsEnabled()) {
|
|
3945
|
+
return;
|
|
3946
|
+
}
|
|
3947
|
+
getState().exitCode = exitCode;
|
|
3948
|
+
}
|
|
3949
|
+
function invocationStartedAt() {
|
|
3950
|
+
return new Date(performance.timeOrigin + getState().baseline);
|
|
3951
|
+
}
|
|
3952
|
+
function invocationElapsedMs() {
|
|
3953
|
+
return performance.now() - getState().baseline;
|
|
3954
|
+
}
|
|
3955
|
+
function markCommandStart() {
|
|
3956
|
+
if (!timingsEnabled()) {
|
|
3957
|
+
return;
|
|
3958
|
+
}
|
|
3959
|
+
getState().commandStart = performance.now();
|
|
3960
|
+
}
|
|
3961
|
+
function recordCommandDuration(durationMs) {
|
|
3962
|
+
if (!timingsEnabled()) {
|
|
3963
|
+
return;
|
|
3964
|
+
}
|
|
3965
|
+
getState().commandMs = durationMs;
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3968
|
+
// ../common/src/exit-code.ts
|
|
3969
|
+
function setExitCode(code) {
|
|
3970
|
+
process.exitCode = code;
|
|
3971
|
+
recordExitCode(code);
|
|
3972
|
+
}
|
|
3973
|
+
var GENERIC_FAILURE_EXIT_CODE = 1;
|
|
3974
|
+
function recordCommandExit(code) {
|
|
3975
|
+
if (code === GENERIC_FAILURE_EXIT_CODE && getExitCode() !== 0) {
|
|
3976
|
+
return;
|
|
3977
|
+
}
|
|
3978
|
+
setExitCode(code);
|
|
3979
|
+
}
|
|
3980
|
+
function getExitCode() {
|
|
3981
|
+
const code = process.exitCode;
|
|
3982
|
+
return typeof code === "number" ? code : 0;
|
|
3983
|
+
}
|
|
3984
|
+
|
|
3271
3985
|
// ../common/src/output-codecs.ts
|
|
3272
3986
|
var yamlSlot = singleton("YamlCodec");
|
|
3273
3987
|
var jmespathSlot = singleton("JmespathCodec");
|
|
3274
3988
|
async function loadOutputCodecsAsync(needed) {
|
|
3275
3989
|
const loads = [];
|
|
3276
3990
|
if (needed.yaml && yamlSlot.get() === undefined) {
|
|
3277
|
-
loads.push(import("./js-yaml-
|
|
3991
|
+
loads.push(import("./js-yaml-a2bk27p6.js").then((mod) => {
|
|
3278
3992
|
yamlSlot.set(mod);
|
|
3279
3993
|
}));
|
|
3280
3994
|
}
|
|
3281
3995
|
if (needed.filter && jmespathSlot.get() === undefined) {
|
|
3282
|
-
loads.push(import("./jmespath-
|
|
3996
|
+
loads.push(import("./jmespath-ab6tdc42.js").then((m)=>__toESM(m.default,1)).then((mod) => {
|
|
3283
3997
|
jmespathSlot.set(mod);
|
|
3284
3998
|
}));
|
|
3285
3999
|
}
|
|
@@ -3300,56 +4014,22 @@ var filterSlot = singleton("OutputFilter");
|
|
|
3300
4014
|
function getOutputFormat() {
|
|
3301
4015
|
return formatSlot.get("json");
|
|
3302
4016
|
}
|
|
3303
|
-
function getOutputFormatExplicit() {
|
|
3304
|
-
return formatExplicitSlot.get(false) ?? false;
|
|
3305
|
-
}
|
|
3306
|
-
function getOutputFilter() {
|
|
3307
|
-
return filterSlot.get();
|
|
3308
|
-
}
|
|
3309
|
-
|
|
3310
|
-
// ../common/src/
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
continue;
|
|
3320
|
-
seen.add(current);
|
|
3321
|
-
const cur = current;
|
|
3322
|
-
yield cur;
|
|
3323
|
-
if (cur.cause !== undefined)
|
|
3324
|
-
queue.push(cur.cause);
|
|
3325
|
-
if (Array.isArray(cur.errors))
|
|
3326
|
-
queue.push(...cur.errors);
|
|
3327
|
-
}
|
|
3328
|
-
return;
|
|
3329
|
-
}
|
|
3330
|
-
function parseHttpStatusFromMessage(message) {
|
|
3331
|
-
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
3332
|
-
if (!match)
|
|
3333
|
-
return;
|
|
3334
|
-
const status = Number(match[1]);
|
|
3335
|
-
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
3336
|
-
}
|
|
3337
|
-
function findHttpStatusInGraph(error) {
|
|
3338
|
-
for (const node of walkErrorGraph(error)) {
|
|
3339
|
-
const response = node.response;
|
|
3340
|
-
const explicit = typeof node.status === "number" ? node.status : response?.status;
|
|
3341
|
-
if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
|
|
3342
|
-
return explicit;
|
|
3343
|
-
}
|
|
3344
|
-
if (typeof node.message === "string") {
|
|
3345
|
-
const parsed = parseHttpStatusFromMessage(node.message);
|
|
3346
|
-
if (parsed !== undefined && parsed >= 400) {
|
|
3347
|
-
return parsed;
|
|
3348
|
-
}
|
|
3349
|
-
}
|
|
3350
|
-
}
|
|
3351
|
-
return;
|
|
3352
|
-
}
|
|
4017
|
+
function getOutputFormatExplicit() {
|
|
4018
|
+
return formatExplicitSlot.get(false) ?? false;
|
|
4019
|
+
}
|
|
4020
|
+
function getOutputFilter() {
|
|
4021
|
+
return filterSlot.get();
|
|
4022
|
+
}
|
|
4023
|
+
|
|
4024
|
+
// ../common/src/result-types.ts
|
|
4025
|
+
var RESULTS = {
|
|
4026
|
+
Success: "Success",
|
|
4027
|
+
Failure: "Failure",
|
|
4028
|
+
ConfigError: "ConfigError",
|
|
4029
|
+
AuthenticationError: "AuthenticationError",
|
|
4030
|
+
ValidationError: "ValidationError",
|
|
4031
|
+
TimeoutError: "TimeoutError"
|
|
4032
|
+
};
|
|
3353
4033
|
|
|
3354
4034
|
// ../common/src/telemetry/command-terminal.ts
|
|
3355
4035
|
var recordedFailureSlot = singleton("CommandTelemetryFailure");
|
|
@@ -3380,7 +4060,7 @@ var NETWORK_OS_ERROR_CODES = new Set([
|
|
|
3380
4060
|
"EAI_FAIL"
|
|
3381
4061
|
]);
|
|
3382
4062
|
var TIMEOUT_OS_ERROR_CODES = new Set(["ETIMEDOUT", "ESOCKETTIMEDOUT"]);
|
|
3383
|
-
var
|
|
4063
|
+
var TLS_ERROR_CODES2 = new Set([
|
|
3384
4064
|
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
3385
4065
|
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
3386
4066
|
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
@@ -3469,17 +4149,8 @@ function terminalSignalFor(input, outcome) {
|
|
|
3469
4149
|
}
|
|
3470
4150
|
return outcome === "cancelled" ? "SIGINT" : undefined;
|
|
3471
4151
|
}
|
|
3472
|
-
function
|
|
3473
|
-
|
|
3474
|
-
return "auth";
|
|
3475
|
-
}
|
|
3476
|
-
if (status === 400 || status === 409 || status === 422) {
|
|
3477
|
-
return "validation";
|
|
3478
|
-
}
|
|
3479
|
-
if (status === 408) {
|
|
3480
|
-
return "timeout";
|
|
3481
|
-
}
|
|
3482
|
-
return "network_http";
|
|
4152
|
+
function classifyFailingHttpStatus(status) {
|
|
4153
|
+
return classifyFromErrorCode(classifyHttpStatus(status)?.errorCode) ?? "network_http";
|
|
3483
4154
|
}
|
|
3484
4155
|
function classifyFromResult(result) {
|
|
3485
4156
|
switch (result) {
|
|
@@ -3529,7 +4200,7 @@ function classifyFromError(error) {
|
|
|
3529
4200
|
if (code.startsWith("commander.")) {
|
|
3530
4201
|
return "validation";
|
|
3531
4202
|
}
|
|
3532
|
-
if (NETWORK_OS_ERROR_CODES.has(code) ||
|
|
4203
|
+
if (NETWORK_OS_ERROR_CODES.has(code) || TLS_ERROR_CODES2.has(code)) {
|
|
3533
4204
|
return "network_http";
|
|
3534
4205
|
}
|
|
3535
4206
|
if (TIMEOUT_OS_ERROR_CODES.has(code)) {
|
|
@@ -3552,14 +4223,14 @@ function classifyFromError(error) {
|
|
|
3552
4223
|
}
|
|
3553
4224
|
return;
|
|
3554
4225
|
}
|
|
3555
|
-
function
|
|
4226
|
+
function classifyError2(input) {
|
|
3556
4227
|
const recorded = input.recordedFailure;
|
|
3557
4228
|
if (recorded?.errorClass) {
|
|
3558
4229
|
return recorded.errorClass;
|
|
3559
4230
|
}
|
|
3560
4231
|
const status = recorded?.context?.httpStatus ?? findHttpStatusInGraph(input.error);
|
|
3561
4232
|
if (status !== undefined) {
|
|
3562
|
-
return
|
|
4233
|
+
return classifyFailingHttpStatus(status);
|
|
3563
4234
|
}
|
|
3564
4235
|
return classifyFromResult(recorded?.result) ?? classifyFromErrorCode(recorded?.errorCode) ?? classifyFromError(input.error) ?? "unknown";
|
|
3565
4236
|
}
|
|
@@ -3577,7 +4248,7 @@ function takeRecordedCommandFailureTelemetry() {
|
|
|
3577
4248
|
function buildCommandTerminalTelemetryProperties(input) {
|
|
3578
4249
|
const cancelled = isCancellationError(input.error, input.exitCode, input.pollSignal);
|
|
3579
4250
|
const outcome = input.recordedFailure?.terminalOutcome ?? (input.exitCode === 0 ? "success" : cancelled ? "cancelled" : "failure");
|
|
3580
|
-
const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" :
|
|
4251
|
+
const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError2(input);
|
|
3581
4252
|
const terminalSignal = terminalSignalFor(input, outcome);
|
|
3582
4253
|
return {
|
|
3583
4254
|
[CommandDimensions.ExitCode]: input.exitCode,
|
|
@@ -3591,6 +4262,7 @@ function buildCommandTerminalTelemetryProperties(input) {
|
|
|
3591
4262
|
var CommonTelemetryEvents = {
|
|
3592
4263
|
Start: "Application.Start",
|
|
3593
4264
|
Error: "Application.Error",
|
|
4265
|
+
ProjectActivity: "Cli.ProjectActivity",
|
|
3594
4266
|
ShipSucceeded: "Cli.ShipSucceeded"
|
|
3595
4267
|
};
|
|
3596
4268
|
|
|
@@ -4108,87 +4780,21 @@ class TelemetryService {
|
|
|
4108
4780
|
return hex;
|
|
4109
4781
|
}
|
|
4110
4782
|
}
|
|
4111
|
-
// ../common/src/timings.ts
|
|
4112
|
-
var TIMINGS_ENV_VAR = "UIP_TIMINGS";
|
|
4113
|
-
function createStorage2() {
|
|
4114
|
-
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
4115
|
-
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
4116
|
-
return {
|
|
4117
|
-
getStore: () => {
|
|
4118
|
-
return;
|
|
4119
|
-
},
|
|
4120
|
-
run: (_store, fn) => fn()
|
|
4121
|
-
};
|
|
4122
|
-
}
|
|
4123
|
-
return new mod.AsyncLocalStorage;
|
|
4124
|
-
}
|
|
4125
|
-
var storageSlot = singleton("TimingStorage");
|
|
4126
|
-
var stateSlot = singleton("Timings");
|
|
4127
|
-
var rootStartedSlot = singleton("TimingsRootStarted");
|
|
4128
|
-
var longLivedHostSlot = singleton("TimingsLongLivedHost");
|
|
4129
|
-
var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
|
|
4130
|
-
function newState(baseline) {
|
|
4131
|
-
return { baseline, httpMs: 0, httpCalls: 0 };
|
|
4132
|
-
}
|
|
4133
|
-
function getState() {
|
|
4134
|
-
const scoped = storage.getStore();
|
|
4135
|
-
if (scoped) {
|
|
4136
|
-
return scoped;
|
|
4137
|
-
}
|
|
4138
|
-
const pinned = livePinnedState();
|
|
4139
|
-
if (pinned !== undefined) {
|
|
4140
|
-
return pinned;
|
|
4141
|
-
}
|
|
4142
|
-
return newState(processStartIsInvocationStart() ? 0 : performance.now());
|
|
4143
|
-
}
|
|
4144
|
-
function livePinnedState() {
|
|
4145
|
-
const pinned = stateSlot.get();
|
|
4146
|
-
return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
|
|
4147
|
-
}
|
|
4148
|
-
function processStartIsInvocationStart() {
|
|
4149
|
-
return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
|
|
4150
|
-
}
|
|
4151
|
-
function timingsEnabled() {
|
|
4152
|
-
if (typeof process === "undefined") {
|
|
4153
|
-
return false;
|
|
4154
|
-
}
|
|
4155
|
-
const value = process.env?.[TIMINGS_ENV_VAR];
|
|
4156
|
-
if (value === undefined) {
|
|
4157
|
-
return false;
|
|
4158
|
-
}
|
|
4159
|
-
const normalized = value.trim().toLowerCase();
|
|
4160
|
-
return normalized === "1" || normalized === "true";
|
|
4161
|
-
}
|
|
4162
|
-
function recordExitCode(exitCode) {
|
|
4163
|
-
if (!timingsEnabled()) {
|
|
4164
|
-
return;
|
|
4165
|
-
}
|
|
4166
|
-
getState().exitCode = exitCode;
|
|
4167
|
-
}
|
|
4168
|
-
function invocationStartedAt() {
|
|
4169
|
-
return new Date(performance.timeOrigin + getState().baseline);
|
|
4170
|
-
}
|
|
4171
|
-
function invocationElapsedMs() {
|
|
4172
|
-
return performance.now() - getState().baseline;
|
|
4173
|
-
}
|
|
4174
|
-
function markCommandStart() {
|
|
4175
|
-
if (!timingsEnabled()) {
|
|
4176
|
-
return;
|
|
4177
|
-
}
|
|
4178
|
-
getState().commandStart = performance.now();
|
|
4179
|
-
}
|
|
4180
|
-
function recordCommandDuration(durationMs) {
|
|
4181
|
-
if (!timingsEnabled()) {
|
|
4182
|
-
return;
|
|
4183
|
-
}
|
|
4184
|
-
getState().commandMs = durationMs;
|
|
4185
|
-
}
|
|
4186
4783
|
// ../common/src/telemetry/proxy-http-agent.ts
|
|
4187
4784
|
var slot = singleton("ProxyAuthHttpsAgent");
|
|
4188
4785
|
|
|
4189
4786
|
// ../common/src/telemetry/node-appinsights-telemetry-provider.ts
|
|
4190
4787
|
var providerSlot = singleton("TelemetryProvider");
|
|
4191
4788
|
|
|
4789
|
+
// ../common/src/telemetry/telemetry-config.ts
|
|
4790
|
+
function isTelemetryDisabled() {
|
|
4791
|
+
const value = process.env.UIPATH_TELEMETRY_DISABLED;
|
|
4792
|
+
return value === "1" || value === "true";
|
|
4793
|
+
}
|
|
4794
|
+
function isProjectTelemetryDisabled() {
|
|
4795
|
+
return isTelemetryDisabled() || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "1" || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "true";
|
|
4796
|
+
}
|
|
4797
|
+
|
|
4192
4798
|
// ../common/src/telemetry/telemetry-spool.ts
|
|
4193
4799
|
var sidecarEntrySlot = singleton("TelemetrySidecarEntry");
|
|
4194
4800
|
var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
|
|
@@ -4224,7 +4830,6 @@ var telemetry = new Proxy({}, {
|
|
|
4224
4830
|
return typeof value === "function" ? value.bind(instance) : value;
|
|
4225
4831
|
}
|
|
4226
4832
|
});
|
|
4227
|
-
|
|
4228
4833
|
// ../common/src/formatter.ts
|
|
4229
4834
|
var ANSI_STYLES = {
|
|
4230
4835
|
red: "\x1B[31m",
|
|
@@ -4234,46 +4839,6 @@ var ANSI_RESET = "\x1B[0m";
|
|
|
4234
4839
|
function styleLine(line, style) {
|
|
4235
4840
|
return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
|
|
4236
4841
|
}
|
|
4237
|
-
var CLI_ERROR_CODES = [
|
|
4238
|
-
"invalid_argument",
|
|
4239
|
-
"authentication_required",
|
|
4240
|
-
"permission_denied",
|
|
4241
|
-
"local_permission_denied",
|
|
4242
|
-
"not_found",
|
|
4243
|
-
"rate_limited",
|
|
4244
|
-
"network_error",
|
|
4245
|
-
"timeout",
|
|
4246
|
-
"server_error",
|
|
4247
|
-
"method_not_allowed",
|
|
4248
|
-
"not_supported",
|
|
4249
|
-
"configuration_error",
|
|
4250
|
-
"execution_failed",
|
|
4251
|
-
"unknown_error"
|
|
4252
|
-
];
|
|
4253
|
-
var RETRY_HINTS = [
|
|
4254
|
-
"RetryWillNotFix",
|
|
4255
|
-
"RetryLater",
|
|
4256
|
-
"RetryAfter1Second",
|
|
4257
|
-
"RetryAfter10Seconds",
|
|
4258
|
-
"RetryAfter30Seconds",
|
|
4259
|
-
"RetryAfter60Seconds"
|
|
4260
|
-
];
|
|
4261
|
-
var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
|
|
4262
|
-
var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
|
|
4263
|
-
function isCliErrorCode(value) {
|
|
4264
|
-
return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
|
|
4265
|
-
}
|
|
4266
|
-
function isRetryHint(value) {
|
|
4267
|
-
return typeof value === "string" && RETRY_HINT_VALUES.has(value);
|
|
4268
|
-
}
|
|
4269
|
-
var RESULTS = {
|
|
4270
|
-
Success: "Success",
|
|
4271
|
-
Failure: "Failure",
|
|
4272
|
-
ConfigError: "ConfigError",
|
|
4273
|
-
AuthenticationError: "AuthenticationError",
|
|
4274
|
-
ValidationError: "ValidationError",
|
|
4275
|
-
TimeoutError: "TimeoutError"
|
|
4276
|
-
};
|
|
4277
4842
|
var EXIT_CODES = {
|
|
4278
4843
|
Success: 0,
|
|
4279
4844
|
Failure: 1,
|
|
@@ -4282,6 +4847,9 @@ var EXIT_CODES = {
|
|
|
4282
4847
|
ValidationError: 3,
|
|
4283
4848
|
TimeoutError: 4
|
|
4284
4849
|
};
|
|
4850
|
+
function exitCodeForResult(result) {
|
|
4851
|
+
return EXIT_CODES[result] ?? EXIT_CODES.Failure;
|
|
4852
|
+
}
|
|
4285
4853
|
function escapeNonAscii(jsonText) {
|
|
4286
4854
|
return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
|
|
4287
4855
|
const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
|
|
@@ -4957,8 +5525,8 @@ function carriesOnlyNulls(value) {
|
|
|
4957
5525
|
}
|
|
4958
5526
|
return false;
|
|
4959
5527
|
}
|
|
4960
|
-
function nameList(names,
|
|
4961
|
-
const shown = names.slice(0,
|
|
5528
|
+
function nameList(names, cap = 12) {
|
|
5529
|
+
const shown = names.slice(0, cap).map((n) => `\`${n}\``);
|
|
4962
5530
|
const rest = names.length - shown.length;
|
|
4963
5531
|
return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
|
|
4964
5532
|
}
|
|
@@ -5095,40 +5663,11 @@ function defaultErrorCodeForResult(result) {
|
|
|
5095
5663
|
return "unknown_error";
|
|
5096
5664
|
}
|
|
5097
5665
|
}
|
|
5098
|
-
function parseHttpStatusFromMessage2(message) {
|
|
5099
|
-
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
5100
|
-
if (!match)
|
|
5101
|
-
return;
|
|
5102
|
-
const status = Number(match[1]);
|
|
5103
|
-
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
5104
|
-
}
|
|
5105
|
-
function defaultErrorCodeForHttpStatus(status) {
|
|
5106
|
-
if (status === undefined)
|
|
5107
|
-
return;
|
|
5108
|
-
if (status === 400 || status === 409 || status === 422) {
|
|
5109
|
-
return "invalid_argument";
|
|
5110
|
-
}
|
|
5111
|
-
if (status === 401)
|
|
5112
|
-
return "authentication_required";
|
|
5113
|
-
if (status === 403)
|
|
5114
|
-
return "permission_denied";
|
|
5115
|
-
if (status === 404)
|
|
5116
|
-
return "not_found";
|
|
5117
|
-
if (status === 405)
|
|
5118
|
-
return "method_not_allowed";
|
|
5119
|
-
if (status === 408)
|
|
5120
|
-
return "timeout";
|
|
5121
|
-
if (status === 429)
|
|
5122
|
-
return "rate_limited";
|
|
5123
|
-
if (status >= 500 && status < 600)
|
|
5124
|
-
return "server_error";
|
|
5125
|
-
return;
|
|
5126
|
-
}
|
|
5127
5666
|
var LOCAL_PERMISSION_TEXT_PATTERN = new RegExp(`(?:\\b|\\()(?:${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})(?::\\s|\\))`);
|
|
5128
5667
|
function defaultErrorCodeForFailure(data) {
|
|
5129
5668
|
if (data.Result === RESULTS.Failure) {
|
|
5130
|
-
const status = data.Context?.httpStatus ??
|
|
5131
|
-
const errorCode =
|
|
5669
|
+
const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage(data.Message);
|
|
5670
|
+
const errorCode = classifyHttpStatus(status)?.errorCode;
|
|
5132
5671
|
if (errorCode)
|
|
5133
5672
|
return errorCode;
|
|
5134
5673
|
if (status === undefined && (LOCAL_PERMISSION_TEXT_PATTERN.test(data.Message) || LOCAL_PERMISSION_TEXT_PATTERN.test(data.Instructions))) {
|
|
@@ -5137,17 +5676,6 @@ function defaultErrorCodeForFailure(data) {
|
|
|
5137
5676
|
}
|
|
5138
5677
|
return defaultErrorCodeForResult(data.Result);
|
|
5139
5678
|
}
|
|
5140
|
-
function defaultRetryForErrorCode(errorCode) {
|
|
5141
|
-
switch (errorCode) {
|
|
5142
|
-
case "network_error":
|
|
5143
|
-
case "rate_limited":
|
|
5144
|
-
case "server_error":
|
|
5145
|
-
case "timeout":
|
|
5146
|
-
return "RetryLater";
|
|
5147
|
-
default:
|
|
5148
|
-
return "RetryWillNotFix";
|
|
5149
|
-
}
|
|
5150
|
-
}
|
|
5151
5679
|
var OutputFormatter;
|
|
5152
5680
|
((OutputFormatter) => {
|
|
5153
5681
|
function success(data, options) {
|
|
@@ -5179,7 +5707,7 @@ var OutputFormatter;
|
|
|
5179
5707
|
data.Log ??= getLogFilePath() || undefined;
|
|
5180
5708
|
data.ErrorCode ??= defaultErrorCodeForFailure(data);
|
|
5181
5709
|
data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
|
|
5182
|
-
const exitCode =
|
|
5710
|
+
const exitCode = exitCodeForResult(data.Result);
|
|
5183
5711
|
setExitCode(exitCode);
|
|
5184
5712
|
recordCommandFailureTelemetry({
|
|
5185
5713
|
result: data.Result,
|
|
@@ -5224,55 +5752,277 @@ var OutputFormatter;
|
|
|
5224
5752
|
if (opts?.warning) {
|
|
5225
5753
|
data.Warning = opts.warning;
|
|
5226
5754
|
}
|
|
5227
|
-
if (opts?.pagination) {
|
|
5228
|
-
data.Pagination = opts.pagination;
|
|
5755
|
+
if (opts?.pagination) {
|
|
5756
|
+
data.Pagination = opts.pagination;
|
|
5757
|
+
}
|
|
5758
|
+
success(data);
|
|
5759
|
+
}
|
|
5760
|
+
OutputFormatter.emitList = emitList;
|
|
5761
|
+
function log(data) {
|
|
5762
|
+
const format = getOutputFormat();
|
|
5763
|
+
const sink = getOutputSink();
|
|
5764
|
+
const normalized = toPascalCaseData(data);
|
|
5765
|
+
if (format === "json") {
|
|
5766
|
+
const json = JSON.stringify(normalized);
|
|
5767
|
+
const safe = needsAsciiSafeJson(sink) ? escapeNonAscii(json) : json;
|
|
5768
|
+
sink.writeErr(`${safe}
|
|
5769
|
+
`);
|
|
5770
|
+
} else {
|
|
5771
|
+
for (const [key, value] of Object.entries(normalized)) {
|
|
5772
|
+
sink.writeErr(`${key}: ${value}
|
|
5773
|
+
`);
|
|
5774
|
+
}
|
|
5775
|
+
}
|
|
5776
|
+
}
|
|
5777
|
+
OutputFormatter.log = log;
|
|
5778
|
+
function formatToString(data) {
|
|
5779
|
+
const filter = getOutputFilter();
|
|
5780
|
+
const envelope = data;
|
|
5781
|
+
if ("Data" in data && data.Data != null) {
|
|
5782
|
+
data.Data = normalizeDataKeys(data.Data);
|
|
5783
|
+
if (filter) {
|
|
5784
|
+
let note;
|
|
5785
|
+
data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
|
|
5786
|
+
note = n;
|
|
5787
|
+
}));
|
|
5788
|
+
if (note) {
|
|
5789
|
+
envelope.Warning = appendWarning(envelope.Warning, note);
|
|
5790
|
+
}
|
|
5791
|
+
}
|
|
5792
|
+
}
|
|
5793
|
+
const output = normalizeOutputKeys(envelope);
|
|
5794
|
+
const lines = [];
|
|
5795
|
+
const sink = getOutputSink();
|
|
5796
|
+
printOutput(output, getOutputFormat(), (msg) => {
|
|
5797
|
+
lines.push(msg);
|
|
5798
|
+
}, needsAsciiSafeJson(sink));
|
|
5799
|
+
return lines.join(`
|
|
5800
|
+
`);
|
|
5801
|
+
}
|
|
5802
|
+
OutputFormatter.formatToString = formatToString;
|
|
5803
|
+
})(OutputFormatter ||= {});
|
|
5804
|
+
|
|
5805
|
+
// ../common/src/pass-through-tail.ts
|
|
5806
|
+
function maybeOption(arg) {
|
|
5807
|
+
return arg.length > 1 && arg[0] === "-";
|
|
5808
|
+
}
|
|
5809
|
+
function tokenizeTail(cmd, tail) {
|
|
5810
|
+
const find = (flag) => cmd.options.find((option) => option.long === flag || option.short === flag);
|
|
5811
|
+
const digitShort = cmd.options.some((option) => option.short !== undefined && /^-\d$/.test(option.short));
|
|
5812
|
+
const negativeNumber = (arg) => !digitShort && /^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg);
|
|
5813
|
+
const tokens = [];
|
|
5814
|
+
let firstUnknown = -1;
|
|
5815
|
+
let sentinel = -1;
|
|
5816
|
+
let variadic;
|
|
5817
|
+
let group;
|
|
5818
|
+
let groupIndex = 0;
|
|
5819
|
+
let i = 0;
|
|
5820
|
+
while (i < tail.length || group !== undefined) {
|
|
5821
|
+
const index = group === undefined ? i : groupIndex;
|
|
5822
|
+
const arg = group ?? tail[i++];
|
|
5823
|
+
group = undefined;
|
|
5824
|
+
if (arg === "--") {
|
|
5825
|
+
sentinel = index;
|
|
5826
|
+
tokens.push({ kind: "sentinel", index });
|
|
5827
|
+
for (let j = i;j < tail.length; j++) {
|
|
5828
|
+
tokens.push({
|
|
5829
|
+
kind: "operand",
|
|
5830
|
+
index: j,
|
|
5831
|
+
text: tail[j],
|
|
5832
|
+
literal: true
|
|
5833
|
+
});
|
|
5834
|
+
}
|
|
5835
|
+
break;
|
|
5836
|
+
}
|
|
5837
|
+
if (variadic && (!maybeOption(arg) || negativeNumber(arg))) {
|
|
5838
|
+
tokens.push({
|
|
5839
|
+
kind: "option",
|
|
5840
|
+
index,
|
|
5841
|
+
text: arg,
|
|
5842
|
+
option: variadic,
|
|
5843
|
+
value: arg
|
|
5844
|
+
});
|
|
5845
|
+
continue;
|
|
5846
|
+
}
|
|
5847
|
+
variadic = undefined;
|
|
5848
|
+
if (maybeOption(arg)) {
|
|
5849
|
+
const option = find(arg);
|
|
5850
|
+
if (option) {
|
|
5851
|
+
let value;
|
|
5852
|
+
if (option.required) {
|
|
5853
|
+
value = tail[i];
|
|
5854
|
+
if (value !== undefined)
|
|
5855
|
+
i++;
|
|
5856
|
+
} else if (option.optional) {
|
|
5857
|
+
const next = tail[i];
|
|
5858
|
+
if (next !== undefined && (!maybeOption(next) || negativeNumber(next))) {
|
|
5859
|
+
value = next;
|
|
5860
|
+
i++;
|
|
5861
|
+
}
|
|
5862
|
+
}
|
|
5863
|
+
tokens.push({
|
|
5864
|
+
kind: "option",
|
|
5865
|
+
index,
|
|
5866
|
+
text: arg,
|
|
5867
|
+
option,
|
|
5868
|
+
...value === undefined ? {} : { value }
|
|
5869
|
+
});
|
|
5870
|
+
variadic = option.variadic ? option : undefined;
|
|
5871
|
+
continue;
|
|
5872
|
+
}
|
|
5873
|
+
}
|
|
5874
|
+
if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
|
|
5875
|
+
const option = find(`-${arg[1]}`);
|
|
5876
|
+
if (option) {
|
|
5877
|
+
if (option.required || option.optional) {
|
|
5878
|
+
tokens.push({
|
|
5879
|
+
kind: "option",
|
|
5880
|
+
index,
|
|
5881
|
+
text: arg,
|
|
5882
|
+
option,
|
|
5883
|
+
value: arg.slice(2)
|
|
5884
|
+
});
|
|
5885
|
+
} else {
|
|
5886
|
+
tokens.push({ kind: "option", index, text: arg, option });
|
|
5887
|
+
group = `-${arg.slice(2)}`;
|
|
5888
|
+
groupIndex = index;
|
|
5889
|
+
}
|
|
5890
|
+
continue;
|
|
5891
|
+
}
|
|
5892
|
+
}
|
|
5893
|
+
if (/^--[^=]+=/.test(arg)) {
|
|
5894
|
+
const equals = arg.indexOf("=");
|
|
5895
|
+
const option = find(arg.slice(0, equals));
|
|
5896
|
+
if (option && (option.required || option.optional)) {
|
|
5897
|
+
tokens.push({
|
|
5898
|
+
kind: "option",
|
|
5899
|
+
index,
|
|
5900
|
+
text: arg,
|
|
5901
|
+
option,
|
|
5902
|
+
value: arg.slice(equals + 1)
|
|
5903
|
+
});
|
|
5904
|
+
continue;
|
|
5905
|
+
}
|
|
5906
|
+
}
|
|
5907
|
+
if (maybeOption(arg) && !negativeNumber(arg)) {
|
|
5908
|
+
const equals = arg.startsWith("--") ? arg.indexOf("=") : -1;
|
|
5909
|
+
if (firstUnknown === -1)
|
|
5910
|
+
firstUnknown = index;
|
|
5911
|
+
tokens.push({
|
|
5912
|
+
kind: "unknown",
|
|
5913
|
+
index,
|
|
5914
|
+
text: arg,
|
|
5915
|
+
flag: equals > 0 ? arg.slice(0, equals) : arg,
|
|
5916
|
+
...equals > 0 ? { inlineValue: arg.slice(equals + 1) } : {}
|
|
5917
|
+
});
|
|
5918
|
+
continue;
|
|
5919
|
+
}
|
|
5920
|
+
tokens.push({ kind: "operand", index, text: arg, literal: false });
|
|
5921
|
+
}
|
|
5922
|
+
return { tokens, firstUnknown, sentinel };
|
|
5923
|
+
}
|
|
5924
|
+
|
|
5925
|
+
// ../common/src/project-telemetry.ts
|
|
5926
|
+
var RESOLVER = Symbol.for("@uipath/common/projectTelemetryResolver");
|
|
5927
|
+
var CAPTURE = Symbol.for("@uipath/common/projectTelemetryCapture");
|
|
5928
|
+
var CONTEXT_RESOLVER = Symbol.for("@uipath/common/projectContextTelemetryResolver");
|
|
5929
|
+
var RULES = Symbol.for("@uipath/common/projectTargetRules");
|
|
5930
|
+
function logSkipped(what, error) {
|
|
5931
|
+
logger.debug(`[project-telemetry] ${what} skipped: ${error instanceof Error ? error.message : String(error)}`);
|
|
5932
|
+
}
|
|
5933
|
+
function bounded(work, what) {
|
|
5934
|
+
return withinProjectIdentityBudget(work, () => logSkipped(what, `no answer within ${PROJECT_IDENTITY_LOOKUP_BUDGET_MS} ms`));
|
|
5935
|
+
}
|
|
5936
|
+
async function identityWithContext(command, identity) {
|
|
5937
|
+
const props = projectIdentityProperties(identity);
|
|
5938
|
+
if (!identity.projectDirectory || isProjectTelemetryDisabled())
|
|
5939
|
+
return props;
|
|
5940
|
+
for (let node = command;node; node = node.parent ?? undefined) {
|
|
5941
|
+
const resolver = node[CONTEXT_RESOLVER];
|
|
5942
|
+
if (typeof resolver !== "function")
|
|
5943
|
+
continue;
|
|
5944
|
+
try {
|
|
5945
|
+
return {
|
|
5946
|
+
...await resolver(identity.projectDirectory),
|
|
5947
|
+
...props
|
|
5948
|
+
};
|
|
5949
|
+
} catch (error) {
|
|
5950
|
+
logSkipped("solution context lookup", error);
|
|
5951
|
+
return props;
|
|
5952
|
+
}
|
|
5953
|
+
}
|
|
5954
|
+
return props;
|
|
5955
|
+
}
|
|
5956
|
+
function getProjectTelemetryResolver(command) {
|
|
5957
|
+
for (let node = command;node; node = node.parent) {
|
|
5958
|
+
const resolver = node[RESOLVER];
|
|
5959
|
+
if (typeof resolver === "function")
|
|
5960
|
+
return resolver;
|
|
5961
|
+
}
|
|
5962
|
+
return;
|
|
5963
|
+
}
|
|
5964
|
+
function attachProjectTelemetryCapture(command, capture) {
|
|
5965
|
+
command[CAPTURE] = capture;
|
|
5966
|
+
}
|
|
5967
|
+
class ProjectTelemetrySession {
|
|
5968
|
+
resolver;
|
|
5969
|
+
command;
|
|
5970
|
+
target;
|
|
5971
|
+
props = {};
|
|
5972
|
+
explicit = false;
|
|
5973
|
+
input;
|
|
5974
|
+
constructor(resolver, command) {
|
|
5975
|
+
this.resolver = resolver;
|
|
5976
|
+
this.command = command;
|
|
5977
|
+
}
|
|
5978
|
+
async setTarget(path) {
|
|
5979
|
+
this.target = path;
|
|
5980
|
+
if (this.input) {
|
|
5981
|
+
await this.resolve({
|
|
5982
|
+
...this.input,
|
|
5983
|
+
phase: "after",
|
|
5984
|
+
success: true
|
|
5985
|
+
});
|
|
5986
|
+
this.explicit = true;
|
|
5987
|
+
}
|
|
5988
|
+
}
|
|
5989
|
+
async setIdentity(identity) {
|
|
5990
|
+
try {
|
|
5991
|
+
const props = await bounded(identityWithContext(this.command, identity), "project identity capture");
|
|
5992
|
+
if (props !== undefined)
|
|
5993
|
+
this.setProperties(props);
|
|
5994
|
+
} catch (error) {
|
|
5995
|
+
logSkipped("project identity capture", error);
|
|
5229
5996
|
}
|
|
5230
|
-
success(data);
|
|
5231
5997
|
}
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
const json = JSON.stringify(normalized);
|
|
5239
|
-
const safe = needsAsciiSafeJson(sink) ? escapeNonAscii(json) : json;
|
|
5240
|
-
sink.writeErr(`${safe}
|
|
5241
|
-
`);
|
|
5242
|
-
} else {
|
|
5243
|
-
for (const [key, value] of Object.entries(normalized)) {
|
|
5244
|
-
sink.writeErr(`${key}: ${value}
|
|
5245
|
-
`);
|
|
5246
|
-
}
|
|
5998
|
+
setProperties(properties) {
|
|
5999
|
+
try {
|
|
6000
|
+
this.props = { ...properties };
|
|
6001
|
+
this.explicit = true;
|
|
6002
|
+
} catch (error) {
|
|
6003
|
+
logSkipped("project identity properties", error);
|
|
5247
6004
|
}
|
|
5248
6005
|
}
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
6006
|
+
properties() {
|
|
6007
|
+
return { ...this.props };
|
|
6008
|
+
}
|
|
6009
|
+
async resolve(input) {
|
|
6010
|
+
this.input = input;
|
|
6011
|
+
if (this.explicit)
|
|
6012
|
+
return;
|
|
6013
|
+
try {
|
|
6014
|
+
const props = await bounded(this.resolver({
|
|
6015
|
+
...input,
|
|
6016
|
+
target: this.target
|
|
6017
|
+
}), `project identity (${input.phase})`);
|
|
6018
|
+
if (props !== undefined) {
|
|
6019
|
+
this.props = props;
|
|
5263
6020
|
}
|
|
6021
|
+
} catch (error) {
|
|
6022
|
+
logSkipped(`project identity (${input.phase})`, error);
|
|
5264
6023
|
}
|
|
5265
|
-
const output = normalizeOutputKeys(envelope);
|
|
5266
|
-
const lines = [];
|
|
5267
|
-
const sink = getOutputSink();
|
|
5268
|
-
printOutput(output, getOutputFormat(), (msg) => {
|
|
5269
|
-
lines.push(msg);
|
|
5270
|
-
}, needsAsciiSafeJson(sink));
|
|
5271
|
-
return lines.join(`
|
|
5272
|
-
`);
|
|
5273
6024
|
}
|
|
5274
|
-
|
|
5275
|
-
})(OutputFormatter ||= {});
|
|
6025
|
+
}
|
|
5276
6026
|
|
|
5277
6027
|
// ../common/src/telemetry/command-attribution.ts
|
|
5278
6028
|
var LEGACY_SKILL_NAMESPACE = "uipath:";
|
|
@@ -5518,8 +6268,7 @@ var pollSignalSlot = singleton("PollSignal");
|
|
|
5518
6268
|
var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
|
|
5519
6269
|
var processContext = {
|
|
5520
6270
|
exit: (code) => {
|
|
5521
|
-
|
|
5522
|
-
setExitCode(code);
|
|
6271
|
+
recordCommandExit(code);
|
|
5523
6272
|
},
|
|
5524
6273
|
get pollSignal() {
|
|
5525
6274
|
return pollSignalSlot.get();
|
|
@@ -5544,6 +6293,8 @@ function recordableArgValue(value, choices) {
|
|
|
5544
6293
|
function extractCommandParams(cmd) {
|
|
5545
6294
|
const params = {};
|
|
5546
6295
|
forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
|
|
6296
|
+
if (name === undefined)
|
|
6297
|
+
return;
|
|
5547
6298
|
const recordable = recordableArgValue(value, choices);
|
|
5548
6299
|
params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
|
|
5549
6300
|
});
|
|
@@ -5559,7 +6310,8 @@ function isDefaultedPositional(cmd, index) {
|
|
|
5559
6310
|
function forEachSuppliedArgument(cmd, visit) {
|
|
5560
6311
|
const registered = cmd.registeredArguments ?? [];
|
|
5561
6312
|
const processed = cmd.processedArgs ?? [];
|
|
5562
|
-
|
|
6313
|
+
const bound = boundPositionalCount(cmd);
|
|
6314
|
+
for (let i = 0;i < bound; i++) {
|
|
5563
6315
|
const name = registered[i].name();
|
|
5564
6316
|
if (name && processed[i] !== undefined) {
|
|
5565
6317
|
visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
|
|
@@ -5574,6 +6326,71 @@ function forEachSuppliedArgument(cmd, visit) {
|
|
|
5574
6326
|
visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
|
|
5575
6327
|
}
|
|
5576
6328
|
}
|
|
6329
|
+
forEachPassThroughToken(cmd, bound, (name, value) => {
|
|
6330
|
+
visit(name, value, name === undefined ? undefined : choicesByAttribute.get(name), false);
|
|
6331
|
+
});
|
|
6332
|
+
}
|
|
6333
|
+
function boundPositionalCount(cmd) {
|
|
6334
|
+
const registered = cmd.registeredArguments ?? [];
|
|
6335
|
+
if (registered.some((argument) => argument.variadic)) {
|
|
6336
|
+
return registered.length;
|
|
6337
|
+
}
|
|
6338
|
+
if ((cmd.args ?? []).length <= registered.length) {
|
|
6339
|
+
return registered.length;
|
|
6340
|
+
}
|
|
6341
|
+
const firstFlag = tokenizeTail(cmd, (cmd.args ?? []).slice(1)).tokens.find((token) => token.kind !== "operand")?.index ?? -1;
|
|
6342
|
+
return firstFlag === -1 ? registered.length : Math.min(registered.length, firstFlag + 1);
|
|
6343
|
+
}
|
|
6344
|
+
function forEachPassThroughToken(cmd, bound, visit) {
|
|
6345
|
+
const registered = cmd.registeredArguments ?? [];
|
|
6346
|
+
const fillsPositionals = !registered.some((argument) => argument.variadic);
|
|
6347
|
+
const { tokens, firstUnknown } = tokenizeTail(cmd, (cmd.args ?? []).slice(bound));
|
|
6348
|
+
const repeated = new Map;
|
|
6349
|
+
let nextPositional = bound;
|
|
6350
|
+
for (const token of tokens) {
|
|
6351
|
+
const pastUnknown = firstUnknown !== -1 && token.index > firstUnknown;
|
|
6352
|
+
if (token.kind === "sentinel")
|
|
6353
|
+
continue;
|
|
6354
|
+
if (token.kind === "operand") {
|
|
6355
|
+
const claimable = !pastUnknown && fillsPositionals && nextPositional < registered.length;
|
|
6356
|
+
const name = claimable ? registered[nextPositional++].name() : undefined;
|
|
6357
|
+
visit(name || undefined, token.text);
|
|
6358
|
+
continue;
|
|
6359
|
+
}
|
|
6360
|
+
if (token.kind === "unknown") {
|
|
6361
|
+
const bare = token.flag.replace(/^-+/, "");
|
|
6362
|
+
const key = bare.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
6363
|
+
const keyable = token.flag.startsWith("--") || token.flag.length === 2;
|
|
6364
|
+
if (!pastUnknown && keyable && /^[a-z][a-z0-9-]*$/i.test(bare) && key) {
|
|
6365
|
+
visit(key, token.inlineValue ?? true);
|
|
6366
|
+
} else {
|
|
6367
|
+
visit(undefined, token.text);
|
|
6368
|
+
if (token.inlineValue !== undefined) {
|
|
6369
|
+
visit(undefined, token.inlineValue);
|
|
6370
|
+
} else if (!token.flag.startsWith("--") && token.flag.length > 2) {
|
|
6371
|
+
visit(undefined, token.flag.slice(2));
|
|
6372
|
+
}
|
|
6373
|
+
}
|
|
6374
|
+
continue;
|
|
6375
|
+
}
|
|
6376
|
+
if (pastUnknown) {
|
|
6377
|
+
visit(undefined, token.text);
|
|
6378
|
+
if (token.value !== undefined)
|
|
6379
|
+
visit(undefined, token.value);
|
|
6380
|
+
continue;
|
|
6381
|
+
}
|
|
6382
|
+
const option = token.option;
|
|
6383
|
+
const name = option.attributeName();
|
|
6384
|
+
const value = option.negate ? false : option.required || option.optional ? token.value ?? true : true;
|
|
6385
|
+
const previous = repeated.get(name);
|
|
6386
|
+
if (previous) {
|
|
6387
|
+
previous.push(value);
|
|
6388
|
+
visit(name, previous);
|
|
6389
|
+
} else {
|
|
6390
|
+
repeated.set(name, [value]);
|
|
6391
|
+
visit(name, value);
|
|
6392
|
+
}
|
|
6393
|
+
}
|
|
5577
6394
|
}
|
|
5578
6395
|
function withheldArgumentValues(cmd) {
|
|
5579
6396
|
const values = [];
|
|
@@ -5635,6 +6452,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
5635
6452
|
const telemetryName = commandTelemetryName(commandParts);
|
|
5636
6453
|
const commandPath = commandInvocationPath(commandParts);
|
|
5637
6454
|
const props = typeof properties === "function" ? properties(...args) : properties;
|
|
6455
|
+
const projectResolver = getProjectTelemetryResolver(command);
|
|
6456
|
+
const projectSession = projectResolver && !isProjectTelemetryDisabled() ? new ProjectTelemetrySession(projectResolver, command) : undefined;
|
|
5638
6457
|
markCommandStart();
|
|
5639
6458
|
const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
|
|
5640
6459
|
try {
|
|
@@ -5647,6 +6466,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
5647
6466
|
if (violation) {
|
|
5648
6467
|
return Promise.reject(violation);
|
|
5649
6468
|
}
|
|
6469
|
+
if (projectSession) {
|
|
6470
|
+
return projectSession.resolve({ command, args, phase: "before" }).then(() => {
|
|
6471
|
+
attachProjectTelemetryCapture(command, projectSession);
|
|
6472
|
+
return fn(...args);
|
|
6473
|
+
});
|
|
6474
|
+
}
|
|
5650
6475
|
return fn(...args);
|
|
5651
6476
|
}));
|
|
5652
6477
|
if (error) {
|
|
@@ -5655,22 +6480,26 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
5655
6480
|
const typed = error;
|
|
5656
6481
|
const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
|
|
5657
6482
|
const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
|
|
5658
|
-
const
|
|
6483
|
+
const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
|
|
6484
|
+
const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
|
|
6485
|
+
const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
|
|
5659
6486
|
const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
|
|
5660
6487
|
const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
|
|
5661
6488
|
const typedRetry = typed.retry ?? typed.Retry;
|
|
5662
6489
|
const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
|
|
5663
6490
|
const typedContext = typed.context ?? typed.Context;
|
|
5664
6491
|
const customContext = isErrorContext(typedContext) ? typedContext : undefined;
|
|
5665
|
-
const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
|
|
5666
6492
|
fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
|
|
6493
|
+
const errorCode = customErrorCode ?? classified?.errorCode;
|
|
6494
|
+
const retry = customRetry ?? classified?.retry;
|
|
6495
|
+
const errorContext = customContext ?? classified?.context;
|
|
5667
6496
|
OutputFormatter.error({
|
|
5668
6497
|
Result: finalResult,
|
|
5669
|
-
...
|
|
6498
|
+
...errorCode ? { ErrorCode: errorCode } : {},
|
|
5670
6499
|
Message: errorMessage,
|
|
5671
6500
|
Instructions: customInstructions ?? commandHelpHint(commandPath),
|
|
5672
|
-
...
|
|
5673
|
-
...
|
|
6501
|
+
...retry ? { Retry: retry } : {},
|
|
6502
|
+
...errorContext ? { Context: errorContext } : {}
|
|
5674
6503
|
});
|
|
5675
6504
|
context.exit(fallbackExitCode);
|
|
5676
6505
|
}
|
|
@@ -5679,6 +6508,14 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
5679
6508
|
const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
|
|
5680
6509
|
const recordedFailure = takeRecordedCommandFailureTelemetry();
|
|
5681
6510
|
const success = !error && exitCode === 0;
|
|
6511
|
+
if (projectSession) {
|
|
6512
|
+
await projectSession.resolve({
|
|
6513
|
+
command,
|
|
6514
|
+
args,
|
|
6515
|
+
phase: "after",
|
|
6516
|
+
success
|
|
6517
|
+
});
|
|
6518
|
+
}
|
|
5682
6519
|
const terminalTelemetry = buildCommandTerminalTelemetryProperties({
|
|
5683
6520
|
error,
|
|
5684
6521
|
exitCode,
|
|
@@ -5696,6 +6533,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
5696
6533
|
}
|
|
5697
6534
|
const baseProperties = redactProperties({
|
|
5698
6535
|
...commandParams,
|
|
6536
|
+
...projectSession?.properties(),
|
|
5699
6537
|
...props,
|
|
5700
6538
|
...buildCommandTelemetryAttribution(commandPath, process.env.UIPATH_SKILL),
|
|
5701
6539
|
...buildAgentSessionTelemetry(process.env),
|
|
@@ -5706,6 +6544,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
5706
6544
|
});
|
|
5707
6545
|
emitInvocationRequest(telemetryName, success, baseProperties);
|
|
5708
6546
|
} finally {
|
|
6547
|
+
if (projectSession)
|
|
6548
|
+
attachProjectTelemetryCapture(command, undefined);
|
|
5709
6549
|
releaseSuppliedArgumentValues(supplied);
|
|
5710
6550
|
}
|
|
5711
6551
|
});
|
|
@@ -5742,57 +6582,41 @@ function withPseudonymizedIdentifiers(payload) {
|
|
|
5742
6582
|
}
|
|
5743
6583
|
};
|
|
5744
6584
|
}
|
|
5745
|
-
function
|
|
6585
|
+
function identityKeysOf(capture) {
|
|
6586
|
+
if (!capture) {
|
|
6587
|
+
return {};
|
|
6588
|
+
}
|
|
6589
|
+
try {
|
|
6590
|
+
const properties = capture.properties?.();
|
|
6591
|
+
if (typeof properties !== "object" || properties === null) {
|
|
6592
|
+
return {};
|
|
6593
|
+
}
|
|
6594
|
+
const keys = {};
|
|
6595
|
+
for (const key of GUID_KEY_DIMENSIONS) {
|
|
6596
|
+
const value = properties[key];
|
|
6597
|
+
if (value !== undefined) {
|
|
6598
|
+
keys[key] = value;
|
|
6599
|
+
}
|
|
6600
|
+
}
|
|
6601
|
+
return keys;
|
|
6602
|
+
} catch (error) {
|
|
6603
|
+
logSkipped("ship identity", error);
|
|
6604
|
+
return {};
|
|
6605
|
+
}
|
|
6606
|
+
}
|
|
6607
|
+
function trackShipSucceeded(payload, capture) {
|
|
5746
6608
|
const keys = getShippedKeys();
|
|
5747
6609
|
const key = dedupeKey(payload);
|
|
5748
6610
|
if (keys.has(key)) {
|
|
5749
6611
|
return false;
|
|
5750
6612
|
}
|
|
5751
6613
|
keys.add(key);
|
|
5752
|
-
telemetry.trackEvent(CommonTelemetryEvents.ShipSucceeded, redactProperties(
|
|
6614
|
+
telemetry.trackEvent(CommonTelemetryEvents.ShipSucceeded, redactProperties({
|
|
6615
|
+
...withPseudonymizedIdentifiers(payload),
|
|
6616
|
+
...identityKeysOf(capture)
|
|
6617
|
+
}));
|
|
5753
6618
|
return true;
|
|
5754
6619
|
}
|
|
5755
|
-
|
|
5756
|
-
// ../common/src/error-handler.ts
|
|
5757
|
-
var DEFAULT_401 = "Unauthorized (401). The session is missing or expired, or its token carries no scope for this API. Run `uip login status --detailed` to see the session and its scopes.";
|
|
5758
|
-
var NETWORK_ERROR_CODES = new Set([
|
|
5759
|
-
"ECONNREFUSED",
|
|
5760
|
-
"ECONNRESET",
|
|
5761
|
-
"ENOTFOUND",
|
|
5762
|
-
"EAI_AGAIN",
|
|
5763
|
-
"ETIMEDOUT",
|
|
5764
|
-
"EPIPE",
|
|
5765
|
-
"EHOSTUNREACH",
|
|
5766
|
-
"ENETUNREACH",
|
|
5767
|
-
"EAI_FAIL"
|
|
5768
|
-
]);
|
|
5769
|
-
var TLS_ERROR_CODES2 = new Set([
|
|
5770
|
-
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
5771
|
-
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
5772
|
-
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
5773
|
-
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
5774
|
-
"UNABLE_TO_GET_ISSUER_CERT",
|
|
5775
|
-
"CERT_HAS_EXPIRED",
|
|
5776
|
-
"CERT_UNTRUSTED",
|
|
5777
|
-
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
5778
|
-
]);
|
|
5779
|
-
var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
|
|
5780
|
-
var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
|
|
5781
|
-
var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
|
|
5782
|
-
function extractErrorMessageSync(error) {
|
|
5783
|
-
if (error instanceof Error) {
|
|
5784
|
-
return error.message;
|
|
5785
|
-
}
|
|
5786
|
-
if (typeof error === "object" && error !== null) {
|
|
5787
|
-
if ("status" in error && error.status === 401) {
|
|
5788
|
-
return DEFAULT_401;
|
|
5789
|
-
}
|
|
5790
|
-
if ("message" in error && typeof error.message === "string") {
|
|
5791
|
-
return error.message;
|
|
5792
|
-
}
|
|
5793
|
-
}
|
|
5794
|
-
return describeThrownValue(error);
|
|
5795
|
-
}
|
|
5796
6620
|
// ../common/src/command-examples.ts
|
|
5797
6621
|
var examplesByCommand = new WeakMap;
|
|
5798
6622
|
Command.prototype.examples = function(examples) {
|
|
@@ -6273,9 +7097,9 @@ function getProfileStorage() {
|
|
|
6273
7097
|
if (isAuthProfileStorage(existing)) {
|
|
6274
7098
|
return existing;
|
|
6275
7099
|
}
|
|
6276
|
-
const
|
|
6277
|
-
globalSlot2[AUTH_PROFILE_STORAGE_KEY] =
|
|
6278
|
-
return
|
|
7100
|
+
const storage = createProfileStorage();
|
|
7101
|
+
globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
|
|
7102
|
+
return storage;
|
|
6279
7103
|
}
|
|
6280
7104
|
var profileStorage = getProfileStorage();
|
|
6281
7105
|
|
|
@@ -6306,8 +7130,8 @@ function resolveAuthProfileFilePath(profile) {
|
|
|
6306
7130
|
if (normalized === undefined) {
|
|
6307
7131
|
throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
|
|
6308
7132
|
}
|
|
6309
|
-
const
|
|
6310
|
-
return
|
|
7133
|
+
const fs = getFileSystem();
|
|
7134
|
+
return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR2, PROFILE_DIR, normalized, AUTH_FILENAME);
|
|
6311
7135
|
}
|
|
6312
7136
|
function getActiveAuthProfileFilePath() {
|
|
6313
7137
|
const profile = getActiveAuthProfile();
|
|
@@ -6480,6 +7304,8 @@ var ENV_AUTH_VARS = {
|
|
|
6480
7304
|
};
|
|
6481
7305
|
|
|
6482
7306
|
class EnvAuthConfigError extends Error {
|
|
7307
|
+
errorCode = "configuration_error";
|
|
7308
|
+
retry = "RetryWillNotFix";
|
|
6483
7309
|
constructor(message) {
|
|
6484
7310
|
super(message);
|
|
6485
7311
|
this.name = "EnvAuthConfigError";
|
|
@@ -6518,11 +7344,11 @@ var readAuthFromEnv = () => {
|
|
|
6518
7344
|
if (!rawUrl) {
|
|
6519
7345
|
throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} is not a JWT (treating it as an opaque token, ` + `e.g. a Personal Access Token). Set ${OPAQUE_TOKEN_BASE_URL_VAR} to the ` + `UiPath base URL if this is a PAT, or fix the token if it was meant to ` + `be a JWT (parse error: ${parseErrorMessage}).`);
|
|
6520
7346
|
}
|
|
6521
|
-
const
|
|
7347
|
+
const baseUrl = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
|
|
6522
7348
|
return {
|
|
6523
7349
|
loginStatus: "Logged in",
|
|
6524
7350
|
accessToken,
|
|
6525
|
-
baseUrl
|
|
7351
|
+
baseUrl,
|
|
6526
7352
|
organizationName,
|
|
6527
7353
|
organizationId,
|
|
6528
7354
|
tenantName,
|
|
@@ -6563,8 +7389,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
|
|
|
6563
7389
|
async function refreshTokenFingerprint(refreshToken) {
|
|
6564
7390
|
const bytes = new TextEncoder().encode(refreshToken);
|
|
6565
7391
|
if (globalThis.crypto?.subtle) {
|
|
6566
|
-
const
|
|
6567
|
-
return Array.from(new Uint8Array(
|
|
7392
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
7393
|
+
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
|
|
6568
7394
|
}
|
|
6569
7395
|
const { createHash } = await import("node:crypto");
|
|
6570
7396
|
return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
@@ -6573,9 +7399,9 @@ function breakerPathFor(authPath) {
|
|
|
6573
7399
|
return `${authPath}${BREAKER_SUFFIX}`;
|
|
6574
7400
|
}
|
|
6575
7401
|
async function loadRefreshBreaker(authPath) {
|
|
6576
|
-
const
|
|
7402
|
+
const fs = getFileSystem();
|
|
6577
7403
|
try {
|
|
6578
|
-
const content = await
|
|
7404
|
+
const content = await fs.readFile(breakerPathFor(authPath), "utf-8");
|
|
6579
7405
|
if (!content)
|
|
6580
7406
|
return {};
|
|
6581
7407
|
const parsed = JSON.parse(content);
|
|
@@ -6586,20 +7412,20 @@ async function loadRefreshBreaker(authPath) {
|
|
|
6586
7412
|
}
|
|
6587
7413
|
async function saveRefreshBreaker(authPath, state) {
|
|
6588
7414
|
try {
|
|
6589
|
-
const
|
|
6590
|
-
const
|
|
6591
|
-
await
|
|
6592
|
-
const tempPath = `${
|
|
6593
|
-
await
|
|
6594
|
-
await
|
|
7415
|
+
const fs = getFileSystem();
|
|
7416
|
+
const path = breakerPathFor(authPath);
|
|
7417
|
+
await fs.mkdir(fs.path.dirname(path));
|
|
7418
|
+
const tempPath = `${path}.tmp`;
|
|
7419
|
+
await fs.writeFile(tempPath, JSON.stringify(state));
|
|
7420
|
+
await fs.rename(tempPath, path);
|
|
6595
7421
|
} catch {}
|
|
6596
7422
|
}
|
|
6597
7423
|
async function clearRefreshBreaker(authPath) {
|
|
6598
|
-
const
|
|
6599
|
-
const
|
|
7424
|
+
const fs = getFileSystem();
|
|
7425
|
+
const path = breakerPathFor(authPath);
|
|
6600
7426
|
try {
|
|
6601
|
-
if (await
|
|
6602
|
-
await
|
|
7427
|
+
if (await fs.exists(path)) {
|
|
7428
|
+
await fs.rm(path);
|
|
6603
7429
|
}
|
|
6604
7430
|
} catch {}
|
|
6605
7431
|
}
|
|
@@ -6620,13 +7446,13 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
|
6620
7446
|
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
6621
7447
|
var PIPE_NAME_MAX_LENGTH = 103;
|
|
6622
7448
|
var getRobotIpcPipeNames = async () => {
|
|
6623
|
-
const
|
|
6624
|
-
const username =
|
|
7449
|
+
const fs = getFileSystem();
|
|
7450
|
+
const username = fs.env.getenv("USER") ?? fs.env.getenv("USERNAME");
|
|
6625
7451
|
if (!username) {
|
|
6626
7452
|
throw new Error("Unable to determine current username");
|
|
6627
7453
|
}
|
|
6628
|
-
const tempPath =
|
|
6629
|
-
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) =>
|
|
7454
|
+
const tempPath = fs.env.getenv("TMPDIR") ?? "/tmp/";
|
|
7455
|
+
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
|
|
6630
7456
|
};
|
|
6631
7457
|
var defaultIsRobotIpcAvailable = async () => {
|
|
6632
7458
|
if (process.platform === "win32") {
|
|
@@ -6636,20 +7462,20 @@ var defaultIsRobotIpcAvailable = async () => {
|
|
|
6636
7462
|
if (pipeNamesError || !pipeNames) {
|
|
6637
7463
|
return false;
|
|
6638
7464
|
}
|
|
6639
|
-
const
|
|
7465
|
+
const fs = getFileSystem();
|
|
6640
7466
|
for (const pipeName of pipeNames) {
|
|
6641
|
-
const [existsError, exists] = await catchError2(
|
|
7467
|
+
const [existsError, exists] = await catchError2(fs.exists(pipeName));
|
|
6642
7468
|
if (!existsError && exists === true) {
|
|
6643
7469
|
return true;
|
|
6644
7470
|
}
|
|
6645
7471
|
}
|
|
6646
7472
|
return false;
|
|
6647
7473
|
};
|
|
6648
|
-
var withTimeout = (promise, timeoutMs) => new Promise((
|
|
7474
|
+
var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
|
|
6649
7475
|
const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
6650
7476
|
promise.then((value) => {
|
|
6651
7477
|
clearTimeout(timer);
|
|
6652
|
-
|
|
7478
|
+
resolve(value);
|
|
6653
7479
|
}, (error) => {
|
|
6654
7480
|
clearTimeout(timer);
|
|
6655
7481
|
reject(error);
|
|
@@ -6822,9 +7648,12 @@ var refreshAccessToken = async ({
|
|
|
6822
7648
|
body: tokenParams
|
|
6823
7649
|
});
|
|
6824
7650
|
const tokenData = await tokenResponse.json();
|
|
6825
|
-
if (
|
|
7651
|
+
if (tokenResponse.status === 400 || tokenResponse.status === 401) {
|
|
6826
7652
|
throw new TokenRefreshOAuthError;
|
|
6827
7653
|
}
|
|
7654
|
+
if (!tokenResponse.ok) {
|
|
7655
|
+
throw new Error(`Token refresh failed: HTTP ${tokenResponse.status}`);
|
|
7656
|
+
}
|
|
6828
7657
|
const newAccessToken = tokenData.access_token;
|
|
6829
7658
|
const newRefreshToken = tokenData.refresh_token;
|
|
6830
7659
|
if (typeof newAccessToken !== "string" || typeof newRefreshToken !== "string") {
|
|
@@ -6856,9 +7685,9 @@ var errorCode = (err) => {
|
|
|
6856
7685
|
}
|
|
6857
7686
|
return "EUNKNOWN";
|
|
6858
7687
|
};
|
|
6859
|
-
var probeAsync = async (
|
|
7688
|
+
var probeAsync = async (fs, candidate) => {
|
|
6860
7689
|
try {
|
|
6861
|
-
const stats = await
|
|
7690
|
+
const stats = await fs.stat(candidate);
|
|
6862
7691
|
if (stats === null) {
|
|
6863
7692
|
return { exists: false };
|
|
6864
7693
|
}
|
|
@@ -6885,36 +7714,36 @@ var probeAsync = async (fs2, candidate) => {
|
|
|
6885
7714
|
}
|
|
6886
7715
|
};
|
|
6887
7716
|
var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
|
|
6888
|
-
const
|
|
6889
|
-
if (
|
|
6890
|
-
const
|
|
6891
|
-
return
|
|
7717
|
+
const fs = getFileSystem();
|
|
7718
|
+
if (fs.path.isAbsolute(envFilePath)) {
|
|
7719
|
+
const probe = await probeAsync(fs, envFilePath);
|
|
7720
|
+
return probe.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
|
|
6892
7721
|
exists: false,
|
|
6893
7722
|
absolutePath: envFilePath,
|
|
6894
7723
|
source: "absolute",
|
|
6895
|
-
...
|
|
7724
|
+
...probe.unusable ? { unusable: probe.unusable } : {}
|
|
6896
7725
|
};
|
|
6897
7726
|
}
|
|
6898
|
-
const cwd = opts?.cwd ??
|
|
7727
|
+
const cwd = opts?.cwd ?? fs.env.cwd();
|
|
6899
7728
|
let searchDir = cwd;
|
|
6900
7729
|
while (true) {
|
|
6901
|
-
const candidate =
|
|
6902
|
-
const
|
|
6903
|
-
if (
|
|
7730
|
+
const candidate = fs.path.join(searchDir, envFilePath);
|
|
7731
|
+
const probe = await probeAsync(fs, candidate);
|
|
7732
|
+
if (probe.exists) {
|
|
6904
7733
|
return {
|
|
6905
7734
|
exists: true,
|
|
6906
7735
|
absolutePath: candidate,
|
|
6907
7736
|
source: searchDir === cwd ? "cwd" : "ancestor"
|
|
6908
7737
|
};
|
|
6909
7738
|
}
|
|
6910
|
-
const parentDir =
|
|
7739
|
+
const parentDir = fs.path.dirname(searchDir);
|
|
6911
7740
|
if (parentDir === searchDir) {
|
|
6912
7741
|
break;
|
|
6913
7742
|
}
|
|
6914
7743
|
searchDir = parentDir;
|
|
6915
7744
|
}
|
|
6916
|
-
const homePath =
|
|
6917
|
-
const probe = await probeAsync(
|
|
7745
|
+
const homePath = fs.path.join(fs.env.homedir(), envFilePath);
|
|
7746
|
+
const probe = await probeAsync(fs, homePath);
|
|
6918
7747
|
if (probe.exists) {
|
|
6919
7748
|
return { exists: true, absolutePath: homePath, source: "home" };
|
|
6920
7749
|
}
|
|
@@ -6957,12 +7786,12 @@ var parseEnvContent = (content) => {
|
|
|
6957
7786
|
return env;
|
|
6958
7787
|
};
|
|
6959
7788
|
var loadEnvFileAsync = async ({ envPath }) => {
|
|
6960
|
-
const
|
|
6961
|
-
const absolutePath =
|
|
6962
|
-
if (!await
|
|
7789
|
+
const fs = getFileSystem();
|
|
7790
|
+
const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
|
|
7791
|
+
if (!await fs.exists(absolutePath)) {
|
|
6963
7792
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
6964
7793
|
}
|
|
6965
|
-
const content = await
|
|
7794
|
+
const content = await fs.readFile(absolutePath, "utf-8");
|
|
6966
7795
|
if (content === null) {
|
|
6967
7796
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
6968
7797
|
}
|
|
@@ -6973,10 +7802,10 @@ var saveEnvFileAsync = async ({
|
|
|
6973
7802
|
data,
|
|
6974
7803
|
merge = true
|
|
6975
7804
|
}) => {
|
|
6976
|
-
const
|
|
6977
|
-
const absolutePath =
|
|
7805
|
+
const fs = getFileSystem();
|
|
7806
|
+
const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.homedir(), envPath);
|
|
6978
7807
|
let existingData = {};
|
|
6979
|
-
if (merge && await
|
|
7808
|
+
if (merge && await fs.exists(absolutePath)) {
|
|
6980
7809
|
try {
|
|
6981
7810
|
existingData = await loadEnvFileAsync({ envPath: absolutePath });
|
|
6982
7811
|
} catch {}
|
|
@@ -6994,11 +7823,11 @@ var saveEnvFileAsync = async ({
|
|
|
6994
7823
|
const content = `${lines.join(`
|
|
6995
7824
|
`)}
|
|
6996
7825
|
`;
|
|
6997
|
-
const dir =
|
|
6998
|
-
await
|
|
7826
|
+
const dir = fs.path.dirname(absolutePath);
|
|
7827
|
+
await fs.mkdir(dir);
|
|
6999
7828
|
const tempPath = `${absolutePath}.tmp`;
|
|
7000
|
-
await
|
|
7001
|
-
await
|
|
7829
|
+
await fs.writeFile(tempPath, content);
|
|
7830
|
+
await fs.rename(tempPath, absolutePath);
|
|
7002
7831
|
};
|
|
7003
7832
|
|
|
7004
7833
|
// ../auth/src/loginStatus.ts
|
|
@@ -7122,11 +7951,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
|
7122
7951
|
return { credentials };
|
|
7123
7952
|
}
|
|
7124
7953
|
async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
|
|
7125
|
-
const
|
|
7126
|
-
const globalPath =
|
|
7954
|
+
const fs = getFs();
|
|
7955
|
+
const globalPath = fs.path.join(fs.env.homedir(), envFilePath);
|
|
7127
7956
|
if (absolutePath === globalPath)
|
|
7128
7957
|
return;
|
|
7129
|
-
if (!await
|
|
7958
|
+
if (!await fs.exists(globalPath))
|
|
7130
7959
|
return;
|
|
7131
7960
|
try {
|
|
7132
7961
|
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
@@ -7543,6 +8372,49 @@ function errorMessage(error) {
|
|
|
7543
8372
|
}
|
|
7544
8373
|
|
|
7545
8374
|
// ../auth/src/authContext.ts
|
|
8375
|
+
class AuthContextUnavailableError extends Error {
|
|
8376
|
+
instructionContext;
|
|
8377
|
+
sessionHint;
|
|
8378
|
+
errorCode = "authentication_required";
|
|
8379
|
+
retry = "RetryWillNotFix";
|
|
8380
|
+
constructor(message, instructionContext = "auth", sessionHint) {
|
|
8381
|
+
super(message);
|
|
8382
|
+
this.instructionContext = instructionContext;
|
|
8383
|
+
this.sessionHint = sessionHint;
|
|
8384
|
+
this.name = "AuthContextUnavailableError";
|
|
8385
|
+
}
|
|
8386
|
+
}
|
|
8387
|
+
var getAuthContext = async (options = {}) => {
|
|
8388
|
+
const status = await getLoginStatusAsync({
|
|
8389
|
+
ensureTokenValidityMinutes: options.ensureTokenValidityMinutes,
|
|
8390
|
+
envFilePath: options.envFilePath
|
|
8391
|
+
});
|
|
8392
|
+
if (status.loginStatus !== "Logged in" || !status.baseUrl || !status.accessToken) {
|
|
8393
|
+
throw new AuthContextUnavailableError(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.", "auth", status.hint);
|
|
8394
|
+
}
|
|
8395
|
+
const tenantName = options.tenant || status.tenantName;
|
|
8396
|
+
if (options.requireOrganizationId && !status.organizationId) {
|
|
8397
|
+
throw new AuthContextUnavailableError("Organization ID not available. Ensure you are logged in with an organization context.", "identity");
|
|
8398
|
+
}
|
|
8399
|
+
if (options.requireOrganizationName && !status.organizationName) {
|
|
8400
|
+
throw new AuthContextUnavailableError("Organization name not available. Ensure you are logged in with an organization context.", "identity");
|
|
8401
|
+
}
|
|
8402
|
+
if (options.requireTenantId && !status.tenantId) {
|
|
8403
|
+
throw new AuthContextUnavailableError(`Tenant ID not available. Ensure UIPATH_TENANT_ID is set.${status.hint ? ` ${status.hint}` : ""}`, "identity", status.hint);
|
|
8404
|
+
}
|
|
8405
|
+
if (options.requireTenantName && !tenantName) {
|
|
8406
|
+
throw new AuthContextUnavailableError("Tenant not provided and UIPATH_TENANT_NAME not set. Run 'uip login' to select a tenant, or use 'uip login tenant set <tenant>' to switch tenants.", "identity");
|
|
8407
|
+
}
|
|
8408
|
+
return {
|
|
8409
|
+
baseUrl: status.baseUrl,
|
|
8410
|
+
accessToken: status.accessToken,
|
|
8411
|
+
organizationId: status.organizationId,
|
|
8412
|
+
organizationName: status.organizationName,
|
|
8413
|
+
tenantId: status.tenantId,
|
|
8414
|
+
tenantName,
|
|
8415
|
+
identity: status.identity
|
|
8416
|
+
};
|
|
8417
|
+
};
|
|
7546
8418
|
var getAuthEnv = async (options = {}) => {
|
|
7547
8419
|
const authEnv = {};
|
|
7548
8420
|
let status;
|
|
@@ -7557,7 +8429,7 @@ var getAuthEnv = async (options = {}) => {
|
|
|
7557
8429
|
const org = status.organizationName || status.organizationId;
|
|
7558
8430
|
const tenant = status.tenantName || status.tenantId;
|
|
7559
8431
|
if (org && tenant) {
|
|
7560
|
-
authEnv.UIPATH_URL = `${status.baseUrl.replace(/\/+$/, "")}/${org}/${tenant}`;
|
|
8432
|
+
authEnv.UIPATH_URL = `${status.baseUrl.replace(/\/+$/, "")}/${encodeURIComponent(org)}/${encodeURIComponent(tenant)}`;
|
|
7561
8433
|
}
|
|
7562
8434
|
}
|
|
7563
8435
|
if (status.organizationId)
|
|
@@ -7580,11 +8452,11 @@ var TENANT_SELECTION_CODES = new Set([
|
|
|
7580
8452
|
]);
|
|
7581
8453
|
// ../uipath-python-bridge/src/cache.ts
|
|
7582
8454
|
async function readCache(cacheFile) {
|
|
7583
|
-
const
|
|
7584
|
-
const [existsError, exists] = await catchError(
|
|
8455
|
+
const fs = getFileSystem();
|
|
8456
|
+
const [existsError, exists] = await catchError(fs.exists(cacheFile));
|
|
7585
8457
|
if (existsError || !exists)
|
|
7586
8458
|
return null;
|
|
7587
|
-
const [readError, content] = await catchError(
|
|
8459
|
+
const [readError, content] = await catchError(fs.readFile(cacheFile, "utf-8"));
|
|
7588
8460
|
if (readError) {
|
|
7589
8461
|
logger.warn(`Failed to load cache: ${readError}`);
|
|
7590
8462
|
return null;
|
|
@@ -7596,12 +8468,63 @@ async function readCache(cacheFile) {
|
|
|
7596
8468
|
}
|
|
7597
8469
|
return cache;
|
|
7598
8470
|
}
|
|
8471
|
+
// ../uipath-python-bridge/package.json
|
|
8472
|
+
var package_default = {
|
|
8473
|
+
name: "@uipath/uipath-python-bridge",
|
|
8474
|
+
author: "UiPath",
|
|
8475
|
+
license: "SEE LICENSE IN LICENSE.txt",
|
|
8476
|
+
version: "1.206.0-preview.279",
|
|
8477
|
+
description: "Shared Python detection, caching, and CLI bridge for UiPath Python SDK tools.",
|
|
8478
|
+
keywords: [
|
|
8479
|
+
"uip",
|
|
8480
|
+
"python",
|
|
8481
|
+
"bridge"
|
|
8482
|
+
],
|
|
8483
|
+
uipath: {
|
|
8484
|
+
requires: {
|
|
8485
|
+
uipath: ">=2.14.41"
|
|
8486
|
+
}
|
|
8487
|
+
},
|
|
8488
|
+
type: "module",
|
|
8489
|
+
main: "./dist/index.js",
|
|
8490
|
+
exports: {
|
|
8491
|
+
".": "./dist/index.js"
|
|
8492
|
+
},
|
|
8493
|
+
files: [
|
|
8494
|
+
"dist"
|
|
8495
|
+
],
|
|
8496
|
+
repository: {
|
|
8497
|
+
type: "git",
|
|
8498
|
+
url: "https://github.com/UiPath/cli.git",
|
|
8499
|
+
directory: "packages/uipath-python-bridge"
|
|
8500
|
+
},
|
|
8501
|
+
publishConfig: {
|
|
8502
|
+
registry: "https://npm.pkg.github.com/@uipath"
|
|
8503
|
+
},
|
|
8504
|
+
scripts: {
|
|
8505
|
+
build: "bun build ./src/index.ts --outdir dist --format esm --target node --external applicationinsights --sourcemap=linked",
|
|
8506
|
+
typecheck: "tsc --noEmit",
|
|
8507
|
+
test: "vitest run",
|
|
8508
|
+
"test:coverage": "vitest run --coverage",
|
|
8509
|
+
lint: "biome check .",
|
|
8510
|
+
"lint:fix": "biome check --write ."
|
|
8511
|
+
},
|
|
8512
|
+
devDependencies: {
|
|
8513
|
+
"@uipath/auth": "workspace:*",
|
|
8514
|
+
"@uipath/common": "workspace:*",
|
|
8515
|
+
"@uipath/filesystem": "workspace:*",
|
|
8516
|
+
"@types/bun": "^1.3.11",
|
|
8517
|
+
commander: "^14.0.3",
|
|
8518
|
+
typescript: "^7.0.2"
|
|
8519
|
+
}
|
|
8520
|
+
};
|
|
7599
8521
|
|
|
7600
8522
|
// ../uipath-python-bridge/src/config.ts
|
|
7601
8523
|
var DEFAULT_CONFIG = {
|
|
7602
|
-
allowedPythonVersions: ["3.14", "3.13", "3.12", "3.11"],
|
|
8524
|
+
allowedPythonVersions: ["3.14", "3.13", "3.12", "3.11", "3.15"],
|
|
7603
8525
|
packageName: "uipath",
|
|
7604
|
-
cacheFileName: ".uipath-python-cache.json"
|
|
8526
|
+
cacheFileName: ".uipath-python-cache.json",
|
|
8527
|
+
uipathVersionRequirement: package_default.uipath.requires.uipath
|
|
7605
8528
|
};
|
|
7606
8529
|
function getAllowedPythonVersions() {
|
|
7607
8530
|
const envVersions = process.env.PYTHON_TOOL_PYTHON_VERSIONS;
|
|
@@ -7616,6 +8539,9 @@ function getPackageName() {
|
|
|
7616
8539
|
function getCacheFileName() {
|
|
7617
8540
|
return DEFAULT_CONFIG.cacheFileName;
|
|
7618
8541
|
}
|
|
8542
|
+
function getUipathVersionRequirement() {
|
|
8543
|
+
return DEFAULT_CONFIG.uipathVersionRequirement;
|
|
8544
|
+
}
|
|
7619
8545
|
function matchesPattern(args, pattern) {
|
|
7620
8546
|
if (typeof pattern === "string") {
|
|
7621
8547
|
return args.includes(pattern);
|
|
@@ -7680,7 +8606,7 @@ function hasTypeOption(args) {
|
|
|
7680
8606
|
return args.some((arg) => TYPE_OPTION.test(arg));
|
|
7681
8607
|
}
|
|
7682
8608
|
async function supportsNewTypeOption(exePath, cwd, env = {}, signal) {
|
|
7683
|
-
return new Promise((
|
|
8609
|
+
return new Promise((resolve) => {
|
|
7684
8610
|
execFile(exePath, ["new", "--help"], {
|
|
7685
8611
|
cwd,
|
|
7686
8612
|
env: { ...process.env, ...env },
|
|
@@ -7688,10 +8614,136 @@ async function supportsNewTypeOption(exePath, cwd, env = {}, signal) {
|
|
|
7688
8614
|
windowsHide: true,
|
|
7689
8615
|
signal
|
|
7690
8616
|
}, (error, stdout) => {
|
|
7691
|
-
|
|
8617
|
+
resolve(!error && TYPE_LISTED.test(typeof stdout === "string" ? stdout : ""));
|
|
8618
|
+
});
|
|
8619
|
+
});
|
|
8620
|
+
}
|
|
8621
|
+
|
|
8622
|
+
// ../uipath-python-bridge/src/uipath-version.ts
|
|
8623
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
8624
|
+
|
|
8625
|
+
// ../uipath-python-bridge/src/package-version.ts
|
|
8626
|
+
var VERSION_RE = /^v?(\d+)\.(\d+)(?:\.(\d+))?/;
|
|
8627
|
+
function parseSimpleVersion(raw) {
|
|
8628
|
+
const match = raw.trim().match(VERSION_RE);
|
|
8629
|
+
if (!match)
|
|
8630
|
+
return null;
|
|
8631
|
+
return {
|
|
8632
|
+
major: Number(match[1]),
|
|
8633
|
+
minor: Number(match[2]),
|
|
8634
|
+
patch: match[3] === undefined ? 0 : Number(match[3])
|
|
8635
|
+
};
|
|
8636
|
+
}
|
|
8637
|
+
function compareSimpleVersion(a, b) {
|
|
8638
|
+
return a.major - b.major || a.minor - b.minor || a.patch - b.patch;
|
|
8639
|
+
}
|
|
8640
|
+
var MINIMUM_RE = /^>=\s*(\d+)\.(\d+)\.(\d+)$/;
|
|
8641
|
+
function parseMinimumVersion(specifier) {
|
|
8642
|
+
const match = specifier.trim().match(MINIMUM_RE);
|
|
8643
|
+
if (!match)
|
|
8644
|
+
return null;
|
|
8645
|
+
return {
|
|
8646
|
+
major: Number(match[1]),
|
|
8647
|
+
minor: Number(match[2]),
|
|
8648
|
+
patch: Number(match[3])
|
|
8649
|
+
};
|
|
8650
|
+
}
|
|
8651
|
+
function formatSimpleVersion(version) {
|
|
8652
|
+
return `${version.major}.${version.minor}.${version.patch}`;
|
|
8653
|
+
}
|
|
8654
|
+
|
|
8655
|
+
// ../uipath-python-bridge/src/uipath-version.ts
|
|
8656
|
+
var VERSION_LINE = /uipath\s+version\s+(\S+)/i;
|
|
8657
|
+
async function probeUipathVersion(exePath, options = {}) {
|
|
8658
|
+
return new Promise((resolve) => {
|
|
8659
|
+
execFile2(exePath, ["--version"], {
|
|
8660
|
+
cwd: options.cwd,
|
|
8661
|
+
encoding: "utf-8",
|
|
8662
|
+
windowsHide: true,
|
|
8663
|
+
signal: options.signal
|
|
8664
|
+
}, (error, stdout, stderr) => {
|
|
8665
|
+
const out = typeof stdout === "string" ? stdout.trim() : "";
|
|
8666
|
+
const err = typeof stderr === "string" ? stderr.trim() : "";
|
|
8667
|
+
if (error) {
|
|
8668
|
+
resolve({ error: describeProbeError(exePath, error, err) });
|
|
8669
|
+
return;
|
|
8670
|
+
}
|
|
8671
|
+
const match = out.match(VERSION_LINE);
|
|
8672
|
+
if (!match) {
|
|
8673
|
+
resolve({
|
|
8674
|
+
error: `Could not parse version from '${exePath} --version' output: ${out || "<empty>"}`
|
|
8675
|
+
});
|
|
8676
|
+
return;
|
|
8677
|
+
}
|
|
8678
|
+
resolve({ version: match[1] });
|
|
7692
8679
|
});
|
|
7693
8680
|
});
|
|
7694
8681
|
}
|
|
8682
|
+
function describeProbeError(exePath, error, stderr) {
|
|
8683
|
+
if (typeof error.code === "number") {
|
|
8684
|
+
return `'${exePath} --version' exited with code ${error.code}${stderr ? `: ${stderr}` : ""}`;
|
|
8685
|
+
}
|
|
8686
|
+
return `Failed to run '${exePath} --version': ${error.message}`;
|
|
8687
|
+
}
|
|
8688
|
+
function resolveRequirement() {
|
|
8689
|
+
const requirement = getUipathVersionRequirement();
|
|
8690
|
+
const minimum = parseMinimumVersion(requirement);
|
|
8691
|
+
if (!minimum) {
|
|
8692
|
+
return {
|
|
8693
|
+
requirement,
|
|
8694
|
+
invalid: {
|
|
8695
|
+
ok: false,
|
|
8696
|
+
kind: "unverifiable",
|
|
8697
|
+
requirement,
|
|
8698
|
+
message: `Invalid uipath version requirement '${requirement}' declared by @uipath/uipath-python-bridge.`
|
|
8699
|
+
}
|
|
8700
|
+
};
|
|
8701
|
+
}
|
|
8702
|
+
return { requirement, minimum };
|
|
8703
|
+
}
|
|
8704
|
+
function judge(version, exePath, requirement, minimum) {
|
|
8705
|
+
const parsed = parseSimpleVersion(version);
|
|
8706
|
+
if (!parsed) {
|
|
8707
|
+
return {
|
|
8708
|
+
ok: false,
|
|
8709
|
+
kind: "unverifiable",
|
|
8710
|
+
requirement,
|
|
8711
|
+
message: `Could not read uipath version '${version}' reported by ${exePath}.`
|
|
8712
|
+
};
|
|
8713
|
+
}
|
|
8714
|
+
if (compareSimpleVersion(parsed, minimum) < 0) {
|
|
8715
|
+
return {
|
|
8716
|
+
ok: false,
|
|
8717
|
+
kind: "unsupported",
|
|
8718
|
+
version,
|
|
8719
|
+
requirement,
|
|
8720
|
+
message: `uipath ${version} found at ${exePath}; ${formatSimpleVersion(minimum)} or later is required.`
|
|
8721
|
+
};
|
|
8722
|
+
}
|
|
8723
|
+
return { ok: true, version, requirement };
|
|
8724
|
+
}
|
|
8725
|
+
async function checkUipathVersion(exePath, options = {}) {
|
|
8726
|
+
const resolved = resolveRequirement();
|
|
8727
|
+
if ("invalid" in resolved)
|
|
8728
|
+
return resolved.invalid;
|
|
8729
|
+
const probe = await probeUipathVersion(exePath, options);
|
|
8730
|
+
if ("error" in probe) {
|
|
8731
|
+
return {
|
|
8732
|
+
ok: false,
|
|
8733
|
+
kind: "unverifiable",
|
|
8734
|
+
requirement: resolved.requirement,
|
|
8735
|
+
message: probe.error
|
|
8736
|
+
};
|
|
8737
|
+
}
|
|
8738
|
+
return judge(probe.version, exePath, resolved.requirement, resolved.minimum);
|
|
8739
|
+
}
|
|
8740
|
+
function uipathVersionInstructions(check, toolName) {
|
|
8741
|
+
const setupHint = `then re-run 'uip ${toolName} setup --force'`;
|
|
8742
|
+
if (check.kind === "unverifiable") {
|
|
8743
|
+
return `Make sure the uipath package is installed and runnable in that environment, ${setupHint}.`;
|
|
8744
|
+
}
|
|
8745
|
+
return `Upgrade uipath, ${setupHint}.`;
|
|
8746
|
+
}
|
|
7695
8747
|
|
|
7696
8748
|
// ../uipath-python-bridge/src/execute.ts
|
|
7697
8749
|
var ENV_FILE_NAME = ".env";
|
|
@@ -7719,8 +8771,8 @@ function envValueFromFile(content, name) {
|
|
|
7719
8771
|
if (!line || line.startsWith("#")) {
|
|
7720
8772
|
return false;
|
|
7721
8773
|
}
|
|
7722
|
-
const [key, ...
|
|
7723
|
-
return key.trim() === name &&
|
|
8774
|
+
const [key, ...valueParts] = line.split("=");
|
|
8775
|
+
return key.trim() === name && valueParts.join("=").trim().length > 0;
|
|
7724
8776
|
});
|
|
7725
8777
|
if (!envLine) {
|
|
7726
8778
|
return null;
|
|
@@ -7728,16 +8780,16 @@ function envValueFromFile(content, name) {
|
|
|
7728
8780
|
const [, ...valueParts] = envLine.split("=");
|
|
7729
8781
|
return valueParts.join("=").trim().replace(/^["']|["']$/g, "") || null;
|
|
7730
8782
|
}
|
|
7731
|
-
async function getConfiguredEnvValue(
|
|
8783
|
+
async function getConfiguredEnvValue(fs, name) {
|
|
7732
8784
|
const processValue = process.env[name]?.trim();
|
|
7733
8785
|
if (processValue) {
|
|
7734
8786
|
return processValue;
|
|
7735
8787
|
}
|
|
7736
|
-
const envPath =
|
|
7737
|
-
if (!await
|
|
8788
|
+
const envPath = fs.path.join(fs.env.cwd(), ENV_FILE_NAME);
|
|
8789
|
+
if (!await fs.exists(envPath)) {
|
|
7738
8790
|
return null;
|
|
7739
8791
|
}
|
|
7740
|
-
const [readError, content] = await catchError(
|
|
8792
|
+
const [readError, content] = await catchError(fs.readFile(envPath, "utf-8"));
|
|
7741
8793
|
return !readError && typeof content === "string" ? envValueFromFile(content, name) : null;
|
|
7742
8794
|
}
|
|
7743
8795
|
var fail = (reason, message, instructions, extras = {}) => ({
|
|
@@ -7759,8 +8811,8 @@ function childStdio(stdio) {
|
|
|
7759
8811
|
}
|
|
7760
8812
|
}
|
|
7761
8813
|
async function runUipathPythonCommand(args, options = {}) {
|
|
7762
|
-
const
|
|
7763
|
-
const cacheFile =
|
|
8814
|
+
const fs = getFileSystem();
|
|
8815
|
+
const cacheFile = fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
|
|
7764
8816
|
const toolLabel = options.toolName ?? options.commandPrefix ?? "codedagent";
|
|
7765
8817
|
const setupCommand = `uip ${toolLabel} setup`;
|
|
7766
8818
|
const setupHint = `Run '${setupCommand}' first to configure the environment. ` + `Activate the project's virtual environment and run ${setupCommand} --force.`;
|
|
@@ -7768,7 +8820,7 @@ async function runUipathPythonCommand(args, options = {}) {
|
|
|
7768
8820
|
if (!cache?.uipathExePath) {
|
|
7769
8821
|
return fail("python_not_configured", "Python not configured.", setupHint);
|
|
7770
8822
|
}
|
|
7771
|
-
if (!await
|
|
8823
|
+
if (!await fs.exists(cache.uipathExePath)) {
|
|
7772
8824
|
return fail("uipath_exe_missing", "uipath executable not found. Please install it using 'pip install uipath' or 'uv add uipath'.", setupHint);
|
|
7773
8825
|
}
|
|
7774
8826
|
const processed = processCommandArgs(args, options.commandRules ?? []);
|
|
@@ -7786,21 +8838,21 @@ async function runUipathPythonCommand(args, options = {}) {
|
|
|
7786
8838
|
if (!applies) {
|
|
7787
8839
|
continue;
|
|
7788
8840
|
}
|
|
7789
|
-
const value = await getConfiguredEnvValue(
|
|
8841
|
+
const value = await getConfiguredEnvValue(fs, requirement.name);
|
|
7790
8842
|
if (!value) {
|
|
7791
8843
|
return fail("required_env_missing", `${requirement.name} environment variable not found.`, requirement.instructions);
|
|
7792
8844
|
}
|
|
7793
8845
|
requiredEnv[requirement.name] = value;
|
|
7794
8846
|
}
|
|
7795
|
-
const { authEnv, loginStatus
|
|
7796
|
-
if (!
|
|
8847
|
+
const { authEnv, loginStatus } = await getAuthEnv();
|
|
8848
|
+
if (!loginStatus) {
|
|
7797
8849
|
logger.debug("Auth unavailable, continuing without credentials.");
|
|
7798
8850
|
}
|
|
7799
8851
|
if (options.commandPreflight) {
|
|
7800
8852
|
const preflight = options.commandPreflight;
|
|
7801
8853
|
const [preflightError, preflightResult] = await catchError(Promise.resolve().then(() => preflight({
|
|
7802
8854
|
args: commandArgs,
|
|
7803
|
-
loginStatus
|
|
8855
|
+
loginStatus,
|
|
7804
8856
|
authEnv
|
|
7805
8857
|
})));
|
|
7806
8858
|
if (preflightError) {
|
|
@@ -7811,7 +8863,15 @@ async function runUipathPythonCommand(args, options = {}) {
|
|
|
7811
8863
|
}
|
|
7812
8864
|
}
|
|
7813
8865
|
const stdio = options.stdio ?? "inherit";
|
|
7814
|
-
const cwd = options.cwd ??
|
|
8866
|
+
const cwd = options.cwd ?? fs.env.cwd();
|
|
8867
|
+
const versionCheck = await checkUipathVersion(cache.uipathExePath, {
|
|
8868
|
+
cwd,
|
|
8869
|
+
signal: options.signal
|
|
8870
|
+
});
|
|
8871
|
+
if (!versionCheck.ok) {
|
|
8872
|
+
return fail(versionCheck.kind === "unsupported" ? "uipath_version_unsupported" : "uipath_version_unverifiable", versionCheck.message, uipathVersionInstructions(versionCheck, toolLabel));
|
|
8873
|
+
}
|
|
8874
|
+
logger.debug(`Using uipath ${versionCheck.version} at ${cache.uipathExePath} (source: ${cache.source ?? "unknown"}; requires uipath${versionCheck.requirement})`);
|
|
7815
8875
|
if (options.pinNewType && processed.args[0] === "new" && !isHelpCommand(processed.args) && await supportsNewTypeOption(cache.uipathExePath, cwd, { ...authEnv, ...requiredEnv }, options.signal)) {
|
|
7816
8876
|
commandArgs.push("--type", options.pinNewType);
|
|
7817
8877
|
}
|
|
@@ -7842,8 +8902,8 @@ async function runUipathPythonCommand(args, options = {}) {
|
|
|
7842
8902
|
getOutputSink().writeErr(chunk);
|
|
7843
8903
|
});
|
|
7844
8904
|
}
|
|
7845
|
-
const [spawnError, exitCode] = await catchError(new Promise((
|
|
7846
|
-
proc.on("close", (code) =>
|
|
8905
|
+
const [spawnError, exitCode] = await catchError(new Promise((resolve, reject) => {
|
|
8906
|
+
proc.on("close", (code) => resolve(code ?? 1));
|
|
7847
8907
|
proc.on("error", reject);
|
|
7848
8908
|
}));
|
|
7849
8909
|
if (spawnError) {
|
|
@@ -7860,6 +8920,7 @@ async function runUipathPythonCommand(args, options = {}) {
|
|
|
7860
8920
|
return {
|
|
7861
8921
|
ok: true,
|
|
7862
8922
|
pythonExePath: cache.uipathExePath,
|
|
8923
|
+
uipathVersion: versionCheck.version,
|
|
7863
8924
|
exitCode: 0,
|
|
7864
8925
|
stdout: stdio === "pipe" ? stdout : undefined,
|
|
7865
8926
|
stderr: stdio === "pipe" ? stderr : undefined
|
|
@@ -7868,6 +8929,8 @@ async function runUipathPythonCommand(args, options = {}) {
|
|
|
7868
8929
|
var CLI_RESULT_BY_REASON = {
|
|
7869
8930
|
python_not_configured: RESULTS.ConfigError,
|
|
7870
8931
|
uipath_exe_missing: RESULTS.ConfigError,
|
|
8932
|
+
uipath_version_unsupported: RESULTS.ConfigError,
|
|
8933
|
+
uipath_version_unverifiable: RESULTS.ConfigError,
|
|
7871
8934
|
command_disabled: RESULTS.ValidationError,
|
|
7872
8935
|
new_type_not_allowed: RESULTS.ValidationError,
|
|
7873
8936
|
required_env_missing: RESULTS.ConfigError,
|
|
@@ -7903,8 +8966,8 @@ function createExecuteCommand(config) {
|
|
|
7903
8966
|
processContext.exit(reportUipathPythonFailure(result));
|
|
7904
8967
|
return result;
|
|
7905
8968
|
};
|
|
7906
|
-
const registerExecCommand = (
|
|
7907
|
-
|
|
8969
|
+
const registerExecCommand = (program) => {
|
|
8970
|
+
program.command("exec", { hidden: true }).description("Execute the uipath package with provided arguments").allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, async (_options, cmd) => {
|
|
7908
8971
|
await executeCommand(["_", "_", "exec", ...cmd.args], {});
|
|
7909
8972
|
});
|
|
7910
8973
|
};
|
|
@@ -7918,11 +8981,10 @@ class PythonService {
|
|
|
7918
8981
|
cacheFile;
|
|
7919
8982
|
config;
|
|
7920
8983
|
uipathExePath;
|
|
7921
|
-
packageVersion;
|
|
7922
8984
|
constructor(config) {
|
|
7923
|
-
const
|
|
8985
|
+
const fs = getFileSystem();
|
|
7924
8986
|
this.config = config;
|
|
7925
|
-
this.cacheFile = config.cacheFile ||
|
|
8987
|
+
this.cacheFile = config.cacheFile || fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
|
|
7926
8988
|
}
|
|
7927
8989
|
async setup(packageName, force = false) {
|
|
7928
8990
|
const [error, result] = await catchError(this._setupInternal(packageName, force));
|
|
@@ -7978,26 +9040,20 @@ To install the package, run:
|
|
|
7978
9040
|
${pythonPath} -m pip install ${packageName}`
|
|
7979
9041
|
};
|
|
7980
9042
|
}
|
|
7981
|
-
const
|
|
7982
|
-
if (
|
|
7983
|
-
return {
|
|
7984
|
-
success: false,
|
|
9043
|
+
const versionCheck = await checkUipathVersion(this.uipathExePath);
|
|
9044
|
+
if (!versionCheck.ok) {
|
|
9045
|
+
return this.rejectVersion(versionCheck, {
|
|
7985
9046
|
pythonPath,
|
|
7986
9047
|
pythonVersion: version,
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
source,
|
|
7990
|
-
error: versionResult.error
|
|
7991
|
-
};
|
|
9048
|
+
source
|
|
9049
|
+
});
|
|
7992
9050
|
}
|
|
7993
|
-
this.packageVersion = versionResult.version;
|
|
7994
9051
|
await this.saveCache({
|
|
7995
9052
|
pythonPath,
|
|
7996
9053
|
version,
|
|
7997
9054
|
lastValidated: new Date().toISOString(),
|
|
7998
9055
|
packageName,
|
|
7999
9056
|
uipathExePath: this.uipathExePath,
|
|
8000
|
-
packageVersion: this.packageVersion,
|
|
8001
9057
|
source
|
|
8002
9058
|
});
|
|
8003
9059
|
return {
|
|
@@ -8005,18 +9061,18 @@ To install the package, run:
|
|
|
8005
9061
|
pythonPath,
|
|
8006
9062
|
pythonVersion: version,
|
|
8007
9063
|
packageInstalled: true,
|
|
8008
|
-
packageVersion:
|
|
9064
|
+
packageVersion: versionCheck.version,
|
|
8009
9065
|
uipathExePath: this.uipathExePath,
|
|
8010
9066
|
source
|
|
8011
9067
|
};
|
|
8012
9068
|
}
|
|
8013
9069
|
async reuseCache(packageName, virtualEnv) {
|
|
8014
|
-
const
|
|
9070
|
+
const fs = getFileSystem();
|
|
8015
9071
|
logger.debug("Checking cache...");
|
|
8016
9072
|
const cached = await this.loadCache();
|
|
8017
9073
|
if (!cached)
|
|
8018
9074
|
return null;
|
|
8019
|
-
if (!cached.uipathExePath || !await
|
|
9075
|
+
if (!cached.uipathExePath || !await fs.exists(cached.uipathExePath)) {
|
|
8020
9076
|
logger.warn("Cached Python path no longer exists, re-detecting...");
|
|
8021
9077
|
return null;
|
|
8022
9078
|
}
|
|
@@ -8029,21 +9085,13 @@ To install the package, run:
|
|
|
8029
9085
|
this.uipathExePath = cached.uipathExePath;
|
|
8030
9086
|
const source = cached.source ?? (virtualEnv ? "venv" : "path");
|
|
8031
9087
|
logger.info(`Using cached uipath executable: ${this.uipathExePath}`);
|
|
8032
|
-
|
|
8033
|
-
if (!
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
pythonVersion: version,
|
|
8040
|
-
packageInstalled: true,
|
|
8041
|
-
uipathExePath: this.uipathExePath,
|
|
8042
|
-
source,
|
|
8043
|
-
error: versionResult.error
|
|
8044
|
-
};
|
|
8045
|
-
}
|
|
8046
|
-
this.packageVersion = versionResult.version;
|
|
9088
|
+
const versionCheck = await checkUipathVersion(this.uipathExePath);
|
|
9089
|
+
if (!versionCheck.ok) {
|
|
9090
|
+
return this.rejectVersion(versionCheck, {
|
|
9091
|
+
pythonPath,
|
|
9092
|
+
pythonVersion: version,
|
|
9093
|
+
source
|
|
9094
|
+
});
|
|
8047
9095
|
}
|
|
8048
9096
|
await this.saveCache({
|
|
8049
9097
|
pythonPath,
|
|
@@ -8051,7 +9099,6 @@ To install the package, run:
|
|
|
8051
9099
|
lastValidated: new Date().toISOString(),
|
|
8052
9100
|
packageName,
|
|
8053
9101
|
uipathExePath: this.uipathExePath,
|
|
8054
|
-
packageVersion: this.packageVersion,
|
|
8055
9102
|
source
|
|
8056
9103
|
});
|
|
8057
9104
|
return {
|
|
@@ -8059,15 +9106,15 @@ To install the package, run:
|
|
|
8059
9106
|
pythonPath,
|
|
8060
9107
|
pythonVersion: version,
|
|
8061
9108
|
packageInstalled: true,
|
|
8062
|
-
packageVersion:
|
|
9109
|
+
packageVersion: versionCheck.version,
|
|
8063
9110
|
uipathExePath: this.uipathExePath,
|
|
8064
9111
|
source
|
|
8065
9112
|
};
|
|
8066
9113
|
}
|
|
8067
9114
|
async detectVenvPython(virtualEnv) {
|
|
8068
|
-
const
|
|
9115
|
+
const fs = getFileSystem();
|
|
8069
9116
|
const isWindows = platform() === "win32";
|
|
8070
|
-
const command = isWindows ?
|
|
9117
|
+
const command = isWindows ? fs.path.join(virtualEnv, "Scripts", "python.exe") : fs.path.join(virtualEnv, "bin", "python");
|
|
8071
9118
|
const checkedVersions = [];
|
|
8072
9119
|
const searchedCommands = [];
|
|
8073
9120
|
const version = await this.checkPythonVersion(command, [], checkedVersions, searchedCommands);
|
|
@@ -8077,12 +9124,12 @@ To install the package, run:
|
|
|
8077
9124
|
error: this.buildNotFoundError(checkedVersions, searchedCommands)
|
|
8078
9125
|
};
|
|
8079
9126
|
}
|
|
8080
|
-
const metadataPath = await this.findUipathExeFromMetadata(
|
|
9127
|
+
const metadataPath = await this.findUipathExeFromMetadata(fs, command, []);
|
|
8081
9128
|
let uipathExePath = metadataPath;
|
|
8082
9129
|
if (!uipathExePath) {
|
|
8083
|
-
const candidate = isWindows ?
|
|
9130
|
+
const candidate = isWindows ? fs.path.join(virtualEnv, "Scripts", "uipath.exe") : fs.path.join(virtualEnv, "bin", "uipath");
|
|
8084
9131
|
logger.debug(`Checking for uipath executable at: ${candidate}`);
|
|
8085
|
-
if (await
|
|
9132
|
+
if (await fs.exists(candidate)) {
|
|
8086
9133
|
logger.info(`Found uipath executable at: ${candidate}`);
|
|
8087
9134
|
uipathExePath = candidate;
|
|
8088
9135
|
} else {
|
|
@@ -8101,8 +9148,8 @@ To install the package, run:
|
|
|
8101
9148
|
if (process.env.VIRTUAL_ENV) {
|
|
8102
9149
|
return null;
|
|
8103
9150
|
}
|
|
8104
|
-
const
|
|
8105
|
-
if (!await
|
|
9151
|
+
const fs = getFileSystem();
|
|
9152
|
+
if (!await fs.exists(fs.path.join(fs.env.cwd(), ".venv"))) {
|
|
8106
9153
|
return null;
|
|
8107
9154
|
}
|
|
8108
9155
|
return {
|
|
@@ -8126,12 +9173,12 @@ To install the package, run:
|
|
|
8126
9173
|
};
|
|
8127
9174
|
}
|
|
8128
9175
|
async checkPythonCommand(command, args, checkedVersions, searchedCommands) {
|
|
8129
|
-
const
|
|
9176
|
+
const fs = getFileSystem();
|
|
8130
9177
|
const version = await this.checkPythonVersion(command, args, checkedVersions, searchedCommands);
|
|
8131
9178
|
if (!version)
|
|
8132
9179
|
return null;
|
|
8133
9180
|
const commandStr = args.length > 0 ? `${command} ${args.join(" ")}` : command;
|
|
8134
|
-
const uipathExePath = await this.findUipathExe(
|
|
9181
|
+
const uipathExePath = await this.findUipathExe(fs, command, args);
|
|
8135
9182
|
return {
|
|
8136
9183
|
success: true,
|
|
8137
9184
|
pythonPath: commandStr,
|
|
@@ -8152,8 +9199,8 @@ To install the package, run:
|
|
|
8152
9199
|
const stderrChunks = [];
|
|
8153
9200
|
versionProc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
8154
9201
|
versionProc.stderr.on("data", (chunk) => stderrChunks.push(chunk));
|
|
8155
|
-
const [versionError, exitCode] = await catchError(new Promise((
|
|
8156
|
-
versionProc.on("exit", (code) =>
|
|
9202
|
+
const [versionError, exitCode] = await catchError(new Promise((resolve, reject) => {
|
|
9203
|
+
versionProc.on("exit", (code) => resolve(code ?? 1));
|
|
8157
9204
|
versionProc.on("error", (error) => reject(error));
|
|
8158
9205
|
}));
|
|
8159
9206
|
if (versionError) {
|
|
@@ -8180,31 +9227,31 @@ To install the package, run:
|
|
|
8180
9227
|
logger.info(`Found valid Python: ${commandStr} - ${version}`);
|
|
8181
9228
|
return version;
|
|
8182
9229
|
}
|
|
8183
|
-
async findUipathExe(
|
|
8184
|
-
const metadataPath = await this.findUipathExeFromMetadata(
|
|
9230
|
+
async findUipathExe(fs, command, args) {
|
|
9231
|
+
const metadataPath = await this.findUipathExeFromMetadata(fs, command, args);
|
|
8185
9232
|
if (metadataPath)
|
|
8186
9233
|
return metadataPath;
|
|
8187
9234
|
const isWindows = platform() === "win32";
|
|
8188
9235
|
const candidatePaths = [];
|
|
8189
9236
|
const virtualEnv = process.env.VIRTUAL_ENV;
|
|
8190
9237
|
if (virtualEnv) {
|
|
8191
|
-
candidatePaths.push(isWindows ?
|
|
9238
|
+
candidatePaths.push(isWindows ? fs.path.join(virtualEnv, "Scripts", "uipath.exe") : fs.path.join(virtualEnv, "bin", "uipath"));
|
|
8192
9239
|
}
|
|
8193
9240
|
const prefix = await this.getPythonPrefix(command, args);
|
|
8194
9241
|
if (prefix) {
|
|
8195
|
-
candidatePaths.push(isWindows ?
|
|
9242
|
+
candidatePaths.push(isWindows ? fs.path.join(prefix, "Scripts", "uipath.exe") : fs.path.join(prefix, "bin", "uipath"));
|
|
8196
9243
|
}
|
|
8197
9244
|
for (const candidate of candidatePaths) {
|
|
8198
9245
|
logger.debug(`Checking for uipath executable at: ${candidate}`);
|
|
8199
|
-
if (await
|
|
9246
|
+
if (await fs.exists(candidate)) {
|
|
8200
9247
|
logger.info(`Found uipath executable at: ${candidate}`);
|
|
8201
9248
|
return candidate;
|
|
8202
9249
|
}
|
|
8203
9250
|
}
|
|
8204
|
-
const pathCandidates = this.getPathUipathCandidates(
|
|
9251
|
+
const pathCandidates = this.getPathUipathCandidates(fs, isWindows);
|
|
8205
9252
|
for (const candidate of pathCandidates) {
|
|
8206
9253
|
logger.debug(`Checking for uipath executable on PATH at: ${candidate}`);
|
|
8207
|
-
if (await
|
|
9254
|
+
if (await fs.exists(candidate)) {
|
|
8208
9255
|
logger.info(`Found uipath executable at: ${candidate}`);
|
|
8209
9256
|
return candidate;
|
|
8210
9257
|
}
|
|
@@ -8213,7 +9260,7 @@ To install the package, run:
|
|
|
8213
9260
|
logger.error(`uipath executable not found. Checked: ${checkedCandidates.join(", ")}`);
|
|
8214
9261
|
return;
|
|
8215
9262
|
}
|
|
8216
|
-
async findUipathExeFromMetadata(
|
|
9263
|
+
async findUipathExeFromMetadata(fs, command, args) {
|
|
8217
9264
|
const script = `
|
|
8218
9265
|
from importlib.metadata import distribution, PackageNotFoundError
|
|
8219
9266
|
import os
|
|
@@ -8235,8 +9282,8 @@ sys.exit(3)
|
|
|
8235
9282
|
const stderrChunks = [];
|
|
8236
9283
|
proc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
8237
9284
|
proc.stderr.on("data", (chunk) => stderrChunks.push(chunk));
|
|
8238
|
-
const [error, exitCode] = await catchError(new Promise((
|
|
8239
|
-
proc.on("exit", (code) =>
|
|
9285
|
+
const [error, exitCode] = await catchError(new Promise((resolve, reject) => {
|
|
9286
|
+
proc.on("exit", (code) => resolve(code ?? 1));
|
|
8240
9287
|
proc.on("error", (err) => reject(err));
|
|
8241
9288
|
}));
|
|
8242
9289
|
if (error) {
|
|
@@ -8253,7 +9300,7 @@ sys.exit(3)
|
|
|
8253
9300
|
logger.debug("uipath executable metadata lookup returned empty path");
|
|
8254
9301
|
return;
|
|
8255
9302
|
}
|
|
8256
|
-
if (!await
|
|
9303
|
+
if (!await fs.exists(resolved)) {
|
|
8257
9304
|
logger.debug(`uipath executable path from metadata does not exist: ${resolved}`);
|
|
8258
9305
|
return;
|
|
8259
9306
|
}
|
|
@@ -8266,8 +9313,8 @@ sys.exit(3)
|
|
|
8266
9313
|
});
|
|
8267
9314
|
const stdoutChunks = [];
|
|
8268
9315
|
proc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
8269
|
-
const [error, exitCode] = await catchError(new Promise((
|
|
8270
|
-
proc.on("exit", (code) =>
|
|
9316
|
+
const [error, exitCode] = await catchError(new Promise((resolve, reject) => {
|
|
9317
|
+
proc.on("exit", (code) => resolve(code ?? 1));
|
|
8271
9318
|
proc.on("error", (err) => reject(err));
|
|
8272
9319
|
}));
|
|
8273
9320
|
if (error) {
|
|
@@ -8279,46 +9326,27 @@ sys.exit(3)
|
|
|
8279
9326
|
const prefix = Buffer.concat(stdoutChunks).toString("utf-8").trim();
|
|
8280
9327
|
return prefix || undefined;
|
|
8281
9328
|
}
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
}
|
|
8294
|
-
if (spawnError) {
|
|
8295
|
-
return {
|
|
8296
|
-
error: `Failed to run '${exePath} --version': ${spawnError.message}`
|
|
8297
|
-
};
|
|
8298
|
-
}
|
|
8299
|
-
const stdout = Buffer.concat(stdoutChunks).toString("utf-8").trim();
|
|
8300
|
-
const stderr = Buffer.concat(stderrChunks).toString("utf-8").trim();
|
|
8301
|
-
if (exitCode !== 0) {
|
|
8302
|
-
return {
|
|
8303
|
-
error: `'${exePath} --version' exited with code ${exitCode}${stderr ? `: ${stderr}` : ""}`
|
|
8304
|
-
};
|
|
8305
|
-
}
|
|
8306
|
-
const match = stdout.match(/uipath\s+version\s+(\S+)/i);
|
|
8307
|
-
if (!match) {
|
|
8308
|
-
return {
|
|
8309
|
-
error: `Could not parse version from '${exePath} --version' output: ${stdout || "<empty>"}`
|
|
8310
|
-
};
|
|
8311
|
-
}
|
|
8312
|
-
return { version: match[1] };
|
|
9329
|
+
rejectVersion(check, context) {
|
|
9330
|
+
return {
|
|
9331
|
+
success: false,
|
|
9332
|
+
pythonPath: context.pythonPath,
|
|
9333
|
+
pythonVersion: context.pythonVersion,
|
|
9334
|
+
packageInstalled: true,
|
|
9335
|
+
packageVersion: check.kind === "unsupported" ? check.version : undefined,
|
|
9336
|
+
uipathExePath: this.uipathExePath,
|
|
9337
|
+
source: context.source,
|
|
9338
|
+
error: check.message,
|
|
9339
|
+
instructions: uipathVersionInstructions(check, this.config.toolName ?? "codedagent")
|
|
9340
|
+
};
|
|
8313
9341
|
}
|
|
8314
|
-
getPathUipathCandidates(
|
|
9342
|
+
getPathUipathCandidates(fs, isWindows) {
|
|
8315
9343
|
const pathValue = process.env.PATH || (isWindows ? process.env.Path : undefined);
|
|
8316
9344
|
if (!pathValue)
|
|
8317
9345
|
return [];
|
|
8318
9346
|
const delimiter = isWindows ? ";" : ":";
|
|
8319
9347
|
const pathEntries = pathValue.split(delimiter).map((entry) => entry.trim().replace(/^"|"$/g, "")).filter((entry) => entry.length > 0);
|
|
8320
9348
|
const executableNames = isWindows ? this.getWindowsExecutableNames() : ["uipath"];
|
|
8321
|
-
return pathEntries.flatMap((entry) => executableNames.map((name) =>
|
|
9349
|
+
return pathEntries.flatMap((entry) => executableNames.map((name) => fs.path.join(entry, name)));
|
|
8322
9350
|
}
|
|
8323
9351
|
getWindowsExecutableNames() {
|
|
8324
9352
|
const pathExt = process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD";
|
|
@@ -8394,14 +9422,14 @@ Please install one of the required Python versions:
|
|
|
8394
9422
|
return readCache(this.cacheFile);
|
|
8395
9423
|
}
|
|
8396
9424
|
async saveCache(cache) {
|
|
8397
|
-
const
|
|
8398
|
-
const dir =
|
|
8399
|
-
const [mkdirError] = await catchError(
|
|
9425
|
+
const fs = getFileSystem();
|
|
9426
|
+
const dir = fs.path.dirname(this.cacheFile);
|
|
9427
|
+
const [mkdirError] = await catchError(fs.mkdir(dir));
|
|
8400
9428
|
if (mkdirError) {
|
|
8401
9429
|
logger.warn(`Failed to create cache directory: ${mkdirError}`);
|
|
8402
9430
|
return;
|
|
8403
9431
|
}
|
|
8404
|
-
const [writeError] = await catchError(
|
|
9432
|
+
const [writeError] = await catchError(fs.writeFile(this.cacheFile, JSON.stringify(cache, null, 2)));
|
|
8405
9433
|
if (writeError) {
|
|
8406
9434
|
logger.warn(`Failed to save cache: ${writeError}`);
|
|
8407
9435
|
return;
|
|
@@ -8423,8 +9451,8 @@ function isPathInside(target, root) {
|
|
|
8423
9451
|
|
|
8424
9452
|
// ../uipath-python-bridge/src/register.ts
|
|
8425
9453
|
function createSetupCommand(config) {
|
|
8426
|
-
return (
|
|
8427
|
-
|
|
9454
|
+
return (program) => {
|
|
9455
|
+
program.command("setup").description("Detect Python installation and verify package is installed").option("--force", "Force re-detection of Python even if cached", false).trackedAction(processContext, async (options) => {
|
|
8428
9456
|
const packageName = config.packageName || getPackageName();
|
|
8429
9457
|
const allowedVersions = getAllowedPythonVersions();
|
|
8430
9458
|
if (allowedVersions.length === 0) {
|
|
@@ -8461,6 +9489,7 @@ Searching for Python installations: ${allowedVersions}`);
|
|
|
8461
9489
|
Package: packageName,
|
|
8462
9490
|
PackageInstalled: result.packageInstalled ? "Yes" : "No",
|
|
8463
9491
|
PackageVersion: result.packageVersion ?? "N/A",
|
|
9492
|
+
RequiredPackageVersion: getUipathVersionRequirement(),
|
|
8464
9493
|
UipathPath: result.uipathExePath,
|
|
8465
9494
|
Source: result.source
|
|
8466
9495
|
}
|
|
@@ -8533,9 +9562,9 @@ function personalWorkspaceScopeInstructions() {
|
|
|
8533
9562
|
}
|
|
8534
9563
|
var codedAgentCommandPreflight = ({
|
|
8535
9564
|
args,
|
|
8536
|
-
loginStatus
|
|
9565
|
+
loginStatus
|
|
8537
9566
|
}) => {
|
|
8538
|
-
if (!needsPersonalWorkspaceLookup(args) ||
|
|
9567
|
+
if (!needsPersonalWorkspaceLookup(args) || loginStatus?.loginStatus !== "Logged in" || !loginStatus.accessToken || hasPersonalWorkspaceScope(loginStatus.accessToken)) {
|
|
8539
9568
|
return { allowed: true };
|
|
8540
9569
|
}
|
|
8541
9570
|
return {
|
|
@@ -8546,6 +9575,6 @@ var codedAgentCommandPreflight = ({
|
|
|
8546
9575
|
};
|
|
8547
9576
|
};
|
|
8548
9577
|
|
|
8549
|
-
export { getFileSystem,
|
|
9578
|
+
export { getFileSystem, CommandDimensions, ShipDimensions, catchError, extractErrorMessageSync, RESULTS, Command, OutputFormatter, processContext, trackShipSucceeded, parseJWT, getLoginStatusAsync, getAuthContext, runUipathPythonCommand, createExecuteCommand, createSetupCommand, WHITELISTED_COMMANDS, COMMAND_RULES, codedAgentCommandPreflight };
|
|
8550
9579
|
|
|
8551
|
-
//# debugId=
|
|
9580
|
+
//# debugId=B0A2710297B4964764756E2164756E21
|