@uipath/context-grounding-tool 1.201.0 → 1.202.0-preview.136
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-2fj08e7n.js → index-gpd94m28.js} +27 -27
- package/dist/{index-w03qc9m8.js → index-sby22td6.js} +4 -4
- package/dist/index.js +3 -6
- package/dist/{js-yaml-4ypbq2tt.js → js-yaml-88tdqrtd.js} +27 -19
- package/dist/{tool-0v6na3yp.js → tool-1de529jm.js} +9 -7
- package/dist/{tool-92f343nz.js → tool-3pw03tvv.js} +1678 -595
- package/dist/tool.js +5 -8
- package/package.json +2 -2
- package/dist/browser-strategy-yccf8mtd.js +0 -99
- package/dist/node-strategy-12qfy0nv.js +0 -348
- package/dist/tool-5arsyj36.js +0 -11
- package/dist/tool-7eva0peq.js +0 -265
- package/dist/tool-9qecd4wb.js +0 -14
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isBrowser
|
|
3
|
-
} from "./tool-9qecd4wb.js";
|
|
4
|
-
import {
|
|
5
|
-
catchError,
|
|
6
|
-
getFileSystem
|
|
7
|
-
} from "./tool-7eva0peq.js";
|
|
8
|
-
import {
|
|
9
|
-
AUTH_FILENAME,
|
|
10
|
-
DEFAULT_BASE_URL,
|
|
11
|
-
UIPATH_HOME_DIR
|
|
12
|
-
} from "./tool-5arsyj36.js";
|
|
13
1
|
import {
|
|
14
2
|
__commonJS,
|
|
15
3
|
__require,
|
|
16
4
|
__toESM
|
|
17
|
-
} from "./tool-
|
|
5
|
+
} from "./tool-1de529jm.js";
|
|
18
6
|
|
|
19
7
|
// ../../node_modules/commander/lib/error.js
|
|
20
|
-
var require_error = __commonJS((exports)
|
|
8
|
+
var require_error = __commonJS(function(exports) {
|
|
21
9
|
class CommanderError extends Error {
|
|
22
10
|
constructor(exitCode, code, message) {
|
|
23
11
|
super(message);
|
|
@@ -41,7 +29,7 @@ var require_error = __commonJS((exports) => {
|
|
|
41
29
|
});
|
|
42
30
|
|
|
43
31
|
// ../../node_modules/commander/lib/argument.js
|
|
44
|
-
var require_argument = __commonJS((exports)
|
|
32
|
+
var require_argument = __commonJS(function(exports) {
|
|
45
33
|
var { InvalidArgumentError } = require_error();
|
|
46
34
|
|
|
47
35
|
class Argument {
|
|
@@ -121,7 +109,7 @@ var require_argument = __commonJS((exports) => {
|
|
|
121
109
|
});
|
|
122
110
|
|
|
123
111
|
// ../../node_modules/commander/lib/help.js
|
|
124
|
-
var require_help = __commonJS((exports)
|
|
112
|
+
var require_help = __commonJS(function(exports) {
|
|
125
113
|
var { humanReadableArgName } = require_argument();
|
|
126
114
|
|
|
127
115
|
class Help {
|
|
@@ -478,7 +466,7 @@ ${itemIndentStr}`);
|
|
|
478
466
|
});
|
|
479
467
|
|
|
480
468
|
// ../../node_modules/commander/lib/option.js
|
|
481
|
-
var require_option = __commonJS((exports)
|
|
469
|
+
var require_option = __commonJS(function(exports) {
|
|
482
470
|
var { InvalidArgumentError } = require_error();
|
|
483
471
|
|
|
484
472
|
class Option {
|
|
@@ -662,7 +650,7 @@ var require_option = __commonJS((exports) => {
|
|
|
662
650
|
});
|
|
663
651
|
|
|
664
652
|
// ../../node_modules/commander/lib/suggestSimilar.js
|
|
665
|
-
var require_suggestSimilar = __commonJS((exports)
|
|
653
|
+
var require_suggestSimilar = __commonJS(function(exports) {
|
|
666
654
|
var maxDistance = 3;
|
|
667
655
|
function editDistance(a, b) {
|
|
668
656
|
if (Math.abs(a.length - b.length) > maxDistance)
|
|
@@ -735,11 +723,11 @@ var require_suggestSimilar = __commonJS((exports) => {
|
|
|
735
723
|
});
|
|
736
724
|
|
|
737
725
|
// ../../node_modules/commander/lib/command.js
|
|
738
|
-
var require_command = __commonJS((exports)
|
|
726
|
+
var require_command = __commonJS(function(exports) {
|
|
739
727
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
740
728
|
var childProcess = __require("node:child_process");
|
|
741
|
-
var
|
|
742
|
-
var
|
|
729
|
+
var path2 = __require("node:path");
|
|
730
|
+
var fs2 = __require("node:fs");
|
|
743
731
|
var process2 = __require("node:process");
|
|
744
732
|
var { Argument, humanReadableArgName } = require_argument();
|
|
745
733
|
var { CommanderError } = require_error();
|
|
@@ -1274,7 +1262,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1274
1262
|
this.processedArgs = [];
|
|
1275
1263
|
}
|
|
1276
1264
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
1277
|
-
if (
|
|
1265
|
+
if (fs2.existsSync(executableFile))
|
|
1278
1266
|
return;
|
|
1279
1267
|
const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
|
|
1280
1268
|
const executableMissing = `'${executableFile}' does not exist
|
|
@@ -1288,12 +1276,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1288
1276
|
let launchWithNode = false;
|
|
1289
1277
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1290
1278
|
function findFile(baseDir, baseName) {
|
|
1291
|
-
const localBin =
|
|
1292
|
-
if (
|
|
1279
|
+
const localBin = path2.resolve(baseDir, baseName);
|
|
1280
|
+
if (fs2.existsSync(localBin))
|
|
1293
1281
|
return localBin;
|
|
1294
|
-
if (sourceExt.includes(
|
|
1282
|
+
if (sourceExt.includes(path2.extname(baseName)))
|
|
1295
1283
|
return;
|
|
1296
|
-
const foundExt = sourceExt.find((ext) =>
|
|
1284
|
+
const foundExt = sourceExt.find((ext) => fs2.existsSync(`${localBin}${ext}`));
|
|
1297
1285
|
if (foundExt)
|
|
1298
1286
|
return `${localBin}${foundExt}`;
|
|
1299
1287
|
return;
|
|
@@ -1305,23 +1293,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1305
1293
|
if (this._scriptPath) {
|
|
1306
1294
|
let resolvedScriptPath;
|
|
1307
1295
|
try {
|
|
1308
|
-
resolvedScriptPath =
|
|
1296
|
+
resolvedScriptPath = fs2.realpathSync(this._scriptPath);
|
|
1309
1297
|
} catch {
|
|
1310
1298
|
resolvedScriptPath = this._scriptPath;
|
|
1311
1299
|
}
|
|
1312
|
-
executableDir =
|
|
1300
|
+
executableDir = path2.resolve(path2.dirname(resolvedScriptPath), executableDir);
|
|
1313
1301
|
}
|
|
1314
1302
|
if (executableDir) {
|
|
1315
1303
|
let localFile = findFile(executableDir, executableFile);
|
|
1316
1304
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1317
|
-
const legacyName =
|
|
1305
|
+
const legacyName = path2.basename(this._scriptPath, path2.extname(this._scriptPath));
|
|
1318
1306
|
if (legacyName !== this._name) {
|
|
1319
1307
|
localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
|
|
1320
1308
|
}
|
|
1321
1309
|
}
|
|
1322
1310
|
executableFile = localFile || executableFile;
|
|
1323
1311
|
}
|
|
1324
|
-
launchWithNode = sourceExt.includes(
|
|
1312
|
+
launchWithNode = sourceExt.includes(path2.extname(executableFile));
|
|
1325
1313
|
let proc;
|
|
1326
1314
|
if (process2.platform !== "win32") {
|
|
1327
1315
|
if (launchWithNode) {
|
|
@@ -1910,13 +1898,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1910
1898
|
cmd.helpGroup(this._defaultCommandGroup);
|
|
1911
1899
|
}
|
|
1912
1900
|
nameFromFilename(filename) {
|
|
1913
|
-
this._name =
|
|
1901
|
+
this._name = path2.basename(filename, path2.extname(filename));
|
|
1914
1902
|
return this;
|
|
1915
1903
|
}
|
|
1916
|
-
executableDir(
|
|
1917
|
-
if (
|
|
1904
|
+
executableDir(path3) {
|
|
1905
|
+
if (path3 === undefined)
|
|
1918
1906
|
return this._executableDir;
|
|
1919
|
-
this._executableDir =
|
|
1907
|
+
this._executableDir = path3;
|
|
1920
1908
|
return this;
|
|
1921
1909
|
}
|
|
1922
1910
|
helpInformation(contextOptions) {
|
|
@@ -2090,7 +2078,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2090
2078
|
});
|
|
2091
2079
|
|
|
2092
2080
|
// ../../node_modules/commander/index.js
|
|
2093
|
-
var require_commander = __commonJS((exports)
|
|
2081
|
+
var require_commander = __commonJS(function(exports) {
|
|
2094
2082
|
var { Argument } = require_argument();
|
|
2095
2083
|
var { Command } = require_command();
|
|
2096
2084
|
var { CommanderError, InvalidArgumentError } = require_error();
|
|
@@ -2109,81 +2097,402 @@ var require_commander = __commonJS((exports) => {
|
|
|
2109
2097
|
exports.InvalidOptionArgumentError = InvalidArgumentError;
|
|
2110
2098
|
});
|
|
2111
2099
|
|
|
2112
|
-
// ../
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2100
|
+
// ../filesystem/src/node.ts
|
|
2101
|
+
import { randomUUID } from "node:crypto";
|
|
2102
|
+
import { existsSync } from "node:fs";
|
|
2103
|
+
import * as fs from "node:fs/promises";
|
|
2104
|
+
import * as os from "node:os";
|
|
2105
|
+
import * as path from "node:path";
|
|
2106
|
+
var LOCK_HEARTBEAT_MS = 5000;
|
|
2107
|
+
var LOCK_STALE_MS = 15000;
|
|
2108
|
+
var LOCK_MAX_WAIT_MS = 20000;
|
|
2109
|
+
var LOCK_MAX_HOLD_MS = 60000;
|
|
2110
|
+
var LOCK_RETRY_MIN_MS = 100;
|
|
2111
|
+
var LOCK_RETRY_JITTER_MS = 200;
|
|
2112
|
+
|
|
2113
|
+
class NodeFileSystem {
|
|
2114
|
+
path = {
|
|
2115
|
+
join: path.join,
|
|
2116
|
+
resolve: path.resolve,
|
|
2117
|
+
relative: path.relative,
|
|
2118
|
+
dirname: path.dirname,
|
|
2119
|
+
isAbsolute: path.isAbsolute,
|
|
2120
|
+
basename: path.basename
|
|
2121
|
+
};
|
|
2122
|
+
env = {
|
|
2123
|
+
cwd: process.cwd,
|
|
2124
|
+
homedir: os.homedir,
|
|
2125
|
+
tmpdir: os.tmpdir,
|
|
2126
|
+
getenv: (key) => process.env[key]
|
|
2127
|
+
};
|
|
2128
|
+
utils = {
|
|
2129
|
+
open: async (url) => {
|
|
2130
|
+
const { default: open } = await import("./index-sby22td6.js");
|
|
2131
|
+
await open(url);
|
|
2132
|
+
}
|
|
2133
|
+
};
|
|
2134
|
+
async readFile(path2, options) {
|
|
2135
|
+
try {
|
|
2136
|
+
if (options) {
|
|
2137
|
+
return await fs.readFile(path2, "utf-8");
|
|
2138
|
+
}
|
|
2139
|
+
return await fs.readFile(path2);
|
|
2140
|
+
} catch (error) {
|
|
2141
|
+
if (this.isEnoent(error))
|
|
2142
|
+
return null;
|
|
2143
|
+
throw error;
|
|
2144
|
+
}
|
|
2119
2145
|
}
|
|
2120
|
-
|
|
2121
|
-
const
|
|
2122
|
-
if (
|
|
2123
|
-
|
|
2146
|
+
async writeFile(filePath, data) {
|
|
2147
|
+
const dir = path.dirname(filePath);
|
|
2148
|
+
if (dir) {
|
|
2149
|
+
await fs.mkdir(dir, { recursive: true });
|
|
2124
2150
|
}
|
|
2125
|
-
|
|
2126
|
-
}
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2151
|
+
await fs.writeFile(filePath, data);
|
|
2152
|
+
}
|
|
2153
|
+
async appendFile(filePath, data) {
|
|
2154
|
+
const dir = path.dirname(filePath);
|
|
2155
|
+
if (dir) {
|
|
2156
|
+
await fs.mkdir(dir, { recursive: true });
|
|
2157
|
+
}
|
|
2158
|
+
await fs.appendFile(filePath, data);
|
|
2159
|
+
}
|
|
2160
|
+
async readdir(dirPath) {
|
|
2161
|
+
try {
|
|
2162
|
+
return await fs.readdir(dirPath);
|
|
2163
|
+
} catch (error) {
|
|
2164
|
+
if (this.isEnoent(error))
|
|
2165
|
+
return [];
|
|
2166
|
+
throw error;
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
async stat(filePath) {
|
|
2170
|
+
try {
|
|
2171
|
+
const stats = await fs.stat(filePath);
|
|
2172
|
+
return {
|
|
2173
|
+
isFile: () => stats.isFile(),
|
|
2174
|
+
isDirectory: () => stats.isDirectory(),
|
|
2175
|
+
size: stats.size,
|
|
2176
|
+
mtimeMs: stats.mtimeMs
|
|
2177
|
+
};
|
|
2178
|
+
} catch (error) {
|
|
2179
|
+
if (this.isEnoent(error))
|
|
2180
|
+
return null;
|
|
2181
|
+
throw error;
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
async exists(filePath) {
|
|
2185
|
+
return existsSync(filePath);
|
|
2186
|
+
}
|
|
2187
|
+
async mkdir(dirPath) {
|
|
2188
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
2189
|
+
}
|
|
2190
|
+
async acquireLock(lockPath) {
|
|
2191
|
+
const canonicalPath = await this.canonicalizeLockTarget(lockPath);
|
|
2192
|
+
const lockFile = `${canonicalPath}.lock`;
|
|
2193
|
+
const ownerId = randomUUID();
|
|
2194
|
+
const start = Date.now();
|
|
2195
|
+
while (true) {
|
|
2196
|
+
try {
|
|
2197
|
+
await fs.writeFile(lockFile, ownerId, { flag: "wx" });
|
|
2198
|
+
return this.createLockRelease(lockFile, ownerId);
|
|
2199
|
+
} catch (error) {
|
|
2200
|
+
if (!this.hasErrnoCode(error, "EEXIST")) {
|
|
2201
|
+
throw error;
|
|
2202
|
+
}
|
|
2203
|
+
const stats = await fs.stat(lockFile).catch(() => null);
|
|
2204
|
+
if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
|
|
2205
|
+
const reclaimed = await fs.rm(lockFile, { force: true }).then(() => true).catch(() => false);
|
|
2206
|
+
if (reclaimed)
|
|
2207
|
+
continue;
|
|
2208
|
+
}
|
|
2209
|
+
if (Date.now() - start > LOCK_MAX_WAIT_MS) {
|
|
2210
|
+
throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
|
|
2211
|
+
}
|
|
2212
|
+
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
async canonicalizeLockTarget(lockPath) {
|
|
2217
|
+
const absolute = path.resolve(lockPath);
|
|
2218
|
+
const fullReal = await fs.realpath(absolute).catch(() => null);
|
|
2219
|
+
if (fullReal)
|
|
2220
|
+
return fullReal;
|
|
2221
|
+
const parent = path.dirname(absolute);
|
|
2222
|
+
const base = path.basename(absolute);
|
|
2223
|
+
const canonicalParent = await fs.realpath(parent).catch(() => parent);
|
|
2224
|
+
return path.join(canonicalParent, base);
|
|
2225
|
+
}
|
|
2226
|
+
createLockRelease(lockFile, ownerId) {
|
|
2227
|
+
const heartbeatStart = Date.now();
|
|
2228
|
+
let heartbeatTimer;
|
|
2229
|
+
let stopped = false;
|
|
2230
|
+
const stopHeartbeat = () => {
|
|
2231
|
+
stopped = true;
|
|
2232
|
+
if (heartbeatTimer)
|
|
2233
|
+
clearTimeout(heartbeatTimer);
|
|
2234
|
+
};
|
|
2235
|
+
const scheduleNextHeartbeat = () => {
|
|
2236
|
+
if (stopped)
|
|
2237
|
+
return;
|
|
2238
|
+
if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
|
|
2239
|
+
stopped = true;
|
|
2240
|
+
return;
|
|
2241
|
+
}
|
|
2242
|
+
heartbeatTimer = setTimeout(() => {
|
|
2243
|
+
runHeartbeat();
|
|
2244
|
+
}, LOCK_HEARTBEAT_MS);
|
|
2245
|
+
heartbeatTimer.unref?.();
|
|
2246
|
+
};
|
|
2247
|
+
const runHeartbeat = async () => {
|
|
2248
|
+
if (stopped)
|
|
2249
|
+
return;
|
|
2250
|
+
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
2251
|
+
if (stopped)
|
|
2252
|
+
return;
|
|
2253
|
+
if (current !== ownerId) {
|
|
2254
|
+
stopped = true;
|
|
2255
|
+
return;
|
|
2256
|
+
}
|
|
2257
|
+
const now = Date.now() / 1000;
|
|
2258
|
+
await fs.utimes(lockFile, now, now).catch(() => {});
|
|
2259
|
+
scheduleNextHeartbeat();
|
|
2260
|
+
};
|
|
2261
|
+
scheduleNextHeartbeat();
|
|
2262
|
+
let released = false;
|
|
2263
|
+
return async () => {
|
|
2264
|
+
if (released)
|
|
2265
|
+
return;
|
|
2266
|
+
released = true;
|
|
2267
|
+
stopHeartbeat();
|
|
2268
|
+
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
2269
|
+
if (current === ownerId) {
|
|
2270
|
+
await fs.rm(lockFile, { force: true });
|
|
2271
|
+
}
|
|
2272
|
+
};
|
|
2273
|
+
}
|
|
2274
|
+
async rm(filePath) {
|
|
2275
|
+
await fs.rm(filePath, { recursive: true, force: true });
|
|
2276
|
+
}
|
|
2277
|
+
async rename(oldPath, newPath) {
|
|
2278
|
+
await fs.rename(oldPath, newPath);
|
|
2279
|
+
}
|
|
2280
|
+
async realpath(filePath) {
|
|
2281
|
+
try {
|
|
2282
|
+
return await fs.realpath(filePath);
|
|
2283
|
+
} catch (error) {
|
|
2284
|
+
if (this.isEnoent(error))
|
|
2285
|
+
return filePath;
|
|
2286
|
+
throw error;
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
async getTempDir() {
|
|
2290
|
+
return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
|
|
2291
|
+
}
|
|
2292
|
+
async copyDirectory(sourcePath, destPath) {
|
|
2293
|
+
const sourceStats = await this.stat(sourcePath);
|
|
2294
|
+
if (!sourceStats) {
|
|
2295
|
+
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
2296
|
+
}
|
|
2297
|
+
if (!sourceStats.isDirectory()) {
|
|
2298
|
+
throw new Error(`Source path is not a directory: ${sourcePath}`);
|
|
2299
|
+
}
|
|
2300
|
+
await this.mkdir(destPath);
|
|
2301
|
+
const entries = await this.readdir(sourcePath);
|
|
2302
|
+
for (const entry of entries) {
|
|
2303
|
+
const srcEntry = path.join(sourcePath, entry);
|
|
2304
|
+
const destEntry = path.join(destPath, entry);
|
|
2305
|
+
const entryStats = await this.stat(srcEntry);
|
|
2306
|
+
if (!entryStats)
|
|
2307
|
+
continue;
|
|
2308
|
+
if (entryStats.isDirectory()) {
|
|
2309
|
+
await this.copyDirectory(srcEntry, destEntry);
|
|
2310
|
+
} else if (entryStats.isFile()) {
|
|
2311
|
+
const content = await this.readFile(srcEntry);
|
|
2312
|
+
if (content !== null) {
|
|
2313
|
+
await this.writeFile(destEntry, content);
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
isEnoent(error) {
|
|
2319
|
+
return this.hasErrnoCode(error, "ENOENT");
|
|
2320
|
+
}
|
|
2321
|
+
hasErrnoCode(error, code) {
|
|
2322
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
2131
2323
|
}
|
|
2132
|
-
}
|
|
2133
|
-
function settlePromiseLike(thenable) {
|
|
2134
|
-
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
|
|
2135
|
-
error instanceof Error ? error : new Error(String(error)),
|
|
2136
|
-
undefined
|
|
2137
|
-
]);
|
|
2138
2324
|
}
|
|
2139
2325
|
|
|
2140
|
-
// ../
|
|
2141
|
-
var
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2326
|
+
// ../filesystem/src/index.ts
|
|
2327
|
+
var fsInstance = new NodeFileSystem;
|
|
2328
|
+
var getFileSystem = () => fsInstance;
|
|
2329
|
+
|
|
2330
|
+
// ../common/src/telemetry/pseudonymize.ts
|
|
2331
|
+
var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
|
|
2332
|
+
var PSEUDONYM_HEX_LENGTH = 32;
|
|
2333
|
+
var SHA256_K = new Uint32Array([
|
|
2334
|
+
1116352408,
|
|
2335
|
+
1899447441,
|
|
2336
|
+
3049323471,
|
|
2337
|
+
3921009573,
|
|
2338
|
+
961987163,
|
|
2339
|
+
1508970993,
|
|
2340
|
+
2453635748,
|
|
2341
|
+
2870763221,
|
|
2342
|
+
3624381080,
|
|
2343
|
+
310598401,
|
|
2344
|
+
607225278,
|
|
2345
|
+
1426881987,
|
|
2346
|
+
1925078388,
|
|
2347
|
+
2162078206,
|
|
2348
|
+
2614888103,
|
|
2349
|
+
3248222580,
|
|
2350
|
+
3835390401,
|
|
2351
|
+
4022224774,
|
|
2352
|
+
264347078,
|
|
2353
|
+
604807628,
|
|
2354
|
+
770255983,
|
|
2355
|
+
1249150122,
|
|
2356
|
+
1555081692,
|
|
2357
|
+
1996064986,
|
|
2358
|
+
2554220882,
|
|
2359
|
+
2821834349,
|
|
2360
|
+
2952996808,
|
|
2361
|
+
3210313671,
|
|
2362
|
+
3336571891,
|
|
2363
|
+
3584528711,
|
|
2364
|
+
113926993,
|
|
2365
|
+
338241895,
|
|
2366
|
+
666307205,
|
|
2367
|
+
773529912,
|
|
2368
|
+
1294757372,
|
|
2369
|
+
1396182291,
|
|
2370
|
+
1695183700,
|
|
2371
|
+
1986661051,
|
|
2372
|
+
2177026350,
|
|
2373
|
+
2456956037,
|
|
2374
|
+
2730485921,
|
|
2375
|
+
2820302411,
|
|
2376
|
+
3259730800,
|
|
2377
|
+
3345764771,
|
|
2378
|
+
3516065817,
|
|
2379
|
+
3600352804,
|
|
2380
|
+
4094571909,
|
|
2381
|
+
275423344,
|
|
2382
|
+
430227734,
|
|
2383
|
+
506948616,
|
|
2384
|
+
659060556,
|
|
2385
|
+
883997877,
|
|
2386
|
+
958139571,
|
|
2387
|
+
1322822218,
|
|
2388
|
+
1537002063,
|
|
2389
|
+
1747873779,
|
|
2390
|
+
1955562222,
|
|
2391
|
+
2024104815,
|
|
2392
|
+
2227730452,
|
|
2393
|
+
2361852424,
|
|
2394
|
+
2428436474,
|
|
2395
|
+
2756734187,
|
|
2396
|
+
3204031479,
|
|
2397
|
+
3329325298
|
|
2151
2398
|
]);
|
|
2152
|
-
var
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2399
|
+
var SHA256_INITIAL_STATE = new Uint32Array([
|
|
2400
|
+
1779033703,
|
|
2401
|
+
3144134277,
|
|
2402
|
+
1013904242,
|
|
2403
|
+
2773480762,
|
|
2404
|
+
1359893119,
|
|
2405
|
+
2600822924,
|
|
2406
|
+
528734635,
|
|
2407
|
+
1541459225
|
|
2161
2408
|
]);
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2409
|
+
function rotr(value, bits) {
|
|
2410
|
+
return (value >>> bits | value << 32 - bits) >>> 0;
|
|
2411
|
+
}
|
|
2412
|
+
function sha256Hex(input) {
|
|
2413
|
+
const bytes = new TextEncoder().encode(input);
|
|
2414
|
+
const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
|
|
2415
|
+
const buffer = new Uint8Array(paddedLength);
|
|
2416
|
+
buffer.set(bytes);
|
|
2417
|
+
buffer[bytes.length] = 128;
|
|
2418
|
+
const view = new DataView(buffer.buffer);
|
|
2419
|
+
const bitLength = bytes.length * 8;
|
|
2420
|
+
view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
|
|
2421
|
+
view.setUint32(paddedLength - 4, bitLength >>> 0);
|
|
2422
|
+
const state = SHA256_INITIAL_STATE.slice();
|
|
2423
|
+
const schedule = new Uint32Array(64);
|
|
2424
|
+
for (let offset = 0;offset < paddedLength; offset += 64) {
|
|
2425
|
+
for (let i = 0;i < 16; i++) {
|
|
2426
|
+
schedule[i] = view.getUint32(offset + i * 4);
|
|
2427
|
+
}
|
|
2428
|
+
for (let i = 16;i < 64; i++) {
|
|
2429
|
+
const x = schedule[i - 15];
|
|
2430
|
+
const y = schedule[i - 2];
|
|
2431
|
+
const s0 = (rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3) >>> 0;
|
|
2432
|
+
const s1 = (rotr(y, 17) ^ rotr(y, 19) ^ y >>> 10) >>> 0;
|
|
2433
|
+
schedule[i] = schedule[i - 16] + s0 + schedule[i - 7] + s1 >>> 0;
|
|
2434
|
+
}
|
|
2435
|
+
let a = state[0];
|
|
2436
|
+
let b = state[1];
|
|
2437
|
+
let c = state[2];
|
|
2438
|
+
let d = state[3];
|
|
2439
|
+
let e = state[4];
|
|
2440
|
+
let f = state[5];
|
|
2441
|
+
let g = state[6];
|
|
2442
|
+
let h = state[7];
|
|
2443
|
+
for (let i = 0;i < 64; i++) {
|
|
2444
|
+
const s1 = (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) >>> 0;
|
|
2445
|
+
const ch = (e & f ^ ~e & g) >>> 0;
|
|
2446
|
+
const temp1 = h + s1 + ch + SHA256_K[i] + schedule[i] >>> 0;
|
|
2447
|
+
const s0 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) >>> 0;
|
|
2448
|
+
const maj = (a & b ^ a & c ^ b & c) >>> 0;
|
|
2449
|
+
const temp2 = s0 + maj >>> 0;
|
|
2450
|
+
h = g;
|
|
2451
|
+
g = f;
|
|
2452
|
+
f = e;
|
|
2453
|
+
e = d + temp1 >>> 0;
|
|
2454
|
+
d = c;
|
|
2455
|
+
c = b;
|
|
2456
|
+
b = a;
|
|
2457
|
+
a = temp1 + temp2 >>> 0;
|
|
2458
|
+
}
|
|
2459
|
+
state[0] = state[0] + a >>> 0;
|
|
2460
|
+
state[1] = state[1] + b >>> 0;
|
|
2461
|
+
state[2] = state[2] + c >>> 0;
|
|
2462
|
+
state[3] = state[3] + d >>> 0;
|
|
2463
|
+
state[4] = state[4] + e >>> 0;
|
|
2464
|
+
state[5] = state[5] + f >>> 0;
|
|
2465
|
+
state[6] = state[6] + g >>> 0;
|
|
2466
|
+
state[7] = state[7] + h >>> 0;
|
|
2467
|
+
}
|
|
2468
|
+
let hex = "";
|
|
2469
|
+
for (const word of state) {
|
|
2470
|
+
hex += word.toString(16).padStart(8, "0");
|
|
2471
|
+
}
|
|
2472
|
+
return hex;
|
|
2473
|
+
}
|
|
2474
|
+
function resolveSha256Hex() {
|
|
2475
|
+
try {
|
|
2476
|
+
const nodeCrypto = __require("node:crypto");
|
|
2477
|
+
const createHash = nodeCrypto?.createHash;
|
|
2478
|
+
if (typeof createHash !== "function") {
|
|
2479
|
+
return sha256Hex;
|
|
2480
|
+
}
|
|
2481
|
+
const native = (input) => createHash("sha256").update(input, "utf8").digest("hex");
|
|
2482
|
+
return native("abc") === sha256Hex("abc") ? native : sha256Hex;
|
|
2483
|
+
} catch {
|
|
2484
|
+
return sha256Hex;
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
var cachedSha256Hex;
|
|
2488
|
+
function digest(input) {
|
|
2489
|
+
cachedSha256Hex ??= resolveSha256Hex();
|
|
2490
|
+
return cachedSha256Hex(input);
|
|
2491
|
+
}
|
|
2492
|
+
function pseudonymize(input) {
|
|
2493
|
+
return digest(`${PSEUDONYM_DOMAIN}${input}`).slice(0, PSEUDONYM_HEX_LENGTH);
|
|
2494
|
+
}
|
|
2180
2495
|
|
|
2181
|
-
// ../common/src/command-examples.ts
|
|
2182
|
-
var examplesByCommand = new WeakMap;
|
|
2183
|
-
Command.prototype.examples = function(examples) {
|
|
2184
|
-
examplesByCommand.set(this, examples);
|
|
2185
|
-
return this;
|
|
2186
|
-
};
|
|
2187
2496
|
// ../common/src/singleton.ts
|
|
2188
2497
|
var PREFIX = "@uipath/common/";
|
|
2189
2498
|
var _g = globalThis;
|
|
@@ -2214,58 +2523,414 @@ function singleton(ctorOrName) {
|
|
|
2214
2523
|
};
|
|
2215
2524
|
}
|
|
2216
2525
|
|
|
2217
|
-
// ../common/src/
|
|
2218
|
-
var
|
|
2219
|
-
function
|
|
2220
|
-
|
|
2526
|
+
// ../common/src/telemetry/supplied-values.ts
|
|
2527
|
+
var suppliedValuesSlot = singleton("TelemetrySuppliedArgumentValues");
|
|
2528
|
+
function activeEntries() {
|
|
2529
|
+
const existing = suppliedValuesSlot.get();
|
|
2530
|
+
return Array.isArray(existing) ? existing : [];
|
|
2531
|
+
}
|
|
2532
|
+
var MIN_SCRUBBABLE_LENGTH = 4;
|
|
2533
|
+
function recordSuppliedArgumentValues(values) {
|
|
2534
|
+
const flat = [];
|
|
2535
|
+
const push = (value) => {
|
|
2536
|
+
if (Array.isArray(value)) {
|
|
2537
|
+
for (const item of value) {
|
|
2538
|
+
push(item);
|
|
2539
|
+
}
|
|
2540
|
+
return;
|
|
2541
|
+
}
|
|
2542
|
+
if (typeof value === "string" && value.length >= MIN_SCRUBBABLE_LENGTH) {
|
|
2543
|
+
flat.push(value);
|
|
2544
|
+
}
|
|
2545
|
+
};
|
|
2546
|
+
push(values);
|
|
2547
|
+
const entry = { values: flat };
|
|
2548
|
+
suppliedValuesSlot.set([...activeEntries(), entry]);
|
|
2549
|
+
return entry;
|
|
2221
2550
|
}
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2551
|
+
function releaseSuppliedArgumentValues(entry) {
|
|
2552
|
+
suppliedValuesSlot.set(activeEntries().filter((held) => held !== entry));
|
|
2553
|
+
}
|
|
2554
|
+
function getSuppliedArgumentValues() {
|
|
2555
|
+
const all = new Set;
|
|
2556
|
+
for (const entry of activeEntries()) {
|
|
2557
|
+
for (const value of entry.values) {
|
|
2558
|
+
all.add(value);
|
|
2559
|
+
}
|
|
2225
2560
|
}
|
|
2226
|
-
return
|
|
2227
|
-
}
|
|
2561
|
+
return [...all].sort((a, b) => b.length - a.length);
|
|
2562
|
+
}
|
|
2228
2563
|
|
|
2229
|
-
// ../common/src/
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2564
|
+
// ../common/src/telemetry/pii-redactor.ts
|
|
2565
|
+
var REDACTED = "[REDACTED]";
|
|
2566
|
+
var MAX_VALUE_LENGTH = 280;
|
|
2567
|
+
var MAX_STACK_LENGTH = 4096;
|
|
2568
|
+
var MAX_SCAN_LENGTH = MAX_STACK_LENGTH;
|
|
2569
|
+
function truncate(value, maxLength) {
|
|
2570
|
+
return value.length > maxLength ? `${value.slice(0, maxLength)}…` : value;
|
|
2571
|
+
}
|
|
2572
|
+
var SENSITIVE_NAME_TOKENS = new Set([
|
|
2573
|
+
"token",
|
|
2574
|
+
"tokens",
|
|
2575
|
+
"secret",
|
|
2576
|
+
"secrets",
|
|
2577
|
+
"password",
|
|
2578
|
+
"passwords",
|
|
2579
|
+
"pwd",
|
|
2580
|
+
"credential",
|
|
2581
|
+
"credentials",
|
|
2582
|
+
"auth",
|
|
2583
|
+
"authentication",
|
|
2584
|
+
"authorization",
|
|
2585
|
+
"authority",
|
|
2586
|
+
"cert",
|
|
2587
|
+
"certificate",
|
|
2588
|
+
"certificates"
|
|
2589
|
+
]);
|
|
2590
|
+
var SENSITIVE_KEY_PREFIXES = new Set([
|
|
2591
|
+
"api",
|
|
2592
|
+
"access",
|
|
2593
|
+
"client",
|
|
2594
|
+
"private",
|
|
2595
|
+
"public",
|
|
2596
|
+
"signing",
|
|
2597
|
+
"encryption",
|
|
2598
|
+
"session",
|
|
2599
|
+
"master",
|
|
2600
|
+
"shared",
|
|
2601
|
+
"root",
|
|
2602
|
+
"ssh",
|
|
2603
|
+
"rsa",
|
|
2604
|
+
"aes",
|
|
2605
|
+
"hmac",
|
|
2606
|
+
"oauth"
|
|
2607
|
+
]);
|
|
2608
|
+
var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
|
|
2609
|
+
var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
2610
|
+
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
2611
|
+
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
2612
|
+
var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
2613
|
+
var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
|
|
2614
|
+
var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
|
|
2615
|
+
var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
|
|
2616
|
+
var HOST_PORT_PATTERN = /(?<![/@.\w-])(?!\d+\.\d+\.\d+\.\d+:)[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)+:\d{1,5}\b/g;
|
|
2617
|
+
var SOURCE_FILE_EXTENSIONS = new Set([
|
|
2618
|
+
"ts",
|
|
2619
|
+
"tsx",
|
|
2620
|
+
"js",
|
|
2621
|
+
"jsx",
|
|
2622
|
+
"mjs",
|
|
2623
|
+
"cjs",
|
|
2624
|
+
"cts",
|
|
2625
|
+
"mts",
|
|
2626
|
+
"py",
|
|
2627
|
+
"cs",
|
|
2628
|
+
"java",
|
|
2629
|
+
"go",
|
|
2630
|
+
"rs",
|
|
2631
|
+
"rb",
|
|
2632
|
+
"php",
|
|
2633
|
+
"sh",
|
|
2634
|
+
"ps1",
|
|
2635
|
+
"json",
|
|
2636
|
+
"jsonc",
|
|
2637
|
+
"yaml",
|
|
2638
|
+
"yml",
|
|
2639
|
+
"xml",
|
|
2640
|
+
"xaml",
|
|
2641
|
+
"md",
|
|
2642
|
+
"txt",
|
|
2643
|
+
"log",
|
|
2644
|
+
"css",
|
|
2645
|
+
"html",
|
|
2646
|
+
"htm",
|
|
2647
|
+
"csproj",
|
|
2648
|
+
"nuspec",
|
|
2649
|
+
"sql"
|
|
2650
|
+
]);
|
|
2651
|
+
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
2652
|
+
var QUOTED_LITERAL_MAX_SPAN = 200;
|
|
2653
|
+
var QUOTED_LITERAL_PATTERN = new RegExp([
|
|
2654
|
+
`(?<![A-Za-z0-9])'(?:[^\\
|
|
2655
|
+
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?'(?![A-Za-z0-9])`,
|
|
2656
|
+
`(?<![A-Za-z0-9])"(?:[^\\
|
|
2657
|
+
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
|
|
2658
|
+
].join("|"), "g");
|
|
2659
|
+
var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
|
|
2660
|
+
var COLLAPSED_BODY = "{…}";
|
|
2661
|
+
var COLLAPSED_BODY_MARKER = "\x01body\x01";
|
|
2662
|
+
var MAX_BODY_NESTING = 8;
|
|
2663
|
+
function collapseJsonBodies(text) {
|
|
2664
|
+
let out = text;
|
|
2665
|
+
for (let pass = 0;pass < MAX_BODY_NESTING; pass++) {
|
|
2666
|
+
const next = out.replace(JSON_BODY_PATTERN, COLLAPSED_BODY_MARKER);
|
|
2667
|
+
if (next === out) {
|
|
2668
|
+
break;
|
|
2669
|
+
}
|
|
2670
|
+
out = next;
|
|
2239
2671
|
}
|
|
2240
|
-
return
|
|
2672
|
+
return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
|
|
2241
2673
|
}
|
|
2242
|
-
var
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
outputWidth: 80
|
|
2674
|
+
var TRAILING_PROSE_PUNCT = /[.,;:!?)\]}>'"]+$/;
|
|
2675
|
+
function peelTrailingPunctuation(match) {
|
|
2676
|
+
const trailing = match.match(TRAILING_PROSE_PUNCT)?.[0] ?? "";
|
|
2677
|
+
return trailing ? [match.slice(0, -trailing.length), trailing] : [match, ""];
|
|
2678
|
+
}
|
|
2679
|
+
function redactUrl(raw) {
|
|
2680
|
+
try {
|
|
2681
|
+
const url = new URL(raw);
|
|
2682
|
+
return `${url.protocol}//${url.host}`;
|
|
2683
|
+
} catch {
|
|
2684
|
+
return `url#${pseudonymize(raw)}`;
|
|
2254
2685
|
}
|
|
2255
|
-
};
|
|
2256
|
-
function getOutputSink() {
|
|
2257
|
-
return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
|
|
2258
2686
|
}
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2687
|
+
function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
|
|
2688
|
+
let out = truncate(value, MAX_SCAN_LENGTH);
|
|
2689
|
+
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
2690
|
+
out = out.replace(URL_PATTERN, (match) => {
|
|
2691
|
+
const [core, trailing] = peelTrailingPunctuation(match);
|
|
2692
|
+
return `${redactUrl(core)}${trailing}`;
|
|
2693
|
+
});
|
|
2694
|
+
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
2695
|
+
out = out.replace(UNC_PATH_PATTERN, (_match, before, path2) => {
|
|
2696
|
+
const [core, trailing] = peelTrailingPunctuation(path2);
|
|
2697
|
+
return `${before}unc#${pseudonymize(core)}${trailing}`;
|
|
2698
|
+
});
|
|
2699
|
+
out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
|
|
2700
|
+
out = out.replace(UUID_PATTERN, (match) => `uuid#${pseudonymize(match)}`);
|
|
2701
|
+
out = out.replace(HOST_PORT_PATTERN, (match) => {
|
|
2702
|
+
const split = match.lastIndexOf(":");
|
|
2703
|
+
const host = match.slice(0, split);
|
|
2704
|
+
const extension = host.slice(host.lastIndexOf(".") + 1).toLowerCase();
|
|
2705
|
+
if (SOURCE_FILE_EXTENSIONS.has(extension)) {
|
|
2706
|
+
return match;
|
|
2707
|
+
}
|
|
2708
|
+
return `host#${pseudonymize(host)}:${match.slice(split + 1)}`;
|
|
2709
|
+
});
|
|
2710
|
+
out = out.replace(PADDED_BASE64_PATTERN, () => REDACTED);
|
|
2711
|
+
out = out.replace(BASE64_WITH_PLUS_PATTERN, (match) => match.includes("+") ? REDACTED : match);
|
|
2712
|
+
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
2713
|
+
return truncate(out, maxLength);
|
|
2714
|
+
}
|
|
2715
|
+
function redactSpanName(name) {
|
|
2716
|
+
return redactValueDetectors(truncate(name, MAX_SCAN_LENGTH).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`));
|
|
2717
|
+
}
|
|
2718
|
+
var HTTP_DEPENDENCY_NAME = /^([A-Z]+) (\/.*)$/s;
|
|
2719
|
+
function redactHttpDependencyName(name) {
|
|
2720
|
+
const parts = HTTP_DEPENDENCY_NAME.exec(name);
|
|
2721
|
+
if (!parts) {
|
|
2722
|
+
return redactMessage(name);
|
|
2723
|
+
}
|
|
2724
|
+
return `${parts[1]} ${redactMessage(parts[2])}`;
|
|
2725
|
+
}
|
|
2726
|
+
function redactMessage(value) {
|
|
2727
|
+
let out = collapseJsonBodies(truncate(value, MAX_SCAN_LENGTH)).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`);
|
|
2728
|
+
for (const supplied of getSuppliedArgumentValues()) {
|
|
2729
|
+
out = out.split(supplied).join(REDACTED);
|
|
2730
|
+
}
|
|
2731
|
+
return redactValueDetectors(out);
|
|
2732
|
+
}
|
|
2733
|
+
var MESSAGE_NAMES = new Set([
|
|
2734
|
+
"message",
|
|
2735
|
+
"errormessage",
|
|
2736
|
+
"errmessage",
|
|
2737
|
+
"error_message",
|
|
2738
|
+
"msg",
|
|
2739
|
+
"detail",
|
|
2740
|
+
"details",
|
|
2741
|
+
"reason",
|
|
2742
|
+
"instructions",
|
|
2743
|
+
"warning"
|
|
2744
|
+
]);
|
|
2745
|
+
function isFreeFormValue(name, value) {
|
|
2746
|
+
return MESSAGE_NAMES.has(name.toLowerCase()) || /['"{[]/.test(value);
|
|
2264
2747
|
}
|
|
2265
|
-
function
|
|
2266
|
-
|
|
2748
|
+
function redactError(error) {
|
|
2749
|
+
const safe = new Error(redactMessage(error.message ?? ""));
|
|
2750
|
+
safe.name = error.name;
|
|
2751
|
+
safe.stack = typeof error.stack === "string" ? redactStack(error.stack) : undefined;
|
|
2752
|
+
return safe;
|
|
2753
|
+
}
|
|
2754
|
+
function redactStack(stack) {
|
|
2755
|
+
const bounded = truncate(stack, MAX_STACK_LENGTH);
|
|
2756
|
+
const firstBreak = bounded.indexOf(`
|
|
2757
|
+
`);
|
|
2758
|
+
if (firstBreak === -1) {
|
|
2759
|
+
return redactMessage(bounded);
|
|
2760
|
+
}
|
|
2761
|
+
return `${redactMessage(bounded.slice(0, firstBreak))}
|
|
2762
|
+
${redactValueDetectors(bounded.slice(firstBreak + 1), MAX_STACK_LENGTH)}`;
|
|
2763
|
+
}
|
|
2764
|
+
function nameTokens(name) {
|
|
2765
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(/[\s._-]+/).map((t) => t.toLowerCase()).filter(Boolean);
|
|
2766
|
+
}
|
|
2767
|
+
function isSensitiveName(name) {
|
|
2768
|
+
const tokens = nameTokens(name);
|
|
2769
|
+
for (let i = 0;i < tokens.length; i++) {
|
|
2770
|
+
const token = tokens[i];
|
|
2771
|
+
if (SENSITIVE_NAME_TOKENS.has(token)) {
|
|
2772
|
+
return true;
|
|
2773
|
+
}
|
|
2774
|
+
if (token === "key" || token === "keys") {
|
|
2775
|
+
const prev = tokens[i - 1];
|
|
2776
|
+
if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
|
|
2777
|
+
return true;
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
return false;
|
|
2782
|
+
}
|
|
2783
|
+
function redactProperty(name, value) {
|
|
2784
|
+
if (value === undefined || value === null) {
|
|
2785
|
+
return;
|
|
2786
|
+
}
|
|
2787
|
+
if (isSensitiveName(name)) {
|
|
2788
|
+
return REDACTED;
|
|
2789
|
+
}
|
|
2790
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
2791
|
+
return value;
|
|
2792
|
+
}
|
|
2793
|
+
if (typeof value !== "string") {
|
|
2794
|
+
return "[OBJECT]";
|
|
2795
|
+
}
|
|
2796
|
+
return isFreeFormValue(name, value) ? redactMessage(value) : redactValueDetectors(value);
|
|
2797
|
+
}
|
|
2798
|
+
function redactProperties(properties) {
|
|
2799
|
+
const out = {};
|
|
2800
|
+
for (const [name, value] of Object.entries(properties)) {
|
|
2801
|
+
const redacted = redactProperty(name, value);
|
|
2802
|
+
if (redacted !== undefined) {
|
|
2803
|
+
out[name] = redacted;
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
return out;
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
// ../common/src/catch-error.ts
|
|
2810
|
+
var MAX_SERIALIZED_LENGTH = 500;
|
|
2811
|
+
var TRUNCATION_SUFFIX = "…(truncated)";
|
|
2812
|
+
var REDACTED2 = "[REDACTED]";
|
|
2813
|
+
function cap(text) {
|
|
2814
|
+
return text.length > MAX_SERIALIZED_LENGTH ? `${text.slice(0, MAX_SERIALIZED_LENGTH)}${TRUNCATION_SUFFIX}` : text;
|
|
2815
|
+
}
|
|
2816
|
+
function omitSensitive(key, value) {
|
|
2817
|
+
return key.length > 0 && isSensitiveName(key) ? REDACTED2 : value;
|
|
2818
|
+
}
|
|
2819
|
+
function describeThrownValue(value) {
|
|
2820
|
+
if (typeof value !== "object" || value === null) {
|
|
2821
|
+
return String(value);
|
|
2822
|
+
}
|
|
2823
|
+
let message;
|
|
2824
|
+
try {
|
|
2825
|
+
message = value.message;
|
|
2826
|
+
} catch {
|
|
2827
|
+
message = undefined;
|
|
2828
|
+
}
|
|
2829
|
+
if (typeof message === "string" && message.length > 0) {
|
|
2830
|
+
return cap(message);
|
|
2831
|
+
}
|
|
2832
|
+
try {
|
|
2833
|
+
const json = JSON.stringify(value, omitSensitive);
|
|
2834
|
+
if (json !== undefined) {
|
|
2835
|
+
return cap(json);
|
|
2836
|
+
}
|
|
2837
|
+
} catch {}
|
|
2838
|
+
return String(value);
|
|
2839
|
+
}
|
|
2840
|
+
function toError(error) {
|
|
2841
|
+
return error instanceof Error ? error : new Error(describeThrownValue(error), { cause: error });
|
|
2842
|
+
}
|
|
2843
|
+
function isPromiseLike(value) {
|
|
2844
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
2845
|
+
}
|
|
2846
|
+
function catchError(fnOrPromise) {
|
|
2847
|
+
if (isPromiseLike(fnOrPromise)) {
|
|
2848
|
+
return settlePromiseLike(fnOrPromise);
|
|
2849
|
+
}
|
|
2850
|
+
try {
|
|
2851
|
+
const result = fnOrPromise();
|
|
2852
|
+
if (isPromiseLike(result)) {
|
|
2853
|
+
return settlePromiseLike(result);
|
|
2854
|
+
}
|
|
2855
|
+
return [undefined, result];
|
|
2856
|
+
} catch (error) {
|
|
2857
|
+
return [toError(error), undefined];
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
function settlePromiseLike(thenable) {
|
|
2861
|
+
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2864
|
+
// ../common/src/error-handler.ts
|
|
2865
|
+
var NETWORK_ERROR_CODES = new Set([
|
|
2866
|
+
"ECONNREFUSED",
|
|
2867
|
+
"ECONNRESET",
|
|
2868
|
+
"ENOTFOUND",
|
|
2869
|
+
"EAI_AGAIN",
|
|
2870
|
+
"ETIMEDOUT",
|
|
2871
|
+
"EPIPE",
|
|
2872
|
+
"EHOSTUNREACH",
|
|
2873
|
+
"ENETUNREACH",
|
|
2874
|
+
"EAI_FAIL"
|
|
2875
|
+
]);
|
|
2876
|
+
var TLS_ERROR_CODES = new Set([
|
|
2877
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
2878
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
2879
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
2880
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
2881
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
2882
|
+
"CERT_HAS_EXPIRED",
|
|
2883
|
+
"CERT_UNTRUSTED",
|
|
2884
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
2885
|
+
]);
|
|
2886
|
+
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.";
|
|
2887
|
+
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.";
|
|
2888
|
+
var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
|
|
2889
|
+
// ../common/src/exit-code.ts
|
|
2890
|
+
function setExitCode(code) {
|
|
2891
|
+
process.exitCode = code;
|
|
2892
|
+
}
|
|
2893
|
+
|
|
2894
|
+
// ../common/src/output-context.ts
|
|
2895
|
+
function createStorage() {
|
|
2896
|
+
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
2897
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
2898
|
+
return {
|
|
2899
|
+
getStore: () => {
|
|
2900
|
+
return;
|
|
2901
|
+
},
|
|
2902
|
+
run: (_store, fn) => fn()
|
|
2903
|
+
};
|
|
2904
|
+
}
|
|
2905
|
+
return new mod.AsyncLocalStorage;
|
|
2906
|
+
}
|
|
2907
|
+
var storageSingleton = singleton("OutputStorage");
|
|
2908
|
+
var sinkSlot = singleton("OutputSink");
|
|
2909
|
+
var outputStorage = storageSingleton.getOrInit(createStorage, (v) => ("getStore" in v));
|
|
2910
|
+
var CONSOLE_FALLBACK = {
|
|
2911
|
+
writeOut: (str) => process.stdout.write(str),
|
|
2912
|
+
writeErr: (str) => process.stderr.write(str),
|
|
2913
|
+
writeLog: (str) => process.stdout.write(str),
|
|
2914
|
+
capabilities: {
|
|
2915
|
+
isInteractive: false,
|
|
2916
|
+
canReadInput: false,
|
|
2917
|
+
supportsColor: false,
|
|
2918
|
+
outputWidth: 80
|
|
2919
|
+
}
|
|
2920
|
+
};
|
|
2921
|
+
function getOutputSink() {
|
|
2922
|
+
return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
|
|
2267
2923
|
}
|
|
2268
|
-
|
|
2924
|
+
|
|
2925
|
+
// ../common/src/logger.ts
|
|
2926
|
+
var logFilePathSlot = singleton("logFilePath");
|
|
2927
|
+
function setGlobalLogFilePath(path2) {
|
|
2928
|
+
logFilePathSlot.set(path2);
|
|
2929
|
+
}
|
|
2930
|
+
function getGlobalLogFilePath() {
|
|
2931
|
+
return logFilePathSlot.get("");
|
|
2932
|
+
}
|
|
2933
|
+
var DEFAULT_LOG_LEVEL = 3 /* ERROR */;
|
|
2269
2934
|
|
|
2270
2935
|
class SimpleLogger {
|
|
2271
2936
|
__brand = "SimpleLogger";
|
|
@@ -2297,7 +2962,7 @@ class SimpleLogger {
|
|
|
2297
2962
|
}
|
|
2298
2963
|
return DEFAULT_LOG_LEVEL;
|
|
2299
2964
|
}
|
|
2300
|
-
const [localStorageError, hasDebug] =
|
|
2965
|
+
const [localStorageError, hasDebug] = catchError(() => typeof localStorage !== "undefined" && !!localStorage.getItem("debug"));
|
|
2301
2966
|
if (!localStorageError && hasDebug) {
|
|
2302
2967
|
return 0 /* DEBUG */;
|
|
2303
2968
|
}
|
|
@@ -2328,54 +2993,49 @@ class SimpleLogger {
|
|
|
2328
2993
|
return this.fileLoggingEnabled || !!getGlobalLogFilePath();
|
|
2329
2994
|
}
|
|
2330
2995
|
writeToFile(formatted) {
|
|
2331
|
-
const
|
|
2332
|
-
if (!
|
|
2996
|
+
const path2 = this.logFilePath || getGlobalLogFilePath();
|
|
2997
|
+
if (!path2)
|
|
2333
2998
|
return;
|
|
2334
2999
|
const timestamp = new Date().toISOString();
|
|
2335
3000
|
this.pendingWrites = Promise.all([
|
|
2336
3001
|
this.pendingWrites,
|
|
2337
3002
|
this.pendingInit
|
|
2338
|
-
]).then(() => getFileSystem().appendFile(
|
|
3003
|
+
]).then(() => getFileSystem().appendFile(path2, `${timestamp} ${formatted}`).catch(() => {}));
|
|
2339
3004
|
}
|
|
2340
|
-
|
|
2341
|
-
if (this.level > 0 /* DEBUG */)
|
|
2342
|
-
return;
|
|
2343
|
-
const formatted = this.format(`[DEBUG] ${message}`, args);
|
|
3005
|
+
write(formatted) {
|
|
2344
3006
|
if (this.isFileLoggingActive()) {
|
|
2345
3007
|
this.writeToFile(formatted);
|
|
2346
3008
|
} else {
|
|
2347
3009
|
getOutputSink().writeErr(formatted);
|
|
2348
3010
|
}
|
|
2349
3011
|
}
|
|
3012
|
+
debug(message, ...args) {
|
|
3013
|
+
if (this.level > 0 /* DEBUG */)
|
|
3014
|
+
return;
|
|
3015
|
+
const formatted = this.format(`[DEBUG] ${message}`, args);
|
|
3016
|
+
this.write(formatted);
|
|
3017
|
+
}
|
|
2350
3018
|
info(message, ...args) {
|
|
2351
3019
|
if (this.level > 1 /* INFO */)
|
|
2352
3020
|
return;
|
|
2353
3021
|
const formatted = this.format(message, args);
|
|
2354
|
-
|
|
2355
|
-
this.writeToFile(formatted);
|
|
2356
|
-
} else {
|
|
2357
|
-
getOutputSink().writeErr(formatted);
|
|
2358
|
-
}
|
|
3022
|
+
this.write(formatted);
|
|
2359
3023
|
}
|
|
2360
3024
|
warn(message, ...args) {
|
|
2361
3025
|
if (this.level > 2 /* WARN */)
|
|
2362
3026
|
return;
|
|
2363
3027
|
const formatted = this.format(`[WARN] ${message}`, args);
|
|
2364
|
-
|
|
2365
|
-
this.writeToFile(formatted);
|
|
2366
|
-
} else {
|
|
2367
|
-
getOutputSink().writeErr(formatted);
|
|
2368
|
-
}
|
|
3028
|
+
this.write(formatted);
|
|
2369
3029
|
}
|
|
2370
3030
|
error(message, ...args) {
|
|
2371
3031
|
if (this.level > 3 /* ERROR */)
|
|
2372
3032
|
return;
|
|
2373
3033
|
const formatted = this.format(`[ERROR] ${message}`, args);
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
3034
|
+
this.write(formatted);
|
|
3035
|
+
}
|
|
3036
|
+
report(message) {
|
|
3037
|
+
const formatted = this.format(message, []);
|
|
3038
|
+
this.write(formatted);
|
|
2379
3039
|
}
|
|
2380
3040
|
getLevel() {
|
|
2381
3041
|
return this.level;
|
|
@@ -2390,17 +3050,17 @@ class SimpleLogger {
|
|
|
2390
3050
|
setGlobalLogFilePath("");
|
|
2391
3051
|
}
|
|
2392
3052
|
}
|
|
2393
|
-
setLogFile(
|
|
2394
|
-
this.logFilePath =
|
|
2395
|
-
setGlobalLogFilePath(
|
|
2396
|
-
if (!
|
|
3053
|
+
setLogFile(path2) {
|
|
3054
|
+
this.logFilePath = path2;
|
|
3055
|
+
setGlobalLogFilePath(path2);
|
|
3056
|
+
if (!path2)
|
|
2397
3057
|
return;
|
|
2398
3058
|
this.fileLoggingEnabled = true;
|
|
2399
|
-
const
|
|
3059
|
+
const fs2 = getFileSystem();
|
|
2400
3060
|
this.pendingInit = (async () => {
|
|
2401
|
-
const [error] = await
|
|
2402
|
-
await
|
|
2403
|
-
await
|
|
3061
|
+
const [error] = await catchError((async () => {
|
|
3062
|
+
await fs2.mkdir(fs2.path.dirname(path2));
|
|
3063
|
+
await fs2.writeFile(path2, "");
|
|
2404
3064
|
})());
|
|
2405
3065
|
if (error)
|
|
2406
3066
|
this.fileLoggingEnabled = false;
|
|
@@ -2454,12 +3114,12 @@ var jmespathSlot = singleton("JmespathCodec");
|
|
|
2454
3114
|
async function loadOutputCodecsAsync(needed) {
|
|
2455
3115
|
const loads = [];
|
|
2456
3116
|
if (needed.yaml && yamlSlot.get() === undefined) {
|
|
2457
|
-
loads.push(import("./js-yaml-
|
|
3117
|
+
loads.push(import("./js-yaml-88tdqrtd.js").then((mod) => {
|
|
2458
3118
|
yamlSlot.set(mod);
|
|
2459
3119
|
}));
|
|
2460
3120
|
}
|
|
2461
3121
|
if (needed.filter && jmespathSlot.get() === undefined) {
|
|
2462
|
-
loads.push(import("./index-
|
|
3122
|
+
loads.push(import("./index-gpd94m28.js").then((mod) => {
|
|
2463
3123
|
jmespathSlot.set(mod);
|
|
2464
3124
|
}));
|
|
2465
3125
|
}
|
|
@@ -2717,7 +3377,7 @@ function readRegistryValue(keyPath, valueName) {
|
|
|
2717
3377
|
if (process.platform !== "win32") {
|
|
2718
3378
|
return "";
|
|
2719
3379
|
}
|
|
2720
|
-
const [error, output] =
|
|
3380
|
+
const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
|
|
2721
3381
|
encoding: "utf-8",
|
|
2722
3382
|
stdio: ["pipe", "pipe", "pipe"]
|
|
2723
3383
|
}));
|
|
@@ -2740,27 +3400,41 @@ class LoggerTelemetryProvider {
|
|
|
2740
3400
|
...this.analyticsUniqueId ? { analyticsUniqueId: this.analyticsUniqueId } : {}
|
|
2741
3401
|
};
|
|
2742
3402
|
}
|
|
2743
|
-
async trackEvent(
|
|
2744
|
-
logger.debug(formatMessage("Event",
|
|
3403
|
+
async trackEvent({ name, properties }) {
|
|
3404
|
+
logger.debug(formatMessage("Event", name, this.enrich(properties)));
|
|
2745
3405
|
}
|
|
2746
|
-
async trackException(
|
|
3406
|
+
async trackException({
|
|
3407
|
+
error,
|
|
3408
|
+
properties
|
|
3409
|
+
}) {
|
|
2747
3410
|
logger.error(formatMessage("Exception", error.message, this.enrich({
|
|
2748
3411
|
...properties,
|
|
2749
3412
|
stack: error.stack
|
|
2750
3413
|
})));
|
|
2751
3414
|
}
|
|
2752
|
-
async trackRequest(
|
|
3415
|
+
async trackRequest({
|
|
3416
|
+
name,
|
|
3417
|
+
durationMs,
|
|
3418
|
+
success,
|
|
3419
|
+
properties
|
|
3420
|
+
}) {
|
|
2753
3421
|
logger.debug(formatMessage("Request", name, this.enrich({
|
|
2754
3422
|
...properties,
|
|
2755
|
-
duration: `${
|
|
3423
|
+
duration: `${durationMs}ms`,
|
|
2756
3424
|
success
|
|
2757
3425
|
})));
|
|
2758
3426
|
}
|
|
2759
|
-
async trackDependency(
|
|
3427
|
+
async trackDependency({
|
|
3428
|
+
name,
|
|
3429
|
+
type,
|
|
3430
|
+
durationMs,
|
|
3431
|
+
success,
|
|
3432
|
+
properties
|
|
3433
|
+
}) {
|
|
2760
3434
|
logger.debug(formatMessage("Dependency", name, this.enrich({
|
|
2761
3435
|
...properties,
|
|
2762
3436
|
type,
|
|
2763
|
-
duration: `${
|
|
3437
|
+
duration: `${durationMs}ms`,
|
|
2764
3438
|
success
|
|
2765
3439
|
})));
|
|
2766
3440
|
}
|
|
@@ -3016,144 +3690,16 @@ function getGlobalTelemetryProperties() {
|
|
|
3016
3690
|
return telemetryPropsSlot.get();
|
|
3017
3691
|
}
|
|
3018
3692
|
|
|
3019
|
-
// ../common/src/telemetry/
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
"secrets",
|
|
3027
|
-
"password",
|
|
3028
|
-
"passwords",
|
|
3029
|
-
"pwd",
|
|
3030
|
-
"credential",
|
|
3031
|
-
"credentials",
|
|
3032
|
-
"auth",
|
|
3033
|
-
"authentication",
|
|
3034
|
-
"authorization",
|
|
3035
|
-
"authority",
|
|
3036
|
-
"cert",
|
|
3037
|
-
"certificate",
|
|
3038
|
-
"certificates"
|
|
3039
|
-
]);
|
|
3040
|
-
var SENSITIVE_KEY_PREFIXES = new Set([
|
|
3041
|
-
"api",
|
|
3042
|
-
"access",
|
|
3043
|
-
"client",
|
|
3044
|
-
"private",
|
|
3045
|
-
"public",
|
|
3046
|
-
"signing",
|
|
3047
|
-
"encryption",
|
|
3048
|
-
"session",
|
|
3049
|
-
"master",
|
|
3050
|
-
"shared",
|
|
3051
|
-
"root",
|
|
3052
|
-
"ssh",
|
|
3053
|
-
"rsa",
|
|
3054
|
-
"aes",
|
|
3055
|
-
"hmac",
|
|
3056
|
-
"oauth"
|
|
3057
|
-
]);
|
|
3058
|
-
var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
|
|
3059
|
-
var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
3060
|
-
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
3061
|
-
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
3062
|
-
var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
|
|
3063
|
-
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
3064
|
-
var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
|
|
3065
|
-
function shortHash(input) {
|
|
3066
|
-
let hash = 2166136261;
|
|
3067
|
-
for (let i = 0;i < input.length; i++) {
|
|
3068
|
-
hash ^= input.charCodeAt(i);
|
|
3069
|
-
hash = Math.imul(hash, 16777619);
|
|
3070
|
-
}
|
|
3071
|
-
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
3072
|
-
}
|
|
3073
|
-
function redactUrl(raw) {
|
|
3074
|
-
try {
|
|
3075
|
-
const url = new URL(raw);
|
|
3076
|
-
return `${url.protocol}//${url.host}`;
|
|
3077
|
-
} catch {
|
|
3078
|
-
return `url#${shortHash(raw)}`;
|
|
3079
|
-
}
|
|
3080
|
-
}
|
|
3081
|
-
function redactValueDetectors(value) {
|
|
3082
|
-
let out = value;
|
|
3083
|
-
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
3084
|
-
out = out.replace(URL_PATTERN, (match) => {
|
|
3085
|
-
const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
|
|
3086
|
-
const core = trailing ? match.slice(0, -trailing.length) : match;
|
|
3087
|
-
return `${redactUrl(core)}${trailing}`;
|
|
3088
|
-
});
|
|
3089
|
-
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
3090
|
-
out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
|
|
3091
|
-
out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
|
|
3092
|
-
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
3093
|
-
if (out.length > MAX_VALUE_LENGTH) {
|
|
3094
|
-
out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
|
|
3095
|
-
}
|
|
3096
|
-
return out;
|
|
3097
|
-
}
|
|
3098
|
-
function redactValue(value) {
|
|
3099
|
-
return redactValueDetectors(value);
|
|
3100
|
-
}
|
|
3101
|
-
function redactError(error) {
|
|
3102
|
-
const safe = new Error(redactValueDetectors(error.message ?? ""));
|
|
3103
|
-
safe.name = error.name;
|
|
3104
|
-
safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
|
|
3105
|
-
return safe;
|
|
3106
|
-
}
|
|
3107
|
-
function nameTokens(name) {
|
|
3108
|
-
return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(/[\s._-]+/).map((t) => t.toLowerCase()).filter(Boolean);
|
|
3109
|
-
}
|
|
3110
|
-
function isSensitiveName(name) {
|
|
3111
|
-
const tokens = nameTokens(name);
|
|
3112
|
-
for (let i = 0;i < tokens.length; i++) {
|
|
3113
|
-
const token = tokens[i];
|
|
3114
|
-
if (SENSITIVE_NAME_TOKENS.has(token)) {
|
|
3115
|
-
return true;
|
|
3116
|
-
}
|
|
3117
|
-
if (token === "key" || token === "keys") {
|
|
3118
|
-
const prev = tokens[i - 1];
|
|
3119
|
-
if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
|
|
3120
|
-
return true;
|
|
3121
|
-
}
|
|
3122
|
-
}
|
|
3123
|
-
}
|
|
3124
|
-
return false;
|
|
3125
|
-
}
|
|
3126
|
-
function redactProperty(name, value) {
|
|
3127
|
-
if (value === undefined || value === null) {
|
|
3128
|
-
return;
|
|
3129
|
-
}
|
|
3130
|
-
if (isSensitiveName(name)) {
|
|
3131
|
-
return REDACTED;
|
|
3132
|
-
}
|
|
3133
|
-
if (typeof value === "boolean" || typeof value === "number") {
|
|
3134
|
-
return value;
|
|
3135
|
-
}
|
|
3136
|
-
if (typeof value !== "string") {
|
|
3137
|
-
return "[OBJECT]";
|
|
3138
|
-
}
|
|
3139
|
-
return redactValueDetectors(value);
|
|
3140
|
-
}
|
|
3141
|
-
function redactProperties(properties) {
|
|
3142
|
-
const out = {};
|
|
3143
|
-
for (const [name, value] of Object.entries(properties)) {
|
|
3144
|
-
const redacted = redactProperty(name, value);
|
|
3145
|
-
if (redacted !== undefined) {
|
|
3146
|
-
out[name] = redacted;
|
|
3147
|
-
}
|
|
3148
|
-
}
|
|
3149
|
-
return out;
|
|
3693
|
+
// ../common/src/telemetry/span-clock.ts
|
|
3694
|
+
function startSpanClock() {
|
|
3695
|
+
const started = performance.now();
|
|
3696
|
+
return {
|
|
3697
|
+
startedAt: new Date(performance.timeOrigin + started),
|
|
3698
|
+
elapsedMs: () => performance.now() - started
|
|
3699
|
+
};
|
|
3150
3700
|
}
|
|
3151
3701
|
|
|
3152
3702
|
// ../common/src/telemetry/telemetry-service.ts
|
|
3153
|
-
var TELEMETRY_OPERATION_ID_PROPERTY = "uip.trace.operation_id";
|
|
3154
|
-
var TELEMETRY_PARENT_ID_PROPERTY = "uip.trace.parent_id";
|
|
3155
|
-
var TELEMETRY_SPAN_ID_PROPERTY = "uip.trace.span_id";
|
|
3156
|
-
|
|
3157
3703
|
class TelemetryService {
|
|
3158
3704
|
telemetryProvider;
|
|
3159
3705
|
contextStorage;
|
|
@@ -3173,36 +3719,39 @@ class TelemetryService {
|
|
|
3173
3719
|
this.defaultProperties = properties === undefined ? undefined : { ...this.defaultProperties, ...properties };
|
|
3174
3720
|
}
|
|
3175
3721
|
trackEvent(name, properties) {
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3722
|
+
this.telemetryProvider.trackEvent({
|
|
3723
|
+
name: redactSpanName(name),
|
|
3724
|
+
properties: this.enrichProperties(properties),
|
|
3725
|
+
...this.leafCorrelation()
|
|
3726
|
+
});
|
|
3179
3727
|
}
|
|
3180
|
-
trackException(error, properties) {
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3728
|
+
trackException(error, properties, context) {
|
|
3729
|
+
this.telemetryProvider.trackException({
|
|
3730
|
+
error: redactError(error),
|
|
3731
|
+
properties: this.enrichProperties(properties),
|
|
3732
|
+
...this.leafCorrelation(context)
|
|
3733
|
+
});
|
|
3184
3734
|
}
|
|
3185
3735
|
async trackRequest(name, fn, properties) {
|
|
3186
|
-
const parentContext = this.
|
|
3736
|
+
const parentContext = this.getActiveContext();
|
|
3187
3737
|
const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
|
|
3188
3738
|
const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
|
|
3739
|
+
const clock = startSpanClock();
|
|
3189
3740
|
const context = {
|
|
3190
3741
|
operationId,
|
|
3191
3742
|
...parentId !== undefined ? { parentId } : {},
|
|
3192
|
-
id: this.generateId()
|
|
3743
|
+
id: this.generateId(),
|
|
3744
|
+
startedAt: clock.startedAt
|
|
3193
3745
|
};
|
|
3194
|
-
const startTime = performance.now();
|
|
3195
3746
|
try {
|
|
3196
3747
|
const result = await this.contextStorage.run(context, fn);
|
|
3197
|
-
const durationMs =
|
|
3198
|
-
|
|
3199
|
-
await this.telemetryProvider.trackRequest(name, durationMs, true, enrichedProperties);
|
|
3748
|
+
const durationMs = clock.elapsedMs();
|
|
3749
|
+
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, true, properties, context));
|
|
3200
3750
|
return result;
|
|
3201
3751
|
} catch (error) {
|
|
3202
|
-
const durationMs =
|
|
3752
|
+
const durationMs = clock.elapsedMs();
|
|
3203
3753
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
3204
|
-
|
|
3205
|
-
await this.telemetryProvider.trackRequest(name, durationMs, false, enrichedProperties);
|
|
3754
|
+
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, context));
|
|
3206
3755
|
throw error;
|
|
3207
3756
|
}
|
|
3208
3757
|
}
|
|
@@ -3211,8 +3760,7 @@ class TelemetryService {
|
|
|
3211
3760
|
operationId: this.operationId ?? getTelemetryOperationId(),
|
|
3212
3761
|
id: this.generateId()
|
|
3213
3762
|
};
|
|
3214
|
-
|
|
3215
|
-
this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
|
|
3763
|
+
this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, success, properties, requestContext));
|
|
3216
3764
|
}
|
|
3217
3765
|
createRequestContext() {
|
|
3218
3766
|
const operationId = this.operationId ?? getTelemetryOperationId();
|
|
@@ -3220,7 +3768,8 @@ class TelemetryService {
|
|
|
3220
3768
|
return {
|
|
3221
3769
|
operationId,
|
|
3222
3770
|
...parentId !== undefined ? { parentId } : {},
|
|
3223
|
-
id: this.generateId()
|
|
3771
|
+
id: this.generateId(),
|
|
3772
|
+
startedAt: startSpanClock().startedAt
|
|
3224
3773
|
};
|
|
3225
3774
|
}
|
|
3226
3775
|
inboundParentIdFor(operationId) {
|
|
@@ -3231,58 +3780,84 @@ class TelemetryService {
|
|
|
3231
3780
|
return this.contextStorage.run(context, fn);
|
|
3232
3781
|
}
|
|
3233
3782
|
createDependencyContext() {
|
|
3234
|
-
const parentContext = this.
|
|
3783
|
+
const parentContext = this.getActiveContext();
|
|
3235
3784
|
if (!parentContext) {
|
|
3236
3785
|
return;
|
|
3237
3786
|
}
|
|
3238
3787
|
return {
|
|
3239
3788
|
operationId: parentContext.operationId,
|
|
3240
3789
|
parentId: parentContext.id,
|
|
3241
|
-
id: this.generateId()
|
|
3790
|
+
id: this.generateId(),
|
|
3791
|
+
startedAt: startSpanClock().startedAt
|
|
3242
3792
|
};
|
|
3243
3793
|
}
|
|
3244
3794
|
trackDependencyResult(name, type, durationMs, success, properties, context, resultCode) {
|
|
3245
|
-
|
|
3246
|
-
|
|
3795
|
+
this.telemetryProvider.trackDependency({
|
|
3796
|
+
...this.spanFor(redactHttpDependencyName(name), durationMs, success, properties, context),
|
|
3797
|
+
type,
|
|
3798
|
+
...resultCode !== undefined ? { resultCode } : {}
|
|
3799
|
+
});
|
|
3247
3800
|
}
|
|
3248
3801
|
async trackDependencyOperation(name, type, fn, properties) {
|
|
3249
|
-
const
|
|
3802
|
+
const clock = startSpanClock();
|
|
3803
|
+
const parentContext = this.getActiveContext();
|
|
3250
3804
|
const childContext = parentContext !== undefined ? {
|
|
3251
3805
|
operationId: parentContext.operationId,
|
|
3252
3806
|
parentId: parentContext.id,
|
|
3253
|
-
id: this.generateId()
|
|
3254
|
-
|
|
3255
|
-
|
|
3807
|
+
id: this.generateId(),
|
|
3808
|
+
startedAt: clock.startedAt
|
|
3809
|
+
} : {
|
|
3810
|
+
...this.createRequestContext(),
|
|
3811
|
+
startedAt: clock.startedAt
|
|
3812
|
+
};
|
|
3256
3813
|
try {
|
|
3257
3814
|
const result = await this.contextStorage.run(childContext, fn);
|
|
3258
|
-
const durationMs =
|
|
3259
|
-
|
|
3260
|
-
|
|
3815
|
+
const durationMs = clock.elapsedMs();
|
|
3816
|
+
await this.telemetryProvider.trackDependency({
|
|
3817
|
+
...this.spanFor(name, durationMs, true, properties, childContext),
|
|
3818
|
+
type
|
|
3819
|
+
});
|
|
3261
3820
|
return result;
|
|
3262
3821
|
} catch (error) {
|
|
3263
|
-
const durationMs =
|
|
3822
|
+
const durationMs = clock.elapsedMs();
|
|
3264
3823
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
3265
|
-
|
|
3266
|
-
|
|
3824
|
+
await this.telemetryProvider.trackDependency({
|
|
3825
|
+
...this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, childContext),
|
|
3826
|
+
type
|
|
3827
|
+
});
|
|
3267
3828
|
throw error;
|
|
3268
3829
|
}
|
|
3269
3830
|
}
|
|
3270
|
-
|
|
3831
|
+
getActiveContext() {
|
|
3271
3832
|
return this.contextStorage.getContext();
|
|
3272
3833
|
}
|
|
3273
|
-
|
|
3834
|
+
leafCorrelation(explicit) {
|
|
3835
|
+
const context = explicit ?? this.getActiveContext();
|
|
3836
|
+
return {
|
|
3837
|
+
operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
|
|
3838
|
+
...context !== undefined ? { parentId: context.id } : {}
|
|
3839
|
+
};
|
|
3840
|
+
}
|
|
3841
|
+
spanFor(name, durationMs, success, properties, context) {
|
|
3842
|
+
return {
|
|
3843
|
+
name: redactSpanName(name),
|
|
3844
|
+
durationMs,
|
|
3845
|
+
success,
|
|
3846
|
+
properties: this.enrichProperties(properties),
|
|
3847
|
+
operationId: context.operationId,
|
|
3848
|
+
...context.parentId !== undefined ? { parentId: context.parentId } : {},
|
|
3849
|
+
id: context.id,
|
|
3850
|
+
...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
|
|
3851
|
+
};
|
|
3852
|
+
}
|
|
3853
|
+
enrichProperties(properties) {
|
|
3274
3854
|
const globalProperties = getGlobalTelemetryProperties();
|
|
3275
3855
|
const enriched = {
|
|
3276
3856
|
...getExecutionContextTelemetryProperties(),
|
|
3277
3857
|
...globalProperties,
|
|
3278
3858
|
...this.defaultProperties,
|
|
3279
3859
|
...redactProperties(properties ?? {}),
|
|
3280
|
-
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
|
|
3281
|
-
...context ? {
|
|
3282
|
-
[TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
|
|
3283
|
-
...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
|
|
3284
|
-
[TELEMETRY_SPAN_ID_PROPERTY]: context.id
|
|
3285
|
-
} : {}
|
|
3860
|
+
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
|
|
3286
3861
|
};
|
|
3287
3862
|
return enriched;
|
|
3288
3863
|
}
|
|
@@ -3299,6 +3874,81 @@ class TelemetryService {
|
|
|
3299
3874
|
return hex;
|
|
3300
3875
|
}
|
|
3301
3876
|
}
|
|
3877
|
+
// ../common/src/timings.ts
|
|
3878
|
+
var TIMINGS_ENV_VAR = "UIP_TIMINGS";
|
|
3879
|
+
function createStorage2() {
|
|
3880
|
+
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
3881
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
3882
|
+
return {
|
|
3883
|
+
getStore: () => {
|
|
3884
|
+
return;
|
|
3885
|
+
},
|
|
3886
|
+
run: (_store, fn) => fn()
|
|
3887
|
+
};
|
|
3888
|
+
}
|
|
3889
|
+
return new mod.AsyncLocalStorage;
|
|
3890
|
+
}
|
|
3891
|
+
var storageSlot = singleton("TimingStorage");
|
|
3892
|
+
var stateSlot = singleton("Timings");
|
|
3893
|
+
var rootStartedSlot = singleton("TimingsRootStarted");
|
|
3894
|
+
var longLivedHostSlot = singleton("TimingsLongLivedHost");
|
|
3895
|
+
var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
|
|
3896
|
+
function newState(baseline) {
|
|
3897
|
+
return { baseline, httpMs: 0, httpCalls: 0 };
|
|
3898
|
+
}
|
|
3899
|
+
function getState() {
|
|
3900
|
+
const scoped = storage.getStore();
|
|
3901
|
+
if (scoped) {
|
|
3902
|
+
return scoped;
|
|
3903
|
+
}
|
|
3904
|
+
const pinned = livePinnedState();
|
|
3905
|
+
if (pinned !== undefined) {
|
|
3906
|
+
return pinned;
|
|
3907
|
+
}
|
|
3908
|
+
return newState(processStartIsInvocationStart() ? 0 : performance.now());
|
|
3909
|
+
}
|
|
3910
|
+
function livePinnedState() {
|
|
3911
|
+
const pinned = stateSlot.get();
|
|
3912
|
+
return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
|
|
3913
|
+
}
|
|
3914
|
+
function processStartIsInvocationStart() {
|
|
3915
|
+
return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
|
|
3916
|
+
}
|
|
3917
|
+
function timingsEnabled() {
|
|
3918
|
+
if (typeof process === "undefined") {
|
|
3919
|
+
return false;
|
|
3920
|
+
}
|
|
3921
|
+
const value = process.env?.[TIMINGS_ENV_VAR];
|
|
3922
|
+
if (value === undefined) {
|
|
3923
|
+
return false;
|
|
3924
|
+
}
|
|
3925
|
+
const normalized = value.trim().toLowerCase();
|
|
3926
|
+
return normalized === "1" || normalized === "true";
|
|
3927
|
+
}
|
|
3928
|
+
function recordExitCode(exitCode) {
|
|
3929
|
+
if (!timingsEnabled()) {
|
|
3930
|
+
return;
|
|
3931
|
+
}
|
|
3932
|
+
getState().exitCode = exitCode;
|
|
3933
|
+
}
|
|
3934
|
+
function invocationStartedAt() {
|
|
3935
|
+
return new Date(performance.timeOrigin + getState().baseline);
|
|
3936
|
+
}
|
|
3937
|
+
function invocationElapsedMs() {
|
|
3938
|
+
return performance.now() - getState().baseline;
|
|
3939
|
+
}
|
|
3940
|
+
function markCommandStart() {
|
|
3941
|
+
if (!timingsEnabled()) {
|
|
3942
|
+
return;
|
|
3943
|
+
}
|
|
3944
|
+
getState().commandStart = performance.now();
|
|
3945
|
+
}
|
|
3946
|
+
function recordCommandDuration(durationMs) {
|
|
3947
|
+
if (!timingsEnabled()) {
|
|
3948
|
+
return;
|
|
3949
|
+
}
|
|
3950
|
+
getState().commandMs = durationMs;
|
|
3951
|
+
}
|
|
3302
3952
|
// ../common/src/telemetry/proxy-http-agent.ts
|
|
3303
3953
|
var slot = singleton("ProxyAuthHttpsAgent");
|
|
3304
3954
|
|
|
@@ -3319,6 +3969,9 @@ function getGlobalTelemetryInstance() {
|
|
|
3319
3969
|
}
|
|
3320
3970
|
return;
|
|
3321
3971
|
}
|
|
3972
|
+
function setGlobalTelemetryInstance(instance) {
|
|
3973
|
+
telemetryInstanceSlot.set(instance);
|
|
3974
|
+
}
|
|
3322
3975
|
var _localTelemetryInstance;
|
|
3323
3976
|
function getTelemetryInstance() {
|
|
3324
3977
|
const global = getGlobalTelemetryInstance();
|
|
@@ -3326,6 +3979,7 @@ function getTelemetryInstance() {
|
|
|
3326
3979
|
return global;
|
|
3327
3980
|
if (!_localTelemetryInstance) {
|
|
3328
3981
|
_localTelemetryInstance = new TelemetryService(new LoggerTelemetryProvider, new NodeContextStorage);
|
|
3982
|
+
setGlobalTelemetryInstance(_localTelemetryInstance);
|
|
3329
3983
|
}
|
|
3330
3984
|
return _localTelemetryInstance;
|
|
3331
3985
|
}
|
|
@@ -3338,6 +3992,14 @@ var telemetry = new Proxy({}, {
|
|
|
3338
3992
|
});
|
|
3339
3993
|
|
|
3340
3994
|
// ../common/src/formatter.ts
|
|
3995
|
+
var ANSI_STYLES = {
|
|
3996
|
+
red: "\x1B[31m",
|
|
3997
|
+
dim: "\x1B[2m"
|
|
3998
|
+
};
|
|
3999
|
+
var ANSI_RESET = "\x1B[0m";
|
|
4000
|
+
function styleLine(line, style) {
|
|
4001
|
+
return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
|
|
4002
|
+
}
|
|
3341
4003
|
var CLI_ERROR_CODES = [
|
|
3342
4004
|
"invalid_argument",
|
|
3343
4005
|
"authentication_required",
|
|
@@ -3376,22 +4038,6 @@ var EXIT_CODES = {
|
|
|
3376
4038
|
ValidationError: 3,
|
|
3377
4039
|
TimeoutError: 4
|
|
3378
4040
|
};
|
|
3379
|
-
class SuccessOutput {
|
|
3380
|
-
Result = RESULTS.Success;
|
|
3381
|
-
Code;
|
|
3382
|
-
Data;
|
|
3383
|
-
Pagination;
|
|
3384
|
-
Instructions;
|
|
3385
|
-
Log;
|
|
3386
|
-
constructor(code, data) {
|
|
3387
|
-
this.Code = code;
|
|
3388
|
-
this.Data = data;
|
|
3389
|
-
const logPath = getLogFilePath();
|
|
3390
|
-
if (logPath) {
|
|
3391
|
-
this.Log = logPath;
|
|
3392
|
-
}
|
|
3393
|
-
}
|
|
3394
|
-
}
|
|
3395
4041
|
function escapeNonAscii(jsonText) {
|
|
3396
4042
|
return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
|
|
3397
4043
|
const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
|
|
@@ -3456,19 +4102,45 @@ function toPascalCaseKey(key) {
|
|
|
3456
4102
|
const lowerCamelKey = toLowerCamelCaseKey(key);
|
|
3457
4103
|
return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
|
|
3458
4104
|
}
|
|
3459
|
-
function
|
|
4105
|
+
function collectVerbatimRefs(value, into) {
|
|
4106
|
+
if (typeof value !== "object" || value === null)
|
|
4107
|
+
return;
|
|
4108
|
+
if (into.has(value))
|
|
4109
|
+
return;
|
|
4110
|
+
into.add(value);
|
|
4111
|
+
for (const nested of Array.isArray(value) ? value : Object.values(value)) {
|
|
4112
|
+
collectVerbatimRefs(nested, into);
|
|
4113
|
+
}
|
|
4114
|
+
}
|
|
4115
|
+
function toPascalCaseData(value, verbatimKeys, subtrees) {
|
|
4116
|
+
if (subtrees?.mode === "skip" && typeof value === "object" && value !== null && subtrees.refs.has(value)) {
|
|
4117
|
+
return value;
|
|
4118
|
+
}
|
|
3460
4119
|
if (Array.isArray(value))
|
|
3461
|
-
return value.map(toPascalCaseData);
|
|
4120
|
+
return value.map((entry) => toPascalCaseData(entry, verbatimKeys, subtrees));
|
|
3462
4121
|
if (!isPlainRecord(value))
|
|
3463
4122
|
return value;
|
|
3464
4123
|
const result = {};
|
|
3465
4124
|
for (const [key, nestedValue] of Object.entries(value)) {
|
|
3466
|
-
|
|
4125
|
+
const pascalKey = toPascalCaseKey(key);
|
|
4126
|
+
if (verbatimKeys?.has(pascalKey)) {
|
|
4127
|
+
result[pascalKey] = nestedValue;
|
|
4128
|
+
if (subtrees?.mode === "collect") {
|
|
4129
|
+
collectVerbatimRefs(nestedValue, subtrees.refs);
|
|
4130
|
+
}
|
|
4131
|
+
continue;
|
|
4132
|
+
}
|
|
4133
|
+
result[pascalKey] = toPascalCaseData(nestedValue, verbatimKeys, subtrees);
|
|
3467
4134
|
}
|
|
3468
4135
|
return result;
|
|
3469
4136
|
}
|
|
3470
|
-
function normalizeDataKeys(data) {
|
|
3471
|
-
return toPascalCaseData(data);
|
|
4137
|
+
function normalizeDataKeys(data, verbatimKeys, subtrees) {
|
|
4138
|
+
return toPascalCaseData(data, verbatimKeys, subtrees);
|
|
4139
|
+
}
|
|
4140
|
+
function toVerbatimKeySet(preserve) {
|
|
4141
|
+
if (!Array.isArray(preserve))
|
|
4142
|
+
return;
|
|
4143
|
+
return new Set(preserve.map(toPascalCaseKey));
|
|
3472
4144
|
}
|
|
3473
4145
|
function normalizeOutputKeys(data) {
|
|
3474
4146
|
const result = {};
|
|
@@ -3478,7 +4150,7 @@ function normalizeOutputKeys(data) {
|
|
|
3478
4150
|
}
|
|
3479
4151
|
return result;
|
|
3480
4152
|
}
|
|
3481
|
-
function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
4153
|
+
function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowStyle) {
|
|
3482
4154
|
if (!data) {
|
|
3483
4155
|
logFn("Empty response object. No data to display.");
|
|
3484
4156
|
return;
|
|
@@ -3513,7 +4185,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
3513
4185
|
if (hasData && !(rows !== null && rows.length === 0)) {
|
|
3514
4186
|
const logValue = data.Log;
|
|
3515
4187
|
if (rows !== null) {
|
|
3516
|
-
printResizableTable(rows, logFn, logValue);
|
|
4188
|
+
printResizableTable(rows, logFn, logValue, undefined, tableRowStyle);
|
|
3517
4189
|
} else {
|
|
3518
4190
|
printVerticalTable(data.Data, logFn, logValue);
|
|
3519
4191
|
}
|
|
@@ -3524,10 +4196,11 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
3524
4196
|
}
|
|
3525
4197
|
}
|
|
3526
4198
|
}
|
|
3527
|
-
function logOutput(data, format = "json") {
|
|
4199
|
+
function logOutput(data, format = "json", tableRowStyle) {
|
|
3528
4200
|
const sink = getOutputSink();
|
|
4201
|
+
const styleFn = sink.capabilities.isInteractive && sink.capabilities.supportsColor ? tableRowStyle : undefined;
|
|
3529
4202
|
printOutput(data, format, (msg) => sink.writeOut(`${msg}
|
|
3530
|
-
`), needsAsciiSafeJson(sink));
|
|
4203
|
+
`), needsAsciiSafeJson(sink), styleFn);
|
|
3531
4204
|
}
|
|
3532
4205
|
function cellToString(val) {
|
|
3533
4206
|
return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
|
|
@@ -3541,7 +4214,7 @@ function wrapText(text, width) {
|
|
|
3541
4214
|
}
|
|
3542
4215
|
return lines;
|
|
3543
4216
|
}
|
|
3544
|
-
function printTable(data, logFn, externalLogValue) {
|
|
4217
|
+
function printTable(data, logFn, externalLogValue, tableRowStyle) {
|
|
3545
4218
|
if (data.length === 0)
|
|
3546
4219
|
return;
|
|
3547
4220
|
const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
@@ -3551,7 +4224,7 @@ function printTable(data, logFn, externalLogValue) {
|
|
|
3551
4224
|
logFn(keys.map((_, i) => "-".repeat(maxWidths[i])).join("-|-"));
|
|
3552
4225
|
data.forEach((item) => {
|
|
3553
4226
|
const row = keys.map((key, i) => cellToString(item[key]).padEnd(maxWidths[i])).join(" | ");
|
|
3554
|
-
logFn(row);
|
|
4227
|
+
logFn(styleLine(row, tableRowStyle?.(item)));
|
|
3555
4228
|
});
|
|
3556
4229
|
if (externalLogValue) {
|
|
3557
4230
|
logFn("");
|
|
@@ -3594,14 +4267,14 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
|
3594
4267
|
logFn(`Log: ${externalLogValue}`);
|
|
3595
4268
|
}
|
|
3596
4269
|
}
|
|
3597
|
-
function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth) {
|
|
4270
|
+
function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
|
|
3598
4271
|
if (data.length === 0)
|
|
3599
4272
|
return;
|
|
3600
4273
|
const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
3601
4274
|
if (keys.length === 0)
|
|
3602
4275
|
return;
|
|
3603
4276
|
if (!process.stdout.isTTY) {
|
|
3604
|
-
printTable(data, logFn, externalLogValue);
|
|
4277
|
+
printTable(data, logFn, externalLogValue, tableRowStyle);
|
|
3605
4278
|
return;
|
|
3606
4279
|
}
|
|
3607
4280
|
const naturalWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
|
|
@@ -3609,7 +4282,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
3609
4282
|
const totalWidth = naturalWidths.reduce((a, b) => a + b, 0) + separatorTotal;
|
|
3610
4283
|
const termWidth = availableWidth ?? (process.stdout.columns || 120);
|
|
3611
4284
|
if (totalWidth <= termWidth) {
|
|
3612
|
-
printTable(data, logFn, externalLogValue);
|
|
4285
|
+
printTable(data, logFn, externalLogValue, tableRowStyle);
|
|
3613
4286
|
return;
|
|
3614
4287
|
}
|
|
3615
4288
|
const overflow = totalWidth - termWidth;
|
|
@@ -3655,6 +4328,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
3655
4328
|
logFn(header);
|
|
3656
4329
|
logFn(keys.map((_, i) => "-".repeat(finalWidths[i])).join("-|-"));
|
|
3657
4330
|
data.forEach((item) => {
|
|
4331
|
+
const style = tableRowStyle?.(item);
|
|
3658
4332
|
const cellLines = keys.map((key, i) => wrapText(cellToString(item[key]), finalWidths[i]));
|
|
3659
4333
|
const lineCount = Math.max(...cellLines.map((l) => l.length));
|
|
3660
4334
|
for (let line = 0;line < lineCount; line++) {
|
|
@@ -3662,7 +4336,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
3662
4336
|
const val = line < cellLines[i].length ? cellLines[i][line] : "";
|
|
3663
4337
|
return val.padEnd(finalWidths[i]);
|
|
3664
4338
|
}).join(" | ");
|
|
3665
|
-
logFn(row);
|
|
4339
|
+
logFn(styleLine(row, style));
|
|
3666
4340
|
}
|
|
3667
4341
|
});
|
|
3668
4342
|
if (externalLogValue) {
|
|
@@ -3806,30 +4480,36 @@ var OutputFormatter;
|
|
|
3806
4480
|
((OutputFormatter) => {
|
|
3807
4481
|
function success(data, options) {
|
|
3808
4482
|
data.Log ??= getLogFilePath() || undefined;
|
|
3809
|
-
const normalize =
|
|
4483
|
+
const normalize = options?.preserveDataKeys !== true;
|
|
4484
|
+
const verbatim = toVerbatimKeySet(options?.preserveDataKeys);
|
|
4485
|
+
const subtrees = verbatim && {
|
|
4486
|
+
refs: new Set,
|
|
4487
|
+
mode: "collect"
|
|
4488
|
+
};
|
|
3810
4489
|
if (normalize) {
|
|
3811
|
-
data.Data = normalizeDataKeys(data.Data);
|
|
4490
|
+
data.Data = normalizeDataKeys(data.Data, verbatim, subtrees);
|
|
3812
4491
|
}
|
|
3813
4492
|
const filter = getOutputFilter();
|
|
3814
4493
|
if (filter) {
|
|
3815
4494
|
const filtered = applyFilter(data.Data, filter);
|
|
3816
|
-
data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
|
|
4495
|
+
data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
|
|
3817
4496
|
}
|
|
3818
|
-
logOutput(normalizeOutputKeys(data), getOutputFormat());
|
|
4497
|
+
logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
|
|
3819
4498
|
}
|
|
3820
4499
|
OutputFormatter.success = success;
|
|
3821
4500
|
function error(data) {
|
|
3822
4501
|
data.Log ??= getLogFilePath() || undefined;
|
|
3823
4502
|
data.ErrorCode ??= defaultErrorCodeForFailure(data);
|
|
3824
4503
|
data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
|
|
3825
|
-
|
|
4504
|
+
const exitCode = EXIT_CODES[data.Result] ?? 1;
|
|
4505
|
+
setExitCode(exitCode);
|
|
3826
4506
|
recordCommandFailureTelemetry({
|
|
3827
4507
|
result: data.Result,
|
|
3828
4508
|
errorCode: data.ErrorCode,
|
|
3829
4509
|
retry: data.Retry,
|
|
3830
4510
|
message: data.Message,
|
|
3831
4511
|
context: data.Context,
|
|
3832
|
-
exitCode
|
|
4512
|
+
exitCode,
|
|
3833
4513
|
errorClass: data.TelemetryErrorClass,
|
|
3834
4514
|
terminalOutcome: data.TelemetryTerminalOutcome,
|
|
3835
4515
|
terminalSignal: data.TelemetryTerminalSignal
|
|
@@ -3905,6 +4585,39 @@ var OutputFormatter;
|
|
|
3905
4585
|
}
|
|
3906
4586
|
OutputFormatter.formatToString = formatToString;
|
|
3907
4587
|
})(OutputFormatter ||= {});
|
|
4588
|
+
// ../../node_modules/commander/esm.mjs
|
|
4589
|
+
var import__ = __toESM(require_commander(), 1);
|
|
4590
|
+
var {
|
|
4591
|
+
program,
|
|
4592
|
+
createCommand,
|
|
4593
|
+
createArgument,
|
|
4594
|
+
createOption,
|
|
4595
|
+
CommanderError,
|
|
4596
|
+
InvalidArgumentError,
|
|
4597
|
+
InvalidOptionArgumentError,
|
|
4598
|
+
Command,
|
|
4599
|
+
Argument,
|
|
4600
|
+
Option,
|
|
4601
|
+
Help
|
|
4602
|
+
} = import__.default;
|
|
4603
|
+
|
|
4604
|
+
// ../common/src/command-examples.ts
|
|
4605
|
+
var examplesByCommand = new WeakMap;
|
|
4606
|
+
Command.prototype.examples = function(examples) {
|
|
4607
|
+
examplesByCommand.set(this, examples);
|
|
4608
|
+
return this;
|
|
4609
|
+
};
|
|
4610
|
+
// ../common/src/preview.ts
|
|
4611
|
+
var previewSlot = singleton("PreviewBuild");
|
|
4612
|
+
function isPreviewBuild() {
|
|
4613
|
+
return previewSlot.get(false) ?? false;
|
|
4614
|
+
}
|
|
4615
|
+
Command.prototype.previewCommand = function(nameAndArgs, opts) {
|
|
4616
|
+
if (isPreviewBuild()) {
|
|
4617
|
+
return this.command(nameAndArgs, opts);
|
|
4618
|
+
}
|
|
4619
|
+
return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
|
|
4620
|
+
};
|
|
3908
4621
|
|
|
3909
4622
|
// ../common/src/telemetry/command-attribution.ts
|
|
3910
4623
|
var LEGACY_SKILL_NAMESPACE = "uipath:";
|
|
@@ -4059,6 +4772,57 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
|
|
|
4059
4772
|
};
|
|
4060
4773
|
}
|
|
4061
4774
|
|
|
4775
|
+
// ../common/src/telemetry/command-name.ts
|
|
4776
|
+
var TELEMETRY_COMMAND_ROOT = "uip";
|
|
4777
|
+
function commandTelemetryName(parts) {
|
|
4778
|
+
const tokens = [];
|
|
4779
|
+
for (const part of parts) {
|
|
4780
|
+
const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== TELEMETRY_COMMAND_ROOT);
|
|
4781
|
+
if (pieces.every(isCommandToken)) {
|
|
4782
|
+
tokens.push(...pieces);
|
|
4783
|
+
continue;
|
|
4784
|
+
}
|
|
4785
|
+
tokens.push(UNKNOWN_TOKEN);
|
|
4786
|
+
}
|
|
4787
|
+
return [TELEMETRY_COMMAND_ROOT, ...tokens].join(".");
|
|
4788
|
+
}
|
|
4789
|
+
var COMMAND_TOKEN_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
4790
|
+
var MAX_COMMAND_TOKEN_LENGTH = 32;
|
|
4791
|
+
var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
4792
|
+
function isCommandToken(token) {
|
|
4793
|
+
return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token) && !/^\d+$/.test(token);
|
|
4794
|
+
}
|
|
4795
|
+
var UNKNOWN_TOKEN = "<unknown>";
|
|
4796
|
+
|
|
4797
|
+
// ../common/src/telemetry/invocation-request.ts
|
|
4798
|
+
var requestContextSlot = singleton("TelemetryInvocationRequestContext");
|
|
4799
|
+
function activeContext() {
|
|
4800
|
+
return telemetry.getActiveContext?.();
|
|
4801
|
+
}
|
|
4802
|
+
function runWithInvocationRequest(fn) {
|
|
4803
|
+
const context = telemetry.createRequestContext();
|
|
4804
|
+
context.startedAt = invocationStartedAt();
|
|
4805
|
+
requestContextSlot.set(context);
|
|
4806
|
+
return telemetry.runWithContext(context, fn);
|
|
4807
|
+
}
|
|
4808
|
+
function ensureInvocationRequestScope(fn) {
|
|
4809
|
+
if (activeContext() !== undefined) {
|
|
4810
|
+
return fn();
|
|
4811
|
+
}
|
|
4812
|
+
const kept = requestContextSlot.get();
|
|
4813
|
+
return kept === undefined ? runWithInvocationRequest(fn) : telemetry.runWithContext(kept, fn);
|
|
4814
|
+
}
|
|
4815
|
+
function getInvocationRequestContext() {
|
|
4816
|
+
return activeContext() ?? requestContextSlot.get();
|
|
4817
|
+
}
|
|
4818
|
+
function emitInvocationRequest(name, success, properties) {
|
|
4819
|
+
const context = getInvocationRequestContext();
|
|
4820
|
+
telemetry.trackRequestResult(name, invocationElapsedMs(), success, properties, context);
|
|
4821
|
+
if (context !== undefined && requestContextSlot.get() === context) {
|
|
4822
|
+
requestContextSlot.clear();
|
|
4823
|
+
}
|
|
4824
|
+
}
|
|
4825
|
+
|
|
4062
4826
|
// ../common/src/trackedAction.ts
|
|
4063
4827
|
var pollSignalSlot = singleton("PollSignal");
|
|
4064
4828
|
var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
|
|
@@ -4066,28 +4830,74 @@ var retryHintValues = new Set(RETRY_HINTS);
|
|
|
4066
4830
|
var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
|
|
4067
4831
|
var processContext = {
|
|
4068
4832
|
exit: (code) => {
|
|
4069
|
-
|
|
4833
|
+
recordExitCode(code);
|
|
4834
|
+
setExitCode(code);
|
|
4070
4835
|
},
|
|
4071
4836
|
get pollSignal() {
|
|
4072
4837
|
return pollSignalSlot.get();
|
|
4073
4838
|
}
|
|
4074
4839
|
};
|
|
4840
|
+
var TELEMETRY_ARG_VALUE_WITHHELD = "<provided>";
|
|
4841
|
+
var TELEMETRY_ARG_VALUE_DEFAULTED = "<default>";
|
|
4842
|
+
function recordableArgValue(value, choices) {
|
|
4843
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
4844
|
+
return value;
|
|
4845
|
+
}
|
|
4846
|
+
if (choices && choices.length > 0) {
|
|
4847
|
+
if (typeof value === "string" && choices.includes(value)) {
|
|
4848
|
+
return value;
|
|
4849
|
+
}
|
|
4850
|
+
if (Array.isArray(value) && value.length > 0 && value.every((entry) => typeof entry === "string" && choices.includes(entry))) {
|
|
4851
|
+
return value.join(",");
|
|
4852
|
+
}
|
|
4853
|
+
}
|
|
4854
|
+
return TELEMETRY_ARG_VALUE_WITHHELD;
|
|
4855
|
+
}
|
|
4075
4856
|
function extractCommandParams(cmd) {
|
|
4076
4857
|
const params = {};
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4858
|
+
forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
|
|
4859
|
+
const recordable = recordableArgValue(value, choices);
|
|
4860
|
+
params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
|
|
4861
|
+
});
|
|
4862
|
+
return params;
|
|
4863
|
+
}
|
|
4864
|
+
function isDefaultedOption(cmd, name) {
|
|
4865
|
+
const source = cmd.getOptionValueSource?.(name);
|
|
4866
|
+
return source === "default" || source === "implied";
|
|
4867
|
+
}
|
|
4868
|
+
function isDefaultedPositional(cmd, index) {
|
|
4869
|
+
return index >= (cmd.args?.length ?? 0);
|
|
4870
|
+
}
|
|
4871
|
+
function forEachSuppliedArgument(cmd, visit) {
|
|
4082
4872
|
const registered = cmd.registeredArguments ?? [];
|
|
4083
4873
|
const processed = cmd.processedArgs ?? [];
|
|
4084
4874
|
for (let i = 0;i < registered.length; i++) {
|
|
4085
|
-
|
|
4875
|
+
const name = registered[i].name();
|
|
4876
|
+
if (name && processed[i] !== undefined) {
|
|
4877
|
+
visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
|
|
4878
|
+
}
|
|
4879
|
+
}
|
|
4880
|
+
const choicesByAttribute = new Map;
|
|
4881
|
+
for (const option of cmd.options) {
|
|
4882
|
+
choicesByAttribute.set(option.attributeName(), option.argChoices);
|
|
4086
4883
|
}
|
|
4087
4884
|
for (const [key, value] of Object.entries(cmd.opts())) {
|
|
4088
|
-
|
|
4885
|
+
if (key && value !== undefined) {
|
|
4886
|
+
visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
|
|
4887
|
+
}
|
|
4089
4888
|
}
|
|
4090
|
-
|
|
4889
|
+
}
|
|
4890
|
+
function withheldArgumentValues(cmd) {
|
|
4891
|
+
const values = [];
|
|
4892
|
+
forEachSuppliedArgument(cmd, (_name, value, choices, defaulted) => {
|
|
4893
|
+
if (defaulted) {
|
|
4894
|
+
return;
|
|
4895
|
+
}
|
|
4896
|
+
if (recordableArgValue(value, choices) === TELEMETRY_ARG_VALUE_WITHHELD) {
|
|
4897
|
+
values.push(value);
|
|
4898
|
+
}
|
|
4899
|
+
});
|
|
4900
|
+
return values;
|
|
4091
4901
|
}
|
|
4092
4902
|
function deriveCommandPath(cmd) {
|
|
4093
4903
|
const parts = [];
|
|
@@ -4102,7 +4912,7 @@ function deriveCommandPath(cmd) {
|
|
|
4102
4912
|
if (parts.length > 1) {
|
|
4103
4913
|
parts.shift();
|
|
4104
4914
|
}
|
|
4105
|
-
return
|
|
4915
|
+
return commandTelemetryName(parts);
|
|
4106
4916
|
}
|
|
4107
4917
|
function isCliErrorCode(value) {
|
|
4108
4918
|
return typeof value === "string" && cliErrorCodeValues.has(value);
|
|
@@ -4142,68 +4952,77 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
4142
4952
|
});
|
|
4143
4953
|
const telemetryName = deriveCommandPath(command);
|
|
4144
4954
|
const props = typeof properties === "function" ? properties(...args) : properties;
|
|
4145
|
-
|
|
4146
|
-
const
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4955
|
+
markCommandStart();
|
|
4956
|
+
const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
|
|
4957
|
+
try {
|
|
4958
|
+
const startTime = performance.now();
|
|
4959
|
+
let errorMessage;
|
|
4960
|
+
let fallbackExitCode = EXIT_CODES.Success;
|
|
4961
|
+
clearRecordedCommandFailureTelemetry();
|
|
4962
|
+
const [error] = await catchError(ensureInvocationRequestScope(() => {
|
|
4963
|
+
const violation = implicitLimitViolation(command);
|
|
4964
|
+
if (violation) {
|
|
4965
|
+
return Promise.reject(violation);
|
|
4966
|
+
}
|
|
4967
|
+
return fn(...args);
|
|
4968
|
+
}));
|
|
4969
|
+
if (error) {
|
|
4970
|
+
errorMessage = error instanceof Error ? error.message : String(error);
|
|
4971
|
+
logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
|
|
4972
|
+
const typed = error;
|
|
4973
|
+
const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
|
|
4974
|
+
const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
|
|
4975
|
+
const finalResult = customResult ?? RESULTS.Failure;
|
|
4976
|
+
const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
|
|
4977
|
+
const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
|
|
4978
|
+
const typedRetry = typed.retry ?? typed.Retry;
|
|
4979
|
+
const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
|
|
4980
|
+
const typedContext = typed.context ?? typed.Context;
|
|
4981
|
+
const customContext = isErrorContext(typedContext) ? typedContext : undefined;
|
|
4982
|
+
const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
|
|
4983
|
+
fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
|
|
4984
|
+
OutputFormatter.error({
|
|
4985
|
+
Result: finalResult,
|
|
4986
|
+
...customErrorCode ? { ErrorCode: customErrorCode } : {},
|
|
4987
|
+
Message: errorMessage,
|
|
4988
|
+
Instructions: customInstructions ?? commandHelpHint(telemetryName),
|
|
4989
|
+
...customRetry ? { Retry: customRetry } : {},
|
|
4990
|
+
...customContext ? { Context: customContext } : {}
|
|
4991
|
+
});
|
|
4992
|
+
context.exit(fallbackExitCode);
|
|
4993
|
+
}
|
|
4994
|
+
const durationMs = performance.now() - startTime;
|
|
4995
|
+
recordCommandDuration(durationMs);
|
|
4996
|
+
const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
|
|
4997
|
+
const recordedFailure = takeRecordedCommandFailureTelemetry();
|
|
4998
|
+
const success = !error && exitCode === 0;
|
|
4999
|
+
const terminalTelemetry = buildCommandTerminalTelemetryProperties({
|
|
5000
|
+
error,
|
|
5001
|
+
exitCode,
|
|
5002
|
+
recordedFailure,
|
|
5003
|
+
pollSignal: context.pollSignal
|
|
4179
5004
|
});
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
}
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
|
|
4202
|
-
command: "true",
|
|
4203
|
-
...terminalTelemetry,
|
|
4204
|
-
...errorMessage ? { errorMessage } : {}
|
|
4205
|
-
});
|
|
4206
|
-
telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
|
|
5005
|
+
if (terminalTelemetry.error_class === "internal" && error) {
|
|
5006
|
+
telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { command_name: telemetryName }, getInvocationRequestContext());
|
|
5007
|
+
}
|
|
5008
|
+
const commandParams = extractCommandParams(command);
|
|
5009
|
+
if (props) {
|
|
5010
|
+
for (const key of Object.keys(props)) {
|
|
5011
|
+
delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
|
|
5012
|
+
}
|
|
5013
|
+
}
|
|
5014
|
+
const baseProperties = redactProperties({
|
|
5015
|
+
...commandParams,
|
|
5016
|
+
...props,
|
|
5017
|
+
...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
|
|
5018
|
+
command: "true",
|
|
5019
|
+
...terminalTelemetry,
|
|
5020
|
+
...errorMessage ? { errorMessage } : {}
|
|
5021
|
+
});
|
|
5022
|
+
emitInvocationRequest(telemetryName, success, baseProperties);
|
|
5023
|
+
} finally {
|
|
5024
|
+
releaseSuppliedArgumentValues(supplied);
|
|
5025
|
+
}
|
|
4207
5026
|
});
|
|
4208
5027
|
};
|
|
4209
5028
|
// ../common/src/completer.ts
|
|
@@ -4212,8 +5031,206 @@ var COMPLETER_SYMBOL = Symbol.for("@uipath/common/completer");
|
|
|
4212
5031
|
var guardInstalledSlot = singleton("ConsoleGuardInstalled");
|
|
4213
5032
|
var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
|
|
4214
5033
|
// ../common/src/constants.ts
|
|
4215
|
-
var
|
|
5034
|
+
var UIPATH_HOME_DIR = ".uipath";
|
|
4216
5035
|
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
5036
|
+
// ../common/src/entity-name-rules.ts
|
|
5037
|
+
var RESERVED_SQL_KEYWORDS_LOWER = new Set(["group", "order"]);
|
|
5038
|
+
var RESERVED_FIELD_NAMES_LOWER = new Set([
|
|
5039
|
+
"id",
|
|
5040
|
+
"createdby",
|
|
5041
|
+
"createtime",
|
|
5042
|
+
"updatedby",
|
|
5043
|
+
"updatetime",
|
|
5044
|
+
"recordowner",
|
|
5045
|
+
"version"
|
|
5046
|
+
]);
|
|
5047
|
+
var RESERVED_KEYWORDS_LOWER = new Set([
|
|
5048
|
+
"abstract",
|
|
5049
|
+
"as",
|
|
5050
|
+
"base",
|
|
5051
|
+
"bool",
|
|
5052
|
+
"break",
|
|
5053
|
+
"byte",
|
|
5054
|
+
"case",
|
|
5055
|
+
"catch",
|
|
5056
|
+
"char",
|
|
5057
|
+
"checked",
|
|
5058
|
+
"class",
|
|
5059
|
+
"const",
|
|
5060
|
+
"continue",
|
|
5061
|
+
"decimal",
|
|
5062
|
+
"default",
|
|
5063
|
+
"delegate",
|
|
5064
|
+
"do",
|
|
5065
|
+
"double",
|
|
5066
|
+
"else",
|
|
5067
|
+
"enum",
|
|
5068
|
+
"event",
|
|
5069
|
+
"explicit",
|
|
5070
|
+
"extern",
|
|
5071
|
+
"false",
|
|
5072
|
+
"finally",
|
|
5073
|
+
"fixed",
|
|
5074
|
+
"float",
|
|
5075
|
+
"for",
|
|
5076
|
+
"foreach",
|
|
5077
|
+
"goto",
|
|
5078
|
+
"if",
|
|
5079
|
+
"implicit",
|
|
5080
|
+
"in",
|
|
5081
|
+
"int",
|
|
5082
|
+
"interface",
|
|
5083
|
+
"internal",
|
|
5084
|
+
"is",
|
|
5085
|
+
"lock",
|
|
5086
|
+
"long",
|
|
5087
|
+
"namespace",
|
|
5088
|
+
"new",
|
|
5089
|
+
"null",
|
|
5090
|
+
"object",
|
|
5091
|
+
"operator",
|
|
5092
|
+
"out",
|
|
5093
|
+
"override",
|
|
5094
|
+
"params",
|
|
5095
|
+
"private",
|
|
5096
|
+
"protected",
|
|
5097
|
+
"public",
|
|
5098
|
+
"readonly",
|
|
5099
|
+
"ref",
|
|
5100
|
+
"return",
|
|
5101
|
+
"sbyte",
|
|
5102
|
+
"sealed",
|
|
5103
|
+
"short",
|
|
5104
|
+
"sizeof",
|
|
5105
|
+
"stackalloc",
|
|
5106
|
+
"static",
|
|
5107
|
+
"string",
|
|
5108
|
+
"struct",
|
|
5109
|
+
"switch",
|
|
5110
|
+
"this",
|
|
5111
|
+
"throw",
|
|
5112
|
+
"true",
|
|
5113
|
+
"try",
|
|
5114
|
+
"typeof",
|
|
5115
|
+
"uint",
|
|
5116
|
+
"ulong",
|
|
5117
|
+
"unchecked",
|
|
5118
|
+
"unsafe",
|
|
5119
|
+
"ushort",
|
|
5120
|
+
"using",
|
|
5121
|
+
"virtual",
|
|
5122
|
+
"void",
|
|
5123
|
+
"volatile",
|
|
5124
|
+
"while",
|
|
5125
|
+
"addhandler",
|
|
5126
|
+
"addressof",
|
|
5127
|
+
"alias",
|
|
5128
|
+
"and",
|
|
5129
|
+
"andalso",
|
|
5130
|
+
"boolean",
|
|
5131
|
+
"byref",
|
|
5132
|
+
"byval",
|
|
5133
|
+
"call",
|
|
5134
|
+
"cbool",
|
|
5135
|
+
"cbyte",
|
|
5136
|
+
"cchar",
|
|
5137
|
+
"cdate",
|
|
5138
|
+
"cdbl",
|
|
5139
|
+
"cdec",
|
|
5140
|
+
"cint",
|
|
5141
|
+
"clng",
|
|
5142
|
+
"cobj",
|
|
5143
|
+
"csbyte",
|
|
5144
|
+
"cshort",
|
|
5145
|
+
"csng",
|
|
5146
|
+
"cstr",
|
|
5147
|
+
"ctype",
|
|
5148
|
+
"cuint",
|
|
5149
|
+
"culng",
|
|
5150
|
+
"cushort",
|
|
5151
|
+
"date",
|
|
5152
|
+
"declare",
|
|
5153
|
+
"dim",
|
|
5154
|
+
"directcast",
|
|
5155
|
+
"each",
|
|
5156
|
+
"elseif",
|
|
5157
|
+
"end",
|
|
5158
|
+
"endif",
|
|
5159
|
+
"erase",
|
|
5160
|
+
"error",
|
|
5161
|
+
"exit",
|
|
5162
|
+
"friend",
|
|
5163
|
+
"function",
|
|
5164
|
+
"get",
|
|
5165
|
+
"gettype",
|
|
5166
|
+
"getxmlnamespace",
|
|
5167
|
+
"global",
|
|
5168
|
+
"gosub",
|
|
5169
|
+
"goto",
|
|
5170
|
+
"handles",
|
|
5171
|
+
"implements",
|
|
5172
|
+
"imports",
|
|
5173
|
+
"inherits",
|
|
5174
|
+
"integer",
|
|
5175
|
+
"isnot",
|
|
5176
|
+
"let",
|
|
5177
|
+
"lib",
|
|
5178
|
+
"like",
|
|
5179
|
+
"loop",
|
|
5180
|
+
"me",
|
|
5181
|
+
"mod",
|
|
5182
|
+
"module",
|
|
5183
|
+
"mustinherit",
|
|
5184
|
+
"mustoverride",
|
|
5185
|
+
"mybase",
|
|
5186
|
+
"myclass",
|
|
5187
|
+
"narrowing",
|
|
5188
|
+
"next",
|
|
5189
|
+
"not",
|
|
5190
|
+
"nothing",
|
|
5191
|
+
"notinheritable",
|
|
5192
|
+
"notoverridable",
|
|
5193
|
+
"of",
|
|
5194
|
+
"on",
|
|
5195
|
+
"option",
|
|
5196
|
+
"optional",
|
|
5197
|
+
"or",
|
|
5198
|
+
"orelse",
|
|
5199
|
+
"overloads",
|
|
5200
|
+
"overridable",
|
|
5201
|
+
"overrides",
|
|
5202
|
+
"paramarray",
|
|
5203
|
+
"partial",
|
|
5204
|
+
"property",
|
|
5205
|
+
"raiseevent",
|
|
5206
|
+
"redim",
|
|
5207
|
+
"rem",
|
|
5208
|
+
"removehandler",
|
|
5209
|
+
"resume",
|
|
5210
|
+
"select",
|
|
5211
|
+
"set",
|
|
5212
|
+
"shadows",
|
|
5213
|
+
"shared",
|
|
5214
|
+
"single",
|
|
5215
|
+
"step",
|
|
5216
|
+
"stop",
|
|
5217
|
+
"structure",
|
|
5218
|
+
"sub",
|
|
5219
|
+
"synclock",
|
|
5220
|
+
"then",
|
|
5221
|
+
"to",
|
|
5222
|
+
"trycast",
|
|
5223
|
+
"uinteger",
|
|
5224
|
+
"ushort",
|
|
5225
|
+
"variant",
|
|
5226
|
+
"wend",
|
|
5227
|
+
"when",
|
|
5228
|
+
"widening",
|
|
5229
|
+
"with",
|
|
5230
|
+
"withevents",
|
|
5231
|
+
"writeonly",
|
|
5232
|
+
"xor"
|
|
5233
|
+
]);
|
|
4217
5234
|
// ../common/src/host-global-options.ts
|
|
4218
5235
|
var HOST_GLOBAL_OPTIONS_WITH_VALUE = [
|
|
4219
5236
|
"--output",
|
|
@@ -4283,16 +5300,16 @@ var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
|
|
|
4283
5300
|
var factorySlot = singleton("PackagerFactoryProvider");
|
|
4284
5301
|
// ../uipath-python-bridge/src/cache.ts
|
|
4285
5302
|
async function readCache(cacheFile) {
|
|
4286
|
-
const
|
|
4287
|
-
const [existsError, exists] = await
|
|
5303
|
+
const fs2 = getFileSystem();
|
|
5304
|
+
const [existsError, exists] = await catchError(fs2.exists(cacheFile));
|
|
4288
5305
|
if (existsError || !exists)
|
|
4289
5306
|
return null;
|
|
4290
|
-
const [readError, content] = await
|
|
5307
|
+
const [readError, content] = await catchError(fs2.readFile(cacheFile, "utf-8"));
|
|
4291
5308
|
if (readError) {
|
|
4292
5309
|
logger.warn(`Failed to load cache: ${readError}`);
|
|
4293
5310
|
return null;
|
|
4294
5311
|
}
|
|
4295
|
-
const [parseError, cache] =
|
|
5312
|
+
const [parseError, cache] = catchError(() => JSON.parse(content));
|
|
4296
5313
|
if (parseError) {
|
|
4297
5314
|
logger.warn(`Failed to parse cache: ${parseError}`);
|
|
4298
5315
|
return null;
|
|
@@ -4375,6 +5392,40 @@ function processCommandArgs(args, rules) {
|
|
|
4375
5392
|
// ../uipath-python-bridge/src/execute.ts
|
|
4376
5393
|
import { spawn } from "node:child_process";
|
|
4377
5394
|
|
|
5395
|
+
// ../auth/src/catch-error.ts
|
|
5396
|
+
function isPromiseLike2(value) {
|
|
5397
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
5398
|
+
}
|
|
5399
|
+
function catchError2(fnOrPromise) {
|
|
5400
|
+
if (isPromiseLike2(fnOrPromise)) {
|
|
5401
|
+
return settlePromiseLike2(fnOrPromise);
|
|
5402
|
+
}
|
|
5403
|
+
try {
|
|
5404
|
+
const result = fnOrPromise();
|
|
5405
|
+
if (isPromiseLike2(result)) {
|
|
5406
|
+
return settlePromiseLike2(result);
|
|
5407
|
+
}
|
|
5408
|
+
return [undefined, result];
|
|
5409
|
+
} catch (error) {
|
|
5410
|
+
return [
|
|
5411
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
5412
|
+
undefined
|
|
5413
|
+
];
|
|
5414
|
+
}
|
|
5415
|
+
}
|
|
5416
|
+
function settlePromiseLike2(thenable) {
|
|
5417
|
+
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
|
|
5418
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
5419
|
+
undefined
|
|
5420
|
+
]);
|
|
5421
|
+
}
|
|
5422
|
+
|
|
5423
|
+
// ../auth/src/constants.ts
|
|
5424
|
+
var UIPATH_HOME_DIR2 = ".uipath";
|
|
5425
|
+
var AUTH_FILENAME = ".auth";
|
|
5426
|
+
var DEFAULT_BASE_URL = "https://cloud.uipath.com";
|
|
5427
|
+
var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
|
|
5428
|
+
|
|
4378
5429
|
// ../auth/src/config.ts
|
|
4379
5430
|
var DEFAULT_CLIENT_ID = "36dea5b8-e8bb-423d-8e7b-c808df8f1c00";
|
|
4380
5431
|
var AUTH_FILE_CONFIG_KEY = Symbol.for("@uipath/auth/AuthFileConfig");
|
|
@@ -4388,7 +5439,7 @@ class InvalidBaseUrlError extends Error {
|
|
|
4388
5439
|
super(`Invalid base URL: "${url}"
|
|
4389
5440
|
` + `Reason: ${reason}
|
|
4390
5441
|
|
|
4391
|
-
` + `Expected format: an https:// URL, e.g. https://cloud.uipath.com (commercial), https://govcloud.uipath.us (Public Sector), or your Automation Suite host (https://<your-host>).
|
|
5442
|
+
` + `Expected format: an https:// URL (or bare host — https:// is assumed), e.g. https://cloud.uipath.com (commercial), https://govcloud.uipath.us (Public Sector), or your Automation Suite host (https://<your-host>).
|
|
4392
5443
|
` + `You can specify the URL via:
|
|
4393
5444
|
` + ` • --authority flag
|
|
4394
5445
|
` + ` • UIPATH_URL environment variable
|
|
@@ -4409,10 +5460,16 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
|
4409
5460
|
while (baseUrl.endsWith("/")) {
|
|
4410
5461
|
baseUrl = baseUrl.slice(0, -1);
|
|
4411
5462
|
}
|
|
5463
|
+
const hasScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(baseUrl);
|
|
5464
|
+
const [hostCandidate] = baseUrl.split(/[/?#]/, 1);
|
|
5465
|
+
if (!hasScheme && hostCandidate.includes(".")) {
|
|
5466
|
+
baseUrl = `https://${baseUrl}`;
|
|
5467
|
+
}
|
|
4412
5468
|
const resolvedBaseUrl = baseUrl;
|
|
4413
|
-
const [urlError, url] =
|
|
5469
|
+
const [urlError, url] = catchError2(() => new URL(resolvedBaseUrl));
|
|
4414
5470
|
if (urlError) {
|
|
4415
|
-
|
|
5471
|
+
const shapeHint = !hasScheme && !hostCandidate.includes(".") ? ` "${rawUrl.trim()}" is not a URL or a host name. Pass the full authority URL — https://<host>, or just <host> (https:// is assumed).` : ` ${urlError instanceof Error ? urlError.message : "Unknown error"}`;
|
|
5472
|
+
throw new InvalidBaseUrlError(baseUrl, `Malformed URL.${shapeHint}`);
|
|
4416
5473
|
}
|
|
4417
5474
|
if (url.protocol !== "https:") {
|
|
4418
5475
|
throw new InvalidBaseUrlError(baseUrl, `Authority must use https:// scheme, got ${url.protocol}//. OIDC token exchange requires TLS end-to-end.`);
|
|
@@ -4467,6 +5524,11 @@ var resolveConfigAsync = async ({
|
|
|
4467
5524
|
};
|
|
4468
5525
|
};
|
|
4469
5526
|
|
|
5527
|
+
// ../auth/src/utils/platform.ts
|
|
5528
|
+
function isBrowser() {
|
|
5529
|
+
return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
|
|
5530
|
+
}
|
|
5531
|
+
|
|
4470
5532
|
// ../auth/src/authProfile.ts
|
|
4471
5533
|
var DEFAULT_AUTH_PROFILE = "default";
|
|
4472
5534
|
var PROFILE_DIR = "profiles";
|
|
@@ -4478,7 +5540,7 @@ function isAuthProfileStorage(value) {
|
|
|
4478
5540
|
return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
|
|
4479
5541
|
}
|
|
4480
5542
|
function createProfileStorage() {
|
|
4481
|
-
const [error, mod] =
|
|
5543
|
+
const [error, mod] = catchError2(() => __require("node:async_hooks"));
|
|
4482
5544
|
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
4483
5545
|
return {
|
|
4484
5546
|
getStore: () => {
|
|
@@ -4494,9 +5556,9 @@ function getProfileStorage() {
|
|
|
4494
5556
|
if (isAuthProfileStorage(existing)) {
|
|
4495
5557
|
return existing;
|
|
4496
5558
|
}
|
|
4497
|
-
const
|
|
4498
|
-
globalSlot2[AUTH_PROFILE_STORAGE_KEY] =
|
|
4499
|
-
return
|
|
5559
|
+
const storage2 = createProfileStorage();
|
|
5560
|
+
globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage2;
|
|
5561
|
+
return storage2;
|
|
4500
5562
|
}
|
|
4501
5563
|
var profileStorage = getProfileStorage();
|
|
4502
5564
|
|
|
@@ -4527,8 +5589,8 @@ function resolveAuthProfileFilePath(profile) {
|
|
|
4527
5589
|
if (normalized === undefined) {
|
|
4528
5590
|
throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
|
|
4529
5591
|
}
|
|
4530
|
-
const
|
|
4531
|
-
return
|
|
5592
|
+
const fs2 = getFileSystem();
|
|
5593
|
+
return fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR2, PROFILE_DIR, normalized, AUTH_FILENAME);
|
|
4532
5594
|
}
|
|
4533
5595
|
function getActiveAuthProfileFilePath() {
|
|
4534
5596
|
const profile = getActiveAuthProfile();
|
|
@@ -4609,7 +5671,7 @@ var getTokenExpiration = (accessToken) => {
|
|
|
4609
5671
|
// ../auth/src/sessionIdentity.ts
|
|
4610
5672
|
var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
|
|
4611
5673
|
var decodeClaims = (accessToken) => {
|
|
4612
|
-
const [error, claims] =
|
|
5674
|
+
const [error, claims] = catchError2(() => parseJWT(accessToken));
|
|
4613
5675
|
return error ? undefined : claims;
|
|
4614
5676
|
};
|
|
4615
5677
|
var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
|
|
@@ -4693,27 +5755,48 @@ var requireEnv = (name) => {
|
|
|
4693
5755
|
}
|
|
4694
5756
|
return value;
|
|
4695
5757
|
};
|
|
5758
|
+
var OPAQUE_TOKEN_BASE_URL_VAR = "UIPATH_URL";
|
|
5759
|
+
var resolveBaseUrl = (rawUrl, failureContext) => {
|
|
5760
|
+
const [baseUrlError, baseUrl] = catchError2(() => normalizeAndValidateBaseUrl(rawUrl));
|
|
5761
|
+
if (baseUrlError) {
|
|
5762
|
+
if (baseUrlError instanceof InvalidBaseUrlError) {
|
|
5763
|
+
throw baseUrlError;
|
|
5764
|
+
}
|
|
5765
|
+
throw new EnvAuthConfigError(`${failureContext}: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
|
|
5766
|
+
}
|
|
5767
|
+
return baseUrl;
|
|
5768
|
+
};
|
|
4696
5769
|
var readAuthFromEnv = () => {
|
|
4697
5770
|
const accessToken = requireEnv(ENV_AUTH_VARS.token);
|
|
4698
5771
|
const organizationName = requireEnv(ENV_AUTH_VARS.organizationName);
|
|
4699
5772
|
const organizationId = requireEnv(ENV_AUTH_VARS.organizationId);
|
|
4700
5773
|
const tenantName = requireEnv(ENV_AUTH_VARS.tenantName);
|
|
4701
5774
|
const tenantId = requireEnv(ENV_AUTH_VARS.tenantId);
|
|
4702
|
-
const [parseError, payload] =
|
|
5775
|
+
const [parseError, payload] = catchError2(() => parseJWT(accessToken));
|
|
4703
5776
|
if (parseError) {
|
|
4704
|
-
|
|
5777
|
+
const parseErrorMessage = parseError instanceof Error ? parseError.message : String(parseError);
|
|
5778
|
+
const rawUrl = process.env[OPAQUE_TOKEN_BASE_URL_VAR];
|
|
5779
|
+
if (!rawUrl) {
|
|
5780
|
+
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}).`);
|
|
5781
|
+
}
|
|
5782
|
+
const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
|
|
5783
|
+
return {
|
|
5784
|
+
loginStatus: "Logged in",
|
|
5785
|
+
accessToken,
|
|
5786
|
+
baseUrl: baseUrl2,
|
|
5787
|
+
organizationName,
|
|
5788
|
+
organizationId,
|
|
5789
|
+
tenantName,
|
|
5790
|
+
tenantId,
|
|
5791
|
+
source: "env-vars" /* EnvironmentVariables */,
|
|
5792
|
+
hint: "Token is opaque (not a JWT) - expiration and identity cannot be " + "determined locally. Commands will fail with 401 once it is revoked or " + `expired. If this was meant to be a JWT instead of a PAT, note: ${parseErrorMessage}`
|
|
5793
|
+
};
|
|
4705
5794
|
}
|
|
4706
5795
|
const iss = payload.iss;
|
|
4707
5796
|
if (typeof iss !== "string" || iss.length === 0) {
|
|
4708
5797
|
throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} has no 'iss' claim; cannot determine ` + `the UiPath server. Ensure the token was issued by a UiPath identity server.`);
|
|
4709
5798
|
}
|
|
4710
|
-
const
|
|
4711
|
-
if (baseUrlError) {
|
|
4712
|
-
if (baseUrlError instanceof InvalidBaseUrlError) {
|
|
4713
|
-
throw baseUrlError;
|
|
4714
|
-
}
|
|
4715
|
-
throw new EnvAuthConfigError(`Failed to derive server URL from token 'iss' claim: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
|
|
4716
|
-
}
|
|
5799
|
+
const baseUrl = resolveBaseUrl(iss, "Failed to derive server URL from token 'iss' claim");
|
|
4717
5800
|
const expiration = getTokenExpiration(accessToken);
|
|
4718
5801
|
const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
|
|
4719
5802
|
const identity = resolveSessionIdentity(accessToken);
|
|
@@ -4739,8 +5822,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
|
|
|
4739
5822
|
async function refreshTokenFingerprint(refreshToken) {
|
|
4740
5823
|
const bytes = new TextEncoder().encode(refreshToken);
|
|
4741
5824
|
if (globalThis.crypto?.subtle) {
|
|
4742
|
-
const
|
|
4743
|
-
return Array.from(new Uint8Array(
|
|
5825
|
+
const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
5826
|
+
return Array.from(new Uint8Array(digest2), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
|
|
4744
5827
|
}
|
|
4745
5828
|
const { createHash } = await import("node:crypto");
|
|
4746
5829
|
return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
@@ -4749,9 +5832,9 @@ function breakerPathFor(authPath) {
|
|
|
4749
5832
|
return `${authPath}${BREAKER_SUFFIX}`;
|
|
4750
5833
|
}
|
|
4751
5834
|
async function loadRefreshBreaker(authPath) {
|
|
4752
|
-
const
|
|
5835
|
+
const fs2 = getFileSystem();
|
|
4753
5836
|
try {
|
|
4754
|
-
const content = await
|
|
5837
|
+
const content = await fs2.readFile(breakerPathFor(authPath), "utf-8");
|
|
4755
5838
|
if (!content)
|
|
4756
5839
|
return {};
|
|
4757
5840
|
const parsed = JSON.parse(content);
|
|
@@ -4762,20 +5845,20 @@ async function loadRefreshBreaker(authPath) {
|
|
|
4762
5845
|
}
|
|
4763
5846
|
async function saveRefreshBreaker(authPath, state) {
|
|
4764
5847
|
try {
|
|
4765
|
-
const
|
|
4766
|
-
const
|
|
4767
|
-
await
|
|
4768
|
-
const tempPath = `${
|
|
4769
|
-
await
|
|
4770
|
-
await
|
|
5848
|
+
const fs2 = getFileSystem();
|
|
5849
|
+
const path2 = breakerPathFor(authPath);
|
|
5850
|
+
await fs2.mkdir(fs2.path.dirname(path2));
|
|
5851
|
+
const tempPath = `${path2}.tmp`;
|
|
5852
|
+
await fs2.writeFile(tempPath, JSON.stringify(state));
|
|
5853
|
+
await fs2.rename(tempPath, path2);
|
|
4771
5854
|
} catch {}
|
|
4772
5855
|
}
|
|
4773
5856
|
async function clearRefreshBreaker(authPath) {
|
|
4774
|
-
const
|
|
4775
|
-
const
|
|
5857
|
+
const fs2 = getFileSystem();
|
|
5858
|
+
const path2 = breakerPathFor(authPath);
|
|
4776
5859
|
try {
|
|
4777
|
-
if (await
|
|
4778
|
-
await
|
|
5860
|
+
if (await fs2.exists(path2)) {
|
|
5861
|
+
await fs2.rm(path2);
|
|
4779
5862
|
}
|
|
4780
5863
|
} catch {}
|
|
4781
5864
|
}
|
|
@@ -4796,43 +5879,43 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
|
4796
5879
|
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
4797
5880
|
var PIPE_NAME_MAX_LENGTH = 103;
|
|
4798
5881
|
var getRobotIpcPipeNames = async () => {
|
|
4799
|
-
const
|
|
4800
|
-
const username =
|
|
5882
|
+
const fs2 = getFileSystem();
|
|
5883
|
+
const username = fs2.env.getenv("USER") ?? fs2.env.getenv("USERNAME");
|
|
4801
5884
|
if (!username) {
|
|
4802
5885
|
throw new Error("Unable to determine current username");
|
|
4803
5886
|
}
|
|
4804
|
-
const tempPath =
|
|
4805
|
-
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) =>
|
|
5887
|
+
const tempPath = fs2.env.getenv("TMPDIR") ?? "/tmp/";
|
|
5888
|
+
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs2.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
|
|
4806
5889
|
};
|
|
4807
5890
|
var defaultIsRobotIpcAvailable = async () => {
|
|
4808
5891
|
if (process.platform === "win32") {
|
|
4809
5892
|
return true;
|
|
4810
5893
|
}
|
|
4811
|
-
const [pipeNamesError, pipeNames] = await
|
|
5894
|
+
const [pipeNamesError, pipeNames] = await catchError2(getRobotIpcPipeNames());
|
|
4812
5895
|
if (pipeNamesError || !pipeNames) {
|
|
4813
5896
|
return false;
|
|
4814
5897
|
}
|
|
4815
|
-
const
|
|
5898
|
+
const fs2 = getFileSystem();
|
|
4816
5899
|
for (const pipeName of pipeNames) {
|
|
4817
|
-
const [existsError, exists] = await
|
|
5900
|
+
const [existsError, exists] = await catchError2(fs2.exists(pipeName));
|
|
4818
5901
|
if (!existsError && exists === true) {
|
|
4819
5902
|
return true;
|
|
4820
5903
|
}
|
|
4821
5904
|
}
|
|
4822
5905
|
return false;
|
|
4823
5906
|
};
|
|
4824
|
-
var withTimeout = (promise, timeoutMs) => new Promise((
|
|
5907
|
+
var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
|
|
4825
5908
|
const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
4826
5909
|
promise.then((value) => {
|
|
4827
5910
|
clearTimeout(timer);
|
|
4828
|
-
|
|
5911
|
+
resolve2(value);
|
|
4829
5912
|
}, (error) => {
|
|
4830
5913
|
clearTimeout(timer);
|
|
4831
5914
|
reject(error);
|
|
4832
5915
|
});
|
|
4833
5916
|
});
|
|
4834
5917
|
var parseResourceUrl = (url) => {
|
|
4835
|
-
const [error, parsed] =
|
|
5918
|
+
const [error, parsed] = catchError2(() => new URL(url));
|
|
4836
5919
|
if (error || !parsed)
|
|
4837
5920
|
return;
|
|
4838
5921
|
const segments = parsed.pathname.split("/").filter(Boolean);
|
|
@@ -4852,7 +5935,7 @@ var defaultLoadModule = async () => {
|
|
|
4852
5935
|
if (!hostLoader) {
|
|
4853
5936
|
return;
|
|
4854
5937
|
}
|
|
4855
|
-
const [error, mod] = await
|
|
5938
|
+
const [error, mod] = await catchError2(() => hostLoader());
|
|
4856
5939
|
if (error || !mod) {
|
|
4857
5940
|
return;
|
|
4858
5941
|
}
|
|
@@ -4878,7 +5961,7 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
4878
5961
|
const mod = await loadModule();
|
|
4879
5962
|
if (!mod)
|
|
4880
5963
|
return;
|
|
4881
|
-
const [ctorError, proxy] =
|
|
5964
|
+
const [ctorError, proxy] = catchError2(() => new mod.RobotProxyConstructor);
|
|
4882
5965
|
if (ctorError || !proxy) {
|
|
4883
5966
|
return;
|
|
4884
5967
|
}
|
|
@@ -4901,7 +5984,7 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
4901
5984
|
let organizationIdFromToken;
|
|
4902
5985
|
let tenantIdFromToken;
|
|
4903
5986
|
let issuerFromToken;
|
|
4904
|
-
const [jwtError, claims] =
|
|
5987
|
+
const [jwtError, claims] = catchError2(() => parseJWT(accessToken));
|
|
4905
5988
|
if (!jwtError && claims) {
|
|
4906
5989
|
const rawOrgId = claims.prtId ?? claims.organizationId ?? claims.prt_id;
|
|
4907
5990
|
if (typeof rawOrgId === "string" && rawOrgId.length > 0) {
|
|
@@ -4928,7 +6011,7 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
4928
6011
|
} catch {
|
|
4929
6012
|
return;
|
|
4930
6013
|
} finally {
|
|
4931
|
-
await
|
|
6014
|
+
await catchError2(() => withTimeout(proxy.CloseAsync(), CLOSE_TIMEOUT_MS));
|
|
4932
6015
|
}
|
|
4933
6016
|
};
|
|
4934
6017
|
|
|
@@ -4982,7 +6065,7 @@ var refreshAccessToken = async ({
|
|
|
4982
6065
|
var AUTH_FLOW_ENV_VAR = "UIPATH_AUTH_FLOW";
|
|
4983
6066
|
|
|
4984
6067
|
// ../auth/src/utils/envFile.ts
|
|
4985
|
-
var DEFAULT_ENV_FILENAME = `${
|
|
6068
|
+
var DEFAULT_ENV_FILENAME = `${UIPATH_HOME_DIR2}/${AUTH_FILENAME}`;
|
|
4986
6069
|
var KNOWN_ERROR_CODES = new Set([
|
|
4987
6070
|
"EISDIR",
|
|
4988
6071
|
"EACCES",
|
|
@@ -4998,9 +6081,9 @@ var errorCode = (err) => {
|
|
|
4998
6081
|
}
|
|
4999
6082
|
return "EUNKNOWN";
|
|
5000
6083
|
};
|
|
5001
|
-
var probeAsync = async (
|
|
6084
|
+
var probeAsync = async (fs2, candidate) => {
|
|
5002
6085
|
try {
|
|
5003
|
-
const stats = await
|
|
6086
|
+
const stats = await fs2.stat(candidate);
|
|
5004
6087
|
if (stats === null) {
|
|
5005
6088
|
return { exists: false };
|
|
5006
6089
|
}
|
|
@@ -5027,9 +6110,9 @@ var probeAsync = async (fs, candidate) => {
|
|
|
5027
6110
|
}
|
|
5028
6111
|
};
|
|
5029
6112
|
var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
|
|
5030
|
-
const
|
|
5031
|
-
if (
|
|
5032
|
-
const probe2 = await probeAsync(
|
|
6113
|
+
const fs2 = getFileSystem();
|
|
6114
|
+
if (fs2.path.isAbsolute(envFilePath)) {
|
|
6115
|
+
const probe2 = await probeAsync(fs2, envFilePath);
|
|
5033
6116
|
return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
|
|
5034
6117
|
exists: false,
|
|
5035
6118
|
absolutePath: envFilePath,
|
|
@@ -5037,11 +6120,11 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
|
|
|
5037
6120
|
...probe2.unusable ? { unusable: probe2.unusable } : {}
|
|
5038
6121
|
};
|
|
5039
6122
|
}
|
|
5040
|
-
const cwd = opts?.cwd ??
|
|
6123
|
+
const cwd = opts?.cwd ?? fs2.env.cwd();
|
|
5041
6124
|
let searchDir = cwd;
|
|
5042
6125
|
while (true) {
|
|
5043
|
-
const candidate =
|
|
5044
|
-
const probe2 = await probeAsync(
|
|
6126
|
+
const candidate = fs2.path.join(searchDir, envFilePath);
|
|
6127
|
+
const probe2 = await probeAsync(fs2, candidate);
|
|
5045
6128
|
if (probe2.exists) {
|
|
5046
6129
|
return {
|
|
5047
6130
|
exists: true,
|
|
@@ -5049,14 +6132,14 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
|
|
|
5049
6132
|
source: searchDir === cwd ? "cwd" : "ancestor"
|
|
5050
6133
|
};
|
|
5051
6134
|
}
|
|
5052
|
-
const parentDir =
|
|
6135
|
+
const parentDir = fs2.path.dirname(searchDir);
|
|
5053
6136
|
if (parentDir === searchDir) {
|
|
5054
6137
|
break;
|
|
5055
6138
|
}
|
|
5056
6139
|
searchDir = parentDir;
|
|
5057
6140
|
}
|
|
5058
|
-
const homePath =
|
|
5059
|
-
const probe = await probeAsync(
|
|
6141
|
+
const homePath = fs2.path.join(fs2.env.homedir(), envFilePath);
|
|
6142
|
+
const probe = await probeAsync(fs2, homePath);
|
|
5060
6143
|
if (probe.exists) {
|
|
5061
6144
|
return { exists: true, absolutePath: homePath, source: "home" };
|
|
5062
6145
|
}
|
|
@@ -5078,12 +6161,12 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
|
|
|
5078
6161
|
};
|
|
5079
6162
|
};
|
|
5080
6163
|
var loadEnvFileAsync = async ({ envPath }) => {
|
|
5081
|
-
const
|
|
5082
|
-
const absolutePath =
|
|
5083
|
-
if (!await
|
|
6164
|
+
const fs2 = getFileSystem();
|
|
6165
|
+
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
|
|
6166
|
+
if (!await fs2.exists(absolutePath)) {
|
|
5084
6167
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
5085
6168
|
}
|
|
5086
|
-
const content = await
|
|
6169
|
+
const content = await fs2.readFile(absolutePath, "utf-8");
|
|
5087
6170
|
if (content === null) {
|
|
5088
6171
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
5089
6172
|
}
|
|
@@ -5112,10 +6195,10 @@ var saveEnvFileAsync = async ({
|
|
|
5112
6195
|
data,
|
|
5113
6196
|
merge = true
|
|
5114
6197
|
}) => {
|
|
5115
|
-
const
|
|
5116
|
-
const absolutePath =
|
|
6198
|
+
const fs2 = getFileSystem();
|
|
6199
|
+
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.homedir(), envPath);
|
|
5117
6200
|
let existingData = {};
|
|
5118
|
-
if (merge && await
|
|
6201
|
+
if (merge && await fs2.exists(absolutePath)) {
|
|
5119
6202
|
try {
|
|
5120
6203
|
existingData = await loadEnvFileAsync({ envPath: absolutePath });
|
|
5121
6204
|
} catch {}
|
|
@@ -5133,11 +6216,11 @@ var saveEnvFileAsync = async ({
|
|
|
5133
6216
|
const content = `${lines.join(`
|
|
5134
6217
|
`)}
|
|
5135
6218
|
`;
|
|
5136
|
-
const dir =
|
|
5137
|
-
await
|
|
6219
|
+
const dir = fs2.path.dirname(absolutePath);
|
|
6220
|
+
await fs2.mkdir(dir);
|
|
5138
6221
|
const tempPath = `${absolutePath}.tmp`;
|
|
5139
|
-
await
|
|
5140
|
-
await
|
|
6222
|
+
await fs2.writeFile(tempPath, content);
|
|
6223
|
+
await fs2.rename(tempPath, absolutePath);
|
|
5141
6224
|
};
|
|
5142
6225
|
|
|
5143
6226
|
// ../auth/src/loginStatus.ts
|
|
@@ -5251,11 +6334,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
|
5251
6334
|
return { credentials };
|
|
5252
6335
|
}
|
|
5253
6336
|
async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
|
|
5254
|
-
const
|
|
5255
|
-
const globalPath =
|
|
6337
|
+
const fs2 = getFs();
|
|
6338
|
+
const globalPath = fs2.path.join(fs2.env.homedir(), envFilePath);
|
|
5256
6339
|
if (absolutePath === globalPath)
|
|
5257
6340
|
return;
|
|
5258
|
-
if (!await
|
|
6341
|
+
if (!await fs2.exists(globalPath))
|
|
5259
6342
|
return;
|
|
5260
6343
|
try {
|
|
5261
6344
|
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
@@ -5690,16 +6773,16 @@ function envValueFromFile(content, name) {
|
|
|
5690
6773
|
const [, ...valueParts] = envLine.split("=");
|
|
5691
6774
|
return valueParts.join("=").trim().replace(/^["']|["']$/g, "") || null;
|
|
5692
6775
|
}
|
|
5693
|
-
async function getConfiguredEnvValue(
|
|
6776
|
+
async function getConfiguredEnvValue(fs2, name) {
|
|
5694
6777
|
const processValue = process.env[name]?.trim();
|
|
5695
6778
|
if (processValue) {
|
|
5696
6779
|
return processValue;
|
|
5697
6780
|
}
|
|
5698
|
-
const envPath =
|
|
5699
|
-
if (!await
|
|
6781
|
+
const envPath = fs2.path.join(fs2.env.cwd(), ENV_FILE_NAME);
|
|
6782
|
+
if (!await fs2.exists(envPath)) {
|
|
5700
6783
|
return null;
|
|
5701
6784
|
}
|
|
5702
|
-
const [readError, content] = await
|
|
6785
|
+
const [readError, content] = await catchError(fs2.readFile(envPath, "utf-8"));
|
|
5703
6786
|
return !readError && typeof content === "string" ? envValueFromFile(content, name) : null;
|
|
5704
6787
|
}
|
|
5705
6788
|
var fail = (reason, message, instructions, extras = {}) => ({
|
|
@@ -5711,14 +6794,14 @@ var fail = (reason, message, instructions, extras = {}) => ({
|
|
|
5711
6794
|
stderr: extras.stderr
|
|
5712
6795
|
});
|
|
5713
6796
|
async function runUipathPythonCommand(args, options = {}) {
|
|
5714
|
-
const
|
|
5715
|
-
const cacheFile =
|
|
6797
|
+
const fs2 = getFileSystem();
|
|
6798
|
+
const cacheFile = fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
|
|
5716
6799
|
const setupHint = `Run 'uip ${options.commandPrefix ?? "codedagent"} setup' first to configure the environment. ` + "If you are using a virtual environment, activate it first.";
|
|
5717
6800
|
const cache = await readCache(cacheFile);
|
|
5718
6801
|
if (!cache?.uipathExePath) {
|
|
5719
6802
|
return fail("python_not_configured", "Python not configured.", setupHint);
|
|
5720
6803
|
}
|
|
5721
|
-
if (!await
|
|
6804
|
+
if (!await fs2.exists(cache.uipathExePath)) {
|
|
5722
6805
|
return fail("uipath_exe_missing", "uipath executable not found. Please install it using 'pip install uipath' or 'uv add uipath'.", setupHint);
|
|
5723
6806
|
}
|
|
5724
6807
|
const processed = processCommandArgs(args, options.commandRules ?? []);
|
|
@@ -5733,7 +6816,7 @@ async function runUipathPythonCommand(args, options = {}) {
|
|
|
5733
6816
|
if (!applies) {
|
|
5734
6817
|
continue;
|
|
5735
6818
|
}
|
|
5736
|
-
const value = await getConfiguredEnvValue(
|
|
6819
|
+
const value = await getConfiguredEnvValue(fs2, requirement.name);
|
|
5737
6820
|
if (!value) {
|
|
5738
6821
|
return fail("required_env_missing", `${requirement.name} environment variable not found.`, requirement.instructions);
|
|
5739
6822
|
}
|
|
@@ -5745,7 +6828,7 @@ async function runUipathPythonCommand(args, options = {}) {
|
|
|
5745
6828
|
}
|
|
5746
6829
|
if (options.commandPreflight) {
|
|
5747
6830
|
const preflight = options.commandPreflight;
|
|
5748
|
-
const [preflightError, preflightResult] = await
|
|
6831
|
+
const [preflightError, preflightResult] = await catchError(Promise.resolve().then(() => preflight({
|
|
5749
6832
|
args: commandArgs,
|
|
5750
6833
|
loginStatus: loginStatus2,
|
|
5751
6834
|
authEnv
|
|
@@ -5758,7 +6841,7 @@ async function runUipathPythonCommand(args, options = {}) {
|
|
|
5758
6841
|
}
|
|
5759
6842
|
}
|
|
5760
6843
|
const stdio = options.stdio ?? "inherit";
|
|
5761
|
-
const cwd = options.cwd ??
|
|
6844
|
+
const cwd = options.cwd ?? fs2.env.cwd();
|
|
5762
6845
|
const proc = spawn(cache.uipathExePath, commandArgs, {
|
|
5763
6846
|
cwd,
|
|
5764
6847
|
env: {
|
|
@@ -5779,8 +6862,8 @@ async function runUipathPythonCommand(args, options = {}) {
|
|
|
5779
6862
|
stderr += chunk.toString("utf8");
|
|
5780
6863
|
});
|
|
5781
6864
|
}
|
|
5782
|
-
const [spawnError, exitCode] = await
|
|
5783
|
-
proc.on("close", (code) =>
|
|
6865
|
+
const [spawnError, exitCode] = await catchError(new Promise((resolve2, reject) => {
|
|
6866
|
+
proc.on("close", (code) => resolve2(code ?? 1));
|
|
5784
6867
|
proc.on("error", reject);
|
|
5785
6868
|
}));
|
|
5786
6869
|
if (spawnError) {
|
|
@@ -5850,25 +6933,25 @@ class PythonService {
|
|
|
5850
6933
|
uipathExePath;
|
|
5851
6934
|
packageVersion;
|
|
5852
6935
|
constructor(config) {
|
|
5853
|
-
const
|
|
6936
|
+
const fs2 = getFileSystem();
|
|
5854
6937
|
this.config = config;
|
|
5855
|
-
this.cacheFile = config.cacheFile ||
|
|
6938
|
+
this.cacheFile = config.cacheFile || fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
|
|
5856
6939
|
}
|
|
5857
6940
|
async setup(packageName, force = false) {
|
|
5858
|
-
const [error, result] = await
|
|
6941
|
+
const [error, result] = await catchError(this._setupInternal(packageName, force));
|
|
5859
6942
|
if (error) {
|
|
5860
6943
|
return { success: false, error: error.message };
|
|
5861
6944
|
}
|
|
5862
6945
|
return result;
|
|
5863
6946
|
}
|
|
5864
6947
|
async _setupInternal(packageName, force) {
|
|
5865
|
-
const
|
|
6948
|
+
const fs2 = getFileSystem();
|
|
5866
6949
|
let pythonPath;
|
|
5867
6950
|
let version;
|
|
5868
6951
|
if (!force) {
|
|
5869
6952
|
logger.debug("Checking cache...");
|
|
5870
6953
|
const cached = await this.loadCache();
|
|
5871
|
-
if (cached?.uipathExePath && await
|
|
6954
|
+
if (cached?.uipathExePath && await fs2.exists(cached.uipathExePath)) {
|
|
5872
6955
|
pythonPath = cached.pythonPath;
|
|
5873
6956
|
version = cached.version;
|
|
5874
6957
|
this.uipathExePath = cached.uipathExePath;
|
|
@@ -5971,7 +7054,7 @@ To install the package, run:
|
|
|
5971
7054
|
};
|
|
5972
7055
|
}
|
|
5973
7056
|
async checkPythonCommand(command, args, checkedVersions, searchedCommands) {
|
|
5974
|
-
const
|
|
7057
|
+
const fs2 = getFileSystem();
|
|
5975
7058
|
const commandStr = args.length > 0 ? `${command} ${args.join(" ")}` : command;
|
|
5976
7059
|
searchedCommands.push(commandStr);
|
|
5977
7060
|
logger.debug(`Checking Python command: ${commandStr}`);
|
|
@@ -5983,8 +7066,8 @@ To install the package, run:
|
|
|
5983
7066
|
const stderrChunks = [];
|
|
5984
7067
|
versionProc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
5985
7068
|
versionProc.stderr.on("data", (chunk) => stderrChunks.push(chunk));
|
|
5986
|
-
const [versionError, exitCode] = await
|
|
5987
|
-
versionProc.on("exit", (code) =>
|
|
7069
|
+
const [versionError, exitCode] = await catchError(new Promise((resolve2, reject) => {
|
|
7070
|
+
versionProc.on("exit", (code) => resolve2(code ?? 1));
|
|
5988
7071
|
versionProc.on("error", (error) => reject(error));
|
|
5989
7072
|
}));
|
|
5990
7073
|
if (versionError) {
|
|
@@ -6009,7 +7092,7 @@ To install the package, run:
|
|
|
6009
7092
|
return null;
|
|
6010
7093
|
}
|
|
6011
7094
|
logger.info(`Found valid Python: ${commandStr} - ${version}`);
|
|
6012
|
-
const uipathExePath = await this.findUipathExe(
|
|
7095
|
+
const uipathExePath = await this.findUipathExe(fs2, command, args);
|
|
6013
7096
|
return {
|
|
6014
7097
|
success: true,
|
|
6015
7098
|
pythonPath: commandStr,
|
|
@@ -6017,31 +7100,31 @@ To install the package, run:
|
|
|
6017
7100
|
uipathExePath
|
|
6018
7101
|
};
|
|
6019
7102
|
}
|
|
6020
|
-
async findUipathExe(
|
|
6021
|
-
const metadataPath = await this.findUipathExeFromMetadata(
|
|
7103
|
+
async findUipathExe(fs2, command, args) {
|
|
7104
|
+
const metadataPath = await this.findUipathExeFromMetadata(fs2, command, args);
|
|
6022
7105
|
if (metadataPath)
|
|
6023
7106
|
return metadataPath;
|
|
6024
7107
|
const isWindows = platform() === "win32";
|
|
6025
7108
|
const candidatePaths = [];
|
|
6026
7109
|
const virtualEnv = process.env.VIRTUAL_ENV;
|
|
6027
7110
|
if (virtualEnv) {
|
|
6028
|
-
candidatePaths.push(isWindows ?
|
|
7111
|
+
candidatePaths.push(isWindows ? fs2.path.join(virtualEnv, "Scripts", "uipath.exe") : fs2.path.join(virtualEnv, "bin", "uipath"));
|
|
6029
7112
|
}
|
|
6030
7113
|
const prefix = await this.getPythonPrefix(command, args);
|
|
6031
7114
|
if (prefix) {
|
|
6032
|
-
candidatePaths.push(isWindows ?
|
|
7115
|
+
candidatePaths.push(isWindows ? fs2.path.join(prefix, "Scripts", "uipath.exe") : fs2.path.join(prefix, "bin", "uipath"));
|
|
6033
7116
|
}
|
|
6034
7117
|
for (const candidate of candidatePaths) {
|
|
6035
7118
|
logger.debug(`Checking for uipath executable at: ${candidate}`);
|
|
6036
|
-
if (await
|
|
7119
|
+
if (await fs2.exists(candidate)) {
|
|
6037
7120
|
logger.info(`Found uipath executable at: ${candidate}`);
|
|
6038
7121
|
return candidate;
|
|
6039
7122
|
}
|
|
6040
7123
|
}
|
|
6041
|
-
const pathCandidates = this.getPathUipathCandidates(
|
|
7124
|
+
const pathCandidates = this.getPathUipathCandidates(fs2, isWindows);
|
|
6042
7125
|
for (const candidate of pathCandidates) {
|
|
6043
7126
|
logger.debug(`Checking for uipath executable on PATH at: ${candidate}`);
|
|
6044
|
-
if (await
|
|
7127
|
+
if (await fs2.exists(candidate)) {
|
|
6045
7128
|
logger.info(`Found uipath executable at: ${candidate}`);
|
|
6046
7129
|
return candidate;
|
|
6047
7130
|
}
|
|
@@ -6050,7 +7133,7 @@ To install the package, run:
|
|
|
6050
7133
|
logger.error(`uipath executable not found. Checked: ${checkedCandidates.join(", ")}`);
|
|
6051
7134
|
return;
|
|
6052
7135
|
}
|
|
6053
|
-
async findUipathExeFromMetadata(
|
|
7136
|
+
async findUipathExeFromMetadata(fs2, command, args) {
|
|
6054
7137
|
const script = `
|
|
6055
7138
|
from importlib.metadata import distribution, PackageNotFoundError
|
|
6056
7139
|
import sys
|
|
@@ -6071,8 +7154,8 @@ sys.exit(3)
|
|
|
6071
7154
|
const stderrChunks = [];
|
|
6072
7155
|
proc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
6073
7156
|
proc.stderr.on("data", (chunk) => stderrChunks.push(chunk));
|
|
6074
|
-
const [error, exitCode] = await
|
|
6075
|
-
proc.on("exit", (code) =>
|
|
7157
|
+
const [error, exitCode] = await catchError(new Promise((resolve2, reject) => {
|
|
7158
|
+
proc.on("exit", (code) => resolve2(code ?? 1));
|
|
6076
7159
|
proc.on("error", (err) => reject(err));
|
|
6077
7160
|
}));
|
|
6078
7161
|
if (error) {
|
|
@@ -6089,7 +7172,7 @@ sys.exit(3)
|
|
|
6089
7172
|
logger.debug("uipath executable metadata lookup returned empty path");
|
|
6090
7173
|
return;
|
|
6091
7174
|
}
|
|
6092
|
-
if (!await
|
|
7175
|
+
if (!await fs2.exists(resolved)) {
|
|
6093
7176
|
logger.debug(`uipath executable path from metadata does not exist: ${resolved}`);
|
|
6094
7177
|
return;
|
|
6095
7178
|
}
|
|
@@ -6102,8 +7185,8 @@ sys.exit(3)
|
|
|
6102
7185
|
});
|
|
6103
7186
|
const stdoutChunks = [];
|
|
6104
7187
|
proc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
6105
|
-
const [error, exitCode] = await
|
|
6106
|
-
proc.on("exit", (code) =>
|
|
7188
|
+
const [error, exitCode] = await catchError(new Promise((resolve2, reject) => {
|
|
7189
|
+
proc.on("exit", (code) => resolve2(code ?? 1));
|
|
6107
7190
|
proc.on("error", (err) => reject(err));
|
|
6108
7191
|
}));
|
|
6109
7192
|
if (error) {
|
|
@@ -6123,8 +7206,8 @@ sys.exit(3)
|
|
|
6123
7206
|
const stderrChunks = [];
|
|
6124
7207
|
proc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
6125
7208
|
proc.stderr.on("data", (chunk) => stderrChunks.push(chunk));
|
|
6126
|
-
const [spawnError, exitCode] = await
|
|
6127
|
-
proc.on("exit", (code) =>
|
|
7209
|
+
const [spawnError, exitCode] = await catchError(new Promise((resolve2, reject) => {
|
|
7210
|
+
proc.on("exit", (code) => resolve2(code ?? 1));
|
|
6128
7211
|
proc.on("error", (err) => reject(err));
|
|
6129
7212
|
}));
|
|
6130
7213
|
if (spawnError) {
|
|
@@ -6147,14 +7230,14 @@ sys.exit(3)
|
|
|
6147
7230
|
}
|
|
6148
7231
|
return { version: match[1] };
|
|
6149
7232
|
}
|
|
6150
|
-
getPathUipathCandidates(
|
|
7233
|
+
getPathUipathCandidates(fs2, isWindows) {
|
|
6151
7234
|
const pathValue = process.env.PATH || (isWindows ? process.env.Path : undefined);
|
|
6152
7235
|
if (!pathValue)
|
|
6153
7236
|
return [];
|
|
6154
7237
|
const delimiter = isWindows ? ";" : ":";
|
|
6155
7238
|
const pathEntries = pathValue.split(delimiter).map((entry) => entry.trim().replace(/^"|"$/g, "")).filter((entry) => entry.length > 0);
|
|
6156
7239
|
const executableNames = isWindows ? this.getWindowsExecutableNames() : ["uipath"];
|
|
6157
|
-
return pathEntries.flatMap((entry) => executableNames.map((name) =>
|
|
7240
|
+
return pathEntries.flatMap((entry) => executableNames.map((name) => fs2.path.join(entry, name)));
|
|
6158
7241
|
}
|
|
6159
7242
|
getWindowsExecutableNames() {
|
|
6160
7243
|
const pathExt = process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD";
|
|
@@ -6230,14 +7313,14 @@ Please install one of the required Python versions:
|
|
|
6230
7313
|
return readCache(this.cacheFile);
|
|
6231
7314
|
}
|
|
6232
7315
|
async saveCache(cache) {
|
|
6233
|
-
const
|
|
6234
|
-
const dir =
|
|
6235
|
-
const [mkdirError] = await
|
|
7316
|
+
const fs2 = getFileSystem();
|
|
7317
|
+
const dir = fs2.path.dirname(this.cacheFile);
|
|
7318
|
+
const [mkdirError] = await catchError(fs2.mkdir(dir));
|
|
6236
7319
|
if (mkdirError) {
|
|
6237
7320
|
logger.warn(`Failed to create cache directory: ${mkdirError}`);
|
|
6238
7321
|
return;
|
|
6239
7322
|
}
|
|
6240
|
-
const [writeError] = await
|
|
7323
|
+
const [writeError] = await catchError(fs2.writeFile(this.cacheFile, JSON.stringify(cache, null, 2)));
|
|
6241
7324
|
if (writeError) {
|
|
6242
7325
|
logger.warn(`Failed to save cache: ${writeError}`);
|
|
6243
7326
|
return;
|
|
@@ -6260,9 +7343,9 @@ function createSetupCommand(config) {
|
|
|
6260
7343
|
processContext.exit(1);
|
|
6261
7344
|
return;
|
|
6262
7345
|
}
|
|
6263
|
-
const
|
|
6264
|
-
const venvPath =
|
|
6265
|
-
if (await
|
|
7346
|
+
const fs2 = getFileSystem();
|
|
7347
|
+
const venvPath = fs2.path.join(fs2.env.cwd(), ".venv");
|
|
7348
|
+
if (await fs2.exists(venvPath) && !process.env.VIRTUAL_ENV) {
|
|
6266
7349
|
OutputFormatter.error({
|
|
6267
7350
|
Result: RESULTS.Failure,
|
|
6268
7351
|
Message: "Found .venv in current directory but no virtual environment is activated.",
|
|
@@ -6334,7 +7417,7 @@ function createCommandForwarder(executeCommand) {
|
|
|
6334
7417
|
var package_default = {
|
|
6335
7418
|
name: "@uipath/context-grounding-tool",
|
|
6336
7419
|
license: "MIT",
|
|
6337
|
-
version: "1.
|
|
7420
|
+
version: "1.202.0-preview.136",
|
|
6338
7421
|
description: "Tool for context grounding operations via the UiPath Python SDK",
|
|
6339
7422
|
keywords: [
|
|
6340
7423
|
"uipcli-tool",
|
|
@@ -6435,4 +7518,4 @@ var registerCommands = async (program2) => {
|
|
|
6435
7518
|
|
|
6436
7519
|
export { Command, metadata, registerCommands };
|
|
6437
7520
|
|
|
6438
|
-
//# debugId=
|
|
7521
|
+
//# debugId=43C5C7D0F0C758B764756E2164756E21
|