@uipath/guardrails-tool 1.203.0-preview.205 → 1.204.0-preview.206
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tool.js +585 -54
- package/package.json +2 -2
package/dist/tool.js
CHANGED
|
@@ -2101,7 +2101,7 @@ var package_default = {
|
|
|
2101
2101
|
name: "@uipath/guardrails-tool",
|
|
2102
2102
|
author: "UiPath",
|
|
2103
2103
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
2104
|
-
version: "1.
|
|
2104
|
+
version: "1.204.0-preview.206",
|
|
2105
2105
|
description: "CLI plugin for UiPath AI Trust Layer guardrail configurations.",
|
|
2106
2106
|
private: false,
|
|
2107
2107
|
repository: {
|
|
@@ -2125,6 +2125,7 @@ var package_default = {
|
|
|
2125
2125
|
],
|
|
2126
2126
|
scripts: {
|
|
2127
2127
|
build: "bun ../../../tools/build-tool.ts",
|
|
2128
|
+
typecheck: "tsc --noEmit",
|
|
2128
2129
|
lint: "biome check .",
|
|
2129
2130
|
"lint:fix": "biome check --write .",
|
|
2130
2131
|
test: "vitest run",
|
|
@@ -2135,7 +2136,7 @@ var package_default = {
|
|
|
2135
2136
|
"@uipath/auth": "workspace:*",
|
|
2136
2137
|
"@uipath/common": "workspace:*",
|
|
2137
2138
|
commander: "^14.0.3",
|
|
2138
|
-
typescript: "^
|
|
2139
|
+
typescript: "^7.0.2"
|
|
2139
2140
|
}
|
|
2140
2141
|
};
|
|
2141
2142
|
|
|
@@ -2906,6 +2907,57 @@ function settlePromiseLike(thenable) {
|
|
|
2906
2907
|
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
|
|
2907
2908
|
}
|
|
2908
2909
|
|
|
2910
|
+
// ../../common/src/error-graph.ts
|
|
2911
|
+
function* walkErrorGraph(error) {
|
|
2912
|
+
const queue = [error];
|
|
2913
|
+
const seen = new Set;
|
|
2914
|
+
for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
|
|
2915
|
+
const current = queue.shift();
|
|
2916
|
+
if (current === null || typeof current !== "object")
|
|
2917
|
+
continue;
|
|
2918
|
+
if (seen.has(current))
|
|
2919
|
+
continue;
|
|
2920
|
+
seen.add(current);
|
|
2921
|
+
const cur = current;
|
|
2922
|
+
yield cur;
|
|
2923
|
+
if (cur.cause !== undefined)
|
|
2924
|
+
queue.push(cur.cause);
|
|
2925
|
+
if (Array.isArray(cur.errors))
|
|
2926
|
+
queue.push(...cur.errors);
|
|
2927
|
+
}
|
|
2928
|
+
return;
|
|
2929
|
+
}
|
|
2930
|
+
function parseHttpStatusFromMessage(message) {
|
|
2931
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
2932
|
+
if (!match)
|
|
2933
|
+
return;
|
|
2934
|
+
const status = Number(match[1]);
|
|
2935
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
2936
|
+
}
|
|
2937
|
+
function findHttpStatusInGraph(error) {
|
|
2938
|
+
for (const node of walkErrorGraph(error)) {
|
|
2939
|
+
const response = node.response;
|
|
2940
|
+
const explicit = typeof node.status === "number" ? node.status : response?.status;
|
|
2941
|
+
if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
|
|
2942
|
+
return explicit;
|
|
2943
|
+
}
|
|
2944
|
+
if (typeof node.message === "string") {
|
|
2945
|
+
const parsed = parseHttpStatusFromMessage(node.message);
|
|
2946
|
+
if (parsed !== undefined && parsed >= 400) {
|
|
2947
|
+
return parsed;
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2950
|
+
}
|
|
2951
|
+
return;
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
// ../../common/src/local-permission-codes.ts
|
|
2955
|
+
var LOCAL_PERMISSION_ERROR_CODES = new Set([
|
|
2956
|
+
"EACCES",
|
|
2957
|
+
"EPERM",
|
|
2958
|
+
"EROFS"
|
|
2959
|
+
]);
|
|
2960
|
+
|
|
2909
2961
|
// ../../common/src/error-handler.ts
|
|
2910
2962
|
var NETWORK_ERROR_CODES = new Set([
|
|
2911
2963
|
"ECONNREFUSED",
|
|
@@ -2930,7 +2982,7 @@ var TLS_ERROR_CODES = new Set([
|
|
|
2930
2982
|
]);
|
|
2931
2983
|
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.";
|
|
2932
2984
|
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.";
|
|
2933
|
-
var
|
|
2985
|
+
var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
|
|
2934
2986
|
// ../../common/src/exit-code.ts
|
|
2935
2987
|
function setExitCode(code) {
|
|
2936
2988
|
process.exitCode = code;
|
|
@@ -3189,12 +3241,162 @@ function getOutputFilter() {
|
|
|
3189
3241
|
return filterSlot.get();
|
|
3190
3242
|
}
|
|
3191
3243
|
|
|
3244
|
+
// ../../common/src/telemetry/telemetry-dimensions.ts
|
|
3245
|
+
var BaseDimensions = {
|
|
3246
|
+
ApplicationName: "ApplicationName",
|
|
3247
|
+
ProductVersion: "ProductVersion",
|
|
3248
|
+
InstallationId: "InstallationId",
|
|
3249
|
+
CloudUserId: "CloudUserId",
|
|
3250
|
+
CloudTenantId: "CloudTenantId",
|
|
3251
|
+
CloudOrganizationId: "CloudOrganizationId",
|
|
3252
|
+
IsInternalUser: "IsInternalUser",
|
|
3253
|
+
Environment: "Environment",
|
|
3254
|
+
BaseUrl: "BaseUrl",
|
|
3255
|
+
Region: "Region",
|
|
3256
|
+
Agent: "Agent",
|
|
3257
|
+
AgentVersion: "AgentVersion",
|
|
3258
|
+
AgentModel: "AgentModel",
|
|
3259
|
+
ToolName: "ToolName",
|
|
3260
|
+
ToolVersion: "ToolVersion",
|
|
3261
|
+
ExecutionContext: "ExecutionContext",
|
|
3262
|
+
CiProvider: "CiProvider",
|
|
3263
|
+
SessionIdSource: "SessionIdSource",
|
|
3264
|
+
SessionId: "SessionId"
|
|
3265
|
+
};
|
|
3266
|
+
var CommandDimensions = {
|
|
3267
|
+
IsCommand: "IsCommand",
|
|
3268
|
+
IsReexec: "IsReexec",
|
|
3269
|
+
CommandName: "CommandName",
|
|
3270
|
+
ExitCode: "ExitCode",
|
|
3271
|
+
TerminalOutcome: "TerminalOutcome",
|
|
3272
|
+
ErrorClass: "ErrorClass",
|
|
3273
|
+
TerminalSignal: "TerminalSignal",
|
|
3274
|
+
ErrorMessage: "ErrorMessage",
|
|
3275
|
+
SkillName: "SkillName",
|
|
3276
|
+
ProductArea: "ProductArea",
|
|
3277
|
+
Mode: "Mode"
|
|
3278
|
+
};
|
|
3279
|
+
var ShipDimensions = {
|
|
3280
|
+
ShipKind: "ShipKind",
|
|
3281
|
+
Target: "Target",
|
|
3282
|
+
ProjectType: "ProjectType",
|
|
3283
|
+
ProjectTypes: "ProjectTypes",
|
|
3284
|
+
ArtifactCorrelationKey: "ArtifactCorrelationKey",
|
|
3285
|
+
PackageName: "PackageName",
|
|
3286
|
+
PackageVersion: "PackageVersion",
|
|
3287
|
+
PackageVersionKey: "PackageVersionKey",
|
|
3288
|
+
DeploymentKey: "DeploymentKey",
|
|
3289
|
+
SolutionId: "SolutionId",
|
|
3290
|
+
FolderKey: "FolderKey",
|
|
3291
|
+
FeedId: "FeedId"
|
|
3292
|
+
};
|
|
3293
|
+
var ErrorDimensions = {
|
|
3294
|
+
Result: "Result",
|
|
3295
|
+
ErrorCode: "ErrorCode",
|
|
3296
|
+
Retry: "Retry",
|
|
3297
|
+
ErrorMessage: "ErrorMessage"
|
|
3298
|
+
};
|
|
3299
|
+
var AuthDimensions = {
|
|
3300
|
+
AuthenticationMethod: "AuthenticationMethod",
|
|
3301
|
+
Success: "Success",
|
|
3302
|
+
Reason: "Reason"
|
|
3303
|
+
};
|
|
3304
|
+
var SkillsDimensions = {
|
|
3305
|
+
SchemaVersion: "SchemaVersion",
|
|
3306
|
+
AgentType: "AgentType",
|
|
3307
|
+
SkillsVersion: "SkillsVersion",
|
|
3308
|
+
UipSubcommand: "UipSubcommand",
|
|
3309
|
+
FileExtension: "FileExtension",
|
|
3310
|
+
SubagentModel: "SubagentModel",
|
|
3311
|
+
SubagentType: "SubagentType",
|
|
3312
|
+
PermissionMode: "PermissionMode",
|
|
3313
|
+
EffortLevel: "EffortLevel",
|
|
3314
|
+
SessionSource: "SessionSource",
|
|
3315
|
+
Outcome: "Outcome",
|
|
3316
|
+
DurationMs: "DurationMs",
|
|
3317
|
+
Source: "Source"
|
|
3318
|
+
};
|
|
3319
|
+
var PackagerDimensions = {
|
|
3320
|
+
ProjectId: "ProjectId",
|
|
3321
|
+
ProjectType: "ProjectType",
|
|
3322
|
+
SolutionId: "SolutionId"
|
|
3323
|
+
};
|
|
3324
|
+
var ScopeDimensions = {
|
|
3325
|
+
FolderId: "FolderId"
|
|
3326
|
+
};
|
|
3327
|
+
var ID_DIMENSIONS = new Set([
|
|
3328
|
+
BaseDimensions.CloudUserId,
|
|
3329
|
+
BaseDimensions.CloudTenantId,
|
|
3330
|
+
BaseDimensions.CloudOrganizationId,
|
|
3331
|
+
BaseDimensions.InstallationId,
|
|
3332
|
+
ShipDimensions.ArtifactCorrelationKey,
|
|
3333
|
+
ShipDimensions.PackageVersionKey,
|
|
3334
|
+
ShipDimensions.DeploymentKey,
|
|
3335
|
+
ShipDimensions.SolutionId,
|
|
3336
|
+
ShipDimensions.FolderKey,
|
|
3337
|
+
ShipDimensions.FeedId,
|
|
3338
|
+
PackagerDimensions.ProjectId
|
|
3339
|
+
]);
|
|
3340
|
+
var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
|
|
3341
|
+
var RESERVED_DIMENSION_NAMES = new Set([
|
|
3342
|
+
...Object.values(BaseDimensions),
|
|
3343
|
+
...Object.values(CommandDimensions),
|
|
3344
|
+
...Object.values(ShipDimensions),
|
|
3345
|
+
...Object.values(ErrorDimensions),
|
|
3346
|
+
...Object.values(AuthDimensions),
|
|
3347
|
+
...Object.values(SkillsDimensions),
|
|
3348
|
+
...Object.values(PackagerDimensions),
|
|
3349
|
+
...Object.values(ScopeDimensions)
|
|
3350
|
+
]);
|
|
3351
|
+
var CURATED_DIMENSIONS = new Set([
|
|
3352
|
+
BaseDimensions.ApplicationName,
|
|
3353
|
+
BaseDimensions.ProductVersion,
|
|
3354
|
+
BaseDimensions.InstallationId,
|
|
3355
|
+
BaseDimensions.CloudUserId,
|
|
3356
|
+
BaseDimensions.CloudTenantId,
|
|
3357
|
+
BaseDimensions.CloudOrganizationId,
|
|
3358
|
+
BaseDimensions.IsInternalUser,
|
|
3359
|
+
BaseDimensions.Environment,
|
|
3360
|
+
BaseDimensions.BaseUrl,
|
|
3361
|
+
BaseDimensions.Region,
|
|
3362
|
+
BaseDimensions.Agent,
|
|
3363
|
+
BaseDimensions.AgentVersion,
|
|
3364
|
+
BaseDimensions.ToolVersion,
|
|
3365
|
+
BaseDimensions.ExecutionContext,
|
|
3366
|
+
BaseDimensions.CiProvider,
|
|
3367
|
+
BaseDimensions.SessionIdSource,
|
|
3368
|
+
BaseDimensions.SessionId,
|
|
3369
|
+
...Object.values(CommandDimensions),
|
|
3370
|
+
...Object.values(ShipDimensions)
|
|
3371
|
+
]);
|
|
3372
|
+
function lowercaseIdDimensionValues(properties) {
|
|
3373
|
+
let changed = false;
|
|
3374
|
+
const result = {
|
|
3375
|
+
...properties
|
|
3376
|
+
};
|
|
3377
|
+
for (const key of Object.keys(result)) {
|
|
3378
|
+
const value = result[key];
|
|
3379
|
+
if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
|
|
3380
|
+
continue;
|
|
3381
|
+
}
|
|
3382
|
+
const lowered = value.toLowerCase();
|
|
3383
|
+
if (lowered !== value) {
|
|
3384
|
+
result[key] = lowered;
|
|
3385
|
+
changed = true;
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
return changed ? result : properties;
|
|
3389
|
+
}
|
|
3390
|
+
|
|
3192
3391
|
// ../../common/src/telemetry/command-terminal.ts
|
|
3193
3392
|
var recordedFailureSlot = singleton("CommandTelemetryFailure");
|
|
3194
3393
|
var AUTH_ERROR_CODES = new Set([
|
|
3195
3394
|
"authentication_required",
|
|
3196
3395
|
"permission_denied"
|
|
3197
3396
|
]);
|
|
3397
|
+
var LOCAL_PERMISSION_CLI_ERROR_CODES = new Set([
|
|
3398
|
+
"local_permission_denied"
|
|
3399
|
+
]);
|
|
3198
3400
|
var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
|
|
3199
3401
|
var NETWORK_HTTP_ERROR_CODES = new Set([
|
|
3200
3402
|
"network_error",
|
|
@@ -3335,6 +3537,9 @@ function classifyFromErrorCode(errorCode) {
|
|
|
3335
3537
|
if (AUTH_ERROR_CODES.has(errorCode)) {
|
|
3336
3538
|
return "auth";
|
|
3337
3539
|
}
|
|
3540
|
+
if (LOCAL_PERMISSION_CLI_ERROR_CODES.has(errorCode)) {
|
|
3541
|
+
return "local_permission";
|
|
3542
|
+
}
|
|
3338
3543
|
if (VALIDATION_ERROR_CODES.has(errorCode)) {
|
|
3339
3544
|
return "validation";
|
|
3340
3545
|
}
|
|
@@ -3346,6 +3551,15 @@ function classifyFromErrorCode(errorCode) {
|
|
|
3346
3551
|
}
|
|
3347
3552
|
return;
|
|
3348
3553
|
}
|
|
3554
|
+
function hasLocalPermissionCode(error) {
|
|
3555
|
+
for (const node of walkErrorGraph(error)) {
|
|
3556
|
+
const code = node.code;
|
|
3557
|
+
if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
|
|
3558
|
+
return true;
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3561
|
+
return false;
|
|
3562
|
+
}
|
|
3349
3563
|
function classifyFromError(error) {
|
|
3350
3564
|
const code = findCodeInCauseChain(error);
|
|
3351
3565
|
if (code) {
|
|
@@ -3362,6 +3576,9 @@ function classifyFromError(error) {
|
|
|
3362
3576
|
return "missing_dependency";
|
|
3363
3577
|
}
|
|
3364
3578
|
}
|
|
3579
|
+
if (hasLocalPermissionCode(error)) {
|
|
3580
|
+
return "local_permission";
|
|
3581
|
+
}
|
|
3365
3582
|
const message = stringField(error, "message");
|
|
3366
3583
|
if (message?.includes("fetch failed") === true) {
|
|
3367
3584
|
return "network_http";
|
|
@@ -3377,7 +3594,7 @@ function classifyError(input) {
|
|
|
3377
3594
|
if (recorded?.errorClass) {
|
|
3378
3595
|
return recorded.errorClass;
|
|
3379
3596
|
}
|
|
3380
|
-
const status = recorded?.context?.httpStatus;
|
|
3597
|
+
const status = recorded?.context?.httpStatus ?? findHttpStatusInGraph(input.error);
|
|
3381
3598
|
if (status !== undefined) {
|
|
3382
3599
|
return classifyHttpStatus(status);
|
|
3383
3600
|
}
|
|
@@ -3400,17 +3617,18 @@ function buildCommandTerminalTelemetryProperties(input) {
|
|
|
3400
3617
|
const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError(input);
|
|
3401
3618
|
const terminalSignal = terminalSignalFor(input, outcome);
|
|
3402
3619
|
return {
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
...errorClass ? {
|
|
3406
|
-
...terminalSignal ? {
|
|
3620
|
+
[CommandDimensions.ExitCode]: input.exitCode,
|
|
3621
|
+
[CommandDimensions.TerminalOutcome]: outcome,
|
|
3622
|
+
...errorClass ? { [CommandDimensions.ErrorClass]: errorClass } : {},
|
|
3623
|
+
...terminalSignal ? { [CommandDimensions.TerminalSignal]: terminalSignal } : {}
|
|
3407
3624
|
};
|
|
3408
3625
|
}
|
|
3409
3626
|
|
|
3410
3627
|
// ../../common/src/telemetry/telemetry-events.ts
|
|
3411
3628
|
var CommonTelemetryEvents = {
|
|
3412
|
-
|
|
3413
|
-
|
|
3629
|
+
Start: "Application.Start",
|
|
3630
|
+
Error: "Application.Error",
|
|
3631
|
+
ShipSucceeded: "Cli.ShipSucceeded"
|
|
3414
3632
|
};
|
|
3415
3633
|
|
|
3416
3634
|
// ../../common/src/registry.ts
|
|
@@ -3618,8 +3836,8 @@ function detectExecutionContext(options = {}) {
|
|
|
3618
3836
|
function getExecutionContextTelemetryProperties() {
|
|
3619
3837
|
const detected = detectExecutionContext();
|
|
3620
3838
|
return {
|
|
3621
|
-
|
|
3622
|
-
...detected.ciProvider ? {
|
|
3839
|
+
[BaseDimensions.ExecutionContext]: detected.executionContext,
|
|
3840
|
+
...detected.ciProvider ? { [BaseDimensions.CiProvider]: detected.ciProvider } : {}
|
|
3623
3841
|
};
|
|
3624
3842
|
}
|
|
3625
3843
|
// ../../common/src/telemetry/node-context-storage.ts
|
|
@@ -3662,7 +3880,7 @@ function getInboundTraceContext() {
|
|
|
3662
3880
|
var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
|
|
3663
3881
|
var SESSION_ID_MAX_LENGTH = 64;
|
|
3664
3882
|
var RANDOM_SESSION_ID_LENGTH = 32;
|
|
3665
|
-
var TELEMETRY_SESSION_SOURCE_PROPERTY = "
|
|
3883
|
+
var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
|
|
3666
3884
|
var CONTROL_CHARACTERS = /\p{Cc}/gu;
|
|
3667
3885
|
var INHERITED_SESSION_SOURCES = [
|
|
3668
3886
|
{ envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
|
|
@@ -3714,6 +3932,9 @@ function resolveTelemetrySession() {
|
|
|
3714
3932
|
telemetrySessionSlot.set(resolved);
|
|
3715
3933
|
return resolved;
|
|
3716
3934
|
}
|
|
3935
|
+
function getTelemetrySessionId() {
|
|
3936
|
+
return resolveTelemetrySession().id;
|
|
3937
|
+
}
|
|
3717
3938
|
function getTelemetrySessionSource() {
|
|
3718
3939
|
return resolveTelemetrySession().source;
|
|
3719
3940
|
}
|
|
@@ -3794,7 +4015,10 @@ class TelemetryService {
|
|
|
3794
4015
|
} catch (error) {
|
|
3795
4016
|
const durationMs = clock.elapsedMs();
|
|
3796
4017
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
3797
|
-
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, {
|
|
4018
|
+
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, {
|
|
4019
|
+
...properties,
|
|
4020
|
+
[CommandDimensions.ErrorMessage]: err.message
|
|
4021
|
+
}, context));
|
|
3798
4022
|
throw error;
|
|
3799
4023
|
}
|
|
3800
4024
|
}
|
|
@@ -3865,7 +4089,10 @@ class TelemetryService {
|
|
|
3865
4089
|
const durationMs = clock.elapsedMs();
|
|
3866
4090
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
3867
4091
|
await this.telemetryProvider.trackDependency({
|
|
3868
|
-
...this.spanFor(name, durationMs, false, {
|
|
4092
|
+
...this.spanFor(name, durationMs, false, {
|
|
4093
|
+
...properties,
|
|
4094
|
+
[CommandDimensions.ErrorMessage]: err.message
|
|
4095
|
+
}, childContext),
|
|
3869
4096
|
type
|
|
3870
4097
|
});
|
|
3871
4098
|
throw error;
|
|
@@ -3900,9 +4127,10 @@ class TelemetryService {
|
|
|
3900
4127
|
...globalProperties,
|
|
3901
4128
|
...this.defaultProperties,
|
|
3902
4129
|
...redactProperties(properties ?? {}),
|
|
3903
|
-
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
|
|
4130
|
+
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
|
|
4131
|
+
[BaseDimensions.SessionId]: this.telemetryProvider.getSessionId?.() ?? getTelemetrySessionId()
|
|
3904
4132
|
};
|
|
3905
|
-
return enriched;
|
|
4133
|
+
return lowercaseIdDimensionValues(enriched);
|
|
3906
4134
|
}
|
|
3907
4135
|
generateId() {
|
|
3908
4136
|
const bytes = new Uint8Array(8);
|
|
@@ -4663,7 +4891,165 @@ class FilterImplicitLimitError extends Error {
|
|
|
4663
4891
|
this.instructions = "Pass --limit <n> to choose how many records the filter applies to. " + "To filter over all records, pass the command's maximum accepted --limit (see the option's description in --help).";
|
|
4664
4892
|
}
|
|
4665
4893
|
}
|
|
4666
|
-
function
|
|
4894
|
+
function countRecords(data) {
|
|
4895
|
+
if (Array.isArray(data))
|
|
4896
|
+
return data.length;
|
|
4897
|
+
return data == null ? 0 : 1;
|
|
4898
|
+
}
|
|
4899
|
+
function availableFields(data) {
|
|
4900
|
+
const records = Array.isArray(data) ? data : [data];
|
|
4901
|
+
const keys = new Set;
|
|
4902
|
+
for (const record of records) {
|
|
4903
|
+
if (record && typeof record === "object" && !Array.isArray(record)) {
|
|
4904
|
+
for (const key of Object.keys(record))
|
|
4905
|
+
keys.add(key);
|
|
4906
|
+
}
|
|
4907
|
+
}
|
|
4908
|
+
return [...keys];
|
|
4909
|
+
}
|
|
4910
|
+
function decodeQuotedIdentifier(whole, inner) {
|
|
4911
|
+
const [error, decoded] = catchError(() => JSON.parse(whole));
|
|
4912
|
+
if (!error && typeof decoded === "string")
|
|
4913
|
+
return decoded;
|
|
4914
|
+
return inner.replace(/\\(.)/g, "$1");
|
|
4915
|
+
}
|
|
4916
|
+
function referencedFields(filter) {
|
|
4917
|
+
const top = new Set;
|
|
4918
|
+
const nested = new Set;
|
|
4919
|
+
const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
|
|
4920
|
+
const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
|
|
4921
|
+
const quoted = [];
|
|
4922
|
+
const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
|
|
4923
|
+
const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
|
|
4924
|
+
if (!isAlias) {
|
|
4925
|
+
quoted.push({
|
|
4926
|
+
name: decodeQuotedIdentifier(whole, name),
|
|
4927
|
+
index,
|
|
4928
|
+
tail: isPathTail(withoutValueLiterals, index)
|
|
4929
|
+
});
|
|
4930
|
+
}
|
|
4931
|
+
return `"${" ".repeat(whole.length - 2)}"`;
|
|
4932
|
+
});
|
|
4933
|
+
const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
|
|
4934
|
+
const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
|
|
4935
|
+
const place = (name, index, tail) => {
|
|
4936
|
+
if (tail || index >= rootEnd)
|
|
4937
|
+
nested.add(name);
|
|
4938
|
+
else
|
|
4939
|
+
top.add(name);
|
|
4940
|
+
};
|
|
4941
|
+
for (const entry of quoted)
|
|
4942
|
+
place(entry.name, entry.index, entry.tail);
|
|
4943
|
+
const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
|
|
4944
|
+
const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
|
|
4945
|
+
for (const match of identifiers) {
|
|
4946
|
+
const [, name, trailing] = match;
|
|
4947
|
+
if (trailing || reserved.has(name))
|
|
4948
|
+
continue;
|
|
4949
|
+
place(name, match.index, isPathTail(withoutLiterals, match.index));
|
|
4950
|
+
}
|
|
4951
|
+
return {
|
|
4952
|
+
top: [...top],
|
|
4953
|
+
nested: [...nested].filter((name) => !top.has(name)),
|
|
4954
|
+
hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
|
|
4955
|
+
};
|
|
4956
|
+
}
|
|
4957
|
+
function appearsBelowTopLevel(data, name) {
|
|
4958
|
+
let budget = 2000;
|
|
4959
|
+
const visit = (value, depth) => {
|
|
4960
|
+
if (budget-- <= 0 || depth > 4)
|
|
4961
|
+
return false;
|
|
4962
|
+
if (value === null || typeof value !== "object")
|
|
4963
|
+
return false;
|
|
4964
|
+
if (Array.isArray(value))
|
|
4965
|
+
return value.some((entry) => visit(entry, depth));
|
|
4966
|
+
const record = value;
|
|
4967
|
+
if (depth > 0 && Object.hasOwn(record, name))
|
|
4968
|
+
return true;
|
|
4969
|
+
return Object.values(record).some((entry) => visit(entry, depth + 1));
|
|
4970
|
+
};
|
|
4971
|
+
return visit(data, 0);
|
|
4972
|
+
}
|
|
4973
|
+
function alwaysNullKeys(records) {
|
|
4974
|
+
const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
|
|
4975
|
+
if (objects.length === 0 || objects.length !== records.length)
|
|
4976
|
+
return [];
|
|
4977
|
+
const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
|
|
4978
|
+
if (keys.length === 0)
|
|
4979
|
+
return [];
|
|
4980
|
+
const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
|
|
4981
|
+
return nullKeys.length === keys.length ? nullKeys : [];
|
|
4982
|
+
}
|
|
4983
|
+
function carriesOnlyNulls(value) {
|
|
4984
|
+
if (value === null)
|
|
4985
|
+
return true;
|
|
4986
|
+
if (Array.isArray(value)) {
|
|
4987
|
+
return value.length > 0 && value.every(carriesOnlyNulls);
|
|
4988
|
+
}
|
|
4989
|
+
if (typeof value === "object" && value !== undefined) {
|
|
4990
|
+
const values = Object.values(value);
|
|
4991
|
+
return values.length > 0 && values.every(carriesOnlyNulls);
|
|
4992
|
+
}
|
|
4993
|
+
return false;
|
|
4994
|
+
}
|
|
4995
|
+
function nameList(names, cap2 = 12) {
|
|
4996
|
+
const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
|
|
4997
|
+
const rest = names.length - shown.length;
|
|
4998
|
+
return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
|
|
4999
|
+
}
|
|
5000
|
+
function buildFilterWarning(filter, data, outcome) {
|
|
5001
|
+
const present = availableFields(data);
|
|
5002
|
+
const refs = referencedFields(filter);
|
|
5003
|
+
const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
|
|
5004
|
+
const unchecked = refs.nested.filter((name) => !present.includes(name));
|
|
5005
|
+
const count = countRecords(data);
|
|
5006
|
+
const scope = `${count} record(s)`;
|
|
5007
|
+
const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
|
|
5008
|
+
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" : "";
|
|
5009
|
+
const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
|
|
5010
|
+
let detail;
|
|
5011
|
+
let lede;
|
|
5012
|
+
if (outcome.kind === "null-elements") {
|
|
5013
|
+
lede = "returned only null values";
|
|
5014
|
+
const projected = `all ${outcome.count} of the elements it projected are null`;
|
|
5015
|
+
if (unknown.length > 0) {
|
|
5016
|
+
detail = `${projected}, because ${isNotAField(unknown)}`;
|
|
5017
|
+
} else if (unchecked.length > 0) {
|
|
5018
|
+
detail = withSoundness(projected);
|
|
5019
|
+
} else {
|
|
5020
|
+
detail = `${projected}, and every field it names exists — a multi-select list ` + `(\`[A, B]\`) reads each entry against \`Data\` itself, so on a list ` + `result use \`[].[A, B]\` or \`[].{a: A, b: B}\` to read the records`;
|
|
5021
|
+
}
|
|
5022
|
+
} else if (outcome.kind === "null-rows") {
|
|
5023
|
+
lede = "returned only null values";
|
|
5024
|
+
const projected = `every value it projected is null on all ${outcome.count} row(s)`;
|
|
5025
|
+
detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
|
|
5026
|
+
} else if (outcome.kind === "null-values") {
|
|
5027
|
+
lede = "returned only null values";
|
|
5028
|
+
const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
|
|
5029
|
+
const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
|
|
5030
|
+
if (sameSet) {
|
|
5031
|
+
detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
|
|
5032
|
+
} else if (unknown.length > 0) {
|
|
5033
|
+
detail = `${projected}, because ${isNotAField(unknown)}`;
|
|
5034
|
+
} else {
|
|
5035
|
+
detail = withSoundness(`${projected} on all ${scope}`);
|
|
5036
|
+
}
|
|
5037
|
+
} else {
|
|
5038
|
+
lede = "returned nothing";
|
|
5039
|
+
if (unknown.length > 0) {
|
|
5040
|
+
detail = isNotAField(unknown);
|
|
5041
|
+
} else {
|
|
5042
|
+
const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
|
|
5043
|
+
detail = withSoundness(`${selection} — it read ${scope}`);
|
|
5044
|
+
}
|
|
5045
|
+
}
|
|
5046
|
+
const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
|
|
5047
|
+
return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
|
|
5048
|
+
}
|
|
5049
|
+
function appendWarning(existing, note) {
|
|
5050
|
+
return existing ? `${existing} ${note}` : note;
|
|
5051
|
+
}
|
|
5052
|
+
function applyFilter(data, filter, onWarning) {
|
|
4667
5053
|
const codec = requireJmespath();
|
|
4668
5054
|
let result;
|
|
4669
5055
|
try {
|
|
@@ -4671,9 +5057,34 @@ function applyFilter(data, filter) {
|
|
|
4671
5057
|
} catch (err) {
|
|
4672
5058
|
throw new FilterEvaluationError(filter, err);
|
|
4673
5059
|
}
|
|
4674
|
-
|
|
5060
|
+
const inputCount = countRecords(data);
|
|
5061
|
+
const warn = (outcome) => {
|
|
5062
|
+
if (inputCount === 0)
|
|
5063
|
+
return;
|
|
5064
|
+
const note = buildFilterWarning(filter, data, outcome);
|
|
5065
|
+
getOutputSink().writeErr(`[WARN] ${note}
|
|
5066
|
+
`);
|
|
5067
|
+
onWarning?.(note);
|
|
5068
|
+
};
|
|
5069
|
+
const warnIfAllNull = (records) => {
|
|
5070
|
+
const keys = alwaysNullKeys(records);
|
|
5071
|
+
if (keys.length > 0)
|
|
5072
|
+
warn({ kind: "null-values", keys });
|
|
5073
|
+
};
|
|
5074
|
+
if (result == null) {
|
|
5075
|
+
warn({ kind: "empty" });
|
|
4675
5076
|
return [];
|
|
5077
|
+
}
|
|
4676
5078
|
if (Array.isArray(result)) {
|
|
5079
|
+
if (result.length === 0) {
|
|
5080
|
+
warn({ kind: "empty" });
|
|
5081
|
+
} else if (result.every((entry) => entry === null)) {
|
|
5082
|
+
warn({ kind: "null-elements", count: result.length });
|
|
5083
|
+
} else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
|
|
5084
|
+
warn({ kind: "null-rows", count: result.length });
|
|
5085
|
+
} else {
|
|
5086
|
+
warnIfAllNull(result);
|
|
5087
|
+
}
|
|
4677
5088
|
if (result.length > 0 && typeof result[0] !== "object") {
|
|
4678
5089
|
const fieldMatch = filter.match(/\.(\w+)$/);
|
|
4679
5090
|
const key = fieldMatch ? fieldMatch[1] : "Value";
|
|
@@ -4681,10 +5092,30 @@ function applyFilter(data, filter) {
|
|
|
4681
5092
|
}
|
|
4682
5093
|
return result;
|
|
4683
5094
|
}
|
|
4684
|
-
if (typeof result === "object")
|
|
5095
|
+
if (typeof result === "object") {
|
|
5096
|
+
warnIfAllNull([result]);
|
|
4685
5097
|
return result;
|
|
5098
|
+
}
|
|
4686
5099
|
return { Value: result };
|
|
4687
5100
|
}
|
|
5101
|
+
function filterFailureData(envelope) {
|
|
5102
|
+
const filter = getOutputFilter();
|
|
5103
|
+
const data = envelope.Data;
|
|
5104
|
+
if (!filter || data == null)
|
|
5105
|
+
return;
|
|
5106
|
+
let note;
|
|
5107
|
+
const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
|
|
5108
|
+
note = n;
|
|
5109
|
+
}));
|
|
5110
|
+
if (filterError) {
|
|
5111
|
+
envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
|
|
5112
|
+
return;
|
|
5113
|
+
}
|
|
5114
|
+
envelope.Data = filtered;
|
|
5115
|
+
if (note) {
|
|
5116
|
+
envelope.Warning = appendWarning(envelope.Warning, note);
|
|
5117
|
+
}
|
|
5118
|
+
}
|
|
4688
5119
|
function defaultErrorCodeForResult(result) {
|
|
4689
5120
|
switch (result) {
|
|
4690
5121
|
case RESULTS.AuthenticationError:
|
|
@@ -4699,7 +5130,7 @@ function defaultErrorCodeForResult(result) {
|
|
|
4699
5130
|
return "unknown_error";
|
|
4700
5131
|
}
|
|
4701
5132
|
}
|
|
4702
|
-
function
|
|
5133
|
+
function parseHttpStatusFromMessage2(message) {
|
|
4703
5134
|
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
4704
5135
|
if (!match)
|
|
4705
5136
|
return;
|
|
@@ -4728,10 +5159,10 @@ function defaultErrorCodeForHttpStatus(status) {
|
|
|
4728
5159
|
return "server_error";
|
|
4729
5160
|
return;
|
|
4730
5161
|
}
|
|
4731
|
-
var LOCAL_PERMISSION_TEXT_PATTERN =
|
|
5162
|
+
var LOCAL_PERMISSION_TEXT_PATTERN = new RegExp(`(?:\\b|\\()(?:${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})(?::\\s|\\))`);
|
|
4732
5163
|
function defaultErrorCodeForFailure(data) {
|
|
4733
5164
|
if (data.Result === RESULTS.Failure) {
|
|
4734
|
-
const status = data.Context?.httpStatus ??
|
|
5165
|
+
const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
|
|
4735
5166
|
const errorCode = defaultErrorCodeForHttpStatus(status);
|
|
4736
5167
|
if (errorCode)
|
|
4737
5168
|
return errorCode;
|
|
@@ -4767,8 +5198,14 @@ var OutputFormatter;
|
|
|
4767
5198
|
}
|
|
4768
5199
|
const filter = getOutputFilter();
|
|
4769
5200
|
if (filter) {
|
|
4770
|
-
|
|
5201
|
+
let note;
|
|
5202
|
+
const filtered = applyFilter(data.Data, filter, (n) => {
|
|
5203
|
+
note = n;
|
|
5204
|
+
});
|
|
4771
5205
|
data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
|
|
5206
|
+
if (note) {
|
|
5207
|
+
data.Warning = appendWarning(data.Warning, note);
|
|
5208
|
+
}
|
|
4772
5209
|
}
|
|
4773
5210
|
logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
|
|
4774
5211
|
}
|
|
@@ -4796,12 +5233,13 @@ var OutputFormatter;
|
|
|
4796
5233
|
delete envelope.TelemetryErrorClass;
|
|
4797
5234
|
delete envelope.TelemetryTerminalOutcome;
|
|
4798
5235
|
delete envelope.TelemetryTerminalSignal;
|
|
5236
|
+
filterFailureData(envelope);
|
|
4799
5237
|
if (!suppressTelemetry) {
|
|
4800
5238
|
telemetry.trackEvent(CommonTelemetryEvents.Error, {
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
5239
|
+
[ErrorDimensions.Result]: data.Result,
|
|
5240
|
+
[ErrorDimensions.ErrorCode]: data.ErrorCode,
|
|
5241
|
+
[ErrorDimensions.Retry]: data.Retry,
|
|
5242
|
+
[ErrorDimensions.ErrorMessage]: data.Message
|
|
4805
5243
|
});
|
|
4806
5244
|
}
|
|
4807
5245
|
logOutput(normalizeOutputKeys(envelope), getOutputFormat());
|
|
@@ -4844,13 +5282,20 @@ var OutputFormatter;
|
|
|
4844
5282
|
OutputFormatter.log = log;
|
|
4845
5283
|
function formatToString(data) {
|
|
4846
5284
|
const filter = getOutputFilter();
|
|
5285
|
+
const envelope = data;
|
|
4847
5286
|
if ("Data" in data && data.Data != null) {
|
|
4848
5287
|
data.Data = normalizeDataKeys(data.Data);
|
|
4849
5288
|
if (filter) {
|
|
4850
|
-
|
|
5289
|
+
let note;
|
|
5290
|
+
data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
|
|
5291
|
+
note = n;
|
|
5292
|
+
}));
|
|
5293
|
+
if (note) {
|
|
5294
|
+
envelope.Warning = appendWarning(envelope.Warning, note);
|
|
5295
|
+
}
|
|
4851
5296
|
}
|
|
4852
5297
|
}
|
|
4853
|
-
const output = normalizeOutputKeys(
|
|
5298
|
+
const output = normalizeOutputKeys(envelope);
|
|
4854
5299
|
const lines = [];
|
|
4855
5300
|
const sink = getOutputSink();
|
|
4856
5301
|
printOutput(output, getOutputFormat(), (msg) => {
|
|
@@ -4900,7 +5345,7 @@ var LEGACY_SKILL_NAMESPACE = "uipath:";
|
|
|
4900
5345
|
var MAX_SKILL_NAME_LENGTH = 80;
|
|
4901
5346
|
var SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
|
|
4902
5347
|
function productMode(productArea, mode) {
|
|
4903
|
-
return {
|
|
5348
|
+
return { ProductArea: productArea, Mode: mode };
|
|
4904
5349
|
}
|
|
4905
5350
|
function attributionRecord(groups) {
|
|
4906
5351
|
const record = {};
|
|
@@ -4958,6 +5403,7 @@ var COMMAND_ATTRIBUTION = commandAttribution([
|
|
|
4958
5403
|
["rpa", "build", ["uip.rpa-legacy"]],
|
|
4959
5404
|
["conversational", "operate", ["uip.conversational"]],
|
|
4960
5405
|
["agents", "build", ["uip.codedagent", "uip.agent"]],
|
|
5406
|
+
["coding-agents", "build", ["uip.coder"]],
|
|
4961
5407
|
["agenthub", "build", ["uip.agenthub"]],
|
|
4962
5408
|
["coded-apps", "build", ["uip.codedapp"]],
|
|
4963
5409
|
["functions", "build", ["uip.function", "uip.functions"]],
|
|
@@ -5043,32 +5489,64 @@ function normalizeSkillName(value) {
|
|
|
5043
5489
|
function buildCommandTelemetryAttribution(commandPath, skillSource) {
|
|
5044
5490
|
const skillName = normalizeSkillName(skillSource);
|
|
5045
5491
|
return {
|
|
5046
|
-
...skillName ? {
|
|
5492
|
+
...skillName ? { SkillName: skillName } : {},
|
|
5047
5493
|
...getCommandProductModeAttribution(commandPath)
|
|
5048
5494
|
};
|
|
5049
5495
|
}
|
|
5496
|
+
var AGENT_SESSION_ENV = {
|
|
5497
|
+
[BaseDimensions.AgentModel]: "UIPATH_AGENT_MODEL",
|
|
5498
|
+
[SkillsDimensions.PermissionMode]: "UIPATH_PERMISSION_MODE",
|
|
5499
|
+
[SkillsDimensions.EffortLevel]: "UIPATH_EFFORT_LEVEL",
|
|
5500
|
+
[SkillsDimensions.SkillsVersion]: "UIPATH_SKILLS_VERSION"
|
|
5501
|
+
};
|
|
5502
|
+
var MAX_TELEMETRY_TOKEN_LENGTH = 120;
|
|
5503
|
+
function sanitizeTelemetryToken(value) {
|
|
5504
|
+
return value.replace(/[^A-Za-z0-9:._/ -]/g, "_").slice(0, MAX_TELEMETRY_TOKEN_LENGTH);
|
|
5505
|
+
}
|
|
5506
|
+
function buildAgentSessionTelemetry(env) {
|
|
5507
|
+
const dimensions = {};
|
|
5508
|
+
for (const [key, variable] of Object.entries(AGENT_SESSION_ENV)) {
|
|
5509
|
+
const value = env[variable]?.trim();
|
|
5510
|
+
if (value) {
|
|
5511
|
+
dimensions[key] = sanitizeTelemetryToken(value);
|
|
5512
|
+
}
|
|
5513
|
+
}
|
|
5514
|
+
return dimensions;
|
|
5515
|
+
}
|
|
5050
5516
|
|
|
5051
5517
|
// ../../common/src/telemetry/command-name.ts
|
|
5052
|
-
var
|
|
5518
|
+
var TELEMETRY_NAME_ROOT = "Cli";
|
|
5519
|
+
var CLI_COMMAND_ROOT = "uip";
|
|
5520
|
+
var TELEMETRY_NAME_BARE_ACTION = "Invoke";
|
|
5053
5521
|
function commandTelemetryName(parts) {
|
|
5522
|
+
const action = vetCommandTokens(parts).map(pascalizeToken).join("");
|
|
5523
|
+
return `${TELEMETRY_NAME_ROOT}.${action || TELEMETRY_NAME_BARE_ACTION}`;
|
|
5524
|
+
}
|
|
5525
|
+
function commandInvocationPath(parts) {
|
|
5526
|
+
return [CLI_COMMAND_ROOT, ...vetCommandTokens(parts)].join(" ");
|
|
5527
|
+
}
|
|
5528
|
+
function vetCommandTokens(parts) {
|
|
5054
5529
|
const tokens = [];
|
|
5055
5530
|
for (const part of parts) {
|
|
5056
|
-
const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !==
|
|
5531
|
+
const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== CLI_COMMAND_ROOT);
|
|
5057
5532
|
if (pieces.every(isCommandToken)) {
|
|
5058
5533
|
tokens.push(...pieces);
|
|
5059
5534
|
continue;
|
|
5060
5535
|
}
|
|
5061
5536
|
tokens.push(UNKNOWN_TOKEN);
|
|
5062
5537
|
}
|
|
5063
|
-
return
|
|
5538
|
+
return tokens;
|
|
5539
|
+
}
|
|
5540
|
+
function pascalizeToken(token) {
|
|
5541
|
+
return token.split("-").filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
5064
5542
|
}
|
|
5065
|
-
var COMMAND_TOKEN_PATTERN = /^[a-
|
|
5543
|
+
var COMMAND_TOKEN_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
5066
5544
|
var MAX_COMMAND_TOKEN_LENGTH = 32;
|
|
5067
5545
|
var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
5068
5546
|
function isCommandToken(token) {
|
|
5069
|
-
return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token)
|
|
5547
|
+
return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token);
|
|
5070
5548
|
}
|
|
5071
|
-
var UNKNOWN_TOKEN = "
|
|
5549
|
+
var UNKNOWN_TOKEN = "unknown";
|
|
5072
5550
|
|
|
5073
5551
|
// ../../common/src/telemetry/invocation-request.ts
|
|
5074
5552
|
var requestContextSlot = singleton("TelemetryInvocationRequestContext");
|
|
@@ -5173,7 +5651,7 @@ function withheldArgumentValues(cmd) {
|
|
|
5173
5651
|
});
|
|
5174
5652
|
return values;
|
|
5175
5653
|
}
|
|
5176
|
-
function
|
|
5654
|
+
function deriveCommandParts(cmd) {
|
|
5177
5655
|
const parts = [];
|
|
5178
5656
|
let current = cmd;
|
|
5179
5657
|
while (current) {
|
|
@@ -5186,14 +5664,13 @@ function deriveCommandPath(cmd) {
|
|
|
5186
5664
|
if (parts.length > 1) {
|
|
5187
5665
|
parts.shift();
|
|
5188
5666
|
}
|
|
5189
|
-
return
|
|
5667
|
+
return parts;
|
|
5190
5668
|
}
|
|
5191
5669
|
function isErrorContext(value) {
|
|
5192
5670
|
return value !== null && typeof value === "object";
|
|
5193
5671
|
}
|
|
5194
5672
|
function commandHelpHint(commandPath) {
|
|
5195
|
-
|
|
5196
|
-
return `An unexpected error occurred. Run '${command} --help' to verify command syntax, or run with --log-level debug for details.`;
|
|
5673
|
+
return `An unexpected error occurred. Run '${commandPath} --help' to verify command syntax, or run with --log-level debug for details.`;
|
|
5197
5674
|
}
|
|
5198
5675
|
function isPromptCancellation(error) {
|
|
5199
5676
|
return error instanceof Error && error.name === "ExitPromptError";
|
|
@@ -5218,7 +5695,9 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
5218
5695
|
yaml: getOutputFormat() === "yaml",
|
|
5219
5696
|
filter: getOutputFilter() !== undefined
|
|
5220
5697
|
});
|
|
5221
|
-
const
|
|
5698
|
+
const commandParts = deriveCommandParts(command);
|
|
5699
|
+
const telemetryName = commandTelemetryName(commandParts);
|
|
5700
|
+
const commandPath = commandInvocationPath(commandParts);
|
|
5222
5701
|
const props = typeof properties === "function" ? properties(...args) : properties;
|
|
5223
5702
|
markCommandStart();
|
|
5224
5703
|
const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
|
|
@@ -5253,7 +5732,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
5253
5732
|
Result: finalResult,
|
|
5254
5733
|
...customErrorCode ? { ErrorCode: customErrorCode } : {},
|
|
5255
5734
|
Message: errorMessage,
|
|
5256
|
-
Instructions: customInstructions ?? commandHelpHint(
|
|
5735
|
+
Instructions: customInstructions ?? commandHelpHint(commandPath),
|
|
5257
5736
|
...customRetry ? { Retry: customRetry } : {},
|
|
5258
5737
|
...customContext ? { Context: customContext } : {}
|
|
5259
5738
|
});
|
|
@@ -5270,8 +5749,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
5270
5749
|
recordedFailure,
|
|
5271
5750
|
pollSignal: context.pollSignal
|
|
5272
5751
|
});
|
|
5273
|
-
if (terminalTelemetry.
|
|
5274
|
-
telemetry.trackException(error instanceof Error ? error : new Error(String(error)), {
|
|
5752
|
+
if (terminalTelemetry[CommandDimensions.ErrorClass] === "internal" && error) {
|
|
5753
|
+
telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { [CommandDimensions.CommandName]: commandPath }, getInvocationRequestContext());
|
|
5275
5754
|
}
|
|
5276
5755
|
const commandParams = extractCommandParams(command);
|
|
5277
5756
|
if (props) {
|
|
@@ -5282,10 +5761,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
5282
5761
|
const baseProperties = redactProperties({
|
|
5283
5762
|
...commandParams,
|
|
5284
5763
|
...props,
|
|
5285
|
-
...buildCommandTelemetryAttribution(
|
|
5286
|
-
|
|
5764
|
+
...buildCommandTelemetryAttribution(commandPath, process.env.UIPATH_SKILL),
|
|
5765
|
+
...buildAgentSessionTelemetry(process.env),
|
|
5766
|
+
[CommandDimensions.CommandName]: commandPath,
|
|
5767
|
+
[CommandDimensions.IsCommand]: "true",
|
|
5287
5768
|
...terminalTelemetry,
|
|
5288
|
-
...errorMessage ? { errorMessage } : {}
|
|
5769
|
+
...errorMessage ? { [CommandDimensions.ErrorMessage]: errorMessage } : {}
|
|
5289
5770
|
});
|
|
5290
5771
|
emitInvocationRequest(telemetryName, success, baseProperties);
|
|
5291
5772
|
} finally {
|
|
@@ -5516,6 +5997,40 @@ var BOOLEAN_FLAGS = new Set(HOST_GLOBAL_FLAGS);
|
|
|
5516
5997
|
// ../../common/src/interactivity-context.ts
|
|
5517
5998
|
var modeSlot = singleton("InteractivityMode");
|
|
5518
5999
|
var interactiveFlagSlot = singleton("InteractiveFlag");
|
|
6000
|
+
// ../../common/src/mime-types.ts
|
|
6001
|
+
var MIME_TYPES_BY_EXTENSION = Object.freeze({
|
|
6002
|
+
pdf: "application/pdf",
|
|
6003
|
+
png: "image/png",
|
|
6004
|
+
jpg: "image/jpeg",
|
|
6005
|
+
jpeg: "image/jpeg",
|
|
6006
|
+
gif: "image/gif",
|
|
6007
|
+
webp: "image/webp",
|
|
6008
|
+
bmp: "image/bmp",
|
|
6009
|
+
tif: "image/tiff",
|
|
6010
|
+
tiff: "image/tiff",
|
|
6011
|
+
svg: "image/svg+xml",
|
|
6012
|
+
txt: "text/plain",
|
|
6013
|
+
log: "text/plain",
|
|
6014
|
+
md: "text/markdown",
|
|
6015
|
+
csv: "text/csv",
|
|
6016
|
+
tsv: "text/tab-separated-values",
|
|
6017
|
+
json: "application/json",
|
|
6018
|
+
xml: "application/xml",
|
|
6019
|
+
html: "text/html",
|
|
6020
|
+
htm: "text/html",
|
|
6021
|
+
yaml: "application/yaml",
|
|
6022
|
+
yml: "application/yaml",
|
|
6023
|
+
doc: "application/msword",
|
|
6024
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
6025
|
+
xls: "application/vnd.ms-excel",
|
|
6026
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
6027
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
6028
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
6029
|
+
zip: "application/zip",
|
|
6030
|
+
mp3: "audio/mpeg",
|
|
6031
|
+
wav: "audio/wav",
|
|
6032
|
+
mp4: "video/mp4"
|
|
6033
|
+
});
|
|
5519
6034
|
// ../../common/src/polling/types.ts
|
|
5520
6035
|
var PollOutcome = {
|
|
5521
6036
|
Completed: "completed",
|
|
@@ -5561,6 +6076,7 @@ var ScreenLogger;
|
|
|
5561
6076
|
})(ScreenLogger ||= {});
|
|
5562
6077
|
// ../../common/src/sdk-user-agent.ts
|
|
5563
6078
|
var USER_AGENT_HEADER = "User-Agent";
|
|
6079
|
+
var AGENT_PROPERTY = BaseDimensions.Agent;
|
|
5564
6080
|
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
5565
6081
|
function splitUserAgentTokens(value) {
|
|
5566
6082
|
return value?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
@@ -5907,6 +6423,11 @@ var pickName = (claims) => {
|
|
|
5907
6423
|
const username = asString(claims?.preferred_username);
|
|
5908
6424
|
return asString(claims?.name) ?? (looksLikeEmail(username) ? undefined : username);
|
|
5909
6425
|
};
|
|
6426
|
+
var pickScopes = (claims) => {
|
|
6427
|
+
const raw = claims?.scope;
|
|
6428
|
+
const scopes = Array.isArray(raw) ? raw.filter((entry) => asString(entry) !== undefined) : typeof raw === "string" ? raw.split(/\s+/).filter(Boolean) : [];
|
|
6429
|
+
return scopes.length > 0 ? scopes : undefined;
|
|
6430
|
+
};
|
|
5910
6431
|
var resolveSessionIdentity = (accessToken, authFlow) => {
|
|
5911
6432
|
const claims = accessToken ? decodeClaims(accessToken) : undefined;
|
|
5912
6433
|
const email = pickEmail(claims);
|
|
@@ -5932,6 +6453,7 @@ var resolveSessionIdentity = (accessToken, authFlow) => {
|
|
|
5932
6453
|
identity.clientId = clientId;
|
|
5933
6454
|
return identity;
|
|
5934
6455
|
};
|
|
6456
|
+
var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
|
|
5935
6457
|
|
|
5936
6458
|
// ../../auth/src/envAuth.ts
|
|
5937
6459
|
var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
|
|
@@ -6004,6 +6526,7 @@ var readAuthFromEnv = () => {
|
|
|
6004
6526
|
const expiration = getTokenExpiration(accessToken);
|
|
6005
6527
|
const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
|
|
6006
6528
|
const identity = resolveSessionIdentity(accessToken);
|
|
6529
|
+
const scopes = readTokenScopes(accessToken);
|
|
6007
6530
|
return {
|
|
6008
6531
|
loginStatus,
|
|
6009
6532
|
accessToken,
|
|
@@ -6014,7 +6537,8 @@ var readAuthFromEnv = () => {
|
|
|
6014
6537
|
tenantId,
|
|
6015
6538
|
expiration,
|
|
6016
6539
|
source: "env-vars" /* EnvironmentVariables */,
|
|
6017
|
-
...identity ? { identity } : {}
|
|
6540
|
+
...identity ? { identity } : {},
|
|
6541
|
+
...scopes ? { scopes } : {}
|
|
6018
6542
|
};
|
|
6019
6543
|
};
|
|
6020
6544
|
|
|
@@ -6652,10 +7176,15 @@ async function buildFileStatus(tokens, credentials, globalHint) {
|
|
|
6652
7176
|
}
|
|
6653
7177
|
function identityFields(accessToken, credentials) {
|
|
6654
7178
|
const identity = resolveSessionIdentity(accessToken, parseAuthFlow(credentials[AUTH_FLOW_ENV_VAR]));
|
|
6655
|
-
|
|
7179
|
+
const scopes = readTokenScopes(accessToken);
|
|
7180
|
+
return {
|
|
7181
|
+
...identity ? { identity } : {},
|
|
7182
|
+
...scopes ? { scopes } : {}
|
|
7183
|
+
};
|
|
6656
7184
|
}
|
|
6657
7185
|
function buildRobotStatus(robotCreds) {
|
|
6658
7186
|
const identity = resolveSessionIdentity(robotCreds.accessToken);
|
|
7187
|
+
const scopes = readTokenScopes(robotCreds.accessToken);
|
|
6659
7188
|
return {
|
|
6660
7189
|
loginStatus: "Logged in",
|
|
6661
7190
|
accessToken: robotCreds.accessToken,
|
|
@@ -6667,7 +7196,8 @@ function buildRobotStatus(robotCreds) {
|
|
|
6667
7196
|
issuer: robotCreds.issuer,
|
|
6668
7197
|
expiration: getTokenExpiration(robotCreds.accessToken),
|
|
6669
7198
|
source: "robot" /* Robot */,
|
|
6670
|
-
...identity ? { identity } : {}
|
|
7199
|
+
...identity ? { identity } : {},
|
|
7200
|
+
...scopes ? { scopes } : {}
|
|
6671
7201
|
};
|
|
6672
7202
|
}
|
|
6673
7203
|
var isFileNotFoundError = (error) => {
|
|
@@ -6934,7 +7464,8 @@ var getAuthContext = async (options = {}) => {
|
|
|
6934
7464
|
organizationId: status.organizationId,
|
|
6935
7465
|
organizationName: status.organizationName,
|
|
6936
7466
|
tenantId: status.tenantId,
|
|
6937
|
-
tenantName
|
|
7467
|
+
tenantName,
|
|
7468
|
+
identity: status.identity
|
|
6938
7469
|
};
|
|
6939
7470
|
};
|
|
6940
7471
|
// ../../auth/src/tenantSelection.ts
|
|
@@ -7451,4 +7982,4 @@ export {
|
|
|
7451
7982
|
registerCommands
|
|
7452
7983
|
};
|
|
7453
7984
|
|
|
7454
|
-
//# debugId=
|
|
7985
|
+
//# debugId=DB96097981B119C764756E2164756E21
|
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.204.0-preview.206",
|
|
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": "ea7fd32a02acccf14e8e83522e69101430627b83"
|
|
28
28
|
}
|