@uipath/uipath-python-bridge 1.203.0-preview.203 → 1.204.0-preview.206

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +674 -81
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -8190,6 +8190,57 @@ function settlePromiseLike(thenable) {
8190
8190
  return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
8191
8191
  }
8192
8192
 
8193
+ // ../common/src/error-graph.ts
8194
+ function* walkErrorGraph(error) {
8195
+ const queue = [error];
8196
+ const seen = new Set;
8197
+ for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
8198
+ const current = queue.shift();
8199
+ if (current === null || typeof current !== "object")
8200
+ continue;
8201
+ if (seen.has(current))
8202
+ continue;
8203
+ seen.add(current);
8204
+ const cur = current;
8205
+ yield cur;
8206
+ if (cur.cause !== undefined)
8207
+ queue.push(cur.cause);
8208
+ if (Array.isArray(cur.errors))
8209
+ queue.push(...cur.errors);
8210
+ }
8211
+ return;
8212
+ }
8213
+ function parseHttpStatusFromMessage(message) {
8214
+ const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
8215
+ if (!match)
8216
+ return;
8217
+ const status = Number(match[1]);
8218
+ return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
8219
+ }
8220
+ function findHttpStatusInGraph(error) {
8221
+ for (const node of walkErrorGraph(error)) {
8222
+ const response = node.response;
8223
+ const explicit = typeof node.status === "number" ? node.status : response?.status;
8224
+ if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
8225
+ return explicit;
8226
+ }
8227
+ if (typeof node.message === "string") {
8228
+ const parsed = parseHttpStatusFromMessage(node.message);
8229
+ if (parsed !== undefined && parsed >= 400) {
8230
+ return parsed;
8231
+ }
8232
+ }
8233
+ }
8234
+ return;
8235
+ }
8236
+
8237
+ // ../common/src/local-permission-codes.ts
8238
+ var LOCAL_PERMISSION_ERROR_CODES = new Set([
8239
+ "EACCES",
8240
+ "EPERM",
8241
+ "EROFS"
8242
+ ]);
8243
+
8193
8244
  // ../common/src/error-handler.ts
