@uipath/cli 1.205.0-preview.276 → 1.206.0-preview.279
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{applicationinsights-s28k1t0d.js → applicationinsights-pwe8sf3y.js} +1269 -1269
- package/dist/{browser-strategy-6atc7v8s.js → browser-strategy-p5fhwxqj.js} +6 -7
- package/dist/cli-q6fp9ccp.js +23 -0
- package/dist/contentStore-c51xqdn2.js +41 -0
- package/dist/environmentInfo-fn0za9jw.js +71 -0
- package/dist/feedbackPrompts-t1enxv1x.js +144 -0
- package/dist/handlers-93z27zrr.js +805 -0
- package/dist/index-16d4evd1.js +1051 -0
- package/dist/index-1vyte4ma.js +14 -0
- package/dist/index-21kns9qg.js +10 -0
- package/dist/{index-yhj4pgvt.js → index-2j7ss97f.js} +331 -2595
- package/dist/index-2k8rhmad.js +274 -0
- package/dist/{index-30618bjs.js → index-2mm750yx.js} +174 -234
- package/dist/{index-622x1qb5.js → index-3fvbddpw.js} +7092 -7092
- package/dist/{index-d3w0wn6k.js → index-5gce5wfd.js} +16 -16
- package/dist/index-5j0bfd3e.js +4744 -0
- package/dist/index-68xmrb9x.js +237 -0
- package/dist/index-6wj58qka.js +59 -0
- package/dist/index-898c4tfz.js +668 -0
- package/dist/index-8gr7ny79.js +365 -0
- package/dist/index-99emfvtm.js +13 -0
- package/dist/{index-pj3g8ftz.js → index-9db5vwx9.js} +2429 -1693
- package/dist/index-ayg25v46.js +151 -0
- package/dist/index-bf0e4evz.js +6180 -0
- package/dist/index-bpqx6f8h.js +92 -0
- package/dist/index-bpxh3fqv.js +392 -0
- package/dist/index-cc653qc1.js +1327 -0
- package/dist/{index-m5nwse9v.js → index-cj4v0jct.js} +21 -69
- package/dist/{index-469jgr1w.js → index-dsj3jrm0.js} +105 -106
- package/dist/{index-1yh8g550.js → index-epsr41wx.js} +8 -12
- package/dist/{index-yb4er9vd.js → index-jjejkkg4.js} +474 -528
- package/dist/index-kg1xrq51.js +171 -0
- package/dist/index-m8vqyv3g.js +72 -0
- package/dist/index-mzqm6xfh.js +45 -0
- package/dist/index-nsrrst23.js +44 -0
- package/dist/{index-h8cph72k.js → index-nzr4mx5p.js} +2 -22
- package/dist/index-p9s0gyrw.js +72 -0
- package/dist/index-qadhm1gn.js +271 -0
- package/dist/index-qwbyt2q5.js +95 -0
- package/dist/index-rbna3w6k.js +200 -0
- package/dist/index-rr5hdtcy.js +95 -0
- package/dist/{index-qa9gftnj.js → index-xd2w5pct.js} +3 -3
- package/dist/index-xpdtagqw.js +30 -0
- package/dist/{index-925304r7.js → index-y085rpen.js} +29 -25
- package/dist/index-y5ncb93a.js +240 -0
- package/dist/index-y7d0cth0.js +93 -0
- package/dist/{index-hdxtgckw.js → index-z070caqq.js} +56 -12
- package/dist/index-zdqbp34f.js +14 -0
- package/dist/index.js +38 -36
- package/dist/install-3gw33jcf.js +558 -0
- package/dist/{jmespath-e4a59c8w.js → jmespath-ab6tdc42.js} +1 -1
- package/dist/js-yaml-0c4svjwq.js +36 -0
- package/dist/{mcp-jssaz3wr.js → mcp-s50h6d56.js} +236 -472
- package/dist/{node-strategy-ggx3nmyj.js → node-strategy-p1n8wr5s.js} +16 -19
- package/dist/project-context-285hydnd.js +94 -0
- package/dist/prompt-hxbzt92e.js +13 -0
- package/dist/{server-nfjr7xrb.js → server-gkr3c7hv.js} +28 -43
- package/dist/skillCatalog-fvw4wgw1.js +22 -0
- package/dist/skillsService-20es18vs.js +29 -0
- package/dist/{stdio-tmngemcz.js → stdio-kpsab5bz.js} +2 -4
- package/dist/{telemetry-drain-r92f0e4r.js → telemetry-drain-bw59e8f5.js} +8 -9
- package/dist/tree-j4w7p0pg.js +17 -0
- package/dist/updateService-pq7pkd42.js +522 -0
- package/dist/updateService.skills-4t1s7z45.js +22 -0
- package/dist/updateService.tools-f7tr6kc6.js +16 -0
- package/package.json +2 -2
- package/dist/cli-r7998zeh.js +0 -19
- package/dist/index-0gctz400.js +0 -17
- package/dist/index-2dp7m4r8.js +0 -9867
- package/dist/index-4cq44eth.js +0 -19427
- package/dist/index-7tshyfxx.js +0 -157
- package/dist/index-g8ck9tv6.js +0 -2
- package/dist/index-ngs0a2he.js +0 -15
- package/dist/index-yc4kw997.js +0 -13
- package/dist/js-yaml-69tsdrrf.js +0 -37
- package/dist/updateService-nrmb1tsc.js +0 -14
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./index-
|
|
2
|
+
getFileSystem2
|
|
3
|
+
} from "./index-z070caqq.js";
|
|
4
4
|
import {
|
|
5
|
+
__toESM,
|
|
5
6
|
__commonJS,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "./index-
|
|
7
|
+
__exportCjs,
|
|
8
|
+
__require
|
|
9
|
+
} from "./index-epsr41wx.js";
|
|
9
10
|
|
|
10
11
|
// ../../node_modules/commander/lib/error.js
|
|
11
12
|
var require_error = __commonJS(function(exports) {
|
|
@@ -127,7 +128,7 @@ var require_help = __commonJS(function(exports) {
|
|
|
127
128
|
this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
|
|
128
129
|
}
|
|
129
130
|
visibleCommands(cmd) {
|
|
130
|
-
const visibleCommands = cmd.commands.filter((
|
|
131
|
+
const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);
|
|
131
132
|
const helpCommand = cmd._getHelpCommand();
|
|
132
133
|
if (helpCommand && !helpCommand._hidden) {
|
|
133
134
|
visibleCommands.push(helpCommand);
|
|
@@ -607,8 +608,8 @@ var require_option = __commonJS(function(exports) {
|
|
|
607
608
|
}
|
|
608
609
|
}
|
|
609
610
|
function camelcase(str) {
|
|
610
|
-
return str.split("-").reduce((
|
|
611
|
-
return
|
|
611
|
+
return str.split("-").reduce((str, word) => {
|
|
612
|
+
return str + word[0].toUpperCase() + word.slice(1);
|
|
612
613
|
});
|
|
613
614
|
}
|
|
614
615
|
function splitOptionFlags(flags) {
|
|
@@ -1179,44 +1180,44 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1179
1180
|
});
|
|
1180
1181
|
return source;
|
|
1181
1182
|
}
|
|
1182
|
-
_prepareUserArgs(
|
|
1183
|
-
if (
|
|
1183
|
+
_prepareUserArgs(argv2, parseOptions) {
|
|
1184
|
+
if (argv2 !== undefined && !Array.isArray(argv2)) {
|
|
1184
1185
|
throw new Error("first parameter to parse must be array or undefined");
|
|
1185
1186
|
}
|
|
1186
1187
|
parseOptions = parseOptions || {};
|
|
1187
|
-
if (
|
|
1188
|
+
if (argv2 === undefined && parseOptions.from === undefined) {
|
|
1188
1189
|
if (process2.versions?.electron) {
|
|
1189
1190
|
parseOptions.from = "electron";
|
|
1190
1191
|
}
|
|
1191
|
-
const
|
|
1192
|
-
if (
|
|
1192
|
+
const execArgv2 = process2.execArgv ?? [];
|
|
1193
|
+
if (execArgv2.includes("-e") || execArgv2.includes("--eval") || execArgv2.includes("-p") || execArgv2.includes("--print")) {
|
|
1193
1194
|
parseOptions.from = "eval";
|
|
1194
1195
|
}
|
|
1195
1196
|
}
|
|
1196
|
-
if (
|
|
1197
|
-
|
|
1197
|
+
if (argv2 === undefined) {
|
|
1198
|
+
argv2 = process2.argv;
|
|
1198
1199
|
}
|
|
1199
|
-
this.rawArgs =
|
|
1200
|
+
this.rawArgs = argv2.slice();
|
|
1200
1201
|
let userArgs;
|
|
1201
1202
|
switch (parseOptions.from) {
|
|
1202
1203
|
case undefined:
|
|
1203
1204
|
case "node":
|
|
1204
|
-
this._scriptPath =
|
|
1205
|
-
userArgs =
|
|
1205
|
+
this._scriptPath = argv2[1];
|
|
1206
|
+
userArgs = argv2.slice(2);
|
|
1206
1207
|
break;
|
|
1207
1208
|
case "electron":
|
|
1208
1209
|
if (process2.defaultApp) {
|
|
1209
|
-
this._scriptPath =
|
|
1210
|
-
userArgs =
|
|
1210
|
+
this._scriptPath = argv2[1];
|
|
1211
|
+
userArgs = argv2.slice(2);
|
|
1211
1212
|
} else {
|
|
1212
|
-
userArgs =
|
|
1213
|
+
userArgs = argv2.slice(1);
|
|
1213
1214
|
}
|
|
1214
1215
|
break;
|
|
1215
1216
|
case "user":
|
|
1216
|
-
userArgs =
|
|
1217
|
+
userArgs = argv2.slice(0);
|
|
1217
1218
|
break;
|
|
1218
1219
|
case "eval":
|
|
1219
|
-
userArgs =
|
|
1220
|
+
userArgs = argv2.slice(1);
|
|
1220
1221
|
break;
|
|
1221
1222
|
default:
|
|
1222
1223
|
throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
|
|
@@ -1739,18 +1740,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1739
1740
|
this.error(message, { code: "commander.missingMandatoryOptionValue" });
|
|
1740
1741
|
}
|
|
1741
1742
|
_conflictingOption(option, conflictingOption) {
|
|
1742
|
-
const findBestOptionFromValue = (
|
|
1743
|
-
const optionKey =
|
|
1743
|
+
const findBestOptionFromValue = (option) => {
|
|
1744
|
+
const optionKey = option.attributeName();
|
|
1744
1745
|
const optionValue = this.getOptionValue(optionKey);
|
|
1745
1746
|
const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
|
|
1746
1747
|
const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
|
|
1747
1748
|
if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
|
|
1748
1749
|
return negativeOption;
|
|
1749
1750
|
}
|
|
1750
|
-
return positiveOption ||
|
|
1751
|
+
return positiveOption || option;
|
|
1751
1752
|
};
|
|
1752
|
-
const getErrorMessage = (
|
|
1753
|
-
const bestOption = findBestOptionFromValue(
|
|
1753
|
+
const getErrorMessage = (option) => {
|
|
1754
|
+
const bestOption = findBestOptionFromValue(option);
|
|
1754
1755
|
const optionKey = bestOption.attributeName();
|
|
1755
1756
|
const source = this.getOptionValueSource(optionKey);
|
|
1756
1757
|
if (source === "env") {
|
|
@@ -1904,10 +1905,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1904
1905
|
this._name = path.basename(filename, path.extname(filename));
|
|
1905
1906
|
return this;
|
|
1906
1907
|
}
|
|
1907
|
-
executableDir(
|
|
1908
|
-
if (
|
|
1908
|
+
executableDir(path) {
|
|
1909
|
+
if (path === undefined)
|
|
1909
1910
|
return this._executableDir;
|
|
1910
|
-
this._executableDir =
|
|
1911
|
+
this._executableDir = path;
|
|
1911
1912
|
return this;
|
|
1912
1913
|
}
|
|
1913
1914
|
helpInformation(contextOptions) {
|
|
@@ -2004,11 +2005,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2004
2005
|
}
|
|
2005
2006
|
help(contextOptions) {
|
|
2006
2007
|
this.outputHelp(contextOptions);
|
|
2007
|
-
let
|
|
2008
|
-
if (
|
|
2009
|
-
|
|
2008
|
+
let exitCode2 = Number(process2.exitCode ?? 0);
|
|
2009
|
+
if (exitCode2 === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
2010
|
+
exitCode2 = 1;
|
|
2010
2011
|
}
|
|
2011
|
-
this._exit(
|
|
2012
|
+
this._exit(exitCode2, "commander.help", "(outputHelp)");
|
|
2012
2013
|
}
|
|
2013
2014
|
addHelpText(position, text) {
|
|
2014
2015
|
const allowedValues = ["beforeAll", "before", "after", "afterAll"];
|
|
@@ -2080,25 +2081,224 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2080
2081
|
exports.useColor = useColor;
|
|
2081
2082
|
});
|
|
2082
2083
|
|
|
2083
|
-
//
|
|
2084
|
-
var
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2084
|
+
// ../common/src/telemetry/telemetry-dimensions.ts
|
|
2085
|
+
var CLI_APPLICATION_NAME = "UiPath.Cli";
|
|
2086
|
+
var BaseDimensions = {
|
|
2087
|
+
ApplicationName: "ApplicationName",
|
|
2088
|
+
ProductVersion: "ProductVersion",
|
|
2089
|
+
InstallationId: "InstallationId",
|
|
2090
|
+
CloudUserId: "CloudUserId",
|
|
2091
|
+
CloudTenantId: "CloudTenantId",
|
|
2092
|
+
CloudOrganizationId: "CloudOrganizationId",
|
|
2093
|
+
IsInternalUser: "IsInternalUser",
|
|
2094
|
+
Environment: "Environment",
|
|
2095
|
+
BaseUrl: "BaseUrl",
|
|
2096
|
+
Region: "Region",
|
|
2097
|
+
Agent: "Agent",
|
|
2098
|
+
AgentVersion: "AgentVersion",
|
|
2099
|
+
AgentModel: "AgentModel",
|
|
2100
|
+
ToolName: "ToolName",
|
|
2101
|
+
ToolVersion: "ToolVersion",
|
|
2102
|
+
ExecutionContext: "ExecutionContext",
|
|
2103
|
+
CiProvider: "CiProvider",
|
|
2104
|
+
SessionIdSource: "SessionIdSource",
|
|
2105
|
+
SessionId: "SessionId"
|
|
2106
|
+
};
|
|
2107
|
+
var CommandDimensions = {
|
|
2108
|
+
IsCommand: "IsCommand",
|
|
2109
|
+
IsReexec: "IsReexec",
|
|
2110
|
+
CommandName: "CommandName",
|
|
2111
|
+
ExitCode: "ExitCode",
|
|
2112
|
+
TerminalOutcome: "TerminalOutcome",
|
|
2113
|
+
ErrorClass: "ErrorClass",
|
|
2114
|
+
TerminalSignal: "TerminalSignal",
|
|
2115
|
+
ErrorMessage: "ErrorMessage",
|
|
2116
|
+
SkillName: "SkillName",
|
|
2117
|
+
ProductArea: "ProductArea",
|
|
2118
|
+
Mode: "Mode"
|
|
2119
|
+
};
|
|
2120
|
+
var ProjectDimensions = {
|
|
2121
|
+
ProjectKey: "ProjectKey",
|
|
2122
|
+
ProjectType: "ProjectType",
|
|
2123
|
+
ProjectIdentityStatus: "ProjectIdentityStatus",
|
|
2124
|
+
SolutionKey: "SolutionKey",
|
|
2125
|
+
SolutionProjectKey: "SolutionProjectKey",
|
|
2126
|
+
SolutionIdentityStatus: "SolutionIdentityStatus",
|
|
2127
|
+
PreviousSolutionKey: "PreviousSolutionKey"
|
|
2128
|
+
};
|
|
2129
|
+
var GUID_KEY_DIMENSIONS = new Set([
|
|
2130
|
+
ProjectDimensions.ProjectKey,
|
|
2131
|
+
ProjectDimensions.SolutionKey,
|
|
2132
|
+
ProjectDimensions.SolutionProjectKey,
|
|
2133
|
+
ProjectDimensions.PreviousSolutionKey
|
|
2134
|
+
]);
|
|
2135
|
+
var ShipDimensions = {
|
|
2136
|
+
ShipKind: "ShipKind",
|
|
2137
|
+
Target: "Target",
|
|
2138
|
+
ProjectType: "ProjectType",
|
|
2139
|
+
ProjectTypes: "ProjectTypes",
|
|
2140
|
+
ArtifactCorrelationKey: "ArtifactCorrelationKey",
|
|
2141
|
+
PackageName: "PackageName",
|
|
2142
|
+
PackageVersion: "PackageVersion",
|
|
2143
|
+
PackageVersionKey: "PackageVersionKey",
|
|
2144
|
+
DeploymentKey: "DeploymentKey",
|
|
2145
|
+
SolutionId: "SolutionId",
|
|
2146
|
+
FolderKey: "FolderKey",
|
|
2147
|
+
FeedId: "FeedId"
|
|
2148
|
+
};
|
|
2149
|
+
var ErrorDimensions = {
|
|
2150
|
+
Result: "Result",
|
|
2151
|
+
ErrorCode: "ErrorCode",
|
|
2152
|
+
Retry: "Retry",
|
|
2153
|
+
ErrorMessage: "ErrorMessage",
|
|
2154
|
+
HttpStatus: "HttpStatus",
|
|
2155
|
+
UpstreamErrorCode: "UpstreamErrorCode"
|
|
2156
|
+
};
|
|
2157
|
+
var AuthDimensions = {
|
|
2158
|
+
AuthenticationMethod: "AuthenticationMethod",
|
|
2159
|
+
Success: "Success",
|
|
2160
|
+
Reason: "Reason"
|
|
2161
|
+
};
|
|
2162
|
+
var SkillsDimensions = {
|
|
2163
|
+
SchemaVersion: "SchemaVersion",
|
|
2164
|
+
AgentType: "AgentType",
|
|
2165
|
+
SkillsVersion: "SkillsVersion",
|
|
2166
|
+
UipSubcommand: "UipSubcommand",
|
|
2167
|
+
FileExtension: "FileExtension",
|
|
2168
|
+
SubagentModel: "SubagentModel",
|
|
2169
|
+
SubagentType: "SubagentType",
|
|
2170
|
+
PermissionMode: "PermissionMode",
|
|
2171
|
+
EffortLevel: "EffortLevel",
|
|
2172
|
+
SessionSource: "SessionSource",
|
|
2173
|
+
Outcome: "Outcome",
|
|
2174
|
+
DurationMs: "DurationMs",
|
|
2175
|
+
Source: "Source"
|
|
2176
|
+
};
|
|
2177
|
+
var PackagerDimensions = {
|
|
2178
|
+
ProjectId: "ProjectId",
|
|
2179
|
+
ProjectType: "ProjectType",
|
|
2180
|
+
SolutionId: "SolutionId"
|
|
2181
|
+
};
|
|
2182
|
+
var ScopeDimensions = {
|
|
2183
|
+
FolderId: "FolderId"
|
|
2184
|
+
};
|
|
2185
|
+
var ID_DIMENSIONS = new Set([
|
|
2186
|
+
BaseDimensions.CloudUserId,
|
|
2187
|
+
BaseDimensions.CloudTenantId,
|
|
2188
|
+
BaseDimensions.CloudOrganizationId,
|
|
2189
|
+
BaseDimensions.InstallationId,
|
|
2190
|
+
ShipDimensions.ArtifactCorrelationKey,
|
|
2191
|
+
ShipDimensions.PackageVersionKey,
|
|
2192
|
+
ShipDimensions.DeploymentKey,
|
|
2193
|
+
ShipDimensions.SolutionId,
|
|
2194
|
+
ShipDimensions.FolderKey,
|
|
2195
|
+
ShipDimensions.FeedId,
|
|
2196
|
+
PackagerDimensions.ProjectId
|
|
2197
|
+
]);
|
|
2198
|
+
var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
|
|
2199
|
+
var RESERVED_DIMENSION_NAMES = new Set([
|
|
2200
|
+
...Object.values(BaseDimensions),
|
|
2201
|
+
...Object.values(CommandDimensions),
|
|
2202
|
+
...Object.values(ShipDimensions),
|
|
2203
|
+
...Object.values(ProjectDimensions),
|
|
2204
|
+
...Object.values(ErrorDimensions),
|
|
2205
|
+
...Object.values(AuthDimensions),
|
|
2206
|
+
...Object.values(SkillsDimensions),
|
|
2207
|
+
...Object.values(PackagerDimensions),
|
|
2208
|
+
...Object.values(ScopeDimensions)
|
|
2209
|
+
]);
|
|
2210
|
+
var CURATED_DIMENSIONS = new Set([
|
|
2211
|
+
BaseDimensions.ApplicationName,
|
|
2212
|
+
BaseDimensions.ProductVersion,
|
|
2213
|
+
BaseDimensions.InstallationId,
|
|
2214
|
+
BaseDimensions.CloudUserId,
|
|
2215
|
+
BaseDimensions.CloudTenantId,
|
|
2216
|
+
BaseDimensions.CloudOrganizationId,
|
|
2217
|
+
BaseDimensions.IsInternalUser,
|
|
2218
|
+
BaseDimensions.Environment,
|
|
2219
|
+
BaseDimensions.BaseUrl,
|
|
2220
|
+
BaseDimensions.Region,
|
|
2221
|
+
BaseDimensions.Agent,
|
|
2222
|
+
BaseDimensions.AgentVersion,
|
|
2223
|
+
BaseDimensions.ToolVersion,
|
|
2224
|
+
BaseDimensions.ExecutionContext,
|
|
2225
|
+
BaseDimensions.CiProvider,
|
|
2226
|
+
BaseDimensions.SessionIdSource,
|
|
2227
|
+
BaseDimensions.SessionId,
|
|
2228
|
+
...Object.values(CommandDimensions),
|
|
2229
|
+
...Object.values(ShipDimensions),
|
|
2230
|
+
...Object.values(ProjectDimensions)
|
|
2231
|
+
]);
|
|
2232
|
+
function assertNoCuratedDimensionTargets(map, mapName) {
|
|
2233
|
+
for (const [inputKey, dimension] of Object.entries(map)) {
|
|
2234
|
+
if (CURATED_DIMENSIONS.has(dimension)) {
|
|
2235
|
+
throw new Error(`${mapName}: input field "${inputKey}" maps to curated dimension "${dimension}"`);
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
function lowercaseIdDimensionValues(properties) {
|
|
2240
|
+
let changed = false;
|
|
2241
|
+
const result = {
|
|
2242
|
+
...properties
|
|
2243
|
+
};
|
|
2244
|
+
for (const key of Object.keys(result)) {
|
|
2245
|
+
const value = result[key];
|
|
2246
|
+
if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
|
|
2247
|
+
continue;
|
|
2248
|
+
}
|
|
2249
|
+
const lowered = value.toLowerCase();
|
|
2250
|
+
if (lowered !== value) {
|
|
2251
|
+
result[key] = lowered;
|
|
2252
|
+
changed = true;
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
return changed ? result : properties;
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
// ../common/src/telemetry/project-identity.ts
|
|
2259
|
+
function solutionIdentityProperties(identity) {
|
|
2260
|
+
const key = identity.id ? projectKey(identity.id) : undefined;
|
|
2261
|
+
return {
|
|
2262
|
+
[ProjectDimensions.SolutionIdentityStatus]: identity.status === "resolved" && !key ? "invalid" : identity.status,
|
|
2263
|
+
...identity.status === "resolved" && key ? {
|
|
2264
|
+
[ProjectDimensions.SolutionKey]: key
|
|
2265
|
+
} : {}
|
|
2266
|
+
};
|
|
2267
|
+
}
|
|
2268
|
+
function projectKey(id) {
|
|
2269
|
+
if (typeof id !== "string")
|
|
2270
|
+
return;
|
|
2271
|
+
const key = id.trim().toLowerCase().replaceAll("-", "");
|
|
2272
|
+
return /^[0-9a-f]{32}$/.test(key) ? key : undefined;
|
|
2273
|
+
}
|
|
2274
|
+
function projectIdentityProperties(identity) {
|
|
2275
|
+
const key = identity.id ? projectKey(identity.id) : undefined;
|
|
2276
|
+
return {
|
|
2277
|
+
[ProjectDimensions.ProjectIdentityStatus]: identity.status === "resolved" && !key ? "invalid" : identity.status,
|
|
2278
|
+
[ProjectDimensions.ProjectType]: identity.projectType,
|
|
2279
|
+
...identity.status === "resolved" && key ? {
|
|
2280
|
+
[ProjectDimensions.ProjectKey]: key
|
|
2281
|
+
} : {}
|
|
2282
|
+
};
|
|
2283
|
+
}
|
|
2284
|
+
var PROJECT_IDENTITY_LOOKUP_BUDGET_MS = 1000;
|
|
2285
|
+
async function withinProjectIdentityBudget(work, onTimeout) {
|
|
2286
|
+
work.catch(() => {
|
|
2287
|
+
return;
|
|
2288
|
+
});
|
|
2289
|
+
let timer;
|
|
2290
|
+
const expired = new Promise((resolve) => {
|
|
2291
|
+
timer = setTimeout(() => {
|
|
2292
|
+
onTimeout?.();
|
|
2293
|
+
resolve(undefined);
|
|
2294
|
+
}, PROJECT_IDENTITY_LOOKUP_BUDGET_MS);
|
|
2295
|
+
});
|
|
2296
|
+
try {
|
|
2297
|
+
return await Promise.race([work, expired]);
|
|
2298
|
+
} finally {
|
|
2299
|
+
clearTimeout(timer);
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2102
2302
|
|
|
2103
2303
|
// ../common/src/telemetry/pseudonymize.ts
|
|
2104
2304
|
var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
|
|
@@ -2563,6 +2763,8 @@ function redactProperty(name, value) {
|
|
|
2563
2763
|
if (isSensitiveName(name)) {
|
|
2564
2764
|
return REDACTED;
|
|
2565
2765
|
}
|
|
2766
|
+
if (GUID_KEY_DIMENSIONS.has(name))
|
|
2767
|
+
return projectKey(value);
|
|
2566
2768
|
if (typeof value === "boolean" || typeof value === "number") {
|
|
2567
2769
|
return value;
|
|
2568
2770
|
}
|
|
@@ -2637,1398 +2839,1711 @@ function settlePromiseLike(thenable) {
|
|
|
2637
2839
|
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
|
|
2638
2840
|
}
|
|
2639
2841
|
|
|
2640
|
-
// ../common/src/
|
|
2641
|
-
|
|
2642
|
-
|
|
2842
|
+
// ../common/src/error-codes.ts
|
|
2843
|
+
var CLI_ERROR_CODES = [
|
|
2844
|
+
"invalid_argument",
|
|
2845
|
+
"authentication_required",
|
|
2846
|
+
"permission_denied",
|
|
2847
|
+
"local_permission_denied",
|
|
2848
|
+
"not_found",
|
|
2849
|
+
"rate_limited",
|
|
2850
|
+
"network_error",
|
|
2851
|
+
"timeout",
|
|
2852
|
+
"server_error",
|
|
2853
|
+
"method_not_allowed",
|
|
2854
|
+
"not_supported",
|
|
2855
|
+
"configuration_error",
|
|
2856
|
+
"execution_failed",
|
|
2857
|
+
"unknown_error"
|
|
2858
|
+
];
|
|
2859
|
+
var RETRY_HINTS = [
|
|
2860
|
+
"RetryWillNotFix",
|
|
2861
|
+
"RetryLater",
|
|
2862
|
+
"RetryAfter1Second",
|
|
2863
|
+
"RetryAfter10Seconds",
|
|
2864
|
+
"RetryAfter30Seconds",
|
|
2865
|
+
"RetryAfter60Seconds"
|
|
2866
|
+
];
|
|
2867
|
+
var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
|
|
2868
|
+
var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
|
|
2869
|
+
function isCliErrorCode(value) {
|
|
2870
|
+
return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
|
|
2643
2871
|
}
|
|
2644
|
-
function
|
|
2645
|
-
|
|
2646
|
-
return typeof code === "number" ? code : 0;
|
|
2872
|
+
function isRetryHint(value) {
|
|
2873
|
+
return typeof value === "string" && RETRY_HINT_VALUES.has(value);
|
|
2647
2874
|
}
|
|
2648
|
-
function
|
|
2649
|
-
|
|
2875
|
+
function carriedErrorCode(error) {
|
|
2876
|
+
if (!error || typeof error !== "object")
|
|
2877
|
+
return;
|
|
2878
|
+
const code = error.errorCode;
|
|
2879
|
+
return isCliErrorCode(code) ? code : undefined;
|
|
2650
2880
|
}
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
const
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2881
|
+
function carriedRetry(error) {
|
|
2882
|
+
if (!error || typeof error !== "object")
|
|
2883
|
+
return;
|
|
2884
|
+
const retry = error.retry;
|
|
2885
|
+
return isRetryHint(retry) ? retry : undefined;
|
|
2886
|
+
}
|
|
2887
|
+
function defaultRetryForErrorCode(errorCode) {
|
|
2888
|
+
switch (errorCode) {
|
|
2889
|
+
case "network_error":
|
|
2890
|
+
case "rate_limited":
|
|
2891
|
+
case "server_error":
|
|
2892
|
+
case "timeout":
|
|
2893
|
+
return "RetryLater";
|
|
2894
|
+
default:
|
|
2895
|
+
return "RetryWillNotFix";
|
|
2662
2896
|
}
|
|
2663
|
-
return new mod.AsyncLocalStorage;
|
|
2664
2897
|
}
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2898
|
+
|
|
2899
|
+
// ../common/src/error-graph.ts
|
|
2900
|
+
function* walkErrorGraph(error) {
|
|
2901
|
+
const queue = [error];
|
|
2902
|
+
const seen = new Set;
|
|
2903
|
+
for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
|
|
2904
|
+
const current = queue.shift();
|
|
2905
|
+
if (current === null || typeof current !== "object")
|
|
2906
|
+
continue;
|
|
2907
|
+
if (seen.has(current))
|
|
2908
|
+
continue;
|
|
2909
|
+
seen.add(current);
|
|
2910
|
+
const cur = current;
|
|
2911
|
+
yield cur;
|
|
2912
|
+
if (cur.cause !== undefined)
|
|
2913
|
+
queue.push(cur.cause);
|
|
2914
|
+
if (Array.isArray(cur.errors))
|
|
2915
|
+
queue.push(...cur.errors);
|
|
2677
2916
|
}
|
|
2678
|
-
|
|
2679
|
-
function runWithSink(sink, fn) {
|
|
2680
|
-
return outputStorage.run(sink, fn);
|
|
2681
|
-
}
|
|
2682
|
-
function getOutputSink() {
|
|
2683
|
-
return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
|
|
2684
|
-
}
|
|
2685
|
-
function setGlobalSink(sink) {
|
|
2686
|
-
sinkSlot.set(sink);
|
|
2917
|
+
return;
|
|
2687
2918
|
}
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2919
|
+
function parseHttpStatusFromMessage(message) {
|
|
2920
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
2921
|
+
if (!match)
|
|
2922
|
+
return;
|
|
2923
|
+
const status = Number(match[1]);
|
|
2924
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
2693
2925
|
}
|
|
2694
|
-
function
|
|
2695
|
-
|
|
2926
|
+
function findHttpStatusInGraph(error) {
|
|
2927
|
+
for (const node of walkErrorGraph(error)) {
|
|
2928
|
+
const response = node.response;
|
|
2929
|
+
const explicit = typeof node.status === "number" ? node.status : response?.status;
|
|
2930
|
+
if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
|
|
2931
|
+
return explicit;
|
|
2932
|
+
}
|
|
2933
|
+
if (typeof node.message === "string") {
|
|
2934
|
+
const parsed = parseHttpStatusFromMessage(node.message);
|
|
2935
|
+
if (parsed !== undefined && parsed >= 400) {
|
|
2936
|
+
return parsed;
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
return;
|
|
2696
2941
|
}
|
|
2697
|
-
var LogLevel;
|
|
2698
|
-
((LogLevel2) => {
|
|
2699
|
-
LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
|
|
2700
|
-
LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
|
|
2701
|
-
LogLevel2[LogLevel2["WARN"] = 2] = "WARN";
|
|
2702
|
-
LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
|
|
2703
|
-
})(LogLevel ||= {});
|
|
2704
|
-
var DEFAULT_LOG_LEVEL = 2 /* WARN */;
|
|
2705
2942
|
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
pendingInit = Promise.resolve();
|
|
2713
|
-
constructor() {
|
|
2714
|
-
this.level = SimpleLogger.resolveLevel();
|
|
2715
|
-
this.logFilePath = "";
|
|
2716
|
-
this.fileLoggingEnabled = false;
|
|
2717
|
-
}
|
|
2718
|
-
static getInstance() {
|
|
2719
|
-
return loggerSingleton.getOrInit(() => new SimpleLogger, (v) => ("__brand" in v) && v.__brand === "SimpleLogger");
|
|
2720
|
-
}
|
|
2721
|
-
static resetInstance() {
|
|
2722
|
-
loggerSingleton.clear();
|
|
2943
|
+
// ../common/src/http-status.ts
|
|
2944
|
+
function classifyHttpStatus(status) {
|
|
2945
|
+
if (status === undefined)
|
|
2946
|
+
return;
|
|
2947
|
+
if (status === 400 || status === 409 || status === 413 || status === 422) {
|
|
2948
|
+
return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
|
|
2723
2949
|
}
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
return explicitLevel;
|
|
2730
|
-
const debugVal = process.env?.DEBUG;
|
|
2731
|
-
if (debugVal === "true" || debugVal === "1") {
|
|
2732
|
-
return 0 /* DEBUG */;
|
|
2733
|
-
}
|
|
2734
|
-
return DEFAULT_LOG_LEVEL;
|
|
2735
|
-
}
|
|
2736
|
-
const [localStorageError, hasDebug] = catchError(() => typeof localStorage !== "undefined" && !!localStorage.getItem("debug"));
|
|
2737
|
-
if (!localStorageError && hasDebug) {
|
|
2738
|
-
return 0 /* DEBUG */;
|
|
2739
|
-
}
|
|
2740
|
-
return DEFAULT_LOG_LEVEL;
|
|
2950
|
+
if (status === 401) {
|
|
2951
|
+
return {
|
|
2952
|
+
errorCode: "authentication_required",
|
|
2953
|
+
retry: "RetryWillNotFix"
|
|
2954
|
+
};
|
|
2741
2955
|
}
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
case "debug":
|
|
2745
|
-
return 0 /* DEBUG */;
|
|
2746
|
-
case "info":
|
|
2747
|
-
return 1 /* INFO */;
|
|
2748
|
-
case "warn":
|
|
2749
|
-
return 2 /* WARN */;
|
|
2750
|
-
case "error":
|
|
2751
|
-
return 3 /* ERROR */;
|
|
2752
|
-
default:
|
|
2753
|
-
return;
|
|
2754
|
-
}
|
|
2956
|
+
if (status === 403) {
|
|
2957
|
+
return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
|
|
2755
2958
|
}
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
return `${message}
|
|
2759
|
-
`;
|
|
2760
|
-
return `${message} ${args.map(String).join(" ")}
|
|
2761
|
-
`;
|
|
2959
|
+
if (status === 404) {
|
|
2960
|
+
return { errorCode: "not_found", retry: "RetryWillNotFix" };
|
|
2762
2961
|
}
|
|
2763
|
-
|
|
2764
|
-
return
|
|
2962
|
+
if (status === 405) {
|
|
2963
|
+
return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
|
|
2765
2964
|
}
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
if (!path)
|
|
2769
|
-
return;
|
|
2770
|
-
const timestamp = new Date().toISOString();
|
|
2771
|
-
this.pendingWrites = Promise.all([
|
|
2772
|
-
this.pendingWrites,
|
|
2773
|
-
this.pendingInit
|
|
2774
|
-
]).then(() => getFileSystem().appendFile(path, `${timestamp} ${formatted}`).catch(() => {}));
|
|
2965
|
+
if (status === 408) {
|
|
2966
|
+
return { errorCode: "timeout", retry: "RetryLater" };
|
|
2775
2967
|
}
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
this.writeToFile(formatted);
|
|
2779
|
-
} else {
|
|
2780
|
-
getOutputSink().writeErr(formatted);
|
|
2781
|
-
}
|
|
2968
|
+
if (status === 429) {
|
|
2969
|
+
return { errorCode: "rate_limited", retry: "RetryLater" };
|
|
2782
2970
|
}
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
return;
|
|
2786
|
-
const formatted = this.format(`[DEBUG] ${message}`, args);
|
|
2787
|
-
this.write(formatted);
|
|
2971
|
+
if (status >= 500 && status < 600) {
|
|
2972
|
+
return { errorCode: "server_error", retry: "RetryLater" };
|
|
2788
2973
|
}
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2974
|
+
return;
|
|
2975
|
+
}
|
|
2976
|
+
|
|
2977
|
+
// ../common/src/local-permission-codes.ts
|
|
2978
|
+
var LOCAL_PERMISSION_ERROR_CODES = new Set([
|
|
2979
|
+
"EACCES",
|
|
2980
|
+
"EPERM",
|
|
2981
|
+
"EROFS"
|
|
2982
|
+
]);
|
|
2983
|
+
|
|
2984
|
+
// ../common/src/error-handler.ts
|
|
2985
|
+
var DEFAULT_401 = "Unauthorized (401). The session is missing or expired, or its token carries no scope for this API. Run `uip login status --detailed` to see the session and its scopes.";
|
|
2986
|
+
var DEFAULT_403 = "Forbidden (403). The account lacks permission for this operation, or the token carries no scope for this API. Run `uip login status --detailed` to see the token's scopes.";
|
|
2987
|
+
var DEFAULT_405 = "Method Not Allowed (405). The endpoint may not exist or the base URL may be incorrect.";
|
|
2988
|
+
var DEFAULT_413 = "Payload too large (413). The upload exceeded the server or CDN size limit. Reduce the package size — for example, exclude unused dependencies or remove large files from the project — and try again.";
|
|
2989
|
+
var CLOUDFLARE_BLOCK_403 = "Forbidden (403) by Cloudflare, in front of the service: the answer is a Cloudflare HTML page, not the service's JSON, so the service did not see the request and did not check the account's roles or the token's scopes. Cloudflare blocks a request when its content matches a firewall rule (text that looks like SQL or script code, for example) or when it comes from a network the firewall does not allow.";
|
|
2990
|
+
var CLOUDFLARE_BLOCK_403_INSTRUCTIONS = "If the request carries text that looks like code, change that text and try again. Otherwise send the time of the request and the Cloudflare Ray ID, when the message gives one, to the owner of the service or UiPath support.";
|
|
2991
|
+
var HTML_RESPONSE_MESSAGE = "Received HTML instead of the expected JSON response.";
|
|
2992
|
+
var NETWORK_ERROR_CODES = new Set([
|
|
2993
|
+
"ECONNREFUSED",
|
|
2994
|
+
"ECONNRESET",
|
|
2995
|
+
"ENOTFOUND",
|
|
2996
|
+
"EAI_AGAIN",
|
|
2997
|
+
"ETIMEDOUT",
|
|
2998
|
+
"EPIPE",
|
|
2999
|
+
"EHOSTUNREACH",
|
|
3000
|
+
"ENETUNREACH",
|
|
3001
|
+
"EAI_FAIL"
|
|
3002
|
+
]);
|
|
3003
|
+
var TLS_ERROR_CODES = new Set([
|
|
3004
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
3005
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
3006
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
3007
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
3008
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
3009
|
+
"CERT_HAS_EXPIRED",
|
|
3010
|
+
"CERT_UNTRUSTED",
|
|
3011
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
3012
|
+
]);
|
|
3013
|
+
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.";
|
|
3014
|
+
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.";
|
|
3015
|
+
var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
|
|
3016
|
+
function localPermissionInstructions(code, path) {
|
|
3017
|
+
const target = path !== undefined ? `'${path}'` : "a local file or resource";
|
|
3018
|
+
if (code === "EROFS") {
|
|
3019
|
+
return `The filesystem containing ${target} is read-only (EROFS), so the ` + "CLI could not write to it. This is a local environment problem, " + "not a UiPath service error — retrying will not help. Use a " + "writable location, or give this environment write access to the " + "path.";
|
|
2794
3020
|
}
|
|
2795
|
-
|
|
2796
|
-
|
|
3021
|
+
const onWindows = typeof process !== "undefined" && process.platform === "win32";
|
|
3022
|
+
const remedy = onWindows ? "Re-run from an elevated terminal, close any program holding " + "the file open, or grant your user access to the path." : "Grant this user (or the sandbox the command runs in) access " + "to the path, or run the command outside the sandbox.";
|
|
3023
|
+
return `The operating system denied access to ${target} (${code}). This is ` + "a local permission problem, not a UiPath service error — retrying " + `without a permission change will not help. ${remedy}`;
|
|
3024
|
+
}
|
|
3025
|
+
function carriedInstructions(error) {
|
|
3026
|
+
if (!error || typeof error !== "object")
|
|
3027
|
+
return;
|
|
3028
|
+
const e = error;
|
|
3029
|
+
return typeof e.instructions === "string" ? e.instructions : undefined;
|
|
3030
|
+
}
|
|
3031
|
+
function formatErrorChain(error) {
|
|
3032
|
+
const lines = [];
|
|
3033
|
+
const seen = new Set;
|
|
3034
|
+
const visit = (value, depth) => {
|
|
3035
|
+
if (lines.length >= 32)
|
|
2797
3036
|
return;
|
|
2798
|
-
const
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
error(message, ...args) {
|
|
2802
|
-
if (this.level > 3 /* ERROR */)
|
|
3037
|
+
const indent = " ".repeat(depth);
|
|
3038
|
+
if (value === null || typeof value !== "object") {
|
|
3039
|
+
lines.push(`${indent}${String(value)}`);
|
|
2803
3040
|
return;
|
|
2804
|
-
const formatted = this.format(`[ERROR] ${message}`, args);
|
|
2805
|
-
this.write(formatted);
|
|
2806
|
-
}
|
|
2807
|
-
report(message) {
|
|
2808
|
-
const formatted = this.format(message, []);
|
|
2809
|
-
this.write(formatted);
|
|
2810
|
-
}
|
|
2811
|
-
getLevel() {
|
|
2812
|
-
return this.level;
|
|
2813
|
-
}
|
|
2814
|
-
setLevel(level) {
|
|
2815
|
-
this.level = level;
|
|
2816
|
-
}
|
|
2817
|
-
setFileLogging(enabled) {
|
|
2818
|
-
this.fileLoggingEnabled = enabled;
|
|
2819
|
-
if (!enabled) {
|
|
2820
|
-
this.logFilePath = "";
|
|
2821
|
-
setGlobalLogFilePath("");
|
|
2822
3041
|
}
|
|
2823
|
-
|
|
2824
|
-
setLogFile(path) {
|
|
2825
|
-
this.logFilePath = path;
|
|
2826
|
-
setGlobalLogFilePath(path);
|
|
2827
|
-
if (!path)
|
|
3042
|
+
if (seen.has(value))
|
|
2828
3043
|
return;
|
|
2829
|
-
|
|
2830
|
-
const
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
await this.pendingInit;
|
|
2842
|
-
await this.pendingWrites;
|
|
2843
|
-
}
|
|
2844
|
-
getLogFilePath() {
|
|
2845
|
-
return this.logFilePath || getGlobalLogFilePath();
|
|
2846
|
-
}
|
|
2847
|
-
handleLog = (logMessage) => {
|
|
2848
|
-
const parts = [];
|
|
2849
|
-
if (logMessage.source) {
|
|
2850
|
-
parts.push(`[${logMessage.source}]`);
|
|
2851
|
-
}
|
|
2852
|
-
if (logMessage.sourceTarget) {
|
|
2853
|
-
parts.push(`[${logMessage.sourceTarget}]`);
|
|
2854
|
-
}
|
|
2855
|
-
parts.push(logMessage.message);
|
|
2856
|
-
const msg = parts.join(" ");
|
|
2857
|
-
switch (logMessage.logLevel) {
|
|
2858
|
-
case "Debug":
|
|
2859
|
-
this.debug(msg);
|
|
2860
|
-
break;
|
|
2861
|
-
case "Information":
|
|
2862
|
-
this.info(msg);
|
|
2863
|
-
break;
|
|
2864
|
-
case "Warning":
|
|
2865
|
-
this.warn(msg);
|
|
2866
|
-
break;
|
|
2867
|
-
case "Error":
|
|
2868
|
-
this.error(msg);
|
|
2869
|
-
break;
|
|
2870
|
-
default:
|
|
2871
|
-
this.info(msg);
|
|
2872
|
-
break;
|
|
3044
|
+
seen.add(value);
|
|
3045
|
+
const cur = value;
|
|
3046
|
+
const name = typeof cur.name === "string" ? cur.name : "Error";
|
|
3047
|
+
const message = typeof cur.message === "string" ? cur.message : String(value);
|
|
3048
|
+
const code = typeof cur.code === "string" ? ` [${cur.code}]` : "";
|
|
3049
|
+
lines.push(`${indent}${name}: ${message}${code}`);
|
|
3050
|
+
if (cur.cause !== undefined)
|
|
3051
|
+
visit(cur.cause, depth + 1);
|
|
3052
|
+
if (Array.isArray(cur.errors)) {
|
|
3053
|
+
for (const nested of cur.errors) {
|
|
3054
|
+
visit(nested, depth + 1);
|
|
3055
|
+
}
|
|
2873
3056
|
}
|
|
2874
3057
|
};
|
|
3058
|
+
visit(error, 0);
|
|
3059
|
+
return lines.join(`
|
|
3060
|
+
`);
|
|
2875
3061
|
}
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
3062
|
+
function describeConnectivityError(error) {
|
|
3063
|
+
for (const cur of walkErrorGraph(error)) {
|
|
3064
|
+
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
3065
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
3066
|
+
if (code && TLS_ERROR_CODES.has(code)) {
|
|
3067
|
+
return {
|
|
3068
|
+
code,
|
|
3069
|
+
kind: "tls",
|
|
3070
|
+
message: message ?? code,
|
|
3071
|
+
instructions: TLS_INSTRUCTIONS
|
|
3072
|
+
};
|
|
3073
|
+
}
|
|
3074
|
+
if (code && NETWORK_ERROR_CODES.has(code)) {
|
|
3075
|
+
return {
|
|
3076
|
+
code,
|
|
3077
|
+
kind: "network",
|
|
3078
|
+
message: message ?? code,
|
|
3079
|
+
instructions: NETWORK_INSTRUCTIONS
|
|
3080
|
+
};
|
|
3081
|
+
}
|
|
2893
3082
|
}
|
|
3083
|
+
return;
|
|
2894
3084
|
}
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
3085
|
+
function describePermissionError(error) {
|
|
3086
|
+
for (const cur of walkErrorGraph(error)) {
|
|
3087
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
3088
|
+
const code = matchLocalPermissionCode(cur.code, message);
|
|
3089
|
+
if (!code)
|
|
3090
|
+
continue;
|
|
3091
|
+
const path = localPermissionPath(cur.path, message);
|
|
3092
|
+
return {
|
|
3093
|
+
code,
|
|
3094
|
+
message: message ?? code,
|
|
3095
|
+
...path !== undefined ? { path } : {},
|
|
3096
|
+
instructions: localPermissionInstructions(code, path)
|
|
3097
|
+
};
|
|
3098
|
+
}
|
|
3099
|
+
return;
|
|
2900
3100
|
}
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
3101
|
+
function matchLocalPermissionCode(code, message) {
|
|
3102
|
+
if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
|
|
3103
|
+
return code;
|
|
3104
|
+
}
|
|
3105
|
+
const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
|
|
3106
|
+
return match ? match[1] : undefined;
|
|
2907
3107
|
}
|
|
2908
|
-
function
|
|
2909
|
-
|
|
3108
|
+
function localPermissionPath(path, message) {
|
|
3109
|
+
if (typeof path === "string")
|
|
3110
|
+
return path;
|
|
3111
|
+
return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
|
|
2910
3112
|
}
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
3113
|
+
function readHeader(response, name) {
|
|
3114
|
+
const headers = response?.headers;
|
|
3115
|
+
if (!headers || typeof headers !== "object")
|
|
3116
|
+
return;
|
|
3117
|
+
if (typeof headers.get === "function") {
|
|
3118
|
+
const value = headers.get(name);
|
|
3119
|
+
if (value)
|
|
3120
|
+
return value;
|
|
3121
|
+
}
|
|
3122
|
+
const plain = headers;
|
|
3123
|
+
const key = Object.keys(plain).find((k) => k.toLowerCase() === name.toLowerCase());
|
|
3124
|
+
const value = key === undefined ? undefined : plain[key];
|
|
3125
|
+
return typeof value === "string" && value !== "" ? value : undefined;
|
|
2919
3126
|
}
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
const dir = getTelemetrySpoolDir();
|
|
2923
|
-
await fs.mkdir(dir);
|
|
2924
|
-
const name = `${Date.now()}-${process.pid}`;
|
|
2925
|
-
const finalPath = fs.path.join(dir, `${name}${PENDING_SUFFIX}`);
|
|
2926
|
-
const tempPath = fs.path.join(dir, `${name}${WRITE_TEMP_SUFFIX}`);
|
|
2927
|
-
await fs.writeFile(tempPath, JSON.stringify(payload));
|
|
2928
|
-
await fs.rename(tempPath, finalPath);
|
|
2929
|
-
return finalPath;
|
|
3127
|
+
function isHtmlDocument(body) {
|
|
3128
|
+
return /^\s*(<!doctype html|<html\b)/i.test(body);
|
|
2930
3129
|
}
|
|
2931
|
-
function
|
|
2932
|
-
|
|
3130
|
+
function retryHintForRetryAfter(seconds) {
|
|
3131
|
+
if (seconds <= 1) {
|
|
3132
|
+
return "RetryAfter1Second";
|
|
3133
|
+
}
|
|
3134
|
+
if (seconds <= 10) {
|
|
3135
|
+
return "RetryAfter10Seconds";
|
|
3136
|
+
}
|
|
3137
|
+
if (seconds <= 30) {
|
|
3138
|
+
return "RetryAfter30Seconds";
|
|
3139
|
+
}
|
|
3140
|
+
return "RetryAfter60Seconds";
|
|
2933
3141
|
}
|
|
2934
|
-
|
|
2935
|
-
const
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
if (
|
|
2939
|
-
return {
|
|
3142
|
+
function classifyError(status, error) {
|
|
3143
|
+
const byStatus = classifyHttpStatus(status);
|
|
3144
|
+
if (byStatus)
|
|
3145
|
+
return byStatus;
|
|
3146
|
+
if (status === undefined && describePermissionError(error)) {
|
|
3147
|
+
return {
|
|
3148
|
+
errorCode: "local_permission_denied",
|
|
3149
|
+
retry: "RetryWillNotFix"
|
|
3150
|
+
};
|
|
2940
3151
|
}
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
3152
|
+
const connectivity = describeConnectivityError(error);
|
|
3153
|
+
if (connectivity) {
|
|
3154
|
+
return {
|
|
3155
|
+
errorCode: "network_error",
|
|
3156
|
+
retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
|
|
3157
|
+
};
|
|
3158
|
+
}
|
|
3159
|
+
return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
|
|
2945
3160
|
}
|
|
2946
|
-
|
|
2947
|
-
const
|
|
2948
|
-
const
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
3161
|
+
function withCarriedClass(inferred, error) {
|
|
3162
|
+
const errorCode = carriedErrorCode(error);
|
|
3163
|
+
const retry = carriedRetry(error);
|
|
3164
|
+
if (errorCode === undefined || errorCode === inferred.errorCode) {
|
|
3165
|
+
return {
|
|
3166
|
+
errorCode: inferred.errorCode,
|
|
3167
|
+
retry: retry ?? inferred.retry
|
|
3168
|
+
};
|
|
3169
|
+
}
|
|
3170
|
+
return { errorCode, retry: retry ?? defaultRetryForErrorCode(errorCode) };
|
|
3171
|
+
}
|
|
3172
|
+
function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
|
|
3173
|
+
if (extractedMessage) {
|
|
3174
|
+
return `HTTP ${status}: ${extractedMessage}`;
|
|
3175
|
+
}
|
|
3176
|
+
return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
|
|
3177
|
+
}
|
|
3178
|
+
async function extractErrorDetails(error, options) {
|
|
3179
|
+
const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
|
|
3180
|
+
const response = err.response;
|
|
3181
|
+
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
3182
|
+
const explicitStatus = err.status ?? response?.status;
|
|
3183
|
+
const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
|
|
3184
|
+
const status = explicitStatus ?? inferredStatus;
|
|
3185
|
+
const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
|
|
3186
|
+
let rawBody;
|
|
3187
|
+
let extractedMessage;
|
|
3188
|
+
let parsedBody;
|
|
3189
|
+
const textFn = response?.text?.bind(response);
|
|
3190
|
+
if (textFn) {
|
|
3191
|
+
const [bodyError, body] = await catchError((async () => textFn())());
|
|
3192
|
+
if (!bodyError && body) {
|
|
3193
|
+
rawBody = body;
|
|
3194
|
+
const [parseError, parsed] = catchError(() => JSON.parse(body));
|
|
3195
|
+
if (!parseError && parsed && typeof parsed === "object") {
|
|
3196
|
+
parsedBody = parsed;
|
|
3197
|
+
if (parsedBody.errors && typeof parsedBody.errors === "object") {
|
|
3198
|
+
for (const field of Object.values(parsedBody.errors)) {
|
|
3199
|
+
if (Array.isArray(field) && field.length > 0) {
|
|
3200
|
+
const first = field[0];
|
|
3201
|
+
if (first && typeof first.message === "string") {
|
|
3202
|
+
extractedMessage = first.message;
|
|
3203
|
+
break;
|
|
3204
|
+
}
|
|
3205
|
+
}
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
if (!extractedMessage) {
|
|
3209
|
+
extractedMessage = typeof parsedBody.message === "string" ? parsedBody.message : typeof parsedBody.errorMessage === "string" ? parsedBody.errorMessage : typeof parsedBody.title === "string" ? parsedBody.title : undefined;
|
|
3210
|
+
}
|
|
3211
|
+
if (!extractedMessage) {
|
|
3212
|
+
extractedMessage = body;
|
|
3213
|
+
}
|
|
3214
|
+
if (extractedMessage && typeof parsedBody.detail === "string" && parsedBody.detail.length > 0 && !extractedMessage.includes(parsedBody.detail)) {
|
|
3215
|
+
extractedMessage = `${extractedMessage}: ${parsedBody.detail}`;
|
|
3216
|
+
}
|
|
3217
|
+
} else {
|
|
3218
|
+
extractedMessage = isHtmlDocument(body) ? HTML_RESPONSE_MESSAGE : body;
|
|
3219
|
+
}
|
|
2968
3220
|
}
|
|
2969
|
-
claimed.push({ claimedPath, payload: parsed });
|
|
2970
3221
|
}
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
const
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
3222
|
+
let message;
|
|
3223
|
+
let result = "Failure";
|
|
3224
|
+
const classificationStatus = status ?? findHttpStatusInGraph(error);
|
|
3225
|
+
const classification = classifyError(classificationStatus, error);
|
|
3226
|
+
let retry = classification.retry;
|
|
3227
|
+
const htmlForbidden = status === 403 && rawBody !== undefined && isHtmlDocument(rawBody);
|
|
3228
|
+
const rayId = htmlForbidden ? readHeader(response, "cf-ray") : undefined;
|
|
3229
|
+
const cloudflareBlock = htmlForbidden && (rayId !== undefined || /\bcloudflare\b/i.test(readHeader(response, "server") ?? ""));
|
|
3230
|
+
if (status === 401) {
|
|
3231
|
+
message = DEFAULT_401;
|
|
3232
|
+
result = "AuthenticationError";
|
|
3233
|
+
} else if (cloudflareBlock) {
|
|
3234
|
+
message = rayId ? `${CLOUDFLARE_BLOCK_403} Cloudflare Ray ID: ${rayId}.` : CLOUDFLARE_BLOCK_403;
|
|
3235
|
+
} else if (status === 403) {
|
|
3236
|
+
message = options?.forbiddenMessage ?? DEFAULT_403;
|
|
3237
|
+
result = "AuthenticationError";
|
|
3238
|
+
} else if (status === 405) {
|
|
3239
|
+
message = DEFAULT_405;
|
|
3240
|
+
} else if (status === 413) {
|
|
3241
|
+
message = DEFAULT_413;
|
|
3242
|
+
} else if (status === 400 || status === 422) {
|
|
3243
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
3244
|
+
result = "ValidationError";
|
|
3245
|
+
} else if (status === 429) {
|
|
3246
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
3247
|
+
} else if (extractedMessage) {
|
|
3248
|
+
if (isSuccessfulResponse && rawMessage !== "Unknown error") {
|
|
3249
|
+
message = rawMessage;
|
|
3250
|
+
} else {
|
|
3251
|
+
message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
|
|
3252
|
+
}
|
|
3253
|
+
} else if (status) {
|
|
3254
|
+
if (inferredStatus !== undefined) {
|
|
3255
|
+
message = rawMessage;
|
|
3256
|
+
} else if (rawMessage === "Unknown error" && response) {
|
|
3257
|
+
const statusText = response.statusText;
|
|
3258
|
+
message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
|
|
3259
|
+
} else {
|
|
3260
|
+
message = `HTTP ${status}: ${rawMessage}`;
|
|
2992
3261
|
}
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
3262
|
+
} else {
|
|
3263
|
+
message = rawMessage;
|
|
3264
|
+
}
|
|
3265
|
+
if (status === undefined) {
|
|
3266
|
+
const connectivity = describeConnectivityError(error);
|
|
3267
|
+
if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
|
|
3268
|
+
message = `${message}: ${connectivity.message}`;
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
const permission = status === undefined ? describePermissionError(error) : undefined;
|
|
3272
|
+
if (permission) {
|
|
3273
|
+
if (permission.message !== message && !message.includes(permission.message)) {
|
|
3274
|
+
message = `${message}: ${permission.message}`;
|
|
3275
|
+
}
|
|
3276
|
+
if (!message.includes(permission.instructions)) {
|
|
3277
|
+
const punctuated = message.endsWith(".") ? message : `${message}.`;
|
|
3278
|
+
message = `${punctuated} ${permission.instructions}`;
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
let details = rawMessage;
|
|
3282
|
+
if (htmlForbidden) {
|
|
3283
|
+
details = cloudflareBlock ? CLOUDFLARE_BLOCK_403_INSTRUCTIONS : HTML_RESPONSE_MESSAGE;
|
|
3284
|
+
} else if (rawBody) {
|
|
3285
|
+
if (parsedBody) {
|
|
3286
|
+
const extra = {};
|
|
3287
|
+
if (parsedBody.errorCode)
|
|
3288
|
+
extra.errorCode = parsedBody.errorCode;
|
|
3289
|
+
if (parsedBody.detail)
|
|
3290
|
+
extra.detail = parsedBody.detail;
|
|
3291
|
+
if (parsedBody.details)
|
|
3292
|
+
extra.details = parsedBody.details;
|
|
3293
|
+
if (parsedBody.errors != null)
|
|
3294
|
+
extra.errors = parsedBody.errors;
|
|
3295
|
+
if (parsedBody.data && typeof parsedBody.data === "object" && Object.keys(parsedBody.data).length > 0) {
|
|
3296
|
+
extra.data = parsedBody.data;
|
|
3297
|
+
}
|
|
3298
|
+
details = Object.keys(extra).length > 0 ? JSON.stringify(extra) : rawBody;
|
|
3299
|
+
} else {
|
|
3300
|
+
details = rawBody;
|
|
2996
3301
|
}
|
|
2997
|
-
|
|
2998
|
-
|
|
3302
|
+
} else if (typeof err.message === "string") {
|
|
3303
|
+
details = err.message;
|
|
3304
|
+
} else {
|
|
3305
|
+
details = describeThrownValue(error);
|
|
3306
|
+
}
|
|
3307
|
+
const context = {};
|
|
3308
|
+
if (classificationStatus) {
|
|
3309
|
+
context.httpStatus = classificationStatus;
|
|
3310
|
+
}
|
|
3311
|
+
if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
|
|
3312
|
+
context.errorCode = parsedBody.errorCode;
|
|
3313
|
+
} else if (parsedBody?.code && typeof parsedBody.code === "string") {
|
|
3314
|
+
context.errorCode = parsedBody.code;
|
|
3315
|
+
}
|
|
3316
|
+
if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
|
|
3317
|
+
context.requestId = parsedBody.requestId;
|
|
3318
|
+
} else if (cloudflareBlock && rayId) {
|
|
3319
|
+
context.requestId = rayId;
|
|
3320
|
+
}
|
|
3321
|
+
if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
|
|
3322
|
+
context.traceId = parsedBody.traceId;
|
|
3323
|
+
}
|
|
3324
|
+
if (permission?.path !== undefined) {
|
|
3325
|
+
context.path = permission.path;
|
|
3326
|
+
}
|
|
3327
|
+
if (status === 429) {
|
|
3328
|
+
const retryAfterValue = readHeader(response, "retry-after");
|
|
3329
|
+
if (retryAfterValue) {
|
|
3330
|
+
const seconds = Number(retryAfterValue);
|
|
3331
|
+
if (!Number.isNaN(seconds)) {
|
|
3332
|
+
context.retryAfter = seconds;
|
|
3333
|
+
retry = retryHintForRetryAfter(seconds);
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
}
|
|
3337
|
+
const hasContext = Object.keys(context).length > 0;
|
|
3338
|
+
let parsedErrors;
|
|
3339
|
+
if (parsedBody?.errors && typeof parsedBody.errors === "object") {
|
|
3340
|
+
const errors = {};
|
|
3341
|
+
for (const [field, raw] of Object.entries(parsedBody.errors)) {
|
|
3342
|
+
if (Array.isArray(raw)) {
|
|
3343
|
+
const messages = raw.map((entry) => {
|
|
3344
|
+
if (typeof entry === "string")
|
|
3345
|
+
return entry;
|
|
3346
|
+
if (entry && typeof entry === "object" && typeof entry.message === "string") {
|
|
3347
|
+
return entry.message;
|
|
3348
|
+
}
|
|
3349
|
+
return String(entry);
|
|
3350
|
+
}).filter(Boolean);
|
|
3351
|
+
if (messages.length > 0)
|
|
3352
|
+
errors[field] = messages;
|
|
3353
|
+
} else if (typeof raw === "string") {
|
|
3354
|
+
errors[field] = [raw];
|
|
3355
|
+
}
|
|
2999
3356
|
}
|
|
3357
|
+
if (Object.keys(errors).length > 0)
|
|
3358
|
+
parsedErrors = errors;
|
|
3000
3359
|
}
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3360
|
+
return {
|
|
3361
|
+
result,
|
|
3362
|
+
...withCarriedClass({ errorCode: classification.errorCode, retry }, error),
|
|
3363
|
+
message,
|
|
3364
|
+
details,
|
|
3365
|
+
...hasContext ? { context } : {},
|
|
3366
|
+
...parsedErrors ? { parsedErrors } : {}
|
|
3367
|
+
};
|
|
3368
|
+
}
|
|
3369
|
+
function extractErrorMessageSync(error) {
|
|
3370
|
+
if (error instanceof Error) {
|
|
3371
|
+
return error.message;
|
|
3372
|
+
}
|
|
3373
|
+
if (typeof error === "object" && error !== null) {
|
|
3374
|
+
if ("status" in error && error.status === 401) {
|
|
3375
|
+
return DEFAULT_401;
|
|
3376
|
+
}
|
|
3377
|
+
if ("message" in error && typeof error.message === "string") {
|
|
3378
|
+
return error.message;
|
|
3006
3379
|
}
|
|
3007
|
-
logger.debug(`[TelemetrySpool] deleted ${excess.length} oldest files over the ${MAX_SPOOL_FILES}-file cap`);
|
|
3008
3380
|
}
|
|
3381
|
+
return describeThrownValue(error);
|
|
3009
3382
|
}
|
|
3010
3383
|
|
|
3011
|
-
// ../common/src/
|
|
3012
|
-
|
|
3384
|
+
// ../common/src/result-types.ts
|
|
3385
|
+
var RESULTS = {
|
|
3386
|
+
Success: "Success",
|
|
3387
|
+
Failure: "Failure",
|
|
3388
|
+
ConfigError: "ConfigError",
|
|
3389
|
+
AuthenticationError: "AuthenticationError",
|
|
3390
|
+
ValidationError: "ValidationError",
|
|
3391
|
+
TimeoutError: "TimeoutError"
|
|
3392
|
+
};
|
|
3013
3393
|
|
|
3014
|
-
//
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3394
|
+
// ../../node_modules/commander/index.js
|
|
3395
|
+
var exports_commander = {};
|
|
3396
|
+
__exportCjs(exports_commander, {
|
|
3397
|
+
program: () => $program,
|
|
3398
|
+
createCommand: () => $createCommand,
|
|
3399
|
+
createOption: () => $createOption,
|
|
3400
|
+
createArgument: () => $createArgument,
|
|
3401
|
+
Command: () => $Command,
|
|
3402
|
+
Option: () => $Option,
|
|
3403
|
+
Argument: () => $Argument,
|
|
3404
|
+
Help: () => $Help,
|
|
3405
|
+
CommanderError: () => $CommanderError,
|
|
3406
|
+
InvalidArgumentError: () => $InvalidArgumentError,
|
|
3407
|
+
InvalidOptionArgumentError: () => $InvalidOptionArgumentError
|
|
3408
|
+
}, {
|
|
3409
|
+
program: (value) => $program = value,
|
|
3410
|
+
createCommand: (value) => $createCommand = value,
|
|
3411
|
+
createOption: (value) => $createOption = value,
|
|
3412
|
+
createArgument: (value) => $createArgument = value,
|
|
3413
|
+
Command: (value) => $Command = value,
|
|
3414
|
+
Option: (value) => $Option = value,
|
|
3415
|
+
Argument: (value) => $Argument = value,
|
|
3416
|
+
Help: (value) => $Help = value,
|
|
3417
|
+
CommanderError: (value) => $CommanderError = value,
|
|
3418
|
+
InvalidArgumentError: (value) => $InvalidArgumentError = value,
|
|
3419
|
+
InvalidOptionArgumentError: (value) => $InvalidOptionArgumentError = value
|
|
3420
|
+
});
|
|
3421
|
+
var { Argument } = require_argument();
|
|
3422
|
+
var { Command: Command2 } = require_command();
|
|
3423
|
+
var { CommanderError, InvalidArgumentError } = require_error();
|
|
3424
|
+
var { Help } = require_help();
|
|
3425
|
+
var { Option: Option2 } = require_option();
|
|
3426
|
+
var $program = new Command2;
|
|
3427
|
+
var $createCommand = (name) => new Command2(name);
|
|
3428
|
+
var $createOption = (flags, description) => new Option2(flags, description);
|
|
3429
|
+
var $createArgument = (name, description) => new Argument(name, description);
|
|
3430
|
+
var $Command = Command2;
|
|
3431
|
+
var $Option = Option2;
|
|
3432
|
+
var $Argument = Argument;
|
|
3433
|
+
var $Help = Help;
|
|
3434
|
+
var $CommanderError = CommanderError;
|
|
3435
|
+
var $InvalidArgumentError = InvalidArgumentError;
|
|
3436
|
+
var $InvalidOptionArgumentError = InvalidArgumentError;
|
|
3031
3437
|
|
|
3032
|
-
//
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3438
|
+
// ../../node_modules/commander/esm.mjs
|
|
3439
|
+
var {
|
|
3440
|
+
program,
|
|
3441
|
+
createCommand,
|
|
3442
|
+
createArgument,
|
|
3443
|
+
createOption,
|
|
3444
|
+
CommanderError: CommanderError2,
|
|
3445
|
+
InvalidArgumentError: InvalidArgumentError2,
|
|
3446
|
+
InvalidOptionArgumentError,
|
|
3447
|
+
Command,
|
|
3448
|
+
Argument: Argument2,
|
|
3449
|
+
Option,
|
|
3450
|
+
Help: Help2
|
|
3451
|
+
} = exports_commander;
|
|
3452
|
+
|
|
3453
|
+
// ../common/src/output-context.ts
|
|
3454
|
+
function createStorage() {
|
|
3455
|
+
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
3456
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
3039
3457
|
return {
|
|
3040
|
-
|
|
3041
|
-
|
|
3458
|
+
getStore: () => {
|
|
3459
|
+
return;
|
|
3460
|
+
},
|
|
3461
|
+
run: (_store, fn) => fn()
|
|
3042
3462
|
};
|
|
3043
3463
|
}
|
|
3044
|
-
|
|
3045
|
-
logger.debug(formatMessage("Event", name, this.enrich(properties)));
|
|
3046
|
-
}
|
|
3047
|
-
async trackException({
|
|
3048
|
-
error,
|
|
3049
|
-
properties
|
|
3050
|
-
}) {
|
|
3051
|
-
logger.error(formatMessage("Exception", error.message, this.enrich({
|
|
3052
|
-
...properties,
|
|
3053
|
-
stack: error.stack
|
|
3054
|
-
})));
|
|
3055
|
-
}
|
|
3056
|
-
async trackRequest({
|
|
3057
|
-
name,
|
|
3058
|
-
durationMs,
|
|
3059
|
-
success,
|
|
3060
|
-
properties
|
|
3061
|
-
}) {
|
|
3062
|
-
logger.debug(formatMessage("Request", name, this.enrich({
|
|
3063
|
-
...properties,
|
|
3064
|
-
duration: `${durationMs}ms`,
|
|
3065
|
-
success
|
|
3066
|
-
})));
|
|
3067
|
-
}
|
|
3068
|
-
async trackDependency({
|
|
3069
|
-
name,
|
|
3070
|
-
type,
|
|
3071
|
-
durationMs,
|
|
3072
|
-
success,
|
|
3073
|
-
properties
|
|
3074
|
-
}) {
|
|
3075
|
-
logger.debug(formatMessage("Dependency", name, this.enrich({
|
|
3076
|
-
...properties,
|
|
3077
|
-
type,
|
|
3078
|
-
duration: `${durationMs}ms`,
|
|
3079
|
-
success
|
|
3080
|
-
})));
|
|
3081
|
-
}
|
|
3464
|
+
return new mod.AsyncLocalStorage;
|
|
3082
3465
|
}
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3466
|
+
var storageSingleton = singleton("OutputStorage");
|
|
3467
|
+
var sinkSlot = singleton("OutputSink");
|
|
3468
|
+
var outputStorage = storageSingleton.getOrInit(createStorage, (v) => ("getStore" in v));
|
|
3469
|
+
var CONSOLE_FALLBACK = {
|
|
3470
|
+
writeOut: (str) => process.stdout.write(str),
|
|
3471
|
+
writeErr: (str) => process.stderr.write(str),
|
|
3472
|
+
writeLog: (str) => process.stdout.write(str),
|
|
3473
|
+
capabilities: {
|
|
3474
|
+
isInteractive: false,
|
|
3475
|
+
canReadInput: false,
|
|
3476
|
+
supportsColor: false,
|
|
3477
|
+
outputWidth: 80
|
|
3090
3478
|
}
|
|
3091
|
-
|
|
3479
|
+
};
|
|
3480
|
+
function runWithSink(sink, fn) {
|
|
3481
|
+
return outputStorage.run(sink, fn);
|
|
3092
3482
|
}
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
{ envVar: "CLAUDECODE", value: "1", id: "claude-code" },
|
|
3096
|
-
{ envVar: "CURSOR_AGENT", value: "1", id: "cursor" },
|
|
3097
|
-
{ envVar: "GEMINI_CLI", value: "1", id: "gemini-cli" },
|
|
3098
|
-
{ envVar: "CODEX_THREAD_ID", id: "codex" },
|
|
3099
|
-
{ envVar: "CODEX_SANDBOX", id: "codex" },
|
|
3100
|
-
{ envVar: "AUGMENT_AGENT", value: "1", id: "augment" },
|
|
3101
|
-
{ envVar: "CLINE_ACTIVE", value: "true", id: "cline" }
|
|
3102
|
-
];
|
|
3103
|
-
function detectAgent() {
|
|
3104
|
-
return detectAgentFromEnv(process.env);
|
|
3483
|
+
function getOutputSink() {
|
|
3484
|
+
return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
|
|
3105
3485
|
}
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
return detectAgentVersionFromEnv(process.env);
|
|
3486
|
+
function setGlobalSink(sink) {
|
|
3487
|
+
sinkSlot.set(sink);
|
|
3109
3488
|
}
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
return version?.replace(/-/g, ".");
|
|
3489
|
+
|
|
3490
|
+
// ../common/src/logger.ts
|
|
3491
|
+
var logFilePathSlot = singleton("logFilePath");
|
|
3492
|
+
function setGlobalLogFilePath(path) {
|
|
3493
|
+
logFilePathSlot.set(path);
|
|
3116
3494
|
}
|
|
3117
|
-
function
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3495
|
+
function getGlobalLogFilePath() {
|
|
3496
|
+
return logFilePathSlot.get("");
|
|
3497
|
+
}
|
|
3498
|
+
var LogLevel;
|
|
3499
|
+
((LogLevel) => {
|
|
3500
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
3501
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
3502
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
3503
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
3504
|
+
})(LogLevel ||= {});
|
|
3505
|
+
var DEFAULT_LOG_LEVEL = 2 /* WARN */;
|
|
3506
|
+
|
|
3507
|
+
class SimpleLogger {
|
|
3508
|
+
__brand = "SimpleLogger";
|
|
3509
|
+
level;
|
|
3510
|
+
logFilePath;
|
|
3511
|
+
fileLoggingEnabled;
|
|
3512
|
+
pendingWrites = Promise.resolve();
|
|
3513
|
+
pendingInit = Promise.resolve();
|
|
3514
|
+
constructor() {
|
|
3515
|
+
this.level = SimpleLogger.resolveLevel();
|
|
3516
|
+
this.logFilePath = "";
|
|
3517
|
+
this.fileLoggingEnabled = false;
|
|
3518
|
+
}
|
|
3519
|
+
static getInstance() {
|
|
3520
|
+
return loggerSingleton.getOrInit(() => new SimpleLogger, (v) => ("__brand" in v) && v.__brand === "SimpleLogger");
|
|
3521
|
+
}
|
|
3522
|
+
static resetInstance() {
|
|
3523
|
+
loggerSingleton.clear();
|
|
3524
|
+
}
|
|
3525
|
+
static isNode = typeof process !== "undefined" && !!process.versions?.node;
|
|
3526
|
+
static resolveLevel() {
|
|
3527
|
+
if (SimpleLogger.isNode) {
|
|
3528
|
+
const explicitLevel = SimpleLogger.parseLevel(process.env?.UIP_LOG_LEVEL ?? "");
|
|
3529
|
+
if (explicitLevel !== undefined)
|
|
3530
|
+
return explicitLevel;
|
|
3531
|
+
const debugVal = process.env?.DEBUG;
|
|
3532
|
+
if (debugVal === "true" || debugVal === "1") {
|
|
3533
|
+
return 0 /* DEBUG */;
|
|
3534
|
+
}
|
|
3535
|
+
return DEFAULT_LOG_LEVEL;
|
|
3536
|
+
}
|
|
3537
|
+
const [localStorageError, hasDebug] = catchError(() => typeof localStorage !== "undefined" && !!localStorage.getItem("debug"));
|
|
3538
|
+
if (!localStorageError && hasDebug) {
|
|
3539
|
+
return 0 /* DEBUG */;
|
|
3540
|
+
}
|
|
3541
|
+
return DEFAULT_LOG_LEVEL;
|
|
3542
|
+
}
|
|
3543
|
+
static parseLevel(value) {
|
|
3544
|
+
switch (value.toLowerCase()) {
|
|
3545
|
+
case "debug":
|
|
3546
|
+
return 0 /* DEBUG */;
|
|
3547
|
+
case "info":
|
|
3548
|
+
return 1 /* INFO */;
|
|
3549
|
+
case "warn":
|
|
3550
|
+
return 2 /* WARN */;
|
|
3551
|
+
case "error":
|
|
3552
|
+
return 3 /* ERROR */;
|
|
3553
|
+
default:
|
|
3554
|
+
return;
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
format(message, args) {
|
|
3558
|
+
if (args.length === 0)
|
|
3559
|
+
return `${message}
|
|
3560
|
+
`;
|
|
3561
|
+
return `${message} ${args.map(String).join(" ")}
|
|
3562
|
+
`;
|
|
3563
|
+
}
|
|
3564
|
+
isFileLoggingActive() {
|
|
3565
|
+
return this.fileLoggingEnabled || !!getGlobalLogFilePath();
|
|
3566
|
+
}
|
|
3567
|
+
writeToFile(formatted) {
|
|
3568
|
+
const path = this.logFilePath || getGlobalLogFilePath();
|
|
3569
|
+
if (!path)
|
|
3570
|
+
return;
|
|
3571
|
+
const timestamp = new Date().toISOString();
|
|
3572
|
+
this.pendingWrites = Promise.all([
|
|
3573
|
+
this.pendingWrites,
|
|
3574
|
+
this.pendingInit
|
|
3575
|
+
]).then(() => getFileSystem2().appendFile(path, `${timestamp} ${formatted}`).catch(() => {}));
|
|
3576
|
+
}
|
|
3577
|
+
write(formatted) {
|
|
3578
|
+
if (this.isFileLoggingActive()) {
|
|
3579
|
+
this.writeToFile(formatted);
|
|
3123
3580
|
} else {
|
|
3124
|
-
|
|
3125
|
-
return agent.id;
|
|
3581
|
+
getOutputSink().writeErr(formatted);
|
|
3126
3582
|
}
|
|
3127
3583
|
}
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
return agentEnv.toLowerCase();
|
|
3584
|
+
debug(message, ...args) {
|
|
3585
|
+
if (this.level > 0 /* DEBUG */)
|
|
3586
|
+
return;
|
|
3587
|
+
const formatted = this.format(`[DEBUG] ${message}`, args);
|
|
3588
|
+
this.write(formatted);
|
|
3134
3589
|
}
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
ApplicationName: "ApplicationName",
|
|
3141
|
-
ProductVersion: "ProductVersion",
|
|
3142
|
-
InstallationId: "InstallationId",
|
|
3143
|
-
CloudUserId: "CloudUserId",
|
|
3144
|
-
CloudTenantId: "CloudTenantId",
|
|
3145
|
-
CloudOrganizationId: "CloudOrganizationId",
|
|
3146
|
-
IsInternalUser: "IsInternalUser",
|
|
3147
|
-
Environment: "Environment",
|
|
3148
|
-
BaseUrl: "BaseUrl",
|
|
3149
|
-
Region: "Region",
|
|
3150
|
-
Agent: "Agent",
|
|
3151
|
-
AgentVersion: "AgentVersion",
|
|
3152
|
-
AgentModel: "AgentModel",
|
|
3153
|
-
ToolName: "ToolName",
|
|
3154
|
-
ToolVersion: "ToolVersion",
|
|
3155
|
-
ExecutionContext: "ExecutionContext",
|
|
3156
|
-
CiProvider: "CiProvider",
|
|
3157
|
-
SessionIdSource: "SessionIdSource",
|
|
3158
|
-
SessionId: "SessionId"
|
|
3159
|
-
};
|
|
3160
|
-
var CommandDimensions = {
|
|
3161
|
-
IsCommand: "IsCommand",
|
|
3162
|
-
IsReexec: "IsReexec",
|
|
3163
|
-
CommandName: "CommandName",
|
|
3164
|
-
ExitCode: "ExitCode",
|
|
3165
|
-
TerminalOutcome: "TerminalOutcome",
|
|
3166
|
-
ErrorClass: "ErrorClass",
|
|
3167
|
-
TerminalSignal: "TerminalSignal",
|
|
3168
|
-
ErrorMessage: "ErrorMessage",
|
|
3169
|
-
SkillName: "SkillName",
|
|
3170
|
-
ProductArea: "ProductArea",
|
|
3171
|
-
Mode: "Mode"
|
|
3172
|
-
};
|
|
3173
|
-
var ShipDimensions = {
|
|
3174
|
-
ShipKind: "ShipKind",
|
|
3175
|
-
Target: "Target",
|
|
3176
|
-
ProjectType: "ProjectType",
|
|
3177
|
-
ProjectTypes: "ProjectTypes",
|
|
3178
|
-
ArtifactCorrelationKey: "ArtifactCorrelationKey",
|
|
3179
|
-
PackageName: "PackageName",
|
|
3180
|
-
PackageVersion: "PackageVersion",
|
|
3181
|
-
PackageVersionKey: "PackageVersionKey",
|
|
3182
|
-
DeploymentKey: "DeploymentKey",
|
|
3183
|
-
SolutionId: "SolutionId",
|
|
3184
|
-
FolderKey: "FolderKey",
|
|
3185
|
-
FeedId: "FeedId"
|
|
3186
|
-
};
|
|
3187
|
-
var ErrorDimensions = {
|
|
3188
|
-
Result: "Result",
|
|
3189
|
-
ErrorCode: "ErrorCode",
|
|
3190
|
-
Retry: "Retry",
|
|
3191
|
-
ErrorMessage: "ErrorMessage",
|
|
3192
|
-
HttpStatus: "HttpStatus",
|
|
3193
|
-
UpstreamErrorCode: "UpstreamErrorCode"
|
|
3194
|
-
};
|
|
3195
|
-
var AuthDimensions = {
|
|
3196
|
-
AuthenticationMethod: "AuthenticationMethod",
|
|
3197
|
-
Success: "Success",
|
|
3198
|
-
Reason: "Reason"
|
|
3199
|
-
};
|
|
3200
|
-
var SkillsDimensions = {
|
|
3201
|
-
SchemaVersion: "SchemaVersion",
|
|
3202
|
-
AgentType: "AgentType",
|
|
3203
|
-
SkillsVersion: "SkillsVersion",
|
|
3204
|
-
UipSubcommand: "UipSubcommand",
|
|
3205
|
-
FileExtension: "FileExtension",
|
|
3206
|
-
SubagentModel: "SubagentModel",
|
|
3207
|
-
SubagentType: "SubagentType",
|
|
3208
|
-
PermissionMode: "PermissionMode",
|
|
3209
|
-
EffortLevel: "EffortLevel",
|
|
3210
|
-
SessionSource: "SessionSource",
|
|
3211
|
-
Outcome: "Outcome",
|
|
3212
|
-
DurationMs: "DurationMs",
|
|
3213
|
-
Source: "Source"
|
|
3214
|
-
};
|
|
3215
|
-
var PackagerDimensions = {
|
|
3216
|
-
ProjectId: "ProjectId",
|
|
3217
|
-
ProjectType: "ProjectType",
|
|
3218
|
-
SolutionId: "SolutionId"
|
|
3219
|
-
};
|
|
3220
|
-
var ScopeDimensions = {
|
|
3221
|
-
FolderId: "FolderId"
|
|
3222
|
-
};
|
|
3223
|
-
var ID_DIMENSIONS = new Set([
|
|
3224
|
-
BaseDimensions.CloudUserId,
|
|
3225
|
-
BaseDimensions.CloudTenantId,
|
|
3226
|
-
BaseDimensions.CloudOrganizationId,
|
|
3227
|
-
BaseDimensions.InstallationId,
|
|
3228
|
-
ShipDimensions.ArtifactCorrelationKey,
|
|
3229
|
-
ShipDimensions.PackageVersionKey,
|
|
3230
|
-
ShipDimensions.DeploymentKey,
|
|
3231
|
-
ShipDimensions.SolutionId,
|
|
3232
|
-
ShipDimensions.FolderKey,
|
|
3233
|
-
ShipDimensions.FeedId,
|
|
3234
|
-
PackagerDimensions.ProjectId
|
|
3235
|
-
]);
|
|
3236
|
-
var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
|
|
3237
|
-
var RESERVED_DIMENSION_NAMES = new Set([
|
|
3238
|
-
...Object.values(BaseDimensions),
|
|
3239
|
-
...Object.values(CommandDimensions),
|
|
3240
|
-
...Object.values(ShipDimensions),
|
|
3241
|
-
...Object.values(ErrorDimensions),
|
|
3242
|
-
...Object.values(AuthDimensions),
|
|
3243
|
-
...Object.values(SkillsDimensions),
|
|
3244
|
-
...Object.values(PackagerDimensions),
|
|
3245
|
-
...Object.values(ScopeDimensions)
|
|
3246
|
-
]);
|
|
3247
|
-
var CURATED_DIMENSIONS = new Set([
|
|
3248
|
-
BaseDimensions.ApplicationName,
|
|
3249
|
-
BaseDimensions.ProductVersion,
|
|
3250
|
-
BaseDimensions.InstallationId,
|
|
3251
|
-
BaseDimensions.CloudUserId,
|
|
3252
|
-
BaseDimensions.CloudTenantId,
|
|
3253
|
-
BaseDimensions.CloudOrganizationId,
|
|
3254
|
-
BaseDimensions.IsInternalUser,
|
|
3255
|
-
BaseDimensions.Environment,
|
|
3256
|
-
BaseDimensions.BaseUrl,
|
|
3257
|
-
BaseDimensions.Region,
|
|
3258
|
-
BaseDimensions.Agent,
|
|
3259
|
-
BaseDimensions.AgentVersion,
|
|
3260
|
-
BaseDimensions.ToolVersion,
|
|
3261
|
-
BaseDimensions.ExecutionContext,
|
|
3262
|
-
BaseDimensions.CiProvider,
|
|
3263
|
-
BaseDimensions.SessionIdSource,
|
|
3264
|
-
BaseDimensions.SessionId,
|
|
3265
|
-
...Object.values(CommandDimensions),
|
|
3266
|
-
...Object.values(ShipDimensions)
|
|
3267
|
-
]);
|
|
3268
|
-
function assertNoCuratedDimensionTargets(map, mapName) {
|
|
3269
|
-
for (const [inputKey, dimension] of Object.entries(map)) {
|
|
3270
|
-
if (CURATED_DIMENSIONS.has(dimension)) {
|
|
3271
|
-
throw new Error(`${mapName}: input field "${inputKey}" maps to curated dimension "${dimension}"`);
|
|
3272
|
-
}
|
|
3590
|
+
info(message, ...args) {
|
|
3591
|
+
if (this.level > 1 /* INFO */)
|
|
3592
|
+
return;
|
|
3593
|
+
const formatted = this.format(message, args);
|
|
3594
|
+
this.write(formatted);
|
|
3273
3595
|
}
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
}
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3596
|
+
warn(message, ...args) {
|
|
3597
|
+
if (this.level > 2 /* WARN */)
|
|
3598
|
+
return;
|
|
3599
|
+
const formatted = this.format(`[WARN] ${message}`, args);
|
|
3600
|
+
this.write(formatted);
|
|
3601
|
+
}
|
|
3602
|
+
error(message, ...args) {
|
|
3603
|
+
if (this.level > 3 /* ERROR */)
|
|
3604
|
+
return;
|
|
3605
|
+
const formatted = this.format(`[ERROR] ${message}`, args);
|
|
3606
|
+
this.write(formatted);
|
|
3607
|
+
}
|
|
3608
|
+
report(message) {
|
|
3609
|
+
const formatted = this.format(message, []);
|
|
3610
|
+
this.write(formatted);
|
|
3611
|
+
}
|
|
3612
|
+
getLevel() {
|
|
3613
|
+
return this.level;
|
|
3614
|
+
}
|
|
3615
|
+
setLevel(level) {
|
|
3616
|
+
this.level = level;
|
|
3617
|
+
}
|
|
3618
|
+
setFileLogging(enabled) {
|
|
3619
|
+
this.fileLoggingEnabled = enabled;
|
|
3620
|
+
if (!enabled) {
|
|
3621
|
+
this.logFilePath = "";
|
|
3622
|
+
setGlobalLogFilePath("");
|
|
3289
3623
|
}
|
|
3290
3624
|
}
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3625
|
+
setLogFile(path) {
|
|
3626
|
+
this.logFilePath = path;
|
|
3627
|
+
setGlobalLogFilePath(path);
|
|
3628
|
+
if (!path)
|
|
3629
|
+
return;
|
|
3630
|
+
this.fileLoggingEnabled = true;
|
|
3631
|
+
const fs = getFileSystem2();
|
|
3632
|
+
this.pendingInit = (async () => {
|
|
3633
|
+
const [error] = await catchError((async () => {
|
|
3634
|
+
await fs.mkdir(fs.path.dirname(path));
|
|
3635
|
+
await fs.writeFile(path, "");
|
|
3636
|
+
})());
|
|
3637
|
+
if (error)
|
|
3638
|
+
this.fileLoggingEnabled = false;
|
|
3639
|
+
})();
|
|
3303
3640
|
}
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
if (!host)
|
|
3308
|
-
return "unknown";
|
|
3309
|
-
if (LOCAL_HOSTS.has(host) || host.endsWith(".local"))
|
|
3310
|
-
return "local";
|
|
3311
|
-
if (host.includes("alpha"))
|
|
3312
|
-
return "alpha";
|
|
3313
|
-
if (host.includes("staging") || host.includes("stage"))
|
|
3314
|
-
return "staging";
|
|
3315
|
-
if (host === "cloud.uipath.com" || host.endsWith(".uipath.us")) {
|
|
3316
|
-
return "prod";
|
|
3641
|
+
async flushFile() {
|
|
3642
|
+
await this.pendingInit;
|
|
3643
|
+
await this.pendingWrites;
|
|
3317
3644
|
}
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
function normalizeBaseUrl(baseUrl) {
|
|
3321
|
-
if (!baseUrl)
|
|
3322
|
-
return;
|
|
3323
|
-
try {
|
|
3324
|
-
return new URL(baseUrl).origin;
|
|
3325
|
-
} catch {
|
|
3326
|
-
return;
|
|
3645
|
+
getLogFilePath() {
|
|
3646
|
+
return this.logFilePath || getGlobalLogFilePath();
|
|
3327
3647
|
}
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
}
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3648
|
+
handleLog = (logMessage) => {
|
|
3649
|
+
const parts = [];
|
|
3650
|
+
if (logMessage.source) {
|
|
3651
|
+
parts.push(`[${logMessage.source}]`);
|
|
3652
|
+
}
|
|
3653
|
+
if (logMessage.sourceTarget) {
|
|
3654
|
+
parts.push(`[${logMessage.sourceTarget}]`);
|
|
3655
|
+
}
|
|
3656
|
+
parts.push(logMessage.message);
|
|
3657
|
+
const msg = parts.join(" ");
|
|
3658
|
+
switch (logMessage.logLevel) {
|
|
3659
|
+
case "Debug":
|
|
3660
|
+
this.debug(msg);
|
|
3661
|
+
break;
|
|
3662
|
+
case "Information":
|
|
3663
|
+
this.info(msg);
|
|
3664
|
+
break;
|
|
3665
|
+
case "Warning":
|
|
3666
|
+
this.warn(msg);
|
|
3667
|
+
break;
|
|
3668
|
+
case "Error":
|
|
3669
|
+
this.error(msg);
|
|
3670
|
+
break;
|
|
3671
|
+
default:
|
|
3672
|
+
this.info(msg);
|
|
3673
|
+
break;
|
|
3674
|
+
}
|
|
3338
3675
|
};
|
|
3339
|
-
const normalized = normalizeBaseUrl(baseUrl);
|
|
3340
|
-
if (normalized)
|
|
3341
|
-
props[BaseDimensions.BaseUrl] = normalized;
|
|
3342
|
-
const region = deriveRegion(baseUrl);
|
|
3343
|
-
if (region)
|
|
3344
|
-
props[BaseDimensions.Region] = region;
|
|
3345
|
-
return props;
|
|
3346
|
-
}
|
|
3347
|
-
// ../common/src/telemetry/execution-context.ts
|
|
3348
|
-
var authSignalSlot = singleton("TelemetryExecutionContextAuthSignal");
|
|
3349
|
-
var isTruthy = (value) => value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
3350
|
-
var isEqual = (value, expected) => value?.toLowerCase() === expected;
|
|
3351
|
-
var CI_SIGNATURES = [
|
|
3352
|
-
{
|
|
3353
|
-
provider: "github_actions",
|
|
3354
|
-
matches: (env) => isTruthy(env.GITHUB_ACTIONS),
|
|
3355
|
-
isScheduler: (env) => env.GITHUB_EVENT_NAME === "schedule"
|
|
3356
|
-
},
|
|
3357
|
-
{
|
|
3358
|
-
provider: "azure_devops",
|
|
3359
|
-
matches: (env) => isTruthy(env.TF_BUILD),
|
|
3360
|
-
isScheduler: (env) => isEqual(env.BUILD_REASON, "schedule")
|
|
3361
|
-
},
|
|
3362
|
-
{
|
|
3363
|
-
provider: "gitlab",
|
|
3364
|
-
matches: (env) => isTruthy(env.GITLAB_CI),
|
|
3365
|
-
isScheduler: (env) => env.CI_PIPELINE_SOURCE === "schedule"
|
|
3366
|
-
},
|
|
3367
|
-
{
|
|
3368
|
-
provider: "circleci",
|
|
3369
|
-
matches: (env) => isTruthy(env.CIRCLECI),
|
|
3370
|
-
isScheduler: (env) => env.CIRCLE_PIPELINE_TRIGGER_SOURCE === "scheduled_pipeline"
|
|
3371
|
-
},
|
|
3372
|
-
{
|
|
3373
|
-
provider: "jenkins",
|
|
3374
|
-
matches: (env) => isTruthy(env.JENKINS_URL) || isTruthy(env.JENKINS_HOME)
|
|
3375
|
-
},
|
|
3376
|
-
{
|
|
3377
|
-
provider: "teamcity",
|
|
3378
|
-
matches: (env) => isTruthy(env.TEAMCITY_VERSION)
|
|
3379
|
-
},
|
|
3380
|
-
{
|
|
3381
|
-
provider: "buildkite",
|
|
3382
|
-
matches: (env) => isTruthy(env.BUILDKITE),
|
|
3383
|
-
isScheduler: (env) => env.BUILDKITE_SOURCE === "schedule"
|
|
3384
|
-
},
|
|
3385
|
-
{
|
|
3386
|
-
provider: "bitbucket",
|
|
3387
|
-
matches: (env) => isTruthy(env.BITBUCKET_BUILD_NUMBER)
|
|
3388
|
-
},
|
|
3389
|
-
{
|
|
3390
|
-
provider: "travis",
|
|
3391
|
-
matches: (env) => isTruthy(env.TRAVIS)
|
|
3392
|
-
},
|
|
3393
|
-
{
|
|
3394
|
-
provider: "appveyor",
|
|
3395
|
-
matches: (env) => isTruthy(env.APPVEYOR)
|
|
3396
|
-
},
|
|
3397
|
-
{
|
|
3398
|
-
provider: "generic",
|
|
3399
|
-
matches: (env) => isTruthy(env.CI)
|
|
3400
|
-
}
|
|
3401
|
-
];
|
|
3402
|
-
function currentEnv() {
|
|
3403
|
-
return typeof process === "undefined" ? {} : process.env;
|
|
3404
3676
|
}
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
return
|
|
3409
|
-
}
|
|
3410
|
-
function detectCi(env) {
|
|
3411
|
-
const signature = CI_SIGNATURES.find((candidate) => candidate.matches(env));
|
|
3412
|
-
if (!signature)
|
|
3413
|
-
return;
|
|
3414
|
-
return {
|
|
3415
|
-
executionContext: signature.isScheduler?.(env) ? "scheduler" : "ci",
|
|
3416
|
-
ciProvider: signature.provider
|
|
3417
|
-
};
|
|
3677
|
+
var loggerSingleton = singleton(SimpleLogger);
|
|
3678
|
+
var logger = SimpleLogger.getInstance();
|
|
3679
|
+
function getLogFilePath() {
|
|
3680
|
+
return logger.getLogFilePath();
|
|
3418
3681
|
}
|
|
3419
|
-
function
|
|
3420
|
-
if (
|
|
3421
|
-
|
|
3422
|
-
return;
|
|
3682
|
+
function configureLogger(config) {
|
|
3683
|
+
if (config.level !== undefined) {
|
|
3684
|
+
logger.setLevel(config.level);
|
|
3423
3685
|
}
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
function detectExecutionContext(options = {}) {
|
|
3427
|
-
const env = options.env ?? currentEnv();
|
|
3428
|
-
const ci = detectCi(env);
|
|
3429
|
-
if (ci)
|
|
3430
|
-
return ci;
|
|
3431
|
-
const agent = options.agent ?? detectAgentFromEnv(env);
|
|
3432
|
-
if (agent) {
|
|
3433
|
-
return { executionContext: "agent" };
|
|
3686
|
+
if (config.sink !== undefined) {
|
|
3687
|
+
setGlobalSink(config.sink);
|
|
3434
3688
|
}
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
return { executionContext: "service_account" };
|
|
3689
|
+
if (config.fileLogging !== undefined) {
|
|
3690
|
+
logger.setFileLogging(config.fileLogging);
|
|
3438
3691
|
}
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
return { executionContext: "manual" };
|
|
3692
|
+
if (config.logFile !== undefined) {
|
|
3693
|
+
logger.setLogFile(config.logFile);
|
|
3442
3694
|
}
|
|
3443
|
-
return { executionContext: "unknown" };
|
|
3444
|
-
}
|
|
3445
|
-
function getExecutionContextTelemetryProperties() {
|
|
3446
|
-
const detected = detectExecutionContext();
|
|
3447
|
-
return {
|
|
3448
|
-
[BaseDimensions.ExecutionContext]: detected.executionContext,
|
|
3449
|
-
...detected.ciProvider ? { [BaseDimensions.CiProvider]: detected.ciProvider } : {}
|
|
3450
|
-
};
|
|
3451
3695
|
}
|
|
3452
|
-
// ../common/src/telemetry/node-context-storage.ts
|
|
3453
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3454
3696
|
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3697
|
+
// ../common/src/timings.ts
|
|
3698
|
+
var TIMINGS_ENV_VAR = "UIP_TIMINGS";
|
|
3699
|
+
var TIMINGS_FILE_ENV_VAR = "UIP_TIMINGS_FILE";
|
|
3700
|
+
var TIMINGS_LINE_PREFIX = "[timing]";
|
|
3701
|
+
function createStorage2() {
|
|
3702
|
+
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
3703
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
3704
|
+
return {
|
|
3705
|
+
getStore: () => {
|
|
3706
|
+
return;
|
|
3707
|
+
},
|
|
3708
|
+
run: (_store, fn) => fn()
|
|
3709
|
+
};
|
|
3462
3710
|
}
|
|
3711
|
+
return new mod.AsyncLocalStorage;
|
|
3463
3712
|
}
|
|
3464
|
-
|
|
3465
|
-
var
|
|
3466
|
-
var
|
|
3467
|
-
|
|
3468
|
-
|
|
3713
|
+
var storageSlot = singleton("TimingStorage");
|
|
3714
|
+
var stateSlot = singleton("Timings");
|
|
3715
|
+
var rootStartedSlot = singleton("TimingsRootStarted");
|
|
3716
|
+
var longLivedHostSlot = singleton("TimingsLongLivedHost");
|
|
3717
|
+
var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
|
|
3718
|
+
function newState(baseline) {
|
|
3719
|
+
return { baseline, httpMs: 0, httpCalls: 0 };
|
|
3469
3720
|
}
|
|
3470
|
-
function
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
|
|
3475
|
-
if (!match) {
|
|
3476
|
-
return;
|
|
3721
|
+
function getState() {
|
|
3722
|
+
const scoped = storage.getStore();
|
|
3723
|
+
if (scoped) {
|
|
3724
|
+
return scoped;
|
|
3477
3725
|
}
|
|
3478
|
-
const
|
|
3479
|
-
if (
|
|
3480
|
-
return;
|
|
3726
|
+
const pinned = livePinnedState();
|
|
3727
|
+
if (pinned !== undefined) {
|
|
3728
|
+
return pinned;
|
|
3481
3729
|
}
|
|
3482
|
-
return
|
|
3730
|
+
return newState(processStartIsInvocationStart() ? 0 : performance.now());
|
|
3483
3731
|
}
|
|
3484
|
-
function
|
|
3485
|
-
|
|
3732
|
+
function livePinnedState() {
|
|
3733
|
+
const pinned = stateSlot.get();
|
|
3734
|
+
return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
|
|
3486
3735
|
}
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
|
|
3490
|
-
var SESSION_ID_MAX_LENGTH = 64;
|
|
3491
|
-
var RANDOM_SESSION_ID_LENGTH = 32;
|
|
3492
|
-
var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
|
|
3493
|
-
var CONTROL_CHARACTERS = /\p{Cc}/gu;
|
|
3494
|
-
var INHERITED_SESSION_SOURCES = [
|
|
3495
|
-
{ envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
|
|
3496
|
-
{ envVar: "CODEX_THREAD_ID", source: "codex" },
|
|
3497
|
-
{ envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
|
|
3498
|
-
{ envVar: "TERM_SESSION_ID", source: "terminal" },
|
|
3499
|
-
{ envVar: "WT_SESSION", source: "terminal" }
|
|
3500
|
-
];
|
|
3501
|
-
var telemetrySessionSlot = singleton("TelemetrySession");
|
|
3502
|
-
var telemetryOperationIdSlot = singleton("TelemetryOperationId");
|
|
3503
|
-
function getProcessEnv2() {
|
|
3504
|
-
return globalThis.process?.env;
|
|
3736
|
+
function processStartIsInvocationStart() {
|
|
3737
|
+
return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
|
|
3505
3738
|
}
|
|
3506
|
-
function
|
|
3507
|
-
if (
|
|
3508
|
-
return;
|
|
3739
|
+
function nextBaseline() {
|
|
3740
|
+
if (!processStartIsInvocationStart()) {
|
|
3741
|
+
return performance.now();
|
|
3509
3742
|
}
|
|
3510
|
-
|
|
3511
|
-
return
|
|
3512
|
-
}
|
|
3513
|
-
function getConfiguredTelemetrySessionId() {
|
|
3514
|
-
return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
|
|
3743
|
+
rootStartedSlot.set(true);
|
|
3744
|
+
return 0;
|
|
3515
3745
|
}
|
|
3516
|
-
function
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3746
|
+
async function runWithTimings(fallbackCommand, fn) {
|
|
3747
|
+
const state = newState(nextBaseline());
|
|
3748
|
+
const enclosing = storage.getStore() ?? livePinnedState();
|
|
3749
|
+
return storage.run(state, async () => {
|
|
3750
|
+
stateSlot.set(state);
|
|
3751
|
+
try {
|
|
3752
|
+
return await fn();
|
|
3753
|
+
} finally {
|
|
3754
|
+
state.finished = true;
|
|
3755
|
+
if (stateSlot.get() === state) {
|
|
3756
|
+
if (enclosing === undefined || enclosing.finished) {
|
|
3757
|
+
stateSlot.clear();
|
|
3758
|
+
} else {
|
|
3759
|
+
stateSlot.set(enclosing);
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
if (timingsEnabled()) {
|
|
3763
|
+
await emitTimingReport(state, fallbackCommand);
|
|
3764
|
+
}
|
|
3521
3765
|
}
|
|
3522
|
-
}
|
|
3523
|
-
return;
|
|
3766
|
+
});
|
|
3524
3767
|
}
|
|
3525
|
-
function
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
let hex = "";
|
|
3529
|
-
for (const byte of bytes) {
|
|
3530
|
-
hex += byte.toString(16).padStart(2, "0");
|
|
3768
|
+
function timingsEnabled() {
|
|
3769
|
+
if (typeof process === "undefined") {
|
|
3770
|
+
return false;
|
|
3531
3771
|
}
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
const existing = telemetrySessionSlot.get();
|
|
3536
|
-
if (existing) {
|
|
3537
|
-
return existing;
|
|
3772
|
+
const value = process.env?.[TIMINGS_ENV_VAR];
|
|
3773
|
+
if (value === undefined) {
|
|
3774
|
+
return false;
|
|
3538
3775
|
}
|
|
3539
|
-
const
|
|
3540
|
-
|
|
3541
|
-
telemetrySessionSlot.set(resolved);
|
|
3542
|
-
return resolved;
|
|
3776
|
+
const normalized = value.trim().toLowerCase();
|
|
3777
|
+
return normalized === "1" || normalized === "true";
|
|
3543
3778
|
}
|
|
3544
|
-
function
|
|
3545
|
-
|
|
3779
|
+
function timingsFile() {
|
|
3780
|
+
if (typeof process === "undefined") {
|
|
3781
|
+
return;
|
|
3782
|
+
}
|
|
3783
|
+
const value = process.env?.[TIMINGS_FILE_ENV_VAR]?.trim();
|
|
3784
|
+
return value === undefined || value === "" ? undefined : value;
|
|
3546
3785
|
}
|
|
3547
|
-
function
|
|
3548
|
-
|
|
3786
|
+
function setTimingCommand(command) {
|
|
3787
|
+
if (!timingsEnabled()) {
|
|
3788
|
+
return;
|
|
3789
|
+
}
|
|
3790
|
+
getState().command = command;
|
|
3549
3791
|
}
|
|
3550
|
-
function
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
return existing;
|
|
3792
|
+
function recordExitCode(exitCode) {
|
|
3793
|
+
if (!timingsEnabled()) {
|
|
3794
|
+
return;
|
|
3554
3795
|
}
|
|
3555
|
-
|
|
3556
|
-
const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
|
|
3557
|
-
telemetryOperationIdSlot.set(generated);
|
|
3558
|
-
return generated;
|
|
3796
|
+
getState().exitCode = exitCode;
|
|
3559
3797
|
}
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3798
|
+
function suppressTimingReport() {
|
|
3799
|
+
if (!timingsEnabled()) {
|
|
3800
|
+
return;
|
|
3801
|
+
}
|
|
3802
|
+
getState().suppressed = true;
|
|
3565
3803
|
}
|
|
3566
|
-
function
|
|
3567
|
-
return
|
|
3804
|
+
function invocationStartedAt() {
|
|
3805
|
+
return new Date(performance.timeOrigin + getState().baseline);
|
|
3568
3806
|
}
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
function startSpanClock() {
|
|
3572
|
-
const started = performance.now();
|
|
3573
|
-
return {
|
|
3574
|
-
startedAt: new Date(performance.timeOrigin + started),
|
|
3575
|
-
elapsedMs: () => performance.now() - started
|
|
3576
|
-
};
|
|
3807
|
+
function invocationElapsedMs() {
|
|
3808
|
+
return performance.now() - getState().baseline;
|
|
3577
3809
|
}
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
telemetryProvider;
|
|
3582
|
-
contextStorage;
|
|
3583
|
-
operationId;
|
|
3584
|
-
defaultProperties;
|
|
3585
|
-
constructor(telemetryProvider, contextStorage) {
|
|
3586
|
-
this.telemetryProvider = telemetryProvider;
|
|
3587
|
-
this.contextStorage = contextStorage;
|
|
3588
|
-
}
|
|
3589
|
-
setOperationId(operationId) {
|
|
3590
|
-
this.operationId = operationId;
|
|
3591
|
-
}
|
|
3592
|
-
setProvider(provider) {
|
|
3593
|
-
this.telemetryProvider = provider;
|
|
3594
|
-
}
|
|
3595
|
-
setDefaultProperties(properties) {
|
|
3596
|
-
this.defaultProperties = properties === undefined ? undefined : { ...this.defaultProperties, ...properties };
|
|
3810
|
+
function markCommandStart() {
|
|
3811
|
+
if (!timingsEnabled()) {
|
|
3812
|
+
return;
|
|
3597
3813
|
}
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
});
|
|
3814
|
+
getState().commandStart = performance.now();
|
|
3815
|
+
}
|
|
3816
|
+
function recordCommandDuration(durationMs) {
|
|
3817
|
+
if (!timingsEnabled()) {
|
|
3818
|
+
return;
|
|
3604
3819
|
}
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
});
|
|
3820
|
+
getState().commandMs = durationMs;
|
|
3821
|
+
}
|
|
3822
|
+
function recordHttpCall(durationMs) {
|
|
3823
|
+
if (!timingsEnabled()) {
|
|
3824
|
+
return;
|
|
3611
3825
|
}
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
const durationMs = clock.elapsedMs();
|
|
3630
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
3631
|
-
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, {
|
|
3632
|
-
...properties,
|
|
3633
|
-
[CommandDimensions.ErrorMessage]: err.message
|
|
3634
|
-
}, context));
|
|
3635
|
-
throw error;
|
|
3826
|
+
const state = getState();
|
|
3827
|
+
state.httpMs += durationMs;
|
|
3828
|
+
state.httpCalls += 1;
|
|
3829
|
+
}
|
|
3830
|
+
function ms(value) {
|
|
3831
|
+
return `${Math.round(value)}ms`;
|
|
3832
|
+
}
|
|
3833
|
+
function quoteCommand(command) {
|
|
3834
|
+
let escaped = "";
|
|
3835
|
+
for (const char of command) {
|
|
3836
|
+
const code = char.codePointAt(0) ?? 0;
|
|
3837
|
+
if (char === "\\" || char === "'") {
|
|
3838
|
+
escaped += `\\${char}`;
|
|
3839
|
+
} else if (code < 32 || code >= 127 && code <= 159) {
|
|
3840
|
+
escaped += `\\x${code.toString(16).padStart(2, "0")}`;
|
|
3841
|
+
} else {
|
|
3842
|
+
escaped += char;
|
|
3636
3843
|
}
|
|
3637
3844
|
}
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
...parentId !== undefined ? { parentId } : {},
|
|
3651
|
-
id: this.generateId(),
|
|
3652
|
-
startedAt: startSpanClock().startedAt
|
|
3653
|
-
};
|
|
3654
|
-
}
|
|
3655
|
-
inboundParentIdFor(operationId) {
|
|
3656
|
-
const inbound = getInboundTraceContext();
|
|
3657
|
-
return inbound && inbound.traceId === operationId ? inbound.parentSpanId : undefined;
|
|
3658
|
-
}
|
|
3659
|
-
runWithContext(context, fn) {
|
|
3660
|
-
return this.contextStorage.run(context, fn);
|
|
3845
|
+
return `'${escaped}'`;
|
|
3846
|
+
}
|
|
3847
|
+
function formatTimingReport(args) {
|
|
3848
|
+
const total = Math.round(args.totalMs);
|
|
3849
|
+
const parts = [
|
|
3850
|
+
TIMINGS_LINE_PREFIX,
|
|
3851
|
+
quoteCommand(args.command),
|
|
3852
|
+
`exit=${args.exitCode}`,
|
|
3853
|
+
`total=${total}ms`
|
|
3854
|
+
];
|
|
3855
|
+
if (args.startupMs === undefined || args.commandMs === undefined) {
|
|
3856
|
+
return parts.join(" ");
|
|
3661
3857
|
}
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
}
|
|
3667
|
-
return {
|
|
3668
|
-
operationId: parentContext.operationId,
|
|
3669
|
-
parentId: parentContext.id,
|
|
3670
|
-
id: this.generateId(),
|
|
3671
|
-
startedAt: startSpanClock().startedAt
|
|
3672
|
-
};
|
|
3858
|
+
const startup = Math.min(Math.round(args.startupMs), total);
|
|
3859
|
+
const command = Math.min(Math.round(args.commandMs), total - startup);
|
|
3860
|
+
parts.push(`startup=${startup}ms`, `command=${command}ms`);
|
|
3861
|
+
if (args.httpCalls > 0) {
|
|
3862
|
+
parts.push(`http=${ms(args.httpMs)}`, `httpCalls=${args.httpCalls}`);
|
|
3673
3863
|
}
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3864
|
+
parts.push(`flush=${total - startup - command}ms`);
|
|
3865
|
+
return parts.join(" ");
|
|
3866
|
+
}
|
|
3867
|
+
async function emitTimingReport(state, fallbackCommand) {
|
|
3868
|
+
if (state.suppressed) {
|
|
3869
|
+
return;
|
|
3680
3870
|
}
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
});
|
|
3700
|
-
return result;
|
|
3701
|
-
} catch (error) {
|
|
3702
|
-
const durationMs = clock.elapsedMs();
|
|
3703
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
3704
|
-
await this.telemetryProvider.trackDependency({
|
|
3705
|
-
...this.spanFor(name, durationMs, false, {
|
|
3706
|
-
...properties,
|
|
3707
|
-
[CommandDimensions.ErrorMessage]: err.message
|
|
3708
|
-
}, childContext),
|
|
3709
|
-
type
|
|
3710
|
-
});
|
|
3711
|
-
throw error;
|
|
3712
|
-
}
|
|
3871
|
+
const now = performance.now();
|
|
3872
|
+
const line = formatTimingReport({
|
|
3873
|
+
command: state.command ?? fallbackCommand,
|
|
3874
|
+
exitCode: state.exitCode ?? 0,
|
|
3875
|
+
totalMs: now - state.baseline,
|
|
3876
|
+
...state.commandStart !== undefined && {
|
|
3877
|
+
startupMs: state.commandStart - state.baseline
|
|
3878
|
+
},
|
|
3879
|
+
...state.commandMs !== undefined && {
|
|
3880
|
+
commandMs: state.commandMs
|
|
3881
|
+
},
|
|
3882
|
+
httpMs: state.httpMs,
|
|
3883
|
+
httpCalls: state.httpCalls
|
|
3884
|
+
});
|
|
3885
|
+
const file = timingsFile();
|
|
3886
|
+
if (file === undefined) {
|
|
3887
|
+
logger.report(line);
|
|
3888
|
+
return;
|
|
3713
3889
|
}
|
|
3714
|
-
|
|
3715
|
-
|
|
3890
|
+
const [error] = await catchError(() => getFileSystem2().appendFile(file, `${line}
|
|
3891
|
+
`));
|
|
3892
|
+
if (error) {
|
|
3893
|
+
logger.report(line);
|
|
3716
3894
|
}
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3895
|
+
}
|
|
3896
|
+
|
|
3897
|
+
// ../common/src/exit-code.ts
|
|
3898
|
+
function setExitCode(code) {
|
|
3899
|
+
process.exitCode = code;
|
|
3900
|
+
recordExitCode(code);
|
|
3901
|
+
}
|
|
3902
|
+
var GENERIC_FAILURE_EXIT_CODE = 1;
|
|
3903
|
+
function recordCommandExit(code) {
|
|
3904
|
+
if (code === GENERIC_FAILURE_EXIT_CODE && getExitCode() !== 0) {
|
|
3905
|
+
return;
|
|
3723
3906
|
}
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
properties: this.enrichProperties(properties),
|
|
3730
|
-
operationId: context.operationId,
|
|
3731
|
-
...context.parentId !== undefined ? { parentId: context.parentId } : {},
|
|
3732
|
-
id: context.id,
|
|
3733
|
-
...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
|
|
3734
|
-
};
|
|
3907
|
+
setExitCode(code);
|
|
3908
|
+
}
|
|
3909
|
+
function recordHostExit(code) {
|
|
3910
|
+
if (code === 0 && getExitCode() !== 0) {
|
|
3911
|
+
return;
|
|
3735
3912
|
}
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3913
|
+
recordCommandExit(code);
|
|
3914
|
+
}
|
|
3915
|
+
function getExitCode() {
|
|
3916
|
+
const code = process.exitCode;
|
|
3917
|
+
return typeof code === "number" ? code : 0;
|
|
3918
|
+
}
|
|
3919
|
+
function resetExitCode() {
|
|
3920
|
+
process.exitCode = 0;
|
|
3921
|
+
}
|
|
3922
|
+
|
|
3923
|
+
// ../common/src/output-format-context.ts
|
|
3924
|
+
var formatSlot = singleton("OutputFormat");
|
|
3925
|
+
var formatExplicitSlot = singleton("OutputFormatExplicit");
|
|
3926
|
+
var helpRequestedSlot = singleton("HelpRequested");
|
|
3927
|
+
var filterSlot = singleton("OutputFilter");
|
|
3928
|
+
function setOutputFormat(format) {
|
|
3929
|
+
formatSlot.set(format);
|
|
3930
|
+
}
|
|
3931
|
+
function getOutputFormat() {
|
|
3932
|
+
return formatSlot.get("json");
|
|
3933
|
+
}
|
|
3934
|
+
function setOutputFormatExplicit(explicit) {
|
|
3935
|
+
formatExplicitSlot.set(explicit);
|
|
3936
|
+
}
|
|
3937
|
+
function getOutputFormatExplicit() {
|
|
3938
|
+
return formatExplicitSlot.get(false) ?? false;
|
|
3939
|
+
}
|
|
3940
|
+
function setHelpRequested(requested) {
|
|
3941
|
+
helpRequestedSlot.set(requested);
|
|
3942
|
+
}
|
|
3943
|
+
function getHelpRequested() {
|
|
3944
|
+
return helpRequestedSlot.get(false) ?? false;
|
|
3945
|
+
}
|
|
3946
|
+
function setOutputFilter(filter) {
|
|
3947
|
+
filterSlot.set(filter);
|
|
3948
|
+
}
|
|
3949
|
+
function getOutputFilter() {
|
|
3950
|
+
return filterSlot.get();
|
|
3951
|
+
}
|
|
3952
|
+
|
|
3953
|
+
// ../common/src/telemetry/detect-agent.ts
|
|
3954
|
+
var KNOWN_AGENTS = [
|
|
3955
|
+
{ envVar: "CLAUDECODE", value: "1", id: "claude-code" },
|
|
3956
|
+
{ envVar: "CURSOR_AGENT", value: "1", id: "cursor" },
|
|
3957
|
+
{ envVar: "GEMINI_CLI", value: "1", id: "gemini-cli" },
|
|
3958
|
+
{ envVar: "CODEX_THREAD_ID", id: "codex" },
|
|
3959
|
+
{ envVar: "CODEX_SANDBOX", id: "codex" },
|
|
3960
|
+
{ envVar: "AUGMENT_AGENT", value: "1", id: "augment" },
|
|
3961
|
+
{ envVar: "CLINE_ACTIVE", value: "true", id: "cline" }
|
|
3962
|
+
];
|
|
3963
|
+
function detectAgent() {
|
|
3964
|
+
return detectAgentFromEnv(process.env);
|
|
3965
|
+
}
|
|
3966
|
+
var AI_AGENT_PATTERN = /^[a-z0-9-]+_([0-9]+(?:-[0-9]+)*)_agent$/;
|
|
3967
|
+
function detectAgentVersion() {
|
|
3968
|
+
return detectAgentVersionFromEnv(process.env);
|
|
3969
|
+
}
|
|
3970
|
+
function detectAgentVersionFromEnv(env) {
|
|
3971
|
+
const raw = env.AI_AGENT;
|
|
3972
|
+
if (!raw || raw.length > 64)
|
|
3973
|
+
return;
|
|
3974
|
+
const version = AI_AGENT_PATTERN.exec(raw)?.[1];
|
|
3975
|
+
return version?.replace(/-/g, ".");
|
|
3976
|
+
}
|
|
3977
|
+
function detectAgentFromEnv(env) {
|
|
3978
|
+
for (const agent of KNOWN_AGENTS) {
|
|
3979
|
+
const envValue = env[agent.envVar];
|
|
3980
|
+
if (agent.value !== undefined) {
|
|
3981
|
+
if (envValue === agent.value)
|
|
3982
|
+
return agent.id;
|
|
3983
|
+
} else {
|
|
3984
|
+
if (envValue)
|
|
3985
|
+
return agent.id;
|
|
3986
|
+
}
|
|
3747
3987
|
}
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
for (const byte of bytes) {
|
|
3755
|
-
hex += byte.toString(16).padStart(2, "0");
|
|
3756
|
-
}
|
|
3757
|
-
} while (/^0+$/.test(hex));
|
|
3758
|
-
return hex;
|
|
3988
|
+
const agentEnv = env.AGENT;
|
|
3989
|
+
if (agentEnv) {
|
|
3990
|
+
if (agentEnv === "1" || agentEnv === "true")
|
|
3991
|
+
return "unknown";
|
|
3992
|
+
if (agentEnv.length <= 32)
|
|
3993
|
+
return agentEnv.toLowerCase();
|
|
3759
3994
|
}
|
|
3995
|
+
return;
|
|
3760
3996
|
}
|
|
3761
|
-
// ../common/src/
|
|
3762
|
-
var
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
return;
|
|
3771
|
-
},
|
|
3772
|
-
run: (_store, fn) => fn()
|
|
3773
|
-
};
|
|
3997
|
+
// ../common/src/telemetry/environment-info.ts
|
|
3998
|
+
var LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
3999
|
+
function parseHost(baseUrl) {
|
|
4000
|
+
if (!baseUrl)
|
|
4001
|
+
return;
|
|
4002
|
+
try {
|
|
4003
|
+
return new URL(baseUrl).hostname.toLowerCase();
|
|
4004
|
+
} catch {
|
|
4005
|
+
return;
|
|
3774
4006
|
}
|
|
3775
|
-
return new mod.AsyncLocalStorage;
|
|
3776
4007
|
}
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
4008
|
+
function normalizeEnvironment(baseUrl) {
|
|
4009
|
+
const host = parseHost(baseUrl);
|
|
4010
|
+
if (!host)
|
|
4011
|
+
return "unknown";
|
|
4012
|
+
if (LOCAL_HOSTS.has(host) || host.endsWith(".local"))
|
|
4013
|
+
return "local";
|
|
4014
|
+
if (host.includes("alpha"))
|
|
4015
|
+
return "alpha";
|
|
4016
|
+
if (host.includes("staging") || host.includes("stage"))
|
|
4017
|
+
return "staging";
|
|
4018
|
+
if (host === "cloud.uipath.com" || host.endsWith(".uipath.us")) {
|
|
4019
|
+
return "prod";
|
|
4020
|
+
}
|
|
4021
|
+
return "unknown";
|
|
3784
4022
|
}
|
|
3785
|
-
function
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
4023
|
+
function normalizeBaseUrl(baseUrl) {
|
|
4024
|
+
if (!baseUrl)
|
|
4025
|
+
return;
|
|
4026
|
+
try {
|
|
4027
|
+
return new URL(baseUrl).origin;
|
|
4028
|
+
} catch {
|
|
4029
|
+
return;
|
|
3789
4030
|
}
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
4031
|
+
}
|
|
4032
|
+
function deriveRegion(baseUrl) {
|
|
4033
|
+
const host = parseHost(baseUrl);
|
|
4034
|
+
if (host?.endsWith(".uipath.us"))
|
|
4035
|
+
return "gov";
|
|
4036
|
+
return;
|
|
4037
|
+
}
|
|
4038
|
+
function buildEnvironmentProperties(baseUrl) {
|
|
4039
|
+
const props = {
|
|
4040
|
+
[BaseDimensions.Environment]: normalizeEnvironment(baseUrl)
|
|
4041
|
+
};
|
|
4042
|
+
const normalized = normalizeBaseUrl(baseUrl);
|
|
4043
|
+
if (normalized)
|
|
4044
|
+
props[BaseDimensions.BaseUrl] = normalized;
|
|
4045
|
+
const region = deriveRegion(baseUrl);
|
|
4046
|
+
if (region)
|
|
4047
|
+
props[BaseDimensions.Region] = region;
|
|
4048
|
+
return props;
|
|
4049
|
+
}
|
|
4050
|
+
// ../common/src/telemetry/execution-context.ts
|
|
4051
|
+
var authSignalSlot = singleton("TelemetryExecutionContextAuthSignal");
|
|
4052
|
+
var isTruthy = (value) => value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
4053
|
+
var isEqual = (value, expected) => value?.toLowerCase() === expected;
|
|
4054
|
+
var CI_SIGNATURES = [
|
|
4055
|
+
{
|
|
4056
|
+
provider: "github_actions",
|
|
4057
|
+
matches: (env) => isTruthy(env.GITHUB_ACTIONS),
|
|
4058
|
+
isScheduler: (env) => env.GITHUB_EVENT_NAME === "schedule"
|
|
4059
|
+
},
|
|
4060
|
+
{
|
|
4061
|
+
provider: "azure_devops",
|
|
4062
|
+
matches: (env) => isTruthy(env.TF_BUILD),
|
|
4063
|
+
isScheduler: (env) => isEqual(env.BUILD_REASON, "schedule")
|
|
4064
|
+
},
|
|
4065
|
+
{
|
|
4066
|
+
provider: "gitlab",
|
|
4067
|
+
matches: (env) => isTruthy(env.GITLAB_CI),
|
|
4068
|
+
isScheduler: (env) => env.CI_PIPELINE_SOURCE === "schedule"
|
|
4069
|
+
},
|
|
4070
|
+
{
|
|
4071
|
+
provider: "circleci",
|
|
4072
|
+
matches: (env) => isTruthy(env.CIRCLECI),
|
|
4073
|
+
isScheduler: (env) => env.CIRCLE_PIPELINE_TRIGGER_SOURCE === "scheduled_pipeline"
|
|
4074
|
+
},
|
|
4075
|
+
{
|
|
4076
|
+
provider: "jenkins",
|
|
4077
|
+
matches: (env) => isTruthy(env.JENKINS_URL) || isTruthy(env.JENKINS_HOME)
|
|
4078
|
+
},
|
|
4079
|
+
{
|
|
4080
|
+
provider: "teamcity",
|
|
4081
|
+
matches: (env) => isTruthy(env.TEAMCITY_VERSION)
|
|
4082
|
+
},
|
|
4083
|
+
{
|
|
4084
|
+
provider: "buildkite",
|
|
4085
|
+
matches: (env) => isTruthy(env.BUILDKITE),
|
|
4086
|
+
isScheduler: (env) => env.BUILDKITE_SOURCE === "schedule"
|
|
4087
|
+
},
|
|
4088
|
+
{
|
|
4089
|
+
provider: "bitbucket",
|
|
4090
|
+
matches: (env) => isTruthy(env.BITBUCKET_BUILD_NUMBER)
|
|
4091
|
+
},
|
|
4092
|
+
{
|
|
4093
|
+
provider: "travis",
|
|
4094
|
+
matches: (env) => isTruthy(env.TRAVIS)
|
|
4095
|
+
},
|
|
4096
|
+
{
|
|
4097
|
+
provider: "appveyor",
|
|
4098
|
+
matches: (env) => isTruthy(env.APPVEYOR)
|
|
4099
|
+
},
|
|
4100
|
+
{
|
|
4101
|
+
provider: "generic",
|
|
4102
|
+
matches: (env) => isTruthy(env.CI)
|
|
3793
4103
|
}
|
|
3794
|
-
|
|
4104
|
+
];
|
|
4105
|
+
function currentEnv() {
|
|
4106
|
+
return typeof process === "undefined" ? {} : process.env;
|
|
4107
|
+
}
|
|
4108
|
+
function currentTtyState() {
|
|
4109
|
+
if (typeof process === "undefined")
|
|
4110
|
+
return false;
|
|
4111
|
+
return Boolean(process.stdout?.isTTY || process.stdin?.isTTY || process.stderr?.isTTY);
|
|
3795
4112
|
}
|
|
3796
|
-
function
|
|
3797
|
-
const
|
|
3798
|
-
|
|
4113
|
+
function detectCi(env) {
|
|
4114
|
+
const signature = CI_SIGNATURES.find((candidate) => candidate.matches(env));
|
|
4115
|
+
if (!signature)
|
|
4116
|
+
return;
|
|
4117
|
+
return {
|
|
4118
|
+
executionContext: signature.isScheduler?.(env) ? "scheduler" : "ci",
|
|
4119
|
+
ciProvider: signature.provider
|
|
4120
|
+
};
|
|
3799
4121
|
}
|
|
3800
|
-
function
|
|
3801
|
-
|
|
4122
|
+
function setExecutionContextAuthSignal(signal) {
|
|
4123
|
+
if (signal === undefined) {
|
|
4124
|
+
authSignalSlot.clear();
|
|
4125
|
+
return;
|
|
4126
|
+
}
|
|
4127
|
+
authSignalSlot.set(signal);
|
|
3802
4128
|
}
|
|
3803
|
-
function
|
|
3804
|
-
|
|
3805
|
-
|
|
4129
|
+
function detectExecutionContext(options = {}) {
|
|
4130
|
+
const env = options.env ?? currentEnv();
|
|
4131
|
+
const ci = detectCi(env);
|
|
4132
|
+
if (ci)
|
|
4133
|
+
return ci;
|
|
4134
|
+
const agent = options.agent ?? detectAgentFromEnv(env);
|
|
4135
|
+
if (agent) {
|
|
4136
|
+
return { executionContext: "agent" };
|
|
3806
4137
|
}
|
|
3807
|
-
|
|
3808
|
-
|
|
4138
|
+
const authSignal = options.authSignal ?? authSignalSlot.get();
|
|
4139
|
+
if (authSignal === "service_account") {
|
|
4140
|
+
return { executionContext: "service_account" };
|
|
4141
|
+
}
|
|
4142
|
+
const isTty = options.isTty ?? currentTtyState();
|
|
4143
|
+
if (isTty) {
|
|
4144
|
+
return { executionContext: "manual" };
|
|
4145
|
+
}
|
|
4146
|
+
return { executionContext: "unknown" };
|
|
3809
4147
|
}
|
|
3810
|
-
|
|
3811
|
-
const
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
return await fn();
|
|
3817
|
-
} finally {
|
|
3818
|
-
state.finished = true;
|
|
3819
|
-
if (stateSlot.get() === state) {
|
|
3820
|
-
if (enclosing === undefined || enclosing.finished) {
|
|
3821
|
-
stateSlot.clear();
|
|
3822
|
-
} else {
|
|
3823
|
-
stateSlot.set(enclosing);
|
|
3824
|
-
}
|
|
3825
|
-
}
|
|
3826
|
-
if (timingsEnabled()) {
|
|
3827
|
-
await emitTimingReport(state, fallbackCommand);
|
|
3828
|
-
}
|
|
3829
|
-
}
|
|
3830
|
-
});
|
|
4148
|
+
function getExecutionContextTelemetryProperties() {
|
|
4149
|
+
const detected = detectExecutionContext();
|
|
4150
|
+
return {
|
|
4151
|
+
[BaseDimensions.ExecutionContext]: detected.executionContext,
|
|
4152
|
+
...detected.ciProvider ? { [BaseDimensions.CiProvider]: detected.ciProvider } : {}
|
|
4153
|
+
};
|
|
3831
4154
|
}
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
4155
|
+
// ../common/src/telemetry/node-context-storage.ts
|
|
4156
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4157
|
+
|
|
4158
|
+
class NodeContextStorage {
|
|
4159
|
+
storage = new AsyncLocalStorage;
|
|
4160
|
+
run(context, fn) {
|
|
4161
|
+
return this.storage.run(context, fn);
|
|
3835
4162
|
}
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
return false;
|
|
4163
|
+
getContext() {
|
|
4164
|
+
return this.storage.getStore();
|
|
3839
4165
|
}
|
|
3840
|
-
const normalized = value.trim().toLowerCase();
|
|
3841
|
-
return normalized === "1" || normalized === "true";
|
|
3842
4166
|
}
|
|
3843
|
-
|
|
3844
|
-
|
|
4167
|
+
// ../common/src/telemetry/trace-context.ts
|
|
4168
|
+
var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
|
|
4169
|
+
var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
|
|
4170
|
+
function getProcessEnv() {
|
|
4171
|
+
return globalThis.process?.env;
|
|
4172
|
+
}
|
|
4173
|
+
function parseInboundTraceparent(value) {
|
|
4174
|
+
if (!value) {
|
|
3845
4175
|
return;
|
|
3846
4176
|
}
|
|
3847
|
-
const
|
|
3848
|
-
|
|
3849
|
-
}
|
|
3850
|
-
function setTimingCommand(command) {
|
|
3851
|
-
if (!timingsEnabled()) {
|
|
4177
|
+
const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
|
|
4178
|
+
if (!match) {
|
|
3852
4179
|
return;
|
|
3853
4180
|
}
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
function recordExitCode(exitCode) {
|
|
3857
|
-
if (!timingsEnabled()) {
|
|
4181
|
+
const [, traceId, parentSpanId] = match;
|
|
4182
|
+
if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
|
|
3858
4183
|
return;
|
|
3859
4184
|
}
|
|
3860
|
-
|
|
4185
|
+
return { traceId, parentSpanId };
|
|
3861
4186
|
}
|
|
3862
|
-
function
|
|
3863
|
-
|
|
4187
|
+
function getInboundTraceContext() {
|
|
4188
|
+
return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
|
|
4189
|
+
}
|
|
4190
|
+
|
|
4191
|
+
// ../common/src/telemetry/session-id.ts
|
|
4192
|
+
var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
|
|
4193
|
+
var SESSION_ID_MAX_LENGTH = 64;
|
|
4194
|
+
var RANDOM_SESSION_ID_LENGTH = 32;
|
|
4195
|
+
var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
|
|
4196
|
+
var CONTROL_CHARACTERS = /\p{Cc}/gu;
|
|
4197
|
+
var INHERITED_SESSION_SOURCES = [
|
|
4198
|
+
{ envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
|
|
4199
|
+
{ envVar: "CODEX_THREAD_ID", source: "codex" },
|
|
4200
|
+
{ envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
|
|
4201
|
+
{ envVar: "TERM_SESSION_ID", source: "terminal" },
|
|
4202
|
+
{ envVar: "WT_SESSION", source: "terminal" }
|
|
4203
|
+
];
|
|
4204
|
+
var telemetrySessionSlot = singleton("TelemetrySession");
|
|
4205
|
+
var telemetryOperationIdSlot = singleton("TelemetryOperationId");
|
|
4206
|
+
function getProcessEnv2() {
|
|
4207
|
+
return globalThis.process?.env;
|
|
4208
|
+
}
|
|
4209
|
+
function normalizeSessionId(value) {
|
|
4210
|
+
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
|
|
3864
4211
|
return;
|
|
3865
4212
|
}
|
|
3866
|
-
|
|
4213
|
+
const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
|
|
4214
|
+
return cleaned || undefined;
|
|
3867
4215
|
}
|
|
3868
|
-
function
|
|
3869
|
-
return
|
|
4216
|
+
function getConfiguredTelemetrySessionId() {
|
|
4217
|
+
return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
|
|
3870
4218
|
}
|
|
3871
|
-
function
|
|
3872
|
-
|
|
4219
|
+
function getInheritedSession(env) {
|
|
4220
|
+
for (const candidate of INHERITED_SESSION_SOURCES) {
|
|
4221
|
+
const handle = normalizeSessionId(env[candidate.envVar]);
|
|
4222
|
+
if (handle) {
|
|
4223
|
+
return { id: handle, source: candidate.source };
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4226
|
+
return;
|
|
3873
4227
|
}
|
|
3874
|
-
function
|
|
3875
|
-
|
|
3876
|
-
|
|
4228
|
+
function generateRandomSession() {
|
|
4229
|
+
const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
|
|
4230
|
+
crypto.getRandomValues(bytes);
|
|
4231
|
+
let hex = "";
|
|
4232
|
+
for (const byte of bytes) {
|
|
4233
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
3877
4234
|
}
|
|
3878
|
-
|
|
4235
|
+
return { id: hex, source: "random" };
|
|
3879
4236
|
}
|
|
3880
|
-
function
|
|
3881
|
-
|
|
3882
|
-
|
|
4237
|
+
function resolveTelemetrySession() {
|
|
4238
|
+
const existing = telemetrySessionSlot.get();
|
|
4239
|
+
if (existing) {
|
|
4240
|
+
return existing;
|
|
3883
4241
|
}
|
|
3884
|
-
|
|
4242
|
+
const declaredHandle = getConfiguredTelemetrySessionId();
|
|
4243
|
+
const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
|
|
4244
|
+
telemetrySessionSlot.set(resolved);
|
|
4245
|
+
return resolved;
|
|
3885
4246
|
}
|
|
3886
|
-
function
|
|
3887
|
-
|
|
3888
|
-
|
|
4247
|
+
function getTelemetrySessionId() {
|
|
4248
|
+
return resolveTelemetrySession().id;
|
|
4249
|
+
}
|
|
4250
|
+
function getTelemetrySessionSource() {
|
|
4251
|
+
return resolveTelemetrySession().source;
|
|
4252
|
+
}
|
|
4253
|
+
function getTelemetryOperationId() {
|
|
4254
|
+
const existing = telemetryOperationIdSlot.get();
|
|
4255
|
+
if (existing) {
|
|
4256
|
+
return existing;
|
|
3889
4257
|
}
|
|
3890
|
-
const
|
|
3891
|
-
|
|
3892
|
-
|
|
4258
|
+
const inboundTraceId = getInboundTraceContext()?.traceId;
|
|
4259
|
+
const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
|
|
4260
|
+
telemetryOperationIdSlot.set(generated);
|
|
4261
|
+
return generated;
|
|
3893
4262
|
}
|
|
3894
|
-
|
|
3895
|
-
|
|
4263
|
+
// ../common/src/telemetry/global-telemetry-properties.ts
|
|
4264
|
+
var telemetryPropsSlot = singleton("TelemetryDefaultProps");
|
|
4265
|
+
function setGlobalTelemetryProperties(properties) {
|
|
4266
|
+
const existing = getGlobalTelemetryProperties();
|
|
4267
|
+
telemetryPropsSlot.set({ ...existing, ...properties });
|
|
3896
4268
|
}
|
|
3897
|
-
function
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
4269
|
+
function getGlobalTelemetryProperties() {
|
|
4270
|
+
return telemetryPropsSlot.get();
|
|
4271
|
+
}
|
|
4272
|
+
|
|
4273
|
+
// ../common/src/telemetry/span-clock.ts
|
|
4274
|
+
function startSpanClock() {
|
|
4275
|
+
const started = performance.now();
|
|
4276
|
+
return {
|
|
4277
|
+
startedAt: new Date(performance.timeOrigin + started),
|
|
4278
|
+
elapsedMs: () => performance.now() - started
|
|
4279
|
+
};
|
|
4280
|
+
}
|
|
4281
|
+
|
|
4282
|
+
// ../common/src/telemetry/telemetry-service.ts
|
|
4283
|
+
class TelemetryService {
|
|
4284
|
+
telemetryProvider;
|
|
4285
|
+
contextStorage;
|
|
4286
|
+
operationId;
|
|
4287
|
+
defaultProperties;
|
|
4288
|
+
constructor(telemetryProvider, contextStorage) {
|
|
4289
|
+
this.telemetryProvider = telemetryProvider;
|
|
4290
|
+
this.contextStorage = contextStorage;
|
|
4291
|
+
}
|
|
4292
|
+
setOperationId(operationId) {
|
|
4293
|
+
this.operationId = operationId;
|
|
4294
|
+
}
|
|
4295
|
+
setProvider(provider) {
|
|
4296
|
+
this.telemetryProvider = provider;
|
|
4297
|
+
}
|
|
4298
|
+
setDefaultProperties(properties) {
|
|
4299
|
+
this.defaultProperties = properties === undefined ? undefined : { ...this.defaultProperties, ...properties };
|
|
4300
|
+
}
|
|
4301
|
+
trackEvent(name, properties) {
|
|
4302
|
+
this.telemetryProvider.trackEvent({
|
|
4303
|
+
name: redactSpanName(name),
|
|
4304
|
+
properties: this.enrichProperties(properties),
|
|
4305
|
+
...this.leafCorrelation()
|
|
4306
|
+
});
|
|
4307
|
+
}
|
|
4308
|
+
trackException(error, properties, context) {
|
|
4309
|
+
this.telemetryProvider.trackException({
|
|
4310
|
+
error: redactError(error),
|
|
4311
|
+
properties: this.enrichProperties(properties),
|
|
4312
|
+
...this.leafCorrelation(context)
|
|
4313
|
+
});
|
|
3908
4314
|
}
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
4315
|
+
async trackRequest(name, fn, properties) {
|
|
4316
|
+
const parentContext = this.getActiveContext();
|
|
4317
|
+
const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
|
|
4318
|
+
const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
|
|
4319
|
+
const clock = startSpanClock();
|
|
4320
|
+
const context = {
|
|
4321
|
+
operationId,
|
|
4322
|
+
...parentId !== undefined ? { parentId } : {},
|
|
4323
|
+
id: this.generateId(),
|
|
4324
|
+
startedAt: clock.startedAt
|
|
4325
|
+
};
|
|
4326
|
+
try {
|
|
4327
|
+
const result = await this.contextStorage.run(context, fn);
|
|
4328
|
+
const durationMs = clock.elapsedMs();
|
|
4329
|
+
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, true, properties, context));
|
|
4330
|
+
return result;
|
|
4331
|
+
} catch (error) {
|
|
4332
|
+
const durationMs = clock.elapsedMs();
|
|
4333
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
4334
|
+
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, {
|
|
4335
|
+
...properties,
|
|
4336
|
+
[CommandDimensions.ErrorMessage]: err.message
|
|
4337
|
+
}, context));
|
|
4338
|
+
throw error;
|
|
4339
|
+
}
|
|
3921
4340
|
}
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
4341
|
+
trackRequestResult(name, durationMs, success, properties, context) {
|
|
4342
|
+
const requestContext = context ?? {
|
|
4343
|
+
operationId: this.operationId ?? getTelemetryOperationId(),
|
|
4344
|
+
id: this.generateId()
|
|
4345
|
+
};
|
|
4346
|
+
this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, success, properties, requestContext));
|
|
3927
4347
|
}
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
4348
|
+
createRequestContext() {
|
|
4349
|
+
const operationId = this.operationId ?? getTelemetryOperationId();
|
|
4350
|
+
const parentId = this.inboundParentIdFor(operationId);
|
|
4351
|
+
return {
|
|
4352
|
+
operationId,
|
|
4353
|
+
...parentId !== undefined ? { parentId } : {},
|
|
4354
|
+
id: this.generateId(),
|
|
4355
|
+
startedAt: startSpanClock().startedAt
|
|
4356
|
+
};
|
|
3934
4357
|
}
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
exitCode: state.exitCode ?? 0,
|
|
3939
|
-
totalMs: now - state.baseline,
|
|
3940
|
-
...state.commandStart !== undefined && {
|
|
3941
|
-
startupMs: state.commandStart - state.baseline
|
|
3942
|
-
},
|
|
3943
|
-
...state.commandMs !== undefined && {
|
|
3944
|
-
commandMs: state.commandMs
|
|
3945
|
-
},
|
|
3946
|
-
httpMs: state.httpMs,
|
|
3947
|
-
httpCalls: state.httpCalls
|
|
3948
|
-
});
|
|
3949
|
-
const file = timingsFile();
|
|
3950
|
-
if (file === undefined) {
|
|
3951
|
-
logger.report(line);
|
|
3952
|
-
return;
|
|
4358
|
+
inboundParentIdFor(operationId) {
|
|
4359
|
+
const inbound = getInboundTraceContext();
|
|
4360
|
+
return inbound && inbound.traceId === operationId ? inbound.parentSpanId : undefined;
|
|
3953
4361
|
}
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
if (error) {
|
|
3957
|
-
logger.report(line);
|
|
4362
|
+
runWithContext(context, fn) {
|
|
4363
|
+
return this.contextStorage.run(context, fn);
|
|
3958
4364
|
}
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
function makeTrackedFetch(realFetch) {
|
|
3964
|
-
return async (input, init) => {
|
|
3965
|
-
const context = telemetry.createDependencyContext();
|
|
3966
|
-
const url = resolveUrl(input);
|
|
3967
|
-
if (!context || !url) {
|
|
3968
|
-
return realFetch(input, init);
|
|
3969
|
-
}
|
|
3970
|
-
const method = resolveMethod(input, init).toUpperCase();
|
|
3971
|
-
const headers = mergeHeaders(input, init);
|
|
3972
|
-
if (!headers.has("traceparent")) {
|
|
3973
|
-
headers.set("traceparent", `00-${context.operationId}-${context.id}-${W3C_TRACE_FLAGS_SAMPLED}`);
|
|
4365
|
+
createDependencyContext() {
|
|
4366
|
+
const parentContext = this.getActiveContext();
|
|
4367
|
+
if (!parentContext) {
|
|
4368
|
+
return;
|
|
3974
4369
|
}
|
|
3975
|
-
|
|
4370
|
+
return {
|
|
4371
|
+
operationId: parentContext.operationId,
|
|
4372
|
+
parentId: parentContext.id,
|
|
4373
|
+
id: this.generateId(),
|
|
4374
|
+
startedAt: startSpanClock().startedAt
|
|
4375
|
+
};
|
|
4376
|
+
}
|
|
4377
|
+
trackDependencyResult(name, type, durationMs, success, properties, context, resultCode) {
|
|
4378
|
+
this.telemetryProvider.trackDependency({
|
|
4379
|
+
...this.spanFor(redactHttpDependencyName(name), durationMs, success, properties, context),
|
|
4380
|
+
type,
|
|
4381
|
+
...resultCode !== undefined ? { resultCode } : {}
|
|
4382
|
+
});
|
|
4383
|
+
}
|
|
4384
|
+
async trackDependencyOperation(name, type, fn, properties) {
|
|
3976
4385
|
const clock = startSpanClock();
|
|
3977
|
-
|
|
4386
|
+
const parentContext = this.getActiveContext();
|
|
4387
|
+
const childContext = parentContext !== undefined ? {
|
|
4388
|
+
operationId: parentContext.operationId,
|
|
4389
|
+
parentId: parentContext.id,
|
|
4390
|
+
id: this.generateId(),
|
|
4391
|
+
startedAt: clock.startedAt
|
|
4392
|
+
} : {
|
|
4393
|
+
...this.createRequestContext(),
|
|
4394
|
+
startedAt: clock.startedAt
|
|
4395
|
+
};
|
|
3978
4396
|
try {
|
|
3979
|
-
const
|
|
4397
|
+
const result = await this.contextStorage.run(childContext, fn);
|
|
3980
4398
|
const durationMs = clock.elapsedMs();
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
}, context, String(response.status));
|
|
3987
|
-
return response;
|
|
4399
|
+
await this.telemetryProvider.trackDependency({
|
|
4400
|
+
...this.spanFor(name, durationMs, true, properties, childContext),
|
|
4401
|
+
type
|
|
4402
|
+
});
|
|
4403
|
+
return result;
|
|
3988
4404
|
} catch (error) {
|
|
3989
4405
|
const durationMs = clock.elapsedMs();
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
4406
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
4407
|
+
await this.telemetryProvider.trackDependency({
|
|
4408
|
+
...this.spanFor(name, durationMs, false, {
|
|
4409
|
+
...properties,
|
|
4410
|
+
[CommandDimensions.ErrorMessage]: err.message
|
|
4411
|
+
}, childContext),
|
|
4412
|
+
type
|
|
4413
|
+
});
|
|
3996
4414
|
throw error;
|
|
3997
4415
|
}
|
|
3998
|
-
}
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
}
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4416
|
+
}
|
|
4417
|
+
getActiveContext() {
|
|
4418
|
+
return this.contextStorage.getContext();
|
|
4419
|
+
}
|
|
4420
|
+
leafCorrelation(explicit) {
|
|
4421
|
+
const context = explicit ?? this.getActiveContext();
|
|
4422
|
+
return {
|
|
4423
|
+
operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
|
|
4424
|
+
...context !== undefined ? { parentId: context.id } : {}
|
|
4425
|
+
};
|
|
4426
|
+
}
|
|
4427
|
+
spanFor(name, durationMs, success, properties, context) {
|
|
4428
|
+
return {
|
|
4429
|
+
name: redactSpanName(name),
|
|
4430
|
+
durationMs,
|
|
4431
|
+
success,
|
|
4432
|
+
properties: this.enrichProperties(properties),
|
|
4433
|
+
operationId: context.operationId,
|
|
4434
|
+
...context.parentId !== undefined ? { parentId: context.parentId } : {},
|
|
4435
|
+
id: context.id,
|
|
4436
|
+
...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
|
|
4437
|
+
};
|
|
4438
|
+
}
|
|
4439
|
+
enrichProperties(properties) {
|
|
4440
|
+
const globalProperties = getGlobalTelemetryProperties();
|
|
4441
|
+
const enriched = {
|
|
4442
|
+
...getExecutionContextTelemetryProperties(),
|
|
4443
|
+
...globalProperties,
|
|
4444
|
+
...this.defaultProperties,
|
|
4445
|
+
...redactProperties(properties ?? {}),
|
|
4446
|
+
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
|
|
4447
|
+
[BaseDimensions.SessionId]: this.telemetryProvider.getSessionId?.() ?? getTelemetrySessionId()
|
|
4448
|
+
};
|
|
4449
|
+
return lowercaseIdDimensionValues(enriched);
|
|
4450
|
+
}
|
|
4451
|
+
generateId() {
|
|
4452
|
+
const bytes = new Uint8Array(8);
|
|
4453
|
+
let hex = "";
|
|
4454
|
+
do {
|
|
4455
|
+
crypto.getRandomValues(bytes);
|
|
4456
|
+
hex = "";
|
|
4457
|
+
for (const byte of bytes) {
|
|
4458
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
4459
|
+
}
|
|
4460
|
+
} while (/^0+$/.test(hex));
|
|
4461
|
+
return hex;
|
|
4462
|
+
}
|
|
4017
4463
|
}
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4464
|
+
// ../common/src/telemetry/telemetry-init.ts
|
|
4465
|
+
import { spawn } from "node:child_process";
|
|
4466
|
+
|
|
4467
|
+
// ../common/src/registry.ts
|
|
4468
|
+
import { execFileSync } from "node:child_process";
|
|
4469
|
+
function readRegistryValue(keyPath, valueName) {
|
|
4470
|
+
if (process.platform !== "win32") {
|
|
4471
|
+
return "";
|
|
4472
|
+
}
|
|
4473
|
+
const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
|
|
4474
|
+
encoding: "utf-8",
|
|
4475
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
4476
|
+
windowsHide: true
|
|
4477
|
+
}));
|
|
4478
|
+
if (error) {
|
|
4479
|
+
return "";
|
|
4480
|
+
}
|
|
4481
|
+
const match = output.match(new RegExp(`${valueName}\\s+REG_SZ\\s+(.+)`));
|
|
4482
|
+
return match?.[1]?.trim() ?? "";
|
|
4483
|
+
}
|
|
4484
|
+
|
|
4485
|
+
// ../common/src/telemetry/logger-telemetry-provider.ts
|
|
4486
|
+
class LoggerTelemetryProvider {
|
|
4487
|
+
analyticsUniqueId;
|
|
4488
|
+
constructor() {
|
|
4489
|
+
this.analyticsUniqueId = readRegistryValue("HKCU\\Software\\UiPath", "AnalyticsUniqueId");
|
|
4024
4490
|
}
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4491
|
+
enrich(properties) {
|
|
4492
|
+
return {
|
|
4493
|
+
...properties,
|
|
4494
|
+
...this.analyticsUniqueId ? { analyticsUniqueId: this.analyticsUniqueId } : {}
|
|
4495
|
+
};
|
|
4029
4496
|
}
|
|
4030
|
-
|
|
4497
|
+
async trackEvent({ name, properties }) {
|
|
4498
|
+
logger.debug(formatMessage("Event", name, this.enrich(properties)));
|
|
4499
|
+
}
|
|
4500
|
+
async trackException({
|
|
4501
|
+
error,
|
|
4502
|
+
properties
|
|
4503
|
+
}) {
|
|
4504
|
+
logger.error(formatMessage("Exception", error.message, this.enrich({
|
|
4505
|
+
...properties,
|
|
4506
|
+
stack: error.stack
|
|
4507
|
+
})));
|
|
4508
|
+
}
|
|
4509
|
+
async trackRequest({
|
|
4510
|
+
name,
|
|
4511
|
+
durationMs,
|
|
4512
|
+
success,
|
|
4513
|
+
properties
|
|
4514
|
+
}) {
|
|
4515
|
+
logger.debug(formatMessage("Request", name, this.enrich({
|
|
4516
|
+
...properties,
|
|
4517
|
+
duration: `${durationMs}ms`,
|
|
4518
|
+
success
|
|
4519
|
+
})));
|
|
4520
|
+
}
|
|
4521
|
+
async trackDependency({
|
|
4522
|
+
name,
|
|
4523
|
+
type,
|
|
4524
|
+
durationMs,
|
|
4525
|
+
success,
|
|
4526
|
+
properties
|
|
4527
|
+
}) {
|
|
4528
|
+
logger.debug(formatMessage("Dependency", name, this.enrich({
|
|
4529
|
+
...properties,
|
|
4530
|
+
type,
|
|
4531
|
+
duration: `${durationMs}ms`,
|
|
4532
|
+
success
|
|
4533
|
+
})));
|
|
4534
|
+
}
|
|
4535
|
+
}
|
|
4536
|
+
function formatMessage(category, name, properties) {
|
|
4537
|
+
let message = `[Telemetry] [${category}] ${name}`;
|
|
4538
|
+
if (properties && Object.keys(properties).length > 0) {
|
|
4539
|
+
const propsStr = Object.entries(properties).filter(([_, value]) => value !== undefined).map(([key, value]) => `${key}=${value}`).join(", ");
|
|
4540
|
+
if (propsStr) {
|
|
4541
|
+
message += ` | ${propsStr}`;
|
|
4542
|
+
}
|
|
4543
|
+
}
|
|
4544
|
+
return message;
|
|
4031
4545
|
}
|
|
4546
|
+
|
|
4032
4547
|
// ../common/src/telemetry/proxy-http-agent.ts
|
|
4033
4548
|
var slot = singleton("ProxyAuthHttpsAgent");
|
|
4034
4549
|
function setProxyAuthHttpsAgent(agent) {
|
|
@@ -4125,7 +4640,7 @@ async function loadApplicationInsights() {
|
|
|
4125
4640
|
const savedDebug = process.env.DEBUG;
|
|
4126
4641
|
delete process.env.DEBUG;
|
|
4127
4642
|
configureAppInsightsEnvironment();
|
|
4128
|
-
const [error, mod] = await catchError(import("./applicationinsights-
|
|
4643
|
+
const [error, mod] = await catchError(import("./applicationinsights-pwe8sf3y.js").then((m)=>__toESM(m.default,1)));
|
|
4129
4644
|
if (savedDebug !== undefined) {
|
|
4130
4645
|
process.env.DEBUG = savedDebug;
|
|
4131
4646
|
}
|
|
@@ -4391,6 +4906,124 @@ async function getOrCreateProvider(connectionString) {
|
|
|
4391
4906
|
return initPromise;
|
|
4392
4907
|
}
|
|
4393
4908
|
|
|
4909
|
+
// ../common/src/telemetry/telemetry-config.ts
|
|
4910
|
+
function isTelemetryDisabled() {
|
|
4911
|
+
const value = process.env.UIPATH_TELEMETRY_DISABLED;
|
|
4912
|
+
return value === "1" || value === "true";
|
|
4913
|
+
}
|
|
4914
|
+
function isProjectTelemetryDisabled() {
|
|
4915
|
+
return isTelemetryDisabled() || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "1" || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "true";
|
|
4916
|
+
}
|
|
4917
|
+
|
|
4918
|
+
// ../common/src/telemetry/telemetry-spool.ts
|
|
4919
|
+
var TELEMETRY_DRAIN_ARGV = "__uip-drain-telemetry";
|
|
4920
|
+
var sidecarEntrySlot = singleton("TelemetrySidecarEntry");
|
|
4921
|
+
function setTelemetrySidecarEntry(entryPath) {
|
|
4922
|
+
sidecarEntrySlot.set(entryPath);
|
|
4923
|
+
}
|
|
4924
|
+
function getTelemetrySidecarEntry() {
|
|
4925
|
+
return sidecarEntrySlot.get();
|
|
4926
|
+
}
|
|
4927
|
+
var PENDING_SUFFIX = ".json";
|
|
4928
|
+
var CLAIMED_SUFFIX = ".sending";
|
|
4929
|
+
var WRITE_TEMP_SUFFIX = ".tmp";
|
|
4930
|
+
var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
|
|
4931
|
+
var MAX_SPOOL_FILES = 50;
|
|
4932
|
+
function getTelemetrySpoolDir() {
|
|
4933
|
+
const fs = getFileSystem2();
|
|
4934
|
+
return fs.path.join(fs.env.homedir(), ".uipath", "telemetry", "pending");
|
|
4935
|
+
}
|
|
4936
|
+
async function writeTelemetrySpoolFile(payload) {
|
|
4937
|
+
const fs = getFileSystem2();
|
|
4938
|
+
const dir = getTelemetrySpoolDir();
|
|
4939
|
+
await fs.mkdir(dir);
|
|
4940
|
+
const name = `${Date.now()}-${process.pid}`;
|
|
4941
|
+
const finalPath = fs.path.join(dir, `${name}${PENDING_SUFFIX}`);
|
|
4942
|
+
const tempPath = fs.path.join(dir, `${name}${WRITE_TEMP_SUFFIX}`);
|
|
4943
|
+
await fs.writeFile(tempPath, JSON.stringify(payload));
|
|
4944
|
+
await fs.rename(tempPath, finalPath);
|
|
4945
|
+
return finalPath;
|
|
4946
|
+
}
|
|
4947
|
+
function isSpoolPayload(value) {
|
|
4948
|
+
return value !== null && typeof value === "object" && typeof value.endpointUrl === "string" && value.endpointUrl.length > 0 && Array.isArray(value.envelopes);
|
|
4949
|
+
}
|
|
4950
|
+
async function listSpoolEntries(suffix) {
|
|
4951
|
+
const fs = getFileSystem2();
|
|
4952
|
+
const dir = getTelemetrySpoolDir();
|
|
4953
|
+
const [readdirError, names] = await catchError(fs.readdir(dir));
|
|
4954
|
+
if (readdirError) {
|
|
4955
|
+
return { dir, names: [] };
|
|
4956
|
+
}
|
|
4957
|
+
return {
|
|
4958
|
+
dir,
|
|
4959
|
+
names: names.filter((n) => n.endsWith(suffix)).sort((a, b) => a.localeCompare(b))
|
|
4960
|
+
};
|
|
4961
|
+
}
|
|
4962
|
+
async function claimPendingSpoolFiles() {
|
|
4963
|
+
const fs = getFileSystem2();
|
|
4964
|
+
const { dir, names } = await listSpoolEntries(PENDING_SUFFIX);
|
|
4965
|
+
const claimed = [];
|
|
4966
|
+
for (const name of names) {
|
|
4967
|
+
const pendingPath = fs.path.join(dir, name);
|
|
4968
|
+
const claimedPath = `${pendingPath.slice(0, -PENDING_SUFFIX.length)}${CLAIMED_SUFFIX}`;
|
|
4969
|
+
const [claimError] = await catchError(fs.rename(pendingPath, claimedPath));
|
|
4970
|
+
if (claimError) {
|
|
4971
|
+
continue;
|
|
4972
|
+
}
|
|
4973
|
+
const [readError, raw] = await catchError(fs.readFile(claimedPath, "utf-8"));
|
|
4974
|
+
if (readError || raw === null) {
|
|
4975
|
+
logger.debug(`[TelemetrySpool] could not read ${name}; leaving it for a later run`);
|
|
4976
|
+
await releaseClaimedSpoolFile(claimedPath);
|
|
4977
|
+
continue;
|
|
4978
|
+
}
|
|
4979
|
+
const [parseError, parsed] = catchError(() => JSON.parse(raw));
|
|
4980
|
+
if (parseError || !isSpoolPayload(parsed)) {
|
|
4981
|
+
logger.debug(`[TelemetrySpool] dropping malformed file: ${name}`);
|
|
4982
|
+
await catchError(fs.rm(claimedPath));
|
|
4983
|
+
continue;
|
|
4984
|
+
}
|
|
4985
|
+
claimed.push({ claimedPath, payload: parsed });
|
|
4986
|
+
}
|
|
4987
|
+
return claimed;
|
|
4988
|
+
}
|
|
4989
|
+
async function releaseClaimedSpoolFile(claimedPath) {
|
|
4990
|
+
const fs = getFileSystem2();
|
|
4991
|
+
const pendingPath = `${claimedPath.slice(0, -CLAIMED_SUFFIX.length)}${PENDING_SUFFIX}`;
|
|
4992
|
+
await catchError(fs.rename(claimedPath, pendingPath));
|
|
4993
|
+
}
|
|
4994
|
+
async function discardClaimedSpoolFile(claimedPath) {
|
|
4995
|
+
const fs = getFileSystem2();
|
|
4996
|
+
await catchError(fs.rm(claimedPath));
|
|
4997
|
+
}
|
|
4998
|
+
async function sweepTelemetrySpool() {
|
|
4999
|
+
const fs = getFileSystem2();
|
|
5000
|
+
const { dir, names } = await listSpoolEntries("");
|
|
5001
|
+
const now = Date.now();
|
|
5002
|
+
const pending = [];
|
|
5003
|
+
for (const name of names) {
|
|
5004
|
+
const filePath = fs.path.join(dir, name);
|
|
5005
|
+
const [statError, stats] = await catchError(fs.stat(filePath));
|
|
5006
|
+
if (statError || !stats) {
|
|
5007
|
+
continue;
|
|
5008
|
+
}
|
|
5009
|
+
if (now - stats.mtimeMs > MAX_SPOOL_AGE_MS) {
|
|
5010
|
+
await catchError(fs.rm(filePath));
|
|
5011
|
+
continue;
|
|
5012
|
+
}
|
|
5013
|
+
if (name.endsWith(PENDING_SUFFIX)) {
|
|
5014
|
+
pending.push({ path: filePath, mtimeMs: stats.mtimeMs });
|
|
5015
|
+
}
|
|
5016
|
+
}
|
|
5017
|
+
if (pending.length > MAX_SPOOL_FILES) {
|
|
5018
|
+
pending.sort((a, b) => a.mtimeMs - b.mtimeMs);
|
|
5019
|
+
const excess = pending.slice(0, pending.length - MAX_SPOOL_FILES);
|
|
5020
|
+
for (const file of excess) {
|
|
5021
|
+
await catchError(fs.rm(file.path));
|
|
5022
|
+
}
|
|
5023
|
+
logger.debug(`[TelemetrySpool] deleted ${excess.length} oldest files over the ${MAX_SPOOL_FILES}-file cap`);
|
|
5024
|
+
}
|
|
5025
|
+
}
|
|
5026
|
+
|
|
4394
5027
|
// ../common/src/telemetry/telemetry-init.ts
|
|
4395
5028
|
var telemetryInstanceSlot = singleton("TelemetryService");
|
|
4396
5029
|
var DEFAULT_AI_CONNECTION_STRING = atob("SW5zdHJ1bWVudGF0aW9uS2V5PTliZDM3NDgyLTgxMGUtNDQyYS1hYWE2LWQzOGVmNjVjNjY3NDtJbmdlc3Rpb25FbmRwb2ludD1odHRwczovL3dlc3RldXJvcGUtNS5pbi5hcHBsaWNhdGlvbmluc2lnaHRzLmF6dXJlLmNvbS87TGl2ZUVuZHBvaW50PWh0dHBzOi8vd2VzdGV1cm9wZS5saXZlZGlhZ25vc3RpY3MubW9uaXRvci5henVyZS5jb20vO0FwcGxpY2F0aW9uSWQ9MzU2OTdlZjEtOGJkMC00ZjE5LWEyN2MtZDg3Y2NhYzY2ZDJj");
|
|
@@ -4417,13 +5050,18 @@ async function createAppInsightsProvider() {
|
|
|
4417
5050
|
}
|
|
4418
5051
|
var telemetryProviderInstance;
|
|
4419
5052
|
var telemetryFlushShutdownPromise;
|
|
4420
|
-
async function createTelemetryProvider() {
|
|
5053
|
+
async function createTelemetryProvider(options) {
|
|
4421
5054
|
telemetryFlushShutdownPromise = undefined;
|
|
4422
5055
|
if (isTelemetryDisabled()) {
|
|
4423
5056
|
const fallback = new LoggerTelemetryProvider;
|
|
4424
5057
|
telemetryProviderInstance = fallback;
|
|
4425
5058
|
return { provider: fallback, name: "Disabled" };
|
|
4426
5059
|
}
|
|
5060
|
+
if (options?.appInsights === false) {
|
|
5061
|
+
const fallback = new LoggerTelemetryProvider;
|
|
5062
|
+
telemetryProviderInstance = fallback;
|
|
5063
|
+
return { provider: fallback, name: "LoggerTelemetryProvider" };
|
|
5064
|
+
}
|
|
4427
5065
|
const [error, provider] = await catchError(createAppInsightsProvider());
|
|
4428
5066
|
if (error) {
|
|
4429
5067
|
logger.warn(`[Telemetry] AppInsights provider failed: ${error.message}. Falling back to logger.`);
|
|
@@ -4465,7 +5103,9 @@ var telemetry = new Proxy({}, {
|
|
|
4465
5103
|
}
|
|
4466
5104
|
});
|
|
4467
5105
|
async function telemetryInit(options) {
|
|
4468
|
-
const { provider, name: providerName } = await createTelemetryProvider(
|
|
5106
|
+
const { provider, name: providerName } = await createTelemetryProvider({
|
|
5107
|
+
appInsights: options?.appInsights
|
|
5108
|
+
});
|
|
4469
5109
|
const existing = getGlobalTelemetryInstance();
|
|
4470
5110
|
const instance = existing ?? new TelemetryService(provider, new NodeContextStorage);
|
|
4471
5111
|
instance.setProvider(provider);
|
|
@@ -4518,7 +5158,7 @@ function isDrainableTelemetryProvider(provider) {
|
|
|
4518
5158
|
return "drainPendingEnvelopes" in provider && typeof provider.drainPendingEnvelopes === "function";
|
|
4519
5159
|
}
|
|
4520
5160
|
async function spawnTelemetrySidecar(entryPath) {
|
|
4521
|
-
const cwd =
|
|
5161
|
+
const cwd = getFileSystem2().env.tmpdir();
|
|
4522
5162
|
const isWindows = process.platform === "win32";
|
|
4523
5163
|
const child = isWindows ? spawn(windowsShell(), windowsLauncherArgs(entryPath), {
|
|
4524
5164
|
cwd,
|
|
@@ -4619,41 +5259,89 @@ async function telemetryShutdownWithoutFlush() {
|
|
|
4619
5259
|
await telemetryFlushShutdownPromise;
|
|
4620
5260
|
}
|
|
4621
5261
|
|
|
4622
|
-
//
|
|
4623
|
-
var
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
5262
|
+
// ../common/src/telemetry/tracked-fetch.ts
|
|
5263
|
+
var W3C_TRACE_FLAGS_SAMPLED = "01";
|
|
5264
|
+
function makeTrackedFetch(realFetch) {
|
|
5265
|
+
return async (input, init) => {
|
|
5266
|
+
const context = telemetry.createDependencyContext();
|
|
5267
|
+
const url = resolveUrl(input);
|
|
5268
|
+
if (!context || !url) {
|
|
5269
|
+
return realFetch(input, init);
|
|
5270
|
+
}
|
|
5271
|
+
const method = resolveMethod(input, init).toUpperCase();
|
|
5272
|
+
const headers = mergeHeaders(input, init);
|
|
5273
|
+
if (!headers.has("traceparent")) {
|
|
5274
|
+
headers.set("traceparent", `00-${context.operationId}-${context.id}-${W3C_TRACE_FLAGS_SAMPLED}`);
|
|
5275
|
+
}
|
|
5276
|
+
const name = `${method} ${url.pathname}`;
|
|
5277
|
+
const clock = startSpanClock();
|
|
5278
|
+
context.startedAt = clock.startedAt;
|
|
5279
|
+
try {
|
|
5280
|
+
const response = await realFetch(input, { ...init, headers });
|
|
5281
|
+
const durationMs = clock.elapsedMs();
|
|
5282
|
+
recordHttpCall(durationMs);
|
|
5283
|
+
telemetry.trackDependencyResult(name, "HTTP", durationMs, response.ok, {
|
|
5284
|
+
"server.address": url.host,
|
|
5285
|
+
"http.request.method": method,
|
|
5286
|
+
"http.response.status_code": response.status
|
|
5287
|
+
}, context, String(response.status));
|
|
5288
|
+
return response;
|
|
5289
|
+
} catch (error) {
|
|
5290
|
+
const durationMs = clock.elapsedMs();
|
|
5291
|
+
recordHttpCall(durationMs);
|
|
5292
|
+
telemetry.trackDependencyResult(name, "HTTP", durationMs, false, {
|
|
5293
|
+
"server.address": url.host,
|
|
5294
|
+
"http.request.method": method,
|
|
5295
|
+
[CommandDimensions.ErrorMessage]: error instanceof Error ? error.message : String(error)
|
|
5296
|
+
}, context);
|
|
5297
|
+
throw error;
|
|
5298
|
+
}
|
|
5299
|
+
};
|
|
5300
|
+
}
|
|
5301
|
+
function resolveUrl(input) {
|
|
5302
|
+
try {
|
|
5303
|
+
if (typeof input === "string")
|
|
5304
|
+
return new URL(input);
|
|
5305
|
+
if (input instanceof URL)
|
|
5306
|
+
return input;
|
|
5307
|
+
if (input instanceof Request)
|
|
5308
|
+
return new URL(input.url);
|
|
5309
|
+
} catch {}
|
|
5310
|
+
return;
|
|
5311
|
+
}
|
|
5312
|
+
function resolveMethod(input, init) {
|
|
5313
|
+
if (init?.method)
|
|
5314
|
+
return init.method;
|
|
5315
|
+
if (input instanceof Request)
|
|
5316
|
+
return input.method;
|
|
5317
|
+
return "GET";
|
|
5318
|
+
}
|
|
5319
|
+
function mergeHeaders(input, init) {
|
|
5320
|
+
const headers = new Headers;
|
|
5321
|
+
if (input instanceof Request) {
|
|
5322
|
+
input.headers.forEach((value, key) => {
|
|
5323
|
+
headers.set(key, value);
|
|
5324
|
+
});
|
|
5325
|
+
}
|
|
5326
|
+
if (init?.headers) {
|
|
5327
|
+
new Headers(init.headers).forEach((value, key) => {
|
|
5328
|
+
headers.set(key, value);
|
|
5329
|
+
});
|
|
5330
|
+
}
|
|
5331
|
+
return headers;
|
|
5332
|
+
}
|
|
4645
5333
|
// ../common/src/output-codecs.ts
|
|
4646
5334
|
var yamlSlot = singleton("YamlCodec");
|
|
4647
5335
|
var jmespathSlot = singleton("JmespathCodec");
|
|
4648
5336
|
async function loadOutputCodecsAsync(needed) {
|
|
4649
5337
|
const loads = [];
|
|
4650
5338
|
if (needed.yaml && yamlSlot.get() === undefined) {
|
|
4651
|
-
loads.push(import("./js-yaml-
|
|
5339
|
+
loads.push(import("./js-yaml-0c4svjwq.js").then((mod) => {
|
|
4652
5340
|
yamlSlot.set(mod);
|
|
4653
5341
|
}));
|
|
4654
5342
|
}
|
|
4655
5343
|
if (needed.filter && jmespathSlot.get() === undefined) {
|
|
4656
|
-
loads.push(import("./jmespath-
|
|
5344
|
+
loads.push(import("./jmespath-ab6tdc42.js").then((m)=>__toESM(m.default,1)).then((mod) => {
|
|
4657
5345
|
jmespathSlot.set(mod);
|
|
4658
5346
|
}));
|
|
4659
5347
|
}
|
|
@@ -4666,36 +5354,6 @@ function getJmespathCodec() {
|
|
|
4666
5354
|
return jmespathSlot.get();
|
|
4667
5355
|
}
|
|
4668
5356
|
|
|
4669
|
-
// ../common/src/output-format-context.ts
|
|
4670
|
-
var formatSlot = singleton("OutputFormat");
|
|
4671
|
-
var formatExplicitSlot = singleton("OutputFormatExplicit");
|
|
4672
|
-
var helpRequestedSlot = singleton("HelpRequested");
|
|
4673
|
-
var filterSlot = singleton("OutputFilter");
|
|
4674
|
-
function setOutputFormat(format) {
|
|
4675
|
-
formatSlot.set(format);
|
|
4676
|
-
}
|
|
4677
|
-
function getOutputFormat() {
|
|
4678
|
-
return formatSlot.get("json");
|
|
4679
|
-
}
|
|
4680
|
-
function setOutputFormatExplicit(explicit) {
|
|
4681
|
-
formatExplicitSlot.set(explicit);
|
|
4682
|
-
}
|
|
4683
|
-
function getOutputFormatExplicit() {
|
|
4684
|
-
return formatExplicitSlot.get(false) ?? false;
|
|
4685
|
-
}
|
|
4686
|
-
function setHelpRequested(requested) {
|
|
4687
|
-
helpRequestedSlot.set(requested);
|
|
4688
|
-
}
|
|
4689
|
-
function getHelpRequested() {
|
|
4690
|
-
return helpRequestedSlot.get(false) ?? false;
|
|
4691
|
-
}
|
|
4692
|
-
function setOutputFilter(filter) {
|
|
4693
|
-
filterSlot.set(filter);
|
|
4694
|
-
}
|
|
4695
|
-
function getOutputFilter() {
|
|
4696
|
-
return filterSlot.get();
|
|
4697
|
-
}
|
|
4698
|
-
|
|
4699
5357
|
// ../common/src/output-formats.ts
|
|
4700
5358
|
var OUTPUT_FORMATS = [
|
|
4701
5359
|
"table",
|
|
@@ -4708,50 +5366,6 @@ function isOutputFormat(value) {
|
|
|
4708
5366
|
return OUTPUT_FORMATS.includes(value);
|
|
4709
5367
|
}
|
|
4710
5368
|
|
|
4711
|
-
// ../common/src/error-graph.ts
|
|
4712
|
-
function* walkErrorGraph(error) {
|
|
4713
|
-
const queue = [error];
|
|
4714
|
-
const seen = new Set;
|
|
4715
|
-
for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
|
|
4716
|
-
const current = queue.shift();
|
|
4717
|
-
if (current === null || typeof current !== "object")
|
|
4718
|
-
continue;
|
|
4719
|
-
if (seen.has(current))
|
|
4720
|
-
continue;
|
|
4721
|
-
seen.add(current);
|
|
4722
|
-
const cur = current;
|
|
4723
|
-
yield cur;
|
|
4724
|
-
if (cur.cause !== undefined)
|
|
4725
|
-
queue.push(cur.cause);
|
|
4726
|
-
if (Array.isArray(cur.errors))
|
|
4727
|
-
queue.push(...cur.errors);
|
|
4728
|
-
}
|
|
4729
|
-
return;
|
|
4730
|
-
}
|
|
4731
|
-
function parseHttpStatusFromMessage(message) {
|
|
4732
|
-
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
4733
|
-
if (!match)
|
|
4734
|
-
return;
|
|
4735
|
-
const status = Number(match[1]);
|
|
4736
|
-
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
4737
|
-
}
|
|
4738
|
-
function findHttpStatusInGraph(error) {
|
|
4739
|
-
for (const node of walkErrorGraph(error)) {
|
|
4740
|
-
const response = node.response;
|
|
4741
|
-
const explicit = typeof node.status === "number" ? node.status : response?.status;
|
|
4742
|
-
if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
|
|
4743
|
-
return explicit;
|
|
4744
|
-
}
|
|
4745
|
-
if (typeof node.message === "string") {
|
|
4746
|
-
const parsed = parseHttpStatusFromMessage(node.message);
|
|
4747
|
-
if (parsed !== undefined && parsed >= 400) {
|
|
4748
|
-
return parsed;
|
|
4749
|
-
}
|
|
4750
|
-
}
|
|
4751
|
-
}
|
|
4752
|
-
return;
|
|
4753
|
-
}
|
|
4754
|
-
|
|
4755
5369
|
// ../common/src/telemetry/command-terminal.ts
|
|
4756
5370
|
var recordedFailureSlot = singleton("CommandTelemetryFailure");
|
|
4757
5371
|
var AUTH_ERROR_CODES = new Set([
|
|
@@ -4781,7 +5395,7 @@ var NETWORK_OS_ERROR_CODES = new Set([
|
|
|
4781
5395
|
"EAI_FAIL"
|
|
4782
5396
|
]);
|
|
4783
5397
|
var TIMEOUT_OS_ERROR_CODES = new Set(["ETIMEDOUT", "ESOCKETTIMEDOUT"]);
|
|
4784
|
-
var
|
|
5398
|
+
var TLS_ERROR_CODES2 = new Set([
|
|
4785
5399
|
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
4786
5400
|
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
4787
5401
|
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
@@ -4870,17 +5484,8 @@ function terminalSignalFor(input, outcome) {
|
|
|
4870
5484
|
}
|
|
4871
5485
|
return outcome === "cancelled" ? "SIGINT" : undefined;
|
|
4872
5486
|
}
|
|
4873
|
-
function
|
|
4874
|
-
|
|
4875
|
-
return "auth";
|
|
4876
|
-
}
|
|
4877
|
-
if (status === 400 || status === 409 || status === 422) {
|
|
4878
|
-
return "validation";
|
|
4879
|
-
}
|
|
4880
|
-
if (status === 408) {
|
|
4881
|
-
return "timeout";
|
|
4882
|
-
}
|
|
4883
|
-
return "network_http";
|
|
5487
|
+
function classifyFailingHttpStatus(status) {
|
|
5488
|
+
return classifyFromErrorCode(classifyHttpStatus(status)?.errorCode) ?? "network_http";
|
|
4884
5489
|
}
|
|
4885
5490
|
function classifyFromResult(result) {
|
|
4886
5491
|
switch (result) {
|
|
@@ -4930,7 +5535,7 @@ function classifyFromError(error) {
|
|
|
4930
5535
|
if (code.startsWith("commander.")) {
|
|
4931
5536
|
return "validation";
|
|
4932
5537
|
}
|
|
4933
|
-
if (NETWORK_OS_ERROR_CODES.has(code) ||
|
|
5538
|
+
if (NETWORK_OS_ERROR_CODES.has(code) || TLS_ERROR_CODES2.has(code)) {
|
|
4934
5539
|
return "network_http";
|
|
4935
5540
|
}
|
|
4936
5541
|
if (TIMEOUT_OS_ERROR_CODES.has(code)) {
|
|
@@ -4953,14 +5558,14 @@ function classifyFromError(error) {
|
|
|
4953
5558
|
}
|
|
4954
5559
|
return;
|
|
4955
5560
|
}
|
|
4956
|
-
function
|
|
5561
|
+
function classifyError2(input) {
|
|
4957
5562
|
const recorded = input.recordedFailure;
|
|
4958
5563
|
if (recorded?.errorClass) {
|
|
4959
5564
|
return recorded.errorClass;
|
|
4960
5565
|
}
|
|
4961
5566
|
const status = recorded?.context?.httpStatus ?? findHttpStatusInGraph(input.error);
|
|
4962
5567
|
if (status !== undefined) {
|
|
4963
|
-
return
|
|
5568
|
+
return classifyFailingHttpStatus(status);
|
|
4964
5569
|
}
|
|
4965
5570
|
return classifyFromResult(recorded?.result) ?? classifyFromErrorCode(recorded?.errorCode) ?? classifyFromError(input.error) ?? "unknown";
|
|
4966
5571
|
}
|
|
@@ -4978,7 +5583,7 @@ function takeRecordedCommandFailureTelemetry() {
|
|
|
4978
5583
|
function buildCommandTerminalTelemetryProperties(input) {
|
|
4979
5584
|
const cancelled = isCancellationError(input.error, input.exitCode, input.pollSignal);
|
|
4980
5585
|
const outcome = input.recordedFailure?.terminalOutcome ?? (input.exitCode === 0 ? "success" : cancelled ? "cancelled" : "failure");
|
|
4981
|
-
const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" :
|
|
5586
|
+
const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError2(input);
|
|
4982
5587
|
const terminalSignal = terminalSignalFor(input, outcome);
|
|
4983
5588
|
return {
|
|
4984
5589
|
[CommandDimensions.ExitCode]: input.exitCode,
|
|
@@ -4992,9 +5597,9 @@ function buildCommandTerminalTelemetryProperties(input) {
|
|
|
4992
5597
|
var CommonTelemetryEvents = {
|
|
4993
5598
|
Start: "Application.Start",
|
|
4994
5599
|
Error: "Application.Error",
|
|
5600
|
+
ProjectActivity: "Cli.ProjectActivity",
|
|
4995
5601
|
ShipSucceeded: "Cli.ShipSucceeded"
|
|
4996
5602
|
};
|
|
4997
|
-
|
|
4998
5603
|
// ../common/src/formatter.ts
|
|
4999
5604
|
var ANSI_STYLES = {
|
|
5000
5605
|
red: "\x1B[31m",
|
|
@@ -5004,58 +5609,6 @@ var ANSI_RESET = "\x1B[0m";
|
|
|
5004
5609
|
function styleLine(line, style) {
|
|
5005
5610
|
return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
|
|
5006
5611
|
}
|
|
5007
|
-
var CLI_ERROR_CODES = [
|
|
5008
|
-
"invalid_argument",
|
|
5009
|
-
"authentication_required",
|
|
5010
|
-
"permission_denied",
|
|
5011
|
-
"local_permission_denied",
|
|
5012
|
-
"not_found",
|
|
5013
|
-
"rate_limited",
|
|
5014
|
-
"network_error",
|
|
5015
|
-
"timeout",
|
|
5016
|
-
"server_error",
|
|
5017
|
-
"method_not_allowed",
|
|
5018
|
-
"not_supported",
|
|
5019
|
-
"configuration_error",
|
|
5020
|
-
"execution_failed",
|
|
5021
|
-
"unknown_error"
|
|
5022
|
-
];
|
|
5023
|
-
var RETRY_HINTS = [
|
|
5024
|
-
"RetryWillNotFix",
|
|
5025
|
-
"RetryLater",
|
|
5026
|
-
"RetryAfter1Second",
|
|
5027
|
-
"RetryAfter10Seconds",
|
|
5028
|
-
"RetryAfter30Seconds",
|
|
5029
|
-
"RetryAfter60Seconds"
|
|
5030
|
-
];
|
|
5031
|
-
var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
|
|
5032
|
-
var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
|
|
5033
|
-
function isCliErrorCode(value) {
|
|
5034
|
-
return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
|
|
5035
|
-
}
|
|
5036
|
-
function isRetryHint(value) {
|
|
5037
|
-
return typeof value === "string" && RETRY_HINT_VALUES.has(value);
|
|
5038
|
-
}
|
|
5039
|
-
function carriedErrorCode(error) {
|
|
5040
|
-
if (!error || typeof error !== "object")
|
|
5041
|
-
return;
|
|
5042
|
-
const code = error.errorCode;
|
|
5043
|
-
return isCliErrorCode(code) ? code : undefined;
|
|
5044
|
-
}
|
|
5045
|
-
function carriedRetry(error) {
|
|
5046
|
-
if (!error || typeof error !== "object")
|
|
5047
|
-
return;
|
|
5048
|
-
const retry = error.retry;
|
|
5049
|
-
return isRetryHint(retry) ? retry : undefined;
|
|
5050
|
-
}
|
|
5051
|
-
var RESULTS = {
|
|
5052
|
-
Success: "Success",
|
|
5053
|
-
Failure: "Failure",
|
|
5054
|
-
ConfigError: "ConfigError",
|
|
5055
|
-
AuthenticationError: "AuthenticationError",
|
|
5056
|
-
ValidationError: "ValidationError",
|
|
5057
|
-
TimeoutError: "TimeoutError"
|
|
5058
|
-
};
|
|
5059
5612
|
var EXIT_CODES = {
|
|
5060
5613
|
Success: 0,
|
|
5061
5614
|
Failure: 1,
|
|
@@ -5064,6 +5617,9 @@ var EXIT_CODES = {
|
|
|
5064
5617
|
ValidationError: 3,
|
|
5065
5618
|
TimeoutError: 4
|
|
5066
5619
|
};
|
|
5620
|
+
function exitCodeForResult(result) {
|
|
5621
|
+
return EXIT_CODES[result] ?? EXIT_CODES.Failure;
|
|
5622
|
+
}
|
|
5067
5623
|
|
|
5068
5624
|
class Pagination {
|
|
5069
5625
|
Returned;
|
|
@@ -5781,8 +6337,8 @@ function carriesOnlyNulls(value) {
|
|
|
5781
6337
|
}
|
|
5782
6338
|
return false;
|
|
5783
6339
|
}
|
|
5784
|
-
function nameList(names,
|
|
5785
|
-
const shown = names.slice(0,
|
|
6340
|
+
function nameList(names, cap = 12) {
|
|
6341
|
+
const shown = names.slice(0, cap).map((n) => `\`${n}\``);
|
|
5786
6342
|
const rest = names.length - shown.length;
|
|
5787
6343
|
return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
|
|
5788
6344
|
}
|
|
@@ -5919,40 +6475,11 @@ function defaultErrorCodeForResult(result) {
|
|
|
5919
6475
|
return "unknown_error";
|
|
5920
6476
|
}
|
|
5921
6477
|
}
|
|
5922
|
-
function parseHttpStatusFromMessage2(message) {
|
|
5923
|
-
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
5924
|
-
if (!match)
|
|
5925
|
-
return;
|
|
5926
|
-
const status = Number(match[1]);
|
|
5927
|
-
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
5928
|
-
}
|
|
5929
|
-
function defaultErrorCodeForHttpStatus(status) {
|
|
5930
|
-
if (status === undefined)
|
|
5931
|
-
return;
|
|
5932
|
-
if (status === 400 || status === 409 || status === 422) {
|
|
5933
|
-
return "invalid_argument";
|
|
5934
|
-
}
|
|
5935
|
-
if (status === 401)
|
|
5936
|
-
return "authentication_required";
|
|
5937
|
-
if (status === 403)
|
|
5938
|
-
return "permission_denied";
|
|
5939
|
-
if (status === 404)
|
|
5940
|
-
return "not_found";
|
|
5941
|
-
if (status === 405)
|
|
5942
|
-
return "method_not_allowed";
|
|
5943
|
-
if (status === 408)
|
|
5944
|
-
return "timeout";
|
|
5945
|
-
if (status === 429)
|
|
5946
|
-
return "rate_limited";
|
|
5947
|
-
if (status >= 500 && status < 600)
|
|
5948
|
-
return "server_error";
|
|
5949
|
-
return;
|
|
5950
|
-
}
|
|
5951
6478
|
var LOCAL_PERMISSION_TEXT_PATTERN = new RegExp(`(?:\\b|\\()(?:${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})(?::\\s|\\))`);
|
|
5952
6479
|
function defaultErrorCodeForFailure(data) {
|
|
5953
6480
|
if (data.Result === RESULTS.Failure) {
|
|
5954
|
-
const status = data.Context?.httpStatus ??
|
|
5955
|
-
const errorCode =
|
|
6481
|
+
const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage(data.Message);
|
|
6482
|
+
const errorCode = classifyHttpStatus(status)?.errorCode;
|
|
5956
6483
|
if (errorCode)
|
|
5957
6484
|
return errorCode;
|
|
5958
6485
|
if (status === undefined && (LOCAL_PERMISSION_TEXT_PATTERN.test(data.Message) || LOCAL_PERMISSION_TEXT_PATTERN.test(data.Instructions))) {
|
|
@@ -5961,17 +6488,6 @@ function defaultErrorCodeForFailure(data) {
|
|
|
5961
6488
|
}
|
|
5962
6489
|
return defaultErrorCodeForResult(data.Result);
|
|
5963
6490
|
}
|
|
5964
|
-
function defaultRetryForErrorCode(errorCode) {
|
|
5965
|
-
switch (errorCode) {
|
|
5966
|
-
case "network_error":
|
|
5967
|
-
case "rate_limited":
|
|
5968
|
-
case "server_error":
|
|
5969
|
-
case "timeout":
|
|
5970
|
-
return "RetryLater";
|
|
5971
|
-
default:
|
|
5972
|
-
return "RetryWillNotFix";
|
|
5973
|
-
}
|
|
5974
|
-
}
|
|
5975
6491
|
var OutputFormatter;
|
|
5976
6492
|
((OutputFormatter) => {
|
|
5977
6493
|
function success(data, options) {
|
|
@@ -6003,7 +6519,7 @@ var OutputFormatter;
|
|
|
6003
6519
|
data.Log ??= getLogFilePath() || undefined;
|
|
6004
6520
|
data.ErrorCode ??= defaultErrorCodeForFailure(data);
|
|
6005
6521
|
data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
|
|
6006
|
-
const exitCode =
|
|
6522
|
+
const exitCode = exitCodeForResult(data.Result);
|
|
6007
6523
|
setExitCode(exitCode);
|
|
6008
6524
|
recordCommandFailureTelemetry({
|
|
6009
6525
|
result: data.Result,
|
|
@@ -6098,6 +6614,231 @@ var OutputFormatter;
|
|
|
6098
6614
|
OutputFormatter.formatToString = formatToString;
|
|
6099
6615
|
})(OutputFormatter ||= {});
|
|
6100
6616
|
|
|
6617
|
+
// ../common/src/pass-through-tail.ts
|
|
6618
|
+
function maybeOption(arg) {
|
|
6619
|
+
return arg.length > 1 && arg[0] === "-";
|
|
6620
|
+
}
|
|
6621
|
+
function tokenizeTail(cmd, tail) {
|
|
6622
|
+
const find = (flag) => cmd.options.find((option) => option.long === flag || option.short === flag);
|
|
6623
|
+
const digitShort = cmd.options.some((option) => option.short !== undefined && /^-\d$/.test(option.short));
|
|
6624
|
+
const negativeNumber = (arg) => !digitShort && /^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg);
|
|
6625
|
+
const tokens = [];
|
|
6626
|
+
let firstUnknown = -1;
|
|
6627
|
+
let sentinel = -1;
|
|
6628
|
+
let variadic;
|
|
6629
|
+
let group;
|
|
6630
|
+
let groupIndex = 0;
|
|
6631
|
+
let i = 0;
|
|
6632
|
+
while (i < tail.length || group !== undefined) {
|
|
6633
|
+
const index = group === undefined ? i : groupIndex;
|
|
6634
|
+
const arg = group ?? tail[i++];
|
|
6635
|
+
group = undefined;
|
|
6636
|
+
if (arg === "--") {
|
|
6637
|
+
sentinel = index;
|
|
6638
|
+
tokens.push({ kind: "sentinel", index });
|
|
6639
|
+
for (let j = i;j < tail.length; j++) {
|
|
6640
|
+
tokens.push({
|
|
6641
|
+
kind: "operand",
|
|
6642
|
+
index: j,
|
|
6643
|
+
text: tail[j],
|
|
6644
|
+
literal: true
|
|
6645
|
+
});
|
|
6646
|
+
}
|
|
6647
|
+
break;
|
|
6648
|
+
}
|
|
6649
|
+
if (variadic && (!maybeOption(arg) || negativeNumber(arg))) {
|
|
6650
|
+
tokens.push({
|
|
6651
|
+
kind: "option",
|
|
6652
|
+
index,
|
|
6653
|
+
text: arg,
|
|
6654
|
+
option: variadic,
|
|
6655
|
+
value: arg
|
|
6656
|
+
});
|
|
6657
|
+
continue;
|
|
6658
|
+
}
|
|
6659
|
+
variadic = undefined;
|
|
6660
|
+
if (maybeOption(arg)) {
|
|
6661
|
+
const option = find(arg);
|
|
6662
|
+
if (option) {
|
|
6663
|
+
let value;
|
|
6664
|
+
if (option.required) {
|
|
6665
|
+
value = tail[i];
|
|
6666
|
+
if (value !== undefined)
|
|
6667
|
+
i++;
|
|
6668
|
+
} else if (option.optional) {
|
|
6669
|
+
const next = tail[i];
|
|
6670
|
+
if (next !== undefined && (!maybeOption(next) || negativeNumber(next))) {
|
|
6671
|
+
value = next;
|
|
6672
|
+
i++;
|
|
6673
|
+
}
|
|
6674
|
+
}
|
|
6675
|
+
tokens.push({
|
|
6676
|
+
kind: "option",
|
|
6677
|
+
index,
|
|
6678
|
+
text: arg,
|
|
6679
|
+
option,
|
|
6680
|
+
...value === undefined ? {} : { value }
|
|
6681
|
+
});
|
|
6682
|
+
variadic = option.variadic ? option : undefined;
|
|
6683
|
+
continue;
|
|
6684
|
+
}
|
|
6685
|
+
}
|
|
6686
|
+
if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
|
|
6687
|
+
const option = find(`-${arg[1]}`);
|
|
6688
|
+
if (option) {
|
|
6689
|
+
if (option.required || option.optional) {
|
|
6690
|
+
tokens.push({
|
|
6691
|
+
kind: "option",
|
|
6692
|
+
index,
|
|
6693
|
+
text: arg,
|
|
6694
|
+
option,
|
|
6695
|
+
value: arg.slice(2)
|
|
6696
|
+
});
|
|
6697
|
+
} else {
|
|
6698
|
+
tokens.push({ kind: "option", index, text: arg, option });
|
|
6699
|
+
group = `-${arg.slice(2)}`;
|
|
6700
|
+
groupIndex = index;
|
|
6701
|
+
}
|
|
6702
|
+
continue;
|
|
6703
|
+
}
|
|
6704
|
+
}
|
|
6705
|
+
if (/^--[^=]+=/.test(arg)) {
|
|
6706
|
+
const equals = arg.indexOf("=");
|
|
6707
|
+
const option = find(arg.slice(0, equals));
|
|
6708
|
+
if (option && (option.required || option.optional)) {
|
|
6709
|
+
tokens.push({
|
|
6710
|
+
kind: "option",
|
|
6711
|
+
index,
|
|
6712
|
+
text: arg,
|
|
6713
|
+
option,
|
|
6714
|
+
value: arg.slice(equals + 1)
|
|
6715
|
+
});
|
|
6716
|
+
continue;
|
|
6717
|
+
}
|
|
6718
|
+
}
|
|
6719
|
+
if (maybeOption(arg) && !negativeNumber(arg)) {
|
|
6720
|
+
const equals = arg.startsWith("--") ? arg.indexOf("=") : -1;
|
|
6721
|
+
if (firstUnknown === -1)
|
|
6722
|
+
firstUnknown = index;
|
|
6723
|
+
tokens.push({
|
|
6724
|
+
kind: "unknown",
|
|
6725
|
+
index,
|
|
6726
|
+
text: arg,
|
|
6727
|
+
flag: equals > 0 ? arg.slice(0, equals) : arg,
|
|
6728
|
+
...equals > 0 ? { inlineValue: arg.slice(equals + 1) } : {}
|
|
6729
|
+
});
|
|
6730
|
+
continue;
|
|
6731
|
+
}
|
|
6732
|
+
tokens.push({ kind: "operand", index, text: arg, literal: false });
|
|
6733
|
+
}
|
|
6734
|
+
return { tokens, firstUnknown, sentinel };
|
|
6735
|
+
}
|
|
6736
|
+
|
|
6737
|
+
// ../common/src/project-telemetry.ts
|
|
6738
|
+
var RESOLVER = Symbol.for("@uipath/common/projectTelemetryResolver");
|
|
6739
|
+
var CAPTURE = Symbol.for("@uipath/common/projectTelemetryCapture");
|
|
6740
|
+
var CONTEXT_RESOLVER = Symbol.for("@uipath/common/projectContextTelemetryResolver");
|
|
6741
|
+
var RULES = Symbol.for("@uipath/common/projectTargetRules");
|
|
6742
|
+
function logSkipped(what, error) {
|
|
6743
|
+
logger.debug(`[project-telemetry] ${what} skipped: ${error instanceof Error ? error.message : String(error)}`);
|
|
6744
|
+
}
|
|
6745
|
+
function bounded(work, what) {
|
|
6746
|
+
return withinProjectIdentityBudget(work, () => logSkipped(what, `no answer within ${PROJECT_IDENTITY_LOOKUP_BUDGET_MS} ms`));
|
|
6747
|
+
}
|
|
6748
|
+
function configureProjectContextTelemetry(command, resolver) {
|
|
6749
|
+
command[CONTEXT_RESOLVER] = resolver;
|
|
6750
|
+
}
|
|
6751
|
+
async function identityWithContext(command, identity) {
|
|
6752
|
+
const props = projectIdentityProperties(identity);
|
|
6753
|
+
if (!identity.projectDirectory || isProjectTelemetryDisabled())
|
|
6754
|
+
return props;
|
|
6755
|
+
for (let node = command;node; node = node.parent ?? undefined) {
|
|
6756
|
+
const resolver = node[CONTEXT_RESOLVER];
|
|
6757
|
+
if (typeof resolver !== "function")
|
|
6758
|
+
continue;
|
|
6759
|
+
try {
|
|
6760
|
+
return {
|
|
6761
|
+
...await resolver(identity.projectDirectory),
|
|
6762
|
+
...props
|
|
6763
|
+
};
|
|
6764
|
+
} catch (error) {
|
|
6765
|
+
logSkipped("solution context lookup", error);
|
|
6766
|
+
return props;
|
|
6767
|
+
}
|
|
6768
|
+
}
|
|
6769
|
+
return props;
|
|
6770
|
+
}
|
|
6771
|
+
function getProjectTelemetryResolver(command) {
|
|
6772
|
+
for (let node = command;node; node = node.parent) {
|
|
6773
|
+
const resolver = node[RESOLVER];
|
|
6774
|
+
if (typeof resolver === "function")
|
|
6775
|
+
return resolver;
|
|
6776
|
+
}
|
|
6777
|
+
return;
|
|
6778
|
+
}
|
|
6779
|
+
function attachProjectTelemetryCapture(command, capture) {
|
|
6780
|
+
command[CAPTURE] = capture;
|
|
6781
|
+
}
|
|
6782
|
+
class ProjectTelemetrySession {
|
|
6783
|
+
resolver;
|
|
6784
|
+
command;
|
|
6785
|
+
target;
|
|
6786
|
+
props = {};
|
|
6787
|
+
explicit = false;
|
|
6788
|
+
input;
|
|
6789
|
+
constructor(resolver, command) {
|
|
6790
|
+
this.resolver = resolver;
|
|
6791
|
+
this.command = command;
|
|
6792
|
+
}
|
|
6793
|
+
async setTarget(path) {
|
|
6794
|
+
this.target = path;
|
|
6795
|
+
if (this.input) {
|
|
6796
|
+
await this.resolve({
|
|
6797
|
+
...this.input,
|
|
6798
|
+
phase: "after",
|
|
6799
|
+
success: true
|
|
6800
|
+
});
|
|
6801
|
+
this.explicit = true;
|
|
6802
|
+
}
|
|
6803
|
+
}
|
|
6804
|
+
async setIdentity(identity) {
|
|
6805
|
+
try {
|
|
6806
|
+
const props = await bounded(identityWithContext(this.command, identity), "project identity capture");
|
|
6807
|
+
if (props !== undefined)
|
|
6808
|
+
this.setProperties(props);
|
|
6809
|
+
} catch (error) {
|
|
6810
|
+
logSkipped("project identity capture", error);
|
|
6811
|
+
}
|
|
6812
|
+
}
|
|
6813
|
+
setProperties(properties) {
|
|
6814
|
+
try {
|
|
6815
|
+
this.props = { ...properties };
|
|
6816
|
+
this.explicit = true;
|
|
6817
|
+
} catch (error) {
|
|
6818
|
+
logSkipped("project identity properties", error);
|
|
6819
|
+
}
|
|
6820
|
+
}
|
|
6821
|
+
properties() {
|
|
6822
|
+
return { ...this.props };
|
|
6823
|
+
}
|
|
6824
|
+
async resolve(input) {
|
|
6825
|
+
this.input = input;
|
|
6826
|
+
if (this.explicit)
|
|
6827
|
+
return;
|
|
6828
|
+
try {
|
|
6829
|
+
const props = await bounded(this.resolver({
|
|
6830
|
+
...input,
|
|
6831
|
+
target: this.target
|
|
6832
|
+
}), `project identity (${input.phase})`);
|
|
6833
|
+
if (props !== undefined) {
|
|
6834
|
+
this.props = props;
|
|
6835
|
+
}
|
|
6836
|
+
} catch (error) {
|
|
6837
|
+
logSkipped(`project identity (${input.phase})`, error);
|
|
6838
|
+
}
|
|
6839
|
+
}
|
|
6840
|
+
}
|
|
6841
|
+
|
|
6101
6842
|
// ../common/src/telemetry/command-attribution.ts
|
|
6102
6843
|
var LEGACY_SKILL_NAMESPACE = "uipath:";
|
|
6103
6844
|
var MAX_SKILL_NAME_LENGTH = 80;
|
|
@@ -6261,10 +7002,10 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
|
|
|
6261
7002
|
function buildSkillEventTelemetryAttribution(skillSource, uipSubcommand) {
|
|
6262
7003
|
const skillName = normalizeLegacySkillName(skillSource);
|
|
6263
7004
|
const skillAttribution = skillName ? SKILL_ATTRIBUTION[skillName] : {};
|
|
6264
|
-
const
|
|
7005
|
+
const commandAttribution = getCommandProductModeAttribution(uipSubcommand);
|
|
6265
7006
|
return {
|
|
6266
7007
|
...skillAttribution,
|
|
6267
|
-
...
|
|
7008
|
+
...commandAttribution,
|
|
6268
7009
|
...skillName ? { SkillName: skillName } : {}
|
|
6269
7010
|
};
|
|
6270
7011
|
}
|
|
@@ -6357,8 +7098,7 @@ var pollSignalSlot = singleton("PollSignal");
|
|
|
6357
7098
|
var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
|
|
6358
7099
|
var processContext = {
|
|
6359
7100
|
exit: (code) => {
|
|
6360
|
-
|
|
6361
|
-
setExitCode(code);
|
|
7101
|
+
recordCommandExit(code);
|
|
6362
7102
|
},
|
|
6363
7103
|
get pollSignal() {
|
|
6364
7104
|
return pollSignalSlot.get();
|
|
@@ -6386,6 +7126,8 @@ function recordableArgValue(value, choices) {
|
|
|
6386
7126
|
function extractCommandParams(cmd) {
|
|
6387
7127
|
const params = {};
|
|
6388
7128
|
forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
|
|
7129
|
+
if (name === undefined)
|
|
7130
|
+
return;
|
|
6389
7131
|
const recordable = recordableArgValue(value, choices);
|
|
6390
7132
|
params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
|
|
6391
7133
|
});
|
|
@@ -6401,7 +7143,8 @@ function isDefaultedPositional(cmd, index) {
|
|
|
6401
7143
|
function forEachSuppliedArgument(cmd, visit) {
|
|
6402
7144
|
const registered = cmd.registeredArguments ?? [];
|
|
6403
7145
|
const processed = cmd.processedArgs ?? [];
|
|
6404
|
-
|
|
7146
|
+
const bound = boundPositionalCount(cmd);
|
|
7147
|
+
for (let i = 0;i < bound; i++) {
|
|
6405
7148
|
const name = registered[i].name();
|
|
6406
7149
|
if (name && processed[i] !== undefined) {
|
|
6407
7150
|
visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
|
|
@@ -6416,6 +7159,71 @@ function forEachSuppliedArgument(cmd, visit) {
|
|
|
6416
7159
|
visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
|
|
6417
7160
|
}
|
|
6418
7161
|
}
|
|
7162
|
+
forEachPassThroughToken(cmd, bound, (name, value) => {
|
|
7163
|
+
visit(name, value, name === undefined ? undefined : choicesByAttribute.get(name), false);
|
|
7164
|
+
});
|
|
7165
|
+
}
|
|
7166
|
+
function boundPositionalCount(cmd) {
|
|
7167
|
+
const registered = cmd.registeredArguments ?? [];
|
|
7168
|
+
if (registered.some((argument) => argument.variadic)) {
|
|
7169
|
+
return registered.length;
|
|
7170
|
+
}
|
|
7171
|
+
if ((cmd.args ?? []).length <= registered.length) {
|
|
7172
|
+
return registered.length;
|
|
7173
|
+
}
|
|
7174
|
+
const firstFlag = tokenizeTail(cmd, (cmd.args ?? []).slice(1)).tokens.find((token) => token.kind !== "operand")?.index ?? -1;
|
|
7175
|
+
return firstFlag === -1 ? registered.length : Math.min(registered.length, firstFlag + 1);
|
|
7176
|
+
}
|
|
7177
|
+
function forEachPassThroughToken(cmd, bound, visit) {
|
|
7178
|
+
const registered = cmd.registeredArguments ?? [];
|
|
7179
|
+
const fillsPositionals = !registered.some((argument) => argument.variadic);
|
|
7180
|
+
const { tokens, firstUnknown } = tokenizeTail(cmd, (cmd.args ?? []).slice(bound));
|
|
7181
|
+
const repeated = new Map;
|
|
7182
|
+
let nextPositional = bound;
|
|
7183
|
+
for (const token of tokens) {
|
|
7184
|
+
const pastUnknown = firstUnknown !== -1 && token.index > firstUnknown;
|
|
7185
|
+
if (token.kind === "sentinel")
|
|
7186
|
+
continue;
|
|
7187
|
+
if (token.kind === "operand") {
|
|
7188
|
+
const claimable = !pastUnknown && fillsPositionals && nextPositional < registered.length;
|
|
7189
|
+
const name = claimable ? registered[nextPositional++].name() : undefined;
|
|
7190
|
+
visit(name || undefined, token.text);
|
|
7191
|
+
continue;
|
|
7192
|
+
}
|
|
7193
|
+
if (token.kind === "unknown") {
|
|
7194
|
+
const bare = token.flag.replace(/^-+/, "");
|
|
7195
|
+
const key = bare.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
7196
|
+
const keyable = token.flag.startsWith("--") || token.flag.length === 2;
|
|
7197
|
+
if (!pastUnknown && keyable && /^[a-z][a-z0-9-]*$/i.test(bare) && key) {
|
|
7198
|
+
visit(key, token.inlineValue ?? true);
|
|
7199
|
+
} else {
|
|
7200
|
+
visit(undefined, token.text);
|
|
7201
|
+
if (token.inlineValue !== undefined) {
|
|
7202
|
+
visit(undefined, token.inlineValue);
|
|
7203
|
+
} else if (!token.flag.startsWith("--") && token.flag.length > 2) {
|
|
7204
|
+
visit(undefined, token.flag.slice(2));
|
|
7205
|
+
}
|
|
7206
|
+
}
|
|
7207
|
+
continue;
|
|
7208
|
+
}
|
|
7209
|
+
if (pastUnknown) {
|
|
7210
|
+
visit(undefined, token.text);
|
|
7211
|
+
if (token.value !== undefined)
|
|
7212
|
+
visit(undefined, token.value);
|
|
7213
|
+
continue;
|
|
7214
|
+
}
|
|
7215
|
+
const option = token.option;
|
|
7216
|
+
const name = option.attributeName();
|
|
7217
|
+
const value = option.negate ? false : option.required || option.optional ? token.value ?? true : true;
|
|
7218
|
+
const previous = repeated.get(name);
|
|
7219
|
+
if (previous) {
|
|
7220
|
+
previous.push(value);
|
|
7221
|
+
visit(name, previous);
|
|
7222
|
+
} else {
|
|
7223
|
+
repeated.set(name, [value]);
|
|
7224
|
+
visit(name, value);
|
|
7225
|
+
}
|
|
7226
|
+
}
|
|
6419
7227
|
}
|
|
6420
7228
|
function withheldArgumentValues(cmd) {
|
|
6421
7229
|
const values = [];
|
|
@@ -6477,6 +7285,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
6477
7285
|
const telemetryName = commandTelemetryName(commandParts);
|
|
6478
7286
|
const commandPath = commandInvocationPath(commandParts);
|
|
6479
7287
|
const props = typeof properties === "function" ? properties(...args) : properties;
|
|
7288
|
+
const projectResolver = getProjectTelemetryResolver(command);
|
|
7289
|
+
const projectSession = projectResolver && !isProjectTelemetryDisabled() ? new ProjectTelemetrySession(projectResolver, command) : undefined;
|
|
6480
7290
|
markCommandStart();
|
|
6481
7291
|
const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
|
|
6482
7292
|
try {
|
|
@@ -6489,6 +7299,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
6489
7299
|
if (violation) {
|
|
6490
7300
|
return Promise.reject(violation);
|
|
6491
7301
|
}
|
|
7302
|
+
if (projectSession) {
|
|
7303
|
+
return projectSession.resolve({ command, args, phase: "before" }).then(() => {
|
|
7304
|
+
attachProjectTelemetryCapture(command, projectSession);
|
|
7305
|
+
return fn(...args);
|
|
7306
|
+
});
|
|
7307
|
+
}
|
|
6492
7308
|
return fn(...args);
|
|
6493
7309
|
}));
|
|
6494
7310
|
if (error) {
|
|
@@ -6497,22 +7313,26 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
6497
7313
|
const typed = error;
|
|
6498
7314
|
const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
|
|
6499
7315
|
const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
|
|
6500
|
-
const
|
|
7316
|
+
const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
|
|
7317
|
+
const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
|
|
7318
|
+
const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
|
|
6501
7319
|
const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
|
|
6502
7320
|
const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
|
|
6503
7321
|
const typedRetry = typed.retry ?? typed.Retry;
|
|
6504
7322
|
const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
|
|
6505
7323
|
const typedContext = typed.context ?? typed.Context;
|
|
6506
7324
|
const customContext = isErrorContext(typedContext) ? typedContext : undefined;
|
|
6507
|
-
const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
|
|
6508
7325
|
fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
|
|
7326
|
+
const errorCode = customErrorCode ?? classified?.errorCode;
|
|
7327
|
+
const retry = customRetry ?? classified?.retry;
|
|
7328
|
+
const errorContext = customContext ?? classified?.context;
|
|
6509
7329
|
OutputFormatter.error({
|
|
6510
7330
|
Result: finalResult,
|
|
6511
|
-
...
|
|
7331
|
+
...errorCode ? { ErrorCode: errorCode } : {},
|
|
6512
7332
|
Message: errorMessage,
|
|
6513
7333
|
Instructions: customInstructions ?? commandHelpHint(commandPath),
|
|
6514
|
-
...
|
|
6515
|
-
...
|
|
7334
|
+
...retry ? { Retry: retry } : {},
|
|
7335
|
+
...errorContext ? { Context: errorContext } : {}
|
|
6516
7336
|
});
|
|
6517
7337
|
context.exit(fallbackExitCode);
|
|
6518
7338
|
}
|
|
@@ -6521,6 +7341,14 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
6521
7341
|
const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
|
|
6522
7342
|
const recordedFailure = takeRecordedCommandFailureTelemetry();
|
|
6523
7343
|
const success = !error && exitCode === 0;
|
|
7344
|
+
if (projectSession) {
|
|
7345
|
+
await projectSession.resolve({
|
|
7346
|
+
command,
|
|
7347
|
+
args,
|
|
7348
|
+
phase: "after",
|
|
7349
|
+
success
|
|
7350
|
+
});
|
|
7351
|
+
}
|
|
6524
7352
|
const terminalTelemetry = buildCommandTerminalTelemetryProperties({
|
|
6525
7353
|
error,
|
|
6526
7354
|
exitCode,
|
|
@@ -6538,6 +7366,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
6538
7366
|
}
|
|
6539
7367
|
const baseProperties = redactProperties({
|
|
6540
7368
|
...commandParams,
|
|
7369
|
+
...projectSession?.properties(),
|
|
6541
7370
|
...props,
|
|
6542
7371
|
...buildCommandTelemetryAttribution(commandPath, process.env.UIPATH_SKILL),
|
|
6543
7372
|
...buildAgentSessionTelemetry(process.env),
|
|
@@ -6548,11 +7377,25 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
6548
7377
|
});
|
|
6549
7378
|
emitInvocationRequest(telemetryName, success, baseProperties);
|
|
6550
7379
|
} finally {
|
|
7380
|
+
if (projectSession)
|
|
7381
|
+
attachProjectTelemetryCapture(command, undefined);
|
|
6551
7382
|
releaseSuppliedArgumentValues(supplied);
|
|
6552
7383
|
}
|
|
6553
7384
|
});
|
|
6554
7385
|
};
|
|
6555
7386
|
|
|
7387
|
+
// ../common/src/completer.ts
|
|
7388
|
+
var COMPLETER_SYMBOL = Symbol.for("@uipath/common/completer");
|
|
7389
|
+
function getCompleter(target) {
|
|
7390
|
+
if (!target)
|
|
7391
|
+
return;
|
|
7392
|
+
const raw = target[COMPLETER_SYMBOL];
|
|
7393
|
+
if (raw && typeof raw === "object" && "command" in raw && "valueSelector" in raw) {
|
|
7394
|
+
return raw;
|
|
7395
|
+
}
|
|
7396
|
+
return;
|
|
7397
|
+
}
|
|
7398
|
+
|
|
6556
7399
|
// ../common/src/console-guard.ts
|
|
6557
7400
|
function format(first, ...rest) {
|
|
6558
7401
|
if (typeof first !== "string") {
|
|
@@ -6633,6 +7476,75 @@ function installConsoleGuard() {
|
|
|
6633
7476
|
guardInstalledSlot.set(true);
|
|
6634
7477
|
}
|
|
6635
7478
|
|
|
7479
|
+
// ../common/src/constants.ts
|
|
7480
|
+
var UIPATH_HOME_DIR = ".uipath";
|
|
7481
|
+
var CONFIG_FILENAME = "config.json";
|
|
7482
|
+
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
7483
|
+
var DEFAULT_FETCH_TIMEOUT_MS = 30000;
|
|
7484
|
+
|
|
7485
|
+
// ../common/src/env-reference.ts
|
|
7486
|
+
function resolveEnvReference(value) {
|
|
7487
|
+
if (value == null)
|
|
7488
|
+
return value;
|
|
7489
|
+
if (value.startsWith("env.")) {
|
|
7490
|
+
const name = value.slice(4);
|
|
7491
|
+
const resolved = process.env[name];
|
|
7492
|
+
if (!resolved) {
|
|
7493
|
+
throw new Error(`Environment variable "${name}" is not set`);
|
|
7494
|
+
}
|
|
7495
|
+
return resolved;
|
|
7496
|
+
}
|
|
7497
|
+
return value;
|
|
7498
|
+
}
|
|
7499
|
+
|
|
7500
|
+
// ../common/src/interactivity-context.ts
|
|
7501
|
+
var modeSlot = singleton("InteractivityMode");
|
|
7502
|
+
var interactiveFlagSlot = singleton("InteractiveFlag");
|
|
7503
|
+
function setInteractivityMode(mode) {
|
|
7504
|
+
modeSlot.set(mode);
|
|
7505
|
+
}
|
|
7506
|
+
function getInteractivityMode() {
|
|
7507
|
+
return modeSlot.get("auto") ?? "auto";
|
|
7508
|
+
}
|
|
7509
|
+
function setInteractiveFlag(passed) {
|
|
7510
|
+
interactiveFlagSlot.set(passed);
|
|
7511
|
+
}
|
|
7512
|
+
function wasInteractiveFlagPassed() {
|
|
7513
|
+
return interactiveFlagSlot.get(false) ?? false;
|
|
7514
|
+
}
|
|
7515
|
+
function canPrompt() {
|
|
7516
|
+
const mode = getInteractivityMode();
|
|
7517
|
+
if (mode === "always") {
|
|
7518
|
+
return true;
|
|
7519
|
+
}
|
|
7520
|
+
if (mode === "never") {
|
|
7521
|
+
return false;
|
|
7522
|
+
}
|
|
7523
|
+
const capabilities = getOutputSink().capabilities;
|
|
7524
|
+
return capabilities.isInteractive && capabilities.canReadInput;
|
|
7525
|
+
}
|
|
7526
|
+
|
|
7527
|
+
// ../common/src/option-validators.ts
|
|
7528
|
+
function parseBoundedInt(raw, optionName, bounds) {
|
|
7529
|
+
const normalized = raw.trim();
|
|
7530
|
+
if (normalized === "") {
|
|
7531
|
+
throw new InvalidArgumentError2(`${optionName} requires a value (got empty).`);
|
|
7532
|
+
}
|
|
7533
|
+
if (!/^-?\d+$/.test(normalized)) {
|
|
7534
|
+
throw new InvalidArgumentError2(`${optionName} must be an integer, got '${normalized}'.`);
|
|
7535
|
+
}
|
|
7536
|
+
const n = parseInt(normalized, 10);
|
|
7537
|
+
if (n < bounds.min || n > bounds.max) {
|
|
7538
|
+
throw new InvalidArgumentError2(`${optionName} must be between ${bounds.min} and ${bounds.max}, got ${n}.`);
|
|
7539
|
+
}
|
|
7540
|
+
return n;
|
|
7541
|
+
}
|
|
7542
|
+
function splitScopeList(raw) {
|
|
7543
|
+
if (!raw)
|
|
7544
|
+
return [];
|
|
7545
|
+
return raw.split(/[\s,]+/).filter((scope) => scope.length > 0);
|
|
7546
|
+
}
|
|
7547
|
+
|
|
6636
7548
|
// ../common/src/polling/abort-controller.ts
|
|
6637
7549
|
var created = false;
|
|
6638
7550
|
function createPollAbortController() {
|
|
@@ -6695,106 +7607,6 @@ var FAILURE_STATUSES = new Set([
|
|
|
6695
7607
|
"canceled",
|
|
6696
7608
|
"stopped"
|
|
6697
7609
|
]);
|
|
6698
|
-
// ../common/src/error-handler.ts
|
|
6699
|
-
var DEFAULT_401 = "Unauthorized (401). The session is missing or expired, or its token carries no scope for this API. Run `uip login status --detailed` to see the session and its scopes.";
|
|
6700
|
-
var NETWORK_ERROR_CODES = new Set([
|
|
6701
|
-
"ECONNREFUSED",
|
|
6702
|
-
"ECONNRESET",
|
|
6703
|
-
"ENOTFOUND",
|
|
6704
|
-
"EAI_AGAIN",
|
|
6705
|
-
"ETIMEDOUT",
|
|
6706
|
-
"EPIPE",
|
|
6707
|
-
"EHOSTUNREACH",
|
|
6708
|
-
"ENETUNREACH",
|
|
6709
|
-
"EAI_FAIL"
|
|
6710
|
-
]);
|
|
6711
|
-
var TLS_ERROR_CODES2 = new Set([
|
|
6712
|
-
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
6713
|
-
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
6714
|
-
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
6715
|
-
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
6716
|
-
"UNABLE_TO_GET_ISSUER_CERT",
|
|
6717
|
-
"CERT_HAS_EXPIRED",
|
|
6718
|
-
"CERT_UNTRUSTED",
|
|
6719
|
-
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
6720
|
-
]);
|
|
6721
|
-
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.";
|
|
6722
|
-
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.";
|
|
6723
|
-
var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
|
|
6724
|
-
function carriedInstructions(error) {
|
|
6725
|
-
if (!error || typeof error !== "object")
|
|
6726
|
-
return;
|
|
6727
|
-
const e = error;
|
|
6728
|
-
return typeof e.instructions === "string" ? e.instructions : undefined;
|
|
6729
|
-
}
|
|
6730
|
-
function formatErrorChain(error) {
|
|
6731
|
-
const lines = [];
|
|
6732
|
-
const seen = new Set;
|
|
6733
|
-
const visit = (value, depth) => {
|
|
6734
|
-
if (lines.length >= 32)
|
|
6735
|
-
return;
|
|
6736
|
-
const indent = " ".repeat(depth);
|
|
6737
|
-
if (value === null || typeof value !== "object") {
|
|
6738
|
-
lines.push(`${indent}${String(value)}`);
|
|
6739
|
-
return;
|
|
6740
|
-
}
|
|
6741
|
-
if (seen.has(value))
|
|
6742
|
-
return;
|
|
6743
|
-
seen.add(value);
|
|
6744
|
-
const cur = value;
|
|
6745
|
-
const name = typeof cur.name === "string" ? cur.name : "Error";
|
|
6746
|
-
const message = typeof cur.message === "string" ? cur.message : String(value);
|
|
6747
|
-
const code = typeof cur.code === "string" ? ` [${cur.code}]` : "";
|
|
6748
|
-
lines.push(`${indent}${name}: ${message}${code}`);
|
|
6749
|
-
if (cur.cause !== undefined)
|
|
6750
|
-
visit(cur.cause, depth + 1);
|
|
6751
|
-
if (Array.isArray(cur.errors)) {
|
|
6752
|
-
for (const nested of cur.errors) {
|
|
6753
|
-
visit(nested, depth + 1);
|
|
6754
|
-
}
|
|
6755
|
-
}
|
|
6756
|
-
};
|
|
6757
|
-
visit(error, 0);
|
|
6758
|
-
return lines.join(`
|
|
6759
|
-
`);
|
|
6760
|
-
}
|
|
6761
|
-
function describeConnectivityError(error) {
|
|
6762
|
-
for (const cur of walkErrorGraph(error)) {
|
|
6763
|
-
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
6764
|
-
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
6765
|
-
if (code && TLS_ERROR_CODES2.has(code)) {
|
|
6766
|
-
return {
|
|
6767
|
-
code,
|
|
6768
|
-
kind: "tls",
|
|
6769
|
-
message: message ?? code,
|
|
6770
|
-
instructions: TLS_INSTRUCTIONS
|
|
6771
|
-
};
|
|
6772
|
-
}
|
|
6773
|
-
if (code && NETWORK_ERROR_CODES.has(code)) {
|
|
6774
|
-
return {
|
|
6775
|
-
code,
|
|
6776
|
-
kind: "network",
|
|
6777
|
-
message: message ?? code,
|
|
6778
|
-
instructions: NETWORK_INSTRUCTIONS
|
|
6779
|
-
};
|
|
6780
|
-
}
|
|
6781
|
-
}
|
|
6782
|
-
return;
|
|
6783
|
-
}
|
|
6784
|
-
function extractErrorMessageSync(error) {
|
|
6785
|
-
if (error instanceof Error) {
|
|
6786
|
-
return error.message;
|
|
6787
|
-
}
|
|
6788
|
-
if (typeof error === "object" && error !== null) {
|
|
6789
|
-
if ("status" in error && error.status === 401) {
|
|
6790
|
-
return DEFAULT_401;
|
|
6791
|
-
}
|
|
6792
|
-
if ("message" in error && typeof error.message === "string") {
|
|
6793
|
-
return error.message;
|
|
6794
|
-
}
|
|
6795
|
-
}
|
|
6796
|
-
return describeThrownValue(error);
|
|
6797
|
-
}
|
|
6798
7610
|
// ../common/src/command-examples.ts
|
|
6799
7611
|
var examplesByCommand = new WeakMap;
|
|
6800
7612
|
function getCommandExamples(cmd) {
|
|
@@ -6823,26 +7635,26 @@ function extractCommandHelp(cmd, helper) {
|
|
|
6823
7635
|
const usage = helper.commandUsage(cmd);
|
|
6824
7636
|
const description = helper.commandDescription(cmd);
|
|
6825
7637
|
const args = helper.visibleArguments(cmd).map((arg) => {
|
|
6826
|
-
const
|
|
7638
|
+
const result = {
|
|
6827
7639
|
Name: arg.name(),
|
|
6828
7640
|
Description: arg.description || "",
|
|
6829
7641
|
Required: arg.required
|
|
6830
7642
|
};
|
|
6831
7643
|
if (arg.defaultValue !== undefined) {
|
|
6832
|
-
|
|
7644
|
+
result.Default = String(arg.defaultValue);
|
|
6833
7645
|
}
|
|
6834
|
-
return
|
|
7646
|
+
return result;
|
|
6835
7647
|
});
|
|
6836
7648
|
const options = helper.visibleOptions(cmd).map((opt) => {
|
|
6837
|
-
const
|
|
7649
|
+
const result = {
|
|
6838
7650
|
Flags: opt.flags,
|
|
6839
7651
|
Description: opt.description || ""
|
|
6840
7652
|
};
|
|
6841
7653
|
const defaultDesc = opt.defaultValueDescription ?? (opt.defaultValue !== undefined ? String(opt.defaultValue) : undefined);
|
|
6842
7654
|
if (defaultDesc !== undefined) {
|
|
6843
|
-
|
|
7655
|
+
result.Default = defaultDesc;
|
|
6844
7656
|
}
|
|
6845
|
-
return
|
|
7657
|
+
return result;
|
|
6846
7658
|
});
|
|
6847
7659
|
const examples = getCommandExamples(cmd);
|
|
6848
7660
|
const result = {
|
|
@@ -6872,17 +7684,6 @@ function collectCommands(command, parentName, result) {
|
|
|
6872
7684
|
collectCommands(sub, name, result);
|
|
6873
7685
|
}
|
|
6874
7686
|
}
|
|
6875
|
-
// ../common/src/completer.ts
|
|
6876
|
-
var COMPLETER_SYMBOL = Symbol.for("@uipath/common/completer");
|
|
6877
|
-
function getCompleter(target) {
|
|
6878
|
-
if (!target)
|
|
6879
|
-
return;
|
|
6880
|
-
const raw = target[COMPLETER_SYMBOL];
|
|
6881
|
-
if (raw && typeof raw === "object" && "command" in raw && "valueSelector" in raw) {
|
|
6882
|
-
return raw;
|
|
6883
|
-
}
|
|
6884
|
-
return;
|
|
6885
|
-
}
|
|
6886
7687
|
// ../common/src/confirmation.ts
|
|
6887
7688
|
function requireConfirmation(flags, operation) {
|
|
6888
7689
|
if (flags.yes === true || flags.force === true) {
|
|
@@ -6896,11 +7697,6 @@ function requireConfirmation(flags, operation) {
|
|
|
6896
7697
|
processContext.exit(1);
|
|
6897
7698
|
return false;
|
|
6898
7699
|
}
|
|
6899
|
-
// ../common/src/constants.ts
|
|
6900
|
-
var UIPATH_HOME_DIR = ".uipath";
|
|
6901
|
-
var CONFIG_FILENAME = "config.json";
|
|
6902
|
-
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
6903
|
-
var DEFAULT_FETCH_TIMEOUT_MS = 30000;
|
|
6904
7700
|
// ../common/src/entity-name-rules.ts
|
|
6905
7701
|
var RESERVED_SQL_KEYWORDS_LOWER = new Set(["group", "order"]);
|
|
6906
7702
|
var RESERVED_FIELD_NAMES_LOWER = new Set([
|
|
@@ -7099,20 +7895,6 @@ var RESERVED_KEYWORDS_LOWER = new Set([
|
|
|
7099
7895
|
"writeonly",
|
|
7100
7896
|
"xor"
|
|
7101
7897
|
]);
|
|
7102
|
-
// ../common/src/env-reference.ts
|
|
7103
|
-
function resolveEnvReference(value) {
|
|
7104
|
-
if (value == null)
|
|
7105
|
-
return value;
|
|
7106
|
-
if (value.startsWith("env.")) {
|
|
7107
|
-
const name = value.slice(4);
|
|
7108
|
-
const resolved = process.env[name];
|
|
7109
|
-
if (!resolved) {
|
|
7110
|
-
throw new Error(`Environment variable "${name}" is not set`);
|
|
7111
|
-
}
|
|
7112
|
-
return resolved;
|
|
7113
|
-
}
|
|
7114
|
-
return value;
|
|
7115
|
-
}
|
|
7116
7898
|
// ../common/src/host-global-options.ts
|
|
7117
7899
|
var HOST_GLOBAL_OPTIONS_WITH_VALUE = [
|
|
7118
7900
|
"--output",
|
|
@@ -7128,32 +7910,6 @@ var HOST_GLOBAL_FLAGS = [
|
|
|
7128
7910
|
];
|
|
7129
7911
|
var VALUE_OPTIONS = new Set(HOST_GLOBAL_OPTIONS_WITH_VALUE);
|
|
7130
7912
|
var BOOLEAN_FLAGS = new Set(HOST_GLOBAL_FLAGS);
|
|
7131
|
-
// ../common/src/interactivity-context.ts
|
|
7132
|
-
var modeSlot = singleton("InteractivityMode");
|
|
7133
|
-
var interactiveFlagSlot = singleton("InteractiveFlag");
|
|
7134
|
-
function setInteractivityMode(mode) {
|
|
7135
|
-
modeSlot.set(mode);
|
|
7136
|
-
}
|
|
7137
|
-
function getInteractivityMode() {
|
|
7138
|
-
return modeSlot.get("auto") ?? "auto";
|
|
7139
|
-
}
|
|
7140
|
-
function setInteractiveFlag(passed) {
|
|
7141
|
-
interactiveFlagSlot.set(passed);
|
|
7142
|
-
}
|
|
7143
|
-
function wasInteractiveFlagPassed() {
|
|
7144
|
-
return interactiveFlagSlot.get(false) ?? false;
|
|
7145
|
-
}
|
|
7146
|
-
function canPrompt() {
|
|
7147
|
-
const mode = getInteractivityMode();
|
|
7148
|
-
if (mode === "always") {
|
|
7149
|
-
return true;
|
|
7150
|
-
}
|
|
7151
|
-
if (mode === "never") {
|
|
7152
|
-
return false;
|
|
7153
|
-
}
|
|
7154
|
-
const capabilities = getOutputSink().capabilities;
|
|
7155
|
-
return capabilities.isInteractive && capabilities.canReadInput;
|
|
7156
|
-
}
|
|
7157
7913
|
// ../common/src/mime-types.ts
|
|
7158
7914
|
var MIME_TYPES_BY_EXTENSION = Object.freeze({
|
|
7159
7915
|
pdf: "application/pdf",
|
|
@@ -7188,26 +7944,6 @@ var MIME_TYPES_BY_EXTENSION = Object.freeze({
|
|
|
7188
7944
|
wav: "audio/wav",
|
|
7189
7945
|
mp4: "video/mp4"
|
|
7190
7946
|
});
|
|
7191
|
-
// ../common/src/option-validators.ts
|
|
7192
|
-
function parseBoundedInt(raw, optionName, bounds) {
|
|
7193
|
-
const normalized = raw.trim();
|
|
7194
|
-
if (normalized === "") {
|
|
7195
|
-
throw new InvalidArgumentError(`${optionName} requires a value (got empty).`);
|
|
7196
|
-
}
|
|
7197
|
-
if (!/^-?\d+$/.test(normalized)) {
|
|
7198
|
-
throw new InvalidArgumentError(`${optionName} must be an integer, got '${normalized}'.`);
|
|
7199
|
-
}
|
|
7200
|
-
const n = parseInt(normalized, 10);
|
|
7201
|
-
if (n < bounds.min || n > bounds.max) {
|
|
7202
|
-
throw new InvalidArgumentError(`${optionName} must be between ${bounds.min} and ${bounds.max}, got ${n}.`);
|
|
7203
|
-
}
|
|
7204
|
-
return n;
|
|
7205
|
-
}
|
|
7206
|
-
function splitScopeList(raw) {
|
|
7207
|
-
if (!raw)
|
|
7208
|
-
return [];
|
|
7209
|
-
return raw.split(/[\s,]+/).filter((scope) => scope.length > 0);
|
|
7210
|
-
}
|
|
7211
7947
|
// ../common/src/packager-tool-import.ts
|
|
7212
7948
|
var REGISTER_EXPORT = "registerPackagerFactories";
|
|
7213
7949
|
// ../common/src/screen-logger.ts
|
|
@@ -7267,6 +8003,6 @@ var factorySlot = singleton("PackagerFactoryProvider");
|
|
|
7267
8003
|
function setPackagerFactoryProvider(provider) {
|
|
7268
8004
|
factorySlot.set(provider);
|
|
7269
8005
|
}
|
|
7270
|
-
export { redactProperties, catchError, carriedInstructions, formatErrorChain, describeConnectivityError, extractErrorMessageSync,
|
|
8006
|
+
export { CLI_APPLICATION_NAME, BaseDimensions, CommandDimensions, ProjectDimensions, AuthDimensions, SkillsDimensions, assertNoCuratedDimensionTargets, solutionIdentityProperties, projectKey, redactProperties, catchError, carriedErrorCode, carriedRetry, carriedInstructions, formatErrorChain, describeConnectivityError, extractErrorMessageSync, RESULTS, Command, Option, setPreviewBuild, runWithSink, getOutputSink, setGlobalSink, LogLevel, logger, configureLogger, runWithTimings, setTimingCommand, suppressTimingReport, setExitCode, recordHostExit, getExitCode, resetExitCode, loadOutputCodecsAsync, setOutputFormat, getOutputFormat, setOutputFormatExplicit, getOutputFormatExplicit, setHelpRequested, getHelpRequested, setOutputFilter, OUTPUT_FORMATS, isOutputFormat, takeRecordedCommandFailureTelemetry, buildCommandTerminalTelemetryProperties, CommonTelemetryEvents, detectAgent, detectAgentVersion, buildEnvironmentProperties, setExecutionContextAuthSignal, setGlobalTelemetryProperties, makeTrackedFetch, setProxyAuthHttpsAgent, isTelemetryDisabled, TELEMETRY_DRAIN_ARGV, setTelemetrySidecarEntry, claimPendingSpoolFiles, releaseClaimedSpoolFile, discardClaimedSpoolFile, sweepTelemetrySpool, getTelemetryIngestionOrigin, telemetry, telemetryInit, telemetryFlushAndShutdown, telemetryShutdownWithoutFlush, EXIT_CODES, Pagination, validateOutputFilter, OutputFormatter, configureProjectContextTelemetry, buildSkillEventTelemetryAttribution, sanitizeTelemetryToken, commandTelemetryName, commandInvocationPath, runWithInvocationRequest, emitInvocationRequest, processContext, setProcessContextPollSignal, TELEMETRY_ARG_VALUE_WITHHELD, extractCommandHelp, collectCommands, getCompleter, requireConfirmation, installConsoleGuard, UIPATH_HOME_DIR, CONFIG_FILENAME, DEFAULT_FETCH_TIMEOUT_MS, resolveEnvReference, setInteractivityMode, setInteractiveFlag, wasInteractiveFlagPassed, canPrompt, parseBoundedInt, splitScopeList, REGISTER_EXPORT, createPollAbortController, setSdkUserAgentHostToken, readStdinWithTimeout, setPackagerFactoryProvider };
|
|
7271
8007
|
|
|
7272
|
-
//# debugId=
|
|
8008
|
+
//# debugId=FCA6B3D316553CD664756E2164756E21
|