@uipath/codedagent-tool 1.203.0-preview.212 → 1.204.0-preview.211

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.
@@ -2097,6 +2097,153 @@ var require_commander = __commonJS(function(exports) {
2097
2097
  exports.InvalidOptionArgumentError = InvalidArgumentError;
2098
2098
  });
2099
2099
 
2100
+ // ../common/src/telemetry/telemetry-dimensions.ts
2101
+ var BaseDimensions = {
2102
+ ApplicationName: "ApplicationName",
2103
+ ProductVersion: "ProductVersion",
2104
+ InstallationId: "InstallationId",
2105
+ CloudUserId: "CloudUserId",
2106
+ CloudTenantId: "CloudTenantId",
2107
+ CloudOrganizationId: "CloudOrganizationId",
2108
+ IsInternalUser: "IsInternalUser",
2109
+ Environment: "Environment",
2110
+ BaseUrl: "BaseUrl",
2111
+ Region: "Region",
2112
+ Agent: "Agent",
2113
+ AgentVersion: "AgentVersion",
2114
+ AgentModel: "AgentModel",
2115
+ ToolName: "ToolName",
2116
+ ToolVersion: "ToolVersion",
2117
+ ExecutionContext: "ExecutionContext",
2118
+ CiProvider: "CiProvider",
2119
+ SessionIdSource: "SessionIdSource",
2120
+ SessionId: "SessionId"
2121
+ };
2122
+ var CommandDimensions = {
2123
+ IsCommand: "IsCommand",
2124
+ IsReexec: "IsReexec",
2125
+ CommandName: "CommandName",
2126
+ ExitCode: "ExitCode",
2127
+ TerminalOutcome: "TerminalOutcome",
2128
+ ErrorClass: "ErrorClass",
2129
+ TerminalSignal: "TerminalSignal",
2130
+ ErrorMessage: "ErrorMessage",
2131
+ SkillName: "SkillName",
2132
+ ProductArea: "ProductArea",
2133
+ Mode: "Mode"
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
+ };
2155
+ var AuthDimensions = {
2156
+ AuthenticationMethod: "AuthenticationMethod",
2157
+ Success: "Success",
2158
+ Reason: "Reason"
2159
+ };
2160
+ var SkillsDimensions = {
2161
+ SchemaVersion: "SchemaVersion",
2162
+ AgentType: "AgentType",
2163
+ SkillsVersion: "SkillsVersion",
2164
+ UipSubcommand: "UipSubcommand",
2165
+ FileExtension: "FileExtension",
2166
+ SubagentModel: "SubagentModel",
2167
+ SubagentType: "SubagentType",
2168
+ PermissionMode: "PermissionMode",
2169
+ EffortLevel: "EffortLevel",
2170
+ SessionSource: "SessionSource",
2171
+ Outcome: "Outcome",
2172
+ DurationMs: "DurationMs",
2173
+ Source: "Source"
2174
+ };
2175
+ var PackagerDimensions = {
2176
+ ProjectId: "ProjectId",
2177
+ ProjectType: "ProjectType",
2178
+ SolutionId: "SolutionId"
2179
+ };
2180
+ var ScopeDimensions = {
2181
+ FolderId: "FolderId"
2182
+ };
2183
+ var ID_DIMENSIONS = new Set([
2184
+ BaseDimensions.CloudUserId,
2185
+ BaseDimensions.CloudTenantId,
2186
+ BaseDimensions.CloudOrganizationId,
2187
+ BaseDimensions.InstallationId,
2188
+ ShipDimensions.ArtifactCorrelationKey,
2189
+ ShipDimensions.PackageVersionKey,
2190
+ ShipDimensions.DeploymentKey,
2191
+ ShipDimensions.SolutionId,
2192
+ ShipDimensions.FolderKey,
2193
+ ShipDimensions.FeedId,
2194
+ PackagerDimensions.ProjectId
2195
+ ]);
2196
+ var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
2197
+ var RESERVED_DIMENSION_NAMES = new Set([
2198
+ ...Object.values(BaseDimensions),
2199
+ ...Object.values(CommandDimensions),
2200
+ ...Object.values(ShipDimensions),
2201
+ ...Object.values(ErrorDimensions),
2202
+ ...Object.values(AuthDimensions),
2203
+ ...Object.values(SkillsDimensions),
2204
+ ...Object.values(PackagerDimensions),
2205
+ ...Object.values(ScopeDimensions)
2206
+ ]);
2207
+ var CURATED_DIMENSIONS = new Set([
2208
+ BaseDimensions.ApplicationName,
2209
+ BaseDimensions.ProductVersion,
2210
+ BaseDimensions.InstallationId,
2211
+ BaseDimensions.CloudUserId,
2212
+ BaseDimensions.CloudTenantId,
2213
+ BaseDimensions.CloudOrganizationId,
2214
+ BaseDimensions.IsInternalUser,
2215
+ BaseDimensions.Environment,
2216
+ BaseDimensions.BaseUrl,
2217
+ BaseDimensions.Region,
2218
+ BaseDimensions.Agent,
2219
+ BaseDimensions.AgentVersion,
2220
+ BaseDimensions.ToolVersion,
2221
+ BaseDimensions.ExecutionContext,
2222
+ BaseDimensions.CiProvider,
2223
+ BaseDimensions.SessionIdSource,
2224
+ BaseDimensions.SessionId,
2225
+ ...Object.values(CommandDimensions),
2226
+ ...Object.values(ShipDimensions)
2227
+ ]);
2228
+ function lowercaseIdDimensionValues(properties) {
2229
+ let changed = false;
2230
+ const result = {
2231
+ ...properties
2232
+ };
2233
+ for (const key of Object.keys(result)) {
2234
+ const value = result[key];
2235
+ if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
2236
+ continue;
2237
+ }
2238
+ const lowered = value.toLowerCase();
2239
+ if (lowered !== value) {
2240
+ result[key] = lowered;
2241
+ changed = true;
2242
+ }
2243
+ }
2244
+ return changed ? result : properties;
2245
+ }
2246
+
2100
2247
  // ../../node_modules/commander/esm.mjs
2101
2248
  var import__ = __toESM(require_commander(), 1);
2102
2249
  var {
@@ -2655,6 +2802,13 @@ function setExitCode(code) {
2655
2802
  process.exitCode = code;
2656
2803
  }
2657
2804
 
2805
+ // ../common/src/local-permission-codes.ts
2806
+ var LOCAL_PERMISSION_ERROR_CODES = new Set([
2807
+ "EACCES",
2808
+ "EPERM",
2809
+ "EROFS"
2810
+ ]);
2811
+
2658
2812
  // ../filesystem/src/node.ts
2659
2813
  import { randomUUID } from "node:crypto";
2660
2814
  import { existsSync } from "node:fs";
@@ -3141,12 +3295,59 @@ function getOutputFilter() {
3141
3295
  return filterSlot.get();
3142
3296
  }
3143
3297
 
3298
+ // ../common/src/error-graph.ts
3299
+ function* walkErrorGraph(error) {
3300
+ const queue = [error];
3301
+ const seen = new Set;
3302
+ for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
3303
+ const current = queue.shift();
3304
+ if (current === null || typeof current !== "object")
3305
+ continue;
3306
+ if (seen.has(current))
3307
+ continue;
3308
+ seen.add(current);
3309
+ const cur = current;
3310
+ yield cur;
3311
+ if (cur.cause !== undefined)
3312
+ queue.push(cur.cause);
3313
+ if (Array.isArray(cur.errors))
3314
+ queue.push(...cur.errors);
3315
+ }
3316
+ return;
3317
+ }
3318
+ function parseHttpStatusFromMessage(message) {
3319
+ const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
3320
+ if (!match)
3321
+ return;
3322
+ const status = Number(match[1]);
3323
+ return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
3324
+ }
3325
+ function findHttpStatusInGraph(error) {
3326
+ for (const node of walkErrorGraph(error)) {
3327
+ const response = node.response;
3328
+ const explicit = typeof node.status === "number" ? node.status : response?.status;
3329
+ if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
3330
+ return explicit;
3331
+ }
3332
+ if (typeof node.message === "string") {
3333
+ const parsed = parseHttpStatusFromMessage(node.message);
3334
+ if (parsed !== undefined && parsed >= 400) {
3335
+ return parsed;
3336
+ }
3337
+ }
3338
+ }
3339
+ return;
3340
+ }
3341
+
3144
3342
  // ../common/src/telemetry/command-terminal.ts
