@uipath/guardrails-tool 1.206.0-preview.303 → 1.207.0-preview.305
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/tool.js +321 -140
- package/package.json +2 -2
package/dist/tool.js
CHANGED
|
@@ -2082,7 +2082,7 @@ var package_default = {
|
|
|
2082
2082
|
name: "@uipath/guardrails-tool",
|
|
2083
2083
|
author: "UiPath",
|
|
2084
2084
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
2085
|
-
version: "1.
|
|
2085
|
+
version: "1.207.0-preview.305",
|
|
2086
2086
|
description: "CLI plugin for UiPath AI Trust Layer guardrail configurations.",
|
|
2087
2087
|
private: false,
|
|
2088
2088
|
repository: {
|
|
@@ -2170,12 +2170,26 @@ class NodeFileSystem {
|
|
|
2170
2170
|
throw error;
|
|
2171
2171
|
}
|
|
2172
2172
|
}
|
|
2173
|
-
async writeFile(filePath, data) {
|
|
2173
|
+
async writeFile(filePath, data, options) {
|
|
2174
2174
|
const dir = path.dirname(filePath);
|
|
2175
2175
|
if (dir) {
|
|
2176
2176
|
await fs.mkdir(dir, { recursive: true });
|
|
2177
2177
|
}
|
|
2178
|
-
|
|
2178
|
+
if (options?.mode === undefined || process.platform === "win32") {
|
|
2179
|
+
if (options?.exclusive) {
|
|
2180
|
+
await fs.writeFile(filePath, data, { flag: "wx" });
|
|
2181
|
+
} else {
|
|
2182
|
+
await fs.writeFile(filePath, data);
|
|
2183
|
+
}
|
|
2184
|
+
return;
|
|
2185
|
+
}
|
|
2186
|
+
const handle = await fs.open(filePath, options.exclusive ? "wx" : "w", options.mode);
|
|
2187
|
+
try {
|
|
2188
|
+
await handle.chmod(options.mode);
|
|
2189
|
+
await handle.writeFile(data);
|
|
2190
|
+
} finally {
|
|
2191
|
+
await handle.close();
|
|
2192
|
+
}
|
|
2179
2193
|
}
|
|
2180
2194
|
async appendFile(filePath, data) {
|
|
2181
2195
|
const dir = path.dirname(filePath);
|
|
@@ -2210,7 +2224,8 @@ class NodeFileSystem {
|
|
|
2210
2224
|
isDirectory: () => stats.isDirectory(),
|
|
2211
2225
|
size: stats.size,
|
|
2212
2226
|
mtimeMs: stats.mtimeMs,
|
|
2213
|
-
ctimeMs: stats.ctimeMs
|
|
2227
|
+
ctimeMs: stats.ctimeMs,
|
|
2228
|
+
mode: stats.mode
|
|
2214
2229
|
};
|
|
2215
2230
|
} catch (error) {
|
|
2216
2231
|
if (this.isEnoent(error))
|
|
@@ -2221,8 +2236,13 @@ class NodeFileSystem {
|
|
|
2221
2236
|
async exists(filePath) {
|
|
2222
2237
|
return existsSync(filePath);
|
|
2223
2238
|
}
|
|
2224
|
-
async mkdir(dirPath) {
|
|
2225
|
-
await fs.mkdir(dirPath, { recursive: true });
|
|
2239
|
+
async mkdir(dirPath, options) {
|
|
2240
|
+
await fs.mkdir(dirPath, { recursive: true, mode: options?.mode });
|
|
2241
|
+
}
|
|
2242
|
+
async chmod(targetPath, mode) {
|
|
2243
|
+
if (process.platform === "win32")
|
|
2244
|
+
return;
|
|
2245
|
+
await fs.chmod(targetPath, mode);
|
|
2226
2246
|
}
|
|
2227
2247
|
async acquireLock(lockPath) {
|
|
2228
2248
|
const canonicalPath = await this.canonicalizeLockTarget(lockPath);
|
|
@@ -2372,7 +2392,7 @@ class NodeFileSystem {
|
|
|
2372
2392
|
async getTempDir() {
|
|
2373
2393
|
return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
|
|
2374
2394
|
}
|
|
2375
|
-
async copyDirectory(sourcePath, destPath) {
|
|
2395
|
+
async copyDirectory(sourcePath, destPath, options) {
|
|
2376
2396
|
const sourceStats = await this.stat(sourcePath);
|
|
2377
2397
|
if (!sourceStats) {
|
|
2378
2398
|
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
@@ -2389,7 +2409,9 @@ class NodeFileSystem {
|
|
|
2389
2409
|
if (!entryStats)
|
|
2390
2410
|
continue;
|
|
2391
2411
|
if (entryStats.isDirectory()) {
|
|
2392
|
-
|
|
2412
|
+
if (options?.skipDirectoryNames?.includes(entry))
|
|
2413
|
+
continue;
|
|
2414
|
+
await this.copyDirectory(srcEntry, destEntry, options);
|
|
2393
2415
|
} else if (entryStats.isFile()) {
|
|
2394
2416
|
const content = await this.readFile(srcEntry);
|
|
2395
2417
|
if (content !== null) {
|
|
@@ -2452,13 +2474,15 @@ var ProjectDimensions = {
|
|
|
2452
2474
|
SolutionKey: "SolutionKey",
|
|
2453
2475
|
SolutionProjectKey: "SolutionProjectKey",
|
|
2454
2476
|
SolutionIdentityStatus: "SolutionIdentityStatus",
|
|
2455
|
-
PreviousSolutionKey: "PreviousSolutionKey"
|
|
2477
|
+
PreviousSolutionKey: "PreviousSolutionKey",
|
|
2478
|
+
PreviousProjectKey: "PreviousProjectKey"
|
|
2456
2479
|
};
|
|
2457
2480
|
var GUID_KEY_DIMENSIONS = new Set([
|
|
2458
2481
|
ProjectDimensions.ProjectKey,
|
|
2459
2482
|
ProjectDimensions.SolutionKey,
|
|
2460
2483
|
ProjectDimensions.SolutionProjectKey,
|
|
2461
|
-
ProjectDimensions.PreviousSolutionKey
|
|
2484
|
+
ProjectDimensions.PreviousSolutionKey,
|
|
2485
|
+
ProjectDimensions.PreviousProjectKey
|
|
2462
2486
|
]);
|
|
2463
2487
|
var ShipDimensions = {
|
|
2464
2488
|
ShipKind: "ShipKind",
|
|
@@ -2612,9 +2636,7 @@ async function withinProjectIdentityBudget(work, onTimeout) {
|
|
|
2612
2636
|
}
|
|
2613
2637
|
}
|
|
2614
2638
|
|
|
2615
|
-
// ../../common/src/
|
|
2616
|
-
var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
|
|
2617
|
-
var PSEUDONYM_HEX_LENGTH = 32;
|
|
2639
|
+
// ../../common/src/sha256.ts
|
|
2618
2640
|
var SHA256_K = new Uint32Array([
|
|
2619
2641
|
1116352408,
|
|
2620
2642
|
1899447441,
|
|
@@ -2694,7 +2716,7 @@ var SHA256_INITIAL_STATE = new Uint32Array([
|
|
|
2694
2716
|
function rotr(value, bits) {
|
|
2695
2717
|
return (value >>> bits | value << 32 - bits) >>> 0;
|
|
2696
2718
|
}
|
|
2697
|
-
function
|
|
2719
|
+
function sha256Words(input) {
|
|
2698
2720
|
const bytes = new TextEncoder().encode(input);
|
|
2699
2721
|
const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
|
|
2700
2722
|
const buffer = new Uint8Array(paddedLength);
|
|
@@ -2750,12 +2772,19 @@ function sha256Hex(input) {
|
|
|
2750
2772
|
state[6] = state[6] + g >>> 0;
|
|
2751
2773
|
state[7] = state[7] + h >>> 0;
|
|
2752
2774
|
}
|
|
2775
|
+
return state;
|
|
2776
|
+
}
|
|
2777
|
+
function sha256Hex(input) {
|
|
2753
2778
|
let hex = "";
|
|
2754
|
-
for (const word of
|
|
2779
|
+
for (const word of sha256Words(input)) {
|
|
2755
2780
|
hex += word.toString(16).padStart(8, "0");
|
|
2756
2781
|
}
|
|
2757
2782
|
return hex;
|
|
2758
2783
|
}
|
|
2784
|
+
|
|
2785
|
+
// ../../common/src/telemetry/pseudonymize.ts
|
|
2786
|
+
var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
|
|
2787
|
+
var PSEUDONYM_HEX_LENGTH = 32;
|
|
2759
2788
|
function resolveSha256Hex() {
|
|
2760
2789
|
try {
|
|
2761
2790
|
const nodeCrypto = __require("node:crypto");
|
|
@@ -3151,13 +3180,25 @@ function settlePromiseLike(thenable) {
|
|
|
3151
3180
|
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
|
|
3152
3181
|
}
|
|
3153
3182
|
|
|
3183
|
+
// ../../common/src/result-types.ts
|
|
3184
|
+
var RESULTS = {
|
|
3185
|
+
Success: "Success",
|
|
3186
|
+
Failure: "Failure",
|
|
3187
|
+
ConfigError: "ConfigError",
|
|
3188
|
+
AuthenticationError: "AuthenticationError",
|
|
3189
|
+
ValidationError: "ValidationError",
|
|
3190
|
+
TimeoutError: "TimeoutError"
|
|
3191
|
+
};
|
|
3192
|
+
|
|
3154
3193
|
// ../../common/src/error-codes.ts
|
|
3155
3194
|
var CLI_ERROR_CODES = [
|
|
3156
3195
|
"invalid_argument",
|
|
3196
|
+
"confirmation_required",
|
|
3157
3197
|
"authentication_required",
|
|
3158
3198
|
"permission_denied",
|
|
3159
3199
|
"local_permission_denied",
|
|
3160
3200
|
"not_found",
|
|
3201
|
+
"not_enabled",
|
|
3161
3202
|
"rate_limited",
|
|
3162
3203
|
"network_error",
|
|
3163
3204
|
"timeout",
|
|
@@ -3196,6 +3237,12 @@ function carriedRetry(error) {
|
|
|
3196
3237
|
const retry = error.retry;
|
|
3197
3238
|
return isRetryHint(retry) ? retry : undefined;
|
|
3198
3239
|
}
|
|
3240
|
+
function carriedResult(error) {
|
|
3241
|
+
if (!error || typeof error !== "object")
|
|
3242
|
+
return;
|
|
3243
|
+
const result = error.result;
|
|
3244
|
+
return typeof result === "string" && result !== RESULTS.Success && Object.values(RESULTS).includes(result) ? result : undefined;
|
|
3245
|
+
}
|
|
3199
3246
|
function defaultRetryForErrorCode(errorCode) {
|
|
3200
3247
|
switch (errorCode) {
|
|
3201
3248
|
case "network_error":
|
|
@@ -3585,6 +3632,8 @@ async function extractErrorDetails(error, options) {
|
|
|
3585
3632
|
}
|
|
3586
3633
|
if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
|
|
3587
3634
|
context.errorCode = parsedBody.errorCode;
|
|
3635
|
+
} else if (typeof parsedBody?.errorCode === "number") {
|
|
3636
|
+
context.errorCode = String(parsedBody.errorCode);
|
|
3588
3637
|
} else if (parsedBody?.code && typeof parsedBody.code === "string") {
|
|
3589
3638
|
context.errorCode = parsedBody.code;
|
|
3590
3639
|
}
|
|
@@ -3641,15 +3690,6 @@ async function extractErrorDetails(error, options) {
|
|
|
3641
3690
|
...parsedErrors ? { parsedErrors } : {}
|
|
3642
3691
|
};
|
|
3643
3692
|
}
|
|
3644
|
-
// ../../common/src/result-types.ts
|
|
3645
|
-
var RESULTS = {
|
|
3646
|
-
Success: "Success",
|
|
3647
|
-
Failure: "Failure",
|
|
3648
|
-
ConfigError: "ConfigError",
|
|
3649
|
-
AuthenticationError: "AuthenticationError",
|
|
3650
|
-
ValidationError: "ValidationError",
|
|
3651
|
-
TimeoutError: "TimeoutError"
|
|
3652
|
-
};
|
|
3653
3693
|
// ../../../node_modules/commander/index.js
|
|
3654
3694
|
var exports_commander = {};
|
|
3655
3695
|
__exportCjs(exports_commander, {
|
|
@@ -4082,7 +4122,10 @@ var AUTH_ERROR_CODES = new Set([
|
|
|
4082
4122
|
var LOCAL_PERMISSION_CLI_ERROR_CODES = new Set([
|
|
4083
4123
|
"local_permission_denied"
|
|
4084
4124
|
]);
|
|
4085
|
-
var VALIDATION_ERROR_CODES = new Set([
|
|
4125
|
+
var VALIDATION_ERROR_CODES = new Set([
|
|
4126
|
+
"invalid_argument",
|
|
4127
|
+
"confirmation_required"
|
|
4128
|
+
]);
|
|
4086
4129
|
var NETWORK_HTTP_ERROR_CODES = new Set([
|
|
4087
4130
|
"network_error",
|
|
4088
4131
|
"rate_limited",
|
|
@@ -4308,6 +4351,109 @@ var CommonTelemetryEvents = {
|
|
|
4308
4351
|
ShipSucceeded: "Cli.ShipSucceeded"
|
|
4309
4352
|
};
|
|
4310
4353
|
|
|
4354
|
+
// ../../common/src/telemetry/global-telemetry-properties.ts
|
|
4355
|
+
var telemetryPropsSlot = singleton("TelemetryDefaultProps");
|
|
4356
|
+
function getGlobalTelemetryProperties() {
|
|
4357
|
+
return telemetryPropsSlot.get();
|
|
4358
|
+
}
|
|
4359
|
+
|
|
4360
|
+
// ../../common/src/telemetry/trace-context.ts
|
|
4361
|
+
var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
|
|
4362
|
+
var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
|
|
4363
|
+
function getProcessEnv() {
|
|
4364
|
+
return globalThis.process?.env;
|
|
4365
|
+
}
|
|
4366
|
+
function parseInboundTraceparent(value) {
|
|
4367
|
+
if (!value) {
|
|
4368
|
+
return;
|
|
4369
|
+
}
|
|
4370
|
+
const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
|
|
4371
|
+
if (!match) {
|
|
4372
|
+
return;
|
|
4373
|
+
}
|
|
4374
|
+
const [, traceId, parentSpanId] = match;
|
|
4375
|
+
if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
|
|
4376
|
+
return;
|
|
4377
|
+
}
|
|
4378
|
+
return { traceId, parentSpanId };
|
|
4379
|
+
}
|
|
4380
|
+
function getInboundTraceContext() {
|
|
4381
|
+
return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
|
|
4382
|
+
}
|
|
4383
|
+
|
|
4384
|
+
// ../../common/src/telemetry/session-id.ts
|
|
4385
|
+
var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
|
|
4386
|
+
var SESSION_ID_MAX_LENGTH = 64;
|
|
4387
|
+
var RANDOM_SESSION_ID_LENGTH = 32;
|
|
4388
|
+
var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
|
|
4389
|
+
var CONTROL_CHARACTERS = /\p{Cc}/gu;
|
|
4390
|
+
var INHERITED_SESSION_SOURCES = [
|
|
4391
|
+
{ envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
|
|
4392
|
+
{ envVar: "CODEX_THREAD_ID", source: "codex" },
|
|
4393
|
+
{ envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
|
|
4394
|
+
{ envVar: "TERM_SESSION_ID", source: "terminal" },
|
|
4395
|
+
{ envVar: "WT_SESSION", source: "terminal" }
|
|
4396
|
+
];
|
|
4397
|
+
var telemetrySessionSlot = singleton("TelemetrySession");
|
|
4398
|
+
var telemetryOperationIdSlot = singleton("TelemetryOperationId");
|
|
4399
|
+
function getProcessEnv2() {
|
|
4400
|
+
return globalThis.process?.env;
|
|
4401
|
+
}
|
|
4402
|
+
function normalizeSessionId(value) {
|
|
4403
|
+
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
|
|
4404
|
+
return;
|
|
4405
|
+
}
|
|
4406
|
+
const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
|
|
4407
|
+
return cleaned || undefined;
|
|
4408
|
+
}
|
|
4409
|
+
function getConfiguredTelemetrySessionId() {
|
|
4410
|
+
return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
|
|
4411
|
+
}
|
|
4412
|
+
function getInheritedSession(env) {
|
|
4413
|
+
for (const candidate of INHERITED_SESSION_SOURCES) {
|
|
4414
|
+
const handle = normalizeSessionId(env[candidate.envVar]);
|
|
4415
|
+
if (handle) {
|
|
4416
|
+
return { id: handle, source: candidate.source };
|
|
4417
|
+
}
|
|
4418
|
+
}
|
|
4419
|
+
return;
|
|
4420
|
+
}
|
|
4421
|
+
function generateRandomSession() {
|
|
4422
|
+
const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
|
|
4423
|
+
crypto.getRandomValues(bytes);
|
|
4424
|
+
let hex = "";
|
|
4425
|
+
for (const byte of bytes) {
|
|
4426
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
4427
|
+
}
|
|
4428
|
+
return { id: hex, source: "random" };
|
|
4429
|
+
}
|
|
4430
|
+
function resolveTelemetrySession() {
|
|
4431
|
+
const existing = telemetrySessionSlot.get();
|
|
4432
|
+
if (existing) {
|
|
4433
|
+
return existing;
|
|
4434
|
+
}
|
|
4435
|
+
const declaredHandle = getConfiguredTelemetrySessionId();
|
|
4436
|
+
const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
|
|
4437
|
+
telemetrySessionSlot.set(resolved);
|
|
4438
|
+
return resolved;
|
|
4439
|
+
}
|
|
4440
|
+
function getTelemetrySessionId() {
|
|
4441
|
+
return resolveTelemetrySession().id;
|
|
4442
|
+
}
|
|
4443
|
+
function getTelemetrySessionSource() {
|
|
4444
|
+
return resolveTelemetrySession().source;
|
|
4445
|
+
}
|
|
4446
|
+
function getTelemetryOperationId() {
|
|
4447
|
+
const existing = telemetryOperationIdSlot.get();
|
|
4448
|
+
if (existing) {
|
|
4449
|
+
return existing;
|
|
4450
|
+
}
|
|
4451
|
+
const inboundTraceId = getInboundTraceContext()?.traceId;
|
|
4452
|
+
const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
|
|
4453
|
+
telemetryOperationIdSlot.set(generated);
|
|
4454
|
+
return generated;
|
|
4455
|
+
}
|
|
4456
|
+
|
|
4311
4457
|
// ../../common/src/registry.ts
|
|
4312
4458
|
import { execFileSync } from "node:child_process";
|
|
4313
4459
|
function readRegistryValue(keyPath, valueName) {
|
|
@@ -4529,108 +4675,6 @@ class NodeContextStorage {
|
|
|
4529
4675
|
return this.storage.getStore();
|
|
4530
4676
|
}
|
|
4531
4677
|
}
|
|
4532
|
-
// ../../common/src/telemetry/trace-context.ts
|
|
4533
|
-
var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
|
|
4534
|
-
var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
|
|
4535
|
-
function getProcessEnv() {
|
|
4536
|
-
return globalThis.process?.env;
|
|
4537
|
-
}
|
|
4538
|
-
function parseInboundTraceparent(value) {
|
|
4539
|
-
if (!value) {
|
|
4540
|
-
return;
|
|
4541
|
-
}
|
|
4542
|
-
const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
|
|
4543
|
-
if (!match) {
|
|
4544
|
-
return;
|
|
4545
|
-
}
|
|
4546
|
-
const [, traceId, parentSpanId] = match;
|
|
4547
|
-
if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
|
|
4548
|
-
return;
|
|
4549
|
-
}
|
|
4550
|
-
return { traceId, parentSpanId };
|
|
4551
|
-
}
|
|
4552
|
-
function getInboundTraceContext() {
|
|
4553
|
-
return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
|
|
4554
|
-
}
|
|
4555
|
-
|
|
4556
|
-
// ../../common/src/telemetry/session-id.ts
|
|
4557
|
-
var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
|
|
4558
|
-
var SESSION_ID_MAX_LENGTH = 64;
|
|
4559
|
-
var RANDOM_SESSION_ID_LENGTH = 32;
|
|
4560
|
-
var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
|
|
4561
|
-
var CONTROL_CHARACTERS = /\p{Cc}/gu;
|
|
4562
|
-
var INHERITED_SESSION_SOURCES = [
|
|
4563
|
-
{ envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
|
|
4564
|
-
{ envVar: "CODEX_THREAD_ID", source: "codex" },
|
|
4565
|
-
{ envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
|
|
4566
|
-
{ envVar: "TERM_SESSION_ID", source: "terminal" },
|
|
4567
|
-
{ envVar: "WT_SESSION", source: "terminal" }
|
|
4568
|
-
];
|
|
4569
|
-
var telemetrySessionSlot = singleton("TelemetrySession");
|
|
4570
|
-
var telemetryOperationIdSlot = singleton("TelemetryOperationId");
|
|
4571
|
-
function getProcessEnv2() {
|
|
4572
|
-
return globalThis.process?.env;
|
|
4573
|
-
}
|
|
4574
|
-
function normalizeSessionId(value) {
|
|
4575
|
-
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
|
|
4576
|
-
return;
|
|
4577
|
-
}
|
|
4578
|
-
const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
|
|
4579
|
-
return cleaned || undefined;
|
|
4580
|
-
}
|
|
4581
|
-
function getConfiguredTelemetrySessionId() {
|
|
4582
|
-
return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
|
|
4583
|
-
}
|
|
4584
|
-
function getInheritedSession(env) {
|
|
4585
|
-
for (const candidate of INHERITED_SESSION_SOURCES) {
|
|
4586
|
-
const handle = normalizeSessionId(env[candidate.envVar]);
|
|
4587
|
-
if (handle) {
|
|
4588
|
-
return { id: handle, source: candidate.source };
|
|
4589
|
-
}
|
|
4590
|
-
}
|
|
4591
|
-
return;
|
|
4592
|
-
}
|
|
4593
|
-
function generateRandomSession() {
|
|
4594
|
-
const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
|
|
4595
|
-
crypto.getRandomValues(bytes);
|
|
4596
|
-
let hex = "";
|
|
4597
|
-
for (const byte of bytes) {
|
|
4598
|
-
hex += byte.toString(16).padStart(2, "0");
|
|
4599
|
-
}
|
|
4600
|
-
return { id: hex, source: "random" };
|
|
4601
|
-
}
|
|
4602
|
-
function resolveTelemetrySession() {
|
|
4603
|
-
const existing = telemetrySessionSlot.get();
|
|
4604
|
-
if (existing) {
|
|
4605
|
-
return existing;
|
|
4606
|
-
}
|
|
4607
|
-
const declaredHandle = getConfiguredTelemetrySessionId();
|
|
4608
|
-
const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
|
|
4609
|
-
telemetrySessionSlot.set(resolved);
|
|
4610
|
-
return resolved;
|
|
4611
|
-
}
|
|
4612
|
-
function getTelemetrySessionId() {
|
|
4613
|
-
return resolveTelemetrySession().id;
|
|
4614
|
-
}
|
|
4615
|
-
function getTelemetrySessionSource() {
|
|
4616
|
-
return resolveTelemetrySession().source;
|
|
4617
|
-
}
|
|
4618
|
-
function getTelemetryOperationId() {
|
|
4619
|
-
const existing = telemetryOperationIdSlot.get();
|
|
4620
|
-
if (existing) {
|
|
4621
|
-
return existing;
|
|
4622
|
-
}
|
|
4623
|
-
const inboundTraceId = getInboundTraceContext()?.traceId;
|
|
4624
|
-
const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
|
|
4625
|
-
telemetryOperationIdSlot.set(generated);
|
|
4626
|
-
return generated;
|
|
4627
|
-
}
|
|
4628
|
-
// ../../common/src/telemetry/global-telemetry-properties.ts
|
|
4629
|
-
var telemetryPropsSlot = singleton("TelemetryDefaultProps");
|
|
4630
|
-
function getGlobalTelemetryProperties() {
|
|
4631
|
-
return telemetryPropsSlot.get();
|
|
4632
|
-
}
|
|
4633
|
-
|
|
4634
4678
|
// ../../common/src/telemetry/span-clock.ts
|
|
4635
4679
|
function startSpanClock() {
|
|
4636
4680
|
const started = performance.now();
|
|
@@ -4844,6 +4888,7 @@ var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
|
|
|
4844
4888
|
// ../../common/src/telemetry/telemetry-init.ts
|
|
4845
4889
|
var telemetryInstanceSlot = singleton("TelemetryService");
|
|
4846
4890
|
var DEFAULT_AI_CONNECTION_STRING = atob("SW5zdHJ1bWVudGF0aW9uS2V5PTliZDM3NDgyLTgxMGUtNDQyYS1hYWE2LWQzOGVmNjVjNjY3NDtJbmdlc3Rpb25FbmRwb2ludD1odHRwczovL3dlc3RldXJvcGUtNS5pbi5hcHBsaWNhdGlvbmluc2lnaHRzLmF6dXJlLmNvbS87TGl2ZUVuZHBvaW50PWh0dHBzOi8vd2VzdGV1cm9wZS5saXZlZGlhZ25vc3RpY3MubW9uaXRvci5henVyZS5jb20vO0FwcGxpY2F0aW9uSWQ9MzU2OTdlZjEtOGJkMC00ZjE5LWEyN2MtZDg3Y2NhYzY2ZDJj");
|
|
4891
|
+
var browserProviderSlot = singleton("BrowserAppInsightsTelemetryProvider");
|
|
4847
4892
|
function getGlobalTelemetryInstance() {
|
|
4848
4893
|
const existing = telemetryInstanceSlot.get();
|
|
4849
4894
|
if (existing && typeof existing === "object" && "trackEvent" in existing && typeof existing.trackEvent === "function") {
|
|
@@ -5027,7 +5072,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
|
|
|
5027
5072
|
const pagedRows = extractPagedRows(data.Data);
|
|
5028
5073
|
const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
|
|
5029
5074
|
items.forEach((item) => {
|
|
5030
|
-
const values = Object.values(item).map((v) => v ?? "").join("\t");
|
|
5075
|
+
const values = item === null || typeof item !== "object" ? String(item ?? "") : Object.values(item).map((v) => v ?? "").join("\t");
|
|
5031
5076
|
logFn(values);
|
|
5032
5077
|
});
|
|
5033
5078
|
} else {
|
|
@@ -5042,7 +5087,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
|
|
|
5042
5087
|
default: {
|
|
5043
5088
|
const hasData = "Data" in data && data.Data != null;
|
|
5044
5089
|
const pagedRows = hasData ? extractPagedRows(data.Data) : null;
|
|
5045
|
-
const
|
|
5090
|
+
const resolvedRows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
|
|
5091
|
+
const rows = resolvedRows && isPrimitiveArray(resolvedRows) ? resolvedRows.map((entry) => ({ Value: entry })) : resolvedRows;
|
|
5046
5092
|
if (hasData && !(rows !== null && rows.length === 0)) {
|
|
5047
5093
|
const logValue = data.Log;
|
|
5048
5094
|
if (rows !== null) {
|
|
@@ -5099,6 +5145,9 @@ function printTable(data, logFn, externalLogValue, tableRowStyle) {
|
|
|
5099
5145
|
function isPlainObjectArray(value) {
|
|
5100
5146
|
return Array.isArray(value) && value.length > 0 && value.every(isPlainRecord);
|
|
5101
5147
|
}
|
|
5148
|
+
function isPrimitiveArray(value) {
|
|
5149
|
+
return Array.isArray(value) && value.length > 0 && value.every((entry) => entry === null || typeof entry !== "object");
|
|
5150
|
+
}
|
|
5102
5151
|
function isNonEmptyPlainObject(value) {
|
|
5103
5152
|
return isPlainRecord(value) && Object.keys(value).length > 0;
|
|
5104
5153
|
}
|
|
@@ -5445,12 +5494,12 @@ class FilterEvaluationError extends Error {
|
|
|
5445
5494
|
instructions;
|
|
5446
5495
|
retry = "RetryWillNotFix";
|
|
5447
5496
|
result = RESULTS.ValidationError;
|
|
5448
|
-
constructor(filter, cause) {
|
|
5497
|
+
constructor(filter, cause, hint) {
|
|
5449
5498
|
const underlying = cause instanceof Error ? cause.message : String(cause);
|
|
5450
|
-
super(`Filter '${filter}' failed to evaluate: ${underlying}`);
|
|
5499
|
+
super(`Filter '${filter}' failed to evaluate: ${underlying}` + (hint ? ` ${hint.detail}` : ""));
|
|
5451
5500
|
this.name = "FilterEvaluationError";
|
|
5452
5501
|
this.filter = filter;
|
|
5453
|
-
this.instructions = `The --output-filter expression '${filter}' failed at evaluation time. ` + "Note that --output-filter operates on the 'Data' field of the envelope, not the full object. " + "For example, on a list result use 'length(@)' instead of 'Data | length(@)'.";
|
|
5502
|
+
this.instructions = (hint ? `${hint.instructions} ` : "") + `The --output-filter expression '${filter}' failed at evaluation time. ` + "Note that --output-filter operates on the 'Data' field of the envelope, not the full object. " + "For example, on a list result use 'length(@)' instead of 'Data | length(@)'.";
|
|
5454
5503
|
}
|
|
5455
5504
|
}
|
|
5456
5505
|
|
|
@@ -5572,6 +5621,93 @@ function nameList(names, cap = 12) {
|
|
|
5572
5621
|
const rest = names.length - shown.length;
|
|
5573
5622
|
return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
|
|
5574
5623
|
}
|
|
5624
|
+
function notFieldsOn(names, scope) {
|
|
5625
|
+
return `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
|
|
5626
|
+
}
|
|
5627
|
+
function failingFieldRead(ast, isList, fn, argIndex) {
|
|
5628
|
+
const [left, right, condition] = ast.children ?? [];
|
|
5629
|
+
let scopes = [];
|
|
5630
|
+
if (!isList) {
|
|
5631
|
+
scopes = [ast];
|
|
5632
|
+
} else if (ast.type === "FilterProjection" && left?.type === "Identity") {
|
|
5633
|
+
scopes = [condition, right];
|
|
5634
|
+
} else if (ast.type === "Projection" && (left?.type === "Identity" || left?.type === "Flatten" && left.children?.[0]?.type === "Identity")) {
|
|
5635
|
+
scopes = [right];
|
|
5636
|
+
}
|
|
5637
|
+
const reads = new Set;
|
|
5638
|
+
let tracked = 0;
|
|
5639
|
+
const visit = (node) => {
|
|
5640
|
+
if (!node)
|
|
5641
|
+
return;
|
|
5642
|
+
switch (node.type) {
|
|
5643
|
+
case "Function": {
|
|
5644
|
+
const arg = node.children?.[argIndex - 1];
|
|
5645
|
+
if (node.name === fn && arg?.type === "Field" && arg.name) {
|
|
5646
|
+
reads.add(arg.name);
|
|
5647
|
+
tracked++;
|
|
5648
|
+
}
|
|
5649
|
+
node.children?.forEach(visit);
|
|
5650
|
+
return;
|
|
5651
|
+
}
|
|
5652
|
+
case "AndExpression":
|
|
5653
|
+
case "OrExpression":
|
|
5654
|
+
case "NotExpression":
|
|
5655
|
+
case "Comparator":
|
|
5656
|
+
case "MultiSelectList":
|
|
5657
|
+
case "MultiSelectHash":
|
|
5658
|
+
node.children?.forEach(visit);
|
|
5659
|
+
return;
|
|
5660
|
+
case "KeyValuePair":
|
|
5661
|
+
visit(node.value);
|
|
5662
|
+
return;
|
|
5663
|
+
}
|
|
5664
|
+
};
|
|
5665
|
+
scopes.forEach(visit);
|
|
5666
|
+
const calls = (node) => {
|
|
5667
|
+
if (node === null || typeof node !== "object")
|
|
5668
|
+
return 0;
|
|
5669
|
+
const own = node.type === "Function" && node.name === fn ? 1 : 0;
|
|
5670
|
+
const next = node.type === "KeyValuePair" ? [node.value] : node.children ?? [];
|
|
5671
|
+
return own + next.reduce((sum, child) => sum + calls(child), 0);
|
|
5672
|
+
};
|
|
5673
|
+
return reads.size === 1 && tracked === calls(ast) ? [...reads][0] : undefined;
|
|
5674
|
+
}
|
|
5675
|
+
function fieldExpression(name) {
|
|
5676
|
+
return /^[A-Za-z_]\w*$/.test(name) ? name : JSON.stringify(name);
|
|
5677
|
+
}
|
|
5678
|
+
function evaluationHint(codec, filter, data, cause) {
|
|
5679
|
+
const underlying = cause instanceof Error ? cause.message : String(cause);
|
|
5680
|
+
const failure = /\b(\w+)\(\) expected argument (\d+) to be type (\S+) but received type null\b/.exec(underlying);
|
|
5681
|
+
if (!failure)
|
|
5682
|
+
return;
|
|
5683
|
+
const [, fn, position, expected] = failure;
|
|
5684
|
+
const name = failingFieldRead(codec.compile(filter), Array.isArray(data), fn, Number(position));
|
|
5685
|
+
if (name === undefined)
|
|
5686
|
+
return;
|
|
5687
|
+
const present = availableFields(data);
|
|
5688
|
+
if (present.length === 0)
|
|
5689
|
+
return;
|
|
5690
|
+
const scope = `${countRecords(data)} record(s)`;
|
|
5691
|
+
if (!present.includes(name)) {
|
|
5692
|
+
return {
|
|
5693
|
+
detail: `${notFieldsOn([name], scope)}. Available fields: ${nameList(present)}.`,
|
|
5694
|
+
instructions: "Use a field the records have; names are case-sensitive."
|
|
5695
|
+
};
|
|
5696
|
+
}
|
|
5697
|
+
const records = Array.isArray(data) ? data : [data];
|
|
5698
|
+
const unset = records.filter((r) => r?.[name] == null).length;
|
|
5699
|
+
const field = fieldExpression(name);
|
|
5700
|
+
let fallback;
|
|
5701
|
+
if (expected.split(",").includes("string")) {
|
|
5702
|
+
fallback = "''";
|
|
5703
|
+
} else if (expected.split(",").includes("array")) {
|
|
5704
|
+
fallback = "`[]`";
|
|
5705
|
+
}
|
|
5706
|
+
return {
|
|
5707
|
+
detail: `\`${name}\` is null or missing on ${unset} of the ${scope} it read.`,
|
|
5708
|
+
instructions: fallback ? `Give it a default where ${fn}() reads it, e.g. \`${field} || ${fallback}\`.` : `Filter out the records where \`${name}\` is null before ${fn}() reads it.`
|
|
5709
|
+
};
|
|
5710
|
+
}
|
|
5575
5711
|
function buildFilterWarning(filter, data, outcome) {
|
|
5576
5712
|
const present = availableFields(data);
|
|
5577
5713
|
const refs = referencedFields(filter);
|
|
@@ -5579,7 +5715,7 @@ function buildFilterWarning(filter, data, outcome) {
|
|
|
5579
5715
|
const unchecked = refs.nested.filter((name) => !present.includes(name));
|
|
5580
5716
|
const count = countRecords(data);
|
|
5581
5717
|
const scope = `${count} record(s)`;
|
|
5582
|
-
const isNotAField = (names) =>
|
|
5718
|
+
const isNotAField = (names) => notFieldsOn(names, scope);
|
|
5583
5719
|
const soundness = unchecked.length > 0 ? `${nameList(unchecked)} ${unchecked.length === 1 ? "reads" : "read"} below the top level, so ${unchecked.length === 1 ? "it was" : "they were"} not checked against the record keys` : refs.top.length > 0 ? "every field it names exists" : "";
|
|
5584
5720
|
const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
|
|
5585
5721
|
let detail;
|
|
@@ -5630,7 +5766,8 @@ function applyFilter(data, filter, onWarning) {
|
|
|
5630
5766
|
try {
|
|
5631
5767
|
result = codec.search(data, filter);
|
|
5632
5768
|
} catch (err) {
|
|
5633
|
-
|
|
5769
|
+
const [, hint] = catchError(() => evaluationHint(codec, filter, data, err));
|
|
5770
|
+
throw new FilterEvaluationError(filter, err, hint);
|
|
5634
5771
|
}
|
|
5635
5772
|
const inputCount = countRecords(data);
|
|
5636
5773
|
const warn = (outcome) => {
|
|
@@ -6521,7 +6658,7 @@ Command2.prototype.trackedAction = function(context, fn, properties) {
|
|
|
6521
6658
|
logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
|
|
6522
6659
|
const typed = error;
|
|
6523
6660
|
const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
|
|
6524
|
-
const customResult =
|
|
6661
|
+
const customResult = carriedResult(error);
|
|
6525
6662
|
const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
|
|
6526
6663
|
const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
|
|
6527
6664
|
const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
|
|
@@ -6883,6 +7020,8 @@ var FAILURE_STATUSES = new Set([
|
|
|
6883
7020
|
"canceled",
|
|
6884
7021
|
"stopped"
|
|
6885
7022
|
]);
|
|
7023
|
+
// ../../common/src/relayed-output.ts
|
|
7024
|
+
var RELAYED_OUTPUT_SYMBOL = Symbol.for("@uipath/common/relayed-output");
|
|
6886
7025
|
// ../../common/src/screen-logger.ts
|
|
6887
7026
|
var ScreenLogger;
|
|
6888
7027
|
((ScreenLogger) => {
|
|
@@ -6961,6 +7100,8 @@ function settlePromiseLike2(thenable) {
|
|
|
6961
7100
|
// ../../auth/src/constants.ts
|
|
6962
7101
|
var UIPATH_HOME_DIR = ".uipath";
|
|
6963
7102
|
var AUTH_FILENAME = ".auth";
|
|
7103
|
+
var AUTH_FILE_MODE = 384;
|
|
7104
|
+
var AUTH_DIR_MODE = 448;
|
|
6964
7105
|
var DEFAULT_BASE_URL = "https://cloud.uipath.com";
|
|
6965
7106
|
var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
|
|
6966
7107
|
|
|
@@ -7784,6 +7925,38 @@ var loadEnvFileAsync = async ({ envPath }) => {
|
|
|
7784
7925
|
}
|
|
7785
7926
|
return parseEnvContent(content);
|
|
7786
7927
|
};
|
|
7928
|
+
var findAuthHomeDir = (fs, dir) => {
|
|
7929
|
+
let current = dir;
|
|
7930
|
+
for (;; ) {
|
|
7931
|
+
if (fs.path.basename(current) === UIPATH_HOME_DIR)
|
|
7932
|
+
return current;
|
|
7933
|
+
const parent = fs.path.dirname(current);
|
|
7934
|
+
if (parent === current)
|
|
7935
|
+
return;
|
|
7936
|
+
current = parent;
|
|
7937
|
+
}
|
|
7938
|
+
};
|
|
7939
|
+
var TEMP_FILE_ATTEMPTS = 5;
|
|
7940
|
+
var isFileExists = (error) => error instanceof Error && error.code === "EEXIST";
|
|
7941
|
+
var writeTempFile = async (fs, targetPath, content) => {
|
|
7942
|
+
for (let attempt = 1;; attempt++) {
|
|
7943
|
+
const tempPath = `${targetPath}.${crypto.randomUUID()}.tmp`;
|
|
7944
|
+
try {
|
|
7945
|
+
await fs.writeFile(tempPath, content, {
|
|
7946
|
+
mode: AUTH_FILE_MODE,
|
|
7947
|
+
exclusive: true
|
|
7948
|
+
});
|
|
7949
|
+
return tempPath;
|
|
7950
|
+
} catch (error) {
|
|
7951
|
+
if (!isFileExists(error)) {
|
|
7952
|
+
await fs.rm(tempPath).catch(() => {});
|
|
7953
|
+
throw error;
|
|
7954
|
+
}
|
|
7955
|
+
if (attempt === TEMP_FILE_ATTEMPTS)
|
|
7956
|
+
throw error;
|
|
7957
|
+
}
|
|
7958
|
+
}
|
|
7959
|
+
};
|
|
7787
7960
|
var saveEnvFileAsync = async ({
|
|
7788
7961
|
envPath,
|
|
7789
7962
|
data,
|
|
@@ -7811,10 +7984,18 @@ var saveEnvFileAsync = async ({
|
|
|
7811
7984
|
`)}
|
|
7812
7985
|
`;
|
|
7813
7986
|
const dir = fs.path.dirname(absolutePath);
|
|
7814
|
-
await fs.mkdir(dir);
|
|
7815
|
-
const
|
|
7816
|
-
|
|
7817
|
-
|
|
7987
|
+
await fs.mkdir(dir, { mode: AUTH_DIR_MODE });
|
|
7988
|
+
const authHomeDir = findAuthHomeDir(fs, dir);
|
|
7989
|
+
if (authHomeDir !== undefined) {
|
|
7990
|
+
await fs.chmod?.(authHomeDir, AUTH_DIR_MODE);
|
|
7991
|
+
}
|
|
7992
|
+
const tempPath = await writeTempFile(fs, absolutePath, content);
|
|
7993
|
+
try {
|
|
7994
|
+
await fs.rename(tempPath, absolutePath);
|
|
7995
|
+
} catch (error) {
|
|
7996
|
+
await fs.rm(tempPath).catch(() => {});
|
|
7997
|
+
throw error;
|
|
7998
|
+
}
|
|
7818
7999
|
};
|
|
7819
8000
|
|
|
7820
8001
|
// ../../auth/src/loginStatus.ts
|
|
@@ -8912,4 +9093,4 @@ export {
|
|
|
8912
9093
|
registerCommands
|
|
8913
9094
|
};
|
|
8914
9095
|
|
|
8915
|
-
//# debugId=
|
|
9096
|
+
//# debugId=A1CB762BA582F1D364756E2164756E21
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@uipath/guardrails-tool",
|
|
3
3
|
"author": "UiPath",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.207.0-preview.305",
|
|
6
6
|
"description": "CLI plugin for UiPath AI Trust Layer guardrail configurations.",
|
|
7
7
|
"private": false,
|
|
8
8
|
"repository": {
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"files": [
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "1600aa89255c37c1b8bc68d9882c3395c1d5bff4"
|
|
28
28
|
}
|