8194
8245
  var NETWORK_ERROR_CODES = new Set([
8195
8246
  "ECONNREFUSED",
@@ -8214,7 +8265,7 @@ var TLS_ERROR_CODES = new Set([
8214
8265
  ]);
8215
8266
  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.";
8216
8267
  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.";
8217
- var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
8268
+ var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
8218
8269
  // ../common/src/exit-code.ts
8219
8270
  function setExitCode(code) {
8220
8271
  process.exitCode = code;
@@ -8479,12 +8530,162 @@ function getOutputFilter() {
8479
8530
  return filterSlot.get();
8480
8531
  }
8481
8532
 
8533
+ // ../common/src/telemetry/telemetry-dimensions.ts
8534
+ var BaseDimensions = {
8535
+ ApplicationName: "ApplicationName",
8536
+ ProductVersion: "ProductVersion",
8537
+ InstallationId: "InstallationId",
8538
+ CloudUserId: "CloudUserId",
8539
+ CloudTenantId: "CloudTenantId",
8540
+ CloudOrganizationId: "CloudOrganizationId",
8541
+ IsInternalUser: "IsInternalUser",
8542
+ Environment: "Environment",
8543
+ BaseUrl: "BaseUrl",
8544
+ Region: "Region",
8545
+ Agent: "Agent",
8546
+ AgentVersion: "AgentVersion",
8547
+ AgentModel: "AgentModel",
8548
+ ToolName: "ToolName",
8549
+ ToolVersion: "ToolVersion",
8550
+ ExecutionContext: "ExecutionContext",
8551
+ CiProvider: "CiProvider",
8552
+ SessionIdSource: "SessionIdSource",
8553
+ SessionId: "SessionId"
8554
+ };
8555
+ var CommandDimensions = {
8556
+ IsCommand: "IsCommand",
8557
+ IsReexec: "IsReexec",
8558
+ CommandName: "CommandName",
8559
+ ExitCode: "ExitCode",
8560
+ TerminalOutcome: "TerminalOutcome",
8561
+ ErrorClass: "ErrorClass",
8562
+ TerminalSignal: "TerminalSignal",
8563
+ ErrorMessage: "ErrorMessage",
8564
+ SkillName: "SkillName",
8565
+ ProductArea: "ProductArea",
8566
+ Mode: "Mode"
8567
+ };
8568
+ var ShipDimensions = {
8569
+ ShipKind: "ShipKind",
8570
+ Target: "Target",
8571
+ ProjectType: "ProjectType",
8572
+ ProjectTypes: "ProjectTypes",
8573
+ ArtifactCorrelationKey: "ArtifactCorrelationKey",
8574
+ PackageName: "PackageName",
8575
+ PackageVersion: "PackageVersion",
8576
+ PackageVersionKey: "PackageVersionKey",
8577
+ DeploymentKey: "DeploymentKey",
8578
+ SolutionId: "SolutionId",
8579
+ FolderKey: "FolderKey",
8580
+ FeedId: "FeedId"
8581
+ };
8582
+ var ErrorDimensions = {
8583
+ Result: "Result",
8584
+ ErrorCode: "ErrorCode",
8585
+ Retry: "Retry",
8586
+ ErrorMessage: "ErrorMessage"
8587
+ };
8588
+ var AuthDimensions = {
8589
+ AuthenticationMethod: "AuthenticationMethod",
8590
+ Success: "Success",
8591
+ Reason: "Reason"
8592
+ };
8593
+ var SkillsDimensions = {
8594
+ SchemaVersion: "SchemaVersion",
8595
+ AgentType: "AgentType",
8596
+ SkillsVersion: "SkillsVersion",
8597
+ UipSubcommand: "UipSubcommand",
8598
+ FileExtension: "FileExtension",
8599
+ SubagentModel: "SubagentModel",
8600
+ SubagentType: "SubagentType",
8601
+ PermissionMode: "PermissionMode",
8602
+ EffortLevel: "EffortLevel",
8603
+ SessionSource: "SessionSource",
8604
+ Outcome: "Outcome",
8605
+ DurationMs: "DurationMs",
8606
+ Source: "Source"
8607
+ };
8608
+ var PackagerDimensions = {
8609
+ ProjectId: "ProjectId",
8610
+ ProjectType: "ProjectType",
8611
+ SolutionId: "SolutionId"
8612
+ };
8613
+ var ScopeDimensions = {
8614
+ FolderId: "FolderId"
8615
+ };
8616
+ var ID_DIMENSIONS = new Set([
8617
+ BaseDimensions.CloudUserId,
8618
+ BaseDimensions.CloudTenantId,
8619
+ BaseDimensions.CloudOrganizationId,
8620
+ BaseDimensions.InstallationId,
8621
+ ShipDimensions.ArtifactCorrelationKey,
8622
+ ShipDimensions.PackageVersionKey,
8623
+ ShipDimensions.DeploymentKey,
8624
+ ShipDimensions.SolutionId,
8625
+ ShipDimensions.FolderKey,
8626
+ ShipDimensions.FeedId,
8627
+ PackagerDimensions.ProjectId
8628
+ ]);
8629
+ var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
8630
+ var RESERVED_DIMENSION_NAMES = new Set([
8631
+ ...Object.values(BaseDimensions),
8632
+ ...Object.values(CommandDimensions),
8633
+ ...Object.values(ShipDimensions),
8634
+ ...Object.values(ErrorDimensions),
8635
+ ...Object.values(AuthDimensions),
8636
+ ...Object.values(SkillsDimensions),
8637
+ ...Object.values(PackagerDimensions),
8638
+ ...Object.values(ScopeDimensions)
8639
+ ]);
8640
+ var CURATED_DIMENSIONS = new Set([
8641
+ BaseDimensions.ApplicationName,
8642
+ BaseDimensions.ProductVersion,
8643
+ BaseDimensions.InstallationId,
8644
+ BaseDimensions.CloudUserId,
8645
+ BaseDimensions.CloudTenantId,
8646
+ BaseDimensions.CloudOrganizationId,
8647
+ BaseDimensions.IsInternalUser,
8648
+ BaseDimensions.Environment,
8649
+ BaseDimensions.BaseUrl,
8650
+ BaseDimensions.Region,
8651
+ BaseDimensions.Agent,
8652
+ BaseDimensions.AgentVersion,
8653
+ BaseDimensions.ToolVersion,
8654
+ BaseDimensions.ExecutionContext,
8655
+ BaseDimensions.CiProvider,
8656
+ BaseDimensions.SessionIdSource,
8657
+ BaseDimensions.SessionId,
8658
+ ...Object.values(CommandDimensions),
8659
+ ...Object.values(ShipDimensions)
8660
+ ]);
8661
+ function lowercaseIdDimensionValues(properties) {
8662
+ let changed = false;
8663
+ const result = {
8664
+ ...properties
8665
+ };
8666
+ for (const key of Object.keys(result)) {
8667
+ const value = result[key];
8668
+ if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
8669
+ continue;
8670
+ }
8671
+ const lowered = value.toLowerCase();
8672
+ if (lowered !== value) {
8673
+ result[key] = lowered;
8674
+ changed = true;
8675
+ }
8676
+ }
8677
+ return changed ? result : properties;
8678
+ }
8679
+
8482
8680
  // ../common/src/telemetry/command-terminal.ts
8483
8681
  var recordedFailureSlot = singleton("CommandTelemetryFailure");
8484
8682
  var AUTH_ERROR_CODES = new Set([
8485
8683
  "authentication_required",
8486
8684
  "permission_denied"
8487
8685
  ]);
8686
+ var LOCAL_PERMISSION_CLI_ERROR_CODES = new Set([
8687
+ "local_permission_denied"
8688
+ ]);
8488
8689
  var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
8489
8690
  var NETWORK_HTTP_ERROR_CODES = new Set([
8490
8691
  "network_error",
@@ -8625,6 +8826,9 @@ function classifyFromErrorCode(errorCode) {
8625
8826
  if (AUTH_ERROR_CODES.has(errorCode)) {
8626
8827
  return "auth";
8627
8828
  }
8829
+ if (LOCAL_PERMISSION_CLI_ERROR_CODES.has(errorCode)) {
8830
+ return "local_permission";
8831
+ }
8628
8832
  if (VALIDATION_ERROR_CODES.has(errorCode)) {
8629
8833
  return "validation";
8630
8834
  }
@@ -8636,6 +8840,15 @@ function classifyFromErrorCode(errorCode) {
8636
8840
  }
8637
8841
  return;
8638
8842
  }
8843
+ function hasLocalPermissionCode(error) {
8844
+ for (const node of walkErrorGraph(error)) {
8845
+ const code = node.code;
8846
+ if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
8847
+ return true;
8848
+ }
8849
+ }
8850
+ return false;
8851
+ }
8639
8852
  function classifyFromError(error) {
8640
8853
  const code = findCodeInCauseChain(error);
8641
8854
  if (code) {
@@ -8652,6 +8865,9 @@ function classifyFromError(error) {
8652
8865
  return "missing_dependency";
8653
8866
  }
8654
8867
  }
8868
+ if (hasLocalPermissionCode(error)) {
8869
+ return "local_permission";
8870
+ }
8655
8871
  const message = stringField(error, "message");
8656
8872
  if (message?.includes("fetch failed") === true) {
8657
8873
  return "network_http";
@@ -8667,7 +8883,7 @@ function classifyError(input) {
8667
8883
  if (recorded?.errorClass) {
8668
8884
  return recorded.errorClass;
8669
8885
  }
8670
- const status = recorded?.context?.httpStatus;
8886
+ const status = recorded?.context?.httpStatus ?? findHttpStatusInGraph(input.error);
8671
8887
  if (status !== undefined) {
8672
8888
  return classifyHttpStatus(status);
8673
8889
  }
@@ -8690,17 +8906,18 @@ function buildCommandTerminalTelemetryProperties(input) {
8690
8906
  const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError(input);
8691
8907
  const terminalSignal = terminalSignalFor(input, outcome);
8692
8908
  return {
8693
- exit_code: input.exitCode,
8694
- terminal_outcome: outcome,
8695
- ...errorClass ? { error_class: errorClass } : {},
8696
- ...terminalSignal ? { terminal_signal: terminalSignal } : {}
8909
+ [CommandDimensions.ExitCode]: input.exitCode,
8910
+ [CommandDimensions.TerminalOutcome]: outcome,
8911
+ ...errorClass ? { [CommandDimensions.ErrorClass]: errorClass } : {},
8912
+ ...terminalSignal ? { [CommandDimensions.TerminalSignal]: terminalSignal } : {}
8697
8913
  };
8698
8914
  }
8699
8915
 
8700
8916
  // ../common/src/telemetry/telemetry-events.ts
8701
8917
  var CommonTelemetryEvents = {
8702
- Error: "uip.error",
8703
- ShipSucceeded: "uip.ship.succeeded"
8918
+ Start: "Application.Start",
8919
+ Error: "Application.Error",
8920
+ ShipSucceeded: "Cli.ShipSucceeded"
8704
8921
  };
8705
8922
 
8706
8923
  // ../common/src/telemetry/telemetry-init.ts
@@ -8911,8 +9128,8 @@ function detectExecutionContext(options = {}) {
8911
9128
  function getExecutionContextTelemetryProperties() {
8912
9129
  const detected = detectExecutionContext();
8913
9130
  return {
8914
- execution_context: detected.executionContext,
8915
- ...detected.ciProvider ? { ci_provider: detected.ciProvider } : {}
9131
+ [BaseDimensions.ExecutionContext]: detected.executionContext,
9132
+ ...detected.ciProvider ? { [BaseDimensions.CiProvider]: detected.ciProvider } : {}
8916
9133
  };
8917
9134
  }
8918
9135
  // ../common/src/telemetry/node-context-storage.ts
@@ -8955,7 +9172,7 @@ function getInboundTraceContext() {
8955
9172
  var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
8956
9173
  var SESSION_ID_MAX_LENGTH = 64;
8957
9174
  var RANDOM_SESSION_ID_LENGTH = 32;
8958
- var TELEMETRY_SESSION_SOURCE_PROPERTY = "session_id_source";
9175
+ var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
8959
9176
  var CONTROL_CHARACTERS = /\p{Cc}/gu;
8960
9177
  var INHERITED_SESSION_SOURCES = [
8961
9178
  { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
@@ -9007,6 +9224,9 @@ function resolveTelemetrySession() {
9007
9224
  telemetrySessionSlot.set(resolved);
9008
9225
  return resolved;
9009
9226
  }
9227
+ function getTelemetrySessionId() {
9228
+ return resolveTelemetrySession().id;
9229
+ }
9010
9230
  function getTelemetrySessionSource() {
9011
9231
  return resolveTelemetrySession().source;
9012
9232
  }
@@ -9087,7 +9307,10 @@ class TelemetryService {
9087
9307
  } catch (error) {
9088
9308
  const durationMs = clock.elapsedMs();
9089
9309
  const err = error instanceof Error ? error : new Error(String(error));
9090
- await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, context));
9310
+ await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, {
9311
+ ...properties,
9312
+ [CommandDimensions.ErrorMessage]: err.message
9313
+ }, context));
9091
9314
  throw error;
9092
9315
  }
9093
9316
  }
@@ -9158,7 +9381,10 @@ class TelemetryService {
9158
9381
  const durationMs = clock.elapsedMs();
9159
9382
  const err = error instanceof Error ? error : new Error(String(error));
9160
9383
  await this.telemetryProvider.trackDependency({
9161
- ...this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, childContext),
9384
+ ...this.spanFor(name, durationMs, false, {
9385
+ ...properties,
9386
+ [CommandDimensions.ErrorMessage]: err.message
9387
+ }, childContext),
9162
9388
  type: type2
9163
9389
  });
9164
9390
  throw error;
@@ -9193,9 +9419,10 @@ class TelemetryService {
9193
9419
  ...globalProperties,
9194
9420
  ...this.defaultProperties,
9195
9421
  ...redactProperties(properties ?? {}),
9196
- [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
9422
+ [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
9423
+ [BaseDimensions.SessionId]: this.telemetryProvider.getSessionId?.() ?? getTelemetrySessionId()
9197
9424
  };
9198
- return enriched;
9425
+ return lowercaseIdDimensionValues(enriched);
9199
9426
  }
9200
9427
  generateId() {
9201
9428
  const bytes = new Uint8Array(8);
@@ -9958,7 +10185,165 @@ class FilterImplicitLimitError extends Error {
9958
10185
  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).";
9959
10186
  }
9960
10187
  }
9961
- function applyFilter(data, filter) {
10188
+ function countRecords(data) {
10189
+ if (Array.isArray(data))
10190
+ return data.length;
10191
+ return data == null ? 0 : 1;
10192
+ }
10193
+ function availableFields(data) {
10194
+ const records = Array.isArray(data) ? data : [data];
10195
+ const keys = new Set;
10196
+ for (const record of records) {
10197
+ if (record && typeof record === "object" && !Array.isArray(record)) {
10198
+ for (const key of Object.keys(record))
10199
+ keys.add(key);
10200
+ }
10201
+ }
10202
+ return [...keys];
10203
+ }
10204
+ function decodeQuotedIdentifier(whole, inner) {
10205
+ const [error, decoded] = catchError(() => JSON.parse(whole));
10206
+ if (!error && typeof decoded === "string")
10207
+ return decoded;
10208
+ return inner.replace(/\\(.)/g, "$1");
10209
+ }
10210
+ function referencedFields(filter) {
10211
+ const top = new Set;
10212
+ const nested = new Set;
10213
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
10214
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
10215
+ const quoted = [];
10216
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
10217
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
10218
+ if (!isAlias) {
10219
+ quoted.push({
10220
+ name: decodeQuotedIdentifier(whole, name),
10221
+ index,
10222
+ tail: isPathTail(withoutValueLiterals, index)
10223
+ });
10224
+ }
10225
+ return `"${" ".repeat(whole.length - 2)}"`;
10226
+ });
10227
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
10228
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
10229
+ const place = (name, index, tail) => {
10230
+ if (tail || index >= rootEnd)
10231
+ nested.add(name);
10232
+ else
10233
+ top.add(name);
10234
+ };
10235
+ for (const entry of quoted)
10236
+ place(entry.name, entry.index, entry.tail);
10237
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
10238
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
10239
+ for (const match of identifiers) {
10240
+ const [, name, trailing] = match;
10241
+ if (trailing || reserved.has(name))
10242
+ continue;
10243
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
10244
+ }
10245
+ return {
10246
+ top: [...top],
10247
+ nested: [...nested].filter((name) => !top.has(name)),
10248
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
10249
+ };
10250
+ }
10251
+ function appearsBelowTopLevel(data, name) {
10252
+ let budget = 2000;
10253
+ const visit = (value, depth) => {
10254
+ if (budget-- <= 0 || depth > 4)
10255
+ return false;
10256
+ if (value === null || typeof value !== "object")
10257
+ return false;
10258
+ if (Array.isArray(value))
10259
+ return value.some((entry) => visit(entry, depth));
10260
+ const record = value;
10261
+ if (depth > 0 && Object.hasOwn(record, name))
10262
+ return true;
10263
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
10264
+ };
10265
+ return visit(data, 0);
10266
+ }
10267
+ function alwaysNullKeys(records) {
10268
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
10269
+ if (objects.length === 0 || objects.length !== records.length)
10270
+ return [];
10271
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
10272
+ if (keys.length === 0)
10273
+ return [];
10274
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
10275
+ return nullKeys.length === keys.length ? nullKeys : [];
10276
+ }
10277
+ function carriesOnlyNulls(value) {
10278
+ if (value === null)
10279
+ return true;
10280
+ if (Array.isArray(value)) {
10281
+ return value.length > 0 && value.every(carriesOnlyNulls);
10282
+ }
10283
+ if (typeof value === "object" && value !== undefined) {
10284
+ const values = Object.values(value);
10285
+ return values.length > 0 && values.every(carriesOnlyNulls);
10286
+ }
10287
+ return false;
10288
+ }
10289
+ function nameList(names, cap2 = 12) {
10290
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
10291
+ const rest = names.length - shown.length;
10292
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
10293
+ }
10294
+ function buildFilterWarning(filter, data, outcome) {
10295
+ const present = availableFields(data);
10296
+ const refs = referencedFields(filter);
10297
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
10298
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
10299
+ const count = countRecords(data);
10300
+ const scope = `${count} record(s)`;
10301
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
10302
+ 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" : "";
10303
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
10304
+ let detail;
10305
+ let lede;
10306
+ if (outcome.kind === "null-elements") {
10307
+ lede = "returned only null values";
10308
+ const projected = `all ${outcome.count} of the elements it projected are null`;
10309
+ if (unknown.length > 0) {
10310
+ detail = `${projected}, because ${isNotAField(unknown)}`;
10311
+ } else if (unchecked.length > 0) {
10312
+ detail = withSoundness(projected);
10313
+ } else {
10314
+ 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`;
10315
+ }
10316
+ } else if (outcome.kind === "null-rows") {
10317
+ lede = "returned only null values";
10318
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
10319
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
10320
+ } else if (outcome.kind === "null-values") {
10321
+ lede = "returned only null values";
10322
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
10323
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
10324
+ if (sameSet) {
10325
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
10326
+ } else if (unknown.length > 0) {
10327
+ detail = `${projected}, because ${isNotAField(unknown)}`;
10328
+ } else {
10329
+ detail = withSoundness(`${projected} on all ${scope}`);
10330
+ }
10331
+ } else {
10332
+ lede = "returned nothing";
10333
+ if (unknown.length > 0) {
10334
+ detail = isNotAField(unknown);
10335
+ } else {
10336
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
10337
+ detail = withSoundness(`${selection} — it read ${scope}`);
10338
+ }
10339
+ }
10340
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
10341
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
10342
+ }
10343
+ function appendWarning(existing, note) {
10344
+ return existing ? `${existing} ${note}` : note;
10345
+ }
10346
+ function applyFilter(data, filter, onWarning) {
9962
10347
  const codec = requireJmespath();
9963
10348
  let result;
9964
10349
  try {
@@ -9966,9 +10351,34 @@ function applyFilter(data, filter) {
9966
10351
  } catch (err) {
9967
10352
  throw new FilterEvaluationError(filter, err);
9968
10353
  }
9969
- if (result == null)
10354
+ const inputCount = countRecords(data);
10355
+ const warn = (outcome) => {
10356
+ if (inputCount === 0)
10357
+ return;
10358
+ const note = buildFilterWarning(filter, data, outcome);
10359
+ getOutputSink().writeErr(`[WARN] ${note}
10360
+ `);
10361
+ onWarning?.(note);
10362
+ };
10363
+ const warnIfAllNull = (records) => {
10364
+ const keys = alwaysNullKeys(records);
10365
+ if (keys.length > 0)
10366
+ warn({ kind: "null-values", keys });
10367
+ };
10368
+ if (result == null) {
10369
+ warn({ kind: "empty" });
9970
10370
  return [];
10371
+ }
9971
10372
  if (Array.isArray(result)) {
10373
+ if (result.length === 0) {
10374
+ warn({ kind: "empty" });
10375
+ } else if (result.every((entry) => entry === null)) {
10376
+ warn({ kind: "null-elements", count: result.length });
10377
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
10378
+ warn({ kind: "null-rows", count: result.length });
10379
+ } else {
10380
+ warnIfAllNull(result);
10381
+ }
9972
10382
  if (result.length > 0 && typeof result[0] !== "object") {
9973
10383
  const fieldMatch = filter.match(/\.(\w+)$/);
9974
10384
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -9976,10 +10386,30 @@ function applyFilter(data, filter) {
9976
10386
  }
9977
10387
  return result;
9978
10388
  }
9979
- if (typeof result === "object")
10389
+ if (typeof result === "object") {
10390
+ warnIfAllNull([result]);
9980
10391
  return result;
10392
+ }
9981
10393
  return { Value: result };
9982
10394
  }
10395
+ function filterFailureData(envelope) {
10396
+ const filter = getOutputFilter();
10397
+ const data = envelope.Data;
10398
+ if (!filter || data == null)
10399
+ return;
10400
+ let note;
10401
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
10402
+ note = n;
10403
+ }));
10404
+ if (filterError) {
10405
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
10406
+ return;
10407
+ }
10408
+ envelope.Data = filtered;
10409
+ if (note) {
10410
+ envelope.Warning = appendWarning(envelope.Warning, note);
10411
+ }
10412
+ }
9983
10413
  function defaultErrorCodeForResult(result) {
9984
10414
  switch (result) {
9985
10415
  case RESULTS.AuthenticationError:
@@ -9994,7 +10424,7 @@ function defaultErrorCodeForResult(result) {
9994
10424
  return "unknown_error";
9995
10425
  }
9996
10426
  }
9997
- function parseHttpStatusFromMessage(message) {
10427
+ function parseHttpStatusFromMessage2(message) {
9998
10428
  const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
9999
10429
  if (!match)
10000
10430
  return;
@@ -10023,10 +10453,10 @@ function defaultErrorCodeForHttpStatus(status) {
10023
10453
  return "server_error";
10024
10454
  return;
10025
10455
  }
10026
- var LOCAL_PERMISSION_TEXT_PATTERN = /(?:\b|\()(?:EACCES|EPERM|EROFS)(?::\s|\))/;
10456
+ var LOCAL_PERMISSION_TEXT_PATTERN = new RegExp(`(?:\\b|\\()(?:${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})(?::\\s|\\))`);
10027
10457
  function defaultErrorCodeForFailure(data) {
10028
10458
  if (data.Result === RESULTS.Failure) {
10029
- const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage(data.Message);
10459
+ const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
10030
10460
  const errorCode = defaultErrorCodeForHttpStatus(status);
10031
10461
  if (errorCode)
10032
10462
  return errorCode;
@@ -10062,8 +10492,14 @@ var OutputFormatter;
10062
10492
  }
10063
10493
  const filter = getOutputFilter();
10064
10494
  if (filter) {
10065
- const filtered = applyFilter(data.Data, filter);
10495
+ let note;
10496
+ const filtered = applyFilter(data.Data, filter, (n) => {
10497
+ note = n;
10498
+ });
10066
10499
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
10500
+ if (note) {
10501
+ data.Warning = appendWarning(data.Warning, note);
10502
+ }
10067
10503
  }
10068
10504
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
10069
10505
  }
@@ -10091,12 +10527,13 @@ var OutputFormatter;
10091
10527
  delete envelope.TelemetryErrorClass;
10092
10528
  delete envelope.TelemetryTerminalOutcome;
10093
10529
  delete envelope.TelemetryTerminalSignal;
10530
+ filterFailureData(envelope);
10094
10531
  if (!suppressTelemetry) {
10095
10532
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
10096
- result: data.Result,
10097
- errorCode: data.ErrorCode,
10098
- retry: data.Retry,
10099
- message: data.Message
10533
+ [ErrorDimensions.Result]: data.Result,
10534
+ [ErrorDimensions.ErrorCode]: data.ErrorCode,
10535
+ [ErrorDimensions.Retry]: data.Retry,
10536
+ [ErrorDimensions.ErrorMessage]: data.Message
10100
10537
  });
10101
10538
  }
10102
10539
  logOutput(normalizeOutputKeys(envelope), getOutputFormat());
@@ -10139,13 +10576,20 @@ var OutputFormatter;
10139
10576
  OutputFormatter.log = log;
10140
10577
  function formatToString(data) {
10141
10578
  const filter = getOutputFilter();
10579
+ const envelope = data;
10142
10580
  if ("Data" in data && data.Data != null) {
10143
10581
  data.Data = normalizeDataKeys(data.Data);
10144
10582
  if (filter) {
10145
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
10583
+ let note;
10584
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
10585
+ note = n;
10586
+ }));
10587
+ if (note) {
10588
+ envelope.Warning = appendWarning(envelope.Warning, note);
10589
+ }
10146
10590
  }
10147
10591
  }
10148
- const output = normalizeOutputKeys(data);
10592
+ const output = normalizeOutputKeys(envelope);
10149
10593
  const lines = [];
10150
10594
  const sink = getOutputSink();
10151
10595
  printOutput(output, getOutputFormat(), (msg) => {
@@ -10195,7 +10639,7 @@ var LEGACY_SKILL_NAMESPACE = "uipath:";
10195
10639
  var MAX_SKILL_NAME_LENGTH = 80;
10196
10640
  var SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
10197
10641
  function productMode(productArea, mode) {
10198
- return { product_area: productArea, mode };
10642
+ return { ProductArea: productArea, Mode: mode };
10199
10643
  }
10200
10644
  function attributionRecord(groups) {
10201
10645
  const record = {};
@@ -10253,6 +10697,7 @@ var COMMAND_ATTRIBUTION = commandAttribution([
10253
10697
  ["rpa", "build", ["uip.rpa-legacy"]],
10254
10698
  ["conversational", "operate", ["uip.conversational"]],
10255
10699
  ["agents", "build", ["uip.codedagent", "uip.agent"]],
10700
+ ["coding-agents", "build", ["uip.coder"]],
10256
10701
  ["agenthub", "build", ["uip.agenthub"]],
10257
10702
  ["coded-apps", "build", ["uip.codedapp"]],
10258
10703
  ["functions", "build", ["uip.function", "uip.functions"]],
@@ -10338,32 +10783,64 @@ function normalizeSkillName(value) {
10338
10783
  function buildCommandTelemetryAttribution(commandPath, skillSource) {
10339
10784
  const skillName = normalizeSkillName(skillSource);
10340
10785
  return {
10341
- ...skillName ? { skill_name: skillName } : {},
10786
+ ...skillName ? { SkillName: skillName } : {},
10342
10787
  ...getCommandProductModeAttribution(commandPath)
10343
10788
  };
10344
10789
  }
10790
+ var AGENT_SESSION_ENV = {
10791
+ [BaseDimensions.AgentModel]: "UIPATH_AGENT_MODEL",
10792
+ [SkillsDimensions.PermissionMode]: "UIPATH_PERMISSION_MODE",
10793
+ [SkillsDimensions.EffortLevel]: "UIPATH_EFFORT_LEVEL",
10794
+ [SkillsDimensions.SkillsVersion]: "UIPATH_SKILLS_VERSION"
10795
+ };
10796
+ var MAX_TELEMETRY_TOKEN_LENGTH = 120;
10797
+ function sanitizeTelemetryToken(value) {
10798
+ return value.replace(/[^A-Za-z0-9:._/ -]/g, "_").slice(0, MAX_TELEMETRY_TOKEN_LENGTH);
10799
+ }
10800
+ function buildAgentSessionTelemetry(env) {
10801
+ const dimensions = {};
10802
+ for (const [key, variable] of Object.entries(AGENT_SESSION_ENV)) {
10803
+ const value = env[variable]?.trim();
10804
+ if (value) {
10805
+ dimensions[key] = sanitizeTelemetryToken(value);
10806
+ }
10807
+ }
10808
+ return dimensions;
10809
+ }
10345
10810
 
10346
10811
  // ../common/src/telemetry/command-name.ts
10347
- var TELEMETRY_COMMAND_ROOT = "uip";
10812
+ var TELEMETRY_NAME_ROOT = "Cli";
10813
+ var CLI_COMMAND_ROOT = "uip";
10814
+ var TELEMETRY_NAME_BARE_ACTION = "Invoke";
10348
10815
  function commandTelemetryName(parts) {
10816
+ const action = vetCommandTokens(parts).map(pascalizeToken).join("");
10817
+ return `${TELEMETRY_NAME_ROOT}.${action || TELEMETRY_NAME_BARE_ACTION}`;
10818
+ }
10819
+ function commandInvocationPath(parts) {
10820
+ return [CLI_COMMAND_ROOT, ...vetCommandTokens(parts)].join(" ");
10821
+ }
10822
+ function vetCommandTokens(parts) {
10349
10823
  const tokens = [];
10350
10824
  for (const part of parts) {
10351
- const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== TELEMETRY_COMMAND_ROOT);
10825
+ const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== CLI_COMMAND_ROOT);
10352
10826
  if (pieces.every(isCommandToken)) {
10353
10827
  tokens.push(...pieces);
10354
10828
  continue;
10355
10829
  }
10356
10830
  tokens.push(UNKNOWN_TOKEN);
10357
10831
  }
10358
- return [TELEMETRY_COMMAND_ROOT, ...tokens].join(".");
10832
+ return tokens;
10833
+ }
10834
+ function pascalizeToken(token) {
10835
+ return token.split("-").filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
10359
10836
  }
10360
- var COMMAND_TOKEN_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
10837
+ var COMMAND_TOKEN_PATTERN = /^[a-z][a-z0-9-]*$/;
10361
10838
  var MAX_COMMAND_TOKEN_LENGTH = 32;
10362
10839
  var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
10363
10840
  function isCommandToken(token) {
10364
- return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token) && !/^\d+$/.test(token);
10841
+ return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token);
10365
10842
  }
10366
- var UNKNOWN_TOKEN = "<unknown>";
10843
+ var UNKNOWN_TOKEN = "unknown";
10367
10844
 
10368
10845
  // ../common/src/telemetry/invocation-request.ts
10369
10846
  var requestContextSlot = singleton("TelemetryInvocationRequestContext");
@@ -10468,7 +10945,7 @@ function withheldArgumentValues(cmd) {
10468
10945
  });
10469
10946
  return values;
10470
10947
  }
10471
- function deriveCommandPath(cmd) {
10948
+ function deriveCommandParts(cmd) {
10472
10949
  const parts = [];
10473
10950
  let current = cmd;
10474
10951
  while (current) {
@@ -10481,14 +10958,13 @@ function deriveCommandPath(cmd) {
10481
10958
  if (parts.length > 1) {
10482
10959
  parts.shift();
10483
10960
  }
10484
- return commandTelemetryName(parts);
10961
+ return parts;
10485
10962
  }
10486
10963
  function isErrorContext(value) {
10487
10964
  return value !== null && typeof value === "object";
10488
10965
  }
10489
10966
  function commandHelpHint(commandPath) {
10490
- const command = commandPath.replace(/\./g, " ");
10491
- return `An unexpected error occurred. Run '${command} --help' to verify command syntax, or run with --log-level debug for details.`;
10967
+ return `An unexpected error occurred. Run '${commandPath} --help' to verify command syntax, or run with --log-level debug for details.`;
10492
10968
  }
10493
10969
  function isPromptCancellation(error) {
10494
10970
  return error instanceof Error && error.name === "ExitPromptError";
@@ -10513,7 +10989,9 @@ Command.prototype.trackedAction = function(context, fn, properties) {
10513
10989
  yaml: getOutputFormat() === "yaml",
10514
10990
  filter: getOutputFilter() !== undefined
10515
10991
  });
10516
- const telemetryName = deriveCommandPath(command);
10992
+ const commandParts = deriveCommandParts(command);
10993
+ const telemetryName = commandTelemetryName(commandParts);
10994
+ const commandPath = commandInvocationPath(commandParts);
10517
10995
  const props = typeof properties === "function" ? properties(...args) : properties;
10518
10996
  markCommandStart();
10519
10997
  const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
@@ -10548,7 +11026,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
10548
11026
  Result: finalResult,
10549
11027
  ...customErrorCode ? { ErrorCode: customErrorCode } : {},
10550
11028
  Message: errorMessage,
10551
- Instructions: customInstructions ?? commandHelpHint(telemetryName),
11029
+ Instructions: customInstructions ?? commandHelpHint(commandPath),
10552
11030
  ...customRetry ? { Retry: customRetry } : {},
10553
11031
  ...customContext ? { Context: customContext } : {}
10554
11032
  });
@@ -10565,8 +11043,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
10565
11043
  recordedFailure,
10566
11044
  pollSignal: context.pollSignal
10567
11045
  });
10568
- if (terminalTelemetry.error_class === "internal" && error) {
10569
- telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { command_name: telemetryName }, getInvocationRequestContext());
11046
+ if (terminalTelemetry[CommandDimensions.ErrorClass] === "internal" && error) {
11047
+ telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { [CommandDimensions.CommandName]: commandPath }, getInvocationRequestContext());
10570
11048
  }
10571
11049
  const commandParams = extractCommandParams(command);
10572
11050
  if (props) {
@@ -10577,10 +11055,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
10577
11055
  const baseProperties = redactProperties({
10578
11056
  ...commandParams,
10579
11057
  ...props,
10580
- ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
10581
- command: "true",
11058
+ ...buildCommandTelemetryAttribution(commandPath, process.env.UIPATH_SKILL),
11059
+ ...buildAgentSessionTelemetry(process.env),
11060
+ [CommandDimensions.CommandName]: commandPath,
11061
+ [CommandDimensions.IsCommand]: "true",
10582
11062
  ...terminalTelemetry,
10583
- ...errorMessage ? { errorMessage } : {}
11063
+ ...errorMessage ? { [CommandDimensions.ErrorMessage]: errorMessage } : {}
10584
11064
  });
10585
11065
  emitInvocationRequest(telemetryName, success, baseProperties);
10586
11066
  } finally {
@@ -10812,6 +11292,40 @@ var BOOLEAN_FLAGS = new Set(HOST_GLOBAL_FLAGS);
10812
11292
  // ../common/src/interactivity-context.ts
10813
11293
  var modeSlot = singleton("InteractivityMode");
10814
11294
  var interactiveFlagSlot = singleton("InteractiveFlag");
11295
+ // ../common/src/mime-types.ts
11296
+ var MIME_TYPES_BY_EXTENSION = Object.freeze({
11297
+ pdf: "application/pdf",
11298
+ png: "image/png",
11299
+ jpg: "image/jpeg",
11300
+ jpeg: "image/jpeg",
11301
+ gif: "image/gif",
11302
+ webp: "image/webp",
11303
+ bmp: "image/bmp",
11304
+ tif: "image/tiff",
11305
+ tiff: "image/tiff",
11306
+ svg: "image/svg+xml",
11307
+ txt: "text/plain",
11308
+ log: "text/plain",
11309
+ md: "text/markdown",
11310
+ csv: "text/csv",
11311
+ tsv: "text/tab-separated-values",
11312
+ json: "application/json",
11313
+ xml: "application/xml",
11314
+ html: "text/html",
11315
+ htm: "text/html",
11316
+ yaml: "application/yaml",
11317
+ yml: "application/yaml",
11318
+ doc: "application/msword",
11319
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
11320
+ xls: "application/vnd.ms-excel",
11321
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
11322
+ ppt: "application/vnd.ms-powerpoint",
11323
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
11324
+ zip: "application/zip",
11325
+ mp3: "audio/mpeg",
11326
+ wav: "audio/wav",
11327
+ mp4: "video/mp4"
11328
+ });
10815
11329
  // ../common/src/polling/types.ts
10816
11330
  var PollOutcome = {
10817
11331
  Completed: "completed",
@@ -10856,6 +11370,7 @@ var ScreenLogger;
10856
11370
  ScreenLogger.progress = progress;
10857
11371
  })(ScreenLogger ||= {});
10858
11372
  // ../common/src/sdk-user-agent.ts
11373
+ var AGENT_PROPERTY = BaseDimensions.Agent;
10859
11374
  var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
10860
11375
  // ../common/src/telemetry/ship-succeeded.ts
10861
11376
  var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
@@ -11235,6 +11750,11 @@ var pickName = (claims) => {
11235
11750
  const username = asString(claims?.preferred_username);
11236
11751
  return asString(claims?.name) ?? (looksLikeEmail(username) ? undefined : username);
11237
11752
  };
11753
+ var pickScopes = (claims) => {
11754
+ const raw = claims?.scope;
11755
+ const scopes = Array.isArray(raw) ? raw.filter((entry) => asString(entry) !== undefined) : typeof raw === "string" ? raw.split(/\s+/).filter(Boolean) : [];
11756
+ return scopes.length > 0 ? scopes : undefined;
11757
+ };
11238
11758
  var resolveSessionIdentity = (accessToken, authFlow) => {
11239
11759
  const claims = accessToken ? decodeClaims(accessToken) : undefined;
11240
11760
  const email = pickEmail(claims);
@@ -11260,6 +11780,7 @@ var resolveSessionIdentity = (accessToken, authFlow) => {
11260
11780
  identity.clientId = clientId;
11261
11781
  return identity;
11262
11782
  };
11783
+ var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
11263
11784
 
11264
11785
  // ../auth/src/envAuth.ts
11265
11786
  var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
@@ -11332,6 +11853,7 @@ var readAuthFromEnv = () => {
11332
11853
  const expiration = getTokenExpiration(accessToken);
11333
11854
  const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
11334
11855
  const identity = resolveSessionIdentity(accessToken);
11856
+ const scopes = readTokenScopes(accessToken);
11335
11857
  return {
11336
11858
  loginStatus,
11337
11859
  accessToken,
@@ -11342,7 +11864,8 @@ var readAuthFromEnv = () => {
11342
11864
  tenantId,
11343
11865
  expiration,
11344
11866
  source: "env-vars" /* EnvironmentVariables */,
11345
- ...identity ? { identity } : {}
11867
+ ...identity ? { identity } : {},
11868
+ ...scopes ? { scopes } : {}
11346
11869
  };
11347
11870
  };
11348
11871
 
@@ -11984,10 +12507,15 @@ async function buildFileStatus(tokens, credentials, globalHint) {
11984
12507
  }
11985
12508
  function identityFields(accessToken, credentials) {
11986
12509
  const identity = resolveSessionIdentity(accessToken, parseAuthFlow(credentials[AUTH_FLOW_ENV_VAR]));
11987
- return identity ? { identity } : {};
12510
+ const scopes = readTokenScopes(accessToken);
12511
+ return {
12512
+ ...identity ? { identity } : {},
12513
+ ...scopes ? { scopes } : {}
12514
+ };
11988
12515
  }
11989
12516
  function buildRobotStatus(robotCreds) {
11990
12517
  const identity = resolveSessionIdentity(robotCreds.accessToken);
12518
+ const scopes = readTokenScopes(robotCreds.accessToken);
11991
12519
  return {
11992
12520
  loginStatus: "Logged in",
11993
12521
  accessToken: robotCreds.accessToken,
@@ -11999,7 +12527,8 @@ function buildRobotStatus(robotCreds) {
11999
12527
  issuer: robotCreds.issuer,
12000
12528
  expiration: getTokenExpiration(robotCreds.accessToken),
12001
12529
  source: "robot" /* Robot */,
12002
- ...identity ? { identity } : {}
12530
+ ...identity ? { identity } : {},
12531
+ ...scopes ? { scopes } : {}
12003
12532
  };
12004
12533
  }
12005
12534
  var isFileNotFoundError = (error) => {
@@ -12289,6 +12818,30 @@ var TENANT_SELECTION_CODES = new Set([
12289
12818
  init_src();
12290
12819
  // src/execute.ts
12291
12820
  init_src();
12821
+
12822
+ // src/scaffold-type.ts
12823
+ import { execFile as execFile7 } from "node:child_process";
12824
+ var PROBE_TIMEOUT_MS = 15000;
12825
+ var TYPE_OPTION = /^--type(=|$)/;
12826
+ var TYPE_LISTED = /^[ \t]*--type(?![\w-])/m;
12827
+ function hasTypeOption(args) {
12828
+ return args.some((arg) => TYPE_OPTION.test(arg));
12829
+ }
12830
+ async function supportsNewTypeOption(exePath, cwd, env = {}, signal) {
12831
+ return new Promise((resolve2) => {
12832
+ execFile7(exePath, ["new", "--help"], {
12833
+ cwd,
12834
+ env: { ...process.env, ...env },
12835
+ timeout: PROBE_TIMEOUT_MS,
12836
+ windowsHide: true,
12837
+ signal
12838
+ }, (error, stdout) => {
12839
+ resolve2(!error && TYPE_LISTED.test(typeof stdout === "string" ? stdout : ""));
12840
+ });
12841
+ });
12842
+ }
12843
+
12844
+ // src/execute.ts
12292
12845
  var ENV_FILE_NAME = ".env";
12293
12846
  function isHelpCommand(args) {
12294
12847
  return args.includes("--help") || args.includes("-h");
@@ -12343,10 +12896,21 @@ var fail = (reason, message, instructions, extras = {}) => ({
12343
12896
  exitCode: extras.exitCode ?? 1,
12344
12897
  stderr: extras.stderr
12345
12898
  });
12899
+ function childStdio(stdio) {
12900
+ switch (stdio) {
12901
+ case "pipe":
12902
+ return ["ignore", "pipe", "pipe"];
12903
+ case "stdout-to-stderr":
12904
+ return ["inherit", "pipe", "inherit"];
12905
+ default:
12906
+ return "inherit";
12907
+ }
12908
+ }
12346
12909
  async function runUipathPythonCommand(args, options = {}) {
12347
12910
  const fs7 = getFileSystem();
12348
12911
  const cacheFile = fs7.path.join(fs7.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
12349
- const setupCommand = `uip ${options.commandPrefix ?? "codedagent"} setup`;
12912
+ const toolLabel = options.toolName ?? options.commandPrefix ?? "codedagent";
12913
+ const setupCommand = `uip ${toolLabel} setup`;
12350
12914
  const setupHint = `Run '${setupCommand}' first to configure the environment. ` + `Activate the project's virtual environment and run ${setupCommand} --force.`;
12351
12915
  const cache = await readCache(cacheFile);
12352
12916
  if (!cache?.uipathExePath) {
@@ -12359,6 +12923,9 @@ async function runUipathPythonCommand(args, options = {}) {
12359
12923
  if (!processed.allowed) {
12360
12924
  return fail("command_disabled", processed.errorMessage || "Command disabled.", "Use of --force flag is not recommended. Favor alternate command.", { exitCode: 3 });
12361
12925
  }
12926
+ if (options.pinNewType && processed.args[0] === "new" && !isHelpCommand(processed.args) && hasTypeOption(processed.args)) {
12927
+ return fail("new_type_not_allowed", "--type is not a valid option.", "Remove --type and re-run.");
12928
+ }
12362
12929
  const processedArgs = applyOutputFormatOption(processed.args, options.outputFormatOption, options.outputFormats);
12363
12930
  const commandArgs = options.commandPrefix ? [options.commandPrefix, ...processedArgs] : [...processedArgs];
12364
12931
  const requiredEnv = {};
@@ -12393,6 +12960,9 @@ async function runUipathPythonCommand(args, options = {}) {
12393
12960
  }
12394
12961
  const stdio = options.stdio ?? "inherit";
12395
12962
  const cwd = options.cwd ?? fs7.env.cwd();
12963
+ if (options.pinNewType && processed.args[0] === "new" && !isHelpCommand(processed.args) && await supportsNewTypeOption(cache.uipathExePath, cwd, { ...authEnv, ...requiredEnv }, options.signal)) {
12964
+ commandArgs.push("--type", options.pinNewType);
12965
+ }
12396
12966
  const proc = spawn(cache.uipathExePath, commandArgs, {
12397
12967
  cwd,
12398
12968
  env: {
@@ -12400,17 +12970,24 @@ async function runUipathPythonCommand(args, options = {}) {
12400
12970
  ...authEnv,
12401
12971
  ...requiredEnv
12402
12972
  },
12403
- stdio: stdio === "pipe" ? ["ignore", "pipe", "pipe"] : "inherit",
12973
+ stdio: childStdio(stdio),
12404
12974
  signal: options.signal
12405
12975
  });
12406
12976
  let stdout = "";
12407
12977
  let stderr = "";
12408
12978
  if (stdio === "pipe") {
12979
+ proc.stdout?.setEncoding("utf8");
12980
+ proc.stderr?.setEncoding("utf8");
12409
12981
  proc.stdout?.on("data", (chunk) => {
12410
- stdout += chunk.toString("utf8");
12982
+ stdout += chunk;
12411
12983
  });
12412
12984
  proc.stderr?.on("data", (chunk) => {
12413
- stderr += chunk.toString("utf8");
12985
+ stderr += chunk;
12986
+ });
12987
+ } else if (stdio === "stdout-to-stderr") {
12988
+ proc.stdout?.setEncoding("utf8");
12989
+ proc.stdout?.on("data", (chunk) => {
12990
+ getOutputSink().writeErr(chunk);
12414
12991
  });
12415
12992
  }
12416
12993
  const [spawnError, exitCode] = await catchError(new Promise((resolve2, reject) => {
@@ -12440,17 +13017,30 @@ var CLI_RESULT_BY_REASON = {
12440
13017
  python_not_configured: RESULTS.ConfigError,
12441
13018
  uipath_exe_missing: RESULTS.ConfigError,
12442
13019
  command_disabled: RESULTS.ValidationError,
13020
+ new_type_not_allowed: RESULTS.ValidationError,
12443
13021
  required_env_missing: RESULTS.ConfigError,
12444
13022
  preflight_error: RESULTS.Failure,
12445
13023
  preflight_rejected: RESULTS.ConfigError,
12446
13024
  spawn_failed: RESULTS.Failure
12447
13025
  };
13026
+ function reportUipathPythonFailure(result) {
13027
+ if (!result.ok && result.reason !== "command_failed") {
13028
+ OutputFormatter.error({
13029
+ Result: CLI_RESULT_BY_REASON[result.reason],
13030
+ Message: result.message,
13031
+ Instructions: result.instructions
13032
+ });
13033
+ }
13034
+ return result.exitCode;
13035
+ }
12448
13036
  function createExecuteCommand(config) {
12449
13037
  const executeCommand = async (rawArgs, _options) => {
12450
13038
  const runIndex = rawArgs.indexOf("exec");
12451
13039
  const actualArgs = runIndex >= 0 ? rawArgs.slice(runIndex + 1) : [];
12452
13040
  const result = await runUipathPythonCommand(actualArgs, {
12453
13041
  commandPrefix: config.commandPrefix,
13042
+ toolName: config.toolName,
13043
+ pinNewType: config.pinNewType,
12454
13044
  commandRules: config.commandRules,
12455
13045
  commandPreflight: config.commandPreflight,
12456
13046
  requiredEnvironmentVariables: config.requiredEnvironmentVariables,
@@ -12458,18 +13048,11 @@ function createExecuteCommand(config) {
12458
13048
  outputFormats: config.outputFormats,
12459
13049
  stdio: "inherit"
12460
13050
  });
12461
- if (!result.ok && result.reason !== "command_failed") {
12462
- OutputFormatter.error({
12463
- Result: CLI_RESULT_BY_REASON[result.reason],
12464
- Message: result.message,
12465
- Instructions: result.instructions
12466
- });
12467
- }
12468
- processContext.exit(result.exitCode);
13051
+ processContext.exit(reportUipathPythonFailure(result));
12469
13052
  return result;
12470
13053
  };
12471
13054
  const registerExecCommand = (program2) => {
12472
- program2.command("exec", { hidden: true }).description("Execute the uipath package with provided arguments").allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, config.telemetryEvent, async (_options, cmd) => {
13055
+ program2.command("exec", { hidden: true }).description("Execute the uipath package with provided arguments").allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, async (_options, cmd) => {
12473
13056
  await executeCommand(["_", "_", "exec", ...cmd.args], {});
12474
13057
  });
12475
13058
  };
@@ -12498,6 +13081,10 @@ class PythonService {
12498
13081
  }
12499
13082
  async _setupInternal(packageName, force) {
12500
13083
  const virtualEnv = process.env.VIRTUAL_ENV || undefined;
13084
+ const dormantVenv = await this.checkDormantVenv();
13085
+ if (dormantVenv) {
13086
+ return dormantVenv;
13087
+ }
12501
13088
  if (!force) {
12502
13089
  const reused = await this.reuseCache(packageName, virtualEnv);
12503
13090
  if (reused)
@@ -12524,7 +13111,7 @@ class PythonService {
12524
13111
  packageInstalled: false,
12525
13112
  source,
12526
13113
  error: `Package '${packageName}' is not installed in the active virtual environment: ${virtualEnv}`,
12527
- instructions: `Install it inside the active virtual environment (uv pip install ${packageName} or the framework package), then re-run uip codedagent setup --force.`
13114
+ 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.`
12528
13115
  };
12529
13116
  }
12530
13117
  return {
@@ -12658,6 +13245,20 @@ To install the package, run:
12658
13245
  source: "venv"
12659
13246
  };
12660
13247
  }
13248
+ async checkDormantVenv() {
13249
+ if (process.env.VIRTUAL_ENV) {
13250
+ return null;
13251
+ }
13252
+ const fs7 = getFileSystem();
13253
+ if (!await fs7.exists(fs7.path.join(fs7.env.cwd(), ".venv"))) {
13254
+ return null;
13255
+ }
13256
+ return {
13257
+ success: false,
13258
+ error: "Found .venv in current directory but no virtual environment is activated.",
13259
+ instructions: process.platform === "win32" ? "Run '.venv\\Scripts\\activate' first, then re-run setup." : "Run 'source .venv/bin/activate' first, then re-run setup."
13260
+ };
13261
+ }
12661
13262
  async detectPython() {
12662
13263
  const pythonCommands = this.getDefaultPythonPaths();
12663
13264
  const checkedVersions = [];
@@ -12968,7 +13569,6 @@ function isPathInside(target, root) {
12968
13569
  return normalizedTarget === normalizedRoot || normalizedTarget.startsWith(`${normalizedRoot}/`);
12969
13570
  }
12970
13571
  // src/register.ts
12971
- init_src();
12972
13572
  function createSetupCommand(config) {
12973
13573
  return (program2) => {
12974
13574
  program2.command("setup").description("Detect Python installation and verify package is installed").option("--force", "Force re-detection of Python even if cached", false).trackedAction(processContext, async (options) => {
@@ -12983,22 +13583,12 @@ function createSetupCommand(config) {
12983
13583
  processContext.exit(1);
12984
13584
  return;
12985
13585
  }
12986
- const fs7 = getFileSystem();
12987
- const venvPath = fs7.path.join(fs7.env.cwd(), ".venv");
12988
- if (await fs7.exists(venvPath) && !process.env.VIRTUAL_ENV) {
12989
- OutputFormatter.error({
12990
- Result: RESULTS.Failure,
12991
- Message: "Found .venv in current directory but no virtual environment is activated.",
12992
- Instructions: process.platform === "win32" ? "Run '.venv\\Scripts\\activate' first, then re-run setup." : "Run 'source .venv/bin/activate' first, then re-run setup."
12993
- });
12994
- processContext.exit(1);
12995
- return;
12996
- }
12997
13586
  logger.info(`
12998
13587
  Searching for Python installations: ${allowedVersions}`);
12999
13588
  const service = new PythonService({
13000
13589
  allowedVersions,
13001
- packageName
13590
+ packageName,
13591
+ toolName: config.toolName
13002
13592
  });
13003
13593
  const result = await service.setup(packageName, options.force);
13004
13594
  if (!result.success) {
@@ -13026,7 +13616,7 @@ Searching for Python installations: ${allowedVersions}`);
13026
13616
  });
13027
13617
  };
13028
13618
  }
13029
- function createDefaultAction(_config, executeCommand) {
13619
+ function createDefaultAction(executeCommand) {
13030
13620
  return (program2) => {
13031
13621
  program2.trackedAction(processContext, async () => {
13032
13622
  const userArgs = program2.args.length > 0 ? normalizeDefaultActionArgs(program2.args) : [];
@@ -13038,7 +13628,7 @@ function createDefaultAction(_config, executeCommand) {
13038
13628
  function normalizeDefaultActionArgs(args) {
13039
13629
  return args.length === 1 && args[0] === "-h" ? ["--help"] : args;
13040
13630
  }
13041
- function createHelpCommand(_config, executeCommand) {
13631
+ function createHelpCommand(executeCommand) {
13042
13632
  return (program2) => {
13043
13633
  program2.command("help").description("Display help for the python tool").trackedAction(processContext, async () => {
13044
13634
  await executeCommand(["_", "_", "exec", "--help"], {});
@@ -13065,10 +13655,13 @@ export {
13065
13655
  getAllowedPythonVersions,
13066
13656
  getCacheFileName,
13067
13657
  getPackageName,
13658
+ hasTypeOption,
13068
13659
  isPathInside,
13069
13660
  processCommandArgs,
13070
13661
  readCache,
13071
- runUipathPythonCommand
13662
+ reportUipathPythonFailure,
13663
+ runUipathPythonCommand,
13664
+ supportsNewTypeOption
13072
13665
  };
13073
13666
 
13074
- //# debugId=219233FAB6B0AA4C64756E2164756E21
13667
+ //# debugId=73B0CD0B17BC53CF64756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/uipath-python-bridge",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.203.0-preview.203",
5
+ "version": "1.204.0-preview.206",
6
6
  "description": "Shared Python detection, caching, and CLI bridge for UiPath Python SDK tools.",
7
7
  "keywords": [
8
8
  "uip",
@@ -25,5 +25,5 @@
25
25
  "publishConfig": {
26
26
  "registry": "https://registry.npmjs.org/"
27
27
  },
28
- "gitHead": "a10661bf5ec19ddd6c628ed7bb1db55f721a6027"
28
+ "gitHead": "ea7fd32a02acccf14e8e83522e69101430627b83"
29
29
  }