3145
3343
  var recordedFailureSlot = singleton("CommandTelemetryFailure");
3146
3344
  var AUTH_ERROR_CODES = new Set([
3147
3345
  "authentication_required",
3148
3346
  "permission_denied"
3149
3347
  ]);
3348
+ var LOCAL_PERMISSION_CLI_ERROR_CODES = new Set([
3349
+ "local_permission_denied"
3350
+ ]);
3150
3351
  var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
3151
3352
  var NETWORK_HTTP_ERROR_CODES = new Set([
3152
3353
  "network_error",
@@ -3287,6 +3488,9 @@ function classifyFromErrorCode(errorCode) {
3287
3488
  if (AUTH_ERROR_CODES.has(errorCode)) {
3288
3489
  return "auth";
3289
3490
  }
3491
+ if (LOCAL_PERMISSION_CLI_ERROR_CODES.has(errorCode)) {
3492
+ return "local_permission";
3493
+ }
3290
3494
  if (VALIDATION_ERROR_CODES.has(errorCode)) {
3291
3495
  return "validation";
3292
3496
  }
@@ -3298,6 +3502,15 @@ function classifyFromErrorCode(errorCode) {
3298
3502
  }
3299
3503
  return;
3300
3504
  }
3505
+ function hasLocalPermissionCode(error) {
3506
+ for (const node of walkErrorGraph(error)) {
3507
+ const code = node.code;
3508
+ if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
3509
+ return true;
3510
+ }
3511
+ }
3512
+ return false;
3513
+ }
3301
3514
  function classifyFromError(error) {
3302
3515
  const code = findCodeInCauseChain(error);
3303
3516
  if (code) {
@@ -3314,6 +3527,9 @@ function classifyFromError(error) {
3314
3527
  return "missing_dependency";
3315
3528
  }
3316
3529
  }
3530
+ if (hasLocalPermissionCode(error)) {
3531
+ return "local_permission";
3532
+ }
3317
3533
  const message = stringField(error, "message");
3318
3534
  if (message?.includes("fetch failed") === true) {
3319
3535
  return "network_http";
@@ -3329,7 +3545,7 @@ function classifyError(input) {
3329
3545
  if (recorded?.errorClass) {
3330
3546
  return recorded.errorClass;
3331
3547
  }
3332
- const status = recorded?.context?.httpStatus;
3548
+ const status = recorded?.context?.httpStatus ?? findHttpStatusInGraph(input.error);
3333
3549
  if (status !== undefined) {
3334
3550
  return classifyHttpStatus(status);
3335
3551
  }
@@ -3352,17 +3568,18 @@ function buildCommandTerminalTelemetryProperties(input) {
3352
3568
  const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError(input);
3353
3569
  const terminalSignal = terminalSignalFor(input, outcome);
3354
3570
  return {
3355
- exit_code: input.exitCode,
3356
- terminal_outcome: outcome,
3357
- ...errorClass ? { error_class: errorClass } : {},
3358
- ...terminalSignal ? { terminal_signal: terminalSignal } : {}
3571
+ [CommandDimensions.ExitCode]: input.exitCode,
3572
+ [CommandDimensions.TerminalOutcome]: outcome,
3573
+ ...errorClass ? { [CommandDimensions.ErrorClass]: errorClass } : {},
3574
+ ...terminalSignal ? { [CommandDimensions.TerminalSignal]: terminalSignal } : {}
3359
3575
  };
3360
3576
  }
3361
3577
 
3362
3578
  // ../common/src/telemetry/telemetry-events.ts
3363
3579
  var CommonTelemetryEvents = {
3364
- Error: "uip.error",
3365
- ShipSucceeded: "uip.ship.succeeded"
3580
+ Start: "Application.Start",
3581
+ Error: "Application.Error",
3582
+ ShipSucceeded: "Cli.ShipSucceeded"
3366
3583
  };
3367
3584
 
3368
3585
  // ../common/src/registry.ts
@@ -3570,8 +3787,8 @@ function detectExecutionContext(options = {}) {
3570
3787
  function getExecutionContextTelemetryProperties() {
3571
3788
  const detected = detectExecutionContext();
3572
3789
  return {
3573
- execution_context: detected.executionContext,
3574
- ...detected.ciProvider ? { ci_provider: detected.ciProvider } : {}
3790
+ [BaseDimensions.ExecutionContext]: detected.executionContext,
3791
+ ...detected.ciProvider ? { [BaseDimensions.CiProvider]: detected.ciProvider } : {}
3575
3792
  };
3576
3793
  }
3577
3794
  // ../common/src/telemetry/node-context-storage.ts
@@ -3614,7 +3831,7 @@ function getInboundTraceContext() {
3614
3831
  var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
3615
3832
  var SESSION_ID_MAX_LENGTH = 64;
3616
3833
  var RANDOM_SESSION_ID_LENGTH = 32;
3617
- var TELEMETRY_SESSION_SOURCE_PROPERTY = "session_id_source";
3834
+ var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
3618
3835
  var CONTROL_CHARACTERS = /\p{Cc}/gu;
3619
3836
  var INHERITED_SESSION_SOURCES = [
3620
3837
  { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
@@ -3666,6 +3883,9 @@ function resolveTelemetrySession() {
3666
3883
  telemetrySessionSlot.set(resolved);
3667
3884
  return resolved;
3668
3885
  }
3886
+ function getTelemetrySessionId() {
3887
+ return resolveTelemetrySession().id;
3888
+ }
3669
3889
  function getTelemetrySessionSource() {
3670
3890
  return resolveTelemetrySession().source;
3671
3891
  }
@@ -3746,7 +3966,10 @@ class TelemetryService {
3746
3966
  } catch (error) {
3747
3967
  const durationMs = clock.elapsedMs();
3748
3968
  const err = error instanceof Error ? error : new Error(String(error));
3749
- await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, context));
3969
+ await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, {
3970
+ ...properties,
3971
+ [CommandDimensions.ErrorMessage]: err.message
3972
+ }, context));
3750
3973
  throw error;
3751
3974
  }
3752
3975
  }
@@ -3817,7 +4040,10 @@ class TelemetryService {
3817
4040
  const durationMs = clock.elapsedMs();
3818
4041
  const err = error instanceof Error ? error : new Error(String(error));
3819
4042
  await this.telemetryProvider.trackDependency({
3820
- ...this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, childContext),
4043
+ ...this.spanFor(name, durationMs, false, {
4044
+ ...properties,
4045
+ [CommandDimensions.ErrorMessage]: err.message
4046
+ }, childContext),
3821
4047
  type
3822
4048
  });
3823
4049
  throw error;
@@ -3852,9 +4078,10 @@ class TelemetryService {
3852
4078
  ...globalProperties,
3853
4079
  ...this.defaultProperties,
3854
4080
  ...redactProperties(properties ?? {}),
3855
- [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
4081
+ [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
4082
+ [BaseDimensions.SessionId]: this.telemetryProvider.getSessionId?.() ?? getTelemetrySessionId()
3856
4083
  };
3857
- return enriched;
4084
+ return lowercaseIdDimensionValues(enriched);
3858
4085
  }
3859
4086
  generateId() {
3860
4087
  const bytes = new Uint8Array(8);
@@ -4615,7 +4842,165 @@ class FilterImplicitLimitError extends Error {
4615
4842
  this.instructions = "Pass --limit <n> to choose how many records the filter applies to. " + "To filter over all records, pass the command's maximum accepted --limit (see the option's description in --help).";
4616
4843
  }
4617
4844
  }
4618
- function applyFilter(data, filter) {
4845
+ function countRecords(data) {
4846
+ if (Array.isArray(data))
4847
+ return data.length;
4848
+ return data == null ? 0 : 1;
4849
+ }
4850
+ function availableFields(data) {
4851
+ const records = Array.isArray(data) ? data : [data];
4852
+ const keys = new Set;
4853
+ for (const record of records) {
4854
+ if (record && typeof record === "object" && !Array.isArray(record)) {
4855
+ for (const key of Object.keys(record))
4856
+ keys.add(key);
4857
+ }
4858
+ }
4859
+ return [...keys];
4860
+ }
4861
+ function decodeQuotedIdentifier(whole, inner) {
4862
+ const [error, decoded] = catchError(() => JSON.parse(whole));
4863
+ if (!error && typeof decoded === "string")
4864
+ return decoded;
4865
+ return inner.replace(/\\(.)/g, "$1");
4866
+ }
4867
+ function referencedFields(filter) {
4868
+ const top = new Set;
4869
+ const nested = new Set;
4870
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
4871
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
4872
+ const quoted = [];
4873
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
4874
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
4875
+ if (!isAlias) {
4876
+ quoted.push({
4877
+ name: decodeQuotedIdentifier(whole, name),
4878
+ index,
4879
+ tail: isPathTail(withoutValueLiterals, index)
4880
+ });
4881
+ }
4882
+ return `"${" ".repeat(whole.length - 2)}"`;
4883
+ });
4884
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
4885
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
4886
+ const place = (name, index, tail) => {
4887
+ if (tail || index >= rootEnd)
4888
+ nested.add(name);
4889
+ else
4890
+ top.add(name);
4891
+ };
4892
+ for (const entry of quoted)
4893
+ place(entry.name, entry.index, entry.tail);
4894
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
4895
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
4896
+ for (const match of identifiers) {
4897
+ const [, name, trailing] = match;
4898
+ if (trailing || reserved.has(name))
4899
+ continue;
4900
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
4901
+ }
4902
+ return {
4903
+ top: [...top],
4904
+ nested: [...nested].filter((name) => !top.has(name)),
4905
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
4906
+ };
4907
+ }
4908
+ function appearsBelowTopLevel(data, name) {
4909
+ let budget = 2000;
4910
+ const visit = (value, depth) => {
4911
+ if (budget-- <= 0 || depth > 4)
4912
+ return false;
4913
+ if (value === null || typeof value !== "object")
4914
+ return false;
4915
+ if (Array.isArray(value))
4916
+ return value.some((entry) => visit(entry, depth));
4917
+ const record = value;
4918
+ if (depth > 0 && Object.hasOwn(record, name))
4919
+ return true;
4920
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
4921
+ };
4922
+ return visit(data, 0);
4923
+ }
4924
+ function alwaysNullKeys(records) {
4925
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
4926
+ if (objects.length === 0 || objects.length !== records.length)
4927
+ return [];
4928
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
4929
+ if (keys.length === 0)
4930
+ return [];
4931
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
4932
+ return nullKeys.length === keys.length ? nullKeys : [];
4933
+ }
4934
+ function carriesOnlyNulls(value) {
4935
+ if (value === null)
4936
+ return true;
4937
+ if (Array.isArray(value)) {
4938
+ return value.length > 0 && value.every(carriesOnlyNulls);
4939
+ }
4940
+ if (typeof value === "object" && value !== undefined) {
4941
+ const values = Object.values(value);
4942
+ return values.length > 0 && values.every(carriesOnlyNulls);
4943
+ }
4944
+ return false;
4945
+ }
4946
+ function nameList(names, cap2 = 12) {
4947
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
4948
+ const rest = names.length - shown.length;
4949
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
4950
+ }
4951
+ function buildFilterWarning(filter, data, outcome) {
4952
+ const present = availableFields(data);
4953
+ const refs = referencedFields(filter);
4954
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
4955
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
4956
+ const count = countRecords(data);
4957
+ const scope = `${count} record(s)`;
4958
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
4959
+ const soundness = unchecked.length > 0 ? `${nameList(unchecked)} ${unchecked.length === 1 ? "reads" : "read"} below the top level, so ${unchecked.length === 1 ? "it was" : "they were"} not checked against the record keys` : refs.top.length > 0 ? "every field it names exists" : "";
4960
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
4961
+ let detail;
4962
+ let lede;
4963
+ if (outcome.kind === "null-elements") {
4964
+ lede = "returned only null values";
4965
+ const projected = `all ${outcome.count} of the elements it projected are null`;
4966
+ if (unknown.length > 0) {
4967
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4968
+ } else if (unchecked.length > 0) {
4969
+ detail = withSoundness(projected);
4970
+ } else {
4971
+ detail = `${projected}, and every field it names exists — a multi-select list ` + `(\`[A, B]\`) reads each entry against \`Data\` itself, so on a list ` + `result use \`[].[A, B]\` or \`[].{a: A, b: B}\` to read the records`;
4972
+ }
4973
+ } else if (outcome.kind === "null-rows") {
4974
+ lede = "returned only null values";
4975
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
4976
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
4977
+ } else if (outcome.kind === "null-values") {
4978
+ lede = "returned only null values";
4979
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
4980
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
4981
+ if (sameSet) {
4982
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
4983
+ } else if (unknown.length > 0) {
4984
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4985
+ } else {
4986
+ detail = withSoundness(`${projected} on all ${scope}`);
4987
+ }
4988
+ } else {
4989
+ lede = "returned nothing";
4990
+ if (unknown.length > 0) {
4991
+ detail = isNotAField(unknown);
4992
+ } else {
4993
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
4994
+ detail = withSoundness(`${selection} — it read ${scope}`);
4995
+ }
4996
+ }
4997
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
4998
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
4999
+ }
5000
+ function appendWarning(existing, note) {
5001
+ return existing ? `${existing} ${note}` : note;
5002
+ }
5003
+ function applyFilter(data, filter, onWarning) {
4619
5004
  const codec = requireJmespath();
4620
5005
  let result;
4621
5006
  try {
@@ -4623,9 +5008,34 @@ function applyFilter(data, filter) {
4623
5008
  } catch (err) {
4624
5009
  throw new FilterEvaluationError(filter, err);
4625
5010
  }
4626
- if (result == null)
5011
+ const inputCount = countRecords(data);
5012
+ const warn = (outcome) => {
5013
+ if (inputCount === 0)
5014
+ return;
5015
+ const note = buildFilterWarning(filter, data, outcome);
5016
+ getOutputSink().writeErr(`[WARN] ${note}
5017
+ `);
5018
+ onWarning?.(note);
5019
+ };
5020
+ const warnIfAllNull = (records) => {
5021
+ const keys = alwaysNullKeys(records);
5022
+ if (keys.length > 0)
5023
+ warn({ kind: "null-values", keys });
5024
+ };
5025
+ if (result == null) {
5026
+ warn({ kind: "empty" });
4627
5027
  return [];
5028
+ }
4628
5029
  if (Array.isArray(result)) {
5030
+ if (result.length === 0) {
5031
+ warn({ kind: "empty" });
5032
+ } else if (result.every((entry) => entry === null)) {
5033
+ warn({ kind: "null-elements", count: result.length });
5034
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
5035
+ warn({ kind: "null-rows", count: result.length });
5036
+ } else {
5037
+ warnIfAllNull(result);
5038
+ }
4629
5039
  if (result.length > 0 && typeof result[0] !== "object") {
4630
5040
  const fieldMatch = filter.match(/\.(\w+)$/);
4631
5041
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -4633,10 +5043,30 @@ function applyFilter(data, filter) {
4633
5043
  }
4634
5044
  return result;
4635
5045
  }
4636
- if (typeof result === "object")
5046
+ if (typeof result === "object") {
5047
+ warnIfAllNull([result]);
4637
5048
  return result;
5049
+ }
4638
5050
  return { Value: result };
4639
5051
  }
5052
+ function filterFailureData(envelope) {
5053
+ const filter = getOutputFilter();
5054
+ const data = envelope.Data;
5055
+ if (!filter || data == null)
5056
+ return;
5057
+ let note;
5058
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
5059
+ note = n;
5060
+ }));
5061
+ if (filterError) {
5062
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
5063
+ return;
5064
+ }
5065
+ envelope.Data = filtered;
5066
+ if (note) {
5067
+ envelope.Warning = appendWarning(envelope.Warning, note);
5068
+ }
5069
+ }
4640
5070
  function defaultErrorCodeForResult(result) {
4641
5071
  switch (result) {
4642
5072
  case RESULTS.AuthenticationError:
@@ -4651,7 +5081,7 @@ function defaultErrorCodeForResult(result) {
4651
5081
  return "unknown_error";
4652
5082
  }
4653
5083
  }
4654
- function parseHttpStatusFromMessage(message) {
5084
+ function parseHttpStatusFromMessage2(message) {
4655
5085
  const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
4656
5086
  if (!match)
4657
5087
  return;
@@ -4680,10 +5110,10 @@ function defaultErrorCodeForHttpStatus(status) {
4680
5110
  return "server_error";
4681
5111
  return;
4682
5112
  }
4683
- var LOCAL_PERMISSION_TEXT_PATTERN = /(?:\b|\()(?:EACCES|EPERM|EROFS)(?::\s|\))/;
5113
+ var LOCAL_PERMISSION_TEXT_PATTERN = new RegExp(`(?:\\b|\\()(?:${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})(?::\\s|\\))`);
4684
5114
  function defaultErrorCodeForFailure(data) {
4685
5115
  if (data.Result === RESULTS.Failure) {
4686
- const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage(data.Message);
5116
+ const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
4687
5117
  const errorCode = defaultErrorCodeForHttpStatus(status);
4688
5118
  if (errorCode)
4689
5119
  return errorCode;
@@ -4719,8 +5149,14 @@ var OutputFormatter;
4719
5149
  }
4720
5150
  const filter = getOutputFilter();
4721
5151
  if (filter) {
4722
- const filtered = applyFilter(data.Data, filter);
5152
+ let note;
5153
+ const filtered = applyFilter(data.Data, filter, (n) => {
5154
+ note = n;
5155
+ });
4723
5156
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
5157
+ if (note) {
5158
+ data.Warning = appendWarning(data.Warning, note);
5159
+ }
4724
5160
  }
4725
5161
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
4726
5162
  }
@@ -4748,12 +5184,13 @@ var OutputFormatter;
4748
5184
  delete envelope.TelemetryErrorClass;
4749
5185
  delete envelope.TelemetryTerminalOutcome;
4750
5186
  delete envelope.TelemetryTerminalSignal;
5187
+ filterFailureData(envelope);
4751
5188
  if (!suppressTelemetry) {
4752
5189
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
4753
- result: data.Result,
4754
- errorCode: data.ErrorCode,
4755
- retry: data.Retry,
4756
- message: data.Message
5190
+ [ErrorDimensions.Result]: data.Result,
5191
+ [ErrorDimensions.ErrorCode]: data.ErrorCode,
5192
+ [ErrorDimensions.Retry]: data.Retry,
5193
+ [ErrorDimensions.ErrorMessage]: data.Message
4757
5194
  });
4758
5195
  }
4759
5196
  logOutput(normalizeOutputKeys(envelope), getOutputFormat());
@@ -4796,13 +5233,20 @@ var OutputFormatter;
4796
5233
  OutputFormatter.log = log;
4797
5234
  function formatToString(data) {
4798
5235
  const filter = getOutputFilter();
5236
+ const envelope = data;
4799
5237
  if ("Data" in data && data.Data != null) {
4800
5238
  data.Data = normalizeDataKeys(data.Data);
4801
5239
  if (filter) {
4802
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
5240
+ let note;
5241
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
5242
+ note = n;
5243
+ }));
5244
+ if (note) {
5245
+ envelope.Warning = appendWarning(envelope.Warning, note);
5246
+ }
4803
5247
  }
4804
5248
  }
4805
- const output = normalizeOutputKeys(data);
5249
+ const output = normalizeOutputKeys(envelope);
4806
5250
  const lines = [];
4807
5251
  const sink = getOutputSink();
4808
5252
  printOutput(output, getOutputFormat(), (msg) => {
@@ -4819,7 +5263,7 @@ var LEGACY_SKILL_NAMESPACE = "uipath:";
4819
5263
  var MAX_SKILL_NAME_LENGTH = 80;
4820
5264
  var SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
4821
5265
  function productMode(productArea, mode) {
4822
- return { product_area: productArea, mode };
5266
+ return { ProductArea: productArea, Mode: mode };
4823
5267
  }
4824
5268
  function attributionRecord(groups) {
4825
5269
  const record = {};
@@ -4877,6 +5321,7 @@ var COMMAND_ATTRIBUTION = commandAttribution([
4877
5321
  ["rpa", "build", ["uip.rpa-legacy"]],
4878
5322
  ["conversational", "operate", ["uip.conversational"]],
4879
5323
  ["agents", "build", ["uip.codedagent", "uip.agent"]],
5324
+ ["coding-agents", "build", ["uip.coder"]],
4880
5325
  ["agenthub", "build", ["uip.agenthub"]],
4881
5326
  ["coded-apps", "build", ["uip.codedapp"]],
4882
5327
  ["functions", "build", ["uip.function", "uip.functions"]],
@@ -4962,32 +5407,64 @@ function normalizeSkillName(value) {
4962
5407
  function buildCommandTelemetryAttribution(commandPath, skillSource) {
4963
5408
  const skillName = normalizeSkillName(skillSource);
4964
5409
  return {
4965
- ...skillName ? { skill_name: skillName } : {},
5410
+ ...skillName ? { SkillName: skillName } : {},
4966
5411
  ...getCommandProductModeAttribution(commandPath)
4967
5412
  };
4968
5413
  }
5414
+ var AGENT_SESSION_ENV = {
5415
+ [BaseDimensions.AgentModel]: "UIPATH_AGENT_MODEL",
5416
+ [SkillsDimensions.PermissionMode]: "UIPATH_PERMISSION_MODE",
5417
+ [SkillsDimensions.EffortLevel]: "UIPATH_EFFORT_LEVEL",
5418
+ [SkillsDimensions.SkillsVersion]: "UIPATH_SKILLS_VERSION"
5419
+ };
5420
+ var MAX_TELEMETRY_TOKEN_LENGTH = 120;
5421
+ function sanitizeTelemetryToken(value) {
5422
+ return value.replace(/[^A-Za-z0-9:._/ -]/g, "_").slice(0, MAX_TELEMETRY_TOKEN_LENGTH);
5423
+ }
5424
+ function buildAgentSessionTelemetry(env) {
5425
+ const dimensions = {};
5426
+ for (const [key, variable] of Object.entries(AGENT_SESSION_ENV)) {
5427
+ const value = env[variable]?.trim();
5428
+ if (value) {
5429
+ dimensions[key] = sanitizeTelemetryToken(value);
5430
+ }
5431
+ }
5432
+ return dimensions;
5433
+ }
4969
5434
 
4970
5435
  // ../common/src/telemetry/command-name.ts
4971
- var TELEMETRY_COMMAND_ROOT = "uip";
5436
+ var TELEMETRY_NAME_ROOT = "Cli";
5437
+ var CLI_COMMAND_ROOT = "uip";
5438
+ var TELEMETRY_NAME_BARE_ACTION = "Invoke";
4972
5439
  function commandTelemetryName(parts) {
5440
+ const action = vetCommandTokens(parts).map(pascalizeToken).join("");
5441
+ return `${TELEMETRY_NAME_ROOT}.${action || TELEMETRY_NAME_BARE_ACTION}`;
5442
+ }
5443
+ function commandInvocationPath(parts) {
5444
+ return [CLI_COMMAND_ROOT, ...vetCommandTokens(parts)].join(" ");
5445
+ }
5446
+ function vetCommandTokens(parts) {
4973
5447
  const tokens = [];
4974
5448
  for (const part of parts) {
4975
- const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== TELEMETRY_COMMAND_ROOT);
5449
+ const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== CLI_COMMAND_ROOT);
4976
5450
  if (pieces.every(isCommandToken)) {
4977
5451
  tokens.push(...pieces);
4978
5452
  continue;
4979
5453
  }
4980
5454
  tokens.push(UNKNOWN_TOKEN);
4981
5455
  }
4982
- return [TELEMETRY_COMMAND_ROOT, ...tokens].join(".");
5456
+ return tokens;
4983
5457
  }
4984
- var COMMAND_TOKEN_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
5458
+ function pascalizeToken(token) {
5459
+ return token.split("-").filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
5460
+ }
5461
+ var COMMAND_TOKEN_PATTERN = /^[a-z][a-z0-9-]*$/;
4985
5462
  var MAX_COMMAND_TOKEN_LENGTH = 32;
4986
5463
  var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
4987
5464
  function isCommandToken(token) {
4988
- return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token) && !/^\d+$/.test(token);
5465
+ return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token);
4989
5466
  }
4990
- var UNKNOWN_TOKEN = "<unknown>";
5467
+ var UNKNOWN_TOKEN = "unknown";
4991
5468
 
4992
5469
  // ../common/src/telemetry/invocation-request.ts
4993
5470
  var requestContextSlot = singleton("TelemetryInvocationRequestContext");
@@ -5092,7 +5569,7 @@ function withheldArgumentValues(cmd) {
5092
5569
  });
5093
5570
  return values;
5094
5571
  }
5095
- function deriveCommandPath(cmd) {
5572
+ function deriveCommandParts(cmd) {
5096
5573
  const parts = [];
5097
5574
  let current = cmd;
5098
5575
  while (current) {
@@ -5105,14 +5582,13 @@ function deriveCommandPath(cmd) {
5105
5582
  if (parts.length > 1) {
5106
5583
  parts.shift();
5107
5584
  }
5108
- return commandTelemetryName(parts);
5585
+ return parts;
5109
5586
  }
5110
5587
  function isErrorContext(value) {
5111
5588
  return value !== null && typeof value === "object";
5112
5589
  }
5113
5590
  function commandHelpHint(commandPath) {
5114
- const command = commandPath.replace(/\./g, " ");
5115
- return `An unexpected error occurred. Run '${command} --help' to verify command syntax, or run with --log-level debug for details.`;
5591
+ return `An unexpected error occurred. Run '${commandPath} --help' to verify command syntax, or run with --log-level debug for details.`;
5116
5592
  }
5117
5593
  function isPromptCancellation(error) {
5118
5594
  return error instanceof Error && error.name === "ExitPromptError";
@@ -5137,7 +5613,9 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5137
5613
  yaml: getOutputFormat() === "yaml",
5138
5614
  filter: getOutputFilter() !== undefined
5139
5615
  });
5140
- const telemetryName = deriveCommandPath(command);
5616
+ const commandParts = deriveCommandParts(command);
5617
+ const telemetryName = commandTelemetryName(commandParts);
5618
+ const commandPath = commandInvocationPath(commandParts);
5141
5619
  const props = typeof properties === "function" ? properties(...args) : properties;
5142
5620
  markCommandStart();
5143
5621
  const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
@@ -5172,7 +5650,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5172
5650
  Result: finalResult,
5173
5651
  ...customErrorCode ? { ErrorCode: customErrorCode } : {},
5174
5652
  Message: errorMessage,
5175
- Instructions: customInstructions ?? commandHelpHint(telemetryName),
5653
+ Instructions: customInstructions ?? commandHelpHint(commandPath),
5176
5654
  ...customRetry ? { Retry: customRetry } : {},
5177
5655
  ...customContext ? { Context: customContext } : {}
5178
5656
  });
@@ -5189,8 +5667,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5189
5667
  recordedFailure,
5190
5668
  pollSignal: context.pollSignal
5191
5669
  });
5192
- if (terminalTelemetry.error_class === "internal" && error) {
5193
- telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { command_name: telemetryName }, getInvocationRequestContext());
5670
+ if (terminalTelemetry[CommandDimensions.ErrorClass] === "internal" && error) {
5671
+ telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { [CommandDimensions.CommandName]: commandPath }, getInvocationRequestContext());
5194
5672
  }
5195
5673
  const commandParams = extractCommandParams(command);
5196
5674
  if (props) {
@@ -5201,10 +5679,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5201
5679
  const baseProperties = redactProperties({
5202
5680
  ...commandParams,
5203
5681
  ...props,
5204
- ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
5205
- command: "true",
5682
+ ...buildCommandTelemetryAttribution(commandPath, process.env.UIPATH_SKILL),
5683
+ ...buildAgentSessionTelemetry(process.env),
5684
+ [CommandDimensions.CommandName]: commandPath,
5685
+ [CommandDimensions.IsCommand]: "true",
5206
5686
  ...terminalTelemetry,
5207
- ...errorMessage ? { errorMessage } : {}
5687
+ ...errorMessage ? { [CommandDimensions.ErrorMessage]: errorMessage } : {}
5208
5688
  });
5209
5689
  emitInvocationRequest(telemetryName, success, baseProperties);
5210
5690
  } finally {
@@ -5226,21 +5706,21 @@ function getShippedKeys() {
5226
5706
  }
5227
5707
  function dedupeKey(payload) {
5228
5708
  return [
5229
- payload.command_name,
5230
- payload.ship_kind,
5231
- payload.target,
5232
- payload.project_type,
5233
- payload.artifact_correlation_key ?? payload.package_version_key ?? payload.deployment_key ?? payload.solution_id ?? payload.package_name ?? ""
5709
+ payload.CommandName,
5710
+ payload.ShipKind,
5711
+ payload.Target,
5712
+ payload.ProjectType,
5713
+ payload.ArtifactCorrelationKey ?? payload.PackageVersionKey ?? payload.DeploymentKey ?? payload.SolutionId ?? payload.PackageName ?? ""
5234
5714
  ].join("|");
5235
5715
  }
5236
5716
  function withPseudonymizedIdentifiers(payload) {
5237
5717
  return {
5238
5718
  ...payload,
5239
- ...payload.package_name === undefined ? {} : {
5240
- package_name: `package#${pseudonymize(payload.package_name)}`
5719
+ ...payload.PackageName === undefined ? {} : {
5720
+ PackageName: `package#${pseudonymize(payload.PackageName)}`
5241
5721
  },
5242
- ...payload.artifact_correlation_key === undefined ? {} : {
5243
- artifact_correlation_key: `artifact#${pseudonymize(payload.artifact_correlation_key)}`
5722
+ ...payload.ArtifactCorrelationKey === undefined ? {} : {
5723
+ ArtifactCorrelationKey: `artifact#${pseudonymize(payload.ArtifactCorrelationKey)}`
5244
5724
  }
5245
5725
  };
5246
5726
  }
@@ -5256,7 +5736,7 @@ function trackShipSucceeded(payload) {
5256
5736
  }
5257
5737
 
5258
5738
  // ../common/src/error-handler.ts
5259
- var DEFAULT_401 = "Unauthorized (401). Run `uip login` to authenticate.";
5739
+ 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.";
5260
5740
  var NETWORK_ERROR_CODES = new Set([
5261
5741
  "ECONNREFUSED",
5262
5742
  "ECONNRESET",
@@ -5280,7 +5760,7 @@ var TLS_ERROR_CODES2 = new Set([
5280
5760
  ]);
5281
5761
  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.";
5282
5762
  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.";
5283
- var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
5763
+ var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
5284
5764
  function extractErrorMessageSync(error) {
5285
5765
  if (error instanceof Error) {
5286
5766
  return error.message;
@@ -5536,6 +6016,40 @@ var BOOLEAN_FLAGS = new Set(HOST_GLOBAL_FLAGS);
5536
6016
  // ../common/src/interactivity-context.ts
5537
6017
  var modeSlot = singleton("InteractivityMode");
5538
6018
  var interactiveFlagSlot = singleton("InteractiveFlag");
6019
+ // ../common/src/mime-types.ts
6020
+ var MIME_TYPES_BY_EXTENSION = Object.freeze({
6021
+ pdf: "application/pdf",
6022
+ png: "image/png",
6023
+ jpg: "image/jpeg",
6024
+ jpeg: "image/jpeg",
6025
+ gif: "image/gif",
6026
+ webp: "image/webp",
6027
+ bmp: "image/bmp",
6028
+ tif: "image/tiff",
6029
+ tiff: "image/tiff",
6030
+ svg: "image/svg+xml",
6031
+ txt: "text/plain",
6032
+ log: "text/plain",
6033
+ md: "text/markdown",
6034
+ csv: "text/csv",
6035
+ tsv: "text/tab-separated-values",
6036
+ json: "application/json",
6037
+ xml: "application/xml",
6038
+ html: "text/html",
6039
+ htm: "text/html",
6040
+ yaml: "application/yaml",
6041
+ yml: "application/yaml",
6042
+ doc: "application/msword",
6043
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
6044
+ xls: "application/vnd.ms-excel",
6045
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
6046
+ ppt: "application/vnd.ms-powerpoint",
6047
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
6048
+ zip: "application/zip",
6049
+ mp3: "audio/mpeg",
6050
+ wav: "audio/wav",
6051
+ mp4: "video/mp4"
6052
+ });
5539
6053
  // ../common/src/polling/types.ts
5540
6054
  var PollOutcome = {
5541
6055
  Completed: "completed",
@@ -5580,6 +6094,7 @@ var ScreenLogger;
5580
6094
  ScreenLogger.progress = progress;
5581
6095
  })(ScreenLogger ||= {});
5582
6096
  // ../common/src/sdk-user-agent.ts
6097
+ var AGENT_PROPERTY = BaseDimensions.Agent;
5583
6098
  var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
5584
6099
  // ../common/src/tool-provider.ts
5585
6100
  var factorySlot = singleton("PackagerFactoryProvider");
@@ -5897,6 +6412,11 @@ var pickName = (claims) => {
5897
6412
  const username = asString(claims?.preferred_username);
5898
6413
  return asString(claims?.name) ?? (looksLikeEmail(username) ? undefined : username);
5899
6414
  };
6415
+ var pickScopes = (claims) => {
6416
+ const raw = claims?.scope;
6417
+ const scopes = Array.isArray(raw) ? raw.filter((entry) => asString(entry) !== undefined) : typeof raw === "string" ? raw.split(/\s+/).filter(Boolean) : [];
6418
+ return scopes.length > 0 ? scopes : undefined;
6419
+ };
5900
6420
  var resolveSessionIdentity = (accessToken, authFlow) => {
5901
6421
  const claims = accessToken ? decodeClaims(accessToken) : undefined;
5902
6422
  const email = pickEmail(claims);
@@ -5922,6 +6442,7 @@ var resolveSessionIdentity = (accessToken, authFlow) => {
5922
6442
  identity.clientId = clientId;
5923
6443
  return identity;
5924
6444
  };
6445
+ var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
5925
6446
 
5926
6447
  // ../auth/src/envAuth.ts
5927
6448
  var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
@@ -5994,6 +6515,7 @@ var readAuthFromEnv = () => {
5994
6515
  const expiration = getTokenExpiration(accessToken);
5995
6516
  const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
5996
6517
  const identity = resolveSessionIdentity(accessToken);
6518
+ const scopes = readTokenScopes(accessToken);
5997
6519
  return {
5998
6520
  loginStatus,
5999
6521
  accessToken,
@@ -6004,7 +6526,8 @@ var readAuthFromEnv = () => {
6004
6526
  tenantId,
6005
6527
  expiration,
6006
6528
  source: "env-vars" /* EnvironmentVariables */,
6007
- ...identity ? { identity } : {}
6529
+ ...identity ? { identity } : {},
6530
+ ...scopes ? { scopes } : {}
6008
6531
  };
6009
6532
  };
6010
6533
 
@@ -6642,10 +7165,15 @@ async function buildFileStatus(tokens, credentials, globalHint) {
6642
7165
  }
6643
7166
  function identityFields(accessToken, credentials) {
6644
7167
  const identity = resolveSessionIdentity(accessToken, parseAuthFlow(credentials[AUTH_FLOW_ENV_VAR]));
6645
- return identity ? { identity } : {};
7168
+ const scopes = readTokenScopes(accessToken);
7169
+ return {
7170
+ ...identity ? { identity } : {},
7171
+ ...scopes ? { scopes } : {}
7172
+ };
6646
7173
  }
6647
7174
  function buildRobotStatus(robotCreds) {
6648
7175
  const identity = resolveSessionIdentity(robotCreds.accessToken);
7176
+ const scopes = readTokenScopes(robotCreds.accessToken);
6649
7177
  return {
6650
7178
  loginStatus: "Logged in",
6651
7179
  accessToken: robotCreds.accessToken,
@@ -6657,7 +7185,8 @@ function buildRobotStatus(robotCreds) {
6657
7185
  issuer: robotCreds.issuer,
6658
7186
  expiration: getTokenExpiration(robotCreds.accessToken),
6659
7187
  source: "robot" /* Robot */,
6660
- ...identity ? { identity } : {}
7188
+ ...identity ? { identity } : {},
7189
+ ...scopes ? { scopes } : {}
6661
7190
  };
6662
7191
  }
6663
7192
  var isFileNotFoundError = (error) => {
@@ -7028,6 +7557,28 @@ function processCommandArgs(args, rules) {
7028
7557
  };
7029
7558
  }
7030
7559
 
7560
+ // ../uipath-python-bridge/src/scaffold-type.ts
7561
+ import { execFile } from "node:child_process";
7562
+ var PROBE_TIMEOUT_MS = 15000;
7563
+ var TYPE_OPTION = /^--type(=|$)/;
7564
+ var TYPE_LISTED = /^[ \t]*--type(?![\w-])/m;
7565
+ function hasTypeOption(args) {
7566
+ return args.some((arg) => TYPE_OPTION.test(arg));
7567
+ }
7568
+ async function supportsNewTypeOption(exePath, cwd, env = {}, signal) {
7569
+ return new Promise((resolve2) => {
7570
+ execFile(exePath, ["new", "--help"], {
7571
+ cwd,
7572
+ env: { ...process.env, ...env },
7573
+ timeout: PROBE_TIMEOUT_MS,
7574
+ windowsHide: true,
7575
+ signal
7576
+ }, (error, stdout) => {
7577
+ resolve2(!error && TYPE_LISTED.test(typeof stdout === "string" ? stdout : ""));
7578
+ });
7579
+ });
7580
+ }
7581
+
7031
7582
  // ../uipath-python-bridge/src/execute.ts
7032
7583
  var ENV_FILE_NAME = ".env";
7033
7584
  function isHelpCommand(args) {
@@ -7083,10 +7634,21 @@ var fail = (reason, message, instructions, extras = {}) => ({
7083
7634
  exitCode: extras.exitCode ?? 1,
7084
7635
  stderr: extras.stderr
7085
7636
  });
7637
+ function childStdio(stdio) {
7638
+ switch (stdio) {
7639
+ case "pipe":
7640
+ return ["ignore", "pipe", "pipe"];
7641
+ case "stdout-to-stderr":
7642
+ return ["inherit", "pipe", "inherit"];
7643
+ default:
7644
+ return "inherit";
7645
+ }
7646
+ }
7086
7647
  async function runUipathPythonCommand(args, options = {}) {
7087
7648
  const fs2 = getFileSystem();
7088
7649
  const cacheFile = fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
7089
- const setupCommand = `uip ${options.commandPrefix ?? "codedagent"} setup`;
7650
+ const toolLabel = options.toolName ?? options.commandPrefix ?? "codedagent";
7651
+ const setupCommand = `uip ${toolLabel} setup`;
7090
7652
  const setupHint = `Run '${setupCommand}' first to configure the environment. ` + `Activate the project's virtual environment and run ${setupCommand} --force.`;
7091
7653
  const cache = await readCache(cacheFile);
7092
7654
  if (!cache?.uipathExePath) {
@@ -7099,6 +7661,9 @@ async function runUipathPythonCommand(args, options = {}) {
7099
7661
  if (!processed.allowed) {
7100
7662
  return fail("command_disabled", processed.errorMessage || "Command disabled.", "Use of --force flag is not recommended. Favor alternate command.", { exitCode: 3 });
7101
7663
  }
7664
+ if (options.pinNewType && processed.args[0] === "new" && !isHelpCommand(processed.args) && hasTypeOption(processed.args)) {
7665
+ return fail("new_type_not_allowed", "--type is not a valid option.", "Remove --type and re-run.");
7666
+ }
7102
7667
  const processedArgs = applyOutputFormatOption(processed.args, options.outputFormatOption, options.outputFormats);
7103
7668
  const commandArgs = options.commandPrefix ? [options.commandPrefix, ...processedArgs] : [...processedArgs];
7104
7669
  const requiredEnv = {};
@@ -7133,6 +7698,9 @@ async function runUipathPythonCommand(args, options = {}) {
7133
7698
  }
7134
7699
  const stdio = options.stdio ?? "inherit";
7135
7700
  const cwd = options.cwd ?? fs2.env.cwd();
7701
+ if (options.pinNewType && processed.args[0] === "new" && !isHelpCommand(processed.args) && await supportsNewTypeOption(cache.uipathExePath, cwd, { ...authEnv, ...requiredEnv }, options.signal)) {
7702
+ commandArgs.push("--type", options.pinNewType);
7703
+ }
7136
7704
  const proc = spawn(cache.uipathExePath, commandArgs, {
7137
7705
  cwd,
7138
7706
  env: {
@@ -7140,17 +7708,24 @@ async function runUipathPythonCommand(args, options = {}) {
7140
7708
  ...authEnv,
7141
7709
  ...requiredEnv
7142
7710
  },
7143
- stdio: stdio === "pipe" ? ["ignore", "pipe", "pipe"] : "inherit",
7711
+ stdio: childStdio(stdio),
7144
7712
  signal: options.signal
7145
7713
  });
7146
7714
  let stdout = "";
7147
7715
  let stderr = "";
7148
7716
  if (stdio === "pipe") {
7717
+ proc.stdout?.setEncoding("utf8");
7718
+ proc.stderr?.setEncoding("utf8");
7149
7719
  proc.stdout?.on("data", (chunk) => {
7150
- stdout += chunk.toString("utf8");
7720
+ stdout += chunk;
7151
7721
  });
7152
7722
  proc.stderr?.on("data", (chunk) => {
7153
- stderr += chunk.toString("utf8");
7723
+ stderr += chunk;
7724
+ });
7725
+ } else if (stdio === "stdout-to-stderr") {
7726
+ proc.stdout?.setEncoding("utf8");
7727
+ proc.stdout?.on("data", (chunk) => {
7728
+ getOutputSink().writeErr(chunk);
7154
7729
  });
7155
7730
  }
7156
7731
  const [spawnError, exitCode] = await catchError(new Promise((resolve2, reject) => {
@@ -7180,17 +7755,30 @@ var CLI_RESULT_BY_REASON = {
7180
7755
  python_not_configured: RESULTS.ConfigError,
7181
7756
  uipath_exe_missing: RESULTS.ConfigError,
7182
7757
  command_disabled: RESULTS.ValidationError,
7758
+ new_type_not_allowed: RESULTS.ValidationError,
7183
7759
  required_env_missing: RESULTS.ConfigError,
7184
7760
  preflight_error: RESULTS.Failure,
7185
7761
  preflight_rejected: RESULTS.ConfigError,
7186
7762
  spawn_failed: RESULTS.Failure
7187
7763
  };
7764
+ function reportUipathPythonFailure(result) {
7765
+ if (!result.ok && result.reason !== "command_failed") {
7766
+ OutputFormatter.error({
7767
+ Result: CLI_RESULT_BY_REASON[result.reason],
7768
+ Message: result.message,
7769
+ Instructions: result.instructions
7770
+ });
7771
+ }
7772
+ return result.exitCode;
7773
+ }
7188
7774
  function createExecuteCommand(config) {
7189
7775
  const executeCommand = async (rawArgs, _options) => {
7190
7776
  const runIndex = rawArgs.indexOf("exec");
7191
7777
  const actualArgs = runIndex >= 0 ? rawArgs.slice(runIndex + 1) : [];
7192
7778
  const result = await runUipathPythonCommand(actualArgs, {
7193
7779
  commandPrefix: config.commandPrefix,
7780
+ toolName: config.toolName,
7781
+ pinNewType: config.pinNewType,
7194
7782
  commandRules: config.commandRules,
7195
7783
  commandPreflight: config.commandPreflight,
7196
7784
  requiredEnvironmentVariables: config.requiredEnvironmentVariables,
@@ -7198,18 +7786,11 @@ function createExecuteCommand(config) {
7198
7786
  outputFormats: config.outputFormats,
7199
7787
  stdio: "inherit"
7200
7788
  });
7201
- if (!result.ok && result.reason !== "command_failed") {
7202
- OutputFormatter.error({
7203
- Result: CLI_RESULT_BY_REASON[result.reason],
7204
- Message: result.message,
7205
- Instructions: result.instructions
7206
- });
7207
- }
7208
- processContext.exit(result.exitCode);
7789
+ processContext.exit(reportUipathPythonFailure(result));
7209
7790
  return result;
7210
7791
  };
7211
7792
  const registerExecCommand = (program2) => {
7212
- program2.command("exec", { hidden: true }).description("Execute the uipath package with provided arguments").allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, config.telemetryEvent, async (_options, cmd) => {
7793
+ program2.command("exec", { hidden: true }).description("Execute the uipath package with provided arguments").allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, async (_options, cmd) => {
7213
7794
  await executeCommand(["_", "_", "exec", ...cmd.args], {});
7214
7795
  });
7215
7796
  };
@@ -7238,6 +7819,10 @@ class PythonService {
7238
7819
  }
7239
7820
  async _setupInternal(packageName, force) {
7240
7821
  const virtualEnv = process.env.VIRTUAL_ENV || undefined;
7822
+ const dormantVenv = await this.checkDormantVenv();
7823
+ if (dormantVenv) {
7824
+ return dormantVenv;
7825
+ }
7241
7826
  if (!force) {
7242
7827
  const reused = await this.reuseCache(packageName, virtualEnv);
7243
7828
  if (reused)
@@ -7264,7 +7849,7 @@ class PythonService {
7264
7849
  packageInstalled: false,
7265
7850
  source,
7266
7851
  error: `Package '${packageName}' is not installed in the active virtual environment: ${virtualEnv}`,
7267
- instructions: `Install it inside the active virtual environment (uv pip install ${packageName} or the framework package), then re-run uip codedagent setup --force.`
7852
+ instructions: `Install it inside the active virtual environment (uv pip install ${packageName} or the framework package), then re-run uip ${this.config.toolName ?? "codedagent"} setup --force.`
7268
7853
  };
7269
7854
  }
7270
7855
  return {
@@ -7398,6 +7983,20 @@ To install the package, run:
7398
7983
  source: "venv"
7399
7984
  };
7400
7985
  }
7986
+ async checkDormantVenv() {
7987
+ if (process.env.VIRTUAL_ENV) {
7988
+ return null;
7989
+ }
7990
+ const fs2 = getFileSystem();
7991
+ if (!await fs2.exists(fs2.path.join(fs2.env.cwd(), ".venv"))) {
7992
+ return null;
7993
+ }
7994
+ return {
7995
+ success: false,
7996
+ error: "Found .venv in current directory but no virtual environment is activated.",
7997
+ instructions: process.platform === "win32" ? "Run '.venv\\Scripts\\activate' first, then re-run setup." : "Run 'source .venv/bin/activate' first, then re-run setup."
7998
+ };
7999
+ }
7401
8000
  async detectPython() {
7402
8001
  const pythonCommands = this.getDefaultPythonPaths();
7403
8002
  const checkedVersions = [];
@@ -7723,22 +8322,12 @@ function createSetupCommand(config) {
7723
8322
  processContext.exit(1);
7724
8323
  return;
7725
8324
  }
7726
- const fs2 = getFileSystem();
7727
- const venvPath = fs2.path.join(fs2.env.cwd(), ".venv");
7728
- if (await fs2.exists(venvPath) && !process.env.VIRTUAL_ENV) {
7729
- OutputFormatter.error({
7730
- Result: RESULTS.Failure,
7731
- Message: "Found .venv in current directory but no virtual environment is activated.",
7732
- Instructions: process.platform === "win32" ? "Run '.venv\\Scripts\\activate' first, then re-run setup." : "Run 'source .venv/bin/activate' first, then re-run setup."
7733
- });
7734
- processContext.exit(1);
7735
- return;
7736
- }
7737
8325
  logger.info(`
7738
8326
  Searching for Python installations: ${allowedVersions}`);
7739
8327
  const service = new PythonService({
7740
8328
  allowedVersions,
7741
- packageName
8329
+ packageName,
8330
+ toolName: config.toolName
7742
8331
  });
7743
8332
  const result = await service.setup(packageName, options.force);
7744
8333
  if (!result.success) {
@@ -7843,6 +8432,6 @@ var codedAgentCommandPreflight = ({
7843
8432
  };
7844
8433
  };
7845
8434
 
7846
- export { getFileSystem, catchError, extractErrorMessageSync, RESULTS, OutputFormatter, Command, processContext, trackShipSucceeded, runUipathPythonCommand, createExecuteCommand, createSetupCommand, WHITELISTED_COMMANDS, COMMAND_RULES, codedAgentCommandPreflight };
8435
+ export { getFileSystem, catchError, extractErrorMessageSync, CommandDimensions, ShipDimensions, RESULTS, OutputFormatter, Command, processContext, trackShipSucceeded, parseJWT, getLoginStatusAsync, runUipathPythonCommand, createExecuteCommand, createSetupCommand, WHITELISTED_COMMANDS, COMMAND_RULES, codedAgentCommandPreflight };
7847
8436
 
7848
- //# debugId=56087E0307A4B44B64756E2164756E21
8437
+ //# debugId=4CE4D7CA6405776864756E2164756E21